diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..d3259a26 --- /dev/null +++ b/.clang-format @@ -0,0 +1,320 @@ +--- +Language: Cpp +AlignAfterOpenBracket: true +AccessModifierOffset: -2 +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + AlignPPAndNotPP: true + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowBreakBeforeQtProperty: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AttributeMacros: + - __capability +BinPackArguments: true +BinPackLongBracedList: true +BinPackParameters: BinPack +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterOpenBracketBracedList: false +BreakAfterOpenBracketFunction: false +BreakAfterOpenBracketIf: false +BreakAfterOpenBracketLoop: false +BreakAfterOpenBracketSwitch: false +BreakAfterReturnType: None +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeCloseBracketBracedList: false +BreakBeforeCloseBracketFunction: false +BreakBeforeCloseBracketIf: false +BreakBeforeCloseBracketLoop: false +BreakBeforeCloseBracketSwitch: false +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTemplateCloser: false +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +BreakTemplateDeclarations: MultiLine +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: AlignFirstComment +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigitsInsert: 0 + BinaryMaxDigitsRemove: 0 + Decimal: 0 + DecimalMinDigitsInsert: 0 + DecimalMaxDigitsRemove: 0 + Hex: 0 + HexMinDigitsInsert: 0 + HexMaxDigitsRemove: 0 + BinaryMinDigits: 0 + DecimalMinDigits: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +NumericLiteralCase: + ExponentLetter: Leave + HexDigit: Leave + Prefix: Leave + Suffix: Leave +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: '' +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: + Enabled: false + IgnoreCase: false + IgnoreExtension: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterNot: false + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBraces: Never +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +WrapNamespaceBodyWithEmptyLines: Leave +... diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 695a8afc..9afca6fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,11 @@ jobs: build: name: Build for ${{ matrix.os }} ${{ matrix.arch }} runs-on: ${{ matrix.runs-on }} + env: + # hk is only needed for local git hooks and is not distributed for every CI host. + # Keep it out of workflow tool installation, including macOS x86_64. + MISE_DISABLE_TOOLS: hk + MISE_NO_HOOKS: "1" strategy: fail-fast: false matrix: diff --git a/PROJECTS/ROLLER/3d.c b/PROJECTS/ROLLER/3d.c index 921c4070..df21373f 100644 --- a/PROJECTS/ROLLER/3d.c +++ b/PROJECTS/ROLLER/3d.c @@ -33,248 +33,248 @@ #include #endif //------------------------------------------------------------------------------------------------- -//symbols defined by ROLLER -char szIngameEng[11] = "ingame.eng"; //000A01FC -char szConfigEng_0[11] = "config.eng"; //000A0208 -char szCheatPal[13] = "cheatpal.pal"; //000A0244 -char szPal[12] = "palette.pal"; //000A0254 -char szF10ToQuitChamp[25] = "F10 TO QUIT CHAMPIONSHIP"; //000A029C -char szF10ToQuitGame[17] = "F10 TO QUIT GAME"; //000A02B8 +// symbols defined by ROLLER +char szIngameEng[11] = "ingame.eng"; // 000A01FC +char szConfigEng_0[11] = "config.eng"; // 000A0208 +char szCheatPal[13] = "cheatpal.pal"; // 000A0244 +char szPal[12] = "palette.pal"; // 000A0254 +char szF10ToQuitChamp[25] = "F10 TO QUIT CHAMPIONSHIP"; // 000A029C +char szF10ToQuitGame[17] = "F10 TO QUIT GAME"; // 000A02B8 //------------------------------------------------------------------------------------------------- -int champ_track[16] = { 1, 2, 3, 9, 5, 1, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1 }; //000A3130 -int exiting = 0; //000A3170 -int dontrestart = 0; //000A3174 -int champ_mode = 0; //000A3178 -int cd_error = 0; //000A317C -int game_count[2] = { -2, -2 }; //000A3180 -int lastblip[2] = { 0, 0 }; //000A3188 -float game_scale[2] = { 32768.0f, 32768.0f }; //000A3190 -int define_mode = 0; //000A3198 -int calibrate_mode = 0; //000A319C -int graphic_mode = 0; //000A31A0 -int calibrate_select = 0; //000A31A4 -int sound_edit = 0; //000A31A8 -int showversion = 0; //000A31AC -int game_svga = 1; //000A31B0 ROLLER modification - SVGA mode by default -int game_size = 64; //000A31B4 -int game_view[2] = { 0, 0 }; //000A31B8 -int svga_possible = -1; //000A31C0 -int autoswitch = -1; //000A31C4 -int hibuffers = 0; //000A32E0 -int lobuffers = 0; //000A32E4 -int mem_used = 0; //000A32E8 -int mem_used_low = 0; //000A32EC -int gosound = 3; //000A3334 -int current_mode = 666; //000A333C -int names_on = 1; //000A3340 -tCarEngine *p_eng[2] = { NULL, NULL }; //000A3498 -int messages = 0; //000A34A8 -int SVGA_ON = 0; //000A34AC -int TrackLoad = 1; //000A34B0 -int paused = 0; //000A34C4 -int pause_request = 0; //000A34C8 -char alltrackflag = 0xFF; //000A34E1 -int dxmouse = 0; //000A34E8 -int dymouse = 0; //000A34EC -int mousex = 159; //000A34F0 -int mousey = 115; //000A34F4 -int mbut = 0; //000A34F8 -int oldbut = 0; //000A34FC -int mclick = 0; //000A3500 -int mouse = 0; //000A3504 -int wide_on = -1; //000A350C -int network_on = 0; //000A3510 -char Banks_On = -1; //000A3514 -char Buildings_On = 0; //000A3515 -char Road_On = -1; //000A3516 -char Walls_On = -1; //000A3517 -char Play_View = 0; //000A3518 -int DriveView[2] = { 0, 0 }; //000A351C -int mirror = 0; //000A3524 -float TopViewHeight = 12288.0f; //000A3528 -int mpressed = 0; //000A352C -int jpressed = 0; //000A352D -int start_time = 0; //000A3534 -uint8 *screen = NULL; //= 0xA0000; //000A3538 -uint8 *scrbuf = NULL; //000A353C +int champ_track[16] = {1, 2, 3, 9, 5, 1, 7, 8, + 1, 1, 1, 1, 1, 1, 1, 1}; // 000A3130 +int exiting = 0; // 000A3170 +int dontrestart = 0; // 000A3174 +int champ_mode = 0; // 000A3178 +int cd_error = 0; // 000A317C +int game_count[2] = {-2, -2}; // 000A3180 +int lastblip[2] = {0, 0}; // 000A3188 +float game_scale[2] = {32768.0f, 32768.0f}; // 000A3190 +int define_mode = 0; // 000A3198 +int calibrate_mode = 0; // 000A319C +int graphic_mode = 0; // 000A31A0 +int calibrate_select = 0; // 000A31A4 +int sound_edit = 0; // 000A31A8 +int showversion = 0; // 000A31AC +int game_svga = 1; // 000A31B0 ROLLER modification - SVGA mode by default +int game_size = 64; // 000A31B4 +int game_view[2] = {0, 0}; // 000A31B8 +int svga_possible = -1; // 000A31C0 +int autoswitch = -1; // 000A31C4 +int hibuffers = 0; // 000A32E0 +int lobuffers = 0; // 000A32E4 +int mem_used = 0; // 000A32E8 +int mem_used_low = 0; // 000A32EC +int gosound = 3; // 000A3334 +int current_mode = 666; // 000A333C +int names_on = 1; // 000A3340 +tCarEngine *p_eng[2] = {NULL, NULL}; // 000A3498 +int messages = 0; // 000A34A8 +int SVGA_ON = 0; // 000A34AC +int TrackLoad = 1; // 000A34B0 +int paused = 0; // 000A34C4 +int pause_request = 0; // 000A34C8 +char alltrackflag = 0xFF; // 000A34E1 +int dxmouse = 0; // 000A34E8 +int dymouse = 0; // 000A34EC +int mousex = 159; // 000A34F0 +int mousey = 115; // 000A34F4 +int mbut = 0; // 000A34F8 +int oldbut = 0; // 000A34FC +int mclick = 0; // 000A3500 +int mouse = 0; // 000A3504 +int wide_on = -1; // 000A350C +int network_on = 0; // 000A3510 +char Banks_On = -1; // 000A3514 +char Buildings_On = 0; // 000A3515 +char Road_On = -1; // 000A3516 +char Walls_On = -1; // 000A3517 +char Play_View = 0; // 000A3518 +int DriveView[2] = {0, 0}; // 000A351C +int mirror = 0; // 000A3524 +float TopViewHeight = 12288.0f; // 000A3528 +int mpressed = 0; // 000A352C +int jpressed = 0; // 000A352D +int start_time = 0; // 000A3534 +uint8 *screen = NULL; //= 0xA0000; //000A3538 +uint8 *scrbuf = NULL; // 000A353C GameRenderer *g_pGameRenderer = NULL; -uint8 *mirbuf = NULL; //000A3540 -uint8 *texture_vga = NULL; //000A3544 -uint8 *building_vga = NULL; //000A3548 -uint8 *horizon_vga = NULL; //000A354C -uint8 *cartex_vga[16] = { NULL }; //000A3550 -uint8 *cargen_vga = NULL; //000A3590 -tBlockHeader *rev_vga[16] = { NULL }; //000A3594 -int firstrun = -1; //000A35D4 -int lagdone = 0; //000A35D8 -int language = 0; //000A4768 -int GroundColour[MAX_TRACK_CHUNKS][5];//000B8C50 -int TrakColour[MAX_TRACK_CHUNKS][6];//000BB360 -int HorizonColour[MAX_TRACK_CHUNKS]; //000BE240 -tData localdata[MAX_TRACK_CHUNKS]; //000BEA10 -tGroundPt GroundPt[MAX_TRACK_CHUNKS]; //000CE410 -float hor_scan[800]; //000D70B0 -tGroundPt TrakPt[MAX_TRACK_CHUNKS]; //000D7D30 -tTrackScreenXYZ GroundScreenXYZ[MAX_TRACK_CHUNKS]; //000E09D0 -tTrackScreenXYZ TrackScreenXYZ[MAX_TRACK_CHUNKS]; //000F03D0 -uint8 shade_palette[4096]; //000FFDD0 -tColor palette[256]; //00100DD0 -float tsin[16384]; //001010F0 -float ptan[16384]; //001110F0 -float tcos[16384]; //00121128 -char buffer[128]; //00131228 -uint8 blank_line[640]; //001312A8 -int p_joyk1[2]; //0013E048 -int p_joyk2[2]; //0013E050 -tMemBlock mem_blocks[MEM_BLOCK_COUNT]; //0013E058 -int zoom_size[2]; //0013E858 -char zoom_mes[2][24]; //0013E860 -int sub_on[2]; //0013E890 -char zoom_sub[2][24]; //0013E898 -int champ_go[16]; //0013E8C8 -int game_overs; //0013E908 -int averagesectionlen; //0013E90C -int racing; //0013E910 -int totaltrackdistance; //0013E914 -int disable_messages; //0013E918 -int curr_time; //0013E924 -volatile int ticks; //0013E92C -int frame_rate; //0013E930 -int frame_count; //0013E934 -float k1; //0013E938 -float k2; //0013E93C -float k3; //0013E940 -float k4; //0013E944 -float k5; //0013E948 -float k6; //0013E94C -float k7; //0013E950 -float k8; //0013E954 -float k9; //0013E958 -float tatn[1025]; //0013E95C -uint32 textures_off; //0013F960 -int tex_count; //0013F964 -int vtilt; //0013F968 -int worldtilt; //0013F96C -float worldx; //0013F970 -float worldy; //0013F974 -float worldz; //0013F978 -int worldelev; //0013F97C -int velevation; //0013F980 -int vdirection; //0013F984 -int scr_size; //0013F988 -int ybase; //0013F98C -int xbase; //0013F990 -int winx; //0013F994 -int winy; //0013F998 -float ext_y; //0013F99C -float ext_z; //0013F9A0 -float viewx; //0013F9A4 -float viewy; //0013F9A8 -float viewz; //0013F9AC +uint8 *mirbuf = NULL; // 000A3540 +uint8 *texture_vga = NULL; // 000A3544 +uint8 *building_vga = NULL; // 000A3548 +uint8 *horizon_vga = NULL; // 000A354C +uint8 *cartex_vga[16] = {NULL}; // 000A3550 +uint8 *cargen_vga = NULL; // 000A3590 +tBlockHeader *rev_vga[16] = {NULL}; // 000A3594 +int firstrun = -1; // 000A35D4 +int lagdone = 0; // 000A35D8 +int language = 0; // 000A4768 +int GroundColour[MAX_TRACK_CHUNKS][5]; // 000B8C50 +int TrakColour[MAX_TRACK_CHUNKS][6]; // 000BB360 +int HorizonColour[MAX_TRACK_CHUNKS]; // 000BE240 +tData localdata[MAX_TRACK_CHUNKS]; // 000BEA10 +tGroundPt GroundPt[MAX_TRACK_CHUNKS]; // 000CE410 +float hor_scan[800]; // 000D70B0 +tGroundPt TrakPt[MAX_TRACK_CHUNKS]; // 000D7D30 +tTrackScreenXYZ GroundScreenXYZ[MAX_TRACK_CHUNKS]; // 000E09D0 +tTrackScreenXYZ TrackScreenXYZ[MAX_TRACK_CHUNKS]; // 000F03D0 +uint8 shade_palette[4096]; // 000FFDD0 +tColor palette[256]; // 00100DD0 +float tsin[16384]; // 001010F0 +float ptan[16384]; // 001110F0 +float tcos[16384]; // 00121128 +char buffer[128]; // 00131228 +uint8 blank_line[640]; // 001312A8 +int p_joyk1[2]; // 0013E048 +int p_joyk2[2]; // 0013E050 +tMemBlock mem_blocks[MEM_BLOCK_COUNT]; // 0013E058 +int zoom_size[2]; // 0013E858 +char zoom_mes[2][24]; // 0013E860 +int sub_on[2]; // 0013E890 +char zoom_sub[2][24]; // 0013E898 +int champ_go[16]; // 0013E8C8 +int game_overs; // 0013E908 +int averagesectionlen; // 0013E90C +int racing; // 0013E910 +int totaltrackdistance; // 0013E914 +int disable_messages; // 0013E918 +int curr_time; // 0013E924 +volatile int ticks; // 0013E92C +int frame_rate; // 0013E930 +int frame_count; // 0013E934 +float k1; // 0013E938 +float k2; // 0013E93C +float k3; // 0013E940 +float k4; // 0013E944 +float k5; // 0013E948 +float k6; // 0013E94C +float k7; // 0013E950 +float k8; // 0013E954 +float k9; // 0013E958 +float tatn[1025]; // 0013E95C +uint32 textures_off; // 0013F960 +int tex_count; // 0013F964 +int vtilt; // 0013F968 +int worldtilt; // 0013F96C +float worldx; // 0013F970 +float worldy; // 0013F974 +float worldz; // 0013F978 +int worldelev; // 0013F97C +int velevation; // 0013F980 +int vdirection; // 0013F984 +int scr_size; // 0013F988 +int ybase; // 0013F98C +int xbase; // 0013F990 +int winx; // 0013F994 +int winy; // 0013F998 +float ext_y; // 0013F99C +float ext_z; // 0013F9A0 +float viewx; // 0013F9A4 +float viewy; // 0013F9A8 +float viewz; // 0013F9AC float fcos; float fsin; -int worlddirn; //0013F9B0 -char keys[140]; //0013F9B4 -int oldmode; //0013FA40 -int clear_borders; //0013FA44 -float DDX; //0013FA48 -float DDY; //0013FA4C -float DDZ; //0013FA50 -float ext_x; //0013FA54 -int test_f1; //0013FA58 -int test_f2; //0013FA5C -int test_f3; //0013FA60 -int print_data; //0013FA68 -int demo_control; //0013FA6C -int tick_on; //0013FA70 -int old_mode; //0013FA74 -int demo_mode; //0013FA78 -int demo_count; //0013FA7C -int start_race; //0013FA80 -int NoOfLaps; //0013FA84 -int human_finishers; //0013FA88 -int finishers; //0013FA8C -int countdown; //0013FA90 -int screenready; //0013FA94 -int shown_panel; //0013FA98 -int start_cd; //0013FA9C -int game_level; //0013FAA0 -int max_mem; //0013FAA4 -int game_req; //0013FAA8 -int game_dam; //0013FAAC -int pausewindow; //0013FAB0 -int scrmode; //0013FAB4 -int control_select; //0013FAB8 -int req_size; //0013FABC -int intro; //0013FAC0 -int shifting; //0013FAC4 -int fadedin; //0013FAC8 -int control_edit; //0013FACC -int req_edit; //0013FAD0 -int controlrelease; //0013FAD4 -float subscale; //0013FAD8 -int fatal_ini_loaded; //0013FADC -int machine_speed; //0013FAE0 -int netCD; //0013FAE4 -int localCD; //0013FAE8 -int dead_humans; //0013FAEC -int I_Want_Out; //0013FAF0 -int champ_car; //0013FAF4 -int champ_zoom; //0013FAF8 -int replay_player; //0013FAFC -int team_mate; //0013FB00 -int winner_done; //0013FB04 -int winner_mode; //0013FB08 -int network_mes_mode; //0013FB0C -int cdchecked; //0013FB10 -int network_slot; //0013FB14 -int trying_to_exit; //0013FB18 -int local_players; //0013FB1C -int draw_type; //0013FB20 -int network_buggered; //0013FB24 -int champ_count; //0013FB28 -int replay_cheat; //0013FB2C -int w95; //0013FB30 -int gave_up; //0013FB34 -int champ_size; //0013FB38 -int send_finished; //0013FB40 -int game_frame; //0013FB44 -int warp_angle; //0013FB4C -int game_track; //0013FB50 -int prev_track; //0013FB54 -int view0_cnt; //0013FB58 -int view1_cnt; //0013FB5C -int I_Would_Like_To_Quit; //0013FB60 -int Quit_Count; //0013FB64 -int winh; //0013FB68 -int winw; //0013FB6C -int VIEWDIST; //0013FB70 -int YMAX; //0013FB74 -int XMAX; //0013FB78 -int time_shown; //0013FB7C -int player2_car; //0013FB7E -int player1_car; //0013FB80 +int worlddirn; // 0013F9B0 +char keys[140]; // 0013F9B4 +int oldmode; // 0013FA40 +int clear_borders; // 0013FA44 +float DDX; // 0013FA48 +float DDY; // 0013FA4C +float DDZ; // 0013FA50 +float ext_x; // 0013FA54 +int test_f1; // 0013FA58 +int test_f2; // 0013FA5C +int test_f3; // 0013FA60 +int print_data; // 0013FA68 +int demo_control; // 0013FA6C +int tick_on; // 0013FA70 +int old_mode; // 0013FA74 +int demo_mode; // 0013FA78 +int demo_count; // 0013FA7C +int start_race; // 0013FA80 +int NoOfLaps; // 0013FA84 +int human_finishers; // 0013FA88 +int finishers; // 0013FA8C +int countdown; // 0013FA90 +int screenready; // 0013FA94 +int shown_panel; // 0013FA98 +int start_cd; // 0013FA9C +int game_level; // 0013FAA0 +int max_mem; // 0013FAA4 +int game_req; // 0013FAA8 +int game_dam; // 0013FAAC +int pausewindow; // 0013FAB0 +int scrmode; // 0013FAB4 +int control_select; // 0013FAB8 +int req_size; // 0013FABC +int intro; // 0013FAC0 +int shifting; // 0013FAC4 +int fadedin; // 0013FAC8 +int control_edit; // 0013FACC +int req_edit; // 0013FAD0 +int controlrelease; // 0013FAD4 +float subscale; // 0013FAD8 +int fatal_ini_loaded; // 0013FADC +int machine_speed; // 0013FAE0 +int netCD; // 0013FAE4 +int localCD; // 0013FAE8 +int dead_humans; // 0013FAEC +int I_Want_Out; // 0013FAF0 +int champ_car; // 0013FAF4 +int champ_zoom; // 0013FAF8 +int replay_player; // 0013FAFC +int team_mate; // 0013FB00 +int winner_done; // 0013FB04 +int winner_mode; // 0013FB08 +int network_mes_mode; // 0013FB0C +int cdchecked; // 0013FB10 +int network_slot; // 0013FB14 +int trying_to_exit; // 0013FB18 +int local_players; // 0013FB1C +int draw_type; // 0013FB20 +int network_buggered; // 0013FB24 +int champ_count; // 0013FB28 +int replay_cheat; // 0013FB2C +int w95; // 0013FB30 +int gave_up; // 0013FB34 +int champ_size; // 0013FB38 +int send_finished; // 0013FB40 +int game_frame; // 0013FB44 +int warp_angle; // 0013FB4C +int game_track; // 0013FB50 +int prev_track; // 0013FB54 +int view0_cnt; // 0013FB58 +int view1_cnt; // 0013FB5C +int I_Would_Like_To_Quit; // 0013FB60 +int Quit_Count; // 0013FB64 +int winh; // 0013FB68 +int winw; // 0013FB6C +int VIEWDIST; // 0013FB70 +int YMAX; // 0013FB74 +int XMAX; // 0013FB78 +int time_shown; // 0013FB7C +int player2_car; // 0013FB7E +int player1_car; // 0013FB80 //------------------------------------------------------------------------------------------------- -//00010020 -void copypic(uint8 *pSrc, uint8 *pDest) -{ - //added by ROLLER - // During gameplay, game_render_end_frame handles presentation +// 00010020 +void copypic(uint8 *pSrc, uint8 *pDest) { + // added by ROLLER + // During gameplay, game_render_end_frame handles presentation if (!g_pGameRenderer) UpdateSDLWindow(); return; - int iRowIdx; // edx - uint8 *pSrcRow; // esi - uint8 *pDestRow; // edi - uint8 *pSrcPixel; // ecx + int iRowIdx; // edx + uint8 *pSrcRow; // esi + uint8 *pDestRow; // edi + uint8 *pSrcPixel; // ecx uint8 *pDestPixel; // eax - int i; // esi - int iPixelIdx; // edx - int iWindowWidth; // edi + int i; // esi + int iPixelIdx; // edx + int iWindowWidth; // edi uint8 byCurrPixel; // bl if (SVGA_ON) { @@ -322,12 +322,11 @@ void copypic(uint8 *pSrc, uint8 *pDest) } //------------------------------------------------------------------------------------------------- -//000101D0 -void init_screen() -{ - int iVesaMode; // ebx - int i; // esi - int16 nY; // bx +// 000101D0 +void init_screen() { + int iVesaMode; // ebx + int i; // esi + int16 nY; // bx int vesaModes[9]; // [esp+0h] [ebp-24h] BYREF vesaModes[0] = 0x100; @@ -348,9 +347,12 @@ void init_screen() if (iVesaMode == -1) { if (firstrun) { if (!language) { - SDL_Log("\n\nThis program has not detected a VESA video driver which it needs to run\n"); - SDL_Log("at it's optimum level. Please contact your video board manufacturer for\n"); - SDL_Log("more information. The program will now continue using lower resolution\n"); + SDL_Log("\n\nThis program has not detected a VESA video driver which " + "it needs to run\n"); + SDL_Log("at it's optimum level. Please contact your video board " + "manufacturer for\n"); + SDL_Log("more information. The program will now continue using lower " + "resolution\n"); SDL_Log("graphics.\n"); SDL_Log("Press any key to continue..."); fflush(stdout); @@ -388,7 +390,7 @@ void init_screen() XMAX = 320; YMAX = 200; scr_size = 64; - + // BIOS interrupt for video services // ah = 0 // al = 13h @@ -403,15 +405,14 @@ void init_screen() winh = YMAX; winy = 0; - //removed by ROLLER, causes no palette after toggling SVGA/VGA mode in-game - //if (palette_brightness > 0) - // resetpal(); + // removed by ROLLER, causes no palette after toggling SVGA/VGA mode in-game + // if (palette_brightness > 0) + // resetpal(); } //------------------------------------------------------------------------------------------------- -//00010430 -void init() -{ +// 00010430 +void init() { test_f1 = 0; test_f2 = 0; switch_sets = 0; @@ -447,7 +448,7 @@ void init() VIEWDIST = 270; DDX = 0.0; - //load tsin, tcos, and ptan + // load tsin, tcos, and ptan for (int i = 0; i < 16384; ++i) { double dAngle = i * TWO_PI * ONE_OVER_TRIG_LOOKUP_AY_COUNT; tsin[i] = (float)sin(dAngle); @@ -459,7 +460,7 @@ void init() ext_y = 0; ext_z = 0; - //load tatn + // load tatn for (int i = 0; i < 1025; ++i) { double dAngle = i * TWO_PI * ONE_OVER_TATN_LOOKUP_AY_COUNT; tatn[i] = (float)atan(dAngle); @@ -471,8 +472,7 @@ void init() //------------------------------------------------------------------------------------------------- -static int find_free_mem_block(void) -{ +static int find_free_mem_block(void) { for (int i = 0; i < MEM_BLOCK_COUNT; ++i) { if (!mem_blocks[i].pBuf) return i; @@ -483,8 +483,7 @@ static int find_free_mem_block(void) //------------------------------------------------------------------------------------------------- -static int find_mem_block(void *pData) -{ +static int find_mem_block(void *pData) { for (int i = 0; i < MEM_BLOCK_COUNT; ++i) { if (mem_blocks[i].pBuf == pData) return i; @@ -495,8 +494,7 @@ static int find_mem_block(void *pData) //------------------------------------------------------------------------------------------------- -static void LogMemBlocks(const char *pszReason, uint32 uiRequestedSize) -{ +static void LogMemBlocks(const char *pszReason, uint32 uiRequestedSize) { FILE *pFile; int iActiveCount = 0; uint32 uiTrackedSize = 0; @@ -525,11 +523,8 @@ static void LogMemBlocks(const char *pszReason, uint32 uiRequestedSize) for (int i = 0; i < MEM_BLOCK_COUNT; ++i) { if (mem_blocks[i].pBuf) { - fprintf(pFile, "%d,%p,%u,%p,%d\n", - i, - mem_blocks[i].pBuf, - mem_blocks[i].uiSize, - mem_blocks[i].pAlsoBuf, + fprintf(pFile, "%d,%p,%u,%p,%d\n", i, mem_blocks[i].pBuf, + mem_blocks[i].uiSize, mem_blocks[i].pAlsoBuf, mem_blocks[i].iRegsDi); } } @@ -539,18 +534,18 @@ static void LogMemBlocks(const char *pszReason, uint32 uiRequestedSize) } //------------------------------------------------------------------------------------------------- -//00010700 -void *getbuffer(uint32 uiSize) -{ +// 00010700 +void *getbuffer(uint32 uiSize) { int iMemBlocksIdx; // esi - void *pBuf; // eax - int iRegsDi = 0; // [esp+28h] [ebp-24h] BYREF + void *pBuf; // eax + int iRegsDi = 0; // [esp+28h] [ebp-24h] BYREF void *pPtr = NULL; // [esp+2Ch] [ebp-20h] BYREF iMemBlocksIdx = find_free_mem_block(); if (iMemBlocksIdx < 0) { LogMemBlocks("getbuffer", uiSize); - ErrorBoxExit("Out of tracked memory blocks while allocating %u bytes", uiSize); + ErrorBoxExit("Out of tracked memory blocks while allocating %u bytes", + uiSize); return NULL; } @@ -567,14 +562,13 @@ void *getbuffer(uint32 uiSize) } //------------------------------------------------------------------------------------------------- -//00010890 -void *trybuffer(uint32 uiSize) -{ +// 00010890 +void *trybuffer(uint32 uiSize) { int iMemBlocksIdx; // esi - void *pBuf; // eax + void *pBuf; // eax void *pPtr = NULL; // [esp+28h] [ebp-20h] BYREF - int iRegsDi = 0; // [esp+2Ch] [ebp-1Ch] BYREF - int iMemUsed; // ecx + int iRegsDi = 0; // [esp+2Ch] [ebp-1Ch] BYREF + int iMemUsed; // ecx iMemBlocksIdx = find_free_mem_block(); if (iMemBlocksIdx < 0) { @@ -597,12 +591,11 @@ void *trybuffer(uint32 uiSize) } //------------------------------------------------------------------------------------------------- -//000109F0 -void fre(void **ppData) -{ +// 000109F0 +void fre(void **ppData) { int iMemBlocksIdx; // edx - uint32 uiSize; // eax - void *pBuf; // ebx + uint32 uiSize; // eax + void *pBuf; // ebx if (ppData && *ppData) { iMemBlocksIdx = find_mem_block(*ppData); @@ -628,9 +621,8 @@ void fre(void **ppData) } //------------------------------------------------------------------------------------------------- -//00010AF0 -void doexit() -{ +// 00010AF0 +void doexit() { exiting = -1; if (network_on) { tick_on = -1; @@ -642,18 +634,18 @@ void doexit() } close_network(); SaveRecords(); - fre((void**)&mirbuf); + fre((void **)&mirbuf); for (int i = 0; i < 16; ++i) { - fre((void**)&rev_vga[i]); - fre((void**)&cartex_vga[i]); - fre((void**)&front_vga[i]); - } - fre((void**)&font_vga); - fre((void**)&title_vga); - fre((void**)&cargen_vga); - fre((void**)&texture_vga); - fre((void**)&building_vga); - fre((void**)&scrbuf); + fre((void **)&rev_vga[i]); + fre((void **)&cartex_vga[i]); + fre((void **)&front_vga[i]); + } + fre((void **)&font_vga); + fre((void **)&title_vga); + fre((void **)&cargen_vga); + fre((void **)&texture_vga); + fre((void **)&building_vga); + fre((void **)&scrbuf); release_key_int(); Uninitialise_SOS(); releasesamples(); @@ -671,38 +663,37 @@ void doexit() if (!intro) save_fatal_config(); - //added by ROLLER + // added by ROLLER ShutdownSDL(); - //clear keyboard buffer - //while (kbhit(iSuccess)) - // iSuccess = getch(); + // clear keyboard buffer + // while (kbhit(iSuccess)) + // iSuccess = getch(); chdir(".."); exit(0); } //------------------------------------------------------------------------------------------------- -//00010C80 -void firework_screen() -{ - int iCarIndex; // esi +// 00010C80 +void firework_screen() { + int iCarIndex; // esi tCarSpray *pCarSpray; // ebx - uint8 byType; // al - int iSprayIndex; // ecx - double fPosX; // st7 - double fPosY; // st7 - int i; // ecx + uint8 byType; // al + int iSprayIndex; // ecx + double fPosX; // st7 + double fPosY; // st7 + int i; // ecx double fRandomOffset; // st7 - double fTempY; // st7 - int iRandValue; // eax - int iColorOffset; // eax - char byFinalOffset; // dl - int iScreenY; // [esp+0h] [ebp-30h] - int iScreenY2; // [esp+4h] [ebp-2Ch] - int iScreenX; // [esp+8h] [ebp-28h] - int iScreenX2; // [esp+Ch] [ebp-24h] - char byColorFade; // [esp+10h] [ebp-20h] + double fTempY; // st7 + int iRandValue; // eax + int iColorOffset; // eax + char byFinalOffset; // dl + int iScreenY; // [esp+0h] [ebp-30h] + int iScreenY2; // [esp+4h] [ebp-2Ch] + int iScreenX; // [esp+8h] [ebp-28h] + int iScreenX2; // [esp+Ch] [ebp-24h] + char byColorFade; // [esp+10h] [ebp-20h] iCarIndex = 0; @@ -714,10 +705,10 @@ void firework_screen() byType = CarSpray[iCarIndex][0].iType; // Check if car has active spray effects - if (byType) { // Type 1: Trail spray effects (up to 5 particles) + if (byType) { // Type 1: Trail spray effects (up to 5 particles) if (byType <= 1u) { iSprayIndex = 0; - byColorFade = 0; // Initialize color fade counter for trail effect + byColorFade = 0; // Initialize color fade counter for trail effect do { if ((uint8)pCarSpray->iType) { // Convert floating point positions to screen coordinates @@ -729,14 +720,20 @@ void firework_screen() iScreenY2 = (int)fPosY; // Bounds check: ensure particle is within screen area - if (iScreenX >= 0 && iScreenX < winw && iScreenY2 >= 0 && iScreenY2 < winh) - scrbuf[winw * iScreenY2 + iScreenX] = (uint8)(pCarSpray->iColor) - byColorFade;// Draw particle with fading color (darker for older trail segments) + if (iScreenX >= 0 && iScreenX < winw && iScreenY2 >= 0 && + iScreenY2 < winh) + scrbuf[winw * iScreenY2 + iScreenX] = + (uint8)(pCarSpray->iColor) - + byColorFade; // Draw particle with fading color (darker for + // older trail segments) } ++pCarSpray; ++iSprayIndex; - byColorFade += 3; // Increase fade amount for next trail segment (3 units darker) + byColorFade += + 3; // Increase fade amount for next trail segment (3 units darker) } while (iSprayIndex < 5); - } else if (byType == 2) // Type 2: Firework explosion effects (32 particles) + } else if (byType == + 2) // Type 2: Firework explosion effects (32 particles) { for (i = 0; i < 32; ++i) { // Only draw particles that are still alive (lifetime > 0) @@ -747,79 +744,90 @@ void firework_screen() fTempY = pCarSpray->position.fY; //_CHP(); iScreenY = (int)fTempY; - iRandValue = ROLLERrandRaw(); // Generate random color variation for firework sparkle effect - iColorOffset = GetHighOrderRand(16, iRandValue);// (16 * iRandValue) >> 15; - //iColorOffset = (16 * iRandValue) % 32768 / 15; - //iColorOffset = (16 * iRandValue - (__CFSHL__((16 * iRandValue) >> 31, 15) + ((16 * iRandValue) >> 31 << 15))) >> 15; - byFinalOffset = iColorOffset - 4; // Calculate color offset (-4 to +11 range) with minimum of 0 + iRandValue = ROLLERrandRaw(); // Generate random color variation for + // firework sparkle effect + iColorOffset = + GetHighOrderRand(16, iRandValue); // (16 * iRandValue) >> 15; + // iColorOffset = (16 * iRandValue) % 32768 / 15; + // iColorOffset = (16 * iRandValue - (__CFSHL__((16 * iRandValue) >> + // 31, 15) + ((16 * iRandValue) >> 31 << 15))) >> 15; + byFinalOffset = + iColorOffset - + 4; // Calculate color offset (-4 to +11 range) with minimum of 0 if (iColorOffset - 4 < 0) byFinalOffset = 0; - if (iScreenX2 >= 0 && iScreenX2 < winw && iScreenY >= 0 && iScreenY < winh)// Bounds check for firework particle position - scrbuf[iScreenX2 + winw * iScreenY] = (uint8)(pCarSpray->iColor) - byFinalOffset;// Draw firework particle with random color variation + if (iScreenX2 >= 0 && iScreenX2 < winw && iScreenY >= 0 && + iScreenY < winh) // Bounds check for firework particle position + scrbuf[iScreenX2 + winw * iScreenY] = + (uint8)(pCarSpray->iColor) - + byFinalOffset; // Draw firework particle with random color + // variation } ++pCarSpray; } } } ++iCarIndex; - } while (iCarIndex != 18); // Loop through all 18 cars' spray effects + } while (iCarIndex != 18); // Loop through all 18 cars' spray effects // Copy finished frame buffer to display screen game_copypic(scrbuf, screen, ViewType[0]); } //------------------------------------------------------------------------------------------------- -//00010E30 -void updatescreen() -{ - int iOriginalScrSize; // esi - int iMirrorWinWidth; // edi - int iMirrorWinHeight; // ebp - int iMirrorXOffset; // esi - uint8 *pDestPtr; // ecx - uint8 *pMirrorSrcPtr; // esi - int iRowCounter; // ebx - uint8 *pCurrentRowPtr; // ecx - int iPixelCounter; // eax - uint8 *pPixelPtr; // ecx - uint8 byPixelData; // dl - int iWinWidthCopy; // eax - int iReareaViewScrSize; // esi - int iRearViewWinWidth; // edi - int iRearViewWinHeight; // ebp - int iViewTypeIndex; // edx - uint8 *pRearViewDestPtr; // ecx - uint8 *pRearViewSrcPtr; // esi - int iRearViewRowCounter; // ebx - uint8 *pRearViewRowPtr; // ecx +// 00010E30 +void updatescreen() { + int iOriginalScrSize; // esi + int iMirrorWinWidth; // edi + int iMirrorWinHeight; // ebp + int iMirrorXOffset; // esi + uint8 *pDestPtr; // ecx + uint8 *pMirrorSrcPtr; // esi + int iRowCounter; // ebx + uint8 *pCurrentRowPtr; // ecx + int iPixelCounter; // eax + uint8 *pPixelPtr; // ecx + uint8 byPixelData; // dl + int iWinWidthCopy; // eax + int iReareaViewScrSize; // esi + int iRearViewWinWidth; // edi + int iRearViewWinHeight; // ebp + int iViewTypeIndex; // edx + uint8 *pRearViewDestPtr; // ecx + uint8 *pRearViewSrcPtr; // esi + int iRearViewRowCounter; // ebx + uint8 *pRearViewRowPtr; // ecx int iRearViewPixelCounter; // eax - uint8 *pRearViewPixelPtr; // ecx + uint8 *pRearViewPixelPtr; // ecx uint8 byRearViewPixelData; // dl int iRearViewWinWidthCopy; // eax - int iXMaxCopy; // ebx - int iWinHeightPlusY; // edx - int iYMaxCopy; // ecx - int iMirrorYOffset; // [esp+0h] [ebp-24h] - int iShowRearView; // [esp+4h] [ebp-20h] + int iXMaxCopy; // ebx + int iWinHeightPlusY; // edx + int iYMaxCopy; // ecx + int iMirrorYOffset; // [esp+0h] [ebp-24h] + int iShowRearView; // [esp+4h] [ebp-20h] game_render_begin_frame(g_pGameRenderer); - mirror = 0; // Initialize global screen state variables + mirror = 0; // Initialize global screen state variables shown_panel = 0; screenready = -1; - if (SVGA_ON) // Set polygon detail level based on SVGA mode + if (SVGA_ON) // Set polygon detail level based on SVGA mode small_poly = 200; else small_poly = 100; time_shown = 0; if (!Play_View) - goto LABEL_30; // Check if we're in a play view mode (rear view or side view) - if ((uint8)Play_View <= 1u) // Handle rear view mode (Play_View <= 1) + goto LABEL_30; // Check if we're in a play view mode (rear view or side + // view) + if ((uint8)Play_View <= 1u) // Handle rear view mode (Play_View <= 1) { - time_shown = -1; // Setup rear view window - reduce screen size and position window + time_shown = + -1; // Setup rear view window - reduce screen size and position window iReareaViewScrSize = scr_size; xbase = 319; - scr_size /= 4; // Reduce screen size to 1/4 for rear view window - //scr_size = (scr_size - (__CFSHL__(scr_size >> 31, 2) + 4 * (scr_size >> 31))) >> 2; + scr_size /= 4; // Reduce screen size to 1/4 for rear view window + // scr_size = (scr_size - (__CFSHL__(scr_size >> 31, 2) + 4 * (scr_size >> + // 31))) >> 2; winw = (320 * scr_size) >> 5; iRearViewWinWidth = (320 * scr_size) >> 5; winx = 0; @@ -827,18 +835,22 @@ void updatescreen() winh = (200 * scr_size) >> 6; iRearViewWinHeight = (200 * scr_size) >> 6; iShowRearView = 0; - if ((ViewType[0] & 1) != 0) // Check if we should show rear view for current car + if ((ViewType[0] & 1) != + 0) // Check if we should show rear view for current car { - iViewTypeIndex = ViewType[0] - 1; // Get car index for rear view based on ViewType flags + iViewTypeIndex = ViewType[0] - + 1; // Get car index for rear view based on ViewType flags if ((Car[iViewTypeIndex].byLives & 0x80u) != 0) - goto LABEL_20; // Check if car is alive (bit 7 of byLives indicates death) + goto LABEL_20; // Check if car is alive (bit 7 of byLives indicates + // death) } else { iViewTypeIndex = ViewType[0] + 1; if ((Car[iViewTypeIndex].byLives & 0x80u) != 0) goto LABEL_20; } iShowRearView = -1; - draw_road(mirbuf, iViewTypeIndex, 2u, 0, 0);// Draw rear view road to mirror buffer + draw_road(mirbuf, iViewTypeIndex, 2u, 0, + 0); // Draw rear view road to mirror buffer LABEL_20: time_shown = 0; shown_panel = 0; @@ -848,8 +860,9 @@ void updatescreen() winx = (XMAX - ((320 * iReareaViewScrSize + 32) >> 6)) / 2; winy = (YMAX - ((200 * iReareaViewScrSize + 32) >> 6)) / 2; scr_size = iReareaViewScrSize; - draw_road(scrbuf, ViewType[0], DriveView[0], 0, 0);// Draw main forward view road to screen buffer - if (clear_borders) // Clear screen borders if needed + draw_road(scrbuf, ViewType[0], DriveView[0], 0, + 0); // Draw main forward view road to screen buffer + if (clear_borders) // Clear screen borders if needed { clear_borders = 0; clear_border(0, 0, XMAX, winy); @@ -857,20 +870,26 @@ void updatescreen() clear_border(winx + winw, winy, winx, winh); clear_border(0, winy + winh, XMAX, YMAX - (winy + winh)); } - if (iShowRearView) // Copy rear view mirror data to main screen with border (color 119) + if (iShowRearView) // Copy rear view mirror data to main screen with border + // (color 119) { // Position rear view mirror horizontally centered pRearViewDestPtr = &scrbuf[(winw - iRearViewWinWidth - 1) / 2]; - //pRearViewDestPtr = &scrbuf[(winw - iRearViewWinWidth - 1) / 2 + winw * ((11 * scr_size - (__CFSHL__((11 * scr_size) >> 31, 6) + ((11 * scr_size) >> 31 << 6))) >> 6)]; + // pRearViewDestPtr = &scrbuf[(winw - iRearViewWinWidth - 1) / 2 + winw * + // ((11 * scr_size - (__CFSHL__((11 * scr_size) >> 31, 6) + ((11 * + // scr_size) >> 31 << 6))) >> 6)]; pRearViewSrcPtr = mirbuf; memset(pRearViewDestPtr, 0x77, iRearViewWinWidth + 2); iRearViewRowCounter = 0; for (pRearViewRowPtr = &pRearViewDestPtr[winw]; - iRearViewRowCounter < iRearViewWinHeight; - pRearViewRowPtr = &pRearViewPixelPtr[iRearViewWinWidthCopy - iRearViewWinWidth - 1]) { + iRearViewRowCounter < iRearViewWinHeight; + pRearViewRowPtr = &pRearViewPixelPtr[iRearViewWinWidthCopy - + iRearViewWinWidth - 1]) { *pRearViewRowPtr = 0x77; iRearViewPixelCounter = 0; - for (pRearViewPixelPtr = pRearViewRowPtr + 1; iRearViewPixelCounter < iRearViewWinWidth; *(pRearViewPixelPtr - 1) = byRearViewPixelData) { + for (pRearViewPixelPtr = pRearViewRowPtr + 1; + iRearViewPixelCounter < iRearViewWinWidth; + *(pRearViewPixelPtr - 1) = byRearViewPixelData) { ++pRearViewPixelPtr; byRearViewPixelData = *pRearViewSrcPtr++; ++iRearViewPixelCounter; @@ -885,7 +904,7 @@ void updatescreen() goto LABEL_14; goto LABEL_59; } - if (Play_View == 2) // Handle side view mode (Play_View == 2) + if (Play_View == 2) // Handle side view mode (Play_View == 2) { iOriginalScrSize = scr_size; xbase = 159; @@ -897,7 +916,9 @@ void updatescreen() winy = 0; winh = (200 * scr_size) >> 7; iMirrorWinHeight = (200 * scr_size) >> 7; - draw_road(mirbuf, ViewType[0], -DriveView[0] - 1, 0, 0);// Draw mirrored view (negative DriveView for reverse perspective) + draw_road( + mirbuf, ViewType[0], -DriveView[0] - 1, 0, + 0); // Draw mirrored view (negative DriveView for reverse perspective) xbase = 159; winw = (320 * iOriginalScrSize + 32) >> 6; winh = (200 * iOriginalScrSize + 32) >> 6; @@ -908,9 +929,10 @@ void updatescreen() scr_size = iOriginalScrSize; draw_road(scrbuf, ViewType[0], DriveView[0], 0, 0); iMirrorXOffset = (winw - iMirrorWinWidth - 1) / 2; - // Calculate vertical offset for rear view mirror position + // Calculate vertical offset for rear view mirror position iMirrorYOffset = (11 * scr_size) / 64; - //iMirrorYOffset = (11 * scr_size - (__CFSHL__((11 * scr_size) >> 31, 6) + ((11 * scr_size) >> 31 << 6))) >> 6; + // iMirrorYOffset = (11 * scr_size - (__CFSHL__((11 * scr_size) >> 31, 6) + + // ((11 * scr_size) >> 31 << 6))) >> 6; if (clear_borders) { clear_borders = 0; clear_border(0, 0, XMAX, winy); @@ -918,16 +940,22 @@ void updatescreen() clear_border(winx + winw, winy, winx, winh); clear_border(0, winh + winy, XMAX, YMAX - (winh + winy)); } - pDestPtr = &scrbuf[iMirrorXOffset + iMirrorYOffset * winw];// Copy side mirror view with border (color 112/0x70) + pDestPtr = + &scrbuf[iMirrorXOffset + + iMirrorYOffset * + winw]; // Copy side mirror view with border (color 112/0x70) pMirrorSrcPtr = &mirbuf[iMirrorWinWidth - 1]; memset(pDestPtr, 0x70, iMirrorWinWidth + 2); iRowCounter = 0; - for (pCurrentRowPtr = &pDestPtr[winw]; iRowCounter < iMirrorWinHeight; pCurrentRowPtr = &pPixelPtr[iWinWidthCopy - iMirrorWinWidth - 1]) { + for (pCurrentRowPtr = &pDestPtr[winw]; iRowCounter < iMirrorWinHeight; + pCurrentRowPtr = &pPixelPtr[iWinWidthCopy - iMirrorWinWidth - 1]) { *pCurrentRowPtr = 0x70; iPixelCounter = 0; - for (pPixelPtr = pCurrentRowPtr + 1; iPixelCounter < iMirrorWinWidth; *(pPixelPtr - 1) = byPixelData) { + for (pPixelPtr = pCurrentRowPtr + 1; iPixelCounter < iMirrorWinWidth; + *(pPixelPtr - 1) = byPixelData) { ++pPixelPtr; - byPixelData = *pMirrorSrcPtr--; // Copy pixels in reverse order for mirror effect + byPixelData = + *pMirrorSrcPtr--; // Copy pixels in reverse order for mirror effect ++iPixelCounter; } iWinWidthCopy = winw; @@ -938,7 +966,9 @@ void updatescreen() memset(pCurrentRowPtr, 0x70, iMirrorWinWidth + 2); if (screenready) { LABEL_14: - game_copypic(scrbuf, screen, ViewType[0]);// Copy screen buffer to final display and initialize animated elements + game_copypic(scrbuf, screen, + ViewType[0]); // Copy screen buffer to final display and + // initialize animated elements init_animate_ads(); game_render_end_frame(g_pGameRenderer); return; @@ -946,8 +976,8 @@ void updatescreen() goto LABEL_59; } LABEL_30: - if (player_type == 2) // Handle 2-player split screen mode - { // Setup split screen for 2-player mode + if (player_type == 2) // Handle 2-player split screen mode + { // Setup split screen for 2-player mode if (SVGA_ON) scr_size = 64; else @@ -959,9 +989,11 @@ void updatescreen() winh = YMAX / 2 - 2; if (clear_borders) memset(&scrbuf[winh * winw], 0, 4 * winw); - draw_road(scrbuf, ViewType[0], DriveView[0], -1, 0);// Draw player 1 view (top half) + draw_road(scrbuf, ViewType[0], DriveView[0], -1, + 0); // Draw player 1 view (top half) shown_panel = 0; - draw_road(&scrbuf[winw * (winh + 4)], ViewType[1], DriveView[1], -1, 1);// Draw player 2 view (bottom half) + draw_road(&scrbuf[winw * (winh + 4)], ViewType[1], DriveView[1], -1, + 1); // Draw player 2 view (bottom half) time_shown = -1; if (SVGA_ON) scr_size = 128; @@ -975,8 +1007,9 @@ void updatescreen() goto LABEL_59; } // CHEAT_MODE_WIDESCREEN - if ((cheat_mode & CHEAT_MODE_WIDESCREEN) == 0 || paused) // Handle single player normal/widescreen mode - { // Standard windowed mode or paused state + if ((cheat_mode & CHEAT_MODE_WIDESCREEN) == 0 || + paused) // Handle single player normal/widescreen mode + { // Standard windowed mode or paused state if ((cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) { if (SVGA_ON) scr_size = 128; @@ -998,7 +1031,7 @@ void updatescreen() iXMaxCopy = XMAX; goto LABEL_44; } - } else { // Widescreen cheat mode (cheat_mode & 0x40) and not paused + } else { // Widescreen cheat mode (cheat_mode & 0x40) and not paused if (SVGA_ON) scr_size = 64; else @@ -1007,13 +1040,14 @@ void updatescreen() winw = XMAX; winx = 0; xbase = 319; - winy = YMAX / 4; // Position window at 1/4 down from top of screen - //winy = (YMAX - (__CFSHL__(YMAX >> 31, 2) + 4 * (YMAX >> 31))) >> 2; + winy = YMAX / 4; // Position window at 1/4 down from top of screen + // winy = (YMAX - (__CFSHL__(YMAX >> 31, 2) + 4 * (YMAX >> 31))) >> 2; if (clear_borders) { clear_borders = 0; // Clear top border area (top quarter of screen) clear_border(0, 0, XMAX, YMAX / 4); - //clear_border(0, 0, XMAX, (YMAX - (__CFSHL__(YMAX >> 31, 2) + 4 * (YMAX >> 31))) >> 2); + // clear_border(0, 0, XMAX, (YMAX - (__CFSHL__(YMAX >> 31, 2) + 4 * (YMAX + // >> 31))) >> 2); iXMaxCopy = XMAX; iWinHeightPlusY = winh + winy; iYMaxCopy = YMAX; @@ -1021,12 +1055,13 @@ void updatescreen() clear_border(0, iWinHeightPlusY, iXMaxCopy, iYMaxCopy - iWinHeightPlusY); } } - draw_road(scrbuf, ViewType[0], DriveView[0], -1, 0);// Draw main road view + draw_road(scrbuf, ViewType[0], DriveView[0], -1, 0); // Draw main road view // CHEAT_MODE_WIDESCREEN - if ((cheat_mode & CHEAT_MODE_WIDESCREEN) == 0) // Check for widescreen cheat mode to copy to final screen + if ((cheat_mode & CHEAT_MODE_WIDESCREEN) == + 0) // Check for widescreen cheat mode to copy to final screen { LABEL_59: - init_animate_ads(); // Initialize animated advertisements and return + init_animate_ads(); // Initialize animated advertisements and return game_render_end_frame(g_pGameRenderer); return; } @@ -1041,40 +1076,53 @@ void updatescreen() } //------------------------------------------------------------------------------------------------- -//00011800 -void draw_road(uint8 *pScrPtr, int iCarIdx, unsigned int uiViewMode, int iCopyImmediately, int iChaseCamIdx) -{ - double dSubscaleMultiplier; // st7 +// 00011800 +void draw_road(uint8 *pScrPtr, int iCarIdx, unsigned int uiViewMode, + int iCopyImmediately, int iChaseCamIdx) { + double dSubscaleMultiplier; // st7 double dTextureSubscaleMultiplier; // st7 // TEX_OFF_PERSPECTIVE_CORRECTION - if ((textures_off & TEX_OFF_PERSPECTIVE_CORRECTION) != 0 || game_track == 13) { // Set minimum subdivision size for texture-less rendering + if ((textures_off & TEX_OFF_PERSPECTIVE_CORRECTION) != 0 || + game_track == + 13) { // Set minimum subdivision size for texture-less rendering if (gfx_size == 1) min_sub_size = 64; else min_sub_size = 128; - } else if (gfx_size == 1) // Set minimum subdivision size for textured rendering + } else if (gfx_size == + 1) // Set minimum subdivision size for textured rendering { min_sub_size = 4; } else { min_sub_size = 8; } - if (SVGA_ON) // Calculate base subscale multiplier based on graphics mode - dSubscaleMultiplier = (double)scr_size * 2.0;// SVGA mode: 2x multiplier for higher detail + if (SVGA_ON) // Calculate base subscale multiplier based on graphics mode + dSubscaleMultiplier = + (double)scr_size * 2.0; // SVGA mode: 2x multiplier for higher detail else - dSubscaleMultiplier = (double)scr_size * 4.0;// VGA mode: 4x multiplier for standard detail + dSubscaleMultiplier = + (double)scr_size * 4.0; // VGA mode: 4x multiplier for standard detail subscale = (float)dSubscaleMultiplier; // TEX_OFF_PERSPECTIVE_CORRECTION - if ((textures_off & TEX_OFF_PERSPECTIVE_CORRECTION) != 0 || game_track == 13) { + if ((textures_off & TEX_OFF_PERSPECTIVE_CORRECTION) != 0 || + game_track == 13) { if (SVGA_ON) - dTextureSubscaleMultiplier = (double)scr_size * 1.1;// SVGA texture-less: 1.1x multiplier (slightly higher detail) + dTextureSubscaleMultiplier = + (double)scr_size * + 1.1; // SVGA texture-less: 1.1x multiplier (slightly higher detail) else - dTextureSubscaleMultiplier = (double)scr_size * 1.2;// VGA texture-less: 1.2x multiplier (slightly higher detail) + dTextureSubscaleMultiplier = + (double)scr_size * + 1.2; // VGA texture-less: 1.2x multiplier (slightly higher detail) subscale = (float)dTextureSubscaleMultiplier; } - screen_pointer = pScrPtr; // Set global screen buffer pointer for rendering functions + screen_pointer = + pScrPtr; // Set global screen buffer pointer for rendering functions game_render_set_target(g_pGameRenderer, pScrPtr, winw, winw, winh); - calculateview(uiViewMode, iCarIdx, iChaseCamIdx); // Calculate camera view matrix and projection parameters + calculateview( + uiViewMode, iCarIdx, + iChaseCamIdx); // Calculate camera view matrix and projection parameters extern float viewx, viewy, viewz; extern int worlddirn, VIEWDIST; GameRenderCamera cam = { @@ -1089,53 +1137,64 @@ void draw_road(uint8 *pScrPtr, int iCarIdx, unsigned int uiViewMode, int iCopyIm extern float vk1, vk2, vk3, vk4, vk5, vk6, vk7, vk8, vk9; GameRenderProjection proj = { - .view = {{vk1, vk2, vk3}, - {vk4, vk5, vk6}, - {vk7, vk8, vk9}}, + .view = {{vk1, vk2, vk3}, {vk4, vk5, vk6}, {vk7, vk8, vk9}}, .screenScale = scr_size, .centerX = xbase, .centerY = ybase, .texHalfRes = gfx_size, }; game_render_set_projection(g_pGameRenderer, &proj); - game_render_draw_sky(g_pGameRenderer, &cam, &proj); // Draw sky/horizon background - CalcVisibleTrack(iCarIdx, uiViewMode); // Calculate which track segments are visible from current viewpoint - DrawCars(iCarIdx, uiViewMode); // Render all visible cars (excluding current player if in chase cam) - CalcVisibleBuildings(); // Calculate visibility and prepare building rendering data - DrawTrack3(pScrPtr, iChaseCamIdx, iCarIdx, &cam, &proj); // Render track surface, buildings, and track-side objects - if (iCopyImmediately) // Check if immediate screen copy is requested - { // Copy rendered frame to display if screen is ready + game_render_draw_sky(g_pGameRenderer, &cam, + &proj); // Draw sky/horizon background + CalcVisibleTrack(iCarIdx, uiViewMode); // Calculate which track segments are + // visible from current viewpoint + DrawCars(iCarIdx, uiViewMode); // Render all visible cars (excluding current + // player if in chase cam) + CalcVisibleBuildings(); // Calculate visibility and prepare building rendering + // data + DrawTrack3(pScrPtr, iChaseCamIdx, iCarIdx, &cam, + &proj); // Render track surface, buildings, and track-side objects + if (iCopyImmediately) // Check if immediate screen copy is requested + { // Copy rendered frame to display if screen is ready if (screenready) game_copypic(pScrPtr, screen, iCarIdx); } } -static void print_usage(FILE *f, const char *argv0) -{ +static void print_usage(FILE *f, const char *argv0) { fprintf(f, "usage: %s [options]\n\n", argv0); fprintf(f, "options:\n"); fprintf(f, " -h, --help show this help message and exit\n"); fprintf(f, " --whiplash-root DIR specify Whiplash data directory\n"); fprintf(f, " --midi-root DIR specify midi data directory\n"); - fprintf(f, " --port N UDP port to bind (default: %d)\n", ROLLER_DEFAULT_PORT); - fprintf(f, " --peer IP:PORT pre-configure a peer for direct connection\n"); - fprintf(f, " --net-slot N network slot index; use -1 to join as client\n"); - fprintf(f, " --no-crash-handler disable crash dump generation for this run\n"); - fprintf(f, " --snapshot REPLAY headless replay-capture mode (writes indexed PNGs)\n"); + fprintf(f, " --port N UDP port to bind (default: %d)\n", + ROLLER_DEFAULT_PORT); + fprintf( + f, + " --peer IP:PORT pre-configure a peer for direct connection\n"); + fprintf( + f, + " --net-slot N network slot index; use -1 to join as client\n"); + fprintf( + f, + " --no-crash-handler disable crash dump generation for this run\n"); + fprintf(f, " --snapshot REPLAY headless replay-capture mode (writes " + "indexed PNGs)\n"); fprintf(f, " --snapshot-scene NAME render a headless named scene snapshot\n"); - fprintf(f, " --frames N[,M,...] replay-frame indices to capture (--snapshot only)\n"); - fprintf(f, " --out DIR output directory for snapshot PNGs (--snapshot only)\n"); + fprintf(f, " --frames N[,M,...] replay-frame indices to capture " + "(--snapshot only)\n"); + fprintf(f, " --out DIR output directory for snapshot PNGs " + "(--snapshot only)\n"); } //------------------------------------------------------------------------------------------------- -//00011930 -int main(int argc, const char **argv, const char **envp) -{ +// 00011930 +int main(int argc, const char **argv, const char **envp) { int nGameFlags; // edx - int16 nCarIdx; // bx + int16 nCarIdx; // bx int consumed = 0; int iCrashHandlerEnabled = 1; - char whiplash_root[260] = { 0 }; + char whiplash_root[260] = {0}; const char *midi_root = NULL; for (int i = 1; i < argc;) { @@ -1226,7 +1285,8 @@ int main(int argc, const char **argv, const char **envp) } else if (strcmp(argv[i], "--frames") == 0) { if (i + 1 < argc) { if (SnapshotParseFrames(argv[i + 1]) != 0) { - fprintf(stderr, "ERROR: '--frames' must be a comma-separated list of non-negative integers\n"); + fprintf(stderr, "ERROR: '--frames' must be a comma-separated list of " + "non-negative integers\n"); return 1; } consumed = 2; @@ -1252,16 +1312,20 @@ int main(int argc, const char **argv, const char **envp) } if (g_bSnapshotMode) { - if (g_SnapshotConfig.eKind == SNAPSHOT_KIND_REPLAY && g_SnapshotConfig.szReplayName[0] == '\0') { + if (g_SnapshotConfig.eKind == SNAPSHOT_KIND_REPLAY && + g_SnapshotConfig.szReplayName[0] == '\0') { fprintf(stderr, "ERROR: '--snapshot' requires a replay filename\n"); return 1; } - if (g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE && g_SnapshotConfig.szSceneName[0] == '\0') { + if (g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE && + g_SnapshotConfig.szSceneName[0] == '\0') { fprintf(stderr, "ERROR: '--snapshot-scene' requires a scene name\n"); return 1; } if (g_SnapshotConfig.eKind == SNAPSHOT_KIND_NONE) { - fprintf(stderr, "ERROR: snapshot mode requires '--snapshot' or '--snapshot-scene'\n"); + fprintf( + stderr, + "ERROR: snapshot mode requires '--snapshot' or '--snapshot-scene'\n"); return 1; } if (g_SnapshotConfig.iNumFrames == 0) { @@ -1294,26 +1358,28 @@ int main(int argc, const char **argv, const char **envp) ROLLERGetAudioInfo(); } - ROLLERCommsSetCommandBase(0x686C6361u); // Initialize communication system with base command - oldmode = readmode(); // Save current video mode + ROLLERCommsSetCommandBase( + 0x686C6361u); // Initialize communication system with base command + oldmode = readmode(); // Save current video mode blankpal(); - SVGA_ON = 0; // Disable SVGA mode for initial screen setup + SVGA_ON = 0; // Disable SVGA mode for initial screen setup init_screen(); blankpal(); SVGA_ON = -1; - init_screen(); // Enable SVGA mode and reinitialize screen + init_screen(); // Enable SVGA mode and reinitialize screen blankpal(); - test_w95(); // Test for Windows 95 compatibility - //harderr((int)criticalhandler, __CS__); // Install critical error handler - // network_slot defaults to 0 (host); --net-slot sets it before we get here + test_w95(); // Test for Windows 95 compatibility + // harderr((int)criticalhandler, __CS__); // Install critical error + // handler + // network_slot defaults to 0 (host); --net-slot sets it before we get here player1_car = 0; player2_car = 1; - name_copy(player_names[0], "HUMAN"); // Initialize default player names + name_copy(player_names[0], "HUMAN"); // Initialize default player names name_copy(player_names[player2_car], "PLAYER 2"); textures_off = 0; frontend_on = -1; claim_key_int(); - max_mem = 0; // Initialize memory tracking + max_mem = 0; // Initialize memory tracking setdirectory(whiplash_root); memset(mem_blocks, 0, sizeof(mem_blocks)); cheat_mode = 0; @@ -1325,20 +1391,22 @@ int main(int argc, const char **argv, const char **envp) } else { load_fatal_config(); } - if ((textures_off & TEX_OFF_WIDESCREEN) != 0) // Check for debug cheat flags in textures_off + if ((textures_off & TEX_OFF_WIDESCREEN) != + 0) // Check for debug cheat flags in textures_off { cheat_mode |= CHEAT_MODE_WIDESCREEN; textures_off ^= TEX_OFF_WIDESCREEN; } - if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) // Check for false starts cheat flag + if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != + 0) // Check for false starts cheat flag { false_starts = -1; // BYTE1 is the second byte textures_off ^= TEX_OFF_PANEL_RESTRICTED; - //uiTexturesOff = textures_off; - //BYTE1(uiTexturesOff) = BYTE1(textures_off) ^ 0x40; - //textures_off = uiTexturesOff; + // uiTexturesOff = textures_off; + // BYTE1(uiTexturesOff) = BYTE1(textures_off) ^ 0x40; + // textures_off = uiTexturesOff; } else { false_starts = 0; } @@ -1367,7 +1435,7 @@ int main(int argc, const char **argv, const char **envp) } else { check_machine_speed(); } - if (fatal_ini_loaded) // Apply performance settings based on machine speed + if (fatal_ini_loaded) // Apply performance settings based on machine speed { if (view_limit) { if (machine_speed >= 2800) @@ -1375,7 +1443,7 @@ int main(int argc, const char **argv, const char **envp) else view_limit = 24; } - } else { // Auto-configure graphics settings for slower machines + } else { // Auto-configure graphics settings for slower machines if (machine_speed < 9000) textures_off |= TEX_OFF_PERSPECTIVE_CORRECTION; if (machine_speed < 5000) @@ -1404,7 +1472,7 @@ int main(int argc, const char **argv, const char **envp) if (machine_speed < 2800) view_limit = 24; } - InitCarStructs(); // Initialize car data structures + InitCarStructs(); // Initialize car data structures init(); if (g_bSnapshotMode && g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE) { SnapshotEnsureMenuRenderer(); @@ -1415,10 +1483,10 @@ int main(int argc, const char **argv, const char **envp) print_data = 0; tick_on = 0; if (!g_bSnapshotMode) { - copy_screens(); // Copy screen buffers and display title screens + copy_screens(); // Copy screen buffers and display title screens title_screens(); } - time_to_start = 0; // Initialize race state variables + time_to_start = 0; // Initialize race state variables replaytype = 2; start_race = 0; countdown = 144; @@ -1429,19 +1497,19 @@ int main(int argc, const char **argv, const char **envp) readptr = 0; winner_mode = 0; intro = -1; - play_game(TrackLoad); // Start initial game with intro sequence + play_game(TrackLoad); // Start initial game with intro sequence intro = 0; if (g_bSnapshotMode) { doexit(); return 0; } - VIEWDIST = 270; // Main game loop - continues until quit_game is set + VIEWDIST = 270; // Main game loop - continues until quit_game is set do { start_race = 0; time_to_start = 0; if (restart_net) { - restart_net_game(); // Handle network game restart - } else { // Wait for player to start race from menu + restart_net_game(); // Handle network game restart + } else { // Wait for player to start race from menu while (!time_to_start) select_screen(); } @@ -1452,7 +1520,8 @@ int main(int argc, const char **argv, const char **envp) delaywrite = 6; writeptr = 0; readptr = 0; - if (!quit_game) { // Handle different game types - single race, championship, etc + if (!quit_game) { // Handle different game types - single race, + // championship, etc if (game_type < 3) { title_screens(); nGameFlags = -1; @@ -1482,7 +1551,8 @@ int main(int argc, const char **argv, const char **envp) if (!quit_game) { if (nGameFlags) { if (game_type) { - if ((unsigned int)game_type > 1) { // Time trial mode - special handling + if ((unsigned int)game_type > + 1) { // Time trial mode - special handling if (game_type == 2) { StoreResult(); for (nCarIdx = 0; nCarIdx < numcars; ++nCarIdx) { @@ -1493,9 +1563,12 @@ int main(int argc, const char **argv, const char **envp) } goto RACE_CLEANUP; } - finish_race(); // Championship mode - handle race completion + finish_race(); // Championship mode - handle race completion StoreResult(); - if ((human_control[carorder[0]] || (cheat_mode & CHEAT_MODE_RACE_HISTORY) != 0) && winner_screen(Car[carorder[0]].byCarDesignIdx, carorder[0] & 1)) + if ((human_control[carorder[0]] || + (cheat_mode & CHEAT_MODE_RACE_HISTORY) != 0) && + winner_screen(Car[carorder[0]].byCarDesignIdx, + carorder[0] & 1)) winner_race(); ResultRoundUp(); RaceResult(); @@ -1505,21 +1578,23 @@ int main(int argc, const char **argv, const char **envp) ShowLapRecords(); ++Race; TrackLoad = prev_track + 1; - if (Race == 8 || (cheat_mode & CHEAT_MODE_END_SEQUENCE) != 0) - { + if (Race == 8 || (cheat_mode & CHEAT_MODE_END_SEQUENCE) != 0) { ChampionshipOver(); goto RACE_CLEANUP; } if ((cheat_mode & CHEAT_MODE_CREDITS) == 0) goto RACE_CLEANUP; -ROLL_CREDITS: + ROLL_CREDITS: RollCredits(); goto RACE_CLEANUP; } if (!gave_up) { finish_race(); StoreResult(); - if ((human_control[carorder[0]] || (cheat_mode & CHEAT_MODE_RACE_HISTORY) != 0) && winner_screen((int)Car[carorder[0]].byCarDesignIdx, carorder[0] & 1)) + if ((human_control[carorder[0]] || + (cheat_mode & CHEAT_MODE_RACE_HISTORY) != 0) && + winner_screen((int)Car[carorder[0]].byCarDesignIdx, + carorder[0] & 1)) winner_race(); ResultRoundUp(); RaceResult(); @@ -1529,8 +1604,9 @@ int main(int argc, const char **argv, const char **envp) ChampionshipOver(); if ((cheat_mode & CHEAT_MODE_CREDITS) != 0) goto ROLL_CREDITS; -RACE_CLEANUP: - if (player_type == 1) // RACE_CLEANUP: Clean up after race completion + RACE_CLEANUP: + if (player_type == + 1) // RACE_CLEANUP: Clean up after race completion player_type = 0; } intro = 0; @@ -1546,42 +1622,42 @@ int main(int argc, const char **argv, const char **envp) } } } while (!quit_game); - //__asm { int 10h; Reset video mode and exit game }// Reset video mode and exit game + //__asm { int 10h; Reset video mode and exit game }// Reset video mode and + // exit game doexit(); return 0; } //------------------------------------------------------------------------------------------------- -//00012050 -void play_game_init() -{ - //uint32 uiTexturesOff; // edx - //uint32 uiCheatMode; // ebx - //int iNumCarsBytes; // ebx - //unsigned int uiLoopCounter; // eax - int iTeamMateIndex; // ebp - int iNonCompetitorFlag; // edx - int iPlayerSearchIndex; // ebp - int i; // eax - int iCurrentLaps; // eax - int iSong; // eax - int iNetworkMesMode; // ebp - char *szPaletteFile; // eax - int iAlternateViewType; // eax - int iTurnRateCalc; // ecx - int iSteeringSensitivity; // edx - int iTurnRateCalc2; // ecx - int iSteeringSensitivity2; // edx - tData *pLocalDataAy; // edx - int iTrackLen; // ecx - double dTotalTrackDistance; // st7 +// 00012050 +void play_game_init() { + // uint32 uiTexturesOff; // edx + // uint32 uiCheatMode; // ebx + // int iNumCarsBytes; // ebx + // unsigned int uiLoopCounter; // eax + int iTeamMateIndex; // ebp + int iNonCompetitorFlag; // edx + int iPlayerSearchIndex; // ebp + int i; // eax + int iCurrentLaps; // eax + int iSong; // eax + int iNetworkMesMode; // ebp + char *szPaletteFile; // eax + int iAlternateViewType; // eax + int iTurnRateCalc; // ecx + int iSteeringSensitivity; // edx + int iTurnRateCalc2; // ecx + int iSteeringSensitivity2; // edx + tData *pLocalDataAy; // edx + int iTrackLen; // ecx + double dTotalTrackDistance; // st7 double dTotalTrackDistance2; // st6 - int iChunkIdx; // eax - int iSavedNetworkMesMode; // ebp - //int iCarLoopCounter; // eax - //int iCarArraySize; // edx + int iChunkIdx; // eax + int iSavedNetworkMesMode; // ebp + // int iCarLoopCounter; // eax + // int iCarArraySize; // edx - DeathView[0] = -1; // Initialize game state variables to default values + DeathView[0] = -1; // Initialize game state variables to default values DeathView[1] = -1; check_set = 0; I_Would_Like_To_Quit = 0; @@ -1601,7 +1677,7 @@ void play_game_init() sync_errors = 0; game_frame = -1; already_quit = 0; - if (network_on) // Clear CD error flag in network mode + if (network_on) // Clear CD error flag in network mode cd_error = 0; send_finished = 0; fudge_wait = -1; @@ -1609,14 +1685,16 @@ void play_game_init() memset(player_syncs, 0, sizeof(player_syncs)); read_check = 0; write_check = 0; - if (!svga_possible || no_mem) // Disable SVGA if not possible or insufficient memory + if (!svga_possible || + no_mem) // Disable SVGA if not possible or insufficient memory game_svga = 0; SVGA_ON = game_svga; if (no_mem) { fre((void **)&scrbuf); scrbuf = (uint8 *)getbuffer(64000u); } - if (gfx_size == 1) // Set minimum sub-frame size based on graphics quality setting + if (gfx_size == + 1) // Set minimum sub-frame size based on graphics quality setting min_sub_size = 4; else min_sub_size = 8; @@ -1625,7 +1703,7 @@ void play_game_init() tick_on = 0; start_race = 0; game_overs = 0; - if (replaytype != 2) // Handle random seed for network championship mode + if (replaytype != 2) // Handle random seed for network championship mode { if (game_type == 1 && player_type == 1) { network_champ_on = random_seed; @@ -1639,39 +1717,42 @@ void play_game_init() frame_number = 0; writeptr = 0; readptr = 0; - if (replaytype == 2) // Special handling for replay mode - copy competitor settings + if (replaytype == + 2) // Special handling for replay mode - copy competitor settings { replay_cheat = cheat_mode; - if ((cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) - { + if ((cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) { textures_off |= TEX_OFF_WIDESCREEN; - //uiTexturesOff = textures_off; - //BYTE1(uiTexturesOff) = BYTE1(textures_off) | 0x20; - //textures_off = uiTexturesOff; + // uiTexturesOff = textures_off; + // BYTE1(uiTexturesOff) = BYTE1(textures_off) | 0x20; + // textures_off = uiTexturesOff; cheat_mode ^= CHEAT_MODE_WIDESCREEN; - //uiCheatMode = cheat_mode; - //LOBYTE(uiCheatMode) = cheat_mode ^ 0x40; - //cheat_mode = uiCheatMode; + // uiCheatMode = cheat_mode; + // LOBYTE(uiCheatMode) = cheat_mode ^ 0x40; + // cheat_mode = uiCheatMode; } player_type = 0; - if (numcars > 0) // Copy competitor flags from non_competitors to result_competing array + if (numcars > 0) // Copy competitor flags from non_competitors to + // result_competing array { for (int i = 0; i < numcars; ++i) { result_competing[i] = non_competitors[i]; } - //iNumCarsBytes = 4 * numcars; - //uiLoopCounter = 0; - //do { - // uiLoopCounter += 4; - // LODWORD(result_best[uiLoopCounter / 4 + 15]) = TrackArrow_variable_1[uiLoopCounter / 4];// references adjacent data - //} while ((int)uiLoopCounter < iNumCarsBytes); + // iNumCarsBytes = 4 * numcars; + // uiLoopCounter = 0; + // do { + // uiLoopCounter += 4; + // LODWORD(result_best[uiLoopCounter / 4 + 15]) = + // TrackArrow_variable_1[uiLoopCounter / 4];// references adjacent data + // } while ((int)uiLoopCounter < iNumCarsBytes); } } memset(copy_multiple, 0, sizeof(copy_multiple)); draw_type = player_type; - local_players = (player_type == 2) + 1; // Set up network teammate and messaging system + local_players = + (player_type == 2) + 1; // Set up network teammate and messaging system if (network_on) { iTeamMateIndex = (player1_car & 1) != 0 ? player1_car - 1 : player1_car + 1; team_mate = iTeamMateIndex; @@ -1703,8 +1784,7 @@ void play_game_init() SDL_Log("Front end speech memory still allocated!!!!!!!\n"); doexit(); } - if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0) - { + if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0) { game_level = level; game_dam = damage_level; damage_level = 3; @@ -1721,12 +1801,12 @@ void play_game_init() game_scale[1] = 32768.0; Joy1used = 0; Joy2used = 0; - check_joystick_usage(); // Initialize joystick usage tracking + check_joystick_usage(); // Initialize joystick usage tracking memset(repsample, 1, sizeof(repsample)); memcpy(newrepsample, repsample, sizeof(newrepsample)); autoswitch = -1; game_req = 0; - mirbuf = getbuffer(0x7D00u); // Allocate mirror buffer for rear-view display + mirbuf = getbuffer(0x7D00u); // Allocate mirror buffer for rear-view display screenready = 0; racing = -1; if (replaytype != 2) @@ -1740,10 +1820,11 @@ void play_game_init() finishers = 0; human_finishers = 0; setreplaytrack(); - loadtrack(game_track, 0); // Load track data and initialize game world + loadtrack(game_track, 0); // Load track data and initialize game world LoadGenericCarTextures(); InitCars(); - if (game_type >= 2) // Set lap count based on game type (championship vs single race) + if (game_type >= + 2) // Set lap count based on game type (championship vs single race) { NoOfLaps = 5; if (network_on) @@ -1761,7 +1842,8 @@ void play_game_init() startreplay(); LoadPanel(); initclouds(); - if (!w95 || MusicCD) // Start background music if not in Windows 95 or using Music CD + if (!w95 || + MusicCD) // Start background music if not in Windows 95 or using Music CD { if (!winner_mode && !loading_replay) { if (replaytype == 2) @@ -1772,12 +1854,13 @@ void play_game_init() } holdmusic = -1; } - loadsamples(); // Initialize audio system - load samples, setup collisions and sounds + loadsamples(); // Initialize audio system - load samples, setup collisions and + // sounds initcollisions(); initsounds(); fade_palette(0); // Before game renderer exists — use direct call init_screen(); - if (intro || replaytype == 2) // Set screen size based on intro mode or replay + if (intro || replaytype == 2) // Set screen size based on intro mode or replay { iNetworkMesMode = network_mes_mode; if (SVGA_ON) @@ -1803,11 +1886,12 @@ void play_game_init() if (!DuoViews[SelectedView[1]]) viewplus(1); } else if (SelectedView[0] == 7) { - iAlternateViewType = (ViewType[0] & 1) != 0 ? ViewType[0] - 1 : ViewType[0] + 1; + iAlternateViewType = + (ViewType[0] & 1) != 0 ? ViewType[0] - 1 : ViewType[0] + 1; if ((Car[iAlternateViewType].byLives & 0x80u) != 0) SelectedView[0] = 0; } - select_view(0); // Initialize camera views for each player + select_view(0); // Initialize camera views for each player if (Play_View == 1) doteaminit(); else @@ -1818,35 +1902,50 @@ void play_game_init() } initnearcars(); ticks = 0; - p_eng[0] = &CarEngines.engines[Car[player1_car].byCarDesignIdx];// Setup engine pointers and calculate joystick sensitivity values + p_eng[0] = + &CarEngines + .engines[Car[player1_car].byCarDesignIdx]; // Setup engine pointers + // and calculate joystick + // sensitivity values if (player_type == 2) p_eng[1] = &CarEngines.engines[Car[player2_car].byCarDesignIdx]; iTurnRateCalc = p_eng[0]->iMaxTurnRate + 2 * p_eng[0]->iTurnDecayRate; iSteeringSensitivity = p_eng[0]->iSteeringSensitivity; - //TODO look at this, cast to uint32 and bit shift or multiply? - p_joyk1[0] = ((iSteeringSensitivity * (p_eng[0]->iMaxTurnRate - p_eng[0]->iTurnDecayRate)) * 256) / iTurnRateCalc; - p_joyk2[0] = ((3 * iSteeringSensitivity * p_eng[0]->iTurnDecayRate) << 16) / iTurnRateCalc; + // TODO look at this, cast to uint32 and bit shift or multiply? + p_joyk1[0] = ((iSteeringSensitivity * + (p_eng[0]->iMaxTurnRate - p_eng[0]->iTurnDecayRate)) * + 256) / + iTurnRateCalc; + p_joyk2[0] = ((3 * iSteeringSensitivity * p_eng[0]->iTurnDecayRate) << 16) / + iTurnRateCalc; if (player_type == 2) { iTurnRateCalc2 = p_eng[1]->iMaxTurnRate + 2 * p_eng[1]->iTurnDecayRate; iSteeringSensitivity2 = p_eng[1]->iSteeringSensitivity; - //TODO look at this, cast to uint32 and bit shift or multiply? - p_joyk1[1] = ((iSteeringSensitivity2 * (p_eng[1]->iMaxTurnRate - p_eng[1]->iTurnDecayRate)) * 256) / iTurnRateCalc2; - p_joyk2[1] = ((3 * iSteeringSensitivity2 * p_eng[1]->iTurnDecayRate) << 16) / iTurnRateCalc2; + // TODO look at this, cast to uint32 and bit shift or multiply? + p_joyk1[1] = ((iSteeringSensitivity2 * + (p_eng[1]->iMaxTurnRate - p_eng[1]->iTurnDecayRate)) * + 256) / + iTurnRateCalc2; + p_joyk2[1] = + ((3 * iSteeringSensitivity2 * p_eng[1]->iTurnDecayRate) << 16) / + iTurnRateCalc2; } start_race = -1; set_palette(0); fadedin = 0; totaltrackdistance = 0; - if (TRAK_LEN > 0) // Calculate total track distance by summing all section lengths + if (TRAK_LEN > + 0) // Calculate total track distance by summing all section lengths { pLocalDataAy = localdata; iTrackLen = TRAK_LEN; dTotalTrackDistance = (double)totaltrackdistance; iChunkIdx = 0; do { - dTotalTrackDistance2 = 2.0 * pLocalDataAy->fTrackHalfLength + dTotalTrackDistance; + dTotalTrackDistance2 = + 2.0 * pLocalDataAy->fTrackHalfLength + dTotalTrackDistance; ++pLocalDataAy; - dTotalTrackDistance2 = floor(dTotalTrackDistance2);//_CHP(); + dTotalTrackDistance2 = floor(dTotalTrackDistance2); //_CHP(); dTotalTrackDistance = dTotalTrackDistance2; ++iChunkIdx; } while (iChunkIdx < iTrackLen); @@ -1854,23 +1953,26 @@ void play_game_init() } iSavedNetworkMesMode = network_mes_mode; averagesectionlen = totaltrackdistance / TRAK_LEN; - if (winner_mode || game_type == 2) // Reset car gear and pitch values for winner mode or wrecker races + if (winner_mode || + game_type == + 2) // Reset car gear and pitch values for winner mode or wrecker races { - for (int i = 0; i < numcars; i++) - { - Car[i].byGearAyMax = 0; - Car[i].iPitchDynamicOffset = 0; - } - //if (numcars > 0) { - // iCarLoopCounter = 0; - // iCarArraySize = 308 * numcars; - // do { - // iCarLoopCounter += 308; - // *((_BYTE *)&CarBox.hitboxAy[14][1].fX + iCarLoopCounter) = 0;// references adjacent data - // *(float *)((char *)&CarBox.hitboxAy[14][0].fZ + iCarLoopCounter) = 0.0;// references adjacent data - // } while (iCarLoopCounter < iCarArraySize); - //} + for (int i = 0; i < numcars; i++) { + Car[i].byGearAyMax = 0; + Car[i].iPitchDynamicOffset = 0; + } + // if (numcars > 0) { + // iCarLoopCounter = 0; + // iCarArraySize = 308 * numcars; + // do { + // iCarLoopCounter += 308; + // *((_BYTE *)&CarBox.hitboxAy[14][1].fX + iCarLoopCounter) = 0;// + // references adjacent data + // *(float *)((char *)&CarBox.hitboxAy[14][0].fZ + iCarLoopCounter) = + // 0.0;// references adjacent data + // } while (iCarLoopCounter < iCarArraySize); + // } race_started = -1; } @@ -1882,18 +1984,16 @@ void play_game_init() // These were loaded before the renderer existed, so the NULL-guarded // calls in graphics.c were skipped. if (texture_vga) - game_render_load_texture(g_pGameRenderer, texture_vga, 256, 0, - 0, gfx_size); + game_render_load_texture(g_pGameRenderer, texture_vga, 256, 0, 0, gfx_size); if (building_vga) - game_render_load_texture(g_pGameRenderer, building_vga, 256, 0, - 17, gfx_size); + game_render_load_texture(g_pGameRenderer, building_vga, 256, 0, 17, + gfx_size); if (cargen_vga) - game_render_load_texture(g_pGameRenderer, cargen_vga, 256, 0, - 18, gfx_size); + game_render_load_texture(g_pGameRenderer, cargen_vga, 256, 0, 18, gfx_size); for (int i = 0; i < 16; i++) { if (cartex_vga[i]) - game_render_load_texture(g_pGameRenderer, cartex_vga[i], 256, 0, - i + 1, gfx_size ? 1 : 0); + game_render_load_texture(g_pGameRenderer, cartex_vga[i], 256, 0, i + 1, + gfx_size ? 1 : 0); } // Register HUD sprite blocks (rev_vga) with the game renderer. @@ -1906,13 +2006,12 @@ void play_game_init() } //------------------------------------------------------------------------------------------------- -//00012930 -void play_game_uninit() -{ +// 00012930 +void play_game_uninit() { int iReplayType; // edx - int iView; // eax - //int iMaxOffset; // ebx - //unsigned int iOffset; // eax + int iView; // eax + // int iMaxOffset; // ebx + // unsigned int iOffset; // eax if (g_pGameRenderer) { game_render_destroy(g_pGameRenderer); @@ -1986,12 +2085,13 @@ void play_game_uninit() for (int i = 0; i < numcars; ++i) { non_competitors[i] = result_competing[i]; } - //iMaxOffset = 4 * numcars; - //iOffset = 0; - //do { - // iOffset += 4; - // TrackArrow_variable_1[iOffset / 4] = LODWORD(result_best[iOffset / 4 + 15]);// references adjacent data - //} while ((int)iOffset < iMaxOffset); + // iMaxOffset = 4 * numcars; + // iOffset = 0; + // do { + // iOffset += 4; + // TrackArrow_variable_1[iOffset / 4] = LODWORD(result_best[iOffset / 4 + // + 15]);// references adjacent data + // } while ((int)iOffset < iMaxOffset); } } else { SaveRecords(); @@ -2005,18 +2105,17 @@ void play_game_uninit() } //------------------------------------------------------------------------------------------------- -//00012B90 -void winner_race() -{ +// 00012B90 +void winner_race() { int iNumCars; // ecx - int iCarIdx; // eax - //int iArrayIdx; // edx + int iCarIdx; // eax + // int iArrayIdx; // edx int iWinnerCarIdx; // edx - int iRacers; // edx - int iPlayerType; // ebx - int iNumCars_1; // ecx - //int iMaxOffset; // ebx - //unsigned int uiOffset; // eax + int iRacers; // edx + int iPlayerType; // ebx + int iNumCars_1; // ecx + // int iMaxOffset; // ebx + // unsigned int uiOffset; // eax iNumCars = numcars; iCarIdx = 0; @@ -2025,13 +2124,13 @@ void winner_race() grid[i] = i; non_competitors[i] = -1; } - //if (numcars > 0) { - // iArrayIdx = 0; - // do { - // finished_car[++iArrayIdx + 15] = iCarIdx++; - // TrackArrow_variable_1[iArrayIdx] = -1; - // } while (iCarIdx < iNumCars); - //} + // if (numcars > 0) { + // iArrayIdx = 0; + // do { + // finished_car[++iArrayIdx + 15] = iCarIdx++; + // TrackArrow_variable_1[iArrayIdx] = -1; + // } while (iCarIdx < iNumCars); + // } iWinnerCarIdx = carorder[0]; winner_mode = -1; @@ -2069,40 +2168,40 @@ void winner_race() for (int i = 0; i < numcars; ++i) { non_competitors[i] = result_competing[i]; } - //if (numcars > 0) { - // iMaxOffset = 4 * numcars; - // uiOffset = 0; - // do { - // uiOffset += 4; - // TrackArrow_variable_1[uiOffset / 4] = LODWORD(result_best[uiOffset / 4 + 15]); - // } while ((int)uiOffset < iMaxOffset); - //} + // if (numcars > 0) { + // iMaxOffset = 4 * numcars; + // uiOffset = 0; + // do { + // uiOffset += 4; + // TrackArrow_variable_1[uiOffset / 4] = LODWORD(result_best[uiOffset / 4 + // + 15]); + // } while ((int)uiOffset < iMaxOffset); + // } numcars = iNumCars_1; } //------------------------------------------------------------------------------------------------- -//00012CE0 -void champion_race() -{ - //int iMaxOffset_1; // ebx - //unsigned int iOffset_1; // eax - int iRacer; // eax - int iNumRacers; // ecx - int iGridIdx; // ebx - int iCarIdx; // edx - int iRacers; // esi - int iCarIdx_1; // edx - int iOffset_2; // ecx +// 00012CE0 +void champion_race() { + // int iMaxOffset_1; // ebx + // unsigned int iOffset_1; // eax + int iRacer; // eax + int iNumRacers; // ecx + int iGridIdx; // ebx + int iCarIdx; // edx + int iRacers; // esi + int iCarIdx_1; // edx + int iOffset_2; // ecx int iMaxOffset_2; // edi - int j; // eax - int iOldRacers; // ebx - int iDriver; // edx - int iPlayerType; // edx - //unsigned int iOffset; // eax - //int iMaxOffset; // ebx + int j; // eax + int iOldRacers; // ebx + int iDriver; // edx + int iPlayerType; // edx + // unsigned int iOffset; // eax + // int iMaxOffset; // ebx int iTrackLoad; // [esp+0h] [ebp-20h] - int iTrack; // [esp+4h] [ebp-1Ch] + int iTrack; // [esp+4h] [ebp-1Ch] iTrackLoad = TrackLoad; champ_size = scr_size; @@ -2111,12 +2210,13 @@ void champion_race() for (int i = 0; i < numcars; ++i) { champorder[i] = result_order[i]; } - //iMaxOffset_1 = 4 * numcars; - //iOffset_1 = 0; - //do { - // iOffset_1 += 4; - // teamorder[iOffset_1 / 4 + 7] = result_lap[iOffset_1 / 4 + 15];// references adjacent data see above fixed loop - //} while ((int)iOffset_1 < iMaxOffset_1); + // iMaxOffset_1 = 4 * numcars; + // iOffset_1 = 0; + // do { + // iOffset_1 += 4; + // teamorder[iOffset_1 / 4 + 7] = result_lap[iOffset_1 / 4 + 15];// + // references adjacent data see above fixed loop + // } while ((int)iOffset_1 < iMaxOffset_1); } iTrack = champ_track[champorder[0] / 2]; @@ -2158,7 +2258,7 @@ void champion_race() SelectedView[0] = 8; iDriver = champorder[racers - 1]; - //iDriver = teamorder[racers + 7]; + // iDriver = teamorder[racers + 7]; champ_car = racers - 1; ViewType[0] = iDriver; @@ -2184,45 +2284,46 @@ void champion_race() for (int i = 0; i < numcars; ++i) { non_competitors[i] = result_competing[i]; } - //if (numcars > 0) { - // iOffset = 0; - // iMaxOffset = 4 * numcars; - // do { - // iOffset += 4; - // TrackArrow_variable_1[iOffset / 4] = LODWORD(result_best[iOffset / 4 + 15]);// references adjacent data see above fixed loop - // } while ((int)iOffset < iMaxOffset); - //} + // if (numcars > 0) { + // iOffset = 0; + // iMaxOffset = 4 * numcars; + // do { + // iOffset += 4; + // TrackArrow_variable_1[iOffset / 4] = LODWORD(result_best[iOffset / 4 + + // 15]);// references adjacent data see above fixed loop + // } while ((int)iOffset < iMaxOffset); + // } scr_size = champ_size; } //------------------------------------------------------------------------------------------------- -//00012EF0 -void play_game(int iTrack) -{ - int iNetTimeItr; // eax - int iNetTimeItr_1; // ecx - int16 nNetTimeItr_2; // bx - int iNetTimeItr_3; // eax +// 00012EF0 +void play_game(int iTrack) { + int iNetTimeItr; // eax + int iNetTimeItr_1; // ecx + int16 nNetTimeItr_2; // bx + int iNetTimeItr_3; // eax bool bShiftKeyPressed; // eax - int iSong; // eax + int iSong; // eax - //added by ROLLER + // added by ROLLER int iLastFrame = frames; - game_track = iTrack; // Initialize game state and track + game_track = iTrack; // Initialize game state and track lagdone = 0; I_Want_Out = 0; - play_game_init(); // Initialize game systems and memory tracking + play_game_init(); // Initialize game systems and memory tracking reset_net_wait(); max_mem = mem_used_low + mem_used; enable_keyboard(); pend_view_init = ViewType[0]; //_disable(); - network_limit = 4320; // Disable interrupts and setup network timing arrays + network_limit = 4320; // Disable interrupts and setup network timing arrays iNetTimeItr = 0; do { - iNetTimeItr_1 = (int16)iNetTimeItr++; // Initialize network timing array with current frame count + iNetTimeItr_1 = (int16)iNetTimeItr++; // Initialize network timing array + // with current frame count net_time[iNetTimeItr_1] = frames; } while ((int16)iNetTimeItr < 16); network_timeout = frames; @@ -2230,11 +2331,14 @@ void play_game(int iTrack) network_sync_error = 0; frontend_on = 0; //_enable(); - while (racing || lastsample > 0) // Main game loop - continues while racing or sound samples playing - { // Stop all sound samples if requested - - //added by ROLLER - ensure we get a frame update before next process - //TODO: figure out how this was handled originally + while ( + racing || + lastsample > + 0) // Main game loop - continues while racing or sound samples playing + { // Stop all sound samples if requested + + // added by ROLLER - ensure we get a frame update before next process + // TODO: figure out how this was handled originally if (g_bSnapshotMode) { // No SDL tick timer in snapshot mode: drive replay one tick per // iteration with no wall-clock pacing, and zero scrbuf so any @@ -2252,82 +2356,106 @@ void play_game(int iTrack) stopallsamples(); dostopsamps = 0; } - if (network_on) // Handle network game timing and synchronization - { // Set countdown for network games after frame 250 + if (network_on) // Handle network game timing and synchronization + { // Set countdown for network games after frame 250 if (frame_number >= 250) countdown = -75; - if (countdown == 144 && replaytype != 2 && fadedin)// Send ready signal when countdown reaches 144 (not in replay mode) + if (countdown == 144 && replaytype != 2 && + fadedin) // Send ready signal when countdown reaches 144 (not in + // replay mode) send_ready(); - if (network_limit == 4320 && countdown < 140)// Switch network timeout from 4320 to 360 frames when race starts + if (network_limit == 4320 && + countdown < 140) // Switch network timeout from 4320 to 360 frames + // when race starts { //_disable(); network_limit = 360; - for (nNetTimeItr_2 = 0; ; ++nNetTimeItr_2) { + for (nNetTimeItr_2 = 0;; ++nNetTimeItr_2) { iNetTimeItr_3 = nNetTimeItr_2; if (nNetTimeItr_2 >= network_on) break; - net_time[iNetTimeItr_3] = frames; // Update network timing array for all connected nodes + net_time[iNetTimeItr_3] = + frames; // Update network timing array for all connected nodes } network_timeout = frames; //_enable(); } } - if (player_type == 1 && (network_error || network_sync_error || cd_error))// Exit network game if errors occur in single player mode + if (player_type == 1 && + (network_error || network_sync_error || + cd_error)) // Exit network game if errors occur in single player mode racing = 0; - if (fadedin && !lagdone && (countdown < 140 || replaytype == 2))// Initialize sound lag compensation when race starts + if (fadedin && !lagdone && + (countdown < 140 || + replaytype == 2)) // Initialize sound lag compensation when race starts { initsoundlag(0); lagdone = -1; } - if (champ_mode < 16) // Handle game control vs fireworks display based on championship mode + if (champ_mode < 16) // Handle game control vs fireworks display based on + // championship mode control(); else firework_display(); - if (!replayspeed && intro && !game_req) // Exit replay if intro mode and no game requested + if (!replayspeed && intro && + !game_req) // Exit replay if intro mode and no game requested racing = replayspeed; - //removed by ROLLER, CD looping is handled in ROLLER code - //if (track_playing && frames - start_cd > 36 * track_duration / 75)// Handle CD audio track looping based on duration + // removed by ROLLER, CD looping is handled in ROLLER code + // if (track_playing && frames - start_cd > 36 * track_duration / 75)// + // Handle CD audio track looping based on duration //{ - // StopTrack(); - // RepeatTrack(); - // start_cd = frames; - //} - if (network_on && net_quit && !intro) // Handle network quit requests + // StopTrack(); + // RepeatTrack(); + // start_cd = frames; + // } + if (network_on && net_quit && !intro) // Handle network quit requests racing = 0; - if (player_type == 2) // Handle end-of-race conditions for different player modes - { // 2-player mode: end race when both cars dead and sound finished - if ((Car[player1_car].byLives & 0x80u) != 0 - && (Car[player2_car].byLives & 0x80u) != 0 - && lastsample < -72 - && readsample == writesample - && player_type != replaytype) { + if (player_type == + 2) // Handle end-of-race conditions for different player modes + { // 2-player mode: end race when both cars dead and sound finished + if ((Car[player1_car].byLives & 0x80u) != 0 && + (Car[player2_car].byLives & 0x80u) != 0 && lastsample < -72 && + readsample == writesample && player_type != replaytype) { racing = 0; } - } else if (!network_on && (Car[player1_car].byLives & 0x80u) != 0 && lastsample < -72 && readsample == writesample && replaytype != 2)// Single player: end race when car dead and sound finished + } else if (!network_on && (Car[player1_car].byLives & 0x80u) != 0 && + lastsample < -72 && readsample == writesample && + replaytype != 2) // Single player: end race when car dead and + // sound finished { racing = (unsigned int)writesample ^ readsample; } - if (winner_mode) // Handle winner celebration mode and championship fireworks + if (winner_mode) // Handle winner celebration mode and championship + // fireworks { if (winner_done && lastsample < -72 && readsample == writesample) { racing = 0; } else { racing = -1; if (champ_mode) { - if (champ_mode >= 16 && champ_zoom > 7 && champ_count < 0 && !winner_done) { + if (champ_mode >= 16 && champ_zoom > 7 && champ_count < 0 && + !winner_done) { // SOUND_SAMPLE_WON - speechsample(114, 0x8000, 18, player1_car);// Play victory sound sample (114) in championship mode + speechsample(114, 0x8000, 18, + player1_car); // Play victory sound sample (114) in + // championship mode winner_done = -1; } if (!winner_done && champ_mode == 2) { // SOUND_SAMPLE_WON - speechsample(114, 0x8000, 18, player1_car);// Play victory sound and advance championship mode + speechsample(114, 0x8000, 18, + player1_car); // Play victory sound and advance + // championship mode ++champ_mode; } - if (champ_mode == 3 && lastsample < -72 && readsample == writesample)// Initialize fireworks sequence with fade out/in + if (champ_mode == 3 && lastsample < -72 && + readsample == + writesample) // Initialize fireworks sequence with fade out/in { holdmusic = -1; - game_render_begin_fade(g_pGameRenderer, 0, 0); // writesample ^ readsample == 0 when readsample == writesample + game_render_begin_fade(g_pGameRenderer, 0, + 0); // writesample ^ readsample == 0 when + // readsample == writesample ++champ_mode; firework_screen(); game_render_begin_fade(g_pGameRenderer, 1, 0); @@ -2344,7 +2472,9 @@ void play_game(int iTrack) winy = 0; winh = YMAX; } - } else if (Car[ViewType[0]].byLap > 1 && !winner_done)// Play victory sound for regular race completion + } else if (Car[ViewType[0]].byLap > 1 && + !winner_done) // Play victory sound for regular race + // completion { // SOUND_SAMPLE_WON speechsample(114, 0x8000, 18, player1_car); @@ -2352,16 +2482,17 @@ void play_game(int iTrack) } } } - if (champ_mode < 16) // Update screen display (normal game or fireworks) + if (champ_mode < 16) // Update screen display (normal game or fireworks) updatescreen(); else firework_screen(); if (print_data) SDL_Log("\n\n"); print_data = 0; - if (pause_request && !intro) // Handle pause requests (excluding intro mode) + if (pause_request && !intro) // Handle pause requests (excluding intro mode) { - if (!pausewindow || !paused) { // Network pause handling - master/slave coordination + if (!pausewindow || + !paused) { // Network pause handling - master/slave coordination if (network_on && replaytype != 2) { if (wConsoleNode == master) { if (!finished_car[player1_car]) { @@ -2375,7 +2506,7 @@ void play_game(int iTrack) } else if (!finished_car[player1_car]) { send_pause(); } - } else { // Local pause handling - toggle game settings and calibration + } else { // Local pause handling - toggle game settings and calibration if (game_req) { clear_borders = -1; scr_size = req_size; @@ -2399,7 +2530,8 @@ void play_game(int iTrack) } pause_request = 0; } - if (network_on && slave_pause && wConsoleNode == master)// Handle slave pause requests in network games + if (network_on && slave_pause && + wConsoleNode == master) // Handle slave pause requests in network games { paused = paused == 0; if (paused) @@ -2415,7 +2547,9 @@ void play_game(int iTrack) else scr_size = 64; } - if (!racing && !winner_done && winner_mode)// Handle race end with victory sound if no winner celebration yet + if (!racing && !winner_done && + winner_mode) // Handle race end with victory sound if no winner + // celebration yet { // SOUND_SAMPLE_WON speechsample(114, 0x8000, 18, player1_car); @@ -2424,8 +2558,8 @@ void play_game(int iTrack) } bShiftKeyPressed = keys[WHIP_SCANCODE_LSHIFT] || keys[WHIP_SCANCODE_RSHIFT]; shifting = bShiftKeyPressed; - if (bShiftKeyPressed && keys[WHIP_SCANCODE_F7] || keys[WHIP_SCANCODE_RETURN] && controlicon == 8) - { + if (bShiftKeyPressed && keys[WHIP_SCANCODE_F7] || + keys[WHIP_SCANCODE_RETURN] && controlicon == 8) { if (shifting && keys[WHIP_SCANCODE_F7]) controlicon = 9; slowing = 0; @@ -2434,8 +2568,8 @@ void play_game(int iTrack) } else if (rewinding) { slowing = -1; } - if (shifting && keys[WHIP_SCANCODE_F8] || keys[WHIP_SCANCODE_RETURN] && controlicon == 10) - { + if (shifting && keys[WHIP_SCANCODE_F8] || + keys[WHIP_SCANCODE_RETURN] && controlicon == 10) { if (shifting && keys[WHIP_SCANCODE_F8]) controlicon = 9; slowing = 0; @@ -2444,13 +2578,14 @@ void play_game(int iTrack) } else if (forwarding) { slowing = -1; } - if (screenready) // Handle screen fade-in and music startup + if (screenready) // Handle screen fade-in and music startup { if (!fadedin) { game_render_begin_fade(g_pGameRenderer, 1, 0); fadedin = -1; holdmusic = 0; - if (w95) { // Start appropriate music track (title song for replay, game track for race) + if (w95) { // Start appropriate music track (title song for replay, game + // track for race) if (!MusicCD && !winner_mode && !loading_replay) { if (replaytype == 2) iSong = titlesong; @@ -2461,45 +2596,46 @@ void play_game(int iTrack) } } } - //NOCD error disabled for ROLLER - //if (!intro && replaytype != 2) // Handle CD-ROM validation for copy protection + // NOCD error disabled for ROLLER + // if (!intro && replaytype != 2) // Handle CD-ROM validation for + // copy protection //{ - // if (player_type && player_type != 2) { - // if (!cdchecked) { - // if (active_nodes == network_on) - // cdchecked = -1; - // if (wConsoleNode == master && !netCD && active_nodes == network_on) { - // send_nocd_error(); - // cd_error = -1; - // cdchecked = -1; - // } - // } - // } else if (!localCD) { - // racing = 0; - // cd_error = -1; - // } - //} - } - play_game_uninit(); // Clean up and uninitialize game systems + // if (player_type && player_type != 2) { + // if (!cdchecked) { + // if (active_nodes == network_on) + // cdchecked = -1; + // if (wConsoleNode == master && !netCD && active_nodes == network_on) + // { + // send_nocd_error(); + // cd_error = -1; + // cdchecked = -1; + // } + // } + // } else if (!localCD) { + // racing = 0; + // cd_error = -1; + // } + // } + } + play_game_uninit(); // Clean up and uninitialize game systems } //------------------------------------------------------------------------------------------------- -//00013A10 -void game_keys() -{ +// 00013A10 +void game_keys() { unsigned int uiKeyCode; // eax - int iExtendedKey; // eax - int iGameReqState; // eax - bool bToggleState; // zf - //uint32 uiTextureFlags1; // eax - //uint32 uiTextureFlags2; // eax - //uint32 uiTextureFlags3; // ecx - //uint32 uiTextureFlags4; // eax + int iExtendedKey; // eax + int iGameReqState; // eax + bool bToggleState; // zf + // uint32 uiTextureFlags1; // eax + // uint32 uiTextureFlags2; // eax + // uint32 uiTextureFlags3; // ecx + // uint32 uiTextureFlags4; // eax if (define_mode) - EXIT_FUNCTION: - return; - //JUMPOUT(0x1381B); + EXIT_FUNCTION: + return; + // JUMPOUT(0x1381B); while (1) { do { while (1) { @@ -2510,9 +2646,12 @@ void game_keys() UpdateSDL(); PROCESS_NEXT_KEY: if (!fatkbhit()) - goto EXIT_FUNCTION; // Check if a key is available in the keyboard buffer - uiKeyCode = fatgetch(); // Get the key code from the keyboard buffer - if (intro || winner_mode) // Handle intro/winner mode - any key exits these modes + goto EXIT_FUNCTION; // Check if a key is available in the + // keyboard buffer + uiKeyCode = + fatgetch(); // Get the key code from the keyboard buffer + if (intro || winner_mode) // Handle intro/winner mode - any key + // exits these modes { if (uiKeyCode) { uiKeyCode = -1; @@ -2522,9 +2661,10 @@ void game_keys() uiKeyCode = -1; } } - if (trying_to_exit) // Handle exit confirmation (Y/N prompt) + if (trying_to_exit) // Handle exit confirmation (Y/N prompt) { - if (uiKeyCode) { // Check for 'Y' or 'y' to confirm exit (ASCII 121='y', 89='Y') + if (uiKeyCode) { // Check for 'Y' or 'y' to confirm exit + // (ASCII 121='y', 89='Y') if (uiKeyCode == 121 || uiKeyCode == 89) { racing = 0; quit_game = -1; @@ -2539,301 +2679,325 @@ void game_keys() } if (uiKeyCode) break; - iExtendedKey = fatgetch(); // Process extended keys (arrow keys, function keys) - if (iExtendedKey != 75 && iExtendedKey != 77 && iExtendedKey != 72 && iExtendedKey != 80)// Check for arrow keys (75=Left, 77=Right, 72=Up, 80=Down) - { // Apply Shift modifier (keys[42]=LShift, keys[54]=RShift, adds 25) - if (keys[WHIP_SCANCODE_LSHIFT] || keys[WHIP_SCANCODE_RSHIFT]) { + iExtendedKey = fatgetch(); // Process extended keys (arrow keys, + // function keys) + if (iExtendedKey != 75 && iExtendedKey != 77 && + iExtendedKey != 72 && + iExtendedKey != 80) // Check for arrow keys (75=Left, + // 77=Right, 72=Up, 80=Down) + { // Apply Shift modifier (keys[42]=LShift, keys[54]=RShift, + // adds 25) + if (keys[WHIP_SCANCODE_LSHIFT] || + keys[WHIP_SCANCODE_RSHIFT]) { iExtendedKey += 25; - } else if (keys[WHIP_SCANCODE_LALT]) // Apply Alt modifier (keys[56]=Alt, adds 45) + } else if (keys[WHIP_SCANCODE_LALT]) // Apply Alt modifier + // (keys[56]=Alt, adds + // 45) { iExtendedKey += 45; } } switch (iExtendedKey) { - case WHIP_SCANCODE_F1: - if (network_on) // F1 (0x3B) - Network message controls / Replay car selection - mesminus(); - if (replaytype == 2) - carminus(); - break; - case WHIP_SCANCODE_F2: - if (network_on) // F2 (0x3C) - Network message controls / Replay car selection - mesplus(); - if (replaytype == 2) - carplus(); - break; - case WHIP_SCANCODE_F3: - if (view0_cnt < 0) // F3 (0x3D) - Previous view for player 1 - { - view0_cnt = 18; - viewminus(0); - } - break; - case WHIP_SCANCODE_F4: - if (view0_cnt < 0) // F4 (0x3E) - Next view for player 1 - { - view0_cnt = 18; - viewplus(0); - } - break; - case WHIP_SCANCODE_F7: - if (player_type == 2 && view1_cnt < 0) { - view1_cnt = 18; - viewminus(1); - } - break; - case WHIP_SCANCODE_F8: - if (player_type == 2 && view1_cnt < 0) { - view1_cnt = 18; - viewplus(1); + case WHIP_SCANCODE_F1: + if (network_on) // F1 (0x3B) - Network message controls / + // Replay car selection + mesminus(); + if (replaytype == 2) + carminus(); + break; + case WHIP_SCANCODE_F2: + if (network_on) // F2 (0x3C) - Network message controls / + // Replay car selection + mesplus(); + if (replaytype == 2) + carplus(); + break; + case WHIP_SCANCODE_F3: + if (view0_cnt < 0) // F3 (0x3D) - Previous view for player 1 + { + view0_cnt = 18; + viewminus(0); + } + break; + case WHIP_SCANCODE_F4: + if (view0_cnt < 0) // F4 (0x3E) - Next view for player 1 + { + view0_cnt = 18; + viewplus(0); + } + break; + case WHIP_SCANCODE_F7: + if (player_type == 2 && view1_cnt < 0) { + view1_cnt = 18; + viewminus(1); + } + break; + case WHIP_SCANCODE_F8: + if (player_type == 2 && view1_cnt < 0) { + view1_cnt = 18; + viewplus(1); + } + break; + case WHIP_SCANCODE_F9: + if (++names_on > 2) // F9 (0x43) - Toggle player names display + // (0=off, 1=on, 2=detailed) + names_on = 0; + break; + case WHIP_SCANCODE_F10: + if (I_Would_Like_To_Quit && + Quit_Count <= + 0) // F10 (0x44) - Quit game (if quit sequence active) + { + I_Want_Out = -1; + stopallsamples(); + } + break; + case WHIP_SCANCODE_F12: + showversion = + showversion == 0; // F12 (0x46) - Toggle version display + break; + case WHIP_SCANCODE_UP: + if (game_req) { + if (!pausewindow && req_edit > 0) + --req_edit; + if (pausewindow == 1 && !calibrate_mode && + calibrate_select < pausewindow) + calibrate_select += pausewindow; + if (pausewindow == 2 && control_select < 2) + ++control_select; + if (pausewindow == 3 && graphic_mode < 16) + ++graphic_mode; + if (pausewindow == 4) { + if (sound_edit <= 1) { + if (!sound_edit) + sound_edit = 7; + } else { + --sound_edit; + } } - break; - case WHIP_SCANCODE_F9: - if (++names_on > 2) // F9 (0x43) - Toggle player names display (0=off, 1=on, 2=detailed) - names_on = 0; - break; - case WHIP_SCANCODE_F10: - if (I_Would_Like_To_Quit && Quit_Count <= 0)// F10 (0x44) - Quit game (if quit sequence active) - { - I_Want_Out = -1; - stopallsamples(); + } else if (replaytype == 2 && game_req != replaypanel) { + switch (game_req + controlicon) { + case 7: + case 8: + case 15: + case 16: + case 17: + controlicon -= 6; + break; + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + controlicon -= 5; + break; + default: + continue; } - break; - case WHIP_SCANCODE_F12: - showversion = showversion == 0;// F12 (0x46) - Toggle version display - break; - case WHIP_SCANCODE_UP: - if (game_req) { - if (!pausewindow && req_edit > 0) - --req_edit; - if (pausewindow == 1 && !calibrate_mode && calibrate_select < pausewindow) - calibrate_select += pausewindow; - if (pausewindow == 2 && control_select < 2) - ++control_select; - if (pausewindow == 3 && graphic_mode < 16) - ++graphic_mode; - if (pausewindow == 4) { - if (sound_edit <= 1) { - if (!sound_edit) - sound_edit = 7; - } else { - --sound_edit; - } - } - } else if (replaytype == 2 && game_req != replaypanel) { - switch (game_req + controlicon) { - case 7: - case 8: - case 15: - case 16: - case 17: - controlicon -= 6; - break; - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - controlicon -= 5; - break; - default: - continue; + } + break; + case WHIP_SCANCODE_LEFT: + if (game_req) { + if (pausewindow == 4) { + switch (sound_edit) { + case 1: + EngineVolume -= + pausewindow; // Left Arrow - Decrease Engine Volume + if (EngineVolume < 0) + EngineVolume = 0; + continue; + case 2: + SFXVolume -= + pausewindow; // Left Arrow - Decrease SFX Volume + if (SFXVolume < 0) + SFXVolume = 0; + continue; + case 3: + SpeechVolume -= + pausewindow; // Left Arrow - Decrease Speech Volume + if (SpeechVolume < 0) + SpeechVolume = 0; + continue; + case 4: + MusicVolume -= + pausewindow; // Left Arrow - Decrease Music Volume + if (MusicVolume < 0) + MusicVolume = 0; + if (MusicCard) + MIDISetMasterVolume(MusicVolume); + // sosMIDISetMasterVolume(MusicVolume); + if (MusicCD) + goto UPDATE_CD_VOLUME; + continue; + default: + continue; } } - break; - case WHIP_SCANCODE_LEFT: - if (game_req) { - if (pausewindow == 4) { - switch (sound_edit) { - case 1: - EngineVolume -= pausewindow;// Left Arrow - Decrease Engine Volume - if (EngineVolume < 0) - EngineVolume = 0; - continue; - case 2: - SFXVolume -= pausewindow;// Left Arrow - Decrease SFX Volume - if (SFXVolume < 0) - SFXVolume = 0; - continue; - case 3: - SpeechVolume -= pausewindow;// Left Arrow - Decrease Speech Volume - if (SpeechVolume < 0) - SpeechVolume = 0; - continue; - case 4: - MusicVolume -= pausewindow;// Left Arrow - Decrease Music Volume - if (MusicVolume < 0) - MusicVolume = 0; - if (MusicCard) - MIDISetMasterVolume(MusicVolume); - //sosMIDISetMasterVolume(MusicVolume); - if (MusicCD) - goto UPDATE_CD_VOLUME; - continue; - default: - continue; - } + } else if (replaytype == 2 && game_req != replaypanel && + controlicon != 1 && controlicon != 7 && + controlicon != 12) { + --controlicon; + } + break; + case WHIP_SCANCODE_RIGHT: + iGameReqState = game_req; + if (game_req) { + if (pausewindow == 4) { + switch (sound_edit) { + case 1: + EngineVolume += 4; + if (EngineVolume >= 128) + EngineVolume = 127; + break; + case 2: + SFXVolume += pausewindow; + if (SFXVolume >= 128) + SFXVolume = 127; + break; + case 3: + SpeechVolume += pausewindow; + if (SpeechVolume >= 128) + SpeechVolume = 127; + break; + case 4: + MusicVolume += pausewindow; + if (MusicVolume >= 128) + MusicVolume = 127; + if (MusicCard) + MIDISetMasterVolume(MusicVolume); + // sosMIDISetMasterVolume(MusicVolume); + if (MusicCD) + UPDATE_CD_VOLUME: + SetAudioVolume(MusicVolume); + break; + default: + continue; } - } else if (replaytype == 2 && game_req != replaypanel && controlicon != 1 && controlicon != 7 && controlicon != 12) { - --controlicon; } - break; - case WHIP_SCANCODE_RIGHT: - iGameReqState = game_req; - if (game_req) { - if (pausewindow == 4) { - switch (sound_edit) { - case 1: - EngineVolume += 4; - if (EngineVolume >= 128) - EngineVolume = 127; - break; - case 2: - SFXVolume += pausewindow; - if (SFXVolume >= 128) - SFXVolume = 127; - break; - case 3: - SpeechVolume += pausewindow; - if (SpeechVolume >= 128) - SpeechVolume = 127; - break; - case 4: - MusicVolume += pausewindow; - if (MusicVolume >= 128) - MusicVolume = 127; - if (MusicCard) - MIDISetMasterVolume(MusicVolume); - //sosMIDISetMasterVolume(MusicVolume); - if (MusicCD) - UPDATE_CD_VOLUME: - SetAudioVolume(MusicVolume); - break; - default: - continue; - } - } - } else if (replaytype == 2 && game_req != replaypanel && controlicon != 6 && controlicon != 11 && controlicon != 25) { - if (controlicon != 17 || game_req != replayedit) - iGameReqState = 1; - if (iGameReqState) - ++controlicon; + } else if (replaytype == 2 && game_req != replaypanel && + controlicon != 6 && controlicon != 11 && + controlicon != 25) { + if (controlicon != 17 || game_req != replayedit) + iGameReqState = 1; + if (iGameReqState) + ++controlicon; + } + break; + case WHIP_SCANCODE_DOWN: + if (game_req) { + if (!pausewindow && req_edit < 6) + ++req_edit; + if (pausewindow == 1 && calibrate_select > 0 && + !calibrate_mode) + calibrate_select -= pausewindow; + if (pausewindow == 2 && control_select > 0) + --control_select; + if (pausewindow == 3 && graphic_mode > 0) + --graphic_mode; + if (pausewindow == 4 && sound_edit > 0) { + if (sound_edit >= 7) + sound_edit = 0; + else + ++sound_edit; } - break; - case WHIP_SCANCODE_DOWN: - if (game_req) { - if (!pausewindow && req_edit < 6) - ++req_edit; - if (pausewindow == 1 && calibrate_select > 0 && !calibrate_mode) - calibrate_select -= pausewindow; - if (pausewindow == 2 && control_select > 0) - --control_select; - if (pausewindow == 3 && graphic_mode > 0) - --graphic_mode; - if (pausewindow == 4 && sound_edit > 0) { - if (sound_edit >= 7) - sound_edit = 0; - else - ++sound_edit; - } - } else if (replaytype == 2 && game_req != replaypanel) { - switch (controlicon) { - case 1: - case 2: - case 3: - case 9: - case 10: - case 11: - controlicon += 6; - break; - case 4: - case 5: - case 6: - case 7: - case 8: - controlicon += 5; - break; - default: - continue; - } + } else if (replaytype == 2 && game_req != replaypanel) { + switch (controlicon) { + case 1: + case 2: + case 3: + case 9: + case 10: + case 11: + controlicon += 6; + break; + case 4: + case 5: + case 6: + case 7: + case 8: + controlicon += 5; + break; + default: + continue; } - break; - case 0x54: - controlicon = 9; - Rreverseplay(); - break; - case 0x55: - controlicon = 9; - Rplay(); - break; - case 0x56: - controlicon = 9; - Rspeedminus(); - break; - case 0x57: - controlicon = 9; - Rspeedplus(); - break; - case 0x58: - controlicon = 9; - Rframeminus(); - break; - case 0x59: - controlicon = 9; - Rframeplus(); - break; - case 0x5C: - controlicon = 9; - Rstart(); - break; - case 0x5D: - controlicon = 9; - Rend(); - break; - case 0x68: - controlicon = 9; - rtoggleedit(); - break; - case 0x69: - controlicon = 9; - rstartblock(); - break; - case 0x6A: - controlicon = 9; - rselectblock(); - break; - case 0x6B: - controlicon = 9; - rdeleteblock(); - break; - case 0x6C: - controlicon = 9; - rstoreview(); - break; - case 0x6D: - controlicon = 9; - rremoveview(); - break; - case 0x6E: - controlicon = 9; - rpreviouscut(); - break; - case 0x6F: - controlicon = 9; - rnextcut(); - break; - case 0x70: - controlicon = 9; - rstartassemble(); - break; - default: - continue; + } + break; + case 0x54: + controlicon = 9; + Rreverseplay(); + break; + case 0x55: + controlicon = 9; + Rplay(); + break; + case 0x56: + controlicon = 9; + Rspeedminus(); + break; + case 0x57: + controlicon = 9; + Rspeedplus(); + break; + case 0x58: + controlicon = 9; + Rframeminus(); + break; + case 0x59: + controlicon = 9; + Rframeplus(); + break; + case 0x5C: + controlicon = 9; + Rstart(); + break; + case 0x5D: + controlicon = 9; + Rend(); + break; + case 0x68: + controlicon = 9; + rtoggleedit(); + break; + case 0x69: + controlicon = 9; + rstartblock(); + break; + case 0x6A: + controlicon = 9; + rselectblock(); + break; + case 0x6B: + controlicon = 9; + rdeleteblock(); + break; + case 0x6C: + controlicon = 9; + rstoreview(); + break; + case 0x6D: + controlicon = 9; + rremoveview(); + break; + case 0x6E: + controlicon = 9; + rpreviouscut(); + break; + case 0x6F: + controlicon = 9; + rnextcut(); + break; + case 0x70: + controlicon = 9; + rstartassemble(); + break; + default: + continue; } } if (uiKeyCode < 0x2D) break; - if (uiKeyCode <= 0x2D) { // '-' key (0x2D) - Decrease screen size + if (uiKeyCode <= 0x2D) { // '-' key (0x2D) - Decrease screen size DECREASE_SCREEN_SIZE: if (replaytype != 2) { if (game_req) { @@ -2856,15 +3020,16 @@ void game_keys() } else { scr_size -= 8; if (scr_size >= 32) - SET_CLEAR_BORDERS: - clear_borders = -1; + SET_CLEAR_BORDERS: + clear_borders = -1; else scr_size = 32; } } } else if (uiKeyCode < 0x4C) { if (uiKeyCode >= 0x3D) { - if (uiKeyCode <= 0x3D) { // '+' key (0x3D) - Increase screen size + if (uiKeyCode <= + 0x3D) { // '+' key (0x3D) - Increase screen size INCREASE_SCREEN_SIZE: if (replaytype != 2) { if (game_req) { @@ -2925,7 +3090,7 @@ void game_keys() } if (uiKeyCode < 0x1B) break; - if (uiKeyCode <= 0x1B) { // Escape key - Exit pause menus + if (uiKeyCode <= 0x1B) { // Escape key - Exit pause menus if (game_req && pausewindow) { if (pausewindow == 1 || pausewindow == 2) remove_uncalibrated(); @@ -2961,233 +3126,238 @@ void game_keys() if (!game_req) break; switch (pausewindow) { + case 0: + switch (req_edit) { case 0: - switch (req_edit) { - case 0: - goto REQUEST_PAUSE; - case 1: - paused = 0; - racing = 0; - gave_up = -1; - scr_size = req_size; - goto PROCESS_NEXT_KEY; - case 2: - sound_edit = 0; - pausewindow = 4; - goto PROCESS_NEXT_KEY; - case 3: - calibrate_select = 0; - calibrate_mode = 0; - pausewindow = 1; - goto PROCESS_NEXT_KEY; - case 4: - pausewindow = 2; - Joy1used = 0; - Joy2used = 0; - controlrelease = -1; - define_mode = 0; - control_select = 0; - control_edit = -1; - goto PROCESS_NEXT_KEY; - case 5: - graphic_mode = 0; - pausewindow = 3; - goto PROCESS_NEXT_KEY; - case 6: - trying_to_exit = -1; - goto PROCESS_NEXT_KEY; - default: - goto PROCESS_NEXT_KEY; + goto REQUEST_PAUSE; + case 1: + paused = 0; + racing = 0; + gave_up = -1; + scr_size = req_size; + goto PROCESS_NEXT_KEY; + case 2: + sound_edit = 0; + pausewindow = 4; + goto PROCESS_NEXT_KEY; + case 3: + calibrate_select = 0; + calibrate_mode = 0; + pausewindow = 1; + goto PROCESS_NEXT_KEY; + case 4: + pausewindow = 2; + Joy1used = 0; + Joy2used = 0; + controlrelease = -1; + define_mode = 0; + control_select = 0; + control_edit = -1; + goto PROCESS_NEXT_KEY; + case 5: + graphic_mode = 0; + pausewindow = 3; + goto PROCESS_NEXT_KEY; + case 6: + trying_to_exit = -1; + goto PROCESS_NEXT_KEY; + default: + goto PROCESS_NEXT_KEY; + } + case 1: + if (calibrate_select) { + if (calibrate_select == 1) { + bToggleState = calibrate_mode != 0; + calibrate_mode = calibrate_mode == 0; + if (bToggleState) + remove_uncalibrated(); + else + check_joystickpresence(); } + } else { + pausewindow = 0; + remove_uncalibrated(); + check_joystick_usage(); + calibrate_mode = 0; + } + break; + case 2: + if (control_select) { + if ((unsigned int)control_select <= 1) { + define_mode = -1; + control_edit = 0; + disable_keyboard(); + controlrelease = -1; + memcpy(oldkeys, userkey, 0xCu); + memcpy(&oldkeys[12], &userkey[12], 2u); + } else if (control_select == 2) { + define_mode = -1; + control_edit = 6; + disable_keyboard(); + controlrelease = -1; + memcpy(oldkeys, userkey, 0xCu); + memcpy(&oldkeys[12], &userkey[12], 2u); + } + } else { + EXIT_PAUSE_MENU: + pausewindow = 0; + } + break; + case 3: + switch (graphic_mode) { + case 0: + goto EXIT_PAUSE_MENU; case 1: - if (calibrate_select) { - if (calibrate_select == 1) { - bToggleState = calibrate_mode != 0; - calibrate_mode = calibrate_mode == 0; - if (bToggleState) - remove_uncalibrated(); - else - check_joystickpresence(); - } - } else { - pausewindow = 0; - remove_uncalibrated(); - check_joystick_usage(); - calibrate_mode = 0; + if (svga_possible && !no_mem || SVGA_ON) { + SVGA_ON = SVGA_ON == 0; + init_screen(); + req_size = scr_size; } - break; + goto PROCESS_NEXT_KEY; case 2: - if (control_select) { - if ((unsigned int)control_select <= 1) { - define_mode = -1; - control_edit = 0; - disable_keyboard(); - controlrelease = -1; - memcpy(oldkeys, userkey, 0xCu); - memcpy(&oldkeys[12], &userkey[12], 2u); - } else if (control_select == 2) { - define_mode = -1; - control_edit = 6; - disable_keyboard(); - controlrelease = -1; - memcpy(oldkeys, userkey, 0xCu); - memcpy(&oldkeys[12], &userkey[12], 2u); + if (replaytype != 2) { + if (SVGA_ON) { + req_size += 16; + if (req_size > 128) + req_size = 64; + if (req_size == 128) + replaypanel = -1; + } else { + req_size += 8; + if (req_size > 64) + req_size = 32; + if (req_size == 64) + replaypanel = -1; } - } else { - EXIT_PAUSE_MENU: - pausewindow = 0; } - break; + goto PROCESS_NEXT_KEY; case 3: - switch (graphic_mode) { - case 0: - goto EXIT_PAUSE_MENU; - case 1: - if (svga_possible && !no_mem || SVGA_ON) { - SVGA_ON = SVGA_ON == 0; - init_screen(); - req_size = scr_size; - } - goto PROCESS_NEXT_KEY; - case 2: - if (replaytype != 2) { - if (SVGA_ON) { - req_size += 16; - if (req_size > 128) - req_size = 64; - if (req_size == 128) - replaypanel = -1; - } else { - req_size += 8; - if (req_size > 64) - req_size = 32; - if (req_size == 64) - replaypanel = -1; - } - } - goto PROCESS_NEXT_KEY; - case 3: - if (view_limit) { - view_limit = 0; - } else if (machine_speed >= 2800) { - view_limit = 32; - } else { - view_limit = 24; - } - goto PROCESS_NEXT_KEY; - case 4: - // 0x20 = TEX_OFF_PANEL_OFF - if ((textures_off & TEX_OFF_PANEL_OFF) != 0)// Panel textures toggle: 0x20=TEX_OFF_PANEL_OFF, 0x40000=TEX_OFF_PANEL_RESTRICTED - { - //uiTextureFlags1 = textures_off; - //LOBYTE(uiTextureFlags1) = textures_off ^ 0x20; - //textures_off = uiTextureFlags1 | 0x40000; - textures_off ^= TEX_OFF_PANEL_OFF; - textures_off |= TEX_OFF_PANEL_RESTRICTED; - } - // 0x40000 = TEX_OFF_PANEL_RESTRICTED - else if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) { - textures_off ^= TEX_OFF_PANEL_RESTRICTED; - } else { - textures_off |= TEX_OFF_PANEL_OFF; - } - goto PROCESS_NEXT_KEY; - case 5: - // 0x8 = TEX_OFF_CLOUDS - textures_off ^= TEX_OFF_CLOUDS; // Toggle clouds textures (0x8 = TEX_OFF_CLOUDS) - goto PROCESS_NEXT_KEY; - case 6: - // 0x100 = TEX_OFF_SHADOWS - textures_off ^= TEX_OFF_SHADOWS; // Toggle shadows (0x100 = TEX_OFF_SHADOWS) - goto PROCESS_NEXT_KEY; - case 7: - // 0x2 = TEX_OFF_ROAD_TEXTURES - textures_off ^= TEX_OFF_ROAD_TEXTURES; - goto PROCESS_NEXT_KEY; - case 8: - // 0x80 = TEX_OFF_BUILDING_TEXTURES - //uiTextureFlags2 = textures_off; - //LOBYTE(uiTextureFlags2) = textures_off ^ 0x80; - //textures_off = uiTextureFlags2; - textures_off ^= TEX_OFF_BUILDING_TEXTURES; - goto PROCESS_NEXT_KEY; - case 9: - // 0x1 = TEX_OFF_GROUND_TEXTURES - textures_off ^= TEX_OFF_GROUND_TEXTURES; - goto PROCESS_NEXT_KEY; - case 10: - // 0x4 = TEX_OFF_WALL_TEXTURES - textures_off ^= TEX_OFF_WALL_TEXTURES; - goto PROCESS_NEXT_KEY; - case 11: - //uiTextureFlags3 = textures_off; - //// 0x40 = TEX_OFF_CAR_TEXTURES - //LOBYTE(uiTextureFlags3) = textures_off ^ 0x40; - //textures_off = uiTextureFlags3; - textures_off ^= TEX_OFF_CAR_TEXTURES; - goto PROCESS_NEXT_KEY; - case 12: - //uiTextureFlags4 = textures_off; - //// 0x10 = TEX_OFF_HORIZON - //LOBYTE(uiTextureFlags4) = textures_off ^ 0x10; - //textures_off = uiTextureFlags4; - textures_off ^= TEX_OFF_HORIZON; - goto PROCESS_NEXT_KEY; - case 13: - // 0x800 = TEX_OFF_GLASS_WALLS - textures_off ^= TEX_OFF_GLASS_WALLS; - goto PROCESS_NEXT_KEY; - case 14: - // 0x200 = TEX_OFF_BUILDINGS - textures_off ^= TEX_OFF_BUILDINGS; - goto PROCESS_NEXT_KEY; - case 15: - if (++names_on > 2) - names_on = 0; - goto PROCESS_NEXT_KEY; - case 16: - // 0x80000 = TEX_OFF_PERSPECTIVE_CORRECTION - textures_off ^= TEX_OFF_PERSPECTIVE_CORRECTION; - goto PROCESS_NEXT_KEY; - default: - goto PROCESS_NEXT_KEY; + if (view_limit) { + view_limit = 0; + } else if (machine_speed >= 2800) { + view_limit = 32; + } else { + view_limit = 24; } + goto PROCESS_NEXT_KEY; case 4: - switch (sound_edit) { - case 0: - goto EXIT_PAUSE_MENU; - case 5: - allengines = allengines == 0; - goto PROCESS_NEXT_KEY; - case 6: - if (SoundCard) { - bToggleState = soundon != 0; - soundon = soundon == 0; - if (!bToggleState) - loadsamples(); - } else { - soundon = 0; - } - goto PROCESS_NEXT_KEY; - case 7: - if (MusicCard || MusicCD) { - musicon = musicon == 0; - reinitmusic(); - } else { - musicon = 0; - } - goto PROCESS_NEXT_KEY; - default: - goto PROCESS_NEXT_KEY; + // 0x20 = TEX_OFF_PANEL_OFF + if ((textures_off & TEX_OFF_PANEL_OFF) != + 0) // Panel textures toggle: 0x20=TEX_OFF_PANEL_OFF, + // 0x40000=TEX_OFF_PANEL_RESTRICTED + { + // uiTextureFlags1 = textures_off; + // LOBYTE(uiTextureFlags1) = textures_off ^ 0x20; + // textures_off = uiTextureFlags1 | 0x40000; + textures_off ^= TEX_OFF_PANEL_OFF; + textures_off |= TEX_OFF_PANEL_RESTRICTED; + } + // 0x40000 = TEX_OFF_PANEL_RESTRICTED + else if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) { + textures_off ^= TEX_OFF_PANEL_RESTRICTED; + } else { + textures_off |= TEX_OFF_PANEL_OFF; + } + goto PROCESS_NEXT_KEY; + case 5: + // 0x8 = TEX_OFF_CLOUDS + textures_off ^= + TEX_OFF_CLOUDS; // Toggle clouds textures (0x8 = TEX_OFF_CLOUDS) + goto PROCESS_NEXT_KEY; + case 6: + // 0x100 = TEX_OFF_SHADOWS + textures_off ^= + TEX_OFF_SHADOWS; // Toggle shadows (0x100 = TEX_OFF_SHADOWS) + goto PROCESS_NEXT_KEY; + case 7: + // 0x2 = TEX_OFF_ROAD_TEXTURES + textures_off ^= TEX_OFF_ROAD_TEXTURES; + goto PROCESS_NEXT_KEY; + case 8: + // 0x80 = TEX_OFF_BUILDING_TEXTURES + // uiTextureFlags2 = textures_off; + // LOBYTE(uiTextureFlags2) = textures_off ^ 0x80; + // textures_off = uiTextureFlags2; + textures_off ^= TEX_OFF_BUILDING_TEXTURES; + goto PROCESS_NEXT_KEY; + case 9: + // 0x1 = TEX_OFF_GROUND_TEXTURES + textures_off ^= TEX_OFF_GROUND_TEXTURES; + goto PROCESS_NEXT_KEY; + case 10: + // 0x4 = TEX_OFF_WALL_TEXTURES + textures_off ^= TEX_OFF_WALL_TEXTURES; + goto PROCESS_NEXT_KEY; + case 11: + // uiTextureFlags3 = textures_off; + //// 0x40 = TEX_OFF_CAR_TEXTURES + // LOBYTE(uiTextureFlags3) = textures_off ^ 0x40; + // textures_off = uiTextureFlags3; + textures_off ^= TEX_OFF_CAR_TEXTURES; + goto PROCESS_NEXT_KEY; + case 12: + // uiTextureFlags4 = textures_off; + //// 0x10 = TEX_OFF_HORIZON + // LOBYTE(uiTextureFlags4) = textures_off ^ 0x10; + // textures_off = uiTextureFlags4; + textures_off ^= TEX_OFF_HORIZON; + goto PROCESS_NEXT_KEY; + case 13: + // 0x800 = TEX_OFF_GLASS_WALLS + textures_off ^= TEX_OFF_GLASS_WALLS; + goto PROCESS_NEXT_KEY; + case 14: + // 0x200 = TEX_OFF_BUILDINGS + textures_off ^= TEX_OFF_BUILDINGS; + goto PROCESS_NEXT_KEY; + case 15: + if (++names_on > 2) + names_on = 0; + goto PROCESS_NEXT_KEY; + case 16: + // 0x80000 = TEX_OFF_PERSPECTIVE_CORRECTION + textures_off ^= TEX_OFF_PERSPECTIVE_CORRECTION; + goto PROCESS_NEXT_KEY; + default: + goto PROCESS_NEXT_KEY; + } + case 4: + switch (sound_edit) { + case 0: + goto EXIT_PAUSE_MENU; + case 5: + allengines = allengines == 0; + goto PROCESS_NEXT_KEY; + case 6: + if (SoundCard) { + bToggleState = soundon != 0; + soundon = soundon == 0; + if (!bToggleState) + loadsamples(); + } else { + soundon = 0; + } + goto PROCESS_NEXT_KEY; + case 7: + if (MusicCard || MusicCD) { + musicon = musicon == 0; + reinitmusic(); + } else { + musicon = 0; } + goto PROCESS_NEXT_KEY; default: goto PROCESS_NEXT_KEY; + } + default: + goto PROCESS_NEXT_KEY; } } - } while (replaytype != 2 || game_req == replaypanel && controlicon != 9 || !ricon[controlicon].pFunc); + } while (replaytype != 2 || game_req == replaypanel && controlicon != 9 || + !ricon[controlicon].pFunc); if ((unsigned int)controlicon < 0xE) { EXECUTE_REPLAY_FN: - //TODO + // TODO ((void (*)(void))ricon[controlicon].pFunc)(); } else if ((unsigned int)controlicon <= 0xE) { viewminus(0); @@ -3200,12 +3370,11 @@ void game_keys() } //------------------------------------------------------------------------------------------------- -//00014B80 -void mesminus() -{ - int iNewMesMode; // ecx +// 00014B80 +void mesminus() { + int iNewMesMode; // ecx int iMesModeMinus; // eax - int iMesModeComp; // edx + int iMesModeComp; // edx iNewMesMode = network_mes_mode; iMesModeMinus = network_mes_mode; @@ -3213,7 +3382,8 @@ void mesminus() do { if (iMesModeMinus < 0) iMesModeMinus = numcars; - if (--iMesModeMinus == team_mate || iMesModeMinus < 0 && players > 2 || human_control[iMesModeMinus] && iMesModeMinus != player1_car) { + if (--iMesModeMinus == team_mate || iMesModeMinus < 0 && players > 2 || + human_control[iMesModeMinus] && iMesModeMinus != player1_car) { iMesModeComp = -666; iNewMesMode = iMesModeMinus; } @@ -3222,10 +3392,9 @@ void mesminus() } //------------------------------------------------------------------------------------------------- -//00014BF0 -void mesplus() -{ - int iNewMesMode; // ecx +// 00014BF0 +void mesplus() { + int iNewMesMode; // ecx int iMesModePlus; // eax int iMesModeComp; // edx @@ -3235,7 +3404,8 @@ void mesplus() do { if (++iMesModePlus >= numcars) iMesModePlus = -1; - if (iMesModePlus == team_mate || iMesModePlus < 0 && players > 2 || human_control[iMesModePlus] && iMesModePlus != player1_car) { + if (iMesModePlus == team_mate || iMesModePlus < 0 && players > 2 || + human_control[iMesModePlus] && iMesModePlus != player1_car) { iMesModeComp = -666; iNewMesMode = iMesModePlus; } @@ -3244,9 +3414,8 @@ void mesplus() } //------------------------------------------------------------------------------------------------- -//00014C60 -void carminus() -{ +// 00014C60 +void carminus() { do { if (--ViewType[0] < 0) ViewType[0] = numcars - 1; @@ -3255,13 +3424,12 @@ void carminus() doteaminit(); else initcarview(ViewType[0], 0); - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } //------------------------------------------------------------------------------------------------- -//00014CD0 -void carplus() -{ +// 00014CD0 +void carplus() { do { if (++ViewType[0] >= numcars) ViewType[0] = 0; @@ -3270,26 +3438,26 @@ void carplus() doteaminit(); else initcarview(ViewType[0], 0); - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } //------------------------------------------------------------------------------------------------- -//00014D50 -void viewminus(int iPlayer) -{ - int iPlayerIndex; // eax - int iViewIndex; // edx - int iPrevView; // ebx - int iOtherPlayer; // ebx - int iPrevViewSingle; // edi +// 00014D50 +void viewminus(int iPlayer) { + int iPlayerIndex; // eax + int iViewIndex; // edx + int iPrevView; // ebx + int iOtherPlayer; // ebx + int iPrevViewSingle; // edi int iOtherPlayerSingle; // ebx - int iPrevViewDuo; // esi + int iPrevViewDuo; // esi iPlayerIndex = iPlayer; - iViewIndex = iPlayer; // Check if we're in replay mode (replaytype == 2) + iViewIndex = iPlayer; // Check if we're in replay mode (replaytype == 2) if (replaytype != 2) { if ((Car[ViewType[iPlayerIndex]].byStatusFlags & 4) != 0) - return; // Don't change view if current car is active (bit 2 set in status flags) + return; // Don't change view if current car is active (bit 2 set in status + // flags) if (player_type == 2) { do { iPrevViewDuo = SelectedView[iViewIndex] - 1; @@ -3298,15 +3466,20 @@ void viewminus(int iPlayer) // Wrap around to view 8 if we've gone below view 0 if (iPrevViewDuo < 0) SelectedView[iViewIndex] = 8; - } while (!DuoViews[SelectedView[iViewIndex]]);// Two-player mode: cycle backwards through views allowed for duo play + } while (!DuoViews[SelectedView[iViewIndex]]); // Two-player mode: cycle + // backwards through views + // allowed for duo play } else { do { // Single player mode: cycle backwards through allowed views iPrevViewSingle = SelectedView[iViewIndex] - 1; SelectedView[iViewIndex] = iPrevViewSingle; if (iPrevViewSingle == 7) { - iOtherPlayerSingle = (ViewType[iPlayerIndex] & 1) != 0 ? ViewType[iPlayerIndex] - 1 : ViewType[iPlayerIndex] + 1; - // View 7 special case: check if other player's car is dead (bit 7 set) + iOtherPlayerSingle = (ViewType[iPlayerIndex] & 1) != 0 + ? ViewType[iPlayerIndex] - 1 + : ViewType[iPlayerIndex] + 1; + // View 7 special case: check if other player's car is dead (bit 7 + // set) if ((Car[iOtherPlayerSingle].byLives & 0x80u) != 0) --SelectedView[iViewIndex]; } @@ -3318,7 +3491,7 @@ void viewminus(int iPlayer) if (Play_View != 1) goto INIT_CAR_VIEW; INIT_TEAM_VIEW: - // If team view (Play_View == 1), initialize team display + // If team view (Play_View == 1), initialize team display doteaminit(); goto PLAY_BUTTON_SOUND; } @@ -3327,7 +3500,9 @@ void viewminus(int iPlayer) iPrevView = SelectedView[iViewIndex] - 1; SelectedView[iViewIndex] = iPrevView; if (iPrevView == 7) { - iOtherPlayer = (ViewType[iPlayerIndex] & 1) != 0 ? ViewType[iPlayerIndex] - 1 : ViewType[iPlayerIndex] + 1; + iOtherPlayer = (ViewType[iPlayerIndex] & 1) != 0 + ? ViewType[iPlayerIndex] - 1 + : ViewType[iPlayerIndex] + 1; // Replay mode view 7: skip if other player is dead if ((Car[iOtherPlayer].byLives & 0x80u) != 0) @@ -3342,45 +3517,53 @@ void viewminus(int iPlayer) if (Play_View == 1) goto INIT_TEAM_VIEW; INIT_CAR_VIEW: - initcarview(ViewType[iPlayer], iPlayer); // Initialize car view for non-team modes + initcarview(ViewType[iPlayer], + iPlayer); // Initialize car view for non-team modes PLAY_BUTTON_SOUND: - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } //------------------------------------------------------------------------------------------------- -//00014F20 -void viewplus(int iPlayer) -{ - int iPlayerIndex; // eax - int iViewIndex; // edx - int iNextView; // ebx - int iOtherPlayer; // ebx - int iNextViewDuo; // ebx - int iOtherPlayerDuo; // ebx +// 00014F20 +void viewplus(int iPlayer) { + int iPlayerIndex; // eax + int iViewIndex; // edx + int iNextView; // ebx + int iOtherPlayer; // ebx + int iNextViewDuo; // ebx + int iOtherPlayerDuo; // ebx int iSelectedViewDuo; // esi - int iPlayer_1; // [esp+0h] [ebp-1Ch] + int iPlayer_1; // [esp+0h] [ebp-1Ch] iPlayer_1 = iPlayer; iPlayerIndex = iPlayer; - iViewIndex = iPlayer; // Check if we're in replay mode (replaytype == 2) + iViewIndex = iPlayer; // Check if we're in replay mode (replaytype == 2) if (replaytype != 2) { - if ((Car[ViewType[iPlayerIndex]].byStatusFlags & 4) != 0)// CAR_STATUS_ACTIVE - return; // Don't change view if current car is active (bit 2 set in status flags) + if ((Car[ViewType[iPlayerIndex]].byStatusFlags & 4) != + 0) // CAR_STATUS_ACTIVE + return; // Don't change view if current car is active (bit 2 set in status + // flags) if (player_type == 2) { do { iSelectedViewDuo = SelectedView[iViewIndex] + 1; SelectedView[iViewIndex] = iSelectedViewDuo; - if (iSelectedViewDuo >= 9) // Wrap around to view 0 if we've gone past view 8 + if (iSelectedViewDuo >= + 9) // Wrap around to view 0 if we've gone past view 8 SelectedView[iViewIndex] = 0; - } while (!DuoViews[SelectedView[iViewIndex]]);// Two-player mode: cycle through views allowed for duo play + } while (!DuoViews[SelectedView[iViewIndex]]); // Two-player mode: cycle + // through views allowed + // for duo play } else { do { // Single player mode: cycle through allowed views iNextViewDuo = SelectedView[iViewIndex] + 1; SelectedView[iViewIndex] = iNextViewDuo; if (iNextViewDuo == 7) { - iOtherPlayerDuo = (ViewType[iPlayerIndex] & 1) != 0 ? ViewType[iPlayerIndex] - 1 : ViewType[iPlayerIndex] + 1; - // View 7 special case: check if other player's car is dead (bit 7 set) + iOtherPlayerDuo = (ViewType[iPlayerIndex] & 1) != 0 + ? ViewType[iPlayerIndex] - 1 + : ViewType[iPlayerIndex] + 1; + // View 7 special case: check if other player's car is dead (bit 7 + // set) if ((Car[iOtherPlayerDuo].byLives & 0x80u) != 0) ++SelectedView[iViewIndex]; } @@ -3394,16 +3577,20 @@ void viewplus(int iPlayer) if (Play_View != 1) goto INIT_CAR_VIEW; INIT_TEAM_VIEW: - // If team view (Play_View == 1), initialize team display + // If team view (Play_View == 1), initialize team display doteaminit(); goto PLAY_BUTTON_SOUND; } do { - iNextView = SelectedView[iViewIndex] + 1; // Replay mode: cycle through replay-allowed views + iNextView = SelectedView[iViewIndex] + + 1; // Replay mode: cycle through replay-allowed views SelectedView[iViewIndex] = iNextView; if (iNextView == 7) { - iOtherPlayer = (ViewType[iPlayerIndex] & 1) != 0 ? ViewType[iPlayerIndex] - 1 : ViewType[iPlayerIndex] + 1; - if ((Car[iOtherPlayer].byLives & 0x80u) != 0)// Replay mode view 7: skip if other player is dead + iOtherPlayer = (ViewType[iPlayerIndex] & 1) != 0 + ? ViewType[iPlayerIndex] - 1 + : ViewType[iPlayerIndex] + 1; + if ((Car[iOtherPlayer].byLives & 0x80u) != + 0) // Replay mode view 7: skip if other player is dead ++SelectedView[iViewIndex]; } if (SelectedView[iViewIndex] >= 9) @@ -3413,206 +3600,233 @@ void viewplus(int iPlayer) if (Play_View == 1) goto INIT_TEAM_VIEW; INIT_CAR_VIEW: - initcarview(ViewType[iPlayer_1], iPlayer_1); // Initialize car view for non-team modes + initcarview(ViewType[iPlayer_1], + iPlayer_1); // Initialize car view for non-team modes PLAY_BUTTON_SOUND: - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } //------------------------------------------------------------------------------------------------- -//00015120 -void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) -{ - int iBufferIndex; // eax - char byChar; // dh - int j; // edx - char byNameChar; // bl - int k; // eax - int i; // eax - int iSoundSample; // eax - int iPlayerCar; // ecx - const char *pMessageStr; // eax - int iKillCount; // ecx - int iPlayerCarForSound; // ecx - int iKillSample; // eax +// 00015120 +void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) { + int iBufferIndex; // eax + char byChar; // dh + int j; // edx + char byNameChar; // bl + int k; // eax + int i; // eax + int iSoundSample; // eax + int iPlayerCar; // ecx + const char *pMessageStr; // eax + int iKillCount; // ecx + int iPlayerCarForSound; // ecx + int iKillSample; // eax int iSoundSampleForWinner; // eax - int iWinnerKillCount; // edx - int iWinnerPlayerCar; // ecx - int iWinnerSoundSample; // eax - int iSavedScrSize; // edi - int iSavedScrSize2; // edi - int iSavedScrSize3; // edi - char *pQuitMessage; // edx - int iFrameCount; // ebx - - screen_pointer = pSrc; // Set global screen pointer to source image buffer - if (network_on) // Handle network messaging if multiplayer is enabled - { // Check if we have received a network message - if (message_received < 0) { // Handle outgoing network messages - if (message_sent >= 0) { // Special case for message type 4 + int iWinnerKillCount; // edx + int iWinnerPlayerCar; // ecx + int iWinnerSoundSample; // eax + int iSavedScrSize; // edi + int iSavedScrSize2; // edi + int iSavedScrSize3; // edi + char *pQuitMessage; // edx + int iFrameCount; // ebx + + screen_pointer = pSrc; // Set global screen pointer to source image buffer + if (network_on) // Handle network messaging if multiplayer is enabled + { // Check if we have received a network message + if (message_received < 0) { // Handle outgoing network messages + if (message_sent >= 0) { // Special case for message type 4 if (message_sent == 4) { small_zoom(&language_buffer[6528]); } else { small_zoom(&language_buffer[6464]); - for (i = 0; i < 14; ++i) { //24 is too long for network_messages - buffer[i] = network_messages[message_sent][i]; + for (i = 0; i < 14; ++i) { // 24 is too long for network_messages + buffer[i] = network_messages[message_sent][i]; } - //for (i = 0; i < 24; currentdir[i + 255] = *((_BYTE *)&head_y + 14 * message_sent + i + 3)) - // ++i; + // for (i = 0; i < 24; currentdir[i + 255] = *((_BYTE *)&head_y + 14 * + // message_sent + i + 3)) + // ++i; subzoom(buffer); } message_sent = -1; } } else { - iBufferIndex = 0; // Process incoming network message - start building display buffer - if (language_buffer[6400]) // Copy language buffer text if present + iBufferIndex = + 0; // Process incoming network message - start building display buffer + if (language_buffer[6400]) // Copy language buffer text if present { do { byChar = language_buffer[++iBufferIndex + 6400]; buffer[iBufferIndex] = language_buffer[iBufferIndex + 6399]; - //currentdir[iBufferIndex + 255] = language_buffer[iBufferIndex + 6399]; + // currentdir[iBufferIndex + 255] = language_buffer[iBufferIndex + + // 6399]; } while (byChar); } - for (j = 0; j < 9; ++j) // Append player name to message buffer (9 chars max) + for (j = 0; j < 9; + ++j) // Append player name to message buffer (9 chars max) { ++iBufferIndex; byNameChar = player_names[message_received][j]; buffer[iBufferIndex] = byNameChar; - //currentdir[iBufferIndex + 255] = byNameChar; + // currentdir[iBufferIndex + 255] = byNameChar; } small_zoom(buffer); for (k = 0; k < 24; ++k) { buffer[k] = received_message[k]; } - //for (k = 0; k < 24; currentdir[k + 255] = p_data[k + 13])// Copy received message data (24 bytes) with unrolled loop + // for (k = 0; k < 24; currentdir[k + 255] = p_data[k + 13])// Copy + // received message data (24 bytes) with unrolled loop //{ - // k += 8; - // currentdir[k + 248] = p_data[k + 6]; - // currentdir[k + 249] = p_data[k + 7]; - // currentdir[k + 250] = p_data[k + 8]; - // currentdir[k + 251] = p_data[k + 9]; - // currentdir[k + 252] = p_data[k + 10]; - // currentdir[k + 253] = p_data[k + 11]; - // currentdir[k + 254] = p_data[k + 12]; - //} + // k += 8; + // currentdir[k + 248] = p_data[k + 6]; + // currentdir[k + 249] = p_data[k + 7]; + // currentdir[k + 250] = p_data[k + 8]; + // currentdir[k + 251] = p_data[k + 9]; + // currentdir[k + 252] = p_data[k + 10]; + // currentdir[k + 253] = p_data[k + 11]; + // currentdir[k + 254] = p_data[k + 12]; + // } subzoom(buffer); message_received = -1; } } - if (Car[ViewType[0]].byDebugDamage) // Handle damage indicator for player 1 + if (Car[ViewType[0]].byDebugDamage) // Handle damage indicator for player 1 { if (game_count[0] == -2) start_zoom(&language_buffer[1600], 0); if (game_count[0] > 0 && Car[ViewType[0]].fHealth < 90.0) game_count[0] = 72; } - if (player_type == 2 && Car[ViewType[1]].byDebugDamage)// Handle damage indicator for player 2 (split screen mode) + if (player_type == 2 && + Car[ViewType[1]].byDebugDamage) // Handle damage indicator for player 2 + // (split screen mode) { if (game_count[1] == -2) start_zoom(&language_buffer[1600], 1); if (game_count[1] > 0 && Car[ViewType[1]].fHealth < 90.0) game_count[1] = 72; } - if (!time_shown) // Main UI rendering branch - check if time display is shown + if (!time_shown) // Main UI rendering branch - check if time display is shown { - if (shown_panel || winner_mode) { // Handle winner mode display and announcements + if (shown_panel || + winner_mode) { // Handle winner mode display and announcements RENDER_UI_ELEMENTS: - if (winner_mode) { // Championship mode winner announcements + if (winner_mode) { // Championship mode winner announcements if (champ_mode) { if (game_count[0] == -2 && !winner_done) { switch (champ_zoom) { - case 0: - if (racers - 1 == champ_car) // Show winner car image - pMessageStr = &language_buffer[1344]; - else - pMessageStr = &language_buffer[64 * champ_car + 384]; - start_zoom(pMessageStr, 0); - goto ADVANCE_WINNER_SEQUENCE; - case 1: - start_zoom(driver_names[champorder[champ_car]], winner_done);// Show driver name - goto ADVANCE_WINNER_SEQUENCE; - case 3: - speechsample(SOUND_SAMPLE_CONGRAT, 0x8000, 18, player1_car);// Play congratulations sound and show message - start_zoom(&config_buffer[6272], 0); - goto ADVANCE_WINNER_SEQUENCE; - case 4: - start_zoom(&config_buffer[6336], 0); - goto ADVANCE_WINNER_SEQUENCE; - case 5: - start_zoom(&config_buffer[6400], 0); - goto ADVANCE_WINNER_SEQUENCE; - case 6: - if (total_wins[champorder[0]] > 0)// Announce race wins if any - speechsample(total_wins[champorder[0]] + SOUND_SAMPLE_FATAL, 0x8000, 18, player1_car);// 1 win starts at SOUND_SAMPLE_1RACE - goto ADVANCE_WINNER_SEQUENCE; - case 7: - iKillCount = total_kills[champorder[0]];// Announce kill statistics - if (iKillCount > 0) { // Lots of kills (17+) gets special sound - if (iKillCount >= 17) { - iKillSample = SOUND_SAMPLE_FATLOTS; // SOUND_SAMPLE_FATLOTS - iPlayerCarForSound = player1_car; - } else { - iPlayerCarForSound = player1_car; - iKillSample = total_kills[champorder[0]] + SOUND_SAMPLE_8RACE;// 1 kill starts at SOUND_SAMPLE_ONE - } - speechsample(iKillSample, 0x8000, 18, iPlayerCarForSound); - } - ++champ_zoom; - break; - default: - break; // Championship zoom sequence state machine - } - } - } else if (game_count[0] == -2 && !winner_done)// Single race winner announcements (non-championship) - { - switch (champ_zoom) { case 0: - speechsample(SOUND_SAMPLE_WON, 0x8000, 18, player1_car);// SOUND_SAMPLE_WON - start_zoom(&config_buffer[5952], 0); + if (racers - 1 == champ_car) // Show winner car image + pMessageStr = &language_buffer[1344]; + else + pMessageStr = &language_buffer[64 * champ_car + 384]; + start_zoom(pMessageStr, 0); goto ADVANCE_WINNER_SEQUENCE; case 1: - start_zoom(&config_buffer[6016], 0); - goto ADVANCE_WINNER_SEQUENCE; - case 2: - if (result_kills[result_order[0]] > 0 || result_order[0] == FastestLap)// Check for kills or fastest lap achievements - speechsample(SOUND_SAMPLE_STAT, 0x8000, 18, player1_car);// SOUND_SAMPLE_STAT + start_zoom(driver_names[champorder[champ_car]], + winner_done); // Show driver name goto ADVANCE_WINNER_SEQUENCE; case 3: - if (result_order[0] == FastestLap)// Fastest lap announcement - { // Check if it's a new lap record - if (BestTime == RecordLaps[game_track]) - iSoundSampleForWinner = SOUND_SAMPLE_NEWLAP; // SOUND_SAMPLE_NEWLAP - else - iSoundSampleForWinner = SOUND_SAMPLE_NEWFAST; // SOUND_SAMPLE_NEWFAST - speechsample(iSoundSampleForWinner, 0x8000, 18, player1_car); - } + speechsample( + SOUND_SAMPLE_CONGRAT, 0x8000, 18, + player1_car); // Play congratulations sound and show message + start_zoom(&config_buffer[6272], 0); goto ADVANCE_WINNER_SEQUENCE; case 4: - iWinnerKillCount = result_kills[result_order[0]]; - if (iWinnerKillCount > 0) { - if (iWinnerKillCount >= 17) { - iWinnerSoundSample = SOUND_SAMPLE_FATLOTS; // SOUND_SAMPLE_FATLOTS - iWinnerPlayerCar = player1_car; + start_zoom(&config_buffer[6336], 0); + goto ADVANCE_WINNER_SEQUENCE; + case 5: + start_zoom(&config_buffer[6400], 0); + goto ADVANCE_WINNER_SEQUENCE; + case 6: + if (total_wins[champorder[0]] > 0) // Announce race wins if any + speechsample(total_wins[champorder[0]] + SOUND_SAMPLE_FATAL, + 0x8000, 18, + player1_car); // 1 win starts at SOUND_SAMPLE_1RACE + goto ADVANCE_WINNER_SEQUENCE; + case 7: + iKillCount = + total_kills[champorder[0]]; // Announce kill statistics + if (iKillCount > 0) { // Lots of kills (17+) gets special sound + if (iKillCount >= 17) { + iKillSample = SOUND_SAMPLE_FATLOTS; // SOUND_SAMPLE_FATLOTS + iPlayerCarForSound = player1_car; } else { - iWinnerPlayerCar = player1_car; - iWinnerSoundSample = result_kills[result_order[0]] + SOUND_SAMPLE_8RACE;// 1 kill starts at SOUND_SAMPLE_ONE + iPlayerCarForSound = player1_car; + iKillSample = + total_kills[champorder[0]] + + SOUND_SAMPLE_8RACE; // 1 kill starts at SOUND_SAMPLE_ONE } - speechsample(iWinnerSoundSample, 0x8000, 18, iWinnerPlayerCar); + speechsample(iKillSample, 0x8000, 18, iPlayerCarForSound); } - ADVANCE_WINNER_SEQUENCE: ++champ_zoom; break; default: - break; + break; // Championship zoom sequence state machine + } + } + } else if (game_count[0] == -2 && + !winner_done) // Single race winner announcements + // (non-championship) + { + switch (champ_zoom) { + case 0: + speechsample(SOUND_SAMPLE_WON, 0x8000, 18, + player1_car); // SOUND_SAMPLE_WON + start_zoom(&config_buffer[5952], 0); + goto ADVANCE_WINNER_SEQUENCE; + case 1: + start_zoom(&config_buffer[6016], 0); + goto ADVANCE_WINNER_SEQUENCE; + case 2: + if (result_kills[result_order[0]] > 0 || + result_order[0] == + FastestLap) // Check for kills or fastest lap achievements + speechsample(SOUND_SAMPLE_STAT, 0x8000, 18, + player1_car); // SOUND_SAMPLE_STAT + goto ADVANCE_WINNER_SEQUENCE; + case 3: + if (result_order[0] == FastestLap) // Fastest lap announcement + { // Check if it's a new lap record + if (BestTime == RecordLaps[game_track]) + iSoundSampleForWinner = + SOUND_SAMPLE_NEWLAP; // SOUND_SAMPLE_NEWLAP + else + iSoundSampleForWinner = + SOUND_SAMPLE_NEWFAST; // SOUND_SAMPLE_NEWFAST + speechsample(iSoundSampleForWinner, 0x8000, 18, player1_car); + } + goto ADVANCE_WINNER_SEQUENCE; + case 4: + iWinnerKillCount = result_kills[result_order[0]]; + if (iWinnerKillCount > 0) { + if (iWinnerKillCount >= 17) { + iWinnerSoundSample = + SOUND_SAMPLE_FATLOTS; // SOUND_SAMPLE_FATLOTS + iWinnerPlayerCar = player1_car; + } else { + iWinnerPlayerCar = player1_car; + iWinnerSoundSample = + result_kills[result_order[0]] + + SOUND_SAMPLE_8RACE; // 1 kill starts at SOUND_SAMPLE_ONE + } + speechsample(iWinnerSoundSample, 0x8000, 18, iWinnerPlayerCar); + } + ADVANCE_WINNER_SEQUENCE: + ++champ_zoom; + break; + default: + break; } } } - if (intro && game_count[0] == -2) // Handle intro sequence display + if (intro && game_count[0] == -2) // Handle intro sequence display { start_zoom(&language_buffer[1792], 0); subzoom(&language_buffer[1856]); } - if (network_on && paused) // Show pause message in network games + if (network_on && paused) // Show pause message in network games { sprintf(buffer, "%s", &language_buffer[6272]); start_zoom(buffer, 0); @@ -3621,8 +3835,9 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) game_scale[0] = 64.0; game_count[0] = 2; } - if (iCarIdx == player1_car || winner_mode || intro)// Render zoom messages for player 1 or in special modes - { // Choose font based on zoom and screen resolution + if (iCarIdx == player1_car || winner_mode || + intro) // Render zoom messages for player 1 or in special modes + { // Choose font based on zoom and screen resolution if (zoom_size[0]) { ZoomString(zoom_mes[0], font3_ascii, rev_vga[3], 0, font3_offsets); } else if (winh < 200) { @@ -3637,7 +3852,8 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) ZoomSub(zoom_sub[0], font6_ascii, rev_vga[1], 0, font6_offsets); } } - if (iCarIdx == player2_car) // Render zoom messages for player 2 (split screen) + if (iCarIdx == + player2_car) // Render zoom messages for player 2 (split screen) { if (zoom_size[1]) { ZoomString(zoom_mes[1], font3_ascii, rev_vga[3], 1, font3_offsets); @@ -3655,23 +3871,28 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) } goto HANDLE_SPECIAL_MODES; } - shown_panel = -1; // Hide panel and handle race countdown logic + shown_panel = -1; // Hide panel and handle race countdown logic if (replaytype != 2) { if (game_type != 2) { if (countdown <= -72) - goto DRAW_EFFECTS_AND_PANEL; // Race has started (countdown <= -72) - if (countdown < 0 && gosound >= 1) // Play GO sound when countdown reaches 0 + goto DRAW_EFFECTS_AND_PANEL; // Race has started (countdown <= -72) + if (countdown < 0 && + gosound >= 1) // Play GO sound when countdown reaches 0 { gosound = 0; - speechsample(SOUND_SAMPLE_GO, 0x8000, 0, player1_car);// SOUND_SAMPLE_GO + speechsample(SOUND_SAMPLE_GO, 0x8000, 0, + player1_car); // SOUND_SAMPLE_GO } - if ((unsigned int)countdown < 0x48) // Pre-race countdown phase (0-72 frames) - { // Play engine sound during countdown + if ((unsigned int)countdown < + 0x48) // Pre-race countdown phase (0-72 frames) + { // Play engine sound during countdown if (gosound >= 2) { gosound = 1; - speechsample(SOUND_SAMPLE_ENGINES, 0x8000, 0, player1_car);// SOUND_SAMPLE_ENGINES + speechsample(SOUND_SAMPLE_ENGINES, 0x8000, 0, + player1_car); // SOUND_SAMPLE_ENGINES } - if (countdown < 18) // Show ready message in final countdown (18 frames) + if (countdown < + 18) // Show ready message in final countdown (18 frames) { if (strcmp(&language_buffer[1664], zoom_mes[0])) { start_zoom(&language_buffer[1664], 0); @@ -3682,13 +3903,13 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) } if (countdown < 72 || countdown >= 144 || !fadedin || gosound < 3) goto DRAW_EFFECTS_AND_PANEL; - iSoundSample = SOUND_SAMPLE_DRIVERS; // SOUND_SAMPLE_DRIVERS + iSoundSample = SOUND_SAMPLE_DRIVERS; // SOUND_SAMPLE_DRIVERS gosound = 2; iPlayerCar = player1_car; goto PLAY_COUNTDOWN_SOUND; } if (gosound >= 1 && active_nodes == network_on) { - iSoundSample = SOUND_SAMPLE_GO; // SOUND_SAMPLE_GO + iSoundSample = SOUND_SAMPLE_GO; // SOUND_SAMPLE_GO iPlayerCar = player1_car; gosound = 0; PLAY_COUNTDOWN_SOUND: @@ -3702,9 +3923,9 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) goto RENDER_UI_ELEMENTS; } HANDLE_SPECIAL_MODES: - if (replaytype == 2 && !intro) // Handle replay mode display + if (replaytype == 2 && !intro) // Handle replay mode display displayreplay(); - if (game_req) // Handle game menu requests and exit confirmation + if (game_req) // Handle game menu requests and exit confirmation { if (draw_type != 2) { display_paused(); @@ -3714,8 +3935,8 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) } } } - if (!winner_mode && replaytype != 2) // Network status and waiting messages - { // Waiting for players message (blinking) + if (!winner_mode && replaytype != 2) // Network status and waiting messages + { // Waiting for players message (blinking) if (network_on && active_nodes < network_on && (frames & 0xFu) < 8) { if (winh >= 200) { prt_centrecol(rev_vga[1], "WAITING FOR PLAYERS", 160, 100, 207); @@ -3726,7 +3947,9 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) scr_size = iSavedScrSize; } } - if (network_on && finished_car[player1_car] && (frames & 0xFu) < 8 && !I_Would_Like_To_Quit && lastsample < -180)// Please wait for race to end message + if (network_on && finished_car[player1_car] && (frames & 0xFu) < 8 && + !I_Would_Like_To_Quit && + lastsample < -180) // Please wait for race to end message { iSavedScrSize2 = scr_size; scr_size = 64; @@ -3734,7 +3957,8 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) mini_prt_centre(rev_vga[0], "FOR RACE TO END", winw / 2, winh / 2 + 16); scr_size = iSavedScrSize2; } - if (I_Would_Like_To_Quit && (frames & 0xFu) < 8)// F10 to quit confirmation message + if (I_Would_Like_To_Quit && + (frames & 0xFu) < 8) // F10 to quit confirmation message { iSavedScrSize3 = scr_size; scr_size = 64; @@ -3747,7 +3971,7 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) scr_size = iSavedScrSize3; } } - if (draw_type != 2) // Frame rate calculation and timing + if (draw_type != 2) // Frame rate calculation and timing { curr_time = ticks; iFrameCount = ++frame_count; @@ -3757,14 +3981,13 @@ void game_copypic(uint8 *pSrc, uint8 *pDest, int iCarIdx) start_time = curr_time; } } - if (draw_type != 2) // Final screen buffer copy to destination + if (draw_type != 2) // Final screen buffer copy to destination copypic(pSrc, pDest); } //------------------------------------------------------------------------------------------------- -//00015CE0 -void test_w95() -{ +// 00015CE0 +void test_w95() { /* REGS regs; // [esp+0h] [ebp-34h] BYREF struct SREGS sregs; // [esp+1Ch] [ebp-18h] BYREF @@ -3772,9 +3995,8 @@ void test_w95() // AX=1600h(5632) is a Microsoft-defined multiplex interrupt function used to // query the windows environment. This returns: // * AL = 0xFF if Windows is not running (i.e., plain DOS) - // * AL = major version and AH = minor version if Windows is running (e.g., AL=4, AH=0 for Windows 95) - memset(&sregs, 0, sizeof(sregs)); - regs.w.ax = 5632; + // * AL = major version and AH = minor version if Windows is running (e.g., + AL=4, AH=0 for Windows 95) memset(&sregs, 0, sizeof(sregs)); regs.w.ax = 5632; int386x(47, ®s, ®s, &sregs); w95 = regs.h.al; if (regs.h.al < 3u || regs.h.al > 4u) @@ -3782,14 +4004,13 @@ void test_w95() else w95 = -1;*/ - //for our purposes we'll pretend to be in DOS + // for our purposes we'll pretend to be in DOS w95 = 0; } //------------------------------------------------------------------------------------------------- -//00015D50 -void *malloc2(int iSize, void *pPtr, int *pRegsDi) -{ +// 00015D50 +void *malloc2(int iSize, void *pPtr, int *pRegsDi) { void *result; // eax result = malloc(iSize); pPtr = result; @@ -3797,9 +4018,8 @@ void *malloc2(int iSize, void *pPtr, int *pRegsDi) } //------------------------------------------------------------------------------------------------- -//00015E00 -void free2(void *ptr) -{ +// 00015E00 +void free2(void *ptr) { free(ptr); --hibuffers; } diff --git a/PROJECTS/ROLLER/3d.h b/PROJECTS/ROLLER/3d.h index d56baf62..cc606312 100644 --- a/PROJECTS/ROLLER/3d.h +++ b/PROJECTS/ROLLER/3d.h @@ -7,27 +7,24 @@ #include "game_render.h" //------------------------------------------------------------------------------------------------- -enum eTrakColour -{ - TRAK_COLOUR_LEFT_LANE = 0, - TRAK_COLOUR_CENTER = 1, +enum eTrakColour { + TRAK_COLOUR_LEFT_LANE = 0, + TRAK_COLOUR_CENTER = 1, TRAK_COLOUR_RIGHT_LANE = 2, - TRAK_COLOUR_LEFT_WALL = 3, + TRAK_COLOUR_LEFT_WALL = 3, TRAK_COLOUR_RIGHT_WALL = 4, - TRAK_COLOUR_ROOF = 5, + TRAK_COLOUR_ROOF = 5, }; -enum eGroundColour -{ - GROUND_COLOUR_LUOWALL = 0, - GROUND_COLOUR_LLOWALL = 1, - GROUND_COLOUR_OFLOOR = 2, - GROUND_COLOUR_RLOWALL = 3, - GROUND_COLOUR_RUOWALL = 4, +enum eGroundColour { + GROUND_COLOUR_LUOWALL = 0, + GROUND_COLOUR_LLOWALL = 1, + GROUND_COLOUR_OFLOOR = 2, + GROUND_COLOUR_RLOWALL = 3, + GROUND_COLOUR_RUOWALL = 4, }; -enum eWhipKeyScancodes -{ +enum eWhipKeyScancodes { WHIP_SCANCODE_ESCAPE = 0x01, WHIP_SCANCODE_1 = 0x02, WHIP_SCANCODE_2 = 0x03, @@ -125,20 +122,18 @@ enum eWhipKeyScancodes //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { void *pBuf; uint32 uiSize; - void *pAlsoBuf; //seems to be set to the same thing as pBuf in W95 - int iRegsDi; //unused by W95 + void *pAlsoBuf; // seems to be set to the same thing as pBuf in W95 + int iRegsDi; // unused by W95 } tMemBlock; #define MEM_BLOCK_COUNT 128 //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 pointAy[4]; float fTrackHalfLength; float fTrackHalfWidth; @@ -162,23 +157,20 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 pointAy[6]; } tGroundPt; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tPoint screen; tVec3 projected; } tScreenPt; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iUnk1; int iClipCount; tScreenPt screenPtAy[6]; @@ -186,8 +178,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int16 nRenderPriority; int16 nChunkIdx; float fZDepth; @@ -418,7 +409,8 @@ void fre(void **ppData); void doexit(); void firework_screen(); void updatescreen(); -void draw_road(uint8 *pScrPtr, int iCarIdx, unsigned int uiViewMode, int iCopyImmediately, int iChaseCamIdx); +void draw_road(uint8 *pScrPtr, int iCarIdx, unsigned int uiViewMode, + int iCopyImmediately, int iChaseCamIdx); int main(int argc, const char **argv, const char **envp); void play_game_init(); void play_game_uninit(); diff --git a/PROJECTS/ROLLER/build_info_default.h b/PROJECTS/ROLLER/build_info_default.h index a9436897..a9904657 100644 --- a/PROJECTS/ROLLER/build_info_default.h +++ b/PROJECTS/ROLLER/build_info_default.h @@ -2,10 +2,10 @@ #define _ROLLER_BUILD_INFO_DEFAULT_H //------------------------------------------------------------------------------------------------- -#define BUILD_VERSION "local" +#define BUILD_VERSION "local" #define BUILD_GIT_HASH "unknown" -#define BUILD_DATE "unknown" -#define BUILD_TARGET "native" +#define BUILD_DATE "unknown" +#define BUILD_TARGET "native" //------------------------------------------------------------------------------------------------- #endif diff --git a/PROJECTS/ROLLER/building.c b/PROJECTS/ROLLER/building.c index 0e8e78bf..26016ef0 100644 --- a/PROJECTS/ROLLER/building.c +++ b/PROJECTS/ROLLER/building.c @@ -11,94 +11,94 @@ #include //------------------------------------------------------------------------------------------------- -uint8 BuildingSub[24] = //000A745C -{ - 1u, 1u, 1u, 1u, 20u, 1u, 1u, 20u, 1u, 1u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u -}; -tBuildingZOrderEntry BuildingZOrder[32];//0018EEC0 -int BuildingSect[MAX_TRACK_CHUNKS]; //0018F040 -tVec3 BuildingView[32]; //0018F810 -float BuildingAngles[768]; //0018F990 -int BuildingBase[256][4]; //00190590 -tVec3 BuildingBox[256][8]; //00191590 -tBuildingCoord BuildingCoords[32]; //00197590 -float BuildingBaseX[256]; //00197710 -float BuildingBaseY[256]; //00197B10 -float BuildingBaseZ[256]; //00197F10 -float BuildingX[256]; //00198310 -float BuildingY[256]; //00198710 -float BuildingZ[256]; //00198B10 -tVisibleBuilding VisibleBuildings[256]; //00198F10 -int16 advert_list[256]; //00199710 -tPolyParams BuildingPol; //00199910 -int NumBuildings; //0019993C -int NumVisibleBuildings; //00199940 +uint8 BuildingSub[24] = // 000A745C + {1u, 1u, 1u, 1u, 20u, 1u, 1u, 20u, 1u, 1u, 1u, 1u, + 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u}; +tBuildingZOrderEntry BuildingZOrder[32]; // 0018EEC0 +int BuildingSect[MAX_TRACK_CHUNKS]; // 0018F040 +tVec3 BuildingView[32]; // 0018F810 +float BuildingAngles[768]; // 0018F990 +int BuildingBase[256][4]; // 00190590 +tVec3 BuildingBox[256][8]; // 00191590 +tBuildingCoord BuildingCoords[32]; // 00197590 +float BuildingBaseX[256]; // 00197710 +float BuildingBaseY[256]; // 00197B10 +float BuildingBaseZ[256]; // 00197F10 +float BuildingX[256]; // 00198310 +float BuildingY[256]; // 00198710 +float BuildingZ[256]; // 00198B10 +tVisibleBuilding VisibleBuildings[256]; // 00198F10 +int16 advert_list[256]; // 00199710 +tPolyParams BuildingPol; // 00199910 +int NumBuildings; // 0019993C +int NumVisibleBuildings; // 00199940 //------------------------------------------------------------------------------------------------- -//000691B0 -void InitBuildings() -{ - int iBuildingIdx_1; // edi - int iBuildingIdx_2; // esi - unsigned int iBuildingType; // eax +// 000691B0 +void InitBuildings() { + int iBuildingIdx_1; // edi + int iBuildingIdx_2; // esi + unsigned int iBuildingType; // eax tBuildingPlan *pBuildingPlan; // ecx - tPolygon *pPols; // ebx - int iNextSect; // edx - tData *pTrackData; // eax - tData *pNextTrackData; // edx - int iHalfHeight; // eax - int byNumPols; // edx - float *p_fX; // edx - int i; // ebx - double dTempY; // st7 - float *pYCoord; // edx - double dTempZ; // st7 - float *pZCoord; // edx - //unsigned int uiBuildingBoxOffset; // edx - double dDeltaY; // [esp+0h] [ebp-118h] - double dDeltaX; // [esp+18h] [ebp-100h] - double dCosPitch; // [esp+28h] [ebp-F0h] - double dCosYaw; // [esp+38h] [ebp-E0h] - double dCosRoll; // [esp+40h] [ebp-D8h] - double dSinYaw; // [esp+48h] [ebp-D0h] - double dSinRoll; // [esp+50h] [ebp-C8h] - double dSinPitch; // [esp+58h] [ebp-C0h] - double dDistance; // [esp+60h] [ebp-B8h] - float fZ; // [esp+70h] [ebp-A8h] - float fY; // [esp+80h] [ebp-98h] - float fX; // [esp+84h] [ebp-94h] - float fHalfWidth; // [esp+8Ch] [ebp-8Ch] - float fNegTrackY; // [esp+90h] [ebp-88h] - float fNegTrackX; // [esp+94h] [ebp-84h] - float fNegTrackZ; // [esp+98h] [ebp-80h] + tPolygon *pPols; // ebx + int iNextSect; // edx + tData *pTrackData; // eax + tData *pNextTrackData; // edx + int iHalfHeight; // eax + int byNumPols; // edx + float *p_fX; // edx + int i; // ebx + double dTempY; // st7 + float *pYCoord; // edx + double dTempZ; // st7 + float *pZCoord; // edx + // unsigned int uiBuildingBoxOffset; // edx + double dDeltaY; // [esp+0h] [ebp-118h] + double dDeltaX; // [esp+18h] [ebp-100h] + double dCosPitch; // [esp+28h] [ebp-F0h] + double dCosYaw; // [esp+38h] [ebp-E0h] + double dCosRoll; // [esp+40h] [ebp-D8h] + double dSinYaw; // [esp+48h] [ebp-D0h] + double dSinRoll; // [esp+50h] [ebp-C8h] + double dSinPitch; // [esp+58h] [ebp-C0h] + double dDistance; // [esp+60h] [ebp-B8h] + float fZ; // [esp+70h] [ebp-A8h] + float fY; // [esp+80h] [ebp-98h] + float fX; // [esp+84h] [ebp-94h] + float fHalfWidth; // [esp+8Ch] [ebp-8Ch] + float fNegTrackY; // [esp+90h] [ebp-88h] + float fNegTrackX; // [esp+94h] [ebp-84h] + float fNegTrackZ; // [esp+98h] [ebp-80h] int iBuildingBoxStride; // [esp+9Ch] [ebp-7Ch] - float fRollAngle; // [esp+A0h] [ebp-78h] - float fPitchAngle; // [esp+A4h] [ebp-74h] - int iBuildingSect; // [esp+A8h] [ebp-70h] - float fYawAngle; // [esp+ACh] [ebp-6Ch] - int iAngleIdx; // [esp+B0h] [ebp-68h] - int iBuildingIdx; // [esp+B4h] [ebp-64h] - float fMatrix20; // [esp+B8h] [ebp-60h] - float fMatrix21; // [esp+BCh] [ebp-5Ch] - float fMatrix12; // [esp+C0h] [ebp-58h] - float fMatrix10; // [esp+C4h] [ebp-54h] - float fMatrix00; // [esp+C8h] [ebp-50h] - float fMatrix02; // [esp+CCh] [ebp-4Ch] - float fMatrix22; // [esp+D0h] [ebp-48h] - float fMatrix11; // [esp+D4h] [ebp-44h] - float fMatrix01; // [esp+D8h] [ebp-40h] - float fBuildingY; // [esp+DCh] [ebp-3Ch] - float fBuildingX; // [esp+E0h] [ebp-38h] - float fBuildingZ; // [esp+E4h] [ebp-34h] - float fMinY; // [esp+E8h] [ebp-30h] - float fMaxZ; // [esp+ECh] [ebp-2Ch] - float fMinX; // [esp+F0h] [ebp-28h] - float fMaxY; // [esp+F4h] [ebp-24h] - float fMinZ; // [esp+F8h] [ebp-20h] - float fMaxX; // [esp+FCh] [ebp-1Ch] + float fRollAngle; // [esp+A0h] [ebp-78h] + float fPitchAngle; // [esp+A4h] [ebp-74h] + int iBuildingSect; // [esp+A8h] [ebp-70h] + float fYawAngle; // [esp+ACh] [ebp-6Ch] + int iAngleIdx; // [esp+B0h] [ebp-68h] + int iBuildingIdx; // [esp+B4h] [ebp-64h] + float fMatrix20; // [esp+B8h] [ebp-60h] + float fMatrix21; // [esp+BCh] [ebp-5Ch] + float fMatrix12; // [esp+C0h] [ebp-58h] + float fMatrix10; // [esp+C4h] [ebp-54h] + float fMatrix00; // [esp+C8h] [ebp-50h] + float fMatrix02; // [esp+CCh] [ebp-4Ch] + float fMatrix22; // [esp+D0h] [ebp-48h] + float fMatrix11; // [esp+D4h] [ebp-44h] + float fMatrix01; // [esp+D8h] [ebp-40h] + float fBuildingY; // [esp+DCh] [ebp-3Ch] + float fBuildingX; // [esp+E0h] [ebp-38h] + float fBuildingZ; // [esp+E4h] [ebp-34h] + float fMinY; // [esp+E8h] [ebp-30h] + float fMaxZ; // [esp+ECh] [ebp-2Ch] + float fMinX; // [esp+F0h] [ebp-28h] + float fMaxY; // [esp+F4h] [ebp-24h] + float fMinZ; // [esp+F8h] [ebp-20h] + float fMaxX; // [esp+FCh] [ebp-1Ch] - memset(BuildingSect, 255, sizeof(BuildingSect));// Initialize building sector map to -1 (no buildings) + memset( + BuildingSect, 255, + sizeof( + BuildingSect)); // Initialize building sector map to -1 (no buildings) iBuildingIdx = 0; if (NumBuildings > 0) { iAngleIdx = 0; @@ -107,13 +107,16 @@ void InitBuildings() iBuildingBoxStride = 96; do { iBuildingType = BuildingBase[iBuildingIdx_1][0]; - if (iBuildingType <= 0x10) // Check if building type is valid (<=16) + if (iBuildingType <= 0x10) // Check if building type is valid (<=16) { pBuildingPlan = &BuildingPlans[iBuildingType]; pPols = pBuildingPlan->pPols; iBuildingSect = BuildingBase[iBuildingIdx_1][1]; - iNextSect = iBuildingSect + 1; // Get next track segment, wrap around if needed - fHalfWidth = (float)(32 * BuildingBase[iBuildingIdx_1][2] / 2);// Calculate half width of building from BuildingBase[2] + iNextSect = + iBuildingSect + 1; // Get next track segment, wrap around if needed + fHalfWidth = + (float)(32 * BuildingBase[iBuildingIdx_1][2] / + 2); // Calculate half width of building from BuildingBase[2] if (iBuildingSect + 1 >= TRAK_LEN) iNextSect -= TRAK_LEN; pTrackData = &localdata[iBuildingSect]; @@ -121,35 +124,50 @@ void InitBuildings() fNegTrackY = -pTrackData->pointAy[3].fY; fNegTrackZ = -pTrackData->pointAy[3].fZ; pNextTrackData = &localdata[iNextSect]; - dDeltaY = pTrackData->pointAy[3].fY - pNextTrackData->pointAy[3].fY;// Calculate track direction vector between current and next segment + dDeltaY = + pTrackData->pointAy[3].fY - + pNextTrackData->pointAy[3].fY; // Calculate track direction vector + // between current and next segment dDeltaX = pTrackData->pointAy[3].fX - pNextTrackData->pointAy[3].fX; - dDistance = sqrt(dDeltaX * dDeltaX + dDeltaY * dDeltaY);// Calculate distance and normalize direction vector - //if ((HIDWORD(dDeltaX) & 0x7FFFFFFF) != 0 || LODWORD(dDeltaX)) + dDistance = sqrt( + dDeltaX * dDeltaX + + dDeltaY * + dDeltaY); // Calculate distance and normalize direction vector + // if ((HIDWORD(dDeltaX) & 0x7FFFFFFF) != 0 || LODWORD(dDeltaX)) if (dDeltaX != 0) - dDeltaX = (pTrackData->pointAy[3].fX - pNextTrackData->pointAy[3].fX) / dDistance; - //if ((HIDWORD(dDeltaY) & 0x7FFFFFFF) != 0 || LODWORD(dDeltaY)) + dDeltaX = + (pTrackData->pointAy[3].fX - pNextTrackData->pointAy[3].fX) / + dDistance; + // if ((HIDWORD(dDeltaY) & 0x7FFFFFFF) != 0 || LODWORD(dDeltaY)) if (dDeltaY != 0) dDeltaY = dDeltaY / dDistance; iHalfHeight = 32 * BuildingBase[iBuildingIdx_1][3] / 2; - BuildingX[iBuildingIdx_2] = fNegTrackX - (float)dDeltaY * fHalfWidth;// Calculate building position offset from track centerline + BuildingX[iBuildingIdx_2] = + fNegTrackX - + (float)dDeltaY * fHalfWidth; // Calculate building position offset + // from track centerline BuildingY[iBuildingIdx_2] = fHalfWidth * (float)dDeltaX + fNegTrackY; BuildingSect[iBuildingSect] = iBuildingIdx; byNumPols = 0; BuildingZ[iBuildingIdx_2] = (float)iHalfHeight + fNegTrackZ; - while (byNumPols < pBuildingPlan->byNumPols) { // Skip polygons with special texture flag (0x200) + while (byNumPols < + pBuildingPlan->byNumPols) { // Skip polygons with special texture + // flag (0x200) if ((pPols->uiTex & 0x200) != 0) byNumPols = pBuildingPlan->byNumPols; ++pPols; ++byNumPols; } - fMinZ = 1073741800.0f; // Initialize min/max values for bounding box calculation + fMinZ = 1073741800.0f; // Initialize min/max values for bounding box + // calculation fMinY = 1073741800.0f; fMinX = 1073741800.0f; p_fX = &pBuildingPlan->pCoords->fX; fMaxZ = -1073741800.0f; fMaxY = -1073741800.0f; fMaxX = -1073741800.0f; - for (i = 0; i < pBuildingPlan->byNumCoords; ++i)// Find min/max coordinates for building bounding box + for (i = 0; i < pBuildingPlan->byNumCoords; + ++i) // Find min/max coordinates for building bounding box { if (*p_fX < (double)fMinX) fMinX = *p_fX; @@ -169,7 +187,8 @@ void InitBuildings() fMaxZ = *pZCoord; p_fX = pZCoord + 1; } - if ((cheat_mode & CHEAT_MODE_DOUBLE_TRACK) != 0) // Scale building 2x if cheat mode 0x1000 is enabled + if ((cheat_mode & CHEAT_MODE_DOUBLE_TRACK) != + 0) // Scale building 2x if cheat mode 0x1000 is enabled { fMinX = fMinX * 2.0f; fMinY = fMinY * 2.0f; @@ -178,20 +197,24 @@ void InitBuildings() fMaxY = fMaxY * 2.0f; fMaxZ = fMaxZ * 2.0f; } - fYawAngle = BuildingAngles[iAngleIdx] * 0.0174532925199f;// Convert building rotation angles from degrees to radians + fYawAngle = BuildingAngles[iAngleIdx] * + 0.0174532925199f; // Convert building rotation angles from + // degrees to radians fPitchAngle = BuildingAngles[iAngleIdx + 1] * 0.0174532925199f; fRollAngle = BuildingAngles[iAngleIdx + 2] * 0.0174532925199f; fBuildingX = BuildingX[iBuildingIdx_2]; fBuildingY = BuildingY[iBuildingIdx_2]; fBuildingZ = BuildingZ[iBuildingIdx_2]; - dCosYaw = cos(fYawAngle); // Calculate sine and cosine values for 3D rotation matrix + dCosYaw = cos(fYawAngle); // Calculate sine and cosine values for 3D + // rotation matrix dCosPitch = cos(fPitchAngle); dSinYaw = sin(fYawAngle); dSinPitch = sin(fPitchAngle); dSinRoll = sin(fRollAngle); dCosRoll = cos(fRollAngle); - //uiBuildingBoxOffset = 96 * iBuildingIdx; - BuildingBox[iBuildingIdx][0].fX = fMinX;// Set up 8 corners of building bounding box (cube vertices) + // uiBuildingBoxOffset = 96 * iBuildingIdx; + BuildingBox[iBuildingIdx][0].fX = + fMinX; // Set up 8 corners of building bounding box (cube vertices) BuildingBox[iBuildingIdx][0].fY = fMinY; BuildingBox[iBuildingIdx][0].fZ = fMinZ; BuildingBox[iBuildingIdx][1].fX = fMaxX; @@ -217,26 +240,40 @@ void InitBuildings() BuildingBox[iBuildingIdx][7].fZ = fMaxZ; int iPoint = 0; do { - fX = BuildingBox[iBuildingIdx][iPoint].fX;// Apply 3D rotation matrix and translate each bounding box corner + fX = BuildingBox[iBuildingIdx][iPoint] + .fX; // Apply 3D rotation matrix and translate each bounding + // box corner fY = BuildingBox[iBuildingIdx][iPoint].fY; fZ = BuildingBox[iBuildingIdx][iPoint].fZ; fMatrix00 = (float)(dCosYaw * dCosPitch); - fMatrix02 = (float)(-dCosYaw * dSinPitch * dCosRoll - dSinYaw * dSinRoll); - fMatrix01 = (float)(dCosYaw * dSinPitch * dSinRoll - dSinYaw * dCosRoll); - BuildingBox[iBuildingIdx][iPoint].fX = fX * fMatrix00 + fY * fMatrix01 + fZ * fMatrix02 + fBuildingX; - fMatrix12 = (float)(-dSinYaw * dSinPitch * dCosRoll + dCosYaw * dSinRoll); + fMatrix02 = + (float)(-dCosYaw * dSinPitch * dCosRoll - dSinYaw * dSinRoll); + fMatrix01 = + (float)(dCosYaw * dSinPitch * dSinRoll - dSinYaw * dCosRoll); + BuildingBox[iBuildingIdx][iPoint].fX = + fX * fMatrix00 + fY * fMatrix01 + fZ * fMatrix02 + fBuildingX; + fMatrix12 = + (float)(-dSinYaw * dSinPitch * dCosRoll + dCosYaw * dSinRoll); fMatrix10 = (float)(dSinYaw * dCosPitch); - fMatrix11 = (float)(dSinYaw * dSinPitch * dSinRoll + dCosYaw * dCosRoll); - BuildingBox[iBuildingIdx][iPoint].fY = fX * fMatrix10 + fY * fMatrix11 + fZ * fMatrix12 + fBuildingY; - //uiBuildingBoxOffset += sizeof(tVec3); + fMatrix11 = + (float)(dSinYaw * dSinPitch * dSinRoll + dCosYaw * dCosRoll); + BuildingBox[iBuildingIdx][iPoint].fY = + fX * fMatrix10 + fY * fMatrix11 + fZ * fMatrix12 + fBuildingY; + // uiBuildingBoxOffset += sizeof(tVec3); fMatrix20 = (float)(dSinPitch); fMatrix22 = (float)(dCosRoll * dCosPitch); fMatrix21 = (float)(-dSinRoll * dCosPitch); - BuildingBox[iBuildingIdx][iPoint].fZ = fX * fMatrix20 + fY * fMatrix21 + fZ * fMatrix22 + fBuildingZ; + BuildingBox[iBuildingIdx][iPoint].fZ = + fX * fMatrix20 + fY * fMatrix21 + fZ * fMatrix22 + fBuildingZ; ++iPoint; - //*(float *)&BuildingBase[255][uiBuildingBoxOffset / 4 + 3] = fX * fMatrix20 + fY * fMatrix21 + fZ * fMatrix22 + fBuildingZ;// reference to BuildingBox - } while (iPoint < 8); //while (uiBuildingBoxOffset != iBuildingBoxStride);// - BuildingBaseX[iBuildingIdx_2] = BuildingX[iBuildingIdx_2];// Store final building position in base arrays + //*(float *)&BuildingBase[255][uiBuildingBoxOffset / 4 + 3] = fX * + // fMatrix20 + fY * fMatrix21 + fZ * fMatrix22 + fBuildingZ;// + // reference to BuildingBox + } while (iPoint < + 8); // while (uiBuildingBoxOffset != iBuildingBoxStride);// + BuildingBaseX[iBuildingIdx_2] = + BuildingX[iBuildingIdx_2]; // Store final building position in base + // arrays BuildingBaseY[iBuildingIdx_2] = BuildingY[iBuildingIdx_2]; BuildingBaseZ[iBuildingIdx_2] = BuildingZ[iBuildingIdx_2]; } @@ -250,240 +287,266 @@ void InitBuildings() } //------------------------------------------------------------------------------------------------- -//00069960 -void CalcVisibleBuildings() -{ - int iTrackLen; // ebp +// 00069960 +void CalcVisibleBuildings() { + int iTrackLen; // ebp tVisibleBuilding *pVisibleBuilding; // edi - int iTrackSectIdx; // ecx - int iBuildingCounter; // edx - int iWrappedSectIdx; // edx - int iBuildingIdx; // esi - unsigned int uiBuildingType; // edx - //int iPointOffset; // edx + int iTrackSectIdx; // ecx + int iBuildingCounter; // edx + int iWrappedSectIdx; // edx + int iBuildingIdx; // esi + unsigned int uiBuildingType; // edx + // int iPointOffset; // edx double dPointDepth; // st7 - //int iPointOffset2; // edx + // int iPointOffset2; // edx double dPointDepth2; // st7 - int iCurrentCount; // eax - //float fTempDepth; // [esp+18h] [ebp-24h] - //float fTempDepth2; // [esp+1Ch] [ebp-20h] + int iCurrentCount; // eax + // float fTempDepth; // [esp+18h] [ebp-24h] + // float fTempDepth2; // [esp+1Ch] [ebp-20h] float fBuildingDepth; // [esp+20h] [ebp-1Ch] - iTrackLen = TRAK_LEN; // Store track length for later restoration - pVisibleBuilding = VisibleBuildings; // Get pointer to visible buildings array + iTrackLen = TRAK_LEN; // Store track length for later restoration + pVisibleBuilding = VisibleBuildings; // Get pointer to visible buildings array iTrackSectIdx = TrackSize; - VisibleBuildings[0].iBuildingIdx = -1; // Initialize visible buildings array with terminator - NumVisibleBuildings = 0; // Reset visible building count - for (iBuildingCounter = 0; iBuildingCounter < NumBuildings; ++iBuildingCounter)// Count through all buildings (purpose unclear - possibly validation) + VisibleBuildings[0].iBuildingIdx = + -1; // Initialize visible buildings array with terminator + NumVisibleBuildings = 0; // Reset visible building count + for (iBuildingCounter = 0; iBuildingCounter < NumBuildings; + ++iBuildingCounter) // Count through all buildings (purpose unclear - + // possibly validation) ; - if ((textures_off & 0x200) == 0) // Check if building textures are enabled (bit 9 of textures_off) + if ((textures_off & 0x200) == + 0) // Check if building textures are enabled (bit 9 of textures_off) { while (1) { if (iTrackSectIdx < 0) - goto FUNCTION_EXIT; // Start of main track section loop - iterate backwards through track - if (iTrackSectIdx <= first_size || iTrackSectIdx >= gap_size)// Skip sections in track gap (between first_size and gap_size) + goto FUNCTION_EXIT; // Start of main track section loop - iterate + // backwards through track + if (iTrackSectIdx <= first_size || + iTrackSectIdx >= gap_size) // Skip sections in track gap (between + // first_size and gap_size) { - iWrappedSectIdx = iTrackSectIdx + start_sect;// Calculate wrapped track section index with start_sect offset - if (iTrackSectIdx + start_sect < 0) // Handle negative wraparound + iWrappedSectIdx = + iTrackSectIdx + start_sect; // Calculate wrapped track section index + // with start_sect offset + if (iTrackSectIdx + start_sect < 0) // Handle negative wraparound iWrappedSectIdx += iTrackLen; - if (iWrappedSectIdx >= iTrackLen) // Handle positive wraparound + if (iWrappedSectIdx >= iTrackLen) // Handle positive wraparound iWrappedSectIdx -= iTrackLen; - iBuildingIdx = BuildingSect[iWrappedSectIdx];// Get building index for this track section + iBuildingIdx = BuildingSect[iWrappedSectIdx]; // Get building index for + // this track section if (iBuildingIdx != -1) - break; // Skip if no building in this section (-1) + break; // Skip if no building in this section (-1) } NEXT_TRACK_SECTION: - --iTrackSectIdx; // Continue to next track section + --iTrackSectIdx; // Continue to next track section } - uiBuildingType = BuildingBase[iBuildingIdx][0];// Get building type from BuildingBase array - if (uiBuildingType < 4) // Check building type - types 0,1 use max depth, others use min depth + uiBuildingType = + BuildingBase[iBuildingIdx] + [0]; // Get building type from BuildingBase array + if (uiBuildingType < 4) // Check building type - types 0,1 use max depth, + // others use min depth { if (uiBuildingType > 1) goto CALC_MIN_DEPTH; - } else if (uiBuildingType > 7 && uiBuildingType != 14)// Types 8+ except 14 use min depth calculation + } else if (uiBuildingType > 7 && + uiBuildingType != + 14) // Types 8+ except 14 use min depth calculation { CALC_MIN_DEPTH: // Calculate min depth - fBuildingDepth = FLT_MAX; // Initialize to very large value - for (int iPointIdx = 0; iPointIdx < 8; iPointIdx++) - { - dPointDepth2 = (BuildingBox[iBuildingIdx][iPointIdx].fX - viewx) * vk3 - + (BuildingBox[iBuildingIdx][iPointIdx].fY - viewy) * vk6 - + (BuildingBox[iBuildingIdx][iPointIdx].fZ - viewz) * vk9; - - if (dPointDepth2 < fBuildingDepth) - { + fBuildingDepth = FLT_MAX; // Initialize to very large value + for (int iPointIdx = 0; iPointIdx < 8; iPointIdx++) { + dPointDepth2 = (BuildingBox[iBuildingIdx][iPointIdx].fX - viewx) * vk3 + + (BuildingBox[iBuildingIdx][iPointIdx].fY - viewy) * vk6 + + (BuildingBox[iBuildingIdx][iPointIdx].fZ - viewz) * vk9; + + if (dPointDepth2 < fBuildingDepth) { fBuildingDepth = (float)dPointDepth2; } } - //iPointOffset2 = 96 * iBuildingIdx + 12; // Calculate min depth for other building types - start with first point - //fBuildingDepth = (BuildingBox[iBuildingIdx][0].fX - viewx) * vk3 + (BuildingBox[iBuildingIdx][0].fY - viewy) * vk6 + (BuildingBox[iBuildingIdx][0].fZ - viewz) * vk9;// Transform first bounding box point to view space depth - //do { - // dPointDepth2 = (*(float *)((char *)&BuildingBox[0][0].fX + iPointOffset2) - viewx) * vk3 - // + (*(float *)((char *)&BuildingBox[0][0].fY + iPointOffset2) - viewy) * vk6 - // + (*(float *)((char *)&BuildingBox[0][0].fZ + iPointOffset2) - viewz) * vk9;// Transform current point to view space depth - // if (dPointDepth2 < fBuildingDepth) // Keep minimum depth value - // { - // fTempDepth = dPointDepth2; - // fBuildingDepth = fTempDepth; - // } - // iPointOffset2 += 12; - //} while (iPointOffset2 != 96 * iBuildingIdx + 96);// Loop through all 8 bounding box points + // iPointOffset2 = 96 * iBuildingIdx + 12; // Calculate min depth for + // other building types - start with first point fBuildingDepth = + // (BuildingBox[iBuildingIdx][0].fX - viewx) * vk3 + + // (BuildingBox[iBuildingIdx][0].fY - viewy) * vk6 + + // (BuildingBox[iBuildingIdx][0].fZ - viewz) * vk9;// Transform first + // bounding box point to view space depth do { + // dPointDepth2 = (*(float *)((char *)&BuildingBox[0][0].fX + + // iPointOffset2) - viewx) * vk3 + // + (*(float *)((char *)&BuildingBox[0][0].fY + iPointOffset2) - + // viewy) * vk6 + // + (*(float *)((char *)&BuildingBox[0][0].fZ + iPointOffset2) - + // viewz) * vk9;// Transform current point to view space depth + // if (dPointDepth2 < fBuildingDepth) // Keep minimum depth value + // { + // fTempDepth = dPointDepth2; + // fBuildingDepth = fTempDepth; + // } + // iPointOffset2 += 12; + // } while (iPointOffset2 != 96 * iBuildingIdx + 96);// Loop through all 8 + // bounding box points ADD_BUILDING_TO_LIST: - ++pVisibleBuilding; // Add building to visible list - advance pointer - pVisibleBuilding[-1].fDepth = fBuildingDepth;// Store depth value in array (float) + ++pVisibleBuilding; // Add building to visible list - advance pointer + pVisibleBuilding[-1].fDepth = + fBuildingDepth; // Store depth value in array (float) iCurrentCount = NumVisibleBuildings; - pVisibleBuilding[-1].iBuildingIdx = iBuildingIdx;// Store building index in array - pVisibleBuilding->iBuildingIdx = -1; // Add array terminator (-1) - NumVisibleBuildings = iCurrentCount + 1; // Increment visible building count + pVisibleBuilding[-1].iBuildingIdx = + iBuildingIdx; // Store building index in array + pVisibleBuilding->iBuildingIdx = -1; // Add array terminator (-1) + NumVisibleBuildings = + iCurrentCount + 1; // Increment visible building count goto NEXT_TRACK_SECTION; } - fBuildingDepth = -FLT_MAX; // Initialize to very small value - for (int iPointIdx = 0; iPointIdx < 8; iPointIdx++) - { - dPointDepth = (BuildingBox[iBuildingIdx][iPointIdx].fX - viewx) * vk3 - + (BuildingBox[iBuildingIdx][iPointIdx].fY - viewy) * vk6 - + (BuildingBox[iBuildingIdx][iPointIdx].fZ - viewz) * vk9; - - if (dPointDepth > fBuildingDepth) - { + fBuildingDepth = -FLT_MAX; // Initialize to very small value + for (int iPointIdx = 0; iPointIdx < 8; iPointIdx++) { + dPointDepth = (BuildingBox[iBuildingIdx][iPointIdx].fX - viewx) * vk3 + + (BuildingBox[iBuildingIdx][iPointIdx].fY - viewy) * vk6 + + (BuildingBox[iBuildingIdx][iPointIdx].fZ - viewz) * vk9; + + if (dPointDepth > fBuildingDepth) { fBuildingDepth = (float)dPointDepth; } } - //iPointOffset = 96 * iBuildingIdx + 12; // Calculate max depth for building types 0,1 - start with first point - //fBuildingDepth = (BuildingBox[iBuildingIdx][0].fX - viewx) * vk3 + (BuildingBox[iBuildingIdx][0].fY - viewy) * vk6 + (BuildingBox[iBuildingIdx][0].fZ - viewz) * vk9;// Transform first bounding box point to view space using view matrix - //do { - // dPointDepth = (*(float *)((char *)&BuildingBox[0][0].fX + iPointOffset) - viewx) * vk3 - // + (*(float *)((char *)&BuildingBox[0][0].fY + iPointOffset) - viewy) * vk6 - // + (*(float *)((char *)&BuildingBox[0][0].fZ + iPointOffset) - viewz) * vk9;// Transform current point to view space depth - // if (dPointDepth > fBuildingDepth) // Keep maximum depth value - // { - // fTempDepth2 = dPointDepth; - // fBuildingDepth = fTempDepth2; - // } - // iPointOffset += sizeof(tVec3); - //} while (iPointOffset != 96 * iBuildingIdx + 96);// Loop through all 8 bounding box points (96 bytes total, 12 per point) + // iPointOffset = 96 * iBuildingIdx + 12; // Calculate max depth for + // building types 0,1 - start with first point fBuildingDepth = + // (BuildingBox[iBuildingIdx][0].fX - viewx) * vk3 + + // (BuildingBox[iBuildingIdx][0].fY - viewy) * vk6 + + // (BuildingBox[iBuildingIdx][0].fZ - viewz) * vk9;// Transform first + // bounding box point to view space using view matrix do { + // dPointDepth = (*(float *)((char *)&BuildingBox[0][0].fX + iPointOffset) + // - viewx) * vk3 + // + (*(float *)((char *)&BuildingBox[0][0].fY + iPointOffset) - viewy) + // * vk6 + // + (*(float *)((char *)&BuildingBox[0][0].fZ + iPointOffset) - viewz) + // * vk9;// Transform current point to view space depth + // if (dPointDepth > fBuildingDepth) // Keep maximum depth value + // { + // fTempDepth2 = dPointDepth; + // fBuildingDepth = fTempDepth2; + // } + // iPointOffset += sizeof(tVec3); + // } while (iPointOffset != 96 * iBuildingIdx + 96);// Loop through all 8 + // bounding box points (96 bytes total, 12 per point) goto ADD_BUILDING_TO_LIST; } FUNCTION_EXIT: - TRAK_LEN = iTrackLen; // Restore original TRAK_LEN value + TRAK_LEN = iTrackLen; // Restore original TRAK_LEN value } //------------------------------------------------------------------------------------------------- -//00069C10 -void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) -{ - tBuildingCoord *pScreenPt; // esi - tVec3 *pBuildingView; // ecx - tPolygon *pPols; // ebx - tVec3 *pCoords; // edi - int iClipped; // ebp - float *p_fZ; // eax - double dTransformedX; // st5 - double dTempX; // rt1 - double dTransformedY; // st5 - double dTempY; // rt2 - double dTransformedZ; // st5 - double dViewX; // st4 - double dViewY; // st4 - double dViewZ; // st7 - int iScreenY; // edx - int *p_iUnk3; // esi - int iPolygonLoop; // edi - int iZOrderIdx; // edx - float fMinZ1; // eax - float fMinZ2; // eax - float fPolygonZ; // eax - float fZ; // eax - float fMaxZ; // eax - int iZOrderLoop; // edx - int iPolygonLink; // esi - int k; // ebx - int iPolygonIndex; // ebx - tPolygon *pPolygon; // ebp - int iVert2; // eax - float fY; // edx - int iVert1; // eax - float fYCoord1; // edx - int iVert0; // eax - int iVert3; // eax - uint8 *pEndVerts; // edi - int iProjectedSum; // ebx - tPoint *pVerticesRev; // edx - uint8 *pVerts_1; // ecx +// 00069C10 +void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) { + tBuildingCoord *pScreenPt; // esi + tVec3 *pBuildingView; // ecx + tPolygon *pPols; // ebx + tVec3 *pCoords; // edi + int iClipped; // ebp + float *p_fZ; // eax + double dTransformedX; // st5 + double dTempX; // rt1 + double dTransformedY; // st5 + double dTempY; // rt2 + double dTransformedZ; // st5 + double dViewX; // st4 + double dViewY; // st4 + double dViewZ; // st7 + int iScreenY; // edx + int *p_iUnk3; // esi + int iPolygonLoop; // edi + int iZOrderIdx; // edx + float fMinZ1; // eax + float fMinZ2; // eax + float fPolygonZ; // eax + float fZ; // eax + float fMaxZ; // eax + int iZOrderLoop; // edx + int iPolygonLink; // esi + int k; // ebx + int iPolygonIndex; // ebx + tPolygon *pPolygon; // ebp + int iVert2; // eax + float fY; // edx + int iVert1; // eax + float fYCoord1; // edx + int iVert0; // eax + int iVert3; // eax + uint8 *pEndVerts; // edi + int iProjectedSum; // ebx + tPoint *pVerticesRev; // edx + uint8 *pVerts_1; // ecx tBuildingCoord *pScreenCoordRev; // eax - tPoint *pVertices; // edx - uint8 *pVerts; // ecx - tBuildingCoord *pScreenCoord; // eax - int *p_y; // edx - int iFinalVert0; // ebx - int iFinalVert1; // esi - int iFinalVert2; // ecx - int iFinalVert3; // edx - float fClosestZ1; // eax - float fClosestZ2; // eax - float fClosestZ; // eax - int iZOrderOffset; // ebp - double dCosYaw; // [esp+48h] [ebp-190h] - double dCosRoll; // [esp+58h] [ebp-180h] - double dSinYaw; // [esp+70h] [ebp-168h] - double dSinPitch; // [esp+78h] [ebp-160h] - double dCosPitch; // [esp+80h] [ebp-158h] - double dSinRoll; // [esp+88h] [ebp-150h] - float fCoordY; // [esp+90h] [ebp-148h] - float fBuildingZ; // [esp+94h] [ebp-144h] - int iViewY; // [esp+98h] [ebp-140h] - float fBuildingX; // [esp+9Ch] [ebp-13Ch] - float fX; // [esp+A0h] [ebp-138h] - float fCoordZ; // [esp+A4h] [ebp-134h] - float fBuildingY; // [esp+A8h] [ebp-130h] - int iViewX; // [esp+ACh] [ebp-12Ch] - float fVert1X; // [esp+B0h] [ebp-128h] - float fVert1Y; // [esp+B0h] [ebp-128h] - float fVert2Z; // [esp+B4h] [ebp-124h] - float fDeltaZ1; // [esp+B4h] [ebp-124h] - int iViewZ; // [esp+B8h] [ebp-120h] - float fVert2X; // [esp+BCh] [ebp-11Ch] - float fVert2Y; // [esp+C0h] [ebp-118h] - float fDeltaY1; // [esp+C0h] [ebp-118h] - float v75; // [esp+C4h] [ebp-114h] - float fDeltaX2; // [esp+C4h] [ebp-114h] - float fVert0Y; // [esp+C8h] [ebp-110h] - float fMatrix01; // [esp+CCh] [ebp-10Ch] - float fMatrix20; // [esp+D0h] [ebp-108h] - float fMatrix10; // [esp+D4h] [ebp-104h] - float fMatrix00; // [esp+D8h] [ebp-100h] - float fZDepth; // [esp+E0h] [ebp-F8h] - float fNormalDot; // [esp+F8h] [ebp-E0h] - float fRollAngle; // [esp+104h] [ebp-D4h] - float fRollRad; // [esp+104h] [ebp-D4h] - int iBestZOrderIdx; // [esp+108h] [ebp-D0h] - float fPitchAngle; // [esp+10Ch] [ebp-CCh] - float fPitchRad; // [esp+10Ch] [ebp-CCh] - float fDeltaY2; // [esp+118h] [ebp-C0h] - float fMatrix12; // [esp+11Ch] [ebp-BCh] - float fMatrix02; // [esp+120h] [ebp-B8h] - float fVert0Z; // [esp+124h] [ebp-B4h] - float fMatrix11; // [esp+128h] [ebp-B0h] - float fVert1Z; // [esp+13Ch] [ebp-9Ch] - float fDeltaZ2; // [esp+13Ch] [ebp-9Ch] - float fTempZ; // [esp+140h] [ebp-98h] - float fTempZ2; // [esp+154h] [ebp-84h] - float fTempClosestZ; // [esp+170h] [ebp-68h] - int iCurrentZOrderIdx; // [esp+184h] [ebp-54h] - float *p_fY; // [esp+188h] [ebp-50h] - int j; // [esp+190h] [ebp-48h] - int iFoundPolygonLink; // [esp+194h] [ebp-44h] - unsigned int uiBuildingType; // [esp+198h] [ebp-40h] - int uiTex; // [esp+1A0h] [ebp-38h] - float fYawAngle; // [esp+1A4h] [ebp-34h] - float fYawRad; // [esp+1A4h] [ebp-34h] - float v109; // [esp+1ACh] [ebp-2Ch] - int i; // [esp+1B0h] [ebp-28h] - float fMatrix21; // [esp+1B4h] [ebp-24h] - uint8 byNumPols; // [esp+1BCh] [ebp-1Ch] - uint8 byNumCoords; // [esp+1C0h] [ebp-18h] + tPoint *pVertices; // edx + uint8 *pVerts; // ecx + tBuildingCoord *pScreenCoord; // eax + int *p_y; // edx + int iFinalVert0; // ebx + int iFinalVert1; // esi + int iFinalVert2; // ecx + int iFinalVert3; // edx + float fClosestZ1; // eax + float fClosestZ2; // eax + float fClosestZ; // eax + int iZOrderOffset; // ebp + double dCosYaw; // [esp+48h] [ebp-190h] + double dCosRoll; // [esp+58h] [ebp-180h] + double dSinYaw; // [esp+70h] [ebp-168h] + double dSinPitch; // [esp+78h] [ebp-160h] + double dCosPitch; // [esp+80h] [ebp-158h] + double dSinRoll; // [esp+88h] [ebp-150h] + float fCoordY; // [esp+90h] [ebp-148h] + float fBuildingZ; // [esp+94h] [ebp-144h] + int iViewY; // [esp+98h] [ebp-140h] + float fBuildingX; // [esp+9Ch] [ebp-13Ch] + float fX; // [esp+A0h] [ebp-138h] + float fCoordZ; // [esp+A4h] [ebp-134h] + float fBuildingY; // [esp+A8h] [ebp-130h] + int iViewX; // [esp+ACh] [ebp-12Ch] + float fVert1X; // [esp+B0h] [ebp-128h] + float fVert1Y; // [esp+B0h] [ebp-128h] + float fVert2Z; // [esp+B4h] [ebp-124h] + float fDeltaZ1; // [esp+B4h] [ebp-124h] + int iViewZ; // [esp+B8h] [ebp-120h] + float fVert2X; // [esp+BCh] [ebp-11Ch] + float fVert2Y; // [esp+C0h] [ebp-118h] + float fDeltaY1; // [esp+C0h] [ebp-118h] + float v75; // [esp+C4h] [ebp-114h] + float fDeltaX2; // [esp+C4h] [ebp-114h] + float fVert0Y; // [esp+C8h] [ebp-110h] + float fMatrix01; // [esp+CCh] [ebp-10Ch] + float fMatrix20; // [esp+D0h] [ebp-108h] + float fMatrix10; // [esp+D4h] [ebp-104h] + float fMatrix00; // [esp+D8h] [ebp-100h] + float fZDepth; // [esp+E0h] [ebp-F8h] + float fNormalDot; // [esp+F8h] [ebp-E0h] + float fRollAngle; // [esp+104h] [ebp-D4h] + float fRollRad; // [esp+104h] [ebp-D4h] + int iBestZOrderIdx; // [esp+108h] [ebp-D0h] + float fPitchAngle; // [esp+10Ch] [ebp-CCh] + float fPitchRad; // [esp+10Ch] [ebp-CCh] + float fDeltaY2; // [esp+118h] [ebp-C0h] + float fMatrix12; // [esp+11Ch] [ebp-BCh] + float fMatrix02; // [esp+120h] [ebp-B8h] + float fVert0Z; // [esp+124h] [ebp-B4h] + float fMatrix11; // [esp+128h] [ebp-B0h] + float fVert1Z; // [esp+13Ch] [ebp-9Ch] + float fDeltaZ2; // [esp+13Ch] [ebp-9Ch] + float fTempZ; // [esp+140h] [ebp-98h] + float fTempZ2; // [esp+154h] [ebp-84h] + float fTempClosestZ; // [esp+170h] [ebp-68h] + int iCurrentZOrderIdx; // [esp+184h] [ebp-54h] + float *p_fY; // [esp+188h] [ebp-50h] + int j; // [esp+190h] [ebp-48h] + int iFoundPolygonLink; // [esp+194h] [ebp-44h] + unsigned int uiBuildingType; // [esp+198h] [ebp-40h] + int uiTex; // [esp+1A0h] [ebp-38h] + float fYawAngle; // [esp+1A4h] [ebp-34h] + float fYawRad; // [esp+1A4h] [ebp-34h] + float v109; // [esp+1ACh] [ebp-2Ch] + int i; // [esp+1B0h] [ebp-28h] + float fMatrix21; // [esp+1B4h] [ebp-24h] + uint8 byNumPols; // [esp+1BCh] [ebp-1Ch] + uint8 byNumCoords; // [esp+1C0h] [ebp-18h] tVec3 worldCoords[32]; float sortDepths[32]; int viewIntX[32]; @@ -494,15 +557,20 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) int screenClipped[32]; if (iBuildingIdx < 0) - return; //added by ROLLER + return; // added by ROLLER - set_starts(0); // Initialize rendering system - uiBuildingType = BuildingBase[iBuildingIdx][0];// Get building plan data (polygons, coordinates, etc.) + set_starts(0); // Initialize rendering system + uiBuildingType = + BuildingBase[iBuildingIdx] + [0]; // Get building plan data (polygons, coordinates, etc.) byNumPols = BuildingPlans[uiBuildingType].byNumPols; pPols = BuildingPlans[uiBuildingType].pPols; byNumCoords = BuildingPlans[uiBuildingType].byNumCoords; pCoords = BuildingPlans[uiBuildingType].pCoords; - if (uiBuildingType >= 9 && (uiBuildingType <= 0xA || uiBuildingType == 15))// Special rotation for buildings 9, 10, and 15 based on world direction + if (uiBuildingType >= 9 && + (uiBuildingType <= 0xA || + uiBuildingType == 15)) // Special rotation for buildings 9, 10, and 15 + // based on world direction { fPitchAngle = BuildingAngles[3 * iBuildingIdx + 1]; fRollAngle = BuildingAngles[3 * iBuildingIdx + 2]; @@ -512,12 +580,13 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) fPitchAngle = BuildingAngles[3 * iBuildingIdx + 1]; fRollAngle = BuildingAngles[3 * iBuildingIdx + 2]; } - fYawRad = fYawAngle * 0.0174532925199f; // Convert rotation angles from degrees to radians + fYawRad = fYawAngle * + 0.0174532925199f; // Convert rotation angles from degrees to radians fPitchRad = fPitchAngle * 0.0174532925199f; fRollRad = 0.0174532925199f * fRollAngle; fBuildingX = BuildingX[iBuildingIdx]; fBuildingZ = BuildingZ[iBuildingIdx]; - dCosYaw = cos(fYawRad); // Calculate sine and cosine for 3D rotation matrix + dCosYaw = cos(fYawRad); // Calculate sine and cosine for 3D rotation matrix dCosPitch = cos(fPitchRad); dSinYaw = sin(fYawRad); dSinPitch = sin(fPitchRad); @@ -528,7 +597,8 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) p_fY = &pCoords->fY; p_fZ = &pCoords->fZ; // CHEAT_MODE_DOUBLE_TRACK - if ((cheat_mode & 0x1000) != 0) // Scale coordinates 2x if cheat mode enabled + if ((cheat_mode & 0x1000) != + 0) // Scale coordinates 2x if cheat mode enabled { fX = pCoords->fX * 2.0f; fCoordY = *p_fY * 2.0f; @@ -540,23 +610,29 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) v109 = *p_fZ; fCoordY = *p_fY; } - fMatrix01 = (float)(dCosYaw * dSinPitch * dSinRoll - dSinYaw * dCosRoll);// Build 3x3 rotation matrix elements from yaw/pitch/roll + fMatrix01 = (float)(dCosYaw * dSinPitch * dSinRoll - + dSinYaw * dCosRoll); // Build 3x3 rotation matrix + // elements from yaw/pitch/roll fMatrix00 = (float)(dCosYaw * dCosPitch); fMatrix02 = (float)(-dCosYaw * dSinPitch * dCosRoll - dSinYaw * dSinRoll); - dTransformedX = fX * fMatrix00 + fCoordY * fMatrix01 + v109 * fMatrix02 + fBuildingX;// Apply 3D rotation and translation to building coordinates + dTransformedX = + fX * fMatrix00 + fCoordY * fMatrix01 + v109 * fMatrix02 + + fBuildingX; // Apply 3D rotation and translation to building coordinates dTempX = dTransformedX; fMatrix10 = (float)(dSinYaw * dCosPitch); fMatrix12 = (float)(-dSinYaw * dSinPitch * dCosRoll + dCosYaw * dSinRoll); fMatrix11 = (float)(dSinYaw * dSinPitch * dSinRoll + dCosYaw * dCosRoll); - dTransformedY = fX * fMatrix10 + fCoordY * fMatrix11 + v109 * fMatrix12 + fBuildingY; + dTransformedY = + fX * fMatrix10 + fCoordY * fMatrix11 + v109 * fMatrix12 + fBuildingY; dTempY = dTransformedY; fVert2X = (float)(dCosPitch * dCosRoll); fMatrix20 = (float)dSinPitch; fMatrix21 = (float)(-dSinRoll * dCosPitch); - dTransformedZ = fX * fMatrix20 + fCoordY * fMatrix21 + v109 * fVert2X + fBuildingZ; - // Store raw (un-floored, un-translated) world coords for game_render_quad_world. - // sw_quad_world performs floor(world − viewer) and the view-matrix multiply - // itself, matching legacy precision. + dTransformedZ = + fX * fMatrix20 + fCoordY * fMatrix21 + v109 * fVert2X + fBuildingZ; + // Store raw (un-floored, un-translated) world coords for + // game_render_quad_world. sw_quad_world performs floor(world − viewer) and + // the view-matrix multiply itself, matching legacy precision. worldCoords[i].fX = (float)dTempX; worldCoords[i].fY = (float)dTempY; worldCoords[i].fZ = (float)dTransformedZ; @@ -589,10 +665,12 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) iPolygonLoop = 0; iZOrderIdx = 0; while (iPolygonLoop < byNumPols) { - BuildingZOrder[iZOrderIdx].iPolygonIndex = iPolygonLoop;// Build Z-order sorting list for polygons + BuildingZOrder[iZOrderIdx].iPolygonIndex = + iPolygonLoop; // Build Z-order sorting list for polygons BuildingZOrder[iZOrderIdx].iPolygonLink = pPols->nNextPolIdx; - if ((pPols->uiTex & 0x8000) == 0) // Calculate polygon Z depth for sorting (front-to-back vs back-to-front) - { // Find maximum Z (farthest) for back-to-front rendering order + if ((pPols->uiTex & 0x8000) == 0) // Calculate polygon Z depth for sorting + // (front-to-back vs back-to-front) + { // Find maximum Z (farthest) for back-to-front rendering order if (sortDepths[pPols->verts[2]] <= (double)sortDepths[pPols->verts[3]]) fZ = sortDepths[pPols->verts[3]]; else @@ -607,12 +685,13 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) fPolygonZ = sortDepths[pPols->verts[3]]; else fPolygonZ = sortDepths[pPols->verts[2]]; - } else if (sortDepths[pPols->verts[0]] <= (double)sortDepths[pPols->verts[1]]) { + } else if (sortDepths[pPols->verts[0]] <= + (double)sortDepths[pPols->verts[1]]) { fPolygonZ = sortDepths[pPols->verts[1]]; } else { fPolygonZ = sortDepths[pPols->verts[0]]; } - } else { // Find minimum Z (closest) for front-to-back rendering order + } else { // Find minimum Z (closest) for front-to-back rendering order if (sortDepths[pPols->verts[2]] >= (double)sortDepths[pPols->verts[3]]) fMinZ1 = sortDepths[pPols->verts[3]]; else @@ -627,7 +706,8 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) fPolygonZ = sortDepths[pPols->verts[3]]; else fPolygonZ = sortDepths[pPols->verts[2]]; - } else if (sortDepths[pPols->verts[0]] >= (double)sortDepths[pPols->verts[1]]) { + } else if (sortDepths[pPols->verts[0]] >= + (double)sortDepths[pPols->verts[1]]) { fPolygonZ = sortDepths[pPols->verts[1]]; } else { fPolygonZ = sortDepths[pPols->verts[0]]; @@ -638,13 +718,14 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) ++iZOrderIdx; ++iPolygonLoop; } - qsort(BuildingZOrder, byNumPols, 0xCu, bldZcmp);// Sort polygons by Z-depth using qsort + qsort(BuildingZOrder, byNumPols, 0xCu, + bldZcmp); // Sort polygons by Z-depth using qsort for (j = 0; byNumPols > j; ++j) { iZOrderLoop = 0; iFoundPolygonLink = -1; iPolygonLink = -1; fZDepth = -32768.0; - for (k = 0; k < byNumPols; ++k) // Find deepest polygon in each linked group + for (k = 0; k < byNumPols; ++k) // Find deepest polygon in each linked group { if (BuildingZOrder[iZOrderLoop].iPolygonLink != iPolygonLink) { iPolygonLink = BuildingZOrder[iZOrderLoop].iPolygonLink; @@ -683,32 +764,41 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) float fDx13 = (float)viewIntX[iV1] - (float)viewIntX[iV3]; float fDy13 = (float)viewIntY[iV1] - (float)viewIntY[iV3]; float fDz13 = (float)viewIntZ[iV1] - (float)viewIntZ[iV3]; - double fNormalDot = (fDy02 * fDz13 - fDz02 * fDy13) * fX0 - + (fDz02 * fDx13 - fDx02 * fDz13) * fY0 - + (fDx02 * fDy13 - fDy02 * fDx13) * fZ0; + double fNormalDot = (fDy02 * fDz13 - fDz02 * fDy13) * fX0 + + (fDz02 * fDx13 - fDx02 * fDz13) * fY0 + + (fDx02 * fDy13 - fDy02 * fDx13) * fZ0; int isBackFace = (fNormalDot >= 0.0); if (isBackFace && (uiTex & SURFACE_FLAG_FLIP_BACKFACE) == 0) goto skip_polygon; - // Sum per-vertex clip flags; skip if entire poly is behind near plane. - int iProjectedSum = screenClipped[iV0] + screenClipped[iV1] - + screenClipped[iV2] + screenClipped[iV3]; + // Sum per-vertex clip flags; skip if entire poly is behind near + // plane. + int iProjectedSum = screenClipped[iV0] + screenClipped[iV1] + + screenClipped[iV2] + screenClipped[iV3]; if (iProjectedSum >= 4) goto skip_polygon; // Handle special textures (advertisements, building remapping) if ((uiTex & 0x200) != 0) uiTex = advert_list[iBuildingIdx]; - if ((textures_off & TEX_OFF_BUILDING_TEXTURES) != 0 && (uiTex & SURFACE_FLAG_APPLY_TEXTURE) != 0) + if ((textures_off & TEX_OFF_BUILDING_TEXTURES) != 0 && + (uiTex & SURFACE_FLAG_APPLY_TEXTURE) != 0) uiTex = (uiTex & 0xFFFFFE00) + bld_remap[(uint8)uiTex]; // Vertex order: forward for front-facing, reversed for the - // back-facing SURFACE_FLAG_FLIP_BACKFACE case so texture mapping stays correct. + // back-facing SURFACE_FLAG_FLIP_BACKFACE case so texture mapping + // stays correct. int iOrder[4]; if (isBackFace) { - iOrder[0] = iV3; iOrder[1] = iV2; iOrder[2] = iV1; iOrder[3] = iV0; + iOrder[0] = iV3; + iOrder[1] = iV2; + iOrder[2] = iV1; + iOrder[3] = iV0; } else { - iOrder[0] = iV0; iOrder[1] = iV1; iOrder[2] = iV2; iOrder[3] = iV3; + iOrder[0] = iV0; + iOrder[1] = iV1; + iOrder[2] = iV2; + iOrder[3] = iV3; } // Closest-Z determines whether the legacy path subdivided. @@ -717,8 +807,10 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) int iZ2 = viewIntZ[iV2]; int iZ3 = viewIntZ[iV3]; float fClosestZ = (float)((iZ0 < iZ1) ? iZ0 : iZ1); - if ((float)iZ2 < fClosestZ) fClosestZ = (float)iZ2; - if ((float)iZ3 < fClosestZ) fClosestZ = (float)iZ3; + if ((float)iZ2 < fClosestZ) + fClosestZ = (float)iZ2; + if ((float)iZ3 < fClosestZ) + fClosestZ = (float)iZ3; GameRenderVertex verts[4]; for (int vi = 0; vi < 4; vi++) { @@ -734,41 +826,43 @@ void DrawBuilding(int iBuildingIdx, uint8 *pScrPtr) // and should use an invalid texture handle. TextureHandle th = ((uiTex & SURFACE_FLAG_APPLY_TEXTURE) != 0) - ? game_render_get_texture_handle(g_pGameRenderer, TEXTURE_BANK_BUILDING) - : TEXTURE_HANDLE_INVALID; + ? game_render_get_texture_handle( + g_pGameRenderer, TEXTURE_BANK_BUILDING) + : TEXTURE_HANDLE_INVALID; game_render_quad_world_subdivide_type( - g_pGameRenderer, verts, th, (int)uiTex, - GAME_RENDER_SUBDIVIDE_TYPE_BUILDING, - (float)BuildingSub[uiBuildingType] * subscale); + g_pGameRenderer, verts, th, (int)uiTex, + GAME_RENDER_SUBDIVIDE_TYPE_BUILDING, + (float)BuildingSub[uiBuildingType] * subscale); } - skip_polygon:; + skip_polygon:; iZOrderOffset = iCurrentZOrderIdx * 12 + 12; ++iCurrentZOrderIdx; ++iBestZOrderIdx; - } while (byNumPols > iBestZOrderIdx && iFoundPolygonLink == *(int *)((char *)&BuildingZOrder[0].iPolygonLink + iZOrderOffset)); + } while (byNumPols > iBestZOrderIdx && + iFoundPolygonLink == + *(int *)((char *)&BuildingZOrder[0].iPolygonLink + + iZOrderOffset)); } } - init_animate_ads(); // Initialize animated advertisements + init_animate_ads(); // Initialize animated advertisements } //------------------------------------------------------------------------------------------------- -//0006AB30 -void init_animate_ads() -{ - ; -} +// 0006AB30 +void init_animate_ads() { ; } //------------------------------------------------------------------------------------------------- -//0006AB40 -int bldZcmp(const void *pBuilding1, const void *pBuilding2) -{ +// 0006AB40 +int bldZcmp(const void *pBuilding1, const void *pBuilding2) { int iPolygonLink1; // ecx int iPolygonLink2; // ebx - float fZDepth2; // [esp+0h] [ebp-10h] - float fZDepth1; // [esp+4h] [ebp-Ch] + float fZDepth2; // [esp+0h] [ebp-10h] + float fZDepth1; // [esp+4h] [ebp-Ch] - const tBuildingZOrderEntry *pEntry1 = (const tBuildingZOrderEntry *)pBuilding1; - const tBuildingZOrderEntry *pEntry2 = (const tBuildingZOrderEntry *)pBuilding2; + const tBuildingZOrderEntry *pEntry1 = + (const tBuildingZOrderEntry *)pBuilding1; + const tBuildingZOrderEntry *pEntry2 = + (const tBuildingZOrderEntry *)pBuilding2; iPolygonLink1 = pEntry1->iPolygonLink; fZDepth1 = pEntry1->fZDepth; diff --git a/PROJECTS/ROLLER/building.h b/PROJECTS/ROLLER/building.h index 30202d0e..190e639e 100644 --- a/PROJECTS/ROLLER/building.h +++ b/PROJECTS/ROLLER/building.h @@ -6,16 +6,14 @@ #include "polyf.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iBuildingIdx; float fDepth; } tVisibleBuilding; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fZDepth; int iPolygonLink; int iPolygonIndex; @@ -23,8 +21,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iX; int iY; int iClipped; diff --git a/PROJECTS/ROLLER/car.c b/PROJECTS/ROLLER/car.c index 9a86f3c5..d5a09218 100644 --- a/PROJECTS/ROLLER/car.c +++ b/PROJECTS/ROLLER/car.c @@ -13,9 +13,11 @@ // Saturating double-to-int cast — avoids UB when screen/projection // coordinates overflow int32 range (caught by UBSan in Debug builds). static inline int d2i(double d) { - if (d >= (double)INT_MAX) return INT_MAX; - if (d <= (double)INT_MIN) return INT_MIN; - return (int)d; + if (d >= (double)INT_MAX) + return INT_MAX; + if (d <= (double)INT_MIN) + return INT_MIN; + return (int)d; } #include "func2.h" #include "function.h" @@ -30,79 +32,62 @@ static inline int d2i(double d) { #include //------------------------------------------------------------------------------------------------- -const int car_c_reference_1[4] = { 0, 1, 1, 2 }; +const int car_c_reference_1[4] = {0, 1, 1, 2}; //------------------------------------------------------------------------------------------------- -int numcars = 16; //000A6114 -int team_col[16] = //000A6118 -{ - 255, 207, 231, 171, 219, 195, 143, 243, 159, 159, 159, 159, 159, 112, 112, 112 -}; -char default_names[16][9] = { //000A6158 - "SAL", - "HAL", - "SLAVE", - "ZEN", - "ASH", - "BISHOP", - "VOYAGER", - "NOMAD", - "BOB", - "VINCENT", - "EDDIE", - "MARVIN", - "KRYTEN", - "HOLLY", - "ROBBY", - "GORT" -}; -int16 ViewType[2] = { 0, 0 }; //000A620C -tVec3 carworld[4]; //0017C9E0 -tVec3 carpoint[4]; //0017CA10 -tVec3 carlocal[4]; //0017CA40 -float roadheight[4]; //0017CA70 -tCarPt CarPt[128]; //0017CA80 -tCarZOrderEntry CarZOrder[MAX_TRACK_CHUNKS]; //0017DA80 -tCarDrawOrder car_draw_order[16]; //0017F1F0 -int car_texmap[16]; //0017F2B0 -tCarBox CarBox; //0017F2F0 -tCar Car[16]; //0017F8F0 -int car_persps[128]; //00180C30 -tCarPt SmokePt[2][64]; //00180E30 -int car_texs_loaded[16]; //00181E30 -tCarSpray CarSpray[18][32]; //00181E70 -char driver_names[16][9]; //00188170 -tStoreEngine StoreEngines[14]; //00188200 -tSLight SLight[2][3]; //00188350 -int finished_car[16]; //00188470 -int grid[16]; //001884B0 -tPolyParams CarPol; //001884F0 -int cars_drawn; //00188528 -float CarBaseX; //0018851C -float CarBaseY; //00188520 -int LoadCarTextures; //0018852C -float CarDiag; //00188524 +int numcars = 16; // 000A6114 +int team_col[16] = // 000A6118 + {255, 207, 231, 171, 219, 195, 143, 243, + 159, 159, 159, 159, 159, 112, 112, 112}; +char default_names[16][9] = { // 000A6158 + "SAL", "HAL", "SLAVE", "ZEN", "ASH", "BISHOP", "VOYAGER", "NOMAD", + "BOB", "VINCENT", "EDDIE", "MARVIN", "KRYTEN", "HOLLY", "ROBBY", "GORT"}; +int16 ViewType[2] = {0, 0}; // 000A620C +tVec3 carworld[4]; // 0017C9E0 +tVec3 carpoint[4]; // 0017CA10 +tVec3 carlocal[4]; // 0017CA40 +float roadheight[4]; // 0017CA70 +tCarPt CarPt[128]; // 0017CA80 +tCarZOrderEntry CarZOrder[MAX_TRACK_CHUNKS]; // 0017DA80 +tCarDrawOrder car_draw_order[16]; // 0017F1F0 +int car_texmap[16]; // 0017F2B0 +tCarBox CarBox; // 0017F2F0 +tCar Car[16]; // 0017F8F0 +int car_persps[128]; // 00180C30 +tCarPt SmokePt[2][64]; // 00180E30 +int car_texs_loaded[16]; // 00181E30 +tCarSpray CarSpray[18][32]; // 00181E70 +char driver_names[16][9]; // 00188170 +tStoreEngine StoreEngines[14]; // 00188200 +tSLight SLight[2][3]; // 00188350 +int finished_car[16]; // 00188470 +int grid[16]; // 001884B0 +tPolyParams CarPol; // 001884F0 +int cars_drawn; // 00188528 +float CarBaseX; // 0018851C +float CarBaseY; // 00188520 +int LoadCarTextures; // 0018852C +float CarDiag; // 00188524 //------------------------------------------------------------------------------------------------- -//00052270 -void InitCarStructs() -{ - int carDesignIndex; // ebx - int v1; // esi +// 00052270 +void InitCarStructs() { + int carDesignIndex; // ebx + int v1; // esi int carDesignIndex2; // ecx - int iNumGears; // edi - float *pSpds; // ebx - int j; // ecx - double v6; // st7 - int iCurrGear; // ebx - int iChgIdx; // ecx + int iNumGears; // edi + float *pSpds; // ebx + int j; // ecx + double v6; // st7 + int iCurrGear; // ebx + int iChgIdx; // ecx int carDesignIndex3; // esi - int iRevsOffset; // ebp - int iNextGear; // edx - float fChg; // [esp+0h] [ebp-20h] - float fNextChg; // [esp+0h] [ebp-20h] - int16 i; // [esp+4h] [ebp-1Ch] + int iRevsOffset; // ebp + int iNextGear; // edx + float fChg; // [esp+0h] [ebp-20h] + float fNextChg; // [esp+0h] [ebp-20h] + int16 i; // [esp+4h] [ebp-1Ch] for (i = 0; i < 14; ++i) { carDesignIndex = (int)i; @@ -124,17 +109,17 @@ void InitCarStructs() if (iNumGears > 0) { iChgIdx = 0; do { - carDesignIndex3 = (int)i; // why is this defined a second time + carDesignIndex3 = (int)i; // why is this defined a second time iRevsOffset = 12 * i; fChg = (float)CarEngines.engines[carDesignIndex3].pChgs[iChgIdx]; - eng_chg_revs[iChgIdx + iRevsOffset] = (float)calc_revs(CarEngines.engines[carDesignIndex3].pRevs, iCurrGear, fChg); - fNextChg = (float)CarEngines.engines[carDesignIndex3].pChgs[iChgIdx + 1]; + eng_chg_revs[iChgIdx + iRevsOffset] = (float)calc_revs( + CarEngines.engines[carDesignIndex3].pRevs, iCurrGear, fChg); + fNextChg = + (float)CarEngines.engines[carDesignIndex3].pChgs[iChgIdx + 1]; iChgIdx += 2; iNextGear = iCurrGear++; eng_chg_revs[iChgIdx + iRevsOffset - 1] = (float)calc_revs( - CarEngines.engines[carDesignIndex3].pRevs, - iNextGear, - fNextChg); + CarEngines.engines[carDesignIndex3].pRevs, iNextGear, fNextChg); } while (iCurrGear < iNumGears); } } @@ -147,25 +132,24 @@ void InitCarStructs() } //------------------------------------------------------------------------------------------------- -//000523A0 -void CalcCarSizes() -{ +// 000523A0 +void CalcCarSizes() { int16 nCarDesignsIdx; // cx - int16 nCoordsIdx; // bx - tVec3 *pCoords; // edx - double fY; // st7 - float *p_fY; // edx - double dZ; // st7 - float *p_fZ; // edx - int iCarBoxIdx; // eax - tVec3 *pAutoCoords; // edx + int16 nCoordsIdx; // bx + tVec3 *pCoords; // edx + double fY; // st7 + float *p_fY; // edx + double dZ; // st7 + float *p_fZ; // edx + int iCarBoxIdx; // eax + tVec3 *pAutoCoords; // edx int16 nAutoCoordsIdx; // bx - float fZLow; // [esp+0h] [ebp-28h] - float fZHigh; // [esp+4h] [ebp-24h] - float fYHigh; // [esp+8h] [ebp-20h] - float fXHigh; // [esp+Ch] [ebp-1Ch] - float fYLow; // [esp+10h] [ebp-18h] - float fXLow; // [esp+14h] [ebp-14h] + float fZLow; // [esp+0h] [ebp-28h] + float fZHigh; // [esp+4h] [ebp-24h] + float fYHigh; // [esp+8h] [ebp-20h] + float fXHigh; // [esp+Ch] [ebp-1Ch] + float fYLow; // [esp+10h] [ebp-18h] + float fXLow; // [esp+14h] [ebp-14h] for (nCarDesignsIdx = 0; nCarDesignsIdx < 14; ++nCarDesignsIdx) { fZLow = 1073741800.0f; @@ -175,7 +159,8 @@ void CalcCarSizes() fYHigh = -1073741800.0f; fXHigh = -1073741800.0f; nCoordsIdx = 0; - // Go through everything listed in CarDesigns and get the max and min values to generate a hit box for each car + // Go through everything listed in CarDesigns and get the max and min values + // to generate a hit box for each car pCoords = CarDesigns[nCarDesignsIdx].pCoords; while (nCoordsIdx < CarDesigns[nCarDesignsIdx].byNumCoords) { if (pCoords->fX < (double)fXLow) @@ -188,13 +173,14 @@ void CalcCarSizes() fYLow = *p_fY; if (*p_fY > (double)fYHigh) fYHigh = *p_fY; - dZ = p_fY[1]; // why is it like this + dZ = p_fY[1]; // why is it like this p_fZ = p_fY + 1; if (dZ < fZLow) fZLow = *p_fZ; if (*p_fZ > (double)fZHigh) fZHigh = *p_fZ; - pCoords = (tVec3 *)(p_fZ + 1); // funny way to get to the next set of coords + pCoords = + (tVec3 *)(p_fZ + 1); // funny way to get to the next set of coords ++nCoordsIdx; } // Multiply by tinycar value if using tinycar cheat @@ -204,7 +190,7 @@ void CalcCarSizes() fXHigh = fXHigh * 0.25f; fYHigh = fYHigh * 0.25f; } - iCarBoxIdx = nCarDesignsIdx; // 24 for 8 3-float points defining a hitbox + iCarBoxIdx = nCarDesignsIdx; // 24 for 8 3-float points defining a hitbox CarBox.hitboxAy[iCarBoxIdx][0].fX = fXLow; CarBox.hitboxAy[iCarBoxIdx][0].fY = fYLow; CarBox.hitboxAy[iCarBoxIdx][0].fZ = fZLow; @@ -230,10 +216,11 @@ void CalcCarSizes() CarBox.hitboxAy[iCarBoxIdx][7].fY = fYHigh; CarBox.hitboxAy[iCarBoxIdx][7].fZ = fZHigh; } - pAutoCoords = CarDesigns[0].pCoords; // ptr to xauto_coords + pAutoCoords = CarDesigns[0].pCoords; // ptr to xauto_coords CarBaseX = 0.0; CarBaseY = 0.0; - for (nAutoCoordsIdx = 0; nAutoCoordsIdx < CarDesigns[0].byNumCoords; ++nAutoCoordsIdx) { + for (nAutoCoordsIdx = 0; nAutoCoordsIdx < CarDesigns[0].byNumCoords; + ++nAutoCoordsIdx) { if (pAutoCoords->fX > (double)CarBaseX) CarBaseX = pAutoCoords->fX; if (pAutoCoords->fY > (double)CarBaseY) @@ -248,23 +235,22 @@ void CalcCarSizes() } //------------------------------------------------------------------------------------------------- -//00052650 -void InitCars() -{ - int16 i; // si - int16 nNumGears; // di - int16 j; // bx - int16 k; // bx - int iCurrCar; // eax - uint8 byCarDesign; // dl - int iCarTexIdxSetUnloaded; // eax +// 00052650 +void InitCars() { + int16 i; // si + int16 nNumGears; // di + int16 j; // bx + int16 k; // bx + int iCurrCar; // eax + uint8 byCarDesign; // dl + int iCarTexIdxSetUnloaded; // eax int iCurrCarTexIdxSetUnloaded; // edx - int16 nCarTexIdx; // di - eCarType carType; // eax - eCarType carTexsLoadedIndex; // esi - int iCarTexLoaded; // edx - int iCurrCarTex; // ecx - int16 m; // [esp+0h] [ebp-1Ch] + int16 nCarTexIdx; // di + eCarType carType; // eax + eCarType carTexsLoadedIndex; // esi + int iCarTexLoaded; // edx + int iCurrCarTex; // ecx + int16 m; // [esp+0h] [ebp-1Ch] for (i = 0; i < 14; ++i) { nNumGears = CarEngines.engines[i].iNumGears; @@ -311,104 +297,120 @@ void InitCars() } //------------------------------------------------------------------------------------------------- -//000527C0 -void placecars() -{ +// 000527C0 +void placecars() { unsigned int uiStartingLane; // ecx - int iDriverIdx; // edi - int iCarIdx; // eax - uint8 byDriversCarDesign; // dl - char byCarIdx; // dl - int iCarIdx2; // eax - int iChampMode; // esi - int16 nStartChunk; // dx - int iCarIdx3; // ebx - int iRandomVal; // eax - unsigned int uiOrderOffset; // eax - int iCarIdx4; // esi - tVec3 *pTrackData; // eax - double dZCmp; // st7 - int iViewCarIdx; // ebx - tCarEngine *pEngine; // eax - char byGearAyMax; // dl - double dPower; // st7 - int nCurrChunk; // edx - tData *pTrackLocalData; // ebp - double dTrackYPos; // st7 - int iPlayers; // edi - int iMaxOffset; // ebp - int iPlayerIdx; // esi - int iPlayerCarIdx; // eax - unsigned int iSLightOffset; // edx - double dZ; // st7 - int nPlayerChunk; // ebx - float *pLightTrackData; // ebx - double dTransform1; // st7 - double dTransform2; // st7 - double dTransform3; // st6 - double dTransform4; // st7 - double dTransform5; // st7 - double dTransform6; // st6 - double dLightSpeedZ; // st7 - int surfaceTypeAy[4]; // [esp+0h] [ebp-50h] - float fX; // [esp+10h] [ebp-40h] - tTrackInfo *pTrackChunk; // [esp+14h] [ebp-3Ch] - float fTempZ; // [esp+18h] [ebp-38h] - float fY; // [esp+1Ch] [ebp-34h] - float fLightPosX; // [esp+20h] [ebp-30h] - float fLightPosZ; // [esp+24h] [ebp-2Ch] - unsigned int uiGridOffset; // [esp+28h] [ebp-28h] - int iCarCounter; // [esp+2Ch] [ebp-24h] - int iGridOffsetDWords; // [esp+30h] [ebp-20h] - int iGridOffsetWords; // [esp+34h] [ebp-1Ch] + int iDriverIdx; // edi + int iCarIdx; // eax + uint8 byDriversCarDesign; // dl + char byCarIdx; // dl + int iCarIdx2; // eax + int iChampMode; // esi + int16 nStartChunk; // dx + int iCarIdx3; // ebx + int iRandomVal; // eax + unsigned int uiOrderOffset; // eax + int iCarIdx4; // esi + tVec3 *pTrackData; // eax + double dZCmp; // st7 + int iViewCarIdx; // ebx + tCarEngine *pEngine; // eax + char byGearAyMax; // dl + double dPower; // st7 + int nCurrChunk; // edx + tData *pTrackLocalData; // ebp + double dTrackYPos; // st7 + int iPlayers; // edi + int iMaxOffset; // ebp + int iPlayerIdx; // esi + int iPlayerCarIdx; // eax + unsigned int iSLightOffset; // edx + double dZ; // st7 + int nPlayerChunk; // ebx + float *pLightTrackData; // ebx + double dTransform1; // st7 + double dTransform2; // st7 + double dTransform3; // st6 + double dTransform4; // st7 + double dTransform5; // st7 + double dTransform6; // st6 + double dLightSpeedZ; // st7 + int surfaceTypeAy[4]; // [esp+0h] [ebp-50h] + float fX; // [esp+10h] [ebp-40h] + tTrackInfo *pTrackChunk; // [esp+14h] [ebp-3Ch] + float fTempZ; // [esp+18h] [ebp-38h] + float fY; // [esp+1Ch] [ebp-34h] + float fLightPosX; // [esp+20h] [ebp-30h] + float fLightPosZ; // [esp+24h] [ebp-2Ch] + unsigned int uiGridOffset; // [esp+28h] [ebp-28h] + int iCarCounter; // [esp+2Ch] [ebp-24h] + int iGridOffsetDWords; // [esp+30h] [ebp-20h] + int iGridOffsetWords; // [esp+34h] [ebp-1Ch] - surfaceTypeAy[0] = car_c_reference_1[0]; // Copy car reference array (car type lookup table) + surfaceTypeAy[0] = + car_c_reference_1[0]; // Copy car reference array (car type lookup table) surfaceTypeAy[1] = car_c_reference_1[1]; surfaceTypeAy[2] = car_c_reference_1[2]; surfaceTypeAy[3] = car_c_reference_1[3]; - memset(Car, 0, sizeof(tCar) * numcars); // Initialize all car data structures to zero + memset(Car, 0, + sizeof(tCar) * numcars); // Initialize all car data structures to zero uiStartingLane = 1; - memset(CarSpray, 0, 1408 * (numcars + 2)); // Initialize spray effect data for all cars + 2 extra - iCarCounter = 0; // Start car placement loop + memset(CarSpray, 0, + 1408 * (numcars + + 2)); // Initialize spray effect data for all cars + 2 extra + iCarCounter = 0; // Start car placement loop if (numcars > 0) { iGridOffsetDWords = 4 * iCarCounter; uiGridOffset = 0; iGridOffsetWords = 2 * iCarCounter; do { - iDriverIdx = grid[uiGridOffset / 4]; // Get driver index from grid position + iDriverIdx = + grid[uiGridOffset / 4]; // Get driver index from grid position iCarIdx = iDriverIdx; - byDriversCarDesign = Drivers_Car[iDriverIdx];// Get car design for this driver - Car[iCarIdx].iDriverIdx = iDriverIdx; // Set driver index for this car - finished_car[iDriverIdx] = 0; // Mark driver as not finished + byDriversCarDesign = + Drivers_Car[iDriverIdx]; // Get car design for this driver + Car[iCarIdx].iDriverIdx = iDriverIdx; // Set driver index for this car + finished_car[iDriverIdx] = 0; // Mark driver as not finished Car[iCarIdx].byCarDesignIdx = byDriversCarDesign; byCarIdx = iCarCounter; Car[iCarIdx].pos.fX = 0.0; - if ((byCarIdx & 1) != 0) // Alternate Y position based on car index (staggered grid) + if ((byCarIdx & 1) != + 0) // Alternate Y position based on car index (staggered grid) Car[iDriverIdx].pos.fY = 500.0f; else Car[iDriverIdx].pos.fY = -500.0f; iCarIdx2 = iDriverIdx; Car[iCarIdx2].pos.fZ = 0.0; - Car[iCarIdx2].fBestLapTime = 9999.9902f; // Initialize best lap time to maximum value - Car[iCarIdx2].nRoll = 0; // Initialize car orientation angles + Car[iCarIdx2].fBestLapTime = + 9999.9902f; // Initialize best lap time to maximum value + Car[iCarIdx2].nRoll = 0; // Initialize car orientation angles Car[iCarIdx2].nYaw = 0; Car[iCarIdx2].fFinalSpeed = 0.0f; Car[iCarIdx2].byGearAyMax = -1; - iChampMode = champ_mode; // Set starting track chunk based on championship mode + iChampMode = + champ_mode; // Set starting track chunk based on championship mode Car[iCarIdx2].nPitch = 0; if (iChampMode) - nStartChunk = TRAK_LEN - 56 - iGridOffsetWords;// start further back (56 chunks + offset) + nStartChunk = + TRAK_LEN - 56 - + iGridOffsetWords; // start further back (56 chunks + offset) else - nStartChunk = TRAK_LEN - 2 - iGridOffsetDWords;// start close to end (2 chunks + offset) - Car[iDriverIdx].nCurrChunk = nStartChunk; // Set current track chunk for car + nStartChunk = + TRAK_LEN - 2 - + iGridOffsetDWords; // start close to end (2 chunks + offset) + Car[iDriverIdx].nCurrChunk = + nStartChunk; // Set current track chunk for car iCarIdx3 = iDriverIdx; - Car[iCarIdx3].iLastValidChunk = Car[iDriverIdx].nCurrChunk;// Initialize track chunk tracking variables + Car[iCarIdx3].iLastValidChunk = + Car[iDriverIdx] + .nCurrChunk; // Initialize track chunk tracking variables Car[iCarIdx3].nReferenceChunk = Car[iDriverIdx].nCurrChunk; Car[iCarIdx3].iTrackedCarIdx = -1; Car[iCarIdx3].byLap = 0; Car[iCarIdx3].byLappedStatus = 0; Car[iCarIdx3].byLapNumber = 0; - Car[iCarIdx3].fDurability = CarEngines.engines[Car[iDriverIdx].byCarDesignIdx].fDurability; + Car[iCarIdx3].fDurability = + CarEngines.engines[Car[iDriverIdx].byCarDesignIdx].fDurability; Car[iCarIdx3].iControlType = 3; Car[iCarIdx3].iSelectedStrategy = 0; Car[iCarIdx3].iBobMode = 0; @@ -418,20 +420,25 @@ void placecars() Car[iDriverIdx].fHealth = 100.0f; Car[iDriverIdx].nTargetChunk = -1; Car[iDriverIdx].nLastCommentaryChunk = -1; - Car[iDriverIdx].iAICurrentLine = GetHighOrderRand(4, iRandomVal);// iRandomVal >> 13; - //Car[iDriverIdx].iUnk37 = (iRandomVal % 8192) / 8192; - //Car[iDriverIdx].iUnk37 = (iRandomVal - (__CFSHL__(iRandomVal >> 31, 13) + (iRandomVal >> 31 << 13))) >> 13; + Car[iDriverIdx].iAICurrentLine = + GetHighOrderRand(4, iRandomVal); // iRandomVal >> 13; + // Car[iDriverIdx].iUnk37 = (iRandomVal % 8192) / 8192; + // Car[iDriverIdx].iUnk37 = (iRandomVal - (__CFSHL__(iRandomVal >> 31, 13) + // + (iRandomVal >> 31 << 13))) >> 13; Car[iDriverIdx].iStunned = 0; Car[iDriverIdx].iPitchDynamicOffset = 0; Car[iDriverIdx].iRollDynamicOffset = 0; Car[iDriverIdx].iDamageState = 0; - Car[iDriverIdx].byRacePosition = iCarCounter;// Set race position and other race parameters + Car[iDriverIdx].byRacePosition = + iCarCounter; // Set race position and other race parameters Car[iDriverIdx].nChangeMateCooldown = 1080; Car[iDriverIdx].byThrottlePressed = 0; uiOrderOffset = uiGridOffset; Car[iDriverIdx].byLives = 3; - *(int *)((char *)carorder + uiOrderOffset) = iDriverIdx;// Add car to race order array - Car[iDriverIdx].byAccelerating = 0; // Initialize various car flags and counters + *(int *)((char *)carorder + uiOrderOffset) = + iDriverIdx; // Add car to race order array + Car[iDriverIdx].byAccelerating = + 0; // Initialize various car flags and counters Car[iDriverIdx].byEngineStartTimer = 0; Car[iDriverIdx].byAIThrottleControl = 0; Car[iDriverIdx].byPitLaneActiveFlag = 0; @@ -439,74 +446,113 @@ void placecars() Car[iDriverIdx].byCollisionTimer = 0; Car[iDriverIdx].byDamageToggle = 0; Car[iDriverIdx].byLastDamageToggle = 0; - Car[iDriverIdx].byCheatAmmo = 8; // Set cheat ammo count + Car[iDriverIdx].byCheatAmmo = 8; // Set cheat ammo count Car[iDriverIdx].nReverseWarnCooldown = 0; - iCarIdx4 = non_competitors[iDriverIdx]; // Check if this is a non-competitor car + iCarIdx4 = + non_competitors[iDriverIdx]; // Check if this is a non-competitor car Car[iDriverIdx].byCheatCooldown = 0; - if (iCarIdx4) // Handle non-competitor cars (spectators/disabled) + if (iCarIdx4) // Handle non-competitor cars (spectators/disabled) { - Car[iDriverIdx].byLives = -1; // Non-competitors have unlimited lives (-1) - finished_car[iDriverIdx] = -1; // Mark as finished (disabled) - pTrackData = localdata[Car[iDriverIdx].nCurrChunk].pointAy;// Get track data for positioning - Car[iDriverIdx].iControlType = 0; // Set control type to inactive (0) - Car[iDriverIdx].pos.fX = 0.0f * pTrackData->fY + 0.0f * pTrackData->fX + 0.0f * pTrackData->fZ - pTrackData[3].fX;// Transform and set position using track transformation matrix - Car[iDriverIdx].pos.fY = 0.0f * pTrackData[1].fX + 0.0f * pTrackData[1].fY + 0.0f * pTrackData[1].fZ - pTrackData[3].fY; - dZCmp = 0.0 * pTrackData[2].fX + 0.0 * pTrackData[2].fY + 0.0 * pTrackData[2].fZ - pTrackData[3].fZ + 1000.0;// Calculate Z position with offset + Car[iDriverIdx].byLives = + -1; // Non-competitors have unlimited lives (-1) + finished_car[iDriverIdx] = -1; // Mark as finished (disabled) + pTrackData = localdata[Car[iDriverIdx].nCurrChunk] + .pointAy; // Get track data for positioning + Car[iDriverIdx].iControlType = 0; // Set control type to inactive (0) + Car[iDriverIdx].pos.fX = + 0.0f * pTrackData->fY + 0.0f * pTrackData->fX + + 0.0f * pTrackData->fZ - + pTrackData[3].fX; // Transform and set position using track + // transformation matrix + Car[iDriverIdx].pos.fY = 0.0f * pTrackData[1].fX + + 0.0f * pTrackData[1].fY + + 0.0f * pTrackData[1].fZ - pTrackData[3].fY; + dZCmp = 0.0 * pTrackData[2].fX + 0.0 * pTrackData[2].fY + + 0.0 * pTrackData[2].fZ - pTrackData[3].fZ + + 1000.0; // Calculate Z position with offset Car[iDriverIdx].fFinalSpeed = 0.0; - //LOWORD(pTrackData) = Car[iDriverIdx].nCurrChunk; + // LOWORD(pTrackData) = Car[iDriverIdx].nCurrChunk; Car[iDriverIdx].fSpeedOverflow = 0; - Car[iDriverIdx].nReferenceChunk = Car[iDriverIdx].nCurrChunk;// (__int16)pTrackData; - Car[iDriverIdx].nCurrChunk = -1; // Set chunk to -1 (disabled car) + Car[iDriverIdx].nReferenceChunk = + Car[iDriverIdx].nCurrChunk; // (__int16)pTrackData; + Car[iDriverIdx].nCurrChunk = -1; // Set chunk to -1 (disabled car) Car[iDriverIdx].pos.fZ = (float)dZCmp; } - if (champ_mode && iDriverIdx == ViewType[0])// Special handling for player car in championship mode + if (champ_mode && + iDriverIdx == ViewType[0]) // Special handling for player car in + // championship mode { iViewCarIdx = ViewType[0]; - pEngine = &CarEngines.engines[Car[iViewCarIdx].byCarDesignIdx];// Get engine data for player car + pEngine = + &CarEngines + .engines[Car[iViewCarIdx].byCarDesignIdx]; // Get engine data + // for player car Car[iViewCarIdx].fRPMRatio = 1.0; - byGearAyMax = (uint8)(pEngine->iNumGears) - 1;// Set maximum gear for this car + byGearAyMax = + (uint8)(pEngine->iNumGears) - 1; // Set maximum gear for this car Car[iViewCarIdx].byGearAyMax = byGearAyMax; - Car[iViewCarIdx].fFinalSpeed = pEngine->pSpds[byGearAyMax];// Set max speed from engine data + Car[iViewCarIdx].fFinalSpeed = + pEngine->pSpds[byGearAyMax]; // Set max speed from engine data Car[iViewCarIdx].fBaseSpeed = Car[iViewCarIdx].fFinalSpeed; - dPower = calc_pow(Car[iViewCarIdx].byCarDesignIdx, (char)Car[iViewCarIdx].byGearAyMax, Car[iViewCarIdx].fRPMRatio);// Calculate power for this car configuration + dPower = calc_pow( + Car[iViewCarIdx].byCarDesignIdx, (char)Car[iViewCarIdx].byGearAyMax, + Car[iViewCarIdx] + .fRPMRatio); // Calculate power for this car configuration Car[iViewCarIdx].fSpeedOverflow = 0; Car[iViewCarIdx].byThrottlePressed = -1; Car[iViewCarIdx].byEngineStartTimer = 36; Car[iViewCarIdx].fPower = (float)dPower; } - nCurrChunk = Car[iDriverIdx].nCurrChunk; // Position cars on track based on available lanes - if (nCurrChunk >= 0 && nCurrChunk < TRAK_LEN) { //added by ROLLER - pTrackLocalData = &localdata[nCurrChunk]; // Get track data for current chunk - pTrackChunk = &TrackInfo[nCurrChunk]; // Get track info for surface types] - while ((TrakColour[Car[iDriverIdx].nCurrChunk][surfaceTypeAy[uiStartingLane]] & SURFACE_FLAG_NO_SPAWN) != 0) - //while ((TrakColour[Car[iDriverIdx].nCurrChunk][*(int *)((char *)surfaceTypeAy + Car[iDriverIdx].nCurrChunk)] & 0x8000000) != 0)// Find valid lane (avoid surfaces with special flags) + nCurrChunk = + Car[iDriverIdx] + .nCurrChunk; // Position cars on track based on available lanes + if (nCurrChunk >= 0 && nCurrChunk < TRAK_LEN) { // added by ROLLER + pTrackLocalData = + &localdata[nCurrChunk]; // Get track data for current chunk + pTrackChunk = + &TrackInfo[nCurrChunk]; // Get track info for surface types] + while ((TrakColour[Car[iDriverIdx].nCurrChunk] + [surfaceTypeAy[uiStartingLane]] & + SURFACE_FLAG_NO_SPAWN) != 0) + // while ((TrakColour[Car[iDriverIdx].nCurrChunk][*(int *)((char + // *)surfaceTypeAy + Car[iDriverIdx].nCurrChunk)] & 0x8000000) != 0)// + // Find valid lane (avoid surfaces with special flags) { if (++uiStartingLane == 4) uiStartingLane = 0; } - if (uiStartingLane <= 3) { // Calculate Y position based on selected lane + if (uiStartingLane <= + 3) { // Calculate Y position based on selected lane switch (uiStartingLane) { - case 0u: - dTrackYPos = pTrackChunk->fLShoulderWidth * 0.5 + pTrackLocalData->fTrackHalfWidth;// Lane 0: left shoulder position - break; - case 1u: - dTrackYPos = pTrackLocalData->fTrackHalfWidth * 0.5;// Lane 1: left side of track - break; - case 2u: - dTrackYPos = -pTrackLocalData->fTrackHalfWidth * 0.5;// Lane 2: right side of track - break; - case 3u: - dTrackYPos = -pTrackLocalData->fTrackHalfWidth - pTrackChunk->fRShoulderWidth * 0.5;// Lane 3: right shoulder position - break; + case 0u: + dTrackYPos = + pTrackChunk->fLShoulderWidth * 0.5 + + pTrackLocalData + ->fTrackHalfWidth; // Lane 0: left shoulder position + break; + case 1u: + dTrackYPos = pTrackLocalData->fTrackHalfWidth * + 0.5; // Lane 1: left side of track + break; + case 2u: + dTrackYPos = -pTrackLocalData->fTrackHalfWidth * + 0.5; // Lane 2: right side of track + break; + case 3u: + dTrackYPos = -pTrackLocalData->fTrackHalfWidth - + pTrackChunk->fRShoulderWidth * + 0.5; // Lane 3: right shoulder position + break; } - Car[iDriverIdx].pos.fY = (float)dTrackYPos; // Set calculated Y position for car + Car[iDriverIdx].pos.fY = + (float)dTrackYPos; // Set calculated Y position for car } } ++uiStartingLane; - putflat(&Car[iDriverIdx]); // Position car flat on track surface + putflat(&Car[iDriverIdx]); // Position car flat on track surface if (uiStartingLane == 4) uiStartingLane = 0; - iGridOffsetDWords += 4; // Advance to next car + iGridOffsetDWords += 4; // Advance to next car iGridOffsetWords += 2; uiGridOffset += 4; ++iCarCounter; @@ -523,23 +569,33 @@ void placecars() SLight[0][iSLightOffset / 0x30].targetPos.fY = Car[iPlayerCarIdx].pos.fY; fLightPosZ = Car[iPlayerCarIdx].pos.fZ + 500.0f; SLight[0][iSLightOffset / 0x30].targetPos.fX = fLightPosX; - SLight[0][iSLightOffset / 0x30].currentPos.fX = SLight[iPlayers][0].targetPos.fX + 10000.0f; - SLight[0][iSLightOffset / 0x30].currentPos.fY = SLight[iPlayers][0].targetPos.fY; + SLight[0][iSLightOffset / 0x30].currentPos.fX = + SLight[iPlayers][0].targetPos.fX + 10000.0f; + SLight[0][iSLightOffset / 0x30].currentPos.fY = + SLight[iPlayers][0].targetPos.fY; SLight[0][iSLightOffset / 0x30].targetPos.fZ = fLightPosZ; - SLight[0][iSLightOffset / 0x30].currentPos.fZ = SLight[iPlayers][0].targetPos.fZ + 5000.0f; - SLight[0][iSLightOffset / 0x30 + 1].targetPos.fY = Car[iPlayerCarIdx].pos.fY + -500.0f; + SLight[0][iSLightOffset / 0x30].currentPos.fZ = + SLight[iPlayers][0].targetPos.fZ + 5000.0f; + SLight[0][iSLightOffset / 0x30 + 1].targetPos.fY = + Car[iPlayerCarIdx].pos.fY + -500.0f; SLight[0][iSLightOffset / 0x30].speed.fX = 100.0f; SLight[0][iSLightOffset / 0x30].speed.fY = 100.0f; SLight[0][iSLightOffset / 0x30].speed.fZ = 40.0f; SLight[0][iSLightOffset / 0x30 + 1].targetPos.fX = fLightPosX; - SLight[0][iSLightOffset / 0x30 + 1].currentPos.fX = SLight[iPlayers][1].targetPos.fX + 10000.0f; - SLight[0][iSLightOffset / 0x30 + 1].currentPos.fY = SLight[iPlayers][1].targetPos.fY + -1000.0f; + SLight[0][iSLightOffset / 0x30 + 1].currentPos.fX = + SLight[iPlayers][1].targetPos.fX + 10000.0f; + SLight[0][iSLightOffset / 0x30 + 1].currentPos.fY = + SLight[iPlayers][1].targetPos.fY + -1000.0f; SLight[0][iSLightOffset / 0x30 + 1].targetPos.fZ = fLightPosZ; - SLight[0][iSLightOffset / 0x30 + 1].currentPos.fZ = SLight[iPlayers][1].targetPos.fZ + 5000.0f; - SLight[0][iSLightOffset / 0x30 + 2].targetPos.fY = Car[iPlayerCarIdx].pos.fY + 500.0f; + SLight[0][iSLightOffset / 0x30 + 1].currentPos.fZ = + SLight[iPlayers][1].targetPos.fZ + 5000.0f; + SLight[0][iSLightOffset / 0x30 + 2].targetPos.fY = + Car[iPlayerCarIdx].pos.fY + 500.0f; SLight[0][iSLightOffset / 0x30 + 2].targetPos.fX = fLightPosX; - SLight[0][iSLightOffset / 0x30 + 2].currentPos.fX = SLight[iPlayers][2].targetPos.fX + 10000.0f; - SLight[0][iSLightOffset / 0x30 + 2].currentPos.fY = SLight[iPlayers][2].targetPos.fY + 1000.0f; + SLight[0][iSLightOffset / 0x30 + 2].currentPos.fX = + SLight[iPlayers][2].targetPos.fX + 10000.0f; + SLight[0][iSLightOffset / 0x30 + 2].currentPos.fY = + SLight[iPlayers][2].targetPos.fY + 1000.0f; SLight[0][iSLightOffset / 0x30].uiRotation = 0; SLight[0][iSLightOffset / 0x30 + 1].uiRotation = 0; SLight[0][iSLightOffset / 0x30 + 2].targetPos.fZ = fLightPosZ; @@ -561,24 +617,43 @@ void placecars() dTransform2 = dTransform1 * fY + *pLightTrackData * fX; dTransform3 = pLightTrackData[2]; fTempZ = SLight[0][iSLightOffset / 0x30].currentPos.fZ; - SLight[0][iSLightOffset / 0x30].currentPos.fX = (float)(dTransform2 + dTransform3 * fTempZ - pLightTrackData[9]); - SLight[0][iSLightOffset / 0x30].currentPos.fY = pLightTrackData[3] * fX + pLightTrackData[4] * fY + pLightTrackData[5] * fTempZ - pLightTrackData[10]; - SLight[0][iSLightOffset / 0x30].currentPos.fZ = pLightTrackData[6] * fX + pLightTrackData[7] * fY + pLightTrackData[8] * fTempZ - pLightTrackData[11]; + SLight[0][iSLightOffset / 0x30].currentPos.fX = + (float)(dTransform2 + dTransform3 * fTempZ - pLightTrackData[9]); + SLight[0][iSLightOffset / 0x30].currentPos.fY = + pLightTrackData[3] * fX + pLightTrackData[4] * fY + + pLightTrackData[5] * fTempZ - pLightTrackData[10]; + SLight[0][iSLightOffset / 0x30].currentPos.fZ = + pLightTrackData[6] * fX + pLightTrackData[7] * fY + + pLightTrackData[8] * fTempZ - pLightTrackData[11]; dTransform4 = pLightTrackData[1]; fX = SLight[0][iSLightOffset / 0x30].targetPos.fX; fY = SLight[0][iSLightOffset / 0x30].targetPos.fY; dTransform5 = dTransform4 * fY + *pLightTrackData * fX; dTransform6 = pLightTrackData[2]; fTempZ = SLight[0][iSLightOffset / 0x30].targetPos.fZ; - SLight[0][iSLightOffset / 0x30].targetPos.fX = (float)(dTransform5 + dTransform6 * fTempZ - pLightTrackData[9]); - SLight[0][iSLightOffset / 0x30].targetPos.fY = pLightTrackData[3] * fX + pLightTrackData[4] * fY + pLightTrackData[5] * fTempZ - pLightTrackData[10]; - SLight[0][iSLightOffset / 0x30].targetPos.fZ = pLightTrackData[6] * fX + pLightTrackData[7] * fY + pLightTrackData[8] * fTempZ - pLightTrackData[11]; - SLight[0][iSLightOffset / 0x30].speed.fX = (float)(fabs(SLight[0][iSLightOffset / 0x30].targetPos.fX - SLight[0][iSLightOffset / 0x30].currentPos.fX) * 0.01388888888888889); - SLight[0][iSLightOffset / 0x30].speed.fY = (float)(fabs(SLight[0][iSLightOffset / 0x30].targetPos.fY - SLight[0][iSLightOffset / 0x30].currentPos.fY) * 0.01388888888888889); - dLightSpeedZ = fabs(SLight[0][iSLightOffset / 0x30].targetPos.fZ - SLight[0][iSLightOffset / 0x30].currentPos.fZ) * 0.02777777777777778; + SLight[0][iSLightOffset / 0x30].targetPos.fX = + (float)(dTransform5 + dTransform6 * fTempZ - pLightTrackData[9]); + SLight[0][iSLightOffset / 0x30].targetPos.fY = + pLightTrackData[3] * fX + pLightTrackData[4] * fY + + pLightTrackData[5] * fTempZ - pLightTrackData[10]; + SLight[0][iSLightOffset / 0x30].targetPos.fZ = + pLightTrackData[6] * fX + pLightTrackData[7] * fY + + pLightTrackData[8] * fTempZ - pLightTrackData[11]; + SLight[0][iSLightOffset / 0x30].speed.fX = + (float)(fabs(SLight[0][iSLightOffset / 0x30].targetPos.fX - + SLight[0][iSLightOffset / 0x30].currentPos.fX) * + 0.01388888888888889); + SLight[0][iSLightOffset / 0x30].speed.fY = + (float)(fabs(SLight[0][iSLightOffset / 0x30].targetPos.fY - + SLight[0][iSLightOffset / 0x30].currentPos.fY) * + 0.01388888888888889); + dLightSpeedZ = fabs(SLight[0][iSLightOffset / 0x30].targetPos.fZ - + SLight[0][iSLightOffset / 0x30].currentPos.fZ) * + 0.02777777777777778; SLight[0][iSLightOffset / 0x30].speed.fZ = (float)dLightSpeedZ; iSLightOffset += 48; - //StoreEngines[iSLightOffset / 0x18 + 13].speeds[2] = (float)dLightSpeedZ; + // StoreEngines[iSLightOffset / 0x18 + 13].speeds[2] = + // (float)dLightSpeedZ; } while (iSLightOffset != iMaxOffset); iMaxOffset += 144; ++iPlayers; @@ -588,31 +663,30 @@ void placecars() } //------------------------------------------------------------------------------------------------- -//00052FE0 -void DrawCars(int iCarIdx, int iViewMode) -{ - int iCarDrawIdx; // ebp - int iCurrChunk_1; // esi - int iCurrChunk; // edi +// 00052FE0 +void DrawCars(int iCarIdx, int iViewMode) { + int iCarDrawIdx; // ebp + int iCurrChunk_1; // esi + int iCurrChunk; // edi int iVisibilityFlag; // edx - int iYaw; // ebx - int iPitch; // eax - int iPointIdx; // edx - tVec3 *pointAy; // ebx - tVec3 *pHitboxPt; // ecx - double dMinZ; // st7 - int iNumCars; // edi - float fHitboxZ; // [esp+0h] [ebp-74h] - float fHitboxY; // [esp+4h] [ebp-70h] - float fHitboxX; // [esp+8h] [ebp-6Ch] - float fWorldZ; // [esp+Ch] [ebp-68h] - float fWorldY; // [esp+10h] [ebp-64h] - int iRoll; // [esp+14h] [ebp-60h] - float fWorldX; // [esp+18h] [ebp-5Ch] - int iCarIterator; // [esp+24h] [ebp-50h] - tCar *pCar; // [esp+28h] [ebp-4Ch] + int iYaw; // ebx + int iPitch; // eax + int iPointIdx; // edx + tVec3 *pointAy; // ebx + tVec3 *pHitboxPt; // ecx + double dMinZ; // st7 + int iNumCars; // edi + float fHitboxZ; // [esp+0h] [ebp-74h] + float fHitboxY; // [esp+4h] [ebp-70h] + float fHitboxX; // [esp+8h] [ebp-6Ch] + float fWorldZ; // [esp+Ch] [ebp-68h] + float fWorldY; // [esp+10h] [ebp-64h] + int iRoll; // [esp+14h] [ebp-60h] + float fWorldX; // [esp+18h] [ebp-5Ch] + int iCarIterator; // [esp+24h] [ebp-50h] + tCar *pCar; // [esp+28h] [ebp-4Ch] float fTransformM12; // [esp+2Ch] [ebp-48h] - float fX; // [esp+30h] [ebp-44h] + float fX; // [esp+30h] [ebp-44h] float fTransformM00; // [esp+34h] [ebp-40h] float fTransformM02; // [esp+38h] [ebp-3Ch] float fTransformM11; // [esp+3Ch] [ebp-38h] @@ -620,24 +694,26 @@ void DrawCars(int iCarIdx, int iViewMode) float fTransformM21; // [esp+44h] [ebp-30h] float fTransformM10; // [esp+48h] [ebp-2Ch] float fTransformM22; // [esp+4Ch] [ebp-28h] - float fZ; // [esp+50h] [ebp-24h] - float fY; // [esp+54h] [ebp-20h] + float fZ; // [esp+50h] [ebp-24h] + float fY; // [esp+54h] [ebp-20h] float fTransformM20; // [esp+58h] [ebp-1Ch] - float fClosestZ; // [esp+5Ch] [ebp-18h] + float fClosestZ; // [esp+5Ch] [ebp-18h] - iCarIterator = 0; // Initialize car iterator counter + iCarIterator = 0; // Initialize car iterator counter if (numcars > 0) { pCar = Car; iCarDrawIdx = 0; do { - fX = pCar->pos.fX; // Get car position and current track chunk + fX = pCar->pos.fX; // Get car position and current track chunk iCurrChunk_1 = pCar->nCurrChunk; fY = pCar->pos.fY; iCurrChunk = iCurrChunk_1; fZ = pCar->pos.fZ; - if (iCurrChunk_1 == -1) // Use last valid chunk if current chunk is invalid (-1) + if (iCurrChunk_1 == + -1) // Use last valid chunk if current chunk is invalid (-1) iCurrChunk = pCar->iLastValidChunk; - if (backwards) // Visibility culling - check if car is in visible track sections + if (backwards) // Visibility culling - check if car is in visible track + // sections { if (front_sec <= back_sec) { if (iCurrChunk <= front_sec || iCurrChunk >= back_sec) { @@ -685,66 +761,98 @@ void DrawCars(int iCarIdx, int iViewMode) iVisibilityFlag = 0; LABEL_42: if (iVisibilityFlag && (pCar->byLives & 0x80u) == 0) { - iRoll = (pCar->iRollDynamicOffset + pCar->nRoll) & 0x3FFF;// Calculate car rotation matrix from yaw, pitch, roll + iRoll = (pCar->iRollDynamicOffset + pCar->nRoll) & + 0x3FFF; // Calculate car rotation matrix from yaw, pitch, roll iYaw = pCar->nYaw; iPitch = ((uint16)pCar->iPitchDynamicOffset + pCar->nPitch) & 0x3FFF; - fTransformM00 = tcos[iYaw] * tcos[iPitch];// Build 3x3 rotation matrix for car orientation + fTransformM00 = + tcos[iYaw] * + tcos[iPitch]; // Build 3x3 rotation matrix for car orientation fTransformM10 = tsin[iYaw] * tcos[iPitch]; fTransformM20 = tsin[iPitch]; - fTransformM01 = tcos[iYaw] * fTransformM20 * tsin[iRoll] - tsin[iYaw] * tcos[iRoll]; - fTransformM11 = tsin[iYaw] * fTransformM20 * tsin[iRoll] + tcos[iYaw] * tcos[iRoll]; + fTransformM01 = + tcos[iYaw] * fTransformM20 * tsin[iRoll] - tsin[iYaw] * tcos[iRoll]; + fTransformM11 = + tsin[iYaw] * fTransformM20 * tsin[iRoll] + tcos[iYaw] * tcos[iRoll]; fTransformM12 = -tsin[iRoll] * tcos[iPitch]; - fTransformM02 = -tcos[iYaw] * fTransformM20 * tcos[iRoll] - tsin[iYaw] * tsin[iRoll]; - fTransformM21 = -tsin[iYaw] * fTransformM20 * tcos[iRoll] + tcos[iYaw] * tsin[iRoll]; + fTransformM02 = -tcos[iYaw] * fTransformM20 * tcos[iRoll] - + tsin[iYaw] * tsin[iRoll]; + fTransformM21 = -tsin[iYaw] * fTransformM20 * tcos[iRoll] + + tcos[iYaw] * tsin[iRoll]; fTransformM22 = tcos[iPitch] * tcos[iRoll]; iPointIdx = 0; - fClosestZ = 1073676300.0f; // Initialize closest Z distance for depth sorting - - if (iCurrChunk_1 >= 0 && iCurrChunk_1 < TRAK_LEN) //check added by ROLLER + fClosestZ = + 1073676300.0f; // Initialize closest Z distance for depth sorting + + if (iCurrChunk_1 >= 0 && + iCurrChunk_1 < TRAK_LEN) // check added by ROLLER pointAy = localdata[iCurrChunk_1].pointAy; else pointAy = NULL; - pHitboxPt = CarBox.hitboxAy[pCar->byCarDesignIdx];// Get car hitbox points and chunk transform matrix + pHitboxPt = + CarBox.hitboxAy[pCar->byCarDesignIdx]; // Get car hitbox points and + // chunk transform matrix do { - fHitboxX = pHitboxPt->fX; // Transform car hitbox points loop (8 points) + fHitboxX = + pHitboxPt->fX; // Transform car hitbox points loop (8 points) fHitboxY = pHitboxPt->fY; fHitboxZ = pHitboxPt->fZ; - CarPt[iPointIdx].world.fX = pHitboxPt->fX * fTransformM00 + fHitboxY * fTransformM01 + fHitboxZ * fTransformM02 + fX;// Apply car rotation matrix to hitbox point - CarPt[iPointIdx].world.fY = fHitboxX * fTransformM10 + fHitboxY * fTransformM11 + fHitboxZ * fTransformM21 + fY; + CarPt[iPointIdx].world.fX = + pHitboxPt->fX * fTransformM00 + fHitboxY * fTransformM01 + + fHitboxZ * fTransformM02 + + fX; // Apply car rotation matrix to hitbox point + CarPt[iPointIdx].world.fY = fHitboxX * fTransformM10 + + fHitboxY * fTransformM11 + + fHitboxZ * fTransformM21 + fY; ++pHitboxPt; - CarPt[iPointIdx].world.fZ = fHitboxX * fTransformM20 + fHitboxY * fTransformM12 + fHitboxZ * fTransformM22 + fZ; - if (iCurrChunk_1 != -1 && pointAy) // Transform from car space to track chunk space if valid chunk + CarPt[iPointIdx].world.fZ = fHitboxX * fTransformM20 + + fHitboxY * fTransformM12 + + fHitboxZ * fTransformM22 + fZ; + if (iCurrChunk_1 != -1 && pointAy) // Transform from car space to + // track chunk space if valid chunk { fWorldX = CarPt[iPointIdx].world.fX; fWorldY = CarPt[iPointIdx].world.fY; fWorldZ = CarPt[iPointIdx].world.fZ; - CarPt[iPointIdx].world.fX = pointAy->fY * fWorldY + pointAy->fX * fWorldX + pointAy->fZ * fWorldZ - pointAy[3].fX; - CarPt[iPointIdx].world.fY = pointAy[1].fX * fWorldX + pointAy[1].fY * fWorldY + pointAy[1].fZ * fWorldZ - pointAy[3].fY; - CarPt[iPointIdx].world.fZ = pointAy[2].fX * fWorldX + pointAy[2].fY * fWorldY + pointAy[2].fZ * fWorldZ - pointAy[3].fZ; + CarPt[iPointIdx].world.fX = pointAy->fY * fWorldY + + pointAy->fX * fWorldX + + pointAy->fZ * fWorldZ - pointAy[3].fX; + CarPt[iPointIdx].world.fY = pointAy[1].fX * fWorldX + + pointAy[1].fY * fWorldY + + pointAy[1].fZ * fWorldZ - pointAy[3].fY; + CarPt[iPointIdx].world.fZ = pointAy[2].fX * fWorldX + + pointAy[2].fY * fWorldY + + pointAy[2].fZ * fWorldZ - pointAy[3].fZ; } - k1 = CarPt[iPointIdx].world.fX - viewx;// Transform to camera view space for rendering + k1 = CarPt[iPointIdx].world.fX - + viewx; // Transform to camera view space for rendering k2 = CarPt[iPointIdx].world.fY - viewy; k3 = CarPt[iPointIdx].world.fZ - viewz; dMinZ = k1 * vk3 + k2 * vk6 + k3 * vk9; CarPt[iPointIdx].view.fZ = (float)dMinZ; - if (dMinZ < fClosestZ) // Track closest Z value for depth sorting + if (dMinZ < fClosestZ) // Track closest Z value for depth sorting fClosestZ = CarPt[iPointIdx].view.fZ; ++iPointIdx; } while (iPointIdx != 8); - car_draw_order[iCarDrawIdx].fMinZDepth = fClosestZ;// Store car in draw order array for Z-sorting + car_draw_order[iCarDrawIdx].fMinZDepth = + fClosestZ; // Store car in draw order array for Z-sorting car_draw_order[iCarDrawIdx].iChunkIdx = iCurrChunk; - if (iCarIterator == iCarIdx && (!iViewMode || iViewMode == -1))// Hide player car in certain view modes + if (iCarIterator == iCarIdx && + (!iViewMode || + iViewMode == -1)) // Hide player car in certain view modes car_draw_order[iCarDrawIdx].iChunkIdx = -2; } else { - car_draw_order[iCarDrawIdx].iChunkIdx = -2;// Mark invisible cars with special values + car_draw_order[iCarDrawIdx].iChunkIdx = + -2; // Mark invisible cars with special values car_draw_order[iCarDrawIdx].fMinZDepth = -1.0f; } iNumCars = numcars; car_draw_order[iCarDrawIdx].iCarIdx = iCarIterator; iCarDrawIdx++; - //CarZOrder[++iCarDrawIdx + 499].iPolygonIndex = iCarIterator;// references car_draw_order + // CarZOrder[++iCarDrawIdx + 499].iPolygonIndex = iCarIterator;// + // references car_draw_order ++pCar; ++iCarIterator; } while (iCarIterator < iNumCars); @@ -752,373 +860,381 @@ void DrawCars(int iCarIdx, int iViewMode) } //------------------------------------------------------------------------------------------------- -//000534A0 -void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCar, - const CarRenderPose *pose, - const CarRenderOptions *options) -{ - int iMotionX; // ebx - int iMotionY; // esi - int iMotionZ; // edi - int16 nRoll; // cx - int iYawAngle; // edx - int iPitch; // ebp - double dCosYaw; // st7 - int iRoll; // ecx - double dRotMat22; // st7 - float fZ; // eax - int iChunk; // edi - tData *pTrackData; // esi - uint8 byCarDesignIdx; // dh - double dY; // st7 - float *p_fX; // edx +// 000534A0 +void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, + float fDistanceToCar, const CarRenderPose *pose, + const CarRenderOptions *options) { + int iMotionX; // ebx + int iMotionY; // esi + int iMotionZ; // edi + int16 nRoll; // cx + int iYawAngle; // edx + int iPitch; // ebp + double dCosYaw; // st7 + int iRoll; // ecx + double dRotMat22; // st7 + float fZ; // eax + int iChunk; // edi + tData *pTrackData; // esi + uint8 byCarDesignIdx; // dh + double dY; // st7 + float *p_fX; // edx unsigned int uiCarWorldOffset; // eax - double dTransformMat22; // st7 - double dTransformMat02; // st6 - double dTransformMat12; // st5 - double dTransformMat11; // st4 - double dTransformMat01; // st3 - double dTransformMat21; // st2 - int i; // eax - double dLocalZ; // st7 - float *pCarPosPtr; // edx - int iCornerIndex; // eax - double dTransformMat22_2; // st7 - double dTransformMat02_2; // st6 - double dTransformMat12_2; // st5 - double dTransformMat11_2; // st4 - double dTransformMat01_2; // st3 - double dTransformMat21_2; // st2 - int nCurrChunk; // eax - tData *pCurrentTrackData; // eax - double dRelativeX; // st7 - double dRelativeY; // st5 - double dRelativeZ; // st4 - int iLeftSurfaceType; // ecx - int iRightSurfaceType; // ecx - int iLaneType; // ebx - int iGroundedCorners; // ecx - //int64 ullTrackColor; // rax - int iGroundColorType; // edx - int iCornerIdx; // ebx - int iHeightIdx; // ebp - double dGroundHeight; // st7 - int iCornerLoopIdx; // edi - int j; // edx - int m; // eax - double dCoordZ; // st7 - int n; // edx - double dBankHeight; // st7 - int k; // edx - double dBankHeight2; // st7 - int iUndergroundCheck; // ebp - int iUndergroundIdx; // edx + double dTransformMat22; // st7 + double dTransformMat02; // st6 + double dTransformMat12; // st5 + double dTransformMat11; // st4 + double dTransformMat01; // st3 + double dTransformMat21; // st2 + int i; // eax + double dLocalZ; // st7 + float *pCarPosPtr; // edx + int iCornerIndex; // eax + double dTransformMat22_2; // st7 + double dTransformMat02_2; // st6 + double dTransformMat12_2; // st5 + double dTransformMat11_2; // st4 + double dTransformMat01_2; // st3 + double dTransformMat21_2; // st2 + int nCurrChunk; // eax + tData *pCurrentTrackData; // eax + double dRelativeX; // st7 + double dRelativeY; // st5 + double dRelativeZ; // st4 + int iLeftSurfaceType; // ecx + int iRightSurfaceType; // ecx + int iLaneType; // ebx + int iGroundedCorners; // ecx + // int64 ullTrackColor; // rax + int iGroundColorType; // edx + int iCornerIdx; // ebx + int iHeightIdx; // ebp + double dGroundHeight; // st7 + int iCornerLoopIdx; // edi + int j; // edx + int m; // eax + double dCoordZ; // st7 + int n; // edx + double dBankHeight; // st7 + int k; // edx + double dBankHeight2; // st7 + int iUndergroundCheck; // ebp + int iUndergroundIdx; // edx double dUndergroundHeight; // st7 - int iShadowOffset; // eax - double dWorldToLocalZ; // st7 - int iScreenSize; // ecx - int ii; // edx - double dViewDeltaX; // st7 - double dViewDeltaY; // st6 - double dViewDeltaZ; // st5 - double dViewSpaceZ; // st7 - double dViewDistance; // st7 - double dInverseZ; // st6 - double dScreenX; // st5 - double dScreenY; // st7 - //int iScreenXInt; // eax - double dShadowX; // st7 - double dShadowCorner0X; // st7 - double dX; // st7 - double dShadowCorner1Y; // st7 - double dShadowCorner2X; // st7 - double dShadowCorner2Y; // st7 - double dShadowCorner3X; // st7 - double dShadowCorner3Y; // st7 - tVec3 *pCoords; // ebx - tPolygon *pPols; // ecx + int iShadowOffset; // eax + double dWorldToLocalZ; // st7 + int iScreenSize; // ecx + int ii; // edx + double dViewDeltaX; // st7 + double dViewDeltaY; // st6 + double dViewDeltaZ; // st5 + double dViewSpaceZ; // st7 + double dViewDistance; // st7 + double dInverseZ; // st6 + double dScreenX; // st5 + double dScreenY; // st7 + // int iScreenXInt; // eax + double dShadowX; // st7 + double dShadowCorner0X; // st7 + double dX; // st7 + double dShadowCorner1Y; // st7 + double dShadowCorner2X; // st7 + double dShadowCorner2Y; // st7 + double dShadowCorner3X; // st7 + double dShadowCorner3Y; // st7 + tVec3 *pCoords; // ebx + tPolygon *pPols; // ecx unsigned int iCoordOffset; // esi - int iCoordLoopSize; // edi - tData *pChunkData; // edx - float fModelCoordX; // eax - float *pCoordPtr; // ebx - float fModelCoordY; // eax - float fModelCoordZ; // eax - double dTransformedX; // st7 - double dTransformedY; // st5 - double dTransformedZ; // st6 - int iCurrentChunk; // ebp - double dChunkTransformY; // st7 - double dChunkTransformX; // st7 - double dChunkMatrixZ; // st6 - double dChunkTransformZ; // st7 - double dViewRelativeX; // st7 - double dViewRelativeY; // st6 - double dViewRelativeZ; // st5 - double dCameraSpaceZ; // st7 - double dProjViewDistance; // st7 - double dProjInverseZ; // st6 - double dProjScreenX; // st5 - double dProjScreenY; // st7 - //int iScreenXResult; // eax + int iCoordLoopSize; // edi + tData *pChunkData; // edx + float fModelCoordX; // eax + float *pCoordPtr; // ebx + float fModelCoordY; // eax + float fModelCoordZ; // eax + double dTransformedX; // st7 + double dTransformedY; // st5 + double dTransformedZ; // st6 + int iCurrentChunk; // ebp + double dChunkTransformY; // st7 + double dChunkTransformX; // st7 + double dChunkMatrixZ; // st6 + double dChunkTransformZ; // st7 + double dViewRelativeX; // st7 + double dViewRelativeY; // st6 + double dViewRelativeZ; // st5 + double dCameraSpaceZ; // st7 + double dProjViewDistance; // st7 + double dProjInverseZ; // st6 + double dProjScreenX; // st5 + double dProjScreenY; // st7 + // int iScreenXResult; // eax signed int iVisiblePolygons; // esi - int iPolygonLoopIdx; // edi - //uint8 *pCurrentPolygon; // edx + int iPolygonLoopIdx; // edi + // uint8 *pCurrentPolygon; // edx int jj; // eax - //tCarPt *pCarVertex; // ebx + // tCarPt *pCarVertex; // ebx double dCrossProduct1X; // st7 double dCrossProduct1Z; // st6 double dCrossProduct2X; // st5 double dCrossProduct2Y; // st4 double dCrossProduct2Z; // st3 - //char byTextureFlags; // dh - int iPolygonResult; // eax - float fZDepthMin1; // eax - float fZDepthMin2; // eax - float fZDepthFinal; // eax - float fZDepthMax1; // eax - float fZDepthMax2; // eax - tPolygon *pPolygonBase; // eax - int iPolygonIndex; // edi - int nNextPolIdx; // ecx - int iDepthSortIdx; // edi - int iLinkedPolygonIdx; // ebx - signed int kk; // eax - int iZOrderCompareIdx; // edx - int iSpriteIdx; // ebp - float *pTrackChunkPtr; // ebx - tCarSpray *pSmokeSpray; // ecx - int iSmokeIndex; // edx + // char byTextureFlags; // dh + int iPolygonResult; // eax + float fZDepthMin1; // eax + float fZDepthMin2; // eax + float fZDepthFinal; // eax + float fZDepthMax1; // eax + float fZDepthMax2; // eax + tPolygon *pPolygonBase; // eax + int iPolygonIndex; // edi + int nNextPolIdx; // ecx + int iDepthSortIdx; // edi + int iLinkedPolygonIdx; // ebx + signed int kk; // eax + int iZOrderCompareIdx; // edx + int iSpriteIdx; // ebp + float *pTrackChunkPtr; // ebx + tCarSpray *pSmokeSpray; // ecx + int iSmokeIndex; // edx signed int iSmokeZOrderIdx; // edi - int iSmokeChunkIdx; // eax - double dSmokeChunkTransY; // st7 - double dSmokeChunkTransX; // st7 - double dSmokeChunkMatZ; // st6 - double dSmokeChunkTransZ; // st7 - double dSmokeViewDeltaX; // st7 - double dSmokeViewDeltaY; // st6 - double dSmokeViewDeltaZ; // st5 - double dSmokeCameraZ; // st7 - double dSmokeProjViewDist; // st7 - double dSmokeProjInverseZ; // st6 - double dSmokeProjScreenX; // st5 - double dSmokeProjScreenY; // st7 - //int iSmokeScreenXResult; // eax - int iSmokeChunkIdx2; // eax - double dSmoke2ChunkTransY; // st7 - double dSmoke2ChunkTransX; // st7 - double dSmoke2ChunkMatZ; // st6 - double dSmoke2ChunkTransZ; // st7 - double dSmoke2ViewDeltaX; // st7 - double dSmoke2ViewDeltaY; // st6 - double dSmoke2ViewDeltaZ; // st5 - double dSmoke2CameraZ; // st7 + int iSmokeChunkIdx; // eax + double dSmokeChunkTransY; // st7 + double dSmokeChunkTransX; // st7 + double dSmokeChunkMatZ; // st6 + double dSmokeChunkTransZ; // st7 + double dSmokeViewDeltaX; // st7 + double dSmokeViewDeltaY; // st6 + double dSmokeViewDeltaZ; // st5 + double dSmokeCameraZ; // st7 + double dSmokeProjViewDist; // st7 + double dSmokeProjInverseZ; // st6 + double dSmokeProjScreenX; // st5 + double dSmokeProjScreenY; // st7 + // int iSmokeScreenXResult; // eax + int iSmokeChunkIdx2; // eax + double dSmoke2ChunkTransY; // st7 + double dSmoke2ChunkTransX; // st7 + double dSmoke2ChunkMatZ; // st6 + double dSmoke2ChunkTransZ; // st7 + double dSmoke2ViewDeltaX; // st7 + double dSmoke2ViewDeltaY; // st6 + double dSmoke2ViewDeltaZ; // st5 + double dSmoke2CameraZ; // st7 double dSmoke2ProjViewDist; // st7 double dSmoke2ProjInverseZ; // st6 - double dSmoke2ProjScreenX; // st5 - double dSmoke2ProjScreenY; // st7 - //int iSmoke2ScreenXResult; // eax + double dSmoke2ProjScreenX; // st5 + double dSmoke2ProjScreenY; // st7 + // int iSmoke2ScreenXResult; // eax unsigned int uiRenderLoopOffset; // edi - int iSpritePolygonIdx; // ebx - int iSpriteIndex; // edx - tCarSpray *pCurrentSprite; // eax - double fSpriteSize; // st7 - int iScreenX; // ecx - int iScreenY; // esi - int x; // ebx - int y; // edx - //tCarSpray *pSpriteDataPtr; // eax - int uiSpriteSurface; // eax + int iSpritePolygonIdx; // ebx + int iSpriteIndex; // edx + tCarSpray *pCurrentSprite; // eax + double fSpriteSize; // st7 + int iScreenX; // ecx + int iScreenY; // esi + int x; // ebx + int y; // edx + // tCarSpray *pSpriteDataPtr; // eax + int uiSpriteSurface; // eax double dSpriteProjection; // st7 - //tCarSpray *pSpriteDataPtr2; // eax - int iSpriteSize; // esi - int iSpriteCenterX; // ebx - int iSpriteCenterY; // edx - int iPolygonIdx; // esi + // tCarSpray *pSpriteDataPtr2; // eax + int iSpriteSize; // esi + int iSpriteCenterX; // ebx + int iSpriteCenterY; // edx + int iPolygonIdx; // esi tPolygon *pRenderPolygon; // edx - int uiTextureSurface; // ecx - int mm; // eax - //tCarPt *pPolygonVertex; // ebx - double dPolygonDepth23; // st7 + int uiTextureSurface; // ecx + int mm; // eax + // tCarPt *pPolygonVertex; // ebx + double dPolygonDepth23; // st7 tCarPt *pMinDepthVertex23; // eax tCarPt *pMinDepthVertex01; // eax tCarPt *pFinalMinVertex01; // eax - float fFinalMinDepth; // eax + float fFinalMinDepth; // eax tCarPt *pFinalMinVertex23; // eax - bool bCloseToCamera; // ebx - int byTextureIndex; // eax - tAnimation *pAnimation; // ecx - int iAnimationFrame; // eax - double dNameTagDeltaX; // st7 - double dNameTagDeltaY; // st6 - double dNameTagDeltaZ; // st5 - double dNameTagCameraZ; // st7 - double dNameTagViewDist; // st7 - double dNameTagInverseZ; // st6 - double dNameTagScreenX; // st5 - double dNameTagScreenY; // st7 - int iNameTagScreenSize; // ebx - //int iNameTagXResult; // eax - int iNameWidth; // ebx - int iNameCharIdx; // eax - int iNameHalfWidth; // eax - int iNameDisplayX; // ecx - int iNameDisplayY; // esi - int iPrevScrSize; // edi - int iTeamColIdx; // eax - tData tempData; // [esp+0h] [ebp-298h] BYREF - tCarPt *polygonVertices[4]; // [esp+80h] [ebp-218h] - float fLocalCarPosY; // [esp+90h] [ebp-208h] - int iCarIndexCopy; // [esp+94h] [ebp-204h] - int iOnTrackFlag; // [esp+98h] [ebp-200h] - tCarSpray *pCarSprayArray; // [esp+9Ch] [ebp-1FCh] - uint8 *pScrBuf; // [esp+A0h] [ebp-1F8h] - int iShadowRenderFlag; // [esp+A4h] [ebp-1F4h] - uint32 uiColorTo; // [esp+A8h] [ebp-1F0h] - uint32 uiColorFrom; // [esp+ACh] [ebp-1ECh] - float fLocalCarPosX; // [esp+B0h] [ebp-1E8h] - float fCarPointZ; // [esp+B4h] [ebp-1E4h] - tTrackInfo *pTrackInfo; // [esp+B8h] [ebp-1E0h] - int iBank; // [esp+BCh] [ebp-1DCh] BYREF - int iSpriteScreenSize; // [esp+C0h] [ebp-1D8h] - float fPolygonVertex1Y; // [esp+C4h] [ebp-1D4h] - float fGroundHeightTemp; // [esp+CCh] [ebp-1CCh] - float *pChunkDataPtr = NULL; // [esp+D4h] [ebp-1C4h] - float fCrossProductY; // [esp+D8h] [ebp-1C0h] - float fClampedZ; // [esp+DCh] [ebp-1BCh] - int iTextureDisabled; // [esp+E0h] [ebp-1B8h] - float fShadowViewX; // [esp+E4h] [ebp-1B4h] - int carDesignIndex; // [esp+E8h] [ebp-1B0h] - float fCarPointY; // [esp+F0h] [ebp-1A8h] - float fTrackRelativeZ; // [esp+F4h] [ebp-1A4h] - float fTrackRelativeY; // [esp+F8h] [ebp-1A0h] - float fLocalCarPosZ; // [esp+FCh] [ebp-19Ch] - int iElevation; // [esp+100h] [ebp-198h] BYREF - int iAzimuth; // [esp+104h] [ebp-194h] BYREF - int iBackfaceFlag; // [esp+108h] [ebp-190h] - int iChunkOffset; // [esp+10Ch] [ebp-18Ch] - float fZDepthCloseMin1; // [esp+110h] [ebp-188h] - float fZDepthCloseMin2; // [esp+114h] [ebp-184h] - float fZDepthCloseFinal; // [esp+118h] [ebp-180h] - float fZDepthCloseFar1; // [esp+11Ch] [ebp-17Ch] - float fZDepthCloseFar2; // [esp+120h] [ebp-178h] - float fZDepthFarMax1; // [esp+124h] [ebp-174h] - float fZDepthFarMax2; // [esp+128h] [ebp-170h] - float fZDepthFarFinal; // [esp+12Ch] [ebp-16Ch] - float fZDepthFarMin1; // [esp+130h] [ebp-168h] - float fZDepthFarMin2; // [esp+134h] [ebp-164h] - tPolygon *pPolygonArray; // [esp+138h] [ebp-160h] - uint32 uiCarDesignStride; // [esp+13Ch] [ebp-15Ch] - tPolygon *pLinkedPolygons; // [esp+140h] [ebp-158h] - float fMinDepthVertex23; // [esp+144h] [ebp-154h] - float fMinDepthVertex01; // [esp+148h] [ebp-150h] - float fPolygonMinDepth; // [esp+14Ch] [ebp-14Ch] - float fFinalVertex01Depth; // [esp+150h] [ebp-148h] - float fFinalVertex23Depth; // [esp+154h] [ebp-144h] - uint32 dwCarDesignOffset; // [esp+158h] [ebp-140h] - int iAnimationOffset; // [esp+15Ch] [ebp-13Ch] - int iSubdivisionParam; // [esp+160h] [ebp-138h] + bool bCloseToCamera; // ebx + int byTextureIndex; // eax + tAnimation *pAnimation; // ecx + int iAnimationFrame; // eax + double dNameTagDeltaX; // st7 + double dNameTagDeltaY; // st6 + double dNameTagDeltaZ; // st5 + double dNameTagCameraZ; // st7 + double dNameTagViewDist; // st7 + double dNameTagInverseZ; // st6 + double dNameTagScreenX; // st5 + double dNameTagScreenY; // st7 + int iNameTagScreenSize; // ebx + // int iNameTagXResult; // eax + int iNameWidth; // ebx + int iNameCharIdx; // eax + int iNameHalfWidth; // eax + int iNameDisplayX; // ecx + int iNameDisplayY; // esi + int iPrevScrSize; // edi + int iTeamColIdx; // eax + tData tempData; // [esp+0h] [ebp-298h] BYREF + tCarPt *polygonVertices[4]; // [esp+80h] [ebp-218h] + float fLocalCarPosY; // [esp+90h] [ebp-208h] + int iCarIndexCopy; // [esp+94h] [ebp-204h] + int iOnTrackFlag; // [esp+98h] [ebp-200h] + tCarSpray *pCarSprayArray; // [esp+9Ch] [ebp-1FCh] + uint8 *pScrBuf; // [esp+A0h] [ebp-1F8h] + int iShadowRenderFlag; // [esp+A4h] [ebp-1F4h] + uint32 uiColorTo; // [esp+A8h] [ebp-1F0h] + uint32 uiColorFrom; // [esp+ACh] [ebp-1ECh] + float fLocalCarPosX; // [esp+B0h] [ebp-1E8h] + float fCarPointZ; // [esp+B4h] [ebp-1E4h] + tTrackInfo *pTrackInfo; // [esp+B8h] [ebp-1E0h] + int iBank; // [esp+BCh] [ebp-1DCh] BYREF + int iSpriteScreenSize; // [esp+C0h] [ebp-1D8h] + float fPolygonVertex1Y; // [esp+C4h] [ebp-1D4h] + float fGroundHeightTemp; // [esp+CCh] [ebp-1CCh] + float *pChunkDataPtr = NULL; // [esp+D4h] [ebp-1C4h] + float fCrossProductY; // [esp+D8h] [ebp-1C0h] + float fClampedZ; // [esp+DCh] [ebp-1BCh] + int iTextureDisabled; // [esp+E0h] [ebp-1B8h] + float fShadowViewX; // [esp+E4h] [ebp-1B4h] + int carDesignIndex; // [esp+E8h] [ebp-1B0h] + float fCarPointY; // [esp+F0h] [ebp-1A8h] + float fTrackRelativeZ; // [esp+F4h] [ebp-1A4h] + float fTrackRelativeY; // [esp+F8h] [ebp-1A0h] + float fLocalCarPosZ; // [esp+FCh] [ebp-19Ch] + int iElevation; // [esp+100h] [ebp-198h] BYREF + int iAzimuth; // [esp+104h] [ebp-194h] BYREF + int iBackfaceFlag; // [esp+108h] [ebp-190h] + int iChunkOffset; // [esp+10Ch] [ebp-18Ch] + float fZDepthCloseMin1; // [esp+110h] [ebp-188h] + float fZDepthCloseMin2; // [esp+114h] [ebp-184h] + float fZDepthCloseFinal; // [esp+118h] [ebp-180h] + float fZDepthCloseFar1; // [esp+11Ch] [ebp-17Ch] + float fZDepthCloseFar2; // [esp+120h] [ebp-178h] + float fZDepthFarMax1; // [esp+124h] [ebp-174h] + float fZDepthFarMax2; // [esp+128h] [ebp-170h] + float fZDepthFarFinal; // [esp+12Ch] [ebp-16Ch] + float fZDepthFarMin1; // [esp+130h] [ebp-168h] + float fZDepthFarMin2; // [esp+134h] [ebp-164h] + tPolygon *pPolygonArray; // [esp+138h] [ebp-160h] + uint32 uiCarDesignStride; // [esp+13Ch] [ebp-15Ch] + tPolygon *pLinkedPolygons; // [esp+140h] [ebp-158h] + float fMinDepthVertex23; // [esp+144h] [ebp-154h] + float fMinDepthVertex01; // [esp+148h] [ebp-150h] + float fPolygonMinDepth; // [esp+14Ch] [ebp-14Ch] + float fFinalVertex01Depth; // [esp+150h] [ebp-148h] + float fFinalVertex23Depth; // [esp+154h] [ebp-144h] + uint32 dwCarDesignOffset; // [esp+158h] [ebp-140h] + int iAnimationOffset; // [esp+15Ch] [ebp-13Ch] + int iSubdivisionParam; // [esp+160h] [ebp-138h] unsigned int uiTextureMapOffset; // [esp+164h] [ebp-134h] unsigned int uiZOrderLoopOffset; // [esp+168h] [ebp-130h] - int iRenderLoopLimit; // [esp+16Ch] [ebp-12Ch] - int iTunnelFlag; // [esp+170h] [ebp-128h] - float fGroundHeightLoop; // [esp+174h] [ebp-124h] - float fBankHeightLoop; // [esp+178h] [ebp-120h] - float fBankHeightLoop2; // [esp+17Ch] [ebp-11Ch] - float fNameTagCameraZCopy; // [esp+180h] [ebp-118h] - float fSmoke2CameraZCopy; // [esp+184h] [ebp-114h] - float fSmokeCameraZCopy; // [esp+188h] [ebp-110h] - float fModelCameraZCopy; // [esp+18Ch] [ebp-10Ch] - float fNameTagClampedZ; // [esp+190h] [ebp-108h] - float fSmoke2ClampedZ; // [esp+194h] [ebp-104h] - float fSmokeClampedZ; // [esp+198h] [ebp-100h] - float fModelClampedZ; // [esp+19Ch] [ebp-FCh] - float fNameTagViewY; // [esp+1A0h] [ebp-F8h] - float fSmoke2ViewY; // [esp+1A4h] [ebp-F4h] - float fSmokeViewY; // [esp+1A8h] [ebp-F0h] - float fModelViewY; // [esp+1ACh] [ebp-ECh] - float fNameTagViewX; // [esp+1B0h] [ebp-E8h] - float fSmoke2ViewX; // [esp+1B4h] [ebp-E4h] - float fSmokeViewX; // [esp+1B8h] [ebp-E0h] - float fModelViewX; // [esp+1BCh] [ebp-DCh] - float fPosZ; // [esp+1C0h] [ebp-D8h] - float fPosY; // [esp+1C4h] [ebp-D4h] - float fPosX; // [esp+1C8h] [ebp-D0h] - float fNameTagWorldZ; // [esp+1CCh] [ebp-CCh] - float fSmokeDepthCheck; // [esp+1D0h] [ebp-C8h] - int iTemp; // [esp+1D4h] [ebp-C4h] - float fNameTagWorldY; // [esp+1D8h] [ebp-C0h] - float fSmokeWorldY; // [esp+1DCh] [ebp-BCh] - float fNameTagWorldX; // [esp+1E0h] [ebp-B8h] - signed int iZOrderIndex; // [esp+1E4h] [ebp-B4h] - int iPolygonCount; // [esp+1E8h] [ebp-B0h] - float fBackfaceDotProduct; // [esp+1ECh] [ebp-ACh] - float fWarpDistortion; // [esp+1F0h] [ebp-A8h] - float fShadowViewY; // [esp+1F4h] [ebp-A4h] - float fModelCoordZLocal; // [esp+200h] [ebp-98h] - float fModelCoordYLocal; // [esp+204h] [ebp-94h] - float fModelCoordXLocal; // [esp+208h] [ebp-90h] - float fModelWorldZ; // [esp+20Ch] [ebp-8Ch] - float fModelWorldY; // [esp+210h] [ebp-88h] - float fModelWorldX; // [esp+214h] [ebp-84h] - float fCarPosZ; // [esp+218h] [ebp-80h] - float fCarPosY; // [esp+21Ch] [ebp-7Ch] - float fCarPosX; // [esp+220h] [ebp-78h] - int iCurrChunk; // [esp+224h] [ebp-74h] - int iNumCoords; // [esp+228h] [ebp-70h] - float fRotMat22Copy; // [esp+22Ch] [ebp-6Ch] - float fRotMat11; // [esp+230h] [ebp-68h] - float fRotMat20; // [esp+234h] [ebp-64h] - float fRotMat21; // [esp+238h] [ebp-60h] - float fRotMat12; // [esp+23Ch] [ebp-5Ch] - float fRotMat10; // [esp+240h] [ebp-58h] - float fRotMat02; // [esp+244h] [ebp-54h] - float fRotMat01; // [esp+248h] [ebp-50h] - float fRotMat00; // [esp+24Ch] [ebp-4Ch] - int iYaw; // [esp+250h] [ebp-48h] - tCar *pCar; // [esp+254h] [ebp-44h] + int iRenderLoopLimit; // [esp+16Ch] [ebp-12Ch] + int iTunnelFlag; // [esp+170h] [ebp-128h] + float fGroundHeightLoop; // [esp+174h] [ebp-124h] + float fBankHeightLoop; // [esp+178h] [ebp-120h] + float fBankHeightLoop2; // [esp+17Ch] [ebp-11Ch] + float fNameTagCameraZCopy; // [esp+180h] [ebp-118h] + float fSmoke2CameraZCopy; // [esp+184h] [ebp-114h] + float fSmokeCameraZCopy; // [esp+188h] [ebp-110h] + float fModelCameraZCopy; // [esp+18Ch] [ebp-10Ch] + float fNameTagClampedZ; // [esp+190h] [ebp-108h] + float fSmoke2ClampedZ; // [esp+194h] [ebp-104h] + float fSmokeClampedZ; // [esp+198h] [ebp-100h] + float fModelClampedZ; // [esp+19Ch] [ebp-FCh] + float fNameTagViewY; // [esp+1A0h] [ebp-F8h] + float fSmoke2ViewY; // [esp+1A4h] [ebp-F4h] + float fSmokeViewY; // [esp+1A8h] [ebp-F0h] + float fModelViewY; // [esp+1ACh] [ebp-ECh] + float fNameTagViewX; // [esp+1B0h] [ebp-E8h] + float fSmoke2ViewX; // [esp+1B4h] [ebp-E4h] + float fSmokeViewX; // [esp+1B8h] [ebp-E0h] + float fModelViewX; // [esp+1BCh] [ebp-DCh] + float fPosZ; // [esp+1C0h] [ebp-D8h] + float fPosY; // [esp+1C4h] [ebp-D4h] + float fPosX; // [esp+1C8h] [ebp-D0h] + float fNameTagWorldZ; // [esp+1CCh] [ebp-CCh] + float fSmokeDepthCheck; // [esp+1D0h] [ebp-C8h] + int iTemp; // [esp+1D4h] [ebp-C4h] + float fNameTagWorldY; // [esp+1D8h] [ebp-C0h] + float fSmokeWorldY; // [esp+1DCh] [ebp-BCh] + float fNameTagWorldX; // [esp+1E0h] [ebp-B8h] + signed int iZOrderIndex; // [esp+1E4h] [ebp-B4h] + int iPolygonCount; // [esp+1E8h] [ebp-B0h] + float fBackfaceDotProduct; // [esp+1ECh] [ebp-ACh] + float fWarpDistortion; // [esp+1F0h] [ebp-A8h] + float fShadowViewY; // [esp+1F4h] [ebp-A4h] + float fModelCoordZLocal; // [esp+200h] [ebp-98h] + float fModelCoordYLocal; // [esp+204h] [ebp-94h] + float fModelCoordXLocal; // [esp+208h] [ebp-90h] + float fModelWorldZ; // [esp+20Ch] [ebp-8Ch] + float fModelWorldY; // [esp+210h] [ebp-88h] + float fModelWorldX; // [esp+214h] [ebp-84h] + float fCarPosZ; // [esp+218h] [ebp-80h] + float fCarPosY; // [esp+21Ch] [ebp-7Ch] + float fCarPosX; // [esp+220h] [ebp-78h] + int iCurrChunk; // [esp+224h] [ebp-74h] + int iNumCoords; // [esp+228h] [ebp-70h] + float fRotMat22Copy; // [esp+22Ch] [ebp-6Ch] + float fRotMat11; // [esp+230h] [ebp-68h] + float fRotMat20; // [esp+234h] [ebp-64h] + float fRotMat21; // [esp+238h] [ebp-60h] + float fRotMat12; // [esp+23Ch] [ebp-5Ch] + float fRotMat10; // [esp+240h] [ebp-58h] + float fRotMat02; // [esp+244h] [ebp-54h] + float fRotMat01; // [esp+248h] [ebp-50h] + float fRotMat00; // [esp+24Ch] [ebp-4Ch] + int iYaw; // [esp+250h] [ebp-48h] + tCar *pCar; // [esp+254h] [ebp-44h] tVec3 renderPosePos; float fPolygonVertex1Z; // [esp+264h] [ebp-34h] float fPolygonVertex1X; // [esp+268h] [ebp-30h] - tAnimation *pAnms; // [esp+278h] [ebp-20h] + tAnimation *pAnms; // [esp+278h] [ebp-20h] tCarDesign *pCarDesign; // [esp+27Ch] [ebp-1Ch] - float fSmokeWorldX; // [esp+280h] [ebp-18h] + float fSmokeWorldX; // [esp+280h] [ebp-18h] - iCarIndexCopy = iCarIndex; // Store car index parameter + iCarIndexCopy = iCarIndex; // Store car index parameter pScrBuf = pScreenBuffer; set_starts(0); - pCar = &Car[iCarIndex]; // Get pointer to car data structure + pCar = &Car[iCarIndex]; // Get pointer to car data structure renderPosePos = pose->position; - carDesignIndex = pCar->byCarDesignIdx; // Get car design index from car data + carDesignIndex = pCar->byCarDesignIdx; // Get car design index from car data iNumCoords = CarDesigns[carDesignIndex].byNumCoords; pCarDesign = &CarDesigns[carDesignIndex]; if (pCar->nCurrChunk == -1 || paused) { (iMotionX) = 0; (iMotionY) = 0; (iMotionZ) = 0; - //LOWORD(iMotionX) = 0; - //LOWORD(iMotionY) = 0; - //LOWORD(iMotionZ) = 0; + // LOWORD(iMotionX) = 0; + // LOWORD(iMotionY) = 0; + // LOWORD(iMotionZ) = 0; } else { iMotionX = pCar->iRollMotion; iMotionY = pCar->iPitchMotion; iMotionZ = pCar->iYawMotion; } - nRoll = pCar->iRollCameraOffset + iMotionX + pose->roll + pCar->iRollDynamicOffset; + nRoll = pCar->iRollCameraOffset + iMotionX + pose->roll + + pCar->iRollDynamicOffset; iYawAngle = ((int16)iMotionZ + pose->yaw) & 0x3FFF; - iPitch = ((uint16)pCar->iPitchCameraOffset + (int16)iMotionY + (uint16)pCar->iPitchDynamicOffset + pose->pitch) & 0x3FFF; + iPitch = ((uint16)pCar->iPitchCameraOffset + (int16)iMotionY + + (uint16)pCar->iPitchDynamicOffset + pose->pitch) & + 0x3FFF; - fRotMat00 = tcos[iYawAngle] * tcos[iPitch]; // Calculate 3x3 rotation matrix from car orientation angles + fRotMat00 = + tcos[iYawAngle] * + tcos[iPitch]; // Calculate 3x3 rotation matrix from car orientation angles fRotMat01 = tsin[iYawAngle] * tcos[iPitch]; dCosYaw = tcos[iYawAngle]; iYaw = iYawAngle; fRotMat02 = tsin[iPitch]; iRoll = nRoll & 0x3FFF; - fRotMat10 = (float)dCosYaw * fRotMat02 * tsin[iRoll] - tsin[iYawAngle] * tcos[iRoll]; - fRotMat12 = tsin[iYawAngle] * fRotMat02 * tsin[iRoll] + tcos[iYawAngle] * tcos[iRoll]; + fRotMat10 = + (float)dCosYaw * fRotMat02 * tsin[iRoll] - tsin[iYawAngle] * tcos[iRoll]; + fRotMat12 = + tsin[iYawAngle] * fRotMat02 * tsin[iRoll] + tcos[iYawAngle] * tcos[iRoll]; fRotMat21 = -tsin[iRoll] * tcos[iPitch]; - fRotMat20 = -tcos[iYawAngle] * fRotMat02 * tcos[iRoll] - tsin[iYawAngle] * tsin[iRoll]; - fRotMat11 = -tsin[iYawAngle] * fRotMat02 * tcos[iRoll] + tcos[iYawAngle] * tsin[iRoll]; + fRotMat20 = -tcos[iYawAngle] * fRotMat02 * tcos[iRoll] - + tsin[iYawAngle] * tsin[iRoll]; + fRotMat11 = -tsin[iYawAngle] * fRotMat02 * tcos[iRoll] + + tcos[iYawAngle] * tsin[iRoll]; dRotMat22 = tcos[iPitch] * tcos[iRoll]; fCarPosX = renderPosePos.fX; fCarPosY = renderPosePos.fY; @@ -1127,11 +1243,16 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa fCarPosZ = fZ; iCurrChunk = pCar->nCurrChunk; const uint8 *color_remap = options ? options->color_remap : NULL; - uiColorFrom = color_remap ? color_remap[0] : car_flat_remap[carDesignIndex].uiColorFrom; - uiColorTo = color_remap ? color_remap[1] : car_flat_remap[carDesignIndex].uiColorTo; + uiColorFrom = + color_remap ? color_remap[0] : car_flat_remap[carDesignIndex].uiColorFrom; + uiColorTo = + color_remap ? color_remap[1] : car_flat_remap[carDesignIndex].uiColorTo; pAnms = CarDesigns[carDesignIndex].pAnms; - if (fDistanceToCar >= 8000.0 && VisibleCars >= 4 || (textures_off & 0x100) != 0 || fDistanceToCar <= 0.0 || (pCar->byStatusFlags & 2) != 0) - goto LABEL_117; // Early exit if car is too far, invisible, or textures disabled + if (fDistanceToCar >= 8000.0 && VisibleCars >= 4 || + (textures_off & 0x100) != 0 || fDistanceToCar <= 0.0 || + (pCar->byStatusFlags & 2) != 0) + goto LABEL_117; // Early exit if car is too far, invisible, or textures + // disabled iChunk = pCar->nCurrChunk; if (iChunk == -1) iChunk = pCar->iLastValidChunk; @@ -1146,7 +1267,8 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa fCarPointY = CarBaseY; else fCarPointY = CarBaseY + -50.0f; - if (pCar->nCurrChunk == -1) // Setup car bounding box corners based on banking angle + if (pCar->nCurrChunk == + -1) // Setup car bounding box corners based on banking angle { if (iBank > 4096) { if (iBank <= 0x2000) { @@ -1230,35 +1352,50 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa dTransformMat11 = fRotMat11; dTransformMat01 = fRotMat01; do { - carworld[uiCarWorldOffset / 3].fX = (float)(carpoint[uiCarWorldOffset / 3].fY * fRotMat10 - + carpoint[uiCarWorldOffset / 3].fX * fRotMat00 - + carpoint[uiCarWorldOffset / 3].fZ * fRotMat20 - + *p_fX);// Transform car corner points from local to world coordinates - carworld[uiCarWorldOffset / 3].fY = (float)(carpoint[uiCarWorldOffset / 3].fY * fRotMat12 - + carpoint[uiCarWorldOffset / 3].fX * dTransformMat01 - + carpoint[uiCarWorldOffset / 3].fZ * dTransformMat11 - + p_fX[1]); - dTransformMat21 = carpoint[uiCarWorldOffset / 3].fY * dTransformMat12 - + carpoint[uiCarWorldOffset / 3].fX * dTransformMat02 - + carpoint[uiCarWorldOffset / 3].fZ * dTransformMat22 - + p_fX[2]; + carworld[uiCarWorldOffset / 3].fX = + (float)(carpoint[uiCarWorldOffset / 3].fY * fRotMat10 + + carpoint[uiCarWorldOffset / 3].fX * fRotMat00 + + carpoint[uiCarWorldOffset / 3].fZ * fRotMat20 + + *p_fX); // Transform car corner points from local to world + // coordinates + carworld[uiCarWorldOffset / 3].fY = + (float)(carpoint[uiCarWorldOffset / 3].fY * fRotMat12 + + carpoint[uiCarWorldOffset / 3].fX * dTransformMat01 + + carpoint[uiCarWorldOffset / 3].fZ * dTransformMat11 + + p_fX[1]); + dTransformMat21 = carpoint[uiCarWorldOffset / 3].fY * dTransformMat12 + + carpoint[uiCarWorldOffset / 3].fX * dTransformMat02 + + carpoint[uiCarWorldOffset / 3].fZ * dTransformMat22 + + p_fX[2]; carworld[uiCarWorldOffset / 3].fZ = (float)dTransformMat21; uiCarWorldOffset += 3; - //wConsoleNode_variable_1[uiCarWorldOffset] = dTransformMat21;// offset into carworld + // wConsoleNode_variable_1[uiCarWorldOffset] = dTransformMat21;// offset + // into carworld } while (uiCarWorldOffset != 12); - for (i = 0; i != 4; ++i)// carpoint[i + 3].fZ = dLocalZ)// offset into carlocal + for (i = 0; i != 4; + ++i) // carpoint[i + 3].fZ = dLocalZ)// offset into carlocal { - carlocal[i].fX = (carworld[i].fY + pTrackData->pointAy[3].fY) * pTrackData->pointAy[1].fX - + (carworld[i].fX + pTrackData->pointAy[3].fX) * pTrackData->pointAy[0].fX - + (carworld[i].fZ + pTrackData->pointAy[3].fZ) * pTrackData->pointAy[2].fX; - carlocal[i].fY = (carworld[i].fY + pTrackData->pointAy[3].fY) * pTrackData->pointAy[1].fY - + (carworld[i].fX + pTrackData->pointAy[3].fX) * pTrackData->pointAy[0].fY - + (carworld[i].fZ + pTrackData->pointAy[3].fZ) * pTrackData->pointAy[2].fY; - dLocalZ = (carworld[i].fY + pTrackData->pointAy[3].fY) * pTrackData->pointAy[1].fZ - + (carworld[i].fX + pTrackData->pointAy[3].fX) * pTrackData->pointAy[0].fZ - + (carworld[i].fZ + pTrackData->pointAy[3].fZ) * pTrackData->pointAy[2].fZ; + carlocal[i].fX = (carworld[i].fY + pTrackData->pointAy[3].fY) * + pTrackData->pointAy[1].fX + + (carworld[i].fX + pTrackData->pointAy[3].fX) * + pTrackData->pointAy[0].fX + + (carworld[i].fZ + pTrackData->pointAy[3].fZ) * + pTrackData->pointAy[2].fX; + carlocal[i].fY = (carworld[i].fY + pTrackData->pointAy[3].fY) * + pTrackData->pointAy[1].fY + + (carworld[i].fX + pTrackData->pointAy[3].fX) * + pTrackData->pointAy[0].fY + + (carworld[i].fZ + pTrackData->pointAy[3].fZ) * + pTrackData->pointAy[2].fY; + dLocalZ = (carworld[i].fY + pTrackData->pointAy[3].fY) * + pTrackData->pointAy[1].fZ + + (carworld[i].fX + pTrackData->pointAy[3].fX) * + pTrackData->pointAy[0].fZ + + (carworld[i].fZ + pTrackData->pointAy[3].fZ) * + pTrackData->pointAy[2].fZ; carlocal[i].fZ = (float)dLocalZ; - //++i; // replace carpoint assignment with this in for loop + //++i; // replace carpoint assignment + // with this in for loop } } else { pCarPosPtr = &renderPosePos.fX; @@ -1269,18 +1406,23 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa dTransformMat11_2 = fRotMat11; dTransformMat01_2 = fRotMat01; do { - carlocal[iCornerIndex].fX = fRotMat10 * carpoint[iCornerIndex].fY + fRotMat00 * carpoint[iCornerIndex].fX + fRotMat20 * carpoint[iCornerIndex].fZ + *pCarPosPtr; - carlocal[iCornerIndex].fY = (float)(fRotMat12 * carpoint[iCornerIndex].fY - + dTransformMat01_2 * carpoint[iCornerIndex].fX - + dTransformMat11_2 * carpoint[iCornerIndex].fZ - + pCarPosPtr[1]); - dTransformMat21_2 = dTransformMat12_2 * carpoint[iCornerIndex].fY - + dTransformMat02_2 * carpoint[iCornerIndex].fX - + dTransformMat22_2 * carpoint[iCornerIndex].fZ - + pCarPosPtr[2]; + carlocal[iCornerIndex].fX = fRotMat10 * carpoint[iCornerIndex].fY + + fRotMat00 * carpoint[iCornerIndex].fX + + fRotMat20 * carpoint[iCornerIndex].fZ + + *pCarPosPtr; + carlocal[iCornerIndex].fY = + (float)(fRotMat12 * carpoint[iCornerIndex].fY + + dTransformMat01_2 * carpoint[iCornerIndex].fX + + dTransformMat11_2 * carpoint[iCornerIndex].fZ + + pCarPosPtr[1]); + dTransformMat21_2 = dTransformMat12_2 * carpoint[iCornerIndex].fY + + dTransformMat02_2 * carpoint[iCornerIndex].fX + + dTransformMat22_2 * carpoint[iCornerIndex].fZ + + pCarPosPtr[2]; carlocal[iCornerIndex].fZ = (float)dTransformMat21_2; ++iCornerIndex; - //carpoint[++iCornerIndex + 3].fZ = dTransformMat21_2;// offset into carlocal + // carpoint[++iCornerIndex + 3].fZ = dTransformMat21_2;// offset into + // carlocal } while (iCornerIndex != 4); } nCurrChunk = pCar->nCurrChunk; @@ -1291,61 +1433,76 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa fLocalCarPosZ = fCarPosZ; } else { pCurrentTrackData = &localdata[nCurrChunk]; - fLocalCarPosX = pCurrentTrackData->pointAy[0].fY * fCarPosY - + pCurrentTrackData->pointAy[0].fX * fCarPosX - + pCurrentTrackData->pointAy[0].fZ * fCarPosZ - - pCurrentTrackData->pointAy[3].fX; - fLocalCarPosY = pCurrentTrackData->pointAy[1].fX * fCarPosX - + pCurrentTrackData->pointAy[1].fY * fCarPosY - + pCurrentTrackData->pointAy[1].fZ * fCarPosZ - - pCurrentTrackData->pointAy[3].fY; - fLocalCarPosZ = fCarPosY * pCurrentTrackData->pointAy[2].fY - + fCarPosX * pCurrentTrackData->pointAy[2].fX - + fCarPosZ * pCurrentTrackData->pointAy[2].fZ - - pCurrentTrackData->pointAy[3].fZ; + fLocalCarPosX = pCurrentTrackData->pointAy[0].fY * fCarPosY + + pCurrentTrackData->pointAy[0].fX * fCarPosX + + pCurrentTrackData->pointAy[0].fZ * fCarPosZ - + pCurrentTrackData->pointAy[3].fX; + fLocalCarPosY = pCurrentTrackData->pointAy[1].fX * fCarPosX + + pCurrentTrackData->pointAy[1].fY * fCarPosY + + pCurrentTrackData->pointAy[1].fZ * fCarPosZ - + pCurrentTrackData->pointAy[3].fY; + fLocalCarPosZ = fCarPosY * pCurrentTrackData->pointAy[2].fY + + fCarPosX * pCurrentTrackData->pointAy[2].fX + + fCarPosZ * pCurrentTrackData->pointAy[2].fZ - + pCurrentTrackData->pointAy[3].fZ; } dRelativeX = fLocalCarPosX + pTrackData->pointAy[3].fX; dRelativeY = fLocalCarPosY + pTrackData->pointAy[3].fY; dRelativeZ = fLocalCarPosZ + pTrackData->pointAy[3].fZ; - fTrackRelativeY = (float)(pTrackData->pointAy[0].fY * dRelativeX + pTrackData->pointAy[1].fY * dRelativeY + pTrackData->pointAy[2].fY * dRelativeZ); - fTrackRelativeZ = (float)(dRelativeX * pTrackData->pointAy[0].fZ + dRelativeY * pTrackData->pointAy[1].fZ + dRelativeZ * pTrackData->pointAy[2].fZ); + fTrackRelativeY = (float)(pTrackData->pointAy[0].fY * dRelativeX + + pTrackData->pointAy[1].fY * dRelativeY + + pTrackData->pointAy[2].fY * dRelativeZ); + fTrackRelativeZ = (float)(dRelativeX * pTrackData->pointAy[0].fZ + + dRelativeY * pTrackData->pointAy[1].fZ + + dRelativeZ * pTrackData->pointAy[2].fZ); iTunnelFlag = 0; if (fTrackRelativeY <= 0.0) { if (-pTrackData->fTrackHalfWidth < fTrackRelativeY) { iRightSurfaceType = pTrackInfo->iRightSurfaceType; - if ((iRightSurfaceType == 5 || iRightSurfaceType == 6 || iRightSurfaceType == 9) && fTrackRelativeZ < (double)pTrackInfo->fRoofHeight) + if ((iRightSurfaceType == 5 || iRightSurfaceType == 6 || + iRightSurfaceType == 9) && + fTrackRelativeZ < (double)pTrackInfo->fRoofHeight) goto LABEL_51; } } else if (fTrackRelativeY < (double)pTrackData->fTrackHalfWidth) { iLeftSurfaceType = pTrackInfo->iLeftSurfaceType; - if ((iLeftSurfaceType == 5 || iLeftSurfaceType == 6 || iLeftSurfaceType == 9) && fTrackRelativeZ < (double)pTrackInfo->fRoofHeight) - LABEL_51: - iTunnelFlag = -1; + if ((iLeftSurfaceType == 5 || iLeftSurfaceType == 6 || + iLeftSurfaceType == 9) && + fTrackRelativeZ < (double)pTrackInfo->fRoofHeight) + LABEL_51: + iTunnelFlag = -1; } iLaneType = pCar->iLaneType; iShadowRenderFlag = -1; iGroundedCorners = 0; - //ullTrackColor = TrakColour[iChunk][iLaneType]; - // SURFACE_FLAG_SKIP_RENDER - if ((TrakColour[iChunk][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0 && GroundColour[iChunk][2] < 0) - //if ((((HIDWORD(ullTrackColor) ^ (unsigned int)ullTrackColor) - HIDWORD(ullTrackColor)) & 0x20000) != 0 && GroundColour[iChunk][2] < 0) + // ullTrackColor = TrakColour[iChunk][iLaneType]; + // SURFACE_FLAG_SKIP_RENDER + if ((TrakColour[iChunk][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0 && + GroundColour[iChunk][2] < 0) + // if ((((HIDWORD(ullTrackColor) ^ (unsigned int)ullTrackColor) - + // HIDWORD(ullTrackColor)) & 0x20000) != 0 && GroundColour[iChunk][2] < 0) iShadowRenderFlag = 0; iGroundColorType = GroundColour[iChunk][2]; if (iGroundColorType == -2) { iUndergroundCheck = iTunnelFlag; iUndergroundIdx = 0; while (1) { - if (pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth < carlocal[iUndergroundIdx].fY - || -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth > carlocal[iUndergroundIdx].fY) { + if (pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth < + carlocal[iUndergroundIdx].fY || + -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth > + carlocal[iUndergroundIdx].fY) { if (!iUndergroundCheck) { - dUndergroundHeight = getbankz(carlocal[iUndergroundIdx].fY, iChunk, 0); + dUndergroundHeight = + getbankz(carlocal[iUndergroundIdx].fY, iChunk, 0); goto LABEL_101; } } else if (!iTunnelFlag) { - dUndergroundHeight = getgroundz(carlocal[iUndergroundIdx].fX, carlocal[iUndergroundIdx].fY, iChunk); + dUndergroundHeight = getgroundz(carlocal[iUndergroundIdx].fX, + carlocal[iUndergroundIdx].fY, iChunk); goto LABEL_101; } - dUndergroundHeight = getroadz(carlocal[iUndergroundIdx].fX, carlocal[iUndergroundIdx].fY, iChunk); + dUndergroundHeight = getroadz(carlocal[iUndergroundIdx].fX, + carlocal[iUndergroundIdx].fY, iChunk); LABEL_101: fGroundHeightTemp = (float)dUndergroundHeight; if (fGroundHeightTemp >= (double)carlocal[iUndergroundIdx].fZ) @@ -1356,7 +1513,7 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa goto LABEL_105; } } - iOnTrackFlag = 0; // Calculate ground/road height at car corner positions + iOnTrackFlag = 0; // Calculate ground/road height at car corner positions if (iGroundColorType == -1) iOnTrackFlag = -1; iCornerIdx = 0; @@ -1364,15 +1521,21 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa iChunkOffset = 24 * iChunk; do { if (iTunnelFlag) - dGroundHeight = getroadz(carlocal[iCornerIdx].fX, carlocal[iCornerIdx].fY, iChunk); + dGroundHeight = + getroadz(carlocal[iCornerIdx].fX, carlocal[iCornerIdx].fY, iChunk); else - dGroundHeight = getgroundz(carlocal[iCornerIdx].fX, carlocal[iCornerIdx].fY, iChunk); + dGroundHeight = + getgroundz(carlocal[iCornerIdx].fX, carlocal[iCornerIdx].fY, iChunk); roadheight[iHeightIdx] = (float)dGroundHeight; - if (pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth >= carlocal[iCornerIdx].fY - && -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth <= carlocal[iCornerIdx].fY) { - //iTemp = 4 * pCar->iLaneType; - // SURFACE_FLAG_SKIP_RENDER - if ((TrakColour[iChunk][pCar->iLaneType] & SURFACE_FLAG_SKIP_RENDER) == 0 && roadheight[iHeightIdx] + -400.0 <= carlocal[iCornerIdx].fZ) + if (pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth >= + carlocal[iCornerIdx].fY && + -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth <= + carlocal[iCornerIdx].fY) { + // iTemp = 4 * pCar->iLaneType; + // SURFACE_FLAG_SKIP_RENDER + if ((TrakColour[iChunk][pCar->iLaneType] & SURFACE_FLAG_SKIP_RENDER) == + 0 && + roadheight[iHeightIdx] + -400.0 <= carlocal[iCornerIdx].fZ) iOnTrackFlag = -1; } ++iHeightIdx; @@ -1403,19 +1566,24 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa } else { pTrackData = &tempData; calculateseparatedcoordinatesystem(iChunk, &tempData); - for (m = 0; m != 4; ++m)//carpoint[m + 3].fZ = fCoordZ)// offset into carlocal + for (m = 0; m != 4; + ++m) // carpoint[m + 3].fZ = fCoordZ)// offset into carlocal { - carlocal[m].fX = (carworld[m].fY + tempData.pointAy[3].fY) * tempData.pointAy[1].fX - + (carworld[m].fX + tempData.pointAy[3].fX) * tempData.pointAy[0].fX - + (carworld[m].fZ + tempData.pointAy[3].fZ) * tempData.pointAy[2].fX; - carlocal[m].fY = (carworld[m].fY + tempData.pointAy[3].fY) * tempData.pointAy[1].fY - + (carworld[m].fX + tempData.pointAy[3].fX) * tempData.pointAy[0].fY - + (carworld[m].fZ + tempData.pointAy[3].fZ) * tempData.pointAy[2].fY; - dCoordZ = (carworld[m].fY + tempData.pointAy[3].fY) * tempData.pointAy[1].fZ - + (carworld[m].fX + tempData.pointAy[3].fX) * tempData.pointAy[0].fZ - + (carworld[m].fZ + tempData.pointAy[3].fZ) * tempData.pointAy[2].fZ; + carlocal[m].fX = + (carworld[m].fY + tempData.pointAy[3].fY) * tempData.pointAy[1].fX + + (carworld[m].fX + tempData.pointAy[3].fX) * tempData.pointAy[0].fX + + (carworld[m].fZ + tempData.pointAy[3].fZ) * tempData.pointAy[2].fX; + carlocal[m].fY = + (carworld[m].fY + tempData.pointAy[3].fY) * tempData.pointAy[1].fY + + (carworld[m].fX + tempData.pointAy[3].fX) * tempData.pointAy[0].fY + + (carworld[m].fZ + tempData.pointAy[3].fZ) * tempData.pointAy[2].fY; + dCoordZ = + (carworld[m].fY + tempData.pointAy[3].fY) * tempData.pointAy[1].fZ + + (carworld[m].fX + tempData.pointAy[3].fX) * tempData.pointAy[0].fZ + + (carworld[m].fZ + tempData.pointAy[3].fZ) * tempData.pointAy[2].fZ; carlocal[m].fZ = (float)dCoordZ; - //++m; // replace carpoint assignment with this in for loop + //++m; // replace carpoint assignment + // with this in for loop } for (n = 0; n != 4; ++n) { dBankHeight = getbankz(carlocal[n].fY, iChunk, &tempData); @@ -1428,31 +1596,41 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa if (iShadowRenderFlag && pCar->iControlType != 3 && iGroundedCorners >= 2) iShadowRenderFlag = 0; if (iShadowRenderFlag) { - for (iShadowOffset = 0; iShadowOffset != 48; iShadowOffset += 0xC)// wConsoleNode_variable_1[iShadowOffset / 4u] = dWorldToLocalZ)// offset into carworld + for (iShadowOffset = 0; iShadowOffset != 48; + iShadowOffset += 0xC) // wConsoleNode_variable_1[iShadowOffset / 4u] = + // dWorldToLocalZ)// offset into carworld { - carworld[iShadowOffset / 0xCu].fX = pTrackData->pointAy[0].fY * carlocal[iShadowOffset / 0xCu].fY - + pTrackData->pointAy[0].fX * carlocal[iShadowOffset / 0xCu].fX - + pTrackData->pointAy[0].fZ * carlocal[iShadowOffset / 0xCu].fZ - - pTrackData->pointAy[3].fX; - carworld[iShadowOffset / 0xCu].fY = pTrackData->pointAy[1].fY * carlocal[iShadowOffset / 0xCu].fY - + pTrackData->pointAy[1].fX * carlocal[iShadowOffset / 0xCu].fX - + pTrackData->pointAy[1].fZ * carlocal[iShadowOffset / 0xCu].fZ - - pTrackData->pointAy[3].fY; - dWorldToLocalZ = pTrackData->pointAy[2].fY * carlocal[iShadowOffset / 0xCu].fY - + pTrackData->pointAy[2].fX * carlocal[iShadowOffset / 0xCu].fX - + pTrackData->pointAy[2].fZ * carlocal[iShadowOffset / 0xCu].fZ - - pTrackData->pointAy[3].fZ; + carworld[iShadowOffset / 0xCu].fX = + pTrackData->pointAy[0].fY * carlocal[iShadowOffset / 0xCu].fY + + pTrackData->pointAy[0].fX * carlocal[iShadowOffset / 0xCu].fX + + pTrackData->pointAy[0].fZ * carlocal[iShadowOffset / 0xCu].fZ - + pTrackData->pointAy[3].fX; + carworld[iShadowOffset / 0xCu].fY = + pTrackData->pointAy[1].fY * carlocal[iShadowOffset / 0xCu].fY + + pTrackData->pointAy[1].fX * carlocal[iShadowOffset / 0xCu].fX + + pTrackData->pointAy[1].fZ * carlocal[iShadowOffset / 0xCu].fZ - + pTrackData->pointAy[3].fY; + dWorldToLocalZ = + pTrackData->pointAy[2].fY * carlocal[iShadowOffset / 0xCu].fY + + pTrackData->pointAy[2].fX * carlocal[iShadowOffset / 0xCu].fX + + pTrackData->pointAy[2].fZ * carlocal[iShadowOffset / 0xCu].fZ - + pTrackData->pointAy[3].fZ; carworld[iShadowOffset / 0xC].fZ = (float)dWorldToLocalZ; - //iShadowOffset += 0xC; // replace consolenode assign with this in for loop + // iShadowOffset += 0xC; // replace consolenode assign + // with this in for loop } iScreenSize = scr_size; - for (ii = 0; ii != 4; ++ii)//carworld[ii + 3].fY = (float)iTemp)// offset into carpoint + for (ii = 0; ii != 4; + ++ii) // carworld[ii + 3].fY = (float)iTemp)// offset into carpoint { - dViewDeltaX = carworld[ii].fX - viewx; // Render car shadow as flat polygon on ground + dViewDeltaX = carworld[ii].fX - + viewx; // Render car shadow as flat polygon on ground dViewDeltaY = carworld[ii].fY - viewy; dViewDeltaZ = carworld[ii].fZ - viewz; - fShadowViewX = (float)(dViewDeltaX * vk1 + dViewDeltaY * vk4 + dViewDeltaZ * vk7); - fShadowViewY = (float)(dViewDeltaX * vk2 + dViewDeltaY * vk5 + dViewDeltaZ * vk8); + fShadowViewX = + (float)(dViewDeltaX * vk1 + dViewDeltaY * vk4 + dViewDeltaZ * vk7); + fShadowViewY = + (float)(dViewDeltaX * vk2 + dViewDeltaY * vk5 + dViewDeltaZ * vk8); dViewSpaceZ = dViewDeltaX * vk3 + dViewDeltaY * vk6 + dViewDeltaZ * vk9; fClampedZ = (float)dViewSpaceZ; if (dViewSpaceZ < 80.0) @@ -1461,17 +1639,18 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa dInverseZ = 1.0 / fClampedZ; dScreenX = dViewDistance * fShadowViewX * dInverseZ + (double)xbase; //_CHP(); - if (!isnan(dScreenX)) { //check added by ROLLER + if (!isnan(dScreenX)) { // check added by ROLLER xp = d2i(dScreenX); dScreenY = dInverseZ * (dViewDistance * fShadowViewY) + (double)ybase; //_CHP(); yp = d2i(dScreenY); carpoint[ii].fX = (float)(xp * iScreenSize >> 6); - //carpoint[ii].fX = (float)(iScreenXInt >> 6); + // carpoint[ii].fX = (float)(iScreenXInt >> 6); iTemp = (iScreenSize * (199 - d2i(dScreenY))) >> 6; carpoint[ii].fY = (float)iTemp; } - //++ii; // replace reference to carworld in for loop with this + //++ii; // replace reference to + // carworld in for loop with this } dShadowX = carpoint[0].fX; //_CHP(); @@ -1499,7 +1678,8 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa CarPol.uiNumVerts = 4; CarPol.iSurfaceType = 0x202002; CarPol.vertices[3].y = d2i(dShadowCorner3Y); - game_render_quad_screen(g_pGameRenderer, &CarPol, TEXTURE_HANDLE_INVALID, NULL); + game_render_quad_screen(g_pGameRenderer, &CarPol, TEXTURE_HANDLE_INVALID, + NULL); } LABEL_117: pCoords = CarDesigns[carDesignIndex].pCoords; @@ -1508,12 +1688,15 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa pCarDesign = NULL; iNumCoords = 0; } - fWarpDistortion = tsin[((uint16)warp_angle + ((uint16)iCarIndexCopy << 11)) & 0x3FFF] * 0.5f; - if (iNumCoords > 0) // Process 3D car model coordinates and transform to screen space + fWarpDistortion = + tsin[((uint16)warp_angle + ((uint16)iCarIndexCopy << 11)) & 0x3FFF] * + 0.5f; + if (iNumCoords > + 0) // Process 3D car model coordinates and transform to screen space { iCoordOffset = 0; iCoordLoopSize = 32 * iNumCoords; - //iCurrChunk bounds check added by ROLLER + // iCurrChunk bounds check added by ROLLER if (iCurrChunk >= 0 && iCurrChunk < TRAK_LEN) pChunkData = &localdata[iCurrChunk]; else @@ -1523,70 +1706,90 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa fModelCoordX = pCoords->fX; pCoordPtr = &pCoords->fY; fModelCoordXLocal = fModelCoordX; - fModelCoordY = *pCoordPtr++; // increment to Z pos + fModelCoordY = *pCoordPtr++; // increment to Z pos fModelCoordYLocal = fModelCoordY; fModelCoordZ = *pCoordPtr; - pCoords = (tVec3 *)(pCoordPtr + 1); // increment to next coord + pCoords = (tVec3 *)(pCoordPtr + 1); // increment to next coord fModelCoordZLocal = fModelCoordZ; // CHEAT_MODE_TINY_CARS - if ((cheat_mode & CHEAT_MODE_TINY_CARS) != 0) // Apply CHEAT_MODE_TINY_CARS scaling if enabled + if ((cheat_mode & CHEAT_MODE_TINY_CARS) != + 0) // Apply CHEAT_MODE_TINY_CARS scaling if enabled { fModelCoordXLocal = fModelCoordXLocal * 0.25f; fModelCoordYLocal = 0.25f * fModelCoordYLocal; } // CHEAT_MODE_WARP - if ((cheat_mode & CHEAT_MODE_WARP) != 0) // Apply CHEAT_MODE_WARP distortion effect if enabled + if ((cheat_mode & CHEAT_MODE_WARP) != + 0) // Apply CHEAT_MODE_WARP distortion effect if enabled { - fModelCoordXLocal = fModelCoordXLocal * fWarpDistortion + fModelCoordXLocal; - fModelCoordYLocal = fModelCoordYLocal * fWarpDistortion + fModelCoordYLocal; - fModelCoordZLocal = fWarpDistortion * fModelCoordZLocal + fModelCoordZLocal; + fModelCoordXLocal = + fModelCoordXLocal * fWarpDistortion + fModelCoordXLocal; + fModelCoordYLocal = + fModelCoordYLocal * fWarpDistortion + fModelCoordYLocal; + fModelCoordZLocal = + fWarpDistortion * fModelCoordZLocal + fModelCoordZLocal; } dTransformedX = fModelCoordXLocal; dTransformedY = fModelCoordYLocal; dTransformedZ = fModelCoordZLocal; - CarPt[iCoordOffset / 0x20].world.fX = fModelCoordXLocal * fRotMat00 + fModelCoordYLocal * fRotMat10 + fModelCoordZLocal * fRotMat20 + fCarPosX; - CarPt[iCoordOffset / 0x20].world.fY = (float)(dTransformedX * fRotMat01 + dTransformedY * fRotMat12 + dTransformedZ * fRotMat11 + fCarPosY); + CarPt[iCoordOffset / 0x20].world.fX = + fModelCoordXLocal * fRotMat00 + fModelCoordYLocal * fRotMat10 + + fModelCoordZLocal * fRotMat20 + fCarPosX; + CarPt[iCoordOffset / 0x20].world.fY = + (float)(dTransformedX * fRotMat01 + dTransformedY * fRotMat12 + + dTransformedZ * fRotMat11 + fCarPosY); iCurrentChunk = iCurrChunk; - CarPt[iCoordOffset / 0x20].world.fZ = (float)(dTransformedX * fRotMat02 + dTransformedY * fRotMat21 + dTransformedZ * fRotMat22Copy + fCarPosZ); + CarPt[iCoordOffset / 0x20].world.fZ = + (float)(dTransformedX * fRotMat02 + dTransformedY * fRotMat21 + + dTransformedZ * fRotMat22Copy + fCarPosZ); if (iCurrentChunk != -1) { dChunkTransformY = pChunkData->pointAy[0].fY; fModelWorldX = CarPt[iCoordOffset / 0x20].world.fX; fModelWorldY = CarPt[iCoordOffset / 0x20].world.fY; - dChunkTransformX = dChunkTransformY * fModelWorldY + pChunkData->pointAy[0].fX * fModelWorldX; + dChunkTransformX = dChunkTransformY * fModelWorldY + + pChunkData->pointAy[0].fX * fModelWorldX; dChunkMatrixZ = pChunkData->pointAy[0].fZ; fModelWorldZ = CarPt[iCoordOffset / 0x20].world.fZ; - CarPt[iCoordOffset / 0x20].world.fX = (float)(dChunkTransformX + dChunkMatrixZ * fModelWorldZ - pChunkData->pointAy[3].fX); - CarPt[iCoordOffset / 0x20].world.fY = pChunkData->pointAy[1].fX * fModelWorldX - + pChunkData->pointAy[1].fY * fModelWorldY - + pChunkData->pointAy[1].fZ * fModelWorldZ - - pChunkData->pointAy[3].fY; - dChunkTransformZ = pChunkData->pointAy[2].fX * fModelWorldX - + pChunkData->pointAy[2].fY * fModelWorldY - + pChunkData->pointAy[2].fZ * fModelWorldZ - - pChunkData->pointAy[3].fZ; + CarPt[iCoordOffset / 0x20].world.fX = + (float)(dChunkTransformX + dChunkMatrixZ * fModelWorldZ - + pChunkData->pointAy[3].fX); + CarPt[iCoordOffset / 0x20].world.fY = + pChunkData->pointAy[1].fX * fModelWorldX + + pChunkData->pointAy[1].fY * fModelWorldY + + pChunkData->pointAy[1].fZ * fModelWorldZ - + pChunkData->pointAy[3].fY; + dChunkTransformZ = pChunkData->pointAy[2].fX * fModelWorldX + + pChunkData->pointAy[2].fY * fModelWorldY + + pChunkData->pointAy[2].fZ * fModelWorldZ - + pChunkData->pointAy[3].fZ; pChunkDataPtr = (float *)pChunkData; CarPt[iCoordOffset / 0x20].world.fZ = (float)dChunkTransformZ; } dViewRelativeX = CarPt[iCoordOffset / 0x20].world.fX - viewx; dViewRelativeY = CarPt[iCoordOffset / 0x20].world.fY - viewy; dViewRelativeZ = CarPt[iCoordOffset / 0x20].world.fZ - viewz; - fModelViewX = (float)(dViewRelativeX * vk1 + dViewRelativeY * vk4 + dViewRelativeZ * vk7); - fModelViewY = (float)(dViewRelativeX * vk2 + dViewRelativeY * vk5 + dViewRelativeZ * vk8); - dCameraSpaceZ = dViewRelativeX * vk3 + dViewRelativeY * vk6 + dViewRelativeZ * vk9; + fModelViewX = (float)(dViewRelativeX * vk1 + dViewRelativeY * vk4 + + dViewRelativeZ * vk7); + fModelViewY = (float)(dViewRelativeX * vk2 + dViewRelativeY * vk5 + + dViewRelativeZ * vk8); + dCameraSpaceZ = + dViewRelativeX * vk3 + dViewRelativeY * vk6 + dViewRelativeZ * vk9; fModelClampedZ = (float)dCameraSpaceZ; fModelCameraZCopy = fModelClampedZ; if (dCameraSpaceZ < 80.0) fModelClampedZ = 80.0; dProjViewDistance = (double)VIEWDIST; dProjInverseZ = 1.0 / fModelClampedZ; - dProjScreenX = dProjViewDistance * fModelViewX * dProjInverseZ + (double)xbase; + dProjScreenX = + dProjViewDistance * fModelViewX * dProjInverseZ + (double)xbase; //_CHP(); xp = d2i(dProjScreenX); - dProjScreenY = dProjInverseZ * (dProjViewDistance * fModelViewY) + (double)ybase; + dProjScreenY = + dProjInverseZ * (dProjViewDistance * fModelViewY) + (double)ybase; //_CHP(); yp = d2i(dProjScreenY); CarPt[iCoordOffset / 0x20].screen.x = xp * scr_size >> 6; - //CarPt[iCoordOffset / 0x20].screen.x = iScreenXResult >> 6; + // CarPt[iCoordOffset / 0x20].screen.x = iScreenXResult >> 6; CarPt[iCoordOffset / 0x20].screen.y = (scr_size * (199 - yp)) >> 6; CarPt[iCoordOffset / 0x20].view.fX = fModelViewX; CarPt[iCoordOffset / 0x20].view.fY = fModelViewY; @@ -1594,10 +1797,10 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa iCoordOffset += 32; // All these are offsets into CarPt - //*(_DWORD *)((char *)&carlocal[3].fX + iCoordOffset) = (scr_size * (199 - yp)) >> 6; - //roadheight[iCoordOffset / 4 + 1] = fModelViewX; - //roadheight[iCoordOffset / 4 + 2] = fModelViewY; - //roadheight[iCoordOffset / 4 + 3] = fModelCameraZCopy; + //*(_DWORD *)((char *)&carlocal[3].fX + iCoordOffset) = (scr_size * (199 - + // yp)) >> 6; roadheight[iCoordOffset / 4 + 1] = fModelViewX; + // roadheight[iCoordOffset / 4 + 2] = fModelViewY; + // roadheight[iCoordOffset / 4 + 3] = fModelCameraZCopy; } while ((int)iCoordOffset < iCoordLoopSize); } iVisiblePolygons = 0; @@ -1608,31 +1811,45 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa for (jj = 0; jj < 4; ++jj) { polygonVertices[jj] = &CarPt[pPols->verts[jj]]; } - //pCurrentPolygon = (uint8 *)pPols; // ->verts[0] - //for (jj = 0; jj != 16; *(_DWORD *)((char *)&tempData.fAIMaxSpeed + jj) = pCarVertex)// reference into polygonVertices + // pCurrentPolygon = (uint8 *)pPols; // ->verts[0] + // for (jj = 0; jj != 16; *(_DWORD *)((char *)&tempData.fAIMaxSpeed + jj) + // = pCarVertex)// reference into polygonVertices //{ - // jj += 4; - // pCarVertex = &CarPt[*pCurrentPolygon++]; - //} + // jj += 4; + // pCarVertex = &CarPt[*pCurrentPolygon++]; + // } - dCrossProduct1X = polygonVertices[2]->view.fX - polygonVertices[0]->view.fX;// Test polygon visibility using cross product (backface culling) - fCrossProductY = polygonVertices[2]->view.fY - polygonVertices[0]->view.fY; - dCrossProduct1Z = polygonVertices[2]->view.fZ - polygonVertices[0]->view.fZ; + dCrossProduct1X = + polygonVertices[2]->view.fX - + polygonVertices[0]->view.fX; // Test polygon visibility using cross + // product (backface culling) + fCrossProductY = + polygonVertices[2]->view.fY - polygonVertices[0]->view.fY; + dCrossProduct1Z = + polygonVertices[2]->view.fZ - polygonVertices[0]->view.fZ; fPolygonVertex1X = polygonVertices[1]->view.fX; fPolygonVertex1Y = polygonVertices[1]->view.fY; fPolygonVertex1Z = polygonVertices[1]->view.fZ; dCrossProduct2X = fPolygonVertex1X - polygonVertices[3]->view.fX; dCrossProduct2Y = fPolygonVertex1Y - polygonVertices[3]->view.fY; dCrossProduct2Z = fPolygonVertex1Z - polygonVertices[3]->view.fZ; - //byTextureFlags = BYTE1(pPols->uiTex); - fBackfaceDotProduct = (float)((fCrossProductY * dCrossProduct2Z - dCrossProduct1Z * dCrossProduct2Y) * fPolygonVertex1X - + (dCrossProduct1Z * dCrossProduct2X - dCrossProduct2Z * dCrossProduct1X) * fPolygonVertex1Y - + (dCrossProduct2Y * dCrossProduct1X - dCrossProduct2X * fCrossProductY) * fPolygonVertex1Z); -// SURFACE_FLAG_FLIP_BACKFACE - if ((pPols->uiTex & SURFACE_FLAG_FLIP_BACKFACE) != 0 || fBackfaceDotProduct <= 0.0) { - //if ((byTextureFlags & 0x20) != 0 || fBackfaceDotProduct <= 0.0) { - // SURFACE_FLAG_BACK - if (fBackfaceDotProduct > 0.0 && (pPols->uiTex & SURFACE_FLAG_BACK) != 0) + // byTextureFlags = BYTE1(pPols->uiTex); + fBackfaceDotProduct = (float)((fCrossProductY * dCrossProduct2Z - + dCrossProduct1Z * dCrossProduct2Y) * + fPolygonVertex1X + + (dCrossProduct1Z * dCrossProduct2X - + dCrossProduct2Z * dCrossProduct1X) * + fPolygonVertex1Y + + (dCrossProduct2Y * dCrossProduct1X - + dCrossProduct2X * fCrossProductY) * + fPolygonVertex1Z); + // SURFACE_FLAG_FLIP_BACKFACE + if ((pPols->uiTex & SURFACE_FLAG_FLIP_BACKFACE) != 0 || + fBackfaceDotProduct <= 0.0) { + // if ((byTextureFlags & 0x20) != 0 || fBackfaceDotProduct <= 0.0) { + // SURFACE_FLAG_BACK + if (fBackfaceDotProduct > 0.0 && + (pPols->uiTex & SURFACE_FLAG_BACK) != 0) iPolygonResult = -iPolygonCount - 1; else iPolygonResult = iPolygonCount; @@ -1640,24 +1857,28 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa CarZOrder[iPolygonLoopIdx].iPolygonLink = pPols->nNextPolIdx; // CAR_FLAG_ANMS_LIVERY if ((pPols->uiTex & CAR_FLAG_ANMS_LIVERY) == 0) { - if (CarPt[pPols->verts[2]].view.fZ <= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ <= + (double)CarPt[pPols->verts[3]].view.fZ) fZDepthMax1 = CarPt[pPols->verts[3]].view.fZ; else fZDepthMax1 = CarPt[pPols->verts[2]].view.fZ; fZDepthFarMax1 = fZDepthMax1; - if (CarPt[pPols->verts[0]].view.fZ <= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ <= + (double)CarPt[pPols->verts[1]].view.fZ) fZDepthMax2 = CarPt[pPols->verts[1]].view.fZ; else fZDepthMax2 = CarPt[pPols->verts[0]].view.fZ; fZDepthFarMax2 = fZDepthMax2; if (fZDepthMax2 <= (double)fZDepthFarMax1) { - if (CarPt[pPols->verts[2]].view.fZ <= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ <= + (double)CarPt[pPols->verts[3]].view.fZ) fZDepthFinal = CarPt[pPols->verts[3]].view.fZ; else fZDepthFinal = CarPt[pPols->verts[2]].view.fZ; fZDepthFarMin2 = fZDepthFinal; } else { - if (CarPt[pPols->verts[0]].view.fZ <= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ <= + (double)CarPt[pPols->verts[1]].view.fZ) fZDepthFinal = CarPt[pPols->verts[1]].view.fZ; else fZDepthFinal = CarPt[pPols->verts[0]].view.fZ; @@ -1665,24 +1886,28 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa } fZDepthFarFinal = fZDepthFinal; } else { - if (CarPt[pPols->verts[2]].view.fZ >= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ >= + (double)CarPt[pPols->verts[3]].view.fZ) fZDepthMin1 = CarPt[pPols->verts[3]].view.fZ; else fZDepthMin1 = CarPt[pPols->verts[2]].view.fZ; fZDepthCloseMin1 = fZDepthMin1; - if (CarPt[pPols->verts[0]].view.fZ >= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ >= + (double)CarPt[pPols->verts[1]].view.fZ) fZDepthMin2 = CarPt[pPols->verts[1]].view.fZ; else fZDepthMin2 = CarPt[pPols->verts[0]].view.fZ; fZDepthCloseMin2 = fZDepthMin2; if (fZDepthMin2 >= (double)fZDepthCloseMin1) { - if (CarPt[pPols->verts[2]].view.fZ >= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ >= + (double)CarPt[pPols->verts[3]].view.fZ) fZDepthFinal = CarPt[pPols->verts[3]].view.fZ; else fZDepthFinal = CarPt[pPols->verts[2]].view.fZ; fZDepthCloseFar2 = fZDepthFinal; } else { - if (CarPt[pPols->verts[0]].view.fZ >= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ >= + (double)CarPt[pPols->verts[1]].view.fZ) fZDepthFinal = CarPt[pPols->verts[1]].view.fZ; else fZDepthFinal = CarPt[pPols->verts[0]].view.fZ; @@ -1722,8 +1947,10 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa kk = iVisiblePolygons; } } - if (iLinkedPolygonIdx > 0 && iDepthSortIdx > 0)//depth sort check added by ROLLER - CarZOrder[iLinkedPolygonIdx].fZDepth = CarZOrder[iDepthSortIdx].fZDepth + -1.0f; + if (iLinkedPolygonIdx > 0 && + iDepthSortIdx > 0) // depth sort check added by ROLLER + CarZOrder[iLinkedPolygonIdx].fZDepth = + CarZOrder[iDepthSortIdx].fZDepth + -1.0f; nNextPolIdx = pLinkedPolygons[nNextPolIdx].nNextPolIdx; iDepthSortIdx = iLinkedPolygonIdx; } while (nNextPolIdx >= 0); @@ -1735,7 +1962,8 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa if (iVisiblePolygons > 0 || (Car[iCarIndexCopy].byStatusFlags & 2) != 0) { iSpriteIdx = 0; - if (iCurrChunk >= 0 && iCurrChunk < TRAK_LEN)// bounds check added by ROLLER + if (iCurrChunk >= 0 && + iCurrChunk < TRAK_LEN) // bounds check added by ROLLER pTrackChunkPtr = (float *)&localdata[iCurrChunk]; else pTrackChunkPtr = NULL; @@ -1744,49 +1972,71 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa pSmokeSpray = pCarSprayArray; iSmokeIndex = 0; iSmokeZOrderIdx = iVisiblePolygons; - do { // Process and render car smoke/spray particle effects + do { // Process and render car smoke/spray particle effects if (pSmokeSpray->iLifeTime > 0) { fPosX = pSmokeSpray->position.fX; fPosY = pSmokeSpray->position.fY; fPosZ = pSmokeSpray->position.fZ; - SmokePt[0][iSmokeIndex].world.fX = fPosX * fRotMat00 + fPosY * fRotMat10 + fPosZ * fRotMat20 + fCarPosX; - SmokePt[0][iSmokeIndex].world.fY = fPosX * fRotMat01 + fPosY * fRotMat12 + fPosZ * fRotMat11 + fCarPosY; + SmokePt[0][iSmokeIndex].world.fX = fPosX * fRotMat00 + + fPosY * fRotMat10 + + fPosZ * fRotMat20 + fCarPosX; + SmokePt[0][iSmokeIndex].world.fY = fPosX * fRotMat01 + + fPosY * fRotMat12 + + fPosZ * fRotMat11 + fCarPosY; iSmokeChunkIdx = iCurrChunk; - SmokePt[0][iSmokeIndex].world.fZ = fPosX * fRotMat02 + fPosY * fRotMat21 + fPosZ * fRotMat22Copy + fCarPosZ; + SmokePt[0][iSmokeIndex].world.fZ = fPosX * fRotMat02 + + fPosY * fRotMat21 + + fPosZ * fRotMat22Copy + fCarPosZ; if (iSmokeChunkIdx != -1 && pTrackChunkPtr) { dSmokeChunkTransY = pTrackChunkPtr[1]; fSmokeWorldX = SmokePt[0][iSmokeIndex].world.fX; fSmokeWorldY = SmokePt[0][iSmokeIndex].world.fY; - dSmokeChunkTransX = dSmokeChunkTransY * fSmokeWorldY + *pTrackChunkPtr * fSmokeWorldX; + dSmokeChunkTransX = + dSmokeChunkTransY * fSmokeWorldY + *pTrackChunkPtr * fSmokeWorldX; dSmokeChunkMatZ = pTrackChunkPtr[2]; - //iTemp = LODWORD(SmokePt[0][iSmokeIndex].world.fZ); + // iTemp = LODWORD(SmokePt[0][iSmokeIndex].world.fZ); float fSmokeWorldZ = SmokePt[0][iSmokeIndex].world.fZ; - SmokePt[0][iSmokeIndex].world.fX = (float)(dSmokeChunkTransX + dSmokeChunkMatZ * fSmokeWorldZ - pTrackChunkPtr[9]); - SmokePt[0][iSmokeIndex].world.fY = pTrackChunkPtr[3] * fSmokeWorldX + pTrackChunkPtr[4] * fSmokeWorldY + pTrackChunkPtr[5] * fSmokeWorldZ - pTrackChunkPtr[10]; - dSmokeChunkTransZ = pTrackChunkPtr[6] * fSmokeWorldX + pTrackChunkPtr[7] * fSmokeWorldY + pTrackChunkPtr[8] * fSmokeWorldZ - pTrackChunkPtr[11]; + SmokePt[0][iSmokeIndex].world.fX = + (float)(dSmokeChunkTransX + dSmokeChunkMatZ * fSmokeWorldZ - + pTrackChunkPtr[9]); + SmokePt[0][iSmokeIndex].world.fY = pTrackChunkPtr[3] * fSmokeWorldX + + pTrackChunkPtr[4] * fSmokeWorldY + + pTrackChunkPtr[5] * fSmokeWorldZ - + pTrackChunkPtr[10]; + dSmokeChunkTransZ = pTrackChunkPtr[6] * fSmokeWorldX + + pTrackChunkPtr[7] * fSmokeWorldY + + pTrackChunkPtr[8] * fSmokeWorldZ - + pTrackChunkPtr[11]; pChunkDataPtr = pTrackChunkPtr; SmokePt[0][iSmokeIndex].world.fZ = (float)dSmokeChunkTransZ; } dSmokeViewDeltaX = SmokePt[0][iSmokeIndex].world.fX - viewx; dSmokeViewDeltaY = SmokePt[0][iSmokeIndex].world.fY - viewy; dSmokeViewDeltaZ = SmokePt[0][iSmokeIndex].world.fZ - viewz; - fSmokeViewX = (float)(dSmokeViewDeltaX * vk1 + dSmokeViewDeltaY * vk4 + dSmokeViewDeltaZ * vk7); - fSmokeViewY = (float)(dSmokeViewDeltaX * vk2 + dSmokeViewDeltaY * vk5 + dSmokeViewDeltaZ * vk8); - dSmokeCameraZ = dSmokeViewDeltaX * vk3 + dSmokeViewDeltaY * vk6 + dSmokeViewDeltaZ * vk9; + fSmokeViewX = (float)(dSmokeViewDeltaX * vk1 + dSmokeViewDeltaY * vk4 + + dSmokeViewDeltaZ * vk7); + fSmokeViewY = (float)(dSmokeViewDeltaX * vk2 + dSmokeViewDeltaY * vk5 + + dSmokeViewDeltaZ * vk8); + dSmokeCameraZ = dSmokeViewDeltaX * vk3 + dSmokeViewDeltaY * vk6 + + dSmokeViewDeltaZ * vk9; fSmokeClampedZ = (float)dSmokeCameraZ; fSmokeCameraZCopy = fSmokeClampedZ; if (dSmokeCameraZ < 80.0) fSmokeClampedZ = 80.0; dSmokeProjViewDist = (double)VIEWDIST; dSmokeProjInverseZ = 1.0 / fSmokeClampedZ; - dSmokeProjScreenX = dSmokeProjViewDist * fSmokeViewX * dSmokeProjInverseZ + (double)xbase; + dSmokeProjScreenX = + dSmokeProjViewDist * fSmokeViewX * dSmokeProjInverseZ + + (double)xbase; //_CHP(); xp = d2i(dSmokeProjScreenX); - dSmokeProjScreenY = dSmokeProjInverseZ * (dSmokeProjViewDist * fSmokeViewY) + (double)ybase; + dSmokeProjScreenY = + dSmokeProjInverseZ * (dSmokeProjViewDist * fSmokeViewY) + + (double)ybase; //_CHP(); yp = d2i(dSmokeProjScreenY); SmokePt[0][iSmokeIndex].screen.x = xp * scr_size >> 6; - //SmokePt[0][iSmokeIndex].screen.x = iSmokeScreenXResult >> 6; + // SmokePt[0][iSmokeIndex].screen.x = iSmokeScreenXResult >> 6; SmokePt[0][iSmokeIndex].screen.y = (scr_size * (199 - yp)) >> 6; SmokePt[0][iSmokeIndex].view.fX = fSmokeViewX; SmokePt[0][iSmokeIndex].view.fY = fSmokeViewY; @@ -1795,44 +2045,68 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa fPosX = fPosX + pSmokeSpray->velocity.fX; fPosY = fPosY + pSmokeSpray->velocity.fY; fPosZ = fPosZ + pSmokeSpray->velocity.fZ; - SmokePt[1][iSmokeIndex].world.fX = fPosX * fRotMat00 + fPosY * fRotMat10 + fPosZ * fRotMat20 + fCarPosX; - SmokePt[1][iSmokeIndex].world.fY = fPosX * fRotMat01 + fPosY * fRotMat12 + fPosZ * fRotMat11 + fCarPosY; + SmokePt[1][iSmokeIndex].world.fX = fPosX * fRotMat00 + + fPosY * fRotMat10 + + fPosZ * fRotMat20 + fCarPosX; + SmokePt[1][iSmokeIndex].world.fY = fPosX * fRotMat01 + + fPosY * fRotMat12 + + fPosZ * fRotMat11 + fCarPosY; iSmokeChunkIdx2 = iCurrChunk; - SmokePt[1][iSmokeIndex].world.fZ = fPosX * fRotMat02 + fPosY * fRotMat21 + fPosZ * fRotMat22Copy + fCarPosZ; + SmokePt[1][iSmokeIndex].world.fZ = fPosX * fRotMat02 + + fPosY * fRotMat21 + + fPosZ * fRotMat22Copy + fCarPosZ; if (iSmokeChunkIdx2 != -1 && pTrackChunkPtr) { dSmoke2ChunkTransY = pTrackChunkPtr[1]; fSmokeWorldX = SmokePt[1][iSmokeIndex].world.fX; fSmokeWorldY = SmokePt[1][iSmokeIndex].world.fY; - dSmoke2ChunkTransX = dSmoke2ChunkTransY * fSmokeWorldY + *pTrackChunkPtr * fSmokeWorldX; + dSmoke2ChunkTransX = dSmoke2ChunkTransY * fSmokeWorldY + + *pTrackChunkPtr * fSmokeWorldX; dSmoke2ChunkMatZ = pTrackChunkPtr[2]; - //iTemp = LODWORD(SmokePt[1][iSmokeIndex].world.fZ); + // iTemp = LODWORD(SmokePt[1][iSmokeIndex].world.fZ); float fSmokeZ = (SmokePt[1][iSmokeIndex].world.fZ); - SmokePt[1][iSmokeIndex].world.fX = (float)(dSmoke2ChunkTransX + dSmoke2ChunkMatZ * fSmokeZ - pTrackChunkPtr[9]); - SmokePt[1][iSmokeIndex].world.fY = pTrackChunkPtr[3] * fSmokeWorldX + pTrackChunkPtr[4] * fSmokeWorldY + pTrackChunkPtr[5] * fSmokeZ - pTrackChunkPtr[10]; - dSmoke2ChunkTransZ = pTrackChunkPtr[6] * fSmokeWorldX + pTrackChunkPtr[7] * fSmokeWorldY + pTrackChunkPtr[8] * fSmokeZ - pTrackChunkPtr[11]; + SmokePt[1][iSmokeIndex].world.fX = + (float)(dSmoke2ChunkTransX + dSmoke2ChunkMatZ * fSmokeZ - + pTrackChunkPtr[9]); + SmokePt[1][iSmokeIndex].world.fY = + pTrackChunkPtr[3] * fSmokeWorldX + + pTrackChunkPtr[4] * fSmokeWorldY + pTrackChunkPtr[5] * fSmokeZ - + pTrackChunkPtr[10]; + dSmoke2ChunkTransZ = pTrackChunkPtr[6] * fSmokeWorldX + + pTrackChunkPtr[7] * fSmokeWorldY + + pTrackChunkPtr[8] * fSmokeZ - + pTrackChunkPtr[11]; pChunkDataPtr = pTrackChunkPtr; SmokePt[1][iSmokeIndex].world.fZ = (float)dSmoke2ChunkTransZ; } dSmoke2ViewDeltaX = SmokePt[1][iSmokeIndex].world.fX - viewx; dSmoke2ViewDeltaY = SmokePt[1][iSmokeIndex].world.fY - viewy; dSmoke2ViewDeltaZ = SmokePt[1][iSmokeIndex].world.fZ - viewz; - fSmoke2ViewX = (float)(dSmoke2ViewDeltaX * vk1 + dSmoke2ViewDeltaY * vk4 + dSmoke2ViewDeltaZ * vk7); - fSmoke2ViewY = (float)(dSmoke2ViewDeltaX * vk2 + dSmoke2ViewDeltaY * vk5 + dSmoke2ViewDeltaZ * vk8); - dSmoke2CameraZ = dSmoke2ViewDeltaX * vk3 + dSmoke2ViewDeltaY * vk6 + dSmoke2ViewDeltaZ * vk9; + fSmoke2ViewX = + (float)(dSmoke2ViewDeltaX * vk1 + dSmoke2ViewDeltaY * vk4 + + dSmoke2ViewDeltaZ * vk7); + fSmoke2ViewY = + (float)(dSmoke2ViewDeltaX * vk2 + dSmoke2ViewDeltaY * vk5 + + dSmoke2ViewDeltaZ * vk8); + dSmoke2CameraZ = dSmoke2ViewDeltaX * vk3 + dSmoke2ViewDeltaY * vk6 + + dSmoke2ViewDeltaZ * vk9; fSmoke2ClampedZ = (float)dSmoke2CameraZ; fSmoke2CameraZCopy = fSmoke2ClampedZ; if (dSmoke2CameraZ < 80.0) fSmoke2ClampedZ = 80.0; dSmoke2ProjViewDist = (double)VIEWDIST; dSmoke2ProjInverseZ = 1.0 / fSmoke2ClampedZ; - dSmoke2ProjScreenX = dSmoke2ProjViewDist * fSmoke2ViewX * dSmoke2ProjInverseZ + (double)xbase; + dSmoke2ProjScreenX = + dSmoke2ProjViewDist * fSmoke2ViewX * dSmoke2ProjInverseZ + + (double)xbase; //_CHP(); xp = d2i(dSmoke2ProjScreenX); - dSmoke2ProjScreenY = dSmoke2ProjInverseZ * (dSmoke2ProjViewDist * fSmoke2ViewY) + (double)ybase; + dSmoke2ProjScreenY = + dSmoke2ProjInverseZ * (dSmoke2ProjViewDist * fSmoke2ViewY) + + (double)ybase; //_CHP(); yp = d2i(dSmoke2ProjScreenY); SmokePt[1][iSmokeIndex].screen.x = xp * scr_size >> 6; - //SmokePt[1][iSmokeIndex].screen.x = iSmoke2ScreenXResult >> 6; + // SmokePt[1][iSmokeIndex].screen.x = iSmoke2ScreenXResult >> 6; SmokePt[1][iSmokeIndex].screen.y = (scr_size * (199 - yp)) >> 6; SmokePt[1][iSmokeIndex].view.fX = fSmoke2ViewX; SmokePt[1][iSmokeIndex].view.fY = fSmoke2ViewY; @@ -1841,7 +2115,8 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa CarZOrder[iSmokeZOrderIdx].iPolygonIndex = iSpriteIdx; CarZOrder[iSmokeZOrderIdx].iPolygonLink = -2; if ((uint8)(pSmokeSpray->iType) == 2) - CarZOrder[iSmokeZOrderIdx].fZDepth = SmokePt[0][iSmokeIndex].view.fZ + -32768.0f; + CarZOrder[iSmokeZOrderIdx].fZDepth = + SmokePt[0][iSmokeIndex].view.fZ + -32768.0f; else CarZOrder[iSmokeZOrderIdx].fZDepth = SmokePt[0][iSmokeIndex].view.fZ; ++iSmokeZOrderIdx; @@ -1851,7 +2126,8 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa ++iSpriteIdx; ++pSmokeSpray; } while (iSpriteIdx < 32); - qsort(CarZOrder, iVisiblePolygons, 0xCu, carZcmp);// Sort polygons by Z-depth for proper rendering order + qsort(CarZOrder, iVisiblePolygons, 0xCu, + carZcmp); // Sort polygons by Z-depth for proper rendering order if (CarZOrder[0].fZDepth <= 16000.0 || VisibleCars < 5) iTextureDisabled = -1; else @@ -1862,11 +2138,11 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa if (iVisiblePolygons > 0) { iSubdivisionParam = iCarIndexCopy + 3; uiTextureMapOffset = 4 * iCarIndexCopy; - dwCarDesignOffset = 28 * carDesignIndex; // 28 is sizeof(tCarDesign) + dwCarDesignOffset = 28 * carDesignIndex; // 28 is sizeof(tCarDesign) iAnimationOffset = 4 * (iCarIndexCopy & 1); uiRenderLoopOffset = 0; iRenderLoopLimit = 12 * iVisiblePolygons; - do { // Main polygon rendering loop - draw sorted polygons + do { // Main polygon rendering loop - draw sorted polygons if (CarZOrder[uiRenderLoopOffset / 0xC].iPolygonLink >= -1) { CarZOrder[uiRenderLoopOffset / 0xC].fZDepth = -1.0; iPolygonIdx = CarZOrder[uiRenderLoopOffset / 0xC].iPolygonIndex; @@ -1877,18 +2153,20 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa iBackfaceFlag = -1; iPolygonIdx = -1 - iPolygonIdx; } - pRenderPolygon = &CarDesigns[dwCarDesignOffset / 0x1C].pPols[iPolygonIdx]; + pRenderPolygon = + &CarDesigns[dwCarDesignOffset / 0x1C].pPols[iPolygonIdx]; uiTextureSurface = pRenderPolygon->uiTex; for (mm = 0; mm < 4; ++mm) { polygonVertices[mm] = &CarPt[pRenderPolygon->verts[mm]]; } - //for (mm = 0; mm != 16; *(_DWORD *)((char *)&tempData.fAIMaxSpeed + mm) = pPolygonVertex)// offset into polygonVertices + // for (mm = 0; mm != 16; *(_DWORD *)((char *)&tempData.fAIMaxSpeed + + // mm) = pPolygonVertex)// offset into polygonVertices //{ - // mm += 4; - // pPolygonVertex = &CarPt[pRenderPolygon->verts[0]]; - // pRenderPolygon = (tPolygon *)((char *)pRenderPolygon + 1); - //} + // mm += 4; + // pPolygonVertex = &CarPt[pRenderPolygon->verts[0]]; + // pRenderPolygon = (tPolygon *)((char *)pRenderPolygon + 1); + // } dPolygonDepth23 = polygonVertices[2]->view.fZ; CarPol.uiNumVerts = 4; @@ -1897,20 +2175,23 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa else pMinDepthVertex23 = polygonVertices[2]; fMinDepthVertex23 = pMinDepthVertex23->view.fZ; - if (polygonVertices[0]->view.fZ >= (double)polygonVertices[1]->view.fZ) + if (polygonVertices[0]->view.fZ >= + (double)polygonVertices[1]->view.fZ) pMinDepthVertex01 = polygonVertices[1]; else pMinDepthVertex01 = polygonVertices[0]; fMinDepthVertex01 = pMinDepthVertex01->view.fZ; if (fMinDepthVertex01 >= (double)fMinDepthVertex23) { - if (polygonVertices[2]->view.fZ >= (double)polygonVertices[3]->view.fZ) + if (polygonVertices[2]->view.fZ >= + (double)polygonVertices[3]->view.fZ) pFinalMinVertex23 = polygonVertices[3]; else pFinalMinVertex23 = polygonVertices[2]; fFinalVertex23Depth = pFinalMinVertex23->view.fZ; fFinalMinDepth = fFinalVertex23Depth; } else { - if (polygonVertices[0]->view.fZ >= (double)polygonVertices[1]->view.fZ) + if (polygonVertices[0]->view.fZ >= + (double)polygonVertices[1]->view.fZ) pFinalMinVertex01 = polygonVertices[1]; else pFinalMinVertex01 = polygonVertices[0]; @@ -1925,29 +2206,39 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa bCloseToCamera = fFinalMinDepth < 1.0; byTextureIndex = (uint8)uiTextureSurface; if (iBackfaceFlag) { - uiTextureSurface = CarDesigns[dwCarDesignOffset / 0x1C].pBacks[iPolygonIdx]; + uiTextureSurface = + CarDesigns[dwCarDesignOffset / 0x1C].pBacks[iPolygonIdx]; uiTextureSurface |= SURFACE_FLAG_FLIP_BACKFACE; - //BYTE1(uiTextureSurface) |= 0x20u; + // BYTE1(uiTextureSurface) |= 0x20u; } else if ((uiTextureSurface & CAR_FLAG_ANMS_LOOKUP) != 0) { pAnimation = &pAnms[(uint8)uiTextureSurface]; if (byTextureIndex >= 4) uiTextureSurface = pAnimation->framesAy[iAnimationOffset / 4u]; else - uiTextureSurface = pAnimation->framesAy[(char)(options ? options->anim_frame : 0)]; + uiTextureSurface = + pAnimation + ->framesAy[(char)(options ? options->anim_frame : 0)]; } // SURFACE_FLAG_BACK if ((uiTextureSurface & SURFACE_FLAG_BACK) != 0) uiTextureSurface ^= SURFACE_FLAG_BACK; - //BYTE1(uiTextureSurface) ^= 8u; + // BYTE1(uiTextureSurface) ^= 8u; // SURFACE_FLAG_APPLY_TEXTURE - if ((uiTextureSurface & SURFACE_FLAG_APPLY_TEXTURE) != 0 && !iTextureDisabled)// Apply texture mapping if SURFACE_FLAG_APPLY_TEXTURE set and not disabled + if ((uiTextureSurface & SURFACE_FLAG_APPLY_TEXTURE) != 0 && + !iTextureDisabled) // Apply texture mapping if + // SURFACE_FLAG_APPLY_TEXTURE set and not + // disabled { iAnimationFrame = (uint8)uiTextureSurface; SET_LOWORD(uiTextureSurface, uiTextureSurface & 0xFE00); - uiTextureSurface += car_remap[256 * car_texmap[uiTextureMapOffset / 4] - 256 + iAnimationFrame]; + uiTextureSurface += + car_remap[256 * car_texmap[uiTextureMapOffset / 4] - 256 + + iAnimationFrame]; } // TEX_OFF_ADVANCED_CARS SURFACE_FLAG_APPLY_TEXTURE - if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && (uiTextureSurface & SURFACE_FLAG_APPLY_TEXTURE) == 0 && (uint8)uiTextureSurface == uiColorFrom) + if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && + (uiTextureSurface & SURFACE_FLAG_APPLY_TEXTURE) == 0 && + (uint8)uiTextureSurface == uiColorFrom) uiTextureSurface = uiColorTo; CarPol.iSurfaceType = uiTextureSurface; GameRenderer *renderer = g_pGameRenderer; @@ -1961,16 +2252,14 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa verts[vi].v = 0.0f; } TextureHandle carPolyTexture = TEXTURE_HANDLE_INVALID; - if ((uiTextureSurface & SURFACE_FLAG_APPLY_TEXTURE) != 0 && iTextureDisabled) { - carPolyTexture = game_render_get_texture_handle(renderer, car_texmap[uiTextureMapOffset / 4]); + if ((uiTextureSurface & SURFACE_FLAG_APPLY_TEXTURE) != 0 && + iTextureDisabled) { + carPolyTexture = game_render_get_texture_handle( + renderer, car_texmap[uiTextureMapOffset / 4]); } game_render_quad_world_subdivide_type( - renderer, - verts, - carPolyTexture, - uiTextureSurface, - iSubdivisionParam, - bCloseToCamera ? 0.0f : 1.0f); + renderer, verts, carPolyTexture, uiTextureSurface, + iSubdivisionParam, bCloseToCamera ? 0.0f : 1.0f); } } else { CarZOrder[uiRenderLoopOffset / 0xC].iPolygonLink = -1; @@ -1981,7 +2270,8 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa if (fSmokeDepthCheck > 80.0) { pCurrentSprite = &pCarSprayArray[iSpritePolygonIdx]; if ((uint8)(pCurrentSprite->iType) == 1) { - fSpriteSize = (double)VIEWDIST * pCurrentSprite->fSize / fSmokeDepthCheck; + fSpriteSize = + (double)VIEWDIST * pCurrentSprite->fSize / fSmokeDepthCheck; //_CHP(); iTemp = d2i(fSpriteSize); iScreenX = SmokePt[0][iSpritePolygonIdx].screen.x; @@ -1993,10 +2283,10 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa CarPol.vertices[0].y = y; CarPol.vertices[1].y = y; uiSpriteSurface = pCurrentSprite->iColor; - //uiSpriteSurface = pSpriteDataPtr->iColor; + // uiSpriteSurface = pSpriteDataPtr->iColor; iTemp = (scr_size * d2i(fSpriteSize)) >> 6; uiSpriteSurface |= SURFACE_FLAG_FLIP_BACKFACE; - //BYTE1(uiSpriteSurface) |= 0x20u; + // BYTE1(uiSpriteSurface) |= 0x20u; CarPol.vertices[0].x = x + iTemp; CarPol.iSurfaceType = uiSpriteSurface; CarPol.vertices[2].x = iScreenX - iTemp; @@ -2007,14 +2297,15 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa if ((uiSpriteSurface & SURFACE_FLAG_APPLY_TEXTURE) == 0) goto LABEL_267; } else { - dSpriteProjection = (double)VIEWDIST * pCurrentSprite->fSize / fSmokeDepthCheck; + dSpriteProjection = + (double)VIEWDIST * pCurrentSprite->fSize / fSmokeDepthCheck; //_CHP(); iSpriteScreenSize = d2i(dSpriteProjection); iSpriteSize = d2i(dSpriteProjection); if (d2i(dSpriteProjection) <= 0 || iSpriteSize >= 100) goto LABEL_268; CarPol.iSurfaceType = pCurrentSprite->iColor; - //CarPol.iSurfaceType = pSpriteDataPtr2->iColor; + // CarPol.iSurfaceType = pSpriteDataPtr2->iColor; iSpriteScreenSize = (scr_size * iSpriteSize) >> 6; CarPol.uiNumVerts = 4; iSpriteCenterX = SmokePt[0][iSpritePolygonIdx].screen.x; @@ -2030,11 +2321,14 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa // SURFACE_FLAG_APPLY_TEXTURE if ((CarPol.iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) == 0) { LABEL_267: - game_render_quad_screen(g_pGameRenderer, &CarPol, TEXTURE_HANDLE_INVALID, NULL); + game_render_quad_screen(g_pGameRenderer, &CarPol, + TEXTURE_HANDLE_INVALID, NULL); goto LABEL_268; } } - game_render_quad_screen(g_pGameRenderer, &CarPol, game_render_get_texture_handle(g_pGameRenderer, 18), NULL); + game_render_quad_screen( + g_pGameRenderer, &CarPol, + game_render_get_texture_handle(g_pGameRenderer, 18), NULL); } } LABEL_268: @@ -2042,15 +2336,13 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa } while ((int)uiRenderLoopOffset < iRenderLoopLimit); } } - if (NamesLeft < 5 - && NamesLeft >= -2 - && (names_on == 1 || names_on == 2 && human_control[pCar->iDriverIdx]) - && replaytype != 2 - && (pCar->byStatusFlags & 2) == 0 - && !winner_mode) // Render driver name above car if enabled and visible + if (NamesLeft < 5 && NamesLeft >= -2 && + (names_on == 1 || names_on == 2 && human_control[pCar->iDriverIdx]) && + replaytype != 2 && (pCar->byStatusFlags & 2) == 0 && + !winner_mode) // Render driver name above car if enabled and visible { float fHitboxZ = CarBox.hitboxAy[carDesignIndex][4].fZ; - //iTemp = LODWORD(CarBox.hitboxAy[carDesignIndex][4].fZ); + // iTemp = LODWORD(CarBox.hitboxAy[carDesignIndex][4].fZ); fNameTagWorldX = fHitboxZ * fRotMat20 + fCarPosX; fNameTagWorldY = fHitboxZ * fRotMat11 + fCarPosY; fNameTagWorldZ = fHitboxZ * fRotMat22Copy + fCarPosZ; @@ -2059,42 +2351,59 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa CarPt[0].world.fY = fNameTagWorldY; CarPt[0].world.fZ = fNameTagWorldZ; } else { - if (pChunkDataPtr) { //added by ROLLER - CarPt[0].world.fX = pChunkDataPtr[1] * fNameTagWorldY + *pChunkDataPtr * fNameTagWorldX + pChunkDataPtr[2] * fNameTagWorldZ - pChunkDataPtr[9]; - CarPt[0].world.fY = pChunkDataPtr[3] * fNameTagWorldX + pChunkDataPtr[4] * fNameTagWorldY + pChunkDataPtr[5] * fNameTagWorldZ - pChunkDataPtr[10]; - CarPt[0].world.fZ = fNameTagWorldY * pChunkDataPtr[7] + fNameTagWorldX * pChunkDataPtr[6] + fNameTagWorldZ * pChunkDataPtr[8] - pChunkDataPtr[11]; + if (pChunkDataPtr) { // added by ROLLER + CarPt[0].world.fX = pChunkDataPtr[1] * fNameTagWorldY + + *pChunkDataPtr * fNameTagWorldX + + pChunkDataPtr[2] * fNameTagWorldZ - + pChunkDataPtr[9]; + CarPt[0].world.fY = pChunkDataPtr[3] * fNameTagWorldX + + pChunkDataPtr[4] * fNameTagWorldY + + pChunkDataPtr[5] * fNameTagWorldZ - + pChunkDataPtr[10]; + CarPt[0].world.fZ = fNameTagWorldY * pChunkDataPtr[7] + + fNameTagWorldX * pChunkDataPtr[6] + + fNameTagWorldZ * pChunkDataPtr[8] - + pChunkDataPtr[11]; } } dNameTagDeltaX = CarPt[0].world.fX - viewx; dNameTagDeltaY = CarPt[0].world.fY - viewy; dNameTagDeltaZ = CarPt[0].world.fZ - viewz; - fNameTagViewX = (float)(dNameTagDeltaX * vk1 + dNameTagDeltaY * vk4 + dNameTagDeltaZ * vk7); - fNameTagViewY = (float)(dNameTagDeltaX * vk2 + dNameTagDeltaY * vk5 + dNameTagDeltaZ * vk8); - dNameTagCameraZ = dNameTagDeltaX * vk3 + dNameTagDeltaY * vk6 + dNameTagDeltaZ * vk9; + fNameTagViewX = (float)(dNameTagDeltaX * vk1 + dNameTagDeltaY * vk4 + + dNameTagDeltaZ * vk7); + fNameTagViewY = (float)(dNameTagDeltaX * vk2 + dNameTagDeltaY * vk5 + + dNameTagDeltaZ * vk8); + dNameTagCameraZ = + dNameTagDeltaX * vk3 + dNameTagDeltaY * vk6 + dNameTagDeltaZ * vk9; fNameTagClampedZ = (float)dNameTagCameraZ; fNameTagCameraZCopy = fNameTagClampedZ; if (dNameTagCameraZ < 80.0) fNameTagClampedZ = 80.0; dNameTagViewDist = (double)VIEWDIST; dNameTagInverseZ = 1.0 / fNameTagClampedZ; - dNameTagScreenX = dNameTagViewDist * fNameTagViewX * dNameTagInverseZ + (double)xbase; + dNameTagScreenX = + dNameTagViewDist * fNameTagViewX * dNameTagInverseZ + (double)xbase; //_CHP(); xp = d2i(dNameTagScreenX); - dNameTagScreenY = dNameTagInverseZ * (dNameTagViewDist * fNameTagViewY) + (double)ybase; + dNameTagScreenY = + dNameTagInverseZ * (dNameTagViewDist * fNameTagViewY) + (double)ybase; iNameTagScreenSize = scr_size; //_CHP(); yp = d2i(dNameTagScreenY); CarPt[0].screen.x = xp * scr_size >> 6; - //CarPt[0].screen.x = iNameTagXResult >> 6; - CarPt[0].screen.y = (iNameTagScreenSize * (199 - d2i(dNameTagScreenY))) >> 6; + // CarPt[0].screen.x = iNameTagXResult >> 6; + CarPt[0].screen.y = + (iNameTagScreenSize * (199 - d2i(dNameTagScreenY))) >> 6; CarPt[0].view.fX = fNameTagViewX; CarPt[0].view.fY = fNameTagViewY; CarPt[0].view.fZ = fNameTagCameraZCopy; iNameWidth = 0; if (pCar->byRacePosition < racers - 1 || racers == 1) - sprintf(buffer, "%s (%s)", driver_names[iCarIndexCopy], &language_buffer[64 * pCar->byRacePosition + 384]); + sprintf(buffer, "%s (%s)", driver_names[iCarIndexCopy], + &language_buffer[64 * pCar->byRacePosition + 384]); else - sprintf(buffer, "%s (%s)", driver_names[iCarIndexCopy], &language_buffer[1344]); + sprintf(buffer, "%s (%s)", driver_names[iCarIndexCopy], + &language_buffer[1344]); iNameCharIdx = 0; if (buffer[0]) { do @@ -2107,13 +2416,17 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa else iNameDisplayX = CarPt[0].screen.x - iNameHalfWidth; iNameDisplayY = CarPt[0].screen.y - 16; - if (iNameDisplayX >= 0 && iNameDisplayX < winw - iNameWidth && iNameDisplayY > 0 && iNameDisplayY < winh - 16 && iNameWidth > 0 && !intro) { + if (iNameDisplayX >= 0 && iNameDisplayX < winw - iNameWidth && + iNameDisplayY > 0 && iNameDisplayY < winh - 16 && iNameWidth > 0 && + !intro) { iPrevScrSize = scr_size; scr_size = 64; if (mirror) - mini_prt_string_rev(rev_vga[0], buffer, iNameDisplayX, CarPt[0].screen.y - 16); + mini_prt_string_rev(rev_vga[0], buffer, iNameDisplayX, + CarPt[0].screen.y - 16); else - mini_prt_string(rev_vga[0], buffer, iNameDisplayX, CarPt[0].screen.y - 16); + mini_prt_string(rev_vga[0], buffer, iNameDisplayX, + CarPt[0].screen.y - 16); CarPol.vertices[0].x = CarPt[0].screen.x + 6; CarPol.vertices[0].y = CarPt[0].screen.y - 7; CarPol.vertices[1].x = CarPt[0].screen.x - 5; @@ -2126,31 +2439,30 @@ void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCa scr_size = iPrevScrSize; CarPol.iSurfaceType = team_col[iTeamColIdx]; CarPol.uiNumVerts = 4; - game_render_quad_screen(g_pGameRenderer, &CarPol, TEXTURE_HANDLE_INVALID, NULL); + game_render_quad_screen(g_pGameRenderer, &CarPol, TEXTURE_HANDLE_INVALID, + NULL); } } } -void DisplayCar(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCar) -{ +void DisplayCar(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCar) { tCar *pCar = &Car[iCarIndex]; CarRenderPose pose = { - .position = pCar->pos, - .yaw = pCar->nYaw, - .pitch = pCar->nPitch, - .roll = pCar->nRoll, + .position = pCar->pos, + .yaw = pCar->nYaw, + .pitch = pCar->nPitch, + .roll = pCar->nRoll, }; CarRenderOptions options = { - .anim_frame = pCar->byWheelAnimationFrame, - .color_remap = NULL, + .anim_frame = pCar->byWheelAnimationFrame, + .color_remap = NULL, }; DisplayCarWithPose(iCarIndex, pScreenBuffer, fDistanceToCar, &pose, &options); } //------------------------------------------------------------------------------------------------- -//00056030 -int carZcmp(const void *pCar1, const void *pCar2) -{ +// 00056030 +int carZcmp(const void *pCar1, const void *pCar2) { const tCarZOrderEntry *pEntry1 = (const tCarZOrderEntry *)pCar1; const tCarZOrderEntry *pEntry2 = (const tCarZOrderEntry *)pCar2; diff --git a/PROJECTS/ROLLER/car.h b/PROJECTS/ROLLER/car.h index 363862f5..2647f68f 100644 --- a/PROJECTS/ROLLER/car.h +++ b/PROJECTS/ROLLER/car.h @@ -6,29 +6,27 @@ #include "polyf.h" //------------------------------------------------------------------------------------------------- -#define CAR_STATUS_DEATH 0x02 +#define CAR_STATUS_DEATH 0x02 #define CAR_STATUS_ACTIVE 0x04 -#define CAR_STATUS_PIT 0x08 +#define CAR_STATUS_PIT 0x08 //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 hitboxAy[16][8]; } tCarBox; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 pos; int16 nCurrChunk; int16 nReferenceChunk; int16 nRoll; int16 nPitch; int16 nYaw; - //padding byte - //padding byte + // padding byte + // padding byte float fFinalSpeed; float fHealth; int iDriverIdx; @@ -48,7 +46,7 @@ typedef struct uint8 byCarDesignIdx; uint8 byLives; uint8 byLapNumber; - //padding byte + // padding byte int16 nExplosionSoundTimer; float fLastAnimationSpeed; float fBaseSpeed; @@ -95,9 +93,9 @@ typedef struct uint8 byAIThrottleControl; uint8 byEngineStartTimer; uint8 byPitLaneActiveFlag; - //padding byte - //padding byte - //padding byte + // padding byte + // padding byte + // padding byte int iLeftTargetIdx; float fLeftTargetTime; int iRightTargetIdx; @@ -111,7 +109,7 @@ typedef struct uint8 byCheatAmmo; uint8 byCheatCooldown; uint8 byWheelAnimationFrame; - //padding byte + // padding byte int iDamageState; int16 nLastCommentaryChunk; int16 nReverseWarnCooldown; @@ -122,20 +120,18 @@ typedef struct uint8 byRepairSpeechPlayed; uint8 byLappedStatus; uint8 bySfxCooldown; - //padding byte + // padding byte } tCar; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float speeds[6]; } tStoreEngine; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tPoint screen; tVec3 world; tVec3 view; @@ -143,8 +139,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iPolygonLink; int iPolygonIndex; float fZDepth; @@ -152,8 +147,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 position; tVec3 velocity; float fSize; @@ -163,24 +157,21 @@ typedef struct int iType; } tCarSpray; -typedef struct CarRenderPose -{ +typedef struct CarRenderPose { tVec3 position; int yaw; int pitch; int roll; } CarRenderPose; -typedef struct CarRenderOptions -{ +typedef struct CarRenderOptions { int anim_frame; const uint8 *color_remap; } CarRenderOptions; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iChunkIdx; int iCarIdx; float fMinZDepth; @@ -188,8 +179,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 currentPos; tVec3 targetPos; tVec3 speed; @@ -238,8 +228,8 @@ void InitCars(); void placecars(); void DrawCars(int iCarIdx, int iViewMode); void DisplayCar(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCar); -void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, float fDistanceToCar, - const CarRenderPose *pose, +void DisplayCarWithPose(int iCarIndex, uint8 *pScreenBuffer, + float fDistanceToCar, const CarRenderPose *pose, const CarRenderOptions *options); int carZcmp(const void *pCar1, const void *pCar2); diff --git a/PROJECTS/ROLLER/carplans.c b/PROJECTS/ROLLER/carplans.c index 26628feb..e1420554 100644 --- a/PROJECTS/ROLLER/carplans.c +++ b/PROJECTS/ROLLER/carplans.c @@ -1,1893 +1,1739 @@ #include "carplans.h" //------------------------------------------------------------------------------------------------- -//000A751C -tVec3 f1wack_coords[120] = -{ - { -606.01202f, 196.944f, 193.804f }, - { -809.79498f, 196.944f, 193.804f }, - { -809.79498f, 196.944f, 409.57501f }, - { -606.01202f, 196.944f, 379.77499f }, - { -606.01202f, -199.039f, 193.804f }, - { -809.79498f, -199.039f, 193.804f }, - { -809.79498f, -199.039f, 409.57501f }, - { -606.01202f, -199.039f, 379.77499f }, - { -643.02301f, -200.315f, 339.45099f }, - { -788.44702f, -200.315f, 381.14999f }, - { -788.44702f, 190.093f, 381.14999f }, - { -643.02301f, 190.093f, 339.45099f }, - { 811.36798f, -29.774f, 0.86400002f }, - { 276.263f, -133.836f, 0.86400002f }, - { 276.263f, 140.936f, 0.86400002f }, - { 811.36798f, 19.565001f, 0.86400002f }, - { 811.36798f, -29.774f, 39.737f }, - { 276.263f, -133.836f, 222.172f }, - { 276.263f, 140.936f, 222.172f }, - { 811.36798f, 19.565001f, 39.737f }, - { -570.05103f, 109.822f, 3.473f }, - { -570.05103f, 162.13f, 174.47501f }, - { -570.05103f, -126.159f, 3.473f }, - { -570.05103f, -168.27499f, 174.47501f }, - { -54.766998f, 121.356f, 196.01601f }, - { -540.25f, 46.049999f, 166.62399f }, - { -540.25f, 11.103f, 209.381f }, - { -92.017998f, 50.209f, 355.64001f }, - { -54.766998f, -125.814f, 198.194f }, - { -540.25f, -46.726002f, 166.62399f }, - { -540.25f, -19.757f, 209.381f }, - { -92.017998f, -54.363998f, 355.64001f }, - { -644.10999f, -200.315f, 224.17f }, - { -787.36499f, -200.315f, 272.79901f }, - { -787.36499f, 190.093f, 272.79901f }, - { -644.10999f, 190.093f, 224.17f }, - { -639.92999f, -378.254f, -3.5450001f }, - { -706.91199f, -378.254f, 103.947f }, - { -647.30902f, -378.254f, 215.701f }, - { -520.72699f, -378.254f, 219.959f }, - { -453.74799f, -378.254f, 112.467f }, - { -513.349f, -378.254f, 0.71499997f }, - { -639.92999f, -206.155f, -3.5450001f }, - { -706.91199f, -206.155f, 103.947f }, - { -647.30902f, -206.155f, 215.701f }, - { -520.72699f, -206.155f, 219.959f }, - { -453.74799f, -206.155f, 112.467f }, - { -513.349f, -206.155f, 0.71499997f }, - { -580.32898f, -206.155f, 108.206f }, - { -580.32898f, -378.254f, 108.206f }, - { 380.746f, -336.905f, -3.5450001f }, - { 313.767f, -336.905f, 103.947f }, - { 373.36801f, -336.905f, 215.701f }, - { 499.95001f, -336.905f, 219.959f }, - { 566.92902f, -336.905f, 112.467f }, - { 507.32901f, -336.905f, 0.71499997f }, - { 380.746f, -232.604f, -3.5450001f }, - { 313.767f, -232.604f, 103.947f }, - { 373.36801f, -232.604f, 215.701f }, - { 499.95001f, -232.604f, 219.959f }, - { 566.92902f, -232.604f, 112.467f }, - { 507.32901f, -232.604f, 0.71499997f }, - { 440.349f, -232.604f, 108.206f }, - { 440.349f, -336.905f, 108.206f }, - { -639.92999f, 207.29401f, -3.5450001f }, - { -706.91199f, 207.29401f, 103.947f }, - { -647.30902f, 207.29401f, 215.701f }, - { -520.72699f, 207.29401f, 219.959f }, - { -453.74799f, 207.29401f, 112.467f }, - { -513.349f, 207.29401f, 0.71499997f }, - { -639.92999f, 370.52802f, -3.5450001f }, - { -706.91199f, 370.52802f, 103.947f }, - { -647.30902f, 370.52802f, 215.701f }, - { -520.72699f, 370.52802f, 219.959f }, - { -453.74799f, 370.52802f, 112.467f }, - { -513.349f, 370.52802f, 0.71499997f }, - { -580.32898f, 370.52802f, 108.206f }, - { -580.32898f, 207.29401f, 108.206f }, - { 380.746f, 236.761f, -3.5450001f }, - { 313.767f, 236.761f, 103.947f }, - { 373.36801f, 236.761f, 215.701f }, - { 499.95001f, 236.761f, 219.959f }, - { 566.92902f, 236.761f, 112.467f }, - { 507.32901f, 236.761f, 0.71499997f }, - { 380.746f, 341.06299f, -3.5450001f }, - { 313.767f, 341.06299f, 103.947f }, - { 373.36801f, 341.06299f, 215.701f }, - { 499.95001f, 341.06299f, 219.959f }, - { 566.92902f, 341.06299f, 112.467f }, - { 507.32901f, 341.06299f, 0.71499997f }, - { 440.349f, 341.06299f, 108.206f }, - { 440.349f, 236.761f, 108.206f }, - { 757.65698f, 297.25201f, 14.426f }, - { 553.87598f, 297.25201f, 14.426f }, - { 596.04498f, 297.25201f, 124.815f }, - { 757.65698f, 297.25201f, 71.572998f }, - { 734.50598f, -300.62299f, 33.571999f }, - { 589.08301f, -300.62299f, 75.272003f }, - { 589.08301f, 286.94101f, 75.272003f }, - { 734.50598f, 286.94101f, 33.571999f }, - { 757.65698f, -298.702f, 14.426f }, - { 553.87598f, -298.702f, 14.426f }, - { 598.11298f, -298.702f, 122.749f }, - { 757.65698f, -298.702f, 73.102997f }, - { 127.439f, -294.42099f, -1.3329999f }, - { -431.32599f, -324.22198f, -1.3329999f }, - { -431.32599f, -130.517f, -1.3329999f }, - { 231.743f, -108.167f, -1.3329999f }, - { 127.439f, -294.42099f, 140.222f }, - { -431.32599f, -324.22198f, 140.222f }, - { -431.32599f, -137.967f, 140.222f }, - { 231.743f, -100.716f, 140.222f }, - { 127.439f, 309.04501f, -1.3329999f }, - { -431.32599f, 338.84601f, -1.3329999f }, - { -431.32599f, 145.142f, -1.3329999f }, - { 231.743f, 122.791f, -1.3329999f }, - { 127.439f, 309.04501f, 140.222f }, - { -431.32599f, 338.84601f, 140.222f }, - { -431.32599f, 152.592f, 140.222f }, - { 231.743f, 115.341f, 140.222f } -}; +// 000A751C +tVec3 f1wack_coords[120] = {{-606.01202f, 196.944f, 193.804f}, + {-809.79498f, 196.944f, 193.804f}, + {-809.79498f, 196.944f, 409.57501f}, + {-606.01202f, 196.944f, 379.77499f}, + {-606.01202f, -199.039f, 193.804f}, + {-809.79498f, -199.039f, 193.804f}, + {-809.79498f, -199.039f, 409.57501f}, + {-606.01202f, -199.039f, 379.77499f}, + {-643.02301f, -200.315f, 339.45099f}, + {-788.44702f, -200.315f, 381.14999f}, + {-788.44702f, 190.093f, 381.14999f}, + {-643.02301f, 190.093f, 339.45099f}, + {811.36798f, -29.774f, 0.86400002f}, + {276.263f, -133.836f, 0.86400002f}, + {276.263f, 140.936f, 0.86400002f}, + {811.36798f, 19.565001f, 0.86400002f}, + {811.36798f, -29.774f, 39.737f}, + {276.263f, -133.836f, 222.172f}, + {276.263f, 140.936f, 222.172f}, + {811.36798f, 19.565001f, 39.737f}, + {-570.05103f, 109.822f, 3.473f}, + {-570.05103f, 162.13f, 174.47501f}, + {-570.05103f, -126.159f, 3.473f}, + {-570.05103f, -168.27499f, 174.47501f}, + {-54.766998f, 121.356f, 196.01601f}, + {-540.25f, 46.049999f, 166.62399f}, + {-540.25f, 11.103f, 209.381f}, + {-92.017998f, 50.209f, 355.64001f}, + {-54.766998f, -125.814f, 198.194f}, + {-540.25f, -46.726002f, 166.62399f}, + {-540.25f, -19.757f, 209.381f}, + {-92.017998f, -54.363998f, 355.64001f}, + {-644.10999f, -200.315f, 224.17f}, + {-787.36499f, -200.315f, 272.79901f}, + {-787.36499f, 190.093f, 272.79901f}, + {-644.10999f, 190.093f, 224.17f}, + {-639.92999f, -378.254f, -3.5450001f}, + {-706.91199f, -378.254f, 103.947f}, + {-647.30902f, -378.254f, 215.701f}, + {-520.72699f, -378.254f, 219.959f}, + {-453.74799f, -378.254f, 112.467f}, + {-513.349f, -378.254f, 0.71499997f}, + {-639.92999f, -206.155f, -3.5450001f}, + {-706.91199f, -206.155f, 103.947f}, + {-647.30902f, -206.155f, 215.701f}, + {-520.72699f, -206.155f, 219.959f}, + {-453.74799f, -206.155f, 112.467f}, + {-513.349f, -206.155f, 0.71499997f}, + {-580.32898f, -206.155f, 108.206f}, + {-580.32898f, -378.254f, 108.206f}, + {380.746f, -336.905f, -3.5450001f}, + {313.767f, -336.905f, 103.947f}, + {373.36801f, -336.905f, 215.701f}, + {499.95001f, -336.905f, 219.959f}, + {566.92902f, -336.905f, 112.467f}, + {507.32901f, -336.905f, 0.71499997f}, + {380.746f, -232.604f, -3.5450001f}, + {313.767f, -232.604f, 103.947f}, + {373.36801f, -232.604f, 215.701f}, + {499.95001f, -232.604f, 219.959f}, + {566.92902f, -232.604f, 112.467f}, + {507.32901f, -232.604f, 0.71499997f}, + {440.349f, -232.604f, 108.206f}, + {440.349f, -336.905f, 108.206f}, + {-639.92999f, 207.29401f, -3.5450001f}, + {-706.91199f, 207.29401f, 103.947f}, + {-647.30902f, 207.29401f, 215.701f}, + {-520.72699f, 207.29401f, 219.959f}, + {-453.74799f, 207.29401f, 112.467f}, + {-513.349f, 207.29401f, 0.71499997f}, + {-639.92999f, 370.52802f, -3.5450001f}, + {-706.91199f, 370.52802f, 103.947f}, + {-647.30902f, 370.52802f, 215.701f}, + {-520.72699f, 370.52802f, 219.959f}, + {-453.74799f, 370.52802f, 112.467f}, + {-513.349f, 370.52802f, 0.71499997f}, + {-580.32898f, 370.52802f, 108.206f}, + {-580.32898f, 207.29401f, 108.206f}, + {380.746f, 236.761f, -3.5450001f}, + {313.767f, 236.761f, 103.947f}, + {373.36801f, 236.761f, 215.701f}, + {499.95001f, 236.761f, 219.959f}, + {566.92902f, 236.761f, 112.467f}, + {507.32901f, 236.761f, 0.71499997f}, + {380.746f, 341.06299f, -3.5450001f}, + {313.767f, 341.06299f, 103.947f}, + {373.36801f, 341.06299f, 215.701f}, + {499.95001f, 341.06299f, 219.959f}, + {566.92902f, 341.06299f, 112.467f}, + {507.32901f, 341.06299f, 0.71499997f}, + {440.349f, 341.06299f, 108.206f}, + {440.349f, 236.761f, 108.206f}, + {757.65698f, 297.25201f, 14.426f}, + {553.87598f, 297.25201f, 14.426f}, + {596.04498f, 297.25201f, 124.815f}, + {757.65698f, 297.25201f, 71.572998f}, + {734.50598f, -300.62299f, 33.571999f}, + {589.08301f, -300.62299f, 75.272003f}, + {589.08301f, 286.94101f, 75.272003f}, + {734.50598f, 286.94101f, 33.571999f}, + {757.65698f, -298.702f, 14.426f}, + {553.87598f, -298.702f, 14.426f}, + {598.11298f, -298.702f, 122.749f}, + {757.65698f, -298.702f, 73.102997f}, + {127.439f, -294.42099f, -1.3329999f}, + {-431.32599f, -324.22198f, -1.3329999f}, + {-431.32599f, -130.517f, -1.3329999f}, + {231.743f, -108.167f, -1.3329999f}, + {127.439f, -294.42099f, 140.222f}, + {-431.32599f, -324.22198f, 140.222f}, + {-431.32599f, -137.967f, 140.222f}, + {231.743f, -100.716f, 140.222f}, + {127.439f, 309.04501f, -1.3329999f}, + {-431.32599f, 338.84601f, -1.3329999f}, + {-431.32599f, 145.142f, -1.3329999f}, + {231.743f, 122.791f, -1.3329999f}, + {127.439f, 309.04501f, 140.222f}, + {-431.32599f, 338.84601f, 140.222f}, + {-431.32599f, 152.592f, 140.222f}, + {231.743f, 115.341f, 140.222f}}; //------------------------------------------------------------------------------------------------- -//000A7ABC -tPolygon f1wack_pols[80] = -{ - { { 0u, 1u, 2u, 3u }, 8308u, -1, 0u }, - { { 4u, 7u, 6u, 5u }, 8308u, -1, 0u }, - { { 8u, 11u, 10u, 9u }, 8306u, -1, 0u }, - { { 12u, 13u, 14u, 15u }, 112u, -1, 0u }, - { { 12u, 16u, 17u, 13u }, 227u, -1, 0u }, - { { 14u, 18u, 19u, 15u }, 227u, -1, 0u }, - { { 15u, 19u, 16u, 12u }, 228u, -1, 0u }, - { { 18u, 17u, 16u, 19u }, 257u, -1, 0u }, - { { 14u, 20u, 21u, 18u }, 226u, -1, 0u }, - { { 14u, 13u, 22u, 20u }, 112u, -1, 0u }, - { { 20u, 22u, 23u, 21u }, 116u, -1, 0u }, - { { 21u, 23u, 17u, 18u }, 227u, -1, 0u }, - { { 13u, 17u, 23u, 22u }, 228u, -1, 0u }, - { { 26u, 27u, 24u, 25u }, 256u, -1, 0u }, - { { 25u, 29u, 30u, 26u }, 112u, -1, 0u }, - { { 26u, 30u, 31u, 27u }, 231u, -1, 0u }, - { { 27u, 31u, 28u, 24u }, 112u, -1, 0u }, - { { 31u, 30u, 29u, 28u }, 256u, -1, 0u }, - { { 32u, 35u, 34u, 33u }, 8304u, -1, 0u }, - { { 36u, 37u, 43u, 42u }, 114u, -1, 0u }, - { { 37u, 38u, 44u, 43u }, 116u, -1, 0u }, - { { 38u, 39u, 45u, 44u }, 118u, -1, 0u }, - { { 39u, 40u, 46u, 45u }, 32884u, -1, 0u }, - { { 40u, 41u, 47u, 46u }, 32882u, -1, 0u }, - { { 41u, 36u, 42u, 47u }, 112u, -1, 0u }, - { { 49u, 37u, 36u, 41u }, 112u, -1, 0u }, - { { 49u, 39u, 38u, 37u }, 112u, -1, 0u }, - { { 49u, 41u, 40u, 39u }, 112u, -1, 0u }, - { { 48u, 42u, 43u, 44u }, 112u, -1, 0u }, - { { 48u, 44u, 45u, 46u }, 112u, -1, 0u }, - { { 48u, 46u, 47u, 42u }, 112u, -1, 0u }, - { { 50u, 51u, 57u, 56u }, 114u, -1, 0u }, - { { 51u, 52u, 58u, 57u }, 116u, -1, 0u }, - { { 52u, 53u, 59u, 58u }, 118u, -1, 0u }, - { { 53u, 54u, 60u, 59u }, 116u, -1, 0u }, - { { 54u, 55u, 61u, 60u }, 114u, -1, 0u }, - { { 55u, 50u, 56u, 61u }, 112u, -1, 0u }, - { { 63u, 51u, 50u, 55u }, 112u, -1, 0u }, - { { 63u, 53u, 52u, 51u }, 112u, -1, 0u }, - { { 63u, 55u, 54u, 53u }, 112u, -1, 0u }, - { { 62u, 56u, 57u, 58u }, 112u, -1, 0u }, - { { 62u, 58u, 59u, 60u }, 112u, -1, 0u }, - { { 62u, 60u, 61u, 56u }, 112u, -1, 0u }, - { { 64u, 65u, 71u, 70u }, 114u, -1, 0u }, - { { 65u, 66u, 72u, 71u }, 116u, -1, 0u }, - { { 66u, 67u, 73u, 72u }, 118u, -1, 0u }, - { { 67u, 68u, 74u, 73u }, 32884u, -1, 0u }, - { { 68u, 69u, 75u, 74u }, 32882u, -1, 0u }, - { { 69u, 64u, 70u, 75u }, 112u, -1, 0u }, - { { 77u, 65u, 64u, 69u }, 112u, -1, 0u }, - { { 77u, 67u, 66u, 65u }, 112u, -1, 0u }, - { { 77u, 69u, 68u, 67u }, 112u, -1, 0u }, - { { 76u, 70u, 71u, 72u }, 112u, -1, 0u }, - { { 76u, 72u, 73u, 74u }, 112u, -1, 0u }, - { { 76u, 74u, 75u, 70u }, 112u, -1, 0u }, - { { 78u, 79u, 85u, 84u }, 114u, -1, 0u }, - { { 79u, 80u, 86u, 85u }, 116u, -1, 0u }, - { { 80u, 81u, 87u, 86u }, 118u, -1, 0u }, - { { 81u, 82u, 88u, 87u }, 116u, -1, 0u }, - { { 82u, 83u, 89u, 88u }, 114u, -1, 0u }, - { { 83u, 78u, 84u, 89u }, 112u, -1, 0u }, - { { 79u, 78u, 83u, 91u }, 112u, -1, 0u }, - { { 81u, 80u, 79u, 91u }, 112u, -1, 0u }, - { { 83u, 82u, 81u, 91u }, 112u, -1, 0u }, - { { 84u, 85u, 86u, 90u }, 112u, -1, 0u }, - { { 86u, 87u, 88u, 90u }, 112u, -1, 0u }, - { { 88u, 89u, 84u, 90u }, 112u, -1, 0u }, - { { 92u, 93u, 94u, 95u }, 41076u, -1, 0u }, - { { 96u, 99u, 98u, 97u }, 8306u, -1, 0u }, - { { 100u, 103u, 102u, 101u }, 41076u, -1, 0u }, - { { 104u, 105u, 106u, 107u }, 112u, -1, 0u }, - { { 104u, 108u, 109u, 105u }, 227u, -1, 0u }, - { { 105u, 109u, 110u, 106u }, 111u, -1, 0u }, - { { 107u, 111u, 108u, 104u }, 111u, -1, 0u }, - { { 108u, 111u, 110u, 109u }, 229u, -1, 0u }, - { { 114u, 113u, 112u, 115u }, 112u, -1, 0u }, - { { 117u, 116u, 112u, 113u }, 227u, -1, 0u }, - { { 118u, 117u, 113u, 114u }, 111u, -1, 0u }, - { { 116u, 119u, 115u, 112u }, 111u, -1, 0u }, - { { 118u, 119u, 116u, 117u }, 229u, -1, 0u } -}; +// 000A7ABC +tPolygon f1wack_pols[80] = {{{0u, 1u, 2u, 3u}, 8308u, -1, 0u}, + {{4u, 7u, 6u, 5u}, 8308u, -1, 0u}, + {{8u, 11u, 10u, 9u}, 8306u, -1, 0u}, + {{12u, 13u, 14u, 15u}, 112u, -1, 0u}, + {{12u, 16u, 17u, 13u}, 227u, -1, 0u}, + {{14u, 18u, 19u, 15u}, 227u, -1, 0u}, + {{15u, 19u, 16u, 12u}, 228u, -1, 0u}, + {{18u, 17u, 16u, 19u}, 257u, -1, 0u}, + {{14u, 20u, 21u, 18u}, 226u, -1, 0u}, + {{14u, 13u, 22u, 20u}, 112u, -1, 0u}, + {{20u, 22u, 23u, 21u}, 116u, -1, 0u}, + {{21u, 23u, 17u, 18u}, 227u, -1, 0u}, + {{13u, 17u, 23u, 22u}, 228u, -1, 0u}, + {{26u, 27u, 24u, 25u}, 256u, -1, 0u}, + {{25u, 29u, 30u, 26u}, 112u, -1, 0u}, + {{26u, 30u, 31u, 27u}, 231u, -1, 0u}, + {{27u, 31u, 28u, 24u}, 112u, -1, 0u}, + {{31u, 30u, 29u, 28u}, 256u, -1, 0u}, + {{32u, 35u, 34u, 33u}, 8304u, -1, 0u}, + {{36u, 37u, 43u, 42u}, 114u, -1, 0u}, + {{37u, 38u, 44u, 43u}, 116u, -1, 0u}, + {{38u, 39u, 45u, 44u}, 118u, -1, 0u}, + {{39u, 40u, 46u, 45u}, 32884u, -1, 0u}, + {{40u, 41u, 47u, 46u}, 32882u, -1, 0u}, + {{41u, 36u, 42u, 47u}, 112u, -1, 0u}, + {{49u, 37u, 36u, 41u}, 112u, -1, 0u}, + {{49u, 39u, 38u, 37u}, 112u, -1, 0u}, + {{49u, 41u, 40u, 39u}, 112u, -1, 0u}, + {{48u, 42u, 43u, 44u}, 112u, -1, 0u}, + {{48u, 44u, 45u, 46u}, 112u, -1, 0u}, + {{48u, 46u, 47u, 42u}, 112u, -1, 0u}, + {{50u, 51u, 57u, 56u}, 114u, -1, 0u}, + {{51u, 52u, 58u, 57u}, 116u, -1, 0u}, + {{52u, 53u, 59u, 58u}, 118u, -1, 0u}, + {{53u, 54u, 60u, 59u}, 116u, -1, 0u}, + {{54u, 55u, 61u, 60u}, 114u, -1, 0u}, + {{55u, 50u, 56u, 61u}, 112u, -1, 0u}, + {{63u, 51u, 50u, 55u}, 112u, -1, 0u}, + {{63u, 53u, 52u, 51u}, 112u, -1, 0u}, + {{63u, 55u, 54u, 53u}, 112u, -1, 0u}, + {{62u, 56u, 57u, 58u}, 112u, -1, 0u}, + {{62u, 58u, 59u, 60u}, 112u, -1, 0u}, + {{62u, 60u, 61u, 56u}, 112u, -1, 0u}, + {{64u, 65u, 71u, 70u}, 114u, -1, 0u}, + {{65u, 66u, 72u, 71u}, 116u, -1, 0u}, + {{66u, 67u, 73u, 72u}, 118u, -1, 0u}, + {{67u, 68u, 74u, 73u}, 32884u, -1, 0u}, + {{68u, 69u, 75u, 74u}, 32882u, -1, 0u}, + {{69u, 64u, 70u, 75u}, 112u, -1, 0u}, + {{77u, 65u, 64u, 69u}, 112u, -1, 0u}, + {{77u, 67u, 66u, 65u}, 112u, -1, 0u}, + {{77u, 69u, 68u, 67u}, 112u, -1, 0u}, + {{76u, 70u, 71u, 72u}, 112u, -1, 0u}, + {{76u, 72u, 73u, 74u}, 112u, -1, 0u}, + {{76u, 74u, 75u, 70u}, 112u, -1, 0u}, + {{78u, 79u, 85u, 84u}, 114u, -1, 0u}, + {{79u, 80u, 86u, 85u}, 116u, -1, 0u}, + {{80u, 81u, 87u, 86u}, 118u, -1, 0u}, + {{81u, 82u, 88u, 87u}, 116u, -1, 0u}, + {{82u, 83u, 89u, 88u}, 114u, -1, 0u}, + {{83u, 78u, 84u, 89u}, 112u, -1, 0u}, + {{79u, 78u, 83u, 91u}, 112u, -1, 0u}, + {{81u, 80u, 79u, 91u}, 112u, -1, 0u}, + {{83u, 82u, 81u, 91u}, 112u, -1, 0u}, + {{84u, 85u, 86u, 90u}, 112u, -1, 0u}, + {{86u, 87u, 88u, 90u}, 112u, -1, 0u}, + {{88u, 89u, 84u, 90u}, 112u, -1, 0u}, + {{92u, 93u, 94u, 95u}, 41076u, -1, 0u}, + {{96u, 99u, 98u, 97u}, 8306u, -1, 0u}, + {{100u, 103u, 102u, 101u}, 41076u, -1, 0u}, + {{104u, 105u, 106u, 107u}, 112u, -1, 0u}, + {{104u, 108u, 109u, 105u}, 227u, -1, 0u}, + {{105u, 109u, 110u, 106u}, 111u, -1, 0u}, + {{107u, 111u, 108u, 104u}, 111u, -1, 0u}, + {{108u, 111u, 110u, 109u}, 229u, -1, 0u}, + {{114u, 113u, 112u, 115u}, 112u, -1, 0u}, + {{117u, 116u, 112u, 113u}, 227u, -1, 0u}, + {{118u, 117u, 113u, 114u}, 111u, -1, 0u}, + {{116u, 119u, 115u, 112u}, 111u, -1, 0u}, + {{118u, 119u, 116u, 117u}, 229u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000A7E7C -unsigned int f1wack_backs[] = { 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000A7E7C +unsigned int f1wack_backs[] = {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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000A7FBC -int f1wack_places[] = { 24, 28, 64, 42 }; +// 000A7FBC +int f1wack_places[] = {24, 28, 64, 42}; //------------------------------------------------------------------------------------------------- -//000A7FCC -tVec3 xauto_coords[86] = -{ - { -287.526f, 172.476f, 410.20001f }, - { -46.679001f, 188.446f, 410.556f }, - { 312.23199f, 139.66701f, 294.771f }, - { 279.39301f, 278.664f, 281.83499f }, - { -355.147f, 249.81599f, 314.76099f }, - { 559.854f, 228.09801f, 246.34801f }, - { 514.388f, 270.095f, 245.21001f }, - { -47.658001f, 94.111f, 410.67999f }, - { 624.05103f, 246.571f, 188.13499f }, - { 527.65399f, 299.76801f, 206.86501f }, - { 660.789f, 227.75301f, 60.766998f }, - { -320.63599f, 301.06699f, 223.998f }, - { -535.45099f, 299.77301f, 50.234001f }, - { 317.31601f, 299.11401f, 207.17999f }, - { -320.50201f, 301.01001f, 50.689999f }, - { 527.54303f, 300.89001f, 52.320999f }, - { 317.07401f, 300.34698f, 52.195999f }, - { -537.67902f, 299.405f, 224.53999f }, - { -564.91901f, 234.282f, 311.87601f }, - { -287.599f, -170.91701f, 410.198f }, - { -47.735001f, -186.256f, 410.58899f }, - { 312.32001f, -143.379f, 295.02399f }, - { 279.03201f, -278.08801f, 281.814f }, - { -354.35199f, -252.939f, 315.42899f }, - { 559.57703f, -225.29201f, 246.229f }, - { 514.11499f, -269.07599f, 245.52299f }, - { -46.951f, -89.950996f, 410.49799f }, - { 622.85797f, -244.19501f, 188.134f }, - { 527.65399f, -298.534f, 206.864f }, - { 660.79498f, -230.657f, 60.765999f }, - { -320.70001f, -297.06299f, 223.99699f }, - { -535.94299f, -298.53799f, 50.233002f }, - { 317.31601f, -297.879f, 207.179f }, - { -320.88f, -297.00601f, 50.689999f }, - { 527.54303f, -296.82199f, 52.32f }, - { 317.07501f, -296.27899f, 53.457001f }, - { -536.23999f, -298.10599f, 224.53799f }, - { -566.474f, -245.403f, 312.44901f }, - { -562.09003f, -223.60001f, 341.29901f }, - { -643.47998f, -208.16299f, 343.18201f }, - { -562.625f, 213.541f, 341.30301f }, - { -642.87903f, 192.517f, 343.53699f }, - { 527.47101f, 299.51099f, 0.31799999f }, - { 317.08899f, 299.51099f, 0.31799999f }, - { -320.51599f, 301.79199f, 2.8429999f }, - { -535.51501f, 301.79199f, 2.8429999f }, - { 527.47101f, -298.634f, 0.359f }, - { 317.08899f, -298.634f, 0.359f }, - { -320.51599f, -298.634f, 2.8840001f }, - { -537.36298f, -298.634f, 2.8840001f }, - { -443.17599f, -160.722f, 2.302f }, - { -443.17599f, -160.72301f, 54.969002f }, - { -443.17599f, -294.28299f, 2.302f }, - { -443.17599f, -294.28299f, 54.967999f }, - { -443.17599f, 298.24701f, 2.303f }, - { -443.17599f, 298.24701f, 54.969002f }, - { -443.17599f, 164.687f, 2.303f }, - { -443.17599f, 164.687f, 54.969002f }, - { 432.66f, 298.24701f, -1.376f }, - { 432.66f, 298.24701f, 51.290001f }, - { 432.66f, 164.687f, -1.376f }, - { 432.66f, 164.687f, 51.290001f }, - { 432.66f, -160.722f, 1.638f }, - { 432.66f, -160.72301f, 54.304001f }, - { 432.66f, -294.28299f, 1.637f }, - { 432.66f, -294.28299f, 54.304001f }, - { 186.312f, 362.32901f, 312.28101f }, - { 200.231f, 315.048f, 322.061f }, - { 183.166f, 371.75201f, 274.17599f }, - { 211.77499f, 271.647f, 274.17599f }, - { 200.34399f, -316.46701f, 323.62601f }, - { 184.561f, -364.884f, 312.21701f }, - { 213.59f, -272.03601f, 274.17499f }, - { 183.16701f, -372.91599f, 274.17499f }, - { -332.05899f, -172.76401f, 399.38f }, - { -333.457f, 176.91499f, 399.78299f }, - { -635.64398f, 226.80299f, 306.31f }, - { -635.61798f, -237.457f, 306.323f }, - { -633.83099f, 282.31601f, 108.517f }, - { -649.49701f, 273.93399f, 227.132f }, - { -631.38f, -278.806f, 107.095f }, - { -650.159f, -277.271f, 227.131f }, - { -505.939f, -263.57999f, 298.65302f }, - { -641.95398f, -257.62f, 294.11499f }, - { -506.43201f, 254.89799f, 299.25299f }, - { -642.37903f, 249.106f, 293.97501f } -}; +// 000A7FCC +tVec3 xauto_coords[86] = {{-287.526f, 172.476f, 410.20001f}, + {-46.679001f, 188.446f, 410.556f}, + {312.23199f, 139.66701f, 294.771f}, + {279.39301f, 278.664f, 281.83499f}, + {-355.147f, 249.81599f, 314.76099f}, + {559.854f, 228.09801f, 246.34801f}, + {514.388f, 270.095f, 245.21001f}, + {-47.658001f, 94.111f, 410.67999f}, + {624.05103f, 246.571f, 188.13499f}, + {527.65399f, 299.76801f, 206.86501f}, + {660.789f, 227.75301f, 60.766998f}, + {-320.63599f, 301.06699f, 223.998f}, + {-535.45099f, 299.77301f, 50.234001f}, + {317.31601f, 299.11401f, 207.17999f}, + {-320.50201f, 301.01001f, 50.689999f}, + {527.54303f, 300.89001f, 52.320999f}, + {317.07401f, 300.34698f, 52.195999f}, + {-537.67902f, 299.405f, 224.53999f}, + {-564.91901f, 234.282f, 311.87601f}, + {-287.599f, -170.91701f, 410.198f}, + {-47.735001f, -186.256f, 410.58899f}, + {312.32001f, -143.379f, 295.02399f}, + {279.03201f, -278.08801f, 281.814f}, + {-354.35199f, -252.939f, 315.42899f}, + {559.57703f, -225.29201f, 246.229f}, + {514.11499f, -269.07599f, 245.52299f}, + {-46.951f, -89.950996f, 410.49799f}, + {622.85797f, -244.19501f, 188.134f}, + {527.65399f, -298.534f, 206.864f}, + {660.79498f, -230.657f, 60.765999f}, + {-320.70001f, -297.06299f, 223.99699f}, + {-535.94299f, -298.53799f, 50.233002f}, + {317.31601f, -297.879f, 207.179f}, + {-320.88f, -297.00601f, 50.689999f}, + {527.54303f, -296.82199f, 52.32f}, + {317.07501f, -296.27899f, 53.457001f}, + {-536.23999f, -298.10599f, 224.53799f}, + {-566.474f, -245.403f, 312.44901f}, + {-562.09003f, -223.60001f, 341.29901f}, + {-643.47998f, -208.16299f, 343.18201f}, + {-562.625f, 213.541f, 341.30301f}, + {-642.87903f, 192.517f, 343.53699f}, + {527.47101f, 299.51099f, 0.31799999f}, + {317.08899f, 299.51099f, 0.31799999f}, + {-320.51599f, 301.79199f, 2.8429999f}, + {-535.51501f, 301.79199f, 2.8429999f}, + {527.47101f, -298.634f, 0.359f}, + {317.08899f, -298.634f, 0.359f}, + {-320.51599f, -298.634f, 2.8840001f}, + {-537.36298f, -298.634f, 2.8840001f}, + {-443.17599f, -160.722f, 2.302f}, + {-443.17599f, -160.72301f, 54.969002f}, + {-443.17599f, -294.28299f, 2.302f}, + {-443.17599f, -294.28299f, 54.967999f}, + {-443.17599f, 298.24701f, 2.303f}, + {-443.17599f, 298.24701f, 54.969002f}, + {-443.17599f, 164.687f, 2.303f}, + {-443.17599f, 164.687f, 54.969002f}, + {432.66f, 298.24701f, -1.376f}, + {432.66f, 298.24701f, 51.290001f}, + {432.66f, 164.687f, -1.376f}, + {432.66f, 164.687f, 51.290001f}, + {432.66f, -160.722f, 1.638f}, + {432.66f, -160.72301f, 54.304001f}, + {432.66f, -294.28299f, 1.637f}, + {432.66f, -294.28299f, 54.304001f}, + {186.312f, 362.32901f, 312.28101f}, + {200.231f, 315.048f, 322.061f}, + {183.166f, 371.75201f, 274.17599f}, + {211.77499f, 271.647f, 274.17599f}, + {200.34399f, -316.46701f, 323.62601f}, + {184.561f, -364.884f, 312.21701f}, + {213.59f, -272.03601f, 274.17499f}, + {183.16701f, -372.91599f, 274.17499f}, + {-332.05899f, -172.76401f, 399.38f}, + {-333.457f, 176.91499f, 399.78299f}, + {-635.64398f, 226.80299f, 306.31f}, + {-635.61798f, -237.457f, 306.323f}, + {-633.83099f, 282.31601f, 108.517f}, + {-649.49701f, 273.93399f, 227.132f}, + {-631.38f, -278.806f, 107.095f}, + {-650.159f, -277.271f, 227.131f}, + {-505.939f, -263.57999f, 298.65302f}, + {-641.95398f, -257.62f, 294.11499f}, + {-506.43201f, 254.89799f, 299.25299f}, + {-642.37903f, 249.106f, 293.97501f}}; //------------------------------------------------------------------------------------------------- -//000A83D4 -tPolygon xauto_pols[50] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 33, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 298u, -1, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 34, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 278u, -1, 0u }, - { { 38u, 40u, 41u, 39u }, 41233u, -1, 0u }, - { { 26u, 20u, 22u, 21u }, 37158u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 37156u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 11776u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 11777u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 11778u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 11779u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 28, 0u }, - { { 56u, 57u, 55u, 54u }, 8304u, 26, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 25, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 27, 0u }, - { { 68u, 66u, 67u, 69u }, 43191u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43191u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 37127u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 33031u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 299u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 277u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 4382u, -1, 0u }, - { { 80u, 78u, 12u, 31u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 276u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 285u, -1, 0u }, - { { 37u, 18u, 76u, 77u }, 273u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, -1, 0u }, - { { 19u, 0u, 75u, 74u }, 264u, -1, 0u }, - { { 20u, 1u, 0u, 19u }, 259u, -1, 0u }, - { { 82u, 38u, 39u, 83u }, 41233u, -1, 0u }, - { { 40u, 84u, 85u, 41u }, 41233u, -1, 0u } -}; +// 000A83D4 +tPolygon xauto_pols[50] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 33, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 298u, -1, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 34, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 278u, -1, 0u}, + {{38u, 40u, 41u, 39u}, 41233u, -1, 0u}, + {{26u, 20u, 22u, 21u}, 37158u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 37156u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 11776u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 11777u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 11778u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 11779u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 28, 0u}, + {{56u, 57u, 55u, 54u}, 8304u, 26, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 25, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 27, 0u}, + {{68u, 66u, 67u, 69u}, 43191u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43191u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 37127u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 33031u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 299u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 277u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 4382u, -1, 0u}, + {{80u, 78u, 12u, 31u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 276u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 285u, -1, 0u}, + {{37u, 18u, 76u, 77u}, 273u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, -1, 0u}, + {{19u, 0u, 75u, 74u}, 264u, -1, 0u}, + {{20u, 1u, 0u, 19u}, 259u, -1, 0u}, + {{82u, 38u, 39u, 83u}, 41233u, -1, 0u}, + {{40u, 84u, 85u, 41u}, 41233u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000A862C -unsigned int xauto_backs[] = { 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000A862C +unsigned int xauto_backs[] = {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, 1281, + 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000A86F4 -int xauto_places[] = { 3, 22, 56, 50 }; +// 000A86F4 +int xauto_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000A8704 -tAnimation xauto_anms[8] = -{ - { 5u, { 13586u, 13587u, 13577u, 13578u, 13568u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 13582u, 13581u, 13579u, 13580u, 13570u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 9490u, 9491u, 9481u, 9482u, 9472u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 9485u, 9486u, 9483u, 9484u, 9474u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u }}, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000A8704 +tAnimation xauto_anms[8] = { + {5u, + {13586u, 13587u, 13577u, 13578u, 13568u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u, 0u, 0u}}, + {5u, + {13582u, 13581u, 13579u, 13580u, 13570u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u, 0u, 0u}}, + {5u, + {9490u, 9491u, 9481u, 9482u, 9472u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {9485u, 9486u, 9483u, 9484u, 9474u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000A8924 -tVec3 xdesilva_coords[88] = -{ - { -295.76901f, 172.239f, 409.457f }, - { -54.924f, 188.21001f, 409.81201f }, - { 303.98901f, 139.42999f, 294.02802f }, - { 271.14999f, 278.427f, 281.09201f }, - { -363.39099f, 249.57899f, 314.017f }, - { 551.60999f, 227.862f, 245.605f }, - { 506.14401f, 269.85901f, 244.466f }, - { -55.901001f, 93.874001f, 409.93701f }, - { 615.80603f, 246.334f, 187.392f }, - { 519.41101f, 299.53101f, 206.12199f }, - { 652.54498f, 227.51601f, 60.023998f }, - { -328.88f, 300.82999f, 223.254f }, - { -543.69501f, 299.53601f, 49.490002f }, - { 309.07101f, 298.87701f, 206.436f }, - { -328.746f, 300.77301f, 49.946999f }, - { 519.29999f, 300.65302f, 51.577f }, - { 308.82999f, 300.10999f, 51.452f }, - { -545.922f, 299.168f, 223.79601f }, - { -573.16302f, 234.04601f, 311.133f }, - { -295.84299f, -171.15401f, 409.45401f }, - { -55.978001f, -186.493f, 409.845f }, - { 304.07599f, -143.616f, 294.28f }, - { 270.789f, -278.32501f, 281.07101f }, - { -362.595f, -253.177f, 314.685f }, - { 551.33398f, -225.52901f, 245.48599f }, - { 505.871f, -269.31299f, 244.78f }, - { -55.195f, -90.188004f, 409.754f }, - { 614.61401f, -244.431f, 187.39f }, - { 519.41101f, -298.76999f, 206.121f }, - { 652.55103f, -230.89301f, 60.022999f }, - { -328.94299f, -297.29999f, 223.25301f }, - { -544.18799f, -298.77499f, 49.490002f }, - { 309.07101f, -298.116f, 206.435f }, - { -329.12299f, -297.24301f, 49.946999f }, - { 519.29999f, -297.05899f, 51.577f }, - { 308.82999f, -296.51599f, 52.714001f }, - { -544.48401f, -298.34201f, 223.795f }, - { -574.71698f, -245.64f, 311.70499f }, - { -410.36899f, -193.655f, 372.353f }, - { -603.43201f, -208.39999f, 375.332f }, - { -410.90399f, 195.19501f, 372.35699f }, - { -602.83099f, 210.38901f, 375.68701f }, - { 519.22699f, 299.27301f, -0.42500001f }, - { 308.845f, 299.27301f, -0.42500001f }, - { -328.76099f, 301.55499f, 2.0999999f }, - { -543.75897f, 301.55499f, 2.0999999f }, - { 519.22699f, -298.871f, -0.38499999f }, - { 308.845f, -298.871f, -0.38499999f }, - { -328.76099f, -298.871f, 2.1400001f }, - { -545.60797f, -298.871f, 2.1400001f }, - { -451.42001f, -160.959f, 1.558f }, - { -451.42001f, -160.959f, 54.224998f }, - { -451.42001f, -294.51901f, 1.558f }, - { -451.42001f, -294.51999f, 54.224998f }, - { -451.42001f, 298.01001f, 1.559f }, - { -451.42001f, 298.01001f, 54.226002f }, - { -451.42001f, 164.45f, 1.559f }, - { -451.42001f, 164.45f, 54.224998f }, - { 424.41699f, 298.01001f, -2.1199999f }, - { 424.41699f, 298.01001f, 50.547001f }, - { 424.41699f, 164.45f, -2.1199999f }, - { 424.41699f, 164.45f, 50.547001f }, - { 424.41699f, -160.959f, 0.89399999f }, - { 424.41699f, -160.959f, 53.561001f }, - { 424.41699f, -294.51901f, 0.89399999f }, - { 424.41699f, -294.51999f, 53.561001f }, - { 178.06799f, 362.09201f, 311.53799f }, - { 191.987f, 314.811f, 321.31699f }, - { 174.92101f, 371.51401f, 273.43201f }, - { 203.53f, 271.41f, 273.43201f }, - { 192.10001f, -316.703f, 322.88199f }, - { 176.31599f, -365.121f, 311.474f }, - { 205.345f, -272.27301f, 273.431f }, - { 174.924f, -373.15399f, 273.431f }, - { -340.302f, -173.00101f, 398.63599f }, - { -341.702f, 176.677f, 399.04001f }, - { -643.888f, 226.56599f, 305.56699f }, - { -643.862f, -237.694f, 305.57999f }, - { -642.07397f, 282.07999f, 107.773f }, - { -657.73999f, 273.698f, 226.388f }, - { -639.62402f, -279.043f, 106.351f }, - { -658.40302f, -277.508f, 226.38699f }, - { -662.06299f, -208.39999f, 395.06799f }, - { -661.46198f, 210.38901f, 395.42401f }, - { -424.026f, -7.4850001f, 361.73001f }, - { -549.77802f, -7.4850001f, 317.285f }, - { -602.68799f, -7.4850001f, 372.79001f }, - { -411.82101f, -7.4850001f, 371.349f } -}; +// 000A8924 +tVec3 xdesilva_coords[88] = {{-295.76901f, 172.239f, 409.457f}, + {-54.924f, 188.21001f, 409.81201f}, + {303.98901f, 139.42999f, 294.02802f}, + {271.14999f, 278.427f, 281.09201f}, + {-363.39099f, 249.57899f, 314.017f}, + {551.60999f, 227.862f, 245.605f}, + {506.14401f, 269.85901f, 244.466f}, + {-55.901001f, 93.874001f, 409.93701f}, + {615.80603f, 246.334f, 187.392f}, + {519.41101f, 299.53101f, 206.12199f}, + {652.54498f, 227.51601f, 60.023998f}, + {-328.88f, 300.82999f, 223.254f}, + {-543.69501f, 299.53601f, 49.490002f}, + {309.07101f, 298.87701f, 206.436f}, + {-328.746f, 300.77301f, 49.946999f}, + {519.29999f, 300.65302f, 51.577f}, + {308.82999f, 300.10999f, 51.452f}, + {-545.922f, 299.168f, 223.79601f}, + {-573.16302f, 234.04601f, 311.133f}, + {-295.84299f, -171.15401f, 409.45401f}, + {-55.978001f, -186.493f, 409.845f}, + {304.07599f, -143.616f, 294.28f}, + {270.789f, -278.32501f, 281.07101f}, + {-362.595f, -253.177f, 314.685f}, + {551.33398f, -225.52901f, 245.48599f}, + {505.871f, -269.31299f, 244.78f}, + {-55.195f, -90.188004f, 409.754f}, + {614.61401f, -244.431f, 187.39f}, + {519.41101f, -298.76999f, 206.121f}, + {652.55103f, -230.89301f, 60.022999f}, + {-328.94299f, -297.29999f, 223.25301f}, + {-544.18799f, -298.77499f, 49.490002f}, + {309.07101f, -298.116f, 206.435f}, + {-329.12299f, -297.24301f, 49.946999f}, + {519.29999f, -297.05899f, 51.577f}, + {308.82999f, -296.51599f, 52.714001f}, + {-544.48401f, -298.34201f, 223.795f}, + {-574.71698f, -245.64f, 311.70499f}, + {-410.36899f, -193.655f, 372.353f}, + {-603.43201f, -208.39999f, 375.332f}, + {-410.90399f, 195.19501f, 372.35699f}, + {-602.83099f, 210.38901f, 375.68701f}, + {519.22699f, 299.27301f, -0.42500001f}, + {308.845f, 299.27301f, -0.42500001f}, + {-328.76099f, 301.55499f, 2.0999999f}, + {-543.75897f, 301.55499f, 2.0999999f}, + {519.22699f, -298.871f, -0.38499999f}, + {308.845f, -298.871f, -0.38499999f}, + {-328.76099f, -298.871f, 2.1400001f}, + {-545.60797f, -298.871f, 2.1400001f}, + {-451.42001f, -160.959f, 1.558f}, + {-451.42001f, -160.959f, 54.224998f}, + {-451.42001f, -294.51901f, 1.558f}, + {-451.42001f, -294.51999f, 54.224998f}, + {-451.42001f, 298.01001f, 1.559f}, + {-451.42001f, 298.01001f, 54.226002f}, + {-451.42001f, 164.45f, 1.559f}, + {-451.42001f, 164.45f, 54.224998f}, + {424.41699f, 298.01001f, -2.1199999f}, + {424.41699f, 298.01001f, 50.547001f}, + {424.41699f, 164.45f, -2.1199999f}, + {424.41699f, 164.45f, 50.547001f}, + {424.41699f, -160.959f, 0.89399999f}, + {424.41699f, -160.959f, 53.561001f}, + {424.41699f, -294.51901f, 0.89399999f}, + {424.41699f, -294.51999f, 53.561001f}, + {178.06799f, 362.09201f, 311.53799f}, + {191.987f, 314.811f, 321.31699f}, + {174.92101f, 371.51401f, 273.43201f}, + {203.53f, 271.41f, 273.43201f}, + {192.10001f, -316.703f, 322.88199f}, + {176.31599f, -365.121f, 311.474f}, + {205.345f, -272.27301f, 273.431f}, + {174.924f, -373.15399f, 273.431f}, + {-340.302f, -173.00101f, 398.63599f}, + {-341.702f, 176.677f, 399.04001f}, + {-643.888f, 226.56599f, 305.56699f}, + {-643.862f, -237.694f, 305.57999f}, + {-642.07397f, 282.07999f, 107.773f}, + {-657.73999f, 273.698f, 226.388f}, + {-639.62402f, -279.043f, 106.351f}, + {-658.40302f, -277.508f, 226.38699f}, + {-662.06299f, -208.39999f, 395.06799f}, + {-661.46198f, 210.38901f, 395.42401f}, + {-424.026f, -7.4850001f, 361.73001f}, + {-549.77802f, -7.4850001f, 317.285f}, + {-602.68799f, -7.4850001f, 372.79001f}, + {-411.82101f, -7.4850001f, 371.349f}}; //------------------------------------------------------------------------------------------------- -//000A8D44 -tPolygon xdesilva_pols[50] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 33, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 33066u, 36, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 34, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 33046u, 35, 0u }, - { { 41u, 39u, 38u, 40u }, 41233u, 48, 0u }, - { { 26u, 20u, 22u, 21u }, 33060u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 33062u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 28, 0u }, - { { 57u, 56u, 54u, 55u }, 8304u, 26, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 25, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 27, 0u }, - { { 68u, 66u, 67u, 69u }, 43215u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43215u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 37127u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 33031u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 33067u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 33045u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 308u, -1, 0u }, - { { 12u, 31u, 80u, 78u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 276u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 285u, -1, 0u }, - { { 76u, 77u, 37u, 18u }, 273u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, 49, 0u }, - { { 19u, 0u, 75u, 74u }, 264u, -1, 0u }, - { { 0u, 19u, 20u, 1u }, 262403u, -1, 0u }, - { { 39u, 41u, 83u, 82u }, 41233u, -1, 0u }, - { { 86u, 87u, 84u, 85u }, 8465u, 18, 0u } -}; - - +// 000A8D44 +tPolygon xdesilva_pols[50] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 33, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 33066u, 36, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 34, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 33046u, 35, 0u}, + {{41u, 39u, 38u, 40u}, 41233u, 48, 0u}, + {{26u, 20u, 22u, 21u}, 33060u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 33062u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 28, 0u}, + {{57u, 56u, 54u, 55u}, 8304u, 26, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 25, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 27, 0u}, + {{68u, 66u, 67u, 69u}, 43215u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43215u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 37127u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 33031u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 33067u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 33045u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 308u, -1, 0u}, + {{12u, 31u, 80u, 78u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 276u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 285u, -1, 0u}, + {{76u, 77u, 37u, 18u}, 273u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, 49, 0u}, + {{19u, 0u, 75u, 74u}, 264u, -1, 0u}, + {{0u, 19u, 20u, 1u}, 262403u, -1, 0u}, + {{39u, 41u, 83u, 82u}, 41233u, -1, 0u}, + {{86u, 87u, 84u, 85u}, 8465u, 18, 0u}}; //------------------------------------------------------------------------------------------------- -//000A8F9C -unsigned int xdesilva_backs[] = { 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000A8F9C +unsigned int xdesilva_backs[] = { + 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000A9064 -int xdesilva_places[] = { 3, 22, 56, 50 }; +// 000A9064 +int xdesilva_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000A9074 -tAnimation xdesilva_anms[8] = -{ - { 5u, { 5395u, 5394u, 5386u, 5385u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5389u, 5390u, 5388u, 5387u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5394u, 5395u, 5386u, 5385u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1293u, 1294u, 1292u, 1291u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000A9074 +tAnimation xdesilva_anms[8] = { + {5u, + {5395u, 5394u, 5386u, 5385u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5389u, 5390u, 5388u, 5387u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5394u, 5395u, 5386u, 5385u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1293u, 1294u, 1292u, 1291u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000A9294 -tVec3 xpulse_coords[86] = -{ - { -287.526f, 172.476f, 410.20001f }, - { -46.679001f, 188.446f, 410.556f }, - { 312.23199f, 139.66701f, 294.771f }, - { 279.39301f, 278.664f, 281.83499f }, - { -355.147f, 249.81599f, 314.76099f }, - { 559.854f, 228.09801f, 246.34801f }, - { 514.388f, 270.095f, 245.21001f }, - { -47.658001f, 94.111f, 410.67999f }, - { 624.05103f, 246.571f, 188.13499f }, - { 527.65399f, 299.76801f, 206.86501f }, - { 660.789f, 227.75301f, 60.766998f }, - { -320.63599f, 301.06699f, 223.998f }, - { -535.45099f, 299.77301f, 50.234001f }, - { 317.31601f, 299.11401f, 207.17999f }, - { -320.50201f, 301.01001f, 50.689999f }, - { 527.54303f, 300.89001f, 52.320999f }, - { 317.07401f, 300.34698f, 52.195999f }, - { -537.67902f, 299.405f, 224.53999f }, - { -564.91901f, 234.282f, 311.87601f }, - { -287.599f, -170.91701f, 410.198f }, - { -47.735001f, -186.256f, 410.58899f }, - { 312.32001f, -143.379f, 295.02399f }, - { 279.03201f, -278.08801f, 281.814f }, - { -354.35199f, -252.939f, 315.42899f }, - { 559.57703f, -225.29201f, 246.229f }, - { 514.11499f, -269.07599f, 245.52299f }, - { -46.951f, -89.950996f, 410.49799f }, - { 622.85797f, -244.19501f, 188.134f }, - { 527.65399f, -298.534f, 206.864f }, - { 660.79498f, -230.657f, 60.765999f }, - { -320.70001f, -297.06299f, 223.99699f }, - { -535.94299f, -298.53799f, 50.233002f }, - { 317.31601f, -297.879f, 207.179f }, - { -320.88f, -297.00601f, 50.689999f }, - { 527.54303f, -296.82199f, 52.32f }, - { 317.07501f, -296.27899f, 53.457001f }, - { -536.23999f, -298.10599f, 224.53799f }, - { -566.474f, -245.403f, 312.44901f }, - { -562.09003f, -223.60001f, 341.29901f }, - { -643.47998f, -208.16299f, 343.18201f }, - { -562.625f, 213.541f, 341.30301f }, - { -642.87903f, 192.517f, 343.53699f }, - { 527.47101f, 299.51099f, 0.31799999f }, - { 317.08899f, 299.51099f, 0.31799999f }, - { -320.51599f, 301.79199f, 2.8429999f }, - { -535.51501f, 301.79199f, 2.8429999f }, - { 527.47101f, -298.634f, 0.359f }, - { 317.08899f, -298.634f, 0.359f }, - { -320.51599f, -298.634f, 2.8840001f }, - { -537.36298f, -298.634f, 2.8840001f }, - { -443.17599f, -160.722f, 2.302f }, - { -443.17599f, -160.72301f, 54.969002f }, - { -443.17599f, -294.28299f, 2.302f }, - { -443.17599f, -294.28299f, 54.967999f }, - { -443.17599f, 298.24701f, 2.303f }, - { -443.17599f, 298.24701f, 54.969002f }, - { -443.17599f, 164.687f, 2.303f }, - { -443.17599f, 164.687f, 54.969002f }, - { 432.66f, 298.24701f, -1.376f }, - { 432.66f, 298.24701f, 51.290001f }, - { 432.66f, 164.687f, -1.376f }, - { 432.66f, 164.687f, 51.290001f }, - { 432.66f, -160.722f, 1.638f }, - { 432.66f, -160.72301f, 54.304001f }, - { 432.66f, -294.28299f, 1.637f }, - { 432.66f, -294.28299f, 54.304001f }, - { 186.312f, 362.32901f, 312.28101f }, - { 200.231f, 315.048f, 322.061f }, - { 183.166f, 371.75201f, 274.17599f }, - { 211.77499f, 271.647f, 274.17599f }, - { 200.34399f, -316.46701f, 323.62601f }, - { 184.561f, -364.884f, 312.21701f }, - { 213.59f, -272.03601f, 274.17499f }, - { 183.16701f, -372.91599f, 274.17499f }, - { -332.05899f, -172.76401f, 399.38f }, - { -333.457f, 176.91499f, 399.78299f }, - { -635.64398f, 226.80299f, 306.31f }, - { -635.61798f, -237.457f, 306.323f }, - { -633.83099f, 282.31601f, 108.517f }, - { -649.49701f, 273.93399f, 227.132f }, - { -631.38f, -278.806f, 107.095f }, - { -650.159f, -277.271f, 227.131f }, - { -505.939f, -263.57999f, 298.65302f }, - { -641.95398f, -257.62f, 294.11499f }, - { -506.43201f, 254.89799f, 299.25299f }, - { -642.37903f, 249.106f, 293.97501f } -}; +// 000A9294 +tVec3 xpulse_coords[86] = {{-287.526f, 172.476f, 410.20001f}, + {-46.679001f, 188.446f, 410.556f}, + {312.23199f, 139.66701f, 294.771f}, + {279.39301f, 278.664f, 281.83499f}, + {-355.147f, 249.81599f, 314.76099f}, + {559.854f, 228.09801f, 246.34801f}, + {514.388f, 270.095f, 245.21001f}, + {-47.658001f, 94.111f, 410.67999f}, + {624.05103f, 246.571f, 188.13499f}, + {527.65399f, 299.76801f, 206.86501f}, + {660.789f, 227.75301f, 60.766998f}, + {-320.63599f, 301.06699f, 223.998f}, + {-535.45099f, 299.77301f, 50.234001f}, + {317.31601f, 299.11401f, 207.17999f}, + {-320.50201f, 301.01001f, 50.689999f}, + {527.54303f, 300.89001f, 52.320999f}, + {317.07401f, 300.34698f, 52.195999f}, + {-537.67902f, 299.405f, 224.53999f}, + {-564.91901f, 234.282f, 311.87601f}, + {-287.599f, -170.91701f, 410.198f}, + {-47.735001f, -186.256f, 410.58899f}, + {312.32001f, -143.379f, 295.02399f}, + {279.03201f, -278.08801f, 281.814f}, + {-354.35199f, -252.939f, 315.42899f}, + {559.57703f, -225.29201f, 246.229f}, + {514.11499f, -269.07599f, 245.52299f}, + {-46.951f, -89.950996f, 410.49799f}, + {622.85797f, -244.19501f, 188.134f}, + {527.65399f, -298.534f, 206.864f}, + {660.79498f, -230.657f, 60.765999f}, + {-320.70001f, -297.06299f, 223.99699f}, + {-535.94299f, -298.53799f, 50.233002f}, + {317.31601f, -297.879f, 207.179f}, + {-320.88f, -297.00601f, 50.689999f}, + {527.54303f, -296.82199f, 52.32f}, + {317.07501f, -296.27899f, 53.457001f}, + {-536.23999f, -298.10599f, 224.53799f}, + {-566.474f, -245.403f, 312.44901f}, + {-562.09003f, -223.60001f, 341.29901f}, + {-643.47998f, -208.16299f, 343.18201f}, + {-562.625f, 213.541f, 341.30301f}, + {-642.87903f, 192.517f, 343.53699f}, + {527.47101f, 299.51099f, 0.31799999f}, + {317.08899f, 299.51099f, 0.31799999f}, + {-320.51599f, 301.79199f, 2.8429999f}, + {-535.51501f, 301.79199f, 2.8429999f}, + {527.47101f, -298.634f, 0.359f}, + {317.08899f, -298.634f, 0.359f}, + {-320.51599f, -298.634f, 2.8840001f}, + {-537.36298f, -298.634f, 2.8840001f}, + {-443.17599f, -160.722f, 2.302f}, + {-443.17599f, -160.72301f, 54.969002f}, + {-443.17599f, -294.28299f, 2.302f}, + {-443.17599f, -294.28299f, 54.967999f}, + {-443.17599f, 298.24701f, 2.303f}, + {-443.17599f, 298.24701f, 54.969002f}, + {-443.17599f, 164.687f, 2.303f}, + {-443.17599f, 164.687f, 54.969002f}, + {432.66f, 298.24701f, -1.376f}, + {432.66f, 298.24701f, 51.290001f}, + {432.66f, 164.687f, -1.376f}, + {432.66f, 164.687f, 51.290001f}, + {432.66f, -160.722f, 1.638f}, + {432.66f, -160.72301f, 54.304001f}, + {432.66f, -294.28299f, 1.637f}, + {432.66f, -294.28299f, 54.304001f}, + {186.312f, 362.32901f, 312.28101f}, + {200.231f, 315.048f, 322.061f}, + {183.166f, 371.75201f, 274.17599f}, + {211.77499f, 271.647f, 274.17599f}, + {200.34399f, -316.46701f, 323.62601f}, + {184.561f, -364.884f, 312.21701f}, + {213.59f, -272.03601f, 274.17499f}, + {183.16701f, -372.91599f, 274.17499f}, + {-332.05899f, -172.76401f, 399.38f}, + {-333.457f, 176.91499f, 399.78299f}, + {-635.64398f, 226.80299f, 306.31f}, + {-635.61798f, -237.457f, 306.323f}, + {-633.83099f, 282.31601f, 108.517f}, + {-649.49701f, 273.93399f, 227.132f}, + {-631.38f, -278.806f, 107.095f}, + {-650.159f, -277.271f, 227.131f}, + {-505.939f, -263.57999f, 298.65302f}, + {-641.95398f, -257.62f, 294.11499f}, + {-506.43201f, 254.89799f, 299.25299f}, + {-642.37903f, 249.106f, 293.97501f}}; //------------------------------------------------------------------------------------------------- -//000A969C -tPolygon xpulse_pols[50] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 33, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 298u, -1, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 34, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 278u, -1, 0u }, - { { 38u, 40u, 41u, 39u }, 41233u, -1, 0u }, - { { 26u, 20u, 22u, 21u }, 37158u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 37156u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 28, 0u }, - { { 56u, 57u, 55u, 54u }, 8304u, 26, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 25, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 27, 0u }, - { { 68u, 66u, 67u, 69u }, 43239u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43239u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 37127u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 33031u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 299u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 277u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 4382u, -1, 0u }, - { { 80u, 78u, 12u, 31u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 33044u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 285u, -1, 0u }, - { { 37u, 18u, 76u, 77u }, 273u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, -1, 0u }, - { { 19u, 0u, 75u, 74u }, 264u, -1, 0u }, - { { 20u, 1u, 0u, 19u }, 259u, -1, 0u }, - { { 82u, 38u, 39u, 83u }, 41233u, -1, 0u }, - { { 40u, 84u, 85u, 41u }, 41233u, -1, 0u } -}; +// 000A969C +tPolygon xpulse_pols[50] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 33, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 298u, -1, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 34, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 278u, -1, 0u}, + {{38u, 40u, 41u, 39u}, 41233u, -1, 0u}, + {{26u, 20u, 22u, 21u}, 37158u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 37156u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 28, 0u}, + {{56u, 57u, 55u, 54u}, 8304u, 26, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 25, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 27, 0u}, + {{68u, 66u, 67u, 69u}, 43239u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43239u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 37127u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 33031u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 299u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 277u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 4382u, -1, 0u}, + {{80u, 78u, 12u, 31u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 33044u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 285u, -1, 0u}, + {{37u, 18u, 76u, 77u}, 273u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, -1, 0u}, + {{19u, 0u, 75u, 74u}, 264u, -1, 0u}, + {{20u, 1u, 0u, 19u}, 259u, -1, 0u}, + {{82u, 38u, 39u, 83u}, 41233u, -1, 0u}, + {{40u, 84u, 85u, 41u}, 41233u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000A98F4 -unsigned int xpulse_backs[] = { 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000A98F4 +unsigned int xpulse_backs[] = { + 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000A99BC -int xpulse_places[] = { 3, 22, 56, 50 }; +// 000A99BC +int xpulse_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000A99CC -tAnimation xpulse_anms[8] = -{ - { 5u, { 5394u, 5395u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1298u, 1299u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 300u, 297u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 309u, 306u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 271u, 279u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 272u, 288u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000A99CC +tAnimation xpulse_anms[8] = { + {5u, + {5394u, 5395u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1298u, 1299u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {300u, 297u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {309u, 306u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {271u, 279u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {272u, 288u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000A9BEC -tVec3 xglobal_coords[86] = -{ - { -287.526f, 172.476f, 410.20001f }, - { -46.679001f, 188.446f, 410.556f }, - { 312.23199f, 139.66701f, 294.771f }, - { 279.39301f, 278.664f, 281.83499f }, - { -355.147f, 249.81599f, 314.76099f }, - { 559.854f, 228.09801f, 246.34801f }, - { 514.388f, 270.095f, 245.21001f }, - { -47.658001f, 94.111f, 410.67999f }, - { 624.05103f, 246.571f, 188.13499f }, - { 527.65399f, 299.76801f, 206.86501f }, - { 660.789f, 227.75301f, 60.766998f }, - { -320.63599f, 301.06699f, 223.998f }, - { -535.45099f, 299.77301f, 50.234001f }, - { 317.31601f, 299.11401f, 207.17999f }, - { -320.50201f, 301.01001f, 50.689999f }, - { 527.54303f, 300.89001f, 52.320999f }, - { 317.07401f, 300.34698f, 52.195999f }, - { -537.67902f, 299.405f, 224.53999f }, - { -564.91901f, 234.282f, 311.87601f }, - { -287.599f, -170.91701f, 410.198f }, - { -47.735001f, -186.256f, 410.58899f }, - { 312.32001f, -143.379f, 295.02399f }, - { 279.03201f, -278.08801f, 281.814f }, - { -354.35199f, -252.939f, 315.42899f }, - { 559.57703f, -225.29201f, 246.229f }, - { 514.11499f, -269.07599f, 245.52299f }, - { -46.951f, -89.950996f, 410.49799f }, - { 622.85797f, -244.19501f, 188.134f }, - { 527.65399f, -298.534f, 206.864f }, - { 660.79498f, -230.657f, 60.765999f }, - { -320.70001f, -297.06299f, 223.99699f }, - { -535.94299f, -298.53799f, 50.233002f }, - { 317.31601f, -297.879f, 207.179f }, - { -320.88f, -297.00601f, 50.689999f }, - { 527.54303f, -296.82199f, 52.32f }, - { 317.07501f, -296.27899f, 53.457001f }, - { -536.23999f, -298.10599f, 224.53799f }, - { -566.474f, -245.403f, 312.44901f }, - { -562.09003f, -223.60001f, 341.29901f }, - { -643.47998f, -208.16299f, 343.18201f }, - { -562.625f, 213.541f, 341.30301f }, - { -642.87903f, 192.517f, 343.53699f }, - { 527.47101f, 299.51099f, 0.31799999f }, - { 317.08899f, 299.51099f, 0.31799999f }, - { -320.51599f, 301.79199f, 2.8429999f }, - { -535.51501f, 301.79199f, 2.8429999f }, - { 527.47101f, -298.634f, 0.359f }, - { 317.08899f, -298.634f, 0.359f }, - { -320.51599f, -298.634f, 2.8840001f }, - { -537.36298f, -298.634f, 2.8840001f }, - { -443.17599f, -160.722f, 2.302f }, - { -443.17599f, -160.72301f, 54.969002f }, - { -443.17599f, -294.28299f, 2.302f }, - { -443.17599f, -294.28299f, 54.967999f }, - { -443.17599f, 298.24701f, 2.303f }, - { -443.17599f, 298.24701f, 54.969002f }, - { -443.17599f, 164.687f, 2.303f }, - { -443.17599f, 164.687f, 54.969002f }, - { 432.66f, 298.24701f, -1.376f }, - { 432.66f, 298.24701f, 51.290001f }, - { 432.66f, 164.687f, -1.376f }, - { 432.66f, 164.687f, 51.290001f }, - { 432.66f, -160.722f, 1.638f }, - { 432.66f, -160.72301f, 54.304001f }, - { 432.66f, -294.28299f, 1.637f }, - { 432.66f, -294.28299f, 54.304001f }, - { 186.312f, 362.32901f, 312.28101f }, - { 200.231f, 315.048f, 322.061f }, - { 183.166f, 371.75201f, 274.17599f }, - { 211.77499f, 271.647f, 274.17599f }, - { 200.34399f, -316.46701f, 323.62601f }, - { 184.561f, -364.884f, 312.21701f }, - { 213.59f, -272.03601f, 274.17499f }, - { 183.16701f, -372.91599f, 274.17499f }, - { -332.05899f, -172.76401f, 399.38f }, - { -333.457f, 176.91499f, 399.78299f }, - { -635.64398f, 226.80299f, 306.31f }, - { -635.61798f, -237.457f, 306.323f }, - { -633.83099f, 282.31601f, 108.517f }, - { -649.49701f, 273.93399f, 227.132f }, - { -631.38f, -278.806f, 107.095f }, - { -650.159f, -277.271f, 227.131f }, - { -505.939f, -263.57999f, 298.65302f }, - { -641.95398f, -257.62f, 294.11499f }, - { -506.43201f, 254.89799f, 299.25299f }, - { -642.37903f, 249.106f, 293.97501f } -}; +// 000A9BEC +tVec3 xglobal_coords[86] = {{-287.526f, 172.476f, 410.20001f}, + {-46.679001f, 188.446f, 410.556f}, + {312.23199f, 139.66701f, 294.771f}, + {279.39301f, 278.664f, 281.83499f}, + {-355.147f, 249.81599f, 314.76099f}, + {559.854f, 228.09801f, 246.34801f}, + {514.388f, 270.095f, 245.21001f}, + {-47.658001f, 94.111f, 410.67999f}, + {624.05103f, 246.571f, 188.13499f}, + {527.65399f, 299.76801f, 206.86501f}, + {660.789f, 227.75301f, 60.766998f}, + {-320.63599f, 301.06699f, 223.998f}, + {-535.45099f, 299.77301f, 50.234001f}, + {317.31601f, 299.11401f, 207.17999f}, + {-320.50201f, 301.01001f, 50.689999f}, + {527.54303f, 300.89001f, 52.320999f}, + {317.07401f, 300.34698f, 52.195999f}, + {-537.67902f, 299.405f, 224.53999f}, + {-564.91901f, 234.282f, 311.87601f}, + {-287.599f, -170.91701f, 410.198f}, + {-47.735001f, -186.256f, 410.58899f}, + {312.32001f, -143.379f, 295.02399f}, + {279.03201f, -278.08801f, 281.814f}, + {-354.35199f, -252.939f, 315.42899f}, + {559.57703f, -225.29201f, 246.229f}, + {514.11499f, -269.07599f, 245.52299f}, + {-46.951f, -89.950996f, 410.49799f}, + {622.85797f, -244.19501f, 188.134f}, + {527.65399f, -298.534f, 206.864f}, + {660.79498f, -230.657f, 60.765999f}, + {-320.70001f, -297.06299f, 223.99699f}, + {-535.94299f, -298.53799f, 50.233002f}, + {317.31601f, -297.879f, 207.179f}, + {-320.88f, -297.00601f, 50.689999f}, + {527.54303f, -296.82199f, 52.32f}, + {317.07501f, -296.27899f, 53.457001f}, + {-536.23999f, -298.10599f, 224.53799f}, + {-566.474f, -245.403f, 312.44901f}, + {-562.09003f, -223.60001f, 341.29901f}, + {-643.47998f, -208.16299f, 343.18201f}, + {-562.625f, 213.541f, 341.30301f}, + {-642.87903f, 192.517f, 343.53699f}, + {527.47101f, 299.51099f, 0.31799999f}, + {317.08899f, 299.51099f, 0.31799999f}, + {-320.51599f, 301.79199f, 2.8429999f}, + {-535.51501f, 301.79199f, 2.8429999f}, + {527.47101f, -298.634f, 0.359f}, + {317.08899f, -298.634f, 0.359f}, + {-320.51599f, -298.634f, 2.8840001f}, + {-537.36298f, -298.634f, 2.8840001f}, + {-443.17599f, -160.722f, 2.302f}, + {-443.17599f, -160.72301f, 54.969002f}, + {-443.17599f, -294.28299f, 2.302f}, + {-443.17599f, -294.28299f, 54.967999f}, + {-443.17599f, 298.24701f, 2.303f}, + {-443.17599f, 298.24701f, 54.969002f}, + {-443.17599f, 164.687f, 2.303f}, + {-443.17599f, 164.687f, 54.969002f}, + {432.66f, 298.24701f, -1.376f}, + {432.66f, 298.24701f, 51.290001f}, + {432.66f, 164.687f, -1.376f}, + {432.66f, 164.687f, 51.290001f}, + {432.66f, -160.722f, 1.638f}, + {432.66f, -160.72301f, 54.304001f}, + {432.66f, -294.28299f, 1.637f}, + {432.66f, -294.28299f, 54.304001f}, + {186.312f, 362.32901f, 312.28101f}, + {200.231f, 315.048f, 322.061f}, + {183.166f, 371.75201f, 274.17599f}, + {211.77499f, 271.647f, 274.17599f}, + {200.34399f, -316.46701f, 323.62601f}, + {184.561f, -364.884f, 312.21701f}, + {213.59f, -272.03601f, 274.17499f}, + {183.16701f, -372.91599f, 274.17499f}, + {-332.05899f, -172.76401f, 399.38f}, + {-333.457f, 176.91499f, 399.78299f}, + {-635.64398f, 226.80299f, 306.31f}, + {-635.61798f, -237.457f, 306.323f}, + {-633.83099f, 282.31601f, 108.517f}, + {-649.49701f, 273.93399f, 227.132f}, + {-631.38f, -278.806f, 107.095f}, + {-650.159f, -277.271f, 227.131f}, + {-505.939f, -263.57999f, 298.65302f}, + {-641.95398f, -257.62f, 294.11499f}, + {-506.43201f, 254.89799f, 299.25299f}, + {-642.37903f, 249.106f, 293.97501f}}; //------------------------------------------------------------------------------------------------- -//000A9FF4 -tPolygon xglobal_pols[50] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 33, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 298u, -1, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 34, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 278u, -1, 0u }, - { { 38u, 40u, 41u, 39u }, 41233u, -1, 0u }, - { { 26u, 20u, 22u, 21u }, 37158u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 37156u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 28, 0u }, - { { 56u, 57u, 55u, 54u }, 8304u, 26, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 25, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 27, 0u }, - { { 68u, 66u, 67u, 69u }, 43239u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43239u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 37127u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 33031u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 299u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 277u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 4382u, -1, 0u }, - { { 80u, 78u, 12u, 31u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 33044u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 285u, -1, 0u }, - { { 37u, 18u, 76u, 77u }, 273u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, -1, 0u }, - { { 19u, 0u, 75u, 74u }, 273u, -1, 0u }, - { { 20u, 1u, 0u, 19u }, 259u, -1, 0u }, - { { 82u, 38u, 39u, 83u }, 41233u, -1, 0u }, - { { 40u, 84u, 85u, 41u }, 41233u, -1, 0u } -}; +// 000A9FF4 +tPolygon xglobal_pols[50] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 33, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 298u, -1, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 34, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 278u, -1, 0u}, + {{38u, 40u, 41u, 39u}, 41233u, -1, 0u}, + {{26u, 20u, 22u, 21u}, 37158u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 37156u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 28, 0u}, + {{56u, 57u, 55u, 54u}, 8304u, 26, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 25, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 27, 0u}, + {{68u, 66u, 67u, 69u}, 43239u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43239u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 37127u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 33031u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 299u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 277u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 4382u, -1, 0u}, + {{80u, 78u, 12u, 31u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 33044u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 285u, -1, 0u}, + {{37u, 18u, 76u, 77u}, 273u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, -1, 0u}, + {{19u, 0u, 75u, 74u}, 273u, -1, 0u}, + {{20u, 1u, 0u, 19u}, 259u, -1, 0u}, + {{82u, 38u, 39u, 83u}, 41233u, -1, 0u}, + {{40u, 84u, 85u, 41u}, 41233u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000AA24C -unsigned int xglobal_backs[] = { 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000AA24C +unsigned int xglobal_backs[] = { + 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AA314 -int xglobal_places[] = { 3, 22, 56, 50 }; +// 000AA314 +int xglobal_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000AA324 -tAnimation xglobal_anms[8] = -{ - { 5u, { 5394u, 5395u, 5386u, 5385u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1298u, 1299u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000AA324 +tAnimation xglobal_anms[8] = { + {5u, + {5394u, 5395u, 5386u, 5385u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1298u, 1299u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000AA544 -tVec3 xmillion_coords[86] = -{ - { -287.23099f, 172.299f, 409.78f }, - { -46.631001f, 188.254f, 410.13599f }, - { 311.91299f, 139.524f, 294.47f }, - { 279.10699f, 278.379f, 281.547f }, - { -354.784f, 249.56f, 314.439f }, - { 559.28101f, 227.86501f, 246.09599f }, - { 513.862f, 269.819f, 244.959f }, - { -47.609001f, 94.014999f, 410.26001f }, - { 623.41199f, 246.319f, 187.942f }, - { 527.11401f, 299.461f, 206.65401f }, - { 660.11298f, 227.52f, 60.705002f }, - { -320.30801f, 300.759f, 223.769f }, - { -534.90302f, 299.466f, 50.181999f }, - { 316.991f, 298.80801f, 206.968f }, - { -320.17401f, 300.702f, 50.639f }, - { 527.00403f, 300.58301f, 52.266998f }, - { 316.75f, 300.039f, 52.141998f }, - { -537.12799f, 299.09799f, 224.31f }, - { -564.341f, 234.043f, 311.55701f }, - { -287.30499f, -170.742f, 409.77802f }, - { -47.686001f, -186.065f, 410.16901f }, - { 312.0f, -143.23199f, 294.72198f }, - { 278.74701f, -277.80399f, 281.526f }, - { -353.98901f, -252.67999f, 315.10599f }, - { 559.005f, -225.062f, 245.97701f }, - { 513.58899f, -268.80099f, 245.272f }, - { -46.903f, -89.859001f, 410.078f }, - { 622.22101f, -243.94501f, 187.94099f }, - { 527.11401f, -298.228f, 206.65199f }, - { 660.11902f, -230.42101f, 60.703999f }, - { -320.37201f, -296.759f, 223.76801f }, - { -535.39502f, -298.23199f, 50.181999f }, - { 316.991f, -297.57401f, 206.967f }, - { -320.55099f, -296.702f, 50.638f }, - { 527.00403f, -296.51801f, 52.265999f }, - { 316.75f, -295.97601f, 53.403f }, - { -535.69202f, -297.80099f, 224.30901f }, - { -565.89398f, -245.151f, 312.13f }, - { -561.51501f, -223.371f, 340.95001f }, - { -642.82202f, -207.95f, 342.83099f }, - { -562.04901f, 213.323f, 340.95401f }, - { -642.22101f, 192.32001f, 343.186f }, - { 526.93201f, 299.20401f, 0.31799999f }, - { 316.76501f, 299.20401f, 0.31799999f }, - { -320.18799f, 301.483f, 2.8399999f }, - { -534.96698f, 301.483f, 2.8399999f }, - { 526.93201f, -298.32901f, 0.35800001f }, - { 316.76501f, -298.32901f, 0.35800001f }, - { -320.18799f, -298.32901f, 2.881f }, - { -536.81403f, -298.32901f, 2.881f }, - { -442.72299f, -160.55701f, 2.3f }, - { -442.72299f, -160.558f, 54.912998f }, - { -442.72299f, -293.98099f, 2.3f }, - { -442.72299f, -293.98099f, 54.911999f }, - { -442.72299f, 297.94199f, 2.3f }, - { -442.72299f, 297.94199f, 54.912998f }, - { -442.72299f, 164.51801f, 2.3f }, - { -442.72299f, 164.51801f, 54.912998f }, - { 432.21799f, 297.94199f, -1.374f }, - { 432.21799f, 297.94199f, 51.237999f }, - { 432.21799f, 164.51801f, -1.374f }, - { 432.21799f, 164.51801f, 51.237999f }, - { 432.21799f, -160.55701f, 1.636f }, - { 432.21799f, -160.558f, 54.249001f }, - { 432.21799f, -293.98099f, 1.635f }, - { 432.21799f, -293.98099f, 54.249001f }, - { 186.121f, 361.95901f, 311.961f }, - { 200.026f, 314.72601f, 321.73099f }, - { 182.978f, 371.371f, 273.89499f }, - { 211.558f, 271.36899f, 273.89499f }, - { 200.13901f, -316.14301f, 323.29501f }, - { 184.37199f, -364.51099f, 311.897f }, - { 213.371f, -271.75699f, 273.89499f }, - { 182.98f, -372.535f, 273.89499f }, - { -331.71899f, -172.58701f, 398.97101f }, - { -333.116f, 176.73399f, 399.37399f }, - { -634.99402f, 226.57001f, 305.99701f }, - { -634.96802f, -237.214f, 306.01001f }, - { -633.18201f, 282.02701f, 108.406f }, - { -648.83197f, 273.65399f, 226.899f }, - { -630.73401f, -278.521f, 106.985f }, - { -649.49402f, -276.987f, 226.899f }, - { -505.42099f, -263.311f, 298.34799f }, - { -641.297f, -257.35599f, 293.814f }, - { -505.914f, 254.63699f, 298.94699f }, - { -641.72101f, 248.851f, 293.67401f } -}; +// 000AA544 +tVec3 xmillion_coords[86] = {{-287.23099f, 172.299f, 409.78f}, + {-46.631001f, 188.254f, 410.13599f}, + {311.91299f, 139.524f, 294.47f}, + {279.10699f, 278.379f, 281.547f}, + {-354.784f, 249.56f, 314.439f}, + {559.28101f, 227.86501f, 246.09599f}, + {513.862f, 269.819f, 244.959f}, + {-47.609001f, 94.014999f, 410.26001f}, + {623.41199f, 246.319f, 187.942f}, + {527.11401f, 299.461f, 206.65401f}, + {660.11298f, 227.52f, 60.705002f}, + {-320.30801f, 300.759f, 223.769f}, + {-534.90302f, 299.466f, 50.181999f}, + {316.991f, 298.80801f, 206.968f}, + {-320.17401f, 300.702f, 50.639f}, + {527.00403f, 300.58301f, 52.266998f}, + {316.75f, 300.039f, 52.141998f}, + {-537.12799f, 299.09799f, 224.31f}, + {-564.341f, 234.043f, 311.55701f}, + {-287.30499f, -170.742f, 409.77802f}, + {-47.686001f, -186.065f, 410.16901f}, + {312.0f, -143.23199f, 294.72198f}, + {278.74701f, -277.80399f, 281.526f}, + {-353.98901f, -252.67999f, 315.10599f}, + {559.005f, -225.062f, 245.97701f}, + {513.58899f, -268.80099f, 245.272f}, + {-46.903f, -89.859001f, 410.078f}, + {622.22101f, -243.94501f, 187.94099f}, + {527.11401f, -298.228f, 206.65199f}, + {660.11902f, -230.42101f, 60.703999f}, + {-320.37201f, -296.759f, 223.76801f}, + {-535.39502f, -298.23199f, 50.181999f}, + {316.991f, -297.57401f, 206.967f}, + {-320.55099f, -296.702f, 50.638f}, + {527.00403f, -296.51801f, 52.265999f}, + {316.75f, -295.97601f, 53.403f}, + {-535.69202f, -297.80099f, 224.30901f}, + {-565.89398f, -245.151f, 312.13f}, + {-561.51501f, -223.371f, 340.95001f}, + {-642.82202f, -207.95f, 342.83099f}, + {-562.04901f, 213.323f, 340.95401f}, + {-642.22101f, 192.32001f, 343.186f}, + {526.93201f, 299.20401f, 0.31799999f}, + {316.76501f, 299.20401f, 0.31799999f}, + {-320.18799f, 301.483f, 2.8399999f}, + {-534.96698f, 301.483f, 2.8399999f}, + {526.93201f, -298.32901f, 0.35800001f}, + {316.76501f, -298.32901f, 0.35800001f}, + {-320.18799f, -298.32901f, 2.881f}, + {-536.81403f, -298.32901f, 2.881f}, + {-442.72299f, -160.55701f, 2.3f}, + {-442.72299f, -160.558f, 54.912998f}, + {-442.72299f, -293.98099f, 2.3f}, + {-442.72299f, -293.98099f, 54.911999f}, + {-442.72299f, 297.94199f, 2.3f}, + {-442.72299f, 297.94199f, 54.912998f}, + {-442.72299f, 164.51801f, 2.3f}, + {-442.72299f, 164.51801f, 54.912998f}, + {432.21799f, 297.94199f, -1.374f}, + {432.21799f, 297.94199f, 51.237999f}, + {432.21799f, 164.51801f, -1.374f}, + {432.21799f, 164.51801f, 51.237999f}, + {432.21799f, -160.55701f, 1.636f}, + {432.21799f, -160.558f, 54.249001f}, + {432.21799f, -293.98099f, 1.635f}, + {432.21799f, -293.98099f, 54.249001f}, + {186.121f, 361.95901f, 311.961f}, + {200.026f, 314.72601f, 321.73099f}, + {182.978f, 371.371f, 273.89499f}, + {211.558f, 271.36899f, 273.89499f}, + {200.13901f, -316.14301f, 323.29501f}, + {184.37199f, -364.51099f, 311.897f}, + {213.371f, -271.75699f, 273.89499f}, + {182.98f, -372.535f, 273.89499f}, + {-331.71899f, -172.58701f, 398.97101f}, + {-333.116f, 176.73399f, 399.37399f}, + {-634.99402f, 226.57001f, 305.99701f}, + {-634.96802f, -237.214f, 306.01001f}, + {-633.18201f, 282.02701f, 108.406f}, + {-648.83197f, 273.65399f, 226.899f}, + {-630.73401f, -278.521f, 106.985f}, + {-649.49402f, -276.987f, 226.899f}, + {-505.42099f, -263.311f, 298.34799f}, + {-641.297f, -257.35599f, 293.814f}, + {-505.914f, 254.63699f, 298.94699f}, + {-641.72101f, 248.851f, 293.67401f}}; //------------------------------------------------------------------------------------------------- -//000AA94C -tPolygon xmillion_pols[47] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 32, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 33066u, 35, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 33, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 33046u, 34, 0u }, - { { 26u, 20u, 22u, 21u }, 33060u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 33062u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 53u, 52u, 50u, 51u }, 8304u, 27, 0u }, - { { 57u, 56u, 54u, 55u }, 8304u, 25, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 24, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 26, 0u }, - { { 68u, 66u, 67u, 69u }, 43151u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43151u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 57607u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 41223u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 299u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 277u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 308u, -1, 0u }, - { { 12u, 31u, 80u, 78u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 33044u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 33288u, -1, 0u }, - { { 37u, 18u, 76u, 77u }, 273u, -1, 0u }, - { { 0u, 19u, 20u, 1u }, 33027u, -1, 0u }, - { { 23u, 4u, 18u, 37u }, 273u, -1, 0u }, - { { 19u, 0u, 4u, 23u }, 33029u, -1, 0u } -}; +// 000AA94C +tPolygon xmillion_pols[47] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 32, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 33066u, 35, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 33, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 33046u, 34, 0u}, + {{26u, 20u, 22u, 21u}, 33060u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 33062u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{53u, 52u, 50u, 51u}, 8304u, 27, 0u}, + {{57u, 56u, 54u, 55u}, 8304u, 25, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 24, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 26, 0u}, + {{68u, 66u, 67u, 69u}, 43151u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43151u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 57607u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 41223u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 299u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 277u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 308u, -1, 0u}, + {{12u, 31u, 80u, 78u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 33044u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 33288u, -1, 0u}, + {{37u, 18u, 76u, 77u}, 273u, -1, 0u}, + {{0u, 19u, 20u, 1u}, 33027u, -1, 0u}, + {{23u, 4u, 18u, 37u}, 273u, -1, 0u}, + {{19u, 0u, 4u, 23u}, 33029u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000AAB80 -unsigned int xmillion_backs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000AAB80 +unsigned int xmillion_backs[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AAC3C -int xmillion_places[] = { 3, 22, 56, 50 }; +// 000AAC3C +int xmillion_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000AAC4C -tAnimation xmillion_anms[9] = -{ - { 5u, { 5395u, 5394u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1299u, 1298u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 285u, 284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000AAC4C +tAnimation xmillion_anms[9] = { + {5u, + {5395u, 5394u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1299u, 1298u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {285u, 284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000AAEB0 -tVec3 xmission_coords[88] = -{ - { -295.76901f, 172.239f, 409.457f }, - { -54.924f, 188.21001f, 409.81201f }, - { 303.98901f, 139.42999f, 294.02802f }, - { 271.14999f, 278.427f, 281.09201f }, - { -363.39099f, 249.57899f, 314.017f }, - { 551.60999f, 227.862f, 245.605f }, - { 506.14401f, 269.85901f, 244.466f }, - { -55.901001f, 93.874001f, 409.93701f }, - { 615.80603f, 246.334f, 187.392f }, - { 519.41101f, 299.53101f, 206.12199f }, - { 652.54498f, 227.51601f, 60.023998f }, - { -328.88f, 300.82999f, 223.254f }, - { -543.69501f, 299.53601f, 49.490002f }, - { 309.07101f, 298.87701f, 206.436f }, - { -328.746f, 300.77301f, 49.946999f }, - { 519.29999f, 300.65302f, 51.577f }, - { 308.82999f, 300.10999f, 51.452f }, - { -545.922f, 299.168f, 223.79601f }, - { -573.16302f, 234.04601f, 311.133f }, - { -295.84299f, -171.15401f, 409.45401f }, - { -55.978001f, -186.493f, 409.845f }, - { 304.07599f, -143.616f, 294.28f }, - { 270.789f, -278.32501f, 281.07101f }, - { -362.595f, -253.177f, 314.685f }, - { 551.33398f, -225.52901f, 245.48599f }, - { 505.871f, -269.31299f, 244.78f }, - { -55.195f, -90.188004f, 409.754f }, - { 614.61401f, -244.431f, 187.39f }, - { 519.41101f, -298.76999f, 206.121f }, - { 652.55103f, -230.89301f, 60.022999f }, - { -328.94299f, -297.29999f, 223.25301f }, - { -544.18799f, -298.77499f, 49.490002f }, - { 309.07101f, -298.116f, 206.435f }, - { -329.12299f, -297.24301f, 49.946999f }, - { 519.29999f, -297.05899f, 51.577f }, - { 308.82999f, -296.51599f, 52.714001f }, - { -544.48401f, -298.34201f, 223.795f }, - { -574.71698f, -245.64f, 311.70499f }, - { -410.36899f, -193.655f, 372.353f }, - { -603.43201f, -208.39999f, 375.332f }, - { -410.90399f, 195.19501f, 372.35699f }, - { -602.83099f, 210.38901f, 375.68701f }, - { 519.22699f, 299.27301f, -0.42500001f }, - { 308.845f, 299.27301f, -0.42500001f }, - { -328.76099f, 301.55499f, 2.0999999f }, - { -543.75897f, 301.55499f, 2.0999999f }, - { 519.22699f, -298.871f, -0.38499999f }, - { 308.845f, -298.871f, -0.38499999f }, - { -328.76099f, -298.871f, 2.1400001f }, - { -545.60797f, -298.871f, 2.1400001f }, - { -451.42001f, -160.959f, 1.558f }, - { -451.42001f, -160.959f, 54.224998f }, - { -451.42001f, -294.51901f, 1.558f }, - { -451.42001f, -294.51999f, 54.224998f }, - { -451.42001f, 298.01001f, 1.559f }, - { -451.42001f, 298.01001f, 54.226002f }, - { -451.42001f, 164.45f, 1.559f }, - { -451.42001f, 164.45f, 54.224998f }, - { 424.41699f, 298.01001f, -2.1199999f }, - { 424.41699f, 298.01001f, 50.547001f }, - { 424.41699f, 164.45f, -2.1199999f }, - { 424.41699f, 164.45f, 50.547001f }, - { 424.41699f, -160.959f, 0.89399999f }, - { 424.41699f, -160.959f, 53.561001f }, - { 424.41699f, -294.51901f, 0.89399999f }, - { 424.41699f, -294.51999f, 53.561001f }, - { 178.06799f, 362.09201f, 311.53799f }, - { 191.987f, 314.811f, 321.31699f }, - { 174.92101f, 371.51401f, 273.43201f }, - { 203.53f, 271.41f, 273.43201f }, - { 192.10001f, -316.703f, 322.88199f }, - { 176.31599f, -365.121f, 311.474f }, - { 205.345f, -272.27301f, 273.431f }, - { 174.924f, -373.15399f, 273.431f }, - { -340.302f, -173.00101f, 398.63599f }, - { -341.702f, 176.677f, 399.04001f }, - { -643.888f, 226.56599f, 305.56699f }, - { -643.862f, -237.694f, 305.57999f }, - { -642.07397f, 282.07999f, 107.773f }, - { -657.73999f, 273.698f, 226.388f }, - { -639.62402f, -279.043f, 106.351f }, - { -658.40302f, -277.508f, 226.38699f }, - { -662.06299f, -208.39999f, 395.06799f }, - { -661.46198f, 210.38901f, 395.42401f }, - { -424.026f, -7.4850001f, 361.73001f }, - { -549.77802f, -7.4850001f, 317.285f }, - { -602.68799f, -7.4850001f, 372.79001f }, - { -411.82101f, -7.4850001f, 371.349f } -}; +// 000AAEB0 +tVec3 xmission_coords[88] = {{-295.76901f, 172.239f, 409.457f}, + {-54.924f, 188.21001f, 409.81201f}, + {303.98901f, 139.42999f, 294.02802f}, + {271.14999f, 278.427f, 281.09201f}, + {-363.39099f, 249.57899f, 314.017f}, + {551.60999f, 227.862f, 245.605f}, + {506.14401f, 269.85901f, 244.466f}, + {-55.901001f, 93.874001f, 409.93701f}, + {615.80603f, 246.334f, 187.392f}, + {519.41101f, 299.53101f, 206.12199f}, + {652.54498f, 227.51601f, 60.023998f}, + {-328.88f, 300.82999f, 223.254f}, + {-543.69501f, 299.53601f, 49.490002f}, + {309.07101f, 298.87701f, 206.436f}, + {-328.746f, 300.77301f, 49.946999f}, + {519.29999f, 300.65302f, 51.577f}, + {308.82999f, 300.10999f, 51.452f}, + {-545.922f, 299.168f, 223.79601f}, + {-573.16302f, 234.04601f, 311.133f}, + {-295.84299f, -171.15401f, 409.45401f}, + {-55.978001f, -186.493f, 409.845f}, + {304.07599f, -143.616f, 294.28f}, + {270.789f, -278.32501f, 281.07101f}, + {-362.595f, -253.177f, 314.685f}, + {551.33398f, -225.52901f, 245.48599f}, + {505.871f, -269.31299f, 244.78f}, + {-55.195f, -90.188004f, 409.754f}, + {614.61401f, -244.431f, 187.39f}, + {519.41101f, -298.76999f, 206.121f}, + {652.55103f, -230.89301f, 60.022999f}, + {-328.94299f, -297.29999f, 223.25301f}, + {-544.18799f, -298.77499f, 49.490002f}, + {309.07101f, -298.116f, 206.435f}, + {-329.12299f, -297.24301f, 49.946999f}, + {519.29999f, -297.05899f, 51.577f}, + {308.82999f, -296.51599f, 52.714001f}, + {-544.48401f, -298.34201f, 223.795f}, + {-574.71698f, -245.64f, 311.70499f}, + {-410.36899f, -193.655f, 372.353f}, + {-603.43201f, -208.39999f, 375.332f}, + {-410.90399f, 195.19501f, 372.35699f}, + {-602.83099f, 210.38901f, 375.68701f}, + {519.22699f, 299.27301f, -0.42500001f}, + {308.845f, 299.27301f, -0.42500001f}, + {-328.76099f, 301.55499f, 2.0999999f}, + {-543.75897f, 301.55499f, 2.0999999f}, + {519.22699f, -298.871f, -0.38499999f}, + {308.845f, -298.871f, -0.38499999f}, + {-328.76099f, -298.871f, 2.1400001f}, + {-545.60797f, -298.871f, 2.1400001f}, + {-451.42001f, -160.959f, 1.558f}, + {-451.42001f, -160.959f, 54.224998f}, + {-451.42001f, -294.51901f, 1.558f}, + {-451.42001f, -294.51999f, 54.224998f}, + {-451.42001f, 298.01001f, 1.559f}, + {-451.42001f, 298.01001f, 54.226002f}, + {-451.42001f, 164.45f, 1.559f}, + {-451.42001f, 164.45f, 54.224998f}, + {424.41699f, 298.01001f, -2.1199999f}, + {424.41699f, 298.01001f, 50.547001f}, + {424.41699f, 164.45f, -2.1199999f}, + {424.41699f, 164.45f, 50.547001f}, + {424.41699f, -160.959f, 0.89399999f}, + {424.41699f, -160.959f, 53.561001f}, + {424.41699f, -294.51901f, 0.89399999f}, + {424.41699f, -294.51999f, 53.561001f}, + {178.06799f, 362.09201f, 311.53799f}, + {191.987f, 314.811f, 321.31699f}, + {174.92101f, 371.51401f, 273.43201f}, + {203.53f, 271.41f, 273.43201f}, + {192.10001f, -316.703f, 322.88199f}, + {176.31599f, -365.121f, 311.474f}, + {205.345f, -272.27301f, 273.431f}, + {174.924f, -373.15399f, 273.431f}, + {-340.302f, -173.00101f, 398.63599f}, + {-341.702f, 176.677f, 399.04001f}, + {-643.888f, 226.56599f, 305.56699f}, + {-643.862f, -237.694f, 305.57999f}, + {-642.07397f, 282.07999f, 107.773f}, + {-657.73999f, 273.698f, 226.388f}, + {-639.62402f, -279.043f, 106.351f}, + {-658.40302f, -277.508f, 226.38699f}, + {-662.06299f, -208.39999f, 395.06799f}, + {-661.46198f, 210.38901f, 395.42401f}, + {-424.026f, -7.4850001f, 361.73001f}, + {-549.77802f, -7.4850001f, 317.285f}, + {-602.68799f, -7.4850001f, 372.79001f}, + {-411.82101f, -7.4850001f, 371.349f}}; //------------------------------------------------------------------------------------------------- -//000AB2D0 -tPolygon xmission_pols[47] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 32, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 298u, -1, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 33, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 278u, -1, 0u }, - { { 26u, 20u, 22u, 21u }, 33060u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 33062u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 27, 0u }, - { { 57u, 56u, 54u, 55u }, 8304u, 25, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 24, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 26, 0u }, - { { 68u, 66u, 67u, 69u }, 43203u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43203u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 4359u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 263u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 299u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 277u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 308u, -1, 0u }, - { { 12u, 31u, 80u, 78u }, 114u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 276u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 520u, -1, 0u }, - { { 76u, 77u, 37u, 18u }, 195u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, -1, 0u }, - { { 19u, 0u, 75u, 74u }, 259u, -1, 0u }, - { { 0u, 19u, 20u, 1u }, 259u, -1, 0u } -}; +// 000AB2D0 +tPolygon xmission_pols[47] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 32, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 298u, -1, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 33, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 278u, -1, 0u}, + {{26u, 20u, 22u, 21u}, 33060u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 33062u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 27, 0u}, + {{57u, 56u, 54u, 55u}, 8304u, 25, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 24, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 26, 0u}, + {{68u, 66u, 67u, 69u}, 43203u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43203u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 4359u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 263u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 299u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 277u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 308u, -1, 0u}, + {{12u, 31u, 80u, 78u}, 114u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 276u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 520u, -1, 0u}, + {{76u, 77u, 37u, 18u}, 195u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, -1, 0u}, + {{19u, 0u, 75u, 74u}, 259u, -1, 0u}, + {{0u, 19u, 20u, 1u}, 259u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000AB504 -unsigned int xmission_backs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000AB504 +unsigned int xmission_backs[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AB5C0 -int xmission_places[] = { 3, 22, 56, 50 }; +// 000AB5C0 +int xmission_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000AB5D0 -tAnimation xmission_anms[9] = -{ - { 5u, { 5395u, 5394u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1299u, 1298u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 285u, 284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000AB5D0 +tAnimation xmission_anms[9] = { + {5u, + {5395u, 5394u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1299u, 1298u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {285u, 284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000AB834 -tVec3 xzizin_coords[86] = -{ - { -287.526f, 172.476f, 410.20001f }, - { -46.679001f, 188.446f, 410.556f }, - { 312.23199f, 139.66701f, 294.771f }, - { 279.39301f, 278.664f, 281.83499f }, - { -355.147f, 249.81599f, 314.76099f }, - { 559.854f, 228.09801f, 246.34801f }, - { 514.388f, 270.095f, 245.21001f }, - { -47.658001f, 94.111f, 410.67999f }, - { 624.05103f, 246.571f, 188.13499f }, - { 527.65399f, 299.76801f, 206.86501f }, - { 660.789f, 227.75301f, 60.766998f }, - { -320.63599f, 301.06699f, 223.998f }, - { -535.45099f, 299.77301f, 50.234001f }, - { 317.31601f, 299.11401f, 207.17999f }, - { -320.50201f, 301.01001f, 50.689999f }, - { 527.54303f, 300.89001f, 52.320999f }, - { 317.07401f, 300.34698f, 52.195999f }, - { -537.67902f, 299.405f, 224.53999f }, - { -564.91901f, 234.282f, 311.87601f }, - { -287.599f, -170.91701f, 410.198f }, - { -47.735001f, -186.256f, 410.58899f }, - { 312.32001f, -143.379f, 295.02399f }, - { 279.03201f, -278.08801f, 281.814f }, - { -354.35199f, -252.939f, 315.42899f }, - { 559.57703f, -225.29201f, 246.229f }, - { 514.11499f, -269.07599f, 245.52299f }, - { -46.951f, -89.950996f, 410.49799f }, - { 622.85797f, -244.19501f, 188.134f }, - { 527.65399f, -298.534f, 206.864f }, - { 660.79498f, -230.657f, 60.765999f }, - { -320.70001f, -297.06299f, 223.99699f }, - { -535.94299f, -298.53799f, 50.233002f }, - { 317.31601f, -297.879f, 207.179f }, - { -320.88f, -297.00601f, 50.689999f }, - { 527.54303f, -296.82199f, 52.32f }, - { 317.07501f, -296.27899f, 53.457001f }, - { -536.23999f, -298.10599f, 224.53799f }, - { -566.474f, -245.403f, 312.44901f }, - { -562.09003f, -223.60001f, 341.29901f }, - { -643.47998f, -208.16299f, 343.18201f }, - { -562.625f, 213.541f, 341.30301f }, - { -642.87903f, 192.517f, 343.53699f }, - { 527.47101f, 299.51099f, 0.31799999f }, - { 317.08899f, 299.51099f, 0.31799999f }, - { -320.51599f, 301.79199f, 2.8429999f }, - { -535.51501f, 301.79199f, 2.8429999f }, - { 527.47101f, -298.634f, 0.359f }, - { 317.08899f, -298.634f, 0.359f }, - { -320.51599f, -298.634f, 2.8840001f }, - { -537.36298f, -298.634f, 2.8840001f }, - { -443.17599f, -160.722f, 2.302f }, - { -443.17599f, -160.72301f, 54.969002f }, - { -443.17599f, -294.28299f, 2.302f }, - { -443.17599f, -294.28299f, 54.967999f }, - { -443.17599f, 298.24701f, 2.303f }, - { -443.17599f, 298.24701f, 54.969002f }, - { -443.17599f, 164.687f, 2.303f }, - { -443.17599f, 164.687f, 54.969002f }, - { 432.66f, 298.24701f, -1.376f }, - { 432.66f, 298.24701f, 51.290001f }, - { 432.66f, 164.687f, -1.376f }, - { 432.66f, 164.687f, 51.290001f }, - { 432.66f, -160.722f, 1.638f }, - { 432.66f, -160.72301f, 54.304001f }, - { 432.66f, -294.28299f, 1.637f }, - { 432.66f, -294.28299f, 54.304001f }, - { 186.312f, 362.32901f, 312.28101f }, - { 200.231f, 315.048f, 322.061f }, - { 183.166f, 371.75201f, 274.17599f }, - { 211.77499f, 271.647f, 274.17599f }, - { 200.34399f, -316.46701f, 323.62601f }, - { 184.561f, -364.884f, 312.21701f }, - { 213.59f, -272.03601f, 274.17499f }, - { 183.16701f, -372.91599f, 274.17499f }, - { -332.05899f, -172.76401f, 399.38f }, - { -333.457f, 176.91499f, 399.78299f }, - { -635.64398f, 226.80299f, 306.31f }, - { -635.61798f, -237.457f, 306.323f }, - { -633.83099f, 282.31601f, 108.517f }, - { -649.49701f, 273.93399f, 227.132f }, - { -631.38f, -278.806f, 107.095f }, - { -650.159f, -277.271f, 227.131f }, - { -505.939f, -263.57999f, 298.65302f }, - { -641.95398f, -257.62f, 294.11499f }, - { -506.43201f, 254.89799f, 299.25299f }, - { -642.37903f, 249.106f, 293.97501f } -}; +// 000AB834 +tVec3 xzizin_coords[86] = {{-287.526f, 172.476f, 410.20001f}, + {-46.679001f, 188.446f, 410.556f}, + {312.23199f, 139.66701f, 294.771f}, + {279.39301f, 278.664f, 281.83499f}, + {-355.147f, 249.81599f, 314.76099f}, + {559.854f, 228.09801f, 246.34801f}, + {514.388f, 270.095f, 245.21001f}, + {-47.658001f, 94.111f, 410.67999f}, + {624.05103f, 246.571f, 188.13499f}, + {527.65399f, 299.76801f, 206.86501f}, + {660.789f, 227.75301f, 60.766998f}, + {-320.63599f, 301.06699f, 223.998f}, + {-535.45099f, 299.77301f, 50.234001f}, + {317.31601f, 299.11401f, 207.17999f}, + {-320.50201f, 301.01001f, 50.689999f}, + {527.54303f, 300.89001f, 52.320999f}, + {317.07401f, 300.34698f, 52.195999f}, + {-537.67902f, 299.405f, 224.53999f}, + {-564.91901f, 234.282f, 311.87601f}, + {-287.599f, -170.91701f, 410.198f}, + {-47.735001f, -186.256f, 410.58899f}, + {312.32001f, -143.379f, 295.02399f}, + {279.03201f, -278.08801f, 281.814f}, + {-354.35199f, -252.939f, 315.42899f}, + {559.57703f, -225.29201f, 246.229f}, + {514.11499f, -269.07599f, 245.52299f}, + {-46.951f, -89.950996f, 410.49799f}, + {622.85797f, -244.19501f, 188.134f}, + {527.65399f, -298.534f, 206.864f}, + {660.79498f, -230.657f, 60.765999f}, + {-320.70001f, -297.06299f, 223.99699f}, + {-535.94299f, -298.53799f, 50.233002f}, + {317.31601f, -297.879f, 207.179f}, + {-320.88f, -297.00601f, 50.689999f}, + {527.54303f, -296.82199f, 52.32f}, + {317.07501f, -296.27899f, 53.457001f}, + {-536.23999f, -298.10599f, 224.53799f}, + {-566.474f, -245.403f, 312.44901f}, + {-562.09003f, -223.60001f, 341.29901f}, + {-643.47998f, -208.16299f, 343.18201f}, + {-562.625f, 213.541f, 341.30301f}, + {-642.87903f, 192.517f, 343.53699f}, + {527.47101f, 299.51099f, 0.31799999f}, + {317.08899f, 299.51099f, 0.31799999f}, + {-320.51599f, 301.79199f, 2.8429999f}, + {-535.51501f, 301.79199f, 2.8429999f}, + {527.47101f, -298.634f, 0.359f}, + {317.08899f, -298.634f, 0.359f}, + {-320.51599f, -298.634f, 2.8840001f}, + {-537.36298f, -298.634f, 2.8840001f}, + {-443.17599f, -160.722f, 2.302f}, + {-443.17599f, -160.72301f, 54.969002f}, + {-443.17599f, -294.28299f, 2.302f}, + {-443.17599f, -294.28299f, 54.967999f}, + {-443.17599f, 298.24701f, 2.303f}, + {-443.17599f, 298.24701f, 54.969002f}, + {-443.17599f, 164.687f, 2.303f}, + {-443.17599f, 164.687f, 54.969002f}, + {432.66f, 298.24701f, -1.376f}, + {432.66f, 298.24701f, 51.290001f}, + {432.66f, 164.687f, -1.376f}, + {432.66f, 164.687f, 51.290001f}, + {432.66f, -160.722f, 1.638f}, + {432.66f, -160.72301f, 54.304001f}, + {432.66f, -294.28299f, 1.637f}, + {432.66f, -294.28299f, 54.304001f}, + {186.312f, 362.32901f, 312.28101f}, + {200.231f, 315.048f, 322.061f}, + {183.166f, 371.75201f, 274.17599f}, + {211.77499f, 271.647f, 274.17599f}, + {200.34399f, -316.46701f, 323.62601f}, + {184.561f, -364.884f, 312.21701f}, + {213.59f, -272.03601f, 274.17499f}, + {183.16701f, -372.91599f, 274.17499f}, + {-332.05899f, -172.76401f, 399.38f}, + {-333.457f, 176.91499f, 399.78299f}, + {-635.64398f, 226.80299f, 306.31f}, + {-635.61798f, -237.457f, 306.323f}, + {-633.83099f, 282.31601f, 108.517f}, + {-649.49701f, 273.93399f, 227.132f}, + {-631.38f, -278.806f, 107.095f}, + {-650.159f, -277.271f, 227.131f}, + {-505.939f, -263.57999f, 298.65302f}, + {-641.95398f, -257.62f, 294.11499f}, + {-506.43201f, 254.89799f, 299.25299f}, + {-642.37903f, 249.106f, 293.97501f}}; //------------------------------------------------------------------------------------------------- -//000ABC3C -tPolygon xzizin_pols[50] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33070u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 33, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33284u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33285u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 298u, -1, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 34, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33286u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33287u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 278u, -1, 0u }, - { { 38u, 40u, 41u, 39u }, 41233u, -1, 0u }, - { { 26u, 20u, 22u, 21u }, 37158u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 37156u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 28, 0u }, - { { 56u, 57u, 55u, 54u }, 8304u, 26, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 25, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 27, 0u }, - { { 68u, 66u, 67u, 69u }, 43151u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43151u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 4359u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 263u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 299u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 277u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 4382u, -1, 0u }, - { { 80u, 78u, 12u, 31u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 33044u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 285u, -1, 0u }, - { { 37u, 18u, 76u, 77u }, 273u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, -1, 0u }, - { { 19u, 0u, 75u, 74u }, 273u, -1, 0u }, - { { 20u, 1u, 0u, 19u }, 259u, -1, 0u }, - { { 82u, 38u, 39u, 83u }, 41233u, -1, 0u }, - { { 40u, 84u, 85u, 41u }, 41233u, -1, 0u } -}; +// 000ABC3C +tPolygon xzizin_pols[50] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33070u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 33, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33284u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33285u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 298u, -1, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 34, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33286u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33287u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 278u, -1, 0u}, + {{38u, 40u, 41u, 39u}, 41233u, -1, 0u}, + {{26u, 20u, 22u, 21u}, 37158u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 37156u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 28, 0u}, + {{56u, 57u, 55u, 54u}, 8304u, 26, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 25, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 27, 0u}, + {{68u, 66u, 67u, 69u}, 43151u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43151u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 4359u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 263u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 299u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 277u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 4382u, -1, 0u}, + {{80u, 78u, 12u, 31u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 33044u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 285u, -1, 0u}, + {{37u, 18u, 76u, 77u}, 273u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, -1, 0u}, + {{19u, 0u, 75u, 74u}, 273u, -1, 0u}, + {{20u, 1u, 0u, 19u}, 259u, -1, 0u}, + {{82u, 38u, 39u, 83u}, 41233u, -1, 0u}, + {{40u, 84u, 85u, 41u}, 41233u, -1, 0u}}; //------------------------------------------------------------------------------------------------- -//000ABE94 -unsigned int xzizin_backs[] = { 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000ABE94 +unsigned int xzizin_backs[] = { + 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000ABF5C -int xzizin_places[] = { 3, 22, 56, 50 }; +// 000ABF5C +int xzizin_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000ABF6C -tAnimation xzizin_anms[8] = -{ - { 5u, { 5394u, 5394u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1298u, 1299u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000ABF6C +tAnimation xzizin_anms[8] = { + {5u, + {5394u, 5394u, 5385u, 5386u, 5376u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {5389u, 5390u, 5387u, 5388u, 5378u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1298u, 1299u, 1289u, 1290u, 1280u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {1293u, 1294u, 1291u, 1292u, 1282u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000AC18C -tVec3 xreise_coords[88] = -{ - { -295.76901f, 172.239f, 409.457f }, - { -54.924f, 188.21001f, 409.81201f }, - { 303.98901f, 139.42999f, 294.02802f }, - { 271.14999f, 278.427f, 281.09201f }, - { -363.39099f, 249.57899f, 314.017f }, - { 551.60999f, 227.862f, 245.605f }, - { 506.14401f, 269.85901f, 244.466f }, - { -55.901001f, 93.874001f, 409.93701f }, - { 615.80603f, 246.334f, 187.392f }, - { 519.41101f, 299.53101f, 206.12199f }, - { 652.54498f, 227.51601f, 60.023998f }, - { -328.88f, 300.82999f, 223.254f }, - { -543.69501f, 299.53601f, 49.490002f }, - { 309.07101f, 298.87701f, 206.436f }, - { -328.746f, 300.77301f, 49.946999f }, - { 519.29999f, 300.65302f, 51.577f }, - { 308.82999f, 300.10999f, 51.452f }, - { -545.922f, 299.168f, 223.79601f }, - { -573.16302f, 234.04601f, 311.133f }, - { -295.84299f, -171.15401f, 409.45401f }, - { -55.978001f, -186.493f, 409.845f }, - { 304.07599f, -143.616f, 294.28f }, - { 270.789f, -278.32501f, 281.07101f }, - { -362.595f, -253.177f, 314.685f }, - { 551.33398f, -225.52901f, 245.48599f }, - { 505.871f, -269.31299f, 244.78f }, - { -55.195f, -90.188004f, 409.754f }, - { 614.61401f, -244.431f, 187.39f }, - { 519.41101f, -298.76999f, 206.121f }, - { 652.55103f, -230.89301f, 60.022999f }, - { -328.94299f, -297.29999f, 223.25301f }, - { -544.18799f, -298.77499f, 49.490002f }, - { 309.07101f, -298.116f, 206.435f }, - { -329.12299f, -297.24301f, 49.946999f }, - { 519.29999f, -297.05899f, 51.577f }, - { 308.82999f, -296.51599f, 52.714001f }, - { -544.48401f, -298.34201f, 223.795f }, - { -574.71698f, -245.64f, 311.70499f }, - { -410.36899f, -193.655f, 372.353f }, - { -603.43201f, -208.39999f, 375.332f }, - { -410.90399f, 195.19501f, 372.35699f }, - { -602.83099f, 210.38901f, 375.68701f }, - { 519.22699f, 299.27301f, -0.42500001f }, - { 308.845f, 299.27301f, -0.42500001f }, - { -328.76099f, 301.55499f, 2.0999999f }, - { -543.75897f, 301.55499f, 2.0999999f }, - { 519.22699f, -298.871f, -0.38499999f }, - { 308.845f, -298.871f, -0.38499999f }, - { -328.76099f, -298.871f, 2.1400001f }, - { -545.60797f, -298.871f, 2.1400001f }, - { -451.42001f, -160.959f, 1.558f }, - { -451.42001f, -160.959f, 54.224998f }, - { -451.42001f, -294.51901f, 1.558f }, - { -451.42001f, -294.51999f, 54.224998f }, - { -451.42001f, 298.01001f, 1.559f }, - { -451.42001f, 298.01001f, 54.226002f }, - { -451.42001f, 164.45f, 1.559f }, - { -451.42001f, 164.45f, 54.224998f }, - { 424.41699f, 298.01001f, -2.1199999f }, - { 424.41699f, 298.01001f, 50.547001f }, - { 424.41699f, 164.45f, -2.1199999f }, - { 424.41699f, 164.45f, 50.547001f }, - { 424.41699f, -160.959f, 0.89399999f }, - { 424.41699f, -160.959f, 53.561001f }, - { 424.41699f, -294.51901f, 0.89399999f }, - { 424.41699f, -294.51999f, 53.561001f }, - { 178.06799f, 362.09201f, 311.53799f }, - { 191.987f, 314.811f, 321.31699f }, - { 174.92101f, 371.51401f, 273.43201f }, - { 203.53f, 271.41f, 273.43201f }, - { 192.10001f, -316.703f, 322.88199f }, - { 176.31599f, -365.121f, 311.474f }, - { 205.345f, -272.27301f, 273.431f }, - { 174.924f, -373.15399f, 273.431f }, - { -340.302f, -173.00101f, 398.63599f }, - { -341.702f, 176.677f, 399.04001f }, - { -643.888f, 226.56599f, 305.56699f }, - { -643.862f, -237.694f, 305.57999f }, - { -642.07397f, 282.07999f, 107.773f }, - { -657.73999f, 273.698f, 226.388f }, - { -639.62402f, -279.043f, 106.351f }, - { -658.40302f, -277.508f, 226.38699f }, - { -662.06299f, -208.39999f, 395.06799f }, - { -661.46198f, 210.38901f, 395.42401f }, - { -424.026f, -7.4850001f, 361.73001f }, - { -549.77802f, -7.4850001f, 317.285f }, - { -602.68799f, -7.4850001f, 372.79001f }, - { -411.82101f, -7.4850001f, 371.349f } -}; +// 000AC18C +tVec3 xreise_coords[88] = {{-295.76901f, 172.239f, 409.457f}, + {-54.924f, 188.21001f, 409.81201f}, + {303.98901f, 139.42999f, 294.02802f}, + {271.14999f, 278.427f, 281.09201f}, + {-363.39099f, 249.57899f, 314.017f}, + {551.60999f, 227.862f, 245.605f}, + {506.14401f, 269.85901f, 244.466f}, + {-55.901001f, 93.874001f, 409.93701f}, + {615.80603f, 246.334f, 187.392f}, + {519.41101f, 299.53101f, 206.12199f}, + {652.54498f, 227.51601f, 60.023998f}, + {-328.88f, 300.82999f, 223.254f}, + {-543.69501f, 299.53601f, 49.490002f}, + {309.07101f, 298.87701f, 206.436f}, + {-328.746f, 300.77301f, 49.946999f}, + {519.29999f, 300.65302f, 51.577f}, + {308.82999f, 300.10999f, 51.452f}, + {-545.922f, 299.168f, 223.79601f}, + {-573.16302f, 234.04601f, 311.133f}, + {-295.84299f, -171.15401f, 409.45401f}, + {-55.978001f, -186.493f, 409.845f}, + {304.07599f, -143.616f, 294.28f}, + {270.789f, -278.32501f, 281.07101f}, + {-362.595f, -253.177f, 314.685f}, + {551.33398f, -225.52901f, 245.48599f}, + {505.871f, -269.31299f, 244.78f}, + {-55.195f, -90.188004f, 409.754f}, + {614.61401f, -244.431f, 187.39f}, + {519.41101f, -298.76999f, 206.121f}, + {652.55103f, -230.89301f, 60.022999f}, + {-328.94299f, -297.29999f, 223.25301f}, + {-544.18799f, -298.77499f, 49.490002f}, + {309.07101f, -298.116f, 206.435f}, + {-329.12299f, -297.24301f, 49.946999f}, + {519.29999f, -297.05899f, 51.577f}, + {308.82999f, -296.51599f, 52.714001f}, + {-544.48401f, -298.34201f, 223.795f}, + {-574.71698f, -245.64f, 311.70499f}, + {-410.36899f, -193.655f, 372.353f}, + {-603.43201f, -208.39999f, 375.332f}, + {-410.90399f, 195.19501f, 372.35699f}, + {-602.83099f, 210.38901f, 375.68701f}, + {519.22699f, 299.27301f, -0.42500001f}, + {308.845f, 299.27301f, -0.42500001f}, + {-328.76099f, 301.55499f, 2.0999999f}, + {-543.75897f, 301.55499f, 2.0999999f}, + {519.22699f, -298.871f, -0.38499999f}, + {308.845f, -298.871f, -0.38499999f}, + {-328.76099f, -298.871f, 2.1400001f}, + {-545.60797f, -298.871f, 2.1400001f}, + {-451.42001f, -160.959f, 1.558f}, + {-451.42001f, -160.959f, 54.224998f}, + {-451.42001f, -294.51901f, 1.558f}, + {-451.42001f, -294.51999f, 54.224998f}, + {-451.42001f, 298.01001f, 1.559f}, + {-451.42001f, 298.01001f, 54.226002f}, + {-451.42001f, 164.45f, 1.559f}, + {-451.42001f, 164.45f, 54.224998f}, + {424.41699f, 298.01001f, -2.1199999f}, + {424.41699f, 298.01001f, 50.547001f}, + {424.41699f, 164.45f, -2.1199999f}, + {424.41699f, 164.45f, 50.547001f}, + {424.41699f, -160.959f, 0.89399999f}, + {424.41699f, -160.959f, 53.561001f}, + {424.41699f, -294.51901f, 0.89399999f}, + {424.41699f, -294.51999f, 53.561001f}, + {178.06799f, 362.09201f, 311.53799f}, + {191.987f, 314.811f, 321.31699f}, + {174.92101f, 371.51401f, 273.43201f}, + {203.53f, 271.41f, 273.43201f}, + {192.10001f, -316.703f, 322.88199f}, + {176.31599f, -365.121f, 311.474f}, + {205.345f, -272.27301f, 273.431f}, + {174.924f, -373.15399f, 273.431f}, + {-340.302f, -173.00101f, 398.63599f}, + {-341.702f, 176.677f, 399.04001f}, + {-643.888f, 226.56599f, 305.56699f}, + {-643.862f, -237.694f, 305.57999f}, + {-642.07397f, 282.07999f, 107.773f}, + {-657.73999f, 273.698f, 226.388f}, + {-639.62402f, -279.043f, 106.351f}, + {-658.40302f, -277.508f, 226.38699f}, + {-662.06299f, -208.39999f, 395.06799f}, + {-661.46198f, 210.38901f, 395.42401f}, + {-424.026f, -7.4850001f, 361.73001f}, + {-549.77802f, -7.4850001f, 317.285f}, + {-602.68799f, -7.4850001f, 372.79001f}, + {-411.82101f, -7.4850001f, 371.349f}}; //------------------------------------------------------------------------------------------------- -//000AC5AC -tPolygon xreise_pols[50] = -{ - { { 7u, 26u, 21u, 2u }, 293u, -1, 0u }, - { { 2u, 21u, 24u, 5u }, 33284u, -1, 0u }, - { { 0u, 1u, 3u, 4u }, 33030u, 33, 0u }, - { { 5u, 24u, 27u, 8u }, 282u, -1, 0u }, - { { 6u, 5u, 8u, 9u }, 295u, -1, 0u }, - { { 8u, 27u, 29u, 10u }, 291u, -1, 0u }, - { { 4u, 3u, 13u, 11u }, 33285u, 2, 0u }, - { { 11u, 13u, 16u, 14u }, 33286u, -1, 0u }, - { { 3u, 6u, 9u, 13u }, 33064u, -1, 0u }, - { { 9u, 8u, 10u, 15u }, 304u, -1, 0u }, - { { 18u, 4u, 11u, 17u }, 33066u, -1, 0u }, - { { 20u, 19u, 23u, 22u }, 37126u, 34, 0u }, - { { 24u, 25u, 28u, 27u }, 281u, -1, 0u }, - { { 22u, 23u, 30u, 32u }, 33287u, 11, 0u }, - { { 32u, 30u, 33u, 35u }, 33288u, -1, 0u }, - { { 25u, 22u, 32u, 28u }, 33048u, -1, 0u }, - { { 27u, 28u, 34u, 29u }, 290u, -1, 0u }, - { { 23u, 37u, 36u, 30u }, 33046u, -1, 0u }, - { { 41u, 39u, 38u, 40u }, 41233u, 48, 0u }, - { { 26u, 20u, 22u, 21u }, 33060u, -1, 0u }, - { { 1u, 7u, 2u, 3u }, 33062u, -1, 0u }, - { { 21u, 22u, 25u, 24u }, 33069u, -1, 0u }, - { { 3u, 2u, 5u, 6u }, 33071u, -1, 0u }, - { { 10u, 29u, 34u, 15u }, 112u, -1, 0u }, - { { 15u, 34u, 31u, 12u }, 112u, -1, 0u }, - { { 13u, 9u, 42u, 43u }, 10752u, -1, 0u }, - { { 17u, 11u, 44u, 45u }, 10753u, -1, 0u }, - { { 28u, 32u, 47u, 46u }, 10754u, -1, 0u }, - { { 30u, 36u, 49u, 48u }, 10755u, -1, 0u }, - { { 52u, 53u, 51u, 50u }, 8304u, 28, 0u }, - { { 57u, 56u, 54u, 55u }, 8304u, 26, 0u }, - { { 61u, 60u, 58u, 59u }, 8304u, 25, 0u }, - { { 65u, 64u, 62u, 63u }, 8304u, 27, 0u }, - { { 68u, 66u, 67u, 69u }, 43145u, -1, 0u }, - { { 73u, 72u, 70u, 71u }, 43145u, -1, 0u }, - { { 19u, 74u, 37u, 23u }, 37127u, -1, 0u }, - { { 75u, 0u, 4u, 18u }, 33031u, -1, 0u }, - { { 76u, 18u, 17u, 79u }, 33067u, -1, 0u }, - { { 37u, 77u, 81u, 36u }, 33045u, -1, 0u }, - { { 79u, 17u, 12u, 78u }, 308u, -1, 0u }, - { { 12u, 31u, 80u, 78u }, 112u, -1, 0u }, - { { 36u, 81u, 80u, 31u }, 286u, -1, 0u }, - { { 77u, 76u, 79u, 81u }, 33044u, -1, 0u }, - { { 81u, 79u, 78u, 80u }, 33289u, -1, 0u }, - { { 76u, 77u, 37u, 18u }, 273u, -1, 0u }, - { { 74u, 75u, 18u, 37u }, 33029u, 49, 0u }, - { { 19u, 0u, 75u, 74u }, 264u, -1, 0u }, - { { 0u, 19u, 20u, 1u }, 262403u, -1, 0u }, - { { 39u, 41u, 83u, 82u }, 41233u, -1, 0u }, - { { 86u, 87u, 84u, 85u }, 41233u, 18, 0u } -}; +// 000AC5AC +tPolygon xreise_pols[50] = {{{7u, 26u, 21u, 2u}, 293u, -1, 0u}, + {{2u, 21u, 24u, 5u}, 33284u, -1, 0u}, + {{0u, 1u, 3u, 4u}, 33030u, 33, 0u}, + {{5u, 24u, 27u, 8u}, 282u, -1, 0u}, + {{6u, 5u, 8u, 9u}, 295u, -1, 0u}, + {{8u, 27u, 29u, 10u}, 291u, -1, 0u}, + {{4u, 3u, 13u, 11u}, 33285u, 2, 0u}, + {{11u, 13u, 16u, 14u}, 33286u, -1, 0u}, + {{3u, 6u, 9u, 13u}, 33064u, -1, 0u}, + {{9u, 8u, 10u, 15u}, 304u, -1, 0u}, + {{18u, 4u, 11u, 17u}, 33066u, -1, 0u}, + {{20u, 19u, 23u, 22u}, 37126u, 34, 0u}, + {{24u, 25u, 28u, 27u}, 281u, -1, 0u}, + {{22u, 23u, 30u, 32u}, 33287u, 11, 0u}, + {{32u, 30u, 33u, 35u}, 33288u, -1, 0u}, + {{25u, 22u, 32u, 28u}, 33048u, -1, 0u}, + {{27u, 28u, 34u, 29u}, 290u, -1, 0u}, + {{23u, 37u, 36u, 30u}, 33046u, -1, 0u}, + {{41u, 39u, 38u, 40u}, 41233u, 48, 0u}, + {{26u, 20u, 22u, 21u}, 33060u, -1, 0u}, + {{1u, 7u, 2u, 3u}, 33062u, -1, 0u}, + {{21u, 22u, 25u, 24u}, 33069u, -1, 0u}, + {{3u, 2u, 5u, 6u}, 33071u, -1, 0u}, + {{10u, 29u, 34u, 15u}, 112u, -1, 0u}, + {{15u, 34u, 31u, 12u}, 112u, -1, 0u}, + {{13u, 9u, 42u, 43u}, 10752u, -1, 0u}, + {{17u, 11u, 44u, 45u}, 10753u, -1, 0u}, + {{28u, 32u, 47u, 46u}, 10754u, -1, 0u}, + {{30u, 36u, 49u, 48u}, 10755u, -1, 0u}, + {{52u, 53u, 51u, 50u}, 8304u, 28, 0u}, + {{57u, 56u, 54u, 55u}, 8304u, 26, 0u}, + {{61u, 60u, 58u, 59u}, 8304u, 25, 0u}, + {{65u, 64u, 62u, 63u}, 8304u, 27, 0u}, + {{68u, 66u, 67u, 69u}, 43145u, -1, 0u}, + {{73u, 72u, 70u, 71u}, 43145u, -1, 0u}, + {{19u, 74u, 37u, 23u}, 37127u, -1, 0u}, + {{75u, 0u, 4u, 18u}, 33031u, -1, 0u}, + {{76u, 18u, 17u, 79u}, 33067u, -1, 0u}, + {{37u, 77u, 81u, 36u}, 33045u, -1, 0u}, + {{79u, 17u, 12u, 78u}, 308u, -1, 0u}, + {{12u, 31u, 80u, 78u}, 112u, -1, 0u}, + {{36u, 81u, 80u, 31u}, 286u, -1, 0u}, + {{77u, 76u, 79u, 81u}, 33044u, -1, 0u}, + {{81u, 79u, 78u, 80u}, 33289u, -1, 0u}, + {{76u, 77u, 37u, 18u}, 273u, -1, 0u}, + {{74u, 75u, 18u, 37u}, 33029u, 49, 0u}, + {{19u, 0u, 75u, 74u}, 264u, -1, 0u}, + {{0u, 19u, 20u, 1u}, 262403u, -1, 0u}, + {{39u, 41u, 83u, 82u}, 41233u, -1, 0u}, + {{86u, 87u, 84u, 85u}, 41233u, 18, 0u}}; //------------------------------------------------------------------------------------------------- -//000AC804 -unsigned int xreise_backs[] = { 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000AC804 +unsigned int xreise_backs[] = { + 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, 1281, 1281, 1281, 1281, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AC8CC -int xreise_places[] = { 3, 22, 56, 50 }; +// 000AC8CC +int xreise_places[] = {3, 22, 56, 50}; //------------------------------------------------------------------------------------------------- -//000AC8DC -tAnimation xreise_anms[10] = -{ - { 5u, { 7442u, 7443u, 7433u, 7434u, 7424u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 7437u, 7438u, 7435u, 7436u, 7426u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 3346u, 3347u, 3337u, 3338u, 3328u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 5u, { 3341u, 3342u, 3339u, 3340u, 3330u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 302u, 283u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 2u, { 285u, 284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000AC8DC +tAnimation xreise_anms[10] = { + {5u, + {7442u, 7443u, 7433u, 7434u, 7424u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {7437u, 7438u, 7435u, 7436u, 7426u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {3346u, 3347u, 3337u, 3338u, 3328u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {5u, + {3341u, 3342u, 3339u, 3340u, 3330u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, + 0u}}, + {2u, {302u, 283u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {297u, 300u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {306u, 309u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {279u, 271u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {288u, 272u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {2u, {285u, 284u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000ACB84 +// 000ACB84 char CarNames[14][20] = { - "Fouette 270 ZX", - "DeSilva 511 GTi", - "Errant V8 GT", - "Celerity MKII", - "Ninjato", - "Chimera Turbo SE", - "KLR 330", - "Merkur GT", - "Thunderbolt", - "The Rocket", - "The Invertor", - "The Kangaroo", - "LV 1973", - "CHRISTINE" -}; + "Fouette 270 ZX", "DeSilva 511 GTi", "Errant V8 GT", "Celerity MKII", + "Ninjato", "Chimera Turbo SE", "KLR 330", "Merkur GT", + "Thunderbolt", "The Rocket", "The Invertor", "The Kangaroo", + "LV 1973", "CHRISTINE"}; //------------------------------------------------------------------------------------------------- -//000ACC9C -char CompanyNames[14][20] = { - "AUTO ARIEL", - "DESILVA", - "PULSE ENGINEERING", - "GLOBAL", - "MILLION PLUS", - "MISSION MOTORS", - "ZIZIN", - "REISE WAGON", - "DRH MOTORS", - "GODLEY PLC", - "GSS AUTOS", - "CROSS CARS", - "VRANIC", - "DEATH MOTORS" -}; +// 000ACC9C +char CompanyNames[14][20] = {"AUTO ARIEL", "DESILVA", "PULSE ENGINEERING", + "GLOBAL", "MILLION PLUS", "MISSION MOTORS", + "ZIZIN", "REISE WAGON", "DRH MOTORS", + "GODLEY PLC", "GSS AUTOS", "CROSS CARS", + "VRANIC", "DEATH MOTORS"}; //------------------------------------------------------------------------------------------------- -//000ACDB4 -tCarDesign CarDesigns[] = -{ - { - 50u, - 86u, - 0u, - 0u, - &xauto_pols[0], - &xauto_coords[0], - &xauto_backs[0], - CAR_AUTO, - &xauto_places[0], - &xauto_anms[0] - }, - { - 50u, - 88u, - 0u, - 0u, - &xdesilva_pols[0], - &xdesilva_coords[0], - &xdesilva_backs[0], - CAR_DESILVA, - &xdesilva_places[0], - &xdesilva_anms[0] - }, - { - 50u, - 86u, - 0u, - 0u, - &xpulse_pols[0], - &xpulse_coords[0], - &xpulse_backs[0], - CAR_PULSE, - &xpulse_places[0], - &xpulse_anms[0] - }, - { - 50u, - 86u, - 0u, - 0u, - &xglobal_pols[0], - &xglobal_coords[0], - &xglobal_backs[0], - CAR_GLOBAL, - &xglobal_places[0], - &xglobal_anms[0] - }, - { - 47u, - 86u, - 0u, - 0u, - &xmillion_pols[0], - &xmillion_coords[0], - &xmillion_backs[0], - CAR_MILLION, - &xmillion_places[0], - &xmillion_anms[0] - }, - { - 47u, - 88u, - 0u, - 0u, - &xmission_pols[0], - &xmission_coords[0], - &xmission_backs[0], - CAR_MISSION, - &xmission_places[0], - &xmission_anms[0] - }, - { - 50u, - 86u, - 0u, - 0u, - &xzizin_pols[0], - &xzizin_coords[0], - &xzizin_backs[0], - CAR_ZIZIN, - &xzizin_places[0], - &xzizin_anms[0] - }, - { - 50u, - 88u, - 0u, - 0u, - &xreise_pols[0], - &xreise_coords[0], - &xreise_backs[0], - CAR_REISE, - &xreise_places[0], - &xreise_anms[0] - }, - { - 50u, - 86u, - 0u, - 0u, - &xzizin_pols[0], - &xzizin_coords[0], - &xzizin_backs[0], - CAR_ZIZIN, - &xzizin_places[0], - &xzizin_anms[0] - }, - { - 50u, - 86u, - 0u, - 0u, - &xauto_pols[0], - &xauto_coords[0], - &xauto_backs[0], - CAR_AUTO, - &xauto_places[0], - &xauto_anms[0] - }, - { - 50u, - 86u, - 0u, - 0u, - &xpulse_pols[0], - &xpulse_coords[0], - &xpulse_backs[0], - CAR_PULSE, - &xpulse_places[0], - &xpulse_anms[0] - }, - { - 50u, - 88u, - 0u, - 0u, - &xreise_pols[0], - &xreise_coords[0], - &xreise_backs[0], - CAR_REISE, - &xreise_places[0], - &xreise_anms[0] - }, - { - 80u, - 120u, - 0u, - 0u, - &f1wack_pols[0], - &f1wack_coords[0], - &f1wack_backs[0], - CAR_F1WACK, - &f1wack_places[0], - (tAnimation *)-1 //0xFFFFFFFF - }, - { - 50u, - 88u, - 0u, - 0u, - &xreise_pols[0], - &xreise_coords[0], - &xreise_backs[0], - CAR_DEATH, - &xreise_places[0], - &xreise_anms[0] - } -}; +// 000ACDB4 +tCarDesign CarDesigns[] = { + {50u, 86u, 0u, 0u, &xauto_pols[0], &xauto_coords[0], &xauto_backs[0], + CAR_AUTO, &xauto_places[0], &xauto_anms[0]}, + {50u, 88u, 0u, 0u, &xdesilva_pols[0], &xdesilva_coords[0], + &xdesilva_backs[0], CAR_DESILVA, &xdesilva_places[0], &xdesilva_anms[0]}, + {50u, 86u, 0u, 0u, &xpulse_pols[0], &xpulse_coords[0], &xpulse_backs[0], + CAR_PULSE, &xpulse_places[0], &xpulse_anms[0]}, + {50u, 86u, 0u, 0u, &xglobal_pols[0], &xglobal_coords[0], &xglobal_backs[0], + CAR_GLOBAL, &xglobal_places[0], &xglobal_anms[0]}, + {47u, 86u, 0u, 0u, &xmillion_pols[0], &xmillion_coords[0], + &xmillion_backs[0], CAR_MILLION, &xmillion_places[0], &xmillion_anms[0]}, + {47u, 88u, 0u, 0u, &xmission_pols[0], &xmission_coords[0], + &xmission_backs[0], CAR_MISSION, &xmission_places[0], &xmission_anms[0]}, + {50u, 86u, 0u, 0u, &xzizin_pols[0], &xzizin_coords[0], &xzizin_backs[0], + CAR_ZIZIN, &xzizin_places[0], &xzizin_anms[0]}, + {50u, 88u, 0u, 0u, &xreise_pols[0], &xreise_coords[0], &xreise_backs[0], + CAR_REISE, &xreise_places[0], &xreise_anms[0]}, + {50u, 86u, 0u, 0u, &xzizin_pols[0], &xzizin_coords[0], &xzizin_backs[0], + CAR_ZIZIN, &xzizin_places[0], &xzizin_anms[0]}, + {50u, 86u, 0u, 0u, &xauto_pols[0], &xauto_coords[0], &xauto_backs[0], + CAR_AUTO, &xauto_places[0], &xauto_anms[0]}, + {50u, 86u, 0u, 0u, &xpulse_pols[0], &xpulse_coords[0], &xpulse_backs[0], + CAR_PULSE, &xpulse_places[0], &xpulse_anms[0]}, + {50u, 88u, 0u, 0u, &xreise_pols[0], &xreise_coords[0], &xreise_backs[0], + CAR_REISE, &xreise_places[0], &xreise_anms[0]}, + { + 80u, 120u, 0u, 0u, &f1wack_pols[0], &f1wack_coords[0], &f1wack_backs[0], + CAR_F1WACK, &f1wack_places[0], + (tAnimation *)-1 // 0xFFFFFFFF + }, + {50u, 88u, 0u, 0u, &xreise_pols[0], &xreise_coords[0], &xreise_backs[0], + CAR_DEATH, &xreise_places[0], &xreise_anms[0]}}; //------------------------------------------------------------------------------------------------- -//000ACF3C -char car_texture_names[11][256] = -{ - "track0.drh", - "xauto.bm", - "xdesilva.bm", - "xpulse.bm", - "xglobal.bm", - "xmillion.bm", - "xmission.bm", - "xzizin.bm", - "xreise.bm", - "red28.bm", - "death.bm" -}; +// 000ACF3C +char car_texture_names[11][256] = {"track0.drh", "xauto.bm", "xdesilva.bm", + "xpulse.bm", "xglobal.bm", "xmillion.bm", + "xmission.bm", "xzizin.bm", "xreise.bm", + "red28.bm", "death.bm"}; //------------------------------------------------------------------------------------------------- -//000ADA3C -int Drivers_Car[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }; +// 000ADA3C +int Drivers_Car[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; //------------------------------------------------------------------------------------------------- -//000ADA7C -tCarColorRemap car_flat_remap[16] = -{ - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0CF, 0x0C3 }, - { 0x0E7, 0x0AB }, - { 0x0E7, 0x0FF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0C3, 0x0AB }, - { 0x8F, 0x0DB }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF }, - { 0x0FFFFFFFF, 0x0FFFFFFFF } -}; +// 000ADA7C +tCarColorRemap car_flat_remap[16] = {{0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0CF, 0x0C3}, + {0x0E7, 0x0AB}, + {0x0E7, 0x0FF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0C3, 0x0AB}, + {0x8F, 0x0DB}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}, + {0x0FFFFFFFF, 0x0FFFFFFFF}}; //------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/PROJECTS/ROLLER/carplans.h b/PROJECTS/ROLLER/carplans.h index a03a90fc..80aec52f 100644 --- a/PROJECTS/ROLLER/carplans.h +++ b/PROJECTS/ROLLER/carplans.h @@ -4,16 +4,14 @@ #include "types.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint32 uiCount; uint32 framesAy[16]; } tAnimation; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint8 verts[4]; uint32 uiTex; int16 nNextPolIdx; @@ -22,8 +20,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint8 byNumPols; uint8 byNumCoords; uint8 byUnk3; @@ -38,8 +35,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint32 uiColorFrom; uint32 uiColorTo; } tCarColorRemap; @@ -120,10 +116,12 @@ extern tAnimation xreise_anms[]; extern char CarNames[14][20]; extern char CompanyNames[14][20]; -extern tCarDesign CarDesigns[]; +extern tCarDesign CarDesigns[]; extern char car_texture_names[11][256]; extern int Drivers_Car[16]; -extern tCarColorRemap car_flat_remap[]; //this is used to remap the palette indices used to color the mirrors for the advanced car set - +extern tCarColorRemap + car_flat_remap[]; // this is used to remap the palette indices used to color + // the mirrors for the advanced car set + //------------------------------------------------------------------------------------------------- #endif \ No newline at end of file diff --git a/PROJECTS/ROLLER/cdx.c b/PROJECTS/ROLLER/cdx.c index c44aed63..0bc5475e 100644 --- a/PROJECTS/ROLLER/cdx.c +++ b/PROJECTS/ROLLER/cdx.c @@ -18,30 +18,29 @@ #endif //------------------------------------------------------------------------------------------------- -int track_playing = 0; //000A7510 -int last_audio_track = 0; //000A7514 -int numCDdrives = 0; //000A7518 -int firstCDdrive; //001A1B4C -int last_track; //001A1B50 -int first_track; //001A1B54 -int sector_size; //001A1B58 -int tracklengths[99]; //001A1B5C -int track_duration; //001A1CE8 -void *iobuffer; //001A1CEC -void *cdbuffer; //001A1CF0 -int trackstarts[99]; //001A1CF8 -int16 ioselector; //001A1E88 -int16 cdselector; //001A1E8C -tAudioControlParams playControl; //001A1EB8 renamed from "play" by ROLLER -tIOControlBlock io; //001A1ED0 -DPMI_RMI RMIcd; //001A1EEC -char volscale[129]; //001A1F1E -int drive; //001A1F9F +int track_playing = 0; // 000A7510 +int last_audio_track = 0; // 000A7514 +int numCDdrives = 0; // 000A7518 +int firstCDdrive; // 001A1B4C +int last_track; // 001A1B50 +int first_track; // 001A1B54 +int sector_size; // 001A1B58 +int tracklengths[99]; // 001A1B5C +int track_duration; // 001A1CE8 +void *iobuffer; // 001A1CEC +void *cdbuffer; // 001A1CF0 +int trackstarts[99]; // 001A1CF8 +int16 ioselector; // 001A1E88 +int16 cdselector; // 001A1E8C +tAudioControlParams playControl; // 001A1EB8 renamed from "play" by ROLLER +tIOControlBlock io; // 001A1ED0 +DPMI_RMI RMIcd; // 001A1EEC +char volscale[129]; // 001A1F1E +int drive; // 001A1F9F //------------------------------------------------------------------------------------------------- -//00074C80 -int FinishedAudio() -{ +// 00074C80 +int FinishedAudio() { tAudioFinished audioFinished; // [esp+0h] [ebp-14h] BYREF audioFinished.byCommand = 12; @@ -56,33 +55,27 @@ int FinishedAudio() } //------------------------------------------------------------------------------------------------- -//00074CC0 -void OpenDoor() -{ - uint8 byCommand = 0; // Open door command +// 00074CC0 +void OpenDoor() { + uint8 byCommand = 0; // Open door command WriteIOCTL(0x0C, 1, &byCommand); } //------------------------------------------------------------------------------------------------- -//00074CF0 -void CloseDoor() -{ - uint8 byCommand = 5; // Close door command +// 00074CF0 +void CloseDoor() { + uint8 byCommand = 5; // Close door command WriteIOCTL(0xCu, 1u, &byCommand); ResetDrive(); } //------------------------------------------------------------------------------------------------- -//00074D10 -void ResetDrive() -{ - ; -} +// 00074D10 +void ResetDrive() { ; } //------------------------------------------------------------------------------------------------- -//00074D20 -void GetCDStatus() -{ +// 00074D20 +void GetCDStatus() { uint8 szBuf[16]; // [esp+0h] [ebp-10h] BYREF memset(szBuf, 0, sizeof(szBuf)); @@ -129,9 +122,8 @@ void GetCDStatus() } //------------------------------------------------------------------------------------------------- -//00074E60 -void WriteIOCTL(uint8 bySubCommand, unsigned int uiSize, void *pBuffer) -{ +// 00074E60 +void WriteIOCTL(uint8 bySubCommand, unsigned int uiSize, void *pBuffer) { io.bySubCommand = bySubCommand; io.unFlags2 = 0; io.unCount = 0; @@ -155,113 +147,115 @@ void WriteIOCTL(uint8 bySubCommand, unsigned int uiSize, void *pBuffer) // Prepare real mode call structure memset(&RMIcd, 0, sizeof(RMIcd)); - RMIcd.ecx = (uint8)drive; // CD drive number + RMIcd.ecx = (uint8)drive; // CD drive number RMIcd.ebx = 0; - RMIcd.es = (uint16)(((int64)iobuffer + ((int64)iobuffer < 0 ? 15 : 0)) >> 4); // segment_of(iobuffer) - RMIcd.eax = 0x1510; // (Function: Get CD-ROM Drive Information) - intRM(0x2Fu); // Get address of the driver for a specific CD-ROM drive + RMIcd.es = (uint16)(((int64)iobuffer + ((int64)iobuffer < 0 ? 15 : 0)) >> + 4); // segment_of(iobuffer) + RMIcd.eax = 0x1510; // (Function: Get CD-ROM Drive Information) + intRM(0x2Fu); // Get address of the driver for a specific CD-ROM drive memcpy(pBuffer, cdbuffer, uiSize); memcpy(&io, iobuffer, sizeof(tIOControlBlock)); } //------------------------------------------------------------------------------------------------- -//00074FA0 -void *AllocDOSMemory(int iSizeBytes, int16 *pOutSegment) -{ +// 00074FA0 +void *AllocDOSMemory(int iSizeBytes, int16 *pOutSegment) { pOutSegment = NULL; return malloc(iSizeBytes); - //memset(&sregs, 0, sizeof(sregs)); // clear sregs - //regs.w.ax = 0x100; // allocate DOS memory block - //regs.w.bx = ((iSizeBytes - (__CFSHL__(iSizeBytes >> 31, 4) + 16 * (iSizeBytes >> 31))) >> 4) + 1;// compute number of 16-byte paragraphs needed to hold iSizeBytes - //int386x(0x31, ®s, ®s, &sregs); + // memset(&sregs, 0, sizeof(sregs)); // clear sregs + // regs.w.ax = 0x100; // allocate DOS memory block + // regs.w.bx = ((iSizeBytes - (__CFSHL__(iSizeBytes >> 31, 4) + 16 * + // (iSizeBytes >> 31))) >> 4) + 1;// compute number of 16-byte paragraphs + // needed to hold iSizeBytes int386x(0x31, ®s, ®s, &sregs); // //// if carry flag is set, alloc failed - //if (regs.x.cflag) { - // *(_DWORD *)pOutSegment = -1; - // return 0; - //} else { - // // alloc succeeded - // *(_DWORD *)pOutSegment = regs.w.dx; - // return (void *)(16 * regs.w.ax); - //} + // if (regs.x.cflag) { + // *(_DWORD *)pOutSegment = -1; + // return 0; + // } else { + // // alloc succeeded + // *(_DWORD *)pOutSegment = regs.w.dx; + // return (void *)(16 * regs.w.ax); + // } } //------------------------------------------------------------------------------------------------- -//00075020 -void GetAudioInfo() -{ +// 00075020 +void GetAudioInfo() { ROLLERGetAudioInfo(); - //uint8 buffer[7]; - //uint32 track_sectors[100]; // Temporary storage for track sectors (including lead-out) + // uint8 buffer[7]; + // uint32 track_sectors[100]; // Temporary storage for track sectors + // (including lead-out) // //// Read TOC header to get first/last tracks and lead-out position - //buffer[0] = 0x0A; - //WriteIOCTL(3, 7, buffer); + // buffer[0] = 0x0A; + // WriteIOCTL(3, 7, buffer); // - //uint32 uiLeadOutPacked = *(uint32 *)&buffer[3]; // Packed MSF format + // uint32 uiLeadOutPacked = *(uint32 *)&buffer[3]; // Packed MSF format // //// Store first/last track numbers in global variables - //first_track = buffer[1]; - //last_track = buffer[2]; - //if (last_track >= 99) - // return; + // first_track = buffer[1]; + // last_track = buffer[2]; + // if (last_track >= 99) + // return; // //// Process audio tracks - //if (first_track <= last_track) { - // for (uint8 byTrack = first_track; byTrack <= last_track; byTrack++) { - // // Read track start position - // buffer[0] = 0x0B; - // buffer[1] = byTrack; - // WriteIOCTL(3, 7, buffer); - // uint32 uiTrackPacked = *(uint32 *)&buffer[2]; // Packed MSF format + // if (first_track <= last_track) { + // for (uint8 byTrack = first_track; byTrack <= last_track; byTrack++) { + // // Read track start position + // buffer[0] = 0x0B; + // buffer[1] = byTrack; + // WriteIOCTL(3, 7, buffer); + // uint32 uiTrackPacked = *(uint32 *)&buffer[2]; // Packed MSF format // - // // Convert MSF to sector number (minutes/seconds/frames) - // uint32 uiMinutes = (uiTrackPacked >> 16) & 0xFF; - // uint32 uiSeconds = (uiTrackPacked >> 8) & 0xFF; - // uint32 uiFrames = uiTrackPacked & 0xFF; - // uint32 uiSector = (uiMinutes * 4500) + (uiSeconds * 75) + uiFrames - 150; + // // Convert MSF to sector number (minutes/seconds/frames) + // uint32 uiMinutes = (uiTrackPacked >> 16) & 0xFF; + // uint32 uiSeconds = (uiTrackPacked >> 8) & 0xFF; + // uint32 uiFrames = uiTrackPacked & 0xFF; + // uint32 uiSector = (uiMinutes * 4500) + (uiSeconds * 75) + uiFrames - + // 150; // - // // Store in global trackstarts array (indexed by track number) - // trackstarts[byTrack] = uiSector; - // // Cache sector in local array for length calculation - // track_sectors[byTrack] = uiSector; - // } - //} + // // Store in global trackstarts array (indexed by track number) + // trackstarts[byTrack] = uiSector; + // // Cache sector in local array for length calculation + // track_sectors[byTrack] = uiSector; + // } + // } // //// Convert lead-out MSF to sectors - //uint32 uiLeadMin = (uiLeadOutPacked >> 16) & 0xFF; - //uint32 uiLeadSec = (uiLeadOutPacked >> 8) & 0xFF; - //uint32 uiLeadFrame = uiLeadOutPacked & 0xFF; - //uint32 uiLeadOutSector = (uiLeadMin * 4500) + (uiLeadSec * 75) + uiLeadFrame - 150; - //track_sectors[last_track + 1] = uiLeadOutSector; // Store after last track + // uint32 uiLeadMin = (uiLeadOutPacked >> 16) & 0xFF; + // uint32 uiLeadSec = (uiLeadOutPacked >> 8) & 0xFF; + // uint32 uiLeadFrame = uiLeadOutPacked & 0xFF; + // uint32 uiLeadOutSector = (uiLeadMin * 4500) + (uiLeadSec * 75) + + // uiLeadFrame - 150; track_sectors[last_track + 1] = uiLeadOutSector; // + // Store after last track // //// Calculate track lengths - //if (first_track <= last_track) { - // for (uint8 byTrack = first_track; byTrack <= last_track; byTrack++) { - // // Track length = next start position - current start position - // uint32 uiLength = track_sectors[byTrack + 1] - track_sectors[byTrack]; - // // Store in global tracklengths array (indexed by track number) - // tracklengths[byTrack] = uiLength; - // } - //} + // if (first_track <= last_track) { + // for (uint8 byTrack = first_track; byTrack <= last_track; byTrack++) { + // // Track length = next start position - current start position + // uint32 uiLength = track_sectors[byTrack + 1] - track_sectors[byTrack]; + // // Store in global tracklengths array (indexed by track number) + // tracklengths[byTrack] = uiLength; + // } + // } } //------------------------------------------------------------------------------------------------- -//000751A0 -void PlayTrack(int iTrack) -{ +// 000751A0 +void PlayTrack(int iTrack) { ROLLERPlayTrack(iTrack); g_bRepeat = true; //// Prepare audio control structure - //playControl.byPlayFlag = 1; - //playControl.uiStartSector = trackstarts[iTrack]; - //playControl.uiSectorCount = tracklengths[iTrack]; + // playControl.byPlayFlag = 1; + // playControl.uiStartSector = trackstarts[iTrack]; + // playControl.uiSectorCount = tracklengths[iTrack]; // //// Execute audio command - //AudioIOCTL(0x84u); - + // AudioIOCTL(0x84u); + // Update global state track_playing = -1; last_audio_track = iTrack; @@ -269,86 +263,82 @@ void PlayTrack(int iTrack) } //------------------------------------------------------------------------------------------------- -//000751F0 -void PlayTrack4(int iStartTrack) -{ +// 000751F0 +void PlayTrack4(int iStartTrack) { ROLLERPlayTrack4(iStartTrack); // Calculate total duration of four tracks - //uint32 uiTotalDuration = tracklengths[iStartTrack] + - // tracklengths[iStartTrack + 1] + tracklengths[iStartTrack + 2] + tracklengths[iStartTrack + 3]; + // uint32 uiTotalDuration = tracklengths[iStartTrack] + + // tracklengths[iStartTrack + 1] + tracklengths[iStartTrack + 2] + + // tracklengths[iStartTrack + 3]; // //// Prepare audio control structure - //playControl.byPlayFlag = 1; // Play command flag - //playControl.uiStartSector = trackstarts[iStartTrack]; // Start sector - //playControl.uiSectorCount = uiTotalDuration; // Sector count + // playControl.byPlayFlag = 1; // Play command flag + // playControl.uiStartSector = trackstarts[iStartTrack]; // Start sector + // playControl.uiSectorCount = uiTotalDuration; // Sector count // //// Execute audio command - //AudioIOCTL(0x84); // 0x84 = Play Audio command + // AudioIOCTL(0x84); // 0x84 = Play Audio command // //// Update global state - //track_duration = uiTotalDuration; + // track_duration = uiTotalDuration; track_playing = -1; // Indicate track is starting last_audio_track = iStartTrack; } //------------------------------------------------------------------------------------------------- -//00075260 -void RepeatTrack() -{ +// 00075260 +void RepeatTrack() { g_bRepeat = true; - //playControl.byPlayFlag = 1; - //playControl.uiStartSector = trackstarts[last_audio_track]; - //playControl.uiSectorCount = track_duration; - //AudioIOCTL(0x84u); + // playControl.byPlayFlag = 1; + // playControl.uiStartSector = trackstarts[last_audio_track]; + // playControl.uiSectorCount = track_duration; + // AudioIOCTL(0x84u); track_playing = -1; } //------------------------------------------------------------------------------------------------- -//000752A0 -void StopTrack() -{ +// 000752A0 +void StopTrack() { ROLLERStopTrack(); - //AudioIOCTL(0x85); //stop track + // AudioIOCTL(0x85); //stop track track_playing = 0; } //------------------------------------------------------------------------------------------------- -//000752E0 -void SetAudioVolume(int iVolume) -{ +// 000752E0 +void SetAudioVolume(int iVolume) { int iUseVolume; // eax - //tVolumeControl volCtrl; // [esp+0h] [ebp-14h] BYREF - + // tVolumeControl volCtrl; // [esp+0h] [ebp-14h] BYREF + // Double the volume level (range expansion) iUseVolume = 2 * iVolume; - + // Clamp volume to [1, 255] if (iUseVolume < 1) iUseVolume = 1; if (iUseVolume > 255) iUseVolume = 255; - + ROLLERSetAudioVolume(iUseVolume); //// Prepare volume control struct - //volCtrl.byVolChMaster = iUseVolume; - //volCtrl.byVolLeft = iUseVolume; - //volCtrl.byVolRight = iUseVolume; - //volCtrl.unused = iUseVolume; // set but ignored? - //volCtrl.byCommand = 3; - //volCtrl.byChannelBase = 0; - //volCtrl.byChannelLeft = 1; - //volCtrl.byChannelRight = 2; - //volCtrl.byTerminator = 3; + // volCtrl.byVolChMaster = iUseVolume; + // volCtrl.byVolLeft = iUseVolume; + // volCtrl.byVolRight = iUseVolume; + // volCtrl.unused = iUseVolume; // set but ignored? + // volCtrl.byCommand = 3; + // volCtrl.byChannelBase = 0; + // volCtrl.byChannelLeft = 1; + // volCtrl.byChannelRight = 2; + // volCtrl.byTerminator = 3; // //// Send volume command - //WriteIOCTL(0xCu, 9u, &volCtrl); + // WriteIOCTL(0xCu, 9u, &volCtrl); } //------------------------------------------------------------------------------------------------- -//00075340 -void AudioIOCTL(uint8 bySubcommand) -{ +// 00075340 +void AudioIOCTL(uint8 bySubcommand) { // Prepare audio control structure playControl.byCommand = 0x16; // Audio command group playControl.bySubcommand = bySubcommand; // Specific audio function @@ -360,49 +350,46 @@ void AudioIOCTL(uint8 bySubcommand) // Prepare DPMI request structure memset(&RMIcd, 0, sizeof(DPMI_RMI)); - RMIcd.eax = 0x1510; // CD-ROM IOCTL function - RMIcd.ecx = drive; // Current CD-ROM drive + RMIcd.eax = 0x1510; // CD-ROM IOCTL function + RMIcd.ecx = drive; // Current CD-ROM drive // Convert linear address to segment:offset format uint32 uiLinearAddr = (uint32)(uint64)iobuffer; - uint16 unSegment = (uiLinearAddr >> 4) & 0xFFFF; // Segment calculation - RMIcd.es = unSegment; // Set segment register - RMIcd.ebx = 0; // Offset = 0 + uint16 unSegment = (uiLinearAddr >> 4) & 0xFFFF; // Segment calculation + RMIcd.es = unSegment; // Set segment register + RMIcd.ebx = 0; // Offset = 0 // Execute real-mode interrupt - intRM(0x2F); // CD-ROM driver interrupt + intRM(0x2F); // CD-ROM driver interrupt // Copy results back from I/O buffer memcpy(&playControl, iobuffer, sizeof(tAudioControlParams)); } //------------------------------------------------------------------------------------------------- -//00075400 -void FreeDOSMemory(uint16 unSegment) -{ - //memset(&sregs, 0, sizeof(sregs)); - //regs.w.dx = nSegment; - //regs.w.ax = 0x101; - //int386x(0x31, ®s, ®s, &sregs); +// 00075400 +void FreeDOSMemory(uint16 unSegment) { + // memset(&sregs, 0, sizeof(sregs)); + // regs.w.dx = nSegment; + // regs.w.ax = 0x101; + // int386x(0x31, ®s, ®s, &sregs); } //------------------------------------------------------------------------------------------------- -//00075450 -void intRM(uint8 byInterruptNumber) -{ +// 00075450 +void intRM(uint8 byInterruptNumber) { /* - regs.w.ax = 768; // DPMI: Simulate Real Mode Interrupt - regs.w.bx = byInterruptNumber; // Interrupt number to simulate - regs.w.cx = 0; // Reserved - sregs.es = __DS__; // Segment of RMIcd - regs.x.edi = (unsigned int)&RMIcd; // Offset of RMIcd (real mode register set) + regs.w.ax = 768; // DPMI: Simulate Real Mode + Interrupt regs.w.bx = byInterruptNumber; // Interrupt number to + simulate regs.w.cx = 0; // Reserved sregs.es = + __DS__; // Segment of RMIcd regs.x.edi = (unsigned + int)&RMIcd; // Offset of RMIcd (real mode register set) int386x(0x31, ®s, ®s, &sregs);*/ } //------------------------------------------------------------------------------------------------- -//000754B0 -void GetFirstCDDrive() -{ +// 000754B0 +void GetFirstCDDrive() { firstCDdrive = -1; #if defined(IS_WINDOWS) uint32 uiDrives = GetLogicalDrives(); @@ -414,7 +401,7 @@ void GetFirstCDDrive() if (!(uiDrives & (1 << (cDrive - 'A')))) continue; - char szRootPath[] = { cDrive, ':', '\\', '\0' }; + char szRootPath[] = {cDrive, ':', '\\', '\0'}; uint32 uiType = GetDriveTypeA(szRootPath); if (uiType == DRIVE_CDROM) { if (firstCDdrive == -1) { @@ -428,7 +415,7 @@ void GetFirstCDDrive() numCDdrives = iCount; #elif defined(IS_LINUX) const char *szDevPrefix = "/dev/"; - const char *targets[] = { "cdrom", "sr0", "sr1", "sr2", "sr3", NULL }; + const char *targets[] = {"cdrom", "sr0", "sr1", "sr2", "sr3", NULL}; int iCount = 0; for (int i = 0; targets[i] != NULL; ++i) { @@ -457,9 +444,8 @@ void GetFirstCDDrive() } //------------------------------------------------------------------------------------------------- -//00075520 -void cdxinit() -{ +// 00075520 +void cdxinit() { iobuffer = AllocDOSMemory(256, &ioselector); cdbuffer = AllocDOSMemory(1024, &cdselector); @@ -471,14 +457,13 @@ void cdxinit() float fPow = (float)dPow; volscale[i] = (uint8)round(fPow); } else { - volscale[i] = 127; // Cap to 127 if over the limit + volscale[i] = 127; // Cap to 127 if over the limit } } } //------------------------------------------------------------------------------------------------- -//000755D0 -void cdxdone() -{ +// 000755D0 +void cdxdone() { free(cdbuffer); free(iobuffer); cdbuffer = NULL; @@ -486,49 +471,47 @@ void cdxdone() CleanupAudioCD(); - //memset(&sregs, 0, sizeof(sregs)); - //regs.w.dx = cdselector; - //regs.w.ax = 257; - //int386x(49, ®s, ®s, &sregs); - //memset(&sregs, 0, sizeof(sregs)); - //regs.w.dx = ioselector; - //regs.w.ax = 257; - //int386x(49, ®s, ®s, &sregs); + // memset(&sregs, 0, sizeof(sregs)); + // regs.w.dx = cdselector; + // regs.w.ax = 257; + // int386x(49, ®s, ®s, &sregs); + // memset(&sregs, 0, sizeof(sregs)); + // regs.w.dx = ioselector; + // regs.w.ax = 257; + // int386x(49, ®s, ®s, &sregs); } //------------------------------------------------------------------------------------------------- -//00075660 -int cdpresent() -{ - //added by ROLLER +// 00075660 +int cdpresent() { + // added by ROLLER return (g_iNumTracks > 0) ? -1 : 0; - //int iSuccess = 0; + // int iSuccess = 0; // - //for (int i = 0; i < numCDdrives; ++i) { - // if (!iSuccess) - // iSuccess = checkCD(i + firstCDdrive); - //} - //return iSuccess; + // for (int i = 0; i < numCDdrives; ++i) { + // if (!iSuccess) + // iSuccess = checkCD(i + firstCDdrive); + // } + // return iSuccess; } //------------------------------------------------------------------------------------------------- -//00075690 -int checkCD(uint8 byDriveIdx) -{ +// 00075690 +int checkCD(uint8 byDriveIdx) { char szFilename[128]; char buffer[20]; FILE *fp; uint32 uiBytesRead; // Construct filename - //TODO: linux compatibility + // TODO: linux compatibility sprintf(szFilename, "%c:/FATAL.EXE", byDriveIdx + 'A'); // Try to open the file fp = ROLLERfopen(szFilename, "rb"); if (!fp) { - //added by ROLLER, check for WHIP.EXE too + // added by ROLLER, check for WHIP.EXE too sprintf(szFilename, "%c:/WHIP.EXE", byDriveIdx + 'A'); fp = ROLLERfopen(szFilename, "rb"); if (!fp) @@ -544,9 +527,8 @@ int checkCD(uint8 byDriveIdx) } //------------------------------------------------------------------------------------------------- -//000756F0 -int criticalhandler() -{ +// 000756F0 +int criticalhandler() { return 3; /* _BYTE retaddr[8]; // [esp+0h] [ebp+0h] diff --git a/PROJECTS/ROLLER/cdx.h b/PROJECTS/ROLLER/cdx.h index 6ed3d659..4b0213ae 100644 --- a/PROJECTS/ROLLER/cdx.h +++ b/PROJECTS/ROLLER/cdx.h @@ -6,8 +6,7 @@ //------------------------------------------------------------------------------------------------- #pragma pack(push, 1) -typedef struct -{ +typedef struct { uint8 byCommand; uint8 byFlags1; uint8 bySubCommand; @@ -25,8 +24,7 @@ typedef struct //------------------------------------------------------------------------------------------------- #pragma pack(push, 1) -typedef struct -{ +typedef struct { uint8 byCommand; uint8 byParam0; uint8 bySubcommand; @@ -40,8 +38,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint8 byCommand; uint8 byChannelBase; uint8 byVolChMaster; @@ -56,8 +53,7 @@ typedef struct //------------------------------------------------------------------------------------------------- #pragma pack(push, 1) -typedef struct -{ +typedef struct { uint8 byCommand; uint8 byFlags1; uint8 bySubCommand; diff --git a/PROJECTS/ROLLER/colision.c b/PROJECTS/ROLLER/colision.c index aa09321c..7bae4ec5 100644 --- a/PROJECTS/ROLLER/colision.c +++ b/PROJECTS/ROLLER/colision.c @@ -7,41 +7,56 @@ #include //------------------------------------------------------------------------------------------------- -float damage_levels[4] = { 1.0, 2.0, 4.0, 8.0 }; //000A639C -float coldist[33][33]; //00188840 -int damage_level; //00189944 +float damage_levels[4] = {1.0, 2.0, 4.0, 8.0}; // 000A639C +float coldist[33][33]; // 00188840 +int damage_level; // 00189944 //------------------------------------------------------------------------------------------------- -//0005F8F0 -void testcollisions() -{ - int iSecondCarIdx; // esi - tCar *pSecondCar; // ecx +// 0005F8F0 +void testcollisions() { + int iSecondCarIdx; // esi + tCar *pSecondCar; // ecx int iChunkDistance; // ebx tCar *pTrailingCar; // edx - tCar *pLeadingCar; // eax - int iFirstCarIdx; // [esp+0h] [ebp-20h] + tCar *pLeadingCar; // eax + int iFirstCarIdx; // [esp+0h] [ebp-20h] int iCurrentCarIdx; // [esp+4h] [ebp-1Ch] - iFirstCarIdx = 0; // Initialize first car index for outer loop + iFirstCarIdx = 0; // Initialize first car index for outer loop if (numcars > 0) { iCurrentCarIdx = 0; - do { // Check if car is AI controlled (type 3) and not destroyed (status bit 2 clear) - if (Car[iCurrentCarIdx].iControlType == 3 && (Car[iCurrentCarIdx].byStatusFlags & 2) == 0) { - iSecondCarIdx = iFirstCarIdx + 1; // Start inner loop from next car to avoid duplicate collision checks + do { // Check if car is AI controlled (type 3) and not destroyed (status bit + // 2 clear) + if (Car[iCurrentCarIdx].iControlType == 3 && + (Car[iCurrentCarIdx].byStatusFlags & 2) == 0) { + iSecondCarIdx = iFirstCarIdx + 1; // Start inner loop from next car to + // avoid duplicate collision checks if (iFirstCarIdx + 1 < numcars) { pSecondCar = &Car[iSecondCarIdx]; - do { // Check if second car is also AI controlled and not destroyed - if (Car[iSecondCarIdx].iControlType == 3 && (Car[iSecondCarIdx].byStatusFlags & 2) == 0) { - iChunkDistance = Car[iSecondCarIdx].nCurrChunk - Car[iCurrentCarIdx].nCurrChunk;// Calculate distance between cars in track chunks (handles circular track wraparound) + do { // Check if second car is also AI controlled and not destroyed + if (Car[iSecondCarIdx].iControlType == 3 && + (Car[iSecondCarIdx].byStatusFlags & 2) == 0) { + iChunkDistance = + Car[iSecondCarIdx].nCurrChunk - + Car[iCurrentCarIdx] + .nCurrChunk; // Calculate distance between cars in track + // chunks (handles circular track wraparound) if (iChunkDistance < 0) - iChunkDistance += TRAK_LEN; // Handle negative distance by adding track length (circular track) - if (iChunkDistance > TRAK_LEN / 2)// Use shortest path around circular track (normalize distance > half track length) + iChunkDistance += + TRAK_LEN; // Handle negative distance by adding track length + // (circular track) + if (iChunkDistance > + TRAK_LEN / 2) // Use shortest path around circular track + // (normalize distance > half track length) iChunkDistance -= TRAK_LEN; - if ((int)abs(iChunkDistance) < 4)// Check if cars are close enough for collision (within 4 track chunks) + if ((int)abs(iChunkDistance) < + 4) // Check if cars are close enough for collision (within 4 + // track chunks) { pTrailingCar = &Car[iCurrentCarIdx]; - if (iChunkDistance < 0) // Determine which car is leading/trailing for collision calculation + if (iChunkDistance < + 0) // Determine which car is leading/trailing for collision + // calculation { iChunkDistance = -iChunkDistance; pLeadingCar = pSecondCar; @@ -49,7 +64,9 @@ void testcollisions() pLeadingCar = &Car[iCurrentCarIdx]; pTrailingCar = pSecondCar; } - testcoll(pLeadingCar, pTrailingCar, iChunkDistance);// Perform detailed collision test between leading and trailing cars + testcoll(pLeadingCar, pTrailingCar, + iChunkDistance); // Perform detailed collision test + // between leading and trailing cars } } ++iSecondCarIdx; @@ -64,139 +81,153 @@ void testcollisions() } //------------------------------------------------------------------------------------------------- -//0005FA00 -void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) -{ - tData *pData2; // eax - double dRelativeX1; // st7 - double dRelativeY1; // st6 - double dRelativeZ1; // st5 - tData *pData1; // eax - double dRelativeZ1Copy; // rt0 - double dTransformedY1; // st5 - double dTransformedX1; // st4 - double dProjectedX1; // st7 - double dTransformedX1Copy; // rt2 - double dTransformedZ1; // st4 - int nCar2Yaw; // ebx - int nCurrChunk; // eax - int iChunkStep; // edx - int iChunkOffset; // ecx - int16 nCar2PredictedYaw; // bx - int iCollisionDetected; // ebp - int16 nAngleToCollision; // ax - int iCar1AngleDiff; // ecx - int iCar2AngleDiff; // eax - int iCar1NormalizedAngle; // edx - tData *pData2_2; // eax - double dRelativeX2; // st7 - double dRelativeY2; // st6 - double dRelativeZ2; // st5 - tData *pData1_1; // eax - double dRelativeZ2Copy; // rt0 - double dTransformedY2; // st5 - double dTransformedX2; // st4 - double dProjectedX2; // st7 - double dTransformedX2Copy; // rt2 - double dTransformedZ2; // st4 - int iCollisionAngle; // eax +// 0005FA00 +void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) { + tData *pData2; // eax + double dRelativeX1; // st7 + double dRelativeY1; // st6 + double dRelativeZ1; // st5 + tData *pData1; // eax + double dRelativeZ1Copy; // rt0 + double dTransformedY1; // st5 + double dTransformedX1; // st4 + double dProjectedX1; // st7 + double dTransformedX1Copy; // rt2 + double dTransformedZ1; // st4 + int nCar2Yaw; // ebx + int nCurrChunk; // eax + int iChunkStep; // edx + int iChunkOffset; // ecx + int16 nCar2PredictedYaw; // bx + int iCollisionDetected; // ebp + int16 nAngleToCollision; // ax + int iCar1AngleDiff; // ecx + int iCar2AngleDiff; // eax + int iCar1NormalizedAngle; // edx + tData *pData2_2; // eax + double dRelativeX2; // st7 + double dRelativeY2; // st6 + double dRelativeZ2; // st5 + tData *pData1_1; // eax + double dRelativeZ2Copy; // rt0 + double dTransformedY2; // st5 + double dTransformedX2; // st4 + double dProjectedX2; // st7 + double dTransformedX2Copy; // rt2 + double dTransformedZ2; // st4 + int iCollisionAngle; // eax int16 nCollisionAngleShort; // dx - int iCollisionDirection; // ecx - int iCar1Angle2Diff; // ebp - int iCar2Angle2Diff; // eax - int iCar1Normalized2; // edx + int iCollisionDirection; // ecx + int iCar1Angle2Diff; // ebp + int iCar2Angle2Diff; // eax + int iCar1Normalized2; // edx double dSeparationDistance; // st7 - double dMidpointX; // st6 - double dMidpointY; // st5 - int16 nCurrentChunk; // ax - tData *pTrackData; // edx - int iCar1VelAngle; // eax - int iCar2VelAngle; // ebx - double dInverseTotalMass; // st4 - double dCar1NewVelocity; // st7 - double dCar1NewVelY; // st6 - double dCar2NewVelocity; // st7 - double dMomentumFactor; // st6 - int iDriverIdx; // edx - int iSoundEffectId; // eax - int iSelectedStrategy; // eax - double dCar1SineFactor; // st7 - int iCar1AITimer; // edx - int iCar2Strategy; // ebx - double dCar2SineFactor; // st7 - int iCar2AITimer; // eax - double dNegCar2VelX; // st7 - double dInverseVelSum; // st7 - int iSpeechId1; // eax - int iCar1DriverIdx; // ecx - int iSpeechId2; // eax - int iCar2DriverIdx; // ecx - float fDeltaX1; // [esp+0h] [ebp-CCh] - float fDeltaX2; // [esp+0h] [ebp-CCh] - float fDeltaX3; // [esp+0h] [ebp-CCh] - float fDeltaY1; // [esp+4h] [ebp-C8h] - float fDeltaY2; // [esp+4h] [ebp-C8h] - float fDeltaY3; // [esp+4h] [ebp-C8h] - float fCar1FinalSpeed; // [esp+4h] [ebp-C8h] - float fCar2FinalSpeed; // [esp+4h] [ebp-C8h] - float fCar1FinalDamage; // [esp+4h] [ebp-C8h] - float fCar2FinalDamage; // [esp+4h] [ebp-C8h] - float fFinalSpeed; // [esp+18h] [ebp-B4h] - float fCar1PosX2; // [esp+20h] [ebp-ACh] - float fCar1PosY2; // [esp+28h] [ebp-A4h] - float fCar2Speed; // [esp+2Ch] [ebp-A0h] - float fTransformedPosX1; // [esp+38h] [ebp-94h] - float fTransformedPosX2; // [esp+38h] [ebp-94h] - float fTransformedPosY1; // [esp+44h] [ebp-88h] - float fTransformedPosY2; // [esp+44h] [ebp-88h] - float fCar1Damage; // [esp+50h] [ebp-7Ch] - float fCar2VelY; // [esp+58h] [ebp-74h] - float fVelocityLimit1; // [esp+5Ch] [ebp-70h] - float fCar2Damage; // [esp+60h] [ebp-6Ch] - float fVelocityLimit2; // [esp+64h] [ebp-68h] - float fCar1VelY; // [esp+68h] [ebp-64h] - int16 nCar1Yaw; // [esp+6Ch] [ebp-60h] - int iVelocityAngle; // [esp+70h] [ebp-5Ch] - float fCar1NewVelY; // [esp+74h] [ebp-58h] - float fCar2NewVelX; // [esp+78h] [ebp-54h] - float fCar2NewVelY; // [esp+7Ch] [ebp-50h] - float fCar1NewVelX; // [esp+80h] [ebp-4Ch] - float fCar2VelX; // [esp+84h] [ebp-48h] - float fPosX1Copy; // [esp+88h] [ebp-44h] - float fY; // [esp+8Ch] [ebp-40h] - float fPosY1Copy; // [esp+90h] [ebp-3Ch] - float fCar1VelX; // [esp+94h] [ebp-38h] - float fX; // [esp+98h] [ebp-34h] - float fCar2Mass; // [esp+9Ch] [ebp-30h] - float fCar1Mass; // [esp+A0h] [ebp-2Ch] - float fAdjustedVel1; // [esp+A4h] [ebp-28h] - int iCar1RotAngle; // [esp+A8h] [ebp-24h] - float fAdjustedVel2; // [esp+ACh] [ebp-20h] - int iCar2RotAngle; // [esp+B0h] [ebp-1Ch] - float fSpeedDifference; // [esp+B4h] [ebp-18h] - float fDamageModifier; // [esp+B4h] [ebp-18h] + double dMidpointX; // st6 + double dMidpointY; // st5 + int16 nCurrentChunk; // ax + tData *pTrackData; // edx + int iCar1VelAngle; // eax + int iCar2VelAngle; // ebx + double dInverseTotalMass; // st4 + double dCar1NewVelocity; // st7 + double dCar1NewVelY; // st6 + double dCar2NewVelocity; // st7 + double dMomentumFactor; // st6 + int iDriverIdx; // edx + int iSoundEffectId; // eax + int iSelectedStrategy; // eax + double dCar1SineFactor; // st7 + int iCar1AITimer; // edx + int iCar2Strategy; // ebx + double dCar2SineFactor; // st7 + int iCar2AITimer; // eax + double dNegCar2VelX; // st7 + double dInverseVelSum; // st7 + int iSpeechId1; // eax + int iCar1DriverIdx; // ecx + int iSpeechId2; // eax + int iCar2DriverIdx; // ecx + float fDeltaX1; // [esp+0h] [ebp-CCh] + float fDeltaX2; // [esp+0h] [ebp-CCh] + float fDeltaX3; // [esp+0h] [ebp-CCh] + float fDeltaY1; // [esp+4h] [ebp-C8h] + float fDeltaY2; // [esp+4h] [ebp-C8h] + float fDeltaY3; // [esp+4h] [ebp-C8h] + float fCar1FinalSpeed; // [esp+4h] [ebp-C8h] + float fCar2FinalSpeed; // [esp+4h] [ebp-C8h] + float fCar1FinalDamage; // [esp+4h] [ebp-C8h] + float fCar2FinalDamage; // [esp+4h] [ebp-C8h] + float fFinalSpeed; // [esp+18h] [ebp-B4h] + float fCar1PosX2; // [esp+20h] [ebp-ACh] + float fCar1PosY2; // [esp+28h] [ebp-A4h] + float fCar2Speed; // [esp+2Ch] [ebp-A0h] + float fTransformedPosX1; // [esp+38h] [ebp-94h] + float fTransformedPosX2; // [esp+38h] [ebp-94h] + float fTransformedPosY1; // [esp+44h] [ebp-88h] + float fTransformedPosY2; // [esp+44h] [ebp-88h] + float fCar1Damage; // [esp+50h] [ebp-7Ch] + float fCar2VelY; // [esp+58h] [ebp-74h] + float fVelocityLimit1; // [esp+5Ch] [ebp-70h] + float fCar2Damage; // [esp+60h] [ebp-6Ch] + float fVelocityLimit2; // [esp+64h] [ebp-68h] + float fCar1VelY; // [esp+68h] [ebp-64h] + int16 nCar1Yaw; // [esp+6Ch] [ebp-60h] + int iVelocityAngle; // [esp+70h] [ebp-5Ch] + float fCar1NewVelY; // [esp+74h] [ebp-58h] + float fCar2NewVelX; // [esp+78h] [ebp-54h] + float fCar2NewVelY; // [esp+7Ch] [ebp-50h] + float fCar1NewVelX; // [esp+80h] [ebp-4Ch] + float fCar2VelX; // [esp+84h] [ebp-48h] + float fPosX1Copy; // [esp+88h] [ebp-44h] + float fY; // [esp+8Ch] [ebp-40h] + float fPosY1Copy; // [esp+90h] [ebp-3Ch] + float fCar1VelX; // [esp+94h] [ebp-38h] + float fX; // [esp+98h] [ebp-34h] + float fCar2Mass; // [esp+9Ch] [ebp-30h] + float fCar1Mass; // [esp+A0h] [ebp-2Ch] + float fAdjustedVel1; // [esp+A4h] [ebp-28h] + int iCar1RotAngle; // [esp+A8h] [ebp-24h] + float fAdjustedVel2; // [esp+ACh] [ebp-20h] + int iCar2RotAngle; // [esp+B0h] [ebp-1Ch] + float fSpeedDifference; // [esp+B4h] [ebp-18h] + float fDamageModifier; // [esp+B4h] [ebp-18h] - fX = pCar1->pos.fX; // Get current positions of both cars for collision calculation + fX = pCar1->pos + .fX; // Get current positions of both cars for collision calculation fY = pCar1->pos.fY; - pData2 = &localdata[pCar2->nCurrChunk]; // Transform car2 position from world space to track local coordinates - dRelativeX1 = pData2->pointAy[0].fY * pCar2->pos.fY + pData2->pointAy[0].fX * pCar2->pos.fX + pData2->pointAy[0].fZ * pCar2->pos.fZ - pData2->pointAy[3].fX; - dRelativeY1 = pData2->pointAy[1].fY * pCar2->pos.fY + pData2->pointAy[1].fX * pCar2->pos.fX + pData2->pointAy[1].fZ * pCar2->pos.fZ - pData2->pointAy[3].fY; - dRelativeZ1 = pData2->pointAy[2].fY * pCar2->pos.fY + pData2->pointAy[2].fX * pCar2->pos.fX + pData2->pointAy[2].fZ * pCar2->pos.fZ - pData2->pointAy[3].fZ; - pData1 = &localdata[pCar1->nCurrChunk]; // Transform relative position back to car1's local coordinate system + pData2 = &localdata[pCar2->nCurrChunk]; // Transform car2 position from world + // space to track local coordinates + dRelativeX1 = pData2->pointAy[0].fY * pCar2->pos.fY + + pData2->pointAy[0].fX * pCar2->pos.fX + + pData2->pointAy[0].fZ * pCar2->pos.fZ - pData2->pointAy[3].fX; + dRelativeY1 = pData2->pointAy[1].fY * pCar2->pos.fY + + pData2->pointAy[1].fX * pCar2->pos.fX + + pData2->pointAy[1].fZ * pCar2->pos.fZ - pData2->pointAy[3].fY; + dRelativeZ1 = pData2->pointAy[2].fY * pCar2->pos.fY + + pData2->pointAy[2].fX * pCar2->pos.fX + + pData2->pointAy[2].fZ * pCar2->pos.fZ - pData2->pointAy[3].fZ; + pData1 = &localdata[pCar1->nCurrChunk]; // Transform relative position back to + // car1's local coordinate system dRelativeZ1Copy = dRelativeZ1; dTransformedY1 = dRelativeY1 + pData1->pointAy[3].fY; dTransformedX1 = dRelativeX1 + pData1->pointAy[3].fX; - dProjectedX1 = pData1->pointAy[1].fX * dTransformedY1 + pData1->pointAy[0].fX * dTransformedX1; + dProjectedX1 = pData1->pointAy[1].fX * dTransformedY1 + + pData1->pointAy[0].fX * dTransformedX1; dTransformedX1Copy = dTransformedX1; dTransformedZ1 = (float)dRelativeZ1Copy + pData1->pointAy[3].fZ; - fTransformedPosX1 = (float)dProjectedX1 + pData1->pointAy[2].fX * (float)dTransformedZ1; - fTransformedPosY1 = (float)(dTransformedZ1 * pData1->pointAy[2].fY + dTransformedX1Copy * pData1->pointAy[0].fY + dTransformedY1 * pData1->pointAy[1].fY); + fTransformedPosX1 = + (float)dProjectedX1 + pData1->pointAy[2].fX * (float)dTransformedZ1; + fTransformedPosY1 = (float)(dTransformedZ1 * pData1->pointAy[2].fY + + dTransformedX1Copy * pData1->pointAy[0].fY + + dTransformedY1 * pData1->pointAy[1].fY); fPosX1Copy = fTransformedPosX1; fPosY1Copy = fTransformedPosY1; nCar2Yaw = pCar2->nYaw; nCar1Yaw = pCar1->nYaw; nCurrChunk = pCar1->nCurrChunk; - for (iChunkStep = 0; iChunkStep < iDistanceSteps; ++iChunkStep)// Predict car2's future position and angle based on distance steps ahead + for (iChunkStep = 0; iChunkStep < iDistanceSteps; + ++iChunkStep) // Predict car2's future position and angle based on + // distance steps ahead { iChunkOffset = nCurrChunk++ << 7; nCar2Yaw += *(int *)((char *)&localdata[0].iYaw + iChunkOffset); @@ -207,8 +238,12 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) fDeltaX1 = fTransformedPosX1 - fX; nCar2PredictedYaw = nCar2Yaw & 0x3FFF; iCollisionDetected = 0; - nAngleToCollision = getangle(fDeltaX1, fDeltaY1);// Calculate angle from car1 to collision point for lookup table indexing - iCar1AngleDiff = (nCar1Yaw - nAngleToCollision) & 0x3FFF;// Normalize angle differences to proper ranges for collision lookup table + nAngleToCollision = + getangle(fDeltaX1, fDeltaY1); // Calculate angle from car1 to collision + // point for lookup table indexing + iCar1AngleDiff = (nCar1Yaw - nAngleToCollision) & + 0x3FFF; // Normalize angle differences to proper ranges for + // collision lookup table iCar2AngleDiff = (nCar2PredictedYaw - nAngleToCollision) & 0x3FFF; iCar1NormalizedAngle = iCar1AngleDiff; if (iCar1AngleDiff > 0x2000) @@ -219,28 +254,46 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) iCar1NormalizedAngle -= 0x2000; if (iCar2AngleDiff > 4096) iCar2AngleDiff -= 0x2000; - //TODO look at this and ensure casting is correct - if (coldist[(((uint32)iCar1NormalizedAngle << 6) + 270336) >> 14][(((uint32)iCar2AngleDiff << 6) + 270336) >> 14] > sqrt( - (fTransformedPosX1 - fX) * (fTransformedPosX1 - fX) - + (fTransformedPosY1 - fY) * (fTransformedPosY1 - fY)))// Check if cars are within collision distance using precomputed lookup table + // TODO look at this and ensure casting is correct + if (coldist[(((uint32)iCar1NormalizedAngle << 6) + 270336) >> 14] + [(((uint32)iCar2AngleDiff << 6) + 270336) >> 14] > + sqrt((fTransformedPosX1 - fX) * (fTransformedPosX1 - fX) + + (fTransformedPosY1 - fY) * + (fTransformedPosY1 - + fY))) // Check if cars are within collision distance using + // precomputed lookup table iCollisionDetected = -1; - if (iCollisionDetected) // COLLISION DETECTED: Begin collision resolution calculations + if (iCollisionDetected) // COLLISION DETECTED: Begin collision resolution + // calculations { fCar1PosX2 = pCar1->posLastFrame.fX; fCar1PosY2 = pCar1->posLastFrame.fY; pData2_2 = &localdata[pCar2->nReferenceChunk]; - dRelativeX2 = pData2_2->pointAy[0].fY * pCar2->posLastFrame.fY + pData2_2->pointAy[0].fX * pCar2->posLastFrame.fX + pData2_2->pointAy[0].fZ * pCar2->posLastFrame.fZ - pData2_2->pointAy[3].fX; - dRelativeY2 = pData2_2->pointAy[1].fX * pCar2->posLastFrame.fX + pData2_2->pointAy[1].fY * pCar2->posLastFrame.fY + pData2_2->pointAy[1].fZ * pCar2->posLastFrame.fZ - pData2_2->pointAy[3].fY; - dRelativeZ2 = pData2_2->pointAy[2].fX * pCar2->posLastFrame.fX + pData2_2->pointAy[2].fY * pCar2->posLastFrame.fY + pData2_2->pointAy[2].fZ * pCar2->posLastFrame.fZ - pData2_2->pointAy[3].fZ; + dRelativeX2 = pData2_2->pointAy[0].fY * pCar2->posLastFrame.fY + + pData2_2->pointAy[0].fX * pCar2->posLastFrame.fX + + pData2_2->pointAy[0].fZ * pCar2->posLastFrame.fZ - + pData2_2->pointAy[3].fX; + dRelativeY2 = pData2_2->pointAy[1].fX * pCar2->posLastFrame.fX + + pData2_2->pointAy[1].fY * pCar2->posLastFrame.fY + + pData2_2->pointAy[1].fZ * pCar2->posLastFrame.fZ - + pData2_2->pointAy[3].fY; + dRelativeZ2 = pData2_2->pointAy[2].fX * pCar2->posLastFrame.fX + + pData2_2->pointAy[2].fY * pCar2->posLastFrame.fY + + pData2_2->pointAy[2].fZ * pCar2->posLastFrame.fZ - + pData2_2->pointAy[3].fZ; pData1_1 = &localdata[pCar1->nReferenceChunk]; dRelativeZ2Copy = dRelativeZ2; dTransformedY2 = dRelativeY2 + pData1_1->pointAy[3].fY; dTransformedX2 = dRelativeX2 + pData1_1->pointAy[3].fX; - dProjectedX2 = pData1_1->pointAy[1].fX * dTransformedY2 + pData1_1->pointAy[0].fX * dTransformedX2; + dProjectedX2 = pData1_1->pointAy[1].fX * dTransformedY2 + + pData1_1->pointAy[0].fX * dTransformedX2; dTransformedX2Copy = dTransformedX2; dTransformedZ2 = dRelativeZ2Copy + pData1_1->pointAy[3].fZ; - fTransformedPosX2 = (float)(dProjectedX2 + pData1_1->pointAy[2].fX * dTransformedZ2); - fTransformedPosY2 = (float)(dTransformedZ2 * pData1_1->pointAy[2].fY + dTransformedX2Copy * pData1_1->pointAy[0].fY + dTransformedY2 * pData1_1->pointAy[1].fY); + fTransformedPosX2 = + (float)(dProjectedX2 + pData1_1->pointAy[2].fX * dTransformedZ2); + fTransformedPosY2 = (float)(dTransformedZ2 * pData1_1->pointAy[2].fY + + dTransformedX2Copy * pData1_1->pointAy[0].fY + + dTransformedY2 * pData1_1->pointAy[1].fY); fDeltaY2 = fPosY1Copy - fY; fDeltaX2 = fPosX1Copy - fX; iCollisionAngle = getangle(fDeltaX2, fDeltaY2); @@ -260,14 +313,23 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) iCar1Normalized2 -= 0x2000; if (iCar2Angle2Diff > 4096) iCar2Angle2Diff -= 0x2000; - //TODO look at this and ensure casting is correct - dSeparationDistance = coldist[(((uint32)iCar1Normalized2 << 6) + 270336) >> 14][(((uint32)iCar2Angle2Diff << 6) + 270336) >> 14] + 60.0; + // TODO look at this and ensure casting is correct + dSeparationDistance = + coldist[(((uint32)iCar1Normalized2 << 6) + 270336) >> 14] + [(((uint32)iCar2Angle2Diff << 6) + 270336) >> 14] + + 60.0; dMidpointX = (fX + fPosX1Copy) * 0.5; dMidpointY = (fY + fPosY1Copy) * 0.5; - pCar1->pos.fX = (float)(dMidpointX - dSeparationDistance * tcos[iCollisionDirection] * 0.5);// Separate cars to prevent overlap: move each car away from collision point - pCar1->pos.fY = (float)(dMidpointY - dSeparationDistance * tsin[iCollisionDirection] * 0.5); - pCar2->pos.fX = (float)(dMidpointX + dSeparationDistance * tcos[iCollisionDirection] * 0.5); - pCar2->pos.fY = (float)(dMidpointY + dSeparationDistance * tsin[iCollisionDirection] * 0.5); + pCar1->pos.fX = + (float)(dMidpointX - dSeparationDistance * tcos[iCollisionDirection] * + 0.5); // Separate cars to prevent overlap: move + // each car away from collision point + pCar1->pos.fY = (float)(dMidpointY - dSeparationDistance * + tsin[iCollisionDirection] * 0.5); + pCar2->pos.fX = (float)(dMidpointX + dSeparationDistance * + tcos[iCollisionDirection] * 0.5); + pCar2->pos.fY = (float)(dMidpointY + dSeparationDistance * + tsin[iCollisionDirection] * 0.5); nCurrentChunk = pCar1->nCurrChunk; pCar2->nCurrChunk = nCurrentChunk; pTrackData = &localdata[nCurrentChunk]; @@ -277,7 +339,9 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) scansection(pCar2); fFinalSpeed = pCar1->fFinalSpeed; iCar1VelAngle = (nCar1Yaw - (int16)iVelocityAngle) & 0x3FFF; - fCar1VelX = fFinalSpeed * tcos[iCar1VelAngle];// Calculate velocity components for both cars relative to collision angle + fCar1VelX = fFinalSpeed * + tcos[iCar1VelAngle]; // Calculate velocity components for both + // cars relative to collision angle fCar1VelY = fFinalSpeed * tsin[iCar1VelAngle]; fCar2Speed = pCar2->fFinalSpeed; iCar2VelAngle = (nCar2PredictedYaw - (int16)iVelocityAngle) & 0x3FFF; @@ -286,26 +350,49 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) if (fCar2VelX < (double)fCar1VelX) { fCar1Mass = CarEngines.engines[pCar1->byCarDesignIdx].fMass; fCar2Mass = CarEngines.engines[pCar2->byCarDesignIdx].fMass; - dInverseTotalMass = 1.0 / (fCar1Mass + fCar2Mass);// Calculate momentum exchange using car masses and velocity differences - dCar1NewVelocity = ((fCar1Mass - fCar2Mass * 0.6) * fCar1VelX + fCar2Mass * 1.6 * fCar2VelX) * dInverseTotalMass; - fCar1NewVelX = (float)(dCar1NewVelocity * tcos[iVelocityAngle] - fCar1VelY * tsin[iVelocityAngle]); - dCar1NewVelY = (float)(dCar1NewVelocity * tsin[iVelocityAngle] + fCar1VelY * tcos[iVelocityAngle]); - dCar2NewVelocity = (fCar2VelX * (fCar2Mass - fCar1Mass * 0.6) + fCar1VelX * (fCar1Mass * 1.6)) * dInverseTotalMass; + dInverseTotalMass = + 1.0 / (fCar1Mass + fCar2Mass); // Calculate momentum exchange using + // car masses and velocity differences + dCar1NewVelocity = ((fCar1Mass - fCar2Mass * 0.6) * fCar1VelX + + fCar2Mass * 1.6 * fCar2VelX) * + dInverseTotalMass; + fCar1NewVelX = (float)(dCar1NewVelocity * tcos[iVelocityAngle] - + fCar1VelY * tsin[iVelocityAngle]); + dCar1NewVelY = (float)(dCar1NewVelocity * tsin[iVelocityAngle] + + fCar1VelY * tcos[iVelocityAngle]); + dCar2NewVelocity = (fCar2VelX * (fCar2Mass - fCar1Mass * 0.6) + + fCar1VelX * (fCar1Mass * 1.6)) * + dInverseTotalMass; fCar1NewVelY = (float)dCar1NewVelY; - fCar2NewVelX = (float)(dCar2NewVelocity * tcos[iVelocityAngle] - fCar2VelY * tsin[iVelocityAngle]); - iCar1RotAngle = ((uint16)pCar1->nActualYaw - (int16)iCollisionDirection) & 0x3FFF; - fCar2NewVelY = (float)(dCar2NewVelocity * tsin[iVelocityAngle] + fCar2VelY * tcos[iVelocityAngle]); + fCar2NewVelX = (float)(dCar2NewVelocity * tcos[iVelocityAngle] - + fCar2VelY * tsin[iVelocityAngle]); + iCar1RotAngle = + ((uint16)pCar1->nActualYaw - (int16)iCollisionDirection) & 0x3FFF; + fCar2NewVelY = (float)(dCar2NewVelocity * tsin[iVelocityAngle] + + fCar2VelY * tcos[iVelocityAngle]); if ((unsigned int)iCar1RotAngle > 0x2000) - iCar1RotAngle = (((uint16)pCar1->nActualYaw - (int16)iCollisionDirection) & 0x3FFF) - 0x4000; - iCar2RotAngle = ((uint16)pCar2->nActualYaw - (int16)iCollisionDirection) & 0x3FFF; + iCar1RotAngle = + (((uint16)pCar1->nActualYaw - (int16)iCollisionDirection) & + 0x3FFF) - + 0x4000; + iCar2RotAngle = + ((uint16)pCar2->nActualYaw - (int16)iCollisionDirection) & 0x3FFF; if ((unsigned int)iCar2RotAngle > 0x2000) - iCar2RotAngle = (((uint16)pCar2->nActualYaw - (int16)iCollisionDirection) & 0x3FFF) - 0x4000; + iCar2RotAngle = + (((uint16)pCar2->nActualYaw - (int16)iCollisionDirection) & + 0x3FFF) - + 0x4000; fSpeedDifference = (float)fabs(fCar2VelX - fCar1VelX); dMomentumFactor = 1.0 / ((fCar2Mass + fCar1Mass) * 2048.0); - dMomentumFactor = floor(dMomentumFactor);//_CHP(); - pCar1->iJumpMomentum = (int)(fCar2Mass * 2.0 * (double)iCar2RotAngle * fSpeedDifference * dMomentumFactor);// Calculate jump/spin momentum based on angular impact and speed difference + dMomentumFactor = floor(dMomentumFactor); //_CHP(); + pCar1->iJumpMomentum = + (int)(fCar2Mass * 2.0 * (double)iCar2RotAngle * fSpeedDifference * + dMomentumFactor); // Calculate jump/spin momentum based on + // angular impact and speed difference //_CHP(); - pCar2->iJumpMomentum = (int)(dMomentumFactor * (fCar1Mass * 2.0 * (double)iCar1RotAngle * fSpeedDifference)); + pCar2->iJumpMomentum = + (int)(dMomentumFactor * + (fCar1Mass * 2.0 * (double)iCar1RotAngle * fSpeedDifference)); if (pCar1->iJumpMomentum > 1300) pCar1->iJumpMomentum = 1300; if (pCar2->iJumpMomentum > 1300) @@ -323,12 +410,17 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) iSoundEffectId = 8; else iSoundEffectId = 7; - sfxpend(iSoundEffectId, iDriverIdx, (int)(fSpeedDifference * 32768.0 * 0.025));// Play collision sound effect based on impact severity + sfxpend( + iSoundEffectId, iDriverIdx, + (int)(fSpeedDifference * 32768.0 * + 0.025)); // Play collision sound effect based on impact severity pCar1->nActualYaw = getangle(fCar1NewVelX, fCar1NewVelY); pCar2->nActualYaw = getangle(fCar2NewVelX, fCar2NewVelY); - fCar1FinalSpeed = (float)sqrt(fCar1NewVelX * fCar1NewVelX + fCar1NewVelY * fCar1NewVelY); + fCar1FinalSpeed = (float)sqrt(fCar1NewVelX * fCar1NewVelX + + fCar1NewVelY * fCar1NewVelY); SetEngine(pCar1, fCar1FinalSpeed); - fCar2FinalSpeed = (float)sqrt(fCar2NewVelX * fCar2NewVelX + fCar2NewVelY * fCar2NewVelY); + fCar2FinalSpeed = (float)sqrt(fCar2NewVelX * fCar2NewVelX + + fCar2NewVelY * fCar2NewVelY); SetEngine(pCar2, fCar2FinalSpeed); iSelectedStrategy = pCar1->iSelectedStrategy; if (iSelectedStrategy) { @@ -376,14 +468,22 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) if (fAdjustedVel2 > (double)fVelocityLimit1) fAdjustedVel2 = fAdjustedVel1 * 9.0f; fDamageModifier = fSpeedDifference + damage_levels[damage_level]; - dInverseVelSum = 1.0 / (fAdjustedVel1 + fAdjustedVel2);// Calculate damage amounts based on velocity ratios and impact severity - fCar1Damage = (float)(fAdjustedVel1 * fDamageModifier * 0.006 * dInverseVelSum); - fCar2Damage = (float)(dInverseVelSum * (fAdjustedVel2 * fDamageModifier * 0.006)); + dInverseVelSum = + 1.0 / (fAdjustedVel1 + + fAdjustedVel2); // Calculate damage amounts based on velocity + // ratios and impact severity + fCar1Damage = + (float)(fAdjustedVel1 * fDamageModifier * 0.006 * dInverseVelSum); + fCar2Damage = + (float)(dInverseVelSum * (fAdjustedVel2 * fDamageModifier * 0.006)); if (fCar1Damage >= 1.0) { - if (player1_car == pCar2->iDriverIdx || player2_car == pCar2->iDriverIdx) { + if (player1_car == pCar2->iDriverIdx || + player2_car == pCar2->iDriverIdx) { iSpeechId1 = 48; LABEL_87: - speechonly(iSpeechId1, 0x8000, 18, pCar1->iDriverIdx);// Trigger driver speech/taunts based on damage dealt to opponents + speechonly(iSpeechId1, 0x8000, 18, + pCar1->iDriverIdx); // Trigger driver speech/taunts based + // on damage dealt to opponents goto LABEL_88; } iCar1DriverIdx = pCar1->iDriverIdx; @@ -394,7 +494,8 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) } LABEL_88: if (fCar2Damage >= 1.0) { - if (player1_car == pCar1->iDriverIdx || player2_car == pCar1->iDriverIdx) { + if (player1_car == pCar1->iDriverIdx || + player2_car == pCar1->iDriverIdx) { iSpeechId2 = 48; } else { iCar2DriverIdx = pCar2->iDriverIdx; @@ -412,7 +513,8 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) pCar2->byAttacker = pCar1->iDriverIdx; pCar2->byDamageSourceTimer = -40; fCar1FinalDamage = fCar1Damage * damage_levels[damage_level]; - dodamage(pCar1, fCar1FinalDamage); // Apply calculated damage to both cars and set attacker information + dodamage(pCar1, fCar1FinalDamage); // Apply calculated damage to both cars + // and set attacker information fCar2FinalDamage = fCar2Damage * damage_levels[damage_level]; dodamage(pCar2, fCar2FinalDamage); } @@ -420,117 +522,195 @@ void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps) } //------------------------------------------------------------------------------------------------- -//000604B0 -void initcollisions() -{ - int iAngleIdx1; // ecx - int iTableOffset; // esi - int iCurrentOffset; // ebx - double dCarBaseX; // [esp+38h] [ebp-38h] - double dCarBaseY; // [esp+40h] [ebp-30h] - int iAngleIdx2; // [esp+4Ch] [ebp-24h] - int iCurrentDistance; // [esp+50h] [ebp-20h] +// 000604B0 +void initcollisions() { + int iAngleIdx1; // ecx + int iTableOffset; // esi + int iCurrentOffset; // ebx + double dCarBaseX; // [esp+38h] [ebp-38h] + double dCarBaseY; // [esp+40h] [ebp-30h] + int iAngleIdx2; // [esp+4Ch] [ebp-24h] + int iCurrentDistance; // [esp+50h] [ebp-20h] int iBinarySearchStep; // [esp+54h] [ebp-1Ch] - dCarBaseX = CarBaseX; // Load car bounding box dimensions for collision calculations - iAngleIdx1 = -4096; // Initialize first car angle index (-4096 to 4352, 256 steps = 34 angles) - iTableOffset = 0; // Initialize collision distance table offset (34x34 lookup table) + dCarBaseX = + CarBaseX; // Load car bounding box dimensions for collision calculations + iAngleIdx1 = -4096; // Initialize first car angle index (-4096 to 4352, 256 + // steps = 34 angles) + iTableOffset = + 0; // Initialize collision distance table offset (34x34 lookup table) dCarBaseY = CarBaseY; do { - iCurrentOffset = iTableOffset; // Start building row in collision distance table for current angle pair - for (iAngleIdx2 = -4096; iAngleIdx2 != 4352; iAngleIdx2 += 256)// Inner loop: iterate through second car angles (-4096 to 4352, 256 steps) + iCurrentOffset = iTableOffset; // Start building row in collision distance + // table for current angle pair + for (iAngleIdx2 = -4096; iAngleIdx2 != 4352; + iAngleIdx2 += 256) // Inner loop: iterate through second car angles + // (-4096 to 4352, 256 steps) { - iCurrentDistance = 1600; // Initialize binary search for minimum collision distance (start at 1600) - iBinarySearchStep = 1024; // Binary search step size starts at 1024 (halved each iteration) - do { // Test collision at current distance between cars at angle difference - if (!checkintersect(0.0, 0.0, (double)iAngleIdx1, (double)iCurrentDistance - (double)iBinarySearchStep, 0.0, (double)iAngleIdx2, dCarBaseX, dCarBaseY)) - iCurrentDistance -= iBinarySearchStep;// No collision detected: reduce distance and continue binary search - iBinarySearchStep /= 2; // Halve binary search step size for next iteration + iCurrentDistance = 1600; // Initialize binary search for minimum collision + // distance (start at 1600) + iBinarySearchStep = 1024; // Binary search step size starts at 1024 + // (halved each iteration) + do { // Test collision at current distance between cars at angle + // difference + if (!checkintersect(0.0, 0.0, (double)iAngleIdx1, + (double)iCurrentDistance - + (double)iBinarySearchStep, + 0.0, (double)iAngleIdx2, dCarBaseX, dCarBaseY)) + iCurrentDistance -= + iBinarySearchStep; // No collision detected: reduce distance and + // continue binary search + iBinarySearchStep /= + 2; // Halve binary search step size for next iteration } while (iBinarySearchStep); - //TODO make this more readable - *(float *)((char *)&coldist + iCurrentOffset) = (float)iCurrentDistance;// Store minimum collision distance in lookup table (coldist array) + // TODO make this more readable + *(float *)((char *)&coldist + iCurrentOffset) = + (float)iCurrentDistance; // Store minimum collision distance in lookup + // table (coldist array) iCurrentOffset += 4; - //*(float *)((char *)&result_p1_pos + iCurrentOffset) = (float)iCurrentDistance;// Store minimum collision distance in lookup table (coldist array) + //*(float *)((char *)&result_p1_pos + iCurrentOffset) = + //(float)iCurrentDistance;// Store minimum collision distance in lookup + // table (coldist array) } - iAngleIdx1 += 256; // Move to next angle index for first car (256 units = ~5.625 degrees) - iTableOffset += 132; // Move to next row in collision distance table (132 bytes = 33 floats) + iAngleIdx1 += 256; // Move to next angle index for first car (256 units = + // ~5.625 degrees) + iTableOffset += 132; // Move to next row in collision distance table (132 + // bytes = 33 floats) } while (iAngleIdx1 != 4352); } //------------------------------------------------------------------------------------------------- -//000605C0 -int checkintersect(double dCar1PosX, double dCar1PosY, double dAngleIdx1, double dCar2PosX, double dCar2PosY, double dAngleIdx2, double dCarBaseX, double dCarBaseY) -{ - double dAngleDifference; // st6 - double dCosAngle2; // rt2 - int iIntersects; // edx - double dCosAngle1; // rt1 +// 000605C0 +int checkintersect(double dCar1PosX, double dCar1PosY, double dAngleIdx1, + double dCar2PosX, double dCar2PosY, double dAngleIdx2, + double dCarBaseX, double dCarBaseY) { + double dAngleDifference; // st6 + double dCosAngle2; // rt2 + int iIntersects; // edx + double dCosAngle1; // rt1 double dTransformedDistX1; // [esp+48h] [ebp-3Ch] double dTransformedDistY2; // [esp+50h] [ebp-34h] double dTransformedDistY1; // [esp+58h] [ebp-2Ch] double dTransformedDistX2; // [esp+60h] [ebp-24h] - double dCosAngleDelta; // [esp+68h] [ebp-1Ch] - double dSinAngleDelta; // [esp+70h] [ebp-14h] - double dSinAngle2; // [esp+78h] [ebp-Ch] - double dSinAngle1; // [esp+78h] [ebp-Ch] + double dCosAngleDelta; // [esp+68h] [ebp-1Ch] + double dSinAngleDelta; // [esp+70h] [ebp-14h] + double dSinAngle2; // [esp+78h] [ebp-Ch] + double dSinAngle1; // [esp+78h] [ebp-Ch] - dAngleDifference = (dAngleIdx1 - dAngleIdx2) * 0.0003834951969714356;// Calculate angle difference between two cars (convert from angle indices to radians) - dCosAngleDelta = cos(dAngleDifference); // Calculate trigonometric values for angle difference (rotation matrix components) + dAngleDifference = + (dAngleIdx1 - dAngleIdx2) * + 0.0003834951969714356; // Calculate angle difference between two cars + // (convert from angle indices to radians) + dCosAngleDelta = + cos(dAngleDifference); // Calculate trigonometric values for angle + // difference (rotation matrix components) dSinAngleDelta = sin(dAngleDifference); - dCosAngle2 = cos(dAngleIdx2 * 0.0003834951969714356);// Calculate trigonometric values for second car's orientation + dCosAngle2 = + cos(dAngleIdx2 * 0.0003834951969714356); // Calculate trigonometric values + // for second car's orientation dSinAngle2 = sin(dAngleIdx2 * 0.0003834951969714356); - dTransformedDistX1 = (dCar1PosX - dCar2PosX) * dCosAngle2 + (dCar1PosY - dCar2PosY) * dSinAngle2;// Transform car position difference into second car's local coordinate system - dTransformedDistY1 = dCosAngle2 * (dCar1PosY - dCar2PosY) + (dCar2PosX - dCar1PosX) * dSinAngle2; - iIntersects = 0; // Initialize intersection result (0 = no intersection, -1 = intersection found) - if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * dCarBaseY + dTransformedDistX1) <= dCarBaseX - && fabs(dCarBaseY * dCosAngleDelta + dSinAngleDelta * dCarBaseX + dTransformedDistY1) <= dCarBaseY)// Test intersection for first car's corner (+X, +Y) against second car's bounding box + dTransformedDistX1 = (dCar1PosX - dCar2PosX) * dCosAngle2 + + (dCar1PosY - dCar2PosY) * + dSinAngle2; // Transform car position difference into + // second car's local coordinate system + dTransformedDistY1 = dCosAngle2 * (dCar1PosY - dCar2PosY) + + (dCar2PosX - dCar1PosX) * dSinAngle2; + iIntersects = 0; // Initialize intersection result (0 = no intersection, -1 = + // intersection found) + if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * dCarBaseY + + dTransformedDistX1) <= dCarBaseX && + fabs(dCarBaseY * dCosAngleDelta + dSinAngleDelta * dCarBaseX + + dTransformedDistY1) <= + dCarBaseY) // Test intersection for first car's corner (+X, +Y) + // against second car's bounding box { iIntersects = -1; } - if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * -dCarBaseY + dTransformedDistX1) <= dCarBaseX - && fabs(-dCarBaseY * dCosAngleDelta + dSinAngleDelta * dCarBaseX + dTransformedDistY1) <= dCarBaseY)// Test intersection for first car's corner (+X, -Y) against second car's bounding box + if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * -dCarBaseY + + dTransformedDistX1) <= dCarBaseX && + fabs(-dCarBaseY * dCosAngleDelta + dSinAngleDelta * dCarBaseX + + dTransformedDistY1) <= + dCarBaseY) // Test intersection for first car's corner (+X, -Y) + // against second car's bounding box { iIntersects = -1; } - if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * dCarBaseY + dTransformedDistX1) <= dCarBaseX - && fabs(-dCarBaseX * dSinAngleDelta + dCarBaseY * dCosAngleDelta + dTransformedDistY1) <= dCarBaseY)// Test intersection for first car's corner (-X, +Y) against second car's bounding box + if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * dCarBaseY + + dTransformedDistX1) <= dCarBaseX && + fabs(-dCarBaseX * dSinAngleDelta + dCarBaseY * dCosAngleDelta + + dTransformedDistY1) <= + dCarBaseY) // Test intersection for first car's corner (-X, +Y) + // against second car's bounding box { iIntersects = -1; } - if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * -dCarBaseY + dTransformedDistX1) <= dCarBaseX - && fabs(-dCarBaseX * dSinAngleDelta + dCosAngleDelta * -dCarBaseY + dTransformedDistY1) <= dCarBaseY)// Test intersection for first car's corner (-X, -Y) against second car's bounding box + if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * -dCarBaseY + + dTransformedDistX1) <= dCarBaseX && + fabs(-dCarBaseX * dSinAngleDelta + dCosAngleDelta * -dCarBaseY + + dTransformedDistY1) <= + dCarBaseY) // Test intersection for first car's corner (-X, -Y) + // against second car's bounding box { iIntersects = -1; } - if (fabs(dTransformedDistX1) <= dCarBaseX && fabs(dTransformedDistY1) <= dCarBaseY)// Test if first car's center point is inside second car's bounding box + if (fabs(dTransformedDistX1) <= dCarBaseX && + fabs(dTransformedDistY1) <= + dCarBaseY) // Test if first car's center point is inside second car's + // bounding box iIntersects = -1; - //HIBYTE(dSinAngleDelta) ^= 0x80u; // Flip sign of sine component to reverse transformation direction + // HIBYTE(dSinAngleDelta) ^= 0x80u; // Flip sign of sine + // component to reverse transformation direction dSinAngleDelta = -dSinAngleDelta; - dCosAngle1 = cos(dAngleIdx1 * 0.0003834951969714356);// Calculate trigonometric values for first car's orientation + dCosAngle1 = + cos(dAngleIdx1 * 0.0003834951969714356); // Calculate trigonometric values + // for first car's orientation dSinAngle1 = sin(dAngleIdx1 * 0.0003834951969714356); - dTransformedDistX2 = (dCar2PosX - dCar1PosX) * dCosAngle1 + (dCar2PosY - dCar1PosY) * dSinAngle1;// Transform car position difference into first car's local coordinate system - dTransformedDistY2 = dCosAngle1 * (dCar2PosY - dCar1PosY) + (dCar1PosX - dCar2PosX) * dSinAngle1; - if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * dCarBaseY + dTransformedDistX2) <= dCarBaseX - && fabs(dSinAngleDelta * dCarBaseX + dCarBaseY * dCosAngleDelta + dTransformedDistY2) <= dCarBaseY)// Test intersection for second car's corner (+X, +Y) against first car's bounding box + dTransformedDistX2 = (dCar2PosX - dCar1PosX) * dCosAngle1 + + (dCar2PosY - dCar1PosY) * + dSinAngle1; // Transform car position difference into + // first car's local coordinate system + dTransformedDistY2 = dCosAngle1 * (dCar2PosY - dCar1PosY) + + (dCar1PosX - dCar2PosX) * dSinAngle1; + if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * dCarBaseY + + dTransformedDistX2) <= dCarBaseX && + fabs(dSinAngleDelta * dCarBaseX + dCarBaseY * dCosAngleDelta + + dTransformedDistY2) <= + dCarBaseY) // Test intersection for second car's corner (+X, +Y) + // against first car's bounding box { iIntersects = -1; } - if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * -dCarBaseY + dTransformedDistX2) <= dCarBaseX - && fabs(-dCarBaseY * dCosAngleDelta + dSinAngleDelta * dCarBaseX + dTransformedDistY2) <= dCarBaseY)// Test intersection for second car's corner (+X, -Y) against first car's bounding box + if (fabs(dCosAngleDelta * dCarBaseX - dSinAngleDelta * -dCarBaseY + + dTransformedDistX2) <= dCarBaseX && + fabs(-dCarBaseY * dCosAngleDelta + dSinAngleDelta * dCarBaseX + + dTransformedDistY2) <= + dCarBaseY) // Test intersection for second car's corner (+X, -Y) + // against first car's bounding box { iIntersects = -1; } - if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * dCarBaseY + dTransformedDistX2) <= dCarBaseX - && fabs(-dCarBaseX * dSinAngleDelta + dCarBaseY * dCosAngleDelta + dTransformedDistY2) <= dCarBaseY)// Test intersection for second car's corner (-X, +Y) against first car's bounding box + if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * dCarBaseY + + dTransformedDistX2) <= dCarBaseX && + fabs(-dCarBaseX * dSinAngleDelta + dCarBaseY * dCosAngleDelta + + dTransformedDistY2) <= + dCarBaseY) // Test intersection for second car's corner (-X, +Y) + // against first car's bounding box { iIntersects = -1; } - if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * -dCarBaseY + dTransformedDistX2) <= dCarBaseX - && fabs(-dCarBaseX * dSinAngleDelta + dCosAngleDelta * -dCarBaseY + dTransformedDistY2) <= dCarBaseY)// Test intersection for second car's corner (-X, -Y) against first car's bounding box + if (fabs(dCosAngleDelta * -dCarBaseX - dSinAngleDelta * -dCarBaseY + + dTransformedDistX2) <= dCarBaseX && + fabs(-dCarBaseX * dSinAngleDelta + dCosAngleDelta * -dCarBaseY + + dTransformedDistY2) <= + dCarBaseY) // Test intersection for second car's corner (-X, -Y) + // against first car's bounding box { iIntersects = -1; } - if (fabs(dTransformedDistX2) <= dCarBaseX && fabs(dTransformedDistY2) <= dCarBaseY)// Test if second car's center point is inside first car's bounding box + if (fabs(dTransformedDistX2) <= dCarBaseX && + fabs(dTransformedDistY2) <= + dCarBaseY) // Test if second car's center point is inside first car's + // bounding box return -1; return iIntersects; } diff --git a/PROJECTS/ROLLER/colision.h b/PROJECTS/ROLLER/colision.h index c78f23d0..c93b162e 100644 --- a/PROJECTS/ROLLER/colision.h +++ b/PROJECTS/ROLLER/colision.h @@ -13,7 +13,9 @@ extern int damage_level; void testcollisions(); void testcoll(tCar *pCar1, tCar *pCar2, int iDistanceSteps); void initcollisions(); -int checkintersect(double dCar1PosX, double dCar1PosY, double dAngleIdx1, double dCar2PosX, double dCar2PosY, double dAngleIdx2, double dCarBaseX, double dCarBaseY); +int checkintersect(double dCar1PosX, double dCar1PosY, double dAngleIdx1, + double dCar2PosX, double dCar2PosY, double dAngleIdx2, + double dCarBaseX, double dCarBaseY); //------------------------------------------------------------------------------------------------- #endif \ No newline at end of file diff --git a/PROJECTS/ROLLER/comms.c b/PROJECTS/ROLLER/comms.c index 879662ba..d93d9fe8 100644 --- a/PROJECTS/ROLLER/comms.c +++ b/PROJECTS/ROLLER/comms.c @@ -10,124 +10,154 @@ #include //------------------------------------------------------------------------------------------------- -int serial_port = 2; //000AFD98 -int modem_port = 2; //000AFD9C -int modem_baud = 19200; //000AFDA0 -int no_16550 = 0; //000AFDA4 -int current_modem = 0; //000AFDA8 -char modem_initstring[51] = "ATX"; //000AFDAC -char modem_phone[53] = { 0 }; //000AFDDF -int modem_tone = -1; //000AFE14 -int modem_call = -1; //000AFE18 -int modemstrs; //001A2BA0 -char *modembuffer; //001A2BA4 -int modems; //001A2BA8 -tModemBuffer2 modembuffer2; //001A2BAC +int serial_port = 2; // 000AFD98 +int modem_port = 2; // 000AFD9C +int modem_baud = 19200; // 000AFDA0 +int no_16550 = 0; // 000AFDA4 +int current_modem = 0; // 000AFDA8 +char modem_initstring[51] = "ATX"; // 000AFDAC +char modem_phone[53] = {0}; // 000AFDDF +int modem_tone = -1; // 000AFE14 +int modem_call = -1; // 000AFE18 +int modemstrs; // 001A2BA0 +char *modembuffer; // 001A2BA4 +int modems; // 001A2BA8 +tModemBuffer2 modembuffer2; // 001A2BAC //------------------------------------------------------------------------------------------------- -//00075DC0 -int select_comport(int iIconIdx) -{ // BIOS interrupt 11h - Equipment determination (detect available COM ports) - unsigned int uiKey; // esi - int iAvailableComPorts; // edi - char byCom1Color; // al - char byCom2Color; // al - char byCom3Color; // al - char byCom4Color; // al - unsigned int uiTempKey; // eax - unsigned int uiExtendedKey; // eax - int iExitFlag; // [esp+4h] [ebp-4h] +// 00075DC0 +int select_comport(int iIconIdx) { // BIOS interrupt 11h - Equipment + // determination (detect available COM ports) + unsigned int uiKey; // esi + int iAvailableComPorts; // edi + char byCom1Color; // al + char byCom2Color; // al + char byCom3Color; // al + char byCom4Color; // al + unsigned int uiTempKey; // eax + unsigned int uiExtendedKey; // eax + int iExitFlag; // [esp+4h] [ebp-4h] - //__asm { int 11h; BIOS interrupt 11h - Equipment determination(detect available COM ports) } - iExitFlag = 0; // Initialize exit flag (0 = continue loop, -1 = exit) + //__asm { int 11h; BIOS interrupt 11h - Equipment determination(detect + // available COM ports) } + iExitFlag = 0; // Initialize exit flag (0 = continue loop, -1 = exit) - //Set this to 4 for modern systems to always show 4 comm ports - iAvailableComPorts = 4;// ((int)(unsigned __int16)iIconIdx >> 9) & 7;// Extract COM port count from BIOS equipment word (AX bits 9-11) - DECOMPILER ERROR: uses AX from INT 11h, not parameter a1 + // Set this to 4 for modern systems to always show 4 comm ports + iAvailableComPorts = + 4; // ((int)(unsigned __int16)iIconIdx >> 9) & 7;// Extract COM port count + // from BIOS equipment word (AX bits 9-11) - DECOMPILER ERROR: uses AX + // from INT 11h, not parameter a1 - if ((unsigned int)iAvailableComPorts < 2) // Ensure minimum of 2 COM ports are available + if ((unsigned int)iAvailableComPorts < + 2) // Ensure minimum of 2 COM ports are available iAvailableComPorts = 2; - if (iAvailableComPorts < serial_port) // Validate current serial port selection against available ports + if (iAvailableComPorts < serial_port) // Validate current serial port + // selection against available ports serial_port = 2; - check16550(serial_port); // Test 16550 UART availability on selected serial port - ROLLERCommsSetComBaudRate(9600); // Set communication baud rate to 9600 bps + check16550( + serial_port); // Test 16550 UART availability on selected serial port + ROLLERCommsSetComBaudRate(9600); // Set communication baud rate to 9600 bps do { - display_picture(scrbuf, front_vga[0]); // Display main background picture + display_picture(scrbuf, front_vga[0]); // Display main background picture display_block(scrbuf, front_vga[1], 3, head_x, head_y, 0); - display_block(scrbuf, front_vga[6], 0, 36, 2, 0);// Display UI element at position (36, 2) - display_block(scrbuf, front_vga[5], iIconIdx, -4, 247, 0);// Display gear selection indicator at bottom left - display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, 0);// Display game type indicator (5 + game_type offset) - display_block(scrbuf, front_vga[4], 4, 76, 257, -1);// Display UI element at position (76, 257) with special color - display_block(scrbuf, front_vga[6], 4, 62, 336, -1);// Display UI element at position (62, 336) with special color - scale_text(front_vga[15], &language_buffer[5312], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640);// Display main menu title text - scale_text(front_vga[15], &language_buffer[3008], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640);// Display COM port selection instructions - if (serial_port == 1) // Set color for COM 1 text (highlighted if selected) + display_block(scrbuf, front_vga[6], 0, 36, 2, + 0); // Display UI element at position (36, 2) + display_block(scrbuf, front_vga[5], iIconIdx, -4, 247, + 0); // Display gear selection indicator at bottom left + display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, + 0); // Display game type indicator (5 + game_type offset) + display_block( + scrbuf, front_vga[4], 4, 76, 257, + -1); // Display UI element at position (76, 257) with special color + display_block( + scrbuf, front_vga[6], 4, 62, 336, + -1); // Display UI element at position (62, 336) with special color + scale_text(front_vga[15], &language_buffer[5312], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, + 640); // Display main menu title text + scale_text(front_vga[15], &language_buffer[3008], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, + 640); // Display COM port selection instructions + if (serial_port == 1) // Set color for COM 1 text (highlighted if selected) byCom1Color = 0xAB; else byCom1Color = 0x8F; - scale_text(front_vga[15], "COM 1", font1_ascii, font1_offsets, 400, 135, byCom1Color, 1u, 200, 640);// Display 'COM 1' option text - if (serial_port == 2) // Set color for COM 2 text (highlighted if selected) + scale_text(front_vga[15], "COM 1", font1_ascii, font1_offsets, 400, 135, + byCom1Color, 1u, 200, 640); // Display 'COM 1' option text + if (serial_port == 2) // Set color for COM 2 text (highlighted if selected) byCom2Color = 0xAB; else byCom2Color = 0x8F; - scale_text(front_vga[15], "COM 2", font1_ascii, font1_offsets, 400, 153, byCom2Color, 1u, 200, 640);// Display 'COM 2' option text - if (iAvailableComPorts >= 3) // Check if 3 or more COM ports are available - { // Set color for COM 3 text (highlighted if selected) + scale_text(front_vga[15], "COM 2", font1_ascii, font1_offsets, 400, 153, + byCom2Color, 1u, 200, 640); // Display 'COM 2' option text + if (iAvailableComPorts >= 3) // Check if 3 or more COM ports are available + { // Set color for COM 3 text (highlighted if selected) if (serial_port == 3) byCom3Color = 0xAB; else byCom3Color = 0x8F; - scale_text(front_vga[15], "COM 3", font1_ascii, font1_offsets, 400, 171, byCom3Color, 1u, 200, 640);// Display 'COM 3' option text (if available) + scale_text(front_vga[15], "COM 3", font1_ascii, font1_offsets, 400, 171, + byCom3Color, 1u, 200, + 640); // Display 'COM 3' option text (if available) } - if (iAvailableComPorts >= 4) // Check if 4 or more COM ports are available - { // Set color for COM 4 text (highlighted if selected) + if (iAvailableComPorts >= 4) // Check if 4 or more COM ports are available + { // Set color for COM 4 text (highlighted if selected) if (serial_port == 4) byCom4Color = 0xAB; else byCom4Color = 0x8F; - scale_text(front_vga[15], "COM 4", font1_ascii, font1_offsets, 400, 189, byCom4Color, 1u, 200, 640);// Display 'COM 4' option text (if available) + scale_text(front_vga[15], "COM 4", font1_ascii, font1_offsets, 400, 189, + byCom4Color, 1u, 200, + 640); // Display 'COM 4' option text (if available) } - if (no_16550) // Check if 16550 UART error occurred - scale_text(front_vga[15], &language_buffer[6976], font1_ascii, font1_offsets, 400, 351, 231, 1u, 200, 640);// Display 16550 error message at bottom of screen - copypic(scrbuf, screen); // Copy completed frame buffer to screen - while (fatkbhit()) // Process all pending keyboard input + if (no_16550) // Check if 16550 UART error occurred + scale_text(front_vga[15], &language_buffer[6976], font1_ascii, + font1_offsets, 400, 351, 231, 1u, 200, + 640); // Display 16550 error message at bottom of screen + copypic(scrbuf, screen); // Copy completed frame buffer to screen + while (fatkbhit()) // Process all pending keyboard input { - uiTempKey = fatgetch(); // Get next character from keyboard buffer + uiTempKey = fatgetch(); // Get next character from keyboard buffer uiKey = uiTempKey; - if (uiTempKey < 0xD) // Check if key code is less than 13 (Enter key) - { // Check for extended key code (0 = function/arrow keys) + if (uiTempKey < 0xD) // Check if key code is less than 13 (Enter key) + { // Check for extended key code (0 = function/arrow keys) if (!uiTempKey) { - uiExtendedKey = fatgetch(); // Get extended key code (second byte) + uiExtendedKey = fatgetch(); // Get extended key code (second byte) uiKey = uiExtendedKey; - if (uiExtendedKey >= 0x48) // Check if key code is 0x48 or higher (Up arrow = 0x48) - { // Check for Up arrow key (0x48) - if (uiExtendedKey <= 0x48) { // Move to previous COM port (minimum COM 1) + if (uiExtendedKey >= + 0x48) // Check if key code is 0x48 or higher (Up arrow = 0x48) + { // Check for Up arrow key (0x48) + if (uiExtendedKey <= + 0x48) { // Move to previous COM port (minimum COM 1) if (serial_port != 1) --serial_port; LABEL_38: - check16550(serial_port); // Test 16550 UART on newly selected COM port - } else if (uiExtendedKey == 0x50) // Check for Down arrow key (0x50) - { // Move to next COM port (maximum available ports) + check16550( + serial_port); // Test 16550 UART on newly selected COM port + } else if (uiExtendedKey == 0x50) // Check for Down arrow key (0x50) + { // Move to next COM port (maximum available ports) if (iAvailableComPorts != serial_port) ++serial_port; goto LABEL_38; } } } - } else if (uiTempKey <= 0xD || uiTempKey == 0x1B)// Check for Enter (13) or Escape (27) keys + } else if (uiTempKey <= 0xD || + uiTempKey == 0x1B) // Check for Enter (13) or Escape (27) keys { - iExitFlag = -1; // Set exit flag to exit menu loop + iExitFlag = -1; // Set exit flag to exit menu loop } } - } while (!iExitFlag); // Continue loop until user presses Enter or Escape - ROLLERCommsSetComPort(serial_port); // Configure communications system with selected COM port - return (uiKey != 13) - 1; // Return 0 if Enter pressed, -1 if Escape pressed + } while (!iExitFlag); // Continue loop until user presses Enter or Escape + ROLLERCommsSetComPort( + serial_port); // Configure communications system with selected COM port + return (uiKey != 13) - 1; // Return 0 if Enter pressed, -1 if Escape pressed } //------------------------------------------------------------------------------------------------- -//00076180 -int stringwidth(char *szString) -{ - int iStringWidth; // eax +// 00076180 +int stringwidth(char *szString) { + int iStringWidth; // eax int iCharBlockIdx; // ebx iStringWidth = 0; @@ -142,93 +172,100 @@ int stringwidth(char *szString) } //------------------------------------------------------------------------------------------------- -//00076270 -int select_modemstuff(int iIconIdx) -{ - bool bIsAnswer; // ebp - int iResult; // eax - int iMenuPos; // ebp - char *szDestPtr; // edi - char *szSrcPtr; // esi - int iTemp; // ecx - char *szTemp2; // ebx - tKeycodePair keypair; // rax +// 00076270 +int select_modemstuff(int iIconIdx) { + bool bIsAnswer; // ebp + int iResult; // eax + int iMenuPos; // ebp + char *szDestPtr; // edi + char *szSrcPtr; // esi + int iTemp; // ecx + char *szTemp2; // ebx + tKeycodePair keypair; // rax unsigned int uiStringLen; // kr08_4 - int iModemResponse; // eax - int iModemRespCopy; // edx - int iMaxCOMPorts; // [esp+Ch] [ebp-3Ch] - int bExitRequested; // [esp+10h] [ebp-38h] - int iWaitingForAnswer; // [esp+14h] [ebp-34h] - float fInitTime; // [esp+18h] [ebp-30h] - int iMessageTimeout; // [esp+20h] [ebp-28h] - float fDialTime; // [esp+24h] [ebp-24h] - int iDisplayMessage; // [esp+28h] [ebp-20h] + int iModemResponse; // eax + int iModemRespCopy; // edx + int iMaxCOMPorts; // [esp+Ch] [ebp-3Ch] + int bExitRequested; // [esp+10h] [ebp-38h] + int iWaitingForAnswer; // [esp+14h] [ebp-34h] + float fInitTime; // [esp+18h] [ebp-30h] + int iMessageTimeout; // [esp+20h] [ebp-28h] + float fDialTime; // [esp+24h] [ebp-24h] + int iDisplayMessage; // [esp+28h] [ebp-20h] unsigned int unInputMode; // [esp+2Ch] [ebp-1Ch] - iMessageTimeout = 0; // Initialize variables + iMessageTimeout = 0; // Initialize variables unInputMode = 0; bExitRequested = 0; fInitTime = 0.0; fDialTime = 0.0; iWaitingForAnswer = 0; iDisplayMessage = -1; - bIsAnswer = modem_call == 0; // Check if this is answer mode (incoming call) - loadmodemnames(); // Load available modem configurations - iMenuPos = bIsAnswer + 5; // Calculate menu position (answer mode offset by 5) - if (current_modem >= 0) // Copy modem init string if modem is selected + bIsAnswer = modem_call == 0; // Check if this is answer mode (incoming call) + loadmodemnames(); // Load available modem configurations + iMenuPos = bIsAnswer + 5; // Calculate menu position (answer mode offset by 5) + if (current_modem >= 0) // Copy modem init string if modem is selected { iResult = 51 * *(int *)&modembuffer[56 * current_modem + 52]; szDestPtr = modem_initstring; szSrcPtr = &modembuffer2.bufPtr[iResult]; - //TODO - //do { - // LOBYTE(iResult) = *szSrcPtr; - // *szDestPtr = *szSrcPtr; - // if (!(uint8)iResult) - // break; - // LOBYTE(iResult) = szSrcPtr[1]; - // szSrcPtr += 2; - // szDestPtr[1] = iResult; - // szDestPtr += 2; - //} while ((uint8)iResult); + // TODO + // do { + // LOBYTE(iResult) = *szSrcPtr; + // *szDestPtr = *szSrcPtr; + // if (!(uint8)iResult) + // break; + // LOBYTE(iResult) = szSrcPtr[1]; + // szSrcPtr += 2; + // szDestPtr[1] = iResult; + // szDestPtr += 2; + // } while ((uint8)iResult); } - //TODO - //__asm { int 11h; BIOS equipment determination to detect COM ports }// BIOS equipment determination to detect COM ports + // TODO + //__asm { int 11h; BIOS equipment determination to detect COM ports }// + // BIOS equipment determination to detect COM ports iTemp = modem_port; - iMaxCOMPorts = ((int)(uint16)iResult >> 9) & 7;// Extract number of COM ports from BIOS data - if (modem_port < 2) // Ensure minimum 2 COM ports available + iMaxCOMPorts = ((int)(uint16)iResult >> 9) & + 7; // Extract number of COM ports from BIOS data + if (modem_port < 2) // Ensure minimum 2 COM ports available iMaxCOMPorts = 2; if (iMaxCOMPorts < modem_port) modem_port = 2; - check16550(modem_port); // Check if COM port has 16550 UART - modem_baud = 19200; // Set default baud rate to 19200 + check16550(modem_port); // Check if COM port has 16550 UART + modem_baud = 19200; // Set default baud rate to 19200 ROLLERCommsSetComBaudRate(19200); do { - //szTemp2 = (char *)unInputMode; // Main UI loop - display menu and handle input + // szTemp2 = (char *)unInputMode; // Main UI loop - display + // menu and handle input display_essentials(iIconIdx, iMenuPos, unInputMode); - if (iDisplayMessage == 93 || iDisplayMessage == 94 || iDisplayMessage == 95 || iDisplayMessage == 96 || iDisplayMessage == 104)// Display flashing status messages + if (iDisplayMessage == 93 || iDisplayMessage == 94 || + iDisplayMessage == 95 || iDisplayMessage == 96 || + iDisplayMessage == 104) // Display flashing status messages { if ((frames & 0xFu) < 8) { - //szTemp2 = font1_ascii; - //iTemp = (int)font1_offsets; - scale_text(front_vga[15], &language_buffer[64 * iDisplayMessage], font1_ascii, font1_offsets, 400, 279, 143, 1u, 200, 640); + // szTemp2 = font1_ascii; + // iTemp = (int)font1_offsets; + scale_text(front_vga[15], &language_buffer[64 * iDisplayMessage], + font1_ascii, font1_offsets, 400, 279, 143, 1u, 200, 640); } } else if (iDisplayMessage >= 0) { - //szTemp2 = font1_ascii; - //iTemp = (int)font1_offsets; - scale_text(front_vga[15], &language_buffer[64 * iDisplayMessage], font1_ascii, font1_offsets, 400, 279, 231, 1u, 200, 640); + // szTemp2 = font1_ascii; + // iTemp = (int)font1_offsets; + scale_text(front_vga[15], &language_buffer[64 * iDisplayMessage], + font1_ascii, font1_offsets, 400, 279, 231, 1u, 200, 640); } - //keypair.iCharacter = (int)screen; + // keypair.iCharacter = (int)screen; copypic(scrbuf, screen); if (iMessageTimeout && iMessageTimeout + 72 < frames) bExitRequested = -1; while (fatkbhit()) { keypair.iKeycode = fatgetch(); iTemp = unInputMode; - //szTemp2 = (char *)keypair.iKeycode; + // szTemp2 = (char *)keypair.iKeycode; keypair.iCharacter = keypair.iKeycode; if (unInputMode) { - if (unInputMode <= 1) { // String input mode - edit init string or phone number + if (unInputMode <= + 1) { // String input mode - edit init string or phone number if (iMenuPos == 3) szTemp2 = modem_initstring; else @@ -239,65 +276,67 @@ int select_modemstuff(int iIconIdx) if (!keypair.iKeycode) goto LABEL_57; LABEL_63: - if (keys[WHIP_SCANCODE_LSHIFT] || keys[WHIP_SCANCODE_RSHIFT]) // Handle shifted characters for special symbols + if (keys[WHIP_SCANCODE_LSHIFT] || + keys[WHIP_SCANCODE_RSHIFT]) // Handle shifted characters for + // special symbols { switch (keypair.iKeycode) { - case '#': - keypair.iCharacter = '~'; - break; - case '\'': - keypair.iCharacter = '@'; - break; - case ',': - keypair.iCharacter = '<'; - break; - case '-': - keypair.iCharacter = '_'; - break; - case '.': - keypair.iCharacter = '>'; - break; - case '/': - keypair.iCharacter = '?'; - break; - case '0': - keypair.iCharacter = ')'; - break; - case '1': - keypair.iCharacter = '!'; - break; - case '2': - keypair.iCharacter = '"'; - break; - case '3': - keypair.iCharacter = 0x9C; - break; - case '4': - keypair.iCharacter = '$'; - break; - case '5': - keypair.iCharacter = '%'; - break; - case '6': - keypair.iCharacter = '^'; - break; - case '7': - keypair.iCharacter = '&'; - break; - case '8': - keypair.iCharacter = '*'; - break; - case '9': - keypair.iCharacter = '('; - break; - case ';': - keypair.iCharacter = ':'; - break; - case '=': - keypair.iCharacter = '+'; - break; - default: - break; + case '#': + keypair.iCharacter = '~'; + break; + case '\'': + keypair.iCharacter = '@'; + break; + case ',': + keypair.iCharacter = '<'; + break; + case '-': + keypair.iCharacter = '_'; + break; + case '.': + keypair.iCharacter = '>'; + break; + case '/': + keypair.iCharacter = '?'; + break; + case '0': + keypair.iCharacter = ')'; + break; + case '1': + keypair.iCharacter = '!'; + break; + case '2': + keypair.iCharacter = '"'; + break; + case '3': + keypair.iCharacter = 0x9C; + break; + case '4': + keypair.iCharacter = '$'; + break; + case '5': + keypair.iCharacter = '%'; + break; + case '6': + keypair.iCharacter = '^'; + break; + case '7': + keypair.iCharacter = '&'; + break; + case '8': + keypair.iCharacter = '*'; + break; + case '9': + keypair.iCharacter = '('; + break; + case ';': + keypair.iCharacter = ':'; + break; + case '=': + keypair.iCharacter = '+'; + break; + default: + break; } } iTemp = (uint32)strlen(szTemp2); @@ -317,7 +356,8 @@ int select_modemstuff(int iIconIdx) } } } else { - if (keypair.iKeycode < 0xDu || keypair.iKeycode > 0xDu && keypair.iKeycode != 27) + if (keypair.iKeycode < 0xDu || + keypair.iKeycode > 0xDu && keypair.iKeycode != 27) goto LABEL_63; szTemp2 = (char *)-1; unInputMode = 0; @@ -333,10 +373,11 @@ int select_modemstuff(int iIconIdx) fDialTime = 0.0; iWaitingForAnswer = 0; display_essentials(iIconIdx, iMenuPos, 0); - //iTemp = (int)font1_offsets; - //szTemp2 = font1_ascii; - scale_text(front_vga[15], &language_buffer[6912], font1_ascii, font1_offsets, 400, 279, 143, 1u, 200, 640); - //keypair.iCharacter = (int)screen; + // iTemp = (int)font1_offsets; + // szTemp2 = font1_ascii; + scale_text(front_vga[15], &language_buffer[6912], font1_ascii, + font1_offsets, 400, 279, 143, 1u, 200, 640); + // keypair.iCharacter = (int)screen; copypic(scrbuf, screen); close_network(); } @@ -345,7 +386,7 @@ int select_modemstuff(int iIconIdx) fatgetch(); } } else { - iDisplayMessage = -1; // Menu navigation mode + iDisplayMessage = -1; // Menu navigation mode if (keypair.iKeycode < 0xDu) { if (!keypair.iKeycode) { keypair.iKeycode = fatgetch(); @@ -364,42 +405,44 @@ int select_modemstuff(int iIconIdx) szTemp2 = 0; display_essentials(iIconIdx, iMenuPos, 0); switch (iMenuPos) { - case 0: - select_modem(iIconIdx); // Menu 0: Select modem type - break; - case 1: - //szTemp2 = (char *)(modem_port + 1);// Menu 1: Cycle through COM ports - iTemp = iMaxCOMPorts; - modem_port = modem_port + 1;// (int)szTemp2; - if (modem_port > iMaxCOMPorts) - modem_port = 1; - check16550(modem_port); - break; - case 2: - modem_tone = modem_tone == 0; // Menu 2: Toggle tone/pulse dialing - break; - case 3: - case 4: - unInputMode = 1; // Menu 3/4: Edit init string or phone number - break; - case 5: - case 6: - unInputMode = 2; // Menu 5/6: Start call (5=dial out, 6=answer) - iDisplayMessage = 104; - //szTemp2 = font1_ascii; - //iTemp = (int)font1_offsets; - modem_call = (iMenuPos != 5) - 1; - scale_text(front_vga[15], &language_buffer[6656], font1_ascii, font1_offsets, 400, 279, 143, 1u, 200, 640); - copypic(scrbuf, screen); - ROLLERCommsSetComPort(modem_port); - Initialise_Network(0); - ROLLERModemHangUp(); - //TODO - //keypair = (tKeycodePair)clock(); - //fDialTime = (float)(unsigned int)keypair.iKeycode; - break; - default: - continue; // Execute menu selection + case 0: + select_modem(iIconIdx); // Menu 0: Select modem type + break; + case 1: + // szTemp2 = (char *)(modem_port + 1);// Menu 1: Cycle through COM + // ports + iTemp = iMaxCOMPorts; + modem_port = modem_port + 1; // (int)szTemp2; + if (modem_port > iMaxCOMPorts) + modem_port = 1; + check16550(modem_port); + break; + case 2: + modem_tone = modem_tone == 0; // Menu 2: Toggle tone/pulse dialing + break; + case 3: + case 4: + unInputMode = 1; // Menu 3/4: Edit init string or phone number + break; + case 5: + case 6: + unInputMode = 2; // Menu 5/6: Start call (5=dial out, 6=answer) + iDisplayMessage = 104; + // szTemp2 = font1_ascii; + // iTemp = (int)font1_offsets; + modem_call = (iMenuPos != 5) - 1; + scale_text(front_vga[15], &language_buffer[6656], font1_ascii, + font1_offsets, 400, 279, 143, 1u, 200, 640); + copypic(scrbuf, screen); + ROLLERCommsSetComPort(modem_port); + Initialise_Network(0); + ROLLERModemHangUp(); + // TODO + // keypair = (tKeycodePair)clock(); + // fDialTime = (float)(unsigned int)keypair.iKeycode; + break; + default: + continue; // Execute menu selection } } else if (keypair.iKeycode == 27) { bExitRequested = -1; @@ -410,60 +453,67 @@ int select_modemstuff(int iIconIdx) } } } - if (unInputMode == 2 && !iMessageTimeout) // Handle modem responses during call + if (unInputMode == 2 && + !iMessageTimeout) // Handle modem responses during call { - //TODO - iModemResponse = 0;// gssModemCheckResponse(0, keypair.iCharacter, (int)szTemp2, iTemp); + // TODO + iModemResponse = 0; // gssModemCheckResponse(0, keypair.iCharacter, + // (int)szTemp2, iTemp); iModemRespCopy = iModemResponse; if (iModemResponse >= 0) { switch (iModemResponse) { - case 0: - if (fabs(fInitTime) != 0)// Response 0: Modem ready - init or dial - { - //TODO - //if (modem_call) - // gssModemDial((int)modem_phone, modem_tone); - iModemRespCopy = modem_call; - fInitTime = 0.0; - szTemp2 = (char *)-1; - iWaitingForAnswer = -1; - iDisplayMessage = (modem_call != 0) + 93; - } - if (fabs(fDialTime) != 0) { - //TODO - //gssModemInit((int)modem_initstring, iModemRespCopy, (int)szTemp2, iTemp); - fDialTime = 0.0; - //fInitTime = (float)(unsigned int)clock(); - } - break; - case 1: - iDisplayMessage = 95; // Response 1: Modem busy - iMessageTimeout = frames; - break; - case 2: - if (iWaitingForAnswer && !modem_call)// Response 2: Incoming call detected - { - //TODO - //gssModemAnswer(); - iDisplayMessage = 96; - } - break; - case 3: - case 4: - case 5: - case 6: - case 7: - iDisplayMessage = iModemResponse + 94;// Response 3-7: Connection errors - close_network(); - unInputMode = 0; - break; - default: - break; + case 0: + if (fabs(fInitTime) != 0) // Response 0: Modem ready - init or dial + { + // TODO + // if (modem_call) + // gssModemDial((int)modem_phone, modem_tone); + iModemRespCopy = modem_call; + fInitTime = 0.0; + szTemp2 = (char *)-1; + iWaitingForAnswer = -1; + iDisplayMessage = (modem_call != 0) + 93; + } + if (fabs(fDialTime) != 0) { + // TODO + // gssModemInit((int)modem_initstring, iModemRespCopy, (int)szTemp2, + // iTemp); + fDialTime = 0.0; + // fInitTime = (float)(unsigned int)clock(); + } + break; + case 1: + iDisplayMessage = 95; // Response 1: Modem busy + iMessageTimeout = frames; + break; + case 2: + if (iWaitingForAnswer && + !modem_call) // Response 2: Incoming call detected + { + // TODO + // gssModemAnswer(); + iDisplayMessage = 96; + } + break; + case 3: + case 4: + case 5: + case 6: + case 7: + iDisplayMessage = + iModemResponse + 94; // Response 3-7: Connection errors + close_network(); + unInputMode = 0; + break; + default: + break; } } } - //TODO - if (fabs(fInitTime) != 0)// && ((double)(unsigned int)clock() - fInitTime) * 0.0099999998 > 5.0)// Check for dial timeout (5 seconds) + // TODO + if (fabs(fInitTime) != + 0) // && ((double)(unsigned int)clock() - fInitTime) * 0.0099999998 + // > 5.0)// Check for dial timeout (5 seconds) { close_network(); iTemp = 105; @@ -473,75 +523,84 @@ int select_modemstuff(int iIconIdx) unInputMode = 0; iDisplayMessage = 105; } - if (fabs(fDialTime) != 0)// Check for init timeout (5 seconds) + if (fabs(fDialTime) != 0) // Check for init timeout (5 seconds) { iTemp = 0; - //TODO - //if (((double)(unsigned int)clock() - fDialTime) * 0.0099999998 > 5.0) { - // close_network(); - // fInitTime = 0.0; - // fDialTime = 0.0; - // iWaitingForAnswer = 0; - // unInputMode = 0; - // iDisplayMessage = 105; - //} + // TODO + // if (((double)(unsigned int)clock() - fDialTime) * 0.0099999998 > 5.0) { + // close_network(); + // fInitTime = 0.0; + // fDialTime = 0.0; + // iWaitingForAnswer = 0; + // unInputMode = 0; + // iDisplayMessage = 105; + // } } } while (!bExitRequested); - fre((void **)&modembuffer); // Cleanup - free modem buffers + fre((void **)&modembuffer); // Cleanup - free modem buffers fre((void **)&modembuffer2.bufPtr); if (iMessageTimeout) return -1; - //TODO - //gssModemHangUp(); + // TODO + // gssModemHangUp(); close_network(); return 0; } //------------------------------------------------------------------------------------------------- -//000769D0 -void loadmodemnames() -{ - FILE *pFileModem; // ecx - char *pszToken; // eax - int iModemOffset; // ebp - char *pszModemData; // eax - char *pszSrc; // esi - char *pszDest; // edi - char byChar1; // al - char byChar2; // al - FILE *pFileModemStr; // ecx - char *pszStrToken; // eax - int iStrCount; // ebp - char *pszStrData; // eax - int iStrOffset; // edx - char *pszStrSrc; // esi - char *pszStrDest; // edi - char byStrChar1; // al - char byStrChar2; // al - char szBuffer[512]; // [esp+0h] [ebp-224h] BYREF - char *pszDelimiters; // [esp+200h] [ebp-24h] +// 000769D0 +void loadmodemnames() { + FILE *pFileModem; // ecx + char *pszToken; // eax + int iModemOffset; // ebp + char *pszModemData; // eax + char *pszSrc; // esi + char *pszDest; // edi + char byChar1; // al + char byChar2; // al + FILE *pFileModemStr; // ecx + char *pszStrToken; // eax + int iStrCount; // ebp + char *pszStrData; // eax + int iStrOffset; // edx + char *pszStrSrc; // esi + char *pszStrDest; // edi + char byStrChar1; // al + char byStrChar2; // al + char szBuffer[512]; // [esp+0h] [ebp-224h] BYREF + char *pszDelimiters; // [esp+200h] [ebp-24h] int iStrOffsetCurrent; // [esp+204h] [ebp-20h] - int iModemIndex; // [esp+208h] [ebp-1Ch] + int iModemIndex; // [esp+208h] [ebp-1Ch] - pszDelimiters = " ,\n\t\r"; // Set up delimiters for parsing config files - pFileModem = fopen("MODEM.INI", "r"); // Open MODEM.INI file for reading modem configurations - fgets(szBuffer, 512, pFileModem); // Read first line containing number of modems - pszToken = strtok(szBuffer, " ,\n\t\r"); // Parse modem count from first token - modems = strtol(pszToken, 0, 10); // Convert string to integer and store global modem count - modembuffer = (char *)getbuffer(56 * modems); // Allocate buffer for modem data (56 bytes per modem) - if (!modembuffer) // If allocation failed, reset modem count to 0 + pszDelimiters = " ,\n\t\r"; // Set up delimiters for parsing config files + pFileModem = fopen( + "MODEM.INI", "r"); // Open MODEM.INI file for reading modem configurations + fgets(szBuffer, 512, + pFileModem); // Read first line containing number of modems + pszToken = strtok(szBuffer, " ,\n\t\r"); // Parse modem count from first token + modems = strtol(pszToken, 0, + 10); // Convert string to integer and store global modem count + modembuffer = (char *)getbuffer( + 56 * modems); // Allocate buffer for modem data (56 bytes per modem) + if (!modembuffer) // If allocation failed, reset modem count to 0 modems = 0; - iModemIndex = 0; // Initialize modem index counter + iModemIndex = 0; // Initialize modem index counter if (modems > 0) { iModemOffset = 0; do { - fgets(szBuffer, 512, pFileModem); // Read next line from MODEM.INI for each modem entry - pszModemData = strtok(szBuffer, " "); // Parse modem type ID from first token - *(int *)&modembuffer[iModemOffset + 52] = strtol(pszModemData, 0, 10) - 1;// Store modem type (subtract 1 for 0-based index) at offset +52 - pszSrc = strtok(0, "\r\n"); // Get remainder of line (modem name string) - pszDest = &modembuffer[iModemOffset]; // Set destination pointer to current modem buffer slot + fgets(szBuffer, 512, + pFileModem); // Read next line from MODEM.INI for each modem entry + pszModemData = + strtok(szBuffer, " "); // Parse modem type ID from first token + *(int *)&modembuffer[iModemOffset + 52] = + strtol(pszModemData, 0, 10) - + 1; // Store modem type (subtract 1 for 0-based index) at offset +52 + pszSrc = strtok(0, "\r\n"); // Get remainder of line (modem name string) + pszDest = &modembuffer[iModemOffset]; // Set destination pointer to + // current modem buffer slot do { - byChar1 = *pszSrc; // Copy modem name string 2 bytes at a time for efficiency + byChar1 = + *pszSrc; // Copy modem name string 2 bytes at a time for efficiency *pszDest = *pszSrc; if (!byChar1) break; @@ -550,30 +609,42 @@ void loadmodemnames() pszDest[1] = byChar2; pszDest += 2; } while (byChar2); - iModemOffset += 56; // Advance to next modem slot (56 bytes per entry) + iModemOffset += 56; // Advance to next modem slot (56 bytes per entry) ++iModemIndex; } while (iModemIndex < modems); } - fclose(pFileModem); // Close MODEM.INI file - pFileModemStr = fopen("MODEMSTR.INI", "r"); // Open MODEMSTR.INI file for reading modem command strings - fgets(szBuffer, 512, pFileModemStr); // Read first line containing number of modem strings - pszStrToken = strtok(szBuffer, pszDelimiters);// Parse modem string count from first token - modemstrs = strtol(pszStrToken, 0, 10); // Convert string to integer and store global string count - modembuffer2.bufPtr = (char *)getbuffer(51 * modemstrs);// Allocate buffer for modem strings (51 bytes per string) - if (!modembuffer2.bufPtr) // If allocation failed, reset string count to 0 + fclose(pFileModem); // Close MODEM.INI file + pFileModemStr = + fopen("MODEMSTR.INI", + "r"); // Open MODEMSTR.INI file for reading modem command strings + fgets(szBuffer, 512, + pFileModemStr); // Read first line containing number of modem strings + pszStrToken = strtok( + szBuffer, pszDelimiters); // Parse modem string count from first token + modemstrs = + strtol(pszStrToken, 0, + 10); // Convert string to integer and store global string count + modembuffer2.bufPtr = (char *)getbuffer( + 51 * + modemstrs); // Allocate buffer for modem strings (51 bytes per string) + if (!modembuffer2.bufPtr) // If allocation failed, reset string count to 0 modemstrs = 0; - iStrCount = 0; // Initialize string counter and offset variables + iStrCount = 0; // Initialize string counter and offset variables if (modemstrs > 0) { iStrOffsetCurrent = 0; do { - fgets(szBuffer, 512, pFileModemStr); // Read next line from MODEMSTR.INI for each string entry - pszStrData = strtok(szBuffer, "\t");// Parse modem command string using tab delimiter + fgets(szBuffer, 512, pFileModemStr); // Read next line from MODEMSTR.INI + // for each string entry + pszStrData = strtok( + szBuffer, "\t"); // Parse modem command string using tab delimiter iStrOffset = iStrOffsetCurrent; pszStrSrc = pszStrData; - pszStrDest = &modembuffer2.bufPtr[iStrOffsetCurrent];// Set destination pointer to current string buffer slot + pszStrDest = + &modembuffer2.bufPtr[iStrOffsetCurrent]; // Set destination pointer to + // current string buffer slot ++iStrCount; do { - byStrChar1 = *pszStrSrc; // Copy modem command string 2 bytes at a time + byStrChar1 = *pszStrSrc; // Copy modem command string 2 bytes at a time *pszStrDest = *pszStrSrc; if (!byStrChar1) break; @@ -582,160 +653,194 @@ void loadmodemnames() pszStrDest[1] = byStrChar2; pszStrDest += 2; } while (byStrChar2); - iStrOffsetCurrent = iStrOffset + 51; // Advance to next string slot (51 bytes per entry) + iStrOffsetCurrent = + iStrOffset + 51; // Advance to next string slot (51 bytes per entry) } while (iStrCount < modemstrs); } - fclose(pFileModemStr); // Close MODEMSTR.INI file - if (current_modem >= modems) // Validate current_modem index - clamp to valid range - current_modem = modems - 1; // If current modem >= total modems, set to last valid index - if (-modems > current_modem) // Clamp current_modem to minimum valid range + fclose(pFileModemStr); // Close MODEMSTR.INI file + if (current_modem >= + modems) // Validate current_modem index - clamp to valid range + current_modem = + modems - 1; // If current modem >= total modems, set to last valid index + if (-modems > current_modem) // Clamp current_modem to minimum valid range current_modem = -modems; } //------------------------------------------------------------------------------------------------- -//00076C30 -void select_modem(int iIconIdx) -{ - int iStartIdx; // eax - int iCurrentIdx; // esi - int iYPosition; // edi - char byTextColor; // al +// 00076C30 +void select_modem(int iIconIdx) { + int iStartIdx; // eax + int iCurrentIdx; // esi + int iYPosition; // edi + char byTextColor; // al unsigned int uiKeyCode; // eax - int iExtendedKey; // kr00_4 - int iMaxIdx; // eax - char *pszDestInit; // edi - char *pszSrcInit; // esi - char byChar1; // al - char byChar2; // al - int iEndIdx; // [esp+4h] [ebp-10h] - int iExitFlag; // [esp+8h] [ebp-Ch] - int iModemOffset; // [esp+Ch] [ebp-8h] - int iSelectedModem; // [esp+10h] [ebp-4h] + int iExtendedKey; // kr00_4 + int iMaxIdx; // eax + char *pszDestInit; // edi + char *pszSrcInit; // esi + char byChar1; // al + char byChar2; // al + int iEndIdx; // [esp+4h] [ebp-10h] + int iExitFlag; // [esp+8h] [ebp-Ch] + int iModemOffset; // [esp+Ch] [ebp-8h] + int iSelectedModem; // [esp+10h] [ebp-4h] - iExitFlag = 0; // Initialize exit flag (0 = continue loop, -1 = exit) - iSelectedModem = current_modem; // Get current modem selection for display - if (current_modem < 0) // Handle negative modem index (convert to positive for display) + iExitFlag = 0; // Initialize exit flag (0 = continue loop, -1 = exit) + iSelectedModem = current_modem; // Get current modem selection for display + if (current_modem < + 0) // Handle negative modem index (convert to positive for display) iSelectedModem = -current_modem - 1; - while (!iExitFlag) // Main display and input loop + while (!iExitFlag) // Main display and input loop { - display_picture(scrbuf, front_vga[0]); // Display main background picture + display_picture(scrbuf, front_vga[0]); // Display main background picture display_block(scrbuf, front_vga[1], 3, head_x, head_y, 0); - display_block(scrbuf, front_vga[6], 0, 36, 2, 0);// Display UI element at position (36, 2) - display_block(scrbuf, front_vga[5], iIconIdx, -4, 247, 0);// Display gear selection indicator at bottom left - display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, 0);// Display game type indicator (5 + game_type offset) - display_block(scrbuf, front_vga[4], 4, 76, 257, -1);// Display UI element at position (76, 257) with special color - display_block(scrbuf, front_vga[6], 4, 62, 336, -1);// Display UI element at position (62, 336) with special color - scale_text(front_vga[15], &language_buffer[6784], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640);// Display 'Select Modem' title text - iStartIdx = iSelectedModem - 7; // Calculate display window start (7 items before current) - if (iSelectedModem - 7 < 0) // Ensure start index is not negative + display_block(scrbuf, front_vga[6], 0, 36, 2, + 0); // Display UI element at position (36, 2) + display_block(scrbuf, front_vga[5], iIconIdx, -4, 247, + 0); // Display gear selection indicator at bottom left + display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, + 0); // Display game type indicator (5 + game_type offset) + display_block( + scrbuf, front_vga[4], 4, 76, 257, + -1); // Display UI element at position (76, 257) with special color + display_block( + scrbuf, front_vga[6], 4, 62, 336, + -1); // Display UI element at position (62, 336) with special color + scale_text(front_vga[15], &language_buffer[6784], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, + 640); // Display 'Select Modem' title text + iStartIdx = iSelectedModem - + 7; // Calculate display window start (7 items before current) + if (iSelectedModem - 7 < 0) // Ensure start index is not negative iStartIdx = 0; - iEndIdx = iSelectedModem + 7; // Calculate display window end (7 items after current) - if (iSelectedModem + 7 >= modems) // Ensure end index does not exceed available modems + iEndIdx = iSelectedModem + + 7; // Calculate display window end (7 items after current) + if (iSelectedModem + 7 >= + modems) // Ensure end index does not exceed available modems iEndIdx = modems - 1; - iCurrentIdx = iStartIdx; // Initialize loop variables for modem list display - if (iStartIdx <= iEndIdx) // Check if there are modems to display + iCurrentIdx = iStartIdx; // Initialize loop variables for modem list display + if (iStartIdx <= iEndIdx) // Check if there are modems to display { - iModemOffset = 56 * iStartIdx; // Calculate byte offset into modem buffer (56 bytes per modem) - iYPosition = -18 * iSelectedModem + 18 * iStartIdx + 237;// Calculate Y position for first visible modem (18 pixels per line) - do { // Set highlight color for currently selected modem + iModemOffset = 56 * iStartIdx; // Calculate byte offset into modem buffer + // (56 bytes per modem) + iYPosition = -18 * iSelectedModem + 18 * iStartIdx + + 237; // Calculate Y position for first visible modem (18 + // pixels per line) + do { // Set highlight color for currently selected modem if (iCurrentIdx == iSelectedModem) byTextColor = 0xAB; else byTextColor = 0x8F; - ++iCurrentIdx; // Move to next modem in list - scale_text(front_vga[15], &modembuffer[iModemOffset], font1_ascii, font1_offsets, 400, iYPosition, byTextColor, 1u, 200, 640);// Display modem name from buffer (56 bytes per entry) - iYPosition += 18; // Move to next line (18 pixels down) - iModemOffset += 56; // Move to next modem data (56 bytes forward) - } while (iCurrentIdx <= iEndIdx); // Continue until all visible modems are displayed + ++iCurrentIdx; // Move to next modem in list + scale_text(front_vga[15], &modembuffer[iModemOffset], font1_ascii, + font1_offsets, 400, iYPosition, byTextColor, 1u, 200, + 640); // Display modem name from buffer (56 bytes per entry) + iYPosition += 18; // Move to next line (18 pixels down) + iModemOffset += 56; // Move to next modem data (56 bytes forward) + } while (iCurrentIdx <= + iEndIdx); // Continue until all visible modems are displayed } - copypic(scrbuf, screen); // Copy completed frame buffer to screen - while (fatkbhit()) // Process all pending keyboard input + copypic(scrbuf, screen); // Copy completed frame buffer to screen + while (fatkbhit()) // Process all pending keyboard input { - uiKeyCode = fatgetch(); // Get next character from keyboard buffer - if (uiKeyCode < 0xD) // Check if key code is less than 13 (Enter key) - { // Check for extended key code (0 = function/arrow keys) + uiKeyCode = fatgetch(); // Get next character from keyboard buffer + if (uiKeyCode < 0xD) // Check if key code is less than 13 (Enter key) + { // Check for extended key code (0 = function/arrow keys) if (!uiKeyCode) { - iExtendedKey = fatgetch() - 71; // Get extended key and subtract 71 (base for navigation keys) + iExtendedKey = + fatgetch() - + 71; // Get extended key and subtract 71 (base for navigation keys) iMaxIdx = modems - 1; switch (iExtendedKey) { - case 0: - iSelectedModem = 0; // HOME key (71) - Jump to first modem - continue; - case 1: - if (!iSelectedModem) - continue; // UP key (72) - Move to previous modem - iMaxIdx = iSelectedModem - 1; - LABEL_26: - iSelectedModem = iMaxIdx; // LEFT key (75) and END key (79) - Move to previous modem - break; - case 2: - iSelectedModem -= 15; // PAGE UP key (73) - Move up 15 modems - if (iSelectedModem < 0) - iSelectedModem = 0; - continue; - case 8: - goto LABEL_26; - case 9: - if (iMaxIdx > iSelectedModem) // RIGHT key (77) and DOWN key (80) - Move to next modem - ++iSelectedModem; - continue; - case 10: - iSelectedModem += 15; // PAGE DOWN key (81) - Move down 15 modems - if (iMaxIdx < iSelectedModem) - iSelectedModem = modems - 1; - continue; - default: - continue; + case 0: + iSelectedModem = 0; // HOME key (71) - Jump to first modem + continue; + case 1: + if (!iSelectedModem) + continue; // UP key (72) - Move to previous modem + iMaxIdx = iSelectedModem - 1; + LABEL_26: + iSelectedModem = iMaxIdx; // LEFT key (75) and END key (79) - Move + // to previous modem + break; + case 2: + iSelectedModem -= 15; // PAGE UP key (73) - Move up 15 modems + if (iSelectedModem < 0) + iSelectedModem = 0; + continue; + case 8: + goto LABEL_26; + case 9: + if (iMaxIdx > iSelectedModem) // RIGHT key (77) and DOWN key (80) - + // Move to next modem + ++iSelectedModem; + continue; + case 10: + iSelectedModem += 15; // PAGE DOWN key (81) - Move down 15 modems + if (iMaxIdx < iSelectedModem) + iSelectedModem = modems - 1; + continue; + default: + continue; } } - } else if (uiKeyCode <= 0xD) // Check for Enter key (13) to select modem + } else if (uiKeyCode <= 0xD) // Check for Enter key (13) to select modem { - current_modem = iSelectedModem; // Save selected modem as current choice - pszDestInit = modem_initstring; // Set destination pointer for modem init string copy - pszSrcInit = &modembuffer2.bufPtr[51 * *(int *)&modembuffer[56 * iSelectedModem + 52]];// Calculate source pointer to modem init string (51 bytes per init string) - iExitFlag = -1; // Set exit flag to leave menu + current_modem = iSelectedModem; // Save selected modem as current choice + pszDestInit = modem_initstring; // Set destination pointer for modem + // init string copy + pszSrcInit = + &modembuffer2 + .bufPtr[51 * + *(int *)&modembuffer[56 * iSelectedModem + + 52]]; // Calculate source pointer + // to modem init string (51 + // bytes per init string) + iExitFlag = -1; // Set exit flag to leave menu do { - byChar1 = *pszSrcInit; // Copy modem initialization string (2 bytes per iteration) + byChar1 = *pszSrcInit; // Copy modem initialization string (2 bytes + // per iteration) *pszDestInit = *pszSrcInit; if (!byChar1) - break; // Check for null terminator to end string copy - byChar2 = pszSrcInit[1]; // Copy second byte of character pair + break; // Check for null terminator to end string copy + byChar2 = pszSrcInit[1]; // Copy second byte of character pair pszSrcInit += 2; pszDestInit[1] = byChar2; pszDestInit += 2; - } while (byChar2); // Continue until null terminator found - } else if (uiKeyCode == 27) // Check for Escape key (27) to cancel selection + } while (byChar2); // Continue until null terminator found + } else if (uiKeyCode == + 27) // Check for Escape key (27) to cancel selection { - iExitFlag = -1; // Set exit flag to leave menu without selection + iExitFlag = -1; // Set exit flag to leave menu without selection } } } exit(0); - //JUMPOUT(0x76174); + // JUMPOUT(0x76174); } //------------------------------------------------------------------------------------------------- -//00076F10 -char *getprintstring(const char *szStr, int iEditMode) -{ - char *pszDest; // edi - const char *pszSrc; // esi - char byChar1; // al - char byChar2; // al - unsigned int uiStringLen; // ecx - unsigned int uiCursorPos; // kr08_4 +// 00076F10 +char *getprintstring(const char *szStr, int iEditMode) { + char *pszDest; // edi + const char *pszSrc; // esi + char byChar1; // al + char byChar2; // al + unsigned int uiStringLen; // ecx + unsigned int uiCursorPos; // kr08_4 unsigned int uiLastCharIdx; // ecx - char *pszTruncDest; // edi - const char *pszTruncSrc; // esi - char byTruncChar1; // al - char byTruncChar2; // al - unsigned int uiTruncLen; // ecx - unsigned int uiFinalLen; // ecx + char *pszTruncDest; // edi + const char *pszTruncSrc; // esi + char byTruncChar1; // al + char byTruncChar2; // al + unsigned int uiTruncLen; // ecx + unsigned int uiFinalLen; // ecx - pszDest = modembuffer2.buffer; // Initialize destination pointer to modembuffer2[1] (skip first byte) - pszSrc = szStr; // Initialize source pointer to input string + pszDest = modembuffer2.buffer; // Initialize destination pointer to + // modembuffer2[1] (skip first byte) + pszSrc = szStr; // Initialize source pointer to input string do { - byChar1 = *pszSrc; // Copy string 2 bytes at a time to destination buffer + byChar1 = *pszSrc; // Copy string 2 bytes at a time to destination buffer *pszDest = *pszSrc; if (!byChar1) break; @@ -744,21 +849,28 @@ char *getprintstring(const char *szStr, int iEditMode) pszDest[1] = byChar2; pszDest += 2; } while (byChar2); - if (iEditMode) // If in edit mode, add cursor and handle text width + if (iEditMode) // If in edit mode, add cursor and handle text width { - uiCursorPos = (int)strlen(modembuffer2.buffer) + 1;// Get string length and add underscore cursor at end + uiCursorPos = (int)strlen(modembuffer2.buffer) + + 1; // Get string length and add underscore cursor at end uiLastCharIdx = uiCursorPos - 1; - modembuffer2.buffer[uiLastCharIdx] = '_'; // Place underscore cursor at end of string (ASCII 95 = '_') + modembuffer2.buffer[uiLastCharIdx] = + '_'; // Place underscore cursor at end of string (ASCII 95 = '_') modembuffer2.buffer[uiLastCharIdx + 1] = '\0'; - if (stringwidth(modembuffer2.buffer) <= 240)// Check if string width fits in 240 pixel limit + if (stringwidth(modembuffer2.buffer) <= + 240) // Check if string width fits in 240 pixel limit { uiFinalLen = uiCursorPos; } else { - pszTruncDest = &modembuffer2.buffer[3]; // String too wide - truncate with ellipsis (...) + pszTruncDest = + &modembuffer2 + .buffer[3]; // String too wide - truncate with ellipsis (...) pszTruncSrc = szStr; - memset(modembuffer2.buffer, 46, 3); // Set first 3 chars to dots (0x2E2E2E = "...") + memset(modembuffer2.buffer, 46, + 3); // Set first 3 chars to dots (0x2E2E2E = "...") do { - byTruncChar1 = *pszTruncSrc; // Copy remainder of source string after ellipsis + byTruncChar1 = + *pszTruncSrc; // Copy remainder of source string after ellipsis *pszTruncDest = *pszTruncSrc; if (!byTruncChar1) break; @@ -770,167 +882,224 @@ char *getprintstring(const char *szStr, int iEditMode) modembuffer2.buffer[uiLastCharIdx + 4] = '\0'; modembuffer2.buffer[uiLastCharIdx + 3] = '_'; uiTruncLen = uiCursorPos; - while (stringwidth(modembuffer2.buffer) > 240)// Shrink string from beginning until it fits width limit + while (stringwidth(modembuffer2.buffer) > + 240) // Shrink string from beginning until it fits width limit memmove(&modembuffer2.buffer[3], &modembuffer2.buffer[4], uiTruncLen--); uiFinalLen = uiTruncLen + 3; } - if ((frames & 0xFu) >= 8) // Blinking cursor: hide cursor every 8 frames + if ((frames & 0xFu) >= 8) // Blinking cursor: hide cursor every 8 frames modembuffer2.buffer[uiFinalLen - 1] = '\0'; - } else if (stringwidth((char *)szStr) > 240) // Not in edit mode - just check if string fits + } else if (stringwidth((char *)szStr) > + 240) // Not in edit mode - just check if string fits { uiStringLen = (int)strlen(modembuffer2.buffer); do { - modembuffer2.buffer[uiStringLen - 1] = '.';// Truncate from end with "..." until string fits + modembuffer2.buffer[uiStringLen - 1] = + '.'; // Truncate from end with "..." until string fits modembuffer2.buffer[uiStringLen] = '.'; modembuffer2.buffer[uiStringLen + 1] = '.'; modembuffer2.buffer[uiStringLen-- + 2] = '\0'; } while (stringwidth(modembuffer2.buffer) > 240); } - return modembuffer2.buffer; // Return pointer to formatted string in modembuffer2[1] + return modembuffer2 + .buffer; // Return pointer to formatted string in modembuffer2[1] } //------------------------------------------------------------------------------------------------- -//00077060 -void display_essentials(int iSelectedItem, int iHighlightedItem, int iEditMode) -{ - char byTextColor1; // al - char byTextColor2; // al - char byTextColor3; // al - char byTextColor4; // al - char byTextColor5; // al - char byTextColor6; // al - char byTextColor7; // al - char byTextColor8; // al - char byTextColor9; // al - bool bIsInitEditMode; // edx - char *pszInitString; // eax - char byTextColor10; // al - char byTextColor11; // al +// 00077060 +void display_essentials(int iSelectedItem, int iHighlightedItem, + int iEditMode) { + char byTextColor1; // al + char byTextColor2; // al + char byTextColor3; // al + char byTextColor4; // al + char byTextColor5; // al + char byTextColor6; // al + char byTextColor7; // al + char byTextColor8; // al + char byTextColor9; // al + bool bIsInitEditMode; // edx + char *pszInitString; // eax + char byTextColor10; // al + char byTextColor11; // al bool bIsPhoneEditMode; // edx - char *pszPhoneString; // eax - char byTextColor12; // al - char byTextColor13; // al - char byInitTextColor; // [esp-10h] [ebp-78h] + char *pszPhoneString; // eax + char byTextColor12; // al + char byTextColor13; // al + char byInitTextColor; // [esp-10h] [ebp-78h] char byPhoneTextColor; // [esp-10h] [ebp-78h] - char szText[100]; // [esp+0h] [ebp-68h] BYREF - int iBlockIdx; // [esp+64h] [ebp-4h] + char szText[100]; // [esp+0h] [ebp-68h] BYREF + int iBlockIdx; // [esp+64h] [ebp-4h] - iBlockIdx = iSelectedItem; // Store selected block index for gear selection display - display_picture(scrbuf, front_vga[0]); // Display main background picture (modem config screen) - display_block(scrbuf, front_vga[1], 3, head_x, head_y, 0);// Display driver head icon at current position - display_block(scrbuf, front_vga[6], 0, 36, 2, 0);// Display UI element at position (36, 2) - display_block(scrbuf, front_vga[5], iBlockIdx, -4, 247, 0);// Display selected gear indicator at bottom left - display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, 0);// Display game type indicator (5 + game_type offset) - display_block(scrbuf, front_vga[4], 4, 76, 257, -1);// Display UI element at position (76, 257) with special color (-1) - display_block(scrbuf, front_vga[6], 4, 62, 336, -1);// Display UI element at position (62, 336) with special color (-1) - scale_text(front_vga[15], &language_buffer[5376], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640);// Display main menu title text - if (modembuffer) // Check if modem data is available - { // Check if no modem is currently selected (negative index) - if (current_modem < 0) { // Set color for 'no modem' text based on highlight state + iBlockIdx = + iSelectedItem; // Store selected block index for gear selection display + display_picture( + scrbuf, + front_vga[0]); // Display main background picture (modem config screen) + display_block(scrbuf, front_vga[1], 3, head_x, head_y, + 0); // Display driver head icon at current position + display_block(scrbuf, front_vga[6], 0, 36, 2, + 0); // Display UI element at position (36, 2) + display_block(scrbuf, front_vga[5], iBlockIdx, -4, 247, + 0); // Display selected gear indicator at bottom left + display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, + 0); // Display game type indicator (5 + game_type offset) + display_block( + scrbuf, front_vga[4], 4, 76, 257, + -1); // Display UI element at position (76, 257) with special color (-1) + display_block( + scrbuf, front_vga[6], 4, 62, 336, + -1); // Display UI element at position (62, 336) with special color (-1) + scale_text(front_vga[15], &language_buffer[5376], font1_ascii, font1_offsets, + 400, 75, 143, 1u, 200, 640); // Display main menu title text + if (modembuffer) // Check if modem data is available + { // Check if no modem is currently selected (negative index) + if (current_modem < + 0) { // Set color for 'no modem' text based on highlight state if (iHighlightedItem) byTextColor2 = 0x8F; else byTextColor2 = 0xAB; - scale_text(front_vga[15], &language_buffer[6848], font1_ascii, font1_offsets, 400, 117, byTextColor2, 1u, 200, 640);// Display 'no modem selected' message - } else { // Set color for modem name based on highlight state + scale_text(front_vga[15], &language_buffer[6848], font1_ascii, + font1_offsets, 400, 117, byTextColor2, 1u, 200, + 640); // Display 'no modem selected' message + } else { // Set color for modem name based on highlight state if (iHighlightedItem) byTextColor1 = 0x8F; else byTextColor1 = 0xAB; - scale_text(front_vga[15], &modembuffer[56 * current_modem], font1_ascii, font1_offsets, 400, 117, byTextColor1, 1u, 200, 640);// Display selected modem name (56 bytes per modem entry) + scale_text(front_vga[15], &modembuffer[56 * current_modem], font1_ascii, + font1_offsets, 400, 117, byTextColor1, 1u, 200, + 640); // Display selected modem name (56 bytes per modem entry) } } - sprintf(szText, "COM %d", modem_port); // Format COM port number into text buffer - if (iHighlightedItem == 1) // Set colors for COM port label (item 1) + sprintf(szText, "COM %d", + modem_port); // Format COM port number into text buffer + if (iHighlightedItem == 1) // Set colors for COM port label (item 1) byTextColor3 = 0xAB; else byTextColor3 = 0x8F; - scale_text(front_vga[15], &language_buffer[5440], font1_ascii, font1_offsets, 400, 135, byTextColor3, 2u, 200, 640);// Display COM port label text - if (iHighlightedItem == 1) // Set colors for COM port value (item 1) + scale_text(front_vga[15], &language_buffer[5440], font1_ascii, font1_offsets, + 400, 135, byTextColor3, 2u, 200, + 640); // Display COM port label text + if (iHighlightedItem == 1) // Set colors for COM port value (item 1) byTextColor4 = 0xAB; else byTextColor4 = 0x8F; - scale_text(front_vga[15], szText, font1_ascii, font1_offsets, 400, 135, byTextColor4, 0, 200, 640);// Display COM port number (e.g. 'COM 1') - if (iHighlightedItem == 2) // Set colors for dial mode label (item 2) + scale_text(front_vga[15], szText, font1_ascii, font1_offsets, 400, 135, + byTextColor4, 0, 200, + 640); // Display COM port number (e.g. 'COM 1') + if (iHighlightedItem == 2) // Set colors for dial mode label (item 2) byTextColor5 = 0xAB; else byTextColor5 = 0x8F; - scale_text(front_vga[15], &language_buffer[5504], font1_ascii, font1_offsets, 400, 153, byTextColor5, 2u, 200, 640);// Display dial mode label text - if (modem_tone) // Check if tone dialing is enabled - { // Set colors for 'TONE' mode display + scale_text(front_vga[15], &language_buffer[5504], font1_ascii, font1_offsets, + 400, 153, byTextColor5, 2u, 200, + 640); // Display dial mode label text + if (modem_tone) // Check if tone dialing is enabled + { // Set colors for 'TONE' mode display if (iHighlightedItem == 2) byTextColor6 = 0xAB; else byTextColor6 = 0x8F; - scale_text(front_vga[15], &language_buffer[5568], font1_ascii, font1_offsets, 400, 153, byTextColor6, 0, 200, 640);// Display 'TONE' dialing mode text - } else { // Set colors for 'PULSE' mode display + scale_text(front_vga[15], &language_buffer[5568], font1_ascii, + font1_offsets, 400, 153, byTextColor6, 0, 200, + 640); // Display 'TONE' dialing mode text + } else { // Set colors for 'PULSE' mode display if (iHighlightedItem == 2) byTextColor7 = 0xAB; else byTextColor7 = 0x8F; - scale_text(front_vga[15], &language_buffer[5632], font1_ascii, font1_offsets, 400, 153, byTextColor7, 0, 200, 640);// Display 'PULSE' dialing mode text + scale_text(front_vga[15], &language_buffer[5632], font1_ascii, + font1_offsets, 400, 153, byTextColor7, 0, 200, + 640); // Display 'PULSE' dialing mode text } - if (iHighlightedItem == 3) // Set colors for modem init string label (item 3) + if (iHighlightedItem == 3) // Set colors for modem init string label (item 3) byTextColor8 = 0xAB; else byTextColor8 = 0x8F; - scale_text(front_vga[15], &language_buffer[5696], font1_ascii, font1_offsets, 400, 171, byTextColor8, 2u, 200, 640);// Display modem initialization string label - if (iHighlightedItem == 3) // Set colors for init string value (item 3) + scale_text(front_vga[15], &language_buffer[5696], font1_ascii, font1_offsets, + 400, 171, byTextColor8, 2u, 200, + 640); // Display modem initialization string label + if (iHighlightedItem == 3) // Set colors for init string value (item 3) byTextColor9 = 0xAB; else byTextColor9 = 0x8F; byInitTextColor = byTextColor9; - bIsInitEditMode = iHighlightedItem == 3 && iEditMode == 1;// Check if init string is in edit mode (item 3 + edit flag) - pszInitString = (char *)getprintstring(modem_initstring, bIsInitEditMode);// Get printable version of init string (handles edit cursor) - scale_text(front_vga[15], pszInitString, font1_ascii, font1_offsets, 400, 171, byInitTextColor, 0, 200, 640);// Display modem initialization string - if (iHighlightedItem == 4) // Set colors for phone number label (item 4) + bIsInitEditMode = + iHighlightedItem == 3 && + iEditMode == + 1; // Check if init string is in edit mode (item 3 + edit flag) + pszInitString = (char *)getprintstring( + modem_initstring, bIsInitEditMode); // Get printable version of init + // string (handles edit cursor) + scale_text(front_vga[15], pszInitString, font1_ascii, font1_offsets, 400, 171, + byInitTextColor, 0, 200, + 640); // Display modem initialization string + if (iHighlightedItem == 4) // Set colors for phone number label (item 4) byTextColor10 = 0xAB; else byTextColor10 = 0x8F; - scale_text(front_vga[15], &language_buffer[5760], font1_ascii, font1_offsets, 400, 189, byTextColor10, 2u, 200, 640);// Display phone number label text - if (iHighlightedItem == 4) // Set colors for phone number value (item 4) + scale_text(front_vga[15], &language_buffer[5760], font1_ascii, font1_offsets, + 400, 189, byTextColor10, 2u, 200, + 640); // Display phone number label text + if (iHighlightedItem == 4) // Set colors for phone number value (item 4) byTextColor11 = 0xAB; else byTextColor11 = 0x8F; byPhoneTextColor = byTextColor11; - bIsPhoneEditMode = iHighlightedItem == 4 && iEditMode == 1;// Check if phone number is in edit mode (item 4 + edit flag) - pszPhoneString = (char *)getprintstring(modem_phone, bIsPhoneEditMode);// Get printable version of phone number (handles edit cursor) - scale_text(front_vga[15], pszPhoneString, font1_ascii, font1_offsets, 400, 189, byPhoneTextColor, 0, 200, 640);// Display phone number string - if (iHighlightedItem == 5) // Set colors for 'Accept' button (item 5) + bIsPhoneEditMode = + iHighlightedItem == 4 && + iEditMode == + 1; // Check if phone number is in edit mode (item 4 + edit flag) + pszPhoneString = (char *)getprintstring( + modem_phone, bIsPhoneEditMode); // Get printable version of phone number + // (handles edit cursor) + scale_text(front_vga[15], pszPhoneString, font1_ascii, font1_offsets, 400, + 189, byPhoneTextColor, 0, 200, 640); // Display phone number string + if (iHighlightedItem == 5) // Set colors for 'Accept' button (item 5) byTextColor12 = 0xAB; else byTextColor12 = 0x8F; - scale_text(front_vga[15], &language_buffer[5824], font1_ascii, font1_offsets, 400, 225, byTextColor12, 1u, 200, 640);// Display 'Accept' button text - if (iHighlightedItem == 6) // Set colors for 'Cancel' button (item 6) + scale_text(front_vga[15], &language_buffer[5824], font1_ascii, font1_offsets, + 400, 225, byTextColor12, 1u, 200, + 640); // Display 'Accept' button text + if (iHighlightedItem == 6) // Set colors for 'Cancel' button (item 6) byTextColor13 = 0xAB; else byTextColor13 = 0x8F; - scale_text(front_vga[15], &language_buffer[5888], font1_ascii, font1_offsets, 400, 243, byTextColor13, 1u, 200, 640);// Display 'Cancel' button text - if (no_16550) // Check if 16550 UART error occurred - scale_text(front_vga[15], &language_buffer[64 * no_16550], font1_ascii, font1_offsets, 400, 351, 231, 1u, 200, 640);// Display 16550 error message (64 bytes per error code) + scale_text(front_vga[15], &language_buffer[5888], font1_ascii, font1_offsets, + 400, 243, byTextColor13, 1u, 200, + 640); // Display 'Cancel' button text + if (no_16550) // Check if 16550 UART error occurred + scale_text(front_vga[15], &language_buffer[64 * no_16550], font1_ascii, + font1_offsets, 400, 351, 231, 1u, 200, + 640); // Display 16550 error message (64 bytes per error code) } //------------------------------------------------------------------------------------------------- -//00077560 -void check16550(int iPort) -{ // Test if 16550 UART is available at the specified port - //TODO - //if (gss16550(iPort)) { +// 00077560 +void check16550( + int iPort) { // Test if 16550 UART is available at the specified port + // TODO + // if (gss16550(iPort)) { if (true) { - no_16550 = 0; // 16550 UART detected - clear error flag (0 = success) - } else if (MusicCD) // 16550 not found - check if CD music is enabled + no_16550 = 0; // 16550 UART detected - clear error flag (0 = success) + } else if (MusicCD) // 16550 not found - check if CD music is enabled { - no_16550 = 110; // CD music available - set error code 110 (CD audio fallback) + no_16550 = + 110; // CD music available - set error code 110 (CD audio fallback) } else { - no_16550 = 109; // No 16550 and no CD music - set error code 109 (no audio support) + no_16550 = + 109; // No 16550 and no CD music - set error code 109 (no audio support) } - if (no_16550 == 109) // Check if complete audio failure occurred (code 109) + if (no_16550 == 109) // Check if complete audio failure occurred (code 109) { - musicon = 0; // Disable music playback due to hardware failure - reinitmusic(); // Reinitialize music system with new settings + musicon = 0; // Disable music playback due to hardware failure + reinitmusic(); // Reinitialize music system with new settings } - if (no_16550) // Check if any 16550 error occurred - soundon = 0; // Disable all sound effects if 16550 hardware issues detected + if (no_16550) // Check if any 16550 error occurred + soundon = 0; // Disable all sound effects if 16550 hardware issues detected } //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/comms.h b/PROJECTS/ROLLER/comms.h index 719ea5cf..b95b19a5 100644 --- a/PROJECTS/ROLLER/comms.h +++ b/PROJECTS/ROLLER/comms.h @@ -4,16 +4,14 @@ #include "types.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { char *bufPtr; char buffer[100]; } tModemBuffer2; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iKeycode; int iCharacter; } tKeycodePair; diff --git a/PROJECTS/ROLLER/control.c b/PROJECTS/ROLLER/control.c index bec9125d..d44870ab 100644 --- a/PROJECTS/ROLLER/control.c +++ b/PROJECTS/ROLLER/control.c @@ -17,140 +17,154 @@ #include //------------------------------------------------------------------------------------------------- -float levels[7] = { 100.0f, 97.0f, 94.0f, 90.0f, 85.0f, 80.0f, -1.0f }; //000A4290 -float mineff[6] = { 1.0f, 0.95999998f, 0.92000002f, 0.88f, 0.83999997f, 0.80000001f }; //000A42AC -int flipst[6] = { 0, 20, 40, 60, 80, 100 }; //000A42C4 -int level = 3; //000A42DC -tCarStrategy CarStrategy[16] = //000A42E8 -{ - { { 20, 40, 40, 0, 2 }, 2.5f, 1.0f, 3.0f, 1.0f, 5000.0f }, - { { 50, 30, 10, 10, 0 }, 4.0f, 1.0f, 2.8f, 1.0f, 5000.0f }, - { { 70, 20, 5, 5, 0 }, 2.0f, 1.0f, 1.6f, 1.6f, 5000.0f }, - { { 90, 5, 0, 5, 0 }, 1.4f, 1.0f, 4.0f, 3.0f, 5000.0f }, - { { 10, 50, 35, 5, 2 }, 1.4f, 1.0f, 3.0999999f, 1.0f, 9000.0f }, - { { 30, 45, 5, 20, 0 }, 2.0f, 1.0f, 2.0f, 1.0f, 9000.0f }, - { { 10, 20, 70, 0, 4 }, 2.0f, 2.0f, 4.3000002f, 1.0f, 8000.0f }, - { { 30, 30, 5, 35, 2 }, 2.5f, 1.2f, 2.8f, 1.0f, 8000.0f }, - { { 25, 25, 25, 25, 40 }, 3.0f, 2.0f, 3.0f, 2.0f, 5000.0f }, - { { 20, 70, 5, 5, 0 }, 1.4f, 1.0f, 2.0f, 1.0f, 5000.0f }, - { { 70, 5, 5, 20, 0 }, 2.0f, 1.0f, 4.0f, 1.4f, 5000.0f }, - { { 15, 75, 5, 5, 0 }, 1.4f, 1.0f, 3.4000001f, 1.0f, 5000.0f }, - { { 70, 20, 10, 0, 0 }, 3.0f, 1.0f, 4.0f, 1.0f, 11000.0f }, - { { 85, 5, 5, 5, 0 }, 3.0f, 1.0f, 4.0f, 1.4f, 11000.0f }, - { { 20, 60, 5, 15, 0 }, 4.0f, 1.2f, 4.0f, 1.4f, 9000.0f }, - { { 20, 40, 0, 40, 1 }, 3.0f, 2.0f, 3.4000001f, 1.0f, 9000.0f } -}; -int nearcall[4][4]; //00149750 -int carorder[16]; //00149790 -int stops[10]; //001497D0 -float trial_times[96]; //001497F8 -float eng_chg_revs[168]; //00149978 -int FirstTick; //00149C18 -int JBYmax; //00149C24 -int JBYmin; //00149C30 -int JBXmin; //00149C34 -int JBXmax; //00149C3C -int JAYmax; //00149C40 -int JAXmax; //00149C44 -int numstops; //00149C48 -int JAYmin; //00149C4C -int JAXmin; //00149C50 -int race_started; //00149C54 -int updates; //00149C58 -float RecordLaps[25]; //00149C5C -int RecordCars[25]; //00149CC0 -int RecordKills[25]; //00149D24 -int Destroyed; //00149D8C -int nearcarcheck; //00149D90 -int ahead_sect; //00149D94 -int ahead_time; //00149D98 -int Victim; //00149D9C -int Fatality; //00149DB0 -int Fatality_Count; //00149DB4 -int cheat_control; //00149DB8 -int rightang; //00149DBC -int leftang; //00149DC0 -int fudge_wait; //00149DC4 -char RecordNames[25][9]; //00149DC8 +float levels[7] = {100.0f, 97.0f, 94.0f, 90.0f, + 85.0f, 80.0f, -1.0f}; // 000A4290 +float mineff[6] = {1.0f, 0.95999998f, 0.92000002f, + 0.88f, 0.83999997f, 0.80000001f}; // 000A42AC +int flipst[6] = {0, 20, 40, 60, 80, 100}; // 000A42C4 +int level = 3; // 000A42DC +tCarStrategy CarStrategy[16] = // 000A42E8 + {{{20, 40, 40, 0, 2}, 2.5f, 1.0f, 3.0f, 1.0f, 5000.0f}, + {{50, 30, 10, 10, 0}, 4.0f, 1.0f, 2.8f, 1.0f, 5000.0f}, + {{70, 20, 5, 5, 0}, 2.0f, 1.0f, 1.6f, 1.6f, 5000.0f}, + {{90, 5, 0, 5, 0}, 1.4f, 1.0f, 4.0f, 3.0f, 5000.0f}, + {{10, 50, 35, 5, 2}, 1.4f, 1.0f, 3.0999999f, 1.0f, 9000.0f}, + {{30, 45, 5, 20, 0}, 2.0f, 1.0f, 2.0f, 1.0f, 9000.0f}, + {{10, 20, 70, 0, 4}, 2.0f, 2.0f, 4.3000002f, 1.0f, 8000.0f}, + {{30, 30, 5, 35, 2}, 2.5f, 1.2f, 2.8f, 1.0f, 8000.0f}, + {{25, 25, 25, 25, 40}, 3.0f, 2.0f, 3.0f, 2.0f, 5000.0f}, + {{20, 70, 5, 5, 0}, 1.4f, 1.0f, 2.0f, 1.0f, 5000.0f}, + {{70, 5, 5, 20, 0}, 2.0f, 1.0f, 4.0f, 1.4f, 5000.0f}, + {{15, 75, 5, 5, 0}, 1.4f, 1.0f, 3.4000001f, 1.0f, 5000.0f}, + {{70, 20, 10, 0, 0}, 3.0f, 1.0f, 4.0f, 1.0f, 11000.0f}, + {{85, 5, 5, 5, 0}, 3.0f, 1.0f, 4.0f, 1.4f, 11000.0f}, + {{20, 60, 5, 15, 0}, 4.0f, 1.2f, 4.0f, 1.4f, 9000.0f}, + {{20, 40, 0, 40, 1}, 3.0f, 2.0f, 3.4000001f, 1.0f, 9000.0f}}; +int nearcall[4][4]; // 00149750 +int carorder[16]; // 00149790 +int stops[10]; // 001497D0 +float trial_times[96]; // 001497F8 +float eng_chg_revs[168]; // 00149978 +int FirstTick; // 00149C18 +int JBYmax; // 00149C24 +int JBYmin; // 00149C30 +int JBXmin; // 00149C34 +int JBXmax; // 00149C3C +int JAYmax; // 00149C40 +int JAXmax; // 00149C44 +int numstops; // 00149C48 +int JAYmin; // 00149C4C +int JAXmin; // 00149C50 +int race_started; // 00149C54 +int updates; // 00149C58 +float RecordLaps[25]; // 00149C5C +int RecordCars[25]; // 00149CC0 +int RecordKills[25]; // 00149D24 +int Destroyed; // 00149D8C +int nearcarcheck; // 00149D90 +int ahead_sect; // 00149D94 +int ahead_time; // 00149D98 +int Victim; // 00149D9C +int Fatality; // 00149DB0 +int Fatality_Count; // 00149DB4 +int cheat_control; // 00149DB8 +int rightang; // 00149DBC +int leftang; // 00149DC0 +int fudge_wait; // 00149DC4 +char RecordNames[25][9]; // 00149DC8 //------------------------------------------------------------------------------------------------- -//00029640 -void humancar(int iCarIdx) -{ - int iTrakLen; // ebp - int iInput; // eax - int iSteeringInput; // edi - uint16 unFlags; // ax - int byCarDesignIdx; // esi - int iFinisherCount; // edx - int iCarIndex1; // ecx - int iCarIndex2; // eax - uint8 byCheatAmmo_1; // bl - int iCurrentChunk; // eax - int iColorIndex; // edx - int iTrackColor1; // ecx - int iTrackColor2; // esi - int iTrackColor3; // ecx - uint8 byNewCheatAmmo; // ch - uint8 byCheatAmmo; // bh - int iSoundEffect1; // eax - int iTargetCarIdx; // eax - int iTargetCar1; // edx - int iTargetCar2; // edx - int iPlayerIdx; // eax - uint8 byCheatAmmo_2; // bh - int iSoundEffect2; // eax - int iJumpTargetIdx; // eax - int iJumpTarget; // ebx - int iJumpTargetCar; // eax - int iTargetCarDesign; // ecx - double dNewZ; // st7 - uint8 byCheatAmmo_3; // cl - int iSoundEffect3; // eax - int iTeleportTargetIdx; // eax - int iTeleportTarget; // esi - int nReferenceChunk; // ecx - int nPitch; // edx - int nCurrChunk; // edi - tVec3 *posAy; // edi - double dLocalZ; // st7 - float fChunkValue; // eax - int iPlayerIdx2; // eax - tCar *pCar; // eax - int iElevation; // [esp+0h] [ebp-40h] BYREF - int iAzimuth; // [esp+4h] [ebp-3Ch] BYREF - int iBank; // [esp+8h] [ebp-38h] BYREF - float fLocalZ; // [esp+Ch] [ebp-34h] - int iAzi2; // [esp+10h] [ebp-30h] BYREF - float fLocalX; // [esp+14h] [ebp-2Ch] - float fLocalY; // [esp+18h] [ebp-28h] +// 00029640 +void humancar(int iCarIdx) { + int iTrakLen; // ebp + int iInput; // eax + int iSteeringInput; // edi + uint16 unFlags; // ax + int byCarDesignIdx; // esi + int iFinisherCount; // edx + int iCarIndex1; // ecx + int iCarIndex2; // eax + uint8 byCheatAmmo_1; // bl + int iCurrentChunk; // eax + int iColorIndex; // edx + int iTrackColor1; // ecx + int iTrackColor2; // esi + int iTrackColor3; // ecx + uint8 byNewCheatAmmo; // ch + uint8 byCheatAmmo; // bh + int iSoundEffect1; // eax + int iTargetCarIdx; // eax + int iTargetCar1; // edx + int iTargetCar2; // edx + int iPlayerIdx; // eax + uint8 byCheatAmmo_2; // bh + int iSoundEffect2; // eax + int iJumpTargetIdx; // eax + int iJumpTarget; // ebx + int iJumpTargetCar; // eax + int iTargetCarDesign; // ecx + double dNewZ; // st7 + uint8 byCheatAmmo_3; // cl + int iSoundEffect3; // eax + int iTeleportTargetIdx; // eax + int iTeleportTarget; // esi + int nReferenceChunk; // ecx + int nPitch; // edx + int nCurrChunk; // edi + tVec3 *posAy; // edi + double dLocalZ; // st7 + float fChunkValue; // eax + int iPlayerIdx2; // eax + tCar *pCar; // eax + int iElevation; // [esp+0h] [ebp-40h] BYREF + int iAzimuth; // [esp+4h] [ebp-3Ch] BYREF + int iBank; // [esp+8h] [ebp-38h] BYREF + float fLocalZ; // [esp+Ch] [ebp-34h] + int iAzi2; // [esp+10h] [ebp-30h] BYREF + float fLocalX; // [esp+14h] [ebp-2Ch] + float fLocalY; // [esp+18h] [ebp-28h] int iTeleportTargetIndex; // [esp+1Ch] [ebp-24h] - int iCarIdx_1; // [esp+20h] [ebp-20h] - int iControlFlags; // [esp+24h] [ebp-1Ch] + int iCarIdx_1; // [esp+20h] [ebp-20h] + int iControlFlags; // [esp+24h] [ebp-1Ch] - iTrakLen = TRAK_LEN; // Initialize track length and player index + iTrakLen = TRAK_LEN; // Initialize track length and player index iCarIdx_1 = iCarIdx; - iInput = (int16)copy_multiple[readptr][iCarIdx].data.unInput;// Extract steering input and control flags from player input data + iInput = (int16)copy_multiple[readptr][iCarIdx] + .data.unInput; // Extract steering input and control flags from + // player input data iSteeringInput = iInput / 256; - //iSteeringInput = (unInput - (__CFSHL__(unInput >> 31, 8) + (unInput >> 31 << 8))) >> 8; + // iSteeringInput = (unInput - (__CFSHL__(unInput >> 31, 8) + (unInput >> 31 + // << 8))) >> 8; unFlags = copy_multiple[readptr][iCarIdx_1].data.unFlags; byCarDesignIdx = Car[iCarIdx_1].byCarDesignIdx; iControlFlags = unFlags; - //LOWORD(iControlFlags) = unFlags; - if (byCarDesignIdx < 8) // Enable cheat mode for special car designs (8-12), disable for normal cars + // LOWORD(iControlFlags) = unFlags; + if (byCarDesignIdx < 8) // Enable cheat mode for special car designs (8-12), + // disable for normal cars cheat_control = 0; else cheat_control = unFlags & 0x20; - if (finished_car[iCarIdx_1] || racers - 1 == finishers && Car[iCarIdx_1].byLap < NoOfLaps && competitors > 1)// Force brake mode if car finished or race is over for this player + if (finished_car[iCarIdx_1] || + racers - 1 == finishers && Car[iCarIdx_1].byLap < NoOfLaps && + competitors > 1) // Force brake mode if car finished or race is over + // for this player iControlFlags = 2; - //LOWORD(iControlFlags) = 2; - //if (racers - 1 == finishers && Car[iCarIdx_1].byLap < NoOfLaps && (LODWORD(Car[iCarIdx_1].fFinalSpeed) & 0x7FFFFFFF) == 0 && competitors > 1)// Handle race finish condition: play finish sounds and mark player as finished - if (racers - 1 == finishers && Car[iCarIdx_1].byLap < NoOfLaps && fabs(Car[iCarIdx_1].fFinalSpeed) == 0 && competitors > 1)// Handle race finish condition: play finish sounds and mark player as finished + // LOWORD(iControlFlags) = 2; + // if (racers - 1 == finishers && Car[iCarIdx_1].byLap < NoOfLaps && + // (LODWORD(Car[iCarIdx_1].fFinalSpeed) & 0x7FFFFFFF) == 0 && competitors > + // 1)// Handle race finish condition: play finish sounds and mark player as + // finished + if (racers - 1 == finishers && Car[iCarIdx_1].byLap < NoOfLaps && + fabs(Car[iCarIdx_1].fFinalSpeed) == 0 && + competitors > 1) // Handle race finish condition: play finish sounds and + // mark player as finished { if (player1_car == iCarIdx_1 || player2_car == iCarIdx_1) { if ((char)Car[iCarIdx_1].byLives > 0) - speechsample(SOUND_SAMPLE_RUBBISH, 0x8000, 18, iCarIdx_1);// SOUND_SAMPLE_RUBBISH - speechsample(SOUND_SAMPLE_RACEOVER, 0x8000, 18, iCarIdx_1); // SOUND_SAMPLE_RACEOVER + speechsample(SOUND_SAMPLE_RUBBISH, 0x8000, 18, + iCarIdx_1); // SOUND_SAMPLE_RUBBISH + speechsample(SOUND_SAMPLE_RACEOVER, 0x8000, 18, + iCarIdx_1); // SOUND_SAMPLE_RACEOVER } iTrakLen = TRAK_LEN; iFinisherCount = human_finishers; @@ -158,388 +172,468 @@ void humancar(int iCarIdx) human_finishers = iFinisherCount + 1; ++finishers; } - if (Car[iCarIdx_1].fHealth <= 0.0) // Disable controls if car health is zero or below + if (Car[iCarIdx_1].fHealth <= + 0.0) // Disable controls if car health is zero or below iControlFlags = 0; - //LOWORD(unControlFlags) = 0; + // LOWORD(unControlFlags) = 0; iCarIndex1 = iCarIdx_1; iCarIndex2 = iCarIdx_1; - Car[iCarIdx_1].iSteeringInput = iSteeringInput;// Store steering input and handle cheat power activation + Car[iCarIdx_1].iSteeringInput = + iSteeringInput; // Store steering input and handle cheat power activation if (!cheat_control) goto PROCESS_VEHICLE_CONTROLS; switch (byCarDesignIdx) { - case 8: // SUICYCO (explode opponent) - if (Car[iCarIndex1].byCheatCooldown) // Car type 8: finds nearest car and applies massive damage - goto PROCESS_VEHICLE_CONTROLS; - byCheatAmmo = Car[iCarIndex1].byCheatAmmo; - TRAK_LEN = iTrakLen; - if (!byCheatAmmo) { - if (!cheatsampleok(iCarIndex1)) - goto SET_DAMAGE_COOLDOWN; - iSoundEffect1 = SOUND_SAMPLE_BLOP; - goto PLAY_DAMAGE_SOUND; - } - if (Car[iCarIndex1].nCurrChunk == -1) { - if (!cheatsampleok(iCarIndex1)) - goto SET_DAMAGE_COOLDOWN; - iSoundEffect1 = SOUND_SAMPLE_BRP; - goto PLAY_DAMAGE_SOUND; - } - iTargetCarIdx = findcardistance(iCarIndex1, 8000.0);// Find target car within range (8000 units) - iTargetCar1 = iTargetCarIdx; - if (iTargetCarIdx >= 0 && Car[iTargetCarIdx].nCurrChunk != -1 && Car[iTargetCarIdx].byCarDesignIdx != 13) { - Car[iTargetCarIdx].byAttacker = iCarIdx_1;// Apply damage: 200 damage, stop target car, consume ammo - Car[iTargetCarIdx].byDamageSourceTimer = -40; - dodamage(&Car[iTargetCarIdx], 200.0); - Car[iTargetCar1].fFinalSpeed = 0.0; - Car[iTargetCar1].byGearAyMax = 0; - Car[iTargetCar1].fBaseSpeed = 0.0; - Car[iTargetCar1].fSpeedOverflow = 0.0; - Car[iTargetCar1].fRPMRatio = 0.0; - iTargetCar2 = iTargetCar1; - Car[iTargetCar2].fPower = 0.0; - iPlayerIdx = iCarIdx_1; - Car[iTargetCar2].nDeathTimer = 18; - --Car[iPlayerIdx].byCheatAmmo; - goto SET_DAMAGE_COOLDOWN; - } - if (cheatsampleok(iCarIdx_1)) { - iSoundEffect1 = SOUND_SAMPLE_BRP; - PLAY_DAMAGE_SOUND: - sfxsample(iSoundEffect1, 0x8000); - } - SET_DAMAGE_COOLDOWN: - iTrakLen = TRAK_LEN; - Car[iCarIdx_1].byCheatCooldown = 36; // Set cheat power cooldown (36 frames) after use + case 8: // SUICYCO (explode opponent) + if (Car[iCarIndex1].byCheatCooldown) // Car type 8: finds nearest car and + // applies massive damage goto PROCESS_VEHICLE_CONTROLS; - case 9: // MAYTE (top speed) - iControlFlags = iControlFlags | 1; - //LOBYTE(unControlFlags) = unControlFlags | 1; + byCheatAmmo = Car[iCarIndex1].byCheatAmmo; + TRAK_LEN = iTrakLen; + if (!byCheatAmmo) { + if (!cheatsampleok(iCarIndex1)) + goto SET_DAMAGE_COOLDOWN; + iSoundEffect1 = SOUND_SAMPLE_BLOP; + goto PLAY_DAMAGE_SOUND; + } + if (Car[iCarIndex1].nCurrChunk == -1) { + if (!cheatsampleok(iCarIndex1)) + goto SET_DAMAGE_COOLDOWN; + iSoundEffect1 = SOUND_SAMPLE_BRP; + goto PLAY_DAMAGE_SOUND; + } + iTargetCarIdx = findcardistance( + iCarIndex1, 8000.0); // Find target car within range (8000 units) + iTargetCar1 = iTargetCarIdx; + if (iTargetCarIdx >= 0 && Car[iTargetCarIdx].nCurrChunk != -1 && + Car[iTargetCarIdx].byCarDesignIdx != 13) { + Car[iTargetCarIdx].byAttacker = + iCarIdx_1; // Apply damage: 200 damage, stop target car, consume ammo + Car[iTargetCarIdx].byDamageSourceTimer = -40; + dodamage(&Car[iTargetCarIdx], 200.0); + Car[iTargetCar1].fFinalSpeed = 0.0; + Car[iTargetCar1].byGearAyMax = 0; + Car[iTargetCar1].fBaseSpeed = 0.0; + Car[iTargetCar1].fSpeedOverflow = 0.0; + Car[iTargetCar1].fRPMRatio = 0.0; + iTargetCar2 = iTargetCar1; + Car[iTargetCar2].fPower = 0.0; + iPlayerIdx = iCarIdx_1; + Car[iTargetCar2].nDeathTimer = 18; + --Car[iPlayerIdx].byCheatAmmo; + goto SET_DAMAGE_COOLDOWN; + } + if (cheatsampleok(iCarIdx_1)) { + iSoundEffect1 = SOUND_SAMPLE_BRP; + PLAY_DAMAGE_SOUND: + sfxsample(iSoundEffect1, 0x8000); + } + SET_DAMAGE_COOLDOWN: + iTrakLen = TRAK_LEN; + Car[iCarIdx_1].byCheatCooldown = + 36; // Set cheat power cooldown (36 frames) after use + goto PROCESS_VEHICLE_CONTROLS; + case 9: // MAYTE (top speed) + iControlFlags = iControlFlags | 1; + // LOBYTE(unControlFlags) = unControlFlags | 1; + goto PROCESS_VEHICLE_CONTROLS; + case 10: // 2X4B523P (flip opponent) + if (Car[iCarIndex2].byCheatCooldown) goto PROCESS_VEHICLE_CONTROLS; - case 10: // 2X4B523P (flip opponent) - if (Car[iCarIndex2].byCheatCooldown) - goto PROCESS_VEHICLE_CONTROLS; - byCheatAmmo_2 = Car[iCarIndex2].byCheatAmmo; - TRAK_LEN = iTrakLen; - if (!byCheatAmmo_2) { - if (!cheatsampleok(iCarIndex1)) - goto SET_JUMP_COOLDOWN; - iSoundEffect2 = SOUND_SAMPLE_BLOP; // SOUND_SAMPLE_BLOP - goto PLAY_JUMP_SOUND; - } - if (Car[iCarIndex2].nCurrChunk == -1) { - if (!cheatsampleok(iCarIndex1)) - goto SET_JUMP_COOLDOWN; - } else { - iJumpTargetIdx = findcardistance(iCarIndex1, 16000.0);// Find target car within jump range (16000 units) - iJumpTarget = iJumpTargetIdx; - if (iJumpTargetIdx >= 0) { - iJumpTargetCar = iJumpTargetIdx; - if (Car[iJumpTargetCar].nCurrChunk != -1 && Car[iJumpTargetCar].byCarDesignIdx != 13) { - iTargetCarDesign = Car[iJumpTargetCar].byCarDesignIdx;// Apply jump effect: launch target car into air with roll and Z-offset - Car[iJumpTargetCar].nRoll = 0x2000; - dNewZ = CarBox.hitboxAy[iTargetCarDesign][4].fZ + Car[iJumpTargetCar].pos.fZ; - Car[iJumpTargetCar].iStunned = -1; - Car[iJumpTargetCar].iSteeringInput = 0; - Car[iJumpTargetCar].iJumpMomentum = 2048; - Car[iJumpTargetCar].pos.fZ = (float)dNewZ; - if (cheatsampleok(iCarIdx_1)) - sfxsample(SOUND_SAMPLE_BOING, 0x8000); // SOUND_SAMPLE_BOING - if (cheatsampleok(iJumpTarget)) - sfxsample(SOUND_SAMPLE_BOING, 0x8000); // SOUND_SAMPLE_BOING - --Car[iCarIdx_1].byCheatAmmo; - SET_JUMP_COOLDOWN: - iTrakLen = TRAK_LEN; - Car[iCarIdx_1].byCheatCooldown = 36; - goto PROCESS_VEHICLE_CONTROLS; - } + byCheatAmmo_2 = Car[iCarIndex2].byCheatAmmo; + TRAK_LEN = iTrakLen; + if (!byCheatAmmo_2) { + if (!cheatsampleok(iCarIndex1)) + goto SET_JUMP_COOLDOWN; + iSoundEffect2 = SOUND_SAMPLE_BLOP; // SOUND_SAMPLE_BLOP + goto PLAY_JUMP_SOUND; + } + if (Car[iCarIndex2].nCurrChunk == -1) { + if (!cheatsampleok(iCarIndex1)) + goto SET_JUMP_COOLDOWN; + } else { + iJumpTargetIdx = findcardistance( + iCarIndex1, + 16000.0); // Find target car within jump range (16000 units) + iJumpTarget = iJumpTargetIdx; + if (iJumpTargetIdx >= 0) { + iJumpTargetCar = iJumpTargetIdx; + if (Car[iJumpTargetCar].nCurrChunk != -1 && + Car[iJumpTargetCar].byCarDesignIdx != 13) { + iTargetCarDesign = + Car[iJumpTargetCar] + .byCarDesignIdx; // Apply jump effect: launch target car into + // air with roll and Z-offset + Car[iJumpTargetCar].nRoll = 0x2000; + dNewZ = CarBox.hitboxAy[iTargetCarDesign][4].fZ + + Car[iJumpTargetCar].pos.fZ; + Car[iJumpTargetCar].iStunned = -1; + Car[iJumpTargetCar].iSteeringInput = 0; + Car[iJumpTargetCar].iJumpMomentum = 2048; + Car[iJumpTargetCar].pos.fZ = (float)dNewZ; + if (cheatsampleok(iCarIdx_1)) + sfxsample(SOUND_SAMPLE_BOING, 0x8000); // SOUND_SAMPLE_BOING + if (cheatsampleok(iJumpTarget)) + sfxsample(SOUND_SAMPLE_BOING, 0x8000); // SOUND_SAMPLE_BOING + --Car[iCarIdx_1].byCheatAmmo; + SET_JUMP_COOLDOWN: + iTrakLen = TRAK_LEN; + Car[iCarIdx_1].byCheatCooldown = 36; + goto PROCESS_VEHICLE_CONTROLS; } - if (!cheatsampleok(iCarIdx_1)) - goto SET_JUMP_COOLDOWN; - } - iSoundEffect2 = SOUND_SAMPLE_BRP; // SOUND_SAMPLE_BRP - PLAY_JUMP_SOUND: - sfxsample(iSoundEffect2, 0x8000); - goto SET_JUMP_COOLDOWN; - case 11: // TINKLE (swap places with opponent) - if (Car[iCarIndex2].byCheatCooldown) - goto PROCESS_VEHICLE_CONTROLS; - byCheatAmmo_3 = Car[iCarIndex2].byCheatAmmo; - TRAK_LEN = iTrakLen; - if (!byCheatAmmo_3) { - if (!cheatsampleok(iCarIdx_1)) - goto SET_TELEPORT_COOLDOWN; - iSoundEffect3 = SOUND_SAMPLE_BLOP; - goto PLAY_TELEPORT_SOUND; - } - if (Car[iCarIndex2].nCurrChunk == -1) { - if (!cheatsampleok(iCarIdx_1)) - goto SET_TELEPORT_COOLDOWN; - goto PLAY_TELEPORT_FAIL_SOUND; } - iTeleportTargetIdx = findcardistance(iCarIdx_1, 16000.0);// Find target car for teleport swap (16000 units) - iTeleportTargetIndex = iTeleportTargetIdx; - if (iTeleportTargetIdx < 0 || (iTeleportTarget = iTeleportTargetIdx, Car[iTeleportTargetIdx].nCurrChunk == -1) || Car[iTeleportTargetIdx].byCarDesignIdx == 13) { - if (!cheatsampleok(iCarIdx_1)) - goto SET_TELEPORT_COOLDOWN; - PLAY_TELEPORT_FAIL_SOUND: - iSoundEffect3 = SOUND_SAMPLE_BRP;//SOUND_SAMPLE_BRP - PLAY_TELEPORT_SOUND: - sfxsample(iSoundEffect3, 0x8000); + if (!cheatsampleok(iCarIdx_1)) + goto SET_JUMP_COOLDOWN; + } + iSoundEffect2 = SOUND_SAMPLE_BRP; // SOUND_SAMPLE_BRP + PLAY_JUMP_SOUND: + sfxsample(iSoundEffect2, 0x8000); + goto SET_JUMP_COOLDOWN; + case 11: // TINKLE (swap places with opponent) + if (Car[iCarIndex2].byCheatCooldown) + goto PROCESS_VEHICLE_CONTROLS; + byCheatAmmo_3 = Car[iCarIndex2].byCheatAmmo; + TRAK_LEN = iTrakLen; + if (!byCheatAmmo_3) { + if (!cheatsampleok(iCarIdx_1)) goto SET_TELEPORT_COOLDOWN; - } - Car[iTeleportTargetIdx].fHorizontalSpeed = 0; - nReferenceChunk = Car[iTeleportTargetIdx].nReferenceChunk; - Car[iTeleportTargetIdx].iSteeringInput = 0; - nPitch = Car[iTeleportTargetIdx].nPitch; - Car[iTeleportTargetIdx].direction.fZ = 128.0f; - nCurrChunk = Car[iTeleportTargetIdx].nCurrChunk; - getworldangles(Car[iTeleportTargetIdx].nActualYaw, nPitch, Car[iTeleportTargetIdx].nRoll, nReferenceChunk, &iAzimuth, &iElevation, &iBank);// Swap car positions and orientations using world angle transformations - getworldangles(Car[iTeleportTarget].nYaw, Car[iTeleportTarget].nPitch, Car[iTeleportTarget].nRoll, Car[iTeleportTarget].nReferenceChunk, &iAzi2, &iElevation, &iBank); - Car[iTeleportTarget].pos.fZ = Car[iTeleportTarget].pos.fZ + 64.0f; - Car[iTeleportTarget].nYaw = iAzi2; - Car[iTeleportTarget].nActualYaw = iAzi2; - Car[iTeleportTarget].nPitch = iElevation; - posAy = localdata[nCurrChunk].pointAy; - Car[iTeleportTarget].nRoll = iBank; - fLocalX = posAy->fY * Car[iTeleportTarget].pos.fY + posAy->fX * Car[iTeleportTarget].pos.fX + posAy->fZ * Car[iTeleportTarget].pos.fZ - posAy[3].fX; - fLocalY = posAy[1].fY * Car[iTeleportTarget].pos.fY + posAy[1].fX * Car[iTeleportTarget].pos.fX + posAy[1].fZ * Car[iTeleportTarget].pos.fZ - posAy[3].fY; - dLocalZ = posAy[2].fY * Car[iTeleportTarget].pos.fY + posAy[2].fX * Car[iTeleportTarget].pos.fX + posAy[2].fZ * Car[iTeleportTarget].pos.fZ - posAy[3].fZ; - Car[iTeleportTarget].pos.fX = fLocalX; - Car[iTeleportTarget].iRollMomentum = 0; - Car[iTeleportTarget].direction.fX = 0.0; - Car[iTeleportTarget].direction.fY = 0.0; - Car[iTeleportTarget].iControlType = 0; - Car[iTeleportTarget].fFinalSpeed = 0.0; - Car[iTeleportTarget].fBaseSpeed = 0.0; - Car[iTeleportTarget].fSpeedOverflow = 0.0; - fLocalZ = (float)dLocalZ; - Car[iTeleportTarget].fRPMRatio = 0.0; - fChunkValue = fLocalY; - Car[iTeleportTarget].fPower = 0.0; - Car[iTeleportTarget].pos.fY = fChunkValue; - Car[iTeleportTarget].nDeathTimer = 18; - Car[iTeleportTarget].pos.fZ = fLocalZ; - //LOWORD(fChunkValue) = Car[iTeleportTarget].nCurrChunk; - int16 nTemp = Car[iTeleportTarget].nCurrChunk; - Car[iTeleportTarget].nReferenceChunk = nTemp; //LOWORD(fChunkValue); - Car[iTeleportTarget].iLastValidChunk = nTemp;// SLOWORD(fChunkValue); - Car[iTeleportTarget].byAttacker = iCarIdx_1; - Car[iTeleportTarget].byGearAyMax = 0; - Car[iTeleportTarget].byDamageSourceTimer = -40; - iPlayerIdx2 = iCarIdx_1; - Car[iTeleportTarget].nCurrChunk = -1; - if (cheatsampleok(iPlayerIdx2)) - sfxsample(SOUND_SAMPLE_UP, 0x8000); // SOUND_SAMPLE_UP - if (cheatsampleok(iTeleportTargetIndex)) - sfxsample(SOUND_SAMPLE_UP, 0x8000); // SOUND_SAMPLE_UP - --Car[iCarIdx_1].byCheatAmmo; - SET_TELEPORT_COOLDOWN: - iTrakLen = TRAK_LEN; - Car[iCarIdx_1].byCheatCooldown = 36; - PROCESS_VEHICLE_CONTROLS: - TRAK_LEN = iTrakLen; - if (race_started) // Process main vehicle controls: gear changes, material selection, throttle/brake - { // Handle gear shift controls if race has started - if ((iControlFlags & 4) != 0) - GoUpGear(&Car[iCarIdx_1]); - if ((iControlFlags & 8) != 0) - GoDownGear(&Car[iCarIdx_1], iControlFlags & 1); - if (player_type != 2) // Handle material selection controls (paint job changes) - { - if ((iControlFlags & 0x40) != 0) - changemateto(iCarIdx_1, 0); - if ((iControlFlags & 0x80u) != 0) - changemateto(iCarIdx_1, 1); - if ((iControlFlags & 0x100) != 0) - changemateto(iCarIdx_1, 2); - if ((iControlFlags & 0x200) != 0) - changemateto(iCarIdx_1, 3); - } - } - pCar = &Car[iCarIdx_1]; // Apply vehicle physics based on throttle/brake input - if ((iControlFlags & 2) != 0) // Check control flags: bit 2=brake, bit 1=accelerate, else=freewheel + iSoundEffect3 = SOUND_SAMPLE_BLOP; + goto PLAY_TELEPORT_SOUND; + } + if (Car[iCarIndex2].nCurrChunk == -1) { + if (!cheatsampleok(iCarIdx_1)) + goto SET_TELEPORT_COOLDOWN; + goto PLAY_TELEPORT_FAIL_SOUND; + } + iTeleportTargetIdx = findcardistance( + iCarIdx_1, 16000.0); // Find target car for teleport swap (16000 units) + iTeleportTargetIndex = iTeleportTargetIdx; + if (iTeleportTargetIdx < 0 || + (iTeleportTarget = iTeleportTargetIdx, + Car[iTeleportTargetIdx].nCurrChunk == -1) || + Car[iTeleportTargetIdx].byCarDesignIdx == 13) { + if (!cheatsampleok(iCarIdx_1)) + goto SET_TELEPORT_COOLDOWN; + PLAY_TELEPORT_FAIL_SOUND: + iSoundEffect3 = SOUND_SAMPLE_BRP; // SOUND_SAMPLE_BRP + PLAY_TELEPORT_SOUND: + sfxsample(iSoundEffect3, 0x8000); + goto SET_TELEPORT_COOLDOWN; + } + Car[iTeleportTargetIdx].fHorizontalSpeed = 0; + nReferenceChunk = Car[iTeleportTargetIdx].nReferenceChunk; + Car[iTeleportTargetIdx].iSteeringInput = 0; + nPitch = Car[iTeleportTargetIdx].nPitch; + Car[iTeleportTargetIdx].direction.fZ = 128.0f; + nCurrChunk = Car[iTeleportTargetIdx].nCurrChunk; + getworldangles(Car[iTeleportTargetIdx].nActualYaw, nPitch, + Car[iTeleportTargetIdx].nRoll, nReferenceChunk, &iAzimuth, + &iElevation, &iBank); // Swap car positions and orientations + // using world angle transformations + getworldangles(Car[iTeleportTarget].nYaw, Car[iTeleportTarget].nPitch, + Car[iTeleportTarget].nRoll, + Car[iTeleportTarget].nReferenceChunk, &iAzi2, &iElevation, + &iBank); + Car[iTeleportTarget].pos.fZ = Car[iTeleportTarget].pos.fZ + 64.0f; + Car[iTeleportTarget].nYaw = iAzi2; + Car[iTeleportTarget].nActualYaw = iAzi2; + Car[iTeleportTarget].nPitch = iElevation; + posAy = localdata[nCurrChunk].pointAy; + Car[iTeleportTarget].nRoll = iBank; + fLocalX = posAy->fY * Car[iTeleportTarget].pos.fY + + posAy->fX * Car[iTeleportTarget].pos.fX + + posAy->fZ * Car[iTeleportTarget].pos.fZ - posAy[3].fX; + fLocalY = posAy[1].fY * Car[iTeleportTarget].pos.fY + + posAy[1].fX * Car[iTeleportTarget].pos.fX + + posAy[1].fZ * Car[iTeleportTarget].pos.fZ - posAy[3].fY; + dLocalZ = posAy[2].fY * Car[iTeleportTarget].pos.fY + + posAy[2].fX * Car[iTeleportTarget].pos.fX + + posAy[2].fZ * Car[iTeleportTarget].pos.fZ - posAy[3].fZ; + Car[iTeleportTarget].pos.fX = fLocalX; + Car[iTeleportTarget].iRollMomentum = 0; + Car[iTeleportTarget].direction.fX = 0.0; + Car[iTeleportTarget].direction.fY = 0.0; + Car[iTeleportTarget].iControlType = 0; + Car[iTeleportTarget].fFinalSpeed = 0.0; + Car[iTeleportTarget].fBaseSpeed = 0.0; + Car[iTeleportTarget].fSpeedOverflow = 0.0; + fLocalZ = (float)dLocalZ; + Car[iTeleportTarget].fRPMRatio = 0.0; + fChunkValue = fLocalY; + Car[iTeleportTarget].fPower = 0.0; + Car[iTeleportTarget].pos.fY = fChunkValue; + Car[iTeleportTarget].nDeathTimer = 18; + Car[iTeleportTarget].pos.fZ = fLocalZ; + // LOWORD(fChunkValue) = Car[iTeleportTarget].nCurrChunk; + int16 nTemp = Car[iTeleportTarget].nCurrChunk; + Car[iTeleportTarget].nReferenceChunk = nTemp; // LOWORD(fChunkValue); + Car[iTeleportTarget].iLastValidChunk = nTemp; // SLOWORD(fChunkValue); + Car[iTeleportTarget].byAttacker = iCarIdx_1; + Car[iTeleportTarget].byGearAyMax = 0; + Car[iTeleportTarget].byDamageSourceTimer = -40; + iPlayerIdx2 = iCarIdx_1; + Car[iTeleportTarget].nCurrChunk = -1; + if (cheatsampleok(iPlayerIdx2)) + sfxsample(SOUND_SAMPLE_UP, 0x8000); // SOUND_SAMPLE_UP + if (cheatsampleok(iTeleportTargetIndex)) + sfxsample(SOUND_SAMPLE_UP, 0x8000); // SOUND_SAMPLE_UP + --Car[iCarIdx_1].byCheatAmmo; + SET_TELEPORT_COOLDOWN: + iTrakLen = TRAK_LEN; + Car[iCarIdx_1].byCheatCooldown = 36; + PROCESS_VEHICLE_CONTROLS: + TRAK_LEN = iTrakLen; + if (race_started) // Process main vehicle controls: gear changes, material + // selection, throttle/brake + { // Handle gear shift controls if race has started + if ((iControlFlags & 4) != 0) + GoUpGear(&Car[iCarIdx_1]); + if ((iControlFlags & 8) != 0) + GoDownGear(&Car[iCarIdx_1], iControlFlags & 1); + if (player_type != + 2) // Handle material selection controls (paint job changes) { - Decelerate(pCar); - } else if ((iControlFlags & 1) != 0) { - Accelerate(pCar); - } else { - FreeWheel(pCar); + if ((iControlFlags & 0x40) != 0) + changemateto(iCarIdx_1, 0); + if ((iControlFlags & 0x80u) != 0) + changemateto(iCarIdx_1, 1); + if ((iControlFlags & 0x100) != 0) + changemateto(iCarIdx_1, 2); + if ((iControlFlags & 0x200) != 0) + changemateto(iCarIdx_1, 3); } - return; - case 12: // LOVEBUN (formula car) - if (!Car[iCarIndex2].byCheatCooldown) { - byCheatAmmo_1 = Car[iCarIndex2].byCheatAmmo; - TRAK_LEN = iTrakLen; - if (byCheatAmmo_1) { - iCurrentChunk = Car[iCarIndex2].nCurrChunk; - if (iCurrentChunk != -1) { - iColorIndex = -12; // Modify track surface in 16-chunk range around car position - do { - if ((TrakColour[iCurrentChunk][1] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_WALL_22)) == 0) { - iTrackColor1 = TrakColour[iCurrentChunk][1] & SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE; - TrakColour[iCurrentChunk][1] = (159 - (iColorIndex & 7)) | iTrackColor1; - localdata[iCurrentChunk].iCenterGrip = 12; - } - if ((TrakColour[iCurrentChunk][0] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_WALL_22)) == 0) { - iTrackColor2 = TrakColour[iCurrentChunk][0] & SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE; - TrakColour[iCurrentChunk][0] = iTrackColor2 | (159 - (iColorIndex & 7)); - localdata[iCurrentChunk].iLeftShoulderGrip = 12; - } - if ((TrakColour[iCurrentChunk][2] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_WALL_22)) == 0) { - iTrackColor3 = TrakColour[iCurrentChunk][1] & SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE; - TrakColour[iCurrentChunk][2] = (159 - (iColorIndex & 7)) | iTrackColor3; - localdata[iCurrentChunk].iRightShoulderGrip = 12; - } - if (++iCurrentChunk >= iTrakLen) - iCurrentChunk = 0; - ++iColorIndex; - } while (iColorIndex < 4); - byNewCheatAmmo = Car[iCarIdx_1].byCheatAmmo - 1; - TRAK_LEN = iTrakLen; - Car[iCarIdx_1].byCheatAmmo = byNewCheatAmmo; - } - } else if (cheatsampleok(iCarIndex1)) { - sfxsample(SOUND_SAMPLE_BLOP, 0x8000); // SOUND_SAMPLE_BLOP + } + pCar = + &Car[iCarIdx_1]; // Apply vehicle physics based on throttle/brake input + if ((iControlFlags & 2) != + 0) // Check control flags: bit 2=brake, bit 1=accelerate, else=freewheel + { + Decelerate(pCar); + } else if ((iControlFlags & 1) != 0) { + Accelerate(pCar); + } else { + FreeWheel(pCar); + } + return; + case 12: // LOVEBUN (formula car) + if (!Car[iCarIndex2].byCheatCooldown) { + byCheatAmmo_1 = Car[iCarIndex2].byCheatAmmo; + TRAK_LEN = iTrakLen; + if (byCheatAmmo_1) { + iCurrentChunk = Car[iCarIndex2].nCurrChunk; + if (iCurrentChunk != -1) { + iColorIndex = + -12; // Modify track surface in 16-chunk range around car position + do { + if ((TrakColour[iCurrentChunk][1] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_WALL_22)) == 0) { + iTrackColor1 = TrakColour[iCurrentChunk][1] & SURFACE_MASK_FLAGS ^ + SURFACE_FLAG_APPLY_TEXTURE; + TrakColour[iCurrentChunk][1] = + (159 - (iColorIndex & 7)) | iTrackColor1; + localdata[iCurrentChunk].iCenterGrip = 12; + } + if ((TrakColour[iCurrentChunk][0] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_WALL_22)) == 0) { + iTrackColor2 = TrakColour[iCurrentChunk][0] & SURFACE_MASK_FLAGS ^ + SURFACE_FLAG_APPLY_TEXTURE; + TrakColour[iCurrentChunk][0] = + iTrackColor2 | (159 - (iColorIndex & 7)); + localdata[iCurrentChunk].iLeftShoulderGrip = 12; + } + if ((TrakColour[iCurrentChunk][2] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_WALL_22)) == 0) { + iTrackColor3 = TrakColour[iCurrentChunk][1] & SURFACE_MASK_FLAGS ^ + SURFACE_FLAG_APPLY_TEXTURE; + TrakColour[iCurrentChunk][2] = + (159 - (iColorIndex & 7)) | iTrackColor3; + localdata[iCurrentChunk].iRightShoulderGrip = 12; + } + if (++iCurrentChunk >= iTrakLen) + iCurrentChunk = 0; + ++iColorIndex; + } while (iColorIndex < 4); + byNewCheatAmmo = Car[iCarIdx_1].byCheatAmmo - 1; + TRAK_LEN = iTrakLen; + Car[iCarIdx_1].byCheatAmmo = byNewCheatAmmo; } - iTrakLen = TRAK_LEN; - Car[iCarIdx_1].byCheatCooldown = 36; + } else if (cheatsampleok(iCarIndex1)) { + sfxsample(SOUND_SAMPLE_BLOP, 0x8000); // SOUND_SAMPLE_BLOP } - goto PROCESS_VEHICLE_CONTROLS; - default: - goto PROCESS_VEHICLE_CONTROLS; // Cheat power switch: handle different special car abilities + iTrakLen = TRAK_LEN; + Car[iCarIdx_1].byCheatCooldown = 36; + } + goto PROCESS_VEHICLE_CONTROLS; + default: + goto PROCESS_VEHICLE_CONTROLS; // Cheat power switch: handle different + // special car abilities } } //------------------------------------------------------------------------------------------------- -//0002A060 -void GoUpGear(tCar *pCar) -{ - int iCarDesignIdx; // esi +// 0002A060 +void GoUpGear(tCar *pCar) { + int iCarDesignIdx; // esi tCarEngine *pEngineData; // edi - int byGearAyMax; // ecx - int iTargetGear; // ecx - float *pSpds; // edi - float fNewPowerForward; // [esp+0h] [ebp-2Ch] - float fNewPowerReverse; // [esp+0h] [ebp-2Ch] - float fMinShiftSpeed; // [esp+4h] [ebp-28h] - float fAdjustedSpeed; // [esp+8h] [ebp-24h] - float fHealthFactor; // [esp+Ch] [ebp-20h] - float fRPMRatio; // [esp+10h] [ebp-1Ch] + int byGearAyMax; // ecx + int iTargetGear; // ecx + float *pSpds; // edi + float fNewPowerForward; // [esp+0h] [ebp-2Ch] + float fNewPowerReverse; // [esp+0h] [ebp-2Ch] + float fMinShiftSpeed; // [esp+4h] [ebp-28h] + float fAdjustedSpeed; // [esp+8h] [ebp-24h] + float fHealthFactor; // [esp+Ch] [ebp-20h] + float fRPMRatio; // [esp+10h] [ebp-1Ch] - iCarDesignIdx = pCar->byCarDesignIdx; // Get car design index and engine data + iCarDesignIdx = pCar->byCarDesignIdx; // Get car design index and engine data pEngineData = &CarEngines.engines[iCarDesignIdx]; byGearAyMax = (char)pCar->byGearAyMax; - if (byGearAyMax < pEngineData->iNumGears - 1)// Check if car can upshift (not already in top gear) + if (byGearAyMax < pEngineData->iNumGears - + 1) // Check if car can upshift (not already in top gear) { - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car damage, capped at 1.0 + fHealthFactor = + (pCar->fHealth + 34.0f) * 0.01f; // Calculate health factor (0-1) based + // on car damage, capped at 1.0 iTargetGear = byGearAyMax + 1; if (fHealthFactor > 1.0) fHealthFactor = 1.0; - fMinShiftSpeed = -1.0; // Initialize minimum shift speed to -1 (no restriction) - fAdjustedSpeed = (float)(fabs(pCar->fFinalSpeed) / fHealthFactor);// Calculate current speed adjusted by health factor - if (human_control[pCar->iDriverIdx] != 2 && iTargetGear > 0)// For AI drivers, set minimum speed for upshift (50% of current gear max speed) + fMinShiftSpeed = + -1.0; // Initialize minimum shift speed to -1 (no restriction) + fAdjustedSpeed = (float)(fabs(pCar->fFinalSpeed) / + fHealthFactor); // Calculate current speed adjusted + // by health factor + if (human_control[pCar->iDriverIdx] != 2 && + iTargetGear > 0) // For AI drivers, set minimum speed for upshift (50% + // of current gear max speed) fMinShiftSpeed = pEngineData->pSpds[iTargetGear - 1] * 0.5f; - if (fAdjustedSpeed >= (double)fMinShiftSpeed)// Check if car is fast enough to upshift + if (fAdjustedSpeed >= + (double)fMinShiftSpeed) // Check if car is fast enough to upshift { pSpds = pEngineData->pSpds; - if (iTargetGear < 0) // Handle reverse gear upshift (gear < 0) + if (iTargetGear < 0) // Handle reverse gear upshift (gear < 0) { fRPMRatio = fAdjustedSpeed / *pSpds; if (fRPMRatio > 1.0) fRPMRatio = 1.0; } else { - fRPMRatio = fAdjustedSpeed / pSpds[iTargetGear];// Calculate RPM ratio for target gear + fRPMRatio = fAdjustedSpeed / + pSpds[iTargetGear]; // Calculate RPM ratio for target gear if (fRPMRatio > 1.0) fRPMRatio = 1.0; } pCar->fRPMRatio = fRPMRatio; - if (player1_car == pCar->iDriverIdx && !DriveView[0])// Play gear shift sound for human players (not in cockpit view) - sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT + if (player1_car == pCar->iDriverIdx && + !DriveView[0]) // Play gear shift sound for human players (not in + // cockpit view) + sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT if (player2_car == pCar->iDriverIdx && !DriveView[1]) - sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT - if (iTargetGear < 0) // Handle upshift to reverse gear (set gear 0) + sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT + if (iTargetGear < 0) // Handle upshift to reverse gear (set gear 0) { fNewPowerReverse = (float)calc_pow(iCarDesignIdx, 0, fRPMRatio); pCar->fBaseSpeed = 0.0; pCar->byGearAyMax = iTargetGear; pCar->fPower = fNewPowerReverse; } else { - fNewPowerForward = (float)calc_pow(iCarDesignIdx, iTargetGear, fRPMRatio);// Handle normal forward gear upshift + fNewPowerForward = + (float)calc_pow(iCarDesignIdx, iTargetGear, + fRPMRatio); // Handle normal forward gear upshift pCar->byGearAyMax = iTargetGear; pCar->fPower = fNewPowerForward; pCar->fBaseSpeed = pSpds[iTargetGear] * fRPMRatio * fHealthFactor; } - pCar->fSpeedOverflow = pCar->fFinalSpeed - pCar->fBaseSpeed;// Update speed overflow (difference between current and base speed) + pCar->fSpeedOverflow = + pCar->fFinalSpeed - + pCar->fBaseSpeed; // Update speed overflow (difference between current + // and base speed) } } } //------------------------------------------------------------------------------------------------- -//0002A200 -void GoDownGear(tCar *pCar, int iUseAutoLogic) -{ - int iCarDesignIdx; // ecx - tCarEngine *pEngineData; // edi - int iGearAyMax; // eax - int iTargetGear; // eax - int iGearForCalc; // edx - int iCurrentGear; // eax - tCar *pCarCopy; // ebx - double dBaseSpeed; // st7 - float *pSpds; // ecx - double dMaxSpeed; // st7 - float fRPMRatio; // [esp+0h] [ebp-28h] +// 0002A200 +void GoDownGear(tCar *pCar, int iUseAutoLogic) { + int iCarDesignIdx; // ecx + tCarEngine *pEngineData; // edi + int iGearAyMax; // eax + int iTargetGear; // eax + int iGearForCalc; // edx + int iCurrentGear; // eax + tCar *pCarCopy; // ebx + double dBaseSpeed; // st7 + float *pSpds; // ecx + double dMaxSpeed; // st7 + float fRPMRatio; // [esp+0h] [ebp-28h] float fDownshiftThreshold; // [esp+4h] [ebp-24h] - float fHealthFactor; // [esp+8h] [ebp-20h] - float fCalculatedPower; // [esp+Ch] [ebp-1Ch] - int iTargetGearIdx; // [esp+10h] [ebp-18h] + float fHealthFactor; // [esp+8h] [ebp-20h] + float fCalculatedPower; // [esp+Ch] [ebp-1Ch] + int iTargetGearIdx; // [esp+10h] [ebp-18h] - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car damage - iCarDesignIdx = pCar->byCarDesignIdx; // Get car design index and engine data + fHealthFactor = (pCar->fHealth + 34.0f) * + 0.01f; // Calculate health factor (0-1) based on car damage + iCarDesignIdx = pCar->byCarDesignIdx; // Get car design index and engine data pEngineData = &CarEngines.engines[iCarDesignIdx]; if (fHealthFactor > 1.0) fHealthFactor = 1.0; iGearAyMax = (char)pCar->byGearAyMax; - if (iGearAyMax > -2) // Check if car can downshift (not already in lowest gear -2) + if (iGearAyMax > + -2) // Check if car can downshift (not already in lowest gear -2) { - iTargetGear = iGearAyMax - 1; // Calculate target gear (current gear - 1) + iTargetGear = iGearAyMax - 1; // Calculate target gear (current gear - 1) iTargetGearIdx = iTargetGear; - if (iTargetGear < 0) // Handle reverse gear downshift (target < 0) + if (iTargetGear < 0) // Handle reverse gear downshift (target < 0) { iCurrentGear = 1; pCarCopy = pCar; iGearForCalc = 0; } else { - iGearForCalc = iTargetGear; // Handle forward gear downshift + iGearForCalc = iTargetGear; // Handle forward gear downshift iCurrentGear = iTargetGear + 1; pCarCopy = pCar; } - fCalculatedPower = (float)change_gear(iCurrentGear, iGearForCalc, pCarCopy, iCarDesignIdx);// Calculate power output for target gear using change_gear function - fDownshiftThreshold = 1000.0; // Set downshift threshold: high value for human, gear change value * 1.2 for AI + fCalculatedPower = + (float)change_gear(iCurrentGear, iGearForCalc, pCarCopy, + iCarDesignIdx); // Calculate power output for target + // gear using change_gear function + fDownshiftThreshold = 1000.0; // Set downshift threshold: high value for + // human, gear change value * 1.2 for AI if (human_control[pCar->iDriverIdx] != 2 && iUseAutoLogic) fDownshiftThreshold = pEngineData->pChgs[2 * iTargetGearIdx] * 1.2f; - if (fCalculatedPower < (double)fDownshiftThreshold)// Check if calculated power is below downshift threshold + if (fCalculatedPower < + (double)fDownshiftThreshold) // Check if calculated power is below + // downshift threshold { pCar->fPower = fCalculatedPower; pCar->byGearAyMax = iTargetGearIdx; - if (iTargetGearIdx == -1) // Handle downshift to reverse gear (-1): zero base speed + if (iTargetGearIdx == + -1) // Handle downshift to reverse gear (-1): zero base speed { dBaseSpeed = pCar->fBaseSpeed; pCar->fBaseSpeed = 0.0; } else { pSpds = pEngineData->pSpds; - if (iTargetGearIdx >= 0) // Handle forward gear downshift: calculate RPM ratio and speeds + if (iTargetGearIdx >= + 0) // Handle forward gear downshift: calculate RPM ratio and speeds { - fRPMRatio = (float)calc_revs(pEngineData->pRevs, iTargetGearIdx, fCalculatedPower);// Forward gear: use target gear curve data and positive max speed + fRPMRatio = (float)calc_revs( + pEngineData->pRevs, iTargetGearIdx, + fCalculatedPower); // Forward gear: use target gear curve data and + // positive max speed pCar->fRPMRatio = fRPMRatio; dMaxSpeed = pSpds[iTargetGearIdx]; } else { - fRPMRatio = (float)calc_revs(pEngineData->pRevs, 0, fCalculatedPower);// Reverse gear: use gear 0 curve data, negative max speed + fRPMRatio = (float)calc_revs( + pEngineData->pRevs, 0, + fCalculatedPower); // Reverse gear: use gear 0 curve data, + // negative max speed pCar->fRPMRatio = fRPMRatio; dMaxSpeed = -*pSpds; } - pCar->fBaseSpeed = (float)dMaxSpeed * fRPMRatio * fHealthFactor;// Calculate new base speed: max speed * RPM ratio * health factor - dBaseSpeed = pCar->fFinalSpeed - pCar->fBaseSpeed;// Update speed overflow (difference between final and base speed) + pCar->fBaseSpeed = (float)dMaxSpeed * fRPMRatio * + fHealthFactor; // Calculate new base speed: max speed + // * RPM ratio * health factor + dBaseSpeed = pCar->fFinalSpeed - + pCar->fBaseSpeed; // Update speed overflow (difference + // between final and base speed) } pCar->fSpeedOverflow = (float)dBaseSpeed; } @@ -547,83 +641,83 @@ void GoDownGear(tCar *pCar, int iUseAutoLogic) } //------------------------------------------------------------------------------------------------- -//0002A350 -void control() -{ - int iChecksum; // ebx - int iCarCounter; // edi +// 0002A350 +void control() { + int iChecksum; // ebx + int iCarCounter; // edi int iCompetitorIdx; // esi - int iCarIdx; // ecx - double dHealth; // st7 - //int iCarArraySize; // ebx - //int iByteOffset; // eax - //int iStructOffset; // ecx - //int iDataValue; // edx - int iFatalityCounter; // edx - int iCar; // ecx - int iCar_1; // eax - int iCarArrayIdx; // ebx - int iCarStructIdx; // edx - int iCarLoopIdx; // ecx - uint8 byStatusFlags; // ah - int16 nTimerValue; // ax - int iUpdateCarIdx; // ecx - int iCarUpdateIdx; // edx - uint8 byUnk43; // bh - int i; // ecx + int iCarIdx; // ecx + double dHealth; // st7 + // int iCarArraySize; // ebx + // int iByteOffset; // eax + // int iStructOffset; // ecx + // int iDataValue; // edx + int iFatalityCounter; // edx + int iCar; // ecx + int iCar_1; // eax + int iCarArrayIdx; // ebx + int iCarStructIdx; // edx + int iCarLoopIdx; // ecx + uint8 byStatusFlags; // ah + int16 nTimerValue; // ax + int iUpdateCarIdx; // ecx + int iCarUpdateIdx; // edx + uint8 byUnk43; // bh + int i; // ecx unsigned int uiSLightOffset; // edx - float fLightSpeed; // esi - double dLightPosX; // st7 - double dLightPosY; // st7 - double dLightPosZ; // st7 - double dLightSpeedZ; // st7 - int iCrossLineIdx; // ebx - tCar *pCarPtr; // edx - int iMotionCarIdx; // ecx - tCar *pCurrentCar; // ebx - tCar *pMotionCar; // edx - double dDamageFactor; // st7 - double dRollMotionCalc; // st7 - double dPitchMotionCalc; // st7 - double dYawMotionCalc; // st7 - int iNumCarsTemp; // edi - int j; // ecx - char bySampleValue; // ah - int iNetworkArraySize; // ecx - int iCarOffset; // edx - int iMasterCarIdx; // ebx - int iMasterByteIdx; // edx - int iSlaveByteIdx; // ebx - int iSlaveCarIdx; // edx - int iRacingByteIdx; // ebx - int iFinalArraySize; // ecx - int iFinalCarIdx; // edx - int iFinalByteIdx; // ebx - int8 byUnk68; // ah - uint8 byNewValue; // al - int aiCarStates[17]; // [esp+0h] [ebp-9Ch] - double dLightDistanceX; // [esp+44h] [ebp-58h] - double dLightDistanceY; // [esp+4Ch] [ebp-50h] - double dLightDistanceZ; // [esp+54h] [ebp-48h] - float fLightDeltaZ; // [esp+5Ch] [ebp-40h] - float fX; // [esp+60h] [ebp-3Ch] - float fLightDeltaX; // [esp+64h] [ebp-38h] - float fDamageMultiplier; // [esp+68h] [ebp-34h] - float fHealthFactor; // [esp+6Ch] [ebp-30h] - float fHealthValue; // [esp+70h] [ebp-2Ch] - int iRandomValue; // [esp+74h] [ebp-28h] - float fZ; // [esp+78h] [ebp-24h] - float fY; // [esp+7Ch] [ebp-20h] - float fLightDeltaY; // [esp+80h] [ebp-1Ch] + float fLightSpeed; // esi + double dLightPosX; // st7 + double dLightPosY; // st7 + double dLightPosZ; // st7 + double dLightSpeedZ; // st7 + int iCrossLineIdx; // ebx + tCar *pCarPtr; // edx + int iMotionCarIdx; // ecx + tCar *pCurrentCar; // ebx + tCar *pMotionCar; // edx + double dDamageFactor; // st7 + double dRollMotionCalc; // st7 + double dPitchMotionCalc; // st7 + double dYawMotionCalc; // st7 + int iNumCarsTemp; // edi + int j; // ecx + char bySampleValue; // ah + int iNetworkArraySize; // ecx + int iCarOffset; // edx + int iMasterCarIdx; // ebx + int iMasterByteIdx; // edx + int iSlaveByteIdx; // ebx + int iSlaveCarIdx; // edx + int iRacingByteIdx; // ebx + int iFinalArraySize; // ecx + int iFinalCarIdx; // edx + int iFinalByteIdx; // ebx + int8 byUnk68; // ah + uint8 byNewValue; // al + int aiCarStates[17]; // [esp+0h] [ebp-9Ch] + double dLightDistanceX; // [esp+44h] [ebp-58h] + double dLightDistanceY; // [esp+4Ch] [ebp-50h] + double dLightDistanceZ; // [esp+54h] [ebp-48h] + float fLightDeltaZ; // [esp+5Ch] [ebp-40h] + float fX; // [esp+60h] [ebp-3Ch] + float fLightDeltaX; // [esp+64h] [ebp-38h] + float fDamageMultiplier; // [esp+68h] [ebp-34h] + float fHealthFactor; // [esp+6Ch] [ebp-30h] + float fHealthValue; // [esp+70h] [ebp-2Ch] + int iRandomValue; // [esp+74h] [ebp-28h] + float fZ; // [esp+78h] [ebp-24h] + float fY; // [esp+7Ch] [ebp-20h] + float fLightDeltaY; // [esp+80h] [ebp-1Ch] - updates = 0; // Initialize update counter and handle replay mode + updates = 0; // Initialize update counter and handle replay mode if (replaytype == 2) readptr = -10000; if (readptr == writeptr) analysespeechsamples(); - while (readptr != writeptr) // Main game update loop - process each frame while data available + while (readptr != writeptr) // Main game update loop - process each frame + // while data available { - --view1_cnt; // Update frame counters and warp animation angle + --view1_cnt; // Update frame counters and warp animation angle --view0_cnt; --Quit_Count; warp_angle = (warp_angle + 512) & 0x3FFF; @@ -631,7 +725,9 @@ void control() racing = master ^ wConsoleNode; ++game_frame; --countdown; - if (network_on && replaytype != 2 && write_check >= 0)// Network synchronization: calculate checksums for car state validation + if (network_on && replaytype != 2 && + write_check >= 0) // Network synchronization: calculate checksums for + // car state validation { iChecksum = 0; iCarCounter = 0; @@ -642,20 +738,19 @@ void control() if (!non_competitors[iCompetitorIdx]) { dHealth = Car[iCarIdx].fHealth; //_CHP(); - //LODWORD(fHealthValue) = (int)dHealth; - //iChecksum += abs16(Car[iCarIdx].nCurrChunk) + // LODWORD(fHealthValue) = (int)dHealth; + // iChecksum += abs16(Car[iCarIdx].nCurrChunk) // + LODWORD(Car[iCarIdx].pos.fZ) // + LODWORD(Car[iCarIdx].pos.fY) // + LODWORD(Car[iCarIdx].pos.fX) // + abs8(Car[iCarIdx].byLives) // + abs32((int)dHealth); // Calculate network synchronization checksum from car state data - iChecksum += abs(Car[iCarIdx].nCurrChunk) - + *(int *)&Car[iCarIdx].pos.fX // Float bit pattern as int - + *(int *)&Car[iCarIdx].pos.fY - + *(int *)&Car[iCarIdx].pos.fZ - + abs(Car[iCarIdx].byLives) - + abs((int)dHealth); + iChecksum += + abs(Car[iCarIdx].nCurrChunk) + + *(int *)&Car[iCarIdx].pos.fX // Float bit pattern as int + + *(int *)&Car[iCarIdx].pos.fY + *(int *)&Car[iCarIdx].pos.fZ + + abs(Car[iCarIdx].byLives) + abs((int)dHealth); } ++iCompetitorIdx; ++iCarCounter; @@ -666,10 +761,8 @@ void control() write_check = ((int16)write_check + 1) & 0x1FF; } - if (numcars > 0) - { - for (int i = 0; i < numcars; i++) - { + if (numcars > 0) { + for (int i = 0; i < numcars; i++) { // Initialize wheel spin factor to 1.0 Car[i].fWheelSpinFactor = 1.0; @@ -677,23 +770,27 @@ void control() aiCarStates[i] = Car[i].byWheelAnimationFrame; } } - //if (numcars > 0) // Initialize car state array and copy car data for processing + // if (numcars > 0) // Initialize car state array + // and copy car data for processing //{ - // iCarArraySize = 4 * numcars; - // iByteOffset = 0; - // iStructOffset = 0; - // do { - // iStructOffset += sizeof(tCar); - // iByteOffset += 4; - // iDataValue = *((char *)&CarBox.hitboxAy[15][5].fY + iStructOffset + 2);// references adjacent data Car - // *(float *)((char *)&CarBox.hitboxAy[15][7].fX + iStructOffset) = 1.0;// references adjacent data Car - // aiCarStates[iByteOffset / 4u] = iDataValue; - // } while (iByteOffset < iCarArraySize); - //} + // iCarArraySize = 4 * numcars; + // iByteOffset = 0; + // iStructOffset = 0; + // do { + // iStructOffset += sizeof(tCar); + // iByteOffset += 4; + // iDataValue = *((char *)&CarBox.hitboxAy[15][5].fY + iStructOffset + + // 2);// references adjacent data Car + // *(float *)((char *)&CarBox.hitboxAy[15][7].fX + iStructOffset) + // = 1.0;// references adjacent data Car aiCarStates[iByteOffset / 4u] = + // iDataValue; + // } while (iByteOffset < iCarArraySize); + // } if (!paused) ++updates; - iFatalityCounter = Fatality_Count; // Handle fatality timer and camera zoom effects + iFatalityCounter = + Fatality_Count; // Handle fatality timer and camera zoom effects if (Fatality_Count > 0) { --Fatality_Count; if (iFatalityCounter == 1) @@ -702,14 +799,18 @@ void control() dozoomstuff(0); if (player_type == 2) dozoomstuff(1); - if (readptr >= 0) { // Process each car: handle race start, player controls, and network events - for (iCar = 0; iCar < numcars; ++iCar) { // Race start condition: clear high bit from gear and enable racing + if (readptr >= 0) { // Process each car: handle race start, player controls, + // and network events + for (iCar = 0; iCar < numcars; + ++iCar) { // Race start condition: clear high bit from gear and + // enable racing if (game_frame == 145 && (Car[iCar].byGearAyMax & 0x80u) != 0) { Car[iCar].byGearAyMax = 0; race_started = -1; Car[iCar].fPower = 0.0; } - if (human_control[iCar]) { // Network sync request: reset car to neutral state + if (human_control[iCar]) { // Network sync request: reset car to neutral + // state if ((copy_multiple[readptr][iCar].uiFullData & 0x10000000) != 0) { iCar_1 = iCar; Car[iCar_1].byGearAyMax = -1; @@ -722,7 +823,8 @@ void control() fudge_wait = ((int16)readptr + 1) & 0x1FF; stopallsamples(); } - if ((copy_multiple[readptr][iCar].uiFullData & 0x4000000) != 0)// Network player quit: cleanup and handle disconnection + if ((copy_multiple[readptr][iCar].uiFullData & 0x4000000) != + 0) // Network player quit: cleanup and handle disconnection { memset(player_checks, -1, sizeof(player_checks)); read_check = 0; @@ -742,21 +844,28 @@ void control() } } } - if (replaytype == 2) // Handle replay data and update stunt system + if (replaytype == 2) // Handle replay data and update stunt system DoReplayData(); updatestunts(); if (replaytype != 2) { - memset(newrepsample, 0, sizeof(newrepsample));// Process car controls and AI for non-replay mode + memset( + newrepsample, 0, + sizeof( + newrepsample)); // Process car controls and AI for non-replay mode iCarArrayIdx = 0; if (numcars > 0) { iCarStructIdx = 0; iCarLoopIdx = 0; do { - byStatusFlags = Car[iCarStructIdx].byStatusFlags;// Check car status and handle death/damage states + byStatusFlags = + Car[iCarStructIdx].byStatusFlags; // Check car status and handle + // death/damage states Car[iCarStructIdx].byAccelerating = 0; if ((byStatusFlags & 4) != 0 || !Car[iCarStructIdx].byLives) { - //if ((LODWORD(Car[iCarStructIdx].fFinalSpeed) & 0x7FFFFFFF) == 0 || Car[iCarStructIdx].nUnk21 < 126) { - if (fabs(Car[iCarStructIdx].fFinalSpeed) == 0 || Car[iCarStructIdx].nDeathTimer < 126) { + // if ((LODWORD(Car[iCarStructIdx].fFinalSpeed) & 0x7FFFFFFF) == 0 + // || Car[iCarStructIdx].nUnk21 < 126) { + if (fabs(Car[iCarStructIdx].fFinalSpeed) == 0 || + Car[iCarStructIdx].nDeathTimer < 126) { nTimerValue = Car[iCarStructIdx].nExplosionSoundTimer - 1; --Car[iCarStructIdx].nDeathTimer; Car[iCarStructIdx].nExplosionSoundTimer = nTimerValue; @@ -764,11 +873,15 @@ void control() if (Car[iCarStructIdx].nDeathTimer < 0) Car[iCarStructIdx].byStatusFlags |= 2u; } - if ((Car[iCarStructIdx].byLives & 0x80u) == 0) { // Process car controls: human player or AI based on control type + if ((Car[iCarStructIdx].byLives & 0x80u) == + 0) { // Process car controls: human player or AI based on control + // type if (human_control[iCarLoopIdx]) { - if (Car[iCarStructIdx].iControlType != 2 && !Car[iCarStructIdx].iStunned) + if (Car[iCarStructIdx].iControlType != 2 && + !Car[iCarStructIdx].iStunned) humancar(iCarArrayIdx); - } else if (Car[iCarStructIdx].iControlType == 3 && !Car[iCarStructIdx].iStunned) { + } else if (Car[iCarStructIdx].iControlType == 3 && + !Car[iCarStructIdx].iStunned) { autocar2(&Car[iCarStructIdx]); } } @@ -777,7 +890,7 @@ void control() ++iCarLoopIdx; } while (iCarArrayIdx < numcars); } - iUpdateCarIdx = 0; // Update car physics and damage over time effects + iUpdateCarIdx = 0; // Update car physics and damage over time effects if (numcars > 0) { iCarUpdateIdx = 0; do { @@ -793,51 +906,67 @@ void control() ++iCarUpdateIdx; } while (iUpdateCarIdx < numcars); } - if (countdown > -72 && replaytype != 2) // Update dynamic lighting effects for local players + if (countdown > -72 && + replaytype != 2) // Update dynamic lighting effects for local players { for (i = 0; i < local_players; ++i) { uiSLightOffset = 0x90 * i; do { - fLightDeltaX = SLight[0][uiSLightOffset / 0x30].targetPos.fX - SLight[0][uiSLightOffset / 0x30].currentPos.fX;// Animate lights toward target positions with speed limiting + fLightDeltaX = SLight[0][uiSLightOffset / 0x30].targetPos.fX - + SLight[0][uiSLightOffset / 0x30] + .currentPos.fX; // Animate lights toward target + // positions with speed limiting fLightSpeed = fLightDeltaX; - SLight[0][uiSLightOffset / 0x30].uiRotation = (SLight[0][uiSLightOffset / 0x30].uiRotation + 128) & 0x3FFF; - //if ((LODWORD(fLightSpeed) & 0x7FFFFFFF) != 0) { + SLight[0][uiSLightOffset / 0x30].uiRotation = + (SLight[0][uiSLightOffset / 0x30].uiRotation + 128) & 0x3FFF; + // if ((LODWORD(fLightSpeed) & 0x7FFFFFFF) != 0) { if (fabs(fLightSpeed) > FLT_EPSILON) { fX = SLight[0][uiSLightOffset / 0x30].speed.fX; dLightDistanceX = fabs(fLightDeltaX); if (fX > dLightDistanceX) fX = (float)dLightDistanceX; if (fLightDeltaX <= 0.0) - dLightPosX = SLight[0][uiSLightOffset / 0x30].currentPos.fX - fX; + dLightPosX = + SLight[0][uiSLightOffset / 0x30].currentPos.fX - fX; else - dLightPosX = SLight[0][uiSLightOffset / 0x30].currentPos.fX + fX; - SLight[0][uiSLightOffset / 0x30].currentPos.fX = (float)dLightPosX; + dLightPosX = + SLight[0][uiSLightOffset / 0x30].currentPos.fX + fX; + SLight[0][uiSLightOffset / 0x30].currentPos.fX = + (float)dLightPosX; } - fLightDeltaY = SLight[0][uiSLightOffset / 0x30].targetPos.fY - SLight[0][uiSLightOffset / 0x30].currentPos.fY; - //if ((LODWORD(fLightDeltaY) & 0x7FFFFFFF) != 0) { + fLightDeltaY = SLight[0][uiSLightOffset / 0x30].targetPos.fY - + SLight[0][uiSLightOffset / 0x30].currentPos.fY; + // if ((LODWORD(fLightDeltaY) & 0x7FFFFFFF) != 0) { if (fabs(fLightDeltaY) > FLT_EPSILON) { fY = SLight[0][uiSLightOffset / 0x30].speed.fY; dLightDistanceY = fabs(fLightDeltaY); if (fY > dLightDistanceY) fY = (float)dLightDistanceY; if (fLightDeltaY <= 0.0) - dLightPosY = SLight[0][uiSLightOffset / 0x30].currentPos.fY - fY; + dLightPosY = + SLight[0][uiSLightOffset / 0x30].currentPos.fY - fY; else - dLightPosY = SLight[0][uiSLightOffset / 0x30].currentPos.fY + fY; - SLight[0][uiSLightOffset / 0x30].currentPos.fY = (float)dLightPosY; + dLightPosY = + SLight[0][uiSLightOffset / 0x30].currentPos.fY + fY; + SLight[0][uiSLightOffset / 0x30].currentPos.fY = + (float)dLightPosY; } - fLightDeltaZ = SLight[0][uiSLightOffset / 0x30].targetPos.fZ - SLight[0][uiSLightOffset / 0x30].currentPos.fZ; - //if ((LODWORD(fLightDeltaZ) & 0x7FFFFFFF) != 0) { + fLightDeltaZ = SLight[0][uiSLightOffset / 0x30].targetPos.fZ - + SLight[0][uiSLightOffset / 0x30].currentPos.fZ; + // if ((LODWORD(fLightDeltaZ) & 0x7FFFFFFF) != 0) { if (fabs(fLightDeltaZ) > FLT_EPSILON) { fZ = SLight[0][uiSLightOffset / 0x30].speed.fZ; dLightDistanceZ = fabs(fLightDeltaZ); if (fZ > dLightDistanceZ) fZ = (float)dLightDistanceZ; if (fLightDeltaZ <= 0.0) - dLightPosZ = SLight[0][uiSLightOffset / 0x30].currentPos.fZ - fZ; + dLightPosZ = + SLight[0][uiSLightOffset / 0x30].currentPos.fZ - fZ; else - dLightPosZ = SLight[0][uiSLightOffset / 0x30].currentPos.fZ + fZ; - SLight[0][uiSLightOffset / 0x30].currentPos.fZ = (float)dLightPosZ; + dLightPosZ = + SLight[0][uiSLightOffset / 0x30].currentPos.fZ + fZ; + SLight[0][uiSLightOffset / 0x30].currentPos.fZ = + (float)dLightPosZ; if (countdown < 126) { dLightSpeedZ = SLight[0][uiSLightOffset / 0x30].speed.fZ + -2.5; SLight[0][uiSLightOffset / 0x30].speed.fZ = (float)dLightSpeedZ; @@ -849,7 +978,7 @@ void control() } while (uiSLightOffset != 0x90 * i + 144); } } - if (fudge_wait < 0) // Test collisions and check lap line crossings + if (fudge_wait < 0) // Test collisions and check lap line crossings testcollisions(); iCrossLineIdx = 0; if (numcars > 0) { @@ -864,13 +993,16 @@ void control() } if (replaytype == 1 && fudge_wait < 0) DoReplayData(); - if (replaytype != 2 || newreplayframe) // Calculate car motion effects based on health and speed + if (replaytype != 2 || newreplayframe) // Calculate car motion effects based + // on health and speed { iMotionCarIdx = 0; if (numcars > 0) { pCurrentCar = Car; do { - fHealthFactor = (pCurrentCar->fHealth + 34.0f) * 0.01f;// Apply random motion effects: more damage = more erratic movement + fHealthFactor = (pCurrentCar->fHealth + 34.0f) * + 0.01f; // Apply random motion effects: more damage = + // more erratic movement pMotionCar = pCurrentCar; if (fHealthFactor > 1.0) fHealthFactor = 1.0; @@ -878,21 +1010,32 @@ void control() fDamageMultiplier = (float)dDamageFactor; fHealthValue = (float)dDamageFactor * pCurrentCar->fFinalSpeed; iRandomValue = ROLLERrand() - 0x4000; - dRollMotionCalc = (double)iRandomValue * fHealthValue / (double)CarEngines.engines[pCurrentCar->byCarDesignIdx].iStabilityFactor; + dRollMotionCalc = + (double)iRandomValue * fHealthValue / + (double)CarEngines.engines[pCurrentCar->byCarDesignIdx] + .iStabilityFactor; //_CHP(); pCurrentCar->iRollMotion = (int)dRollMotionCalc; fHealthValue = fDamageMultiplier * pCurrentCar->fFinalSpeed; iRandomValue = ROLLERrand() - 0x4000; - dPitchMotionCalc = (double)iRandomValue * fHealthValue / (double)CarEngines.engines[pCurrentCar->byCarDesignIdx].iStabilityFactor; + dPitchMotionCalc = + (double)iRandomValue * fHealthValue / + (double)CarEngines.engines[pCurrentCar->byCarDesignIdx] + .iStabilityFactor; //_CHP(); pCurrentCar->iPitchMotion = (int)dPitchMotionCalc; fHealthValue = fDamageMultiplier * pCurrentCar->fFinalSpeed; iRandomValue = ROLLERrand() - 0x4000; - dYawMotionCalc = (double)iRandomValue * fHealthValue / (double)CarEngines.engines[pCurrentCar->byCarDesignIdx].iStabilityFactor; - //*(float *)&iRandomValue = fDamageMultiplier * pCurrentCar->fFinalSpeed; - //LODWORD(fHealthValue) = ROLLERrandRaw() - 0x4000; - //dYawMotionCalc = (double)SLODWORD(fHealthValue) * *(float *)&iRandomValue / (double)CarEngines.engines[pCurrentCar->byCarDesignIdx].iStabilityFactor; + dYawMotionCalc = + (double)iRandomValue * fHealthValue / + (double)CarEngines.engines[pCurrentCar->byCarDesignIdx] + .iStabilityFactor; + //*(float *)&iRandomValue = fDamageMultiplier * + // pCurrentCar->fFinalSpeed; LODWORD(fHealthValue) = ROLLERrandRaw() - + // 0x4000; dYawMotionCalc = (double)SLODWORD(fHealthValue) * *(float + // *)&iRandomValue / + // (double)CarEngines.engines[pCurrentCar->byCarDesignIdx].iStabilityFactor; //_CHP(); ++pCurrentCar; ++iMotionCarIdx; @@ -901,7 +1044,8 @@ void control() } while (iMotionCarIdx < iNumCarsTemp); } } - if (replaytype == 2 && replayspeed == 256)// Handle replay sound effects synchronization + if (replaytype == 2 && + replayspeed == 256) // Handle replay sound effects synchronization { for (j = 0; j < numcars; ++j) { bySampleValue = newrepsample[j]; @@ -914,7 +1058,8 @@ void control() } } } - analysespeechsamples(); // Finalize frame: analyze speech, order cars, handle audio + analysespeechsamples(); // Finalize frame: analyze speech, order cars, + // handle audio ordercars(); if (replaytype != 2) { if (paused) { @@ -926,43 +1071,53 @@ void control() enginesounds(ViewType[0]); } } - if (!intro && human_finishers >= players && (disable_messages || network_on))// Check race completion conditions and network state + if (!intro && human_finishers >= players && + (disable_messages || + network_on)) // Check race completion conditions and network state { iNetworkArraySize = 4 * numcars; iCarOffset = network_on; if (network_on) { if (wConsoleNode == master) { - send_finished = -1; // Network master: check if any human players still racing + send_finished = + -1; // Network master: check if any human players still racing if (numcars > 0) { iMasterCarIdx = 0; iMasterByteIdx = 0; do { - if ((Car[iMasterCarIdx].byLives & 0x80u) == 0 && Car[iMasterCarIdx].fFinalSpeed > 0.0 && human_control[iMasterByteIdx / 4u]) + if ((Car[iMasterCarIdx].byLives & 0x80u) == 0 && + Car[iMasterCarIdx].fFinalSpeed > 0.0 && + human_control[iMasterByteIdx / 4u]) send_finished = 0; iMasterByteIdx += 4; ++iMasterCarIdx; } while (iMasterByteIdx < iNetworkArraySize); } } else { - iSlaveByteIdx = 0; // Network slave: determine local racing state + iSlaveByteIdx = 0; // Network slave: determine local racing state racing = 0; if (numcars > 0) { iSlaveCarIdx = 0; do { - if ((Car[iSlaveCarIdx].byLives & 0x80u) == 0 && Car[iSlaveCarIdx].fFinalSpeed > 0.0 && human_control[iSlaveByteIdx / 4u]) + if ((Car[iSlaveCarIdx].byLives & 0x80u) == 0 && + Car[iSlaveCarIdx].fFinalSpeed > 0.0 && + human_control[iSlaveByteIdx / 4u]) racing = -1; iSlaveByteIdx += 4; ++iSlaveCarIdx; } while (iSlaveByteIdx < iNetworkArraySize); } } - } else if (lastsample < -72) // Single player: check if any human players still racing + } else if (lastsample < + -72) // Single player: check if any human players still racing { racing = network_on; if (numcars > 0) { iRacingByteIdx = 0; do { - if (*((char *)&Car[0].byLives + iCarOffset) >= 0 && *(float *)((char *)&Car[0].fFinalSpeed + iCarOffset) > 0.0 && human_control[iRacingByteIdx / 4u]) + if (*((char *)&Car[0].byLives + iCarOffset) >= 0 && + *(float *)((char *)&Car[0].fFinalSpeed + iCarOffset) > 0.0 && + human_control[iRacingByteIdx / 4u]) racing = -1; iRacingByteIdx += 4; iCarOffset += sizeof(tCar); @@ -970,21 +1125,25 @@ void control() } } } - if (++nearcarcheck == 4) // Update near car checking counter and advance frame pointer + if (++nearcarcheck == + 4) // Update near car checking counter and advance frame pointer nearcarcheck = 0; if (replaytype == 2) readptr = writeptr; else readptr = ((int16)readptr + 1) & 0x1FF; } - if (replaytype != 2 && numcars > 0) // Final processing: handle special car state changes for active cars + if (replaytype != 2 && numcars > 0) // Final processing: handle special car + // state changes for active cars { iFinalArraySize = 4 * numcars; iFinalCarIdx = 0; iFinalByteIdx = 0; while (1) { - if (Car[iFinalCarIdx].fFinalSpeed <= 36.0 || Car[iFinalCarIdx].fFinalSpeed >= 100.0) - goto LABEL_185; // Toggle special car state (byUnk68) based on speed and current state + if (Car[iFinalCarIdx].fFinalSpeed <= 36.0 || + Car[iFinalCarIdx].fFinalSpeed >= 100.0) + goto LABEL_185; // Toggle special car state (byUnk68) based on speed and + // current state byUnk68 = Car[iFinalCarIdx].byWheelAnimationFrame; if (byUnk68 > 1) break; @@ -1006,9 +1165,8 @@ void control() } //------------------------------------------------------------------------------------------------- -//0002AEC0 -double calc_revs(tRevCurve *pRevs, int iGear, float fChg) -{ +// 0002AEC0 +double calc_revs(tRevCurve *pRevs, int iGear, float fChg) { tRevCurve *pCurrentGearCurve; // eax double dDelta0; double dDelta1; // [esp+18h] [ebp-30h] @@ -1029,8 +1187,9 @@ double calc_revs(tRevCurve *pRevs, int iGear, float fChg) float fRPM3; float fCalculatedResult; // [esp+3Ch] [ebp-Ch] - pCurrentGearCurve = &pRevs[iGear];// Get pointer to power/RPM curve for specified gear - fPower0 = pCurrentGearCurve->points[0].fPower;// Load power and RPM values + pCurrentGearCurve = + &pRevs[iGear]; // Get pointer to power/RPM curve for specified gear + fPower0 = pCurrentGearCurve->points[0].fPower; // Load power and RPM values fPower1 = pCurrentGearCurve->points[1].fPower; fPower2 = pCurrentGearCurve->points[2].fPower; fPower3 = pCurrentGearCurve->points[3].fPower; @@ -1038,30 +1197,41 @@ double calc_revs(tRevCurve *pRevs, int iGear, float fChg) fRPM1 = pCurrentGearCurve->points[1].fRPM; fRPM2 = pCurrentGearCurve->points[2].fRPM; fRPM3 = pCurrentGearCurve->points[3].fRPM; - dDelta0 = fChg - fPower0;// Calculate delta values for quadratic interpolation + dDelta0 = + fChg - fPower0; // Calculate delta values for quadratic interpolation dDelta1 = fChg - fPower1; dDelta2 = fChg - fPower2; dDelta3 = fChg - fPower3; if (fChg < 0.0 || fChg >= (double)fPower1) { if (fChg >= (double)fPower3) { - fCalculatedResult = 1.0;// High RPM range: return maximum value + fCalculatedResult = 1.0; // High RPM range: return maximum value } else { - dHighInterp1 = (fPower1 - fPower2) * (fPower1 - fPower3);// Mid RPM range: quadratic interpolation between points 1-3 + dHighInterp1 = (fPower1 - fPower2) * + (fPower1 - fPower3); // Mid RPM range: quadratic + // interpolation between points 1-3 dHighInterp2 = (fPower2 - fPower1) * (fPower2 - fPower3); dHighInterp3 = (fPower3 - fPower1) * (fPower3 - fPower2); - fCalculatedResult = (float)(dDelta2 * dDelta3 * fRPM1 / dHighInterp1 - + dDelta1 * dDelta3 * fRPM2 / dHighInterp2 - + dDelta1 * dDelta2 * fRPM3 / dHighInterp3);// Complete quadratic interpolation using all three points + fCalculatedResult = + (float)(dDelta2 * dDelta3 * fRPM1 / dHighInterp1 + + dDelta1 * dDelta3 * fRPM2 / dHighInterp2 + + dDelta1 * dDelta2 * fRPM3 / + dHighInterp3); // Complete quadratic interpolation using + // all three points } } else { - dLowInterp1 = (fPower0 - fPower1) * fPower0;// Low RPM range: quadratic interpolation between points 0-1 + dLowInterp1 = + (fPower0 - fPower1) * + fPower0; // Low RPM range: quadratic interpolation between points 0-1 dLowInterp2 = (fPower1 - fPower0) * fPower1; - fCalculatedResult = (float)(dDelta1 * fChg * fRPM0 / dLowInterp1 - + dDelta0 * fChg * fRPM1 / dLowInterp2);// Calculate interpolated value using quadratic formula for low range + fCalculatedResult = + (float)(dDelta1 * fChg * fRPM0 / dLowInterp1 + + dDelta0 * fChg * fRPM1 / + dLowInterp2); // Calculate interpolated value using + // quadratic formula for low range } // clamp result to between 0.0 and 1.0 - if (fCalculatedResult < 0.0) // Clamp result to valid range [0.0, 1.0] + if (fCalculatedResult < 0.0) // Clamp result to valid range [0.0, 1.0] fCalculatedResult = 0.0; if (fCalculatedResult > 1.0) return 1.0; @@ -1069,31 +1239,35 @@ double calc_revs(tRevCurve *pRevs, int iGear, float fChg) } //------------------------------------------------------------------------------------------------- -//0002B030 -double calc_pow(int iCarDesignIdx, int iCurrentGear, float fRPMRatio) -{ - tRevCurve *pfRevData; // eax - double dLowInterp1; // st5 - double dLowInterp2; // st4 - double dLowCoeffA; // st6 - double dLowCoeffB; // st7 - double dHighInterp1; // st5 - double dHighInterp2; // st3 - double dHighInterp3; // [esp+20h] [ebp-2Ch] - double dHighCoeffA; // [esp+0h] [ebp-4Ch] - double dHighCoeffB; // rtt - float fPower0; // [esp+30h] [ebp-1Ch] - float fPower1; // [esp+44h] [ebp-8h] - float fPower2; // [esp+3Ch] [ebp-10h] - float fPower3; // [esp+40h] [ebp-Ch] - float fRPM0; // [esp+24h] [ebp-28h] - float fRPM1; // [esp+34h] [ebp-18h] - float fRPM2; // [esp+28h] [ebp-24h] - float fRPM3; // [esp+2Ch] [ebp-20h] +// 0002B030 +double calc_pow(int iCarDesignIdx, int iCurrentGear, float fRPMRatio) { + tRevCurve *pfRevData; // eax + double dLowInterp1; // st5 + double dLowInterp2; // st4 + double dLowCoeffA; // st6 + double dLowCoeffB; // st7 + double dHighInterp1; // st5 + double dHighInterp2; // st3 + double dHighInterp3; // [esp+20h] [ebp-2Ch] + double dHighCoeffA; // [esp+0h] [ebp-4Ch] + double dHighCoeffB; // rtt + float fPower0; // [esp+30h] [ebp-1Ch] + float fPower1; // [esp+44h] [ebp-8h] + float fPower2; // [esp+3Ch] [ebp-10h] + float fPower3; // [esp+40h] [ebp-Ch] + float fRPM0; // [esp+24h] [ebp-28h] + float fRPM1; // [esp+34h] [ebp-18h] + float fRPM2; // [esp+28h] [ebp-24h] + float fRPM3; // [esp+2Ch] [ebp-20h] float fCalculatedPower; // [esp+38h] [ebp-14h] - pfRevData = CarEngines.engines[iCarDesignIdx].pRevs;// Get pointer to power/RPM curve data for this car and gear - fPower0 = pfRevData[iCurrentGear].points[0].fPower;// Load 4 power values and 4 RPM points for power curve interpolation + pfRevData = + CarEngines.engines[iCarDesignIdx] + .pRevs; // Get pointer to power/RPM curve data for this car and gear + fPower0 = pfRevData[iCurrentGear] + .points[0] + .fPower; // Load 4 power values and 4 RPM points for power curve + // interpolation fPower1 = pfRevData[iCurrentGear].points[1].fPower; fPower2 = pfRevData[iCurrentGear].points[2].fPower; fPower3 = pfRevData[iCurrentGear].points[3].fPower; @@ -1103,33 +1277,42 @@ double calc_pow(int iCarDesignIdx, int iCurrentGear, float fRPMRatio) fRPM3 = pfRevData[iCurrentGear].points[3].fRPM; if (fRPMRatio < 0.0 || fRPMRatio >= (double)fRPM1) { if (fRPMRatio >= (double)fRPM3) { - fCalculatedPower = fPower3;// High RPM range: use maximum power value + fCalculatedPower = fPower3; // High RPM range: use maximum power value } else { - dHighInterp1 = (fPower1 - fPower2) * (fPower1 - fPower3);// Mid RPM range: quadratic interpolation between points 1-3 + dHighInterp1 = (fPower1 - fPower2) * + (fPower1 - fPower3); // Mid RPM range: quadratic + // interpolation between points 1-3 dHighInterp2 = (fPower2 - fPower1) * (fPower2 - fPower3); dHighInterp3 = (fPower3 - fPower1) * (fPower3 - fPower2); - dHighCoeffA = fRPM1 / dHighInterp1 + fRPM2 / dHighInterp2 + fRPM3 / dHighInterp3; - dHighCoeffB = -(fPower2 + fPower3) * fRPM1 / dHighInterp1 - - (fPower1 + fPower3) * fRPM2 / dHighInterp2 - - (fPower1 + fPower2) * fRPM3 / dHighInterp3; - fCalculatedPower = (float)((sqrt( - dHighCoeffB * dHighCoeffB - - (fPower2 * fPower3 * fRPM1 / dHighInterp1 - + fPower1 * fPower3 * fRPM2 / dHighInterp2 - + fPower1 * fPower2 * fRPM3 / dHighInterp3 - - fRPMRatio) - * dHighCoeffA * 4.0) - dHighCoeffB) - / (dHighCoeffA * 2.0));// Solve complex quadratic equation for mid-range power + dHighCoeffA = + fRPM1 / dHighInterp1 + fRPM2 / dHighInterp2 + fRPM3 / dHighInterp3; + dHighCoeffB = -(fPower2 + fPower3) * fRPM1 / dHighInterp1 - + (fPower1 + fPower3) * fRPM2 / dHighInterp2 - + (fPower1 + fPower2) * fRPM3 / dHighInterp3; + fCalculatedPower = + (float)((sqrt(dHighCoeffB * dHighCoeffB - + (fPower2 * fPower3 * fRPM1 / dHighInterp1 + + fPower1 * fPower3 * fRPM2 / dHighInterp2 + + fPower1 * fPower2 * fRPM3 / dHighInterp3 - fRPMRatio) * + dHighCoeffA * 4.0) - + dHighCoeffB) / + (dHighCoeffA * 2.0)); // Solve complex quadratic equation for + // mid-range power } } else { - dLowInterp1 = (fPower0 - fPower1) * fPower0;// Low RPM range: quadratic interpolation between points 0-1 + dLowInterp1 = + (fPower0 - fPower1) * + fPower0; // Low RPM range: quadratic interpolation between points 0-1 dLowInterp2 = (fPower1 - fPower0) * fPower1; dLowCoeffA = fRPM0 / dLowInterp1 + fRPM1 / dLowInterp2; dLowCoeffB = -fPower1 * fRPM0 / dLowInterp1 - fPower0 * fRPM1 / dLowInterp2; - fCalculatedPower = (float)((sqrt(dLowCoeffB * dLowCoeffB - - -fRPMRatio * dLowCoeffA * 4.0) - dLowCoeffB) / (dLowCoeffA * 2.0));// Solve quadratic equation using quadratic formula + fCalculatedPower = + (float)((sqrt(dLowCoeffB * dLowCoeffB - -fRPMRatio * dLowCoeffA * 4.0) - + dLowCoeffB) / + (dLowCoeffA * + 2.0)); // Solve quadratic equation using quadratic formula } - if (fCalculatedPower < 0.0) // Clamp power output to valid range [0, 1024] + if (fCalculatedPower < 0.0) // Clamp power output to valid range [0, 1024] fCalculatedPower = 0.0; if (fCalculatedPower > 1024.0) return 1024.0; @@ -1137,56 +1320,61 @@ double calc_pow(int iCarDesignIdx, int iCurrentGear, float fRPMRatio) } //------------------------------------------------------------------------------------------------- -//0002B260 -void Accelerate(tCar *pCar) -{ // Set car complexity factor: 2.0 for advanced cars, 1.0 for simple cars - int iCarDesignIdx; // ebp - tCarEngine *pEngineData; // edi - int nCurrChunk; // eax - int iNextChunk; // eax - tData *pTrackData; // edx - tTrackInfo *pTrackInfo; // ebx - int iDriverIdx; // ebx - double dDownshiftPower; // st7 - double dUpshiftPower; // st7 +// 0002B260 +void Accelerate(tCar *pCar) { // Set car complexity factor: 2.0 for advanced + // cars, 1.0 for simple cars + int iCarDesignIdx; // ebp + tCarEngine *pEngineData; // edi + int nCurrChunk; // eax + int iNextChunk; // eax + tData *pTrackData; // edx + tTrackInfo *pTrackInfo; // ebx + int iDriverIdx; // ebx + double dDownshiftPower; // st7 + double dUpshiftPower; // st7 double dCalculatedRPMRatio; // st7 - int iPitchDelta; // ebp - int iMaxPitchOffset_1; // eax - int iPitchDynamicOffset; // eax - int iMaxPitchOffset; // edx - int iOldPitchOffset; // eax - double dPitchDecay; // st6 - int iPitchDeltaNormal; // ecx - int iMaxPitchNormal; // ebp - double dMaxRPMChange; // [esp+8h] [ebp-78h] - float fUpshiftSpeed; // [esp+28h] [ebp-58h] - float fNegHealthFactor; // [esp+2Ch] [ebp-54h] - float fTrackHalfWidth; // [esp+30h] [ebp-50h] - float fDownshiftThreshold; // [esp+34h] [ebp-4Ch] - float fAdjustedGravity; // [esp+38h] [ebp-48h] - float fPitchDecayAmount; // [esp+3Ch] [ebp-44h] - int iGearChanged; // [esp+40h] [ebp-40h] - float *pSpds; // [esp+44h] [ebp-3Ch] + int iPitchDelta; // ebp + int iMaxPitchOffset_1; // eax + int iPitchDynamicOffset; // eax + int iMaxPitchOffset; // edx + int iOldPitchOffset; // eax + double dPitchDecay; // st6 + int iPitchDeltaNormal; // ecx + int iMaxPitchNormal; // ebp + double dMaxRPMChange; // [esp+8h] [ebp-78h] + float fUpshiftSpeed; // [esp+28h] [ebp-58h] + float fNegHealthFactor; // [esp+2Ch] [ebp-54h] + float fTrackHalfWidth; // [esp+30h] [ebp-50h] + float fDownshiftThreshold; // [esp+34h] [ebp-4Ch] + float fAdjustedGravity; // [esp+38h] [ebp-48h] + float fPitchDecayAmount; // [esp+3Ch] [ebp-44h] + int iGearChanged; // [esp+40h] [ebp-40h] + float *pSpds; // [esp+44h] [ebp-3Ch] float fCarComplexityFactor; // [esp+48h] [ebp-38h] - float fGravityFactor; // [esp+4Ch] [ebp-34h] - float fNewRPMRatio; // [esp+50h] [ebp-30h] + float fGravityFactor; // [esp+4Ch] [ebp-34h] + float fNewRPMRatio; // [esp+50h] [ebp-30h] float fCalculatedBaseSpeed; // [esp+50h] [ebp-30h] - float fRPMRatioChange; // [esp+54h] [ebp-2Ch] - float fHealthFactor; // [esp+58h] [ebp-28h] - float fPower; // [esp+5Ch] [ebp-24h] - int iGearAyMax; // [esp+60h] [ebp-20h] - int iChunkIdx; // [esp+64h] [ebp-1Ch] + float fRPMRatioChange; // [esp+54h] [ebp-2Ch] + float fHealthFactor; // [esp+58h] [ebp-28h] + float fPower; // [esp+5Ch] [ebp-24h] + int iGearAyMax; // [esp+60h] [ebp-20h] + int iChunkIdx; // [esp+64h] [ebp-1Ch] // TEX_OFF_ADVANCED_CARS if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) fCarComplexityFactor = 2.0; else fCarComplexityFactor = 1.0; - pCar->byAccelerating = -1; // Initialize acceleration state and gear change flag + pCar->byAccelerating = + -1; // Initialize acceleration state and gear change flag iGearChanged = 0; - if (pCar->byThrottlePressed && !pCar->byEngineStartTimer)// Check if car can accelerate (throttle pressed and not crashed) + if (pCar->byThrottlePressed && + !pCar->byEngineStartTimer) // Check if car can accelerate (throttle + // pressed and not crashed) { - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car damage, capped at 1.0 + fHealthFactor = + (pCar->fHealth + 34.0f) * 0.01f; // Calculate health factor (0-1) based + // on car damage, capped at 1.0 iCarDesignIdx = pCar->byCarDesignIdx; pCar->iEngineState = 10; pEngineData = &CarEngines.engines[iCarDesignIdx]; @@ -1194,95 +1382,135 @@ void Accelerate(tCar *pCar) fHealthFactor = 1.0; fPower = pCar->fPower; iGearAyMax = (char)pCar->byGearAyMax; - if (pCar->fRPMRatio >= 1.0) // Check for redline condition (RPM ratio >= 1.0) + if (pCar->fRPMRatio >= + 1.0) // Check for redline condition (RPM ratio >= 1.0) { - pCar->fWheelSpinFactor = 1.0; // Redline: limit acceleration and apply engine damage for over-revving - if (pEngineData->iNumGears - 1 > iGearAyMax && iGearAyMax >= 0 || iGearAyMax == -2 && pCar->fFinalSpeed > 0.0) + pCar->fWheelSpinFactor = 1.0; // Redline: limit acceleration and apply + // engine damage for over-revving + if (pEngineData->iNumGears - 1 > iGearAyMax && iGearAyMax >= 0 || + iGearAyMax == -2 && pCar->fFinalSpeed > 0.0) dodamage(pCar, 0.02f); } else { nCurrChunk = pCar->nCurrChunk; - if (nCurrChunk == -1) // Off-track: apply high acceleration bonus and reduced wheel spin + if (nCurrChunk == + -1) // Off-track: apply high acceleration bonus and reduced wheel spin { pCar->fWheelSpinFactor = 20.0f; fPower = fPower + 32.0f; } else { - iNextChunk = nCurrChunk + 1; // On-track: calculate track physics effects (banking, gravity) + iNextChunk = + nCurrChunk + + 1; // On-track: calculate track physics effects (banking, gravity) if (iNextChunk == TRAK_LEN) iNextChunk ^= TRAK_LEN; iChunkIdx = pCar->nCurrChunk; pTrackData = &localdata[iChunkIdx]; - fTrackHalfWidth = ((pCar->pos.fX + pTrackData->fTrackHalfLength) * localdata[iNextChunk].fTrackHalfWidth - - (pCar->pos.fX - pTrackData->fTrackHalfLength) * localdata[iChunkIdx].fTrackHalfWidth) - / (pTrackData->fTrackHalfLength - * 2.0f); // Calculate interpolated track half-width at car position + fTrackHalfWidth = + ((pCar->pos.fX + pTrackData->fTrackHalfLength) * + localdata[iNextChunk].fTrackHalfWidth - + (pCar->pos.fX - pTrackData->fTrackHalfLength) * + localdata[iChunkIdx].fTrackHalfWidth) / + (pTrackData->fTrackHalfLength * + 2.0f); // Calculate interpolated track half-width at car position pTrackInfo = &TrackInfo[iChunkIdx]; - if (pCar->pos.fY <= (double)fTrackHalfWidth)// Select banking angle based on car position (left/right/center of track) + if (pCar->pos.fY <= + (double)fTrackHalfWidth) // Select banking angle based on car + // position (left/right/center of track) { if (-fTrackHalfWidth <= pCar->pos.fY) fAdjustedGravity = pTrackData->gravity.fY; else - fAdjustedGravity = pTrackData->gravity.fY * tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - pTrackData->gravity.fZ * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; + fAdjustedGravity = pTrackData->gravity.fY * + tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - + pTrackData->gravity.fZ * + tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; } else { - fAdjustedGravity = pTrackData->gravity.fY * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + pTrackData->gravity.fZ * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; + fAdjustedGravity = pTrackData->gravity.fY * + tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + + pTrackData->gravity.fZ * + tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; } - fGravityFactor = (pTrackData->gravity.fX * tcos[pCar->nYaw] + fAdjustedGravity * tsin[pCar->nYaw]) * 2.0f;// Calculate gravity factor based on track inclination and car orientation + fGravityFactor = (pTrackData->gravity.fX * tcos[pCar->nYaw] + + fAdjustedGravity * tsin[pCar->nYaw]) * + 2.0f; // Calculate gravity factor based on track + // inclination and car orientation fNegHealthFactor = -fHealthFactor; if (fGravityFactor < (double)fNegHealthFactor) fGravityFactor = -fHealthFactor; iDriverIdx = pCar->iDriverIdx; - if (player1_car == iDriverIdx || player2_car == iDriverIdx)// Apply different wheel spin factors for human vs AI players + if (player1_car == iDriverIdx || + player2_car == iDriverIdx) // Apply different wheel spin factors for + // human vs AI players pCar->fWheelSpinFactor = (fGravityFactor + 1.0f) * 6.0f; else pCar->fWheelSpinFactor = 1.0; - if (cheat_control && iCarDesignIdx == 9)// Special acceleration bonuses: cheat mode, neutral gear, or race position + if (cheat_control && + iCarDesignIdx == 9) // Special acceleration bonuses: cheat mode, + // neutral gear, or race position { fPower = fPower + 32.0f; } else if (iGearAyMax == -1) { fPower = fCarComplexityFactor * 2.0f + fPower; - } else if (pCar->fTotalRaceTime >= 20.0f || human_control[pCar->iDriverIdx] || g_bAINoCheatStart) { // Last check added by ROLLER - fPower = (fHealthFactor + fCarComplexityFactor + fGravityFactor) * 0.5f + fPower; + } else if (pCar->fTotalRaceTime >= 20.0f || + human_control[pCar->iDriverIdx] || + g_bAINoCheatStart) { // Last check added by ROLLER + fPower = + (fHealthFactor + fCarComplexityFactor + fGravityFactor) * 0.5f + + fPower; } else { - fPower = (fHealthFactor + fCarComplexityFactor + fGravityFactor) / (float)(pCar->byRacePosition / 15 + 1) + fPower; + fPower = (fHealthFactor + fCarComplexityFactor + fGravityFactor) / + (float)(pCar->byRacePosition / 15 + 1) + + fPower; } } } - if (fPower >= 1024.0f) // Clamp power output to maximum value (1023) + if (fPower >= 1024.0f) // Clamp power output to maximum value (1023) fPower = 1023.0f; pSpds = pEngineData->pSpds; if (iGearAyMax <= 0) fDownshiftThreshold = 0.0f; else fDownshiftThreshold = pSpds[iGearAyMax - 1] * 0.5f; - if (fabs(pCar->fFinalSpeed / fHealthFactor) < fDownshiftThreshold && human_control[pCar->iDriverIdx] != 2 && iGearAyMax > 0)// Auto downshift: check if speed is too low for current gear + if (fabs(pCar->fFinalSpeed / fHealthFactor) < fDownshiftThreshold && + human_control[pCar->iDriverIdx] != 2 && + iGearAyMax > + 0) // Auto downshift: check if speed is too low for current gear { - dDownshiftPower = change_gear(iGearAyMax, iGearAyMax - 1, pCar, iCarDesignIdx); + dDownshiftPower = + change_gear(iGearAyMax, iGearAyMax - 1, pCar, iCarDesignIdx); --iGearAyMax; iGearChanged = -1; fPower = (float)dDownshiftPower; pCar->byGearAyMax = iGearAyMax; } - if (pEngineData->iNumGears - 1 > iGearAyMax - && iGearAyMax >= 0 - && human_control[pCar->iDriverIdx] != 2 - && fPower > (double)pEngineData->pChgs[2 * iGearAyMax] * 1.2 - && pCar->fRPMRatio >= (double)eng_chg_revs[12 * iCarDesignIdx + 2 * iGearAyMax])// Auto upshift: check power, RPM, and speed thresholds + if (pEngineData->iNumGears - 1 > iGearAyMax && iGearAyMax >= 0 && + human_control[pCar->iDriverIdx] != 2 && + fPower > (double)pEngineData->pChgs[2 * iGearAyMax] * 1.2 && + pCar->fRPMRatio >= + (double)eng_chg_revs[12 * iCarDesignIdx + + 2 * iGearAyMax]) // Auto upshift: check power, + // RPM, and speed thresholds { - fUpshiftSpeed = pCar->fRPMRatio * pSpds[iGearAyMax] * fHealthFactor * 0.5f; + fUpshiftSpeed = + pCar->fRPMRatio * pSpds[iGearAyMax] * fHealthFactor * 0.5f; if (pCar->fFinalSpeed >= (double)fUpshiftSpeed) { - dUpshiftPower = change_gear(iGearAyMax, iGearAyMax + 1, pCar, iCarDesignIdx); + dUpshiftPower = + change_gear(iGearAyMax, iGearAyMax + 1, pCar, iCarDesignIdx); pCar->byGearAyMax = ++iGearAyMax; fPower = (float)dUpshiftPower; iGearChanged = -1; } } - pCar->fPower = fPower; // Calculate new RPM ratio using calc_revs function + pCar->fPower = fPower; // Calculate new RPM ratio using calc_revs function if (iGearAyMax < 0) dCalculatedRPMRatio = calc_revs(pEngineData->pRevs, 0, fPower); else dCalculatedRPMRatio = calc_revs(pEngineData->pRevs, iGearAyMax, fPower); fNewRPMRatio = (float)dCalculatedRPMRatio; fRPMRatioChange = fNewRPMRatio - pCar->fRPMRatio; - if (pCar->nCurrChunk != -1 && iCarDesignIdx != 9 && iGearAyMax != -1)// Limit RPM ratio changes to realistic values when on track + if (pCar->nCurrChunk != -1 && iCarDesignIdx != 9 && + iGearAyMax != + -1) // Limit RPM ratio changes to realistic values when on track { if (fRPMRatioChange <= 0.0f) { if (fRPMRatioChange < -0.03f) @@ -1297,7 +1525,7 @@ void Accelerate(tCar *pCar) } } pCar->fRPMRatio = pCar->fRPMRatio + fRPMRatioChange; - if (iGearAyMax == -1) // Calculate base speed for different gear types + if (iGearAyMax == -1) // Calculate base speed for different gear types { pCar->fBaseSpeed = 0.0; } else if (iGearAyMax < 0) { @@ -1306,15 +1534,19 @@ void Accelerate(tCar *pCar) fCalculatedBaseSpeed = pSpds[iGearAyMax] * fNewRPMRatio * fHealthFactor; pCar->fBaseSpeed = fCalculatedBaseSpeed; } - if (iGearAyMax < 0 && !race_started) // Reset speed overflow in reverse before race starts + if (iGearAyMax < 0 && + !race_started) // Reset speed overflow in reverse before race starts pCar->fSpeedOverflow = 0.0; - if (iGearChanged) // Update speed overflow when gear changes occur + if (iGearChanged) // Update speed overflow when gear changes occur pCar->fSpeedOverflow = pCar->fFinalSpeed - pCar->fBaseSpeed; - if ((char)pCar->byGearAyMax != -1) // Update car pitch dynamics based on acceleration + if ((char)pCar->byGearAyMax != + -1) // Update car pitch dynamics based on acceleration { - if (iCarDesignIdx == 9) { // Special pitch handling for cheat mode (car design 9) + if (iCarDesignIdx == + 9) { // Special pitch handling for cheat mode (car design 9) if (cheat_control && pCar->fRPMRatio < 1.0) { - iPitchDelta = 32 * pEngineData->iPitchAccelRate + pCar->iPitchDynamicOffset; + iPitchDelta = + 32 * pEngineData->iPitchAccelRate + pCar->iPitchDynamicOffset; pCar->iPitchDynamicOffset = iPitchDelta; iMaxPitchOffset_1 = pEngineData->iMaxPitchOffset; if (12 * iMaxPitchOffset_1 < iPitchDelta) @@ -1324,7 +1556,9 @@ void Accelerate(tCar *pCar) iMaxPitchOffset = pEngineData->iMaxPitchOffset; if (iPitchDynamicOffset > iMaxPitchOffset) { fPitchDecayAmount = (float)(iPitchDynamicOffset - iMaxPitchOffset); - if ((double)(48 * pEngineData->iPitchAccelRate) < fPitchDecayAmount)// Handle extreme pitch: reset camera offsets and apply damage + if ((double)(48 * pEngineData->iPitchAccelRate) < + fPitchDecayAmount) // Handle extreme pitch: reset camera offsets + // and apply damage { pCar->iCameraOscillationPhase = 0; pCar->iRollDampingMomentum = 0; @@ -1343,7 +1577,10 @@ void Accelerate(tCar *pCar) } } } else { - iPitchDeltaNormal = pEngineData->iPitchAccelRate + pCar->iPitchDynamicOffset;// Normal cars: increase pitch with acceleration, clamp to max + iPitchDeltaNormal = + pEngineData->iPitchAccelRate + + pCar->iPitchDynamicOffset; // Normal cars: increase pitch with + // acceleration, clamp to max pCar->iPitchDynamicOffset = iPitchDeltaNormal; iMaxPitchNormal = pEngineData->iMaxPitchOffset; if (iPitchDeltaNormal > iMaxPitchNormal) @@ -1354,41 +1591,42 @@ void Accelerate(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//0002B990 -void Decelerate(tCar *pCar) -{ - int iCarDesignIdx; // edi - tCarEngine *pEngineData; // esi - int byGearAyMax; // ecx - int iCurrChunk; // eax +// 0002B990 +void Decelerate(tCar *pCar) { + int iCarDesignIdx; // edi + tCarEngine *pEngineData; // esi + int byGearAyMax; // ecx + int iCurrChunk; // eax double dInitialDecelerationCalc; // st7 - int iNextChunk; // eax - tData *pTrackData; // edx - tTrackInfo *pTrackInfo; // ebp - double dGravityFactor; // st7 - double dCalculatedPower; // st7 - double dRPMRatioChange; // st7 - int iPitchDelta; // ebp - int iMinPitchOffset; // edx - int iPitchDeltaNeg; // esi - int iPitchDeltaPos; // edx - float fTrackHalfWidth; // [esp+18h] [ebp-44h] - float fAdjustedGravity; // [esp+1Ch] [ebp-40h] - int iNextChunkIdx; // [esp+20h] [ebp-3Ch] - float fRPMRatioChange; // [esp+24h] [ebp-38h] - float fDecelerationRate; // [esp+28h] [ebp-34h] - float fCurrentPower; // [esp+2Ch] [ebp-30h] - float *pSpds; // [esp+30h] [ebp-2Ch] - float fGravityMultiplier; // [esp+34h] [ebp-28h] - float fHealthFactor; // [esp+38h] [ebp-24h] - float fRPMRatio; // [esp+3Ch] [ebp-20h] - float fBaseSpeed; // [esp+40h] [ebp-1Ch] - float fNewBaseSpeed; // [esp+40h] [ebp-1Ch] - float fNewSpeedOverflow; // [esp+40h] [ebp-1Ch] + int iNextChunk; // eax + tData *pTrackData; // edx + tTrackInfo *pTrackInfo; // ebp + double dGravityFactor; // st7 + double dCalculatedPower; // st7 + double dRPMRatioChange; // st7 + int iPitchDelta; // ebp + int iMinPitchOffset; // edx + int iPitchDeltaNeg; // esi + int iPitchDeltaPos; // edx + float fTrackHalfWidth; // [esp+18h] [ebp-44h] + float fAdjustedGravity; // [esp+1Ch] [ebp-40h] + int iNextChunkIdx; // [esp+20h] [ebp-3Ch] + float fRPMRatioChange; // [esp+24h] [ebp-38h] + float fDecelerationRate; // [esp+28h] [ebp-34h] + float fCurrentPower; // [esp+2Ch] [ebp-30h] + float *pSpds; // [esp+30h] [ebp-2Ch] + float fGravityMultiplier; // [esp+34h] [ebp-28h] + float fHealthFactor; // [esp+38h] [ebp-24h] + float fRPMRatio; // [esp+3Ch] [ebp-20h] + float fBaseSpeed; // [esp+40h] [ebp-1Ch] + float fNewBaseSpeed; // [esp+40h] [ebp-1Ch] + float fNewSpeedOverflow; // [esp+40h] [ebp-1Ch] - pCar->byAccelerating = 0; // Initialize car status flags for deceleration + pCar->byAccelerating = 0; // Initialize car status flags for deceleration pCar->iEngineState = 6; - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car damage, capped at 1.0 + fHealthFactor = + (pCar->fHealth + 34.0f) * + 0.01f; // Calculate health factor (0-1) based on car damage, capped at 1.0 iCarDesignIdx = pCar->byCarDesignIdx; pEngineData = &CarEngines.engines[iCarDesignIdx]; fBaseSpeed = pCar->fBaseSpeed; @@ -1396,46 +1634,68 @@ void Decelerate(tCar *pCar) fHealthFactor = 1.0; byGearAyMax = (char)pCar->byGearAyMax; pSpds = pEngineData->pSpds; - if (byGearAyMax < 0) // Handle reverse gear: calculate base speed using RPM ratio + if (byGearAyMax < + 0) // Handle reverse gear: calculate base speed using RPM ratio fBaseSpeed = pCar->fRPMRatio * *pEngineData->pSpds * fHealthFactor; iCurrChunk = pCar->nCurrChunk; - fDecelerationRate = pSpds[pEngineData->iNumGears - 1] / (pEngineData->fDragCoefficient * 36.0f);// Calculate base deceleration rate from top gear max speed - if (iCurrChunk == -1) // Off-track: apply 3x deceleration penalty + fDecelerationRate = + pSpds[pEngineData->iNumGears - 1] / + (pEngineData->fDragCoefficient * + 36.0f); // Calculate base deceleration rate from top gear max speed + if (iCurrChunk == -1) // Off-track: apply 3x deceleration penalty { dInitialDecelerationCalc = fBaseSpeed - fDecelerationRate * 3.0f; - } else if (human_control[pCar->iDriverIdx]) // Human players: apply track banking and gravity effects + } else if (human_control[pCar->iDriverIdx]) // Human players: apply track + // banking and gravity effects { iNextChunk = iCurrChunk + 1; iNextChunkIdx = iNextChunk; if (iNextChunk == TRAK_LEN) iNextChunkIdx = TRAK_LEN ^ iNextChunk; pTrackData = &localdata[pCar->nCurrChunk]; - fTrackHalfWidth = ((pCar->pos.fX + pTrackData->fTrackHalfLength) * localdata[iNextChunkIdx].fTrackHalfWidth - - (pCar->pos.fX - pTrackData->fTrackHalfLength) * localdata[pCar->nCurrChunk].fTrackHalfWidth) - / (pTrackData->fTrackHalfLength - * 2.0f); // Calculate interpolated track half-width at car position + fTrackHalfWidth = + ((pCar->pos.fX + pTrackData->fTrackHalfLength) * + localdata[iNextChunkIdx].fTrackHalfWidth - + (pCar->pos.fX - pTrackData->fTrackHalfLength) * + localdata[pCar->nCurrChunk].fTrackHalfWidth) / + (pTrackData->fTrackHalfLength * + 2.0f); // Calculate interpolated track half-width at car position pTrackInfo = &TrackInfo[pCar->nCurrChunk]; - if (pCar->pos.fY <= (double)fTrackHalfWidth)// Select banking angle based on car position (left/right/center of track) + if (pCar->pos.fY <= + (double)fTrackHalfWidth) // Select banking angle based on car position + // (left/right/center of track) { if (-fTrackHalfWidth <= pCar->pos.fY) fAdjustedGravity = pTrackData->gravity.fY; else - fAdjustedGravity = pTrackData->gravity.fY * tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - pTrackData->gravity.fZ * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; + fAdjustedGravity = + pTrackData->gravity.fY * + tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - + pTrackData->gravity.fZ * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; } else { - fAdjustedGravity = pTrackData->gravity.fY * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + pTrackData->gravity.fZ * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; + fAdjustedGravity = + pTrackData->gravity.fY * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + + pTrackData->gravity.fZ * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; } - dGravityFactor = (pTrackData->gravity.fX * tcos[pCar->nYaw] + fAdjustedGravity * tsin[pCar->nYaw]) * -0.3333333333333333 + 1.0;// Calculate gravity factor based on track inclination and car orientation + dGravityFactor = (pTrackData->gravity.fX * tcos[pCar->nYaw] + + fAdjustedGravity * tsin[pCar->nYaw]) * + -0.3333333333333333 + + 1.0; // Calculate gravity factor based on track inclination + // and car orientation fGravityMultiplier = (float)dGravityFactor; if (dGravityFactor < 0.5) fGravityMultiplier = 0.5f; - dInitialDecelerationCalc = fBaseSpeed - fDecelerationRate * fGravityMultiplier; + dInitialDecelerationCalc = + fBaseSpeed - fDecelerationRate * fGravityMultiplier; } else { - dInitialDecelerationCalc = fBaseSpeed - fDecelerationRate;// AI players: apply standard deceleration rate + dInitialDecelerationCalc = + fBaseSpeed - + fDecelerationRate; // AI players: apply standard deceleration rate } fNewBaseSpeed = (float)dInitialDecelerationCalc; if (fNewBaseSpeed < 0.0) fNewBaseSpeed = 0.0; - if (byGearAyMax >= 0) // Calculate RPM ratio and power for current gear + if (byGearAyMax >= 0) // Calculate RPM ratio and power for current gear { fRPMRatio = fNewBaseSpeed / (pSpds[byGearAyMax] * fHealthFactor); if (fRPMRatio > 1.0) @@ -1448,7 +1708,10 @@ void Decelerate(tCar *pCar) dCalculatedPower = calc_pow(iCarDesignIdx, 0, fRPMRatio); } fCurrentPower = (float)dCalculatedPower; - if (byGearAyMax > 0 && human_control[pCar->iDriverIdx] != 2 && (double)pEngineData->pChgs[2 * byGearAyMax - 1] > fCurrentPower)// Auto downshift: check if power is below gear change threshold + if (byGearAyMax > 0 && human_control[pCar->iDriverIdx] != 2 && + (double)pEngineData->pChgs[2 * byGearAyMax - 1] > + fCurrentPower) // Auto downshift: check if power is below gear change + // threshold { fRPMRatio = fNewBaseSpeed / (pSpds[--byGearAyMax] * fHealthFactor); if (fRPMRatio > 1.0) @@ -1459,7 +1722,9 @@ void Decelerate(tCar *pCar) pCar->byGearAyMax = byGearAyMax; pCar->fPower = fCurrentPower; fRPMRatioChange = (float)dRPMRatioChange; - if (pCar->nCurrChunk != -1 && byGearAyMax != -1) { // Limit RPM ratio changes to realistic values when on track + if (pCar->nCurrChunk != -1 && + byGearAyMax != + -1) { // Limit RPM ratio changes to realistic values when on track if (fRPMRatioChange <= 0.03) { if (fRPMRatioChange < -0.1) fRPMRatioChange = -0.1f; @@ -1468,29 +1733,35 @@ void Decelerate(tCar *pCar) } } pCar->fRPMRatio = pCar->fRPMRatio + fRPMRatioChange; - if (byGearAyMax == -1) // Handle special cases: neutral gear (0) and reverse gear (negate speed) + if (byGearAyMax == -1) // Handle special cases: neutral gear (0) and reverse + // gear (negate speed) { fNewBaseSpeed = 0.0; } else if (byGearAyMax == -2) { fNewBaseSpeed = -fNewBaseSpeed; - //HIBYTE(fNewBaseSpeed) ^= 0x80u; + // HIBYTE(fNewBaseSpeed) ^= 0x80u; } pCar->fBaseSpeed = fNewBaseSpeed; - fNewSpeedOverflow = pCar->fSpeedOverflow - fDecelerationRate;// Update speed overflow, reducing it by deceleration rate + fNewSpeedOverflow = pCar->fSpeedOverflow - + fDecelerationRate; // Update speed overflow, reducing it + // by deceleration rate if (fNewSpeedOverflow < 0.0) fNewSpeedOverflow = 0.0; pCar->fSpeedOverflow = fNewSpeedOverflow; if (byGearAyMax < 0) pCar->fSpeedOverflow = 0.0; - if (pCar->fFinalSpeed <= 0.0) // Update car pitch dynamics based on movement direction + if (pCar->fFinalSpeed <= + 0.0) // Update car pitch dynamics based on movement direction { if (pCar->iPitchDynamicOffset >= 0) { - iPitchDeltaPos = pCar->iPitchDynamicOffset - pEngineData->iNoseUpRecoveryRate; + iPitchDeltaPos = + pCar->iPitchDynamicOffset - pEngineData->iNoseUpRecoveryRate; pCar->iPitchDynamicOffset = iPitchDeltaPos; if (iPitchDeltaPos >= 0) return; } else { - iPitchDeltaNeg = pEngineData->iNoseDownRecoveryRate + pCar->iPitchDynamicOffset; + iPitchDeltaNeg = + pEngineData->iNoseDownRecoveryRate + pCar->iPitchDynamicOffset; pCar->iPitchDynamicOffset = iPitchDeltaNeg; if (iPitchDeltaNeg <= 0) return; @@ -1506,40 +1777,41 @@ void Decelerate(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//0002BDD0 -void FreeWheel(tCar *pCar) -{ - int iCarDesignIdx; // esi - int iGearAyMax; // ecx - tCarEngine *pEngineData; // edi - int iCurrChunk; // eax +// 0002BDD0 +void FreeWheel(tCar *pCar) { + int iCarDesignIdx; // esi + int iGearAyMax; // ecx + tCarEngine *pEngineData; // edi + int iCurrChunk; // eax double dInitialDecelerationCalc; // st7 - int iNextChunk; // eax - tData *pTrackData; // edx - tTrackInfo *pTrackInfo; // ebp - double dGravityFactor; // st7 - double dCalculatedPower; // st7 - double dRPMRatioChange; // st7 - int iPitchDynamicOffset; // esi - int iPitchDeltaNeg; // edx - int iNoseUpRecoveryRate; // eax + int iNextChunk; // eax + tData *pTrackData; // edx + tTrackInfo *pTrackInfo; // ebp + double dGravityFactor; // st7 + double dCalculatedPower; // st7 + double dRPMRatioChange; // st7 + int iPitchDynamicOffset; // esi + int iPitchDeltaNeg; // edx + int iNoseUpRecoveryRate; // eax float fAdjustedDecelerationRate; // [esp+18h] [ebp-48h] - float fDecelerationRate; // [esp+1Ch] [ebp-44h] - float fTrackHalfWidth; // [esp+20h] [ebp-40h] - float fAdjustedGravity; // [esp+24h] [ebp-3Ch] - int iNextChunkIdx; // [esp+28h] [ebp-38h] - float fCurrentPower; // [esp+2Ch] [ebp-34h] - float fRPMRatioChange; // [esp+30h] [ebp-30h] - float *pSpds; // [esp+34h] [ebp-2Ch] - float fGravityMultiplier; // [esp+38h] [ebp-28h] - float fHealthFactor; // [esp+3Ch] [ebp-24h] - float fRPMRatio; // [esp+40h] [ebp-20h] - float fBaseSpeed; // [esp+44h] [ebp-1Ch] - float fNewBaseSpeed; // [esp+44h] [ebp-1Ch] + float fDecelerationRate; // [esp+1Ch] [ebp-44h] + float fTrackHalfWidth; // [esp+20h] [ebp-40h] + float fAdjustedGravity; // [esp+24h] [ebp-3Ch] + int iNextChunkIdx; // [esp+28h] [ebp-38h] + float fCurrentPower; // [esp+2Ch] [ebp-34h] + float fRPMRatioChange; // [esp+30h] [ebp-30h] + float *pSpds; // [esp+34h] [ebp-2Ch] + float fGravityMultiplier; // [esp+38h] [ebp-28h] + float fHealthFactor; // [esp+3Ch] [ebp-24h] + float fRPMRatio; // [esp+40h] [ebp-20h] + float fBaseSpeed; // [esp+44h] [ebp-1Ch] + float fNewBaseSpeed; // [esp+44h] [ebp-1Ch] - pCar->byAccelerating = 0; // Initialize freewheeling state and engine status + pCar->byAccelerating = 0; // Initialize freewheeling state and engine status pCar->iEngineState = 8; - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car damage, capped at 1.0 + fHealthFactor = + (pCar->fHealth + 34.0f) * + 0.01f; // Calculate health factor (0-1) based on car damage, capped at 1.0 iCarDesignIdx = pCar->byCarDesignIdx; iGearAyMax = (char)pCar->byGearAyMax; fBaseSpeed = pCar->fBaseSpeed; @@ -1547,39 +1819,62 @@ void FreeWheel(tCar *pCar) if (fHealthFactor > 1.0) fHealthFactor = 1.0; pSpds = pEngineData->pSpds; - if (iGearAyMax < 0) // Handle reverse gear: calculate base speed using RPM ratio + if (iGearAyMax < + 0) // Handle reverse gear: calculate base speed using RPM ratio fBaseSpeed = pCar->fRPMRatio * *pEngineData->pSpds * fHealthFactor; iCurrChunk = pCar->nCurrChunk; - fDecelerationRate = pSpds[pEngineData->iNumGears - 1] / (pEngineData->fDragCoefficient * 256.0f);// Calculate base deceleration rate from top gear max speed and drag coefficient - if (iCurrChunk == -1) // Off-track: apply 16x deceleration penalty + fDecelerationRate = pSpds[pEngineData->iNumGears - 1] / + (pEngineData->fDragCoefficient * + 256.0f); // Calculate base deceleration rate from top + // gear max speed and drag coefficient + if (iCurrChunk == -1) // Off-track: apply 16x deceleration penalty { dInitialDecelerationCalc = fBaseSpeed - fDecelerationRate * 16.0; } else { - iNextChunk = iCurrChunk + 1; // On-track: calculate track physics effects (banking, gravity) + iNextChunk = + iCurrChunk + + 1; // On-track: calculate track physics effects (banking, gravity) iNextChunkIdx = iNextChunk; if (iNextChunk == TRAK_LEN) iNextChunkIdx = TRAK_LEN ^ iNextChunk; pTrackData = &localdata[pCar->nCurrChunk]; - fTrackHalfWidth = ((pCar->pos.fX + pTrackData->fTrackHalfLength) * localdata[iNextChunkIdx].fTrackHalfWidth - - (pCar->pos.fX - pTrackData->fTrackHalfLength) * localdata[pCar->nCurrChunk].fTrackHalfWidth) - / (pTrackData->fTrackHalfLength - * 2.0f); // Calculate interpolated track half-width at car position + fTrackHalfWidth = + ((pCar->pos.fX + pTrackData->fTrackHalfLength) * + localdata[iNextChunkIdx].fTrackHalfWidth - + (pCar->pos.fX - pTrackData->fTrackHalfLength) * + localdata[pCar->nCurrChunk].fTrackHalfWidth) / + (pTrackData->fTrackHalfLength * + 2.0f); // Calculate interpolated track half-width at car position pTrackInfo = &TrackInfo[pCar->nCurrChunk]; - if (pCar->pos.fY <= (double)fTrackHalfWidth)// Select banking angle based on car position (left/right/center of track) + if (pCar->pos.fY <= + (double)fTrackHalfWidth) // Select banking angle based on car position + // (left/right/center of track) { if (-fTrackHalfWidth <= pCar->pos.fY) - fAdjustedGravity = pTrackData->gravity.fY;// fY = adjusted gravity Y component based on track banking + fAdjustedGravity = + pTrackData->gravity + .fY; // fY = adjusted gravity Y component based on track banking else - fAdjustedGravity = pTrackData->gravity.fY * tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - pTrackData->gravity.fZ * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; + fAdjustedGravity = + pTrackData->gravity.fY * + tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - + pTrackData->gravity.fZ * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; } else { - fAdjustedGravity = pTrackData->gravity.fY * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + pTrackData->gravity.fZ * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; + fAdjustedGravity = + pTrackData->gravity.fY * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + + pTrackData->gravity.fZ * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; } - dGravityFactor = (pTrackData->gravity.fX * tcos[pCar->nYaw] + fAdjustedGravity * tsin[pCar->nYaw]) * -0.3333333333333333f + 1.0f;// Calculate gravity factor based on track inclination and car orientation + dGravityFactor = (pTrackData->gravity.fX * tcos[pCar->nYaw] + + fAdjustedGravity * tsin[pCar->nYaw]) * + -0.3333333333333333f + + 1.0f; // Calculate gravity factor based on track + // inclination and car orientation fGravityMultiplier = (float)dGravityFactor; if (dGravityFactor < 0.5) fGravityMultiplier = 0.5f; fAdjustedDecelerationRate = fDecelerationRate * fGravityMultiplier; - if (iGearAyMax == -1) // Apply different deceleration rates: 6x for neutral gear, 1x for forward gears + if (iGearAyMax == -1) // Apply different deceleration rates: 6x for neutral + // gear, 1x for forward gears dInitialDecelerationCalc = fBaseSpeed - fAdjustedDecelerationRate * 6.0; else dInitialDecelerationCalc = fBaseSpeed - fAdjustedDecelerationRate; @@ -1587,7 +1882,7 @@ void FreeWheel(tCar *pCar) fNewBaseSpeed = (float)dInitialDecelerationCalc; if (fNewBaseSpeed < 0.0) fNewBaseSpeed = 0.0; - if (iGearAyMax >= 0) // Calculate RPM ratio and power for current gear + if (iGearAyMax >= 0) // Calculate RPM ratio and power for current gear { fRPMRatio = fNewBaseSpeed / (pSpds[iGearAyMax] * fHealthFactor); if (fRPMRatio > 1.0) @@ -1600,7 +1895,10 @@ void FreeWheel(tCar *pCar) dCalculatedPower = (float)calc_pow(iCarDesignIdx, 0, fRPMRatio); } fCurrentPower = (float)dCalculatedPower; - if (iGearAyMax > 0 && human_control[pCar->iDriverIdx] != 2 && (double)pEngineData->pChgs[2 * iGearAyMax - 1] > fCurrentPower)// Auto downshift: check if power is below gear change threshold + if (iGearAyMax > 0 && human_control[pCar->iDriverIdx] != 2 && + (double)pEngineData->pChgs[2 * iGearAyMax - 1] > + fCurrentPower) // Auto downshift: check if power is below gear change + // threshold { fRPMRatio = fNewBaseSpeed / (pSpds[--iGearAyMax] * fHealthFactor); if (fRPMRatio > 1.0) @@ -1611,7 +1909,9 @@ void FreeWheel(tCar *pCar) pCar->byGearAyMax = iGearAyMax; pCar->fPower = fCurrentPower; fRPMRatioChange = (float)dRPMRatioChange; - if (pCar->nCurrChunk != -1 && iGearAyMax != -1)// Limit RPM ratio changes to realistic values when on track + if (pCar->nCurrChunk != -1 && + iGearAyMax != + -1) // Limit RPM ratio changes to realistic values when on track { if (fRPMRatioChange <= 0.03) { if (fRPMRatioChange < -0.1) @@ -1621,14 +1921,17 @@ void FreeWheel(tCar *pCar) } } pCar->fRPMRatio = pCar->fRPMRatio + fRPMRatioChange; - if (iGearAyMax == -1) // Handle special cases: neutral gear (0) and reverse gear (negate speed) + if (iGearAyMax == -1) // Handle special cases: neutral gear (0) and reverse + // gear (negate speed) { fNewBaseSpeed = 0.0; } else if (iGearAyMax == -2) { fNewBaseSpeed = -fNewBaseSpeed; - //HIBYTE(fNewBaseSpeed) ^= 0x80u; + // HIBYTE(fNewBaseSpeed) ^= 0x80u; } - iPitchDynamicOffset = pCar->iPitchDynamicOffset;// Update car pitch dynamics: gradual recovery to neutral position + iPitchDynamicOffset = + pCar->iPitchDynamicOffset; // Update car pitch dynamics: gradual recovery + // to neutral position pCar->fBaseSpeed = fNewBaseSpeed; if (iPitchDynamicOffset >= 0) { iNoseUpRecoveryRate = pEngineData->iNoseUpRecoveryRate; @@ -1645,44 +1948,48 @@ void FreeWheel(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//0002C1A0 -void SetEngine(tCar *pCar, float fThrottle) -{ - int byCarDesignIdx; // edi - float *pSpds; // edx - int iNumGears; // ecx - double dThrottleRatio; // st7 +// 0002C1A0 +void SetEngine(tCar *pCar, float fThrottle) { + int byCarDesignIdx; // edi + float *pSpds; // edx + int iNumGears; // ecx + double dThrottleRatio; // st7 double dCalculatedPower; // st7 - int iCurrentGear; // ebx - int iGearTableIdx; // ecx + int iCurrentGear; // ebx + int iGearTableIdx; // ecx float *pfCurrentGearSpd; // esi - double dFinalSpeed; // st7 - float fReverseRatio; // [esp+0h] [ebp-44h] - float *pfSpeedsArray; // [esp+4h] [ebp-40h] - float fReverseSpeed; // [esp+8h] [ebp-3Ch] - float fHealthFactor; // [esp+Ch] [ebp-38h] - int iMaxGearIdx; // [esp+10h] [ebp-34h] + double dFinalSpeed; // st7 + float fReverseRatio; // [esp+0h] [ebp-44h] + float *pfSpeedsArray; // [esp+4h] [ebp-40h] + float fReverseSpeed; // [esp+8h] [ebp-3Ch] + float fHealthFactor; // [esp+Ch] [ebp-38h] + int iMaxGearIdx; // [esp+10h] [ebp-34h] tCarEngine *pEngineData; // [esp+14h] [ebp-30h] - float fGearShiftFlag; // [esp+18h] [ebp-2Ch] - float fCurrentPower; // [esp+1Ch] [ebp-28h] + float fGearShiftFlag; // [esp+18h] [ebp-2Ch] + float fCurrentPower; // [esp+1Ch] [ebp-28h] float fAdjustedThrottle; // [esp+20h] [ebp-24h] - float fSpeedRatio; // [esp+24h] [ebp-20h] - float fLoopExitFlag; // [esp+28h] [ebp-1Ch] + float fSpeedRatio; // [esp+24h] [ebp-20h] + float fLoopExitFlag; // [esp+28h] [ebp-1Ch] - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car health, capped at 1.0 + fHealthFactor = + (pCar->fHealth + 34.0f) * + 0.01f; // Calculate health factor (0-1) based on car health, capped at 1.0 if (fHealthFactor > 1.0) fHealthFactor = 1.0; byCarDesignIdx = pCar->byCarDesignIdx; pCar->fSpeedOverflow = 0.0; - pEngineData = &CarEngines.engines[byCarDesignIdx];// Get engine data for this car design + pEngineData = + &CarEngines + .engines[byCarDesignIdx]; // Get engine data for this car design pSpds = pEngineData->pSpds; iNumGears = pEngineData->iNumGears; pfSpeedsArray = pSpds; - if (fThrottle >= 0.5) // Forward throttle - calculate gear and power + if (fThrottle >= 0.5) // Forward throttle - calculate gear and power { iCurrentGear = 0; fLoopExitFlag = 0.0; - fAdjustedThrottle = fThrottle / fHealthFactor;// Adjust throttle by health factor + fAdjustedThrottle = + fThrottle / fHealthFactor; // Adjust throttle by health factor do { if (fAdjustedThrottle > (double)*pSpds) { ++iCurrentGear; @@ -1691,8 +1998,10 @@ void SetEngine(tCar *pCar, float fThrottle) continue; } fLoopExitFlag = -1.0; - } while (fabs(fLoopExitFlag) == 0);// Find appropriate gear for current throttle - //} while ((LODWORD(fLoopExitFlag) & 0x7FFFFFFF) == 0);// Find appropriate gear for current throttle + } while (fabs(fLoopExitFlag) == + 0); // Find appropriate gear for current throttle + //} while ((LODWORD(fLoopExitFlag) & 0x7FFFFFFF) == 0);// Find appropriate + // gear for current throttle if (iCurrentGear < iNumGears) { fSpeedRatio = fAdjustedThrottle / *pSpds; } else { @@ -1704,10 +2013,13 @@ void SetEngine(tCar *pCar, float fThrottle) iMaxGearIdx = iNumGears - 1; iGearTableIdx = 2 * iCurrentGear; pfCurrentGearSpd = &pfSpeedsArray[iCurrentGear]; - fCurrentPower = (float)calc_pow(byCarDesignIdx, iCurrentGear, fSpeedRatio);// Calculate power for current gear/throttle - while (iCurrentGear < iMaxGearIdx) // Check if car can upshift to higher gears + fCurrentPower = (float)calc_pow( + byCarDesignIdx, iCurrentGear, + fSpeedRatio); // Calculate power for current gear/throttle + while (iCurrentGear < + iMaxGearIdx) // Check if car can upshift to higher gears { - //if ((LODWORD(fGearShiftFlag) & 0x7FFFFFFF) != 0) + // if ((LODWORD(fGearShiftFlag) & 0x7FFFFFFF) != 0) if (fabs(fGearShiftFlag) > FLT_EPSILON) break; if ((double)pEngineData->pChgs[iGearTableIdx] * 1.2 >= fCurrentPower) { @@ -1717,7 +2029,8 @@ void SetEngine(tCar *pCar, float fThrottle) iGearTableIdx += 2; ++iCurrentGear; ++pfCurrentGearSpd; - fCurrentPower = (float)calc_pow(byCarDesignIdx, iCurrentGear, fSpeedRatio); + fCurrentPower = + (float)calc_pow(byCarDesignIdx, iCurrentGear, fSpeedRatio); } } pCar->fPower = fCurrentPower; @@ -1726,12 +2039,13 @@ void SetEngine(tCar *pCar, float fThrottle) pCar->fBaseSpeed = (float)dFinalSpeed; pCar->byGearAyMax = iCurrentGear; pCar->fSpeedOverflow = fThrottle - (float)dFinalSpeed; - } else if (fabs(fThrottle) >= 0.5) // Reverse throttle - calculate reverse power and speed + } else if (fabs(fThrottle) >= + 0.5) // Reverse throttle - calculate reverse power and speed { pCar->byGearAyMax = -2; fReverseSpeed = *pSpds * fHealthFactor; fThrottle = -fThrottle; - //HIBYTE(fThrottle) ^= 0x80u; + // HIBYTE(fThrottle) ^= 0x80u; if (fThrottle <= (double)fReverseSpeed) { dThrottleRatio = fThrottle / fReverseSpeed; pCar->fSpeedOverflow = 0.0; @@ -1746,292 +2060,312 @@ void SetEngine(tCar *pCar, float fThrottle) pCar->fRPMRatio = fReverseRatio; pCar->fPower = (float)dCalculatedPower; } else { - pCar->byGearAyMax = 0; // Neutral/idle - zero all engine output values + pCar->byGearAyMax = 0; // Neutral/idle - zero all engine output values pCar->fPower = 0.0; pCar->fRPMRatio = 0.0; pCar->fBaseSpeed = 0.0; pCar->fSpeedOverflow = 0.0; pCar->fFinalSpeed = 0.0; } - pCar->fFinalSpeed = pCar->fBaseSpeed + pCar->fSpeedOverflow;// Final speed = base speed + speed overflow + pCar->fFinalSpeed = + pCar->fBaseSpeed + + pCar->fSpeedOverflow; // Final speed = base speed + speed overflow } //------------------------------------------------------------------------------------------------- -//0002C420 -double change_gear(int iCurrentGear, int iNextGear, tCar *pCar, int iCarDesignIdx) -{ +// 0002C420 +double change_gear(int iCurrentGear, int iNextGear, tCar *pCar, + int iCarDesignIdx) { float fCalculatedPower; // [esp+4h] [ebp-18h] - float fAdjustedSpeed; // [esp+8h] [ebp-14h] - float fHealthFactor; // [esp+Ch] [ebp-10h] - float fSpeedRatio; // [esp+10h] [ebp-Ch] + float fAdjustedSpeed; // [esp+8h] [ebp-14h] + float fHealthFactor; // [esp+Ch] [ebp-10h] + float fSpeedRatio; // [esp+10h] [ebp-Ch] - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0-1) based on car damage, capped at 1.0 + fHealthFactor = + (pCar->fHealth + 34.0f) * + 0.01f; // Calculate health factor (0-1) based on car damage, capped at 1.0 if (fHealthFactor > 1.0) fHealthFactor = 1.0; - fAdjustedSpeed = (float)fabs(pCar->fFinalSpeed) / fHealthFactor;// Get current speed adjusted by health factor (damaged cars perform worse) - if (iNextGear < 0) // Clamp negative gear to 0 for power curve lookup (reverse uses gear 0 data) + fAdjustedSpeed = (float)fabs(pCar->fFinalSpeed) / + fHealthFactor; // Get current speed adjusted by health factor + // (damaged cars perform worse) + if (iNextGear < 0) // Clamp negative gear to 0 for power curve lookup (reverse + // uses gear 0 data) iNextGear = 0; - fSpeedRatio = fAdjustedSpeed / CarEngines.engines[iCarDesignIdx].pSpds[iNextGear];// Calculate speed ratio: current speed vs max speed for target gear - if (fSpeedRatio > 1.0) // Clamp speed ratio to 1.0 (can't exceed gear's max RPM) + fSpeedRatio = fAdjustedSpeed / + CarEngines.engines[iCarDesignIdx] + .pSpds[iNextGear]; // Calculate speed ratio: current speed + // vs max speed for target gear + if (fSpeedRatio > + 1.0) // Clamp speed ratio to 1.0 (can't exceed gear's max RPM) fSpeedRatio = 1.0; - fCalculatedPower = (float)calc_pow(iCarDesignIdx, iNextGear, fSpeedRatio);// Calculate power output for target gear at current speed ratio - if (player1_car == pCar->iDriverIdx && !DriveView[0])// Play gear shift sound for human players (not in cockpit view) - sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT + fCalculatedPower = + (float)calc_pow(iCarDesignIdx, iNextGear, + fSpeedRatio); // Calculate power output for target gear at + // current speed ratio + if (player1_car == pCar->iDriverIdx && + !DriveView[0]) // Play gear shift sound for human players (not in cockpit + // view) + sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT if (player2_car == pCar->iDriverIdx && !DriveView[0]) - sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT - return fCalculatedPower; // Return calculated power for the gear change + sfxsample(SOUND_SAMPLE_GRSHIFT, 12000); // SOUND_SAMPLE_GRSHIFT + return fCalculatedPower; // Return calculated power for the gear change } //------------------------------------------------------------------------------------------------- -//0002C5A0 -void updatecar2(tCar *pCar) -{ - int iLeaderCarIdx; // edi - int iLeaderProgress; // ecx - int iCarLoopIdx; // edx - int iCarArrayIdx; // eax - int iLastValidChunk; // ebx - int iLeaderChunk; // eax - int iLeaderProgressTotal; // ecx - int iPlayerProgress; // eax - int iPlayer1Car; // ecx - int iCurrentDriverIdx; // ebx - int iPlayer2Car; // ecx - int iSoundSampleId; // eax - int iPlayerCarCheck; // ecx - int iDriverIdx; // eax - int iThisDriverIdx; // ebp - int iPitLaneFlag; // edx - int iCurrentChunk; // edx - int iPrevChunk; // edx - uint8 byEngineStartTimer; // cl - uint8 bySfxCooldown; // al - uint8 byCollisionTimer; // dl - uint8 byCheatCooldown; // bl - int iRandomValue; // eax - double dWheelSpinAccumulator; // st7 - int iRandomValue2; // eax - int iOscillationValue; // ebp - int16 ReverseWarnCooldown; // dx - int iCurrentYaw3; // ecx - int iSpeechDriverIdx; // ebp - int iYaw3Value; // ebx - int iAudioDriverIdx; // edi - int iAudioSample; // eax - int16 nChangeMateCooldown; // di - double dOscillationFactor; // st7 - int iControlType; // eax - double dPitchBackupCalc; // st7 - double dTempPitchCalc; // st6 - double dCosineValue; // st7 - double dRollCalc; // st6 - int iControlTypeCheck; // edx - double dBaseSpeed; // st7 - int iChunkCheck; // eax - double dNewSpeed; // st7 - double dAbsoluteSpeed; // st7 - int iSteeringInput; // edx - int iRollDynamicTemp; // ebx - tCarEngine *pEngineTemp; // eax - int iEngineCalc; // eax - int iRollTemp; // ebp - tCarEngine *pEngineTemp2; // eax - int iEngineCalc2; // eax - int iRollDynamicOffset; // ebp - int iEngineParam; // eax - int iOffsetCalc; // edx - int iSteeringCalc; // ecx - tCarEngine *pEngineTemp3; // eax - int iEngineCalc3; // eax - int iSteeringCalc2; // ebp - tCarEngine *pEngineTemp4; // edx - int iUnk14; // ebx - int iRollDynamicCheck; // ebp - int iRollCenteringRate; // eax - int iOffsetCalc2; // edx - int iViewType; // eax - int iViewDriverIdx; // edi +// 0002C5A0 +void updatecar2(tCar *pCar) { + int iLeaderCarIdx; // edi + int iLeaderProgress; // ecx + int iCarLoopIdx; // edx + int iCarArrayIdx; // eax + int iLastValidChunk; // ebx + int iLeaderChunk; // eax + int iLeaderProgressTotal; // ecx + int iPlayerProgress; // eax + int iPlayer1Car; // ecx + int iCurrentDriverIdx; // ebx + int iPlayer2Car; // ecx + int iSoundSampleId; // eax + int iPlayerCarCheck; // ecx + int iDriverIdx; // eax + int iThisDriverIdx; // ebp + int iPitLaneFlag; // edx + int iCurrentChunk; // edx + int iPrevChunk; // edx + uint8 byEngineStartTimer; // cl + uint8 bySfxCooldown; // al + uint8 byCollisionTimer; // dl + uint8 byCheatCooldown; // bl + int iRandomValue; // eax + double dWheelSpinAccumulator; // st7 + int iRandomValue2; // eax + int iOscillationValue; // ebp + int16 ReverseWarnCooldown; // dx + int iCurrentYaw3; // ecx + int iSpeechDriverIdx; // ebp + int iYaw3Value; // ebx + int iAudioDriverIdx; // edi + int iAudioSample; // eax + int16 nChangeMateCooldown; // di + double dOscillationFactor; // st7 + int iControlType; // eax + double dPitchBackupCalc; // st7 + double dTempPitchCalc; // st6 + double dCosineValue; // st7 + double dRollCalc; // st6 + int iControlTypeCheck; // edx + double dBaseSpeed; // st7 + int iChunkCheck; // eax + double dNewSpeed; // st7 + double dAbsoluteSpeed; // st7 + int iSteeringInput; // edx + int iRollDynamicTemp; // ebx + tCarEngine *pEngineTemp; // eax + int iEngineCalc; // eax + int iRollTemp; // ebp + tCarEngine *pEngineTemp2; // eax + int iEngineCalc2; // eax + int iRollDynamicOffset; // ebp + int iEngineParam; // eax + int iOffsetCalc; // edx + int iSteeringCalc; // ecx + tCarEngine *pEngineTemp3; // eax + int iEngineCalc3; // eax + int iSteeringCalc2; // ebp + tCarEngine *pEngineTemp4; // edx + int iUnk14; // ebx + int iRollDynamicCheck; // ebp + int iRollCenteringRate; // eax + int iOffsetCalc2; // edx + int iViewType; // eax + int iViewDriverIdx; // edi unsigned int iControlTypeLocal; // eax - float *pLocalData; // ecx - int iChunkCurrent; // ebx - int iChunkNext; // edx - double dPositionCalc; // st7 - double dTrackPosCalc; // st5 - double dInterpolationFactor; // st6 - int iSurfaceType; // eax + float *pLocalData; // ecx + int iChunkCurrent; // ebx + int iChunkNext; // edx + double dPositionCalc; // st7 + double dTrackPosCalc; // st5 + double dInterpolationFactor; // st6 + int iSurfaceType; // eax //__int16 v75; // fps - double fBankingCalc1; // st6 - double fBankingCalc2; // st7 + double fBankingCalc1; // st6 + double fBankingCalc2; // st7 double dLeftBankAngle; // st7 double fRightBankCalc; // st7 //__int16 v83; // fps - double fRightBankCalc2; // st6 - double dRightBankAngle; // st7 - bool bZeroFlag; // zf - int iTrackColorFlag; // edx - int iPlayer1CarIdx; // eax - int iCurrentDriverIdx2; // ebp - int iSpeechDriverIdx2; // ecx - int iCurrentChunk2; // edx - int iLoopCounter; // edx - int iNumCarsLocal; // ecx - int iArrayIndex; // eax - double dHealthIncrease; // st7 - int iPlayer1Check; // eax - int iDriverForHealth; // ecx - int iCenterGrip; // edx - double dSurfaceValue; // st7 - uint8 byStatusFlags; // bl - int iGripIndex; // edx - int iChunkIdx; // ebx - double fY; // st7 - tVec3 *pPointAy; // edx - tTrackInfo *pTrackInfo; // edi - int iCurrentYaw; // eax - float fRPMRatio; // ebp + double fRightBankCalc2; // st6 + double dRightBankAngle; // st7 + bool bZeroFlag; // zf + int iTrackColorFlag; // edx + int iPlayer1CarIdx; // eax + int iCurrentDriverIdx2; // ebp + int iSpeechDriverIdx2; // ecx + int iCurrentChunk2; // edx + int iLoopCounter; // edx + int iNumCarsLocal; // ecx + int iArrayIndex; // eax + double dHealthIncrease; // st7 + int iPlayer1Check; // eax + int iDriverForHealth; // ecx + int iCenterGrip; // edx + double dSurfaceValue; // st7 + uint8 byStatusFlags; // bl + int iGripIndex; // edx + int iChunkIdx; // ebx + double fY; // st7 + tVec3 *pPointAy; // edx + tTrackInfo *pTrackInfo; // edi + int iCurrentYaw; // eax + float fRPMRatio; // ebp double dSpeedOverflowCalc1; // st7 double dSpeedOverflowCalc2; // st7 double dSpeedOverflowCalc3; // st7 double dSpeedOverflowCalc4; // st7 - double dSteeringSpeedCalc; // st7 - double iUnk20; // st7 - int iYawForCarBase; // ebx - double dCurrentSpeed; // st7 - double dMovementSpeed; // st7 - int iYaw3ForMovement; // eax - tData *pChunkData; // eax - double dPositionY; // st7 - int iChunkForColor; // eax - int iTrackColorValue; // ebx - unsigned int uiJumpFlag; // ecx - int iCollisionFlag; // edx - double dLeftWallCheck; // st7 - double dLeftWallCheck2; // st7 - int iLaneTypeCheck; // edx + double dSteeringSpeedCalc; // st7 + double iUnk20; // st7 + int iYawForCarBase; // ebx + double dCurrentSpeed; // st7 + double dMovementSpeed; // st7 + int iYaw3ForMovement; // eax + tData *pChunkData; // eax + double dPositionY; // st7 + int iChunkForColor; // eax + int iTrackColorValue; // ebx + unsigned int uiJumpFlag; // ecx + int iCollisionFlag; // edx + double dLeftWallCheck; // st7 + double dLeftWallCheck2; // st7 + int iLaneTypeCheck; // edx //__int64 llTrackColorData; // rax - int iYawDifferenceCalc; // eax - double dSpeedAbs; // st7 + int iYawDifferenceCalc; // eax + double dSpeedAbs; // st7 double dGripCalculation; // st7 - int iHumanControlIdx; // eax - //int iInput; // eax + int iHumanControlIdx; // eax + // int iInput; // eax //__int64 llInputCheck; // rax - int iCurrentYawForInput; // eax - int iYaw3ForInput; // ebp - int16 nYawAdjusted; // ax - int16 nTargetChunk; // cx - double dDirectionZ; // st7 + int iCurrentYawForInput; // eax + int iYaw3ForInput; // ebp + int16 nYawAdjusted; // ax + int16 nTargetChunk; // cx + double dDirectionZ; // st7 float fHorizontalSpeedLocal; // ebp - int iPitchAngle; // eax + int iPitchAngle; // eax //__int16 v144; // fps - double dAtanResult; // st7 - int16 nRollAdjusted; // ax - int iYaw3Current; // ecx - int iYawDelta; // ebx - int16 nTargetChunkLocal; // dx - int iYaw3ForType2; // eax - double dCoordY; // st7 - double dCoordX; // st5 - double dCoordZ; // rtt - int iChunkPlus2; // ebx - int iChunkPlus3; // ecx - double dGroundHeightForward; // st7 - int iChunkMinus1; // ecx - int iChunkMinus2; // ebx - double dGroundHeightBackward; // st7 - double dBoundaryLimit; // st7 - double dTransformedY; // st7 - double dTransformedX; // st5 - double dTransformedZ; // st6 - float fCurrentSpeedFloat; // edx - double dFallDamage; // st7 - int iGroundChunk; // eax - int iPitch; // ebx - int iRoll; // eax - float fDamageAmount; // [esp+0h] [ebp-190h] - tData coordinateSystemData; // [esp+4h] [ebp-18Ch] BYREF - int iRightBankAngle; // [esp+8Ch] [ebp-104h] - int iNearestChunk; // [esp+90h] [ebp-100h] BYREF + double dAtanResult; // st7 + int16 nRollAdjusted; // ax + int iYaw3Current; // ecx + int iYawDelta; // ebx + int16 nTargetChunkLocal; // dx + int iYaw3ForType2; // eax + double dCoordY; // st7 + double dCoordX; // st5 + double dCoordZ; // rtt + int iChunkPlus2; // ebx + int iChunkPlus3; // ecx + double dGroundHeightForward; // st7 + int iChunkMinus1; // ecx + int iChunkMinus2; // ebx + double dGroundHeightBackward; // st7 + double dBoundaryLimit; // st7 + double dTransformedY; // st7 + double dTransformedX; // st5 + double dTransformedZ; // st6 + float fCurrentSpeedFloat; // edx + double dFallDamage; // st7 + int iGroundChunk; // eax + int iPitch; // ebx + int iRoll; // eax + float fDamageAmount; // [esp+0h] [ebp-190h] + tData coordinateSystemData; // [esp+4h] [ebp-18Ch] BYREF + int iRightBankAngle; // [esp+8Ch] [ebp-104h] + int iNearestChunk; // [esp+90h] [ebp-100h] BYREF float fLeftShoulderTrackWidth; // [esp+94h] [ebp-FCh] - float fCurrentTrackHalfWidth; // [esp+98h] [ebp-F8h] + float fCurrentTrackHalfWidth; // [esp+98h] [ebp-F8h] float fCameraOscillationRange; // [esp+9Ch] [ebp-F4h] - float fTempFloat1; // [esp+A0h] [ebp-F0h] - float fDirectionZ; // [esp+A4h] [ebp-ECh] - float fBankingForceX; // [esp+A8h] [ebp-E8h] - float fCameraOscillationBase; // [esp+ACh] [ebp-E4h] - float fHorizontalSpeedCopy; // [esp+B0h] [ebp-E0h] - float fNegativeYawLimit; // [esp+B4h] [ebp-DCh] - float fNegativeYawLimitHuman; // [esp+B8h] [ebp-D8h] - float fLeftTrackBoundary; // [esp+BCh] [ebp-D4h] - int iLeaderValidationFlag; // [esp+C0h] [ebp-D0h] - float fRightCarPosY; // [esp+C4h] [ebp-CCh] - float fRightTrackBoundary; // [esp+C8h] [ebp-C8h] - float fSpeedLimited; // [esp+CCh] [ebp-C4h] - float fTrackPointY; // [esp+D0h] [ebp-C0h] - float fTrackBankingY; // [esp+D4h] [ebp-BCh] - float fCarPosZ; // [esp+D8h] [ebp-B8h] - float fGroundBoundaryY; // [esp+DCh] [ebp-B4h] - float fCarBaseYProjected; // [esp+E0h] [ebp-B0h] - float fTrackBankingX; // [esp+E4h] [ebp-ACh] - float fCarBaseXProjected; // [esp+E8h] [ebp-A8h] - int iYaw3; // [esp+ECh] [ebp-A4h] - float fGroundAverageZ1; // [esp+F0h] [ebp-A0h] - float fCoordTransformX; // [esp+F4h] [ebp-9Ch] - float fCoordTransformZ; // [esp+F8h] [ebp-98h] - float fBankingForceY; // [esp+FCh] [ebp-94h] - float fSurfaceGripBase; // [esp+100h] [ebp-90h] - float fLeftShoulderBoundary; // [esp+104h] [ebp-8Ch] - float fZ; // [esp+108h] [ebp-88h] - int byCarTypeIndex; // [esp+10Ch] [ebp-84h] - float fCurrentSpeedAbs; // [esp+110h] [ebp-80h] - float fSpeedChangeRate; // [esp+114h] [ebp-7Ch] - float fTempGrip; // [esp+118h] [ebp-78h] - float fSurfaceGripValue; // [esp+11Ch] [ebp-74h] - float fCurrentGripMultiplier; // [esp+120h] [ebp-70h] - float fFinalSpeedThisFrame; // [esp+124h] [ebp-6Ch] - float fRightShoulderBoundary; // [esp+128h] [ebp-68h] - float fHealthAdjustment; // [esp+12Ch] [ebp-64h] - float fMaxGripLimit_1; // [esp+130h] [ebp-60h] - float fCoordTransformY; // [esp+134h] [ebp-5Ch] - float fSpeedScaled; // [esp+138h] [ebp-58h] - int iJumpMomentum; // [esp+13Ch] [ebp-54h] - int iSteeringInputProcessed; // [esp+140h] [ebp-50h] - float fCarPosZBackup; // [esp+144h] [ebp-4Ch] - int iHumanYawDiff; // [esp+148h] [ebp-48h] - int nCurrentChunk; // [esp+14Ch] [ebp-44h] - int iYawDifference; // [esp+150h] [ebp-40h] - float fMaxGripLimit; // [esp+154h] [ebp-3Ch] - tCarEngine *pCarEngine; // [esp+158h] [ebp-38h] - int iYawCurrent; // [esp+15Ch] [ebp-34h] - float fAbsoluteSpeed; // [esp+160h] [ebp-30h] - float fSpeedOverflow; // [esp+164h] [ebp-2Ch] - float fCarHalfWidthProjected; // [esp+168h] [ebp-28h] - float fTrackCenterLine; // [esp+16Ch] [ebp-24h] - float fAnimationSpeed; // [esp+170h] [ebp-20h] - float fHorizontalSpeed; // [esp+174h] [ebp-1Ch] + float fTempFloat1; // [esp+A0h] [ebp-F0h] + float fDirectionZ; // [esp+A4h] [ebp-ECh] + float fBankingForceX; // [esp+A8h] [ebp-E8h] + float fCameraOscillationBase; // [esp+ACh] [ebp-E4h] + float fHorizontalSpeedCopy; // [esp+B0h] [ebp-E0h] + float fNegativeYawLimit; // [esp+B4h] [ebp-DCh] + float fNegativeYawLimitHuman; // [esp+B8h] [ebp-D8h] + float fLeftTrackBoundary; // [esp+BCh] [ebp-D4h] + int iLeaderValidationFlag; // [esp+C0h] [ebp-D0h] + float fRightCarPosY; // [esp+C4h] [ebp-CCh] + float fRightTrackBoundary; // [esp+C8h] [ebp-C8h] + float fSpeedLimited; // [esp+CCh] [ebp-C4h] + float fTrackPointY; // [esp+D0h] [ebp-C0h] + float fTrackBankingY; // [esp+D4h] [ebp-BCh] + float fCarPosZ; // [esp+D8h] [ebp-B8h] + float fGroundBoundaryY; // [esp+DCh] [ebp-B4h] + float fCarBaseYProjected; // [esp+E0h] [ebp-B0h] + float fTrackBankingX; // [esp+E4h] [ebp-ACh] + float fCarBaseXProjected; // [esp+E8h] [ebp-A8h] + int iYaw3; // [esp+ECh] [ebp-A4h] + float fGroundAverageZ1; // [esp+F0h] [ebp-A0h] + float fCoordTransformX; // [esp+F4h] [ebp-9Ch] + float fCoordTransformZ; // [esp+F8h] [ebp-98h] + float fBankingForceY; // [esp+FCh] [ebp-94h] + float fSurfaceGripBase; // [esp+100h] [ebp-90h] + float fLeftShoulderBoundary; // [esp+104h] [ebp-8Ch] + float fZ; // [esp+108h] [ebp-88h] + int byCarTypeIndex; // [esp+10Ch] [ebp-84h] + float fCurrentSpeedAbs; // [esp+110h] [ebp-80h] + float fSpeedChangeRate; // [esp+114h] [ebp-7Ch] + float fTempGrip; // [esp+118h] [ebp-78h] + float fSurfaceGripValue; // [esp+11Ch] [ebp-74h] + float fCurrentGripMultiplier; // [esp+120h] [ebp-70h] + float fFinalSpeedThisFrame; // [esp+124h] [ebp-6Ch] + float fRightShoulderBoundary; // [esp+128h] [ebp-68h] + float fHealthAdjustment; // [esp+12Ch] [ebp-64h] + float fMaxGripLimit_1; // [esp+130h] [ebp-60h] + float fCoordTransformY; // [esp+134h] [ebp-5Ch] + float fSpeedScaled; // [esp+138h] [ebp-58h] + int iJumpMomentum; // [esp+13Ch] [ebp-54h] + int iSteeringInputProcessed; // [esp+140h] [ebp-50h] + float fCarPosZBackup; // [esp+144h] [ebp-4Ch] + int iHumanYawDiff; // [esp+148h] [ebp-48h] + int nCurrentChunk; // [esp+14Ch] [ebp-44h] + int iYawDifference; // [esp+150h] [ebp-40h] + float fMaxGripLimit; // [esp+154h] [ebp-3Ch] + tCarEngine *pCarEngine; // [esp+158h] [ebp-38h] + int iYawCurrent; // [esp+15Ch] [ebp-34h] + float fAbsoluteSpeed; // [esp+160h] [ebp-30h] + float fSpeedOverflow; // [esp+164h] [ebp-2Ch] + float fCarHalfWidthProjected; // [esp+168h] [ebp-28h] + float fTrackCenterLine; // [esp+16Ch] [ebp-24h] + float fAnimationSpeed; // [esp+170h] [ebp-20h] + float fHorizontalSpeed; // [esp+174h] [ebp-1Ch] byCarTypeIndex = pCar->byCarDesignIdx; iYaw3 = pCar->nActualYaw; iJumpMomentum = pCar->iJumpMomentum; iYawCurrent = pCar->nYaw; nCurrentChunk = pCar->nCurrChunk; - pCarEngine = &CarEngines.engines[byCarTypeIndex];// Get car engine data based on car design index + pCarEngine = &CarEngines.engines[byCarTypeIndex]; // Get car engine data based + // on car design index if (pCar->iControlType != 3) - goto LABEL_45; // AI Control Type - Find leader car for lap/unlap detection + goto LABEL_45; // AI Control Type - Find leader car for lap/unlap detection iLeaderCarIdx = 0; iLeaderProgress = 0; iCarLoopIdx = 0; iLeaderValidationFlag = -1; - if (numcars > 0) // Loop through all cars to find race leader + if (numcars > 0) // Loop through all cars to find race leader { iCarArrayIdx = 0; while (1) { iLastValidChunk = Car[iCarArrayIdx].iLastValidChunk; if (iLastValidChunk < 3 || TRAK_LEN - 4 < iLastValidChunk) break; - if (Car[iCarArrayIdx].iLastValidChunk + TRAK_LEN * (char)Car[iCarArrayIdx].byLapNumber > iLeaderProgress)// Calculate total progress: chunk + lap * track_length + if (Car[iCarArrayIdx].iLastValidChunk + + TRAK_LEN * (char)Car[iCarArrayIdx].byLapNumber > + iLeaderProgress) // Calculate total progress: chunk + lap * + // track_length { iLeaderCarIdx = iCarLoopIdx; - iLeaderProgress = Car[iCarArrayIdx].iLastValidChunk + TRAK_LEN * (char)Car[iCarArrayIdx].byLapNumber; + iLeaderProgress = Car[iCarArrayIdx].iLastValidChunk + + TRAK_LEN * (char)Car[iCarArrayIdx].byLapNumber; } ++iCarLoopIdx; ++iCarArrayIdx; @@ -2041,11 +2375,17 @@ void updatecar2(tCar *pCar) iLeaderValidationFlag = 0; } LABEL_10: - if (iLeaderCarIdx != pCar->iDriverIdx && Car[iLeaderCarIdx].iControlType == 3 && (char)Car[iLeaderCarIdx].byLives > 0 && iLeaderValidationFlag) { - iLeaderChunk = Car[iLeaderCarIdx].nCurrChunk == -1 ? Car[iLeaderCarIdx].iLastValidChunk : Car[iLeaderCarIdx].nCurrChunk; - iLeaderProgressTotal = TRAK_LEN * (char)Car[iLeaderCarIdx].byLapNumber + iLeaderChunk; + if (iLeaderCarIdx != pCar->iDriverIdx && + Car[iLeaderCarIdx].iControlType == 3 && + (char)Car[iLeaderCarIdx].byLives > 0 && iLeaderValidationFlag) { + iLeaderChunk = Car[iLeaderCarIdx].nCurrChunk == -1 + ? Car[iLeaderCarIdx].iLastValidChunk + : Car[iLeaderCarIdx].nCurrChunk; + iLeaderProgressTotal = + TRAK_LEN * (char)Car[iLeaderCarIdx].byLapNumber + iLeaderChunk; if (lastsample < -18) { - iPlayerProgress = TRAK_LEN + pCar->nCurrChunk + TRAK_LEN * (char)pCar->byLapNumber; + iPlayerProgress = + TRAK_LEN + pCar->nCurrChunk + TRAK_LEN * (char)pCar->byLapNumber; if (pCar->byLappedStatus) { if (iLeaderProgressTotal >= iPlayerProgress - 1) goto LABEL_30; @@ -2053,11 +2393,12 @@ void updatecar2(tCar *pCar) iDriverIdx = pCar->iDriverIdx; pCar->byLappedStatus = 0; if (iPlayerCarCheck == iDriverIdx) - speechsample(SOUND_SAMPLE_UNLAPPED, 0x8000, 18, iPlayerCarCheck);// Play "unlapped" sound sample (52) + speechsample(SOUND_SAMPLE_UNLAPPED, 0x8000, 18, + iPlayerCarCheck); // Play "unlapped" sound sample (52) iPlayer2Car = player2_car; if (player2_car != pCar->iDriverIdx) goto LABEL_30; - iSoundSampleId = SOUND_SAMPLE_UNLAPPED; // SOUND_SAMPLE_UNLAPPED + iSoundSampleId = SOUND_SAMPLE_UNLAPPED; // SOUND_SAMPLE_UNLAPPED } else { if (iLeaderProgressTotal <= iPlayerProgress + 1) goto LABEL_30; @@ -2065,11 +2406,12 @@ void updatecar2(tCar *pCar) iCurrentDriverIdx = pCar->iDriverIdx; pCar->byLappedStatus = -1; if (iPlayer1Car == iCurrentDriverIdx) - speechsample(SOUND_SAMPLE_LAPPED, 0x8000, 18, iPlayer1Car);// Play "lapped" sound sample (51) + speechsample(SOUND_SAMPLE_LAPPED, 0x8000, 18, + iPlayer1Car); // Play "lapped" sound sample (51) iPlayer2Car = player2_car; if (player2_car != pCar->iDriverIdx) goto LABEL_30; - iSoundSampleId = SOUND_SAMPLE_LAPPED; // SOUND_SAMPLE_LAPPED + iSoundSampleId = SOUND_SAMPLE_LAPPED; // SOUND_SAMPLE_LAPPED } speechsample(iSoundSampleId, 0x8000, 18, iPlayer2Car); } @@ -2078,7 +2420,8 @@ void updatecar2(tCar *pCar) iThisDriverIdx = pCar->iDriverIdx; if (player1_car == iThisDriverIdx || player2_car == iThisDriverIdx) { iPitLaneFlag = 0; - if ((char)pCar->byLapNumber == NoOfLaps && TRAK_LEN - pCar->nCurrChunk < 200) + if ((char)pCar->byLapNumber == NoOfLaps && + TRAK_LEN - pCar->nCurrChunk < 200) iPitLaneFlag = -1; if (death_race) iPitLaneFlag = -1; @@ -2088,13 +2431,18 @@ void updatecar2(tCar *pCar) iPrevChunk = iCurrentChunk - 1; if (iPrevChunk < 0) iPrevChunk = TRAK_LEN - 1; - if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_PIT_ZONE) != 0 && (TrakColour[iPrevChunk][1] & SURFACE_FLAG_PIT_ZONE) == 0) - speechonly(SOUND_SAMPLE_PITIN, 0x8000, 18, pCar->iDriverIdx);// Play "pit in" sound sample (46) when entering pit lane + if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_PIT_ZONE) != 0 && + (TrakColour[iPrevChunk][1] & SURFACE_FLAG_PIT_ZONE) == 0) + speechonly(SOUND_SAMPLE_PITIN, 0x8000, 18, + pCar->iDriverIdx); // Play "pit in" sound sample (46) when + // entering pit lane } } } LABEL_45: - byEngineStartTimer = pCar->byEngineStartTimer;// Update various car timers - collision, cheat cooldown, etc. + byEngineStartTimer = + pCar->byEngineStartTimer; // Update various car timers - collision, cheat + // cooldown, etc. if (byEngineStartTimer) pCar->byEngineStartTimer = byEngineStartTimer - 1; bySfxCooldown = pCar->bySfxCooldown; @@ -2106,26 +2454,35 @@ void updatecar2(tCar *pCar) byCheatCooldown = pCar->byCheatCooldown; if (byCheatCooldown) pCar->byCheatCooldown = byCheatCooldown - 1; - //if (pCar->byThrottlePressed && !pCar->byEngineStartTimer && (LODWORD(pCar->fRPMRatio) & 0x7FFFFFFF) == 0 && !pCar->byAccelerating) - if (pCar->byThrottlePressed && !pCar->byEngineStartTimer && fabs(pCar->fRPMRatio) == 0 && !pCar->byAccelerating) + // if (pCar->byThrottlePressed && !pCar->byEngineStartTimer && + // (LODWORD(pCar->fRPMRatio) & 0x7FFFFFFF) == 0 && !pCar->byAccelerating) + if (pCar->byThrottlePressed && !pCar->byEngineStartTimer && + fabs(pCar->fRPMRatio) == 0 && !pCar->byAccelerating) pCar->byThrottlePressed = 0; - if (!pCar->byThrottlePressed && !pCar->byEngineStartTimer && pCar->byAccelerating && pCar->iControlType == 3)// False start detection and engine start logic for AI cars + if (!pCar->byThrottlePressed && !pCar->byEngineStartTimer && + pCar->byAccelerating && + pCar->iControlType == + 3) // False start detection and engine start logic for AI cars { fHorizontalSpeed = pCar->fHealth * 9.0f * 0.0099999998f; iRandomValue = ROLLERrandRaw(); - int iTemp = GetHighOrderRand(20, iRandomValue);// (20 * iRandomValue) >> 15; - //LODWORD(fCameraOscillationRange) = (20 * iRandomValue) >> 15; + int iTemp = + GetHighOrderRand(20, iRandomValue); // (20 * iRandomValue) >> 15; + // LODWORD(fCameraOscillationRange) = (20 * iRandomValue) >> 15; if (fHorizontalSpeed + 10.0 <= (double)iTemp && false_starts) { if (player1_car == pCar->iDriverIdx) - sfxsample(29, 0x8000); // SOUND_SAMPLE_FALSE - play false start sound for player 1 + sfxsample( + 29, + 0x8000); // SOUND_SAMPLE_FALSE - play false start sound for player 1 if (player2_car == pCar->iDriverIdx) - sfxsample(29, 0x8000); // SOUND_SAMPLE_FALSE + sfxsample(29, 0x8000); // SOUND_SAMPLE_FALSE pCar->byEngineStartTimer = 72; } else { if (player1_car == pCar->iDriverIdx) - sfxsample(28, 0x8000); // SOUND_SAMPLE_ESTART - play engine start sound for player 1 + sfxsample(28, 0x8000); // SOUND_SAMPLE_ESTART - play engine start sound + // for player 1 if (player2_car == pCar->iDriverIdx) - sfxsample(28, 0x8000); // SOUND_SAMPLE_ESTART + sfxsample(28, 0x8000); // SOUND_SAMPLE_ESTART pCar->byThrottlePressed = -1; pCar->byEngineStartTimer = 36; } @@ -2133,14 +2490,17 @@ void updatecar2(tCar *pCar) if (pCar->fRPMRatio < 1.0) { pCar->fWheelSpinAccumulation = 0.0; } else { - dWheelSpinAccumulator = pCar->fWheelSpinFactor + pCar->fWheelSpinAccumulation; + dWheelSpinAccumulator = + pCar->fWheelSpinFactor + pCar->fWheelSpinAccumulation; pCar->fWheelSpinAccumulation = (float)dWheelSpinAccumulator; if (dWheelSpinAccumulator < -1000.0) pCar->fWheelSpinAccumulation = -1000.0; } iRandomValue2 = ROLLERrandRaw(); - //iOscillationValue = ((iRandomValue2) >> 13) + 512 + pCar->iEngineVibrateOffset; - iOscillationValue = GetHighOrderRand(4, iRandomValue2) + 512 + pCar->iEngineVibrateOffset; + // iOscillationValue = ((iRandomValue2) >> 13) + 512 + + // pCar->iEngineVibrateOffset; + iOscillationValue = + GetHighOrderRand(4, iRandomValue2) + 512 + pCar->iEngineVibrateOffset; pCar->iEngineVibrateOffset = iOscillationValue; if (iOscillationValue >= 0x4000) pCar->iEngineVibrateOffset = iOscillationValue - 0x4000; @@ -2149,10 +2509,14 @@ void updatecar2(tCar *pCar) pCar->nReverseWarnCooldown = ReverseWarnCooldown - 1; if (pCar->fFinalSpeed >= 200.0 && nCurrentChunk >= 0) { iCurrentYaw3 = pCar->nActualYaw; - if (iCurrentYaw3 > 4096 && iCurrentYaw3 < 12288 && !pCar->nReverseWarnCooldown) { + if (iCurrentYaw3 > 4096 && iCurrentYaw3 < 12288 && + !pCar->nReverseWarnCooldown) { iSpeechDriverIdx = pCar->iDriverIdx; if (player1_car == iSpeechDriverIdx || player2_car == iSpeechDriverIdx) - speechsample(26, 0x8000, 18, pCar->iDriverIdx);// SOUND_SAMPLE_REVERSE - warn player about driving in reverse at high speed + speechsample( + 26, 0x8000, 18, + pCar->iDriverIdx); // SOUND_SAMPLE_REVERSE - warn player about + // driving in reverse at high speed pCar->nReverseWarnCooldown = 360; } } @@ -2160,14 +2524,17 @@ void updatecar2(tCar *pCar) if (iYaw3Value <= 4096 || iYaw3Value >= 12288 && pCar->fFinalSpeed > 0.0) pCar->nReverseWarnCooldown = 180; iAudioDriverIdx = pCar->iDriverIdx; - if ((player1_car == iAudioDriverIdx || player2_car == iAudioDriverIdx) && (nCurrentChunk >= 0 && pCar->nActualYaw < 4096 || pCar->nActualYaw > 12288)) { - //nCurrentChunk check and iAudioSample init added by ROLLER + if ((player1_car == iAudioDriverIdx || player2_car == iAudioDriverIdx) && + (nCurrentChunk >= 0 && pCar->nActualYaw < 4096 || + pCar->nActualYaw > 12288)) { + // nCurrentChunk check and iAudioSample init added by ROLLER iAudioSample = 0; - if (nCurrentChunk >= 0 && (double)samplespeed[nCurrentChunk] <= pCar->fFinalSpeed) { + if (nCurrentChunk >= 0 && + (double)samplespeed[nCurrentChunk] <= pCar->fFinalSpeed) { iAudioSample = samplemax[nCurrentChunk]; } else if (pCar->fFinalSpeed <= 80.0) { iAudioSample = 0; - } else if (nCurrentChunk >= 0){ + } else if (nCurrentChunk >= 0) { iAudioSample = samplemin[nCurrentChunk]; } if (iAudioSample) { @@ -2185,11 +2552,22 @@ void updatecar2(tCar *pCar) fHealthAdjustment = (pCar->fHealth + 34.0f) * 0.01f; if (fHealthAdjustment > 1.0) fHealthAdjustment = 1.0; - fCameraOscillationRange = CarEngines.engines[byCarTypeIndex].fOscillationMax - CarEngines.engines[byCarTypeIndex].fOscillationMin;// Calculate camera pitch and roll offsets based on car engine oscillation - //fHorizontalSpeed = COERCE_FLOAT(abs(pCar->iPitchBackup)); - //dOscillationFactor = (double)SLODWORD(fHorizontalSpeed) * fCameraOscillationRange * 0.00024414062 + CarEngines.engines[byCarTypeIndex].fOscillationMin; - dOscillationFactor = (double)abs(pCar->iPitchBackup) * fCameraOscillationRange * 0.00024414062 + CarEngines.engines[byCarTypeIndex].fOscillationMin; - fTempFloat1 = tcos[((uint16)CarEngines.engines[byCarTypeIndex].iOscillationFreq * (uint16)pCar->iCameraOscillationPhase) & 0x3FFF]; + fCameraOscillationRange = + CarEngines.engines[byCarTypeIndex].fOscillationMax - + CarEngines.engines[byCarTypeIndex] + .fOscillationMin; // Calculate camera pitch and roll offsets based on + // car engine oscillation + // fHorizontalSpeed = COERCE_FLOAT(abs(pCar->iPitchBackup)); + // dOscillationFactor = (double)SLODWORD(fHorizontalSpeed) * + // fCameraOscillationRange * 0.00024414062 + + // CarEngines.engines[byCarTypeIndex].fOscillationMin; + dOscillationFactor = (double)abs(pCar->iPitchBackup) * + fCameraOscillationRange * 0.00024414062 + + CarEngines.engines[byCarTypeIndex].fOscillationMin; + fTempFloat1 = + tcos[((uint16)CarEngines.engines[byCarTypeIndex].iOscillationFreq * + (uint16)pCar->iCameraOscillationPhase) & + 0x3FFF]; iControlType = pCar->iControlType; fCameraOscillationBase = (float)dOscillationFactor; if (iControlType == 2) @@ -2214,7 +2592,9 @@ void updatecar2(tCar *pCar) fSpeedOverflow = pCar->fSpeedOverflow; iChunkCheck = pCar->nCurrChunk; fSpeedChangeRate = (float)dBaseSpeed + fSpeedOverflow - pCar->fFinalSpeed; - if (iChunkCheck != -1 && pCar->byCarDesignIdx != 9)// Speed change rate limiting - prevent unrealistic acceleration/deceleration + if (iChunkCheck != -1 && + pCar->byCarDesignIdx != 9) // Speed change rate limiting - prevent + // unrealistic acceleration/deceleration { if (fSpeedChangeRate <= 2.0) { if (fSpeedChangeRate < -6.0) @@ -2262,10 +2642,12 @@ void updatecar2(tCar *pCar) if ((double)pCarEngine->iSteeringSpeedLimit > fAbsoluteSpeed) iSteeringInput = 0; // CHEAT_MODE_TINY_CARS - if ((cheat_mode & CHEAT_MODE_TINY_CARS) != 0) // CHEAT_MODE_TINY_CARS - modified steering response + if ((cheat_mode & CHEAT_MODE_TINY_CARS) != + 0) // CHEAT_MODE_TINY_CARS - modified steering response { if (iSteeringInput < 0) { - iRollDynamicTemp = pCar->iRollDynamicOffset - 8 * pCarEngine->iRollResponseRate; + iRollDynamicTemp = + pCar->iRollDynamicOffset - 8 * pCarEngine->iRollResponseRate; pEngineTemp = pCarEngine; pCar->iRollDynamicOffset = iRollDynamicTemp; iEngineCalc = -8 * pEngineTemp->iMaxRollOffset; @@ -2338,15 +2720,20 @@ void updatecar2(tCar *pCar) doviewtend(pCar, 1, 0); if (ViewType[1] == pCar->iDriverIdx) doviewtend(pCar, 1, 1); - iControlTypeLocal = pCar->iControlType; // Branch on car control type: 0=Free Movement, 1=?, 2=Ground, 3=AI/Player - if (pCar->nCurrChunk >= 0 && pCar->nCurrChunk < TRAK_LEN)//check added by ROLLER + iControlTypeLocal = + pCar->iControlType; // Branch on car control type: 0=Free Movement, 1=?, + // 2=Ground, 3=AI/Player + if (pCar->nCurrChunk >= 0 && + pCar->nCurrChunk < TRAK_LEN) // check added by ROLLER pLocalData = (float *)&localdata[pCar->nCurrChunk]; else pLocalData = NULL; if (iControlTypeLocal < 2) { if (!iControlTypeLocal) { - pCar->direction.fZ = pCar->direction.fZ + -3.0f;// Free movement physics - direct position and direction updates + pCar->direction.fZ = + pCar->direction.fZ + -3.0f; // Free movement physics - direct position + // and direction updates pCar->pos.fX = pCar->direction.fX + pCar->pos.fX; pCar->pos.fY = pCar->direction.fY + pCar->pos.fY; dDirectionZ = pCar->direction.fZ + pCar->pos.fZ; @@ -2356,20 +2743,23 @@ void updatecar2(tCar *pCar) fHorizontalSpeedLocal = fHorizontalSpeed; fDirectionZ = fCarPosZ; pCar->pos.fZ = (float)dDirectionZ; - //if ((LODWORD(fHorizontalSpeedLocal) & 0x7FFFFFFF) != 0 || (LODWORD(fCarPosZ) & 0x7FFFFFFF) != 0) { - if (fabs(fHorizontalSpeedLocal) > FLT_EPSILON || fabs(fCarPosZ) > FLT_EPSILON) { - dAtanResult = atan2(fDirectionZ, fHorizontalSpeedCopy) * 16384.0 / 6.28318530718; + // if ((LODWORD(fHorizontalSpeedLocal) & 0x7FFFFFFF) != 0 || + // (LODWORD(fCarPosZ) & 0x7FFFFFFF) != 0) { + if (fabs(fHorizontalSpeedLocal) > FLT_EPSILON || + fabs(fCarPosZ) > FLT_EPSILON) { + dAtanResult = + atan2(fDirectionZ, fHorizontalSpeedCopy) * 16384.0 / 6.28318530718; //_CHP(); - //LODWORD(fHorizontalSpeed) = (int)dAtanResult; + // LODWORD(fHorizontalSpeed) = (int)dAtanResult; iPitchAngle = (int)dAtanResult & 0x3FFF; } else { iPitchAngle = 0; - //LOWORD(iPitchAngle) = 0; + // LOWORD(iPitchAngle) = 0; } pCar->nPitch = iPitchAngle; nRollAdjusted = (int16)(pCar->iRollMomentum) + pCar->nRoll; nRollAdjusted &= 0x3FFFu; - //HIBYTE(nRollAdjusted) &= 0x3Fu; + // HIBYTE(nRollAdjusted) &= 0x3Fu; iYaw3Current = pCar->nActualYaw; pCar->nRoll = nRollAdjusted; iYawDelta = ((int16)iYaw3Current - pCar->nYaw) & 0x3FFF; @@ -2387,19 +2777,22 @@ void updatecar2(tCar *pCar) } pCar->nYaw = iYawCurrent; landontrack(pCar); - //if ((LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && pCar->nDeathTimer < -90) + // if ((LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && pCar->nDeathTimer < + // -90) if (fabs(pCar->fHealth) == 0 && pCar->nDeathTimer < -90) goto LABEL_501; } goto LABEL_502; } - if (iControlTypeLocal > 2 && pCar->nCurrChunk >= 0 && pCar->nCurrChunk < TRAK_LEN) {//curr chunk check added by ROLLER + if (iControlTypeLocal > 2 && pCar->nCurrChunk >= 0 && + pCar->nCurrChunk < TRAK_LEN) { // curr chunk check added by ROLLER if (iControlTypeLocal != 3) goto LABEL_502; if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_PIT_ZONE) == 0) pCar->byPitLaneActiveFlag = 0; iChunkCurrent = pCar->nCurrChunk; - iChunkNext = iChunkCurrent + 1; // Track surface calculations - determine track width and banking angles + iChunkNext = iChunkCurrent + 1; // Track surface calculations - determine + // track width and banking angles if (iChunkCurrent + 1 == TRAK_LEN) iChunkNext ^= TRAK_LEN; dPositionCalc = pCar->pos.fX + pLocalData[12]; @@ -2407,71 +2800,79 @@ void updatecar2(tCar *pCar) fLeftShoulderTrackWidth = localdata[iChunkNext].fTrackHalfWidth; dTrackPosCalc = pCar->pos.fX - pLocalData[12]; dInterpolationFactor = 1.0 / (pLocalData[12] * 2.0); - fTrackCenterLine = (float)((dPositionCalc * fLeftShoulderTrackWidth - dTrackPosCalc * fCurrentTrackHalfWidth) * dInterpolationFactor); + fTrackCenterLine = (float)((dPositionCalc * fLeftShoulderTrackWidth - + dTrackPosCalc * fCurrentTrackHalfWidth) * + dInterpolationFactor); fCurrentTrackHalfWidth = TrackInfo[iChunkCurrent].fLShoulderWidth; fLeftShoulderTrackWidth = TrackInfo[iChunkNext].fLShoulderWidth; - fLeftShoulderBoundary = (float)((dPositionCalc * fLeftShoulderTrackWidth - dTrackPosCalc * fCurrentTrackHalfWidth) * dInterpolationFactor); + fLeftShoulderBoundary = (float)((dPositionCalc * fLeftShoulderTrackWidth - + dTrackPosCalc * fCurrentTrackHalfWidth) * + dInterpolationFactor); fLeftShoulderTrackWidth = TrackInfo[iChunkNext].fRShoulderWidth; fCurrentTrackHalfWidth = TrackInfo[iChunkCurrent].fRShoulderWidth; leftang = 0; rightang = 0; iSurfaceType = TrackInfo[iChunkCurrent].iLeftSurfaceType - 1; - fRightShoulderBoundary = (float)((dPositionCalc * fLeftShoulderTrackWidth - dTrackPosCalc * fCurrentTrackHalfWidth) * dInterpolationFactor); + fRightShoulderBoundary = (float)((dPositionCalc * fLeftShoulderTrackWidth - + dTrackPosCalc * fCurrentTrackHalfWidth) * + dInterpolationFactor); switch (iSurfaceType) { - case 0: - case 2: - case 3: - case 6: - case 7: - fBankingCalc1 = TrackInfo[iChunkNext].fLShoulderWidth - + localdata[iChunkNext].fTrackHalfWidth - - (TrackInfo[iChunkCurrent].fLShoulderWidth - + localdata[iChunkCurrent].fTrackHalfWidth); - fBankingCalc2 = pLocalData[12] * 2.0; - goto LABEL_188; - case 4: - case 5: - case 8: - fBankingCalc2 = pLocalData[12] * 2.0; - fCurrentTrackHalfWidth = localdata[iChunkCurrent].fTrackHalfWidth; - fLeftShoulderTrackWidth = localdata[iChunkNext].fTrackHalfWidth; - fBankingCalc1 = fLeftShoulderTrackWidth - fCurrentTrackHalfWidth; - LABEL_188: - dLeftBankAngle = atan2(fBankingCalc1, fBankingCalc2) * 16384.0 / 6.28318530718; - //_CHP(); - //LODWORD(fCameraOscillationRange) = (int)dLeftBankAngle; - leftang = (int)dLeftBankAngle & 0x3FFF; - break; - default: - break; + case 0: + case 2: + case 3: + case 6: + case 7: + fBankingCalc1 = TrackInfo[iChunkNext].fLShoulderWidth + + localdata[iChunkNext].fTrackHalfWidth - + (TrackInfo[iChunkCurrent].fLShoulderWidth + + localdata[iChunkCurrent].fTrackHalfWidth); + fBankingCalc2 = pLocalData[12] * 2.0; + goto LABEL_188; + case 4: + case 5: + case 8: + fBankingCalc2 = pLocalData[12] * 2.0; + fCurrentTrackHalfWidth = localdata[iChunkCurrent].fTrackHalfWidth; + fLeftShoulderTrackWidth = localdata[iChunkNext].fTrackHalfWidth; + fBankingCalc1 = fLeftShoulderTrackWidth - fCurrentTrackHalfWidth; + LABEL_188: + dLeftBankAngle = + atan2(fBankingCalc1, fBankingCalc2) * 16384.0 / 6.28318530718; + //_CHP(); + // LODWORD(fCameraOscillationRange) = (int)dLeftBankAngle; + leftang = (int)dLeftBankAngle & 0x3FFF; + break; + default: + break; } switch (TrackInfo[iChunkCurrent].iRightSurfaceType) { - case 1: - case 3: - case 4: - case 7: - case 8: - fRightBankCalc = pLocalData[12] * 2.0; - fRightBankCalc2 = TrackInfo[iChunkCurrent].fRShoulderWidth - + localdata[iChunkCurrent].fTrackHalfWidth - - (TrackInfo[iChunkNext].fRShoulderWidth - + localdata[iChunkNext].fTrackHalfWidth); - goto LABEL_192; - case 5: - case 6: - case 9: - fRightBankCalc = pLocalData[12] * 2.0; - fCurrentTrackHalfWidth = localdata[iChunkCurrent].fTrackHalfWidth; - fLeftShoulderTrackWidth = localdata[iChunkNext].fTrackHalfWidth; - fRightBankCalc2 = fCurrentTrackHalfWidth - fLeftShoulderTrackWidth; - LABEL_192: - dRightBankAngle = atan2(fRightBankCalc2, fRightBankCalc) * 16384.0 / 6.28318530718; - //_CHP(); - iRightBankAngle = (int)dRightBankAngle; - rightang = (int)dRightBankAngle & 0x3FFF; - break; - default: - break; + case 1: + case 3: + case 4: + case 7: + case 8: + fRightBankCalc = pLocalData[12] * 2.0; + fRightBankCalc2 = TrackInfo[iChunkCurrent].fRShoulderWidth + + localdata[iChunkCurrent].fTrackHalfWidth - + (TrackInfo[iChunkNext].fRShoulderWidth + + localdata[iChunkNext].fTrackHalfWidth); + goto LABEL_192; + case 5: + case 6: + case 9: + fRightBankCalc = pLocalData[12] * 2.0; + fCurrentTrackHalfWidth = localdata[iChunkCurrent].fTrackHalfWidth; + fLeftShoulderTrackWidth = localdata[iChunkNext].fTrackHalfWidth; + fRightBankCalc2 = fCurrentTrackHalfWidth - fLeftShoulderTrackWidth; + LABEL_192: + dRightBankAngle = + atan2(fRightBankCalc2, fRightBankCalc) * 16384.0 / 6.28318530718; + //_CHP(); + iRightBankAngle = (int)dRightBankAngle; + rightang = (int)dRightBankAngle & 0x3FFF; + break; + default: + break; } if (pCar->pos.fY <= (double)fTrackCenterLine) { if (-fTrackCenterLine <= pCar->pos.fY) @@ -2485,37 +2886,46 @@ void updatecar2(tCar *pCar) iTrackColorFlag = 0; bZeroFlag = 1; } else { - iTrackColorFlag = TrakColour[pCar->nCurrChunk][pCar->iLaneType] & SURFACE_FLAG_PIT; + iTrackColorFlag = + TrakColour[pCar->nCurrChunk][pCar->iLaneType] & SURFACE_FLAG_PIT; bZeroFlag = iTrackColorFlag == 0; } if (bZeroFlag) Car[0].byStatusFlags &= ~8u; - //if ((LODWORD(fAbsoluteSpeed) & 0x7FFFFFFF) != 0) + // if ((LODWORD(fAbsoluteSpeed) & 0x7FFFFFFF) != 0) if (fabs(fAbsoluteSpeed) > FLT_EPSILON) pCar->byRepairSpeechPlayed = 0; - //if ((LODWORD(fAbsoluteSpeed) & 0x7FFFFFFF) != 0 || !iTrackColorFlag || (pCar->byStatusFlags & 4) != 0) { - if (fabs(fAbsoluteSpeed) > FLT_EPSILON || !iTrackColorFlag || (pCar->byStatusFlags & 4) != 0) { + // if ((LODWORD(fAbsoluteSpeed) & 0x7FFFFFFF) != 0 || !iTrackColorFlag || + // (pCar->byStatusFlags & 4) != 0) { + if (fabs(fAbsoluteSpeed) > FLT_EPSILON || !iTrackColorFlag || + (pCar->byStatusFlags & 4) != 0) { pCar->byDebugDamage = 0; } else { iPlayer1CarIdx = player1_car; iCurrentDriverIdx2 = pCar->iDriverIdx; pCar->byCheatAmmo = 8; - if ((iPlayer1CarIdx == iCurrentDriverIdx2 || player2_car == iCurrentDriverIdx2) && !pCar->byRepairSpeechPlayed && pCar->fHealth < 100.0) { + if ((iPlayer1CarIdx == iCurrentDriverIdx2 || + player2_car == iCurrentDriverIdx2) && + !pCar->byRepairSpeechPlayed && pCar->fHealth < 100.0) { iSpeechDriverIdx2 = pCar->iDriverIdx; pCar->byRepairSpeechPlayed = -1; - speechonly(SOUND_SAMPLE_MENDING, 0x8000, 18, iSpeechDriverIdx2);// SOUND_SAMPLE_MENDING - play repair sound when health is low + speechonly(SOUND_SAMPLE_MENDING, 0x8000, 18, + iSpeechDriverIdx2); // SOUND_SAMPLE_MENDING - play repair + // sound when health is low } pCar->byDebugDamage = -1; iCurrentChunk2 = pCar->nCurrChunk; pCar->byStatusFlags |= 8u; - if ((TrakColour[iCurrentChunk2][1] & SURFACE_FLAG_PIT_BOX) != 0)// Handle special pit lane targeting for AI cars on repair strips + if ((TrakColour[iCurrentChunk2][1] & SURFACE_FLAG_PIT_BOX) != + 0) // Handle special pit lane targeting for AI cars on repair strips { iLoopCounter = 0; if (numcars > 0) { iNumCarsLocal = numcars; iArrayIndex = 0; do { - if (iLoopCounter != pCar->iDriverIdx && pCar->nCurrChunk == Car[iArrayIndex].iAITargetCar) + if (iLoopCounter != pCar->iDriverIdx && + pCar->nCurrChunk == Car[iArrayIndex].iAITargetCar) Car[iArrayIndex].iAITargetCar = -1; ++iLoopCounter; ++iArrayIndex; @@ -2529,26 +2939,37 @@ void updatecar2(tCar *pCar) iPlayer1Check = player1_car; iDriverForHealth = pCar->iDriverIdx; pCar->fHealth = 100.0; - if ((iPlayer1Check == iDriverForHealth || player2_car == iDriverForHealth) && pCar->byRepairSpeechPlayed) { - speechonly(SOUND_SAMPLE_FIXED, 0x8000, 18, pCar->iDriverIdx);// SOUND_SAMPLE_FIXED - play repair complete sound when health reaches 100% + if ((iPlayer1Check == iDriverForHealth || + player2_car == iDriverForHealth) && + pCar->byRepairSpeechPlayed) { + speechonly( + SOUND_SAMPLE_FIXED, 0x8000, 18, + pCar->iDriverIdx); // SOUND_SAMPLE_FIXED - play repair complete + // sound when health reaches 100% pCar->byRepairSpeechPlayed = 0; } pCar->byDebugDamage = 0; pCar->byStatusFlags = 0; } } - iCenterGrip = localdata[pCar->nCurrChunk].iCenterGrip;// Calculate grip values based on car position (center track vs shoulders) + iCenterGrip = localdata[pCar->nCurrChunk] + .iCenterGrip; // Calculate grip values based on car + // position (center track vs shoulders) if (pCar->pos.fY > (double)fTrackCenterLine) iCenterGrip = localdata[pCar->nCurrChunk].iLeftShoulderGrip; if (-fTrackCenterLine > pCar->pos.fY) iCenterGrip = localdata[pCar->nCurrChunk].iRightShoulderGrip; // CHEAT_MODE_ICY_ROAD - if ((cheat_mode & CHEAT_MODE_ICY_ROAD) != 0) // CHEAT_MODE grip hack - force maximum grip value of 10 + if ((cheat_mode & CHEAT_MODE_ICY_ROAD) != + 0) // CHEAT_MODE grip hack - force maximum grip value of 10 iCenterGrip = 10; dSurfaceValue = (double)surface[iCenterGrip].iGripModifier; fSurfaceGripValue = surface[iCenterGrip].fBaseGrip; byStatusFlags = pCar->byStatusFlags; - fCurrentGripMultiplier = (float)((dSurfaceValue + CarEngines.engines[byCarTypeIndex].fGripBonus) / (2.5 - fHealthAdjustment * 1.5)); + fCurrentGripMultiplier = + (float)((dSurfaceValue + + CarEngines.engines[byCarTypeIndex].fGripBonus) / + (2.5 - fHealthAdjustment * 1.5)); if ((byStatusFlags & 4) != 0) fMaxGripLimit_1 = 10.0; else @@ -2559,7 +2980,9 @@ void updatecar2(tCar *pCar) fCurrentGripMultiplier = 0.0; iGripIndex = iCenterGrip; fSurfaceGripBase = surface[iGripIndex].fGripMultiplier * fHealthAdjustment; - fTempGrip = (float)(((double)surface[iGripIndex].iSecondaryGrip + CarEngines.engines[byCarTypeIndex].fGripBonus) / (2.5 - fHealthAdjustment * 1.5)); + fTempGrip = (float)(((double)surface[iGripIndex].iSecondaryGrip + + CarEngines.engines[byCarTypeIndex].fGripBonus) / + (2.5 - fHealthAdjustment * 1.5)); fMaxGripLimit_1 = fMaxGripLimit_1 * 0.5f; if (fTempGrip > (double)fMaxGripLimit_1) fTempGrip = fMaxGripLimit_1; @@ -2574,17 +2997,20 @@ void updatecar2(tCar *pCar) if (-fTrackCenterLine <= pCar->pos.fY) fZ = pPointAy[6].fZ; else - fZ = pPointAy[6].fZ * tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - pPointAy[7].fX * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; + fZ = pPointAy[6].fZ * tcos[pTrackInfo->iRightBankAngle & 0x3FFF] - + pPointAy[7].fX * tsin[pTrackInfo->iRightBankAngle & 0x3FFF]; } else { - fZ = pPointAy[6].fZ * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + pPointAy[7].fX * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; + fZ = pPointAy[6].fZ * tcos[pTrackInfo->iLeftBankAngle & 0x3FFF] + + pPointAy[7].fX * tsin[pTrackInfo->iLeftBankAngle & 0x3FFF]; } iCurrentYaw = pCar->nYaw; fBankingForceY = fTrackPointY * tcos[iCurrentYaw] + fZ * tsin[iCurrentYaw]; fBankingForceX = -fTrackPointY * tsin[iCurrentYaw] + fZ * tcos[iCurrentYaw]; - fRPMRatio = pCar->fRPMRatio; // Physics calculations - banking effects on car movement + fRPMRatio = pCar->fRPMRatio; // Physics calculations - banking effects on + // car movement fSpeedScaled = fAbsoluteSpeed * 0.015f; if (fRPMRatio != 1.0 || (char)pCar->byGearAyMax == -1) { - //if ((LODWORD(fBankingForceY) & 0x7FFFFFFF) == 0) { + // if ((LODWORD(fBankingForceY) & 0x7FFFFFFF) == 0) { if (fabs(fBankingForceY) == 0) { if (fSpeedOverflow >= 0.0) { if (fSpeedOverflow > 0.0) { @@ -2614,12 +3040,15 @@ void updatecar2(tCar *pCar) fSpeedOverflow = 0.0; } pCar->fSpeedOverflow = fSpeedOverflow; - iSteeringInputProcessed = pCar->iSteeringInput;// Process steering input and apply speed-based steering modifiers + iSteeringInputProcessed = + pCar->iSteeringInput; // Process steering input and apply speed-based + // steering modifiers if (!iSteeringInputProcessed) goto LABEL_272; if (pCar->fFinalSpeed < 0.0) { - //LODWORD(fCameraOscillationRange) = -iSteeringInputProcessed; - dSteeringSpeedCalc = (4500.0 - fAbsoluteSpeed * 23.0) * (double)-iSteeringInputProcessed * 0.00039999999; + // LODWORD(fCameraOscillationRange) = -iSteeringInputProcessed; + dSteeringSpeedCalc = (4500.0 - fAbsoluteSpeed * 23.0) * + (double)-iSteeringInputProcessed * 0.00039999999; } else { if (fAbsoluteSpeed >= 360.0) { LABEL_272: @@ -2627,7 +3056,9 @@ void updatecar2(tCar *pCar) iSteeringInputProcessed += pCar->iBankingSteerOffset; if (iUnk20 > fAbsoluteSpeed) iSteeringInputProcessed = 0; - iYawCurrent = ((uint16)pCar->iJumpMomentum + (int16)iSteeringInputProcessed + (int16)iYawCurrent) & 0x3FFF; + iYawCurrent = ((uint16)pCar->iJumpMomentum + + (int16)iSteeringInputProcessed + (int16)iYawCurrent) & + 0x3FFF; pCar->nYaw = iYawCurrent; if ((int)abs(iJumpMomentum) > 50) { if (iJumpMomentum <= 0) @@ -2647,8 +3078,10 @@ void updatecar2(tCar *pCar) fTrackBankingY = CarBaseX; else fTrackBankingY = -CarBaseX; - fCarHalfWidthProjected = fCarBaseYProjected * tcos[iYawCurrent] - fTrackBankingY * tsin[iYawCurrent]; - if ((((int16)iYawCurrent + 4096) & 0x3FFFu) < 0x1000 || (((int16)iYawCurrent + 4096) & 0x3FFFu) >= 0x3000) + fCarHalfWidthProjected = fCarBaseYProjected * tcos[iYawCurrent] - + fTrackBankingY * tsin[iYawCurrent]; + if ((((int16)iYawCurrent + 4096) & 0x3FFFu) < 0x1000 || + (((int16)iYawCurrent + 4096) & 0x3FFFu) >= 0x3000) fTrackBankingX = CarBaseY; else fTrackBankingX = -CarBaseY; @@ -2656,34 +3089,44 @@ void updatecar2(tCar *pCar) fCarBaseXProjected = CarBaseX; else fCarBaseXProjected = -CarBaseX; - pCar->fCarWidthBankingProjection = fTrackBankingX * tcos[((int16)iYawCurrent + 4096) & 0x3FFF] - fCarBaseXProjected * tsin[((int16)iYawCurrent + 4096) & 0x3FFF]; + pCar->fCarWidthBankingProjection = + fTrackBankingX * tcos[((int16)iYawCurrent + 4096) & 0x3FFF] - + fCarBaseXProjected * tsin[((int16)iYawCurrent + 4096) & 0x3FFF]; dCurrentSpeed = fAbsoluteSpeed; pCar->fCarHalfWidth = fCarHalfWidthProjected; fSpeedLimited = fAbsoluteSpeed; if (dCurrentSpeed > 100.0) fSpeedLimited = 100.0; //_CHP(); - pCar->iBankingSteerOffset = (int)(fSpeedLimited * fBankingForceX * 0.16666667); + pCar->iBankingSteerOffset = + (int)(fSpeedLimited * fBankingForceX * 0.16666667); if (pCar->iBankingSteerOffset > 16) pCar->iBankingSteerOffset = 16; if (pCar->iBankingSteerOffset < -16) pCar->iBankingSteerOffset = -16; - if (race_started && !pCar->byDebugDamage)// Update car position and handle track collision detection + if (race_started && + !pCar->byDebugDamage) // Update car position and handle track + // collision detection { - if ((fBankingForceY > 0.0 || fAbsoluteSpeed > 2.0) && pCar->fHealth > 0.0) - pCar->fSpeedOverflow = fBankingForceY * 0.125f + pCar->fSpeedOverflow; + if ((fBankingForceY > 0.0 || fAbsoluteSpeed > 2.0) && + pCar->fHealth > 0.0) + pCar->fSpeedOverflow = + fBankingForceY * 0.125f + pCar->fSpeedOverflow; } else { pCar->fSpeedOverflow = 0.0; } fFinalSpeedThisFrame = pCar->fFinalSpeed; - if (fFinalSpeedThisFrame < 1.0 && (pCar->byGearAyMax & 0x80u) == 0 && pCar->fPower > 0.0) + if (fFinalSpeedThisFrame < 1.0 && (pCar->byGearAyMax & 0x80u) == 0 && + pCar->fPower > 0.0) fFinalSpeedThisFrame = 1.0; dMovementSpeed = fFinalSpeedThisFrame; iYaw3ForMovement = iYaw3; pCar->pos.fX = fFinalSpeedThisFrame * tcos[iYaw3] + pCar->pos.fX; - pCar->pos.fY = (float)dMovementSpeed * tsin[iYaw3ForMovement] + pCar->pos.fY; + pCar->pos.fY = + (float)dMovementSpeed * tsin[iYaw3ForMovement] + pCar->pos.fY; if (dMovementSpeed < 200.0) - pCar->pos.fZ = fFinalSpeedThisFrame * tsin[pCar->nPitch] + pCar->pos.fZ; + pCar->pos.fZ = + fFinalSpeedThisFrame * tsin[pCar->nPitch] + pCar->pos.fZ; pChunkData = &localdata[pCar->nCurrChunk]; pCar->pos.fZ = pChunkData->gravity.fZ + pCar->pos.fZ; if (fabs(pCar->pos.fX) > pChunkData->fTrackHalfLength) @@ -2702,10 +3145,12 @@ void updatecar2(tCar *pCar) uiJumpFlag = abs(iTrackColorValue) & SURFACE_FLAG_NON_MAGNETIC; if (pCar->fFinalSpeed < 0.0) uiJumpFlag = 0; - if ((iTrackColorValue & SURFACE_FLAG_PREVENT_JUMP) != 0 && pCar->fFinalSpeed > 240.0) + if ((iTrackColorValue & SURFACE_FLAG_PREVENT_JUMP) != 0 && + pCar->fFinalSpeed > 240.0) uiJumpFlag = 0; iCollisionFlag = 0; - if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_WALL_22) != 0 && fTrackCenterLine >= fabs(pCar->pos.fY) - fCarHalfWidthProjected) { + if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_WALL_22) != 0 && + fTrackCenterLine >= fabs(pCar->pos.fY) - fCarHalfWidthProjected) { if (pCar->pos.fY < 0.0) { pCar->pos.fY = -fTrackCenterLine - fCarHalfWidthProjected; hitleft(pCar, 12, 1); @@ -2715,12 +3160,14 @@ void updatecar2(tCar *pCar) } iCollisionFlag = -1; } - if ((TrakColour[pCar->nCurrChunk][0] & SURFACE_FLAG_WALL_22) != 0 && pCar->pos.fY + fCarHalfWidthProjected >= fTrackCenterLine) { + if ((TrakColour[pCar->nCurrChunk][0] & SURFACE_FLAG_WALL_22) != 0 && + pCar->pos.fY + fCarHalfWidthProjected >= fTrackCenterLine) { pCar->pos.fY = fTrackCenterLine - fCarHalfWidthProjected; hitleft(pCar, 12, 0); iCollisionFlag = -1; } - if ((TrakColour[pCar->nCurrChunk][2] & SURFACE_FLAG_WALL_22) != 0 && -fTrackCenterLine >= pCar->pos.fY - fCarHalfWidthProjected) { + if ((TrakColour[pCar->nCurrChunk][2] & SURFACE_FLAG_WALL_22) != 0 && + -fTrackCenterLine >= pCar->pos.fY - fCarHalfWidthProjected) { pCar->pos.fY = fCarHalfWidthProjected - fTrackCenterLine; hitright(pCar, 12, 1); iCollisionFlag = -1; @@ -2729,90 +3176,21 @@ void updatecar2(tCar *pCar) fCarPosZBackup = pCar->pos.fZ; if (pCar->iStunned) { iCollisionFlag = pCar->byCarDesignIdx; - //LOBYTE(iCollisionFlag) = pCar->byCarDesignIdx; - fCarPosZBackup = fCarPosZBackup - CarBox.hitboxAy[iCollisionFlag][4].fZ; + // LOBYTE(iCollisionFlag) = pCar->byCarDesignIdx; + fCarPosZBackup = + fCarPosZBackup - CarBox.hitboxAy[iCollisionFlag][4].fZ; } if (pCar->pos.fY > 0.0) { switch (pTrackInfo->iLeftSurfaceType) { - case 0: - case 2: - if (fTrackCenterLine + fLeftShoulderBoundary >= pCar->pos.fY - fCarHalfWidthProjected * 0.5) { - if (!uiJumpFlag) - goto LABEL_344; - fCameraOscillationRange = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) >= fCameraOscillationRange) - goto LABEL_344; - } - goto LABEL_403; - case 1: - case 3: - case 4: - case 7: - case 8: - dLeftWallCheck = pCar->pos.fY + fCarHalfWidthProjected; - fLeftTrackBoundary = fTrackCenterLine + fLeftShoulderBoundary; - if (dLeftWallCheck > fLeftTrackBoundary) { - pCar->pos.fY = fLeftTrackBoundary - fCarHalfWidthProjected; - hitleft(pCar, 12, 0); - goto LABEL_404; - } - if (uiJumpFlag) { - fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < fHorizontalSpeed) - goto LABEL_403; - } - goto LABEL_344; - case 5: - dLeftWallCheck2 = pCar->pos.fY + fCarHalfWidthProjected; - fRightTrackBoundary = fTrackCenterLine + fLeftShoulderBoundary; - if (dLeftWallCheck2 > fRightTrackBoundary) { - pCar->pos.fY = fRightTrackBoundary - fCarHalfWidthProjected; - hitleft(pCar, 12, 0); - } - if (pCar->pos.fY + fCarHalfWidthProjected > fTrackCenterLine && pCar->iLaneType) { - pCar->pos.fY = fTrackCenterLine - fCarHalfWidthProjected; - hitleft(pCar, 12, 0); - } - if (pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && !pCar->iLaneType) { - pCar->pos.fY = fTrackCenterLine + fCarHalfWidthProjected; - hitright(pCar, 12, 0); - } - if (uiJumpFlag) { - fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < fHorizontalSpeed) - goto LABEL_403; - } - goto LABEL_344; - case 6: - case 9: - if (fTrackCenterLine + fLeftShoulderBoundary < pCar->pos.fY - fCarHalfWidthProjected * 0.5) - goto LABEL_403; - if (fCarHalfWidthProjected > fabs(pCar->pos.fY - fTrackCenterLine) && pCar->pos.fY + fCarHalfWidthProjected > fTrackCenterLine && pCar->iLaneType) { - pCar->pos.fY = fTrackCenterLine - fCarHalfWidthProjected; - hitleft(pCar, 12, 0); - } - if (pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && !pCar->iLaneType) { - pCar->pos.fY = fTrackCenterLine + fCarHalfWidthProjected; - hitright(pCar, 12, 0); - } - if (uiJumpFlag) { - fCameraOscillationRange = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < fCameraOscillationRange) - goto LABEL_403; - } - goto LABEL_344; - default: - goto LABEL_404; // Handle left track surface types - walls, ramps, barriers, etc. - } - } - switch (pTrackInfo->iRightSurfaceType) { case 0: case 2: - if (fTrackCenterLine + fRightShoulderBoundary >= -pCar->pos.fY - fCarHalfWidthProjected * 0.5) { + if (fTrackCenterLine + fLeftShoulderBoundary >= + pCar->pos.fY - fCarHalfWidthProjected * 0.5) { if (!uiJumpFlag) goto LABEL_344; fCameraOscillationRange = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) >= fCameraOscillationRange) + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) >= + fCameraOscillationRange) goto LABEL_344; } goto LABEL_403; @@ -2821,62 +3199,165 @@ void updatecar2(tCar *pCar) case 4: case 7: case 8: - if (fTrackCenterLine + fRightShoulderBoundary >= fCarHalfWidthProjected - pCar->pos.fY) { - if (uiJumpFlag && (fHorizontalSpeed = fCarPosZBackup - fSpeedScaled, getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < fHorizontalSpeed)) - LABEL_403: - converttoair(pCar); - else - LABEL_344: - putflat(pCar); - } else { - pCar->pos.fY = -fTrackCenterLine - fRightShoulderBoundary + fCarHalfWidthProjected; - hitright(pCar, 12, 1); + dLeftWallCheck = pCar->pos.fY + fCarHalfWidthProjected; + fLeftTrackBoundary = fTrackCenterLine + fLeftShoulderBoundary; + if (dLeftWallCheck > fLeftTrackBoundary) { + pCar->pos.fY = fLeftTrackBoundary - fCarHalfWidthProjected; + hitleft(pCar, 12, 0); + goto LABEL_404; } - break; + if (uiJumpFlag) { + fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < + fHorizontalSpeed) + goto LABEL_403; + } + goto LABEL_344; case 5: - if (fTrackCenterLine + fRightShoulderBoundary < fCarHalfWidthProjected - pCar->pos.fY) { - pCar->pos.fY = -fTrackCenterLine - fRightShoulderBoundary + fCarHalfWidthProjected; - hitright(pCar, 12, 1); + dLeftWallCheck2 = pCar->pos.fY + fCarHalfWidthProjected; + fRightTrackBoundary = fTrackCenterLine + fLeftShoulderBoundary; + if (dLeftWallCheck2 > fRightTrackBoundary) { + pCar->pos.fY = fRightTrackBoundary - fCarHalfWidthProjected; + hitleft(pCar, 12, 0); } - if (fCarHalfWidthProjected - pCar->pos.fY > fTrackCenterLine && pCar->iLaneType != 2) { - pCar->pos.fY = fCarHalfWidthProjected - fTrackCenterLine; - hitright(pCar, 12, 1); + if (pCar->pos.fY + fCarHalfWidthProjected > fTrackCenterLine && + pCar->iLaneType) { + pCar->pos.fY = fTrackCenterLine - fCarHalfWidthProjected; + hitleft(pCar, 12, 0); } - if (-pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && pCar->iLaneType == 2) { - pCar->pos.fY = -fTrackCenterLine - fCarHalfWidthProjected; - hitleft(pCar, 12, 1); + if (pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && + !pCar->iLaneType) { + pCar->pos.fY = fTrackCenterLine + fCarHalfWidthProjected; + hitright(pCar, 12, 0); } if (uiJumpFlag) { fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < fHorizontalSpeed) + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < + fHorizontalSpeed) goto LABEL_403; } goto LABEL_344; case 6: case 9: - fRightCarPosY = -pCar->pos.fY; - if (fTrackCenterLine + fRightShoulderBoundary < fRightCarPosY - fCarHalfWidthProjected * 0.5) + if (fTrackCenterLine + fLeftShoulderBoundary < + pCar->pos.fY - fCarHalfWidthProjected * 0.5) goto LABEL_403; - if (fCarHalfWidthProjected > fabs(fRightCarPosY - fTrackCenterLine) && fCarHalfWidthProjected - pCar->pos.fY > fTrackCenterLine && pCar->iLaneType != 2) { - pCar->pos.fY = fCarHalfWidthProjected - fTrackCenterLine; - hitright(pCar, 12, 1); + if (fCarHalfWidthProjected > + fabs(pCar->pos.fY - fTrackCenterLine) && + pCar->pos.fY + fCarHalfWidthProjected > fTrackCenterLine && + pCar->iLaneType) { + pCar->pos.fY = fTrackCenterLine - fCarHalfWidthProjected; + hitleft(pCar, 12, 0); } - if (-pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && pCar->iLaneType == 2) { - pCar->pos.fY = -fTrackCenterLine - fCarHalfWidthProjected; - hitleft(pCar, 12, 1); + if (pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && + !pCar->iLaneType) { + pCar->pos.fY = fTrackCenterLine + fCarHalfWidthProjected; + hitright(pCar, 12, 0); } if (uiJumpFlag) { - fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; - if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < fHorizontalSpeed) + fCameraOscillationRange = fCarPosZBackup - fSpeedScaled; + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < + fCameraOscillationRange) goto LABEL_403; } goto LABEL_344; default: - break; // Handle right track surface types - walls, ramps, barriers, etc. + goto LABEL_404; // Handle left track surface types - walls, ramps, + // barriers, etc. + } + } + switch (pTrackInfo->iRightSurfaceType) { + case 0: + case 2: + if (fTrackCenterLine + fRightShoulderBoundary >= + -pCar->pos.fY - fCarHalfWidthProjected * 0.5) { + if (!uiJumpFlag) + goto LABEL_344; + fCameraOscillationRange = fCarPosZBackup - fSpeedScaled; + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) >= + fCameraOscillationRange) + goto LABEL_344; + } + goto LABEL_403; + case 1: + case 3: + case 4: + case 7: + case 8: + if (fTrackCenterLine + fRightShoulderBoundary >= + fCarHalfWidthProjected - pCar->pos.fY) { + if (uiJumpFlag && + (fHorizontalSpeed = fCarPosZBackup - fSpeedScaled, + getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < + fHorizontalSpeed)) + LABEL_403: + converttoair(pCar); + else + LABEL_344: + putflat(pCar); + } else { + pCar->pos.fY = -fTrackCenterLine - fRightShoulderBoundary + + fCarHalfWidthProjected; + hitright(pCar, 12, 1); + } + break; + case 5: + if (fTrackCenterLine + fRightShoulderBoundary < + fCarHalfWidthProjected - pCar->pos.fY) { + pCar->pos.fY = -fTrackCenterLine - fRightShoulderBoundary + + fCarHalfWidthProjected; + hitright(pCar, 12, 1); + } + if (fCarHalfWidthProjected - pCar->pos.fY > fTrackCenterLine && + pCar->iLaneType != 2) { + pCar->pos.fY = fCarHalfWidthProjected - fTrackCenterLine; + hitright(pCar, 12, 1); + } + if (-pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && + pCar->iLaneType == 2) { + pCar->pos.fY = -fTrackCenterLine - fCarHalfWidthProjected; + hitleft(pCar, 12, 1); + } + if (uiJumpFlag) { + fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < + fHorizontalSpeed) + goto LABEL_403; + } + goto LABEL_344; + case 6: + case 9: + fRightCarPosY = -pCar->pos.fY; + if (fTrackCenterLine + fRightShoulderBoundary < + fRightCarPosY - fCarHalfWidthProjected * 0.5) + goto LABEL_403; + if (fCarHalfWidthProjected > + fabs(fRightCarPosY - fTrackCenterLine) && + fCarHalfWidthProjected - pCar->pos.fY > fTrackCenterLine && + pCar->iLaneType != 2) { + pCar->pos.fY = fCarHalfWidthProjected - fTrackCenterLine; + hitright(pCar, 12, 1); + } + if (-pCar->pos.fY - fCarHalfWidthProjected < fTrackCenterLine && + pCar->iLaneType == 2) { + pCar->pos.fY = -fTrackCenterLine - fCarHalfWidthProjected; + hitleft(pCar, 12, 1); + } + if (uiJumpFlag) { + fHorizontalSpeed = fCarPosZBackup - fSpeedScaled; + if (getgroundz(pCar->pos.fX, pCar->pos.fY, pCar->nCurrChunk) < + fHorizontalSpeed) + goto LABEL_403; + } + goto LABEL_344; + default: + break; // Handle right track surface types - walls, ramps, barriers, + // etc. } } LABEL_404: - if (pCar->iControlType == 3 && localdata[pCar->nCurrChunk].fTrackHalfLength * 2.0 > CarBaseX) { + if (pCar->iControlType == 3 && + localdata[pCar->nCurrChunk].fTrackHalfLength * 2.0 > CarBaseX) { if (pCar->pos.fY <= (double)fTrackCenterLine) { if (-fTrackCenterLine <= pCar->pos.fY) iLaneTypeCheck = 1; @@ -2885,29 +3366,39 @@ void updatecar2(tCar *pCar) } else { iLaneTypeCheck = 0; } - //llTrackColorData = TrakColour[pCar->nCurrChunk][iLaneTypeCheck]; - //if ((((HIDWORD(llTrackColorData) ^ (unsigned int)llTrackColorData) - HIDWORD(llTrackColorData)) & 0x20000) != 0) - if ((TrakColour[pCar->nCurrChunk][iLaneTypeCheck] & SURFACE_FLAG_SKIP_RENDER) != 0) + // llTrackColorData = TrakColour[pCar->nCurrChunk][iLaneTypeCheck]; + // if ((((HIDWORD(llTrackColorData) ^ (unsigned int)llTrackColorData) + // - HIDWORD(llTrackColorData)) & 0x20000) != 0) + if ((TrakColour[pCar->nCurrChunk][iLaneTypeCheck] & + SURFACE_FLAG_SKIP_RENDER) != 0) converttoair(pCar); else analysefalloff(pCar); } if (pCar->iControlType == 3) { iYawDifferenceCalc = pCar->nYaw - pCar->nActualYaw; - iYawDifference = iYawDifferenceCalc + (iYawDifferenceCalc < 0 ? 0x4000 : 0); + iYawDifference = + iYawDifferenceCalc + (iYawDifferenceCalc < 0 ? 0x4000 : 0); if (iYawDifference > 0x2000) iYawDifference -= 0x4000; dSpeedAbs = fabs(pCar->fFinalSpeed); fCurrentSpeedAbs = (float)dSpeedAbs; if (dSpeedAbs <= fSurfaceGripValue) { fMaxGripLimit = fHealthAdjustment * 200.0f; - dGripCalculation = (fCurrentGripMultiplier - fMaxGripLimit) / fSurfaceGripValue * fCurrentSpeedAbs + fMaxGripLimit; + dGripCalculation = (fCurrentGripMultiplier - fMaxGripLimit) / + fSurfaceGripValue * fCurrentSpeedAbs + + fMaxGripLimit; } else { - dGripCalculation = (fCurrentSpeedAbs - fSurfaceGripBase) / (fSurfaceGripValue - fSurfaceGripBase) * fCurrentGripMultiplier - + (fCurrentSpeedAbs - fSurfaceGripValue) / (fSurfaceGripBase - fSurfaceGripValue) * fTempGrip; + dGripCalculation = (fCurrentSpeedAbs - fSurfaceGripBase) / + (fSurfaceGripValue - fSurfaceGripBase) * + fCurrentGripMultiplier + + (fCurrentSpeedAbs - fSurfaceGripValue) / + (fSurfaceGripBase - fSurfaceGripValue) * + fTempGrip; } fMaxGripLimit = (float)dGripCalculation; - fMaxGripLimit = (tsin[abs(iYawDifference)] * 4.0f + 1.0f) * fMaxGripLimit; + fMaxGripLimit = + (tsin[abs(iYawDifference)] * 4.0f + 1.0f) * fMaxGripLimit; if ((double)iYawDifference > fMaxGripLimit) { //_CHP(); iYawDifference = (int)fMaxGripLimit; @@ -2918,20 +3409,30 @@ void updatecar2(tCar *pCar) iYawDifference = (int)fNegativeYawLimit; } if (!pCar->iStunned) - pCar->nActualYaw = ((int16)iYawDifference + (uint16)pCar->nActualYaw) & 0x3FFF; + pCar->nActualYaw = + ((int16)iYawDifference + (uint16)pCar->nActualYaw) & 0x3FFF; iHumanControlIdx = pCar->iDriverIdx; if (human_control[iHumanControlIdx]) { if (!iJumpMomentum) { - //if (!pCar->iSteeringInput - // || (iInput = (int16)copy_multiple[((int16)readptr - 1) & 0x1FF][iHumanControlIdx].data.unInput, - // llInputCheck = (iInput) >> 8, - // (int)((HIDWORD(llInputCheck) ^ llInputCheck) - HIDWORD(llInputCheck) - abs32(pCar->iSteeringInput)) < 0)) { - //TODO check this - if (!pCar->iSteeringInput || abs((copy_multiple[((int16)readptr - 1) & 0x1FF][iHumanControlIdx].data.unInput) >> 8) < abs(pCar->iSteeringInput)) { + // if (!pCar->iSteeringInput + // || (iInput = (int16)copy_multiple[((int16)readptr - 1) & + // 0x1FF][iHumanControlIdx].data.unInput, + // llInputCheck = (iInput) >> 8, + // (int)((HIDWORD(llInputCheck) ^ llInputCheck) - + // HIDWORD(llInputCheck) - abs32(pCar->iSteeringInput)) < + // 0)) { + // TODO check this + if (!pCar->iSteeringInput || + abs((copy_multiple[((int16)readptr - 1) & 0x1FF] + [iHumanControlIdx] + .data.unInput) >> + 8) < abs(pCar->iSteeringInput)) { iCurrentYawForInput = pCar->nYaw; iYaw3ForInput = pCar->nActualYaw; if (iCurrentYawForInput != iYaw3ForInput) { - iHumanYawDiff = iCurrentYawForInput - iYaw3ForInput + (iCurrentYawForInput - iYaw3ForInput < 0 ? 0x4000 : 0); + iHumanYawDiff = + iCurrentYawForInput - iYaw3ForInput + + (iCurrentYawForInput - iYaw3ForInput < 0 ? 0x4000 : 0); if (iHumanYawDiff > 0x2000) iHumanYawDiff -= 0x4000; if ((double)iHumanYawDiff > fMaxGripLimit) { @@ -2945,27 +3446,32 @@ void updatecar2(tCar *pCar) } nYawAdjusted = pCar->nYaw - iHumanYawDiff; nYawAdjusted &= 0x3FFF; - //HIBYTE(nYawAdjusted) &= 0x3Fu; + // HIBYTE(nYawAdjusted) &= 0x3Fu; pCar->nYaw = nYawAdjusted; } } } } } - if (pCar->iStunned && pCar->iControlType == 3 || (pCar->byStatusFlags & 4) != 0)// Apply speed reduction when car is stunned or has damage status + if (pCar->iStunned && pCar->iControlType == 3 || + (pCar->byStatusFlags & 4) != 0) // Apply speed reduction when car is + // stunned or has damage status { pCar->fFinalSpeed = pCar->fFinalSpeed + -2.0f; if (pCar->fFinalSpeed < 0.0) pCar->fFinalSpeed = 0.0; - //if (pCar->nTargetChunk == -1 && (LODWORD(pCar->fFinalSpeed) & 0x7FFFFFFF) == 0) + // if (pCar->nTargetChunk == -1 && (LODWORD(pCar->fFinalSpeed) & + // 0x7FFFFFFF) == 0) if (pCar->nTargetChunk == -1 && fabs(pCar->fFinalSpeed) == 0) pCar->nTargetChunk = 72; SetEngine(pCar, pCar->fFinalSpeed); - //if (((LODWORD(pCar->fFinalSpeed) & 0x7FFFFFFF) == 0 || (LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && pCar->nDeathTimer < -54) - if ((fabs(pCar->fFinalSpeed) == 0 || fabs(pCar->fHealth) == 0 && pCar->nDeathTimer < -54) - && !pCar->iPitchCameraOffset - && !pCar->iRollCameraOffset - && !pCar->nTargetChunk) { + // if (((LODWORD(pCar->fFinalSpeed) & 0x7FFFFFFF) == 0 || + // (LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && pCar->nDeathTimer < + // -54) + if ((fabs(pCar->fFinalSpeed) == 0 || + fabs(pCar->fHealth) == 0 && pCar->nDeathTimer < -54) && + !pCar->iPitchCameraOffset && !pCar->iRollCameraOffset && + !pCar->nTargetChunk) { checkplacement(pCar); } } @@ -2974,14 +3480,17 @@ void updatecar2(tCar *pCar) pCar->nTargetChunk = nTargetChunk - 1; goto LABEL_502; } - //LODWORD(fCameraOscillationRange) = 6 * iSteeringInputProcessed; - dSteeringSpeedCalc = (double)(6 * iSteeringInputProcessed) * (360.0 - fAbsoluteSpeed) * 0.00027777778 + (double)iSteeringInputProcessed; + // LODWORD(fCameraOscillationRange) = 6 * iSteeringInputProcessed; + dSteeringSpeedCalc = (double)(6 * iSteeringInputProcessed) * + (360.0 - fAbsoluteSpeed) * 0.00027777778 + + (double)iSteeringInputProcessed; } //_CHP(); iSteeringInputProcessed = (int)dSteeringSpeedCalc; goto LABEL_272; } - //if (pCar->nTargetChunk == -1 && (LODWORD(fAbsoluteSpeed) & 0x7FFFFFFF) == 0) + // if (pCar->nTargetChunk == -1 && (LODWORD(fAbsoluteSpeed) & 0x7FFFFFFF) == + // 0) if (pCar->nTargetChunk == -1 && fabs(fAbsoluteSpeed) == 0) pCar->nTargetChunk = 144; nTargetChunkLocal = pCar->nTargetChunk; @@ -2990,22 +3499,35 @@ void updatecar2(tCar *pCar) iYaw3ForType2 = iYaw3; pCar->pos.fX = pCar->fFinalSpeed * tcos[iYaw3] + pCar->pos.fX; pCar->pos.fY = pCar->fFinalSpeed * tsin[iYaw3ForType2] + pCar->pos.fY; - calculateseparatedcoordinatesystem(pCar->iLastValidChunk, &coordinateSystemData);// Transform car coordinates to track coordinate system + calculateseparatedcoordinatesystem( + pCar->iLastValidChunk, + &coordinateSystemData); // Transform car coordinates to track coordinate + // system dCoordY = pCar->pos.fY + coordinateSystemData.pointAy[3].fY; dCoordX = pCar->pos.fX + coordinateSystemData.pointAy[3].fX; dCoordZ = pCar->pos.fZ + coordinateSystemData.pointAy[3].fZ; - fCoordTransformX = (float)(coordinateSystemData.pointAy[1].fX * dCoordY + coordinateSystemData.pointAy[0].fX * dCoordX + coordinateSystemData.pointAy[2].fX * dCoordZ); - fCoordTransformY = (float)(coordinateSystemData.pointAy[1].fY * dCoordY + coordinateSystemData.pointAy[0].fY * dCoordX + coordinateSystemData.pointAy[2].fY * dCoordZ); + fCoordTransformX = (float)(coordinateSystemData.pointAy[1].fX * dCoordY + + coordinateSystemData.pointAy[0].fX * dCoordX + + coordinateSystemData.pointAy[2].fX * dCoordZ); + fCoordTransformY = (float)(coordinateSystemData.pointAy[1].fY * dCoordY + + coordinateSystemData.pointAy[0].fY * dCoordX + + coordinateSystemData.pointAy[2].fY * dCoordZ); iChunkPlus2 = pCar->iLastValidChunk + 2; iChunkPlus3 = pCar->iLastValidChunk + 3; - fCoordTransformZ = (float)(dCoordY * coordinateSystemData.pointAy[1].fZ + dCoordX * coordinateSystemData.pointAy[0].fZ + dCoordZ * coordinateSystemData.pointAy[2].fZ); + fCoordTransformZ = (float)(dCoordY * coordinateSystemData.pointAy[1].fZ + + dCoordX * coordinateSystemData.pointAy[0].fZ + + dCoordZ * coordinateSystemData.pointAy[2].fZ); if (iChunkPlus3 >= TRAK_LEN) iChunkPlus3 -= TRAK_LEN; if (iChunkPlus2 >= TRAK_LEN) iChunkPlus2 -= TRAK_LEN; - dGroundHeightForward = (GroundPt[iChunkPlus2].pointAy[2].fZ + GroundPt[iChunkPlus2].pointAy[3].fZ + GroundPt[iChunkPlus3].pointAy[2].fZ + GroundPt[iChunkPlus3].pointAy[3].fZ) - * 0.25; // Check ground height ahead to prevent impossible jumps - dGroundHeightForward = floor(dGroundHeightForward);//_CHP(); + dGroundHeightForward = + (GroundPt[iChunkPlus2].pointAy[2].fZ + + GroundPt[iChunkPlus2].pointAy[3].fZ + + GroundPt[iChunkPlus3].pointAy[2].fZ + + GroundPt[iChunkPlus3].pointAy[3].fZ) * + 0.25; // Check ground height ahead to prevent impossible jumps + dGroundHeightForward = floor(dGroundHeightForward); //_CHP(); if (dGroundHeightForward > GroundLevel[iChunkPlus2] + 20.0) pCar->fFinalSpeed = 0.0; iChunkMinus1 = pCar->iLastValidChunk - 1; @@ -3014,25 +3536,39 @@ void updatecar2(tCar *pCar) iChunkMinus1 += TRAK_LEN; if (iChunkMinus2 < 0) iChunkMinus2 += TRAK_LEN; - dGroundHeightBackward = (GroundPt[iChunkMinus2].pointAy[2].fZ - + GroundPt[iChunkMinus2].pointAy[3].fZ - + GroundPt[iChunkMinus1].pointAy[2].fZ - + GroundPt[iChunkMinus1].pointAy[3].fZ) - * 0.25; - dGroundHeightBackward = floor(dGroundHeightBackward);//_CHP(); + dGroundHeightBackward = (GroundPt[iChunkMinus2].pointAy[2].fZ + + GroundPt[iChunkMinus2].pointAy[3].fZ + + GroundPt[iChunkMinus1].pointAy[2].fZ + + GroundPt[iChunkMinus1].pointAy[3].fZ) * + 0.25; + dGroundHeightBackward = floor(dGroundHeightBackward); //_CHP(); if (dGroundHeightBackward > GroundLevel[iChunkMinus2] + 20.0) pCar->fFinalSpeed = 0.0; if (fCoordTransformY <= 0.0) { - fGroundAverageZ1 = (GroundPt[pCar->iLastValidChunk].pointAy[3].fY + coordinateSystemData.pointAy[3].fY) * coordinateSystemData.pointAy[1].fY - + (GroundPt[pCar->iLastValidChunk].pointAy[3].fX + coordinateSystemData.pointAy[3].fX) * coordinateSystemData.pointAy[0].fY - + (GroundPt[pCar->iLastValidChunk].pointAy[3].fZ + coordinateSystemData.pointAy[3].fZ) * coordinateSystemData.pointAy[2].fY;// Calculate track boundary limits for airborne cars + fGroundAverageZ1 = + (GroundPt[pCar->iLastValidChunk].pointAy[3].fY + + coordinateSystemData.pointAy[3].fY) * + coordinateSystemData.pointAy[1].fY + + (GroundPt[pCar->iLastValidChunk].pointAy[3].fX + + coordinateSystemData.pointAy[3].fX) * + coordinateSystemData.pointAy[0].fY + + (GroundPt[pCar->iLastValidChunk].pointAy[3].fZ + + coordinateSystemData.pointAy[3].fZ) * + coordinateSystemData.pointAy[2] + .fY; // Calculate track boundary limits for airborne cars if (fCoordTransformY - CarBaseX >= fGroundAverageZ1) goto LABEL_493; dBoundaryLimit = fGroundAverageZ1 + CarBaseX; } else { - fGroundBoundaryY = (GroundPt[pCar->iLastValidChunk].pointAy[2].fY + coordinateSystemData.pointAy[3].fY) * coordinateSystemData.pointAy[1].fY - + (GroundPt[pCar->iLastValidChunk].pointAy[2].fX + coordinateSystemData.pointAy[3].fX) * coordinateSystemData.pointAy[0].fY - + (GroundPt[pCar->iLastValidChunk].pointAy[2].fZ + coordinateSystemData.pointAy[3].fZ) * coordinateSystemData.pointAy[2].fY; + fGroundBoundaryY = (GroundPt[pCar->iLastValidChunk].pointAy[2].fY + + coordinateSystemData.pointAy[3].fY) * + coordinateSystemData.pointAy[1].fY + + (GroundPt[pCar->iLastValidChunk].pointAy[2].fX + + coordinateSystemData.pointAy[3].fX) * + coordinateSystemData.pointAy[0].fY + + (GroundPt[pCar->iLastValidChunk].pointAy[2].fZ + + coordinateSystemData.pointAy[3].fZ) * + coordinateSystemData.pointAy[2].fY; if (fCoordTransformY + CarBaseX <= fGroundBoundaryY) goto LABEL_493; dBoundaryLimit = fGroundBoundaryY - CarBaseX; @@ -3043,34 +3579,38 @@ void updatecar2(tCar *pCar) dTransformedY = fCoordTransformY; dTransformedX = fCoordTransformX; dTransformedZ = fCoordTransformZ; - pCar->pos.fX = (float)(coordinateSystemData.pointAy[0].fY * fCoordTransformY - + coordinateSystemData.pointAy[0].fX * fCoordTransformX - + coordinateSystemData.pointAy[0].fZ * fCoordTransformZ - - coordinateSystemData.pointAy[3].fX); - pCar->pos.fY = (float)(coordinateSystemData.pointAy[1].fX * dTransformedX - + coordinateSystemData.pointAy[1].fY * dTransformedY - + coordinateSystemData.pointAy[1].fZ * dTransformedZ - - coordinateSystemData.pointAy[3].fY); - pCar->pos.fZ = (float)(dTransformedY * coordinateSystemData.pointAy[2].fY - + dTransformedX * coordinateSystemData.pointAy[2].fX - + dTransformedZ * coordinateSystemData.pointAy[2].fZ - - coordinateSystemData.pointAy[3].fZ); + pCar->pos.fX = (float)(coordinateSystemData.pointAy[0].fY * fCoordTransformY + + coordinateSystemData.pointAy[0].fX * fCoordTransformX + + coordinateSystemData.pointAy[0].fZ * fCoordTransformZ - + coordinateSystemData.pointAy[3].fX); + pCar->pos.fY = (float)(coordinateSystemData.pointAy[1].fX * dTransformedX + + coordinateSystemData.pointAy[1].fY * dTransformedY + + coordinateSystemData.pointAy[1].fZ * dTransformedZ - + coordinateSystemData.pointAy[3].fY); + pCar->pos.fZ = (float)(dTransformedY * coordinateSystemData.pointAy[2].fY + + dTransformedX * coordinateSystemData.pointAy[2].fX + + dTransformedZ * coordinateSystemData.pointAy[2].fZ - + coordinateSystemData.pointAy[3].fZ); findnearsection(pCar, &iNearestChunk); pCar->fFinalSpeed = pCar->fFinalSpeed + -6.0f; if (pCar->fFinalSpeed < 0.0) pCar->fFinalSpeed = 0.0; fCurrentSpeedFloat = fAbsoluteSpeed; SetEngine(pCar, pCar->fFinalSpeed); - //if (((LODWORD(fCurrentSpeedFloat) & 0x7FFFFFFF) == 0 || (LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && pCar->nDeathTimer < -54) - if ((fabs(fCurrentSpeedFloat) == 0 || fabs(pCar->fHealth) == 0 && pCar->nDeathTimer < -54) - && !pCar->iPitchCameraOffset - && !pCar->iRollCameraOffset - && !pCar->nTargetChunk) { + // if (((LODWORD(fCurrentSpeedFloat) & 0x7FFFFFFF) == 0 || + // (LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && pCar->nDeathTimer < -54) + if ((fabs(fCurrentSpeedFloat) == 0 || + fabs(pCar->fHealth) == 0 && pCar->nDeathTimer < -54) && + !pCar->iPitchCameraOffset && !pCar->iRollCameraOffset && + !pCar->nTargetChunk) { LABEL_501: checkplacement(pCar); } LABEL_502: - if (!pCar->iControlType && pCar->pos.fZ < (double)GroundLevel[pCar->iLastValidChunk] && (char)pCar->byLives > 0) { // Handle fall damage and car landing after being airborne + if (!pCar->iControlType && + pCar->pos.fZ < (double)GroundLevel[pCar->iLastValidChunk] && + (char)pCar->byLives > + 0) { // Handle fall damage and car landing after being airborne if (death_race) dFallDamage = fabs(pCar->direction.fZ) * 0.05 * 4.0; else @@ -3105,7 +3645,9 @@ void updatecar2(tCar *pCar) pCar->iRollDampingMomentum = iRoll; pCar->iRollCameraOffset = iRoll; } - if (!finished_car[pCar->iDriverIdx] && pCar->fRunningLapTime < 1000.0)// Update lap timing - running lap time and total race time + if (!finished_car[pCar->iDriverIdx] && + pCar->fRunningLapTime < + 1000.0) // Update lap timing - running lap time and total race time { if (race_started) { pCar->fRunningLapTime = pCar->fRunningLapTime + 0.02777777777777778f; @@ -3117,67 +3659,68 @@ void updatecar2(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//0002F040 -void check_crossed_line(tCar *pCar) -{ - int iDriverIdx; // eax - int16 nCurrChunk; // dx - int iRacers; // edx - int iRacePosition; // eax - int iCurrentChunk; // edx - int iChunk2; // eax - int byLap; // edx - int iChampMode; // esi - int iDriverIdx2; // eax - int iTargetDriverIdx; // edx - int iRacePos; // eax - int iTargetCar; // ebx - tCarEngine *pEngine; // eax - int8 byMaxGear; // dl - double dPowerCalc; // st7 - int iSoundSample1; // ecx - int iHumanControl1; // edx - int iDriverIdx3; // esi - uint8 byRacePosition; // dl - int iDriverIdx4; // ebx - int iCarDesignIdx; // edx - char *szDriverName; // esi - char *szRecordName; // edi - char cChar1; // al - char cChar2; // al - int iFastestLapFlag; // esi - int iCarCounter; // edx - int iCarOrderIdx; // eax - int iDriverIdx5; // edx - int iDriverIdx6; // ebx - uint8 byRacePos2; // bl - int iSoundSample2; // eax - int iDriverIdx7; // ecx +// 0002F040 +void check_crossed_line(tCar *pCar) { + int iDriverIdx; // eax + int16 nCurrChunk; // dx + int iRacers; // edx + int iRacePosition; // eax + int iCurrentChunk; // edx + int iChunk2; // eax + int byLap; // edx + int iChampMode; // esi + int iDriverIdx2; // eax + int iTargetDriverIdx; // edx + int iRacePos; // eax + int iTargetCar; // ebx + tCarEngine *pEngine; // eax + int8 byMaxGear; // dl + double dPowerCalc; // st7 + int iSoundSample1; // ecx + int iHumanControl1; // edx + int iDriverIdx3; // esi + uint8 byRacePosition; // dl + int iDriverIdx4; // ebx + int iCarDesignIdx; // edx + char *szDriverName; // esi + char *szRecordName; // edi + char cChar1; // al + char cChar2; // al + int iFastestLapFlag; // esi + int iCarCounter; // edx + int iCarOrderIdx; // eax + int iDriverIdx5; // edx + int iDriverIdx6; // ebx + uint8 byRacePos2; // bl + int iSoundSample2; // eax + int iDriverIdx7; // ecx double dRunningLapTime; // st7 - int iFinishersCount1; // eax - int iDriverIdx8; // eax - int iHumanControl2; // ebx - int iDriverIdx9; // esi - uint8 byRacePos3; // al - int iSoundSample3; // eax - int iFinishersCount2; // eax - int iDriverIdx10; // eax - int v44; // edx - int iDriverIdx11; // ecx - uint8 byRacePos4; // bh - int iSoundSample4; // eax - int iSoundSample5; // [esp+0h] [ebp-20h] - int iSoundSample6; // [esp+4h] [ebp-1Ch] + int iFinishersCount1; // eax + int iDriverIdx8; // eax + int iHumanControl2; // ebx + int iDriverIdx9; // esi + uint8 byRacePos3; // al + int iSoundSample3; // eax + int iFinishersCount2; // eax + int iDriverIdx10; // eax + int v44; // edx + int iDriverIdx11; // ecx + uint8 byRacePos4; // bh + int iSoundSample4; // eax + int iSoundSample5; // [esp+0h] [ebp-20h] + int iSoundSample6; // [esp+4h] [ebp-1Ch] if (champ_mode) { iDriverIdx = pCar->iDriverIdx; - if (champ_go[iDriverIdx]) // Check if this driver has championship go flag set + if (champ_go[iDriverIdx]) // Check if this driver has championship go flag + // set { nCurrChunk = pCar->nCurrChunk; - if (nCurrChunk > 16 && nCurrChunk < 64) // Check if car is in early race chunk range (after start line) + if (nCurrChunk > 16 && nCurrChunk < 64) // Check if car is in early race + // chunk range (after start line) { iRacers = racers; - champ_go[iDriverIdx] = 0; // Clear championship go flag for this driver + champ_go[iDriverIdx] = 0; // Clear championship go flag for this driver iRacePosition = pCar->byRacePosition; if (iRacePosition < iRacers - 1) { champ_zoom = 0; @@ -3187,39 +3730,44 @@ void check_crossed_line(tCar *pCar) } } } - iCurrentChunk = pCar->nCurrChunk; // Check if car has valid current chunk position + iCurrentChunk = + pCar->nCurrChunk; // Check if car has valid current chunk position if (iCurrentChunk != -1) { iChunk2 = pCar->nReferenceChunk; - if (iChunk2 != -1) { // Detect forward lap line crossing (crossed finish line going forward) - if (iChunk2 - iCurrentChunk > TRAK_LEN / 2 && !finished_car[pCar->iDriverIdx]) { // Check if lap count matches expected lap number + if (iChunk2 != -1) { // Detect forward lap line crossing (crossed finish + // line going forward) + if (iChunk2 - iCurrentChunk > TRAK_LEN / 2 && + !finished_car[pCar->iDriverIdx]) { // Check if lap count matches + // expected lap number if (pCar->byLap == pCar->byLapNumber) { byLap = pCar->byLap; - if (byLap <= NoOfLaps) { // Record lap time for trial mode (game_type == 2) + if (byLap <= + NoOfLaps) { // Record lap time for trial mode (game_type == 2) if (game_type == 2) trial_times[6 * pCar->iDriverIdx + byLap] = pCar->fRunningLapTime; iChampMode = champ_mode; - ++pCar->byLap; // Increment lap counter - if (iChampMode) { // Handle championship mode camera switching + ++pCar->byLap; // Increment lap counter + if (iChampMode) { // Handle championship mode camera switching if (champ_car) { iTargetDriverIdx = pCar->iDriverIdx; if (ViewType[0] == iTargetDriverIdx) { - iRacePos = 0;// iTargetDriverIdx ^ViewType[0]; + iRacePos = 0; // iTargetDriverIdx ^ViewType[0]; iRacePos = pCar->byRacePosition; - //LOBYTE(iRacePos) = pCar->byRacePosition; + // LOBYTE(iRacePos) = pCar->byRacePosition; if (iRacePos < racers - 1) { iTargetCar = carorder[iRacePos + 1]; champ_go[iTargetCar] = -1; - //iTargetCar *= sizeof(tCar); - pEngine = &CarEngines.engines[Car[iTargetCar].byCarDesignIdx]; + // iTargetCar *= sizeof(tCar); + pEngine = + &CarEngines.engines[Car[iTargetCar].byCarDesignIdx]; Car[iTargetCar].fRPMRatio = 1.0; byMaxGear = (uint8)(pEngine->iNumGears) - 1; Car[iTargetCar].byGearAyMax = byMaxGear; Car[iTargetCar].fFinalSpeed = pEngine->pSpds[byMaxGear]; Car[iTargetCar].fBaseSpeed = Car[iTargetCar].fFinalSpeed; - dPowerCalc = calc_pow( - Car[iTargetCar].byCarDesignIdx, - Car[iTargetCar].byGearAyMax, - Car[iTargetCar].fRPMRatio); + dPowerCalc = calc_pow(Car[iTargetCar].byCarDesignIdx, + Car[iTargetCar].byGearAyMax, + Car[iTargetCar].fRPMRatio); Car[iTargetCar].fSpeedOverflow = 0.0; Car[iTargetCar].byEngineStartTimer = 36; Car[iTargetCar].byThrottlePressed = -1; @@ -3235,31 +3783,39 @@ void check_crossed_line(tCar *pCar) iSoundSample1 = -1; iSoundSample5 = -1; iSoundSample6 = -1; - if (pCar->byLap > NoOfLaps && NoOfLaps)// Check if race is finished (exceeded total lap count) + if (pCar->byLap > NoOfLaps && + NoOfLaps) // Check if race is finished (exceeded total lap + // count) { - finished_car[pCar->iDriverIdx] = -1;// Mark car as finished and increment finisher count + finished_car[pCar->iDriverIdx] = + -1; // Mark car as finished and increment finisher count iHumanControl1 = human_control[pCar->iDriverIdx]; ++finishers; if (iHumanControl1) ++human_finishers; iDriverIdx3 = pCar->iDriverIdx; - if (player1_car == iDriverIdx3 || player2_car == iDriverIdx3)// Handle finish sounds for player cars based on position + if (player1_car == iDriverIdx3 || + player2_car == iDriverIdx3) // Handle finish sounds for player + // cars based on position { if ((char)pCar->byLives > 0) { byRacePosition = pCar->byRacePosition; if (byRacePosition) { if (byRacePosition >= 3u) { if (byRacePosition >= 0xDu) - iSoundSample6 = SOUND_SAMPLE_RUBBISH; // SOUND_SAMPLE_RUBBISH + iSoundSample6 = + SOUND_SAMPLE_RUBBISH; // SOUND_SAMPLE_RUBBISH else - iSoundSample6 = SOUND_SAMPLE_POOR; // SOUND_SAMPLE_POOR + iSoundSample6 = SOUND_SAMPLE_POOR; // SOUND_SAMPLE_POOR } else { - iSoundSample6 = SOUND_SAMPLE_HARDER; // SOUND_SAMPLE_HARDER + iSoundSample6 = + SOUND_SAMPLE_HARDER; // SOUND_SAMPLE_HARDER } } else { - iSoundSample6 = SOUND_SAMPLE_WINNER; // SOUND_SAMPLE_WINNER + iSoundSample6 = SOUND_SAMPLE_WINNER; // SOUND_SAMPLE_WINNER } - iSoundSample5 = SOUND_SAMPLE_RACEOVER; // SOUND_SAMPLE_RACEOVER + iSoundSample5 = + SOUND_SAMPLE_RACEOVER; // SOUND_SAMPLE_RACEOVER } } else if (player_type != 2) { if (pCar->byRacePosition) @@ -3269,18 +3825,24 @@ void check_crossed_line(tCar *pCar) subzoom(driver_names[pCar->iDriverIdx]); } } - if (pCar->fRunningLapTime < (double)pCar->fBestLapTime && pCar->byLap > 1)// Check if this lap is a new personal best + if (pCar->fRunningLapTime < (double)pCar->fBestLapTime && + pCar->byLap > 1) // Check if this lap is a new personal best { pCar->fBestLapTime = pCar->fRunningLapTime; - if (pCar->fBestLapTime >= (double)RecordLaps[game_track])// Check if lap time beats track record + if (pCar->fBestLapTime >= + (double)RecordLaps[game_track]) // Check if lap time beats + // track record { iFastestLapFlag = -1; - if (racers > 0) // Check if this is fastest lap among all drivers + if (racers > + 0) // Check if this is fastest lap among all drivers { iCarCounter = 0; do { iCarOrderIdx = carorder[iCarCounter]; - if (iCarOrderIdx != pCar->iDriverIdx && Car[iCarOrderIdx].fBestLapTime <= (double)pCar->fBestLapTime) + if (iCarOrderIdx != pCar->iDriverIdx && + Car[iCarOrderIdx].fBestLapTime <= + (double)pCar->fBestLapTime) iFastestLapFlag = 0; ++iCarCounter; } while (iCarCounter < racers); @@ -3294,7 +3856,8 @@ void check_crossed_line(tCar *pCar) iSoundSample1 = 39; } } else if (iFastestLapFlag && pCar->byLap > 2) { - sprintf(buffer, "%s %s", &language_buffer[2880], driver_names[iDriverIdx5]); + sprintf(buffer, "%s %s", &language_buffer[2880], + driver_names[iDriverIdx5]); small_zoom(buffer); make_time(buffer, pCar->fBestLapTime); subzoom(buffer); @@ -3307,7 +3870,8 @@ void check_crossed_line(tCar *pCar) else iSoundSample1 = 38; } else if (pCar->byLap > 2) { - sprintf(buffer, "%s %s", &language_buffer[2752], driver_names[iDriverIdx4]); + sprintf(buffer, "%s %s", &language_buffer[2752], + driver_names[iDriverIdx4]); small_zoom(buffer); make_time(buffer, pCar->fBestLapTime); subzoom(buffer); @@ -3340,51 +3904,56 @@ void check_crossed_line(tCar *pCar) speechsample(iSoundSample5, 0x8000, 18, pCar->iDriverIdx); if (pCar->byLap != 1) { iDriverIdx6 = pCar->iDriverIdx; - if ((player1_car == iDriverIdx6 || player2_car == iDriverIdx6) && finishers - Destroyed <= 0 && !finished_car[pCar->iDriverIdx] && competitors > 1) { // Announce remaining laps to player cars + if ((player1_car == iDriverIdx6 || player2_car == iDriverIdx6) && + finishers - Destroyed <= 0 && + !finished_car[pCar->iDriverIdx] && + competitors > 1) { // Announce remaining laps to player cars switch (NoOfLaps - pCar->byLap) { - case 0: - byRacePos2 = pCar->byRacePosition; - if (byRacePos2) { - if (byRacePos2 >= 5u) { - if (!SamplePtr[16]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_FINAL1; // SOUND_SAMPLE_FINAL1 - } else { - if (!SamplePtr[17]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_FINAL2; // SOUND_SAMPLE_FINAL2 - } - break; + case 0: + byRacePos2 = pCar->byRacePosition; + if (byRacePos2) { + if (byRacePos2 >= 5u) { + if (!SamplePtr[16]) + goto LABEL_102; + iSoundSample2 = + SOUND_SAMPLE_FINAL1; // SOUND_SAMPLE_FINAL1 + } else { + if (!SamplePtr[17]) + goto LABEL_102; + iSoundSample2 = + SOUND_SAMPLE_FINAL2; // SOUND_SAMPLE_FINAL2 } - if (!SamplePtr[18]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_FINAL3; // SOUND_SAMPLE_FINAL3 - iDriverIdx7 = pCar->iDriverIdx; - goto LABEL_104; - case 1: - if (!SamplePtr[53]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_2LAPS; // SOUND_SAMPLE_2LAPS - break; - case 2: - if (!SamplePtr[54]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_3LAPS; // SOUND_SAMPLE_3LAPS - break; - case 3: - if (!SamplePtr[55]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_4LAPS; // SOUND_SAMPLE_4LAPS - break; - case 4: - if (!SamplePtr[56]) - goto LABEL_102; - iSoundSample2 = SOUND_SAMPLE_5LAPS; // SOUND_SAMPLE_5LAPS - break; - default: - LABEL_102: - iSoundSample2 = SOUND_SAMPLE_KEEPGO; // SOUND_SAMPLE_KEEPGO break; + } + if (!SamplePtr[18]) + goto LABEL_102; + iSoundSample2 = SOUND_SAMPLE_FINAL3; // SOUND_SAMPLE_FINAL3 + iDriverIdx7 = pCar->iDriverIdx; + goto LABEL_104; + case 1: + if (!SamplePtr[53]) + goto LABEL_102; + iSoundSample2 = SOUND_SAMPLE_2LAPS; // SOUND_SAMPLE_2LAPS + break; + case 2: + if (!SamplePtr[54]) + goto LABEL_102; + iSoundSample2 = SOUND_SAMPLE_3LAPS; // SOUND_SAMPLE_3LAPS + break; + case 3: + if (!SamplePtr[55]) + goto LABEL_102; + iSoundSample2 = SOUND_SAMPLE_4LAPS; // SOUND_SAMPLE_4LAPS + break; + case 4: + if (!SamplePtr[56]) + goto LABEL_102; + iSoundSample2 = SOUND_SAMPLE_5LAPS; // SOUND_SAMPLE_5LAPS + break; + default: + LABEL_102: + iSoundSample2 = SOUND_SAMPLE_KEEPGO; // SOUND_SAMPLE_KEEPGO + break; } iDriverIdx7 = pCar->iDriverIdx; LABEL_104: @@ -3407,27 +3976,32 @@ void check_crossed_line(tCar *pCar) if (iHumanControl2) ++human_finishers; iDriverIdx9 = pCar->iDriverIdx; - if ((player1_car == iDriverIdx9 || player2_car == iDriverIdx9) && (char)pCar->byLives > 0) { + if ((player1_car == iDriverIdx9 || player2_car == iDriverIdx9) && + (char)pCar->byLives > 0) { byRacePos3 = pCar->byRacePosition; if (byRacePos3) { if (byRacePos3 >= 3u) { if (byRacePos3 >= 0xDu) - iSoundSample3 = SOUND_SAMPLE_RUBBISH; // SOUND_SAMPLE_RUBBISH + iSoundSample3 = + SOUND_SAMPLE_RUBBISH; // SOUND_SAMPLE_RUBBISH else - iSoundSample3 = SOUND_SAMPLE_POOR; // SOUND_SAMPLE_POOR + iSoundSample3 = SOUND_SAMPLE_POOR; // SOUND_SAMPLE_POOR } else { - iSoundSample3 = SOUND_SAMPLE_HARDER; // SOUND_SAMPLE_HARDER + iSoundSample3 = SOUND_SAMPLE_HARDER; // SOUND_SAMPLE_HARDER } } else { - iSoundSample3 = SOUND_SAMPLE_WINNER; // SOUND_SAMPLE_WINNER + iSoundSample3 = SOUND_SAMPLE_WINNER; // SOUND_SAMPLE_WINNER } speechsample(iSoundSample3, 0x8000, 18, pCar->iDriverIdx); - speechsample(SOUND_SAMPLE_RACEOVER, 0x8000, 18, pCar->iDriverIdx);// SOUND_SAMPLE_RACEOVER + speechsample(SOUND_SAMPLE_RACEOVER, 0x8000, 18, + pCar->iDriverIdx); // SOUND_SAMPLE_RACEOVER } } } } - if (pCar->nReferenceChunk - pCar->nCurrChunk < -TRAK_LEN / 2)// Detect backward lap line crossing (went backwards across finish line) + if (pCar->nReferenceChunk - pCar->nCurrChunk < + -TRAK_LEN / 2) // Detect backward lap line crossing (went backwards + // across finish line) { iFinishersCount2 = finishers; --pCar->byLapNumber; @@ -3440,92 +4014,107 @@ void check_crossed_line(tCar *pCar) if (v44) ++human_finishers; iDriverIdx11 = pCar->iDriverIdx; - if ((player1_car == iDriverIdx11 || player2_car == iDriverIdx11) && (char)pCar->byLives > 0) { + if ((player1_car == iDriverIdx11 || player2_car == iDriverIdx11) && + (char)pCar->byLives > 0) { byRacePos4 = pCar->byRacePosition; if (byRacePos4) { if (byRacePos4 >= 3u) { if (byRacePos4 >= 0xDu) - iSoundSample4 = SOUND_SAMPLE_RUBBISH; // SOUND_SAMPLE_RUBBISH + iSoundSample4 = + SOUND_SAMPLE_RUBBISH; // SOUND_SAMPLE_RUBBISH else - iSoundSample4 = SOUND_SAMPLE_POOR; // SOUND_SAMPLE_POOR + iSoundSample4 = SOUND_SAMPLE_POOR; // SOUND_SAMPLE_POOR } else { - iSoundSample4 = SOUND_SAMPLE_HARDER; // SOUND_SAMPLE_HARDER + iSoundSample4 = SOUND_SAMPLE_HARDER; // SOUND_SAMPLE_HARDER } } else { - iSoundSample4 = SOUND_SAMPLE_WINNER; // SOUND_SAMPLE_WINNER + iSoundSample4 = SOUND_SAMPLE_WINNER; // SOUND_SAMPLE_WINNER } speechsample(iSoundSample4, 0x8000, 18, pCar->iDriverIdx); - speechsample(SOUND_SAMPLE_RACEOVER, 0x8000, 18, pCar->iDriverIdx);// SOUND_SAMPLE_RACEOVER + speechsample(SOUND_SAMPLE_RACEOVER, 0x8000, 18, + pCar->iDriverIdx); // SOUND_SAMPLE_RACEOVER } } } } - if ((pCar->byLapNumber & 0x80u) != 0) // Prevent lap number underflow (reset to 0 if went negative) + if ((pCar->byLapNumber & 0x80u) != + 0) // Prevent lap number underflow (reset to 0 if went negative) pCar->byLapNumber = 0; } } } //------------------------------------------------------------------------------------------------- -//0002F920 -void checkplacement(tCar *pCar) -{ - int iRandValue; // eax - int iNewChunk; // edi - int iPlacementResult; // ebp - int16 nCurrChunk; // ax - int iRandValue2; // eax - unsigned int uiLaneType; // ebx - int iCarArrayIdx; // edx - int iChunkDiff; // ecx +// 0002F920 +void checkplacement(tCar *pCar) { + int iRandValue; // eax + int iNewChunk; // edi + int iPlacementResult; // ebp + int16 nCurrChunk; // ax + int iRandValue2; // eax + unsigned int uiLaneType; // ebx + int iCarArrayIdx; // edx + int iChunkDiff; // ecx int iNormalizedChunkDiff; // eax - double dLanePosition; // st7 - int iSelectedView; // eax - int iMaskedDriverIdx; // eax - int iMaskedViewType; // edx - int iCurrentChunk; // eax - tData *pDataAy; // eax - double dPosZ; // st7 - int iCurrentViewType; // eax - int iRespawnRand; // eax - int iCarLoopIdx; // edx - int iCarArrayIdx2; // eax - //int i; // eax + double dLanePosition; // st7 + int iSelectedView; // eax + int iMaskedDriverIdx; // eax + int iMaskedViewType; // edx + int iCurrentChunk; // eax + tData *pDataAy; // eax + double dPosZ; // st7 + int iCurrentViewType; // eax + int iRespawnRand; // eax + int iCarLoopIdx; // edx + int iCarArrayIdx2; // eax + // int i; // eax int iDriverIdx; // edi - //int iSprayOffset1; // eax + // int iSprayOffset1; // eax int iDriverIdx2; // edx - //int iSprayOffset2; // eax - int8 byPreviousLap; // ch - int iPlayer1Car; // eax + // int iSprayOffset2; // eax + int8 byPreviousLap; // ch + int iPlayer1Car; // eax int iCurrentDriverIdx; // edx - uint8 byLives; // al - int iSpeechSample; // eax - int iViewType; // eax - int iPlayerNum; // edx - int iCalcViewType; // eax - uint8 byUnk64; // dl - int16 iBackupChunk; // [esp+0h] [ebp-34h] - float fX; // [esp+4h] [ebp-30h] - float fY; // [esp+8h] [ebp-2Ch] - int iTempChunk; // [esp+10h] [ebp-24h] - int iRespawnChunk; // [esp+14h] [ebp-20h] - int iCarCounter; // [esp+18h] [ebp-1Ch] + uint8 byLives; // al + int iSpeechSample; // eax + int iViewType; // eax + int iPlayerNum; // edx + int iCalcViewType; // eax + uint8 byUnk64; // dl + int16 iBackupChunk; // [esp+0h] [ebp-34h] + float fX; // [esp+4h] [ebp-30h] + float fY; // [esp+8h] [ebp-2Ch] + int iTempChunk; // [esp+10h] [ebp-24h] + int iRespawnChunk; // [esp+14h] [ebp-20h] + int iCarCounter; // [esp+18h] [ebp-1Ch] - iRandValue = ROLLERrandRaw(); // Generate random chunk position near current chunk + iRandValue = + ROLLERrandRaw(); // Generate random chunk position near current chunk iNewChunk = GetHighOrderRand(10, iRandValue) + pCar->nReferenceChunk; if (iNewChunk >= TRAK_LEN) iNewChunk = TRAK_LEN - 1; if (iNewChunk == -1) iNewChunk = 0; - //if ((LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && !numstops)// Reset health to 100 if car has zero health and there's no pit boxes - if (fabs(pCar->fHealth) == 0 && !numstops)// Reset health to 100 if car has zero health and there's no pit boxes + // if ((LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0 && !numstops)// Reset health + // to 100 if car has zero health and there's no pit boxes + if (fabs(pCar->fHealth) == 0 && + !numstops) // Reset health to 100 if car has zero health and there's no + // pit boxes pCar->fHealth = 100.0; - //if ((LODWORD(pCar->fHealth) & 0x7FFFFFFF) != 0)// Handle placement for cars with health (alive cars) - if (fabs(pCar->fHealth) > FLT_EPSILON)// Handle placement for cars with health (alive cars) - { // Find a valid track chunk - while ((TrakColour[iNewChunk][0] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | SURFACE_FLAG_SKIP_RENDER)) != 0 - && (TrakColour[iNewChunk][1] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | SURFACE_FLAG_SKIP_RENDER)) != 0 - && (TrakColour[iNewChunk][2] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | SURFACE_FLAG_SKIP_RENDER)) != 0) { + // if ((LODWORD(pCar->fHealth) & 0x7FFFFFFF) != 0)// Handle placement for cars + // with health (alive cars) + if (fabs(pCar->fHealth) > + FLT_EPSILON) // Handle placement for cars with health (alive cars) + { // Find a valid track chunk + while ((TrakColour[iNewChunk][0] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | + SURFACE_FLAG_SKIP_RENDER)) != 0 && + (TrakColour[iNewChunk][1] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | + SURFACE_FLAG_SKIP_RENDER)) != 0 && + (TrakColour[iNewChunk][2] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | + SURFACE_FLAG_SKIP_RENDER)) != 0) { if (++iNewChunk == TRAK_LEN) iNewChunk ^= TRAK_LEN; } @@ -3538,15 +4127,19 @@ void checkplacement(tCar *pCar) iBackupChunk = nCurrChunk; pCar->nCurrChunk = iNewChunk; do { - iRandValue2 = ROLLERrandRaw(); // Generate random lane (0-2) + iRandValue2 = ROLLERrandRaw(); // Generate random lane (0-2) uiLaneType = GetHighOrderRand(3, iRandValue2); - } while ((TrakColour[iNewChunk][uiLaneType] & (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | SURFACE_FLAG_SKIP_RENDER)) != 0); + } while ((TrakColour[iNewChunk][uiLaneType] & + (SURFACE_FLAG_NO_SPAWN | SURFACE_FLAG_PIT | SURFACE_FLAG_WALL_22 | + SURFACE_FLAG_SKIP_RENDER)) != 0); iCarCounter = 0; - if (numcars > 0) // Check for collision with other cars in same lane + if (numcars > 0) // Check for collision with other cars in same lane { iCarArrayIdx = 0; do { - if (iCarCounter != pCar->iDriverIdx && Car[iCarArrayIdx].iControlType == 3 && uiLaneType == Car[iCarArrayIdx].iLaneType) { + if (iCarCounter != pCar->iDriverIdx && + Car[iCarArrayIdx].iControlType == 3 && + uiLaneType == Car[iCarArrayIdx].iLaneType) { iChunkDiff = iNewChunk - Car[iCarArrayIdx].nCurrChunk; iNormalizedChunkDiff = iChunkDiff; if (iChunkDiff < 0) @@ -3562,7 +4155,8 @@ void checkplacement(tCar *pCar) } if (!iPlacementResult) goto LABEL_39; - if (uiLaneType) // Set Y position based on lane type (0=left shoulder, 1=center, 2=right shoulder) + if (uiLaneType) // Set Y position based on lane type (0=left shoulder, + // 1=center, 2=right shoulder) { if (uiLaneType <= 1) { pCar->pos.fY = 0.0; @@ -3578,26 +4172,35 @@ void checkplacement(tCar *pCar) } if (uiLaneType != 2) goto LABEL_38; - dLanePosition = -localdata[iNewChunk].fTrackHalfWidth - TrackInfo[iNewChunk].fRShoulderWidth * 0.5f; + dLanePosition = -localdata[iNewChunk].fTrackHalfWidth - + TrackInfo[iNewChunk].fRShoulderWidth * 0.5f; } else { - dLanePosition = TrackInfo[iNewChunk].fLShoulderWidth * 0.5f + localdata[iNewChunk].fTrackHalfWidth; + dLanePosition = TrackInfo[iNewChunk].fLShoulderWidth * 0.5f + + localdata[iNewChunk].fTrackHalfWidth; } pCar->pos.fY = (float)dLanePosition; goto LABEL_38; } iPlacementResult = 0; - if ((network_on || (char)pCar->byLives > 0 || lastsample >= -144 || pCar->nDeathTimer >= -64) && (!network_on || (char)pCar->byLives > 0 || pCar->nDeathTimer >= 0)) { // Handle respawn for dead cars (health=0, has lives left) + if ((network_on || (char)pCar->byLives > 0 || lastsample >= -144 || + pCar->nDeathTimer >= -64) && + (!network_on || (char)pCar->byLives > 0 || + pCar->nDeathTimer >= + 0)) { // Handle respawn for dead cars (health=0, has lives left) if (pCar->nDeathTimer < 0 && (char)pCar->byLives > 0) { - iRespawnRand = ROLLERrandRaw(); // Randomly select a respawn stop position + iRespawnRand = ROLLERrandRaw(); // Randomly select a respawn stop position iPlacementResult = -1; iCarLoopIdx = 0; iRespawnChunk = stops[GetHighOrderRand(numstops, iRespawnRand)]; if (numcars > 0) { iCarArrayIdx2 = 0; do { - if (iCarLoopIdx != pCar->iDriverIdx && (char)Car[iCarArrayIdx2].byLives > 0 && Car[iCarArrayIdx2].iControlType == 3) { + if (iCarLoopIdx != pCar->iDriverIdx && + (char)Car[iCarArrayIdx2].byLives > 0 && + Car[iCarArrayIdx2].iControlType == 3) { iTempChunk = Car[iCarArrayIdx2].nCurrChunk; - if ((TrakColour[iTempChunk][Car[iCarArrayIdx2].iLaneType] & SURFACE_FLAG_PIT) != 0) { + if ((TrakColour[iTempChunk][Car[iCarArrayIdx2].iLaneType] & + SURFACE_FLAG_PIT) != 0) { if (iTempChunk == iRespawnChunk) iPlacementResult = 0; if (Car[iCarArrayIdx2].nCurrChunk - 1 == iRespawnChunk) @@ -3611,59 +4214,78 @@ void checkplacement(tCar *pCar) } while (iCarLoopIdx < numcars); } if (iPlacementResult) { - //TODO may need to look at this further + // TODO may need to look at this further for (int j = 0; j < 32; j++) CarSpray[pCar->iDriverIdx][j].fSize = 0.0f; - //for (i = 0; i != 352; car_texs_loaded[352 * pCar->iDriverIdx + 12 + i] = 0) - // i += 11; + // for (i = 0; i != 352; car_texs_loaded[352 * pCar->iDriverIdx + 12 + + // i] = 0) + // i += 11; if (player_type == 2) { iDriverIdx = pCar->iDriverIdx; if (player1_car == iDriverIdx) { // Clear iLifeTime for all CarSpray objects for driver 16 for (int j = 0; j < 32; j++) { - CarSpray[16][j].iLifeTime = 0; + CarSpray[16][j].iLifeTime = 0; } - //iSprayOffset1 = iDriverIdx ^ player1_car; - //do { - // iSprayOffset1 += 352; - // *(int *)((char *)&CarSpray[15][24].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][25].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][26].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][27].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][28].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][29].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][30].iLifeTime + iSprayOffset1) = 0; - // *(int *)((char *)&CarSpray[15][31].iLifeTime + iSprayOffset1) = 0; - //} while (iSprayOffset1 != 1408); + // iSprayOffset1 = iDriverIdx ^ player1_car; + // do { + // iSprayOffset1 += 352; + // *(int *)((char *)&CarSpray[15][24].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][25].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][26].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][27].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][28].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][29].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][30].iLifeTime + iSprayOffset1) = + // 0; + // *(int *)((char *)&CarSpray[15][31].iLifeTime + iSprayOffset1) = + // 0; + // } while (iSprayOffset1 != 1408); } iDriverIdx2 = pCar->iDriverIdx; if (player2_car == iDriverIdx2) { // Clear iLifeTime for all CarSpray objects for driver 17 for (int j = 0; j < 32; j++) { - CarSpray[17][j].iLifeTime = 0; + CarSpray[17][j].iLifeTime = 0; } - //iSprayOffset2 = iDriverIdx2 ^ player2_car; - //do { - // iSprayOffset2 += 352; - // *(int *)((char *)&CarSpray[16][24].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][25].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][26].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][27].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][28].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][29].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][30].iLifeTime + iSprayOffset2) = 0; - // *(int *)((char *)&CarSpray[16][31].iLifeTime + iSprayOffset2) = 0; - //} while (iSprayOffset2 != 1408); + // iSprayOffset2 = iDriverIdx2 ^ player2_car; + // do { + // iSprayOffset2 += 352; + // *(int *)((char *)&CarSpray[16][24].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][25].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][26].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][27].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][28].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][29].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][30].iLifeTime + iSprayOffset2) = + // 0; + // *(int *)((char *)&CarSpray[16][31].iLifeTime + iSprayOffset2) = + // 0; + // } while (iSprayOffset2 != 1408); } } - if (player1_car == pCar->iDriverIdx && SelectedView[0] != DeathView[0]) { + if (player1_car == pCar->iDriverIdx && + SelectedView[0] != DeathView[0]) { SelectedView[0] = DeathView[0]; DeathView[0] = -1; select_view(0); initcarview(ViewType[0], 0); } - if (player2_car == pCar->iDriverIdx && SelectedView[1] != DeathView[1]) { + if (player2_car == pCar->iDriverIdx && + SelectedView[1] != DeathView[1]) { SelectedView[1] = DeathView[1]; DeathView[1] = -1; select_view(1); @@ -3672,7 +4294,7 @@ void checkplacement(tCar *pCar) iNewChunk = iRespawnChunk; pCar->pos.fY = localdata[iRespawnChunk].fAILine1; if (pCar->nCurrChunk < stops[numstops - 1] - 10) { - //if (pCar->nCurrChunk < carorder[numstops + 15] - 10) { + // if (pCar->nCurrChunk < carorder[numstops + 15] - 10) { byPreviousLap = pCar->byLapNumber - 1; pCar->byLapNumber = byPreviousLap; if (byPreviousLap < 0) @@ -3682,25 +4304,27 @@ void checkplacement(tCar *pCar) iPlayer1Car = player1_car; iCurrentDriverIdx = pCar->iDriverIdx; pCar->byCheatAmmo = 8; - if (iPlayer1Car == iCurrentDriverIdx || player2_car == iCurrentDriverIdx) { + if (iPlayer1Car == iCurrentDriverIdx || + player2_car == iCurrentDriverIdx) { byLives = pCar->byLives; if (byLives) { if (byLives <= 1u) { - iSpeechSample = SOUND_SAMPLE_1LEFT; // SOUND_SAMPLE_1LEFT + iSpeechSample = SOUND_SAMPLE_1LEFT; // SOUND_SAMPLE_1LEFT } else { if (byLives != 2) goto LABEL_113; - iSpeechSample = SOUND_SAMPLE_2LEFT; // SOUND_SAMPLE_2LEFT + iSpeechSample = SOUND_SAMPLE_2LEFT; // SOUND_SAMPLE_2LEFT } } else { - iSpeechSample = SOUND_SAMPLE_0LEFT; // SOUND_SAMPLE_0LEFT + iSpeechSample = SOUND_SAMPLE_0LEFT; // SOUND_SAMPLE_0LEFT } speechsample(iSpeechSample, 0x8000, 18, pCar->iDriverIdx); } } } } else { - iSelectedView = SelectedView[0]; // Handle permanently dead cars (no lives left) + iSelectedView = + SelectedView[0]; // Handle permanently dead cars (no lives left) pCar->byLives = -1; if (iSelectedView == 7) { iMaskedDriverIdx = pCar->iDriverIdx & 0xFE; @@ -3722,9 +4346,14 @@ void checkplacement(tCar *pCar) pCar->pos.fZ = 1000.0f; } else { pDataAy = &localdata[iCurrentChunk]; - pCar->pos.fX = 0.0f * pDataAy->pointAy[0].fY + 0.0f * pDataAy->pointAy[0].fX + 0.0f * pDataAy->pointAy[0].fZ - pDataAy->pointAy[3].fX; - pCar->pos.fY = 0.0f * pDataAy->pointAy[1].fX + 0.0f * pDataAy->pointAy[1].fY + 0.0f * pDataAy->pointAy[1].fZ - pDataAy->pointAy[3].fY; - dPosZ = 0.0 * pDataAy->pointAy[2].fX + 0.0 * pDataAy->pointAy[2].fY + 0.0 * pDataAy->pointAy[2].fZ - pDataAy->pointAy[3].fZ + 1000.0; + pCar->pos.fX = 0.0f * pDataAy->pointAy[0].fY + + 0.0f * pDataAy->pointAy[0].fX + + 0.0f * pDataAy->pointAy[0].fZ - pDataAy->pointAy[3].fX; + pCar->pos.fY = 0.0f * pDataAy->pointAy[1].fX + + 0.0f * pDataAy->pointAy[1].fY + + 0.0f * pDataAy->pointAy[1].fZ - pDataAy->pointAy[3].fY; + dPosZ = 0.0 * pDataAy->pointAy[2].fX + 0.0 * pDataAy->pointAy[2].fY + + 0.0 * pDataAy->pointAy[2].fZ - pDataAy->pointAy[3].fZ + 1000.0; pCar->nReferenceChunk = pCar->nCurrChunk; pCar->pos.fZ = (float)dPosZ; } @@ -3737,13 +4366,17 @@ void checkplacement(tCar *pCar) pCar->fRPMRatio = 0.0; pCar->fPower = 0.0; if ((Car[iCurrentViewType].byLives & 0x80u) != 0) { - for (ViewType[0] = 0; !human_control[ViewType[0]] || (Car[ViewType[0]].byLives & 0x80u) != 0; ++ViewType[0]) + for (ViewType[0] = 0; !human_control[ViewType[0]] || + (Car[ViewType[0]].byLives & 0x80u) != 0; + ++ViewType[0]) ; initcarview(ViewType[0], 0); stopallsamples(); } if ((Car[ViewType[1]].byLives & 0x80u) != 0) { - for (ViewType[1] = 0; !human_control[ViewType[1]] || (Car[ViewType[1]].byLives & 0x80u) != 0; ++ViewType[1]) + for (ViewType[1] = 0; !human_control[ViewType[1]] || + (Car[ViewType[1]].byLives & 0x80u) != 0; + ++ViewType[1]) ; initcarview(ViewType[1], 0); stopallsamples(); @@ -3751,7 +4384,9 @@ void checkplacement(tCar *pCar) } } LABEL_113: - if (iPlacementResult && (char)pCar->byLives > 0)// Initialize car state after successful placement + if (iPlacementResult && + (char)pCar->byLives > + 0) // Initialize car state after successful placement { pCar->pos.fX = 0.0; pCar->pos.fZ = 0.0; @@ -3791,7 +4426,7 @@ void checkplacement(tCar *pCar) pCar->nReferenceChunk = iNewChunk; pCar->iPitchDynamicOffset = 0; pCar->iRollDynamicOffset = 0; - putflat(pCar); // Reset car to flat ground position and update camera views + putflat(pCar); // Reset car to flat ground position and update camera views pCar->iDamageState = 1 - pCar->iDamageState; if (Play_View == 1) { if ((ViewType[0] & 1) != 0) @@ -3822,9 +4457,8 @@ void checkplacement(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//00030200 -void testteaminit(tCar *pCar) -{ +// 00030200 +void testteaminit(tCar *pCar) { int iViewType; // eax if ((ViewType[0] & 1) != 0) @@ -3836,9 +4470,8 @@ void testteaminit(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//00030230 -void doteaminit() -{ +// 00030230 +void doteaminit() { int iViewType; // eax if ((ViewType[0] & 1) != 0) @@ -3849,38 +4482,39 @@ void doteaminit() } //------------------------------------------------------------------------------------------------- -//00030260 -void hitleft(tCar *pCar, int iSampleIdx, int iIsRightSide) -{ // Calculate maximum yaw change based on speed (capped at 500.0) - double dSpeedScale; // st7 - int iYaw3; // eax - int iCollisionAngle; // eax - double dDamageAmount; // st7 - double dVelX; // st7 - double dVelY; // st6 - int iAngleIdx; // eax - int iNewYaw; // eax - //int16 nFpuTemp1; // fps - double dAngleCalc; // st7 +// 00030260 +void hitleft(tCar *pCar, int iSampleIdx, + int iIsRightSide) { // Calculate maximum yaw change based on speed + // (capped at 500.0) + double dSpeedScale; // st7 + int iYaw3; // eax + int iCollisionAngle; // eax + double dDamageAmount; // st7 + double dVelX; // st7 + double dVelY; // st6 + int iAngleIdx; // eax + int iNewYaw; // eax + // int16 nFpuTemp1; // fps + double dAngleCalc; // st7 double dFinalSpeed; // st7 - int iReverseYaw; // eax - //int16 nFpuTemp2; // fps + int iReverseYaw; // eax + // int16 nFpuTemp2; // fps double dReverseAngle; // st7 - int iYawDiff; // edx - int iConstrainedYaw; // eax - int16 nNewYawValue; // ax - float fDamageFloat; // [esp+0h] [ebp-44h] - float fFinalSpeed; // [esp+0h] [ebp-44h] - float fNegVelX; // [esp+4h] [ebp-40h] - float fNegVelY; // [esp+18h] [ebp-2Ch] - int iMaxYawChange; // [esp+1Ch] [ebp-28h] - float fVelX; // [esp+20h] [ebp-24h] + int iYawDiff; // edx + int iConstrainedYaw; // eax + int16 nNewYawValue; // ax + float fDamageFloat; // [esp+0h] [ebp-44h] + float fFinalSpeed; // [esp+0h] [ebp-44h] + float fNegVelX; // [esp+4h] [ebp-40h] + float fNegVelY; // [esp+18h] [ebp-2Ch] + int iMaxYawChange; // [esp+1Ch] [ebp-28h] + float fVelX; // [esp+20h] [ebp-24h] float fTangentialVel; // [esp+24h] [ebp-20h] - float fVelY; // [esp+28h] [ebp-1Ch] - float fFinalVelX; // [esp+2Ch] [ebp-18h] - float fFinalVelY; // [esp+30h] [ebp-14h] - float fPerpVel; // [esp+34h] [ebp-10h] - float fNegPerpVel; // [esp+34h] [ebp-10h] + float fVelY; // [esp+28h] [ebp-1Ch] + float fFinalVelX; // [esp+2Ch] [ebp-18h] + float fFinalVelY; // [esp+30h] [ebp-14h] + float fPerpVel; // [esp+34h] [ebp-10h] + float fNegPerpVel; // [esp+34h] [ebp-10h] if (pCar->fFinalSpeed >= 500.0) { iMaxYawChange = 512; @@ -3890,19 +4524,27 @@ void hitleft(tCar *pCar, int iSampleIdx, int iIsRightSide) iMaxYawChange = (int)dSpeedScale; } iYaw3 = pCar->nActualYaw; - fVelX = tcos[iYaw3] * pCar->fFinalSpeed; // Calculate velocity components from car's current speed and direction + fVelX = tcos[iYaw3] * pCar->fFinalSpeed; // Calculate velocity components from + // car's current speed and direction fVelY = tsin[iYaw3] * pCar->fFinalSpeed; - if (iIsRightSide) // Select collision angle based on left/right side (a3 parameter) + if (iIsRightSide) // Select collision angle based on left/right side (a3 + // parameter) iCollisionAngle = rightang; else iCollisionAngle = leftang; - fTangentialVel = fVelX * tcos[iCollisionAngle] + fVelY * tsin[iCollisionAngle];// Transform velocity vector to collision surface coordinate system + fTangentialVel = + fVelX * tcos[iCollisionAngle] + + fVelY * tsin[iCollisionAngle]; // Transform velocity vector to collision + // surface coordinate system fPerpVel = -fVelX * tsin[iCollisionAngle] + fVelY * tcos[iCollisionAngle]; - if (!pCar->byCollisionTimer) // Check if car is not already in collision state (byUnk63 flag) - { // If velocity into wall is positive, play collision sound and calculate damage + if (!pCar->byCollisionTimer) // Check if car is not already in collision state + // (byUnk63 flag) + { // If velocity into wall is positive, play collision sound and calculate + // damage if (fPerpVel > 0.0) { //_CHP(); - sfxpend(iSampleIdx, pCar->iDriverIdx, (int)(fVelY * 32768.0 * 0.0049999999)); + sfxpend(iSampleIdx, pCar->iDriverIdx, + (int)(fVelY * 32768.0 * 0.0049999999)); if (death_race) dDamageAmount = fVelY * 0.006 * 4.0; else @@ -3910,12 +4552,14 @@ void hitleft(tCar *pCar, int iSampleIdx, int iIsRightSide) fDamageFloat = (float)dDamageAmount; dodamage(pCar, fDamageFloat); } - fPerpVel = fPerpVel * -0.6f; // Apply collision physics - reverse perpendicular velocity with damping + fPerpVel = fPerpVel * -0.6f; // Apply collision physics - reverse + // perpendicular velocity with damping fTangentialVel = fTangentialVel * 0.8f; } //_CHP(); fNegPerpVel = (float)-abs((int)fPerpVel); - dVelX = fTangentialVel; // Transform velocity back to world coordinates after collision response + dVelX = fTangentialVel; // Transform velocity back to world coordinates after + // collision response dVelY = fTangentialVel; if (iIsRightSide) iAngleIdx = rightang; @@ -3923,29 +4567,32 @@ void hitleft(tCar *pCar, int iSampleIdx, int iIsRightSide) iAngleIdx = leftang; fFinalVelX = (float)dVelY * tcos[iAngleIdx] - fNegPerpVel * tsin[iAngleIdx]; fFinalVelY = (float)dVelX * tsin[iAngleIdx] + fNegPerpVel * tcos[iAngleIdx]; - if (pCar->fHealth <= 0.0 && fFinalVelY == -40.0)// Special case - if car is dead and velocity is exactly -40, stop completely + if (pCar->fHealth <= 0.0 && + fFinalVelY == -40.0) // Special case - if car is dead and velocity is + // exactly -40, stop completely { pCar->fFinalSpeed = 0.0; - } else { // Handle reverse motion - calculate new direction and speed + } else { // Handle reverse motion - calculate new direction and speed if (pCar->fFinalSpeed < 0.0) { fNegVelX = -fFinalVelX; if (fabs(fNegVelX) > FLT_EPSILON || fabs(-fFinalVelY)) { - //if ((LODWORD(fNegVelX) & 0x7FFFFFFF) != 0 || fabs(-fFinalVelY)) { + // if ((LODWORD(fNegVelX) & 0x7FFFFFFF) != 0 || fabs(-fFinalVelY)) { fNegVelY = -fFinalVelY; dReverseAngle = atan2(fNegVelY, fNegVelX) * 16384.0 / 6.28318530718; - //dReverseAngle = IF_DATAN2(nFpuTemp2, fNegVelY, fNegVelX) * 16384.0 / 6.28318530718; - //_CHP(); + // dReverseAngle = IF_DATAN2(nFpuTemp2, fNegVelY, fNegVelX) * 16384.0 + // / 6.28318530718; _CHP(); iReverseYaw = (int)dReverseAngle & 0x3FFF; } else { iReverseYaw = 0; } pCar->nActualYaw = iReverseYaw; dFinalSpeed = -sqrt(fFinalVelX * fFinalVelX + fFinalVelY * fFinalVelY); - } else { // Handle forward motion - calculate new direction and speed - if (fabs(dVelY * tcos[iAngleIdx] - fNegPerpVel * tsin[iAngleIdx]) || fabs(dVelX * tsin[iAngleIdx] + fNegPerpVel * tcos[iAngleIdx])) { + } else { // Handle forward motion - calculate new direction and speed + if (fabs(dVelY * tcos[iAngleIdx] - fNegPerpVel * tsin[iAngleIdx]) || + fabs(dVelX * tsin[iAngleIdx] + fNegPerpVel * tcos[iAngleIdx])) { dAngleCalc = atan2(fFinalVelY, fFinalVelX) * 16384.0 / 6.28318530718; - //dAngleCalc = IF_DATAN2(nFpuTemp1, fFinalVelY, fFinalVelX) * 16384.0 / 6.28318530718; - //_CHP(); + // dAngleCalc = IF_DATAN2(nFpuTemp1, fFinalVelY, fFinalVelX) * 16384.0 + // / 6.28318530718; _CHP(); iNewYaw = (int)dAngleCalc & 0x3FFF; } else { iNewYaw = 0; @@ -3955,7 +4602,8 @@ void hitleft(tCar *pCar, int iSampleIdx, int iIsRightSide) } pCar->fFinalSpeed = (float)dFinalSpeed; } - iYawDiff = pCar->nActualYaw - pCar->nYaw; // Apply yaw constraints - limit how fast car can turn based on speed + iYawDiff = pCar->nActualYaw - pCar->nYaw; // Apply yaw constraints - limit how + // fast car can turn based on speed iConstrainedYaw = iYawDiff + (iYawDiff < 0 ? 0x4000 : 0); if (iConstrainedYaw > 0x2000) iConstrainedYaw -= 0x4000; @@ -3966,48 +4614,50 @@ void hitleft(tCar *pCar, int iSampleIdx, int iIsRightSide) fFinalSpeed = pCar->fFinalSpeed; nNewYawValue = pCar->nYaw + iConstrainedYaw; nNewYawValue &= 0x3FFF; - //HIBYTE(nNewYawValue) &= 0x3Fu; + // HIBYTE(nNewYawValue) &= 0x3Fu; pCar->nYaw = nNewYawValue; - SetEngine(pCar, fFinalSpeed); // Apply final changes - update engine, reset steering, flatten car, set collision timer + SetEngine(pCar, fFinalSpeed); // Apply final changes - update engine, reset + // steering, flatten car, set collision timer pCar->iSteeringInput = 0; putflat(pCar); pCar->byCollisionTimer = 18; } //------------------------------------------------------------------------------------------------- -//00030590 -void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) -{ // Calculate maximum yaw change based on speed (capped at 500.0) - double dSpeedScale; // st7 - int iYaw3; // eax - int iCollisionAngle; // eax - double dAbsVelY; // st7 - double dDamageAmount; // st7 - double dVelX; // st7 - double dVelY; // st6 - int iAngleIdx; // eax - int iNewYaw; // eax - //int16 nFpuTemp1; // fps - double dAngleCalc; // st7 +// 00030590 +void hitright(tCar *pCar, int iSampleIdx, + int iIsRightSide) { // Calculate maximum yaw change based on speed + // (capped at 500.0) + double dSpeedScale; // st7 + int iYaw3; // eax + int iCollisionAngle; // eax + double dAbsVelY; // st7 + double dDamageAmount; // st7 + double dVelX; // st7 + double dVelY; // st6 + int iAngleIdx; // eax + int iNewYaw; // eax + // int16 nFpuTemp1; // fps + double dAngleCalc; // st7 double dFinalSpeed; // st7 - int iReverseYaw; // eax - //int16 nFpuTemp2; // fps + int iReverseYaw; // eax + // int16 nFpuTemp2; // fps double dReverseAngle; // st7 - int iYawDiff; // edx - int iConstrainedYaw; // eax - int16 nNewYawValue; // ax - float fDamageFloat; // [esp+0h] [ebp-4Ch] - float fNegVelX; // [esp+4h] [ebp-48h] - float fNegVelY; // [esp+18h] [ebp-34h] - float fAbsVelYFloat; // [esp+1Ch] [ebp-30h] - int iMaxYawChange; // [esp+20h] [ebp-2Ch] - float fVelX; // [esp+24h] [ebp-28h] - float fVelY; // [esp+28h] [ebp-24h] + int iYawDiff; // edx + int iConstrainedYaw; // eax + int16 nNewYawValue; // ax + float fDamageFloat; // [esp+0h] [ebp-4Ch] + float fNegVelX; // [esp+4h] [ebp-48h] + float fNegVelY; // [esp+18h] [ebp-34h] + float fAbsVelYFloat; // [esp+1Ch] [ebp-30h] + int iMaxYawChange; // [esp+20h] [ebp-2Ch] + float fVelX; // [esp+24h] [ebp-28h] + float fVelY; // [esp+28h] [ebp-24h] float fTangentialVel; // [esp+2Ch] [ebp-20h] - float fFinalVelX; // [esp+30h] [ebp-1Ch] - float fPerpVel; // [esp+34h] [ebp-18h] - float fAbsPerpVel; // [esp+34h] [ebp-18h] - float fFinalVelY; // [esp+38h] [ebp-14h] + float fFinalVelX; // [esp+30h] [ebp-1Ch] + float fPerpVel; // [esp+34h] [ebp-18h] + float fAbsPerpVel; // [esp+34h] [ebp-18h] + float fFinalVelY; // [esp+38h] [ebp-14h] if (pCar->fFinalSpeed >= 500.0) { iMaxYawChange = 512; @@ -4017,21 +4667,29 @@ void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) iMaxYawChange = (int)dSpeedScale; } iYaw3 = pCar->nActualYaw; - fVelX = tcos[iYaw3] * pCar->fFinalSpeed; // Calculate velocity components from car's current speed and direction + fVelX = tcos[iYaw3] * pCar->fFinalSpeed; // Calculate velocity components from + // car's current speed and direction fVelY = tsin[iYaw3] * pCar->fFinalSpeed; - if (iIsRightSide) // Select collision angle based on left/right side (iIsRightSide parameter) + if (iIsRightSide) // Select collision angle based on left/right side + // (iIsRightSide parameter) iCollisionAngle = rightang; else iCollisionAngle = leftang; - fTangentialVel = fVelX * tcos[iCollisionAngle] + fVelY * tsin[iCollisionAngle];// Transform velocity vector to collision surface coordinate system + fTangentialVel = + fVelX * tcos[iCollisionAngle] + + fVelY * tsin[iCollisionAngle]; // Transform velocity vector to collision + // surface coordinate system fPerpVel = -fVelX * tsin[iCollisionAngle] + fVelY * tcos[iCollisionAngle]; - if (!pCar->byCollisionTimer) // Check if car is not already in collision state (byCollisionTimer) - { // If velocity into wall is negative, play collision sound and calculate damage + if (!pCar->byCollisionTimer) // Check if car is not already in collision state + // (byCollisionTimer) + { // If velocity into wall is negative, play collision sound and calculate + // damage if (fVelY < 0.0) { dAbsVelY = -fVelY; fAbsVelYFloat = (float)dAbsVelY; //_CHP(); - sfxpend(iSampleIdx, pCar->iDriverIdx, (int)(dAbsVelY * 32768.0 * 0.0049999999)); + sfxpend(iSampleIdx, pCar->iDriverIdx, + (int)(dAbsVelY * 32768.0 * 0.0049999999)); if (death_race) dDamageAmount = fAbsVelYFloat * 0.006 * 4.0; else @@ -4039,12 +4697,14 @@ void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) fDamageFloat = (float)dDamageAmount; dodamage(pCar, fDamageFloat); } - fPerpVel = fPerpVel * -0.6f; // Apply collision physics - reverse perpendicular velocity with damping + fPerpVel = fPerpVel * -0.6f; // Apply collision physics - reverse + // perpendicular velocity with damping fTangentialVel = fTangentialVel * 0.8f; } //_CHP(); fAbsPerpVel = (float)(int)abs((int)fPerpVel); - dVelX = fTangentialVel; // Transform velocity back to world coordinates after collision response + dVelX = fTangentialVel; // Transform velocity back to world coordinates after + // collision response dVelY = fTangentialVel; if (iIsRightSide) iAngleIdx = rightang; @@ -4052,14 +4712,16 @@ void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) iAngleIdx = leftang; fFinalVelX = (float)dVelY * tcos[iAngleIdx] - fAbsPerpVel * tsin[iAngleIdx]; fFinalVelY = (float)dVelX * tsin[iAngleIdx] + fAbsPerpVel * tcos[iAngleIdx]; - if (pCar->fHealth <= 0.0 && fFinalVelY == 40.0)// Special case - if car is dead and velocity is exactly 40, stop completely + if (pCar->fHealth <= 0.0 && + fFinalVelY == 40.0) // Special case - if car is dead and velocity is + // exactly 40, stop completely { pCar->fFinalSpeed = 0.0; - } else { // Handle reverse motion - calculate new direction and speed + } else { // Handle reverse motion - calculate new direction and speed if (pCar->fFinalSpeed < 0.0) { fNegVelX = -fFinalVelX; if (fabs(fNegVelX) > FLT_EPSILON || fabs(-fFinalVelY)) { - //if ((LODWORD(fNegVelX) & 0x7FFFFFFF) != 0 || fabs(-fFinalVelY)) { + // if ((LODWORD(fNegVelX) & 0x7FFFFFFF) != 0 || fabs(-fFinalVelY)) { fNegVelY = -fFinalVelY; dReverseAngle = atan2(fNegVelY, fNegVelX) * 16384.0 / 6.28318530718; //_CHP(); @@ -4069,8 +4731,9 @@ void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) } pCar->nActualYaw = iReverseYaw; dFinalSpeed = -sqrt(fFinalVelX * fFinalVelX + fFinalVelY * fFinalVelY); - } else { // Handle forward motion - calculate new direction and speed - if (fabs(dVelY * tcos[iAngleIdx] - fAbsPerpVel * tsin[iAngleIdx]) || fabs(dVelX * tsin[iAngleIdx] + fAbsPerpVel * tcos[iAngleIdx])) { + } else { // Handle forward motion - calculate new direction and speed + if (fabs(dVelY * tcos[iAngleIdx] - fAbsPerpVel * tsin[iAngleIdx]) || + fabs(dVelX * tsin[iAngleIdx] + fAbsPerpVel * tcos[iAngleIdx])) { dAngleCalc = atan2(fFinalVelY, fFinalVelX) * 16384.0 / 6.28318530718; //_CHP(); iNewYaw = (int)dAngleCalc & 0x3FFF; @@ -4083,7 +4746,9 @@ void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) pCar->fFinalSpeed = (float)dFinalSpeed; } if (!pCar->byCollisionTimer) { - iYawDiff = pCar->nActualYaw - pCar->nYaw; // Apply yaw constraints only if not in collision state + iYawDiff = + pCar->nActualYaw - + pCar->nYaw; // Apply yaw constraints only if not in collision state iConstrainedYaw = iYawDiff + (iYawDiff < 0 ? 0x4000 : 0); if (iConstrainedYaw > 0x2000) iConstrainedYaw -= 0x4000; @@ -4093,36 +4758,37 @@ void hitright(tCar *pCar, int iSampleIdx, int iIsRightSide) iConstrainedYaw = -iMaxYawChange; nNewYawValue = pCar->nYaw + iConstrainedYaw; nNewYawValue &= 0x3FFFu; - //HIBYTE(nNewYawValue) &= 0x3Fu; + // HIBYTE(nNewYawValue) &= 0x3Fu; pCar->nYaw = nNewYawValue; } - SetEngine(pCar, pCar->fFinalSpeed); // Apply final changes - update engine, reset steering, flatten car, set collision timer + SetEngine(pCar, + pCar->fFinalSpeed); // Apply final changes - update engine, reset + // steering, flatten car, set collision timer pCar->iSteeringInput = 0; putflat(pCar); pCar->byCollisionTimer = 18; } //------------------------------------------------------------------------------------------------- -//000308D0 -void scansection(tCar *pCar) -{ - int iTrackLen; // edi - int iChunkIdx; // ebx - tData *pData; // edx - int iDirection; // ecx - double dTempY; // st7 - double dTempX; // st5 - double dTempZ; // rt0 - double dTempY2; // st7 - double dTempX2; // st5 - double dTempZ2; // rt1 - int iTempYaw; // eax +// 000308D0 +void scansection(tCar *pCar) { + int iTrackLen; // edi + int iChunkIdx; // ebx + tData *pData; // edx + int iDirection; // ecx + double dTempY; // st7 + double dTempX; // st5 + double dTempZ; // rt0 + double dTempY2; // st7 + double dTempX2; // st5 + double dTempZ2; // rt1 + int iTempYaw; // eax float fTransformedX; // [esp+4h] [ebp-30h] float fTransformedY; // [esp+8h] [ebp-2Ch] float fTransformedZ; // [esp+Ch] [ebp-28h] - float fZ; // [esp+10h] [ebp-24h] - float fY; // [esp+14h] [ebp-20h] - float fX; // [esp+18h] [ebp-1Ch] + float fZ; // [esp+10h] [ebp-24h] + float fY; // [esp+14h] [ebp-20h] + float fX; // [esp+18h] [ebp-1Ch] iTrackLen = TRAK_LEN; fX = pCar->pos.fX; @@ -4130,11 +4796,21 @@ void scansection(tCar *pCar) iChunkIdx = pCar->nCurrChunk; fZ = pCar->pos.fZ; pData = &localdata[iChunkIdx]; - fTransformedX = pData->pointAy[0].fY * fY + pData->pointAy[0].fX * pCar->pos.fX + pData->pointAy[0].fZ * fZ - pData->pointAy[3].fX;// Transform car position relative to current track chunk coordinate system - fTransformedY = pData->pointAy[1].fY * fY + pData->pointAy[1].fX * pCar->pos.fX + pData->pointAy[1].fZ * fZ - pData->pointAy[3].fY; - fTransformedZ = pData->pointAy[2].fY * fY + pData->pointAy[2].fX * pCar->pos.fX + pData->pointAy[2].fZ * fZ - pData->pointAy[3].fZ; + fTransformedX = pData->pointAy[0].fY * fY + + pData->pointAy[0].fX * pCar->pos.fX + + pData->pointAy[0].fZ * fZ - + pData->pointAy[3].fX; // Transform car position relative to + // current track chunk coordinate system + fTransformedY = pData->pointAy[1].fY * fY + + pData->pointAy[1].fX * pCar->pos.fX + + pData->pointAy[1].fZ * fZ - pData->pointAy[3].fY; + fTransformedZ = pData->pointAy[2].fY * fY + + pData->pointAy[2].fX * pCar->pos.fX + + pData->pointAy[2].fZ * fZ - pData->pointAy[3].fZ; iDirection = 0; - if (pCar->pos.fX < (double)pData->fTrackHalfLength)// If car is behind track half-length, scan backwards through chunks + if (pCar->pos.fX < + (double)pData->fTrackHalfLength) // If car is behind track half-length, + // scan backwards through chunks { do { if (--iChunkIdx == -1) @@ -4143,13 +4819,24 @@ void scansection(tCar *pCar) dTempY = fTransformedY + pData->pointAy[3].fY; dTempX = fTransformedX + pData->pointAy[3].fX; dTempZ = fTransformedZ + pData->pointAy[3].fZ; - fX = (float)(pData->pointAy[1].fX * dTempY + pData->pointAy[0].fX * dTempX + pData->pointAy[2].fX * dTempZ);// Apply inverse transformation to get position in new chunk's coordinate system - fY = (float)(pData->pointAy[0].fY * dTempX + pData->pointAy[1].fY * dTempY + pData->pointAy[2].fY * dTempZ); - fZ = (float)(dTempY * pData->pointAy[1].fZ + dTempX * pData->pointAy[0].fZ + dTempZ * pData->pointAy[2].fZ); + fX = (float)(pData->pointAy[1].fX * dTempY + + pData->pointAy[0].fX * dTempX + + pData->pointAy[2].fX * + dTempZ); // Apply inverse transformation to get position + // in new chunk's coordinate system + fY = (float)(pData->pointAy[0].fY * dTempX + + pData->pointAy[1].fY * dTempY + + pData->pointAy[2].fY * dTempZ); + fZ = (float)(dTempY * pData->pointAy[1].fZ + + dTempX * pData->pointAy[0].fZ + + dTempZ * pData->pointAy[2].fZ); iDirection -= pData->iYaw; } while (fX < (double)pData->fTrackHalfLength); } - while (fX > (double)pData->fTrackHalfLength)// If car is ahead of track half-length, scan forwards through chunks + while ( + fX > + (double)pData->fTrackHalfLength) // If car is ahead of track half-length, + // scan forwards through chunks { ++iChunkIdx; iDirection += pData->iYaw; @@ -4159,16 +4846,24 @@ void scansection(tCar *pCar) dTempY2 = fTransformedY + pData->pointAy[3].fY; dTempX2 = fTransformedX + pData->pointAy[3].fX; dTempZ2 = fTransformedZ + pData->pointAy[3].fZ; - fX = (float)(pData->pointAy[1].fX * dTempY2 + pData->pointAy[0].fX * dTempX2 + pData->pointAy[2].fX * dTempZ2); - fY = (float)(pData->pointAy[0].fY * dTempX2 + pData->pointAy[1].fY * dTempY2 + pData->pointAy[2].fY * dTempZ2); - fZ = (float)(dTempY2 * pData->pointAy[1].fZ + dTempX2 * pData->pointAy[0].fZ + dTempZ2 * pData->pointAy[2].fZ); + fX = (float)(pData->pointAy[1].fX * dTempY2 + + pData->pointAy[0].fX * dTempX2 + + pData->pointAy[2].fX * dTempZ2); + fY = (float)(pData->pointAy[0].fY * dTempX2 + + pData->pointAy[1].fY * dTempY2 + + pData->pointAy[2].fY * dTempZ2); + fZ = (float)(dTempY2 * pData->pointAy[1].fZ + + dTempX2 * pData->pointAy[0].fZ + + dTempZ2 * pData->pointAy[2].fZ); } - pCar->pos.fX = fX; // Store final transformed position and updated chunk/yaw back to car + pCar->pos.fX = + fX; // Store final transformed position and updated chunk/yaw back to car pCar->pos.fY = fY; pCar->pos.fZ = fZ; pCar->nYaw -= iDirection; pCar->nYaw &= 0x3FFF; - //HIBYTE(pCar->nYaw) &= 0x3Fu; // Mask yaw values to keep them within valid ranges (14-bit values) + // HIBYTE(pCar->nYaw) &= 0x3Fu; // Mask yaw values to keep + // them within valid ranges (14-bit values) iTempYaw = pCar->nActualYaw - iDirection; pCar->nCurrChunk = iChunkIdx; pCar->nActualYaw = iTempYaw; @@ -4177,95 +4872,114 @@ void scansection(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//00030AC0 -double getgroundz(float fXPos, float fYOffset, int iChunkIdx) -{ - tData *pData; // edx - double dAngleIdx; // st7 +// 00030AC0 +double getgroundz(float fXPos, float fYOffset, int iChunkIdx) { + tData *pData; // edx + double dAngleIdx; // st7 tTrackInfo *pTrackInfo; // ebx - double dAbsYOffset; // st7 - float fTempYOffset; // [esp+4h] [ebp-14h] - float fGroundZ; // [esp+8h] [ebp-10h] + double dAbsYOffset; // st7 + float fTempYOffset; // [esp+4h] [ebp-14h] + float fGroundZ; // [esp+8h] [ebp-10h] - pData = &localdata[iChunkIdx]; // Get track data for the specified chunk - dAngleIdx = (double)pData->iBankDelta * fXPos / (pData->fTrackHalfLength * 2.0);// Calculate banking angle index based on X position in chunk + pData = &localdata[iChunkIdx]; // Get track data for the specified chunk + dAngleIdx = + (double)pData->iBankDelta * fXPos / + (pData->fTrackHalfLength * + 2.0); // Calculate banking angle index based on X position in chunk //_CHP(); - pTrackInfo = &TrackInfo[iChunkIdx]; // Get track shoulder information for this chunk - fGroundZ = -fYOffset * ptan[(int)dAngleIdx & 0x3FFF];// Calculate base ground height using banking angle - if (fYOffset >= (double)pData->fTrackHalfWidth)// Check if position is on left shoulder (positive Y beyond track) - fGroundZ = (fYOffset - pData->fTrackHalfWidth) * pTrackInfo->fLShoulderHeight / pTrackInfo->fLShoulderWidth + fGroundZ;// Add left shoulder height based on distance beyond track edge + pTrackInfo = + &TrackInfo[iChunkIdx]; // Get track shoulder information for this chunk + fGroundZ = -fYOffset * + ptan[(int)dAngleIdx & + 0x3FFF]; // Calculate base ground height using banking angle + if (fYOffset >= + (double)pData->fTrackHalfWidth) // Check if position is on left shoulder + // (positive Y beyond track) + fGroundZ = (fYOffset - pData->fTrackHalfWidth) * + pTrackInfo->fLShoulderHeight / pTrackInfo->fLShoulderWidth + + fGroundZ; // Add left shoulder height based on distance beyond + // track edge dAbsYOffset = -fYOffset; - if (dAbsYOffset >= pData->fTrackHalfWidth) // Check if position is on right shoulder (negative Y beyond track) + if (dAbsYOffset >= + pData->fTrackHalfWidth) // Check if position is on right shoulder + // (negative Y beyond track) { fTempYOffset = (float)dAbsYOffset; - return (float)((fTempYOffset - pData->fTrackHalfWidth) * pTrackInfo->fRShoulderHeight / pTrackInfo->fRShoulderWidth + fGroundZ);// Add right shoulder height and return total ground Z + return ( + float)((fTempYOffset - pData->fTrackHalfWidth) * + pTrackInfo->fRShoulderHeight / pTrackInfo->fRShoulderWidth + + fGroundZ); // Add right shoulder height and return total ground Z } - return fGroundZ; // Return banking height for positions on main track + return fGroundZ; // Return banking height for positions on main track } //------------------------------------------------------------------------------------------------- -//00030B80 -double getroadz(float fX, float fY, int iChunkIdx) -{ +// 00030B80 +double getroadz(float fX, float fY, int iChunkIdx) { double dBankAngleIndex; // st7 - dBankAngleIndex = (double)localdata[iChunkIdx].iBankDelta * fX / (localdata[iChunkIdx].fTrackHalfLength * 2.0);// Calculate banking angle index based on X position and track banking + dBankAngleIndex = (double)localdata[iChunkIdx].iBankDelta * fX / + (localdata[iChunkIdx].fTrackHalfLength * + 2.0); // Calculate banking angle index based on X position + // and track banking //_CHP(); - return -fY * ptan[(int)dBankAngleIndex & 0x3FFF];// Apply banking effect: negative Y times tangent of banking angle + return -fY * ptan[(int)dBankAngleIndex & + 0x3FFF]; // Apply banking effect: negative Y times tangent + // of banking angle } //------------------------------------------------------------------------------------------------- -//00030BD0 -void putflat(tCar *pCar) -{ - int nCurrChunk; // esi +// 00030BD0 +void putflat(tCar *pCar) { + int nCurrChunk; // esi tTrackInfo *pTrackInfo; // edi - tData *pCurrData; // ecx - int iPrevChunkIdx; // eax - int iNextChunkIdx2; // edx - tData *pPrevData; // ebp - int iPitch; // eax - int iLaneType; // edx - //int64 llSurfaceType1; // rax - //int64 llSurfaceType2; // rax - //int64 llSurfaceType3; // rax - double dPitchFloat; // st7 - int iBankDelta; // esi + tData *pCurrData; // ecx + int iPrevChunkIdx; // eax + int iNextChunkIdx2; // edx + tData *pPrevData; // ebp + int iPitch; // eax + int iLaneType; // edx + // int64 llSurfaceType1; // rax + // int64 llSurfaceType2; // rax + // int64 llSurfaceType3; // rax + double dPitchFloat; // st7 + int iBankDelta; // esi double dInvHalfLength; // st7 - double dBankTerm1; // st6 - double dBankTerm2; // st5 - double dBankAngle; // st7 - //int16 nBankAngleInt; // fps + double dBankTerm1; // st6 + double dBankTerm2; // st5 + double dBankAngle; // st7 + // int16 nBankAngleInt; // fps double dPitchCorrected; // st7 - double dBankFloat; // st7 - double dLeftBankAdj; // st7 + double dBankFloat; // st7 + double dLeftBankAdj; // st7 double dShoulderHeight; // st7 - double dRightBankAdj; // st7 - double dAbsYPos; // st7 - double dPitchForCalc; // st7 - double dPitchResult; // st5 - //int iYawIndex; // eax + double dRightBankAdj; // st7 + double dAbsYPos; // st7 + double dPitchForCalc; // st7 + double dPitchResult; // st5 + // int iYawIndex; // eax double dRollResult; // st7 - int iPitchFinal_1; // eax - int iStunned; // edi - int nYaw; // [esp+14h] [ebp-40h] - float fAbsYPos; // [esp+1Ch] [ebp-38h] - float fNegYPos; // [esp+20h] [ebp-34h] - int iRollFinal; // [esp+24h] [ebp-30h] - tData *pNextData; // [esp+28h] [ebp-2Ch] - int iNextChunkIdx; // [esp+2Ch] [ebp-28h] - int iBankInt; // [esp+30h] [ebp-24h] - int iPitchInt; // [esp+34h] [ebp-20h] - int iPitchFinal; // [esp+34h] [ebp-20h] + int iPitchFinal_1; // eax + int iStunned; // edi + int nYaw; // [esp+14h] [ebp-40h] + float fAbsYPos; // [esp+1Ch] [ebp-38h] + float fNegYPos; // [esp+20h] [ebp-34h] + int iRollFinal; // [esp+24h] [ebp-30h] + tData *pNextData; // [esp+28h] [ebp-2Ch] + int iNextChunkIdx; // [esp+2Ch] [ebp-28h] + int iBankInt; // [esp+30h] [ebp-24h] + int iPitchInt; // [esp+34h] [ebp-20h] + int iPitchFinal; // [esp+34h] [ebp-20h] - nCurrChunk = pCar->nCurrChunk; // Get current track chunk and related data - if (nCurrChunk < 0 || nCurrChunk >= TRAK_LEN) //added by ROLLER + nCurrChunk = pCar->nCurrChunk; // Get current track chunk and related data + if (nCurrChunk < 0 || nCurrChunk >= TRAK_LEN) // added by ROLLER nCurrChunk = 0; pTrackInfo = &TrackInfo[nCurrChunk]; pCurrData = &localdata[nCurrChunk]; nYaw = pCar->nYaw; - if (pCar->pos.fX >= 0.0) // Determine previous and next chunk indices based on car direction + if (pCar->pos.fX >= + 0.0) // Determine previous and next chunk indices based on car direction { iPrevChunkIdx = nCurrChunk; iNextChunkIdx = nCurrChunk + 1; @@ -4280,161 +4994,226 @@ void putflat(tCar *pCar) } pNextData = &localdata[iNextChunkIdx2]; pPrevData = &localdata[iPrevChunkIdx]; - if (pCar->pos.fY <= (double)pCurrData->fTrackHalfWidth)// Determine which lane car is in and get appropriate pitch angle + if (pCar->pos.fY <= + (double)pCurrData->fTrackHalfWidth) // Determine which lane car is in and + // get appropriate pitch angle { if (-pCurrData->fTrackHalfWidth <= pCar->pos.fY) { - iPitch = pPrevData->iPitch; // Center lane (on track) + iPitch = pPrevData->iPitch; // Center lane (on track) iLaneType = 1; } else { - iPitch = pPrevData->iOuterLanePitchAngle; // Outer lane (left side of track) + iPitch = + pPrevData->iOuterLanePitchAngle; // Outer lane (left side of track) iLaneType = 2; } } else { - iPitch = pPrevData->iInnerLanePitchAngle; // Inner lane (right side of track) + iPitch = + pPrevData->iInnerLanePitchAngle; // Inner lane (right side of track) iLaneType = 0; } iPitchInt = iPitch; - if (pCar->pos.fX < 0.0) // Check surface type and apply pitch corrections based on car position + if (pCar->pos.fX < 0.0) // Check surface type and apply pitch corrections + // based on car position { if ((TrakColour[nCurrChunk][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0) - //llSurfaceType3 = TrakColour[nCurrChunk][iLaneType]; - //if ((((HIDWORD(llSurfaceType3) ^ (unsigned int)llSurfaceType3) - HIDWORD(llSurfaceType3)) & 0x20000) != 0)// SURFACE_FLAG_SKIP_RENDER + // llSurfaceType3 = TrakColour[nCurrChunk][iLaneType]; + // if ((((HIDWORD(llSurfaceType3) ^ (unsigned int)llSurfaceType3) - + // HIDWORD(llSurfaceType3)) & 0x20000) != 0)// SURFACE_FLAG_SKIP_RENDER iPitchInt = 0; - } else { // Steep downhill: zero pitch if car is fast and AI state allows - if (iPitch < -512 && pCar->fFinalSpeed > 50.0 && (TrakColour[pCar->nCurrChunk][pCar->iLaneType] & SURFACE_FLAG_NON_MAGNETIC) != 0) + } else { // Steep downhill: zero pitch if car is fast and AI state allows + if (iPitch < -512 && pCar->fFinalSpeed > 50.0 && + (TrakColour[pCar->nCurrChunk][pCar->iLaneType] & + SURFACE_FLAG_NON_MAGNETIC) != 0) iPitchInt = 0; if ((TrakColour[nCurrChunk][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0) - //llSurfaceType1 = TrakColour[nCurrChunk][iLaneType];// Check current chunk surface type and zero pitch if needed - //if ((((HIDWORD(llSurfaceType1) ^ (unsigned int)llSurfaceType1) - HIDWORD(llSurfaceType1)) & 0x20000) != 0)// SURFACE_FLAG_SKIP_RENDER + // llSurfaceType1 = TrakColour[nCurrChunk][iLaneType];// Check current + // chunk surface type and zero pitch if needed if + // ((((HIDWORD(llSurfaceType1) ^ (unsigned int)llSurfaceType1) - + // HIDWORD(llSurfaceType1)) & 0x20000) != 0)// SURFACE_FLAG_SKIP_RENDER iPitchInt = 0; if (pCar->fFinalSpeed > 50.0) { - if ((TrakColour[iNextChunkIdx][pCar->iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0) - //llSurfaceType2 = TrakColour[iNextChunkIdx][pCar->iLaneType];// Check next chunk surface type for fast cars - //if ((((HIDWORD(llSurfaceType2) ^ (unsigned int)llSurfaceType2) - HIDWORD(llSurfaceType2)) & 0x20000) != 0)// SURFACE_FLAG_SKIP_RENDER + if ((TrakColour[iNextChunkIdx][pCar->iLaneType] & + SURFACE_FLAG_SKIP_RENDER) != 0) + // llSurfaceType2 = TrakColour[iNextChunkIdx][pCar->iLaneType];// Check + // next chunk surface type for fast cars if ((((HIDWORD(llSurfaceType2) + // ^ (unsigned int)llSurfaceType2) - HIDWORD(llSurfaceType2)) & 0x20000) + // != 0)// SURFACE_FLAG_SKIP_RENDER iPitchInt = 0; } } - dPitchFloat = (double)iPitchInt * pCar->pos.fX / (pCurrData->fTrackHalfLength * 2.0);// Calculate pitch angle based on car position along track + dPitchFloat = + (double)iPitchInt * pCar->pos.fX / + (pCurrData->fTrackHalfLength * + 2.0); // Calculate pitch angle based on car position along track //_CHP(); iPitchFinal = (int)dPitchFloat; - if ((TrakColour[nCurrChunk][1] & SURFACE_FLAG_BOUNCE_30) != 0)// SURFACE_FLAG_BOUNCE_30 + if ((TrakColour[nCurrChunk][1] & SURFACE_FLAG_BOUNCE_30) != + 0) // SURFACE_FLAG_BOUNCE_30 { if (pCar->pos.fX < 0.0) { dInvHalfLength = 1.0 / pCurrData->fTrackHalfLength; - dBankTerm1 = (pCar->pos.fX + pCurrData->fTrackHalfLength) * (double)pCurrData->iBankDelta * dInvHalfLength; - dBankTerm2 = (double)((pNextData->iBankDelta + pCurrData->iBankDelta) / -2); + dBankTerm1 = (pCar->pos.fX + pCurrData->fTrackHalfLength) * + (double)pCurrData->iBankDelta * dInvHalfLength; + dBankTerm2 = + (double)((pNextData->iBankDelta + pCurrData->iBankDelta) / -2); } else { iBankDelta = pCurrData->iBankDelta; dInvHalfLength = 1.0 / pCurrData->fTrackHalfLength; - dBankTerm1 = (pCar->pos.fX - pCurrData->fTrackHalfLength) * (double)-iBankDelta * dInvHalfLength; + dBankTerm1 = (pCar->pos.fX - pCurrData->fTrackHalfLength) * + (double)-iBankDelta * dInvHalfLength; dBankTerm2 = (double)((iBankDelta + pNextData->iBankDelta) / 2); } - dBankAngle = dInvHalfLength * (dBankTerm2 * pCar->pos.fX) + dBankTerm1;// Apply special banking interpolation and atan2 correction + dBankAngle = + dInvHalfLength * (dBankTerm2 * pCar->pos.fX) + + dBankTerm1; // Apply special banking interpolation and atan2 correction //_CHP(); - dPitchCorrected = (double)iPitchFinal - - atan2(pCar->pos.fY * tsin[(int)dBankAngle & 0x3FFF], pCurrData->fTrackHalfLength * 2.0) * 16384.0 / 6.28318530718; + dPitchCorrected = (double)iPitchFinal - + atan2(pCar->pos.fY * tsin[(int)dBankAngle & 0x3FFF], + pCurrData->fTrackHalfLength * 2.0) * + 16384.0 / 6.28318530718; //_CHP(); iPitchFinal = (int)dPitchCorrected; } - dBankFloat = (double)pCurrData->iBankDelta * pCar->pos.fX / (pCurrData->fTrackHalfLength * 2.0);// Calculate basic banking angle based on car X position + dBankFloat = (double)pCurrData->iBankDelta * pCar->pos.fX / + (pCurrData->fTrackHalfLength * + 2.0); // Calculate basic banking angle based on car X position //_CHP(); iBankInt = (int)dBankFloat; - pCar->pos.fZ = -(pCar->pos.fY * ptan[(int)dBankFloat & 0x3FFF]);// Calculate car Z position using banking angle - if (pCar->pos.fY < 0.0) // Apply track banking adjustments based on car Y position + pCar->pos.fZ = -(pCar->pos.fY * + ptan[(int)dBankFloat & 0x3FFF]); // Calculate car Z position + // using banking angle + if (pCar->pos.fY < + 0.0) // Apply track banking adjustments based on car Y position { - fNegYPos = -pCar->pos.fY; // Right side banking adjustments + fNegYPos = -pCar->pos.fY; // Right side banking adjustments if (pCurrData->fTrackHalfWidth + pCar->fCarHalfWidth > fNegYPos) { if (pCurrData->fTrackHalfWidth - pCar->fCarHalfWidth <= fNegYPos) { - dRightBankAdj = (fNegYPos - pCurrData->fTrackHalfWidth + pCar->fCarHalfWidth) * (double)pTrackInfo->iRightBankAngle / (pCar->fCarHalfWidth * 2.0) + (double)iBankInt; + dRightBankAdj = + (fNegYPos - pCurrData->fTrackHalfWidth + pCar->fCarHalfWidth) * + (double)pTrackInfo->iRightBankAngle / + (pCar->fCarHalfWidth * 2.0) + + (double)iBankInt; //_CHP(); iBankInt = (int)dRightBankAdj; } } else { iBankInt += pTrackInfo->iRightBankAngle; } - dAbsYPos = -pCar->pos.fY; // Add shoulder height if car is off track (right side) + dAbsYPos = + -pCar->pos.fY; // Add shoulder height if car is off track (right side) if (dAbsYPos >= pCurrData->fTrackHalfWidth) { fAbsYPos = (float)dAbsYPos; - dShoulderHeight = (fAbsYPos - pCurrData->fTrackHalfWidth) * pTrackInfo->fRShoulderHeight / pTrackInfo->fRShoulderWidth; + dShoulderHeight = (fAbsYPos - pCurrData->fTrackHalfWidth) * + pTrackInfo->fRShoulderHeight / + pTrackInfo->fRShoulderWidth; goto LABEL_43; } - } else { // Left side banking adjustments + } else { // Left side banking adjustments if (pCurrData->fTrackHalfWidth + pCar->fCarHalfWidth > pCar->pos.fY) { if (pCurrData->fTrackHalfWidth - pCar->fCarHalfWidth <= pCar->pos.fY) { - dLeftBankAdj = (double)iBankInt - (pCar->pos.fY - pCurrData->fTrackHalfWidth + pCar->fCarHalfWidth) * (double)pTrackInfo->iLeftBankAngle / (pCar->fCarHalfWidth * 2.0); + dLeftBankAdj = + (double)iBankInt - + (pCar->pos.fY - pCurrData->fTrackHalfWidth + pCar->fCarHalfWidth) * + (double)pTrackInfo->iLeftBankAngle / + (pCar->fCarHalfWidth * 2.0); //_CHP(); iBankInt = (int)dLeftBankAdj; } } else { iBankInt -= pTrackInfo->iLeftBankAngle; } - if (pCar->pos.fY >= (double)pCurrData->fTrackHalfWidth)// Add shoulder height if car is off track (left side) + if (pCar->pos.fY >= + (double)pCurrData->fTrackHalfWidth) // Add shoulder height if car is off + // track (left side) { - dShoulderHeight = (pCar->pos.fY - pCurrData->fTrackHalfWidth) * pTrackInfo->fLShoulderHeight / pTrackInfo->fLShoulderWidth; + dShoulderHeight = (pCar->pos.fY - pCurrData->fTrackHalfWidth) * + pTrackInfo->fLShoulderHeight / + pTrackInfo->fLShoulderWidth; LABEL_43: pCar->pos.fZ = (float)dShoulderHeight + pCar->pos.fZ; } } - dPitchForCalc = (double)iPitchFinal; // Transform pitch and bank angles using car yaw rotation + dPitchForCalc = (double) + iPitchFinal; // Transform pitch and bank angles using car yaw rotation dPitchResult = dPitchForCalc * tcos[nYaw] - (double)iBankInt * tsin[nYaw]; //_CHP(); dRollResult = dPitchForCalc * tsin[nYaw] + (double)iBankInt * tcos[nYaw]; //_CHP(); - - //iPitchFinal_1 = (int)dPitchResult; - ////iPitchFinal_1 = ((int16)(int)dPitchResult >> 8) & 0x3FFF;// Mask pitch angle to 14-bit range - //SET_BYTE1(iPitchFinal_1, ((uint16)(int)dPitchResult >> 8) & 0x3F);// Mask pitch result to 14-bit range (0x3FFF) - //BYTE1(iPitchFinal_1) = ((unsigned __int16)(int)dPitchResult >> 8) & 0x3F;// Mask pitch result to 14-bit range (0x3FFF) + // iPitchFinal_1 = (int)dPitchResult; + ////iPitchFinal_1 = ((int16)(int)dPitchResult >> 8) & 0x3FFF;// Mask pitch + /// angle to 14-bit range + // SET_BYTE1(iPitchFinal_1, ((uint16)(int)dPitchResult >> 8) & 0x3F);// Mask + // pitch result to 14-bit range (0x3FFF) BYTE1(iPitchFinal_1) = ((unsigned + // __int16)(int)dPitchResult >> 8) & 0x3F;// Mask pitch result to 14-bit range + // (0x3FFF) iPitchFinal_1 = ((int)dPitchResult) & 0x3FFF; iStunned = pCar->iStunned; pCar->nPitch = iPitchFinal_1; iRollFinal = (int)dRollResult; - if (iStunned) // Apply stunned car effects - add roll offset and height adjustment + if (iStunned) // Apply stunned car effects - add roll offset and height + // adjustment { iRollFinal = (int16)(iRollFinal) + 0x2000; pCar->pos.fZ = CarBox.hitboxAy[pCar->byCarDesignIdx][4].fZ + pCar->pos.fZ; } - pCar->nRoll = (int16)iRollFinal & 0x3FFF; // Set final roll angle with 14-bit mask + pCar->nRoll = + (int16)iRollFinal & 0x3FFF; // Set final roll angle with 14-bit mask } //------------------------------------------------------------------------------------------------- -//00031060 -void findnearcars(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *piRightCarIdx, float *pfRightTime, float *pfTargetX, float *pfTargetY) -{ - int iDriverIdx; // eax +// 00031060 +void findnearcars(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, + int *piRightCarIdx, float *pfRightTime, float *pfTargetX, + float *pfTargetY) { + int iDriverIdx; // eax float fRightTargetTime; // [esp+0h] [ebp-18h] - float fLeftTargetTime; // [esp+4h] [ebp-14h] + float fLeftTargetTime; // [esp+4h] [ebp-14h] - iDriverIdx = pCar->iDriverIdx; // Check if this car should perform full collision detection this frame - if (iDriverIdx == nearcall[nearcarcheck][0] || iDriverIdx == nearcall[nearcarcheck][1] || iDriverIdx == nearcall[nearcarcheck][2] || iDriverIdx == nearcall[nearcarcheck][3])// Check against scheduled cars for this frame (load balancing) + iDriverIdx = pCar->iDriverIdx; // Check if this car should perform full + // collision detection this frame + if (iDriverIdx == nearcall[nearcarcheck][0] || + iDriverIdx == nearcall[nearcarcheck][1] || + iDriverIdx == nearcall[nearcarcheck][2] || + iDriverIdx == + nearcall[nearcarcheck][3]) // Check against scheduled cars for this + // frame (load balancing) { - findnearcarsforce(pCar, piLeftCarIdx, pfLeftTime, piRightCarIdx, pfRightTime, pfTargetX, pfTargetY);// Perform full collision detection and cache results - pCar->iLeftTargetIdx = *piLeftCarIdx; // Cache collision detection results in car structure + findnearcarsforce( + pCar, piLeftCarIdx, pfLeftTime, piRightCarIdx, pfRightTime, pfTargetX, + pfTargetY); // Perform full collision detection and cache results + pCar->iLeftTargetIdx = + *piLeftCarIdx; // Cache collision detection results in car structure pCar->fLeftTargetTime = *pfLeftTime; pCar->iRightTargetIdx = *piRightCarIdx; pCar->fRightTargetTime = *pfRightTime; pCar->fTargetX = *pfTargetX; pCar->fTargetY = *pfTargetY; } else { - *piLeftCarIdx = pCar->iLeftTargetIdx; // Use cached collision data from previous frame + *piLeftCarIdx = + pCar->iLeftTargetIdx; // Use cached collision data from previous frame fLeftTargetTime = pCar->fLeftTargetTime; *piRightCarIdx = pCar->iRightTargetIdx; fRightTargetTime = pCar->fRightTargetTime; *pfTargetX = pCar->fTargetX; *pfTargetY = pCar->fTargetY; - if (*piLeftCarIdx != -1) // Update cached collision times by subtracting frame time + if (*piLeftCarIdx != + -1) // Update cached collision times by subtracting frame time { if (fLeftTargetTime < 0.0) { - fLeftTargetTime = fLeftTargetTime + -0.02777777777777778f;// Subtract frame time (1/36 second is about 0.0278s for 36 FPS) + fLeftTargetTime = + fLeftTargetTime + + -0.02777777777777778f; // Subtract frame time (1/36 second is about + // 0.0278s for 36 FPS) } else { fLeftTargetTime = fLeftTargetTime + -0.02777777777777778f; - if (fLeftTargetTime < 0.0) // Clamp positive times to zero (collision imminent) + if (fLeftTargetTime < + 0.0) // Clamp positive times to zero (collision imminent) fLeftTargetTime = 0.0; } } @@ -4451,16 +5230,21 @@ void findnearcars(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *piRight *pfRightTime = fRightTargetTime; pCar->fLeftTargetTime = fLeftTargetTime; pCar->fRightTargetTime = fRightTargetTime; - if (*piLeftCarIdx >= 0 && Car[*piLeftCarIdx].nCurrChunk == -1) // Validate left target car is still on track + if (*piLeftCarIdx >= 0 && + Car[*piLeftCarIdx].nCurrChunk == + -1) // Validate left target car is still on track { - *piLeftCarIdx = -1; // Clear invalid left target (car removed from track) + *piLeftCarIdx = -1; // Clear invalid left target (car removed from track) *pfLeftTime = -10000.0; pCar->iLeftTargetIdx = -1; pCar->fLeftTargetTime = -10000.0; } - if (*piRightCarIdx >= 0 && Car[*piRightCarIdx].nCurrChunk == -1) // Validate right target car is still on track + if (*piRightCarIdx >= 0 && + Car[*piRightCarIdx].nCurrChunk == + -1) // Validate right target car is still on track { - *piRightCarIdx = -1; // Clear invalid right target (car removed from track) + *piRightCarIdx = + -1; // Clear invalid right target (car removed from track) *pfRightTime = -10000.0; pCar->iRightTargetIdx = -1; pCar->fRightTargetTime = -10000.0; @@ -4469,75 +5253,82 @@ void findnearcars(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *piRight } //------------------------------------------------------------------------------------------------- -//00031250 -void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *piRightCarIdx, float *pfRightTime, float *pfTargetX, float *pfTargetY) -{ - int iTrakLen; // esi - double dAbsSpeed; // st7 - int nCurrChunk; // ebx - tData *pTrackData; // ecx - double dTrackPos; // st7 - double dNewTrackPos; // st7 - int iNextChunk; // ebx - double dYPos; // st6 - double dTempX; // rt0 - double dTempY; // rt1 - double dTempZ; // st5 - tData *pCurrTrackData; // ecx - int iCarIdx; // edi - int iDriverIdx; // eax - int iChunkDiff; // ebx - double dOtherCarSpeed; // st7 - int iTrakLenTemp; // esi - int iChunkIdx; // ebx - int iCounter; // eax - double dDistanceCalc; // st7 - int iOtherCarChunk; // ebx - double dTempDistance; // st7 - signed int i; // ecx - int iSideFlag; // ebx - double dSpeedDiff; // st7 - float *pOutParam; // ebx - float fOutValue; // eax - float fSpeedForCalc; // [esp+1Ch] [ebp-54h] - float fStrategyValue; // [esp+20h] [ebp-50h] - float fTrackPos; // [esp+24h] [ebp-4Ch] - float fOwnSpeedForward; // [esp+28h] [ebp-48h] - int iLeftCarIdx; // [esp+2Ch] [ebp-44h] - int iRightCarIdx; // [esp+30h] [ebp-40h] - float fCarWidth; // [esp+34h] [ebp-3Ch] - float fTrackLength; // [esp+38h] [ebp-38h] - float fSpeedDiffCalc; // [esp+3Ch] [ebp-34h] - float fOtherCarSpeed; // [esp+40h] [ebp-30h] - float fForwardPos; // [esp+44h] [ebp-2Ch] - float fReversePos; // [esp+48h] [ebp-28h] - float fLeftTime; // [esp+4Ch] [ebp-24h] - float fRightTime; // [esp+50h] [ebp-20h] - int iCarLoopIdx; // [esp+54h] [ebp-1Ch] - float fTimeToCollision; // [esp+58h] [ebp-18h] +// 00031250 +void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, + int *piRightCarIdx, float *pfRightTime, float *pfTargetX, + float *pfTargetY) { + int iTrakLen; // esi + double dAbsSpeed; // st7 + int nCurrChunk; // ebx + tData *pTrackData; // ecx + double dTrackPos; // st7 + double dNewTrackPos; // st7 + int iNextChunk; // ebx + double dYPos; // st6 + double dTempX; // rt0 + double dTempY; // rt1 + double dTempZ; // st5 + tData *pCurrTrackData; // ecx + int iCarIdx; // edi + int iDriverIdx; // eax + int iChunkDiff; // ebx + double dOtherCarSpeed; // st7 + int iTrakLenTemp; // esi + int iChunkIdx; // ebx + int iCounter; // eax + double dDistanceCalc; // st7 + int iOtherCarChunk; // ebx + double dTempDistance; // st7 + signed int i; // ecx + int iSideFlag; // ebx + double dSpeedDiff; // st7 + float *pOutParam; // ebx + float fOutValue; // eax + float fSpeedForCalc; // [esp+1Ch] [ebp-54h] + float fStrategyValue; // [esp+20h] [ebp-50h] + float fTrackPos; // [esp+24h] [ebp-4Ch] + float fOwnSpeedForward; // [esp+28h] [ebp-48h] + int iLeftCarIdx; // [esp+2Ch] [ebp-44h] + int iRightCarIdx; // [esp+30h] [ebp-40h] + float fCarWidth; // [esp+34h] [ebp-3Ch] + float fTrackLength; // [esp+38h] [ebp-38h] + float fSpeedDiffCalc; // [esp+3Ch] [ebp-34h] + float fOtherCarSpeed; // [esp+40h] [ebp-30h] + float fForwardPos; // [esp+44h] [ebp-2Ch] + float fReversePos; // [esp+48h] [ebp-28h] + float fLeftTime; // [esp+4Ch] [ebp-24h] + float fRightTime; // [esp+50h] [ebp-20h] + int iCarLoopIdx; // [esp+54h] [ebp-1Ch] + float fTimeToCollision; // [esp+58h] [ebp-18h] int iNormalizedChunkDiff; // [esp+5Ch] [ebp-14h] - float fDistFromChunk; // [esp+60h] [ebp-10h] - float fDistance; // [esp+60h] [ebp-10h] - float fNegDistance; // [esp+60h] [ebp-10h] - float fAdjustedDistance; // [esp+60h] [ebp-10h] + float fDistFromChunk; // [esp+60h] [ebp-10h] + float fDistance; // [esp+60h] [ebp-10h] + float fNegDistance; // [esp+60h] [ebp-10h] + float fAdjustedDistance; // [esp+60h] [ebp-10h] iTrakLen = TRAK_LEN; - fStrategyValue = CarStrategy[pCar->iDriverIdx].fAvoidDistance;// Get AI strategy value for car avoidance distance - dAbsSpeed = fabs(pCar->fFinalSpeed); // Calculate absolute speed for distance scaling + fStrategyValue = + CarStrategy[pCar->iDriverIdx] + .fAvoidDistance; // Get AI strategy value for car avoidance distance + dAbsSpeed = + fabs(pCar->fFinalSpeed); // Calculate absolute speed for distance scaling if (dAbsSpeed < 450.0) { fSpeedForCalc = (float)dAbsSpeed; - fStrategyValue = (fStrategyValue + -1000.0f) * fSpeedForCalc * 0.0022222223f + 1000.0f; + fStrategyValue = + (fStrategyValue + -1000.0f) * fSpeedForCalc * 0.0022222223f + 1000.0f; } fLeftTime = -10000.0; fRightTime = -10000.0; nCurrChunk = pCar->nCurrChunk; iLeftCarIdx = -1; iRightCarIdx = -1; - if (pCar->iBobMode) // Calculate look-ahead position based on revenge mode + if (pCar->iBobMode) // Calculate look-ahead position based on revenge mode { - fReversePos = pCar->pos.fX - localdata[nCurrChunk].fTrackHalfLength - fStrategyValue; + fReversePos = + pCar->pos.fX - localdata[nCurrChunk].fTrackHalfLength - fStrategyValue; while (-2.0 * localdata[nCurrChunk].fTrackHalfLength > fReversePos) { - dNewTrackPos = 2.0 * localdata[nCurrChunk--].fTrackHalfLength + fReversePos; + dNewTrackPos = + 2.0 * localdata[nCurrChunk--].fTrackHalfLength + fReversePos; fReversePos = (float)dNewTrackPos; if (nCurrChunk < 0) nCurrChunk = TRAK_LEN - 1; @@ -4545,7 +5336,8 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi pTrackData = &localdata[nCurrChunk]; dTrackPos = fReversePos + pTrackData->fTrackHalfLength; } else { - fForwardPos = fStrategyValue + pCar->pos.fX + localdata[nCurrChunk].fTrackHalfLength; + fForwardPos = + fStrategyValue + pCar->pos.fX + localdata[nCurrChunk].fTrackHalfLength; while (1) { fTrackLength = 2.0f * localdata[nCurrChunk].fTrackHalfLength; if (fForwardPos <= (double)fTrackLength) @@ -4562,23 +5354,33 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi iNextChunk = nCurrChunk + 1; if (iNextChunk == TRAK_LEN) iNextChunk ^= TRAK_LEN; - dYPos = ((pTrackData->fTrackHalfLength - fTrackPos) * *(&pTrackData->fAILine1 + pCar->iAICurrentLine) - + (fTrackPos + pTrackData->fTrackHalfLength) * *(&localdata[iNextChunk].fAILine1 + pCar->iAICurrentLine)) - / (pTrackData->fTrackHalfLength - * 2.0); - dTempX = pTrackData->pointAy[1].fX * fTrackPos + pTrackData->pointAy[1].fY * dYPos - pTrackData->pointAy[3].fY; - dTempY = pTrackData->pointAy[0].fY * dYPos + pTrackData->pointAy[0].fX * fTrackPos - pTrackData->pointAy[3].fX; - dTempZ = fTrackPos * pTrackData->pointAy[2].fX + dYPos * pTrackData->pointAy[2].fY - pTrackData->pointAy[3].fZ; + dYPos = ((pTrackData->fTrackHalfLength - fTrackPos) * + *(&pTrackData->fAILine1 + pCar->iAICurrentLine) + + (fTrackPos + pTrackData->fTrackHalfLength) * + *(&localdata[iNextChunk].fAILine1 + pCar->iAICurrentLine)) / + (pTrackData->fTrackHalfLength * 2.0); + dTempX = pTrackData->pointAy[1].fX * fTrackPos + + pTrackData->pointAy[1].fY * dYPos - pTrackData->pointAy[3].fY; + dTempY = pTrackData->pointAy[0].fY * dYPos + + pTrackData->pointAy[0].fX * fTrackPos - pTrackData->pointAy[3].fX; + dTempZ = fTrackPos * pTrackData->pointAy[2].fX + + dYPos * pTrackData->pointAy[2].fY - pTrackData->pointAy[3].fZ; pCurrTrackData = &localdata[pCar->nCurrChunk]; - *pfTargetX = (float)((dTempX + pCurrTrackData->pointAy[3].fY) * pCurrTrackData->pointAy[1].fX - + (dTempY + pCurrTrackData->pointAy[3].fX) * pCurrTrackData->pointAy[0].fX - + (dTempZ + pCurrTrackData->pointAy[3].fZ) * pCurrTrackData->pointAy[2].fX); - *pfTargetY = (float)((dTempY + pCurrTrackData->pointAy[3].fX) * pCurrTrackData->pointAy[0].fY - + (dTempX + pCurrTrackData->pointAy[3].fY) * pCurrTrackData->pointAy[1].fY - + (dTempZ + pCurrTrackData->pointAy[3].fZ) * pCurrTrackData->pointAy[2].fY); + *pfTargetX = (float)((dTempX + pCurrTrackData->pointAy[3].fY) * + pCurrTrackData->pointAy[1].fX + + (dTempY + pCurrTrackData->pointAy[3].fX) * + pCurrTrackData->pointAy[0].fX + + (dTempZ + pCurrTrackData->pointAy[3].fZ) * + pCurrTrackData->pointAy[2].fX); + *pfTargetY = (float)((dTempY + pCurrTrackData->pointAy[3].fX) * + pCurrTrackData->pointAy[0].fY + + (dTempX + pCurrTrackData->pointAy[3].fY) * + pCurrTrackData->pointAy[1].fY + + (dTempZ + pCurrTrackData->pointAy[3].fZ) * + pCurrTrackData->pointAy[2].fY); iCarLoopIdx = 0; fOwnSpeedForward = pCar->fFinalSpeed * tcos[pCar->nActualYaw & 0x3FFF]; - if (numcars > 0) // Main loop: check all cars for collision threats + if (numcars > 0) // Main loop: check all cars for collision threats { iCarIdx = 0; do { @@ -4592,13 +5394,16 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi iNormalizedChunkDiff = iChunkDiff + iTrakLen; if (iTrakLen / 2 < iNormalizedChunkDiff) iNormalizedChunkDiff -= iTrakLen; - dOtherCarSpeed = Car[iCarIdx].fFinalSpeed * tcos[Car[iCarIdx].nActualYaw & 0x3FFF]; + dOtherCarSpeed = + Car[iCarIdx].fFinalSpeed * tcos[Car[iCarIdx].nActualYaw & 0x3FFF]; TRAK_LEN = iTrakLen; fOtherCarSpeed = (float)dOtherCarSpeed; - if (Car[iCarIdx].iControlType != 3 - || fabs((double)iNormalizedChunkDiff / (fOwnSpeedForward - fOtherCarSpeed)) >= 0.2f - || !linevalid(pCar->nCurrChunk, pCar->pos.fY, Car[iCarIdx].pos.fY)) { - goto LABEL_67; // Check if car is AI-controlled and within collision range + if (Car[iCarIdx].iControlType != 3 || + fabs((double)iNormalizedChunkDiff / + (fOwnSpeedForward - fOtherCarSpeed)) >= 0.2f || + !linevalid(pCar->nCurrChunk, pCar->pos.fY, Car[iCarIdx].pos.fY)) { + goto LABEL_67; // Check if car is AI-controlled and within collision + // range } iTrakLenTemp = TRAK_LEN; if (iNormalizedChunkDiff <= 0) { @@ -4606,29 +5411,38 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi fDistance = Car[iCarIdx].pos.fX - pCar->pos.fX; } else { iOtherCarChunk = Car[iCarIdx].nCurrChunk; - fNegDistance = -(localdata[iOtherCarChunk].fTrackHalfLength - Car[iCarIdx].pos.fX); - dTempDistance = fNegDistance - (localdata[pCar->nCurrChunk].fTrackHalfLength + pCar->pos.fX); - for (i = 1; ; ++i) { + fNegDistance = -(localdata[iOtherCarChunk].fTrackHalfLength - + Car[iCarIdx].pos.fX); + dTempDistance = + fNegDistance - + (localdata[pCar->nCurrChunk].fTrackHalfLength + pCar->pos.fX); + for (i = 1;; ++i) { ++iOtherCarChunk; fDistance = (float)dTempDistance; if (i >= (int)abs(iNormalizedChunkDiff)) break; if (iOtherCarChunk >= TRAK_LEN) iOtherCarChunk -= TRAK_LEN; - dTempDistance = fDistance - 2.0 * localdata[iOtherCarChunk].fTrackHalfLength; + dTempDistance = + fDistance - 2.0 * localdata[iOtherCarChunk].fTrackHalfLength; } iTrakLenTemp = TRAK_LEN; if (fDistance > 0.0) fDistance = 0.0; } } else { - fDistFromChunk = localdata[pCar->nCurrChunk].fTrackHalfLength - pCar->pos.fX; + fDistFromChunk = + localdata[pCar->nCurrChunk].fTrackHalfLength - pCar->pos.fX; iChunkIdx = pCar->nCurrChunk + 1; iCounter = 1; - for (fDistance = localdata[Car[iCarIdx].nCurrChunk].fTrackHalfLength + Car[iCarIdx].pos.fX + fDistFromChunk; iCounter < iNormalizedChunkDiff; fDistance = (float)dDistanceCalc) { + for (fDistance = localdata[Car[iCarIdx].nCurrChunk].fTrackHalfLength + + Car[iCarIdx].pos.fX + fDistFromChunk; + iCounter < iNormalizedChunkDiff; + fDistance = (float)dDistanceCalc) { if (iChunkIdx >= TRAK_LEN) iChunkIdx -= TRAK_LEN; - dDistanceCalc = 2.0 * localdata[iChunkIdx].fTrackHalfLength + fDistance; + dDistanceCalc = + 2.0 * localdata[iChunkIdx].fTrackHalfLength + fDistance; ++iCounter; ++iChunkIdx; } @@ -4650,7 +5464,10 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi dSpeedDiff = fOwnSpeedForward - fOtherCarSpeed; if (fabs(dSpeedDiff) >= 0.0001) { fSpeedDiffCalc = (float)dSpeedDiff; - fTimeToCollision = fAdjustedDistance / (36.0f * fSpeedDiffCalc);// Calculate time to collision based on relative speed + fTimeToCollision = + fAdjustedDistance / + (36.0f * fSpeedDiffCalc); // Calculate time to collision based on + // relative speed } else { fTimeToCollision = -10000.0; } @@ -4683,7 +5500,8 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi ++iCarLoopIdx; } while (iCarLoopIdx < numcars); } - if (pCar->iBobMode) // Return results: left/right car indices and collision times + if (pCar->iBobMode) // Return results: left/right car indices and collision + // times { *piLeftCarIdx = iRightCarIdx; *piRightCarIdx = iLeftCarIdx; @@ -4702,180 +5520,215 @@ void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *pi } //------------------------------------------------------------------------------------------------- -//00031870 -double interpolatesteer(float fSteeringInput, float fSaturationThreshold, float fDeadzoneThreshold, float fMaxOutput, float fMinOutput) -{ +// 00031870 +double interpolatesteer(float fSteeringInput, float fSaturationThreshold, + float fDeadzoneThreshold, float fMaxOutput, + float fMinOutput) { double dAbsInput; // st7 - float fAbsInput; // [esp+Ch] [ebp+4h] + float fAbsInput; // [esp+Ch] [ebp+4h] - dAbsInput = fabs(fSteeringInput); // Get absolute value of steering input + dAbsInput = fabs(fSteeringInput); // Get absolute value of steering input fAbsInput = (float)dAbsInput; - if (dAbsInput <= fSaturationThreshold) // Check if input exceeds saturation threshold - { // Check if input is in deadzone + if (dAbsInput <= + fSaturationThreshold) // Check if input exceeds saturation threshold + { // Check if input is in deadzone if (fAbsInput < (double)fDeadzoneThreshold) - return fMinOutput; // Return minimum output value (deadzone) - return (float)(((fAbsInput - fDeadzoneThreshold) * fMaxOutput - (fAbsInput - fSaturationThreshold) * fMinOutput) / (fSaturationThreshold - fDeadzoneThreshold));// Linear interpolation between deadzone and saturation + return fMinOutput; // Return minimum output value (deadzone) + return (float)(((fAbsInput - fDeadzoneThreshold) * fMaxOutput - + (fAbsInput - fSaturationThreshold) * fMinOutput) / + (fSaturationThreshold - + fDeadzoneThreshold)); // Linear interpolation between + // deadzone and saturation } else { - return fMaxOutput; // Return maximum output value (saturation) + return fMaxOutput; // Return maximum output value (saturation) } } //------------------------------------------------------------------------------------------------- -//000318F0 -double avoid( - int iCurrentCarIdx, - int iTargetCarIdx, - float fSteeringInput, - float fMaxOutput, - float fSaturationThreshold, - float fDeadzoneThreshold, - int *piOvertakeFlag) -{ - int iDriverOffset; // eax - double dTargetY; // st7 - float fMinRange; // [esp+0h] [ebp-30h] BYREF - float fMaxRange; // [esp+4h] [ebp-2Ch] BYREF +// 000318F0 +double avoid(int iCurrentCarIdx, int iTargetCarIdx, float fSteeringInput, + float fMaxOutput, float fSaturationThreshold, + float fDeadzoneThreshold, int *piOvertakeFlag) { + int iDriverOffset; // eax + double dTargetY; // st7 + float fMinRange; // [esp+0h] [ebp-30h] BYREF + float fMaxRange; // [esp+4h] [ebp-2Ch] BYREF float fCenterRange; // [esp+8h] [ebp-28h] - float fTargetY; // [esp+Ch] [ebp-24h] - float fLowerBound; // [esp+10h] [ebp-20h] - float fUpperBound; // [esp+14h] [ebp-1Ch] + float fTargetY; // [esp+Ch] [ebp-24h] + float fLowerBound; // [esp+10h] [ebp-20h] + float fUpperBound; // [esp+14h] [ebp-1Ch] - *piOvertakeFlag = 0; // Initialize collision flag to no collision - if (iTargetCarIdx != -1 && fSteeringInput < fabs(fSaturationThreshold))// Check if target car exists and steering input is within saturation threshold + *piOvertakeFlag = 0; // Initialize collision flag to no collision + if (iTargetCarIdx != -1 && + fSteeringInput < + fabs(fSaturationThreshold)) // Check if target car exists and steering + // input is within saturation threshold { - fUpperBound = CarBaseY + Car[iTargetCarIdx].fCarHalfWidth + 200.0f + Car[iTargetCarIdx].pos.fY;// Calculate upper avoidance boundary (car position + half width + safety margin) - fLowerBound = -CarBaseY - Car[iTargetCarIdx].fCarHalfWidth + -200.0f + Car[iTargetCarIdx].pos.fY;// Calculate lower avoidance boundary (car position - half width - safety margin) - if (fMaxOutput < (double)fUpperBound && fMaxOutput >(double)fLowerBound)// Check if our car Y position is within avoidance zone + fUpperBound = + CarBaseY + Car[iTargetCarIdx].fCarHalfWidth + 200.0f + + Car[iTargetCarIdx].pos.fY; // Calculate upper avoidance boundary (car + // position + half width + safety margin) + fLowerBound = + -CarBaseY - Car[iTargetCarIdx].fCarHalfWidth + -200.0f + + Car[iTargetCarIdx].pos.fY; // Calculate lower avoidance boundary (car + // position - half width - safety margin) + if (fMaxOutput < (double)fUpperBound && + fMaxOutput > (double)fLowerBound) // Check if our car Y position is + // within avoidance zone { - driverange(&Car[iTargetCarIdx], &fMinRange, &fMaxRange);// Get driving range boundaries for target car - iDriverOffset = iCurrentCarIdx + Car[iTargetCarIdx].iDriverIdx;// Calculate combined driver index for avoidance direction - fCenterRange = (fMinRange + fMaxRange) * 0.5f;// Calculate center of driving range - if ((iDriverOffset & 1) != 0) // Choose avoidance direction based on driver index parity - dTargetY = Car[iTargetCarIdx].pos.fY + -100.0;// Odd driver index: avoid by going down (-100 offset) + driverange(&Car[iTargetCarIdx], &fMinRange, + &fMaxRange); // Get driving range boundaries for target car + iDriverOffset = + iCurrentCarIdx + + Car[iTargetCarIdx].iDriverIdx; // Calculate combined driver index for + // avoidance direction + fCenterRange = + (fMinRange + fMaxRange) * 0.5f; // Calculate center of driving range + if ((iDriverOffset & 1) != + 0) // Choose avoidance direction based on driver index parity + dTargetY = + Car[iTargetCarIdx].pos.fY + + -100.0; // Odd driver index: avoid by going down (-100 offset) else - dTargetY = Car[iTargetCarIdx].pos.fY + 100.0;// Even driver index: avoid by going up (+100 offset) + dTargetY = Car[iTargetCarIdx].pos.fY + + 100.0; // Even driver index: avoid by going up (+100 offset) fTargetY = (float)dTargetY; - if (fTargetY <= (double)fCenterRange) { // Adjust upper boundary to minimum range if needed + if (fTargetY <= (double)fCenterRange) { // Adjust upper boundary to + // minimum range if needed if (fUpperBound > (double)fMinRange) { fUpperBound = fMinRange; - if (fSteeringInput > 0.0 - && Car[iCurrentCarIdx].fFinalSpeed > 80.0 - && Car[iCurrentCarIdx].fFinalSpeed > Car[iTargetCarIdx].fFinalSpeed * tcos[Car[iTargetCarIdx].nActualYaw] + 120.0)// Check for aggressive overtaking conditions (speed advantage) + if (fSteeringInput > 0.0 && Car[iCurrentCarIdx].fFinalSpeed > 80.0 && + Car[iCurrentCarIdx].fFinalSpeed > + Car[iTargetCarIdx].fFinalSpeed * + tcos[Car[iTargetCarIdx].nActualYaw] + + 120.0) // Check for aggressive overtaking conditions + // (speed advantage) { *piOvertakeFlag = -1; } } if (fMaxOutput <= (double)fUpperBound) - return (float)interpolatesteer(fSteeringInput, fSaturationThreshold, fDeadzoneThreshold, fMaxOutput, fUpperBound);// Return interpolated steering to avoid upper boundary - } else { // Adjust lower boundary to maximum range if needed + return (float)interpolatesteer( + fSteeringInput, fSaturationThreshold, fDeadzoneThreshold, + fMaxOutput, fUpperBound); // Return interpolated steering to avoid + // upper boundary + } else { // Adjust lower boundary to maximum range if needed if (fLowerBound < (double)fMaxRange) { fLowerBound = fMaxRange; - if (fSteeringInput > 0.0 - && Car[iCurrentCarIdx].fFinalSpeed > 80.0 - && Car[iCurrentCarIdx].fFinalSpeed > Car[iTargetCarIdx].fFinalSpeed * tcos[Car[iTargetCarIdx].nActualYaw] + 120.0)// Check for aggressive overtaking conditions (speed advantage) + if (fSteeringInput > 0.0 && Car[iCurrentCarIdx].fFinalSpeed > 80.0 && + Car[iCurrentCarIdx].fFinalSpeed > + Car[iTargetCarIdx].fFinalSpeed * + tcos[Car[iTargetCarIdx].nActualYaw] + + 120.0) // Check for aggressive overtaking conditions + // (speed advantage) { *piOvertakeFlag = -1; } } if (fMaxOutput >= (double)fLowerBound) - return (float)interpolatesteer(fSteeringInput, fSaturationThreshold, fDeadzoneThreshold, fMaxOutput, fLowerBound);// Return interpolated steering to avoid lower boundary + return (float)interpolatesteer( + fSteeringInput, fSaturationThreshold, fDeadzoneThreshold, + fMaxOutput, fLowerBound); // Return interpolated steering to avoid + // lower boundary } } } - return fMaxOutput; // No avoidance needed, return original steering value + return fMaxOutput; // No avoidance needed, return original steering value } //------------------------------------------------------------------------------------------------- -//00031B40 -double block(int iCarIdx, float fSteeringInput, float fMaxOutput, float fSaturationThreshold, float fDeadzoneThreshold) -{ +// 00031B40 +double block(int iCarIdx, float fSteeringInput, float fMaxOutput, + float fSaturationThreshold, float fDeadzoneThreshold) { if (iCarIdx == -1) return fMaxOutput; else - return (float)interpolatesteer(fSteeringInput, fSaturationThreshold, fDeadzoneThreshold, fMaxOutput, Car[iCarIdx].pos.fY); + return (float)interpolatesteer(fSteeringInput, fSaturationThreshold, + fDeadzoneThreshold, fMaxOutput, + Car[iCarIdx].pos.fY); } //------------------------------------------------------------------------------------------------- -//00031BA0 -void autocar2(tCar *pCar) -{ - tCarStrategy *pStrategy; // ebp - int iCountdown; // ebx - int iCurrChunk; // edx - double dAIMaxSpeed; // st7 - int iHumanBestPosition; // edi - int iCarIdx; // eax - int iLoopIdx; // edx - int iCarArrayIdx; // ebx - int byRacePosition; // ecx - int iPositionDifference; // eax - double dSpeedAdjustment; // st7 - double dSpeedReduction; // st7 - int iCurrentPosition; // eax - double dReducedSpeed; // st7 - double dSpeedDifference; // st7 - int iSelectedStrategy; // edi +// 00031BA0 +void autocar2(tCar *pCar) { + tCarStrategy *pStrategy; // ebp + int iCountdown; // ebx + int iCurrChunk; // edx + double dAIMaxSpeed; // st7 + int iHumanBestPosition; // edi + int iCarIdx; // eax + int iLoopIdx; // edx + int iCarArrayIdx; // ebx + int byRacePosition; // ecx + int iPositionDifference; // eax + double dSpeedAdjustment; // st7 + double dSpeedReduction; // st7 + int iCurrentPosition; // eax + double dReducedSpeed; // st7 + double dSpeedDifference; // st7 + int iSelectedStrategy; // edi double dTargetReducedSpeed; // st7 - double dSpeedDelta; // st7 - uint8 byCurrentRacePos; // bl - int iCurrentChunk; // ebx - int iRandomPitStop; // eax - int iPitStopTaken; // ebx - int iCarLoopIdx; // eax - int iChunkForPitStop; // eax - int iPrevChunk; // eax - int iPlayerType; // eax - double dAvoidanceY; // st7 - int iAITargetCar; // eax - float fInterpolatedY; // eax - int iTargetAngle; // eax - double dAvoidanceResult; // st7 - double dYPositionDiff; // st7 - double dTargetCarSpeed; // st7 - double dSpeedDiffCalc; // st7 + double dSpeedDelta; // st7 + uint8 byCurrentRacePos; // bl + int iCurrentChunk; // ebx + int iRandomPitStop; // eax + int iPitStopTaken; // ebx + int iCarLoopIdx; // eax + int iChunkForPitStop; // eax + int iPrevChunk; // eax + int iPlayerType; // eax + double dAvoidanceY; // st7 + int iAITargetCar; // eax + float fInterpolatedY; // eax + int iTargetAngle; // eax + double dAvoidanceResult; // st7 + double dYPositionDiff; // st7 + double dTargetCarSpeed; // st7 + double dSpeedDiffCalc; // st7 //__int16 nFPUStatus; // fps - double dCalculatedAngle; // st7 - int iSteeringSensitivity; // eax - int iRandomValue; // eax - double fRPMRatio; // [esp+0h] [ebp-ACh] - float fRightTime; // [esp+8h] [ebp-A4h] BYREF - float fLeftTime; // [esp+Ch] [ebp-A0h] BYREF - int iLeftCarIdx; // [esp+10h] [ebp-9Ch] BYREF - float fTargetY; // [esp+14h] [ebp-98h] BYREF - int iRightCarIdx; // [esp+18h] [ebp-94h] BYREF - float fTargetX; // [esp+1Ch] [ebp-90h] BYREF - int iActionFlag; // [esp+20h] [ebp-8Ch] BYREF - float fDeltaX; // [esp+24h] [ebp-88h] - float fDeltaXCopy; // [esp+28h] [ebp-84h] - float fDragCoefficient; // [esp+2Ch] [ebp-80h] - float fStrategyParam1; // [esp+30h] [ebp-7Ch] - float fDeltaYCopy; // [esp+34h] [ebp-78h] - float fSteerSensitivity; // [esp+38h] [ebp-74h] - float fStrategyA1; // [esp+3Ch] [ebp-70h] + double dCalculatedAngle; // st7 + int iSteeringSensitivity; // eax + int iRandomValue; // eax + double fRPMRatio; // [esp+0h] [ebp-ACh] + float fRightTime; // [esp+8h] [ebp-A4h] BYREF + float fLeftTime; // [esp+Ch] [ebp-A0h] BYREF + int iLeftCarIdx; // [esp+10h] [ebp-9Ch] BYREF + float fTargetY; // [esp+14h] [ebp-98h] BYREF + int iRightCarIdx; // [esp+18h] [ebp-94h] BYREF + float fTargetX; // [esp+1Ch] [ebp-90h] BYREF + int iActionFlag; // [esp+20h] [ebp-8Ch] BYREF + float fDeltaX; // [esp+24h] [ebp-88h] + float fDeltaXCopy; // [esp+28h] [ebp-84h] + float fDragCoefficient; // [esp+2Ch] [ebp-80h] + float fStrategyParam1; // [esp+30h] [ebp-7Ch] + float fDeltaYCopy; // [esp+34h] [ebp-78h] + float fSteerSensitivity; // [esp+38h] [ebp-74h] + float fStrategyA1; // [esp+3Ch] [ebp-70h] float fSteerSensitivity_1; // [esp+40h] [ebp-6Ch] - float fStrategyA0_3; // [esp+44h] [ebp-68h] - float fTrackDistance; // [esp+48h] [ebp-64h] - float fStrategyParam2; // [esp+4Ch] [ebp-60h] - float fCalculatedY; // [esp+50h] [ebp-5Ch] - float fLeftInterpolated; // [esp+54h] [ebp-58h] - float fDeltaY; // [esp+58h] [ebp-54h] - float fRightInterpolated; // [esp+5Ch] [ebp-50h] - float fDefensiveY; // [esp+60h] [ebp-4Ch] - float fForwardSpeed; // [esp+64h] [ebp-48h] - int iAccelerationControl; // [esp+68h] [ebp-44h] - int iPitZoneFlag; // [esp+6Ch] [ebp-40h] - int iLastLapFlag; // [esp+70h] [ebp-3Ch] - float fMaxEngineSpeed; // [esp+74h] [ebp-38h] - tCarEngine *pEngine; // [esp+78h] [ebp-34h] - int iDistanceToTarget; // [esp+7Ch] [ebp-30h] - int iAITargetSpeed; // [esp+80h] [ebp-2Ch] - float fTargetSteerY; // [esp+84h] [ebp-28h] - int iPitStopTarget; // [esp+88h] [ebp-24h] - int iAIThrottleControl; // [esp+8Ch] [ebp-20h] - int iHumanCarIdx; // [esp+90h] [ebp-1Ch] + float fStrategyA0_3; // [esp+44h] [ebp-68h] + float fTrackDistance; // [esp+48h] [ebp-64h] + float fStrategyParam2; // [esp+4Ch] [ebp-60h] + float fCalculatedY; // [esp+50h] [ebp-5Ch] + float fLeftInterpolated; // [esp+54h] [ebp-58h] + float fDeltaY; // [esp+58h] [ebp-54h] + float fRightInterpolated; // [esp+5Ch] [ebp-50h] + float fDefensiveY; // [esp+60h] [ebp-4Ch] + float fForwardSpeed; // [esp+64h] [ebp-48h] + int iAccelerationControl; // [esp+68h] [ebp-44h] + int iPitZoneFlag; // [esp+6Ch] [ebp-40h] + int iLastLapFlag; // [esp+70h] [ebp-3Ch] + float fMaxEngineSpeed; // [esp+74h] [ebp-38h] + tCarEngine *pEngine; // [esp+78h] [ebp-34h] + int iDistanceToTarget; // [esp+7Ch] [ebp-30h] + int iAITargetSpeed; // [esp+80h] [ebp-2Ch] + float fTargetSteerY; // [esp+84h] [ebp-28h] + int iPitStopTarget; // [esp+88h] [ebp-24h] + int iAIThrottleControl; // [esp+8Ch] [ebp-20h] + int iHumanCarIdx; // [esp+90h] [ebp-1Ch] iActionFlag = 0; - pEngine = &CarEngines.engines[pCar->byCarDesignIdx];// Initialize car engine and strategy pointers + pEngine = &CarEngines.engines[pCar->byCarDesignIdx]; // Initialize car engine + // and strategy pointers pStrategy = &CarStrategy[pCar->iDriverIdx]; fDragCoefficient = pEngine->fDragCoefficient; iCountdown = pCar->iAIUpdateTimer - 1; @@ -4886,27 +5739,32 @@ void autocar2(tCar *pCar) changestrategy(pCar); changeline(pCar); iCurrChunk = pCar->nCurrChunk; - dAIMaxSpeed = localdata[iCurrChunk].fAIMaxSpeed;// Calculate AI maximum speed based on track chunk + dAIMaxSpeed = + localdata[iCurrChunk] + .fAIMaxSpeed; // Calculate AI maximum speed based on track chunk //_CHP(); - //LOBYTE(iCurrChunk) = HIBYTE(TrakColour[iCurrChunk][1]); + // LOBYTE(iCurrChunk) = HIBYTE(TrakColour[iCurrChunk][1]); iAITargetSpeed = (int)dAIMaxSpeed; if ((TrakColour[iCurrChunk][1] & SURFACE_FLAG_AI_MAX_SPEED) == 0) { - //if ((iCurrChunk & 0x10) == 0) { + // if ((iCurrChunk & 0x10) == 0) { if (!winner_mode) { - fMaxEngineSpeed = fMaxEngineSpeed * levels[level] * 0.01f;// Apply difficulty level scaling to AI maximum speed + fMaxEngineSpeed = + fMaxEngineSpeed * levels[level] * + 0.01f; // Apply difficulty level scaling to AI maximum speed if ((double)iAITargetSpeed > fMaxEngineSpeed) { //_CHP(); iAITargetSpeed = (int)fMaxEngineSpeed; } } - //LODWORD(fDeltaX) = 2 * pCar->byRacePosition; + // LODWORD(fDeltaX) = 2 * pCar->byRacePosition; iHumanBestPosition = 1000; if (pCar->fTotalRaceTime <= 80.0 - (double)(2 * pCar->byRacePosition)) - //if (pCar->fTotalRaceTime <= 80.0 - (double)SLODWORD(fDeltaX)) + // if (pCar->fTotalRaceTime <= 80.0 - (double)SLODWORD(fDeltaX)) goto LABEL_18; iHumanCarIdx = -1; iCarIdx = 0; - if (numcars > 0) // Find human player with best race position for AI targeting + if (numcars > + 0) // Find human player with best race position for AI targeting { iLoopIdx = 0; iCarArrayIdx = 0; @@ -4923,13 +5781,20 @@ void autocar2(tCar *pCar) ++iCarArrayIdx; } while (iCarIdx < numcars); } - iPositionDifference = (char)pCar->byLapNumber * TRAK_LEN + pCar->nCurrChunk - (TRAK_LEN * (char)Car[iHumanCarIdx].byLapNumber + Car[iHumanCarIdx].nCurrChunk);// Calculate position difference between AI car and leading human player + iPositionDifference = + (char)pCar->byLapNumber * TRAK_LEN + pCar->nCurrChunk - + (TRAK_LEN * (char)Car[iHumanCarIdx].byLapNumber + + Car[iHumanCarIdx].nCurrChunk); // Calculate position difference between + // AI car and leading human player if (iPositionDifference < 80) { - if (iPositionDifference <= 20) { // Special logic for car design 13 (boss car) - reduce speed when near human player + if (iPositionDifference <= + 20) { // Special logic for car design 13 (boss car) - reduce speed + // when near human player LABEL_18: if (pCar->byCarDesignIdx == 13) { iCurrentPosition = pCar->byRacePosition; - if (iCurrentPosition < iHumanBestPosition && iCurrentPosition + 4 >= iHumanBestPosition) { + if (iCurrentPosition < iHumanBestPosition && + iCurrentPosition + 4 >= iHumanBestPosition) { if (Car[iHumanCarIdx].fFinalSpeed <= 200.0) { dReducedSpeed = Car[iHumanCarIdx].fFinalSpeed + -20.0; //_CHP(); @@ -4941,10 +5806,12 @@ void autocar2(tCar *pCar) } goto LABEL_24; } - //LODWORD(fDeltaX) = iPositionDifference - 20; + // LODWORD(fDeltaX) = iPositionDifference - 20; dSpeedReduction = (double)(iPositionDifference - 20) * mineff[level]; - //LODWORD(fDeltaX) = iPositionDifference - 80; - dSpeedAdjustment = ((double)(iPositionDifference - 80) - dSpeedReduction) * -0.016666668 * (double)iAITargetSpeed; + // LODWORD(fDeltaX) = iPositionDifference - 80; + dSpeedAdjustment = + ((double)(iPositionDifference - 80) - dSpeedReduction) * + -0.016666668 * (double)iAITargetSpeed; } else { dSpeedAdjustment = (double)iAITargetSpeed * mineff[level]; } @@ -4955,8 +5822,8 @@ void autocar2(tCar *pCar) LABEL_24: if (pCar->iBobMode) { if (tcos[pCar->nYaw] > 0.0) - LABEL_28: - iAITargetSpeed = 25; + LABEL_28: + iAITargetSpeed = 25; } else if (tcos[pCar->nYaw] < 0.0) { goto LABEL_28; } @@ -4964,15 +5831,23 @@ void autocar2(tCar *pCar) //_CHP(); iAIThrottleControl = (int)dSpeedDifference; iAccelerationControl = (int)dSpeedDifference; - findnearcars(pCar, &iLeftCarIdx, &fLeftTime, &iRightCarIdx, &fRightTime, &fTargetX, &fTargetY);// Find nearby cars for collision avoidance and targeting + findnearcars( + pCar, &iLeftCarIdx, &fLeftTime, &iRightCarIdx, &fRightTime, &fTargetX, + &fTargetY); // Find nearby cars for collision avoidance and targeting iSelectedStrategy = pCar->iSelectedStrategy; - if (pCar->fHealth >= 30.0) // AI strategy selection based on car health and nearby cars + if (pCar->fHealth >= + 30.0) // AI strategy selection based on car health and nearby cars { if (iRightCarIdx == -1 || fRightTime < 0.0) { if (iLeftCarIdx != -1 && fLeftTime >= 0.0) { if (Car[iLeftCarIdx].fHealth < 25.0 && !finished_car[iLeftCarIdx]) - iSelectedStrategy = Car[iLeftCarIdx].fHealth > 0.0 && ((uint8)iRightCarIdx & (pCar->iDriverIdx == 65534) & 0xFE) == 0 && pCar->fHealth >= 40.0; - if (human_control[iLeftCarIdx] && ((cheat_mode & 2) != 0 || pCar->byCarDesignIdx == 13) && Car[iLeftCarIdx].fHealth > 0.0 && !finished_car[iLeftCarIdx]) { + iSelectedStrategy = + Car[iLeftCarIdx].fHealth > 0.0 && + ((uint8)iRightCarIdx & (pCar->iDriverIdx == 65534) & 0xFE) == 0 && + pCar->fHealth >= 40.0; + if (human_control[iLeftCarIdx] && + ((cheat_mode & 2) != 0 || pCar->byCarDesignIdx == 13) && + Car[iLeftCarIdx].fHealth > 0.0 && !finished_car[iLeftCarIdx]) { iSelectedStrategy = 1; if (pCar->byCarDesignIdx == 13 && fLeftTime < 3.0) { dTargetReducedSpeed = Car[iLeftCarIdx].fFinalSpeed + -20.0; @@ -4986,12 +5861,16 @@ void autocar2(tCar *pCar) } } else { if (Car[iRightCarIdx].fHealth < 25.0 && !finished_car[iRightCarIdx]) { - if (Car[iRightCarIdx].fHealth <= 0.0 || ((uint8)iRightCarIdx & (pCar->iDriverIdx == 65534) & 0xFE) != 0 || pCar->fHealth < 40.0) + if (Car[iRightCarIdx].fHealth <= 0.0 || + ((uint8)iRightCarIdx & (pCar->iDriverIdx == 65534) & 0xFE) != 0 || + pCar->fHealth < 40.0) iSelectedStrategy = 0; else iSelectedStrategy = 3; } - if (human_control[iRightCarIdx] && ((cheat_mode & 2) != 0 || pCar->byCarDesignIdx == 13) && Car[iRightCarIdx].fHealth > 0.0 && !finished_car[iRightCarIdx]) { + if (human_control[iRightCarIdx] && + ((cheat_mode & 2) != 0 || pCar->byCarDesignIdx == 13) && + Car[iRightCarIdx].fHealth > 0.0 && !finished_car[iRightCarIdx]) { iSelectedStrategy = 3; iAccelerationControl = 1; } @@ -4999,19 +5878,26 @@ void autocar2(tCar *pCar) } else { pCar->iSelectedStrategy = 0; } - if (iRightCarIdx != -1 && iSelectedStrategy == 3 && Car[iRightCarIdx].byDebugDamage) + if (iRightCarIdx != -1 && iSelectedStrategy == 3 && + Car[iRightCarIdx].byDebugDamage) iSelectedStrategy = 0; - if (iLeftCarIdx != -1 && Car[iLeftCarIdx].byDebugDamage && iSelectedStrategy <= 3) + if (iLeftCarIdx != -1 && Car[iLeftCarIdx].byDebugDamage && + iSelectedStrategy <= 3) iSelectedStrategy = 0; - if (iLeftCarIdx != -1 && pCar->byRacePosition < 4u && pCar->byRacePosition - Car[iLeftCarIdx].byRacePosition > 2 && !human_control[iLeftCarIdx]) + if (iLeftCarIdx != -1 && pCar->byRacePosition < 4u && + pCar->byRacePosition - Car[iLeftCarIdx].byRacePosition > 2 && + !human_control[iLeftCarIdx]) iSelectedStrategy = 0; if (iRightCarIdx != -1) { byCurrentRacePos = pCar->byRacePosition; - //left car check added by ROLLER, todo look at asm and see if correct - if (byCurrentRacePos < 4u && iLeftCarIdx != -1 && byCurrentRacePos - Car[iLeftCarIdx].byRacePosition > 2 && !human_control[iLeftCarIdx]) + // left car check added by ROLLER, todo look at asm and see if correct + if (byCurrentRacePos < 4u && iLeftCarIdx != -1 && + byCurrentRacePos - Car[iLeftCarIdx].byRacePosition > 2 && + !human_control[iLeftCarIdx]) iSelectedStrategy = 0; } - if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_AI_FAST_STRAT) == 0)// Check if car is in not in go fast zone + if ((TrakColour[pCar->nCurrChunk][1] & SURFACE_FLAG_AI_FAST_STRAT) == + 0) // Check if car is in not in go fast zone iAIThrottleControl = iAccelerationControl; else iSelectedStrategy = 4; @@ -5029,7 +5915,8 @@ void autocar2(tCar *pCar) if (!iPitZoneFlag || pCar->fHealth >= 60.0 || iLastLapFlag) { pCar->iAITargetCar = -1; } else if (pCar->iAITargetCar == -1) { - iRandomPitStop = ROLLERrandRaw(); // Select random pit stop target for AI car + iRandomPitStop = + ROLLERrandRaw(); // Select random pit stop target for AI car iPitStopTaken = 0; iPitStopTarget = stops[GetHighOrderRand(numstops, iRandomPitStop)]; if (numcars > 0) { @@ -5045,7 +5932,8 @@ void autocar2(tCar *pCar) } if (iPitZoneFlag && !pCar->iAICurrentLine && !iLastLapFlag) { iSelectedStrategy = pCar->fHealth >= 60.0 ? 0 : 5; - if (pCar->fHealth < 90.0) // Force pit stop strategy (5) if health is low and in pit zone + if (pCar->fHealth < + 90.0) // Force pit stop strategy (5) if health is low and in pit zone iSelectedStrategy = 5; } if (pCar->byDebugDamage) @@ -5057,151 +5945,180 @@ void autocar2(tCar *pCar) iPrevChunk = iChunkForPitStop - 1; if (iPrevChunk < 0) iPrevChunk = TRAK_LEN - 1; - if (!pCar->byPitLaneActiveFlag && (TrakColour[iPrevChunk][1] & SURFACE_FLAG_PIT_ZONE) == 0) { + if (!pCar->byPitLaneActiveFlag && + (TrakColour[iPrevChunk][1] & SURFACE_FLAG_PIT_ZONE) == 0) { pCar->byPitLaneActiveFlag = -1; iPlayerType = player_type; pCar->nChangeMateCooldown = 1080; - if (iPlayerType != 2 - && (cheat_mode & 0x4000) == 0 - && player1_car != pCar->iDriverIdx - && pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx - && pCar->byCarDesignIdx <= 7u - && readsample == writesample - && lastsample < -18) { - speechsample(pCar->byCarDesignIdx + 71, 20000, 18, player1_car + 17920); - speechsample(SOUND_SAMPLE_TPITS, 20000, 0, player1_car);// SOUND_SAMPLE_TPITS + if (iPlayerType != 2 && (cheat_mode & 0x4000) == 0 && + player1_car != pCar->iDriverIdx && + pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx && + pCar->byCarDesignIdx <= 7u && readsample == writesample && + lastsample < -18) { + speechsample(pCar->byCarDesignIdx + 71, 20000, 18, + player1_car + 17920); + speechsample(SOUND_SAMPLE_TPITS, 20000, 0, + player1_car); // SOUND_SAMPLE_TPITS } } } } } switch (iSelectedStrategy) { - case 0: - if (iRightCarIdx != -1 && fRightTime >= 0.0) - goto LABEL_175; - if (iLeftCarIdx != pCar->iTrackedCarIdx) - goto LABEL_154; + case 0: + if (iRightCarIdx != -1 && fRightTime >= 0.0) + goto LABEL_175; + if (iLeftCarIdx != pCar->iTrackedCarIdx) + goto LABEL_154; + goto LABEL_178; + case 1: + if (iRightCarIdx != -1 && fRightTime >= 0.0) + goto LABEL_175; + if (iLeftCarIdx == pCar->iTrackedCarIdx && fLeftTime < 0.0) goto LABEL_178; - case 1: - if (iRightCarIdx != -1 && fRightTime >= 0.0) - goto LABEL_175; - if (iLeftCarIdx == pCar->iTrackedCarIdx && fLeftTime < 0.0) - goto LABEL_178; - if (iLeftCarIdx >= 0 && pCar->byCarDesignIdx == Car[iLeftCarIdx].byCarDesignIdx) - goto LABEL_154; - pCar->iTrackedCarIdx = -1; - fStrategyParam1 = pStrategy->fSteerSensitivity; - fStrategyParam2 = pStrategy->fSteerDamping; - if (iLeftCarIdx == -1) - fCalculatedY = fTargetY; - else - fCalculatedY = (float)interpolatesteer(fLeftTime, fStrategyParam1, fStrategyParam2, fTargetY, Car[iLeftCarIdx].pos.fY); - fInterpolatedY = fCalculatedY; - goto LABEL_156; - case 2: - if (iRightCarIdx == -1 || fRightTime < 0.0) { - if (iLeftCarIdx == pCar->iTrackedCarIdx && fLeftTime < 0.0) { - LABEL_178: - fTargetSteerY = (float)avoid(pCar->iDriverIdx, iLeftCarIdx, fLeftTime, fTargetY, pStrategy->fAvoidSensitivity, pStrategy->fAvoidReaction, &iActionFlag); - } else { - //index check added by ROLLER - if (iLeftCarIdx >= 0 && pCar->byCarDesignIdx == Car[iLeftCarIdx].byCarDesignIdx) { - LABEL_154: - pCar->iTrackedCarIdx = -1; - goto LABEL_155; - } + if (iLeftCarIdx >= 0 && + pCar->byCarDesignIdx == Car[iLeftCarIdx].byCarDesignIdx) + goto LABEL_154; + pCar->iTrackedCarIdx = -1; + fStrategyParam1 = pStrategy->fSteerSensitivity; + fStrategyParam2 = pStrategy->fSteerDamping; + if (iLeftCarIdx == -1) + fCalculatedY = fTargetY; + else + fCalculatedY = + (float)interpolatesteer(fLeftTime, fStrategyParam1, fStrategyParam2, + fTargetY, Car[iLeftCarIdx].pos.fY); + fInterpolatedY = fCalculatedY; + goto LABEL_156; + case 2: + if (iRightCarIdx == -1 || fRightTime < 0.0) { + if (iLeftCarIdx == pCar->iTrackedCarIdx && fLeftTime < 0.0) { + LABEL_178: + fTargetSteerY = (float)avoid(pCar->iDriverIdx, iLeftCarIdx, fLeftTime, + fTargetY, pStrategy->fAvoidSensitivity, + pStrategy->fAvoidReaction, &iActionFlag); + } else { + // index check added by ROLLER + if (iLeftCarIdx >= 0 && + pCar->byCarDesignIdx == Car[iLeftCarIdx].byCarDesignIdx) { + LABEL_154: pCar->iTrackedCarIdx = -1; - fStrategyA0_3 = pStrategy->fSteerSensitivity; - fStrategyA1 = pStrategy->fSteerDamping; - if (iLeftCarIdx == -1) - fDefensiveY = fTargetY; - else - fDefensiveY = (float)interpolatesteer(fLeftTime, fStrategyA0_3, fStrategyA1, fTargetY, Car[iLeftCarIdx].pos.fY); + goto LABEL_155; + } + pCar->iTrackedCarIdx = -1; + fStrategyA0_3 = pStrategy->fSteerSensitivity; + fStrategyA1 = pStrategy->fSteerDamping; + if (iLeftCarIdx == -1) + fDefensiveY = fTargetY; + else + fDefensiveY = + (float)interpolatesteer(fLeftTime, fStrategyA0_3, fStrategyA1, + fTargetY, Car[iLeftCarIdx].pos.fY); - //index check added by ROLLER - if (iLeftCarIdx == -1) - dYPositionDiff = 0; - else - dYPositionDiff = pCar->pos.fY - Car[iLeftCarIdx].pos.fY; - - fTargetSteerY = fDefensiveY; - if (CarBaseY * 2.0 + -200.0 > fabs(dYPositionDiff) && fLeftTime > 0.0) { - dTargetCarSpeed = Car[iLeftCarIdx].fFinalSpeed * 0.2; - //_CHP(); - iAIThrottleControl = (int)dTargetCarSpeed; - if ((int)dTargetCarSpeed < 80) - iAIThrottleControl = 80; - if (iAIThrottleControl > iAITargetSpeed) - iAIThrottleControl = iAITargetSpeed; - dSpeedDiffCalc = (double)iAIThrottleControl - pCar->fFinalSpeed; - //_CHP(); - iAIThrottleControl = (int)dSpeedDiffCalc; - } + // index check added by ROLLER + if (iLeftCarIdx == -1) + dYPositionDiff = 0; + else + dYPositionDiff = pCar->pos.fY - Car[iLeftCarIdx].pos.fY; + + fTargetSteerY = fDefensiveY; + if (CarBaseY * 2.0 + -200.0 > fabs(dYPositionDiff) && fLeftTime > 0.0) { + dTargetCarSpeed = Car[iLeftCarIdx].fFinalSpeed * 0.2; + //_CHP(); + iAIThrottleControl = (int)dTargetCarSpeed; + if ((int)dTargetCarSpeed < 80) + iAIThrottleControl = 80; + if (iAIThrottleControl > iAITargetSpeed) + iAIThrottleControl = iAITargetSpeed; + dSpeedDiffCalc = (double)iAIThrottleControl - pCar->fFinalSpeed; + //_CHP(); + iAIThrottleControl = (int)dSpeedDiffCalc; } - } else { - LABEL_175: - dAvoidanceResult = avoid(pCar->iDriverIdx, iRightCarIdx, fRightTime, fTargetY, pStrategy->fAvoidSensitivity, pStrategy->fAvoidReaction, &iActionFlag); - pCar->iTrackedCarIdx = iRightCarIdx; - fTargetSteerY = (float)dAvoidanceResult; } - break; - case 3: - pCar->iTrackedCarIdx = -1; - if (iRightCarIdx == -1 || fRightTime < 0.0 || fRightTime >(double)fLeftTime && fLeftTime >= 0.0 || pCar->byCarDesignIdx == Car[iRightCarIdx].byCarDesignIdx) { - if (iLeftCarIdx == -1 || fLeftTime < 0.0 || fLeftTime >(double)fRightTime && fRightTime >= 0.0 || pCar->byCarDesignIdx == Car[iLeftCarIdx].byCarDesignIdx) { - LABEL_155: - fInterpolatedY = fTargetY; - } else { - fSteerSensitivity = pStrategy->fSteerSensitivity; - fLeftInterpolated = (float)interpolatesteer(fLeftTime, fSteerSensitivity, pStrategy->fSteerDamping, fTargetY, Car[iLeftCarIdx].pos.fY); - fInterpolatedY = fLeftInterpolated; - } - LABEL_156: - fTargetSteerY = fInterpolatedY; + } else { + LABEL_175: + dAvoidanceResult = avoid(pCar->iDriverIdx, iRightCarIdx, fRightTime, + fTargetY, pStrategy->fAvoidSensitivity, + pStrategy->fAvoidReaction, &iActionFlag); + pCar->iTrackedCarIdx = iRightCarIdx; + fTargetSteerY = (float)dAvoidanceResult; + } + break; + case 3: + pCar->iTrackedCarIdx = -1; + if (iRightCarIdx == -1 || fRightTime < 0.0 || + fRightTime > (double)fLeftTime && fLeftTime >= 0.0 || + pCar->byCarDesignIdx == Car[iRightCarIdx].byCarDesignIdx) { + if (iLeftCarIdx == -1 || fLeftTime < 0.0 || + fLeftTime > (double)fRightTime && fRightTime >= 0.0 || + pCar->byCarDesignIdx == Car[iLeftCarIdx].byCarDesignIdx) { + LABEL_155: + fInterpolatedY = fTargetY; } else { - fSteerSensitivity_1 = pStrategy->fSteerSensitivity; - fRightInterpolated = (float)interpolatesteer(fRightTime, fSteerSensitivity_1, pStrategy->fSteerDamping, fTargetY, Car[iRightCarIdx].pos.fY); - fTargetSteerY = fRightInterpolated; - iAIThrottleControl = 1; + fSteerSensitivity = pStrategy->fSteerSensitivity; + fLeftInterpolated = (float)interpolatesteer( + fLeftTime, fSteerSensitivity, pStrategy->fSteerDamping, fTargetY, + Car[iLeftCarIdx].pos.fY); + fInterpolatedY = fLeftInterpolated; } - break; - case 4: - fTargetSteerY = fTargetY; - pCar->iTrackedCarIdx = -1; - break; - case 5: - if (iRightCarIdx == -1 || fRightTime < 0.0) { - if (iLeftCarIdx == pCar->iTrackedCarIdx) { - fTargetSteerY = (float)avoid(pCar->iDriverIdx, iLeftCarIdx, fLeftTime, fTargetY, pStrategy->fAvoidSensitivity, pStrategy->fAvoidReaction, &iActionFlag); - } else { - pCar->iTrackedCarIdx = -1; - fTargetSteerY = fTargetY; - } + LABEL_156: + fTargetSteerY = fInterpolatedY; + } else { + fSteerSensitivity_1 = pStrategy->fSteerSensitivity; + fRightInterpolated = (float)interpolatesteer( + fRightTime, fSteerSensitivity_1, pStrategy->fSteerDamping, fTargetY, + Car[iRightCarIdx].pos.fY); + fTargetSteerY = fRightInterpolated; + iAIThrottleControl = 1; + } + break; + case 4: + fTargetSteerY = fTargetY; + pCar->iTrackedCarIdx = -1; + break; + case 5: + if (iRightCarIdx == -1 || fRightTime < 0.0) { + if (iLeftCarIdx == pCar->iTrackedCarIdx) { + fTargetSteerY = (float)avoid(pCar->iDriverIdx, iLeftCarIdx, fLeftTime, + fTargetY, pStrategy->fAvoidSensitivity, + pStrategy->fAvoidReaction, &iActionFlag); } else { - dAvoidanceY = avoid(pCar->iDriverIdx, iRightCarIdx, fRightTime, fTargetY, pStrategy->fAvoidSensitivity, pStrategy->fAvoidReaction, &iActionFlag); - pCar->iTrackedCarIdx = iRightCarIdx; - fTargetSteerY = (float)dAvoidanceY; - } - iAITargetCar = pCar->iAITargetCar; - if (iAITargetCar != -1) { - iDistanceToTarget = iAITargetCar - pCar->nCurrChunk; - if (iDistanceToTarget < 0) - iDistanceToTarget += TRAK_LEN; - if (TRAK_LEN / 2 < iDistanceToTarget) - iDistanceToTarget -= TRAK_LEN; - fForwardSpeed = pCar->fFinalSpeed * tcos[pCar->nActualYaw & 0x3FFF]; - fTrackDistance = localdata[pCar->nCurrChunk].fTrackHalfLength * 2.0f * (float)iDistanceToTarget; - if (iDistanceToTarget < 0 || fabs(fTrackDistance / fForwardSpeed) < fDragCoefficient * 36.0 * fForwardSpeed / fMaxEngineSpeed) - iActionFlag = -1; + pCar->iTrackedCarIdx = -1; + fTargetSteerY = fTargetY; } - //if ((LODWORD(pCar->fFinalSpeed) & 0x7FFFFFFF) == 0) - if (fabs(pCar->fFinalSpeed) == 0) - pCar->byDebugDamage = -1; - if ((TrakColour[pCar->nCurrChunk][pCar->iLaneType] & SURFACE_FLAG_PIT) == 0 && pCar->fFinalSpeed < 40.0) - iActionFlag = 0; - break; - default: - break; // AI strategy selection: 0=Normal, 1=Aggressive, 2=Defensive, 3=Attack, 4=Fast, 5=Pits + } else { + dAvoidanceY = avoid(pCar->iDriverIdx, iRightCarIdx, fRightTime, fTargetY, + pStrategy->fAvoidSensitivity, + pStrategy->fAvoidReaction, &iActionFlag); + pCar->iTrackedCarIdx = iRightCarIdx; + fTargetSteerY = (float)dAvoidanceY; + } + iAITargetCar = pCar->iAITargetCar; + if (iAITargetCar != -1) { + iDistanceToTarget = iAITargetCar - pCar->nCurrChunk; + if (iDistanceToTarget < 0) + iDistanceToTarget += TRAK_LEN; + if (TRAK_LEN / 2 < iDistanceToTarget) + iDistanceToTarget -= TRAK_LEN; + fForwardSpeed = pCar->fFinalSpeed * tcos[pCar->nActualYaw & 0x3FFF]; + fTrackDistance = localdata[pCar->nCurrChunk].fTrackHalfLength * 2.0f * + (float)iDistanceToTarget; + if (iDistanceToTarget < 0 || + fabs(fTrackDistance / fForwardSpeed) < + fDragCoefficient * 36.0 * fForwardSpeed / fMaxEngineSpeed) + iActionFlag = -1; + } + // if ((LODWORD(pCar->fFinalSpeed) & 0x7FFFFFFF) == 0) + if (fabs(pCar->fFinalSpeed) == 0) + pCar->byDebugDamage = -1; + if ((TrakColour[pCar->nCurrChunk][pCar->iLaneType] & SURFACE_FLAG_PIT) == + 0 && + pCar->fFinalSpeed < 40.0) + iActionFlag = 0; + break; + default: + break; // AI strategy selection: 0=Normal, 1=Aggressive, 2=Defensive, + // 3=Attack, 4=Fast, 5=Pits } if (pCar->byDebugDamage) iActionFlag = -1; @@ -5211,17 +6128,22 @@ void autocar2(tCar *pCar) fDeltaY = fTargetSteerY - pCar->pos.fY; fDeltaXCopy = fDeltaX; fDeltaYCopy = fDeltaY; - //if ((LODWORD(fDeltaX) & 0x7FFFFFFF) != 0 || (LODWORD(fDeltaY) & 0x7FFFFFFF) != 0) { + // if ((LODWORD(fDeltaX) & 0x7FFFFFFF) != 0 || (LODWORD(fDeltaY) & 0x7FFFFFFF) + // != 0) { if (fabs(fDeltaX) > FLT_EPSILON || fabs(fDeltaY) > FLT_EPSILON) { - dCalculatedAngle = atan2(fDeltaYCopy, fDeltaXCopy) * 16384.0 / 6.28318530718;// Calculate steering angle to target position + dCalculatedAngle = + atan2(fDeltaYCopy, fDeltaXCopy) * 16384.0 / + 6.28318530718; // Calculate steering angle to target position //_CHP(); - //LODWORD(fDeltaX) = (int)dCalculatedAngle; + // LODWORD(fDeltaX) = (int)dCalculatedAngle; iTargetAngle = (int)dCalculatedAngle & 0x3FFF; } else { iTargetAngle = 0; - //LOWORD(iTargetAngle) = 0; + // LOWORD(iTargetAngle) = 0; } - iSteeringSensitivity = ((int16)iTargetAngle - pCar->nYaw) & 0x3FFF;// Apply steering input with engine sensitivity limits + iSteeringSensitivity = + ((int16)iTargetAngle - pCar->nYaw) & + 0x3FFF; // Apply steering input with engine sensitivity limits if (iSteeringSensitivity > 0x2000) iSteeringSensitivity -= 0x4000; if (iSteeringSensitivity < -pEngine->iSteeringSensitivity) @@ -5229,7 +6151,8 @@ void autocar2(tCar *pCar) if (iSteeringSensitivity > pEngine->iSteeringSensitivity) iSteeringSensitivity = pEngine->iSteeringSensitivity; pCar->iSteeringInput = iSteeringSensitivity; - if ((char)pCar->byGearAyMax == -1) // AI gear shifting and RPM control based on engine state + if ((char)pCar->byGearAyMax == + -1) // AI gear shifting and RPM control based on engine state { fRPMRatio = pCar->fRPMRatio; if (fRPMRatio >= 0.1) { @@ -5250,12 +6173,13 @@ void autocar2(tCar *pCar) iAIThrottleControl = 1; } } - //if (iAIThrottleControl > 0 && (LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0) + // if (iAIThrottleControl > 0 && (LODWORD(pCar->fHealth) & 0x7FFFFFFF) == 0) if (iAIThrottleControl > 0 && fabs(pCar->fHealth) == 0) iAIThrottleControl = -1; if (champ_mode && !champ_go[pCar->iDriverIdx]) iAIThrottleControl = -1; - if (iAIThrottleControl <= 0) // Apply acceleration, deceleration, or freewheeling based on AI decision + if (iAIThrottleControl <= 0) // Apply acceleration, deceleration, or + // freewheeling based on AI decision { if (iAIThrottleControl >= 0) FreeWheel(pCar); @@ -5267,90 +6191,119 @@ void autocar2(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//00032BF0 -void changestrategy(tCar *pCar) -{ +// 00032BF0 +void changestrategy(tCar *pCar) { tCarStrategy *pStrategyData; // ecx - int iOldStrategy; // edi - int iRandStrategy; // eax - int iRandProbability; // eax - int iSelectedStrategy; // ebx - int iProbabilityRemaining; // edx - int *piStrategyIterator; // eax - int iCurrentProbability; // ebp - int iRandFlip; // eax - int iRandRevenge; // eax + int iOldStrategy; // edi + int iRandStrategy; // eax + int iRandProbability; // eax + int iSelectedStrategy; // ebx + int iProbabilityRemaining; // edx + int *piStrategyIterator; // eax + int iCurrentProbability; // ebp + int iRandFlip; // eax + int iRandRevenge; // eax unsigned int uiRacePosition; // ebx - int iRevengeProbability; // ebx - int iRandRevengeCheck; // eax - uint8 byCarDesignIdx; // dl - int iRandRevengeAlt; // eax - uint8 byCarDesignCopy; // bl + int iRevengeProbability; // ebx + int iRandRevengeCheck; // eax + uint8 byCarDesignIdx; // dl + int iRandRevengeAlt; // eax + uint8 byCarDesignCopy; // bl - pStrategyData = &CarStrategy[pCar->iDriverIdx];// Get strategy data for this driver (40 bytes per driver) - if (pCar->nChangeMateCooldown) // Skip strategy change if cooldown timer active + pStrategyData = + &CarStrategy[pCar->iDriverIdx]; // Get strategy data for this driver (40 + // bytes per driver) + if (pCar->nChangeMateCooldown) // Skip strategy change if cooldown timer + // active return; iOldStrategy = pCar->iSelectedStrategy; - if (pCar->fTotalRaceTime > 40.0) // Only allow strategy changes after 40 seconds of race time + if (pCar->fTotalRaceTime > + 40.0) // Only allow strategy changes after 40 seconds of race time { iRandStrategy = ROLLERrandRaw(); - if (GetHighOrderRand(800, iRandStrategy) == 100)// 1 in 800 chance + if (GetHighOrderRand(800, iRandStrategy) == 100) // 1 in 800 chance { iRandProbability = ROLLERrandRaw(); iSelectedStrategy = 0; - iProbabilityRemaining = GetHighOrderRand(100, iRandProbability);// Select strategy based on probability table (0-99 random) - for (piStrategyIterator = (int *)pStrategyData; iProbabilityRemaining >= *piStrategyIterator; ++iSelectedStrategy) { + iProbabilityRemaining = GetHighOrderRand( + 100, iRandProbability); // Select strategy based on probability table + // (0-99 random) + for (piStrategyIterator = (int *)pStrategyData; + iProbabilityRemaining >= *piStrategyIterator; ++iSelectedStrategy) { iCurrentProbability = *piStrategyIterator++; iProbabilityRemaining -= iCurrentProbability; } - if (pCar->byRacePosition < 4u && iSelectedStrategy == 2)// Front runners (positions 0-3) cannot use strategy 2, downgrade to 1 + if (pCar->byRacePosition < 4u && + iSelectedStrategy == 2) // Front runners (positions 0-3) cannot use + // strategy 2, downgrade to 1 iSelectedStrategy = 1; pCar->iSelectedStrategy = iSelectedStrategy; if (iSelectedStrategy) { iRandFlip = ROLLERrandRaw(); - if (GetHighOrderRand(100, iRandFlip) < flipst[level])// Chance to flip aggressive strategy back to normal based on level + if (GetHighOrderRand(100, iRandFlip) < + flipst[level]) // Chance to flip aggressive strategy back to normal + // based on level pCar->iSelectedStrategy = 0; } // CHEAT_MODE_DEATH_MODE - if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0) // Death mode forces normal strategy (no aggression) + if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != + 0) // Death mode forces normal strategy (no aggression) pCar->iSelectedStrategy = 0; } iRandRevenge = ROLLERrandRaw(); if (GetHighOrderRand(720, iRandRevenge) != 250) - goto LABEL_39; // 1 in 720 chance for revenge mode consideration + goto LABEL_39; // 1 in 720 chance for revenge mode consideration // CHEAT_MODE_DEATH_MODE if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0 || level < 4) { uiRacePosition = pCar->byRacePosition; if (uiRacePosition >= 7) { // CHEAT_MODE_DEATH_MODE if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0) - iRevengeProbability = 50 * uiRacePosition - 250;// Death mode: simple position-based revenge (50 * pos - 250) + iRevengeProbability = + 50 * uiRacePosition - + 250; // Death mode: simple position-based revenge (50 * pos - 250) else - iRevengeProbability = (int)(pStrategyData->strategyAy[4] * (uiRacePosition - level)) / 2 + uiRacePosition - level;// Normal mode: complex revenge based on strategy data and position + iRevengeProbability = + (int)(pStrategyData->strategyAy[4] * (uiRacePosition - level)) / + 2 + + uiRacePosition - level; // Normal mode: complex revenge based on + // strategy data and position } else { iRevengeProbability = -1; } iRandRevengeCheck = ROLLERrandRaw(); - if (GetHighOrderRand(1000, iRandRevengeCheck) < iRevengeProbability) { // Trigger revenge speech if same car design as player (not in clones mode) + if (GetHighOrderRand(1000, iRandRevengeCheck) < + iRevengeProbability) { // Trigger revenge speech if same car design as + // player (not in clones mode) // CHEAT_MODE_CLONES - if (player_type != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0 && !pCar->iBobMode && pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx) { + if (player_type != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0 && + !pCar->iBobMode && + pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx) { byCarDesignIdx = pCar->byCarDesignIdx; if (byCarDesignIdx <= 7u) { speechsample(byCarDesignIdx + 71, 20000, 18, player1_car + 17664); - speechsample(SOUND_SAMPLE_REVERST, 20000, 0, player1_car);// SOUND_SAMPLE_REVERST + speechsample(SOUND_SAMPLE_REVERST, 20000, 0, + player1_car); // SOUND_SAMPLE_REVERST } } - pCar->iBobMode = -1; // Activate revenge mode (-1) + pCar->iBobMode = -1; // Activate revenge mode (-1) goto LABEL_39; } } else { iRandRevengeAlt = ROLLERrandRaw(); - if (GetHighOrderRand(1000, iRandRevengeAlt) < pStrategyData->strategyAy[4])// Advanced levels (4+): use strategy data for revenge probability + if (GetHighOrderRand(1000, iRandRevengeAlt) < + pStrategyData->strategyAy[4]) // Advanced levels (4+): use strategy + // data for revenge probability { // CHEAT_MODE_CLONES - if (player_type != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0 && !pCar->iBobMode && pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx && pCar->byCarDesignIdx <= 7u) { - speechsample(pCar->byCarDesignIdx + 71, 20000, 18, player1_car + 17664); - speechsample(SOUND_SAMPLE_REVERST, 20000, 0, player1_car);// SOUND_SAMPLE_REVERST + if (player_type != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0 && + !pCar->iBobMode && + pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx && + pCar->byCarDesignIdx <= 7u) { + speechsample(pCar->byCarDesignIdx + 71, 20000, 18, + player1_car + 17664); + speechsample(SOUND_SAMPLE_REVERST, 20000, 0, + player1_car); // SOUND_SAMPLE_REVERST } pCar->iBobMode = -1; goto LABEL_39; @@ -5358,287 +6311,293 @@ void changestrategy(tCar *pCar) } pCar->iBobMode = 0; LABEL_39: - if (winner_mode) // Winner mode disables revenge/aggression + if (winner_mode) // Winner mode disables revenge/aggression pCar->iBobMode = 0; } - if (iOldStrategy != pCar->iSelectedStrategy) // If strategy changed, play speech and set cooldown timer + if (iOldStrategy != pCar->iSelectedStrategy) // If strategy changed, play + // speech and set cooldown timer { // CHEAT_MODE_CLONES - if (player_type != 2 && (cheat_mode & 0x4000) == 0 && pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx) { + if (player_type != 2 && (cheat_mode & 0x4000) == 0 && + pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx) { byCarDesignCopy = pCar->byCarDesignIdx; if (byCarDesignCopy <= 7u) { - speechsample(byCarDesignCopy + 71, 20000, 18, ((pCar->iSelectedStrategy + 61) << 8) + player1_car); + speechsample(byCarDesignCopy + 71, 20000, 18, + ((pCar->iSelectedStrategy + 61) << 8) + player1_car); speechsample(pCar->iSelectedStrategy + 61, 20000, 0, player1_car); } } - pCar->nChangeMateCooldown = 1080; // Set 1080 frame cooldown (18 seconds at 60 FPS) + pCar->nChangeMateCooldown = + 1080; // Set 1080 frame cooldown (18 seconds at 60 FPS) } } //------------------------------------------------------------------------------------------------- -//00032FB0 -int getangle(float fX, float fY) -{ +// 00032FB0 +int getangle(float fX, float fY) { double dAngle; // st7 // If floats are both zero, return 0 // Masking off most significant bit so -0 == 0 // Did this used to be necessary? It doesn't // seem to make a difference now. - //if ((LODWORD(fX) & 0x7FFFFFFF) == 0 && (LODWORD(fY) & 0x7FFFFFFF) == 0) + // if ((LODWORD(fX) & 0x7FFFFFFF) == 0 && (LODWORD(fY) & 0x7FFFFFFF) == 0) if (fX == 0 && fY == 0) return 0; // IF_DATAN2 is atan2 that returns a double dAngle = atan2(fY, fX) * 16384.0 / 6.28318530718; - // return value is used as an index into tsin/tcos/ptan lookup tables each with 16384 elements - // masking off all but the 14 least significant bits ensures this value maxes out at 16383 + // return value is used as an index into tsin/tcos/ptan lookup tables each + // with 16384 elements masking off all but the 14 least significant bits + // ensures this value maxes out at 16383 return (int)dAngle & 0x3FFF; } //------------------------------------------------------------------------------------------------- -//00033000 -void landontrack(tCar *pCar) -{ - tTrackInfo *pTrackInfo; // ebp - int iNextChunkIdx; // eax - tData *pCurrentData; // esi +// 00033000 +void landontrack(tCar *pCar) { + tTrackInfo *pTrackInfo; // ebp + int iNextChunkIdx; // eax + tData *pCurrentData; // esi tTrackInfo *pNextTrackInfo; // ecx - tData *pNextData; // ebx - double dTransformedY; // st7 - double dTransformedX; // st5 - double dTransformedZ; // rt0 - bool bRoofCollision; // eax - double dWallNormalY; // st7 - int iRollMomentumBackup; // ecx - double dDamageAmount; // st7 - double dSoundVolume; // st7 - double dLocalY; // st7 - double dLocalX; // st5 - double dLocalZ; // st6 - double dTempX; // st6 - double dTempZ; // st7 - double dPositionZ; // st7 - float fDirectionX; // edx - int iChunkIdx; // eax + tData *pNextData; // ebx + double dTransformedY; // st7 + double dTransformedX; // st5 + double dTransformedZ; // rt0 + bool bRoofCollision; // eax + double dWallNormalY; // st7 + int iRollMomentumBackup; // ecx + double dDamageAmount; // st7 + double dSoundVolume; // st7 + double dLocalY; // st7 + double dLocalX; // st5 + double dLocalZ; // st6 + double dTempX; // st6 + double dTempZ; // st7 + double dPositionZ; // st7 + float fDirectionX; // edx + int iChunkIdx; // eax //__int16 nFpuStack1; // fps - double dAngle1; // st7 - bool bRoofCheck; // eax + double dAngle1; // st7 + bool bRoofCheck; // eax double dWallPosition; // st7 - double dDamageLeft; // st7 - int iRollBackup; // edx - double dVolumeCalc; // st7 - double dVelocityY; // st7 - double dVelocityX; // st5 - double dVelocityZ; // st6 - double dLocalPosX; // st6 - double dLocalPosZ; // st7 - double dFinalPosZ; // st7 - float fDirX; // ecx + double dDamageLeft; // st7 + int iRollBackup; // edx + double dVolumeCalc; // st7 + double dVelocityY; // st7 + double dVelocityX; // st5 + double dVelocityZ; // st6 + double dLocalPosX; // st6 + double dLocalPosZ; // st7 + double dFinalPosZ; // st7 + float fDirX; // ecx //__int16 nFpuStack2; // fps - double dAngle2; // st7 + double dAngle2; // st7 long double dHorizontalSpeed; // st7 - double dNegTrackWidth; // st7 - int iGroundType; // edx - //int64 llTrackColor; // rax - int iChunkIndex; // ecx + double dNegTrackWidth; // st7 + int iGroundType; // edx + // int64 llTrackColor; // rax + int iChunkIndex; // ecx float fTransformX; // edx //__int16 nFpuStack3; // fps - double dAngle3; // st7 - int iBankAdjusted; // edx - int iElevationAdjusted; // eax - double dHeightDiff; // st7 - int iBankValue; // eax - int iStunned; // eax - double dImpactVolume; // st7 - int iSfxType; // eax - double dStunnedVolume; // st7 - int iGroundColorType; // edx - double dSeparatedY; // st7 - double dSeparatedX; // st5 - double dSeparatedZ; // rt2 - tGroundPt *pGroundPts; // edx - double dGroundY1; // st7 - double dGroundX1; // st5 - double dGroundZ1; // st4 - double dGroundY0; // st7 - double dGroundX0; // st5 - double dGroundZ0; // st4 - double dSlopeDiff; // st7 + double dAngle3; // st7 + int iBankAdjusted; // edx + int iElevationAdjusted; // eax + double dHeightDiff; // st7 + int iBankValue; // eax + int iStunned; // eax + double dImpactVolume; // st7 + int iSfxType; // eax + double dStunnedVolume; // st7 + int iGroundColorType; // edx + double dSeparatedY; // st7 + double dSeparatedX; // st5 + double dSeparatedZ; // rt2 + tGroundPt *pGroundPts; // edx + double dGroundY1; // st7 + double dGroundX1; // st5 + double dGroundZ1; // st4 + double dGroundY0; // st7 + double dGroundX0; // st5 + double dGroundZ0; // st4 + double dSlopeDiff; // st7 double dUndergroundDamage; // st7 - int iRollBackup2; // edx - double dNegSpeed; // st7 - double dBankSoundVolume; // st7 - double dInterpolatedY; // st7 - double dInterpolatedX; // st5 - double dInterpolatedZ; // st6 - double dDirectionY2; // st7 - double dDirectionX2; // st5 - double dDirectionZ2; // st6 - double dFinalDirectionZ; // st7 - float fDirXFinal; // ecx - int dYawCalc; // eax + int iRollBackup2; // edx + double dNegSpeed; // st7 + double dBankSoundVolume; // st7 + double dInterpolatedY; // st7 + double dInterpolatedX; // st5 + double dInterpolatedZ; // st6 + double dDirectionY2; // st7 + double dDirectionX2; // st5 + double dDirectionZ2; // st6 + double dFinalDirectionZ; // st7 + float fDirXFinal; // ecx + int dYawCalc; // eax //__int16 nFpuStack4; // fps - double dAngle4; // st7 - double dGroundY2; // st7 - double dGroundX2; // st5 - double dGroundZ2; // st4 - double dSlopeDiff2; // st7 + double dAngle4; // st7 + double dGroundY2; // st7 + double dGroundX2; // st5 + double dGroundZ2; // st4 + double dSlopeDiff2; // st7 double dUndergroundDamage2; // st7 - double dNegSpeed2; // st7 - double dBankSoundVolume2; // st7 - double dInterpolatedY2; // st7 - double dInterpolatedX2; // st5 - double dInterpolatedZ2; // st6 - double dDirectionY3; // st7 - double dDirectionX3; // st5 - double dDirectionZ3; // st6 - double dFinalDirectionZ2; // st7 - float fDirXFinal2; // ecx + double dNegSpeed2; // st7 + double dBankSoundVolume2; // st7 + double dInterpolatedY2; // st7 + double dInterpolatedX2; // st5 + double dInterpolatedZ2; // st6 + double dDirectionY3; // st7 + double dDirectionX3; // st5 + double dDirectionZ3; // st6 + double dFinalDirectionZ2; // st7 + float fDirXFinal2; // ecx //__int16 nFpuStack5; // fps - double dAngle5; // st7 - double dSeparatedY2; // st7 - double dSeparatedX2; // st5 - double dSeparatedZ2; // rt0 - tGroundPt *pGroundPts2; // edx - double dGroundY4; // st7 - double dGroundX4; // st5 - double dGroundZ4; // st4 - double dGroundY5; // st7 - double dGroundX5; // st5 - double dGroundZ5; // st4 - double dSlopeDiff5; // st7 + double dAngle5; // st7 + double dSeparatedY2; // st7 + double dSeparatedX2; // st5 + double dSeparatedZ2; // rt0 + tGroundPt *pGroundPts2; // edx + double dGroundY4; // st7 + double dGroundX4; // st5 + double dGroundZ4; // st4 + double dGroundY5; // st7 + double dGroundX5; // st5 + double dGroundZ5; // st4 + double dSlopeDiff5; // st7 double dUndergroundDamage5; // st7 - double dBankSoundVolume5; // st7 - double dGroundY3; // st7 - double dGroundX3; // st5 - double dGroundZ3; // st6 - double dDirectionY4; // st7 - double dDirectionX4; // st5 - double dDirectionZ4; // st6 - double dFinalDirectionZ4; // st7 - float fDirXFinal5; // ebx + double dBankSoundVolume5; // st7 + double dGroundY3; // st7 + double dGroundX3; // st5 + double dGroundZ3; // st6 + double dDirectionY4; // st7 + double dDirectionX4; // st5 + double dDirectionZ4; // st6 + double dFinalDirectionZ4; // st7 + float fDirXFinal5; // ebx //__int16 nFpuStack6; // fps - double dAngle6; // st7 - double dGroundY6; // st7 - double dGroundX6; // st5 - double dGroundZ6; // st4 - double dSlopeDiff6; // st7 + double dAngle6; // st7 + double dGroundY6; // st7 + double dGroundX6; // st5 + double dGroundZ6; // st4 + double dSlopeDiff6; // st7 double dUndergroundDamage6; // st7 - double dBankSoundVolume6; // st7 - double dInterpolatedY3; // st7 - double dInterpolatedX3; // st5 - double dInterpolatedZ3; // st6 - double dDirectionY5; // st7 - double dDirectionX5; // st5 - double dDirectionZ5; // st6 - double dFinalDirectionZ5; // st7 - float fDirXFinal6; // edx + double dBankSoundVolume6; // st7 + double dInterpolatedY3; // st7 + double dInterpolatedX3; // st5 + double dInterpolatedZ3; // st6 + double dDirectionY5; // st7 + double dDirectionX5; // st5 + double dDirectionZ5; // st6 + double dFinalDirectionZ5; // st7 + float fDirXFinal6; // edx //__int16 nFpuStack7; // fps - double dAngle7; // st7 - double dFinalHorizSpeed; // st7 - float fTempDamage; // [esp+0h] [ebp-1ECh] - float fTempDamage2; // [esp+0h] [ebp-1ECh] - float fTempDamage3; // [esp+0h] [ebp-1ECh] - float fThrottle; // [esp+0h] [ebp-1ECh] - float fUndergroundDamage; // [esp+0h] [ebp-1ECh] - float fUndergroundDamage2; // [esp+0h] [ebp-1ECh] - float fUndergroundDamage5; // [esp+0h] [ebp-1ECh] - float fUndergroundDamage6; // [esp+0h] [ebp-1ECh] - tData data; // [esp+4h] [ebp-1E8h] BYREF - int iBank; // [esp+84h] [ebp-168h] BYREF - int iAzimuth; // [esp+88h] [ebp-164h] BYREF - int piNearestChunk; // [esp+8Ch] [ebp-160h] BYREF - int iElevation; // [esp+90h] [ebp-15Ch] BYREF - float fAngleCalcTemp1; // [esp+94h] [ebp-158h] - float fDirectionTemp1; // [esp+98h] [ebp-154h] - float fX; // [esp+9Ch] [ebp-150h] - float fDirectionTemp2; // [esp+A0h] [ebp-14Ch] - float fDirectionTemp3; // [esp+A4h] [ebp-148h] - float fAngleCalcTemp2; // [esp+A8h] [ebp-144h] - float fAngleCalcTemp3; // [esp+ACh] [ebp-140h] - float fAngleCalcTemp4; // [esp+B0h] [ebp-13Ch] - float fGroundYCalc1; // [esp+B4h] [ebp-138h] - float fAngleCalcTemp5; // [esp+B8h] [ebp-134h] - float fAngleCalcTemp6; // [esp+BCh] [ebp-130h] - float fY; // [esp+C0h] [ebp-12Ch] - float fAngleCalcTemp7; // [esp+C4h] [ebp-128h] - float fGroundYCalc2; // [esp+C8h] [ebp-124h] - float fGroundYCalc3; // [esp+CCh] [ebp-120h] - float fGroundYCalc4; // [esp+D0h] [ebp-11Ch] - float fTrackHalfWidthNext; // [esp+D4h] [ebp-118h] - float fHeightDiffCalc; // [esp+D8h] [ebp-114h] - float fSlopeDiffCalc1; // [esp+DCh] [ebp-110h] - float fDirectionYTemp1; // [esp+E0h] [ebp-10Ch] - float fTrackWidthNeg; // [esp+E4h] [ebp-108h] - float fWallDamageCalc; // [esp+E8h] [ebp-104h] - float fSlopeDiffCalc2; // [esp+ECh] [ebp-100h] - float fTrackHalfWidth; // [esp+F0h] [ebp-FCh] - float fSlopeDiffCalc3; // [esp+F4h] [ebp-F8h] - float fNegSpeedCalc1; // [esp+F8h] [ebp-F4h] - float fNegSpeedCalc2; // [esp+FCh] [ebp-F0h] - float fDirectionYTemp2; // [esp+100h] [ebp-ECh] - float fHeightDiffGround; // [esp+104h] [ebp-E8h] - float fPrevZPosition; // [esp+108h] [ebp-E4h] - float fHeightDiffUnder; // [esp+10Ch] [ebp-E0h] - float fDirectionYTemp3; // [esp+110h] [ebp-DCh] - float fGroundHeight; // [esp+114h] [ebp-D8h] - float fDirectionYTemp4; // [esp+118h] [ebp-D4h] - float fDirectionYTemp5; // [esp+11Ch] [ebp-D0h] - float fSlopeDiffCalc4; // [esp+120h] [ebp-CCh] + double dAngle7; // st7 + double dFinalHorizSpeed; // st7 + float fTempDamage; // [esp+0h] [ebp-1ECh] + float fTempDamage2; // [esp+0h] [ebp-1ECh] + float fTempDamage3; // [esp+0h] [ebp-1ECh] + float fThrottle; // [esp+0h] [ebp-1ECh] + float fUndergroundDamage; // [esp+0h] [ebp-1ECh] + float fUndergroundDamage2; // [esp+0h] [ebp-1ECh] + float fUndergroundDamage5; // [esp+0h] [ebp-1ECh] + float fUndergroundDamage6; // [esp+0h] [ebp-1ECh] + tData data; // [esp+4h] [ebp-1E8h] BYREF + int iBank; // [esp+84h] [ebp-168h] BYREF + int iAzimuth; // [esp+88h] [ebp-164h] BYREF + int piNearestChunk; // [esp+8Ch] [ebp-160h] BYREF + int iElevation; // [esp+90h] [ebp-15Ch] BYREF + float fAngleCalcTemp1; // [esp+94h] [ebp-158h] + float fDirectionTemp1; // [esp+98h] [ebp-154h] + float fX; // [esp+9Ch] [ebp-150h] + float fDirectionTemp2; // [esp+A0h] [ebp-14Ch] + float fDirectionTemp3; // [esp+A4h] [ebp-148h] + float fAngleCalcTemp2; // [esp+A8h] [ebp-144h] + float fAngleCalcTemp3; // [esp+ACh] [ebp-140h] + float fAngleCalcTemp4; // [esp+B0h] [ebp-13Ch] + float fGroundYCalc1; // [esp+B4h] [ebp-138h] + float fAngleCalcTemp5; // [esp+B8h] [ebp-134h] + float fAngleCalcTemp6; // [esp+BCh] [ebp-130h] + float fY; // [esp+C0h] [ebp-12Ch] + float fAngleCalcTemp7; // [esp+C4h] [ebp-128h] + float fGroundYCalc2; // [esp+C8h] [ebp-124h] + float fGroundYCalc3; // [esp+CCh] [ebp-120h] + float fGroundYCalc4; // [esp+D0h] [ebp-11Ch] + float fTrackHalfWidthNext; // [esp+D4h] [ebp-118h] + float fHeightDiffCalc; // [esp+D8h] [ebp-114h] + float fSlopeDiffCalc1; // [esp+DCh] [ebp-110h] + float fDirectionYTemp1; // [esp+E0h] [ebp-10Ch] + float fTrackWidthNeg; // [esp+E4h] [ebp-108h] + float fWallDamageCalc; // [esp+E8h] [ebp-104h] + float fSlopeDiffCalc2; // [esp+ECh] [ebp-100h] + float fTrackHalfWidth; // [esp+F0h] [ebp-FCh] + float fSlopeDiffCalc3; // [esp+F4h] [ebp-F8h] + float fNegSpeedCalc1; // [esp+F8h] [ebp-F4h] + float fNegSpeedCalc2; // [esp+FCh] [ebp-F0h] + float fDirectionYTemp2; // [esp+100h] [ebp-ECh] + float fHeightDiffGround; // [esp+104h] [ebp-E8h] + float fPrevZPosition; // [esp+108h] [ebp-E4h] + float fHeightDiffUnder; // [esp+10Ch] [ebp-E0h] + float fDirectionYTemp3; // [esp+110h] [ebp-DCh] + float fGroundHeight; // [esp+114h] [ebp-D8h] + float fDirectionYTemp4; // [esp+118h] [ebp-D4h] + float fDirectionYTemp5; // [esp+11Ch] [ebp-D0h] + float fSlopeDiffCalc4; // [esp+120h] [ebp-CCh] float fInterpolatedBoundary; // [esp+124h] [ebp-C8h] - float fDirectionYTemp6; // [esp+128h] [ebp-C4h] - float fCarPosZ; // [esp+12Ch] [ebp-C0h] - float fCarPosX; // [esp+130h] [ebp-BCh] - float fWallBoundary; // [esp+134h] [ebp-B8h] - float fGroundYInterp1; // [esp+138h] [ebp-B4h] - float fGroundZInterp1; // [esp+13Ch] [ebp-B0h] - float fDirectionZTemp1; // [esp+140h] [ebp-ACh] - float fCarPosY; // [esp+144h] [ebp-A8h] - float fDirectionZTemp2; // [esp+148h] [ebp-A4h] - float fGroundZInterp2; // [esp+14Ch] [ebp-A0h] - float fGroundZInterp3; // [esp+150h] [ebp-9Ch] - float fInterpolatedHeight1; // [esp+154h] [ebp-98h] - float fInterpolatedHeight2; // [esp+158h] [ebp-94h] - float fDirectionXTemp1; // [esp+15Ch] [ebp-90h] - float fDirectionXTemp2; // [esp+160h] [ebp-8Ch] - float fInterpolatedHeight3; // [esp+164h] [ebp-88h] - float fInterpolatedHeight4; // [esp+168h] [ebp-84h] - float fVolumeCalc; // [esp+16Ch] [ebp-80h] - float fGroundYInterp2; // [esp+170h] [ebp-7Ch] - float fDirectionZTemp3; // [esp+174h] [ebp-78h] - float fDirectionZTemp4; // [esp+178h] [ebp-74h] - float fGroundZInterp4; // [esp+17Ch] [ebp-70h] - float fDirectionXTemp3; // [esp+180h] [ebp-6Ch] - float fDirectionXTemp4; // [esp+184h] [ebp-68h] - float fRoofHeightCheck; // [esp+188h] [ebp-64h] - float fRoofHeight; // [esp+18Ch] [ebp-60h] - float fGroundYInterp3; // [esp+190h] [ebp-5Ch] - float fGroundZInterp5; // [esp+194h] [ebp-58h] - float fDirectionZLocal; // [esp+198h] [ebp-54h] - float fDirectionXLocal; // [esp+19Ch] [ebp-50h] - float fDirectionYLocal1; // [esp+1A0h] [ebp-4Ch] - float fDirectionYLocal2; // [esp+1A4h] [ebp-48h] - float fDirectionYLocal3; // [esp+1A8h] [ebp-44h] - float fDirectionYLocal4; // [esp+1ACh] [ebp-40h] - int iChunk; // [esp+1B0h] [ebp-3Ch] - float fLocalCoordX; // [esp+1B4h] [ebp-38h] - float fDirectionYLocal; // [esp+1B8h] [ebp-34h] - float fLocalCoordY; // [esp+1BCh] [ebp-30h] - float fLocalCoordZ; // [esp+1C0h] [ebp-2Ch] - float fTempCalc; // [esp+1C4h] [ebp-28h] - float fZ; // [esp+1C8h] [ebp-24h] - float fDirectionYFinal; // [esp+1CCh] [ebp-20h] - float fDirectionYFinal2; // [esp+1D0h] [ebp-1Ch] + float fDirectionYTemp6; // [esp+128h] [ebp-C4h] + float fCarPosZ; // [esp+12Ch] [ebp-C0h] + float fCarPosX; // [esp+130h] [ebp-BCh] + float fWallBoundary; // [esp+134h] [ebp-B8h] + float fGroundYInterp1; // [esp+138h] [ebp-B4h] + float fGroundZInterp1; // [esp+13Ch] [ebp-B0h] + float fDirectionZTemp1; // [esp+140h] [ebp-ACh] + float fCarPosY; // [esp+144h] [ebp-A8h] + float fDirectionZTemp2; // [esp+148h] [ebp-A4h] + float fGroundZInterp2; // [esp+14Ch] [ebp-A0h] + float fGroundZInterp3; // [esp+150h] [ebp-9Ch] + float fInterpolatedHeight1; // [esp+154h] [ebp-98h] + float fInterpolatedHeight2; // [esp+158h] [ebp-94h] + float fDirectionXTemp1; // [esp+15Ch] [ebp-90h] + float fDirectionXTemp2; // [esp+160h] [ebp-8Ch] + float fInterpolatedHeight3; // [esp+164h] [ebp-88h] + float fInterpolatedHeight4; // [esp+168h] [ebp-84h] + float fVolumeCalc; // [esp+16Ch] [ebp-80h] + float fGroundYInterp2; // [esp+170h] [ebp-7Ch] + float fDirectionZTemp3; // [esp+174h] [ebp-78h] + float fDirectionZTemp4; // [esp+178h] [ebp-74h] + float fGroundZInterp4; // [esp+17Ch] [ebp-70h] + float fDirectionXTemp3; // [esp+180h] [ebp-6Ch] + float fDirectionXTemp4; // [esp+184h] [ebp-68h] + float fRoofHeightCheck; // [esp+188h] [ebp-64h] + float fRoofHeight; // [esp+18Ch] [ebp-60h] + float fGroundYInterp3; // [esp+190h] [ebp-5Ch] + float fGroundZInterp5; // [esp+194h] [ebp-58h] + float fDirectionZLocal; // [esp+198h] [ebp-54h] + float fDirectionXLocal; // [esp+19Ch] [ebp-50h] + float fDirectionYLocal1; // [esp+1A0h] [ebp-4Ch] + float fDirectionYLocal2; // [esp+1A4h] [ebp-48h] + float fDirectionYLocal3; // [esp+1A8h] [ebp-44h] + float fDirectionYLocal4; // [esp+1ACh] [ebp-40h] + int iChunk; // [esp+1B0h] [ebp-3Ch] + float fLocalCoordX; // [esp+1B4h] [ebp-38h] + float fDirectionYLocal; // [esp+1B8h] [ebp-34h] + float fLocalCoordY; // [esp+1BCh] [ebp-30h] + float fLocalCoordZ; // [esp+1C0h] [ebp-2Ch] + float fTempCalc; // [esp+1C4h] [ebp-28h] + float fZ; // [esp+1C8h] [ebp-24h] + float fDirectionYFinal; // [esp+1CCh] [ebp-20h] + float fDirectionYFinal2; // [esp+1D0h] [ebp-1Ch] - fX = pCar->posLastFrame.fX; // Store car's current and previous positions for collision calculations + fX = pCar->posLastFrame.fX; // Store car's current and previous positions for + // collision calculations fY = pCar->posLastFrame.fY; fZ = pCar->posLastFrame.fZ; fCarPosX = pCar->pos.fX; fCarPosY = pCar->pos.fY; fCarPosZ = pCar->pos.fZ; - findnearsection(pCar, &piNearestChunk); // Find nearest track section for collision detection + findnearsection( + pCar, + &piNearestChunk); // Find nearest track section for collision detection if (piNearestChunk == -1) iChunk = pCar->iLastValidChunk; else @@ -5650,41 +6609,65 @@ void landontrack(tCar *pCar) iNextChunkIdx = 0; pNextTrackInfo = &TrackInfo[iNextChunkIdx]; pNextData = &localdata[iNextChunkIdx]; - if (GroundColour[iChunk][2] >= 0) // Handle separated coordinate system for underground sections + if (GroundColour[iChunk][2] >= + 0) // Handle separated coordinate system for underground sections calculateseparatedcoordinatesystem(iChunk, &data); dTransformedY = fCarPosY + pCurrentData->pointAy[3].fY; dTransformedX = fCarPosX + pCurrentData->pointAy[3].fX; - dTransformedZ = fCarPosZ + pCurrentData->pointAy[3].fZ;// Transform car position and direction to track local coordinates - fLocalCoordX = (float)(pCurrentData->pointAy[1].fX * dTransformedY + pCurrentData->pointAy[0].fX * dTransformedX + pCurrentData->pointAy[2].fX * dTransformedZ); - fLocalCoordY = (float)(pCurrentData->pointAy[0].fY * dTransformedX + pCurrentData->pointAy[1].fY * dTransformedY + pCurrentData->pointAy[2].fY * dTransformedZ); - fLocalCoordZ = (float)(dTransformedY * pCurrentData->pointAy[1].fZ + dTransformedX * pCurrentData->pointAy[0].fZ + dTransformedZ * pCurrentData->pointAy[2].fZ); - fPrevZPosition = (fX + pCurrentData->pointAy[3].fX) * pCurrentData->pointAy[0].fZ - + (fY + pCurrentData->pointAy[3].fY) * pCurrentData->pointAy[1].fZ - + (fZ + pCurrentData->pointAy[3].fZ) * pCurrentData->pointAy[2].fZ; - fDirectionXLocal = pCurrentData->pointAy[1].fX * pCar->direction.fY + pCurrentData->pointAy[0].fX * pCar->direction.fX + pCurrentData->pointAy[2].fX * pCar->direction.fZ; - fDirectionYLocal = pCurrentData->pointAy[0].fY * pCar->direction.fX + pCurrentData->pointAy[1].fY * pCar->direction.fY + pCurrentData->pointAy[2].fY * pCar->direction.fZ; - fDirectionZLocal = pCurrentData->pointAy[0].fZ * pCar->direction.fX + pCurrentData->pointAy[1].fZ * pCar->direction.fY + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; + dTransformedZ = + fCarPosZ + + pCurrentData->pointAy[3].fZ; // Transform car position and direction to + // track local coordinates + fLocalCoordX = (float)(pCurrentData->pointAy[1].fX * dTransformedY + + pCurrentData->pointAy[0].fX * dTransformedX + + pCurrentData->pointAy[2].fX * dTransformedZ); + fLocalCoordY = (float)(pCurrentData->pointAy[0].fY * dTransformedX + + pCurrentData->pointAy[1].fY * dTransformedY + + pCurrentData->pointAy[2].fY * dTransformedZ); + fLocalCoordZ = (float)(dTransformedY * pCurrentData->pointAy[1].fZ + + dTransformedX * pCurrentData->pointAy[0].fZ + + dTransformedZ * pCurrentData->pointAy[2].fZ); + fPrevZPosition = + (fX + pCurrentData->pointAy[3].fX) * pCurrentData->pointAy[0].fZ + + (fY + pCurrentData->pointAy[3].fY) * pCurrentData->pointAy[1].fZ + + (fZ + pCurrentData->pointAy[3].fZ) * pCurrentData->pointAy[2].fZ; + fDirectionXLocal = pCurrentData->pointAy[1].fX * pCar->direction.fY + + pCurrentData->pointAy[0].fX * pCar->direction.fX + + pCurrentData->pointAy[2].fX * pCar->direction.fZ; + fDirectionYLocal = pCurrentData->pointAy[0].fY * pCar->direction.fX + + pCurrentData->pointAy[1].fY * pCar->direction.fY + + pCurrentData->pointAy[2].fY * pCar->direction.fZ; + fDirectionZLocal = pCurrentData->pointAy[0].fZ * pCar->direction.fX + + pCurrentData->pointAy[1].fZ * pCar->direction.fY + + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; if (fLocalCoordY < 0.0) { if (TrakColour[iChunk][4]) { - fRoofHeight = pTrackInfo->fRoofHeight; // Handle collision with left wall/barrier (positive Y direction) + fRoofHeight = + pTrackInfo->fRoofHeight; // Handle collision with left wall/barrier + // (positive Y direction) if (fRoofHeight < 0.0) bRoofCheck = fLocalCoordZ >= (double)fRoofHeight && fLocalCoordZ <= 0.0; else bRoofCheck = fLocalCoordZ <= (double)fRoofHeight && fLocalCoordZ >= 0.0; if (bRoofCheck && fRoofHeight > 0.0) { - dWallPosition = TrakColour[iChunk][4] < 0 ? -pCurrentData->fTrackHalfWidth : -pCurrentData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth; + dWallPosition = + TrakColour[iChunk][4] < 0 + ? -pCurrentData->fTrackHalfWidth + : -pCurrentData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth; fWallBoundary = (float)dWallPosition; if (fLocalCoordY - CarBaseY <= fWallBoundary) { if (fDirectionYLocal < 0.0) { if (death_race) - dDamageLeft = -fDirectionYLocal * 0.006 * 4.0;// Apply wall collision damage (4x in death race mode) + dDamageLeft = + -fDirectionYLocal * 0.006 * + 4.0; // Apply wall collision damage (4x in death race mode) else dDamageLeft = -fDirectionYLocal * 0.006; fTempDamage2 = (float)dDamageLeft; dodamage(pCar, fTempDamage2); iRollBackup = -pCar->iRollMomentum; fDirectionYLocal = -fDirectionYLocal; - //HIBYTE(fDirectionYLocal) ^= 0x80u; + // HIBYTE(fDirectionYLocal) ^= 0x80u; pCar->iRollMomentum = iRollBackup; } if (fDirectionYLocal < 40.0) @@ -5692,42 +6675,55 @@ void landontrack(tCar *pCar) if (fDirectionYLocal > 40.0 && !pCar->bySfxCooldown) { dVolumeCalc = fDirectionYLocal * 32768.0 * 0.025; //_CHP(); - //LODWORD(fTempCalc) = (int)dVolumeCalc; - sfxpend(SOUND_SAMPLE_WALL1, pCar->iDriverIdx, (int)dVolumeCalc);// SOUND_SAMPLE_WALL1 + // LODWORD(fTempCalc) = (int)dVolumeCalc; + sfxpend(SOUND_SAMPLE_WALL1, pCar->iDriverIdx, + (int)dVolumeCalc); // SOUND_SAMPLE_WALL1 pCar->bySfxCooldown = 9; } dVelocityY = fDirectionYLocal; dVelocityX = fDirectionXLocal; dVelocityZ = fDirectionZLocal; - pCar->direction.fX = (float)(pCurrentData->pointAy[0].fY * fDirectionYLocal + pCurrentData->pointAy[0].fX * fDirectionXLocal + pCurrentData->pointAy[0].fZ * fDirectionZLocal); - pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dVelocityX + pCurrentData->pointAy[1].fY * dVelocityY + pCurrentData->pointAy[1].fZ * dVelocityZ); - pCar->direction.fZ = (float)(dVelocityY * pCurrentData->pointAy[2].fY + dVelocityX * pCurrentData->pointAy[2].fX + dVelocityZ * pCurrentData->pointAy[2].fZ); + pCar->direction.fX = + (float)(pCurrentData->pointAy[0].fY * fDirectionYLocal + + pCurrentData->pointAy[0].fX * fDirectionXLocal + + pCurrentData->pointAy[0].fZ * fDirectionZLocal); + pCar->direction.fY = + (float)(pCurrentData->pointAy[1].fX * dVelocityX + + pCurrentData->pointAy[1].fY * dVelocityY + + pCurrentData->pointAy[1].fZ * dVelocityZ); + pCar->direction.fZ = + (float)(dVelocityY * pCurrentData->pointAy[2].fY + + dVelocityX * pCurrentData->pointAy[2].fX + + dVelocityZ * pCurrentData->pointAy[2].fZ); fLocalCoordY = fWallBoundary + CarBaseY; dLocalPosX = fLocalCoordX; dLocalPosZ = fLocalCoordZ; - pCar->pos.fX = pCurrentData->pointAy[0].fY * fLocalCoordY - + pCurrentData->pointAy[0].fX * fLocalCoordX - + pCurrentData->pointAy[0].fZ * fLocalCoordZ - - pCurrentData->pointAy[3].fX; - pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dLocalPosX - + pCurrentData->pointAy[1].fY * fLocalCoordY - + pCurrentData->pointAy[1].fZ * dLocalPosZ - - pCurrentData->pointAy[3].fY); - dFinalPosZ = dLocalPosZ * pCurrentData->pointAy[2].fZ - + dLocalPosX * pCurrentData->pointAy[2].fX - + pCurrentData->pointAy[2].fY * fLocalCoordY - - pCurrentData->pointAy[3].fZ; + pCar->pos.fX = pCurrentData->pointAy[0].fY * fLocalCoordY + + pCurrentData->pointAy[0].fX * fLocalCoordX + + pCurrentData->pointAy[0].fZ * fLocalCoordZ - + pCurrentData->pointAy[3].fX; + pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dLocalPosX + + pCurrentData->pointAy[1].fY * fLocalCoordY + + pCurrentData->pointAy[1].fZ * dLocalPosZ - + pCurrentData->pointAy[3].fY); + dFinalPosZ = dLocalPosZ * pCurrentData->pointAy[2].fZ + + dLocalPosX * pCurrentData->pointAy[2].fX + + pCurrentData->pointAy[2].fY * fLocalCoordY - + pCurrentData->pointAy[3].fZ; fTempCalc = pCar->direction.fX; fDirectionYTemp2 = pCar->direction.fY; fDirectionTemp1 = fTempCalc; fDirX = fTempCalc; fDirectionTemp3 = fDirectionYTemp2; pCar->pos.fZ = (float)dFinalPosZ; - //if ((LODWORD(fDirX) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYTemp2) & 0x7FFFFFFF) != 0) { - if (fabs(fDirX) > FLT_EPSILON || fabs(fDirectionYTemp2) > FLT_EPSILON) { - dAngle2 = atan2(fDirectionTemp3, fDirectionTemp1) * 16384.0 / 6.28318530718; + // if ((LODWORD(fDirX) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYTemp2) & 0x7FFFFFFF) != 0) { + if (fabs(fDirX) > FLT_EPSILON || + fabs(fDirectionYTemp2) > FLT_EPSILON) { + dAngle2 = atan2(fDirectionTemp3, fDirectionTemp1) * 16384.0 / + 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle2; + // LODWORD(fTempCalc) = (int)dAngle2; iChunkIdx = (int)dAngle2 & 0x3FFF; } else { iChunkIdx = 0; @@ -5736,24 +6732,31 @@ void landontrack(tCar *pCar) } } } - } else if (TrakColour[iChunk][3]) // Handle collision with right wall/barrier (negative Y direction) + } else if (TrakColour[iChunk][3]) // Handle collision with right wall/barrier + // (negative Y direction) { fRoofHeightCheck = pTrackInfo->fRoofHeight; if (fRoofHeightCheck < 0.0) - bRoofCollision = fLocalCoordZ >= (double)fRoofHeightCheck && fLocalCoordZ <= 0.0; + bRoofCollision = + fLocalCoordZ >= (double)fRoofHeightCheck && fLocalCoordZ <= 0.0; else - bRoofCollision = fLocalCoordZ <= (double)fRoofHeightCheck && fLocalCoordZ >= 0.0; + bRoofCollision = + fLocalCoordZ <= (double)fRoofHeightCheck && fLocalCoordZ >= 0.0; if (bRoofCollision && fRoofHeightCheck > 0.0) { if (TrakColour[iChunk][3] < 0) { fTrackHalfWidth = pCurrentData->fTrackHalfWidth; fTrackHalfWidthNext = pNextData->fTrackHalfWidth; } else { - fTrackHalfWidth = pCurrentData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth; - fTrackHalfWidthNext = pNextData->fTrackHalfWidth + pNextTrackInfo->fLShoulderWidth; + fTrackHalfWidth = + pCurrentData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth; + fTrackHalfWidthNext = + pNextData->fTrackHalfWidth + pNextTrackInfo->fLShoulderWidth; } - fInterpolatedBoundary = ((fLocalCoordX + pCurrentData->fTrackHalfLength) * fTrackHalfWidthNext - (fLocalCoordX - pCurrentData->fTrackHalfLength) * fTrackHalfWidth) - / (pCurrentData->fTrackHalfLength - * 2.0f); + fInterpolatedBoundary = + ((fLocalCoordX + pCurrentData->fTrackHalfLength) * + fTrackHalfWidthNext - + (fLocalCoordX - pCurrentData->fTrackHalfLength) * fTrackHalfWidth) / + (pCurrentData->fTrackHalfLength * 2.0f); if (fLocalCoordY + CarBaseY >= fInterpolatedBoundary) { if (fDirectionYLocal > 0.0) { if (death_race) @@ -5764,7 +6767,7 @@ void landontrack(tCar *pCar) dodamage(pCar, fTempDamage); iRollMomentumBackup = -pCar->iRollMomentum; fDirectionYLocal = -fDirectionYLocal; - //HIBYTE(fDirectionYLocal) ^= 0x80u; + // HIBYTE(fDirectionYLocal) ^= 0x80u; pCar->iRollMomentum = iRollMomentumBackup; } if (fDirectionYLocal > -40.0) @@ -5774,77 +6777,107 @@ void landontrack(tCar *pCar) if (dDamageAmount > 40.0 && !pCar->bySfxCooldown) { dSoundVolume = fWallDamageCalc * 32768.0 * 0.025; //_CHP(); - //LODWORD(fTempCalc) = (int)dSoundVolume; - sfxpend(SOUND_SAMPLE_WALL1, pCar->iDriverIdx, (int)dSoundVolume);// SOUND_SAMPLE_WALL1 + // LODWORD(fTempCalc) = (int)dSoundVolume; + sfxpend(SOUND_SAMPLE_WALL1, pCar->iDriverIdx, + (int)dSoundVolume); // SOUND_SAMPLE_WALL1 pCar->bySfxCooldown = 9; } dLocalY = fDirectionYLocal; dLocalX = fDirectionXLocal; dLocalZ = fDirectionZLocal; - pCar->direction.fX = (float)(pCurrentData->pointAy[0].fY * fDirectionYLocal + pCurrentData->pointAy[0].fX * fDirectionXLocal + pCurrentData->pointAy[0].fZ * fDirectionZLocal); - pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dLocalX + pCurrentData->pointAy[1].fY * dLocalY + pCurrentData->pointAy[1].fZ * dLocalZ); - pCar->direction.fZ = (float)(dLocalY * pCurrentData->pointAy[2].fY + dLocalX * pCurrentData->pointAy[2].fX + dLocalZ * pCurrentData->pointAy[2].fZ); + pCar->direction.fX = + (float)(pCurrentData->pointAy[0].fY * fDirectionYLocal + + pCurrentData->pointAy[0].fX * fDirectionXLocal + + pCurrentData->pointAy[0].fZ * fDirectionZLocal); + pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dLocalX + + pCurrentData->pointAy[1].fY * dLocalY + + pCurrentData->pointAy[1].fZ * dLocalZ); + pCar->direction.fZ = (float)(dLocalY * pCurrentData->pointAy[2].fY + + dLocalX * pCurrentData->pointAy[2].fX + + dLocalZ * pCurrentData->pointAy[2].fZ); fLocalCoordY = fInterpolatedBoundary - CarBaseY; dTempX = fLocalCoordX; dTempZ = fLocalCoordZ; - pCar->pos.fX = pCurrentData->pointAy[0].fY * fLocalCoordY - + pCurrentData->pointAy[0].fX * fLocalCoordX - + pCurrentData->pointAy[0].fZ * fLocalCoordZ - - pCurrentData->pointAy[3].fX; - pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dTempX + pCurrentData->pointAy[1].fY * fLocalCoordY + pCurrentData->pointAy[1].fZ * dTempZ - pCurrentData->pointAy[3].fY); - dPositionZ = dTempZ * pCurrentData->pointAy[2].fZ + dTempX * pCurrentData->pointAy[2].fX + pCurrentData->pointAy[2].fY * fLocalCoordY - pCurrentData->pointAy[3].fZ; + pCar->pos.fX = pCurrentData->pointAy[0].fY * fLocalCoordY + + pCurrentData->pointAy[0].fX * fLocalCoordX + + pCurrentData->pointAy[0].fZ * fLocalCoordZ - + pCurrentData->pointAy[3].fX; + pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dTempX + + pCurrentData->pointAy[1].fY * fLocalCoordY + + pCurrentData->pointAy[1].fZ * dTempZ - + pCurrentData->pointAy[3].fY); + dPositionZ = dTempZ * pCurrentData->pointAy[2].fZ + + dTempX * pCurrentData->pointAy[2].fX + + pCurrentData->pointAy[2].fY * fLocalCoordY - + pCurrentData->pointAy[3].fZ; fTempCalc = pCar->direction.fX; fDirectionYTemp1 = pCar->direction.fY; fAngleCalcTemp5 = fTempCalc; fDirectionX = fTempCalc; fAngleCalcTemp6 = fDirectionYTemp1; pCar->pos.fZ = (float)dPositionZ; - //if ((LODWORD(fDirectionX) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYTemp1) & 0x7FFFFFFF) != 0) { - if (fabs(fDirectionX) > FLT_EPSILON || fabs(fDirectionYTemp1) > FLT_EPSILON) { - dAngle1 = atan2(fAngleCalcTemp6, fAngleCalcTemp5) * 16384.0 / 6.28318530718; + // if ((LODWORD(fDirectionX) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYTemp1) & 0x7FFFFFFF) != 0) { + if (fabs(fDirectionX) > FLT_EPSILON || + fabs(fDirectionYTemp1) > FLT_EPSILON) { + dAngle1 = + atan2(fAngleCalcTemp6, fAngleCalcTemp5) * 16384.0 / 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle1; + // LODWORD(fTempCalc) = (int)dAngle1; iChunkIdx = (int)dAngle1 & 0x3FFF; } else { iChunkIdx = 0; } LABEL_69: - dHorizontalSpeed = pCar->direction.fX * pCar->direction.fX + pCar->direction.fY * pCar->direction.fY; + dHorizontalSpeed = pCar->direction.fX * pCar->direction.fX + + pCar->direction.fY * pCar->direction.fY; pCar->nActualYaw = iChunkIdx; pCar->fHorizontalSpeed = (float)sqrt(dHorizontalSpeed); } } } - if (pCurrentData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth >= fLocalCoordY) { - dNegTrackWidth = -pCurrentData->fTrackHalfWidth;// Check if car is within track boundaries for ground collision + if (pCurrentData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth >= + fLocalCoordY) { + dNegTrackWidth = + -pCurrentData->fTrackHalfWidth; // Check if car is within track + // boundaries for ground collision fTrackWidthNeg = (float)dNegTrackWidth; if (dNegTrackWidth - pTrackInfo->fRShoulderWidth <= fLocalCoordY) { if (fLocalCoordY <= (double)pCurrentData->fTrackHalfWidth) iGroundType = fLocalCoordY >= (double)fTrackWidthNeg ? 1 : 2; else iGroundType = 0; - //llTrackColor = TrakColour[iChunk][iGroundType]; - //if ((((HIDWORD(llTrackColor) ^ (unsigned int)llTrackColor) - HIDWORD(llTrackColor)) & 0x20000) == 0 - if ((TrakColour[iChunk][iGroundType] & SURFACE_FLAG_SKIP_RENDER) == 0 - || pCurrentData->fTrackHalfLength * 2.0 <= CarBaseX - || pCurrentData->fTrackHalfWidth * 2.0 <= CarBaseX) { + // llTrackColor = TrakColour[iChunk][iGroundType]; + // if ((((HIDWORD(llTrackColor) ^ (unsigned int)llTrackColor) - + // HIDWORD(llTrackColor)) & 0x20000) == 0 + if ((TrakColour[iChunk][iGroundType] & SURFACE_FLAG_SKIP_RENDER) == 0 || + pCurrentData->fTrackHalfLength * 2.0 <= CarBaseX || + pCurrentData->fTrackHalfWidth * 2.0 <= CarBaseX) { iChunkIndex = iChunk; - fGroundHeight = (float)getgroundz(fLocalCoordX, fLocalCoordY, iChunk);// Handle normal ground collision - calculate ground height and landing physics - if (fLocalCoordZ <= (double)fGroundHeight && fDirectionZLocal * 2.0 + fGroundHeight + -250.0 <= fLocalCoordZ) { + fGroundHeight = (float)getgroundz( + fLocalCoordX, fLocalCoordY, + iChunk); // Handle normal ground collision - calculate ground height + // and landing physics + if (fLocalCoordZ <= (double)fGroundHeight && + fDirectionZLocal * 2.0 + fGroundHeight + -250.0 <= fLocalCoordZ) { pCar->pos.fX = fLocalCoordX; pCar->pos.fY = fLocalCoordY; - getlocalangles(pCar->nYaw, pCar->nPitch, pCar->nRoll, iChunkIndex, &iAzimuth, &iElevation, &iBank); + getlocalangles(pCar->nYaw, pCar->nPitch, pCar->nRoll, iChunkIndex, + &iAzimuth, &iElevation, &iBank); pCar->nYaw = iAzimuth; pCar->nActualYaw = iAzimuth; pCar->nPitch = iElevation; pCar->nRoll = iBank; fTransformX = fDirectionXLocal; pCar->nCurrChunk = iChunk; - //if ((LODWORD(fTransformX) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYLocal) & 0x7FFFFFFF) != 0) { - if (fabs(fTransformX) > FLT_EPSILON || fabs(fDirectionYLocal) > FLT_EPSILON) { - dAngle3 = atan2(fDirectionYLocal, fDirectionXLocal) * 16384.0 / 6.28318530718; + // if ((LODWORD(fTransformX) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYLocal) & 0x7FFFFFFF) != 0) { + if (fabs(fTransformX) > FLT_EPSILON || + fabs(fDirectionYLocal) > FLT_EPSILON) { + dAngle3 = atan2(fDirectionYLocal, fDirectionXLocal) * 16384.0 / + 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle3; + // LODWORD(fTempCalc) = (int)dAngle3; pCar->nActualYaw = (int)dAngle3 & 0x3FFF; } if (iBank < 4096 || iBank > 12288) { @@ -5877,88 +6910,130 @@ void landontrack(tCar *pCar) if (iStunned) { dStunnedVolume = fVolumeCalc; //_CHP(); - //LODWORD(fTempCalc) = (int)dStunnedVolume; - sfxpend(SOUND_SAMPLE_ROOF, pCar->iDriverIdx, (int)dStunnedVolume);// SOUND_SAMPLE_ROOF + // LODWORD(fTempCalc) = (int)dStunnedVolume; + sfxpend(SOUND_SAMPLE_ROOF, pCar->iDriverIdx, + (int)dStunnedVolume); // SOUND_SAMPLE_ROOF } else if (!pCar->bySfxCooldown) { dImpactVolume = fVolumeCalc; if (fHeightDiffCalc <= 40.0) { //_CHP(); - //LODWORD(fTempCalc) = (int)dImpactVolume; - iSfxType = SOUND_SAMPLE_LIGHTLAN; // SOUND_SAMPLE_LIGHTLAN + // LODWORD(fTempCalc) = (int)dImpactVolume; + iSfxType = SOUND_SAMPLE_LIGHTLAN; // SOUND_SAMPLE_LIGHTLAN } else { - //_CHP(); // Play appropriate landing sound effect based on impact severity - //LODWORD(fTempCalc) = (int)dImpactVolume; - iSfxType = SOUND_SAMPLE_LANDSKID; // SOUND_SAMPLE_LANDSKID + //_CHP(); // Play appropriate landing + // sound effect based on impact severity LODWORD(fTempCalc) = + // (int)dImpactVolume; + iSfxType = SOUND_SAMPLE_LANDSKID; // SOUND_SAMPLE_LANDSKID } sfxpend(iSfxType, pCar->iDriverIdx, (int)dImpactVolume); pCar->bySfxCooldown = 9; } - fTempDamage3 = (float)fabs((fPrevZPosition - fLocalCoordZ) * tsin[iElevation & 0x3FFF] * 0.05);// Calculate landing damage based on impact angle and velocity + fTempDamage3 = (float)fabs((fPrevZPosition - fLocalCoordZ) * + tsin[iElevation & 0x3FFF] * + 0.05); // Calculate landing damage based on + // impact angle and velocity dodamage(pCar, fTempDamage3); - fThrottle = (float)sqrt(fDirectionXLocal * fDirectionXLocal + fDirectionYLocal * fDirectionYLocal); + fThrottle = (float)sqrt(fDirectionXLocal * fDirectionXLocal + + fDirectionYLocal * fDirectionYLocal); SetEngine(pCar, fThrottle); } } } } if (pCar->nCurrChunk == -1) { - iGroundColorType = GroundColour[iChunk][2]; // Handle underground section collision detection when car is below track level + iGroundColorType = + GroundColour[iChunk][2]; // Handle underground section collision + // detection when car is below track level if (iGroundColorType != -1) { if (iGroundColorType >= 0) { dSeparatedY = fCarPosY + data.pointAy[3].fY; dSeparatedX = fCarPosX + data.pointAy[3].fX; dSeparatedZ = fCarPosZ + data.pointAy[3].fZ; - fLocalCoordX = (float)(data.pointAy[1].fX * dSeparatedY + data.pointAy[0].fX * dSeparatedX + data.pointAy[2].fX * dSeparatedZ); - fLocalCoordY = (float)(data.pointAy[0].fY * dSeparatedX + data.pointAy[1].fY * dSeparatedY + data.pointAy[2].fY * dSeparatedZ); + fLocalCoordX = (float)(data.pointAy[1].fX * dSeparatedY + + data.pointAy[0].fX * dSeparatedX + + data.pointAy[2].fX * dSeparatedZ); + fLocalCoordY = (float)(data.pointAy[0].fY * dSeparatedX + + data.pointAy[1].fY * dSeparatedY + + data.pointAy[2].fY * dSeparatedZ); pCurrentData = &data; - fLocalCoordZ = (float)(dSeparatedY * data.pointAy[1].fZ + dSeparatedX * data.pointAy[0].fZ + dSeparatedZ * data.pointAy[2].fZ); + fLocalCoordZ = (float)(dSeparatedY * data.pointAy[1].fZ + + dSeparatedX * data.pointAy[0].fZ + + dSeparatedZ * data.pointAy[2].fZ); } - if ((GroundColour[iChunk][2] < 0 || fLocalCoordY < 0.0) - && (GroundColour[iChunk][2] >= 0 || pCurrentData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth - CarBaseY > fLocalCoordY)) { + if ((GroundColour[iChunk][2] < 0 || fLocalCoordY < 0.0) && + (GroundColour[iChunk][2] >= 0 || pCurrentData->fTrackHalfWidth + + pTrackInfo->fLShoulderWidth - + CarBaseY > + fLocalCoordY)) { if (GroundColour[iChunk][2] >= 0) { dSeparatedY2 = fCarPosY + data.pointAy[3].fY; dSeparatedX2 = fCarPosX + data.pointAy[3].fX; dSeparatedZ2 = fCarPosZ + data.pointAy[3].fZ; - fLocalCoordX = (float)(data.pointAy[1].fX * dSeparatedY2 + data.pointAy[0].fX * dSeparatedX2 + data.pointAy[2].fX * dSeparatedZ2); - fLocalCoordY = (float)(data.pointAy[0].fY * dSeparatedX2 + data.pointAy[1].fY * dSeparatedY2 + data.pointAy[2].fY * dSeparatedZ2); + fLocalCoordX = (float)(data.pointAy[1].fX * dSeparatedY2 + + data.pointAy[0].fX * dSeparatedX2 + + data.pointAy[2].fX * dSeparatedZ2); + fLocalCoordY = (float)(data.pointAy[0].fY * dSeparatedX2 + + data.pointAy[1].fY * dSeparatedY2 + + data.pointAy[2].fY * dSeparatedZ2); pCurrentData = &data; - fLocalCoordZ = (float)(dSeparatedY2 * data.pointAy[1].fZ + dSeparatedX2 * data.pointAy[0].fZ + dSeparatedZ2 * data.pointAy[2].fZ); + fLocalCoordZ = (float)(dSeparatedY2 * data.pointAy[1].fZ + + dSeparatedX2 * data.pointAy[0].fZ + + dSeparatedZ2 * data.pointAy[2].fZ); } - if (GroundColour[iChunk][2] >= 0 && fLocalCoordY < 0.0 - || GroundColour[iChunk][2] < 0 && -pCurrentData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth + CarBaseY >= fLocalCoordY) { + if (GroundColour[iChunk][2] >= 0 && fLocalCoordY < 0.0 || + GroundColour[iChunk][2] < 0 && -pCurrentData->fTrackHalfWidth - + pTrackInfo->fRShoulderWidth + + CarBaseY >= + fLocalCoordY) { pGroundPts2 = &GroundPt[iChunk]; dGroundY4 = pGroundPts2->pointAy[4].fY + pCurrentData->pointAy[3].fY; dGroundX4 = pGroundPts2->pointAy[4].fX + pCurrentData->pointAy[3].fX; dGroundZ4 = pGroundPts2->pointAy[4].fZ + pCurrentData->pointAy[3].fZ; - fGroundYInterp1 = (float)(pCurrentData->pointAy[1].fY * dGroundY4 + pCurrentData->pointAy[0].fY * dGroundX4 + pCurrentData->pointAy[2].fY * dGroundZ4); - fGroundZInterp5 = (float)(dGroundY4 * pCurrentData->pointAy[1].fZ + dGroundX4 * pCurrentData->pointAy[0].fZ + dGroundZ4 * pCurrentData->pointAy[2].fZ); + fGroundYInterp1 = (float)(pCurrentData->pointAy[1].fY * dGroundY4 + + pCurrentData->pointAy[0].fY * dGroundX4 + + pCurrentData->pointAy[2].fY * dGroundZ4); + fGroundZInterp5 = (float)(dGroundY4 * pCurrentData->pointAy[1].fZ + + dGroundX4 * pCurrentData->pointAy[0].fZ + + dGroundZ4 * pCurrentData->pointAy[2].fZ); fHeightDiffUnder = fLocalCoordZ - fGroundZInterp5; if (fLocalCoordZ <= (double)fGroundZInterp5) { - dGroundY6 = pGroundPts2->pointAy[3].fY + pCurrentData->pointAy[3].fY; - dGroundX6 = pGroundPts2->pointAy[3].fX + pCurrentData->pointAy[3].fX; - dGroundZ6 = pGroundPts2->pointAy[3].fZ + pCurrentData->pointAy[3].fZ; - fGroundYCalc4 = (float)(pCurrentData->pointAy[1].fY * dGroundY6 + pCurrentData->pointAy[0].fY * dGroundX6 + pCurrentData->pointAy[2].fY * dGroundZ6); - fGroundZInterp1 = (float)(dGroundY6 * pCurrentData->pointAy[1].fZ + dGroundX6 * pCurrentData->pointAy[0].fZ + dGroundZ6 * pCurrentData->pointAy[2].fZ); + dGroundY6 = + pGroundPts2->pointAy[3].fY + pCurrentData->pointAy[3].fY; + dGroundX6 = + pGroundPts2->pointAy[3].fX + pCurrentData->pointAy[3].fX; + dGroundZ6 = + pGroundPts2->pointAy[3].fZ + pCurrentData->pointAy[3].fZ; + fGroundYCalc4 = (float)(pCurrentData->pointAy[1].fY * dGroundY6 + + pCurrentData->pointAy[0].fY * dGroundX6 + + pCurrentData->pointAy[2].fY * dGroundZ6); + fGroundZInterp1 = (float)(dGroundY6 * pCurrentData->pointAy[1].fZ + + dGroundX6 * pCurrentData->pointAy[0].fZ + + dGroundZ6 * pCurrentData->pointAy[2].fZ); dSlopeDiff6 = fGroundZInterp5 - fGroundZInterp1; fSlopeDiffCalc4 = (float)dSlopeDiff6; if (fabs(dSlopeDiff6) <= 10.0) fInterpolatedHeight1 = -1000000.0; else - fInterpolatedHeight1 = fHeightDiffUnder * fGroundYCalc4 / (fGroundZInterp1 - fGroundZInterp5) - + (fLocalCoordZ - fGroundZInterp1) * fGroundYInterp1 / fSlopeDiffCalc4; + fInterpolatedHeight1 = fHeightDiffUnder * fGroundYCalc4 / + (fGroundZInterp1 - fGroundZInterp5) + + (fLocalCoordZ - fGroundZInterp1) * + fGroundYInterp1 / fSlopeDiffCalc4; if (fLocalCoordY - CarBaseY < fInterpolatedHeight1) { - fDirectionXTemp4 = pCurrentData->pointAy[1].fX * pCar->direction.fY - + pCurrentData->pointAy[0].fX * pCar->direction.fX - + pCurrentData->pointAy[2].fX * pCar->direction.fZ; - fDirectionYLocal4 = pCurrentData->pointAy[0].fY * pCar->direction.fX - + pCurrentData->pointAy[1].fY * pCar->direction.fY - + pCurrentData->pointAy[2].fY * pCar->direction.fZ; - fDirectionZTemp2 = pCurrentData->pointAy[0].fZ * pCar->direction.fX - + pCurrentData->pointAy[1].fZ * pCar->direction.fY - + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; + fDirectionXTemp4 = + pCurrentData->pointAy[1].fX * pCar->direction.fY + + pCurrentData->pointAy[0].fX * pCar->direction.fX + + pCurrentData->pointAy[2].fX * pCar->direction.fZ; + fDirectionYLocal4 = + pCurrentData->pointAy[0].fY * pCar->direction.fX + + pCurrentData->pointAy[1].fY * pCar->direction.fY + + pCurrentData->pointAy[2].fY * pCar->direction.fZ; + fDirectionZTemp2 = + pCurrentData->pointAy[0].fZ * pCar->direction.fX + + pCurrentData->pointAy[1].fZ * pCar->direction.fY + + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; if (fDirectionYLocal4 < 0.0) { fDirectionYLocal4 = -fDirectionYLocal4; - //HIBYTE(fDirectionYLocal4) ^= 0x80u; + // HIBYTE(fDirectionYLocal4) ^= 0x80u; if (death_race) dUndergroundDamage6 = fDirectionYLocal4 * 0.005 * 4.0; else @@ -5972,44 +7047,57 @@ void landontrack(tCar *pCar) if (fDirectionYLocal4 > 40.0 && !pCar->bySfxCooldown) { dBankSoundVolume6 = fDirectionYLocal4 * 32768.0 * 0.025; //_CHP(); - //LODWORD(fTempCalc) = (int)dBankSoundVolume6; - sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, (int)dBankSoundVolume6);// SOUND_SAMPLE_BANK + // LODWORD(fTempCalc) = (int)dBankSoundVolume6; + sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, + (int)dBankSoundVolume6); // SOUND_SAMPLE_BANK pCar->bySfxCooldown = 9; } dInterpolatedY3 = fInterpolatedHeight1 + CarBaseY; dInterpolatedX3 = fLocalCoordX; dInterpolatedZ3 = fLocalCoordZ; - pCar->pos.fX = (float)(pCurrentData->pointAy[0].fY * dInterpolatedY3 - + pCurrentData->pointAy[0].fX * fLocalCoordX - + pCurrentData->pointAy[0].fZ * fLocalCoordZ - - pCurrentData->pointAy[3].fX); - pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dInterpolatedX3 - + pCurrentData->pointAy[1].fY * dInterpolatedY3 - + pCurrentData->pointAy[1].fZ * dInterpolatedZ3 - - pCurrentData->pointAy[3].fY); - pCar->pos.fZ = (float)(dInterpolatedY3 * pCurrentData->pointAy[2].fY - + dInterpolatedX3 * pCurrentData->pointAy[2].fX - + dInterpolatedZ3 * pCurrentData->pointAy[2].fZ - - pCurrentData->pointAy[3].fZ); + pCar->pos.fX = + (float)(pCurrentData->pointAy[0].fY * dInterpolatedY3 + + pCurrentData->pointAy[0].fX * fLocalCoordX + + pCurrentData->pointAy[0].fZ * fLocalCoordZ - + pCurrentData->pointAy[3].fX); + pCar->pos.fY = + (float)(pCurrentData->pointAy[1].fX * dInterpolatedX3 + + pCurrentData->pointAy[1].fY * dInterpolatedY3 + + pCurrentData->pointAy[1].fZ * dInterpolatedZ3 - + pCurrentData->pointAy[3].fY); + pCar->pos.fZ = + (float)(dInterpolatedY3 * pCurrentData->pointAy[2].fY + + dInterpolatedX3 * pCurrentData->pointAy[2].fX + + dInterpolatedZ3 * pCurrentData->pointAy[2].fZ - + pCurrentData->pointAy[3].fZ); dDirectionY5 = fDirectionYLocal4; dDirectionX5 = fDirectionXTemp4; dDirectionZ5 = fDirectionZTemp2; - pCar->direction.fX = pCurrentData->pointAy[0].fY * fDirectionYLocal4 - + pCurrentData->pointAy[0].fX * fDirectionXTemp4 - + pCurrentData->pointAy[0].fZ * fDirectionZTemp2; - pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dDirectionX5 + pCurrentData->pointAy[1].fY * dDirectionY5 + pCurrentData->pointAy[1].fZ * dDirectionZ5); - dFinalDirectionZ5 = dDirectionY5 * pCurrentData->pointAy[2].fY + dDirectionX5 * pCurrentData->pointAy[2].fX + dDirectionZ5 * pCurrentData->pointAy[2].fZ; + pCar->direction.fX = + pCurrentData->pointAy[0].fY * fDirectionYLocal4 + + pCurrentData->pointAy[0].fX * fDirectionXTemp4 + + pCurrentData->pointAy[0].fZ * fDirectionZTemp2; + pCar->direction.fY = + (float)(pCurrentData->pointAy[1].fX * dDirectionX5 + + pCurrentData->pointAy[1].fY * dDirectionY5 + + pCurrentData->pointAy[1].fZ * dDirectionZ5); + dFinalDirectionZ5 = dDirectionY5 * pCurrentData->pointAy[2].fY + + dDirectionX5 * pCurrentData->pointAy[2].fX + + dDirectionZ5 * pCurrentData->pointAy[2].fZ; fTempCalc = pCar->direction.fX; fDirectionYTemp4 = pCar->direction.fY; fAngleCalcTemp1 = fTempCalc; fDirXFinal6 = fTempCalc; fDirectionYFinal = fDirectionYTemp4; pCar->direction.fZ = (float)dFinalDirectionZ5; - //if ((LODWORD(fDirXFinal6) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYTemp4) & 0x7FFFFFFF) != 0) { - if (fabs(fDirXFinal6) > FLT_EPSILON || fabs(fDirectionYTemp4) > FLT_EPSILON) { - dAngle7 = atan2(fDirectionYFinal, fAngleCalcTemp1) * 16384.0 / 6.28318530718; + // if ((LODWORD(fDirXFinal6) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYTemp4) & 0x7FFFFFFF) != 0) { + if (fabs(fDirXFinal6) > FLT_EPSILON || + fabs(fDirectionYTemp4) > FLT_EPSILON) { + dAngle7 = atan2(fDirectionYFinal, fAngleCalcTemp1) * 16384.0 / + 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle7; + // LODWORD(fTempCalc) = (int)dAngle7; dYawCalc = (int)dAngle7 & 0x3FFF; } else { dYawCalc = 0; @@ -6017,30 +7105,43 @@ void landontrack(tCar *pCar) goto LABEL_192; } } else if (fLocalCoordY < (double)fGroundYInterp1) { - dGroundY5 = pGroundPts2->pointAy[5].fY + pCurrentData->pointAy[3].fY; - dGroundX5 = pGroundPts2->pointAy[5].fX + pCurrentData->pointAy[3].fX; - dGroundZ5 = pGroundPts2->pointAy[5].fZ + pCurrentData->pointAy[3].fZ; - fGroundYCalc1 = (float)(pCurrentData->pointAy[1].fY * dGroundY5 + pCurrentData->pointAy[0].fY * dGroundX5 + pCurrentData->pointAy[2].fY * dGroundZ5); - fGroundZInterp3 = (float)(dGroundY5 * pCurrentData->pointAy[1].fZ + dGroundX5 * pCurrentData->pointAy[0].fZ + dGroundZ5 * pCurrentData->pointAy[2].fZ); + dGroundY5 = + pGroundPts2->pointAy[5].fY + pCurrentData->pointAy[3].fY; + dGroundX5 = + pGroundPts2->pointAy[5].fX + pCurrentData->pointAy[3].fX; + dGroundZ5 = + pGroundPts2->pointAy[5].fZ + pCurrentData->pointAy[3].fZ; + fGroundYCalc1 = (float)(pCurrentData->pointAy[1].fY * dGroundY5 + + pCurrentData->pointAy[0].fY * dGroundX5 + + pCurrentData->pointAy[2].fY * dGroundZ5); + fGroundZInterp3 = (float)(dGroundY5 * pCurrentData->pointAy[1].fZ + + dGroundX5 * pCurrentData->pointAy[0].fZ + + dGroundZ5 * pCurrentData->pointAy[2].fZ); dSlopeDiff5 = fGroundZInterp5 - fGroundZInterp3; fSlopeDiffCalc3 = (float)dSlopeDiff5; - fInterpolatedHeight2 = fabs(dSlopeDiff5) <= 10.0 - ? -1000000.0f - : fHeightDiffUnder * fGroundYCalc1 / (fGroundZInterp3 - fGroundZInterp5) - + (fLocalCoordZ - fGroundZInterp3) * fGroundYInterp1 / fSlopeDiffCalc3; + fInterpolatedHeight2 = + fabs(dSlopeDiff5) <= 10.0 + ? -1000000.0f + : fHeightDiffUnder * fGroundYCalc1 / + (fGroundZInterp3 - fGroundZInterp5) + + (fLocalCoordZ - fGroundZInterp3) * fGroundYInterp1 / + fSlopeDiffCalc3; if (fLocalCoordY - CarBaseY < fInterpolatedHeight2) { - fDirectionXTemp3 = pCurrentData->pointAy[1].fX * pCar->direction.fY - + pCurrentData->pointAy[0].fX * pCar->direction.fX - + pCurrentData->pointAy[2].fX * pCar->direction.fZ; - fDirectionYLocal3 = pCurrentData->pointAy[0].fY * pCar->direction.fX - + pCurrentData->pointAy[1].fY * pCar->direction.fY - + pCurrentData->pointAy[2].fY * pCar->direction.fZ; - fDirectionZTemp4 = pCurrentData->pointAy[0].fZ * pCar->direction.fX - + pCurrentData->pointAy[1].fZ * pCar->direction.fY - + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; + fDirectionXTemp3 = + pCurrentData->pointAy[1].fX * pCar->direction.fY + + pCurrentData->pointAy[0].fX * pCar->direction.fX + + pCurrentData->pointAy[2].fX * pCar->direction.fZ; + fDirectionYLocal3 = + pCurrentData->pointAy[0].fY * pCar->direction.fX + + pCurrentData->pointAy[1].fY * pCar->direction.fY + + pCurrentData->pointAy[2].fY * pCar->direction.fZ; + fDirectionZTemp4 = + pCurrentData->pointAy[0].fZ * pCar->direction.fX + + pCurrentData->pointAy[1].fZ * pCar->direction.fY + + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; if (fDirectionYLocal3 < 0.0) { fDirectionYLocal3 = -fDirectionYLocal3; - //HIBYTE(fDirectionYLocal3) ^= 0x80u; + // HIBYTE(fDirectionYLocal3) ^= 0x80u; if (death_race) dUndergroundDamage5 = fDirectionYLocal3 * 0.005 * 4.0; else @@ -6054,44 +7155,55 @@ void landontrack(tCar *pCar) if (fDirectionYLocal3 > 40.0 && !pCar->bySfxCooldown) { dBankSoundVolume5 = fDirectionYLocal3 * 32768.0 * 0.025; //_CHP(); - //LODWORD(fTempCalc) = (int)dBankSoundVolume5; - sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, (int)dBankSoundVolume5);// SOUND_SAMPLE_BANK + // LODWORD(fTempCalc) = (int)dBankSoundVolume5; + sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, + (int)dBankSoundVolume5); // SOUND_SAMPLE_BANK pCar->bySfxCooldown = 9; } dGroundY3 = fInterpolatedHeight2 + CarBaseY; dGroundX3 = fLocalCoordX; dGroundZ3 = fLocalCoordZ; - pCar->pos.fX = (float)(pCurrentData->pointAy[0].fY * dGroundY3 - + pCurrentData->pointAy[0].fX * fLocalCoordX - + pCurrentData->pointAy[0].fZ * fLocalCoordZ - - pCurrentData->pointAy[3].fX); - pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dGroundX3 - + pCurrentData->pointAy[1].fY * dGroundY3 - + pCurrentData->pointAy[1].fZ * dGroundZ3 - - pCurrentData->pointAy[3].fY); - pCar->pos.fZ = (float)(dGroundY3 * pCurrentData->pointAy[2].fY - + dGroundX3 * pCurrentData->pointAy[2].fX - + dGroundZ3 * pCurrentData->pointAy[2].fZ - - pCurrentData->pointAy[3].fZ); + pCar->pos.fX = + (float)(pCurrentData->pointAy[0].fY * dGroundY3 + + pCurrentData->pointAy[0].fX * fLocalCoordX + + pCurrentData->pointAy[0].fZ * fLocalCoordZ - + pCurrentData->pointAy[3].fX); + pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dGroundX3 + + pCurrentData->pointAy[1].fY * dGroundY3 + + pCurrentData->pointAy[1].fZ * dGroundZ3 - + pCurrentData->pointAy[3].fY); + pCar->pos.fZ = (float)(dGroundY3 * pCurrentData->pointAy[2].fY + + dGroundX3 * pCurrentData->pointAy[2].fX + + dGroundZ3 * pCurrentData->pointAy[2].fZ - + pCurrentData->pointAy[3].fZ); dDirectionY4 = fDirectionYLocal3; dDirectionX4 = fDirectionXTemp3; dDirectionZ4 = fDirectionZTemp4; - pCar->direction.fX = pCurrentData->pointAy[0].fY * fDirectionYLocal3 - + pCurrentData->pointAy[0].fX * fDirectionXTemp3 - + pCurrentData->pointAy[0].fZ * fDirectionZTemp4; - pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dDirectionX4 + pCurrentData->pointAy[1].fY * dDirectionY4 + pCurrentData->pointAy[1].fZ * dDirectionZ4); - dFinalDirectionZ4 = dDirectionY4 * pCurrentData->pointAy[2].fY + dDirectionX4 * pCurrentData->pointAy[2].fX + dDirectionZ4 * pCurrentData->pointAy[2].fZ; + pCar->direction.fX = + pCurrentData->pointAy[0].fY * fDirectionYLocal3 + + pCurrentData->pointAy[0].fX * fDirectionXTemp3 + + pCurrentData->pointAy[0].fZ * fDirectionZTemp4; + pCar->direction.fY = + (float)(pCurrentData->pointAy[1].fX * dDirectionX4 + + pCurrentData->pointAy[1].fY * dDirectionY4 + + pCurrentData->pointAy[1].fZ * dDirectionZ4); + dFinalDirectionZ4 = dDirectionY4 * pCurrentData->pointAy[2].fY + + dDirectionX4 * pCurrentData->pointAy[2].fX + + dDirectionZ4 * pCurrentData->pointAy[2].fZ; fTempCalc = pCar->direction.fX; fDirectionYTemp6 = pCar->direction.fY; fAngleCalcTemp3 = fTempCalc; fDirXFinal5 = fTempCalc; fDirectionTemp2 = fDirectionYTemp6; pCar->direction.fZ = (float)dFinalDirectionZ4; - //if ((LODWORD(fDirXFinal5) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYTemp6) & 0x7FFFFFFF) != 0) { - if (fabs(fDirXFinal5) > FLT_EPSILON || fabs(fDirectionYTemp6) > FLT_EPSILON) { - dAngle6 = atan2(fDirectionTemp2, fAngleCalcTemp3) * 16384.0 / 6.28318530718; + // if ((LODWORD(fDirXFinal5) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYTemp6) & 0x7FFFFFFF) != 0) { + if (fabs(fDirXFinal5) > FLT_EPSILON || + fabs(fDirectionYTemp6) > FLT_EPSILON) { + dAngle6 = atan2(fDirectionTemp2, fAngleCalcTemp3) * 16384.0 / + 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle6; + // LODWORD(fTempCalc) = (int)dAngle6; dYawCalc = (int)dAngle6 & 0x3FFF; } else { dYawCalc = 0; @@ -6105,32 +7217,45 @@ void landontrack(tCar *pCar) dGroundY1 = pGroundPts->pointAy[1].fY + pCurrentData->pointAy[3].fY; dGroundX1 = pGroundPts->pointAy[1].fX + pCurrentData->pointAy[3].fX; dGroundZ1 = pGroundPts->pointAy[1].fZ + pCurrentData->pointAy[3].fZ; - fGroundYInterp2 = (float)(pCurrentData->pointAy[1].fY * dGroundY1 + pCurrentData->pointAy[0].fY * dGroundX1 + pCurrentData->pointAy[2].fY * dGroundZ1); - fGroundYInterp3 = (float)(dGroundY1 * pCurrentData->pointAy[1].fZ + dGroundX1 * pCurrentData->pointAy[0].fZ + dGroundZ1 * pCurrentData->pointAy[2].fZ); + fGroundYInterp2 = (float)(pCurrentData->pointAy[1].fY * dGroundY1 + + pCurrentData->pointAy[0].fY * dGroundX1 + + pCurrentData->pointAy[2].fY * dGroundZ1); + fGroundYInterp3 = (float)(dGroundY1 * pCurrentData->pointAy[1].fZ + + dGroundX1 * pCurrentData->pointAy[0].fZ + + dGroundZ1 * pCurrentData->pointAy[2].fZ); fHeightDiffGround = fLocalCoordZ - fGroundYInterp3; if (fLocalCoordZ <= (double)fGroundYInterp3) { dGroundY2 = pGroundPts->pointAy[2].fY + pCurrentData->pointAy[3].fY; dGroundX2 = pGroundPts->pointAy[2].fX + pCurrentData->pointAy[3].fX; dGroundZ2 = pGroundPts->pointAy[2].fZ + pCurrentData->pointAy[3].fZ; - fGroundYCalc3 = (float)(pCurrentData->pointAy[1].fY * dGroundY2 + pCurrentData->pointAy[0].fY * dGroundX2 + pCurrentData->pointAy[2].fY * dGroundZ2); - fGroundZInterp2 = (float)(dGroundY2 * pCurrentData->pointAy[1].fZ + dGroundX2 * pCurrentData->pointAy[0].fZ + dGroundZ2 * pCurrentData->pointAy[2].fZ); + fGroundYCalc3 = (float)(pCurrentData->pointAy[1].fY * dGroundY2 + + pCurrentData->pointAy[0].fY * dGroundX2 + + pCurrentData->pointAy[2].fY * dGroundZ2); + fGroundZInterp2 = (float)(dGroundY2 * pCurrentData->pointAy[1].fZ + + dGroundX2 * pCurrentData->pointAy[0].fZ + + dGroundZ2 * pCurrentData->pointAy[2].fZ); dSlopeDiff2 = fGroundYInterp3 - fGroundZInterp2; fSlopeDiffCalc1 = (float)dSlopeDiff2; if (fabs(dSlopeDiff2) <= 10.0) fInterpolatedHeight4 = 1000000.0f; else - fInterpolatedHeight4 = fHeightDiffGround * fGroundYCalc3 / (fGroundZInterp2 - fGroundYInterp3) - + (fLocalCoordZ - fGroundZInterp2) * fGroundYInterp2 / fSlopeDiffCalc1; + fInterpolatedHeight4 = fHeightDiffGround * fGroundYCalc3 / + (fGroundZInterp2 - fGroundYInterp3) + + (fLocalCoordZ - fGroundZInterp2) * + fGroundYInterp2 / fSlopeDiffCalc1; if (fLocalCoordY + CarBaseY > fInterpolatedHeight4) { - fDirectionXTemp2 = pCurrentData->pointAy[1].fX * pCar->direction.fY - + pCurrentData->pointAy[0].fX * pCar->direction.fX - + pCurrentData->pointAy[2].fX * pCar->direction.fZ; - fDirectionYLocal1 = pCurrentData->pointAy[0].fY * pCar->direction.fX - + pCurrentData->pointAy[1].fY * pCar->direction.fY - + pCurrentData->pointAy[2].fY * pCar->direction.fZ; - fDirectionZTemp3 = pCurrentData->pointAy[0].fZ * pCar->direction.fX - + pCurrentData->pointAy[1].fZ * pCar->direction.fY - + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; + fDirectionXTemp2 = + pCurrentData->pointAy[1].fX * pCar->direction.fY + + pCurrentData->pointAy[0].fX * pCar->direction.fX + + pCurrentData->pointAy[2].fX * pCar->direction.fZ; + fDirectionYLocal1 = + pCurrentData->pointAy[0].fY * pCar->direction.fX + + pCurrentData->pointAy[1].fY * pCar->direction.fY + + pCurrentData->pointAy[2].fY * pCar->direction.fZ; + fDirectionZTemp3 = + pCurrentData->pointAy[0].fZ * pCar->direction.fX + + pCurrentData->pointAy[1].fZ * pCar->direction.fY + + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; if (fDirectionYLocal1 > 0.0) { if (death_race) dUndergroundDamage2 = fDirectionYLocal1 * 0.005 * 4.0; @@ -6139,7 +7264,7 @@ void landontrack(tCar *pCar) fUndergroundDamage2 = (float)dUndergroundDamage2; dodamage(pCar, fUndergroundDamage2); fDirectionYLocal1 = -fDirectionYLocal1; - //HIBYTE(fDirectionYLocal1) ^= 0x80u; + // HIBYTE(fDirectionYLocal1) ^= 0x80u; pCar->iRollMomentum = -pCar->iRollMomentum; } if (fDirectionYLocal1 > -40.0) @@ -6149,44 +7274,57 @@ void landontrack(tCar *pCar) if (dNegSpeed2 > 40.0 && !pCar->bySfxCooldown) { dBankSoundVolume2 = fNegSpeedCalc1 * 32768.0 * 0.025; //_CHP(); - //LODWORD(fTempCalc) = (int)dBankSoundVolume2; - sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, (int)dBankSoundVolume2);// SOUND_SAMPLE_BANK + // LODWORD(fTempCalc) = (int)dBankSoundVolume2; + sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, + (int)dBankSoundVolume2); // SOUND_SAMPLE_BANK pCar->bySfxCooldown = 9; } dInterpolatedY2 = fInterpolatedHeight4 - CarBaseY; dInterpolatedX2 = fLocalCoordX; dInterpolatedZ2 = fLocalCoordZ; - pCar->pos.fX = (float)(pCurrentData->pointAy[0].fY * dInterpolatedY2 - + pCurrentData->pointAy[0].fX * fLocalCoordX - + pCurrentData->pointAy[0].fZ * fLocalCoordZ - - pCurrentData->pointAy[3].fX); - pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dInterpolatedX2 - + pCurrentData->pointAy[1].fY * dInterpolatedY2 - + pCurrentData->pointAy[1].fZ * dInterpolatedZ2 - - pCurrentData->pointAy[3].fY); - pCar->pos.fZ = (float)(dInterpolatedY2 * pCurrentData->pointAy[2].fY - + dInterpolatedX2 * pCurrentData->pointAy[2].fX - + dInterpolatedZ2 * pCurrentData->pointAy[2].fZ - - pCurrentData->pointAy[3].fZ); + pCar->pos.fX = + (float)(pCurrentData->pointAy[0].fY * dInterpolatedY2 + + pCurrentData->pointAy[0].fX * fLocalCoordX + + pCurrentData->pointAy[0].fZ * fLocalCoordZ - + pCurrentData->pointAy[3].fX); + pCar->pos.fY = + (float)(pCurrentData->pointAy[1].fX * dInterpolatedX2 + + pCurrentData->pointAy[1].fY * dInterpolatedY2 + + pCurrentData->pointAy[1].fZ * dInterpolatedZ2 - + pCurrentData->pointAy[3].fY); + pCar->pos.fZ = + (float)(dInterpolatedY2 * pCurrentData->pointAy[2].fY + + dInterpolatedX2 * pCurrentData->pointAy[2].fX + + dInterpolatedZ2 * pCurrentData->pointAy[2].fZ - + pCurrentData->pointAy[3].fZ); dDirectionY3 = fDirectionYLocal1; dDirectionX3 = fDirectionXTemp2; dDirectionZ3 = fDirectionZTemp3; - pCar->direction.fX = pCurrentData->pointAy[0].fY * fDirectionYLocal1 - + pCurrentData->pointAy[0].fX * fDirectionXTemp2 - + pCurrentData->pointAy[0].fZ * fDirectionZTemp3; - pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dDirectionX3 + pCurrentData->pointAy[1].fY * dDirectionY3 + pCurrentData->pointAy[1].fZ * dDirectionZ3); - dFinalDirectionZ2 = dDirectionY3 * pCurrentData->pointAy[2].fY + dDirectionX3 * pCurrentData->pointAy[2].fX + dDirectionZ3 * pCurrentData->pointAy[2].fZ; + pCar->direction.fX = + pCurrentData->pointAy[0].fY * fDirectionYLocal1 + + pCurrentData->pointAy[0].fX * fDirectionXTemp2 + + pCurrentData->pointAy[0].fZ * fDirectionZTemp3; + pCar->direction.fY = + (float)(pCurrentData->pointAy[1].fX * dDirectionX3 + + pCurrentData->pointAy[1].fY * dDirectionY3 + + pCurrentData->pointAy[1].fZ * dDirectionZ3); + dFinalDirectionZ2 = dDirectionY3 * pCurrentData->pointAy[2].fY + + dDirectionX3 * pCurrentData->pointAy[2].fX + + dDirectionZ3 * pCurrentData->pointAy[2].fZ; fTempCalc = pCar->direction.fX; fDirectionYTemp5 = pCar->direction.fY; fAngleCalcTemp2 = fTempCalc; fDirXFinal2 = fTempCalc; fAngleCalcTemp7 = fDirectionYTemp5; pCar->direction.fZ = (float)dFinalDirectionZ2; - //if ((LODWORD(fDirXFinal2) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYTemp5) & 0x7FFFFFFF) != 0) { - if (fabs(fDirXFinal2) > FLT_EPSILON || fabs(fDirectionYTemp5) > FLT_EPSILON) { - dAngle5 = atan2(fAngleCalcTemp7, fAngleCalcTemp2) * 16384.0 / 6.28318530718; + // if ((LODWORD(fDirXFinal2) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYTemp5) & 0x7FFFFFFF) != 0) { + if (fabs(fDirXFinal2) > FLT_EPSILON || + fabs(fDirectionYTemp5) > FLT_EPSILON) { + dAngle5 = atan2(fAngleCalcTemp7, fAngleCalcTemp2) * 16384.0 / + 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle5; + // LODWORD(fTempCalc) = (int)dAngle5; dYawCalc = (int)dAngle5 & 0x3FFF; } else { dYawCalc = 0; @@ -6197,23 +7335,34 @@ void landontrack(tCar *pCar) dGroundY0 = pGroundPts->pointAy[0].fY + pCurrentData->pointAy[3].fY; dGroundX0 = pGroundPts->pointAy[0].fX + pCurrentData->pointAy[3].fX; dGroundZ0 = pGroundPts->pointAy[0].fZ + pCurrentData->pointAy[3].fZ; - fGroundYCalc2 = (float)(pCurrentData->pointAy[1].fY * dGroundY0 + pCurrentData->pointAy[0].fY * dGroundX0 + pCurrentData->pointAy[2].fY * dGroundZ0); - fGroundZInterp4 = (float)(dGroundY0 * pCurrentData->pointAy[1].fZ + dGroundX0 * pCurrentData->pointAy[0].fZ + dGroundZ0 * pCurrentData->pointAy[2].fZ); + fGroundYCalc2 = (float)(pCurrentData->pointAy[1].fY * dGroundY0 + + pCurrentData->pointAy[0].fY * dGroundX0 + + pCurrentData->pointAy[2].fY * dGroundZ0); + fGroundZInterp4 = (float)(dGroundY0 * pCurrentData->pointAy[1].fZ + + dGroundX0 * pCurrentData->pointAy[0].fZ + + dGroundZ0 * pCurrentData->pointAy[2].fZ); dSlopeDiff = fGroundYInterp3 - fGroundZInterp4; fSlopeDiffCalc2 = (float)dSlopeDiff; - fInterpolatedHeight3 = fabs(dSlopeDiff) <= 10.0 - ? 1000000.0f - : fHeightDiffGround * fGroundYCalc2 / (fGroundZInterp4 - fGroundYInterp3) + (fLocalCoordZ - fGroundZInterp4) * fGroundYInterp2 / fSlopeDiffCalc2; + fInterpolatedHeight3 = + fabs(dSlopeDiff) <= 10.0 + ? 1000000.0f + : fHeightDiffGround * fGroundYCalc2 / + (fGroundZInterp4 - fGroundYInterp3) + + (fLocalCoordZ - fGroundZInterp4) * fGroundYInterp2 / + fSlopeDiffCalc2; if (fLocalCoordY + CarBaseY > fInterpolatedHeight3) { - fDirectionXTemp1 = pCurrentData->pointAy[1].fX * pCar->direction.fY - + pCurrentData->pointAy[0].fX * pCar->direction.fX - + pCurrentData->pointAy[2].fX * pCar->direction.fZ; - fDirectionYLocal2 = pCurrentData->pointAy[0].fY * pCar->direction.fX - + pCurrentData->pointAy[1].fY * pCar->direction.fY - + pCurrentData->pointAy[2].fY * pCar->direction.fZ; - fDirectionZTemp1 = pCurrentData->pointAy[0].fZ * pCar->direction.fX - + pCurrentData->pointAy[1].fZ * pCar->direction.fY - + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; + fDirectionXTemp1 = + pCurrentData->pointAy[1].fX * pCar->direction.fY + + pCurrentData->pointAy[0].fX * pCar->direction.fX + + pCurrentData->pointAy[2].fX * pCar->direction.fZ; + fDirectionYLocal2 = + pCurrentData->pointAy[0].fY * pCar->direction.fX + + pCurrentData->pointAy[1].fY * pCar->direction.fY + + pCurrentData->pointAy[2].fY * pCar->direction.fZ; + fDirectionZTemp1 = + pCurrentData->pointAy[0].fZ * pCar->direction.fX + + pCurrentData->pointAy[1].fZ * pCar->direction.fY + + pCurrentData->pointAy[2].fZ * pCar->direction.fZ; if (fDirectionYLocal2 > 0.0) { if (death_race) dUndergroundDamage = fDirectionYLocal2 * 0.005 * 4.0; @@ -6222,7 +7371,7 @@ void landontrack(tCar *pCar) fUndergroundDamage = (float)dUndergroundDamage; dodamage(pCar, fUndergroundDamage); iRollBackup2 = -pCar->iRollMomentum; - //HIBYTE(fDirectionYLocal2) ^= 0x80u; + // HIBYTE(fDirectionYLocal2) ^= 0x80u; fDirectionYLocal2 = -fDirectionYLocal2; pCar->iRollMomentum = iRollBackup2; } @@ -6233,50 +7382,64 @@ void landontrack(tCar *pCar) if (dNegSpeed > 40.0 && !pCar->bySfxCooldown) { dBankSoundVolume = fNegSpeedCalc2 * 32768.0 * 0.025; //_CHP(); - //LODWORD(fTempCalc) = (int)dBankSoundVolume; - sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, (int)dBankSoundVolume);// SOUND_SAMPLE_BANK + // LODWORD(fTempCalc) = (int)dBankSoundVolume; + sfxpend(SOUND_SAMPLE_BANK, pCar->iDriverIdx, + (int)dBankSoundVolume); // SOUND_SAMPLE_BANK pCar->bySfxCooldown = 9; } dInterpolatedY = fInterpolatedHeight3 - CarBaseY; dInterpolatedX = fLocalCoordX; dInterpolatedZ = fLocalCoordZ; - pCar->pos.fX = (float)(pCurrentData->pointAy[0].fY * dInterpolatedY - + pCurrentData->pointAy[0].fX * fLocalCoordX - + pCurrentData->pointAy[0].fZ * fLocalCoordZ - - pCurrentData->pointAy[3].fX); - pCar->pos.fY = (float)(pCurrentData->pointAy[1].fX * dInterpolatedX - + pCurrentData->pointAy[1].fY * dInterpolatedY - + pCurrentData->pointAy[1].fZ * dInterpolatedZ - - pCurrentData->pointAy[3].fY); - pCar->pos.fZ = (float)(dInterpolatedY * pCurrentData->pointAy[2].fY - + dInterpolatedX * pCurrentData->pointAy[2].fX - + dInterpolatedZ * pCurrentData->pointAy[2].fZ - - pCurrentData->pointAy[3].fZ); + pCar->pos.fX = + (float)(pCurrentData->pointAy[0].fY * dInterpolatedY + + pCurrentData->pointAy[0].fX * fLocalCoordX + + pCurrentData->pointAy[0].fZ * fLocalCoordZ - + pCurrentData->pointAy[3].fX); + pCar->pos.fY = + (float)(pCurrentData->pointAy[1].fX * dInterpolatedX + + pCurrentData->pointAy[1].fY * dInterpolatedY + + pCurrentData->pointAy[1].fZ * dInterpolatedZ - + pCurrentData->pointAy[3].fY); + pCar->pos.fZ = + (float)(dInterpolatedY * pCurrentData->pointAy[2].fY + + dInterpolatedX * pCurrentData->pointAy[2].fX + + dInterpolatedZ * pCurrentData->pointAy[2].fZ - + pCurrentData->pointAy[3].fZ); dDirectionY2 = fDirectionYLocal2; dDirectionX2 = fDirectionXTemp1; dDirectionZ2 = fDirectionZTemp1; - pCar->direction.fX = pCurrentData->pointAy[0].fY * fDirectionYLocal2 - + pCurrentData->pointAy[0].fX * fDirectionXTemp1 - + pCurrentData->pointAy[0].fZ * fDirectionZTemp1; - pCar->direction.fY = (float)(pCurrentData->pointAy[1].fX * dDirectionX2 + pCurrentData->pointAy[1].fY * dDirectionY2 + pCurrentData->pointAy[1].fZ * dDirectionZ2); - dFinalDirectionZ = dDirectionY2 * pCurrentData->pointAy[2].fY + dDirectionX2 * pCurrentData->pointAy[2].fX + dDirectionZ2 * pCurrentData->pointAy[2].fZ; + pCar->direction.fX = + pCurrentData->pointAy[0].fY * fDirectionYLocal2 + + pCurrentData->pointAy[0].fX * fDirectionXTemp1 + + pCurrentData->pointAy[0].fZ * fDirectionZTemp1; + pCar->direction.fY = + (float)(pCurrentData->pointAy[1].fX * dDirectionX2 + + pCurrentData->pointAy[1].fY * dDirectionY2 + + pCurrentData->pointAy[1].fZ * dDirectionZ2); + dFinalDirectionZ = dDirectionY2 * pCurrentData->pointAy[2].fY + + dDirectionX2 * pCurrentData->pointAy[2].fX + + dDirectionZ2 * pCurrentData->pointAy[2].fZ; fTempCalc = pCar->direction.fX; fDirectionYTemp3 = pCar->direction.fY; fAngleCalcTemp4 = fTempCalc; fDirXFinal = fTempCalc; fDirectionYFinal2 = fDirectionYTemp3; pCar->direction.fZ = (float)dFinalDirectionZ; - //if ((LODWORD(fDirXFinal) & 0x7FFFFFFF) != 0 || (LODWORD(fDirectionYTemp3) & 0x7FFFFFFF) != 0) { - if (fabs(fDirXFinal) > FLT_EPSILON || fabs(fDirectionYTemp3) > FLT_EPSILON) { - dAngle4 = atan2(fDirectionYFinal2, fAngleCalcTemp4) * 16384.0 / 6.28318530718; + // if ((LODWORD(fDirXFinal) & 0x7FFFFFFF) != 0 || + // (LODWORD(fDirectionYTemp3) & 0x7FFFFFFF) != 0) { + if (fabs(fDirXFinal) > FLT_EPSILON || + fabs(fDirectionYTemp3) > FLT_EPSILON) { + dAngle4 = atan2(fDirectionYFinal2, fAngleCalcTemp4) * 16384.0 / + 6.28318530718; //_CHP(); - //LODWORD(fTempCalc) = (int)dAngle4; + // LODWORD(fTempCalc) = (int)dAngle4; dYawCalc = (int)dAngle4 & 0x3FFF; } else { dYawCalc = 0; } LABEL_192: - dFinalHorizSpeed = pCar->direction.fX * pCar->direction.fX + pCar->direction.fY * pCar->direction.fY; + dFinalHorizSpeed = pCar->direction.fX * pCar->direction.fX + + pCar->direction.fY * pCar->direction.fY; pCar->nActualYaw = dYawCalc; pCar->fHorizontalSpeed = (float)sqrt(dFinalHorizSpeed); } @@ -6287,104 +7450,141 @@ void landontrack(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//00034CF0 -void converttoair(tCar *pCar) -{ - int iCurrChunk; // eax - double dRollSpeedCalc; // st7 - int iChunkBackup; // edi - tData *pData; // edi - double dFinalSpeed; // st7 +// 00034CF0 +void converttoair(tCar *pCar) { + int iCurrChunk; // eax + double dRollSpeedCalc; // st7 + int iChunkBackup; // edi + tData *pData; // edi + double dFinalSpeed; // st7 double dHorizontalSpeed; // st7 - int16 nTempChunk; // ax - int iWorldPitch; // [esp+0h] [ebp-30h] BYREF - int iWorldYaw1; // [esp+4h] [ebp-2Ch] BYREF - float fWorldZ; // [esp+8h] [ebp-28h] - float fWorldX; // [esp+Ch] [ebp-24h] - int iWorldRoll; // [esp+10h] [ebp-20h] BYREF - int iWorldYaw2; // [esp+14h] [ebp-1Ch] BYREF - float fWorldY; // [esp+18h] [ebp-18h] + int16 nTempChunk; // ax + int iWorldPitch; // [esp+0h] [ebp-30h] BYREF + int iWorldYaw1; // [esp+4h] [ebp-2Ch] BYREF + float fWorldZ; // [esp+8h] [ebp-28h] + float fWorldX; // [esp+Ch] [ebp-24h] + int iWorldRoll; // [esp+10h] [ebp-20h] BYREF + int iWorldYaw2; // [esp+14h] [ebp-1Ch] BYREF + float fWorldY; // [esp+18h] [ebp-18h] - pCar->iControlType = 0; // Set car to airborne control mode (0) + pCar->iControlType = 0; // Set car to airborne control mode (0) iCurrChunk = pCar->nCurrChunk; - if (iCurrChunk == -1) // Use backup chunk if current chunk is invalid (-1) + if (iCurrChunk == -1) // Use backup chunk if current chunk is invalid (-1) iCurrChunk = pCar->nReferenceChunk; pCar->iLastValidChunk = iCurrChunk; if (iCurrChunk < 0) iCurrChunk += TRAK_LEN; - dRollSpeedCalc = (double)localdata[iCurrChunk].iRoll * pCar->fFinalSpeed * 0.0013888889 + (double)pCar->iRollMomentum;// Calculate banking/roll effect based on speed (0.0013888889 = 1/720) + dRollSpeedCalc = + (double)localdata[iCurrChunk].iRoll * pCar->fFinalSpeed * 0.0013888889 + + (double)pCar->iRollMomentum; // Calculate banking/roll effect based on + // speed (0.0013888889 = 1/720) //_CHP(); pCar->iRollMomentum = (int)dRollSpeedCalc; iChunkBackup = pCar->nCurrChunk; - getworldangles(pCar->nActualYaw, pCar->nPitch, pCar->nRoll, pCar->nReferenceChunk, &iWorldYaw1, &iWorldPitch, &iWorldRoll);// Convert car yaw3/pitch/roll to world angles using current chunk - getworldangles(pCar->nYaw, pCar->nPitch, pCar->nRoll, pCar->nReferenceChunk, &iWorldYaw2, &iWorldPitch, &iWorldRoll);// Convert car yaw/pitch/roll to world angles + getworldangles(pCar->nActualYaw, pCar->nPitch, pCar->nRoll, + pCar->nReferenceChunk, &iWorldYaw1, &iWorldPitch, + &iWorldRoll); // Convert car yaw3/pitch/roll to world angles + // using current chunk + getworldangles(pCar->nYaw, pCar->nPitch, pCar->nRoll, pCar->nReferenceChunk, + &iWorldYaw2, &iWorldPitch, + &iWorldRoll); // Convert car yaw/pitch/roll to world angles pCar->nYaw = iWorldYaw2; pCar->nActualYaw = iWorldYaw2; pCar->nPitch = iWorldPitch; pData = &localdata[iChunkBackup]; pCar->nRoll = iWorldRoll; - fWorldX = pData->pointAy[0].fY * pCar->pos.fY + pData->pointAy[0].fX * pCar->pos.fX + pData->pointAy[0].fZ * pCar->pos.fZ - pData->pointAy[3].fX;// Transform car position from chunk-relative to world coordinates - fWorldY = pData->pointAy[1].fY * pCar->pos.fY + pData->pointAy[1].fX * pCar->pos.fX + pData->pointAy[1].fZ * pCar->pos.fZ - pData->pointAy[3].fY; - fWorldZ = pData->pointAy[2].fY * pCar->pos.fY + pData->pointAy[2].fX * pCar->pos.fX + pData->pointAy[2].fZ * pCar->pos.fZ - pData->pointAy[3].fZ; + fWorldX = pData->pointAy[0].fY * pCar->pos.fY + + pData->pointAy[0].fX * pCar->pos.fX + + pData->pointAy[0].fZ * pCar->pos.fZ - + pData->pointAy[3].fX; // Transform car position from chunk-relative + // to world coordinates + fWorldY = pData->pointAy[1].fY * pCar->pos.fY + + pData->pointAy[1].fX * pCar->pos.fX + + pData->pointAy[1].fZ * pCar->pos.fZ - pData->pointAy[3].fY; + fWorldZ = pData->pointAy[2].fY * pCar->pos.fY + + pData->pointAy[2].fX * pCar->pos.fX + + pData->pointAy[2].fZ * pCar->pos.fZ - pData->pointAy[3].fZ; dFinalSpeed = pCar->fFinalSpeed; pCar->pos.fX = fWorldX; pCar->pos.fY = fWorldY; pCar->pos.fZ = fWorldZ; - pCar->direction.fX = (float)(dFinalSpeed * tcos[iWorldYaw1] * tcos[iWorldPitch]);// Calculate 3D velocity vector from speed and world angles + pCar->direction.fX = + (float)(dFinalSpeed * tcos[iWorldYaw1] * + tcos[iWorldPitch]); // Calculate 3D velocity vector from speed and + // world angles pCar->direction.fY = pCar->fFinalSpeed * tsin[iWorldYaw1] * tcos[iWorldPitch]; pCar->direction.fZ = pCar->fFinalSpeed * tsin[iWorldPitch]; dHorizontalSpeed = pCar->fFinalSpeed * tcos[iWorldPitch]; - pCar->fSpeedOverflow = 0.0; // Reset speed overflow and prepare for airborne physics + pCar->fSpeedOverflow = + 0.0; // Reset speed overflow and prepare for airborne physics nTempChunk = pCar->nCurrChunk; - pCar->nCurrChunk = -1; // Set car as airborne (-1) and backup original chunk position + pCar->nCurrChunk = + -1; // Set car as airborne (-1) and backup original chunk position pCar->nReferenceChunk = nTempChunk; pCar->fHorizontalSpeed = (float)dHorizontalSpeed; } //------------------------------------------------------------------------------------------------- -//00034EA0 -void ordercars() -{ - int iTotalCars; // edi +// 00034EA0 +void ordercars() { + int iTotalCars; // edi unsigned int uiSortIndex; // edx - int iSortLimit; // esi - tCar *pCurrentCar; // ebx - tCar *pNextCar; // eax - int8 byLapNumber; // cl - int8 byCurrentProgress; // ch - int iTempCarIndex; // eax - int16 nCurrChunk; // cx - int iSwapCarIndex; // ebx - int iCarIndex; // eax - int iSortCounter; // [esp+0h] [ebp-18h] - int byPosition; // [esp+0h] [ebp-18h] + int iSortLimit; // esi + tCar *pCurrentCar; // ebx + tCar *pNextCar; // eax + int8 byLapNumber; // cl + int8 byCurrentProgress; // ch + int iTempCarIndex; // eax + int16 nCurrChunk; // cx + int iSwapCarIndex; // ebx + int iCarIndex; // eax + int iSortCounter; // [esp+0h] [ebp-18h] + int byPosition; // [esp+0h] [ebp-18h] - iTotalCars = numcars; // Bubble sort implementation to order cars by race position + iTotalCars = + numcars; // Bubble sort implementation to order cars by race position uiSortIndex = 0; - iSortLimit = 4 * (numcars - 1); // Set up loop limit for bubble sort (numcars-1) iterations + iSortLimit = + 4 * + (numcars - 1); // Set up loop limit for bubble sort (numcars-1) iterations iSortCounter = 0; if (iSortLimit > 0) { do { - pCurrentCar = &Car[carorder[uiSortIndex / 4]];// Get current car from sorted order array - if (!finished_car[pCurrentCar->iDriverIdx])// Skip comparison if current car has finished the race + pCurrentCar = &Car[carorder[uiSortIndex / 4]]; // Get current car from + // sorted order array + if (!finished_car[pCurrentCar->iDriverIdx]) // Skip comparison if current + // car has finished the race { - pNextCar = &Car[carorder[uiSortIndex / 4 + 1]];// Get next car in order for comparison - if (pCurrentCar->nCurrChunk != -1 && pNextCar->nCurrChunk != -1 && !finished_car[pNextCar->iDriverIdx])// Only compare active cars that are on track and not finished + pNextCar = &Car[carorder[uiSortIndex / 4 + 1]]; // Get next car in order + // for comparison + if (pCurrentCar->nCurrChunk != -1 && pNextCar->nCurrChunk != -1 && + !finished_car[pNextCar->iDriverIdx]) // Only compare active cars + // that are on track and not + // finished { byLapNumber = pNextCar->byLapNumber; byCurrentProgress = pCurrentCar->byLapNumber; - if (byLapNumber <= byCurrentProgress)// Compare race progress (byUnk24 - likely lap/sector progress) - { // If same progress, compare by track position (chunk and X coordinate) + if (byLapNumber <= + byCurrentProgress) // Compare race progress (byUnk24 - likely + // lap/sector progress) + { // If same progress, compare by track position (chunk and X + // coordinate) if (byLapNumber == byCurrentProgress) { nCurrChunk = pNextCar->nCurrChunk; - if (nCurrChunk > pCurrentCar->nCurrChunk || nCurrChunk == pCurrentCar->nCurrChunk && pNextCar->pos.fX > (double)pCurrentCar->pos.fX) { - iSwapCarIndex = carorder[uiSortIndex / 4];// Swap car positions: next car is ahead by position + if (nCurrChunk > pCurrentCar->nCurrChunk || + nCurrChunk == pCurrentCar->nCurrChunk && + pNextCar->pos.fX > (double)pCurrentCar->pos.fX) { + iSwapCarIndex = + carorder[uiSortIndex / 4]; // Swap car positions: next car + // is ahead by position carorder[uiSortIndex / 4] = carorder[uiSortIndex / 4 + 1]; carorder[uiSortIndex / 4 + 1] = iSwapCarIndex; } } } else { - iTempCarIndex = carorder[uiSortIndex / 4];// Swap car positions: next car is ahead in progress + iTempCarIndex = + carorder[uiSortIndex / 4]; // Swap car positions: next car is + // ahead in progress carorder[uiSortIndex / 4] = carorder[uiSortIndex / 4 + 1]; carorder[uiSortIndex / 4 + 1] = iTempCarIndex; } @@ -6394,7 +7594,8 @@ void ordercars() ++iSortCounter; } while ((int)uiSortIndex < iSortLimit); } - byPosition = 0; // Assign race positions based on sorted order (0=1st, 1=2nd, etc.) + byPosition = + 0; // Assign race positions based on sorted order (0=1st, 1=2nd, etc.) if (iTotalCars > 0) { iCarIndex = 0; do @@ -6405,44 +7606,51 @@ void ordercars() } //------------------------------------------------------------------------------------------------- -//00034FC0 -void changeline(tCar *pCar) -{ - int iCurrChunk; // eax - tData *pData; // ecx - int iRandValue; // eax - int iRandForPos; // eax - int iTargetLine; // ebp - int iChangeSuccess; // edx +// 00034FC0 +void changeline(tCar *pCar) { + int iCurrChunk; // eax + tData *pData; // ecx + int iRandValue; // eax + int iRandForPos; // eax + int iTargetLine; // ebp + int iChangeSuccess; // edx int iPrevTargetLine; // eax - int iRandNewLine; // eax + int iRandNewLine; // eax iCurrChunk = pCar->nCurrChunk; pData = &localdata[iCurrChunk]; - if (pCar->iAITargetLine == -1) // Check if car needs to select a new AI driving line - { // Check if center line marker is disabled (bit 24) - if ((TrakColour[iCurrChunk][1] & SURFACE_FLAG_PIT_ZONE) == 0) { // Cars in 6th place or lower have reduced aggression + if (pCar->iAITargetLine == + -1) // Check if car needs to select a new AI driving line + { // Check if center line marker is disabled (bit 24) + if ((TrakColour[iCurrChunk][1] & SURFACE_FLAG_PIT_ZONE) == + 0) { // Cars in 6th place or lower have reduced aggression if (pCar->byRacePosition >= 6u) { iRandForPos = ROLLERrandRaw(); if (GetHighOrderRand(720, iRandForPos) != 100) - goto LABEL_13; // 1 in 720 chance for line change when in poor position + goto LABEL_13; // 1 in 720 chance for line change when in poor + // position goto LABEL_7; } LABEL_12: - pCar->iAITargetLine = 3; // Set target line to 3 (conservative choice for front runners) + pCar->iAITargetLine = + 3; // Set target line to 3 (conservative choice for front runners) goto LABEL_13; } - if (pCar->iAITargetCar != -1 && pCar->fHealth < 60.0)// If targeting another car and low health, stay defensive + if (pCar->iAITargetCar != -1 && + pCar->fHealth < + 60.0) // If targeting another car and low health, stay defensive { pCar->iAITargetLine = 0; goto LABEL_13; } - if (!pCar->iAICurrentLine) // Check if car is not currently on an AI line + if (!pCar->iAICurrentLine) // Check if car is not currently on an AI line { if (pCar->byRacePosition >= 6u) { LABEL_7: - iRandValue = ROLLERrandRaw(); // Select random AI line (0-3 modulo operation) - pCar->iAITargetLine = GetHighOrderRand(4, iRandValue);// (iRandValue) >> 13; + iRandValue = + ROLLERrandRaw(); // Select random AI line (0-3 modulo operation) + pCar->iAITargetLine = + GetHighOrderRand(4, iRandValue); // (iRandValue) >> 13; goto LABEL_13; } goto LABEL_12; @@ -6451,59 +7659,79 @@ void changeline(tCar *pCar) LABEL_13: iTargetLine = pCar->iAITargetLine; iChangeSuccess = 0; - if (iTargetLine != -1 && linevalid(pCar->nCurrChunk, pCar->pos.fY, *(&pData->fAILine1 + iTargetLine)))// Check if target line is valid at current position + if (iTargetLine != -1 && + linevalid( + pCar->nCurrChunk, pCar->pos.fY, + *(&pData->fAILine1 + + iTargetLine))) // Check if target line is valid at current position { iPrevTargetLine = pCar->iAITargetLine; - pCar->iAITargetLine = -1; // Successfully switch to target line, clear target + pCar->iAITargetLine = + -1; // Successfully switch to target line, clear target iChangeSuccess = -1; pCar->iAICurrentLine = iPrevTargetLine; } - if (!iChangeSuccess && !linevalid(pCar->nCurrChunk, pCar->pos.fY, *(&pData->fAILine1 + pCar->iAICurrentLine)))// If current line invalid and no change made, pick new random line + if (!iChangeSuccess && + !linevalid(pCar->nCurrChunk, pCar->pos.fY, + *(&pData->fAILine1 + + pCar->iAICurrentLine))) // If current line invalid and no + // change made, pick new random line { iRandNewLine = ROLLERrandRaw(); - pCar->iAITargetLine = GetHighOrderRand(4, iRandNewLine);// (iRandNewLine) >> 13; + pCar->iAITargetLine = + GetHighOrderRand(4, iRandNewLine); // (iRandNewLine) >> 13; } } //------------------------------------------------------------------------------------------------- -//00035130 -void driverange(tCar *pCar, float *pfLeftLimit, float *pfRightLimit) -{ - int iCurrChunk; // eax - tTrackInfo *pTrackInfo; // esi - int iLeftSurfaceType; // edx - tData *pTrackData; // ebx - int iRightSurfaceType; // eax - unsigned int iLaneType; // eax - double dTrackHalfWidth; // st7 - double dLeftBoundary; // st7 - unsigned int uiLeftLaneMarker; // [esp+0h] [ebp-28h] - unsigned int uiRightLaneMarker; // [esp+4h] [ebp-24h] +// 00035130 +void driverange(tCar *pCar, float *pfLeftLimit, float *pfRightLimit) { + int iCurrChunk; // eax + tTrackInfo *pTrackInfo; // esi + int iLeftSurfaceType; // edx + tData *pTrackData; // ebx + int iRightSurfaceType; // eax + unsigned int iLaneType; // eax + double dTrackHalfWidth; // st7 + double dLeftBoundary; // st7 + unsigned int uiLeftLaneMarker; // [esp+0h] [ebp-28h] + unsigned int uiRightLaneMarker; // [esp+4h] [ebp-24h] unsigned int uiCenterLaneMarker; // [esp+8h] [ebp-20h] - int iRightSurfaceFlag; // [esp+Ch] [ebp-1Ch] - int iLeftSurfaceFlag; // [esp+10h] [ebp-18h] + int iRightSurfaceFlag; // [esp+Ch] [ebp-1Ch] + int iLeftSurfaceFlag; // [esp+10h] [ebp-18h] iCurrChunk = pCar->nCurrChunk; pTrackInfo = &TrackInfo[iCurrChunk]; iLeftSurfaceType = pTrackInfo->iLeftSurfaceType; pTrackData = &localdata[iCurrChunk]; - if (iLeftSurfaceType == 5 || iLeftSurfaceType == 6 || iLeftSurfaceType == 9)// Check if left surface is wall/barrier (types 5,6,9) + if (iLeftSurfaceType == 5 || iLeftSurfaceType == 6 || + iLeftSurfaceType == + 9) // Check if left surface is wall/barrier (types 5,6,9) iLeftSurfaceFlag = -1; else iLeftSurfaceFlag = 0; iRightSurfaceType = pTrackInfo->iRightSurfaceType; - if (iRightSurfaceType == 5 || iRightSurfaceType == 6 || iRightSurfaceType == 9)// Check if right surface is wall/barrier (types 5,6,9) + if (iRightSurfaceType == 5 || iRightSurfaceType == 6 || + iRightSurfaceType == + 9) // Check if right surface is wall/barrier (types 5,6,9) iRightSurfaceFlag = -1; else iRightSurfaceFlag = 0; - uiLeftLaneMarker = abs(TrakColour[pCar->nCurrChunk][0]) & SURFACE_FLAG_SKIP_RENDER; - uiCenterLaneMarker = abs(TrakColour[pCar->nCurrChunk][1]) & SURFACE_FLAG_SKIP_RENDER; - uiRightLaneMarker = abs(TrakColour[pCar->nCurrChunk][2]) & SURFACE_FLAG_SKIP_RENDER; + uiLeftLaneMarker = + abs(TrakColour[pCar->nCurrChunk][0]) & SURFACE_FLAG_SKIP_RENDER; + uiCenterLaneMarker = + abs(TrakColour[pCar->nCurrChunk][1]) & SURFACE_FLAG_SKIP_RENDER; + uiRightLaneMarker = + abs(TrakColour[pCar->nCurrChunk][2]) & SURFACE_FLAG_SKIP_RENDER; iLaneType = pCar->iLaneType; - if (!iLaneType) // Lane type 0: Full track width driving (normal racing) + if (!iLaneType) // Lane type 0: Full track width driving (normal racing) { - *pfLeftLimit = pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth - pCar->fCarHalfWidth;// Set left boundary: track edge + left shoulder - car width - if (iLeftSurfaceFlag || uiCenterLaneMarker)// If left wall/barrier or center lane marker, limit right boundary + *pfLeftLimit = pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth - + pCar->fCarHalfWidth; // Set left boundary: track edge + left + // shoulder - car width + if (iLeftSurfaceFlag || + uiCenterLaneMarker) // If left wall/barrier or center lane marker, limit + // right boundary { *pfRightLimit = pTrackData->fTrackHalfWidth + pCar->fCarHalfWidth; return; @@ -6512,27 +7740,35 @@ void driverange(tCar *pCar, float *pfLeftLimit, float *pfRightLimit) *pfRightLimit = pCar->fCarHalfWidth - pTrackData->fTrackHalfWidth; return; } - goto LABEL_21; // If right wall/barrier or right lane marker, limit left boundary + goto LABEL_21; // If right wall/barrier or right lane marker, limit left + // boundary } - if (iLaneType <= 1) // Lane type 1: Left lane driving only - { // Left lane: adjust left boundary based on wall/lane marker + if (iLaneType <= 1) // Lane type 1: Left lane driving only + { // Left lane: adjust left boundary based on wall/lane marker if (iLeftSurfaceFlag || uiLeftLaneMarker) dTrackHalfWidth = pTrackData->fTrackHalfWidth; else - dTrackHalfWidth = pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth; + dTrackHalfWidth = + pTrackData->fTrackHalfWidth + pTrackInfo->fLShoulderWidth; *pfLeftLimit = (float)(dTrackHalfWidth - pCar->fCarHalfWidth); if (iRightSurfaceFlag || uiRightLaneMarker) { *pfRightLimit = pCar->fCarHalfWidth - pTrackData->fTrackHalfWidth; return; } LABEL_21: - *pfRightLimit = -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth + pCar->fCarHalfWidth;// Default right boundary: track edge + right shoulder - car width + *pfRightLimit = -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth + + pCar->fCarHalfWidth; // Default right boundary: track edge + + // right shoulder - car width return; } - if (iLaneType == 2) // Lane type 2: Right lane driving only + if (iLaneType == 2) // Lane type 2: Right lane driving only { - *pfRightLimit = -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth + pCar->fCarHalfWidth;// Right lane: set right boundary to track edge + shoulder - if (iRightSurfaceFlag || uiCenterLaneMarker)// If right wall/barrier or center marker, use track center as left boundary + *pfRightLimit = -pTrackData->fTrackHalfWidth - pTrackInfo->fRShoulderWidth + + pCar->fCarHalfWidth; // Right lane: set right boundary to + // track edge + shoulder + if (iRightSurfaceFlag || + uiCenterLaneMarker) // If right wall/barrier or center marker, use track + // center as left boundary { dLeftBoundary = -pTrackData->fTrackHalfWidth; } else { @@ -6547,13 +7783,13 @@ void driverange(tCar *pCar, float *pfLeftLimit, float *pfRightLimit) } //------------------------------------------------------------------------------------------------- -//00035330 -void updatesmokeandflames(tCar *pCar) -{ +// 00035330 +void updatesmokeandflames(tCar *pCar) { int iCinematicMode; // edx - int iRandSeed; // esi + int iRandSeed; // esi - if (player_type != 2 && ViewType[0] == pCar->iDriverIdx && (!SelectedView[0] || SelectedView[0] == 2 || SelectedView[0] == 7)) + if (player_type != 2 && ViewType[0] == pCar->iDriverIdx && + (!SelectedView[0] || SelectedView[0] == 2 || SelectedView[0] == 7)) iCinematicMode = -1; else iCinematicMode = 0; @@ -6569,209 +7805,269 @@ void updatesmokeandflames(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//000353F0 -void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) -{ - int iCarDesignIdx; // edx - int iSprayIdx; // ebp - uint8 byType; // al - int iRandomValue1; // eax - char byLifeTime; // ah - int iRandomValue2; // eax - int iRandomValue3; // eax - int iRandomValue4; // eax - int iRandomVelY1; // eax - int iRandomSize1; // eax - int iRandomSize2; // eax - int iRandomVelY2; // eax - int iRandomSize3; // eax - int iRandomVel1; // eax - int iRandomVel2; // eax - int iRandomLifetime1; // eax - int iRandomColor1; // eax - int iRandomColor2; // eax - int iColorValue; // ebx - int iTimer; // ebx - int iRandomSize4; // eax - int iRandomSize5; // eax - int iRandomVelY3; // eax - int iRandomVelX1; // edx - int iRandomVelY4; // eax - int iRandomVelY5; // eax - int iRandomSize6; // eax - int iRandomVelX2; // eax - int iRandomVelY6; // eax - int iRandomUnk5_1; // eax - int iRandomVelY7; // eax - int iRandomUnk5_2; // eax - int iRandomVelX3; // eax - int iRandomVelY8; // eax - int iRandomUnk5_3; // eax - int iCalculatedUnk5; // eax - int iLifetimeDecrement; // eax - unsigned int uiColor; // eax - int iColorCycle; // eax - int iColor; // edx - int iRandomSizeGrow1; // eax - int iSizeGrowCalc1; // eax - int iRandomSizeShrink1; // eax - int iSizeShrinkCalc1; // eax - int v50; // eax - int iRandomLifetime2; // eax - int iRandomPlacement1; // eax - int iPlacementIdx; // ebx - int iRandomPosX1; // eax - int iRandomPosY1; // eax - int iRandomPosY2; // eax - int iRandomPlacement2; // eax - tVec3 *pCoordinates1; // eax - int iPlacementIdx2; // ebx - int iRandomPlacement3; // eax - int iRandomPosX2; // eax - int iRandomPosY3; // eax - int iRandomPlacement4; // eax - int iRandomPlacement5; // eax - tVec3 *pCoordinates2; // eax - int iRandomVelY9; // eax - int iVelYCalc1; // eax - int iRandomVelX4; // eax - double dLifetimeCalc1; // st7 - int iRandomVelX5; // eax - int iRandomVelY10; // eax - int iVelYCalc2; // eax - int iVelYBase; // edx - int iRandomVelY11; // eax - int iRandomUnk5_4; // eax - int iRandomSize7; // eax - double dLifetimeCalc2; // st7 - double dLifetimeCalc3; // st7 +// 000353F0 +void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) { + int iCarDesignIdx; // edx + int iSprayIdx; // ebp + uint8 byType; // al + int iRandomValue1; // eax + char byLifeTime; // ah + int iRandomValue2; // eax + int iRandomValue3; // eax + int iRandomValue4; // eax + int iRandomVelY1; // eax + int iRandomSize1; // eax + int iRandomSize2; // eax + int iRandomVelY2; // eax + int iRandomSize3; // eax + int iRandomVel1; // eax + int iRandomVel2; // eax + int iRandomLifetime1; // eax + int iRandomColor1; // eax + int iRandomColor2; // eax + int iColorValue; // ebx + int iTimer; // ebx + int iRandomSize4; // eax + int iRandomSize5; // eax + int iRandomVelY3; // eax + int iRandomVelX1; // edx + int iRandomVelY4; // eax + int iRandomVelY5; // eax + int iRandomSize6; // eax + int iRandomVelX2; // eax + int iRandomVelY6; // eax + int iRandomUnk5_1; // eax + int iRandomVelY7; // eax + int iRandomUnk5_2; // eax + int iRandomVelX3; // eax + int iRandomVelY8; // eax + int iRandomUnk5_3; // eax + int iCalculatedUnk5; // eax + int iLifetimeDecrement; // eax + unsigned int uiColor; // eax + int iColorCycle; // eax + int iColor; // edx + int iRandomSizeGrow1; // eax + int iSizeGrowCalc1; // eax + int iRandomSizeShrink1; // eax + int iSizeShrinkCalc1; // eax + int v50; // eax + int iRandomLifetime2; // eax + int iRandomPlacement1; // eax + int iPlacementIdx; // ebx + int iRandomPosX1; // eax + int iRandomPosY1; // eax + int iRandomPosY2; // eax + int iRandomPlacement2; // eax + tVec3 *pCoordinates1; // eax + int iPlacementIdx2; // ebx + int iRandomPlacement3; // eax + int iRandomPosX2; // eax + int iRandomPosY3; // eax + int iRandomPlacement4; // eax + int iRandomPlacement5; // eax + tVec3 *pCoordinates2; // eax + int iRandomVelY9; // eax + int iVelYCalc1; // eax + int iRandomVelX4; // eax + double dLifetimeCalc1; // st7 + int iRandomVelX5; // eax + int iRandomVelY10; // eax + int iVelYCalc2; // eax + int iVelYBase; // edx + int iRandomVelY11; // eax + int iRandomUnk5_4; // eax + int iRandomSize7; // eax + double dLifetimeCalc2; // st7 + double dLifetimeCalc3; // st7 float fHealthMultiplier1; // [esp+Ch] [ebp-30h] float fHealthMultiplier2; // [esp+10h] [ebp-2Ch] float fHealthMultiplier3; // [esp+14h] [ebp-28h] float fHealthMultiplier4; // [esp+18h] [ebp-24h] - int iStoredCarDesignIdx; // [esp+1Ch] [ebp-20h] - int *pPlaces; // [esp+20h] [ebp-1Ch] - float fHealthFactor; // [esp+24h] [ebp-18h] - int iTempVelocity; // [esp+28h] [ebp-14h] - int iTempPosX; // [esp+28h] [ebp-14h] - int iTempPosX2; // [esp+28h] [ebp-14h] - int iTempRandomValue; // [esp+28h] [ebp-14h] - int iTempVelX; // [esp+28h] [ebp-14h] - int iTempVelY; // [esp+28h] [ebp-14h] + int iStoredCarDesignIdx; // [esp+1Ch] [ebp-20h] + int *pPlaces; // [esp+20h] [ebp-1Ch] + float fHealthFactor; // [esp+24h] [ebp-18h] + int iTempVelocity; // [esp+28h] [ebp-14h] + int iTempPosX; // [esp+28h] [ebp-14h] + int iTempPosX2; // [esp+28h] [ebp-14h] + int iTempRandomValue; // [esp+28h] [ebp-14h] + int iTempVelX; // [esp+28h] [ebp-14h] + int iTempVelY; // [esp+28h] [ebp-14h] - fHealthFactor = (pCar->fHealth + 34.0f) * 0.01f;// Calculate health factor (0.0-1.0) based on car damage + fHealthFactor = + (pCar->fHealth + 34.0f) * + 0.01f; // Calculate health factor (0.0-1.0) based on car damage iCarDesignIdx = pCar->byCarDesignIdx; - pPlaces = CarDesigns[iCarDesignIdx].pPlaces; // Get car design data for spray particle placement points + pPlaces = + CarDesigns[iCarDesignIdx] + .pPlaces; // Get car design data for spray particle placement points if (fHealthFactor > 1.0) fHealthFactor = 1.0; iSprayIdx = 0; iStoredCarDesignIdx = iCarDesignIdx; do { byType = pCarSpray->iType; - if (byType) { // Spray type 1: Active damage/smoke particles + if (byType) { // Spray type 1: Active damage/smoke particles if (byType <= 1u) { - iRandomColor1 = ROLLERrandRaw(); // Generate random color values for active smoke particles - iRandomColor2 = GetHighOrderRand(4, iRandomColor1); // same as (4 * iRandomColor1) / 32768 - //iRandomColor2 = (4 * iRandomColor1 - (__CFSHL__((4 * iRandomColor1) >> 31, 15) + ((4 * iRandomColor1) >> 31 << 15))) >> 15; + iRandomColor1 = ROLLERrandRaw(); // Generate random color values for + // active smoke particles + iRandomColor2 = GetHighOrderRand( + 4, iRandomColor1); // same as (4 * iRandomColor1) / 32768 + // iRandomColor2 = (4 * iRandomColor1 - (__CFSHL__((4 * iRandomColor1) + // >> 31, 15) + ((4 * iRandomColor1) >> 31 << 15))) >> 15; iColorValue = iRandomColor2 + 4; uint8 byColorComponent = ((iRandomColor2 + 4) >> 8) | 5; iColorValue = (iColorValue & 0xFFFF00FF) | (byColorComponent << 8); - //BYTE1(iColorValue) = ((uint16)(iRandomColor2 + 4) >> 8) | 5; + // BYTE1(iColorValue) = ((uint16)(iRandomColor2 + 4) >> 8) | 5; pCarSpray->iColor = iColorValue; iTimer = pCarSpray->iTimer; - if (iCinematicMode) // Different particle behavior for menu/replay mode vs gameplay + if (iCinematicMode) // Different particle behavior for menu/replay mode + // vs gameplay { iRandomSize4 = ROLLERrandRaw(); iRandomSize5 = (GetHighOrderRand(60, iRandomSize4) + 20) * scr_size; - //iRandomSize5 = (((60 * iRandomSize4 - (__CFSHL__((60 * iRandomSize4) >> 31, 15) + ((60 * iRandomSize4) >> 31 << 15))) >> 15) + 20) * scr_size; + // iRandomSize5 = (((60 * iRandomSize4 - (__CFSHL__((60 * + // iRandomSize4) >> 31, 15) + ((60 * iRandomSize4) >> 31 << 15))) >> + // 15) + 20) * scr_size; pCarSpray->fSize = (float)(iRandomSize5 >> 6); - //pCarSpray->fSize = (float)((iRandomSize5 - (__CFSHL__(iRandomSize5 >> 31, 6) + (iRandomSize5 >> 31 << 6))) >> 6); + // pCarSpray->fSize = (float)((iRandomSize5 - (__CFSHL__(iRandomSize5 + // >> 31, 6) + (iRandomSize5 >> 31 << 6))) >> 6); iRandomVelY3 = ROLLERrandRaw(); if (iTimer == 1) iRandomVelX1 = (GetHighOrderRand(50, iRandomVelY3) + 40) * scr_size; - //iRandomVelX1 = (((50 * iRandomVelY3 - (__CFSHL__((50 * iRandomVelY3) >> 31, 15) + ((50 * iRandomVelY3) >> 31 << 15))) >> 15) + 40) * scr_size; + // iRandomVelX1 = (((50 * iRandomVelY3 - (__CFSHL__((50 * + // iRandomVelY3) >> 31, 15) + ((50 * iRandomVelY3) >> 31 << 15))) >> + // 15) + 40) * scr_size; else - iRandomVelX1 = scr_size * (-40 - GetHighOrderRand(50, iRandomVelY3)); - //iRandomVelX1 = scr_size * (-40 - ((50 * iRandomVelY3 - (__CFSHL__((50 * iRandomVelY3) >> 31, 15) + ((50 * iRandomVelY3) >> 31 << 15))) >> 15)); + iRandomVelX1 = + scr_size * (-40 - GetHighOrderRand(50, iRandomVelY3)); + // iRandomVelX1 = scr_size * (-40 - ((50 * iRandomVelY3 - + // (__CFSHL__((50 * iRandomVelY3) >> 31, 15) + ((50 * iRandomVelY3) >> + // 31 << 15))) >> 15)); pCarSpray->velocity.fX = (float)(iRandomVelX1 >> 6); - //pCarSpray->velocity.fX = (float)((iRandomVelX1 - (__CFSHL__(iRandomVelX1 >> 31, 6) + (iRandomVelX1 >> 31 << 6))) >> 6); + // pCarSpray->velocity.fX = (float)((iRandomVelX1 - + // (__CFSHL__(iRandomVelX1 >> 31, 6) + (iRandomVelX1 >> 31 << 6))) >> + // 6); iRandomVelY4 = ROLLERrandRaw(); iRandomVelY5 = (GetHighOrderRand(100, iRandomVelY4) + 40) * scr_size; - //iRandomVelY5 = (((100 * iRandomVelY4 - (__CFSHL__((100 * iRandomVelY4) >> 31, 15) + ((100 * iRandomVelY4) >> 31 << 15))) >> 15) + 40) * scr_size; + // iRandomVelY5 = (((100 * iRandomVelY4 - (__CFSHL__((100 * + // iRandomVelY4) >> 31, 15) + ((100 * iRandomVelY4) >> 31 << 15))) >> + // 15) + 40) * scr_size; pCarSpray->velocity.fY = (float)(iRandomVelY5 >> 6); - //pCarSpray->velocity.fY = (float)((iRandomVelY5 - (__CFSHL__(iRandomVelY5 >> 31, 6) + (iRandomVelY5 >> 31 << 6))) >> 6); + // pCarSpray->velocity.fY = (float)((iRandomVelY5 - + // (__CFSHL__(iRandomVelY5 >> 31, 6) + (iRandomVelY5 >> 31 << 6))) >> + // 6); ROLLERrandRaw(); } else { - iRandomSize6 = ROLLERrandRaw(); // Generate larger particle sizes and velocities for normal gameplay mode + iRandomSize6 = ROLLERrandRaw(); // Generate larger particle sizes and + // velocities for normal gameplay mode pCarSpray->fSize = (float)(GetHighOrderRand(100, iRandomSize6) + 100); - //pCarSpray->fSize = (float)(((100 * iRandomSize6 - (__CFSHL__((100 * iRandomSize6) >> 31, 15) + ((100 * iRandomSize6) >> 31 << 15))) >> 15) + 100); + // pCarSpray->fSize = (float)(((100 * iRandomSize6 - (__CFSHL__((100 * + // iRandomSize6) >> 31, 15) + ((100 * iRandomSize6) >> 31 << 15))) >> + // 15) + 100); if (iTimer) { iRandomVelX3 = ROLLERrandRaw(); if (iTimer == 1) { - pCarSpray->velocity.fX = (float)(-100 - GetHighOrderRand(300, iRandomVelX3)); - //pCarSpray->velocity.fX = (float)(-100 - ((300 * iRandomVelX3 - (__CFSHL__((300 * iRandomVelX3) >> 31, 15) + ((300 * iRandomVelX3) >> 31 << 15))) >> 15)); + pCarSpray->velocity.fX = + (float)(-100 - GetHighOrderRand(300, iRandomVelX3)); + // pCarSpray->velocity.fX = (float)(-100 - ((300 * iRandomVelX3 - + // (__CFSHL__((300 * iRandomVelX3) >> 31, 15) + ((300 * + // iRandomVelX3) >> 31 << 15))) >> 15)); iRandomVelY7 = ROLLERrandRaw(); - pCarSpray->velocity.fY = (float)(-100 - GetHighOrderRand(200, iRandomVelY7)); - //pCarSpray->velocity.fY = (float)(-100 - ((200 * iRandomVelY7 - (__CFSHL__((200 * iRandomVelY7) >> 31, 15) + ((200 * iRandomVelY7) >> 31 << 15))) >> 15)); + pCarSpray->velocity.fY = + (float)(-100 - GetHighOrderRand(200, iRandomVelY7)); + // pCarSpray->velocity.fY = (float)(-100 - ((200 * iRandomVelY7 - + // (__CFSHL__((200 * iRandomVelY7) >> 31, 15) + ((200 * + // iRandomVelY7) >> 31 << 15))) >> 15)); iRandomUnk5_2 = ROLLERrandRaw(); iCalculatedUnk5 = GetHighOrderRand(200, iRandomUnk5_2) + 200; - //iCalculatedUnk5 = ((200 * iRandomUnk5_2 - (__CFSHL__((200 * iRandomUnk5_2) >> 31, 15) + ((200 * iRandomUnk5_2) >> 31 << 15))) >> 15) + 200; + // iCalculatedUnk5 = ((200 * iRandomUnk5_2 - (__CFSHL__((200 * + // iRandomUnk5_2) >> 31, 15) + ((200 * iRandomUnk5_2) >> 31 << + // 15))) >> 15) + 200; } else { - pCarSpray->velocity.fX = (float)(-105 - GetHighOrderRand(150, iRandomVelX3)); - //pCarSpray->velocity.fX = (float)(-105 - ((150 * iRandomVelX3 - (__CFSHL__((150 * iRandomVelX3) >> 31, 15) + ((150 * iRandomVelX3) >> 31 << 15))) >> 15)); + pCarSpray->velocity.fX = + (float)(-105 - GetHighOrderRand(150, iRandomVelX3)); + // pCarSpray->velocity.fX = (float)(-105 - ((150 * iRandomVelX3 - + // (__CFSHL__((150 * iRandomVelX3) >> 31, 15) + ((150 * + // iRandomVelX3) >> 31 << 15))) >> 15)); iRandomVelY8 = ROLLERrandRaw(); - pCarSpray->velocity.fY = (float)GetHighOrderRand(400, iRandomVelY8); - //pCarSpray->velocity.fY = (float)(((400 * iRandomVelY8 - (__CFSHL__((400 * iRandomVelY8) >> 31, 15) + ((400 * iRandomVelY8) >> 31 << 15))) >> 15) - 200); + pCarSpray->velocity.fY = + (float)GetHighOrderRand(400, iRandomVelY8); + // pCarSpray->velocity.fY = (float)(((400 * iRandomVelY8 - + // (__CFSHL__((400 * iRandomVelY8) >> 31, 15) + ((400 * + // iRandomVelY8) >> 31 << 15))) >> 15) - 200); iRandomUnk5_3 = ROLLERrandRaw(); iCalculatedUnk5 = GetHighOrderRand(30, iRandomUnk5_3) - 20; - //iCalculatedUnk5 = ((30 * iRandomUnk5_3 - (__CFSHL__((30 * iRandomUnk5_3) >> 31, 15) + ((30 * iRandomUnk5_3) >> 31 << 15))) >> 15) - 20; + // iCalculatedUnk5 = ((30 * iRandomUnk5_3 - (__CFSHL__((30 * + // iRandomUnk5_3) >> 31, 15) + ((30 * iRandomUnk5_3) >> 31 << + // 15))) >> 15) - 20; } } else { iRandomVelX2 = ROLLERrandRaw(); - pCarSpray->velocity.fX = (float)(-100 - GetHighOrderRand(300, iRandomVelX2)); - //pCarSpray->velocity.fX = (float)(-100 - ((300 * iRandomVelX2 - (__CFSHL__((300 * iRandomVelX2) >> 31, 15) + ((300 * iRandomVelX2) >> 31 << 15))) >> 15)); + pCarSpray->velocity.fX = + (float)(-100 - GetHighOrderRand(300, iRandomVelX2)); + // pCarSpray->velocity.fX = (float)(-100 - ((300 * iRandomVelX2 - + // (__CFSHL__((300 * iRandomVelX2) >> 31, 15) + ((300 * + // iRandomVelX2) >> 31 << 15))) >> 15)); iRandomVelY6 = ROLLERrandRaw(); - pCarSpray->velocity.fY = (float)(GetHighOrderRand(200, iRandomVelY6) + 100); - //pCarSpray->velocity.fY = (float)(((200 * iRandomVelY6 - (__CFSHL__((200 * iRandomVelY6) >> 31, 15) + ((200 * iRandomVelY6) >> 31 << 15))) >> 15) + 100); + pCarSpray->velocity.fY = + (float)(GetHighOrderRand(200, iRandomVelY6) + 100); + // pCarSpray->velocity.fY = (float)(((200 * iRandomVelY6 - + // (__CFSHL__((200 * iRandomVelY6) >> 31, 15) + ((200 * + // iRandomVelY6) >> 31 << 15))) >> 15) + 100); iRandomUnk5_1 = ROLLERrandRaw(); iCalculatedUnk5 = GetHighOrderRand(200, iRandomUnk5_1) + 200; - //iCalculatedUnk5 = ((200 * iRandomUnk5_1 - (__CFSHL__((200 * iRandomUnk5_1) >> 31, 15) + ((200 * iRandomUnk5_1) >> 31 << 15))) >> 15) + 200; + // iCalculatedUnk5 = ((200 * iRandomUnk5_1 - (__CFSHL__((200 * + // iRandomUnk5_1) >> 31, 15) + ((200 * iRandomUnk5_1) >> 31 << 15))) + // >> 15) + 200; } pCarSpray->velocity.fZ = (float)iCalculatedUnk5; } iLifetimeDecrement = pCarSpray->iLifeTime - 1; pCarSpray->iLifeTime = iLifetimeDecrement; if (iLifetimeDecrement < 0) { - pCarSpray->iType = pCarSpray->iType & 0xFFFFFF00; // Clear lowest byte only - //LOBYTE(pCarSpray->iType) = 0; + pCarSpray->iType = + pCarSpray->iType & 0xFFFFFF00; // Clear lowest byte only + // LOBYTE(pCarSpray->iType) = 0; pCarSpray->iTimer = -1; } - } else if (byType == 2) // Spray type 2: Death/explosion particles + } else if (byType == 2) // Spray type 2: Death/explosion particles { - if (pCar->fHealth <= 0.0) { // Car is dead - generate explosion/death particles + if (pCar->fHealth <= + 0.0) { // Car is dead - generate explosion/death particles if (pCarSpray->iLifeTime <= 0) { if (pCar->nExplosionSoundTimer < 0) { if (replaytype != 2) - sfxpend(SOUND_SAMPLE_EXPLO, pCar->iDriverIdx, 0x8000);// SOUND_SAMPLE_EXPLO + sfxpend(SOUND_SAMPLE_EXPLO, pCar->iDriverIdx, + 0x8000); // SOUND_SAMPLE_EXPLO iRandomValue3 = ROLLERrandRaw(); - pCar->nExplosionSoundTimer = GetHighOrderRand(4, iRandomValue3) + 4; - //pCar->nExplosionSoundTimer = ((4 * iRandomValue3 - (__CFSHL__((4 * iRandomValue3) >> 31, 15) + ((4 * iRandomValue3) >> 31 << 15))) >> 15) + 4; + pCar->nExplosionSoundTimer = + GetHighOrderRand(4, iRandomValue3) + 4; + // pCar->nExplosionSoundTimer = ((4 * iRandomValue3 - + // (__CFSHL__((4 * iRandomValue3) >> 31, 15) + ((4 * + // iRandomValue3) >> 31 << 15))) >> 15) + 4; } pCarSpray->position.fX = 0.0; pCarSpray->position.fY = 0.0; pCarSpray->position.fZ = 0.0; iRandomValue4 = ROLLERrandRaw(); if ((iSprayIdx & 7) != 0) { - pCarSpray->velocity.fX = (float)(50 - GetHighOrderRand(100, iRandomValue4)); - //pCarSpray->velocity.fX = (float)(50 - ((100 * iRandomValue4 - (__CFSHL__((100 * iRandomValue4) >> 31, 15) + ((100 * iRandomValue4) >> 31 << 15))) >> 15)); + pCarSpray->velocity.fX = + (float)(50 - GetHighOrderRand(100, iRandomValue4)); + // pCarSpray->velocity.fX = (float)(50 - ((100 * iRandomValue4 - + // (__CFSHL__((100 * iRandomValue4) >> 31, 15) + ((100 * + // iRandomValue4) >> 31 << 15))) >> 15)); iRandomVelY2 = ROLLERrandRaw(); - pCarSpray->velocity.fY = (float)(30 - GetHighOrderRand(60, iRandomVelY2)); + pCarSpray->velocity.fY = + (float)(30 - GetHighOrderRand(60, iRandomVelY2)); iRandomSize3 = ROLLERrandRaw(); iRandomSize2 = GetHighOrderRand(64, iRandomSize3) + 128; } else { - pCarSpray->velocity.fX = (float)(20 - GetHighOrderRand(40, iRandomValue4)); + pCarSpray->velocity.fX = + (float)(20 - GetHighOrderRand(40, iRandomValue4)); iRandomVelY1 = ROLLERrandRaw(); - pCarSpray->velocity.fY = (float)(10 - GetHighOrderRand(20, iRandomVelY1)); + pCarSpray->velocity.fY = + (float)(10 - GetHighOrderRand(20, iRandomVelY1)); iRandomSize1 = ROLLERrandRaw(); iRandomSize2 = GetHighOrderRand(320, iRandomSize1) + 320; } @@ -6787,18 +8083,25 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) pCarSpray->iColor = 9485; iRandomLifetime1 = ROLLERrandRaw(); pCarSpray->iLifeTime = GetHighOrderRand(64, iRandomLifetime1) + 32; - //pCarSpray->iLifeTime = (((iRandomLifetime1 << 6)) >> 15) + 32; + // pCarSpray->iLifeTime = (((iRandomLifetime1 << 6)) >> 15) + 32; } else { - if (pCarSpray->position.fX * pCarSpray->position.fX + pCarSpray->position.fY + pCarSpray->position.fY < 1125000.0 - && pCarSpray->position.fZ < 450.0 - && pCarSpray->position.fZ > -100.0) { + if (pCarSpray->position.fX * pCarSpray->position.fX + + pCarSpray->position.fY + pCarSpray->position.fY < + 1125000.0 && + pCarSpray->position.fZ < 450.0 && + pCarSpray->position.fZ > -100.0) { iRandomValue1 = ROLLERrandRaw(); - pCarSpray->fSize = (float)(GetHighOrderRand(12, iRandomValue1) + 4) - + pCarSpray->fSize; - pCarSpray->position.fX = pCarSpray->velocity.fX + pCarSpray->position.fX; - pCarSpray->position.fY = pCarSpray->velocity.fY + pCarSpray->position.fY; - if (pCarSpray->position.fZ < 450.0 && pCarSpray->position.fZ > -100.0) - pCarSpray->position.fZ = pCarSpray->velocity.fZ + pCarSpray->position.fZ; + pCarSpray->fSize = + (float)(GetHighOrderRand(12, iRandomValue1) + 4) + + pCarSpray->fSize; + pCarSpray->position.fX = + pCarSpray->velocity.fX + pCarSpray->position.fX; + pCarSpray->position.fY = + pCarSpray->velocity.fY + pCarSpray->position.fY; + if (pCarSpray->position.fZ < 450.0 && + pCarSpray->position.fZ > -100.0) + pCarSpray->position.fZ = + pCarSpray->velocity.fZ + pCarSpray->position.fZ; } --pCarSpray->iLifeTime; byLifeTime = pCarSpray->iLifeTime; @@ -6812,24 +8115,28 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) } } else { pCarSpray->iLifeTime = -1; - pCarSpray->iType = pCarSpray->iType & 0xFFFFFF00; // Clear lowest byte only - //LOBYTE(pCarSpray->iType) = 0; + pCarSpray->iType = + pCarSpray->iType & 0xFFFFFF00; // Clear lowest byte only + // LOBYTE(pCarSpray->iType) = 0; pCarSpray->iColor = 0x2516; } } goto NEXT_PARTICLE; } - if (pCarSpray->iLifeTime <= 0) // Spray type 0: Initialize new particles based on car health + if (pCarSpray->iLifeTime <= + 0) // Spray type 0: Initialize new particles based on car health { if (pCar->fHealth > 0.0) { v50 = pCarSpray->iTimer; if (v50 <= 0) { if (fHealthFactor >= 1.0) { pCarSpray->iColor = 1302; - } else { // Generate damage particles based on health factor - more damage = more particles - if ((double)ROLLERrand() * fHealthFactor < 8192.0 && fHealthFactor < 0.66) { + } else { // Generate damage particles based on health factor - more + // damage = more particles + if ((double)ROLLERrand() * fHealthFactor < 8192.0 && + fHealthFactor < 0.66) { pCarSpray->iType = (pCarSpray->iType & 0xFFFFFF00) | 1; - //LOBYTE(pCarSpray->iType) = 1; + // LOBYTE(pCarSpray->iType) = 1; iRandomLifetime2 = ROLLERrandRaw(); pCarSpray->iLifeTime = GetHighOrderRand(16, iRandomLifetime2) + 8; if (pPlaces == (int *)-1) { @@ -6845,23 +8152,32 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) iPlacementIdx = 1; iRandomPosX1 = ROLLERrandRaw(); if (iPlacementIdx == 1) - iTempPosX = winw / 2 + GetHighOrderRand(scr_size, iRandomPosX1); + iTempPosX = + winw / 2 + GetHighOrderRand(scr_size, iRandomPosX1); else - iTempPosX = winw / 2 - GetHighOrderRand(scr_size, iRandomPosX1); + iTempPosX = + winw / 2 - GetHighOrderRand(scr_size, iRandomPosX1); pCarSpray->position.fX = (float)iTempPosX; - iRandomPosY1 = ROLLERrand(); //TODO look at this - pCarSpray->position.fY = (float)(((iRandomPosY1 * scr_size) >> 16) - + winh); + iRandomPosY1 = ROLLERrand(); // TODO look at this + pCarSpray->position.fY = + (float)(((iRandomPosY1 * scr_size) >> 16) + winh); } else { iRandomPosY2 = ROLLERrandRaw(); - pCarSpray->position.fY = (float)(GetHighOrderRand(32, iRandomPosY2) + winh); + pCarSpray->position.fY = + (float)(GetHighOrderRand(32, iRandomPosY2) + winh); iRandomPlacement2 = ROLLERrandRaw(); iPlacementIdx = GetHighOrderRand(4, iRandomPlacement2); if (iPlacementIdx == 4) iPlacementIdx = 3; - pCoordinates1 = &CarDesigns[iStoredCarDesignIdx].pCoords[pPlaces[iPlacementIdx]];// Select random attachment point from car design for particle placement + pCoordinates1 = + &CarDesigns[iStoredCarDesignIdx].pCoords + [pPlaces[iPlacementIdx]]; // Select random attachment + // point from car design + // for particle placement // CHEAT_MODE_TINY_CARS - if ((cheat_mode & CHEAT_MODE_TINY_CARS) == 0)// Handle CHEAT_MODE_TINY_CARS - scale particle positions accordingly + if ((cheat_mode & CHEAT_MODE_TINY_CARS) == + 0) // Handle CHEAT_MODE_TINY_CARS - scale particle + // positions accordingly { pCarSpray->position.fX = pCoordinates1->fX; pCarSpray->position.fY = pCoordinates1->fY; @@ -6877,9 +8193,9 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) } } if ((uint8)(pCarSpray->iType) != 1) { - //TODO look at this + // TODO look at this iPlacementIdx2 = 0; - //iPlacementIdx2 = (int)pPlaces; + // iPlacementIdx2 = (int)pPlaces; if (pPlaces == (int *)-1) { pCarSpray->position.fX = 0.0; pCarSpray->position.fY = 0.0; @@ -6891,14 +8207,17 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) iPlacementIdx2 = 1; iRandomPosX2 = ROLLERrandRaw(); if (iPlacementIdx2 == 1) - iTempPosX2 = winw / 2 + GetHighOrderRand(scr_size, iRandomPosX2); + iTempPosX2 = + winw / 2 + GetHighOrderRand(scr_size, iRandomPosX2); else - iTempPosX2 = winw / 2 - GetHighOrderRand(scr_size, iRandomPosX2); + iTempPosX2 = + winw / 2 - GetHighOrderRand(scr_size, iRandomPosX2); pCarSpray->position.fX = (float)iTempPosX2; - iRandomPosY3 = ROLLERrand(); //TODO: look at this - pCarSpray->position.fY = (float)(((iRandomPosY3 * scr_size) >> 16) - + winh); - } else { // Health-based placement logic: high health uses fewer placements + iRandomPosY3 = ROLLERrand(); // TODO: look at this + pCarSpray->position.fY = + (float)(((iRandomPosY3 * scr_size) >> 16) + winh); + } else { // Health-based placement logic: high health uses fewer + // placements if (fHealthFactor >= 0.75) { iRandomPlacement5 = ROLLERrandRaw(); iPlacementIdx2 = GetHighOrderRand(2, iRandomPlacement5); @@ -6910,7 +8229,8 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) if (iPlacementIdx2 == 4) iPlacementIdx2 = 3; } - pCoordinates2 = &CarDesigns[iStoredCarDesignIdx].pCoords[pPlaces[iPlacementIdx2]]; + pCoordinates2 = &CarDesigns[iStoredCarDesignIdx] + .pCoords[pPlaces[iPlacementIdx2]]; // CHEAT_MODE_TINY_CARS if ((cheat_mode & 0x8000) == 0) { pCarSpray->position.fX = pCoordinates2->fX; @@ -6926,16 +8246,20 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) } iTempRandomValue = ROLLERrandRaw(); pCarSpray->iColor = 1302; - pCarSpray->iLifeTime = GetHighOrderRand(24, iTempRandomValue) + 24; + pCarSpray->iLifeTime = + GetHighOrderRand(24, iTempRandomValue) + 24; if (ROLLERrand() < 0x4000) pCarSpray->iColor |= 0x1000u; - //BYTE1(pCarSpray->iColor) |= 0x10u; + // BYTE1(pCarSpray->iColor) |= 0x10u; if (ROLLERrand() < 0x4000) pCarSpray->iColor |= 40000u; - //BYTE2(pCarSpray->iColor) |= 4u; + // BYTE2(pCarSpray->iColor) |= 4u; if (iCinematicMode) { - iRandomVelY9 = ROLLERrandRaw(); // Calculate menu/replay mode velocities with screen scaling - iVelYCalc1 = (-2 - GetHighOrderRand(6, iRandomVelY9)) * scr_size; + iRandomVelY9 = + ROLLERrandRaw(); // Calculate menu/replay mode velocities + // with screen scaling + iVelYCalc1 = + (-2 - GetHighOrderRand(6, iRandomVelY9)) * scr_size; pCarSpray->velocity.fY = (float)((iVelYCalc1) >> 6); iRandomVelX4 = ROLLERrandRaw(); if (iPlacementIdx2 == 1) @@ -6943,15 +8267,25 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) else iTempVelX = -3 - GetHighOrderRand(3, iRandomVelX4); pCarSpray->velocity.fX = (float)iTempVelX; - pCarSpray->fSize = (float)(((double)ROLLERrand() * ((1.0 - fHealthFactor) * 32.0 + 32.0) * 0.000030517578125 + 32.0) * (double)scr_size * 0.015625); + pCarSpray->fSize = + (float)(((double)ROLLERrand() * + ((1.0 - fHealthFactor) * 32.0 + 32.0) * + 0.000030517578125 + + 32.0) * + (double)scr_size * 0.015625); fHealthMultiplier4 = fHealthFactor * 512.0f; - dLifetimeCalc1 = (double)ROLLERrand() * fHealthMultiplier4 * 0.000030517578 + 64.0; + dLifetimeCalc1 = + (double)ROLLERrand() * fHealthMultiplier4 * 0.000030517578 + + 64.0; //_CHP(); pCarSpray->iTimer = (int)dLifetimeCalc1; ROLLERrandRaw(); } else { - iRandomVelX5 = ROLLERrandRaw(); // Calculate gameplay mode velocities based on placement position - pCarSpray->velocity.fX = (float)(-15 - GetHighOrderRand(20, iRandomVelX5)); + iRandomVelX5 = + ROLLERrandRaw(); // Calculate gameplay mode velocities based + // on placement position + pCarSpray->velocity.fX = + (float)(-15 - GetHighOrderRand(20, iRandomVelX5)); if (iPlacementIdx2) { iRandomVelY10 = ROLLERrandRaw(); if (iPlacementIdx2 == 1) { @@ -6968,22 +8302,30 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) } pCarSpray->velocity.fY = (float)iTempVelY; iRandomUnk5_4 = ROLLERrandRaw(); - pCarSpray->velocity.fZ = (float)GetHighOrderRand(10, iRandomUnk5_4); + pCarSpray->velocity.fZ = + (float)GetHighOrderRand(10, iRandomUnk5_4); iRandomSize7 = ROLLERrandRaw(); - pCarSpray->fSize = (float)(GetHighOrderRand(10, iRandomSize7) + 10); + pCarSpray->fSize = + (float)(GetHighOrderRand(10, iRandomSize7) + 10); if (fHealthFactor <= 0.6) { if (pCar->fHealth <= 0.0) { fHealthMultiplier2 = fHealthFactor * 64.0f; - dLifetimeCalc3 = (double)ROLLERrand() * fHealthMultiplier2 * 0.000030517578 + 18.0; + dLifetimeCalc3 = (double)ROLLERrand() * fHealthMultiplier2 * + 0.000030517578 + + 18.0; } else { fHealthMultiplier3 = fHealthFactor * 256.0f; - dLifetimeCalc3 = (double)ROLLERrand() * fHealthMultiplier3 * 0.000030517578 + 24.0; + dLifetimeCalc3 = (double)ROLLERrand() * fHealthMultiplier3 * + 0.000030517578 + + 24.0; } //_CHP(); pCarSpray->iTimer = (int)dLifetimeCalc3; } else { fHealthMultiplier1 = fHealthFactor * 1024.0f; - dLifetimeCalc2 = (double)ROLLERrand() * fHealthMultiplier1 * 0.000030517578 + 36.0; + dLifetimeCalc2 = (double)ROLLERrand() * fHealthMultiplier1 * + 0.000030517578 + + 36.0; //_CHP(); pCarSpray->iTimer = (int)dLifetimeCalc2; } @@ -6998,12 +8340,13 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) pCarSpray->iLifeTime = -1; pCarSpray->iTimer = -1; pCarSpray->iType = (pCarSpray->iType & 0xFFFFFF00) | 2; - //LOBYTE(pCarSpray->iType) = 2; + // LOBYTE(pCarSpray->iType) = 2; pCar->nExplosionSoundTimer = -1; } goto NEXT_PARTICLE; } - if ((pCarSpray->iLifeTime & 3) == 0) // Animate particle colors by cycling through color palette every 4 frames + if ((pCarSpray->iLifeTime & 3) == 0) // Animate particle colors by cycling + // through color palette every 4 frames { uiColor = (uint8)pCarSpray->iColor; if (uiColor < 0x15) { @@ -7021,15 +8364,15 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) } SET_COLOR_CYCLE: iColor = pCarSpray->iColor; - iColor = iColor & 0xFFFFFF00; // Clear lowest byte only - //LOBYTE(iColor) = 0; + iColor = iColor & 0xFFFFFF00; // Clear lowest byte only + // LOBYTE(iColor) = 0; pCarSpray->iColor = iColorCycle | iColor; if (ROLLERrand() < 0x4000) pCarSpray->iColor ^= 0x1000u; - //BYTE1(pCarSpray->iColor) ^= 0x10u; + // BYTE1(pCarSpray->iColor) ^= 0x10u; if (ROLLERrand() < 0x4000) pCarSpray->iColor ^= 40000u; - //BYTE2(pCarSpray->iColor) ^= 4u; + // BYTE2(pCarSpray->iColor) ^= 4u; goto CONTINUE_COLOR_ANIMATION; } DEFAULT_COLOR_CYCLE: @@ -7037,17 +8380,22 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) goto SET_COLOR_CYCLE; } CONTINUE_COLOR_ANIMATION: - if ((uint8)pCarSpray->iColor && (uint8)pCarSpray->iColor < 0x15u || (uint8)pCarSpray->iColor > 0x17u) + if ((uint8)pCarSpray->iColor && (uint8)pCarSpray->iColor < 0x15u || + (uint8)pCarSpray->iColor > 0x17u) pCarSpray->iColor = 1302; - pCarSpray->position.fX = pCarSpray->velocity.fX + pCarSpray->position.fX;// Update particle physics: position += velocity, apply gravity/forces + pCarSpray->position.fX = + pCarSpray->velocity.fX + + pCarSpray->position.fX; // Update particle physics: position += + // velocity, apply gravity/forces pCarSpray->position.fY = pCarSpray->velocity.fY + pCarSpray->position.fY; pCarSpray->position.fZ = pCarSpray->velocity.fZ + pCarSpray->position.fZ; if (iCinematicMode) { ROLLERrandRaw(); - } else { // Fade out particles: reduce size as they near end of lifetime + } else { // Fade out particles: reduce size as they near end of lifetime if (pCarSpray->iLifeTime <= 8) { iRandomSizeShrink1 = ROLLERrandRaw(); - iSizeShrinkCalc1 = (GetHighOrderRand(24, iRandomSizeShrink1) + 10) * scr_size; + iSizeShrinkCalc1 = + (GetHighOrderRand(24, iRandomSizeShrink1) + 10) * scr_size; pCarSpray->fSize = pCarSpray->fSize - (float)((iSizeShrinkCalc1) >> 6); --pCarSpray->iLifeTime; goto NEXT_PARTICLE; @@ -7060,142 +8408,179 @@ void dospray(tCar *pCar, int iCinematicMode, tCarSpray *pCarSpray) NEXT_PARTICLE: ++iSprayIdx; ++pCarSpray; - } while (iSprayIdx < 32); // Main loop: process all 32 spray particles for this car + } while (iSprayIdx < + 32); // Main loop: process all 32 spray particles for this car } //------------------------------------------------------------------------------------------------- -//00036280 -void calculateseparatedcoordinatesystem(int iChunk, tData *pChunkData) -{ - int iNextChunk; // ecx - int iCurrentChunk; // eax - tData *pLocalData; // ebx +// 00036280 +void calculateseparatedcoordinatesystem(int iChunk, tData *pChunkData) { + int iNextChunk; // ecx + int iCurrentChunk; // eax + tData *pLocalData; // ebx double dInverseTrackLength; // st5 - double dCenterDeltaY; // st6 - float fTangentX; // [esp+0h] [ebp-28h] - float fTangentY; // [esp+4h] [ebp-24h] + double dCenterDeltaY; // st6 + float fTangentX; // [esp+0h] [ebp-28h] + float fTangentY; // [esp+4h] [ebp-24h] - iNextChunk = iChunk + 1; // Calculate next chunk index - if (iChunk + 1 >= TRAK_LEN) // Wrap around if we've reached the end of the track + iNextChunk = iChunk + 1; // Calculate next chunk index + if (iChunk + 1 >= + TRAK_LEN) // Wrap around if we've reached the end of the track iNextChunk = 0; iCurrentChunk = iChunk; - pLocalData = &localdata[iChunk]; // Get pointer to local data for current chunk - dInverseTrackLength = 1.0 / (pLocalData->fTrackHalfLength * 2.0);// Calculate inverse track length for normalization - fTangentX = ((TrakPt[iNextChunk].pointAy[2].fX + TrakPt[iNextChunk].pointAy[3].fX) * 0.5f - (TrakPt[iCurrentChunk].pointAy[2].fX + TrakPt[iCurrentChunk].pointAy[3].fX) * 0.5f) - * (float)dInverseTrackLength; // Calculate X component of track tangent vector (normalized) - dCenterDeltaY = (TrakPt[iNextChunk].pointAy[2].fY + TrakPt[iNextChunk].pointAy[3].fY) * 0.5 - - (TrakPt[iCurrentChunk].pointAy[2].fY + TrakPt[iCurrentChunk].pointAy[3].fY) * 0.5;// Calculate Y difference between track centers + pLocalData = + &localdata[iChunk]; // Get pointer to local data for current chunk + dInverseTrackLength = + 1.0 / (pLocalData->fTrackHalfLength * + 2.0); // Calculate inverse track length for normalization + fTangentX = + ((TrakPt[iNextChunk].pointAy[2].fX + TrakPt[iNextChunk].pointAy[3].fX) * + 0.5f - + (TrakPt[iCurrentChunk].pointAy[2].fX + + TrakPt[iCurrentChunk].pointAy[3].fX) * + 0.5f) * + (float)dInverseTrackLength; // Calculate X component of track tangent + // vector (normalized) + dCenterDeltaY = + (TrakPt[iNextChunk].pointAy[2].fY + TrakPt[iNextChunk].pointAy[3].fY) * + 0.5 - + (TrakPt[iCurrentChunk].pointAy[2].fY + + TrakPt[iCurrentChunk].pointAy[3].fY) * + 0.5; // Calculate Y difference between track centers fTangentY = (float)(dInverseTrackLength * dCenterDeltaY); - pChunkData->pointAy[0].fY = (float)(-(dInverseTrackLength * dCenterDeltaY));// Set up local coordinate system - pointAy[0] is right vector + pChunkData->pointAy[0].fY = (float)(-( + dInverseTrackLength * dCenterDeltaY)); // Set up local coordinate system - + // pointAy[0] is right vector pChunkData->pointAy[0].fZ = 0.0; pChunkData->pointAy[1].fZ = 0.0; - pChunkData->pointAy[2].fX = 0.0; // Set up local coordinate system - pointAy[2] is up vector (0,0,1) + pChunkData->pointAy[2].fX = + 0.0; // Set up local coordinate system - pointAy[2] is up vector (0,0,1) pChunkData->pointAy[2].fY = 0.0; pChunkData->pointAy[2].fZ = 1.0; - pChunkData->pointAy[0].fX = fTangentX; // Set up local coordinate system - pointAy[1] is forward vector + pChunkData->pointAy[0].fX = fTangentX; // Set up local coordinate system - + // pointAy[1] is forward vector pChunkData->pointAy[1].fX = fTangentY; pChunkData->pointAy[1].fY = fTangentX; - pChunkData->pointAy[3] = pLocalData->pointAy[3];// Copy track position and dimensions from local data + pChunkData->pointAy[3] = + pLocalData + ->pointAy[3]; // Copy track position and dimensions from local data pChunkData->fTrackHalfLength = pLocalData->fTrackHalfLength; pChunkData->fTrackHalfWidth = pLocalData->fTrackHalfWidth; } //------------------------------------------------------------------------------------------------- -//00036390 -void findnearsection(tCar *pCar, int *piNearestChunk) -{ - int iTrakLen; // ecx - int iNearestChunk; // edi - int iForwardChunkIdx; // edx - tData *pForwardData; // esi - int iForwardGroundIdx; // ebp - double dForwardCarX; // st7 - double dForwardCarY; // st6 - double dForwardAbsY; // st5 - double dForwardCarZ; // st4 - double dForwardAbsZ; // rt0 - double dForwardAbsX; // st4 - int iBackwardChunkIdx; // edx - tData *pBackwardData; // esi - int iBackwardGroundIdx; // ebp - double dBackwardCarX; // st7 - double dBackwardCarY; // st6 - double dBackwardAbsY; // st5 - double dBackwardCarZ; // st4 - double dBackwardAbsZ; // rt2 - double dBackwardAbsX; // st4 - int iForwardExtraStart; // ebp - int iForwardExtraIdx; // edx - tData *pForwardExtraData; // esi - int iForwardExtraGroundIdx; // ebp - double dForwardExtraCarX; // st7 - double dForwardExtraCarY; // st6 - double dForwardExtraAbsY; // st5 - double dForwardExtraCarZ; // st4 - double dForwardExtraAbsZ; // rt0 - double dForwardExtraAbsX; // st4 - int iBackwardExtraStart; // ebp - tData *pBackwardExtraData; // esi - int iBackwardExtraIdx; // edx - int iBackwardExtraGroundIdx; // ebp - double dBackwardExtraCarX; // st7 - double dBackwardExtraCarY; // st6 - double dBackwardExtraAbsY; // st5 - double dBackwardExtraCarZ; // st4 - double dBackwardExtraAbsZ; // rt2 - double dBackwardExtraAbsX; // st4 - tTrakView *pTrakView; // [esp+10h] [ebp-6Ch] - int iLastValidChunk; // [esp+14h] [ebp-68h] - int iBackwardMainEnd; // [esp+18h] [ebp-64h] - int iBackwardExtraEnd; // [esp+1Ch] [ebp-60h] - int iForwardMainEnd; // [esp+20h] [ebp-5Ch] - float fBackwardDotProduct; // [esp+24h] [ebp-58h] - float fForwardExtraDotProduct; // [esp+28h] [ebp-54h] +// 00036390 +void findnearsection(tCar *pCar, int *piNearestChunk) { + int iTrakLen; // ecx + int iNearestChunk; // edi + int iForwardChunkIdx; // edx + tData *pForwardData; // esi + int iForwardGroundIdx; // ebp + double dForwardCarX; // st7 + double dForwardCarY; // st6 + double dForwardAbsY; // st5 + double dForwardCarZ; // st4 + double dForwardAbsZ; // rt0 + double dForwardAbsX; // st4 + int iBackwardChunkIdx; // edx + tData *pBackwardData; // esi + int iBackwardGroundIdx; // ebp + double dBackwardCarX; // st7 + double dBackwardCarY; // st6 + double dBackwardAbsY; // st5 + double dBackwardCarZ; // st4 + double dBackwardAbsZ; // rt2 + double dBackwardAbsX; // st4 + int iForwardExtraStart; // ebp + int iForwardExtraIdx; // edx + tData *pForwardExtraData; // esi + int iForwardExtraGroundIdx; // ebp + double dForwardExtraCarX; // st7 + double dForwardExtraCarY; // st6 + double dForwardExtraAbsY; // st5 + double dForwardExtraCarZ; // st4 + double dForwardExtraAbsZ; // rt0 + double dForwardExtraAbsX; // st4 + int iBackwardExtraStart; // ebp + tData *pBackwardExtraData; // esi + int iBackwardExtraIdx; // edx + int iBackwardExtraGroundIdx; // ebp + double dBackwardExtraCarX; // st7 + double dBackwardExtraCarY; // st6 + double dBackwardExtraAbsY; // st5 + double dBackwardExtraCarZ; // st4 + double dBackwardExtraAbsZ; // rt2 + double dBackwardExtraAbsX; // st4 + tTrakView *pTrakView; // [esp+10h] [ebp-6Ch] + int iLastValidChunk; // [esp+14h] [ebp-68h] + int iBackwardMainEnd; // [esp+18h] [ebp-64h] + int iBackwardExtraEnd; // [esp+1Ch] [ebp-60h] + int iForwardMainEnd; // [esp+20h] [ebp-5Ch] + float fBackwardDotProduct; // [esp+24h] [ebp-58h] + float fForwardExtraDotProduct; // [esp+28h] [ebp-54h] float fBackwardExtraDotProduct; // [esp+2Ch] [ebp-50h] - float fForwardDotProduct; // [esp+30h] [ebp-4Ch] - float fBackwardExtraPosition; // [esp+34h] [ebp-48h] - float fForwardExtraPosition; // [esp+38h] [ebp-44h] - float fBackwardPosition; // [esp+3Ch] [ebp-40h] - float fForwardPosition; // [esp+40h] [ebp-3Ch] - float fForwardExtraDistance; // [esp+44h] [ebp-38h] - float fForwardDistance; // [esp+48h] [ebp-34h] - float fBackwardExtraDistance; // [esp+4Ch] [ebp-30h] - float fBackwardDistance; // [esp+50h] [ebp-2Ch] - float fMinCurrentDistance; // [esp+54h] [ebp-28h] - float fMinValidDistance; // [esp+58h] [ebp-24h] - float fTempCarX; // [esp+5Ch] [ebp-20h] - float fTempCarX2; // [esp+5Ch] [ebp-20h] - int iForwardExtraEnd; // [esp+60h] [ebp-1Ch] - float fTempCarX3; // [esp+64h] [ebp-18h] - float fTempCarX4; // [esp+64h] [ebp-18h] + float fForwardDotProduct; // [esp+30h] [ebp-4Ch] + float fBackwardExtraPosition; // [esp+34h] [ebp-48h] + float fForwardExtraPosition; // [esp+38h] [ebp-44h] + float fBackwardPosition; // [esp+3Ch] [ebp-40h] + float fForwardPosition; // [esp+40h] [ebp-3Ch] + float fForwardExtraDistance; // [esp+44h] [ebp-38h] + float fForwardDistance; // [esp+48h] [ebp-34h] + float fBackwardExtraDistance; // [esp+4Ch] [ebp-30h] + float fBackwardDistance; // [esp+50h] [ebp-2Ch] + float fMinCurrentDistance; // [esp+54h] [ebp-28h] + float fMinValidDistance; // [esp+58h] [ebp-24h] + float fTempCarX; // [esp+5Ch] [ebp-20h] + float fTempCarX2; // [esp+5Ch] [ebp-20h] + int iForwardExtraEnd; // [esp+60h] [ebp-1Ch] + float fTempCarX3; // [esp+64h] [ebp-18h] + float fTempCarX4; // [esp+64h] [ebp-18h] - iTrakLen = TRAK_LEN; // Store track length and initialize minimum distance trackers + iTrakLen = + TRAK_LEN; // Store track length and initialize minimum distance trackers fMinValidDistance = 1.0e10; fMinCurrentDistance = 1.0e10; - iLastValidChunk = pCar->iLastValidChunk; // Get car's last known valid track chunk and setup search parameters + iLastValidChunk = pCar->iLastValidChunk; // Get car's last known valid track + // chunk and setup search parameters iNearestChunk = -1; pTrakView = &TrakView[iLastValidChunk]; iForwardMainEnd = pTrakView->byForwardMainChunks + iLastValidChunk; iForwardChunkIdx = iLastValidChunk; pForwardData = &localdata[iLastValidChunk]; - if (iLastValidChunk < iForwardMainEnd) // Search forward main chunks for nearest track section + if (iLastValidChunk < + iForwardMainEnd) // Search forward main chunks for nearest track section { iForwardGroundIdx = iLastValidChunk; do { - dForwardCarX = pCar->pos.fX + pForwardData->pointAy[3].fX;// Calculate car position relative to current track chunk + dForwardCarX = + pCar->pos.fX + + pForwardData->pointAy[3] + .fX; // Calculate car position relative to current track chunk fTempCarX3 = (float)dForwardCarX; dForwardCarY = pCar->pos.fY + pForwardData->pointAy[3].fY; dForwardAbsY = fabs(dForwardCarY); dForwardCarZ = pCar->pos.fZ + pForwardData->pointAy[3].fZ; - fForwardDotProduct = pForwardData->pointAy[0].fZ * pCar->direction.fX - + pForwardData->pointAy[1].fZ * pCar->direction.fY - + pForwardData->pointAy[2].fZ * pCar->direction.fZ; + fForwardDotProduct = pForwardData->pointAy[0].fZ * pCar->direction.fX + + pForwardData->pointAy[1].fZ * pCar->direction.fY + + pForwardData->pointAy[2].fZ * pCar->direction.fZ; dForwardAbsZ = fabs(dForwardCarZ); - fForwardPosition = (float)(dForwardCarY * pForwardData->pointAy[1].fZ + pForwardData->pointAy[0].fZ * fTempCarX3 + dForwardCarZ * pForwardData->pointAy[2].fZ); + fForwardPosition = (float)(dForwardCarY * pForwardData->pointAy[1].fZ + + pForwardData->pointAy[0].fZ * fTempCarX3 + + dForwardCarZ * pForwardData->pointAy[2].fZ); dForwardAbsX = fabs(dForwardCarX); - fForwardDistance = (float)sqrt(dForwardAbsX * dForwardAbsX + dForwardAbsY * dForwardAbsY + dForwardAbsZ * dForwardAbsZ) - pForwardData->fTrackHalfLength;// Calculate 3D distance from car to track centerline - if (iForwardGroundIdx >= 0 && iForwardGroundIdx < TRAK_LEN && //bounds check added by ROLLER - (fForwardPosition >= -400.0 || GroundColour[iForwardGroundIdx][2] >= 0) && fForwardDistance < (double)fMinValidDistance)// Check position validity and update closest valid chunk if closer + fForwardDistance = + (float)sqrt(dForwardAbsX * dForwardAbsX + + dForwardAbsY * dForwardAbsY + + dForwardAbsZ * dForwardAbsZ) - + pForwardData->fTrackHalfLength; // Calculate 3D distance from car to + // track centerline + if (iForwardGroundIdx >= 0 && + iForwardGroundIdx < TRAK_LEN && // bounds check added by ROLLER + (fForwardPosition >= -400.0 || + GroundColour[iForwardGroundIdx][2] >= 0) && + fForwardDistance < + (double)fMinValidDistance) // Check position validity and update + // closest valid chunk if closer { fMinValidDistance = fForwardDistance; if (iForwardChunkIdx < iTrakLen) { @@ -7207,8 +8592,13 @@ void findnearsection(tCar *pCar, int *piNearestChunk) pCar->iLastValidChunk = iForwardChunkIdx - iTrakLen; } } - if (iForwardGroundIdx >= 0 && iForwardGroundIdx < TRAK_LEN && //bounds check added by ROLLER - (fForwardDotProduct * 4.0 + -500.0 <= fForwardPosition || GroundColour[iForwardGroundIdx][2] >= 0) && fForwardDistance < (double)fMinCurrentDistance)// Check forward position and update nearest current chunk if closer + if (iForwardGroundIdx >= 0 && + iForwardGroundIdx < TRAK_LEN && // bounds check added by ROLLER + (fForwardDotProduct * 4.0 + -500.0 <= fForwardPosition || + GroundColour[iForwardGroundIdx][2] >= 0) && + fForwardDistance < + (double)fMinCurrentDistance) // Check forward position and update + // nearest current chunk if closer { fMinCurrentDistance = fForwardDistance; if (iForwardChunkIdx < iTrakLen) { @@ -7220,7 +8610,9 @@ void findnearsection(tCar *pCar, int *piNearestChunk) iNearestChunk = iForwardChunkIdx - iTrakLen; } } - if (iForwardChunkIdx == iTrakLen - 1) // Handle track wrapping: loop back to start when reaching end + if (iForwardChunkIdx == + iTrakLen - + 1) // Handle track wrapping: loop back to start when reaching end pForwardData = localdata; else ++pForwardData; @@ -7231,7 +8623,8 @@ void findnearsection(tCar *pCar, int *piNearestChunk) iBackwardMainEnd = iLastValidChunk - pTrakView->byBackwardMainChunks; iBackwardChunkIdx = iLastValidChunk; pBackwardData = &localdata[iLastValidChunk]; - if (iLastValidChunk > iBackwardMainEnd) // Search backward main chunks for nearest track section + if (iLastValidChunk > + iBackwardMainEnd) // Search backward main chunks for nearest track section { iBackwardGroundIdx = iLastValidChunk; do { @@ -7240,15 +8633,23 @@ void findnearsection(tCar *pCar, int *piNearestChunk) dBackwardCarY = pCar->pos.fY + pBackwardData->pointAy[3].fY; dBackwardAbsY = fabs(dBackwardCarY); dBackwardCarZ = pCar->pos.fZ + pBackwardData->pointAy[3].fZ; - fBackwardDotProduct = pBackwardData->pointAy[0].fZ * pCar->direction.fX - + pBackwardData->pointAy[1].fZ * pCar->direction.fY - + pBackwardData->pointAy[2].fZ * pCar->direction.fZ; + fBackwardDotProduct = pBackwardData->pointAy[0].fZ * pCar->direction.fX + + pBackwardData->pointAy[1].fZ * pCar->direction.fY + + pBackwardData->pointAy[2].fZ * pCar->direction.fZ; dBackwardAbsZ = fabs(dBackwardCarZ); - fBackwardPosition = (float)(dBackwardCarY * pBackwardData->pointAy[1].fZ + pBackwardData->pointAy[0].fZ * fTempCarX + dBackwardCarZ * pBackwardData->pointAy[2].fZ); + fBackwardPosition = (float)(dBackwardCarY * pBackwardData->pointAy[1].fZ + + pBackwardData->pointAy[0].fZ * fTempCarX + + dBackwardCarZ * pBackwardData->pointAy[2].fZ); dBackwardAbsX = fabs(dBackwardCarX); - fBackwardDistance = (float)sqrt(dBackwardAbsX * dBackwardAbsX + dBackwardAbsY * dBackwardAbsY + dBackwardAbsZ * dBackwardAbsZ) - pBackwardData->fTrackHalfLength; - if (iBackwardGroundIdx >= 0 && iBackwardGroundIdx < TRAK_LEN && //bounds check added by ROLLER - (fBackwardPosition >= -400.0 || GroundColour[iBackwardGroundIdx][2] >= 0) && fBackwardDistance < (double)fMinValidDistance) { + fBackwardDistance = (float)sqrt(dBackwardAbsX * dBackwardAbsX + + dBackwardAbsY * dBackwardAbsY + + dBackwardAbsZ * dBackwardAbsZ) - + pBackwardData->fTrackHalfLength; + if (iBackwardGroundIdx >= 0 && + iBackwardGroundIdx < TRAK_LEN && // bounds check added by ROLLER + (fBackwardPosition >= -400.0 || + GroundColour[iBackwardGroundIdx][2] >= 0) && + fBackwardDistance < (double)fMinValidDistance) { fMinValidDistance = fBackwardDistance; if (iBackwardChunkIdx < iTrakLen) { if (iBackwardChunkIdx >= 0) @@ -7259,8 +8660,11 @@ void findnearsection(tCar *pCar, int *piNearestChunk) pCar->iLastValidChunk = iBackwardChunkIdx - iTrakLen; } } - if (iBackwardGroundIdx >= 0 && iBackwardGroundIdx < TRAK_LEN && //bounds check added by ROLLER - (fBackwardDotProduct * 4.0 + -500.0 <= fBackwardPosition || GroundColour[iBackwardGroundIdx][2] >= 0) && fBackwardDistance < (double)fMinCurrentDistance) { + if (iBackwardGroundIdx >= 0 && + iBackwardGroundIdx < TRAK_LEN && // bounds check added by ROLLER + (fBackwardDotProduct * 4.0 + -500.0 <= fBackwardPosition || + GroundColour[iBackwardGroundIdx][2] >= 0) && + fBackwardDistance < (double)fMinCurrentDistance) { fMinCurrentDistance = fBackwardDistance; if (iBackwardChunkIdx < iTrakLen) { if (iBackwardChunkIdx >= 0) @@ -7271,7 +8675,8 @@ void findnearsection(tCar *pCar, int *piNearestChunk) iNearestChunk = iBackwardChunkIdx - iTrakLen; } } - if (iBackwardChunkIdx) // Handle track wrapping: loop to end when reaching start + if (iBackwardChunkIdx) // Handle track wrapping: loop to end when reaching + // start --pBackwardData; else pBackwardData = &localdata[iTrakLen - 1]; @@ -7279,17 +8684,21 @@ void findnearsection(tCar *pCar, int *piNearestChunk) --iBackwardGroundIdx; } while (iBackwardChunkIdx > iBackwardMainEnd); } - if ((TrakColour[iLastValidChunk][1] & SURFACE_FLAG_NO_EXTRAS) == 0)// Check if not on special track section - if so, search extra chunks + if ((TrakColour[iLastValidChunk][1] & SURFACE_FLAG_NO_EXTRAS) == + 0) // Check if not on special track section - if so, search extra chunks { iForwardExtraStart = pTrakView->nForwardExtraStart; iForwardExtraEnd = pTrakView->byForwardExtraChunks + iForwardExtraStart; iForwardExtraIdx = iForwardExtraStart; - if (iForwardExtraStart >= 0 && iForwardExtraStart < TRAK_LEN) //check added by ROLLER + if (iForwardExtraStart >= 0 && + iForwardExtraStart < TRAK_LEN) // check added by ROLLER pForwardExtraData = &localdata[iForwardExtraStart]; else pForwardExtraData = NULL; - if (iForwardExtraStart < iForwardExtraEnd && pForwardExtraData)// Search forward extra chunks for nearest track section + if (iForwardExtraStart < iForwardExtraEnd && + pForwardExtraData) // Search forward extra chunks for nearest track + // section { iForwardExtraGroundIdx = iForwardExtraStart; do { @@ -7298,17 +8707,24 @@ void findnearsection(tCar *pCar, int *piNearestChunk) dForwardExtraCarY = pCar->pos.fY + pForwardExtraData->pointAy[3].fY; dForwardExtraAbsY = fabs(dForwardExtraCarY); dForwardExtraCarZ = pCar->pos.fZ + pForwardExtraData->pointAy[3].fZ; - fForwardExtraDotProduct = pForwardExtraData->pointAy[0].fZ * pCar->direction.fX - + pForwardExtraData->pointAy[1].fZ * pCar->direction.fY - + pForwardExtraData->pointAy[2].fZ * pCar->direction.fZ; + fForwardExtraDotProduct = + pForwardExtraData->pointAy[0].fZ * pCar->direction.fX + + pForwardExtraData->pointAy[1].fZ * pCar->direction.fY + + pForwardExtraData->pointAy[2].fZ * pCar->direction.fZ; dForwardExtraAbsZ = fabs(dForwardExtraCarZ); - fForwardExtraPosition = (float)(dForwardExtraCarY * pForwardExtraData->pointAy[1].fZ - + pForwardExtraData->pointAy[0].fZ * fTempCarX2 - + dForwardExtraCarZ * pForwardExtraData->pointAy[2].fZ); + fForwardExtraPosition = + (float)(dForwardExtraCarY * pForwardExtraData->pointAy[1].fZ + + pForwardExtraData->pointAy[0].fZ * fTempCarX2 + + dForwardExtraCarZ * pForwardExtraData->pointAy[2].fZ); dForwardExtraAbsX = fabs(dForwardExtraCarX); - fForwardExtraDistance = (float)sqrt(dForwardExtraAbsX * dForwardExtraAbsX + dForwardExtraAbsY * dForwardExtraAbsY + dForwardExtraAbsZ * dForwardExtraAbsZ) - - pForwardExtraData->fTrackHalfLength; - if ((fForwardExtraPosition >= -400.0 || GroundColour[iForwardExtraGroundIdx][2] >= 0) && fForwardExtraDistance < (double)fMinValidDistance) { + fForwardExtraDistance = + (float)sqrt(dForwardExtraAbsX * dForwardExtraAbsX + + dForwardExtraAbsY * dForwardExtraAbsY + + dForwardExtraAbsZ * dForwardExtraAbsZ) - + pForwardExtraData->fTrackHalfLength; + if ((fForwardExtraPosition >= -400.0 || + GroundColour[iForwardExtraGroundIdx][2] >= 0) && + fForwardExtraDistance < (double)fMinValidDistance) { fMinValidDistance = fForwardExtraDistance; if (iForwardExtraIdx < iTrakLen) { if (iForwardExtraIdx >= 0) @@ -7319,8 +8735,9 @@ void findnearsection(tCar *pCar, int *piNearestChunk) pCar->iLastValidChunk = iForwardExtraIdx - iTrakLen; } } - if ((fForwardExtraDotProduct * 4.0 + -500.0 <= fForwardExtraPosition || GroundColour[iForwardExtraGroundIdx][2] >= 0) - && fForwardExtraDistance < (double)fMinCurrentDistance) { + if ((fForwardExtraDotProduct * 4.0 + -500.0 <= fForwardExtraPosition || + GroundColour[iForwardExtraGroundIdx][2] >= 0) && + fForwardExtraDistance < (double)fMinCurrentDistance) { fMinCurrentDistance = fForwardExtraDistance; if (iForwardExtraIdx < iTrakLen) { if (iForwardExtraIdx >= 0) @@ -7339,12 +8756,17 @@ void findnearsection(tCar *pCar, int *piNearestChunk) ++iForwardExtraGroundIdx; } while (iForwardExtraIdx < iForwardExtraEnd); } - if (pTrakView->nBackwardExtraStart >= 0 && pTrakView->nBackwardExtraStart < TRAK_LEN) { //bounds check added by ROLLER + if (pTrakView->nBackwardExtraStart >= 0 && + pTrakView->nBackwardExtraStart < + TRAK_LEN) { // bounds check added by ROLLER iBackwardExtraStart = pTrakView->nBackwardExtraStart; - iBackwardExtraEnd = iBackwardExtraStart - pTrakView->byBackwardExtraChunks; + iBackwardExtraEnd = + iBackwardExtraStart - pTrakView->byBackwardExtraChunks; pBackwardExtraData = &localdata[iBackwardExtraStart]; iBackwardExtraIdx = iBackwardExtraStart; - if (iBackwardExtraStart > iBackwardExtraEnd)// Search backward extra chunks for nearest track section + if (iBackwardExtraStart > + iBackwardExtraEnd) // Search backward extra chunks for nearest track + // section { iBackwardExtraGroundIdx = iBackwardExtraStart; do { @@ -7353,17 +8775,24 @@ void findnearsection(tCar *pCar, int *piNearestChunk) dBackwardExtraCarY = pCar->pos.fY + pBackwardExtraData->pointAy[3].fY; dBackwardExtraAbsY = fabs(dBackwardExtraCarY); dBackwardExtraCarZ = pCar->pos.fZ + pBackwardExtraData->pointAy[3].fZ; - fBackwardExtraDotProduct = pBackwardExtraData->pointAy[0].fZ * pCar->direction.fX - + pBackwardExtraData->pointAy[1].fZ * pCar->direction.fY - + pBackwardExtraData->pointAy[2].fZ * pCar->direction.fZ; + fBackwardExtraDotProduct = + pBackwardExtraData->pointAy[0].fZ * pCar->direction.fX + + pBackwardExtraData->pointAy[1].fZ * pCar->direction.fY + + pBackwardExtraData->pointAy[2].fZ * pCar->direction.fZ; dBackwardExtraAbsZ = fabs(dBackwardExtraCarZ); - fBackwardExtraPosition = (float)(dBackwardExtraCarY * pBackwardExtraData->pointAy[1].fZ - + pBackwardExtraData->pointAy[0].fZ * fTempCarX4 - + dBackwardExtraCarZ * pBackwardExtraData->pointAy[2].fZ); + fBackwardExtraPosition = + (float)(dBackwardExtraCarY * pBackwardExtraData->pointAy[1].fZ + + pBackwardExtraData->pointAy[0].fZ * fTempCarX4 + + dBackwardExtraCarZ * pBackwardExtraData->pointAy[2].fZ); dBackwardExtraAbsX = fabs(dBackwardExtraCarX); - fBackwardExtraDistance = (float)sqrt(dBackwardExtraAbsX * dBackwardExtraAbsX + dBackwardExtraAbsY * dBackwardExtraAbsY + dBackwardExtraAbsZ * dBackwardExtraAbsZ) - - pBackwardExtraData->fTrackHalfLength; - if ((fBackwardExtraPosition >= -400.0 || GroundColour[iBackwardExtraGroundIdx][2] >= 0) && fBackwardExtraDistance < (double)fMinValidDistance) { + fBackwardExtraDistance = + (float)sqrt(dBackwardExtraAbsX * dBackwardExtraAbsX + + dBackwardExtraAbsY * dBackwardExtraAbsY + + dBackwardExtraAbsZ * dBackwardExtraAbsZ) - + pBackwardExtraData->fTrackHalfLength; + if ((fBackwardExtraPosition >= -400.0 || + GroundColour[iBackwardExtraGroundIdx][2] >= 0) && + fBackwardExtraDistance < (double)fMinValidDistance) { fMinValidDistance = fBackwardExtraDistance; if (iBackwardExtraIdx < iTrakLen) { if (iBackwardExtraIdx >= 0) @@ -7374,8 +8803,10 @@ void findnearsection(tCar *pCar, int *piNearestChunk) pCar->iLastValidChunk = iBackwardExtraIdx - iTrakLen; } } - if ((fBackwardExtraDotProduct * 4.0 + -500.0 <= fBackwardExtraPosition || GroundColour[iBackwardExtraGroundIdx][2] >= 0) - && fBackwardExtraDistance < (double)fMinCurrentDistance) { + if ((fBackwardExtraDotProduct * 4.0 + -500.0 <= + fBackwardExtraPosition || + GroundColour[iBackwardExtraGroundIdx][2] >= 0) && + fBackwardExtraDistance < (double)fMinCurrentDistance) { fMinCurrentDistance = fBackwardExtraDistance; if (iBackwardExtraIdx < iTrakLen) { if (iBackwardExtraIdx >= 0) @@ -7396,38 +8827,42 @@ void findnearsection(tCar *pCar, int *piNearestChunk) } } } - *piNearestChunk = iNearestChunk; // Return index of nearest track chunk found + *piNearestChunk = iNearestChunk; // Return index of nearest track chunk found TRAK_LEN = iTrakLen; } //------------------------------------------------------------------------------------------------- -//000369C0 -void dozoomstuff(int iPlayerIdx) -{ - int iPrevChampMode; // ebx - int iPlayerIdx_1; // eax - int iZoomCountdown; // esi - double dZoomInScale; // st7 - int iPlayerIdx2; // edx +// 000369C0 +void dozoomstuff(int iPlayerIdx) { + int iPrevChampMode; // ebx + int iPlayerIdx_1; // eax + int iZoomCountdown; // esi + double dZoomInScale; // st7 + int iPlayerIdx2; // edx double dZoomOutScale; // st7 - int iPlayerIdx3; // edx + int iPlayerIdx3; // edx - iPrevChampMode = champ_mode; // Store current championship mode state - if (champ_mode >= 16) // Decrement champ counter if in championship mode + iPrevChampMode = champ_mode; // Store current championship mode state + if (champ_mode >= 16) // Decrement champ counter if in championship mode --champ_count; iPlayerIdx_1 = iPlayerIdx; - iZoomCountdown = game_count[iPlayerIdx]; // Get zoom countdown timer for this player + iZoomCountdown = + game_count[iPlayerIdx]; // Get zoom countdown timer for this player if (iZoomCountdown <= 0) { if (iZoomCountdown >= 0) { if (champ_mode) - dZoomOutScale = game_scale[iPlayerIdx] * 0.5;// Zoom out phase: apply zoom factor based on championship vs regular mode + dZoomOutScale = game_scale[iPlayerIdx] * + 0.5; // Zoom out phase: apply zoom factor based on + // championship vs regular mode else dZoomOutScale = game_scale[iPlayerIdx] * 0.7692307692307693; game_scale[iPlayerIdx] = (float)dZoomOutScale; iPlayerIdx3 = iPlayerIdx; - if (game_scale[iPlayerIdx3] < 64.0) // Check if zoom has reached minimum scale limit + if (game_scale[iPlayerIdx3] < + 64.0) // Check if zoom has reached minimum scale limit { - game_scale[iPlayerIdx3] = 64.0; // Clamp to minimum zoom (64.0) and set appropriate countdown timer + game_scale[iPlayerIdx3] = 64.0; // Clamp to minimum zoom (64.0) and set + // appropriate countdown timer if (iPrevChampMode) { game_count[iPlayerIdx3] = 36; champ_mode = iPrevChampMode; @@ -7436,12 +8871,15 @@ void dozoomstuff(int iPlayerIdx) game_count[iPlayerIdx3] = 72; } } else if (iZoomCountdown > -2) { - dZoomInScale = champ_mode ? game_scale[iPlayerIdx] * 2.0 : game_scale[iPlayerIdx] * 1.3; + dZoomInScale = champ_mode ? game_scale[iPlayerIdx] * 2.0 + : game_scale[iPlayerIdx] * 1.3; game_scale[iPlayerIdx] = (float)dZoomInScale; iPlayerIdx2 = iPlayerIdx; - if (game_scale[iPlayerIdx2] > 32768.0) // Check if zoom has reached maximum scale limit + if (game_scale[iPlayerIdx2] > + 32768.0) // Check if zoom has reached maximum scale limit { - game_scale[iPlayerIdx2] = 32768.0; // Clamp to maximum zoom and disable further zooming + game_scale[iPlayerIdx2] = + 32768.0; // Clamp to maximum zoom and disable further zooming game_count[iPlayerIdx2] = -2; sub_on[iPlayerIdx2] = 0; champ_mode = iPrevChampMode; @@ -7449,40 +8887,57 @@ void dozoomstuff(int iPlayerIdx) } } } else { - game_count[iPlayerIdx_1] = iZoomCountdown - 1;// Countdown is positive - decrement timer - if (iZoomCountdown == 1 && game_scale[iPlayerIdx_1] == 64.0)// Special case: if countdown reaches 1 and scale is at minimum (64.0), start zoom in + game_count[iPlayerIdx_1] = + iZoomCountdown - 1; // Countdown is positive - decrement timer + if (iZoomCountdown == 1 && + game_scale[iPlayerIdx_1] == + 64.0) // Special case: if countdown reaches 1 and scale is at + // minimum (64.0), start zoom in game_count[iPlayerIdx_1] = -1; } - champ_mode = iPrevChampMode; // Restore championship mode state + champ_mode = iPrevChampMode; // Restore championship mode state } //------------------------------------------------------------------------------------------------- -//00036B10 -int findcardistance(int iCarIdx, float fMaxDistance) -{ - int iClosestCarIdx; // esi - int iCarCounter; // ebx - int iCurrentCarIdx; // edx - double dCurrentCarPos; // st7 - double dDistance; // st7 +// 00036B10 +int findcardistance(int iCarIdx, float fMaxDistance) { + int iClosestCarIdx; // esi + int iCarCounter; // ebx + int iCurrentCarIdx; // edx + double dCurrentCarPos; // st7 + double dDistance; // st7 float fReferenceCarPos; // [esp+4h] [ebp-24h] float fClosestDistance; // [esp+8h] [ebp-20h] - float fAdjustedCarPos; // [esp+Ch] [ebp-1Ch] + float fAdjustedCarPos; // [esp+Ch] [ebp-1Ch] - iClosestCarIdx = -1; // Initialize closest car index to -1 (no car found) - iCarCounter = 0; // Initialize car counter for iteration - fReferenceCarPos = (float)((double)(averagesectionlen * Car[iCarIdx].nCurrChunk) + Car[iCarIdx].pos.fX);// Calculate absolute track position of reference car - if (numcars > 0) // Check if there are cars to iterate through + iClosestCarIdx = -1; // Initialize closest car index to -1 (no car found) + iCarCounter = 0; // Initialize car counter for iteration + fReferenceCarPos = + (float)((double)(averagesectionlen * Car[iCarIdx].nCurrChunk) + + Car[iCarIdx].pos.fX); // Calculate absolute track position of + // reference car + if (numcars > 0) // Check if there are cars to iterate through { iCurrentCarIdx = 0; - do { // Skip self, dead cars, non-AI cars, and stunned cars - if (iCarCounter != iCarIdx && (char)Car[iCurrentCarIdx].byLives > 0 && Car[iCurrentCarIdx].iControlType == 3 && !Car[iCurrentCarIdx].iStunned) { - dCurrentCarPos = (double)(averagesectionlen * Car[iCurrentCarIdx].nCurrChunk) + Car[iCurrentCarIdx].pos.fX;// Calculate absolute track position of current car + do { // Skip self, dead cars, non-AI cars, and stunned cars + if (iCarCounter != iCarIdx && (char)Car[iCurrentCarIdx].byLives > 0 && + Car[iCurrentCarIdx].iControlType == 3 && + !Car[iCurrentCarIdx].iStunned) { + dCurrentCarPos = + (double)(averagesectionlen * Car[iCurrentCarIdx].nCurrChunk) + + Car[iCurrentCarIdx] + .pos.fX; // Calculate absolute track position of current car fAdjustedCarPos = (float)dCurrentCarPos; if (dCurrentCarPos < fReferenceCarPos) - fAdjustedCarPos = (float)((double)totaltrackdistance + fAdjustedCarPos);// Handle track wrapping - add total track distance if car is behind - dDistance = fAdjustedCarPos - fReferenceCarPos;// Calculate distance from reference car to current car - if (dDistance < fMaxDistance) // If this car is closer than current closest, update closest car + fAdjustedCarPos = + (float)((double)totaltrackdistance + + fAdjustedCarPos); // Handle track wrapping - add total + // track distance if car is behind + dDistance = + fAdjustedCarPos - fReferenceCarPos; // Calculate distance from + // reference car to current car + if (dDistance < fMaxDistance) // If this car is closer than current + // closest, update closest car { iClosestCarIdx = iCarCounter; fClosestDistance = (float)dDistance; @@ -7493,7 +8948,8 @@ int findcardistance(int iCarIdx, float fMaxDistance) ++iCurrentCarIdx; } while (iCarCounter < numcars); } - return iClosestCarIdx; // Return index of closest car ahead, or -1 if none found + return iClosestCarIdx; // Return index of closest car ahead, or -1 if none + // found } //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/control.h b/PROJECTS/ROLLER/control.h index 9464cd3c..b62e85f1 100644 --- a/PROJECTS/ROLLER/control.h +++ b/PROJECTS/ROLLER/control.h @@ -7,8 +7,7 @@ #include "3d.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int strategyAy[5]; float fSteerSensitivity; float fSteerDamping; @@ -67,7 +66,8 @@ void Accelerate(tCar *pCar); void Decelerate(tCar *pCar); void FreeWheel(tCar *pCar); void SetEngine(tCar *pCar, float fThrottle); -double change_gear(int iCurrentGear, int iNextGear, tCar *pCar, int iCarDesignIdx); +double change_gear(int iCurrentGear, int iNextGear, tCar *pCar, + int iCarDesignIdx); void updatecar2(tCar *pCar); void check_crossed_line(tCar *pCar); void checkplacement(tCar *pCar); @@ -79,11 +79,20 @@ void scansection(tCar *pCar); double getgroundz(float fXPos, float fYOffset, int iChunkIdx); double getroadz(float fX, float fY, int iChunkIdx); void putflat(tCar *pCar); -void findnearcars(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *piRightCarIdx, float *pfRightTime, float *pfTargetX, float *pfTargetY); -void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, int *piRightCarIdx, float *pfRightTime, float *pfTargetX, float *pfTargetY); -double interpolatesteer(float fSteeringInput, float fSaturationThreshold, float fDeadzoneThreshold, float fMaxOutput, float fMinOutput); -double avoid(int iCurrentCarIdx, int iTargetCarIdx, float fSteeringInput, float fMaxOutput, float fSaturationThreshold, float fDeadzoneThreshold, int *piOvertakeFlag); -double block(int iCarIdx, float fSteeringInput, float fMaxOutput, float fSaturationThreshold, float fDeadzoneThreshold); +void findnearcars(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, + int *piRightCarIdx, float *pfRightTime, float *pfTargetX, + float *pfTargetY); +void findnearcarsforce(tCar *pCar, int *piLeftCarIdx, float *pfLeftTime, + int *piRightCarIdx, float *pfRightTime, float *pfTargetX, + float *pfTargetY); +double interpolatesteer(float fSteeringInput, float fSaturationThreshold, + float fDeadzoneThreshold, float fMaxOutput, + float fMinOutput); +double avoid(int iCurrentCarIdx, int iTargetCarIdx, float fSteeringInput, + float fMaxOutput, float fSaturationThreshold, + float fDeadzoneThreshold, int *piOvertakeFlag); +double block(int iCarIdx, float fSteeringInput, float fMaxOutput, + float fSaturationThreshold, float fDeadzoneThreshold); void autocar2(tCar *pCar); void changestrategy(tCar *pCar); int getangle(float fX, float fY); diff --git a/PROJECTS/ROLLER/crashdump.c b/PROJECTS/ROLLER/crashdump.c index a2960102..df8c9b27 100644 --- a/PROJECTS/ROLLER/crashdump.c +++ b/PROJECTS/ROLLER/crashdump.c @@ -58,8 +58,7 @@ //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { char szName[CRASHDUMP_MAX_NAME]; char szPath[CRASHDUMP_MAX_PATH]; } tCrashFileEntry; @@ -87,8 +86,7 @@ static int s_iDyldInfoLen = 0; //------------------------------------------------------------------------------------------------- -static int IsEnvEnabled(const char *szName) -{ +static int IsEnvEnabled(const char *szName) { const char *pszValue = getenv(szName); if (!pszValue || !pszValue[0]) return 0; @@ -103,8 +101,7 @@ static int IsEnvEnabled(const char *szName) //------------------------------------------------------------------------------------------------- -static int ShouldEnableCrashHandler(void) -{ +static int ShouldEnableCrashHandler(void) { const char *pszForce = getenv("ROLLER_CRASH_HANDLER"); if (IsEnvEnabled("ROLLER_NO_CRASH_HANDLER")) @@ -121,8 +118,7 @@ static int ShouldEnableCrashHandler(void) //------------------------------------------------------------------------------------------------- -static char GetPathSeparator(void) -{ +static char GetPathSeparator(void) { #ifdef IS_WINDOWS return '\\'; #else @@ -132,8 +128,7 @@ static char GetPathSeparator(void) //------------------------------------------------------------------------------------------------- -static void StripFilename(char *szPath) -{ +static void StripFilename(char *szPath) { char *pszSlash = strrchr(szPath, '/'); char *pszBackslash = strrchr(szPath, '\\'); char *pszSep = pszSlash; @@ -146,8 +141,8 @@ static void StripFilename(char *szPath) //------------------------------------------------------------------------------------------------- -static void BuildPath(char *szOut, int iOutSize, const char *szDir, const char *szName) -{ +static void BuildPath(char *szOut, int iOutSize, const char *szDir, + const char *szName) { char cSep = GetPathSeparator(); int iLen = (int)strlen(szDir); @@ -164,15 +159,14 @@ static void BuildPath(char *szOut, int iOutSize, const char *szDir, const char * //------------------------------------------------------------------------------------------------- -static int IsCrashFileName(const char *szName) -{ +static int IsCrashFileName(const char *szName) { return strncmp(szName, "roller-crash-", 13) == 0; } //------------------------------------------------------------------------------------------------- -static void AddCrashFileEntry(tCrashFileEntry *pEntries, int *piCount, const char *szDir, const char *szName) -{ +static void AddCrashFileEntry(tCrashFileEntry *pEntries, int *piCount, + const char *szDir, const char *szName) { int iCount = *piCount; int iInsert; @@ -185,24 +179,24 @@ static void AddCrashFileEntry(tCrashFileEntry *pEntries, int *piCount, const cha pEntries[iInsert] = pEntries[iInsert - 1]; } - snprintf(pEntries[iInsert].szName, sizeof(pEntries[iInsert].szName), "%s", szName); - BuildPath(pEntries[iInsert].szPath, sizeof(pEntries[iInsert].szPath), szDir, szName); + snprintf(pEntries[iInsert].szName, sizeof(pEntries[iInsert].szName), "%s", + szName); + BuildPath(pEntries[iInsert].szPath, sizeof(pEntries[iInsert].szPath), szDir, + szName); *piCount = iCount + 1; } //------------------------------------------------------------------------------------------------- #ifdef IS_WINDOWS -static void CreateDirIfNeeded(const char *szDir) -{ +static void CreateDirIfNeeded(const char *szDir) { if (szDir[0]) CreateDirectoryA(szDir, NULL); } //------------------------------------------------------------------------------------------------- -static void RotateCrashFiles(const char *szDir) -{ +static void RotateCrashFiles(const char *szDir) { tCrashFileEntry crashFileEntryAy[CRASHDUMP_MAX_ROTATE_FILES]; WIN32_FIND_DATAA stFindData; HANDLE hFind; @@ -234,8 +228,7 @@ static void RotateCrashFiles(const char *szDir) //------------------------------------------------------------------------------------------------- -static void ResolveExecutableDir(char *szOut, int iOutSize) -{ +static void ResolveExecutableDir(char *szOut, int iOutSize) { DWORD dwLen = GetModuleFileNameA(NULL, szOut, (DWORD)iOutSize); if (dwLen == 0 || dwLen >= (DWORD)iOutSize) { snprintf(szOut, iOutSize, "."); @@ -246,8 +239,7 @@ static void ResolveExecutableDir(char *szOut, int iOutSize) //------------------------------------------------------------------------------------------------- -static void ResolveFallbackCrashDir(char *szOut, int iOutSize) -{ +static void ResolveFallbackCrashDir(char *szOut, int iOutSize) { const char *pszLocalAppData = getenv("LOCALAPPDATA"); char szRollerDir[CRASHDUMP_MAX_PATH]; @@ -263,8 +255,7 @@ static void ResolveFallbackCrashDir(char *szOut, int iOutSize) //------------------------------------------------------------------------------------------------- -static int WriteMiniDump(const char *szPath, EXCEPTION_POINTERS *pException) -{ +static int WriteMiniDump(const char *szPath, EXCEPTION_POINTERS *pException) { HANDLE hFile; MINIDUMP_EXCEPTION_INFORMATION stExceptionInfo; MINIDUMP_USER_STREAM stUserStream; @@ -272,7 +263,8 @@ static int WriteMiniDump(const char *szPath, EXCEPTION_POINTERS *pException) MINIDUMP_TYPE eDumpType; BOOL bOk; - hFile = CreateFileA(szPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFileA(szPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return 0; @@ -291,8 +283,8 @@ static int WriteMiniDump(const char *szPath, EXCEPTION_POINTERS *pException) MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithThreadInfo); - bOk = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, eDumpType, - &stExceptionInfo, &stUserStreamInfo, NULL); + bOk = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, + eDumpType, &stExceptionInfo, &stUserStreamInfo, NULL); CloseHandle(hFile); return bOk != FALSE; @@ -300,8 +292,8 @@ static int WriteMiniDump(const char *szPath, EXCEPTION_POINTERS *pException) //------------------------------------------------------------------------------------------------- -static LONG WINAPI CrashUnhandledExceptionFilter(EXCEPTION_POINTERS *pException) -{ +static LONG WINAPI +CrashUnhandledExceptionFilter(EXCEPTION_POINTERS *pException) { const char *pszWrittenPath = NULL; if (InterlockedExchange(&s_lHandlingCrash, 1) != 0) @@ -309,7 +301,8 @@ static LONG WINAPI CrashUnhandledExceptionFilter(EXCEPTION_POINTERS *pException) if (WriteMiniDump(s_szCrashPath, pException)) { pszWrittenPath = s_szCrashPath; - } else if (s_szFallbackCrashPath[0] && WriteMiniDump(s_szFallbackCrashPath, pException)) { + } else if (s_szFallbackCrashPath[0] && + WriteMiniDump(s_szFallbackCrashPath, pException)) { pszWrittenPath = s_szFallbackCrashPath; } @@ -319,7 +312,8 @@ static LONG WINAPI CrashUnhandledExceptionFilter(EXCEPTION_POINTERS *pException) "ROLLER has crashed.\n\nA crash dump was saved to:\n%s\n\n" "Please attach this file to a GitHub crash report.", pszWrittenPath); - MessageBoxA(NULL, szMessage, "ROLLER crash", MB_OK | MB_ICONERROR | MB_TASKMODAL); + MessageBoxA(NULL, szMessage, "ROLLER crash", + MB_OK | MB_ICONERROR | MB_TASKMODAL); } return EXCEPTION_EXECUTE_HANDLER; @@ -327,16 +321,14 @@ static LONG WINAPI CrashUnhandledExceptionFilter(EXCEPTION_POINTERS *pException) #else -static void CreateDirIfNeeded(const char *szDir) -{ +static void CreateDirIfNeeded(const char *szDir) { if (szDir[0]) mkdir(szDir, 0755); } //------------------------------------------------------------------------------------------------- -static void RotateCrashFiles(const char *szDir) -{ +static void RotateCrashFiles(const char *szDir) { tCrashFileEntry crashFileEntryAy[CRASHDUMP_MAX_ROTATE_FILES]; DIR *pDir; struct dirent *pEntry; @@ -364,8 +356,7 @@ static void RotateCrashFiles(const char *szDir) //------------------------------------------------------------------------------------------------- -static void ResolveExecutableDir(char *szOut, int iOutSize) -{ +static void ResolveExecutableDir(char *szOut, int iOutSize) { #ifdef IS_LINUX ssize_t llLen = readlink("/proc/self/exe", szOut, (size_t)iOutSize - 1); if (llLen > 0 && llLen < iOutSize) { @@ -387,8 +378,7 @@ static void ResolveExecutableDir(char *szOut, int iOutSize) //------------------------------------------------------------------------------------------------- -static void ResolveFallbackCrashDir(char *szOut, int iOutSize) -{ +static void ResolveFallbackCrashDir(char *szOut, int iOutSize) { const char *pszHome; szOut[0] = '\0'; @@ -427,8 +417,7 @@ static void ResolveFallbackCrashDir(char *szOut, int iOutSize) //------------------------------------------------------------------------------------------------- -static void WriteBuffer(int iFd, const char *pBuf, size_t uiLen) -{ +static void WriteBuffer(int iFd, const char *pBuf, size_t uiLen) { while (uiLen > 0) { ssize_t llWritten = write(iFd, pBuf, uiLen); if (llWritten < 0) { @@ -445,8 +434,7 @@ static void WriteBuffer(int iFd, const char *pBuf, size_t uiLen) //------------------------------------------------------------------------------------------------- -static void WriteCString(int iFd, const char *szText) -{ +static void WriteCString(int iFd, const char *szText) { const char *pEnd = szText; while (*pEnd) ++pEnd; @@ -455,12 +443,12 @@ static void WriteCString(int iFd, const char *szText) //------------------------------------------------------------------------------------------------- -#define WriteLiteral(iFd, szText) WriteBuffer((iFd), (szText), sizeof(szText) - 1) +#define WriteLiteral(iFd, szText) \ + WriteBuffer((iFd), (szText), sizeof(szText) - 1) //------------------------------------------------------------------------------------------------- -static void WriteUIntDec(int iFd, uint64 ullVal) -{ +static void WriteUIntDec(int iFd, uint64 ullVal) { char szBuf[32]; int iPos = (int)sizeof(szBuf); @@ -475,8 +463,7 @@ static void WriteUIntDec(int iFd, uint64 ullVal) //------------------------------------------------------------------------------------------------- -static void WriteIntDec(int iFd, int iVal) -{ +static void WriteIntDec(int iFd, int iVal) { if (iVal < 0) { WriteLiteral(iFd, "-"); WriteUIntDec(iFd, (uint64)(-(int64)iVal)); @@ -487,8 +474,7 @@ static void WriteIntDec(int iFd, int iVal) //------------------------------------------------------------------------------------------------- -static void WriteHex64(int iFd, uint64 ullVal) -{ +static void WriteHex64(int iFd, uint64 ullVal) { static const char s_szHex[] = "0123456789abcdef"; char szBuf[18]; @@ -504,8 +490,8 @@ static void WriteHex64(int iFd, uint64 ullVal) //------------------------------------------------------------------------------------------------- -static void GetSignalContextRegisters(void *pContext, uint64 *pullPc, uint64 *pullSp) -{ +static void GetSignalContextRegisters(void *pContext, uint64 *pullPc, + uint64 *pullSp) { *pullPc = 0; *pullSp = 0; @@ -540,8 +526,7 @@ static void GetSignalContextRegisters(void *pContext, uint64 *pullPc, uint64 *pu //------------------------------------------------------------------------------------------------- -static void WriteDescriptorContents(int iOutFd, int iInFd) -{ +static void WriteDescriptorContents(int iOutFd, int iInFd) { char szBuf[2048]; for (;;) { @@ -559,8 +544,7 @@ static void WriteDescriptorContents(int iOutFd, int iInFd) //------------------------------------------------------------------------------------------------- -static void WriteMappings(int iFd) -{ +static void WriteMappings(int iFd) { WriteLiteral(iFd, "\nMappings:\n"); #ifdef IS_LINUX @@ -585,8 +569,7 @@ static void WriteMappings(int iFd) //------------------------------------------------------------------------------------------------- -static void WriteBacktrace(int iFd) -{ +static void WriteBacktrace(int iFd) { void *pFrames[64]; int iFrameCount; @@ -600,8 +583,7 @@ static void WriteBacktrace(int iFd) //------------------------------------------------------------------------------------------------- -static void RestoreDefaultAndReraise(int iSig) -{ +static void RestoreDefaultAndReraise(int iSig) { struct sigaction stAction; sigset_t stSigSet; @@ -620,8 +602,7 @@ static void RestoreDefaultAndReraise(int iSig) //------------------------------------------------------------------------------------------------- -static void CrashSignalHandler(int iSig, siginfo_t *pSigInfo, void *pContext) -{ +static void CrashSignalHandler(int iSig, siginfo_t *pSigInfo, void *pContext) { int iFd; uint64 ullFaultAddr = 0; uint64 ullPc = 0; @@ -633,7 +614,8 @@ static void CrashSignalHandler(int iSig, siginfo_t *pSigInfo, void *pContext) iFd = open(s_szCrashPath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); if (iFd < 0 && s_szFallbackCrashPath[0]) - iFd = open(s_szFallbackCrashPath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); + iFd = open(s_szFallbackCrashPath, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, + 0644); if (iFd >= 0) { if (pSigInfo) @@ -663,8 +645,7 @@ static void CrashSignalHandler(int iSig, siginfo_t *pSigInfo, void *pContext) //------------------------------------------------------------------------------------------------- -static void WarmUpBacktrace(void) -{ +static void WarmUpBacktrace(void) { int iFd = open("/dev/null", O_WRONLY | O_CLOEXEC); void *pFrames[1]; int iFrameCount = backtrace(pFrames, 1); @@ -679,24 +660,22 @@ static void WarmUpBacktrace(void) //------------------------------------------------------------------------------------------------- #ifdef IS_MACOS -static void CaptureDyldInfo(void) -{ +static void CaptureDyldInfo(void) { uint32 uiCount = _dyld_image_count(); int iOffset = 0; - iOffset += snprintf(s_szDyldInfo + iOffset, sizeof(s_szDyldInfo) - (size_t)iOffset, - "Dyld images:\n"); + iOffset += snprintf(s_szDyldInfo + iOffset, + sizeof(s_szDyldInfo) - (size_t)iOffset, "Dyld images:\n"); - for (uint32 i = 0; i < uiCount && iOffset < (int)sizeof(s_szDyldInfo) - 1; ++i) { + for (uint32 i = 0; i < uiCount && iOffset < (int)sizeof(s_szDyldInfo) - 1; + ++i) { const struct mach_header *pMachHeader = _dyld_get_image_header(i); const char *szName = _dyld_get_image_name(i); long long llSlide = (long long)_dyld_get_image_vmaddr_slide(i); - iOffset += snprintf(s_szDyldInfo + iOffset, sizeof(s_szDyldInfo) - (size_t)iOffset, - "%u header=0x%llx slide=%lld %s\n", - i, - (unsigned long long)(size_t)pMachHeader, - llSlide, - szName ? szName : ""); + iOffset += snprintf( + s_szDyldInfo + iOffset, sizeof(s_szDyldInfo) - (size_t)iOffset, + "%u header=0x%llx slide=%lld %s\n", i, + (unsigned long long)(size_t)pMachHeader, llSlide, szName ? szName : ""); } if (iOffset >= (int)sizeof(s_szDyldInfo)) @@ -708,9 +687,8 @@ static void CaptureDyldInfo(void) //------------------------------------------------------------------------------------------------- -static void InstallPosixCrashHandlers(void) -{ - const int iSignalAy[] = { SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS }; +static void InstallPosixCrashHandlers(void) { + const int iSignalAy[] = {SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS}; stack_t stAltStack; struct sigaction stAction; @@ -731,19 +709,15 @@ static void InstallPosixCrashHandlers(void) //------------------------------------------------------------------------------------------------- -static void BuildCrashBaseName(const char *szExt) -{ +static void BuildCrashBaseName(const char *szExt) { #ifdef IS_WINDOWS SYSTEMTIME stSystemTime; GetLocalTime(&stSystemTime); snprintf(s_szCrashBaseName, sizeof(s_szCrashBaseName), "roller-crash-%04u%02u%02u-%02u%02u%02u%s", - (unsigned)stSystemTime.wYear, - (unsigned)stSystemTime.wMonth, - (unsigned)stSystemTime.wDay, - (unsigned)stSystemTime.wHour, - (unsigned)stSystemTime.wMinute, - (unsigned)stSystemTime.wSecond, + (unsigned)stSystemTime.wYear, (unsigned)stSystemTime.wMonth, + (unsigned)stSystemTime.wDay, (unsigned)stSystemTime.wHour, + (unsigned)stSystemTime.wMinute, (unsigned)stSystemTime.wSecond, szExt); #else time_t tNow = time(NULL); @@ -756,31 +730,22 @@ static void BuildCrashBaseName(const char *szExt) } snprintf(s_szCrashBaseName, sizeof(s_szCrashBaseName), - "roller-crash-%04d%02d%02d-%02d%02d%02d%s", - stTmNow.tm_year + 1900, - stTmNow.tm_mon + 1, - stTmNow.tm_mday, - stTmNow.tm_hour, - stTmNow.tm_min, - stTmNow.tm_sec, - szExt); + "roller-crash-%04d%02d%02d-%02d%02d%02d%s", stTmNow.tm_year + 1900, + stTmNow.tm_mon + 1, stTmNow.tm_mday, stTmNow.tm_hour, stTmNow.tm_min, + stTmNow.tm_sec, szExt); #endif } //------------------------------------------------------------------------------------------------- -static void BuildStaticCrashInfo(void) -{ +static void BuildStaticCrashInfo(void) { snprintf(s_szBuildInfo, sizeof(s_szBuildInfo), "ROLLER crash build information\n" "Version: %s\n" "Git hash: %s\n" "Build date: %s\n" "Target: %s\n", - BUILD_VERSION, - BUILD_GIT_HASH, - BUILD_DATE, - BUILD_TARGET); + BUILD_VERSION, BUILD_GIT_HASH, BUILD_DATE, BUILD_TARGET); snprintf(s_szReportHeader, sizeof(s_szReportHeader), "ROLLER crash report\n" @@ -789,17 +754,13 @@ static void BuildStaticCrashInfo(void) "Build date: %s\n" "Target: %s\n" "Report path: %s\n\n", - BUILD_VERSION, - BUILD_GIT_HASH, - BUILD_DATE, - BUILD_TARGET, + BUILD_VERSION, BUILD_GIT_HASH, BUILD_DATE, BUILD_TARGET, s_szCrashPath); } //------------------------------------------------------------------------------------------------- -void InitCrashHandler(void) -{ +void InitCrashHandler(void) { if (!ShouldEnableCrashHandler()) return; @@ -812,9 +773,11 @@ void InitCrashHandler(void) BuildCrashBaseName(".txt"); #endif - BuildPath(s_szCrashPath, sizeof(s_szCrashPath), s_szCrashDir, s_szCrashBaseName); + BuildPath(s_szCrashPath, sizeof(s_szCrashPath), s_szCrashDir, + s_szCrashBaseName); if (s_szFallbackCrashDir[0]) - BuildPath(s_szFallbackCrashPath, sizeof(s_szFallbackCrashPath), s_szFallbackCrashDir, s_szCrashBaseName); + BuildPath(s_szFallbackCrashPath, sizeof(s_szFallbackCrashPath), + s_szFallbackCrashDir, s_szCrashBaseName); BuildStaticCrashInfo(); RotateCrashFiles(s_szCrashDir); diff --git a/PROJECTS/ROLLER/debug_overlay.c b/PROJECTS/ROLLER/debug_overlay.c index fd6184ef..56ba5df4 100644 --- a/PROJECTS/ROLLER/debug_overlay.c +++ b/PROJECTS/ROLLER/debug_overlay.c @@ -21,57 +21,57 @@ // --------------------------------------------------------------------------- -#define OVERLAY_W 1280 -#define OVERLAY_H 720 -#define OVERLAY_BPP 4 // RGBA +#define OVERLAY_W 1280 +#define OVERLAY_H 720 +#define OVERLAY_BPP 4 // RGBA #define MAX_LOG_MESSAGES 512 -#define MAX_LOG_LEN 256 +#define MAX_LOG_LEN 256 -#define PANEL_MARGIN 10 -#define PANEL_H (OVERLAY_H - PANEL_MARGIN * 2) -#define LEFT_W 410 -#define RIGHT_X (PANEL_MARGIN + LEFT_W + PANEL_MARGIN) -#define RIGHT_W (OVERLAY_W - RIGHT_X - PANEL_MARGIN) -#define LOG_ROW_H 20 +#define PANEL_MARGIN 10 +#define PANEL_H (OVERLAY_H - PANEL_MARGIN * 2) +#define LEFT_W 410 +#define RIGHT_X (PANEL_MARGIN + LEFT_W + PANEL_MARGIN) +#define RIGHT_W (OVERLAY_W - RIGHT_X - PANEL_MARGIN) +#define LOG_ROW_H 20 typedef struct { char szText[MAX_LOG_LEN]; } tLogEntry; struct DebugOverlay { - SDL_GPUDevice *pDevice; - SDL_Window *pWindow; - bool bVisible; - - struct nk_context nk; - struct nk_font_atlas atlas; - int iAtlasW; - int iAtlasH; - uint8_t *pAtlasPixels; // owned RGBA copy - - uint8_t *pPixels; // OVERLAY_W * OVERLAY_H * OVERLAY_BPP - SDL_GPUTexture *pTexture; + SDL_GPUDevice *pDevice; + SDL_Window *pWindow; + bool bVisible; + + struct nk_context nk; + struct nk_font_atlas atlas; + int iAtlasW; + int iAtlasH; + uint8_t *pAtlasPixels; // owned RGBA copy + + uint8_t *pPixels; // OVERLAY_W * OVERLAY_H * OVERLAY_BPP + SDL_GPUTexture *pTexture; SDL_GPUTransferBuffer *pTransfer; SDL_GPUGraphicsPipeline *pPipeline; - SDL_GPUSampler *pSampler; + SDL_GPUSampler *pSampler; // Log ring buffer - tLogEntry aLogEntries[MAX_LOG_MESSAGES]; - int iLogHead; // index of oldest entry - int iLogCount; - SDL_Mutex *pLogMutex; + tLogEntry aLogEntries[MAX_LOG_MESSAGES]; + int iLogHead; // index of oldest entry + int iLogCount; + SDL_Mutex *pLogMutex; // Chained SDL log function - SDL_LogOutputFunction pPrevLogFn; - void *pPrevLogUserdata; + SDL_LogOutputFunction pPrevLogFn; + void *pPrevLogUserdata; - bool bInputBegun; + bool bInputBegun; // Network panel state - char szNetLocalIP[16]; // selected local IP override; empty = auto - tROLLERNetIface aNetIfaces[ROLLER_MAX_IFACES]; - int iNetIfaceCount; + char szNetLocalIP[16]; // selected local IP override; empty = auto + tROLLERNetIface aNetIfaces[ROLLER_MAX_IFACES]; + int iNetIfaceCount; }; // --------------------------------------------------------------------------- @@ -80,23 +80,31 @@ struct DebugOverlay { static const char *PriorityPrefix(SDL_LogPriority priority) { switch (priority) { - case SDL_LOG_PRIORITY_VERBOSE: return "[VRB] "; - case SDL_LOG_PRIORITY_DEBUG: return "[DBG] "; - case SDL_LOG_PRIORITY_INFO: return "[INF] "; - case SDL_LOG_PRIORITY_WARN: return "[WRN] "; - case SDL_LOG_PRIORITY_ERROR: return "[ERR] "; - case SDL_LOG_PRIORITY_CRITICAL: return "[CRT] "; - default: return " "; + case SDL_LOG_PRIORITY_VERBOSE: + return "[VRB] "; + case SDL_LOG_PRIORITY_DEBUG: + return "[DBG] "; + case SDL_LOG_PRIORITY_INFO: + return "[INF] "; + case SDL_LOG_PRIORITY_WARN: + return "[WRN] "; + case SDL_LOG_PRIORITY_ERROR: + return "[ERR] "; + case SDL_LOG_PRIORITY_CRITICAL: + return "[CRT] "; + default: + return " "; } } -static void LogCallback(void *pUserdata, int iCategory, SDL_LogPriority priority, - const char *pMessage) { +static void LogCallback(void *pUserdata, int iCategory, + SDL_LogPriority priority, const char *pMessage) { DebugOverlay *pOverlay = (DebugOverlay *)pUserdata; // Chain to previous handler so console output is preserved if (pOverlay->pPrevLogFn) - pOverlay->pPrevLogFn(pOverlay->pPrevLogUserdata, iCategory, priority, pMessage); + pOverlay->pPrevLogFn(pOverlay->pPrevLogUserdata, iCategory, priority, + pMessage); SDL_LockMutex(pOverlay->pLogMutex); @@ -109,8 +117,8 @@ static void LogCallback(void *pUserdata, int iCategory, SDL_LogPriority priority pOverlay->iLogHead = (pOverlay->iLogHead + 1) % MAX_LOG_MESSAGES; } - snprintf(pOverlay->aLogEntries[iIdx].szText, MAX_LOG_LEN, - "%s%s", PriorityPrefix(priority), pMessage); + snprintf(pOverlay->aLogEntries[iIdx].szText, MAX_LOG_LEN, "%s%s", + PriorityPrefix(priority), pMessage); SDL_UnlockMutex(pOverlay->pLogMutex); } @@ -120,11 +128,13 @@ static void LogCallback(void *pUserdata, int iCategory, SDL_LogPriority priority // --------------------------------------------------------------------------- static void OverlayFillRect(uint8_t *pBuf, int iBx, int iBy, int iBw, int iBh, - struct nk_color c) { + struct nk_color c) { for (int iY = iBy; iY < iBy + iBh; iY++) { - if (iY < 0 || iY >= OVERLAY_H) continue; + if (iY < 0 || iY >= OVERLAY_H) + continue; for (int iX = iBx; iX < iBx + iBw; iX++) { - if (iX < 0 || iX >= OVERLAY_W) continue; + if (iX < 0 || iX >= OVERLAY_W) + continue; uint8_t *pP = pBuf + (iY * OVERLAY_W + iX) * OVERLAY_BPP; int iA = c.a; pP[0] = (uint8_t)((c.r * iA + pP[0] * (255 - iA)) / 255); @@ -135,21 +145,24 @@ static void OverlayFillRect(uint8_t *pBuf, int iBx, int iBy, int iBw, int iBh, } } -static void OverlayFillTriangle(uint8_t *pBuf, - int iX0, int iY0, int iX1, int iY1, int iX2, int iY2, - struct nk_color c) { +static void OverlayFillTriangle(uint8_t *pBuf, int iX0, int iY0, int iX1, + int iY1, int iX2, int iY2, struct nk_color c) { int iMinX = iX0 < iX1 ? (iX0 < iX2 ? iX0 : iX2) : (iX1 < iX2 ? iX1 : iX2); int iMinY = iY0 < iY1 ? (iY0 < iY2 ? iY0 : iY2) : (iY1 < iY2 ? iY1 : iY2); int iMaxX = iX0 > iX1 ? (iX0 > iX2 ? iX0 : iX2) : (iX1 > iX2 ? iX1 : iX2); int iMaxY = iY0 > iY1 ? (iY0 > iY2 ? iY0 : iY2) : (iY1 > iY2 ? iY1 : iY2); for (int iY = iMinY; iY <= iMaxY; iY++) { - if (iY < 0 || iY >= OVERLAY_H) continue; + if (iY < 0 || iY >= OVERLAY_H) + continue; for (int iX = iMinX; iX <= iMaxX; iX++) { - if (iX < 0 || iX >= OVERLAY_W) continue; - int iD0 = (iX1-iX0)*(iY-iY0) - (iY1-iY0)*(iX-iX0); - int iD1 = (iX2-iX1)*(iY-iY1) - (iY2-iY1)*(iX-iX1); - int iD2 = (iX0-iX2)*(iY-iY2) - (iY0-iY2)*(iX-iX2); - if (!((iD0>=0&&iD1>=0&&iD2>=0)||(iD0<=0&&iD1<=0&&iD2<=0))) continue; + if (iX < 0 || iX >= OVERLAY_W) + continue; + int iD0 = (iX1 - iX0) * (iY - iY0) - (iY1 - iY0) * (iX - iX0); + int iD1 = (iX2 - iX1) * (iY - iY1) - (iY2 - iY1) * (iX - iX1); + int iD2 = (iX0 - iX2) * (iY - iY2) - (iY0 - iY2) * (iX - iX2); + if (!((iD0 >= 0 && iD1 >= 0 && iD2 >= 0) || + (iD0 <= 0 && iD1 <= 0 && iD2 <= 0))) + continue; uint8_t *pP = pBuf + (iY * OVERLAY_W + iX) * OVERLAY_BPP; int iA = c.a; pP[0] = (uint8_t)((c.r * iA + pP[0] * (255 - iA)) / 255); @@ -161,8 +174,8 @@ static void OverlayFillTriangle(uint8_t *pBuf, } static void OverlayStrokeLine(uint8_t *pBuf, int iX0, int iY0, int iX1, int iY1, - struct nk_color c) { - int iDx = abs(iX1-iX0), iDy = abs(iY1-iY0); + struct nk_color c) { + int iDx = abs(iX1 - iX0), iDy = abs(iY1 - iY0); int iSx = iX0 < iX1 ? 1 : -1, iSy = iY0 < iY1 ? 1 : -1; int iErr = iDx - iDy; for (;;) { @@ -174,29 +187,43 @@ static void OverlayStrokeLine(uint8_t *pBuf, int iX0, int iY0, int iX1, int iY1, pP[2] = (uint8_t)((c.b * iA + pP[2] * (255 - iA)) / 255); pP[3] = (uint8_t)(iA + pP[3] * (255 - iA) / 255); } - if (iX0 == iX1 && iY0 == iY1) break; + if (iX0 == iX1 && iY0 == iY1) + break; int iE2 = 2 * iErr; - if (iE2 > -iDy) { iErr -= iDy; iX0 += iSx; } - if (iE2 < iDx) { iErr += iDx; iY0 += iSy; } + if (iE2 > -iDy) { + iErr -= iDy; + iX0 += iSx; + } + if (iE2 < iDx) { + iErr += iDx; + iY0 += iSy; + } } } -static void OverlayDrawGlyph(DebugOverlay *pOverlay, const struct nk_font_glyph *pGlyph, - int iCx, int iCy, struct nk_color fg) { +static void OverlayDrawGlyph(DebugOverlay *pOverlay, + const struct nk_font_glyph *pGlyph, int iCx, + int iCy, struct nk_color fg) { int iGw = (int)(pGlyph->x1 - pGlyph->x0); int iGh = (int)(pGlyph->y1 - pGlyph->y0); for (int iPy = 0; iPy < iGh; iPy++) { for (int iPx = 0; iPx < iGw; iPx++) { - float fU = pGlyph->u0 + (pGlyph->u1 - pGlyph->u0) * ((float)iPx / (float)iGw); - float fV = pGlyph->v0 + (pGlyph->v1 - pGlyph->v0) * ((float)iPy / (float)iGh); + float fU = + pGlyph->u0 + (pGlyph->u1 - pGlyph->u0) * ((float)iPx / (float)iGw); + float fV = + pGlyph->v0 + (pGlyph->v1 - pGlyph->v0) * ((float)iPy / (float)iGh); int iAx = (int)(fU * (float)pOverlay->iAtlasW); int iAy = (int)(fV * (float)pOverlay->iAtlasH); - if (iAx < 0 || iAx >= pOverlay->iAtlasW || iAy < 0 || iAy >= pOverlay->iAtlasH) continue; - int iAlpha = pOverlay->pAtlasPixels[(iAy * pOverlay->iAtlasW + iAx) * 4 + 3]; + if (iAx < 0 || iAx >= pOverlay->iAtlasW || iAy < 0 || + iAy >= pOverlay->iAtlasH) + continue; + int iAlpha = + pOverlay->pAtlasPixels[(iAy * pOverlay->iAtlasW + iAx) * 4 + 3]; iAlpha = iAlpha * fg.a / 255; int iDx = iCx + (int)pGlyph->x0 + iPx; int iDy = iCy + (int)pGlyph->y0 + iPy; - if (iDx < 0 || iDx >= OVERLAY_W || iDy < 0 || iDy >= OVERLAY_H) continue; + if (iDx < 0 || iDx >= OVERLAY_W || iDy < 0 || iDy >= OVERLAY_H) + continue; uint8_t *pDst = pOverlay->pPixels + (iDy * OVERLAY_W + iDx) * OVERLAY_BPP; pDst[0] = (uint8_t)((fg.r * iAlpha + pDst[0] * (255 - iAlpha)) / 255); pDst[1] = (uint8_t)((fg.g * iAlpha + pDst[1] * (255 - iAlpha)) / 255); @@ -215,19 +242,19 @@ static void RenderCommands(DebugOverlay *pOverlay) { break; case NK_COMMAND_LINE: { const struct nk_command_line *pL = (const struct nk_command_line *)pCmd; - OverlayStrokeLine(pOverlay->pPixels, pL->begin.x, pL->begin.y, - pL->end.x, pL->end.y, pL->color); + OverlayStrokeLine(pOverlay->pPixels, pL->begin.x, pL->begin.y, pL->end.x, + pL->end.y, pL->color); } break; case NK_COMMAND_RECT_FILLED: { const struct nk_command_rect_filled *pR = - (const struct nk_command_rect_filled *)pCmd; + (const struct nk_command_rect_filled *)pCmd; OverlayFillRect(pOverlay->pPixels, pR->x, pR->y, pR->w, pR->h, pR->color); } break; case NK_COMMAND_TRIANGLE_FILLED: { const struct nk_command_triangle_filled *pT = - (const struct nk_command_triangle_filled *)pCmd; - OverlayFillTriangle(pOverlay->pPixels, - pT->a.x, pT->a.y, pT->b.x, pT->b.y, pT->c.x, pT->c.y, pT->color); + (const struct nk_command_triangle_filled *)pCmd; + OverlayFillTriangle(pOverlay->pPixels, pT->a.x, pT->a.y, pT->b.x, pT->b.y, + pT->c.x, pT->c.y, pT->color); } break; case NK_COMMAND_TEXT: { const struct nk_command_text *pT = (const struct nk_command_text *)pCmd; @@ -236,12 +263,16 @@ static void RenderCommands(DebugOverlay *pOverlay) { for (int iI = 0; iI < pT->length; iI++) { nk_rune uiRune = (nk_rune)(unsigned char)pT->string[iI]; const struct nk_font_glyph *pGlyph = nk_font_find_glyph(pFont, uiRune); - if (!pGlyph) { fCx += pT->font->height * 0.5f; continue; } + if (!pGlyph) { + fCx += pT->font->height * 0.5f; + continue; + } OverlayDrawGlyph(pOverlay, pGlyph, (int)fCx, pT->y, pT->foreground); fCx += pGlyph->xadvance; } } break; - default: break; + default: + break; } } nk_clear(&pOverlay->nk); @@ -251,17 +282,19 @@ static void RenderCommands(DebugOverlay *pOverlay) { // GPU upload // --------------------------------------------------------------------------- -static void UploadAndBlit(DebugOverlay *pOverlay, SDL_GPUCommandBuffer *pCmdBuf) { - void *pMapped = SDL_MapGPUTransferBuffer(pOverlay->pDevice, pOverlay->pTransfer, true); - if (!pMapped) return; +static void UploadAndBlit(DebugOverlay *pOverlay, + SDL_GPUCommandBuffer *pCmdBuf) { + void *pMapped = + SDL_MapGPUTransferBuffer(pOverlay->pDevice, pOverlay->pTransfer, true); + if (!pMapped) + return; memcpy(pMapped, pOverlay->pPixels, OVERLAY_W * OVERLAY_H * OVERLAY_BPP); SDL_UnmapGPUTransferBuffer(pOverlay->pDevice, pOverlay->pTransfer); SDL_GPUCopyPass *pCp = SDL_BeginGPUCopyPass(pCmdBuf); - SDL_GPUTextureTransferInfo src = { .transfer_buffer = pOverlay->pTransfer }; + SDL_GPUTextureTransferInfo src = {.transfer_buffer = pOverlay->pTransfer}; SDL_GPUTextureRegion dst = { - .texture = pOverlay->pTexture, .w = OVERLAY_W, .h = OVERLAY_H, .d = 1 - }; + .texture = pOverlay->pTexture, .w = OVERLAY_W, .h = OVERLAY_H, .d = 1}; SDL_UploadToGPUTexture(pCp, &src, &dst, false); SDL_EndGPUCopyPass(pCp); } @@ -270,10 +303,11 @@ static void UploadAndBlit(DebugOverlay *pOverlay, SDL_GPUCommandBuffer *pCmdBuf) // Lifecycle // --------------------------------------------------------------------------- -static SDL_GPUShader *LoadOverlayShader(SDL_GPUDevice *pDevice, SDL_GPUShaderStage stage, - const unsigned char *pSpirv, unsigned int uiSpirvSize, - const unsigned char *pMsl, unsigned int uiMslSize, - int iNumSamplers, int iNumUniformBuffers) { +static SDL_GPUShader * +LoadOverlayShader(SDL_GPUDevice *pDevice, SDL_GPUShaderStage stage, + const unsigned char *pSpirv, unsigned int uiSpirvSize, + const unsigned char *pMsl, unsigned int uiMslSize, + int iNumSamplers, int iNumUniformBuffers) { SDL_GPUShaderFormat fmts = SDL_GetGPUShaderFormats(pDevice); SDL_GPUShaderCreateInfo info = {0}; info.stage = stage; @@ -295,47 +329,53 @@ static SDL_GPUShader *LoadOverlayShader(SDL_GPUDevice *pDevice, SDL_GPUShaderSta return SDL_CreateGPUShader(pDevice, &info); } -DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, SDL_Window *pWindow) { +DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, + SDL_Window *pWindow) { DebugOverlay *pOverlay = calloc(1, sizeof(DebugOverlay)); - if (!pOverlay) return NULL; - pOverlay->pDevice = pDevice; - pOverlay->pWindow = pWindow; - pOverlay->bVisible = false; + if (!pOverlay) + return NULL; + pOverlay->pDevice = pDevice; + pOverlay->pWindow = pWindow; + pOverlay->bVisible = false; nk_font_atlas_init_default(&pOverlay->atlas); nk_font_atlas_begin(&pOverlay->atlas); struct nk_font *pFont = nk_font_atlas_add_default(&pOverlay->atlas, 16, NULL); - const void *pBaked = nk_font_atlas_bake(&pOverlay->atlas, - &pOverlay->iAtlasW, &pOverlay->iAtlasH, - NK_FONT_ATLAS_RGBA32); + const void *pBaked = + nk_font_atlas_bake(&pOverlay->atlas, &pOverlay->iAtlasW, + &pOverlay->iAtlasH, NK_FONT_ATLAS_RGBA32); size_t uiAtlasBytes = (size_t)(pOverlay->iAtlasW * pOverlay->iAtlasH * 4); pOverlay->pAtlasPixels = malloc(uiAtlasBytes); memcpy(pOverlay->pAtlasPixels, pBaked, uiAtlasBytes); struct nk_draw_null_texture nullTex = {0}; - nk_font_atlas_end(&pOverlay->atlas, nk_handle_ptr(pOverlay->pAtlasPixels), &nullTex); + nk_font_atlas_end(&pOverlay->atlas, nk_handle_ptr(pOverlay->pAtlasPixels), + &nullTex); nk_init_default(&pOverlay->nk, &pFont->handle); // Make window and group backgrounds translucent (~80% opacity) struct nk_style *pStyle = &pOverlay->nk.style; - pStyle->window.fixed_background = nk_style_item_color(nk_rgba(45, 45, 45, 200)); - pStyle->window.background = nk_rgba(45, 45, 45, 200); - pStyle->window.header.normal = nk_style_item_color(nk_rgba(40, 40, 40, 200)); - pStyle->window.header.hover = nk_style_item_color(nk_rgba(40, 40, 40, 200)); - pStyle->window.header.active = nk_style_item_color(nk_rgba(40, 40, 40, 200)); - pStyle->window.group_border_color = nk_rgba(60, 60, 60, 200); - pStyle->window.border_color = nk_rgba(60, 60, 60, 200); - pStyle->checkbox.cursor_normal = nk_style_item_color(nk_rgba(220, 220, 220, 255)); - pStyle->checkbox.cursor_hover = nk_style_item_color(nk_rgba(255, 255, 255, 255)); + pStyle->window.fixed_background = + nk_style_item_color(nk_rgba(45, 45, 45, 200)); + pStyle->window.background = nk_rgba(45, 45, 45, 200); + pStyle->window.header.normal = nk_style_item_color(nk_rgba(40, 40, 40, 200)); + pStyle->window.header.hover = nk_style_item_color(nk_rgba(40, 40, 40, 200)); + pStyle->window.header.active = nk_style_item_color(nk_rgba(40, 40, 40, 200)); + pStyle->window.group_border_color = nk_rgba(60, 60, 60, 200); + pStyle->window.border_color = nk_rgba(60, 60, 60, 200); + pStyle->checkbox.cursor_normal = + nk_style_item_color(nk_rgba(220, 220, 220, 255)); + pStyle->checkbox.cursor_hover = + nk_style_item_color(nk_rgba(255, 255, 255, 255)); pOverlay->pPixels = calloc(1, OVERLAY_W * OVERLAY_H * OVERLAY_BPP); SDL_GPUTextureCreateInfo ti = {0}; - ti.type = SDL_GPU_TEXTURETYPE_2D; + ti.type = SDL_GPU_TEXTURETYPE_2D; ti.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; - ti.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER; - ti.width = OVERLAY_W; + ti.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER; + ti.width = OVERLAY_W; ti.height = OVERLAY_H; ti.layer_count_or_depth = 1; ti.num_levels = 1; @@ -343,7 +383,7 @@ DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, SDL_Window *pWindow) SDL_GPUTransferBufferCreateInfo tbi = {0}; tbi.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; - tbi.size = OVERLAY_W * OVERLAY_H * OVERLAY_BPP; + tbi.size = OVERLAY_W * OVERLAY_H * OVERLAY_BPP; pOverlay->pTransfer = SDL_CreateGPUTransferBuffer(pDevice, &tbi); pOverlay->pLogMutex = SDL_CreateMutex(); @@ -351,31 +391,33 @@ DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, SDL_Window *pWindow) SDL_SetLogOutputFunction(LogCallback, pOverlay); // Build alpha-blend pipeline for compositing overlay over swapchain - SDL_GPUShader *pVert = LoadOverlayShader(pDevice, SDL_GPU_SHADERSTAGE_VERTEX, - overlay_vertex_spirv, overlay_vertex_spirv_size, - overlay_vertex_msl, overlay_vertex_msl_size, - 0, 0); - SDL_GPUShader *pFrag = LoadOverlayShader(pDevice, SDL_GPU_SHADERSTAGE_FRAGMENT, - overlay_pixel_spirv, overlay_pixel_spirv_size, - overlay_pixel_msl, overlay_pixel_msl_size, - 1, 0); + SDL_GPUShader *pVert = + LoadOverlayShader(pDevice, SDL_GPU_SHADERSTAGE_VERTEX, + overlay_vertex_spirv, overlay_vertex_spirv_size, + overlay_vertex_msl, overlay_vertex_msl_size, 0, 0); + SDL_GPUShader *pFrag = + LoadOverlayShader(pDevice, SDL_GPU_SHADERSTAGE_FRAGMENT, + overlay_pixel_spirv, overlay_pixel_spirv_size, + overlay_pixel_msl, overlay_pixel_msl_size, 1, 0); if (pVert && pFrag) { SDL_GPUGraphicsPipelineCreateInfo pipeInfo = {0}; - pipeInfo.vertex_shader = pVert; + pipeInfo.vertex_shader = pVert; pipeInfo.fragment_shader = pFrag; - pipeInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + pipeInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; SDL_GPUColorTargetDescription ct = {0}; ct.format = SDL_GetGPUSwapchainTextureFormat(pDevice, pWindow); - ct.blend_state.enable_blend = true; - ct.blend_state.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA; - ct.blend_state.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; - ct.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD; - ct.blend_state.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE; - ct.blend_state.dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; - ct.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD; + ct.blend_state.enable_blend = true; + ct.blend_state.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA; + ct.blend_state.dst_color_blendfactor = + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + ct.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD; + ct.blend_state.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE; + ct.blend_state.dst_alpha_blendfactor = + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + ct.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD; pipeInfo.target_info.color_target_descriptions = &ct; - pipeInfo.target_info.num_color_targets = 1; + pipeInfo.target_info.num_color_targets = 1; pOverlay->pPipeline = SDL_CreateGPUGraphicsPipeline(pDevice, &pipeInfo); if (!pOverlay->pPipeline) @@ -383,13 +425,15 @@ DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, SDL_Window *pWindow) } else { SDL_Log("debug_overlay: failed to load overlay shaders"); } - if (pVert) SDL_ReleaseGPUShader(pDevice, pVert); - if (pFrag) SDL_ReleaseGPUShader(pDevice, pFrag); + if (pVert) + SDL_ReleaseGPUShader(pDevice, pVert); + if (pFrag) + SDL_ReleaseGPUShader(pDevice, pFrag); SDL_GPUSamplerCreateInfo si = {0}; - si.min_filter = SDL_GPU_FILTER_LINEAR; - si.mag_filter = SDL_GPU_FILTER_LINEAR; - si.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; + si.min_filter = SDL_GPU_FILTER_LINEAR; + si.mag_filter = SDL_GPU_FILTER_LINEAR; + si.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR; si.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; si.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; pOverlay->pSampler = SDL_CreateGPUSampler(pDevice, &si); @@ -398,7 +442,8 @@ DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, SDL_Window *pWindow) } void debug_overlay_destroy(DebugOverlay *pOverlay) { - if (!pOverlay) return; + if (!pOverlay) + return; SDL_SetLogOutputFunction(pOverlay->pPrevLogFn, pOverlay->pPrevLogUserdata); SDL_DestroyMutex(pOverlay->pLogMutex); nk_free(&pOverlay->nk); @@ -423,18 +468,21 @@ bool debug_overlay_is_visible(DebugOverlay *pOverlay) { } void debug_overlay_toggle(DebugOverlay *pOverlay) { - if (!pOverlay) return; + if (!pOverlay) + return; pOverlay->bVisible = !pOverlay->bVisible; if (pOverlay->bVisible) { SDL_StartTextInput(pOverlay->pWindow); - pOverlay->iNetIfaceCount = ROLLERCommsEnumLocalAddrs(pOverlay->aNetIfaces, ROLLER_MAX_IFACES); + pOverlay->iNetIfaceCount = + ROLLERCommsEnumLocalAddrs(pOverlay->aNetIfaces, ROLLER_MAX_IFACES); } else { SDL_StopTextInput(pOverlay->pWindow); } } void debug_overlay_handle_event(DebugOverlay *pOverlay, SDL_Event *pEvent) { - if (!pOverlay || !pOverlay->bVisible) return; + if (!pOverlay || !pOverlay->bVisible) + return; // Open input bracket on first event of the frame if (!pOverlay->bInputBegun) { @@ -450,40 +498,57 @@ void debug_overlay_handle_event(DebugOverlay *pOverlay, SDL_Event *pEvent) { struct nk_context *pCtx = &pOverlay->nk; if (pEvent->type == SDL_EVENT_MOUSE_MOTION) { - nk_input_motion(pCtx, - (int)(pEvent->motion.x * fScaleX), + nk_input_motion(pCtx, (int)(pEvent->motion.x * fScaleX), (int)(pEvent->motion.y * fScaleY)); } else if (pEvent->type == SDL_EVENT_MOUSE_BUTTON_DOWN || pEvent->type == SDL_EVENT_MOUSE_BUTTON_UP) { int iDown = (pEvent->type == SDL_EVENT_MOUSE_BUTTON_DOWN); if (pEvent->button.button == SDL_BUTTON_LEFT) - nk_input_button(pCtx, NK_BUTTON_LEFT, - (int)(pEvent->button.x * fScaleX), + nk_input_button(pCtx, NK_BUTTON_LEFT, (int)(pEvent->button.x * fScaleX), (int)(pEvent->button.y * fScaleY), iDown); } else if (pEvent->type == SDL_EVENT_MOUSE_WHEEL) { nk_input_scroll(pCtx, nk_vec2(0.0f, pEvent->wheel.y * 20.0f)); - } else if (pEvent->type == SDL_EVENT_KEY_DOWN || pEvent->type == SDL_EVENT_KEY_UP) { + } else if (pEvent->type == SDL_EVENT_KEY_DOWN || + pEvent->type == SDL_EVENT_KEY_UP) { nk_bool bDown = (pEvent->type == SDL_EVENT_KEY_DOWN) ? nk_true : nk_false; SDL_Keymod mod = SDL_GetModState(); switch (pEvent->key.key) { - case SDLK_BACKSPACE: nk_input_key(pCtx, NK_KEY_BACKSPACE, bDown); break; - case SDLK_DELETE: nk_input_key(pCtx, NK_KEY_DEL, bDown); break; + case SDLK_BACKSPACE: + nk_input_key(pCtx, NK_KEY_BACKSPACE, bDown); + break; + case SDLK_DELETE: + nk_input_key(pCtx, NK_KEY_DEL, bDown); + break; case SDLK_RETURN: - case SDLK_RETURN2: nk_input_key(pCtx, NK_KEY_ENTER, bDown); break; + case SDLK_RETURN2: + nk_input_key(pCtx, NK_KEY_ENTER, bDown); + break; case SDLK_LEFT: - nk_input_key(pCtx, (mod & SDL_KMOD_CTRL) ? NK_KEY_TEXT_WORD_LEFT : NK_KEY_LEFT, bDown); + nk_input_key(pCtx, + (mod & SDL_KMOD_CTRL) ? NK_KEY_TEXT_WORD_LEFT : NK_KEY_LEFT, + bDown); break; case SDLK_RIGHT: - nk_input_key(pCtx, (mod & SDL_KMOD_CTRL) ? NK_KEY_TEXT_WORD_RIGHT : NK_KEY_RIGHT, bDown); + nk_input_key( + pCtx, (mod & SDL_KMOD_CTRL) ? NK_KEY_TEXT_WORD_RIGHT : NK_KEY_RIGHT, + bDown); + break; + case SDLK_HOME: + nk_input_key(pCtx, NK_KEY_TEXT_LINE_START, bDown); + break; + case SDLK_END: + nk_input_key(pCtx, NK_KEY_TEXT_LINE_END, bDown); break; - case SDLK_HOME: nk_input_key(pCtx, NK_KEY_TEXT_LINE_START, bDown); break; - case SDLK_END: nk_input_key(pCtx, NK_KEY_TEXT_LINE_END, bDown); break; case SDLK_LSHIFT: - case SDLK_RSHIFT: nk_input_key(pCtx, NK_KEY_SHIFT, bDown); break; + case SDLK_RSHIFT: + nk_input_key(pCtx, NK_KEY_SHIFT, bDown); + break; case SDLK_A: - if (mod & SDL_KMOD_CTRL) nk_input_key(pCtx, NK_KEY_TEXT_SELECT_ALL, bDown); + if (mod & SDL_KMOD_CTRL) + nk_input_key(pCtx, NK_KEY_TEXT_SELECT_ALL, bDown); + break; + default: break; - default: break; } } else if (pEvent->type == SDL_EVENT_TEXT_INPUT) { for (const char *pCh = pEvent->text.text; *pCh; pCh++) @@ -495,8 +560,7 @@ void debug_overlay_handle_event(DebugOverlay *pOverlay, SDL_Event *pEvent) { // UI panels // --------------------------------------------------------------------------- -static void DrawNetworkAdapterCombo(DebugOverlay *pOverlay) -{ +static void DrawNetworkAdapterCombo(DebugOverlay *pOverlay) { struct nk_context *pCtx = &pOverlay->nk; // Adapter combobox — build display list: "Auto" + one entry per interface @@ -515,7 +579,8 @@ static void DrawNetworkAdapterCombo(DebugOverlay *pOverlay) } nk_layout_row_dynamic(pCtx, 20, 1); - int iNewSel = nk_combo(pCtx, apszDisplay, iTotal, iCurSel, 20, nk_vec2(LEFT_W - 20, 150)); + int iNewSel = nk_combo(pCtx, apszDisplay, iTotal, iCurSel, 20, + nk_vec2(LEFT_W - 20, 150)); if (iNewSel != iCurSel) { if (iNewSel == 0) { pOverlay->szNetLocalIP[0] = '\0'; @@ -543,15 +608,21 @@ static void DrawDebugPanel(DebugOverlay *pOverlay) { nk_layout_row_dynamic(pCtx, 8, 1); nk_spacing(pCtx, 1); - static const char *apszMusic[] = { "MIDI", "CD" }; + static const char *apszMusic[] = {"MIDI", "CD"}; int iMusicSel = (MusicCD != 0) ? 1 : 0; nk_layout_row_dynamic(pCtx, 20, 2); nk_label(pCtx, "Music", NK_TEXT_LEFT); - int iNewMusicSel = nk_combo(pCtx, apszMusic, 2, iMusicSel, 20, nk_vec2(100, 60)); + int iNewMusicSel = + nk_combo(pCtx, apszMusic, 2, iMusicSel, 20, nk_vec2(100, 60)); if (iNewMusicSel != iMusicSel) { stopmusic(); - if (iNewMusicSel == 1) { MusicCD = -1; MusicCard = 0; } - else { MusicCD = 0; MusicCard = -1; } + if (iNewMusicSel == 1) { + MusicCD = -1; + MusicCard = 0; + } else { + MusicCD = 0; + MusicCard = -1; + } startmusic(g_iCurrentSong); } @@ -570,7 +641,8 @@ static void DrawDebugPanel(DebugOverlay *pOverlay) { int bGPU = (menu_render_get_mode(pRenderer) == MENU_RENDER_GPU); nk_layout_row_dynamic(pCtx, 20, 1); if (nk_checkbox_label(pCtx, "Hardware rendering", &bGPU)) - menu_render_set_mode(pRenderer, bGPU ? MENU_RENDER_GPU : MENU_RENDER_SOFTWARE); + menu_render_set_mode(pRenderer, + bGPU ? MENU_RENDER_GPU : MENU_RENDER_SOFTWARE); } int bForceMaxDraw = (int)g_bForceMaxDraw; @@ -600,15 +672,14 @@ static void DrawDebugPanel(DebugOverlay *pOverlay) { static void DrawLogPanel(DebugOverlay *pOverlay) { struct nk_context *pCtx = &pOverlay->nk; - if (nk_begin(pCtx, "Log", - nk_rect(RIGHT_X, PANEL_MARGIN, RIGHT_W, PANEL_H), + if (nk_begin(pCtx, "Log", nk_rect(RIGHT_X, PANEL_MARGIN, RIGHT_W, PANEL_H), NK_WINDOW_BORDER | NK_WINDOW_TITLE)) { nk_layout_row_dynamic(pCtx, PANEL_H - 50, 1); if (nk_group_begin(pCtx, "log_inner", NK_WINDOW_BORDER)) { nk_layout_row_dynamic(pCtx, LOG_ROW_H, 1); SDL_LockMutex(pOverlay->pLogMutex); int iCount = pOverlay->iLogCount; - int iHead = pOverlay->iLogHead; + int iHead = pOverlay->iLogHead; for (int iI = 0; iI < iCount; iI++) { int iIdx = (iHead + iI) % MAX_LOG_MESSAGES; nk_label(pCtx, pOverlay->aLogEntries[iIdx].szText, NK_TEXT_LEFT); @@ -624,11 +695,11 @@ static void DrawLogPanel(DebugOverlay *pOverlay) { // Render // --------------------------------------------------------------------------- -void debug_overlay_render(DebugOverlay *pOverlay, - SDL_GPUCommandBuffer *pCmdBuf, - SDL_GPUTexture *pSwapchainTex, - Uint32 uiSwapchainW, Uint32 uiSwapchainH) { - if (!pOverlay || !pOverlay->bVisible) return; +void debug_overlay_render(DebugOverlay *pOverlay, SDL_GPUCommandBuffer *pCmdBuf, + SDL_GPUTexture *pSwapchainTex, Uint32 uiSwapchainW, + Uint32 uiSwapchainH) { + if (!pOverlay || !pOverlay->bVisible) + return; struct nk_context *pCtx = &pOverlay->nk; // Close input bracket (open it first if no events arrived this frame) @@ -644,16 +715,18 @@ void debug_overlay_render(DebugOverlay *pOverlay, RenderCommands(pOverlay); UploadAndBlit(pOverlay, pCmdBuf); - if (!pOverlay->pPipeline || !pOverlay->pSampler) return; + if (!pOverlay->pPipeline || !pOverlay->pSampler) + return; SDL_GPUColorTargetInfo ct = {0}; - ct.texture = pSwapchainTex; - ct.load_op = SDL_GPU_LOADOP_LOAD; - ct.store_op = SDL_GPU_STOREOP_STORE; + ct.texture = pSwapchainTex; + ct.load_op = SDL_GPU_LOADOP_LOAD; + ct.store_op = SDL_GPU_STOREOP_STORE; SDL_GPURenderPass *pRp = SDL_BeginGPURenderPass(pCmdBuf, &ct, 1, NULL); SDL_BindGPUGraphicsPipeline(pRp, pOverlay->pPipeline); - SDL_GPUTextureSamplerBinding binding = { .texture = pOverlay->pTexture, .sampler = pOverlay->pSampler }; + SDL_GPUTextureSamplerBinding binding = {.texture = pOverlay->pTexture, + .sampler = pOverlay->pSampler}; SDL_BindGPUFragmentSamplers(pRp, 0, &binding, 1); SDL_DrawGPUPrimitives(pRp, 3, 1, 0, 0); SDL_EndGPURenderPass(pRp); diff --git a/PROJECTS/ROLLER/debug_overlay.h b/PROJECTS/ROLLER/debug_overlay.h index cbce6a0f..04f0d307 100644 --- a/PROJECTS/ROLLER/debug_overlay.h +++ b/PROJECTS/ROLLER/debug_overlay.h @@ -6,15 +6,14 @@ typedef struct DebugOverlay DebugOverlay; DebugOverlay *debug_overlay_create(SDL_GPUDevice *pDevice, SDL_Window *pWindow); -void debug_overlay_destroy(DebugOverlay *pOverlay); +void debug_overlay_destroy(DebugOverlay *pOverlay); bool debug_overlay_is_visible(DebugOverlay *pOverlay); void debug_overlay_toggle(DebugOverlay *pOverlay); void debug_overlay_handle_event(DebugOverlay *pOverlay, SDL_Event *pEvent); -void debug_overlay_render(DebugOverlay *pOverlay, - SDL_GPUCommandBuffer *pCmdBuf, - SDL_GPUTexture *pSwapchainTex, - Uint32 uiSwapchainW, Uint32 uiSwapchainH); +void debug_overlay_render(DebugOverlay *pOverlay, SDL_GPUCommandBuffer *pCmdBuf, + SDL_GPUTexture *pSwapchainTex, Uint32 uiSwapchainW, + Uint32 uiSwapchainH); #endif diff --git a/PROJECTS/ROLLER/debug_overlay_shaders.h b/PROJECTS/ROLLER/debug_overlay_shaders.h index a8dd7727..414c5a01 100644 --- a/PROJECTS/ROLLER/debug_overlay_shaders.h +++ b/PROJECTS/ROLLER/debug_overlay_shaders.h @@ -1,16 +1,227 @@ #ifndef DEBUG_OVERLAY_SHADERS_H #define DEBUG_OVERLAY_SHADERS_H -static const unsigned char overlay_vertex_spirv[] = {0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x36, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x70, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x70, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; +static const unsigned char overlay_vertex_spirv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, + 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, + 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x2b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x2b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, + 0x36, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x05, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x70, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, + 0x38, 0x00, 0x01, 0x00}; static const unsigned int overlay_vertex_spirv_size = 748; -static const unsigned char overlay_vertex_msl[] = {0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x75, 0x69, 0x6e, 0x74, 0x20, 0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x5b, 0x5b, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x64, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x32, 0x32, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x28, 0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x26, 0x20, 0x31, 0x75, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x32, 0x35, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x28, 0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3e, 0x3e, 0x20, 0x31, 0x75, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x28, 0x5f, 0x32, 0x32, 0x20, 0x2a, 0x20, 0x34, 0x2e, 0x30, 0x29, 0x20, 0x2d, 0x20, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x5f, 0x32, 0x35, 0x20, 0x2a, 0x20, 0x34, 0x2e, 0x30, 0x29, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x5f, 0x32, 0x32, 0x20, 0x2a, 0x20, 0x32, 0x2e, 0x30, 0x2c, 0x20, 0x5f, 0x32, 0x35, 0x20, 0x2a, 0x20, 0x32, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; +static const unsigned char overlay_vertex_msl[] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, + 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, + 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, + 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, + 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, + 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, + 0x72, 0x74, 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, + 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x75, 0x69, 0x6e, + 0x74, 0x20, 0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x20, 0x5b, 0x5b, 0x76, 0x65, 0x72, 0x74, 0x65, + 0x78, 0x5f, 0x69, 0x64, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, + 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x32, 0x32, 0x20, + 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x28, 0x67, 0x6c, 0x5f, 0x56, + 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x26, + 0x20, 0x31, 0x75, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, + 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x32, 0x35, 0x20, 0x3d, 0x20, 0x66, 0x6c, + 0x6f, 0x61, 0x74, 0x28, 0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, + 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3e, 0x3e, 0x20, 0x31, 0x75, + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, + 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x28, 0x5f, 0x32, 0x32, + 0x20, 0x2a, 0x20, 0x34, 0x2e, 0x30, 0x29, 0x20, 0x2d, 0x20, 0x31, 0x2e, + 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x28, 0x5f, 0x32, + 0x35, 0x20, 0x2a, 0x20, 0x34, 0x2e, 0x30, 0x29, 0x2c, 0x20, 0x30, 0x2e, + 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, + 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x3d, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x5f, 0x32, 0x32, 0x20, + 0x2a, 0x20, 0x32, 0x2e, 0x30, 0x2c, 0x20, 0x5f, 0x32, 0x35, 0x20, 0x2a, + 0x20, 0x32, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, + 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, + 0x0a, 0x0a}; static const unsigned int overlay_vertex_msl_size = 506; -static const unsigned char overlay_pixel_spirv[] = {0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x32, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x12, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x57, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; +static const unsigned char overlay_pixel_spirv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x32, 0x64, 0x2e, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x54, + 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x53, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, + 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x57, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, + 0x38, 0x00, 0x01, 0x00}; static const unsigned int overlay_pixel_spirv_size = 772; -static const unsigned char overlay_pixel_msl[] = {0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; +static const unsigned char overlay_pixel_msl[] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, + 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, + 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, + 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, + 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, + 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, + 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, + 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, + 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, + 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, + 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, + 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, + 0x5d, 0x5d, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, + 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x6f, 0x76, 0x65, + 0x72, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, + 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, + 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, + 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x53, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, + 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, + 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, + 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x3d, + 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x54, 0x65, 0x78, 0x74, + 0x75, 0x72, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x6f, + 0x76, 0x65, 0x72, 0x6c, 0x61, 0x79, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x72, 0x2c, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, + 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x29, 0x3b, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, + 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; static const unsigned int overlay_pixel_msl_size = 476; #endif diff --git a/PROJECTS/ROLLER/drawtrk3.c b/PROJECTS/ROLLER/drawtrk3.c index d0a593d8..66d8f509 100644 --- a/PROJECTS/ROLLER/drawtrk3.c +++ b/PROJECTS/ROLLER/drawtrk3.c @@ -16,122 +16,122 @@ #include //------------------------------------------------------------------------------------------------- -int showsub = 0; //000A34A0 -int view_limit = 0; //000A41B8 -int divtype = 0; //000A41BC -int NextSect[MAX_TRACK_CHUNKS]; //00143BF4 -int tex_hgt; //00144464 -int polyysize; //00144468 -int polyxsize; //0014446C -uint8 *subptr; //00144474 -int fliptype; //00144478 -int subpolytype; //0014447C -tPolyParams *subpoly; //00144480 -int tex_wid; //00144484 -int flatpol; //00144488 -tPolyParams RoofPoly; //0014448C -tPolyParams G5Poly; //001444B8 -tPolyParams G4Poly; //001444E4 -tPolyParams G3Poly; //00144510 -tPolyParams G2Poly; //0014453C -tPolyParams G1Poly; //00144568 -tPolyParams RWallPoly;//00144594 -tPolyParams LWallPoly;//001445C0 -tPolyParams RightPoly;//001445EC -tPolyParams LeftPoly; //00144618 -tPolyParams RoadPoly; //00144644 -int start_sect; //00144670 -int gap_size; //00144674 -int first_size; //00144678 -int TrackSize; //0014467C -int backwards; //00144684 -int next_front; //00144684 -int mid_sec; //00144688 -int back_sec; //0014468C -int front_sec; //00144690 -int VisibleHumans; //00144694 -int min_sub_size; //00144698 -int NamesLeft; //0014469C -int CarsLeft; //001446A0 -int VisibleCars; //001446A4 -int num_pols; //001446A8 -int small_poly; //001446AC -int num_bits; //001446B0 +int showsub = 0; // 000A34A0 +int view_limit = 0; // 000A41B8 +int divtype = 0; // 000A41BC +int NextSect[MAX_TRACK_CHUNKS]; // 00143BF4 +int tex_hgt; // 00144464 +int polyysize; // 00144468 +int polyxsize; // 0014446C +uint8 *subptr; // 00144474 +int fliptype; // 00144478 +int subpolytype; // 0014447C +tPolyParams *subpoly; // 00144480 +int tex_wid; // 00144484 +int flatpol; // 00144488 +tPolyParams RoofPoly; // 0014448C +tPolyParams G5Poly; // 001444B8 +tPolyParams G4Poly; // 001444E4 +tPolyParams G3Poly; // 00144510 +tPolyParams G2Poly; // 0014453C +tPolyParams G1Poly; // 00144568 +tPolyParams RWallPoly; // 00144594 +tPolyParams LWallPoly; // 001445C0 +tPolyParams RightPoly; // 001445EC +tPolyParams LeftPoly; // 00144618 +tPolyParams RoadPoly; // 00144644 +int start_sect; // 00144670 +int gap_size; // 00144674 +int first_size; // 00144678 +int TrackSize; // 0014467C +int backwards; // 00144684 +int next_front; // 00144684 +int mid_sec; // 00144688 +int back_sec; // 0014468C +int front_sec; // 00144690 +int VisibleHumans; // 00144694 +int min_sub_size; // 00144698 +int NamesLeft; // 0014469C +int CarsLeft; // 001446A0 +int VisibleCars; // 001446A4 +int num_pols; // 001446A8 +int small_poly; // 001446AC +int num_bits; // 001446B0 //------------------------------------------------------------------------------------------------- -//0001D740 -int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) -{ - int iCurrChunk; // esi - int iSearchRadius; // edi - int iDefaultOffset; // ebp - int iSearchIdx; // ebx - int iChunkIdx2; // edx - tData *pDataAy; // eax - double dDeltaX; // st4 - double dDeltaXSquared; // st7 - double dDeltaY; // st4 - double dDeltaZ; // st6 - double dLengthSquared; // st7 - int iNextChunk; // eax +// 0001D740 +int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) { + int iCurrChunk; // esi + int iSearchRadius; // edi + int iDefaultOffset; // ebp + int iSearchIdx; // ebx + int iChunkIdx2; // edx + tData *pDataAy; // eax + double dDeltaX; // st4 + double dDeltaXSquared; // st7 + double dDeltaY; // st4 + double dDeltaZ; // st6 + double dLengthSquared; // st7 + int iNextChunk; // eax tData *pNextChunkDataAy; // edx tData *pCurrChunkDataAy; // eax - double fDeltaX; // st7 - double fDeltaY; // st6 - uint8 byExtraChunks; // al - int iFrontWithOffset; // esi - int result; // eax - float fViewAlignment; // [esp+20h] [ebp-38h] - int iHasExtraView; // [esp+28h] [ebp-30h] - int iViewOffset; // [esp+2Ch] [ebp-2Ch] - int iExtraViewStart; // [esp+30h] [ebp-28h] - int iChunkIdx; // [esp+34h] [ebp-24h] - float fMinDistSq; // [esp+38h] [ebp-20h] - float fLengthSquared; // [esp+3Ch] [ebp-1Ch] + double fDeltaX; // st7 + double fDeltaY; // st6 + uint8 byExtraChunks; // al + int iFrontWithOffset; // esi + int result; // eax + float fViewAlignment; // [esp+20h] [ebp-38h] + int iHasExtraView; // [esp+28h] [ebp-30h] + int iViewOffset; // [esp+2Ch] [ebp-2Ch] + int iExtraViewStart; // [esp+30h] [ebp-28h] + int iChunkIdx; // [esp+34h] [ebp-24h] + float fMinDistSq; // [esp+38h] [ebp-20h] + float fLengthSquared; // [esp+3Ch] [ebp-1Ch] // Init tex coords set_starts(0); // Init rendering params - TrackSize = -1; // number of track chunks to render - iExtraViewStart = -1; // start of extra view range (for tunnels?) - iCurrChunk = Car[iCarIdx].nCurrChunk; // current track chunk the car is on + TrackSize = -1; // number of track chunks to render + iExtraViewStart = -1; // start of extra view range (for tunnels?) + iCurrChunk = Car[iCarIdx].nCurrChunk; // current track chunk the car is on iHasExtraView = 0; // Set starting chunk idx based on whether the car is on track if (iCurrChunk == -1) - iChunkIdx = Car[iCarIdx].iLastValidChunk; // use last valid chunk if off-track + iChunkIdx = + Car[iCarIdx].iLastValidChunk; // use last valid chunk if off-track else iChunkIdx = Car[iCarIdx].nCurrChunk; - alltrackflag = 0; // flag for rendering entire track + alltrackflag = 0; // flag for rendering entire track // Set view params based on view mode switch (uiViewMode) { - case 2u: // near view (chase cam close) - iSearchRadius = 24; - iDefaultOffset = -4; - iCurrChunk = -1; // force search for nearest chunk - goto LABEL_10; - case 3u: // far view (chase cam far) - iSearchRadius = 96; - iViewOffset = -8; - iCurrChunk = -1; // force search for nearest chunk - break; - case 4u: // in-car view - iSearchRadius = 32; - iViewOffset = -16; - break; - case 6u: // helicopter/top-down view - iSearchRadius = 96; - iCurrChunk = -1; // force search for nearest chunk - iViewOffset = -4; - break; - default: // default view - iDefaultOffset = -1; - iSearchRadius = 4; - LABEL_10: - iViewOffset = iDefaultOffset; - break; + case 2u: // near view (chase cam close) + iSearchRadius = 24; + iDefaultOffset = -4; + iCurrChunk = -1; // force search for nearest chunk + goto LABEL_10; + case 3u: // far view (chase cam far) + iSearchRadius = 96; + iViewOffset = -8; + iCurrChunk = -1; // force search for nearest chunk + break; + case 4u: // in-car view + iSearchRadius = 32; + iViewOffset = -16; + break; + case 6u: // helicopter/top-down view + iSearchRadius = 96; + iCurrChunk = -1; // force search for nearest chunk + iViewOffset = -4; + break; + default: // default view + iDefaultOffset = -1; + iSearchRadius = 4; + LABEL_10: + iViewOffset = iDefaultOffset; + break; } // Calculate view alignment with track direction @@ -141,7 +141,8 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) } else { // Search for nearest track chunk to camera pos iSearchIdx = -iSearchRadius; - for (fMinDistSq = 9.9999998e17f; iSearchIdx <= iSearchRadius; ++iSearchIdx) { + for (fMinDistSq = 9.9999998e17f; iSearchIdx <= iSearchRadius; + ++iSearchIdx) { // Wrap chunk idx around track iChunkIdx2 = iSearchIdx + iChunkIdx; if (iSearchIdx + iChunkIdx < 0) @@ -151,7 +152,7 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) // Calculate distance from camera to chunk center point pDataAy = &localdata[iChunkIdx2]; - dDeltaX = -pDataAy->pointAy[3].fX - viewx;// point 3 is center of chunk + dDeltaX = -pDataAy->pointAy[3].fX - viewx; // point 3 is center of chunk dDeltaXSquared = dDeltaX * dDeltaX; dDeltaY = -pDataAy->pointAy[3].fY - viewy; dDeltaZ = -pDataAy->pointAy[3].fZ - viewz; @@ -178,47 +179,50 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) fDeltaY = pCurrChunkDataAy->pointAy[3].fY - pNextChunkDataAy->pointAy[3].fY; // Calculate dot product of track dir with world view dir (normalized) - fViewAlignment = (float)((fDeltaX * tcos[worlddirn] + fDeltaY * tsin[worlddirn]) - / (sqrt(tcos[worlddirn] * tcos[worlddirn] + tsin[worlddirn] * tsin[worlddirn]) - + sqrt(fDeltaY * fDeltaY + fDeltaX * fDeltaX))); + fViewAlignment = + (float)((fDeltaX * tcos[worlddirn] + fDeltaY * tsin[worlddirn]) / + (sqrt(tcos[worlddirn] * tcos[worlddirn] + + tsin[worlddirn] * tsin[worlddirn]) + + sqrt(fDeltaY * fDeltaY + fDeltaX * fDeltaX))); } // Check if view is perpendicular to track (inside corner or similar) // This triggers special rendering for better visibility - if (fViewAlignment < 0.3 - && fViewAlignment >= -0.3 - && ((TrakColour[iCurrChunk][TRAK_COLOUR_LEFT_LANE] & SURFACE_FLAG_SKIP_RENDER) == 0// SURFACE_FLAG_SKIP_RENDER - || (TrakColour[iCurrChunk][TRAK_COLOUR_CENTER] & SURFACE_FLAG_SKIP_RENDER) == 0 - || (TrakColour[iCurrChunk][TRAK_COLOUR_RIGHT_LANE] & SURFACE_FLAG_SKIP_RENDER) == 0)) { - // Extend view range when looking perpendicular to track + if (fViewAlignment < 0.3 && fViewAlignment >= -0.3 && + ((TrakColour[iCurrChunk][TRAK_COLOUR_LEFT_LANE] & + SURFACE_FLAG_SKIP_RENDER) == 0 // SURFACE_FLAG_SKIP_RENDER + || (TrakColour[iCurrChunk][TRAK_COLOUR_CENTER] & + SURFACE_FLAG_SKIP_RENDER) == 0 || + (TrakColour[iCurrChunk][TRAK_COLOUR_RIGHT_LANE] & + SURFACE_FLAG_SKIP_RENDER) == 0)) { + // Extend view range when looking perpendicular to track if (uiViewMode >= 3 && (uiViewMode <= 3 || uiViewMode == 6)) { - TrackSize = 48; // render 48 chunks - iViewOffset = -24; // center view 24 chunks back + TrackSize = 48; // render 48 chunks + iViewOffset = -24; // center view 24 chunks back } else { - TrackSize = 24; // render 24 chunks - iViewOffset = -12; // center view 12 chunks back + TrackSize = 24; // render 24 chunks + iViewOffset = -12; // center view 12 chunks back } } - test_y1 = iCurrChunk; // debug variable + test_y1 = iCurrChunk; // debug variable backwards = (fViewAlignment >= 0.0) - 1; - - //added by ROLLER to force maximum draw distance - //if (g_bForceMaxDraw) { - // byForwardMainChunks = 255; - // nForwardExtraStart = -1; - // byForwardExtraChunks = 0; - // byBackwardMainChunks = 255; - // nBackwardExtraStart = -1; - // byBackwardExtraChunks = 0; - //} + // added by ROLLER to force maximum draw distance + // if (g_bForceMaxDraw) { + // byForwardMainChunks = 255; + // nForwardExtraStart = -1; + // byForwardExtraChunks = 0; + // byBackwardMainChunks = 255; + // nBackwardExtraStart = -1; + // byBackwardExtraChunks = 0; + // } // Load pre-calculated view ranges from track data if (iCurrChunk >= 0 && TrackSize < 0) { - if (backwards) // looking backward along track + if (backwards) // looking backward along track { - if (g_bForceMaxDraw) { //added by ROLLER for max draw distance + if (g_bForceMaxDraw) { // added by ROLLER for max draw distance TrackSize = 255 - iViewOffset; iExtraViewStart = -1; byExtraChunks = 0; @@ -227,7 +231,7 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) iExtraViewStart = TrakView[iCurrChunk].nBackwardExtraStart; byExtraChunks = TrakView[iCurrChunk].byBackwardExtraChunks; } - } else // looking forward along track + } else // looking forward along track { if (g_bForceMaxDraw) { TrackSize = 255 - iViewOffset; @@ -243,20 +247,21 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) } // Apply view distance limits for certain game modes - if ((view_limit || player_type == 2) && replaytype != 2 && !winner_mode && !g_bForceMaxDraw) { + if ((view_limit || player_type == 2) && replaytype != 2 && !winner_mode && + !g_bForceMaxDraw) { iHasExtraView = 0; iExtraViewStart = -1; if (player_type == 2) { if (TrackSize > 28) TrackSize = 28; } else if (TrackSize > view_limit) { - TrackSize = view_limit; // user-defined limit? + TrackSize = view_limit; // user-defined limit? } } // Handle mirror view or special view mode if (mirror || uiViewMode == 1) - backwards = backwards == 0; // flip view direction + backwards = backwards == 0; // flip view direction // Calculate track section ranges for rendering if (backwards) { @@ -293,7 +298,7 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) next_front = -1; test_y1 = -2; mid_sec = -1; - gap_size = 6 * TRAK_LEN; // large value to disable gap + gap_size = 6 * TRAK_LEN; // large value to disable gap } // Recalculate total track size @@ -310,9 +315,9 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) mid_sec = -1; first_size = TrackSize; next_front = -1; - gap_size = 6 * TRAK_LEN; // large value to disable gap + gap_size = 6 * TRAK_LEN; // large value to disable gap } - } else // looking forward + } else // looking forward { // Calculate front section with offset front_sec = iCurrChunk + iViewOffset; @@ -336,7 +341,7 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) next_front = iExtraViewStart; } else { // Overlap detected, merge ranges - gap_size = 6 * TRAK_LEN; // large value to disable gap + gap_size = 6 * TRAK_LEN; // large value to disable gap next_front = -1; front_sec = iExtraViewStart; test_y1 = -1; @@ -363,7 +368,7 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) mid_sec = -1; first_size = TrackSize; next_front = -1; - gap_size = 6 * TRAK_LEN; // large value to disable gap + gap_size = 6 * TRAK_LEN; // large value to disable gap } } @@ -380,673 +385,746 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -// World-space vertex builders — three winding patterns (forward, cross_first, reverse) -// reading from the caller-provided point array (tGroundPt or tTrakPt). +// World-space vertex builders — three winding patterns (forward, cross_first, +// reverse) reading from the caller-provided point array (tGroundPt or tTrakPt). // Forward: NEXT[ptA], CUR[ptA], CUR[ptB], NEXT[ptB] -static void world_verts_forward(GameRenderVertex *verts, - const tGroundPt *src, int nextSec, int curSec, int ptA, int ptB) -{ - const tGroundPt *n = &src[nextSec]; - const tGroundPt *c = &src[curSec]; - verts[0].x = n->pointAy[ptA].fX; verts[0].y = n->pointAy[ptA].fY; verts[0].z = n->pointAy[ptA].fZ; - verts[1].x = c->pointAy[ptA].fX; verts[1].y = c->pointAy[ptA].fY; verts[1].z = c->pointAy[ptA].fZ; - verts[2].x = c->pointAy[ptB].fX; verts[2].y = c->pointAy[ptB].fY; verts[2].z = c->pointAy[ptB].fZ; - verts[3].x = n->pointAy[ptB].fX; verts[3].y = n->pointAy[ptB].fY; verts[3].z = n->pointAy[ptB].fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; +static void world_verts_forward(GameRenderVertex *verts, const tGroundPt *src, + int nextSec, int curSec, int ptA, int ptB) { + const tGroundPt *n = &src[nextSec]; + const tGroundPt *c = &src[curSec]; + verts[0].x = n->pointAy[ptA].fX; + verts[0].y = n->pointAy[ptA].fY; + verts[0].z = n->pointAy[ptA].fZ; + verts[1].x = c->pointAy[ptA].fX; + verts[1].y = c->pointAy[ptA].fY; + verts[1].z = c->pointAy[ptA].fZ; + verts[2].x = c->pointAy[ptB].fX; + verts[2].y = c->pointAy[ptB].fY; + verts[2].z = c->pointAy[ptB].fZ; + verts[3].x = n->pointAy[ptB].fX; + verts[3].y = n->pointAy[ptB].fY; + verts[3].z = n->pointAy[ptB].fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } // Cross-first: NEXT[ptA], NEXT[ptB], CUR[ptB], CUR[ptA] static void world_verts_cross_first(GameRenderVertex *verts, - const tGroundPt *src, int nextSec, int curSec, int ptA, int ptB) -{ - const tGroundPt *n = &src[nextSec]; - const tGroundPt *c = &src[curSec]; - verts[0].x = n->pointAy[ptA].fX; verts[0].y = n->pointAy[ptA].fY; verts[0].z = n->pointAy[ptA].fZ; - verts[1].x = n->pointAy[ptB].fX; verts[1].y = n->pointAy[ptB].fY; verts[1].z = n->pointAy[ptB].fZ; - verts[2].x = c->pointAy[ptB].fX; verts[2].y = c->pointAy[ptB].fY; verts[2].z = c->pointAy[ptB].fZ; - verts[3].x = c->pointAy[ptA].fX; verts[3].y = c->pointAy[ptA].fY; verts[3].z = c->pointAy[ptA].fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; + const tGroundPt *src, int nextSec, + int curSec, int ptA, int ptB) { + const tGroundPt *n = &src[nextSec]; + const tGroundPt *c = &src[curSec]; + verts[0].x = n->pointAy[ptA].fX; + verts[0].y = n->pointAy[ptA].fY; + verts[0].z = n->pointAy[ptA].fZ; + verts[1].x = n->pointAy[ptB].fX; + verts[1].y = n->pointAy[ptB].fY; + verts[1].z = n->pointAy[ptB].fZ; + verts[2].x = c->pointAy[ptB].fX; + verts[2].y = c->pointAy[ptB].fY; + verts[2].z = c->pointAy[ptB].fZ; + verts[3].x = c->pointAy[ptA].fX; + verts[3].y = c->pointAy[ptA].fY; + verts[3].z = c->pointAy[ptA].fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } // Reverse: CUR[ptA], NEXT[ptA], NEXT[ptB], CUR[ptB] -static void world_verts_reverse(GameRenderVertex *verts, - const tGroundPt *src, int nextSec, int curSec, int ptA, int ptB) -{ - const tGroundPt *n = &src[nextSec]; - const tGroundPt *c = &src[curSec]; - verts[0].x = c->pointAy[ptA].fX; verts[0].y = c->pointAy[ptA].fY; verts[0].z = c->pointAy[ptA].fZ; - verts[1].x = n->pointAy[ptA].fX; verts[1].y = n->pointAy[ptA].fY; verts[1].z = n->pointAy[ptA].fZ; - verts[2].x = n->pointAy[ptB].fX; verts[2].y = n->pointAy[ptB].fY; verts[2].z = n->pointAy[ptB].fZ; - verts[3].x = c->pointAy[ptB].fX; verts[3].y = c->pointAy[ptB].fY; verts[3].z = c->pointAy[ptB].fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; +static void world_verts_reverse(GameRenderVertex *verts, const tGroundPt *src, + int nextSec, int curSec, int ptA, int ptB) { + const tGroundPt *n = &src[nextSec]; + const tGroundPt *c = &src[curSec]; + verts[0].x = c->pointAy[ptA].fX; + verts[0].y = c->pointAy[ptA].fY; + verts[0].z = c->pointAy[ptA].fZ; + verts[1].x = n->pointAy[ptA].fX; + verts[1].y = n->pointAy[ptA].fY; + verts[1].z = n->pointAy[ptA].fZ; + verts[2].x = n->pointAy[ptB].fX; + verts[2].y = n->pointAy[ptB].fY; + verts[2].z = n->pointAy[ptB].fZ; + verts[3].x = c->pointAy[ptB].fX; + verts[3].y = c->pointAy[ptB].fY; + verts[3].z = c->pointAy[ptB].fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } -static const tVec3 *ground_world_point(int sec, int pt) -{ - if (GroundColour[sec][GROUND_COLOUR_OFLOOR] == -2 && TrackScreenXYZ[sec].iClipCount != 99) { - if (pt == 2) return &TrakPt[sec].pointAy[0]; - if (pt == 3) return &TrakPt[sec].pointAy[4]; - } - return &GroundPt[sec].pointAy[pt]; +static const tVec3 *ground_world_point(int sec, int pt) { + if (GroundColour[sec][GROUND_COLOUR_OFLOOR] == -2 && + TrackScreenXYZ[sec].iClipCount != 99) { + if (pt == 2) + return &TrakPt[sec].pointAy[0]; + if (pt == 3) + return &TrakPt[sec].pointAy[4]; + } + return &GroundPt[sec].pointAy[pt]; } -static void world_verts_ground_forward(GameRenderVertex *verts, - int nextSec, int curSec, int ptA, int ptB) -{ - const tVec3 *nA = ground_world_point(nextSec, ptA); - const tVec3 *cA = ground_world_point(curSec, ptA); - const tVec3 *cB = ground_world_point(curSec, ptB); - const tVec3 *nB = ground_world_point(nextSec, ptB); - verts[0].x = nA->fX; verts[0].y = nA->fY; verts[0].z = nA->fZ; - verts[1].x = cA->fX; verts[1].y = cA->fY; verts[1].z = cA->fZ; - verts[2].x = cB->fX; verts[2].y = cB->fY; verts[2].z = cB->fZ; - verts[3].x = nB->fX; verts[3].y = nB->fY; verts[3].z = nB->fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; +static void world_verts_ground_forward(GameRenderVertex *verts, int nextSec, + int curSec, int ptA, int ptB) { + const tVec3 *nA = ground_world_point(nextSec, ptA); + const tVec3 *cA = ground_world_point(curSec, ptA); + const tVec3 *cB = ground_world_point(curSec, ptB); + const tVec3 *nB = ground_world_point(nextSec, ptB); + verts[0].x = nA->fX; + verts[0].y = nA->fY; + verts[0].z = nA->fZ; + verts[1].x = cA->fX; + verts[1].y = cA->fY; + verts[1].z = cA->fZ; + verts[2].x = cB->fX; + verts[2].y = cB->fY; + verts[2].z = cB->fZ; + verts[3].x = nB->fX; + verts[3].y = nB->fY; + verts[3].z = nB->fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } -static void world_verts_ground_cross_first(GameRenderVertex *verts, - int nextSec, int curSec, int ptA, int ptB) -{ - const tVec3 *nA = ground_world_point(nextSec, ptA); - const tVec3 *nB = ground_world_point(nextSec, ptB); - const tVec3 *cB = ground_world_point(curSec, ptB); - const tVec3 *cA = ground_world_point(curSec, ptA); - verts[0].x = nA->fX; verts[0].y = nA->fY; verts[0].z = nA->fZ; - verts[1].x = nB->fX; verts[1].y = nB->fY; verts[1].z = nB->fZ; - verts[2].x = cB->fX; verts[2].y = cB->fY; verts[2].z = cB->fZ; - verts[3].x = cA->fX; verts[3].y = cA->fY; verts[3].z = cA->fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; +static void world_verts_ground_cross_first(GameRenderVertex *verts, int nextSec, + int curSec, int ptA, int ptB) { + const tVec3 *nA = ground_world_point(nextSec, ptA); + const tVec3 *nB = ground_world_point(nextSec, ptB); + const tVec3 *cB = ground_world_point(curSec, ptB); + const tVec3 *cA = ground_world_point(curSec, ptA); + verts[0].x = nA->fX; + verts[0].y = nA->fY; + verts[0].z = nA->fZ; + verts[1].x = nB->fX; + verts[1].y = nB->fY; + verts[1].z = nB->fZ; + verts[2].x = cB->fX; + verts[2].y = cB->fY; + verts[2].z = cB->fZ; + verts[3].x = cA->fX; + verts[3].y = cA->fY; + verts[3].z = cA->fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } -// Master's CalcVisibleTrack picks screenPtAy[4]'s world-space source via a 3-way -// conditional on adjacent left-wall presence: pointAy[1] when both current and -// previous sections have a left wall, else pointAy[0] when both wall types are -// non-negative, else pointAy[2]. The fallback collapses the wall top to the -// wall base at discontinuities so no stray geometry is drawn. -static int left_wall_top_pt_idx(int sec) -{ - int prevSec = sec ? sec - 1 : TRAK_LEN - 1; - int curLW = TrakColour[sec][TRAK_COLOUR_LEFT_WALL]; - int prevLW = TrakColour[prevSec][TRAK_COLOUR_LEFT_WALL]; - if (curLW && prevLW) return 1; - if (curLW >= 0 && prevLW >= 0) return 0; - return 2; +// Master's CalcVisibleTrack picks screenPtAy[4]'s world-space source via a +// 3-way conditional on adjacent left-wall presence: pointAy[1] when both +// current and previous sections have a left wall, else pointAy[0] when both +// wall types are non-negative, else pointAy[2]. The fallback collapses the wall +// top to the wall base at discontinuities so no stray geometry is drawn. +static int left_wall_top_pt_idx(int sec) { + int prevSec = sec ? sec - 1 : TRAK_LEN - 1; + int curLW = TrakColour[sec][TRAK_COLOUR_LEFT_WALL]; + int prevLW = TrakColour[prevSec][TRAK_COLOUR_LEFT_WALL]; + if (curLW && prevLW) + return 1; + if (curLW >= 0 && prevLW >= 0) + return 0; + return 2; } // Left-wall forward quad: top vertex (v[0], v[1]) is chosen per-section by // left_wall_top_pt_idx; bottom vertex (v[2], v[3]) uses ptBottom (0 = low wall, // 2 = high wall). Mirrors master's case 0/8 LWallPoly construction. -static void world_verts_left_wall(GameRenderVertex *verts, - int nextSec, int curSec, int ptBottom) -{ - int nextTop = left_wall_top_pt_idx(nextSec); - int curTop = left_wall_top_pt_idx(curSec); - const tGroundPt *n = &TrakPt[nextSec]; - const tGroundPt *c = &TrakPt[curSec]; - verts[0].x = n->pointAy[nextTop].fX; verts[0].y = n->pointAy[nextTop].fY; verts[0].z = n->pointAy[nextTop].fZ; - verts[1].x = c->pointAy[curTop].fX; verts[1].y = c->pointAy[curTop].fY; verts[1].z = c->pointAy[curTop].fZ; - verts[2].x = c->pointAy[ptBottom].fX; verts[2].y = c->pointAy[ptBottom].fY; verts[2].z = c->pointAy[ptBottom].fZ; - verts[3].x = n->pointAy[ptBottom].fX; verts[3].y = n->pointAy[ptBottom].fY; verts[3].z = n->pointAy[ptBottom].fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; +static void world_verts_left_wall(GameRenderVertex *verts, int nextSec, + int curSec, int ptBottom) { + int nextTop = left_wall_top_pt_idx(nextSec); + int curTop = left_wall_top_pt_idx(curSec); + const tGroundPt *n = &TrakPt[nextSec]; + const tGroundPt *c = &TrakPt[curSec]; + verts[0].x = n->pointAy[nextTop].fX; + verts[0].y = n->pointAy[nextTop].fY; + verts[0].z = n->pointAy[nextTop].fZ; + verts[1].x = c->pointAy[curTop].fX; + verts[1].y = c->pointAy[curTop].fY; + verts[1].z = c->pointAy[curTop].fZ; + verts[2].x = c->pointAy[ptBottom].fX; + verts[2].y = c->pointAy[ptBottom].fY; + verts[2].z = c->pointAy[ptBottom].fZ; + verts[3].x = n->pointAy[ptBottom].fX; + verts[3].y = n->pointAy[ptBottom].fY; + verts[3].z = n->pointAy[ptBottom].fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } -// Symmetric to left_wall_top_pt_idx — selects screenPtAy[5]'s world-space source -// for the right wall: pointAy[5] when both adjacent RW types are non-zero, else -// pointAy[4] when both are non-negative, else pointAy[3]. -static int right_wall_top_pt_idx(int sec) -{ - int prevSec = sec ? sec - 1 : TRAK_LEN - 1; - int curRW = TrakColour[sec][TRAK_COLOUR_RIGHT_WALL]; - int prevRW = TrakColour[prevSec][TRAK_COLOUR_RIGHT_WALL]; - if (curRW && prevRW) return 5; - if (curRW >= 0 && prevRW >= 0) return 4; - return 3; +// Symmetric to left_wall_top_pt_idx — selects screenPtAy[5]'s world-space +// source for the right wall: pointAy[5] when both adjacent RW types are +// non-zero, else pointAy[4] when both are non-negative, else pointAy[3]. +static int right_wall_top_pt_idx(int sec) { + int prevSec = sec ? sec - 1 : TRAK_LEN - 1; + int curRW = TrakColour[sec][TRAK_COLOUR_RIGHT_WALL]; + int prevRW = TrakColour[prevSec][TRAK_COLOUR_RIGHT_WALL]; + if (curRW && prevRW) + return 5; + if (curRW >= 0 && prevRW >= 0) + return 4; + return 3; } // Right-wall reverse quad: top vertex (v[0], v[1]) chosen per-section; bottom // vertex (v[2], v[3]) uses ptBottom (4 = low wall, 3 = high wall). Mirrors // master's case 1/9 RWallPoly construction with reverse winding. -static void world_verts_right_wall(GameRenderVertex *verts, - int nextSec, int curSec, int ptBottom) -{ - int nextTop = right_wall_top_pt_idx(nextSec); - int curTop = right_wall_top_pt_idx(curSec); - const tGroundPt *n = &TrakPt[nextSec]; - const tGroundPt *c = &TrakPt[curSec]; - verts[0].x = c->pointAy[curTop].fX; verts[0].y = c->pointAy[curTop].fY; verts[0].z = c->pointAy[curTop].fZ; - verts[1].x = n->pointAy[nextTop].fX; verts[1].y = n->pointAy[nextTop].fY; verts[1].z = n->pointAy[nextTop].fZ; - verts[2].x = n->pointAy[ptBottom].fX; verts[2].y = n->pointAy[ptBottom].fY; verts[2].z = n->pointAy[ptBottom].fZ; - verts[3].x = c->pointAy[ptBottom].fX; verts[3].y = c->pointAy[ptBottom].fY; verts[3].z = c->pointAy[ptBottom].fZ; - verts[0].u = 0; verts[0].v = 0; - verts[1].u = 0; verts[1].v = 0; - verts[2].u = 0; verts[2].v = 0; - verts[3].u = 0; verts[3].v = 0; +static void world_verts_right_wall(GameRenderVertex *verts, int nextSec, + int curSec, int ptBottom) { + int nextTop = right_wall_top_pt_idx(nextSec); + int curTop = right_wall_top_pt_idx(curSec); + const tGroundPt *n = &TrakPt[nextSec]; + const tGroundPt *c = &TrakPt[curSec]; + verts[0].x = c->pointAy[curTop].fX; + verts[0].y = c->pointAy[curTop].fY; + verts[0].z = c->pointAy[curTop].fZ; + verts[1].x = n->pointAy[nextTop].fX; + verts[1].y = n->pointAy[nextTop].fY; + verts[1].z = n->pointAy[nextTop].fZ; + verts[2].x = n->pointAy[ptBottom].fX; + verts[2].y = n->pointAy[ptBottom].fY; + verts[2].z = n->pointAy[ptBottom].fZ; + verts[3].x = c->pointAy[ptBottom].fX; + verts[3].y = c->pointAy[ptBottom].fY; + verts[3].z = c->pointAy[ptBottom].fZ; + verts[0].u = 0; + verts[0].v = 0; + verts[1].u = 0; + verts[1].v = 0; + verts[2].u = 0; + verts[2].v = 0; + verts[3].u = 0; + verts[3].v = 0; } -static void draw_start_light_cube_world(GameRenderer *renderer, - const tSLight *light, - int countdownValue, - int worldDirection, - const GameRenderCamera *camera, - const GameRenderProjection *projection) -{ - static const int cubeFaces[6][4] = { - { 0, 1, 2, 3 }, - { 4, 5, 6, 7 }, - { 3, 2, 6, 7 }, - { 0, 3, 7, 4 }, - { 1, 2, 6, 5 }, - { 0, 1, 5, 4 }, - }; - static const float cubeCorners[8][3] = { - { -100.0f, 100.0f, -100.0f }, - { -100.0f, -100.0f, -100.0f }, - { 100.0f, -100.0f, -100.0f }, - { 100.0f, 100.0f, -100.0f }, - { -100.0f, 100.0f, 100.0f }, - { -100.0f, -100.0f, 100.0f }, - { 100.0f, -100.0f, 100.0f }, - { 100.0f, 100.0f, 100.0f }, - }; +static void +draw_start_light_cube_world(GameRenderer *renderer, const tSLight *light, + int countdownValue, int worldDirection, + const GameRenderCamera *camera, + const GameRenderProjection *projection) { + static const int cubeFaces[6][4] = { + {0, 1, 2, 3}, {4, 5, 6, 7}, {3, 2, 6, 7}, + {0, 3, 7, 4}, {1, 2, 6, 5}, {0, 1, 5, 4}, + }; + static const float cubeCorners[8][3] = { + {-100.0f, 100.0f, -100.0f}, {-100.0f, -100.0f, -100.0f}, + {100.0f, -100.0f, -100.0f}, {100.0f, 100.0f, -100.0f}, + {-100.0f, 100.0f, 100.0f}, {-100.0f, -100.0f, 100.0f}, + {100.0f, -100.0f, 100.0f}, {100.0f, 100.0f, 100.0f}, + }; + + if (!renderer || !light || !camera || !projection) + return; + + int lightYaw = ((int16)light->uiRotation + (int16)worldDirection) & 0x3FFF; + float sinZero = tsin[0]; + float cosZero = tcos[0]; + float basisX0 = tcos[lightYaw] * cosZero; + float basisY0 = tsin[lightYaw] * cosZero; + double cosYaw = tcos[lightYaw]; + float basisZ0 = sinZero; + double cosYawSinZero = cosYaw * sinZero; + float basisX1 = (float)cosYawSinZero * sinZero - basisY0; + double sinYawSinZero = tsin[lightYaw] * sinZero; + float basisY1 = (float)sinYawSinZero * sinZero + basisX0; + float basisZ1 = -sinZero * cosZero; + float basisX2 = -tcos[lightYaw] * sinZero * cosZero - (float)sinYawSinZero; + float basisY2 = (float)cosYawSinZero + -tsin[lightYaw] * sinZero * cosZero; + float basisZ2 = cosZero * cosZero; + + GameRenderVertex cubeVerts[8]; + float cubeDepth[8]; + for (int i = 0; i < 8; i++) { + float sx = cubeCorners[i][0]; + float sy = cubeCorners[i][1]; + float sz = cubeCorners[i][2]; + cubeVerts[i].x = + sx * basisX0 + sy * basisX1 + sz * basisX2 + light->currentPos.fX; + cubeVerts[i].y = + sx * basisY0 + sy * basisY1 + sz * basisY2 + light->currentPos.fY; + cubeVerts[i].z = + sx * basisZ0 + sy * basisZ1 + sz * basisZ2 + light->currentPos.fZ; + cubeVerts[i].u = 0.0f; + cubeVerts[i].v = 0.0f; + + double depth = (cubeVerts[i].x - camera->viewX) * projection->view[0][2] + + (cubeVerts[i].y - camera->viewY) * projection->view[1][2] + + (cubeVerts[i].z - camera->viewZ) * projection->view[2][2]; + cubeDepth[i] = (float)(int)round(depth); + } - if (!renderer || !light || !camera || !projection) - return; - - int lightYaw = ((int16)light->uiRotation + (int16)worldDirection) & 0x3FFF; - float sinZero = tsin[0]; - float cosZero = tcos[0]; - float basisX0 = tcos[lightYaw] * cosZero; - float basisY0 = tsin[lightYaw] * cosZero; - double cosYaw = tcos[lightYaw]; - float basisZ0 = sinZero; - double cosYawSinZero = cosYaw * sinZero; - float basisX1 = (float)cosYawSinZero * sinZero - basisY0; - double sinYawSinZero = tsin[lightYaw] * sinZero; - float basisY1 = (float)sinYawSinZero * sinZero + basisX0; - float basisZ1 = -sinZero * cosZero; - float basisX2 = -tcos[lightYaw] * sinZero * cosZero - (float)sinYawSinZero; - float basisY2 = (float)cosYawSinZero + -tsin[lightYaw] * sinZero * cosZero; - float basisZ2 = cosZero * cosZero; - - GameRenderVertex cubeVerts[8]; - float cubeDepth[8]; - for (int i = 0; i < 8; i++) { - float sx = cubeCorners[i][0]; - float sy = cubeCorners[i][1]; - float sz = cubeCorners[i][2]; - cubeVerts[i].x = sx * basisX0 + sy * basisX1 + sz * basisX2 + light->currentPos.fX; - cubeVerts[i].y = sx * basisY0 + sy * basisY1 + sz * basisY2 + light->currentPos.fY; - cubeVerts[i].z = sx * basisZ0 + sy * basisZ1 + sz * basisZ2 + light->currentPos.fZ; - cubeVerts[i].u = 0.0f; - cubeVerts[i].v = 0.0f; - - double depth = (cubeVerts[i].x - camera->viewX) * projection->view[0][2] - + (cubeVerts[i].y - camera->viewY) * projection->view[1][2] - + (cubeVerts[i].z - camera->viewZ) * projection->view[2][2]; - cubeDepth[i] = (float)(int)round(depth); - } + int surfaceFlags; + if (countdownValue >= 0) { + surfaceFlags = countdownValue >= 72 ? 0x2101 : 0x2102; + } else { + surfaceFlags = 0x2103; + } - int surfaceFlags; - if (countdownValue >= 0) { - surfaceFlags = countdownValue >= 72 ? 0x2101 : 0x2102; - } else { - surfaceFlags = 0x2103; - } + TextureHandle texture = + (surfaceFlags & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(renderer, TEXTURE_BANK_CARGEN) + : TEXTURE_HANDLE_INVALID; - TextureHandle texture = (surfaceFlags & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(renderer, TEXTURE_BANK_CARGEN) - : TEXTURE_HANDLE_INVALID; + float faceDepth[6]; + for (int i = 0; i < 6; i++) { + faceDepth[i] = (cubeDepth[cubeFaces[i][0]] + cubeDepth[cubeFaces[i][1]] + + cubeDepth[cubeFaces[i][2]] + cubeDepth[cubeFaces[i][3]]) * + 0.25f; + } - float faceDepth[6]; - for (int i = 0; i < 6; i++) { - faceDepth[i] = (cubeDepth[cubeFaces[i][0]] - + cubeDepth[cubeFaces[i][1]] - + cubeDepth[cubeFaces[i][2]] - + cubeDepth[cubeFaces[i][3]]) * 0.25f; + set_starts(0); + for (int drawCount = 0; drawCount < 6; drawCount++) { + int face = 0; + float maxDepth = faceDepth[0]; + for (int i = 1; i < 6; i++) { + if (faceDepth[i] > (double)maxDepth) { + face = i; + maxDepth = faceDepth[i]; + } } + faceDepth[face] = -9.9999998e17f; - set_starts(0); - for (int drawCount = 0; drawCount < 6; drawCount++) { - int face = 0; - float maxDepth = faceDepth[0]; - for (int i = 1; i < 6; i++) { - if (faceDepth[i] > (double)maxDepth) { - face = i; - maxDepth = faceDepth[i]; - } - } - faceDepth[face] = -9.9999998e17f; - - GameRenderVertex faceVerts[4] = { - cubeVerts[cubeFaces[face][0]], - cubeVerts[cubeFaces[face][1]], - cubeVerts[cubeFaces[face][2]], - cubeVerts[cubeFaces[face][3]], - }; - game_render_quad_world(renderer, faceVerts, texture, surfaceFlags, 1.0f); - } + GameRenderVertex faceVerts[4] = { + cubeVerts[cubeFaces[face][0]], + cubeVerts[cubeFaces[face][1]], + cubeVerts[cubeFaces[face][2]], + cubeVerts[cubeFaces[face][3]], + }; + game_render_quad_world(renderer, faceVerts, texture, surfaceFlags, 1.0f); + } } - //------------------------------------------------------------------------------------------------- -//0001DE40 +// 0001DE40 void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, const GameRenderCamera *camera, - const GameRenderProjection *projection) -{ - tTrackScreenXYZ *pScreenCoord; // ebp - tTrackScreenXYZ *pScreenCoord_1; // edi - int iCurrentTrackIndex; // ecx - tVec3 *pCurrentTrackPt; // eax + const GameRenderProjection *projection) { + tTrackScreenXYZ *pScreenCoord; // ebp + tTrackScreenXYZ *pScreenCoord_1; // edi + int iCurrentTrackIndex; // ecx + tVec3 *pCurrentTrackPt; // eax tTrackScreenXYZ *pCurrentTrackScreenXYZ; // edx - tVec3 *pTrackPoint4; // esi - tVec3 *pTrackPoint3; // ebx - double dDeltaX1; // st7 - double dDeltaY1; // st6 - double dDeltaZ1; // st5 - double dCameraZ1; // st7 - double dViewDistance1; // st7 - double dInvZ1; // st6 - double dScreenX1; // st5 - double dScreenY1; // st7 - //int iScreenX1; // eax - int iScreenY1; // eax - double dDeltaX2; // st7 - double dDeltaY2; // st6 - double dDeltaZ2; // st5 - double dCameraZ2; // st7 + tVec3 *pTrackPoint4; // esi + tVec3 *pTrackPoint3; // ebx + double dDeltaX1; // st7 + double dDeltaY1; // st6 + double dDeltaZ1; // st5 + double dCameraZ1; // st7 + double dViewDistance1; // st7 + double dInvZ1; // st6 + double dScreenX1; // st5 + double dScreenY1; // st7 + // int iScreenX1; // eax + int iScreenY1; // eax + double dDeltaX2; // st7 + double dDeltaY2; // st6 + double dDeltaZ2; // st5 + double dCameraZ2; // st7 double dViewDistance2; // st7 - double dInvZ2; // st6 - double dScreenX2; // st5 - double dScreenY2; // st7 - ///int iScreenX2; // eax - int iScreenY2; // eax - double dDeltaX3; // st7 - double dDeltaY3; // st6 - double dDeltaZ3; // st5 - double dCameraZ3; // st7 - int iClipIncrement3; // eax + double dInvZ2; // st6 + double dScreenX2; // st5 + double dScreenY2; // st7 + /// int iScreenX2; // eax + int iScreenY2; // eax + double dDeltaX3; // st7 + double dDeltaY3; // st6 + double dDeltaZ3; // st5 + double dCameraZ3; // st7 + int iClipIncrement3; // eax double dViewDistance3; // st7 - double dInvZ3; // st6 - double dScreenX3; // st5 - double dScreenY3; // st7 - //int iScreenX3; // eax - int iScreenY3; // eax - double dDeltaX4; // st7 - double dDeltaY4; // st6 - double dDeltaZ4; // st5 - double dCameraZ4; // st7 - int iClipIncrement4; // eax + double dInvZ3; // st6 + double dScreenX3; // st5 + double dScreenY3; // st7 + // int iScreenX3; // eax + int iScreenY3; // eax + double dDeltaX4; // st7 + double dDeltaY4; // st6 + double dDeltaZ4; // st5 + double dCameraZ4; // st7 + int iClipIncrement4; // eax double dViewDistance4; // st7 - double dInvZ4; // st6 - double dScreenX4; // st5 - double dScreenY4; // st7 - int iScrSize; // ebx - //int iScreenX4; // eax - int *pLeftWallTypePtr; // esi - int iPrevSectionIndex; // eax + double dInvZ4; // st6 + double dScreenX4; // st5 + double dScreenY4; // st7 + int iScrSize; // ebx + // int iScreenX4; // eax + int *pLeftWallTypePtr; // esi + int iPrevSectionIndex; // eax int *pPrevLeftWallTypePtr; // ebx - tGroundPt *pGroundPt; // eax - double dLeftWallDeltaX; // st7 - double dLeftWallDeltaY; // st6 - double dLeftWallDeltaZ; // st5 - double dLeftWallCameraZ; // st7 - double dLeftWallViewDist; // st7 - double dLeftWallInvZ; // st6 - double dLeftWallScreenX; // st5 - double dLeftWallScreenY; // st7 - //int iLeftWallScreenX; // eax - int iLeftWallScreenY; // eax - double dLeftWallCopyZ; // st7 - int iLeftWallCopyY; // eax - tGroundPt *pGroundPt2; // eax - double dRightWallDeltaX; // st7 - double dRightWallDeltaY; // st6 - double dRightWallDeltaZ; // st5 - double dRightWallCameraZ; // st7 + tGroundPt *pGroundPt; // eax + double dLeftWallDeltaX; // st7 + double dLeftWallDeltaY; // st6 + double dLeftWallDeltaZ; // st5 + double dLeftWallCameraZ; // st7 + double dLeftWallViewDist; // st7 + double dLeftWallInvZ; // st6 + double dLeftWallScreenX; // st5 + double dLeftWallScreenY; // st7 + // int iLeftWallScreenX; // eax + int iLeftWallScreenY; // eax + double dLeftWallCopyZ; // st7 + int iLeftWallCopyY; // eax + tGroundPt *pGroundPt2; // eax + double dRightWallDeltaX; // st7 + double dRightWallDeltaY; // st6 + double dRightWallDeltaZ; // st5 + double dRightWallCameraZ; // st7 double dRightWallViewDist; // st7 - double dRightWallInvZ; // st6 - double dRightWallScreenX; // st5 - double dRightWallScreenY; // st7 - int iRightWallScrSize; // ebx - //int iRightWallScreenX; // eax - int iRightWallScreenY; // eax - double dRightWallDepthCopy; // st7 - int iRightWallCopy; // eax + double dRightWallInvZ; // st6 + double dRightWallScreenX; // st5 + double dRightWallScreenY; // st7 + int iRightWallScrSize; // ebx + // int iRightWallScreenX; // eax + int iRightWallScreenY; // eax + double dRightWallDepthCopy; // st7 + int iRightWallCopy; // eax tTrackScreenXYZ *pGroundScreenXYZ; // eax - tScreenPt *pScreenPoint; // esi - tGroundPt *pCurrentGroundPt; // edx - int iPrevGroundIndex; // eax - int iGroundPointIndex; // ebx - double dGroundDeltaX; // st7 - double dGroundDeltaY; // st6 - float *pGroundPointZ; // edx - double dGroundDeltaZ; // st5 - double dGroundCameraZ; // st7 - double dGroundViewDist; // st7 - double dGroundInvZ; // st6 - double dGroundScreenX; // st5 - double dGroundScreenY; // st7 - //int iGroundScreenX; // eax + tScreenPt *pScreenPoint; // esi + tGroundPt *pCurrentGroundPt; // edx + int iPrevGroundIndex; // eax + int iGroundPointIndex; // ebx + double dGroundDeltaX; // st7 + double dGroundDeltaY; // st6 + float *pGroundPointZ; // edx + double dGroundDeltaZ; // st5 + double dGroundCameraZ; // st7 + double dGroundViewDist; // st7 + double dGroundInvZ; // st6 + double dGroundScreenX; // st5 + double dGroundScreenY; // st7 + // int iGroundScreenX; // eax int iGroundScreenY; // eax - //int iGroundSectionOffset; // eax + // int iGroundSectionOffset; // eax float fGroundProjectedZ; // ecx - //int iGroundSectionOffset2; // eax + // int iGroundSectionOffset2; // eax int iTrackLoopCounter; // ecx - int iCurrentSect; // esi - //int iSectionOffset; // edx - int iOFloorType; // edx - bool bFloorVisible; // eax - int iCurrentFloorType; // ebx - float fGroundDepthMax1; // eax - float fGroundDepthMax2; // eax - float fGroundDepthSelected; // eax - int iTrackIndexPlus2; // eax - tTrackScreenXYZ *pTrackScreenPlus2; // edx - float fTrackDepthChoice1; // eax - float fTrackDepthChoice2; // eax - float fTrackDepthFinal; // eax - tTrackZOrderEntry *pGroundRenderCmd; // eax - float fGroundRenderDepth; // edx - int iGroundRenderIndex; // ebx - float fRoadCenterDepthMax1; // eax - float fRoadCenterDepthMax2; // eax - float fRoadCenterDepthSelected; // eax - tTrackZOrderEntry *pRoadCenterCmd; // eax - float fRoadCenterCmdDepth; // edx - int iRoadCenterCmdIndex; // ebx - float fLeftRoadDepthMax1; // eax - float fLeftRoadDepthMax2; // eax - float fLeftRoadDepthSelected; // eax - tTrackZOrderEntry *pLeftRoadCmd; // eax - float fLeftRoadCmdDepth; // edx - int iLeftRoadCmdIndex; // ebx - float fRightRoadDepthMax1; // eax - float fRightRoadDepthMax2; // eax - float fRightRoadDepthSelected; // eax - tTrackZOrderEntry *pRightRoadCmd; // eax - float fRightRoadCmdDepth; // edx - int iRightRoadCmdIndex; // ebx - int iRoofTypeCheck; // eax - float fRoof1OuterDepth; // eax - float fRoof1InnerDepth; // eax - float fRoof1SelectedDepth; // eax - tTrackZOrderEntry *pRoof1RenderCmd; // eax - float fRoof1CmdDepth; // edx - int iRoofType; // ebx - double dRoof2WallDepth1; // st7 - double dRoof2WallDepth2; // st7 - float fRoof2WallMinDepth; // eax - float fRoof2SelectedDepth; // eax - tTrackZOrderEntry *pRoof2RenderCmd; // eax - float fRoof2CmdDepth; // edx - float fRoof3OuterDepth; // eax - float fRoof3InnerDepth; // eax - float fRoof3SelectedDepth; // eax - int iRoof3CmdIndex; // ebx - float fLeftLowerWallDepth1; // eax - float fLeftLowerWallDepth2; // eax - float fLeftLowerWallSelected; // eax - tTrackZOrderEntry *pLeftLowerWallCmd; // eax - float fLeftLowerWallCmdDepth; // edx - float fRightLowerWallDepth1; // eax - float fRightLowerWallDepth2; // eax - float fRightLowerWallSelected; // eax - tTrackZOrderEntry *pRightLowerWallCmd; // eax - float fRightLowerWallCmdDepth; // edx - float fLeftWallDepthMax1; // eax - float fLeftWallDepthMax2; // eax - float fLeftWallDepthSelected; // eax - tTrackZOrderEntry *pLeftWallCmd; // eax - int iLeftWallCmdIndex; // edx - float fRightWallDepthMax1; // eax - float fRightWallDepthMax2; // eax - float fRightWallDepthSelected; // eax - tTrackZOrderEntry *pRightWallCmd; // eax - float fRightWallCmdDepth; // edx - float fRightWallBasicDepth1; // eax - float fRightWallBasicDepth2; // eax - float fRightWallBasicSelected; // eax - tTrackZOrderEntry *pRightWallBasicCmd; // eax - float fRightWallBasicCmdDepth; // edx - int iRightWallBasicCmdIndex; // ebx - float fRightWallRoofDepth1; // eax - float fRightWallRoofDepth2; // eax - float fRightWallRoofSelected; // eax - tTrackZOrderEntry *pRightWallRoofCmd; // eax - int iRightWallRoofCmdIndex; // edx - int iCarIndex; // esi - int iCarArrayIndex; // ebx - tTrackZOrderEntry *pCarRenderCmd; // eax - int iCarDrawOrderStatus; // edx - float iCarDrawOrderIndex; // edx - int iCarCommandIdx; // edx - int iCarProcessingFlag; // ecx - int iCarsRenderedCount; // esi - int iCarLoopIndex; // ebx - unsigned int uiCarIndexOffset; // edx - int iCarStatusFlag; // ecx - int iCarVisibilityCount; // esi - int iNamesDisplayCount; // eax - tVisibleBuilding *pVisibleBuildingsPtr; // ebx - tTrackZOrderEntry *pBuildingRenderCmd; // edx - int iLightIndex; // ebx - tTrackZOrderEntry *pLightRenderCmd; // ecx - int iLightArrayOffset; // edx - float fLightDepth; // eax - int iLightCmdIndex; // esi - tTrackZOrderEntry *pRenderCommand; // eax + int iCurrentSect; // esi + // int iSectionOffset; // edx + int iOFloorType; // edx + bool bFloorVisible; // eax + int iCurrentFloorType; // ebx + float fGroundDepthMax1; // eax + float fGroundDepthMax2; // eax + float fGroundDepthSelected; // eax + int iTrackIndexPlus2; // eax + tTrackScreenXYZ *pTrackScreenPlus2; // edx + float fTrackDepthChoice1; // eax + float fTrackDepthChoice2; // eax + float fTrackDepthFinal; // eax + tTrackZOrderEntry *pGroundRenderCmd; // eax + float fGroundRenderDepth; // edx + int iGroundRenderIndex; // ebx + float fRoadCenterDepthMax1; // eax + float fRoadCenterDepthMax2; // eax + float fRoadCenterDepthSelected; // eax + tTrackZOrderEntry *pRoadCenterCmd; // eax + float fRoadCenterCmdDepth; // edx + int iRoadCenterCmdIndex; // ebx + float fLeftRoadDepthMax1; // eax + float fLeftRoadDepthMax2; // eax + float fLeftRoadDepthSelected; // eax + tTrackZOrderEntry *pLeftRoadCmd; // eax + float fLeftRoadCmdDepth; // edx + int iLeftRoadCmdIndex; // ebx + float fRightRoadDepthMax1; // eax + float fRightRoadDepthMax2; // eax + float fRightRoadDepthSelected; // eax + tTrackZOrderEntry *pRightRoadCmd; // eax + float fRightRoadCmdDepth; // edx + int iRightRoadCmdIndex; // ebx + int iRoofTypeCheck; // eax + float fRoof1OuterDepth; // eax + float fRoof1InnerDepth; // eax + float fRoof1SelectedDepth; // eax + tTrackZOrderEntry *pRoof1RenderCmd; // eax + float fRoof1CmdDepth; // edx + int iRoofType; // ebx + double dRoof2WallDepth1; // st7 + double dRoof2WallDepth2; // st7 + float fRoof2WallMinDepth; // eax + float fRoof2SelectedDepth; // eax + tTrackZOrderEntry *pRoof2RenderCmd; // eax + float fRoof2CmdDepth; // edx + float fRoof3OuterDepth; // eax + float fRoof3InnerDepth; // eax + float fRoof3SelectedDepth; // eax + int iRoof3CmdIndex; // ebx + float fLeftLowerWallDepth1; // eax + float fLeftLowerWallDepth2; // eax + float fLeftLowerWallSelected; // eax + tTrackZOrderEntry *pLeftLowerWallCmd; // eax + float fLeftLowerWallCmdDepth; // edx + float fRightLowerWallDepth1; // eax + float fRightLowerWallDepth2; // eax + float fRightLowerWallSelected; // eax + tTrackZOrderEntry *pRightLowerWallCmd; // eax + float fRightLowerWallCmdDepth; // edx + float fLeftWallDepthMax1; // eax + float fLeftWallDepthMax2; // eax + float fLeftWallDepthSelected; // eax + tTrackZOrderEntry *pLeftWallCmd; // eax + int iLeftWallCmdIndex; // edx + float fRightWallDepthMax1; // eax + float fRightWallDepthMax2; // eax + float fRightWallDepthSelected; // eax + tTrackZOrderEntry *pRightWallCmd; // eax + float fRightWallCmdDepth; // edx + float fRightWallBasicDepth1; // eax + float fRightWallBasicDepth2; // eax + float fRightWallBasicSelected; // eax + tTrackZOrderEntry *pRightWallBasicCmd; // eax + float fRightWallBasicCmdDepth; // edx + int iRightWallBasicCmdIndex; // ebx + float fRightWallRoofDepth1; // eax + float fRightWallRoofDepth2; // eax + float fRightWallRoofSelected; // eax + tTrackZOrderEntry *pRightWallRoofCmd; // eax + int iRightWallRoofCmdIndex; // edx + int iCarIndex; // esi + int iCarArrayIndex; // ebx + tTrackZOrderEntry *pCarRenderCmd; // eax + int iCarDrawOrderStatus; // edx + float iCarDrawOrderIndex; // edx + int iCarCommandIdx; // edx + int iCarProcessingFlag; // ecx + int iCarsRenderedCount; // esi + int iCarLoopIndex; // ebx + unsigned int uiCarIndexOffset; // edx + int iCarStatusFlag; // ecx + int iCarVisibilityCount; // esi + int iNamesDisplayCount; // eax + tVisibleBuilding *pVisibleBuildingsPtr; // ebx + tTrackZOrderEntry *pBuildingRenderCmd; // edx + int iLightIndex; // ebx + tTrackZOrderEntry *pLightRenderCmd; // ecx + int iLightArrayOffset; // edx + float fLightDepth; // eax + int iLightCmdIndex; // esi + tTrackZOrderEntry *pRenderCommand; // eax const RenderCommand3D *pTypedRenderCommand; // eax - int iSectionNum; // esi - int iSectionCommand; // eax - float iSectionTypeIndex; // eax - float fSurfaceDepth1; // eax - float fSurfaceDepth2; // eax - float fSurfaceDepth3; // eax - float fSurfaceDepth4; // eax - float fSurfaceDepth5; // eax - int iCenterSurfType; // eax - float fObjectDepth1; // eax - float fObjectDepth2; // eax - float fObjectDepth3; // eax - float fObjectDepth4; // eax - float fObjectDepth5; // eax - float fObjectDepth6; // eax - int iLeftSurfType; // eax - //int iObjectCommandType; // edx + int iSectionNum; // esi + int iSectionCommand; // eax + float iSectionTypeIndex; // eax + float fSurfaceDepth1; // eax + float fSurfaceDepth2; // eax + float fSurfaceDepth3; // eax + float fSurfaceDepth4; // eax + float fSurfaceDepth5; // eax + int iCenterSurfType; // eax + float fObjectDepth1; // eax + float fObjectDepth2; // eax + float fObjectDepth3; // eax + float fObjectDepth4; // eax + float fObjectDepth5; // eax + float fObjectDepth6; // eax + int iLeftSurfType; // eax + // int iObjectCommandType; // edx float fMiddleDepth1; // eax float fMiddleDepth2; // eax float fMiddleDepth3; // eax float fMiddleDepth4; // eax float fMiddleDepth5; // eax float fMiddleDepth6; // eax - int iRightSurfType; // eax - //int iMiddleCommandType; // edx + int iRightSurfType; // eax + // int iMiddleCommandType; // edx float fRightDepth1; // eax float fRightDepth2; // eax float fRightDepth3; // eax float fRightDepth4; // eax float fRightDepth5; // eax float fRightDepth6; // eax - int iLeftWallType; // eax - //char byLeftWallFlag; // dl + int iLeftWallType; // eax + // char byLeftWallFlag; // dl float fRoof1InnerDepthAlt; // eax - float fWallDepthZ; // eax - float fWallZDepthAlt; // eax - float fWallInnerDepth; // eax - float fWallDepthZ_1; // eax - float fWallLeftDepth1; // eax - float fWallLeftDepth2; // eax - float fWallLeftDepth3; // eax - float fWallLeftDepth4; // eax - float fWallLeftDepth5; // eax - float fWallLeftDepth6; // eax - float fWallLeftDepth7; // eax - int iRightWallType; // eax - //char byRightWallFlag; // bl + float fWallDepthZ; // eax + float fWallZDepthAlt; // eax + float fWallInnerDepth; // eax + float fWallDepthZ_1; // eax + float fWallLeftDepth1; // eax + float fWallLeftDepth2; // eax + float fWallLeftDepth3; // eax + float fWallLeftDepth4; // eax + float fWallLeftDepth5; // eax + float fWallLeftDepth6; // eax + float fWallLeftDepth7; // eax + int iRightWallType; // eax + // char byRightWallFlag; // bl float fRightWallGeomDepth1; // eax float fRightWallGeomDepth2; // eax float fRightWallGeomDepth3; // eax float fRightWallGeomDepth4; // eax float fRightWallGeomDepth5; // eax float fRightWallGeomDepth6; // eax - //char byWallTypeFlag; // bh - float fGeometryDepth1; // eax - float fGeometryDepth2; // eax - float fGeometryDepth3; // eax - float fGeometryDepth4; // eax - float fGeometryDepth5; // eax - float fGeometryDepth6; // eax - int iGeometryIndex; // eax - int iProcessingIndex; // edx - float fComputedDepth1; // eax - float fRenderValue1; // eax - float fRenderValue2; // eax - float fRenderValue3; // eax - float fRenderValue4; // eax - float fRenderValue5; // eax - int iRenderCommandIndex; // ebx - int iScreenYCoord; // eax - float fTrackDepth1; // eax - float fTrackDepth2; // eax - float fTrackDepth3; // eax - float fTrackDepth4; // eax - float fTrackDepth5; // eax - float fTrackDepth6; // eax - float fTrackDepth7; // eax - float fTrackDepth8; // eax - float fTrackDepth9; // eax - float fTrackDepth10; // eax - float fTrackDepth11; // eax - float fTrackDepth12; // eax - float fTrackDepth13; // eax - float fTrackDepth14; // eax - float fTrackDepth15; // eax - float fTrackDepth16; // eax - float fTrackDepth17; // eax - float fTrackDepth18; // eax - float fTrackDepth19; // eax - float fTrackDepth20; // eax - float fTrackDepth21; // eax - tTrackScreenXYZ *pTrackScreenPtr1; // eax - tTrackScreenXYZ *pTrackScreenPtr2; // eax - tTrackScreenXYZ *pTrackScreenPtr3; // eax - float fScreenDepth1; // eax - tTrackScreenXYZ *pTrackScreenPtr4; // eax - tTrackScreenXYZ *pTrackScreenPtr5; // eax - tTrackScreenXYZ *pTrackScreenPtr6; // eax - tTrackScreenXYZ *pTrackScreenPtr7; // eax - float fScreenDepth2; // eax - tTrackScreenXYZ *pTrackScreenPtr8; // eax - tTrackScreenXYZ *pTrackScreenPtr9; // eax + // char byWallTypeFlag; // bh + float fGeometryDepth1; // eax + float fGeometryDepth2; // eax + float fGeometryDepth3; // eax + float fGeometryDepth4; // eax + float fGeometryDepth5; // eax + float fGeometryDepth6; // eax + int iGeometryIndex; // eax + int iProcessingIndex; // edx + float fComputedDepth1; // eax + float fRenderValue1; // eax + float fRenderValue2; // eax + float fRenderValue3; // eax + float fRenderValue4; // eax + float fRenderValue5; // eax + int iRenderCommandIndex; // ebx + int iScreenYCoord; // eax + float fTrackDepth1; // eax + float fTrackDepth2; // eax + float fTrackDepth3; // eax + float fTrackDepth4; // eax + float fTrackDepth5; // eax + float fTrackDepth6; // eax + float fTrackDepth7; // eax + float fTrackDepth8; // eax + float fTrackDepth9; // eax + float fTrackDepth10; // eax + float fTrackDepth11; // eax + float fTrackDepth12; // eax + float fTrackDepth13; // eax + float fTrackDepth14; // eax + float fTrackDepth15; // eax + float fTrackDepth16; // eax + float fTrackDepth17; // eax + float fTrackDepth18; // eax + float fTrackDepth19; // eax + float fTrackDepth20; // eax + float fTrackDepth21; // eax + tTrackScreenXYZ *pTrackScreenPtr1; // eax + tTrackScreenXYZ *pTrackScreenPtr2; // eax + tTrackScreenXYZ *pTrackScreenPtr3; // eax + float fScreenDepth1; // eax + tTrackScreenXYZ *pTrackScreenPtr4; // eax + tTrackScreenXYZ *pTrackScreenPtr5; // eax + tTrackScreenXYZ *pTrackScreenPtr6; // eax + tTrackScreenXYZ *pTrackScreenPtr7; // eax + float fScreenDepth2; // eax + tTrackScreenXYZ *pTrackScreenPtr8; // eax + tTrackScreenXYZ *pTrackScreenPtr9; // eax tTrackScreenXYZ *pTrackScreenPtr10; // eax tTrackScreenXYZ *pTrackScreenPtr11; // eax - float fScreenDepth3; // eax + float fScreenDepth3; // eax tTrackScreenXYZ *pTrackScreenPtr12; // eax tTrackScreenXYZ *pTrackScreenPtr13; // eax tTrackScreenXYZ *pTrackScreenPtr14; // eax tTrackScreenXYZ *pTrackScreenPtr15; // eax - float fScreenDepth4; // eax + float fScreenDepth4; // eax tTrackScreenXYZ *pTrackScreenPtr16; // eax tTrackScreenXYZ *pTrackScreenPtr17; // eax tTrackScreenXYZ *pTrackScreenPtr18; // eax tTrackScreenXYZ *pTrackScreenPtr19; // eax - float fScreenDepth5; // eax + float fScreenDepth5; // eax tTrackScreenXYZ *pTrackScreenPtr20; // eax tTrackScreenXYZ *pTrackScreenPtr21; // eax tTrackScreenXYZ *pTrackScreenPtr22; // eax tTrackScreenXYZ *pTrackScreenPtr23; // eax - float fScreenDepth6; // eax - tTrackScreenXYZ *pTrackScreen1; // eax - tTrackScreenXYZ *pTrackScreen2; // eax - tTrackScreenXYZ *pTrackScreen3; // eax - tTrackScreenXYZ *pTrackScreen4; // eax - float fTrackScreenDepth7; // eax - tTrackScreenXYZ *pTrackScreen5; // eax - tTrackScreenXYZ *pTrackScreen6; // eax - tTrackScreenXYZ *pTrackScreen7; // eax - tTrackScreenXYZ *pTrackScreen8; // eax - float fTrackScreenDepth8; // eax - tTrackScreenXYZ *pTrackScreen9; // eax - int iScreenIndex1; // edx - int iScreenIndex2; // esi - int iScreenIndex3; // edx - double dTransform1; // st7 - double dTransform2; // st7 - double dTransform3; // st6 - double dTransform4; // st7 - double dTransform5; // st6 - double dTransform6; // st5 - double dTransform7; // st7 - double dTransform8; // st7 - double dTransform9; // st6 - double dTransform10; // st5 - double dTransform11; // st7 - double dTransform12; // st6 - double dTransform13; // st7 - double dTransform14; // st5 - float iTransformInt1; // eax - double dTransform15; // st7 - //float iTransformInt2; // eax - double dTransform16; // st7 - double dTransform17; // st6 - double dTransform18; // st5 - double dTransform19; // st7 - double dTransform20; // st6 - double dTransform21; // st7 - double dTransform22; // st5 + float fScreenDepth6; // eax + tTrackScreenXYZ *pTrackScreen1; // eax + tTrackScreenXYZ *pTrackScreen2; // eax + tTrackScreenXYZ *pTrackScreen3; // eax + tTrackScreenXYZ *pTrackScreen4; // eax + float fTrackScreenDepth7; // eax + tTrackScreenXYZ *pTrackScreen5; // eax + tTrackScreenXYZ *pTrackScreen6; // eax + tTrackScreenXYZ *pTrackScreen7; // eax + tTrackScreenXYZ *pTrackScreen8; // eax + float fTrackScreenDepth8; // eax + tTrackScreenXYZ *pTrackScreen9; // eax + int iScreenIndex1; // edx + int iScreenIndex2; // esi + int iScreenIndex3; // edx + double dTransform1; // st7 + double dTransform2; // st7 + double dTransform3; // st6 + double dTransform4; // st7 + double dTransform5; // st6 + double dTransform6; // st5 + double dTransform7; // st7 + double dTransform8; // st7 + double dTransform9; // st6 + double dTransform10; // st5 + double dTransform11; // st7 + double dTransform12; // st6 + double dTransform13; // st7 + double dTransform14; // st5 + float iTransformInt1; // eax + double dTransform15; // st7 + // float iTransformInt2; // eax + double dTransform16; // st7 + double dTransform17; // st6 + double dTransform18; // st5 + double dTransform19; // st7 + double dTransform20; // st6 + double dTransform21; // st7 + double dTransform22; // st5 float iTransformInt3; // eax - double dTransform23; // st7 - //float iTransformInt4; // eax - double dTransform24; // st7 - double dTransform25; // st6 - double dTransform26; // st5 - double dTransform27; // st7 - double dTransform28; // st6 - double dTransform29; // st7 - double dTransform30; // st5 + double dTransform23; // st7 + // float iTransformInt4; // eax + double dTransform24; // st7 + double dTransform25; // st6 + double dTransform26; // st5 + double dTransform27; // st7 + double dTransform28; // st6 + double dTransform29; // st7 + double dTransform30; // st5 float iTransformInt5; // eax - double dTransform31; // st7 - //float iTransformInt6; // eax - double dTransform32; // st7 - double dTransform33; // st6 - double dTransform34; // st5 + double dTransform31; // st7 + // float iTransformInt6; // eax + double dTransform32; // st7 + double dTransform33; // st6 + double dTransform34; // st5 double dProjectionDepth1; // st7 double dProjectionDepth2; // st6 double dProjectionDepth3; // st7 double dProjectionDepth4; // st5 - float iProjectionIndex1; // eax + float iProjectionIndex1; // eax double dProjectionDepth5; // st7 - //float iProjectionIndex2; // eax - double dProjectionDepth6; // st7 - double dProjectionDepth7; // st6 - double dProjectionDepth8; // st5 - double dProjectionDepth9; // st7 + // float iProjectionIndex2; // eax + double dProjectionDepth6; // st7 + double dProjectionDepth7; // st6 + double dProjectionDepth8; // st5 + double dProjectionDepth9; // st7 double dProjectionDepth10; // st6 double dProjectionDepth11; // st7 double dProjectionDepth12; // st5 - float iProjectionIndex3; // eax + float iProjectionIndex3; // eax double dProjectionDepth13; // st7 - //float iProjectionIndex4; // eax + // float iProjectionIndex4; // eax double dProjectionDepth14; // st7 double dProjectionDepth15; // st6 double dProjectionDepth16; // st5 @@ -1054,9 +1132,9 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, double dProjectionDepth18; // st6 double dProjectionDepth19; // st7 double dProjectionDepth20; // st5 - float iProjectionIndex5; // eax + float iProjectionIndex5; // eax double dProjectionDepth21; // st7 - //float iProjectionIndex6; // eax + // float iProjectionIndex6; // eax double dProjectionDepth22; // st7 double dProjectionDepth23; // st6 double dProjectionDepth24; // st5 @@ -1064,338 +1142,344 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, double dProjectionDepth26; // st6 double dProjectionDepth27; // st7 double dProjectionDepth28; // st5 - float iProjectionIndex7; // eax + float iProjectionIndex7; // eax double dProjectionDepth29; // st7 - //float iProjectionIndex8; // eax + // float iProjectionIndex8; // eax double dProjectionDepth30; // st7 double dProjectionDepth31; // st6 double dProjectionDepth32; // st5 double dProjectionDepth33; // st7 - int iRenderingIndex1; // edx - //int iRenderingIndex2; // eax - int iRenderingIndex3; // edx - int iRenderingIndex4; // eax - double dRenderingDepth1; // st6 - int iRenderingIndex5; // esi - int iRenderingIndex6; // edx - int iRenderingIndex7; // ebx - int iRenderingIndex8; // ebx - int iRenderingIndex9; // eax - int iRenderingIndex10; // edx - int iRenderingIndex11; // ecx - int iRenderLoopVar; // edx - int iRenderingLoopIndex; // esi - int iRenderingIndexTmp; // edx - int iRenderingCoordIndex; // eax - int iRenderingDataIndex; // edx - float fDepthValuesArray[9]; // [esp+4h] [ebp-4F0h] - float fRoadCenterDepth1; // [esp+28h] [ebp-4CCh] - float fRoadCenterDepth2; // [esp+2Ch] [ebp-4C8h] - float fRoadCenterFinalDepth; // [esp+30h] [ebp-4C4h] - float fRoadCenterDepthNear; // [esp+34h] [ebp-4C0h] - float fRoadCenterDepthFar; // [esp+38h] [ebp-4BCh] - float fRightRoadDepth2; // [esp+3Ch] [ebp-4B8h] - float fRightRoadFinalDepth; // [esp+40h] [ebp-4B4h] - float fRightRoadDepthNear; // [esp+44h] [ebp-4B0h] - float fRightRoadDepthFar; // [esp+48h] [ebp-4ACh] - float fRoof1OuterDepthTmp; // [esp+4Ch] [ebp-4A8h] - float fRoof1InnerDepthTmp; // [esp+50h] [ebp-4A4h] - float fRoof1DepthSelected; // [esp+54h] [ebp-4A0h] - float fRoof1DepthOuter; // [esp+58h] [ebp-49Ch] - float fRoof1DepthInner; // [esp+5Ch] [ebp-498h] - float fRoof2WallMinDepthTmp; // [esp+60h] [ebp-494h] - int iRoof2WallDepthMin; // [esp+64h] [ebp-490h] - float fRoof2DepthSelected; // [esp+68h] [ebp-48Ch] - int iRoof2WallDepthChoice; // [esp+6Ch] [ebp-488h] - float fRoof2DepthWall; // [esp+70h] [ebp-484h] - float fRoof3OuterDepthTmp; // [esp+74h] [ebp-480h] - float fRoof3InnerDepthTmp; // [esp+78h] [ebp-47Ch] - float fRoof3DepthSelected; // [esp+7Ch] [ebp-478h] - float fRoof3DepthOuter; // [esp+80h] [ebp-474h] - float fRoof3DepthInner; // [esp+84h] [ebp-470h] - float fLeftLowerWallDepthNear; // [esp+88h] [ebp-46Ch] - float fLeftLowerWallDepthFar; // [esp+8Ch] [ebp-468h] - float fLeftLowerWallDepthSelected; // [esp+90h] [ebp-464h] - float fLeftLowerWallDepthTmp1; // [esp+94h] [ebp-460h] - float fLeftLowerWallDepthTmp2; // [esp+98h] [ebp-45Ch] - float fRightLowerWallDepthNear; // [esp+9Ch] [ebp-458h] - float fRightLowerWallDepthFar; // [esp+A0h] [ebp-454h] + int iRenderingIndex1; // edx + // int iRenderingIndex2; // eax + int iRenderingIndex3; // edx + int iRenderingIndex4; // eax + double dRenderingDepth1; // st6 + int iRenderingIndex5; // esi + int iRenderingIndex6; // edx + int iRenderingIndex7; // ebx + int iRenderingIndex8; // ebx + int iRenderingIndex9; // eax + int iRenderingIndex10; // edx + int iRenderingIndex11; // ecx + int iRenderLoopVar; // edx + int iRenderingLoopIndex; // esi + int iRenderingIndexTmp; // edx + int iRenderingCoordIndex; // eax + int iRenderingDataIndex; // edx + float fDepthValuesArray[9]; // [esp+4h] [ebp-4F0h] + float fRoadCenterDepth1; // [esp+28h] [ebp-4CCh] + float fRoadCenterDepth2; // [esp+2Ch] [ebp-4C8h] + float fRoadCenterFinalDepth; // [esp+30h] [ebp-4C4h] + float fRoadCenterDepthNear; // [esp+34h] [ebp-4C0h] + float fRoadCenterDepthFar; // [esp+38h] [ebp-4BCh] + float fRightRoadDepth2; // [esp+3Ch] [ebp-4B8h] + float fRightRoadFinalDepth; // [esp+40h] [ebp-4B4h] + float fRightRoadDepthNear; // [esp+44h] [ebp-4B0h] + float fRightRoadDepthFar; // [esp+48h] [ebp-4ACh] + float fRoof1OuterDepthTmp; // [esp+4Ch] [ebp-4A8h] + float fRoof1InnerDepthTmp; // [esp+50h] [ebp-4A4h] + float fRoof1DepthSelected; // [esp+54h] [ebp-4A0h] + float fRoof1DepthOuter; // [esp+58h] [ebp-49Ch] + float fRoof1DepthInner; // [esp+5Ch] [ebp-498h] + float fRoof2WallMinDepthTmp; // [esp+60h] [ebp-494h] + int iRoof2WallDepthMin; // [esp+64h] [ebp-490h] + float fRoof2DepthSelected; // [esp+68h] [ebp-48Ch] + int iRoof2WallDepthChoice; // [esp+6Ch] [ebp-488h] + float fRoof2DepthWall; // [esp+70h] [ebp-484h] + float fRoof3OuterDepthTmp; // [esp+74h] [ebp-480h] + float fRoof3InnerDepthTmp; // [esp+78h] [ebp-47Ch] + float fRoof3DepthSelected; // [esp+7Ch] [ebp-478h] + float fRoof3DepthOuter; // [esp+80h] [ebp-474h] + float fRoof3DepthInner; // [esp+84h] [ebp-470h] + float fLeftLowerWallDepthNear; // [esp+88h] [ebp-46Ch] + float fLeftLowerWallDepthFar; // [esp+8Ch] [ebp-468h] + float fLeftLowerWallDepthSelected; // [esp+90h] [ebp-464h] + float fLeftLowerWallDepthTmp1; // [esp+94h] [ebp-460h] + float fLeftLowerWallDepthTmp2; // [esp+98h] [ebp-45Ch] + float fRightLowerWallDepthNear; // [esp+9Ch] [ebp-458h] + float fRightLowerWallDepthFar; // [esp+A0h] [ebp-454h] float fRightLowerWallDepthSelected; // [esp+A4h] [ebp-450h] - float fRightLowerWallDepthTmp1; // [esp+A8h] [ebp-44Ch] - float fRightLowerWallDepthTmp2; // [esp+ACh] [ebp-448h] - float fLeftWallDepth1; // [esp+B0h] [ebp-444h] - float fLeftWallDepth2; // [esp+B4h] [ebp-440h] - float fLeftWallFinalDepth; // [esp+B8h] [ebp-43Ch] - float fLeftWallDepthTmp1; // [esp+BCh] [ebp-438h] - float fLeftWallDepthTmp2; // [esp+C0h] [ebp-434h] - float fLeftWallDepthTmp3; // [esp+C4h] [ebp-430h] - float fLeftWallDepthTmp4; // [esp+C8h] [ebp-42Ch] - float fLeftWallDepthTmp5; // [esp+CCh] [ebp-428h] - float fLeftWallDepthTmp6; // [esp+D0h] [ebp-424h] - float fLeftWallDepthTmp7; // [esp+D4h] [ebp-420h] - float fRightWallDepth2; // [esp+D8h] [ebp-41Ch] - float fRightWallFinalDepth; // [esp+DCh] [ebp-418h] - float fRightWallDepthTmp1; // [esp+E0h] [ebp-414h] - float fRightWallDepthTmp2; // [esp+E4h] [ebp-410h] - float fRightWallDepthTmp3; // [esp+E8h] [ebp-40Ch] - float fRightWallDepthTmp4; // [esp+ECh] [ebp-408h] - float fRightWallDepthTmp5; // [esp+F0h] [ebp-404h] - float fRightWallDepthTmp6; // [esp+F4h] [ebp-400h] - float fRightWallDepthTmp7; // [esp+F8h] [ebp-3FCh] - unsigned int uiCarArrayOffset; // [esp+FCh] [ebp-3F8h] - float fGeometryDepthTmp1; // [esp+100h] [ebp-3F4h] - float fGeometryDepthTmp2; // [esp+104h] [ebp-3F0h] - float fGeometryDepthTmp3; // [esp+108h] [ebp-3ECh] - float fGeometryDepthTmp4; // [esp+10Ch] [ebp-3E8h] - float fGeometryDepthTmp5; // [esp+110h] [ebp-3E4h] - float fGeometryDepthTmp6; // [esp+114h] [ebp-3E0h] - float fGeometryDepthTmp7; // [esp+118h] [ebp-3DCh] - float fRenderDepthTmp1; // [esp+11Ch] [ebp-3D8h] - float fRenderDepthTmp2; // [esp+120h] [ebp-3D4h] - float fRenderDepthTmp3; // [esp+124h] [ebp-3D0h] - float fRenderDepthTmp4; // [esp+128h] [ebp-3CCh] - float fRenderDepthTmp5; // [esp+12Ch] [ebp-3C8h] - float fRenderDepthTmp6; // [esp+130h] [ebp-3C4h] - tVec3 *pTrackVec3Array; // [esp+134h] [ebp-3C0h] - tVec3 *pTrackGeomFloats; // [esp+138h] [ebp-3BCh] - float fRenderDepthTmp7; // [esp+13Ch] [ebp-3B8h] - float fRenderDepthTmp8; // [esp+140h] [ebp-3B4h] - float fRenderDepthTmp9; // [esp+144h] [ebp-3B0h] - float fRenderDepthTmp10; // [esp+148h] [ebp-3ACh] - float fRightWallDepth1; // [esp+14Ch] [ebp-3A8h] - float fRenderDepthTmp11; // [esp+150h] [ebp-3A4h] - float fRenderDepthTmp12; // [esp+154h] [ebp-3A0h] - float fRenderDepthTmp13; // [esp+158h] [ebp-39Ch] - float fRenderDepthTmp14; // [esp+15Ch] [ebp-398h] - int iTrackSectionIndex; // [esp+160h] [ebp-394h] - int iProjectedZ; // [esp+164h] [ebp-390h] - int iNextSectionIndex; // [esp+168h] [ebp-38Ch] - int iRightWallFlags; // [esp+16Ch] [ebp-388h] - int iLeftWallFlags; // [esp+170h] [ebp-384h] - bool bGroundVisible; // [esp+174h] [ebp-380h] - float fScreenTempX1; // [esp+178h] [ebp-37Ch] - float fScreenTempY1; // [esp+17Ch] [ebp-378h] - float fScreenTempZ1; // [esp+180h] [ebp-374h] - float fScreenTempX2; // [esp+184h] [ebp-370h] - float fScreenTempY2; // [esp+188h] [ebp-36Ch] - float fScreenTempZ2; // [esp+18Ch] [ebp-368h] - float fScreenTempX3; // [esp+190h] [ebp-364h] - float fScreenTempY3; // [esp+194h] [ebp-360h] - float fScreenTempZ3; // [esp+198h] [ebp-35Ch] - float fScreenTempX4; // [esp+19Ch] [ebp-358h] - float fScreenTempY4; // [esp+1A0h] [ebp-354h] - float fScreenTempZ4; // [esp+1A4h] [ebp-350h] - float fScreenTempX5; // [esp+1A8h] [ebp-34Ch] - float fScreenTempY5; // [esp+1ACh] [ebp-348h] - float fScreenTempZ5; // [esp+1B0h] [ebp-344h] - float fScreenTempX6; // [esp+1B4h] [ebp-340h] - float fScreenTempY6; // [esp+1B8h] [ebp-33Ch] - float fScreenTempZ6; // [esp+1BCh] [ebp-338h] - float fScreenTempX7; // [esp+1C0h] [ebp-334h] - float fScreenTempY7; // [esp+1C4h] [ebp-330h] - float fScreenTempZ7; // [esp+1C8h] [ebp-32Ch] - float fScreenTempX8; // [esp+1CCh] [ebp-328h] - float fScreenTempY8; // [esp+1D0h] [ebp-324h] - float fScreenTempZ8; // [esp+1D4h] [ebp-320h] - float fScreenTempX9; // [esp+1D8h] [ebp-31Ch] - float fScreenTempY9; // [esp+1DCh] [ebp-318h] - float fScreenTempZ9; // [esp+1E0h] [ebp-314h] - float fScreenTempX10; // [esp+1E4h] [ebp-310h] - float fScreenTempX11; // [esp+1F4h] [ebp-300h] - float fScreenTempY11; // [esp+1F8h] [ebp-2FCh] - float fScreenTempZ11; // [esp+1FCh] [ebp-2F8h] - float fScreenTempX12; // [esp+200h] [ebp-2F4h] - float fScreenTempY12; // [esp+204h] [ebp-2F0h] - float fScreenTempZ12; // [esp+208h] [ebp-2ECh] - float fGroundDepth1; // [esp+20Ch] [ebp-2E8h] - float fGroundDepthTmp1; // [esp+210h] [ebp-2E4h] - float fGroundDepthTmp2; // [esp+214h] [ebp-2E0h] - float fGroundDepthTmp3; // [esp+218h] [ebp-2DCh] - float fGroundDepthTmp4; // [esp+21Ch] [ebp-2D8h] - float fTrackDepthTmp1; // [esp+220h] [ebp-2D4h] - float fTrackDepthTmp2; // [esp+224h] [ebp-2D0h] - float fProjectionTmp1; // [esp+228h] [ebp-2CCh] - float fProjectionTmp2; // [esp+22Ch] [ebp-2C8h] - float fProjectionTmp3; // [esp+230h] [ebp-2C4h] - float fProjectionTmp4; // [esp+234h] [ebp-2C0h] - float fLeftRoadDepth1; // [esp+238h] [ebp-2BCh] - float fLeftRoadDepth2; // [esp+23Ch] [ebp-2B8h] - float fLeftRoadFinalDepth; // [esp+240h] [ebp-2B4h] - float fLeftRoadTmp1; // [esp+244h] [ebp-2B0h] - float fLeftRoadTmp2; // [esp+248h] [ebp-2ACh] - float fRightRoadDepth1; // [esp+24Ch] [ebp-2A8h] - float fRightRoadTmp1; // [esp+250h] [ebp-2A4h] - float fRightRoadTmp2; // [esp+254h] [ebp-2A0h] - float fSurfaceTmp1; // [esp+258h] [ebp-29Ch] - float fSurfaceTmp2; // [esp+25Ch] [ebp-298h] - float fSurfaceTmp3; // [esp+260h] [ebp-294h] - float fSurfaceTmp4; // [esp+264h] [ebp-290h] - float fSurfaceTmp5; // [esp+268h] [ebp-28Ch] - float fSurfaceTmp6; // [esp+26Ch] [ebp-288h] - float fSurfaceTmp7; // [esp+270h] [ebp-284h] - float fSurfaceTmp8; // [esp+274h] [ebp-280h] - float fSurfaceTmp9; // [esp+278h] [ebp-27Ch] - float fSurfaceTmp10; // [esp+27Ch] [ebp-278h] - float fSurfaceTmp11; // [esp+280h] [ebp-274h] - float fSurfaceTmp12; // [esp+284h] [ebp-270h] - float fSurfaceTmp13; // [esp+288h] [ebp-26Ch] - float fSurfaceTmp14; // [esp+28Ch] [ebp-268h] - float fSurfaceTmp15; // [esp+290h] [ebp-264h] - float fSurfaceTmp16; // [esp+294h] [ebp-260h] - float fSurfaceTmp17; // [esp+298h] [ebp-25Ch] - float fSurfaceTmp18; // [esp+29Ch] [ebp-258h] - float fSurfaceTmp19; // [esp+2A0h] [ebp-254h] - float fSurfaceTmp20; // [esp+2A4h] [ebp-250h] - float fSurfaceTmp21; // [esp+2A8h] [ebp-24Ch] - float fSurfaceTmp22; // [esp+2ACh] [ebp-248h] - float fSurfaceTmp23; // [esp+2B0h] [ebp-244h] - float fSurfaceTmp24; // [esp+2B4h] [ebp-240h] - float fSurfaceTmp25; // [esp+2B8h] [ebp-23Ch] - float fSurfaceTmp26; // [esp+2BCh] [ebp-238h] - float fSurfaceTmp27; // [esp+2C0h] [ebp-234h] - float fSurfaceTmp28; // [esp+2C4h] [ebp-230h] - float fSurfaceTmp29; // [esp+2C8h] [ebp-22Ch] - float fSurfaceTmp30; // [esp+2CCh] [ebp-228h] - float fSurfaceTmp31; // [esp+2D0h] [ebp-224h] - float fSurfaceTmp32; // [esp+2D4h] [ebp-220h] - float fSurfaceTmp33; // [esp+2D8h] [ebp-21Ch] - int iIndexTmp1; // [esp+2DCh] [ebp-218h] - //int iIndexTmp2; // [esp+2E0h] [ebp-214h] - int iIndexTmp3; // [esp+2E4h] [ebp-210h] - float fRenderDepth; // [esp+2E8h] [ebp-20Ch] - float fLightZ; // [esp+2ECh] [ebp-208h] - float fRightWallRoofDepth; // [esp+2F0h] [ebp-204h] - float fLeftWallRoofDepth; // [esp+2F4h] [ebp-200h] - int *pPrevGroundColour; // [esp+2F8h] [ebp-1FCh] - float fLightTmp1; // [esp+2FCh] [ebp-1F8h] - float fOffsetTmp1; // [esp+300h] [ebp-1F4h] - int iOffsetTmp2; // [esp+308h] [ebp-1ECh] - int iGroundProjectedZ; // [esp+30Ch] [ebp-1E8h] - int iRightWallProjectedZ; // [esp+310h] [ebp-1E4h] - int iLeftWallProjectedZ; // [esp+314h] [ebp-1E0h] - float fCameraTransformX1; // [esp+318h] [ebp-1DCh] - float fGroundCameraZ; // [esp+31Ch] [ebp-1D8h] - float fRightWallCameraZ; // [esp+320h] [ebp-1D4h] - float fLeftWallCameraZ; // [esp+324h] [ebp-1D0h] - float fCameraTransformY1; // [esp+328h] [ebp-1CCh] - float fGroundCameraY; // [esp+32Ch] [ebp-1C8h] - float fRightWallCameraY; // [esp+330h] [ebp-1C4h] - float fLeftWallCameraY; // [esp+334h] [ebp-1C0h] - float fCameraTransformZ1; // [esp+338h] [ebp-1BCh] - float fGroundCameraX; // [esp+33Ch] [ebp-1B8h] - float fRightWallCameraX; // [esp+340h] [ebp-1B4h] - float fLeftWallCameraX; // [esp+344h] [ebp-1B0h] - int iRenderObjectIndex; // [esp+348h] [ebp-1ACh] - float fObjectDepthA1; // [esp+34Ch] [ebp-1A8h] - float fObjectDepthA2; // [esp+350h] [ebp-1A4h] - float fObjectDepthA3; // [esp+354h] [ebp-1A0h] - float fObjectDepthA4; // [esp+358h] [ebp-19Ch] - float fObjectDepthA5; // [esp+35Ch] [ebp-198h] - float fObjectDepthA6; // [esp+360h] [ebp-194h] - float fObjectDepthB1; // [esp+364h] [ebp-190h] - float fObjectDepthB2; // [esp+368h] [ebp-18Ch] - float fObjectDepthB3; // [esp+36Ch] [ebp-188h] - float fObjectDepthB4; // [esp+370h] [ebp-184h] - float fObjectDepthB5; // [esp+374h] [ebp-180h] - float fObjectDepthB6; // [esp+378h] [ebp-17Ch] - float fObjectDepthC1; // [esp+37Ch] [ebp-178h] - float fObjectDepthC2; // [esp+380h] [ebp-174h] - float fObjectDepthC3; // [esp+384h] [ebp-170h] - float fObjectDepthC4; // [esp+388h] [ebp-16Ch] - float fObjectDepthC5; // [esp+38Ch] [ebp-168h] - float fObjectDepthC6; // [esp+390h] [ebp-164h] - float fObjectDepthD1; // [esp+394h] [ebp-160h] - float fObjectDepthD2; // [esp+398h] [ebp-15Ch] - float fObjectDepthD3; // [esp+39Ch] [ebp-158h] - float fObjectDepthD4; // [esp+3A0h] [ebp-154h] - float fObjectDepthD5; // [esp+3A4h] [ebp-150h] - float fObjectDepthD6; // [esp+3A8h] [ebp-14Ch] - float fObjectDepthE1; // [esp+3ACh] [ebp-148h] - float fObjectDepthE2; // [esp+3B0h] [ebp-144h] - float fObjectDepthE3; // [esp+3B4h] [ebp-140h] - float fObjectDepthE4; // [esp+3B8h] [ebp-13Ch] - float fObjectDepthE5; // [esp+3BCh] [ebp-138h] - float fObjectDepthE6; // [esp+3C0h] [ebp-134h] - float fObjectDepthF1; // [esp+3C4h] [ebp-130h] - float fObjectDepthF2; // [esp+3C8h] [ebp-12Ch] - float fObjectDepthF3; // [esp+3CCh] [ebp-128h] - float fObjectDepthF4; // [esp+3D0h] [ebp-124h] - float fObjectDepthF5; // [esp+3D4h] [ebp-120h] - float fObjectDepthF6; // [esp+3D8h] [ebp-11Ch] - float fObjectDepthG1; // [esp+3DCh] [ebp-118h] - float fObjectDepthG2; // [esp+3E0h] [ebp-114h] - float fObjectDepthG3; // [esp+3E4h] [ebp-110h] - float fProjectionTempX1; // [esp+3E8h] [ebp-10Ch] - float fProjectionTempY1; // [esp+3ECh] [ebp-108h] - float fProjectionTempZ1; // [esp+3F0h] [ebp-104h] - float fProjectionTempX2; // [esp+3F4h] [ebp-100h] - float fProjectionTempY2; // [esp+3F8h] [ebp-FCh] - float fProjectionTempZ2; // [esp+3FCh] [ebp-F8h] - float fProjectionTempX3; // [esp+400h] [ebp-F4h] - float fProjectionTempY3; // [esp+404h] [ebp-F0h] - float fProjectionTempZ3; // [esp+408h] [ebp-ECh] - float fProjectionTempX4; // [esp+40Ch] [ebp-E8h] - float fProjectionTempY4; // [esp+410h] [ebp-E4h] - float fProjectionTempZ4; // [esp+414h] [ebp-E0h] - float fProjectionTempX5; // [esp+418h] [ebp-DCh] - float fProjectionTempY5; // [esp+41Ch] [ebp-D8h] - float fProjectionTempZ5; // [esp+420h] [ebp-D4h] - float fProjectionTempX6; // [esp+424h] [ebp-D0h] - float fProjectionTempY6; // [esp+428h] [ebp-CCh] - float fProjectionTempZ6; // [esp+42Ch] [ebp-C8h] - float fProjectionTempX7; // [esp+430h] [ebp-C4h] - float fProjectionTempY7; // [esp+434h] [ebp-C0h] - float fProjectionTempZ7; // [esp+438h] [ebp-BCh] - float fProjectionTempX8; // [esp+43Ch] [ebp-B8h] - float fProjectionTempY8; // [esp+440h] [ebp-B4h] - float fProjectionTempZ8; // [esp+444h] [ebp-B0h] - float fProjectionTempX9; // [esp+448h] [ebp-ACh] - float fProjectionTempY9; // [esp+44Ch] [ebp-A8h] - float fProjectionTempZ9; // [esp+450h] [ebp-A4h] - float fProjectionTempX10; // [esp+454h] [ebp-A0h] - float fProjectionTempY10; // [esp+458h] [ebp-9Ch] - float fProjectionTempX11; // [esp+464h] [ebp-90h] - float fProjectionTempY11; // [esp+468h] [ebp-8Ch] - float fProjectionTempZ11; // [esp+46Ch] [ebp-88h] - float fProjectionTempX12; // [esp+470h] [ebp-84h] - float fProjectionTempY12; // [esp+474h] [ebp-80h] - float fProjectionTempZ12; // [esp+478h] [ebp-7Ch] - float fProjectionTempX13; // [esp+47Ch] [ebp-78h] - float fProjectionTempY13; // [esp+480h] [ebp-74h] - float fProjectionTempZ13; // [esp+484h] [ebp-70h] - float fProjectionTempFinal; // [esp+488h] [ebp-6Ch] - uint8 *pScrPtr_1; // [esp+48Ch] [ebp-68h] - int iChaseCamIdx_1; // [esp+490h] [ebp-64h] - int iCarIdx_1; // [esp+494h] [ebp-60h] - float fProjectionZ; // [esp+498h] [ebp-5Ch] - tTrackScreenXYZ *pNextGroundScreen; // [esp+49Ch] [ebp-58h] + float fRightLowerWallDepthTmp1; // [esp+A8h] [ebp-44Ch] + float fRightLowerWallDepthTmp2; // [esp+ACh] [ebp-448h] + float fLeftWallDepth1; // [esp+B0h] [ebp-444h] + float fLeftWallDepth2; // [esp+B4h] [ebp-440h] + float fLeftWallFinalDepth; // [esp+B8h] [ebp-43Ch] + float fLeftWallDepthTmp1; // [esp+BCh] [ebp-438h] + float fLeftWallDepthTmp2; // [esp+C0h] [ebp-434h] + float fLeftWallDepthTmp3; // [esp+C4h] [ebp-430h] + float fLeftWallDepthTmp4; // [esp+C8h] [ebp-42Ch] + float fLeftWallDepthTmp5; // [esp+CCh] [ebp-428h] + float fLeftWallDepthTmp6; // [esp+D0h] [ebp-424h] + float fLeftWallDepthTmp7; // [esp+D4h] [ebp-420h] + float fRightWallDepth2; // [esp+D8h] [ebp-41Ch] + float fRightWallFinalDepth; // [esp+DCh] [ebp-418h] + float fRightWallDepthTmp1; // [esp+E0h] [ebp-414h] + float fRightWallDepthTmp2; // [esp+E4h] [ebp-410h] + float fRightWallDepthTmp3; // [esp+E8h] [ebp-40Ch] + float fRightWallDepthTmp4; // [esp+ECh] [ebp-408h] + float fRightWallDepthTmp5; // [esp+F0h] [ebp-404h] + float fRightWallDepthTmp6; // [esp+F4h] [ebp-400h] + float fRightWallDepthTmp7; // [esp+F8h] [ebp-3FCh] + unsigned int uiCarArrayOffset; // [esp+FCh] [ebp-3F8h] + float fGeometryDepthTmp1; // [esp+100h] [ebp-3F4h] + float fGeometryDepthTmp2; // [esp+104h] [ebp-3F0h] + float fGeometryDepthTmp3; // [esp+108h] [ebp-3ECh] + float fGeometryDepthTmp4; // [esp+10Ch] [ebp-3E8h] + float fGeometryDepthTmp5; // [esp+110h] [ebp-3E4h] + float fGeometryDepthTmp6; // [esp+114h] [ebp-3E0h] + float fGeometryDepthTmp7; // [esp+118h] [ebp-3DCh] + float fRenderDepthTmp1; // [esp+11Ch] [ebp-3D8h] + float fRenderDepthTmp2; // [esp+120h] [ebp-3D4h] + float fRenderDepthTmp3; // [esp+124h] [ebp-3D0h] + float fRenderDepthTmp4; // [esp+128h] [ebp-3CCh] + float fRenderDepthTmp5; // [esp+12Ch] [ebp-3C8h] + float fRenderDepthTmp6; // [esp+130h] [ebp-3C4h] + tVec3 *pTrackVec3Array; // [esp+134h] [ebp-3C0h] + tVec3 *pTrackGeomFloats; // [esp+138h] [ebp-3BCh] + float fRenderDepthTmp7; // [esp+13Ch] [ebp-3B8h] + float fRenderDepthTmp8; // [esp+140h] [ebp-3B4h] + float fRenderDepthTmp9; // [esp+144h] [ebp-3B0h] + float fRenderDepthTmp10; // [esp+148h] [ebp-3ACh] + float fRightWallDepth1; // [esp+14Ch] [ebp-3A8h] + float fRenderDepthTmp11; // [esp+150h] [ebp-3A4h] + float fRenderDepthTmp12; // [esp+154h] [ebp-3A0h] + float fRenderDepthTmp13; // [esp+158h] [ebp-39Ch] + float fRenderDepthTmp14; // [esp+15Ch] [ebp-398h] + int iTrackSectionIndex; // [esp+160h] [ebp-394h] + int iProjectedZ; // [esp+164h] [ebp-390h] + int iNextSectionIndex; // [esp+168h] [ebp-38Ch] + int iRightWallFlags; // [esp+16Ch] [ebp-388h] + int iLeftWallFlags; // [esp+170h] [ebp-384h] + bool bGroundVisible; // [esp+174h] [ebp-380h] + float fScreenTempX1; // [esp+178h] [ebp-37Ch] + float fScreenTempY1; // [esp+17Ch] [ebp-378h] + float fScreenTempZ1; // [esp+180h] [ebp-374h] + float fScreenTempX2; // [esp+184h] [ebp-370h] + float fScreenTempY2; // [esp+188h] [ebp-36Ch] + float fScreenTempZ2; // [esp+18Ch] [ebp-368h] + float fScreenTempX3; // [esp+190h] [ebp-364h] + float fScreenTempY3; // [esp+194h] [ebp-360h] + float fScreenTempZ3; // [esp+198h] [ebp-35Ch] + float fScreenTempX4; // [esp+19Ch] [ebp-358h] + float fScreenTempY4; // [esp+1A0h] [ebp-354h] + float fScreenTempZ4; // [esp+1A4h] [ebp-350h] + float fScreenTempX5; // [esp+1A8h] [ebp-34Ch] + float fScreenTempY5; // [esp+1ACh] [ebp-348h] + float fScreenTempZ5; // [esp+1B0h] [ebp-344h] + float fScreenTempX6; // [esp+1B4h] [ebp-340h] + float fScreenTempY6; // [esp+1B8h] [ebp-33Ch] + float fScreenTempZ6; // [esp+1BCh] [ebp-338h] + float fScreenTempX7; // [esp+1C0h] [ebp-334h] + float fScreenTempY7; // [esp+1C4h] [ebp-330h] + float fScreenTempZ7; // [esp+1C8h] [ebp-32Ch] + float fScreenTempX8; // [esp+1CCh] [ebp-328h] + float fScreenTempY8; // [esp+1D0h] [ebp-324h] + float fScreenTempZ8; // [esp+1D4h] [ebp-320h] + float fScreenTempX9; // [esp+1D8h] [ebp-31Ch] + float fScreenTempY9; // [esp+1DCh] [ebp-318h] + float fScreenTempZ9; // [esp+1E0h] [ebp-314h] + float fScreenTempX10; // [esp+1E4h] [ebp-310h] + float fScreenTempX11; // [esp+1F4h] [ebp-300h] + float fScreenTempY11; // [esp+1F8h] [ebp-2FCh] + float fScreenTempZ11; // [esp+1FCh] [ebp-2F8h] + float fScreenTempX12; // [esp+200h] [ebp-2F4h] + float fScreenTempY12; // [esp+204h] [ebp-2F0h] + float fScreenTempZ12; // [esp+208h] [ebp-2ECh] + float fGroundDepth1; // [esp+20Ch] [ebp-2E8h] + float fGroundDepthTmp1; // [esp+210h] [ebp-2E4h] + float fGroundDepthTmp2; // [esp+214h] [ebp-2E0h] + float fGroundDepthTmp3; // [esp+218h] [ebp-2DCh] + float fGroundDepthTmp4; // [esp+21Ch] [ebp-2D8h] + float fTrackDepthTmp1; // [esp+220h] [ebp-2D4h] + float fTrackDepthTmp2; // [esp+224h] [ebp-2D0h] + float fProjectionTmp1; // [esp+228h] [ebp-2CCh] + float fProjectionTmp2; // [esp+22Ch] [ebp-2C8h] + float fProjectionTmp3; // [esp+230h] [ebp-2C4h] + float fProjectionTmp4; // [esp+234h] [ebp-2C0h] + float fLeftRoadDepth1; // [esp+238h] [ebp-2BCh] + float fLeftRoadDepth2; // [esp+23Ch] [ebp-2B8h] + float fLeftRoadFinalDepth; // [esp+240h] [ebp-2B4h] + float fLeftRoadTmp1; // [esp+244h] [ebp-2B0h] + float fLeftRoadTmp2; // [esp+248h] [ebp-2ACh] + float fRightRoadDepth1; // [esp+24Ch] [ebp-2A8h] + float fRightRoadTmp1; // [esp+250h] [ebp-2A4h] + float fRightRoadTmp2; // [esp+254h] [ebp-2A0h] + float fSurfaceTmp1; // [esp+258h] [ebp-29Ch] + float fSurfaceTmp2; // [esp+25Ch] [ebp-298h] + float fSurfaceTmp3; // [esp+260h] [ebp-294h] + float fSurfaceTmp4; // [esp+264h] [ebp-290h] + float fSurfaceTmp5; // [esp+268h] [ebp-28Ch] + float fSurfaceTmp6; // [esp+26Ch] [ebp-288h] + float fSurfaceTmp7; // [esp+270h] [ebp-284h] + float fSurfaceTmp8; // [esp+274h] [ebp-280h] + float fSurfaceTmp9; // [esp+278h] [ebp-27Ch] + float fSurfaceTmp10; // [esp+27Ch] [ebp-278h] + float fSurfaceTmp11; // [esp+280h] [ebp-274h] + float fSurfaceTmp12; // [esp+284h] [ebp-270h] + float fSurfaceTmp13; // [esp+288h] [ebp-26Ch] + float fSurfaceTmp14; // [esp+28Ch] [ebp-268h] + float fSurfaceTmp15; // [esp+290h] [ebp-264h] + float fSurfaceTmp16; // [esp+294h] [ebp-260h] + float fSurfaceTmp17; // [esp+298h] [ebp-25Ch] + float fSurfaceTmp18; // [esp+29Ch] [ebp-258h] + float fSurfaceTmp19; // [esp+2A0h] [ebp-254h] + float fSurfaceTmp20; // [esp+2A4h] [ebp-250h] + float fSurfaceTmp21; // [esp+2A8h] [ebp-24Ch] + float fSurfaceTmp22; // [esp+2ACh] [ebp-248h] + float fSurfaceTmp23; // [esp+2B0h] [ebp-244h] + float fSurfaceTmp24; // [esp+2B4h] [ebp-240h] + float fSurfaceTmp25; // [esp+2B8h] [ebp-23Ch] + float fSurfaceTmp26; // [esp+2BCh] [ebp-238h] + float fSurfaceTmp27; // [esp+2C0h] [ebp-234h] + float fSurfaceTmp28; // [esp+2C4h] [ebp-230h] + float fSurfaceTmp29; // [esp+2C8h] [ebp-22Ch] + float fSurfaceTmp30; // [esp+2CCh] [ebp-228h] + float fSurfaceTmp31; // [esp+2D0h] [ebp-224h] + float fSurfaceTmp32; // [esp+2D4h] [ebp-220h] + float fSurfaceTmp33; // [esp+2D8h] [ebp-21Ch] + int iIndexTmp1; // [esp+2DCh] [ebp-218h] + // int iIndexTmp2; // [esp+2E0h] [ebp-214h] + int iIndexTmp3; // [esp+2E4h] [ebp-210h] + float fRenderDepth; // [esp+2E8h] [ebp-20Ch] + float fLightZ; // [esp+2ECh] [ebp-208h] + float fRightWallRoofDepth; // [esp+2F0h] [ebp-204h] + float fLeftWallRoofDepth; // [esp+2F4h] [ebp-200h] + int *pPrevGroundColour; // [esp+2F8h] [ebp-1FCh] + float fLightTmp1; // [esp+2FCh] [ebp-1F8h] + float fOffsetTmp1; // [esp+300h] [ebp-1F4h] + int iOffsetTmp2; // [esp+308h] [ebp-1ECh] + int iGroundProjectedZ; // [esp+30Ch] [ebp-1E8h] + int iRightWallProjectedZ; // [esp+310h] [ebp-1E4h] + int iLeftWallProjectedZ; // [esp+314h] [ebp-1E0h] + float fCameraTransformX1; // [esp+318h] [ebp-1DCh] + float fGroundCameraZ; // [esp+31Ch] [ebp-1D8h] + float fRightWallCameraZ; // [esp+320h] [ebp-1D4h] + float fLeftWallCameraZ; // [esp+324h] [ebp-1D0h] + float fCameraTransformY1; // [esp+328h] [ebp-1CCh] + float fGroundCameraY; // [esp+32Ch] [ebp-1C8h] + float fRightWallCameraY; // [esp+330h] [ebp-1C4h] + float fLeftWallCameraY; // [esp+334h] [ebp-1C0h] + float fCameraTransformZ1; // [esp+338h] [ebp-1BCh] + float fGroundCameraX; // [esp+33Ch] [ebp-1B8h] + float fRightWallCameraX; // [esp+340h] [ebp-1B4h] + float fLeftWallCameraX; // [esp+344h] [ebp-1B0h] + int iRenderObjectIndex; // [esp+348h] [ebp-1ACh] + float fObjectDepthA1; // [esp+34Ch] [ebp-1A8h] + float fObjectDepthA2; // [esp+350h] [ebp-1A4h] + float fObjectDepthA3; // [esp+354h] [ebp-1A0h] + float fObjectDepthA4; // [esp+358h] [ebp-19Ch] + float fObjectDepthA5; // [esp+35Ch] [ebp-198h] + float fObjectDepthA6; // [esp+360h] [ebp-194h] + float fObjectDepthB1; // [esp+364h] [ebp-190h] + float fObjectDepthB2; // [esp+368h] [ebp-18Ch] + float fObjectDepthB3; // [esp+36Ch] [ebp-188h] + float fObjectDepthB4; // [esp+370h] [ebp-184h] + float fObjectDepthB5; // [esp+374h] [ebp-180h] + float fObjectDepthB6; // [esp+378h] [ebp-17Ch] + float fObjectDepthC1; // [esp+37Ch] [ebp-178h] + float fObjectDepthC2; // [esp+380h] [ebp-174h] + float fObjectDepthC3; // [esp+384h] [ebp-170h] + float fObjectDepthC4; // [esp+388h] [ebp-16Ch] + float fObjectDepthC5; // [esp+38Ch] [ebp-168h] + float fObjectDepthC6; // [esp+390h] [ebp-164h] + float fObjectDepthD1; // [esp+394h] [ebp-160h] + float fObjectDepthD2; // [esp+398h] [ebp-15Ch] + float fObjectDepthD3; // [esp+39Ch] [ebp-158h] + float fObjectDepthD4; // [esp+3A0h] [ebp-154h] + float fObjectDepthD5; // [esp+3A4h] [ebp-150h] + float fObjectDepthD6; // [esp+3A8h] [ebp-14Ch] + float fObjectDepthE1; // [esp+3ACh] [ebp-148h] + float fObjectDepthE2; // [esp+3B0h] [ebp-144h] + float fObjectDepthE3; // [esp+3B4h] [ebp-140h] + float fObjectDepthE4; // [esp+3B8h] [ebp-13Ch] + float fObjectDepthE5; // [esp+3BCh] [ebp-138h] + float fObjectDepthE6; // [esp+3C0h] [ebp-134h] + float fObjectDepthF1; // [esp+3C4h] [ebp-130h] + float fObjectDepthF2; // [esp+3C8h] [ebp-12Ch] + float fObjectDepthF3; // [esp+3CCh] [ebp-128h] + float fObjectDepthF4; // [esp+3D0h] [ebp-124h] + float fObjectDepthF5; // [esp+3D4h] [ebp-120h] + float fObjectDepthF6; // [esp+3D8h] [ebp-11Ch] + float fObjectDepthG1; // [esp+3DCh] [ebp-118h] + float fObjectDepthG2; // [esp+3E0h] [ebp-114h] + float fObjectDepthG3; // [esp+3E4h] [ebp-110h] + float fProjectionTempX1; // [esp+3E8h] [ebp-10Ch] + float fProjectionTempY1; // [esp+3ECh] [ebp-108h] + float fProjectionTempZ1; // [esp+3F0h] [ebp-104h] + float fProjectionTempX2; // [esp+3F4h] [ebp-100h] + float fProjectionTempY2; // [esp+3F8h] [ebp-FCh] + float fProjectionTempZ2; // [esp+3FCh] [ebp-F8h] + float fProjectionTempX3; // [esp+400h] [ebp-F4h] + float fProjectionTempY3; // [esp+404h] [ebp-F0h] + float fProjectionTempZ3; // [esp+408h] [ebp-ECh] + float fProjectionTempX4; // [esp+40Ch] [ebp-E8h] + float fProjectionTempY4; // [esp+410h] [ebp-E4h] + float fProjectionTempZ4; // [esp+414h] [ebp-E0h] + float fProjectionTempX5; // [esp+418h] [ebp-DCh] + float fProjectionTempY5; // [esp+41Ch] [ebp-D8h] + float fProjectionTempZ5; // [esp+420h] [ebp-D4h] + float fProjectionTempX6; // [esp+424h] [ebp-D0h] + float fProjectionTempY6; // [esp+428h] [ebp-CCh] + float fProjectionTempZ6; // [esp+42Ch] [ebp-C8h] + float fProjectionTempX7; // [esp+430h] [ebp-C4h] + float fProjectionTempY7; // [esp+434h] [ebp-C0h] + float fProjectionTempZ7; // [esp+438h] [ebp-BCh] + float fProjectionTempX8; // [esp+43Ch] [ebp-B8h] + float fProjectionTempY8; // [esp+440h] [ebp-B4h] + float fProjectionTempZ8; // [esp+444h] [ebp-B0h] + float fProjectionTempX9; // [esp+448h] [ebp-ACh] + float fProjectionTempY9; // [esp+44Ch] [ebp-A8h] + float fProjectionTempZ9; // [esp+450h] [ebp-A4h] + float fProjectionTempX10; // [esp+454h] [ebp-A0h] + float fProjectionTempY10; // [esp+458h] [ebp-9Ch] + float fProjectionTempX11; // [esp+464h] [ebp-90h] + float fProjectionTempY11; // [esp+468h] [ebp-8Ch] + float fProjectionTempZ11; // [esp+46Ch] [ebp-88h] + float fProjectionTempX12; // [esp+470h] [ebp-84h] + float fProjectionTempY12; // [esp+474h] [ebp-80h] + float fProjectionTempZ12; // [esp+478h] [ebp-7Ch] + float fProjectionTempX13; // [esp+47Ch] [ebp-78h] + float fProjectionTempY13; // [esp+480h] [ebp-74h] + float fProjectionTempZ13; // [esp+484h] [ebp-70h] + float fProjectionTempFinal; // [esp+488h] [ebp-6Ch] + uint8 *pScrPtr_1; // [esp+48Ch] [ebp-68h] + int iChaseCamIdx_1; // [esp+490h] [ebp-64h] + int iCarIdx_1; // [esp+494h] [ebp-60h] + float fProjectionZ; // [esp+498h] [ebp-5Ch] + tTrackScreenXYZ *pNextGroundScreen; // [esp+49Ch] [ebp-58h] tTrackScreenXYZ *pCurrentGroundScreen; // [esp+4A0h] [ebp-54h] - int *pCurrentGroundColour; // [esp+4A4h] [ebp-50h] - float fTransformTempX1; // [esp+4A8h] [ebp-4Ch] - float fTransformTempY1; // [esp+4ACh] [ebp-48h] - float fTransformTempZ1; // [esp+4B0h] [ebp-44h] - float fTransformTempX2; // [esp+4B4h] [ebp-40h] - float fTransformTempY2; // [esp+4B8h] [ebp-3Ch] - float fTransformTempZ2; // [esp+4BCh] [ebp-38h] - float fTransformTempFinal; // [esp+4C0h] [ebp-34h] - float fWorldZ; // [esp+4C8h] [ebp-2Ch] - float fWorldY; // [esp+4CCh] [ebp-28h] - float fWorldX; // [esp+4D0h] [ebp-24h] - int iRenderingTemp; // [esp+4E0h] [ebp-14h] - - pScrPtr_1 = pScrPtr; // Store function parameters + int *pCurrentGroundColour; // [esp+4A4h] [ebp-50h] + float fTransformTempX1; // [esp+4A8h] [ebp-4Ch] + float fTransformTempY1; // [esp+4ACh] [ebp-48h] + float fTransformTempZ1; // [esp+4B0h] [ebp-44h] + float fTransformTempX2; // [esp+4B4h] [ebp-40h] + float fTransformTempY2; // [esp+4B8h] [ebp-3Ch] + float fTransformTempZ2; // [esp+4BCh] [ebp-38h] + float fTransformTempFinal; // [esp+4C0h] [ebp-34h] + float fWorldZ; // [esp+4C8h] [ebp-2Ch] + float fWorldY; // [esp+4CCh] [ebp-28h] + float fWorldX; // [esp+4D0h] [ebp-24h] + int iRenderingTemp; // [esp+4E0h] [ebp-14h] + + pScrPtr_1 = pScrPtr; // Store function parameters iChaseCamIdx_1 = iChaseCamIdx; iCarIdx_1 = iCarIdx; - cars_drawn = 0; // Initialize global counters for rendering + cars_drawn = 0; // Initialize global counters for rendering num_pols = 0; - for (iTrackSectionIndex = 0; TrackSize + 1 >= iTrackSectionIndex; ++iTrackSectionIndex) { - if (first_size + 1 >= iTrackSectionIndex || iTrackSectionIndex >= gap_size) { - iCurrentTrackIndex = start_sect + iTrackSectionIndex;// Calculate current track section index with wraparound + for (iTrackSectionIndex = 0; TrackSize + 1 >= iTrackSectionIndex; + ++iTrackSectionIndex) { + if (first_size + 1 >= iTrackSectionIndex || + iTrackSectionIndex >= gap_size) { + iCurrentTrackIndex = + start_sect + iTrackSectionIndex; // Calculate current track section + // index with wraparound if (start_sect + iTrackSectionIndex >= TRAK_LEN) iCurrentTrackIndex -= TRAK_LEN; if (iCurrentTrackIndex < 0) iCurrentTrackIndex += TRAK_LEN; - pCurrentTrackPt = TrakPt[iCurrentTrackIndex].pointAy;// Get track geometry data and screen projection structures + pCurrentTrackPt = + TrakPt[iCurrentTrackIndex].pointAy; // Get track geometry data and + // screen projection structures pCurrentTrackScreenXYZ = &TrackScreenXYZ[iCurrentTrackIndex]; pTrackGeomFloats = pCurrentTrackPt; pTrackPoint4 = pCurrentTrackPt + 4; @@ -1403,30 +1487,33 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, pTrackPoint3 = pCurrentTrackPt + 3; pCurrentTrackPt += 2; pCurrentTrackScreenXYZ->iClipCount = 0; - dDeltaX1 = pCurrentTrackPt->fX - viewx; // Transform track point 1 from world to camera space + dDeltaX1 = pCurrentTrackPt->fX - + viewx; // Transform track point 1 from world to camera space dDeltaY1 = pCurrentTrackPt->fY - viewy; dDeltaZ1 = pCurrentTrackPt->fZ - viewz; fWorldX = (float)(dDeltaX1 * vk1 + dDeltaY1 * vk4 + dDeltaZ1 * vk7); fWorldY = (float)(dDeltaX1 * vk2 + dDeltaY1 * vk5 + dDeltaZ1 * vk8); dCameraZ1 = dDeltaX1 * vk3 + dDeltaY1 * vk6 + dDeltaZ1 * vk9; fWorldZ = (float)dCameraZ1; - dCameraZ1 = round(dCameraZ1);//_CHP(); + dCameraZ1 = round(dCameraZ1); //_CHP(); iProjectedZ = (int)dCameraZ1; - if (fWorldZ < 80.0) // Apply near clipping plane (min Z = 80.0) + if (fWorldZ < 80.0) // Apply near clipping plane (min Z = 80.0) { fWorldZ = 80.0; ++pCurrentTrackScreenXYZ->iClipCount; } dViewDistance1 = (double)VIEWDIST; - dInvZ1 = 1.0 / fWorldZ; // Project to screen coordinates using perspective division + dInvZ1 = + 1.0 / + fWorldZ; // Project to screen coordinates using perspective division dScreenX1 = dViewDistance1 * fWorldX * dInvZ1 + (double)xbase; - dScreenX1 = round(dScreenX1);//_CHP(); + dScreenX1 = round(dScreenX1); //_CHP(); xp = (int)dScreenX1; dScreenY1 = dInvZ1 * (dViewDistance1 * fWorldY) + (double)ybase; - dScreenY1 = round(dScreenY1);//_CHP(); + dScreenY1 = round(dScreenY1); //_CHP(); yp = (int)dScreenY1; pCurrentTrackScreenXYZ->screenPtAy[1].screen.x = xp * scr_size >> 6; - //pCurrentTrackScreenXYZ->screenPtAy[1].screen.x = iScreenX1 >> 6; + // pCurrentTrackScreenXYZ->screenPtAy[1].screen.x = iScreenX1 >> 6; iScreenY1 = scr_size * (199 - yp); pCurrentTrackScreenXYZ->screenPtAy[1].projected.fZ = (float)iProjectedZ; pCurrentTrackScreenXYZ->screenPtAy[1].screen.y = iScreenY1 >> 6; @@ -1439,7 +1526,7 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, fWorldY = (float)(dDeltaX2 * vk2 + dDeltaY2 * vk5 + dDeltaZ2 * vk8); dCameraZ2 = dDeltaX2 * vk3 + dDeltaY2 * vk6 + dDeltaZ2 * vk9; fWorldZ = (float)dCameraZ2; - dCameraZ2 = round(dCameraZ2);//_CHP(); + dCameraZ2 = round(dCameraZ2); //_CHP(); iProjectedZ = (int)dCameraZ2; if (fWorldZ < 80.0) { fWorldZ = 80.0; @@ -1448,13 +1535,13 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, dViewDistance2 = (double)VIEWDIST; dInvZ2 = 1.0 / fWorldZ; dScreenX2 = dViewDistance2 * fWorldX * dInvZ2 + (double)xbase; - dScreenX2 = round(dScreenX2);//_CHP(); + dScreenX2 = round(dScreenX2); //_CHP(); xp = (int)dScreenX2; dScreenY2 = dInvZ2 * (dViewDistance2 * fWorldY) + (double)ybase; - dScreenY2 = round(dScreenY2);//_CHP(); + dScreenY2 = round(dScreenY2); //_CHP(); yp = (int)dScreenY2; pCurrentTrackScreenXYZ->screenPtAy[0].screen.x = xp * scr_size >> 6; - //pCurrentTrackScreenXYZ->screenPtAy[0].screen.x = iScreenX2 >> 6; + // pCurrentTrackScreenXYZ->screenPtAy[0].screen.x = iScreenX2 >> 6; iScreenY2 = scr_size * (199 - yp); pCurrentTrackScreenXYZ->screenPtAy[0].projected.fZ = (float)iProjectedZ; pCurrentTrackScreenXYZ->screenPtAy[0].screen.y = iScreenY2 >> 6; @@ -1467,7 +1554,7 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, fWorldY = (float)(dDeltaX3 * vk2 + dDeltaY3 * vk5 + dDeltaZ3 * vk8); dCameraZ3 = dDeltaX3 * vk3 + dDeltaY3 * vk6 + dDeltaZ3 * vk9; fWorldZ = (float)dCameraZ3; - dCameraZ3 = round(dCameraZ3);//_CHP(); + dCameraZ3 = round(dCameraZ3); //_CHP(); iProjectedZ = (int)dCameraZ3; if (fWorldZ < 80.0) { iClipIncrement3 = pCurrentTrackScreenXYZ->iClipCount + 1; @@ -1477,13 +1564,13 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, dViewDistance3 = (double)VIEWDIST; dInvZ3 = 1.0 / fWorldZ; dScreenX3 = dViewDistance3 * fWorldX * dInvZ3 + (double)xbase; - dScreenX3 = round(dScreenX3);//_CHP(); + dScreenX3 = round(dScreenX3); //_CHP(); xp = (int)dScreenX3; dScreenY3 = dInvZ3 * (dViewDistance3 * fWorldY) + (double)ybase; - dScreenY3 = round(dScreenY3);//_CHP(); + dScreenY3 = round(dScreenY3); //_CHP(); yp = (int)dScreenY3; pCurrentTrackScreenXYZ->screenPtAy[2].screen.x = xp * scr_size >> 6; - //pCurrentTrackScreenXYZ->screenPtAy[2].screen.x = iScreenX3 >> 6; + // pCurrentTrackScreenXYZ->screenPtAy[2].screen.x = iScreenX3 >> 6; iScreenY3 = scr_size * (199 - yp); pCurrentTrackScreenXYZ->screenPtAy[2].projected.fZ = (float)iProjectedZ; pCurrentTrackScreenXYZ->screenPtAy[2].screen.y = iScreenY3 >> 6; @@ -1496,7 +1583,7 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, fWorldY = (float)(dDeltaX4 * vk2 + dDeltaY4 * vk5 + dDeltaZ4 * vk8); dCameraZ4 = dDeltaX4 * vk3 + dDeltaY4 * vk6 + dDeltaZ4 * vk9; fWorldZ = (float)dCameraZ4; - dCameraZ4 = round(dCameraZ4);//_CHP(); + dCameraZ4 = round(dCameraZ4); //_CHP(); iProjectedZ = (int)dCameraZ4; if (fWorldZ < 80.0) { iClipIncrement4 = pCurrentTrackScreenXYZ->iClipCount + 1; @@ -1506,153 +1593,216 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, dViewDistance4 = (double)VIEWDIST; dInvZ4 = 1.0 / fWorldZ; dScreenX4 = dViewDistance4 * fWorldX * dInvZ4 + (double)xbase; - dScreenX4 = round(dScreenX4);//_CHP(); + dScreenX4 = round(dScreenX4); //_CHP(); xp = (int)dScreenX4; dScreenY4 = dInvZ4 * (dViewDistance4 * fWorldY) + (double)ybase; iScrSize = scr_size; - dScreenY4 = round(dScreenY4);//_CHP(); + dScreenY4 = round(dScreenY4); //_CHP(); yp = (int)dScreenY4; pCurrentTrackScreenXYZ->screenPtAy[3].screen.x = xp * scr_size >> 6; - //pCurrentTrackScreenXYZ->screenPtAy[3].screen.x = iScreenX4 >> 6; - pCurrentTrackScreenXYZ->screenPtAy[3].screen.y = (iScrSize * (199 - yp)) >> 6; + // pCurrentTrackScreenXYZ->screenPtAy[3].screen.x = iScreenX4 >> 6; + pCurrentTrackScreenXYZ->screenPtAy[3].screen.y = + (iScrSize * (199 - yp)) >> 6; pCurrentTrackScreenXYZ->screenPtAy[3].projected.fX = fWorldX; pCurrentTrackScreenXYZ->screenPtAy[3].projected.fY = fWorldY; pCurrentTrackScreenXYZ->screenPtAy[3].projected.fZ = (float)iProjectedZ; pLeftWallTypePtr = &TrakColour[iCurrentTrackIndex][TRAK_COLOUR_LEFT_WALL]; - iPrevSectionIndex = iCurrentTrackIndex ? iCurrentTrackIndex - 1 : TRAK_LEN - 1; - pPrevLeftWallTypePtr = &TrakColour[iPrevSectionIndex][TRAK_COLOUR_LEFT_WALL]; + iPrevSectionIndex = + iCurrentTrackIndex ? iCurrentTrackIndex - 1 : TRAK_LEN - 1; + pPrevLeftWallTypePtr = + &TrakColour[iPrevSectionIndex][TRAK_COLOUR_LEFT_WALL]; if (*pLeftWallTypePtr && *pPrevLeftWallTypePtr) { - //LODWORD(fOffsetTmp1) = 72 * iCurrentTrackIndex;//unused here? + // LODWORD(fOffsetTmp1) = 72 * iCurrentTrackIndex;//unused here? pGroundPt = &TrakPt[iCurrentTrackIndex]; - dLeftWallDeltaX = pGroundPt->pointAy[1].fX - viewx;// Calculate left wall point (point 5) projection to screen coordinates + dLeftWallDeltaX = pGroundPt->pointAy[1].fX - + viewx; // Calculate left wall point (point 5) + // projection to screen coordinates dLeftWallDeltaY = pGroundPt->pointAy[1].fY - viewy; dLeftWallDeltaZ = pGroundPt->pointAy[1].fZ - viewz; - fLeftWallCameraX = (float)(dLeftWallDeltaX * vk1 + dLeftWallDeltaY * vk4 + dLeftWallDeltaZ * vk7); - fLeftWallCameraY = (float)(dLeftWallDeltaX * vk2 + dLeftWallDeltaY * vk5 + dLeftWallDeltaZ * vk8); - dLeftWallCameraZ = dLeftWallDeltaX * vk3 + dLeftWallDeltaY * vk6 + dLeftWallDeltaZ * vk9; + fLeftWallCameraX = + (float)(dLeftWallDeltaX * vk1 + dLeftWallDeltaY * vk4 + + dLeftWallDeltaZ * vk7); + fLeftWallCameraY = + (float)(dLeftWallDeltaX * vk2 + dLeftWallDeltaY * vk5 + + dLeftWallDeltaZ * vk8); + dLeftWallCameraZ = dLeftWallDeltaX * vk3 + dLeftWallDeltaY * vk6 + + dLeftWallDeltaZ * vk9; fLeftWallCameraZ = (float)dLeftWallCameraZ; - dLeftWallCameraZ = round(dLeftWallCameraZ);//_CHP(); + dLeftWallCameraZ = round(dLeftWallCameraZ); //_CHP(); iLeftWallProjectedZ = (int)dLeftWallCameraZ; if (fLeftWallCameraZ < 80.0) fLeftWallCameraZ = 80.0; dLeftWallViewDist = (double)VIEWDIST; dLeftWallInvZ = 1.0 / fLeftWallCameraZ; - dLeftWallScreenX = dLeftWallViewDist * fLeftWallCameraX * dLeftWallInvZ + (double)xbase; - dLeftWallScreenX = round(dLeftWallScreenX);//_CHP(); + dLeftWallScreenX = + dLeftWallViewDist * fLeftWallCameraX * dLeftWallInvZ + + (double)xbase; + dLeftWallScreenX = round(dLeftWallScreenX); //_CHP(); xp = (int)dLeftWallScreenX; - dLeftWallScreenY = dLeftWallInvZ * (dLeftWallViewDist * fLeftWallCameraY) + (double)ybase; - dLeftWallScreenY = round(dLeftWallScreenY);//_CHP(); + dLeftWallScreenY = + dLeftWallInvZ * (dLeftWallViewDist * fLeftWallCameraY) + + (double)ybase; + dLeftWallScreenY = round(dLeftWallScreenY); //_CHP(); yp = (int)dLeftWallScreenY; pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = xp * scr_size >> 6; - //pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = iLeftWallScreenX >> 6; + // pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = iLeftWallScreenX >> + // 6; iLeftWallScreenY = scr_size * (199 - yp); - pCurrentTrackScreenXYZ->screenPtAy[4].projected.fZ = (float)iLeftWallProjectedZ; + pCurrentTrackScreenXYZ->screenPtAy[4].projected.fZ = + (float)iLeftWallProjectedZ; pCurrentTrackScreenXYZ->screenPtAy[4].screen.y = iLeftWallScreenY >> 6; pCurrentTrackScreenXYZ->screenPtAy[4].projected.fX = fLeftWallCameraX; pCurrentTrackScreenXYZ->screenPtAy[4].projected.fY = fLeftWallCameraY; - } else { // Copy coordinates from existing points when walls are not present + } else { // Copy coordinates from existing points when walls are not + // present if (*pLeftWallTypePtr >= 0 && *pPrevLeftWallTypePtr >= 0) { - pCurrentTrackScreenXYZ->screenPtAy[4].projected.fX = pCurrentTrackScreenXYZ->screenPtAy[0].projected.fX; - pCurrentTrackScreenXYZ->screenPtAy[4].projected.fY = pCurrentTrackScreenXYZ->screenPtAy[0].projected.fY; + pCurrentTrackScreenXYZ->screenPtAy[4].projected.fX = + pCurrentTrackScreenXYZ->screenPtAy[0].projected.fX; + pCurrentTrackScreenXYZ->screenPtAy[4].projected.fY = + pCurrentTrackScreenXYZ->screenPtAy[0].projected.fY; dLeftWallCopyZ = pCurrentTrackScreenXYZ->screenPtAy[0].projected.fZ; - pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = pCurrentTrackScreenXYZ->screenPtAy[0].screen.x; + pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = + pCurrentTrackScreenXYZ->screenPtAy[0].screen.x; iLeftWallCopyY = pCurrentTrackScreenXYZ->screenPtAy[0].screen.y; } else { - pCurrentTrackScreenXYZ->screenPtAy[4].projected.fX = pCurrentTrackScreenXYZ->screenPtAy[1].projected.fX; - pCurrentTrackScreenXYZ->screenPtAy[4].projected.fY = pCurrentTrackScreenXYZ->screenPtAy[1].projected.fY; + pCurrentTrackScreenXYZ->screenPtAy[4].projected.fX = + pCurrentTrackScreenXYZ->screenPtAy[1].projected.fX; + pCurrentTrackScreenXYZ->screenPtAy[4].projected.fY = + pCurrentTrackScreenXYZ->screenPtAy[1].projected.fY; dLeftWallCopyZ = pCurrentTrackScreenXYZ->screenPtAy[1].projected.fZ; - pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = pCurrentTrackScreenXYZ->screenPtAy[1].screen.x; + pCurrentTrackScreenXYZ->screenPtAy[4].screen.x = + pCurrentTrackScreenXYZ->screenPtAy[1].screen.x; iLeftWallCopyY = pCurrentTrackScreenXYZ->screenPtAy[1].screen.y; } pCurrentTrackScreenXYZ->screenPtAy[4].screen.y = iLeftWallCopyY; - pCurrentTrackScreenXYZ->screenPtAy[4].projected.fZ = (float)dLeftWallCopyZ; + pCurrentTrackScreenXYZ->screenPtAy[4].projected.fZ = + (float)dLeftWallCopyZ; } - if (TrakColour[iCurrentTrackIndex][TRAK_COLOUR_RIGHT_WALL] && pPrevLeftWallTypePtr[1]) { + if (TrakColour[iCurrentTrackIndex][TRAK_COLOUR_RIGHT_WALL] && + pPrevLeftWallTypePtr[1]) { pGroundPt2 = &TrakPt[iCurrentTrackIndex]; - dRightWallDeltaX = pGroundPt2->pointAy[5].fX - viewx;// Calculate right wall point (point 6) projection to screen coordinates + dRightWallDeltaX = pGroundPt2->pointAy[5].fX - + viewx; // Calculate right wall point (point 6) + // projection to screen coordinates dRightWallDeltaY = pGroundPt2->pointAy[5].fY - viewy; dRightWallDeltaZ = pGroundPt2->pointAy[5].fZ - viewz; - fRightWallCameraX = (float)(dRightWallDeltaX * vk1 + dRightWallDeltaY * vk4 + dRightWallDeltaZ * vk7); - fRightWallCameraY = (float)(dRightWallDeltaX * vk2 + dRightWallDeltaY * vk5 + dRightWallDeltaZ * vk8); - dRightWallCameraZ = dRightWallDeltaX * vk3 + dRightWallDeltaY * vk6 + dRightWallDeltaZ * vk9; + fRightWallCameraX = + (float)(dRightWallDeltaX * vk1 + dRightWallDeltaY * vk4 + + dRightWallDeltaZ * vk7); + fRightWallCameraY = + (float)(dRightWallDeltaX * vk2 + dRightWallDeltaY * vk5 + + dRightWallDeltaZ * vk8); + dRightWallCameraZ = dRightWallDeltaX * vk3 + dRightWallDeltaY * vk6 + + dRightWallDeltaZ * vk9; fRightWallCameraZ = (float)dRightWallCameraZ; - dRightWallCameraZ = round(dRightWallCameraZ);//_CHP(); + dRightWallCameraZ = round(dRightWallCameraZ); //_CHP(); iRightWallProjectedZ = (int)dRightWallCameraZ; if (fRightWallCameraZ < 80.0) fRightWallCameraZ = 80.0; dRightWallViewDist = (double)VIEWDIST; dRightWallInvZ = 1.0 / fRightWallCameraZ; - dRightWallScreenX = dRightWallViewDist * fRightWallCameraX * dRightWallInvZ + (double)xbase; - dRightWallScreenX = round(dRightWallScreenX);//_CHP(); + dRightWallScreenX = + dRightWallViewDist * fRightWallCameraX * dRightWallInvZ + + (double)xbase; + dRightWallScreenX = round(dRightWallScreenX); //_CHP(); xp = (int)dRightWallScreenX; - dRightWallScreenY = dRightWallInvZ * (dRightWallViewDist * fRightWallCameraY) + (double)ybase; + dRightWallScreenY = + dRightWallInvZ * (dRightWallViewDist * fRightWallCameraY) + + (double)ybase; iRightWallScrSize = scr_size; - dRightWallScreenY = round(dRightWallScreenY);//_CHP(); + dRightWallScreenY = round(dRightWallScreenY); //_CHP(); yp = (int)dRightWallScreenY; pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = xp * scr_size >> 6; - //pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = iRightWallScreenX >> 6; + // pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = iRightWallScreenX >> + // 6; iRightWallScreenY = iRightWallScrSize * (199 - yp); - pCurrentTrackScreenXYZ->screenPtAy[5].projected.fZ = (float)iRightWallProjectedZ; + pCurrentTrackScreenXYZ->screenPtAy[5].projected.fZ = + (float)iRightWallProjectedZ; pCurrentTrackScreenXYZ->screenPtAy[5].screen.y = iRightWallScreenY >> 6; pCurrentTrackScreenXYZ->screenPtAy[5].projected.fX = fRightWallCameraX; pCurrentTrackScreenXYZ->screenPtAy[5].projected.fY = fRightWallCameraY; - } else { // Copy right wall coordinates from existing points when walls are not present - if (TrakColour[iCurrentTrackIndex][TRAK_COLOUR_RIGHT_WALL] >= 0 && pPrevLeftWallTypePtr[1] >= 0) { - pCurrentTrackScreenXYZ->screenPtAy[5].projected.fX = pCurrentTrackScreenXYZ->screenPtAy[3].projected.fX; - pCurrentTrackScreenXYZ->screenPtAy[5].projected.fY = pCurrentTrackScreenXYZ->screenPtAy[3].projected.fY; - dRightWallDepthCopy = pCurrentTrackScreenXYZ->screenPtAy[3].projected.fZ; - pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = pCurrentTrackScreenXYZ->screenPtAy[3].screen.x; + } else { // Copy right wall coordinates from existing points when walls + // are not present + if (TrakColour[iCurrentTrackIndex][TRAK_COLOUR_RIGHT_WALL] >= 0 && + pPrevLeftWallTypePtr[1] >= 0) { + pCurrentTrackScreenXYZ->screenPtAy[5].projected.fX = + pCurrentTrackScreenXYZ->screenPtAy[3].projected.fX; + pCurrentTrackScreenXYZ->screenPtAy[5].projected.fY = + pCurrentTrackScreenXYZ->screenPtAy[3].projected.fY; + dRightWallDepthCopy = + pCurrentTrackScreenXYZ->screenPtAy[3].projected.fZ; + pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = + pCurrentTrackScreenXYZ->screenPtAy[3].screen.x; iRightWallCopy = pCurrentTrackScreenXYZ->screenPtAy[3].screen.y; } else { - pCurrentTrackScreenXYZ->screenPtAy[5].projected.fX = pCurrentTrackScreenXYZ->screenPtAy[2].projected.fX; - pCurrentTrackScreenXYZ->screenPtAy[5].projected.fY = pCurrentTrackScreenXYZ->screenPtAy[2].projected.fY; - dRightWallDepthCopy = pCurrentTrackScreenXYZ->screenPtAy[2].projected.fZ; - pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = pCurrentTrackScreenXYZ->screenPtAy[2].screen.x; + pCurrentTrackScreenXYZ->screenPtAy[5].projected.fX = + pCurrentTrackScreenXYZ->screenPtAy[2].projected.fX; + pCurrentTrackScreenXYZ->screenPtAy[5].projected.fY = + pCurrentTrackScreenXYZ->screenPtAy[2].projected.fY; + dRightWallDepthCopy = + pCurrentTrackScreenXYZ->screenPtAy[2].projected.fZ; + pCurrentTrackScreenXYZ->screenPtAy[5].screen.x = + pCurrentTrackScreenXYZ->screenPtAy[2].screen.x; iRightWallCopy = pCurrentTrackScreenXYZ->screenPtAy[2].screen.y; } pCurrentTrackScreenXYZ->screenPtAy[5].screen.y = iRightWallCopy; - pCurrentTrackScreenXYZ->screenPtAy[5].projected.fZ = (float)dRightWallDepthCopy; + pCurrentTrackScreenXYZ->screenPtAy[5].projected.fZ = + (float)dRightWallDepthCopy; } if (Banks_On) { pGroundScreenXYZ = &GroundScreenXYZ[iCurrentTrackIndex]; pScreenPoint = pGroundScreenXYZ->screenPtAy; pGroundScreenXYZ->iClipCount = 0; pCurrentGroundPt = &GroundPt[iCurrentTrackIndex]; - pCurrentGroundColour = &GroundColour[iCurrentTrackIndex][GROUND_COLOUR_LUOWALL]; + pCurrentGroundColour = + &GroundColour[iCurrentTrackIndex][GROUND_COLOUR_LUOWALL]; if (iCurrentTrackIndex) iPrevGroundIndex = iCurrentTrackIndex - 1; else iPrevGroundIndex = TRAK_LEN - 1; - pPrevGroundColour = &GroundColour[iPrevGroundIndex][GROUND_COLOUR_LUOWALL]; + pPrevGroundColour = + &GroundColour[iPrevGroundIndex][GROUND_COLOUR_LUOWALL]; iGroundPointIndex = 0; - //iIndexTmp2 = iCurrentTrackIndex << 7; + // iIndexTmp2 = iCurrentTrackIndex << 7; do { if (*pCurrentGroundColour != -1 || *pPrevGroundColour != -1) { - if (iGroundPointIndex < 2 || iGroundPointIndex > 3 || *pCurrentGroundColour != -2 || TrackScreenXYZ[iCurrentTrackIndex].iClipCount == 99) { - //if (iGroundPointIndex < 2 || iGroundPointIndex > 3 || *pCurrentGroundColour != -2 || *(_DWORD *)(iIndexTmp2 + 0xF03D4) == 99) { + if (iGroundPointIndex < 2 || iGroundPointIndex > 3 || + *pCurrentGroundColour != -2 || + TrackScreenXYZ[iCurrentTrackIndex].iClipCount == 99) { + // if (iGroundPointIndex < 2 || iGroundPointIndex > 3 || + // *pCurrentGroundColour != -2 || *(_DWORD *)(iIndexTmp2 + + // 0xF03D4) == 99) { dGroundDeltaX = pCurrentGroundPt->pointAy[0].fX - viewx; dGroundDeltaY = pCurrentGroundPt->pointAy[0].fY - viewy; pGroundPointZ = &pCurrentGroundPt->pointAy[0].fZ; dGroundDeltaZ = *pGroundPointZ - viewz; - fGroundCameraX = (float)(dGroundDeltaX * vk1 + dGroundDeltaY * vk4 + dGroundDeltaZ * vk7); - fGroundCameraY = (float)(dGroundDeltaX * vk2 + dGroundDeltaY * vk5 + dGroundDeltaZ * vk8); - dGroundCameraZ = dGroundDeltaX * vk3 + dGroundDeltaY * vk6 + dGroundDeltaZ * vk9; + fGroundCameraX = + (float)(dGroundDeltaX * vk1 + dGroundDeltaY * vk4 + + dGroundDeltaZ * vk7); + fGroundCameraY = + (float)(dGroundDeltaX * vk2 + dGroundDeltaY * vk5 + + dGroundDeltaZ * vk8); + dGroundCameraZ = dGroundDeltaX * vk3 + dGroundDeltaY * vk6 + + dGroundDeltaZ * vk9; fGroundCameraZ = (float)dGroundCameraZ; - dGroundCameraZ = round(dGroundCameraZ);//_CHP(); + dGroundCameraZ = round(dGroundCameraZ); //_CHP(); iGroundProjectedZ = (int)dGroundCameraZ; pCurrentGroundPt = (tGroundPt *)(pGroundPointZ + 1); if (fGroundCameraZ < 80.0) fGroundCameraZ = 80.0; dGroundViewDist = (double)VIEWDIST; dGroundInvZ = 1.0 / fGroundCameraZ; - dGroundScreenX = dGroundViewDist * fGroundCameraX * dGroundInvZ + (double)xbase; - dGroundScreenX = round(dGroundScreenX);//_CHP(); + dGroundScreenX = dGroundViewDist * fGroundCameraX * dGroundInvZ + + (double)xbase; + dGroundScreenX = round(dGroundScreenX); //_CHP(); xp = (int)dGroundScreenX; - dGroundScreenY = dGroundInvZ * (dGroundViewDist * fGroundCameraY) + (double)ybase; - dGroundScreenY = round(dGroundScreenY);//_CHP(); + dGroundScreenY = + dGroundInvZ * (dGroundViewDist * fGroundCameraY) + + (double)ybase; + dGroundScreenY = round(dGroundScreenY); //_CHP(); yp = (int)dGroundScreenY; pScreenPoint->screen.x = xp * scr_size >> 6; - //pScreenPoint->screen.x = iGroundScreenX >> 6; + // pScreenPoint->screen.x = iGroundScreenX >> 6; iGroundScreenY = scr_size * (199 - yp); pScreenPoint->projected.fZ = (float)iGroundProjectedZ; pScreenPoint->screen.y = iGroundScreenY >> 6; @@ -1661,29 +1811,51 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, goto LABEL_58; } if (iGroundPointIndex == 2) { - pScreenPoint->screen.x = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].screen.x; - pScreenPoint->screen.y = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].screen.y; - pScreenPoint->projected.fX = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].projected.fX; - pScreenPoint->projected.fY = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].projected.fY; - fGroundProjectedZ = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].projected.fZ; - //pScreenPoint->screen.x = *(int *)((char *)&TrackScreenXYZ[0].screenPtAy[0].screen.x + iIndexTmp2); - //pScreenPoint->screen.y = *(int *)((char *)&TrackScreenXYZ[0].screenPtAy[0].screen.y + iIndexTmp2); - //iGroundSectionOffset = iIndexTmp2; - //pScreenPoint->projected.fX = *(float *)((char *)&TrackScreenXYZ[0].screenPtAy[0].projected.fX + iIndexTmp2); - //pScreenPoint->projected.fY = *(float *)((char *)&TrackScreenXYZ[0].screenPtAy[0].projected.fY + iGroundSectionOffset); - //fGroundProjectedZ = *(float *)((char *)&TrackScreenXYZ[0].screenPtAy[0].projected.fZ + iGroundSectionOffset); + pScreenPoint->screen.x = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].screen.x; + pScreenPoint->screen.y = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].screen.y; + pScreenPoint->projected.fX = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].projected.fX; + pScreenPoint->projected.fY = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].projected.fY; + fGroundProjectedZ = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[0].projected.fZ; + // pScreenPoint->screen.x = *(int *)((char + // *)&TrackScreenXYZ[0].screenPtAy[0].screen.x + iIndexTmp2); + // pScreenPoint->screen.y = *(int *)((char + // *)&TrackScreenXYZ[0].screenPtAy[0].screen.y + iIndexTmp2); + // iGroundSectionOffset = iIndexTmp2; + // pScreenPoint->projected.fX = *(float *)((char + // *)&TrackScreenXYZ[0].screenPtAy[0].projected.fX + iIndexTmp2); + // pScreenPoint->projected.fY = *(float *)((char + // *)&TrackScreenXYZ[0].screenPtAy[0].projected.fY + + // iGroundSectionOffset); fGroundProjectedZ = *(float *)((char + // *)&TrackScreenXYZ[0].screenPtAy[0].projected.fZ + + // iGroundSectionOffset); } else { - pScreenPoint->screen.x = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].screen.x; - pScreenPoint->screen.y = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].screen.y; - pScreenPoint->projected.fX = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].projected.fX; - pScreenPoint->projected.fY = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].projected.fY; - fGroundProjectedZ = TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].projected.fZ; - //pScreenPoint->screen.x = *(int *)((char *)&TrackScreenXYZ[0].screenPtAy[3].screen.x + iIndexTmp2); - //pScreenPoint->screen.y = *(int *)((char *)&TrackScreenXYZ[0].screenPtAy[3].screen.y + iIndexTmp2); - //iGroundSectionOffset2 = iIndexTmp2; - //pScreenPoint->projected.fX = *(float *)((char *)&TrackScreenXYZ[0].screenPtAy[3].projected.fX + iIndexTmp2); - //pScreenPoint->projected.fY = *(float *)((char *)&TrackScreenXYZ[0].screenPtAy[3].projected.fY + iGroundSectionOffset2); - //fGroundProjectedZ = *(float *)((char *)&TrackScreenXYZ[0].screenPtAy[3].projected.fZ + iGroundSectionOffset2); + pScreenPoint->screen.x = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].screen.x; + pScreenPoint->screen.y = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].screen.y; + pScreenPoint->projected.fX = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].projected.fX; + pScreenPoint->projected.fY = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].projected.fY; + fGroundProjectedZ = + TrackScreenXYZ[iCurrentTrackIndex].screenPtAy[3].projected.fZ; + // pScreenPoint->screen.x = *(int *)((char + // *)&TrackScreenXYZ[0].screenPtAy[3].screen.x + iIndexTmp2); + // pScreenPoint->screen.y = *(int *)((char + // *)&TrackScreenXYZ[0].screenPtAy[3].screen.y + iIndexTmp2); + // iGroundSectionOffset2 = iIndexTmp2; + // pScreenPoint->projected.fX = *(float *)((char + // *)&TrackScreenXYZ[0].screenPtAy[3].projected.fX + iIndexTmp2); + // pScreenPoint->projected.fY = *(float *)((char + // *)&TrackScreenXYZ[0].screenPtAy[3].projected.fY + + // iGroundSectionOffset2); fGroundProjectedZ = *(float *)((char + // *)&TrackScreenXYZ[0].screenPtAy[3].projected.fZ + + // iGroundSectionOffset2); } pScreenPoint->projected.fZ = fGroundProjectedZ; } @@ -1699,7 +1871,8 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, } } } - iTrackLoopCounter = TrackSize; // Second phase: Build render list by traversing track backwards + iTrackLoopCounter = TrackSize; // Second phase: Build render list by + // traversing track backwards num_bits = 0; render_queue_3d_clear(render_queue_3d_global()); if (TrackSize >= 0) { @@ -1718,17 +1891,23 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, iNextSectionIndex += TRAK_LEN; if (iNextSectionIndex >= TRAK_LEN) iNextSectionIndex -= TRAK_LEN; - //iSectionOffset = iNextSectionIndex; + // iSectionOffset = iNextSectionIndex; NextSect[iCurrentSect] = iNextSectionIndex; - //iSectionOffset <<= 7; + // iSectionOffset <<= 7; pScreenCoord_1 = &TrackScreenXYZ[iCurrentSect]; pNextGroundScreen = &GroundScreenXYZ[iNextSectionIndex]; pScreenCoord = &TrackScreenXYZ[iNextSectionIndex]; - //pNextGroundScreen = (tTrackScreenXYZ *)((char *)GroundScreenXYZ + iSectionOffset); - //pScreenCoord = (tTrackScreenXYZ *)((char *)TrackScreenXYZ + iSectionOffset); - iOFloorType = GroundColour[iCurrentSect][GROUND_COLOUR_OFLOOR];// Check if ground floor is visible and banks are enabled + // pNextGroundScreen = (tTrackScreenXYZ *)((char *)GroundScreenXYZ + + // iSectionOffset); pScreenCoord = (tTrackScreenXYZ *)((char + // *)TrackScreenXYZ + iSectionOffset); + iOFloorType = + GroundColour[iCurrentSect] + [GROUND_COLOUR_OFLOOR]; // Check if ground floor is visible + // and banks are enabled pCurrentGroundScreen = &GroundScreenXYZ[iCurrentSect]; - bFloorVisible = iOFloorType != -1 && GroundColour[iNextSectionIndex][GROUND_COLOUR_OFLOOR] != -1 && Banks_On; + bFloorVisible = + iOFloorType != -1 && + GroundColour[iNextSectionIndex][GROUND_COLOUR_OFLOOR] != -1 && Banks_On; iCurrentFloorType = GroundColour[iCurrentSect][GROUND_COLOUR_OFLOOR]; bGroundVisible = bFloorVisible; if (iCurrentFloorType != -2 && bFloorVisible) { @@ -1737,24 +1916,28 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, if (iNextSectionIndex + 2 >= TRAK_LEN) iTrackIndexPlus2 -= TRAK_LEN; pTrackScreenPlus2 = &TrackScreenXYZ[iTrackIndexPlus2]; - if (pTrackScreenPlus2->screenPtAy[2].projected.fZ <= (double)pTrackScreenPlus2->screenPtAy[1].projected.fZ) + if (pTrackScreenPlus2->screenPtAy[2].projected.fZ <= + (double)pTrackScreenPlus2->screenPtAy[1].projected.fZ) fTrackDepthChoice1 = pTrackScreenPlus2->screenPtAy[1].projected.fZ; else fTrackDepthChoice1 = pTrackScreenPlus2->screenPtAy[2].projected.fZ; fTrackDepthTmp1 = fTrackDepthChoice1; - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fTrackDepthChoice2 = pScreenCoord->screenPtAy[1].projected.fZ; else fTrackDepthChoice2 = pScreenCoord->screenPtAy[2].projected.fZ; fTrackDepthTmp2 = fTrackDepthChoice2; if (fTrackDepthTmp1 <= (double)fTrackDepthChoice2) { - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fTrackDepthFinal = pScreenCoord->screenPtAy[1].projected.fZ; else fTrackDepthFinal = pScreenCoord->screenPtAy[2].projected.fZ; fDepthValuesArray[8] = fTrackDepthFinal; } else { - if (pTrackScreenPlus2->screenPtAy[2].projected.fZ <= (double)pTrackScreenPlus2->screenPtAy[1].projected.fZ) + if (pTrackScreenPlus2->screenPtAy[2].projected.fZ <= + (double)pTrackScreenPlus2->screenPtAy[1].projected.fZ) fTrackDepthFinal = pTrackScreenPlus2->screenPtAy[1].projected.fZ; else fTrackDepthFinal = pTrackScreenPlus2->screenPtAy[2].projected.fZ; @@ -1764,33 +1947,42 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, fProjectionZ = fTrackDepthFinal; pScreenCoord_1 = &TrackScreenXYZ[iCurrentSect]; } else { - if (pNextGroundScreen->screenPtAy[2].projected.fZ <= (double)pNextGroundScreen->screenPtAy[3].projected.fZ) + if (pNextGroundScreen->screenPtAy[2].projected.fZ <= + (double)pNextGroundScreen->screenPtAy[3].projected.fZ) fGroundDepthMax1 = pNextGroundScreen->screenPtAy[3].projected.fZ; else fGroundDepthMax1 = pNextGroundScreen->screenPtAy[2].projected.fZ; fGroundDepth1 = fGroundDepthMax1; - if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= (double)pCurrentGroundScreen->screenPtAy[3].projected.fZ) + if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= + (double)pCurrentGroundScreen->screenPtAy[3].projected.fZ) fGroundDepthMax2 = pCurrentGroundScreen->screenPtAy[3].projected.fZ; else fGroundDepthMax2 = pCurrentGroundScreen->screenPtAy[2].projected.fZ; fGroundDepthTmp1 = fGroundDepthMax2; if (fGroundDepth1 <= (double)fGroundDepthMax2) { - if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= (double)pCurrentGroundScreen->screenPtAy[3].projected.fZ) - fGroundDepthSelected = pCurrentGroundScreen->screenPtAy[3].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= + (double)pCurrentGroundScreen->screenPtAy[3].projected.fZ) + fGroundDepthSelected = + pCurrentGroundScreen->screenPtAy[3].projected.fZ; else - fGroundDepthSelected = pCurrentGroundScreen->screenPtAy[2].projected.fZ; + fGroundDepthSelected = + pCurrentGroundScreen->screenPtAy[2].projected.fZ; fGroundDepthTmp4 = fGroundDepthSelected; } else { - if (pNextGroundScreen->screenPtAy[2].projected.fZ <= (double)pNextGroundScreen->screenPtAy[3].projected.fZ) - fGroundDepthSelected = pNextGroundScreen->screenPtAy[3].projected.fZ; + if (pNextGroundScreen->screenPtAy[2].projected.fZ <= + (double)pNextGroundScreen->screenPtAy[3].projected.fZ) + fGroundDepthSelected = + pNextGroundScreen->screenPtAy[3].projected.fZ; else - fGroundDepthSelected = pNextGroundScreen->screenPtAy[2].projected.fZ; + fGroundDepthSelected = + pNextGroundScreen->screenPtAy[2].projected.fZ; fGroundDepthTmp3 = fGroundDepthSelected; } fGroundDepthTmp2 = fGroundDepthSelected; fProjectionZ = fGroundDepthSelected; } - pGroundRenderCmd = &TrackView[num_bits]; // Add ground floor polygon to render list + pGroundRenderCmd = + &TrackView[num_bits]; // Add ground floor polygon to render list fGroundRenderDepth = fProjectionZ; iGroundRenderIndex = num_bits; pGroundRenderCmd->nRenderPriority = 2; @@ -1798,32 +1990,38 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, num_bits = iGroundRenderIndex + 1; pGroundRenderCmd->fZDepth = fGroundRenderDepth; } - if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99 && Road_On) { - if (pScreenCoord_1->screenPtAy[2].projected.fZ <= (double)pScreenCoord_1->screenPtAy[1].projected.fZ) + if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99 && + Road_On) { + if (pScreenCoord_1->screenPtAy[2].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[1].projected.fZ) fRoadCenterDepthMax1 = pScreenCoord_1->screenPtAy[1].projected.fZ; else fRoadCenterDepthMax1 = pScreenCoord_1->screenPtAy[2].projected.fZ; fRoadCenterDepth1 = fRoadCenterDepthMax1; - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fRoadCenterDepthMax2 = pScreenCoord->screenPtAy[1].projected.fZ; else fRoadCenterDepthMax2 = pScreenCoord->screenPtAy[2].projected.fZ; fRoadCenterDepth2 = fRoadCenterDepthMax2; if (fRoadCenterDepth1 <= (double)fRoadCenterDepthMax2) { - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fRoadCenterDepthSelected = pScreenCoord->screenPtAy[1].projected.fZ; else fRoadCenterDepthSelected = pScreenCoord->screenPtAy[2].projected.fZ; fRoadCenterDepthFar = fRoadCenterDepthSelected; } else { - if (pScreenCoord_1->screenPtAy[2].projected.fZ <= (double)pScreenCoord_1->screenPtAy[1].projected.fZ) + if (pScreenCoord_1->screenPtAy[2].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[1].projected.fZ) fRoadCenterDepthSelected = pScreenCoord_1->screenPtAy[1].projected.fZ; else fRoadCenterDepthSelected = pScreenCoord_1->screenPtAy[2].projected.fZ; fRoadCenterDepthNear = fRoadCenterDepthSelected; } fRoadCenterFinalDepth = fRoadCenterDepthSelected; - pRoadCenterCmd = &TrackView[num_bits]; // Add road center polygon to render list + pRoadCenterCmd = + &TrackView[num_bits]; // Add road center polygon to render list fRoadCenterCmdDepth = fRoadCenterFinalDepth; iRoadCenterCmdIndex = num_bits; pRoadCenterCmd->nRenderPriority = 5; @@ -1831,32 +2029,38 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, num_bits = iRoadCenterCmdIndex + 1; pRoadCenterCmd->fZDepth = fRoadCenterCmdDepth; } - if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99 && Road_On) { - if (pScreenCoord_1->screenPtAy[0].projected.fZ <= (double)pScreenCoord_1->screenPtAy[1].projected.fZ) + if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99 && + Road_On) { + if (pScreenCoord_1->screenPtAy[0].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[1].projected.fZ) fLeftRoadDepthMax1 = pScreenCoord_1->screenPtAy[1].projected.fZ; else fLeftRoadDepthMax1 = pScreenCoord_1->screenPtAy[0].projected.fZ; fLeftRoadDepth1 = fLeftRoadDepthMax1; - if (pScreenCoord->screenPtAy[0].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[0].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fLeftRoadDepthMax2 = pScreenCoord->screenPtAy[1].projected.fZ; else fLeftRoadDepthMax2 = pScreenCoord->screenPtAy[0].projected.fZ; fLeftRoadDepth2 = fLeftRoadDepthMax2; if (fLeftRoadDepth1 <= (double)fLeftRoadDepthMax2) { - if (pScreenCoord->screenPtAy[0].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[0].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fLeftRoadDepthSelected = pScreenCoord->screenPtAy[1].projected.fZ; else fLeftRoadDepthSelected = pScreenCoord->screenPtAy[0].projected.fZ; fLeftRoadTmp2 = fLeftRoadDepthSelected; } else { - if (pScreenCoord_1->screenPtAy[0].projected.fZ <= (double)pScreenCoord_1->screenPtAy[1].projected.fZ) + if (pScreenCoord_1->screenPtAy[0].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[1].projected.fZ) fLeftRoadDepthSelected = pScreenCoord_1->screenPtAy[1].projected.fZ; else fLeftRoadDepthSelected = pScreenCoord_1->screenPtAy[0].projected.fZ; fLeftRoadTmp1 = fLeftRoadDepthSelected; } fLeftRoadFinalDepth = fLeftRoadDepthSelected; - pLeftRoadCmd = &TrackView[num_bits]; // Add road left side polygon to render list + pLeftRoadCmd = + &TrackView[num_bits]; // Add road left side polygon to render list fLeftRoadCmdDepth = fLeftRoadFinalDepth; iLeftRoadCmdIndex = num_bits; pLeftRoadCmd->nRenderPriority = 6; @@ -1864,32 +2068,38 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, num_bits = iLeftRoadCmdIndex + 1; pLeftRoadCmd->fZDepth = fLeftRoadCmdDepth; } - if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99 && Road_On) { - if (pScreenCoord_1->screenPtAy[2].projected.fZ <= (double)pScreenCoord_1->screenPtAy[3].projected.fZ) + if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99 && + Road_On) { + if (pScreenCoord_1->screenPtAy[2].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[3].projected.fZ) fRightRoadDepthMax1 = pScreenCoord_1->screenPtAy[3].projected.fZ; else fRightRoadDepthMax1 = pScreenCoord_1->screenPtAy[2].projected.fZ; fRightRoadDepth1 = fRightRoadDepthMax1; - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[3].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[3].projected.fZ) fRightRoadDepthMax2 = pScreenCoord->screenPtAy[3].projected.fZ; else fRightRoadDepthMax2 = pScreenCoord->screenPtAy[2].projected.fZ; fRightRoadDepth2 = fRightRoadDepthMax2; if (fRightRoadDepth1 <= (double)fRightRoadDepthMax2) { - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[3].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[3].projected.fZ) fRightRoadDepthSelected = pScreenCoord->screenPtAy[3].projected.fZ; else fRightRoadDepthSelected = pScreenCoord->screenPtAy[2].projected.fZ; fRightRoadDepthFar = fRightRoadDepthSelected; } else { - if (pScreenCoord_1->screenPtAy[2].projected.fZ <= (double)pScreenCoord_1->screenPtAy[3].projected.fZ) + if (pScreenCoord_1->screenPtAy[2].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[3].projected.fZ) fRightRoadDepthSelected = pScreenCoord_1->screenPtAy[3].projected.fZ; else fRightRoadDepthSelected = pScreenCoord_1->screenPtAy[2].projected.fZ; fRightRoadDepthNear = fRightRoadDepthSelected; } fRightRoadFinalDepth = fRightRoadDepthSelected; - pRightRoadCmd = &TrackView[num_bits]; // Add road right side polygon to render list + pRightRoadCmd = + &TrackView[num_bits]; // Add road right side polygon to render list fRightRoadCmdDepth = fRightRoadFinalDepth; iRightRoadCmdIndex = num_bits; pRightRoadCmd->nRenderPriority = 7; @@ -1900,35 +2110,46 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, if (pScreenCoord_1->iClipCount != 99 && pScreenCoord->iClipCount != 99) { if (Walls_On) { iRoofTypeCheck = TrakColour[iCurrentSect][TRAK_COLOUR_ROOF]; - //TODO look at this line - if (iRoofTypeCheck != -1 && TrakColour[iCurrentSect][TRAK_COLOUR_LEFT_WALL] && TrakColour[iCurrentSect][TRAK_COLOUR_RIGHT_WALL]) { - //if (iRoofTypeCheck != -1 && iLeftWallFlags && iRightWallFlags) { + // TODO look at this line + if (iRoofTypeCheck != -1 && + TrakColour[iCurrentSect][TRAK_COLOUR_LEFT_WALL] && + TrakColour[iCurrentSect][TRAK_COLOUR_RIGHT_WALL]) { + // if (iRoofTypeCheck != -1 && iLeftWallFlags && iRightWallFlags) { if (iRoofTypeCheck < 0) { - if (pNextGroundScreen->screenPtAy[5].projected.fZ >= (double)pNextGroundScreen->screenPtAy[0].projected.fZ) + if (pNextGroundScreen->screenPtAy[5].projected.fZ >= + (double)pNextGroundScreen->screenPtAy[0].projected.fZ) fRoof1OuterDepth = pNextGroundScreen->screenPtAy[0].projected.fZ; else fRoof1OuterDepth = pNextGroundScreen->screenPtAy[5].projected.fZ; fRoof1OuterDepthTmp = fRoof1OuterDepth; - if (pNextGroundScreen->screenPtAy[1].projected.fZ >= (double)pNextGroundScreen->screenPtAy[4].projected.fZ) + if (pNextGroundScreen->screenPtAy[1].projected.fZ >= + (double)pNextGroundScreen->screenPtAy[4].projected.fZ) fRoof1InnerDepth = pNextGroundScreen->screenPtAy[4].projected.fZ; else fRoof1InnerDepth = pNextGroundScreen->screenPtAy[1].projected.fZ; fRoof1InnerDepthTmp = fRoof1InnerDepth; if (fRoof1OuterDepthTmp >= (double)fRoof1InnerDepth) { - if (pNextGroundScreen->screenPtAy[1].projected.fZ >= (double)pNextGroundScreen->screenPtAy[4].projected.fZ) - fRoof1SelectedDepth = pNextGroundScreen->screenPtAy[4].projected.fZ; + if (pNextGroundScreen->screenPtAy[1].projected.fZ >= + (double)pNextGroundScreen->screenPtAy[4].projected.fZ) + fRoof1SelectedDepth = + pNextGroundScreen->screenPtAy[4].projected.fZ; else - fRoof1SelectedDepth = pNextGroundScreen->screenPtAy[1].projected.fZ; + fRoof1SelectedDepth = + pNextGroundScreen->screenPtAy[1].projected.fZ; fRoof1DepthInner = fRoof1SelectedDepth; } else { - if (pNextGroundScreen->screenPtAy[5].projected.fZ >= (double)pNextGroundScreen->screenPtAy[0].projected.fZ) - fRoof1SelectedDepth = pNextGroundScreen->screenPtAy[0].projected.fZ; + if (pNextGroundScreen->screenPtAy[5].projected.fZ >= + (double)pNextGroundScreen->screenPtAy[0].projected.fZ) + fRoof1SelectedDepth = + pNextGroundScreen->screenPtAy[0].projected.fZ; else - fRoof1SelectedDepth = pNextGroundScreen->screenPtAy[5].projected.fZ; + fRoof1SelectedDepth = + pNextGroundScreen->screenPtAy[5].projected.fZ; fRoof1DepthOuter = fRoof1SelectedDepth; } fRoof1DepthSelected = fRoof1SelectedDepth; - pRoof1RenderCmd = &TrackView[num_bits];// Add roof/ceiling polygon to render list + pRoof1RenderCmd = + &TrackView[num_bits]; // Add roof/ceiling polygon to render list pRoof1RenderCmd->nRenderPriority = 10; fRoof1CmdDepth = fRoof1DepthSelected; pRoof1RenderCmd->nChunkIdx = iCurrentSect; @@ -1940,27 +2161,39 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, if (iRoofType <= 0) { if (iRoofType >= -1) goto LABEL_238; - if (pCurrentGroundScreen->screenPtAy[5].projected.fZ >= (double)pCurrentGroundScreen->screenPtAy[0].projected.fZ) - fRoof3OuterDepth = pCurrentGroundScreen->screenPtAy[0].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[5].projected.fZ >= + (double)pCurrentGroundScreen->screenPtAy[0].projected.fZ) + fRoof3OuterDepth = + pCurrentGroundScreen->screenPtAy[0].projected.fZ; else - fRoof3OuterDepth = pCurrentGroundScreen->screenPtAy[5].projected.fZ; + fRoof3OuterDepth = + pCurrentGroundScreen->screenPtAy[5].projected.fZ; fRoof3OuterDepthTmp = fRoof3OuterDepth; - if (pCurrentGroundScreen->screenPtAy[1].projected.fZ >= (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) - fRoof3InnerDepth = pCurrentGroundScreen->screenPtAy[4].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[1].projected.fZ >= + (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) + fRoof3InnerDepth = + pCurrentGroundScreen->screenPtAy[4].projected.fZ; else - fRoof3InnerDepth = pCurrentGroundScreen->screenPtAy[1].projected.fZ; + fRoof3InnerDepth = + pCurrentGroundScreen->screenPtAy[1].projected.fZ; fRoof3InnerDepthTmp = fRoof3InnerDepth; if (fRoof3OuterDepthTmp >= (double)fRoof3InnerDepth) { - if (pCurrentGroundScreen->screenPtAy[1].projected.fZ >= (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) - fRoof3SelectedDepth = pCurrentGroundScreen->screenPtAy[4].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[1].projected.fZ >= + (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) + fRoof3SelectedDepth = + pCurrentGroundScreen->screenPtAy[4].projected.fZ; else - fRoof3SelectedDepth = pCurrentGroundScreen->screenPtAy[1].projected.fZ; + fRoof3SelectedDepth = + pCurrentGroundScreen->screenPtAy[1].projected.fZ; fRoof3DepthInner = fRoof3SelectedDepth; } else { - if (pCurrentGroundScreen->screenPtAy[5].projected.fZ >= (double)pCurrentGroundScreen->screenPtAy[0].projected.fZ) - fRoof3SelectedDepth = pCurrentGroundScreen->screenPtAy[0].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[5].projected.fZ >= + (double)pCurrentGroundScreen->screenPtAy[0].projected.fZ) + fRoof3SelectedDepth = + pCurrentGroundScreen->screenPtAy[0].projected.fZ; else - fRoof3SelectedDepth = pCurrentGroundScreen->screenPtAy[5].projected.fZ; + fRoof3SelectedDepth = + pCurrentGroundScreen->screenPtAy[5].projected.fZ; fRoof3DepthOuter = fRoof3SelectedDepth; } fRoof3DepthSelected = fRoof3SelectedDepth; @@ -1971,15 +2204,16 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, dRoof2WallDepth1 = pScreenCoord_1->screenPtAy[3].projected.fZ; else dRoof2WallDepth1 = pScreenCoord_1->screenPtAy[2].projected.fZ; - dRoof2WallDepth1 = round(dRoof2WallDepth1);//_CHP(); + dRoof2WallDepth1 = round(dRoof2WallDepth1); //_CHP(); iRightWallFlags = (int)dRoof2WallDepth1; if (TrakColour[iCurrentSect][TRAK_COLOUR_LEFT_WALL] >= 0) dRoof2WallDepth2 = pScreenCoord_1->screenPtAy[0].projected.fZ; else dRoof2WallDepth2 = pScreenCoord_1->screenPtAy[1].projected.fZ; - dRoof2WallDepth2 = round(dRoof2WallDepth2);//_CHP(); + dRoof2WallDepth2 = round(dRoof2WallDepth2); //_CHP(); iLeftWallFlags = (int)dRoof2WallDepth2; - if (pScreenCoord_1->screenPtAy[4].projected.fZ >= (double)pScreenCoord_1->screenPtAy[5].projected.fZ) + if (pScreenCoord_1->screenPtAy[4].projected.fZ >= + (double)pScreenCoord_1->screenPtAy[5].projected.fZ) fRoof2WallMinDepth = pScreenCoord_1->screenPtAy[5].projected.fZ; else fRoof2WallMinDepth = pScreenCoord_1->screenPtAy[4].projected.fZ; @@ -1989,10 +2223,13 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, else iRoof2WallDepthMin = iRightWallFlags; if ((double)iRoof2WallDepthMin >= fRoof2WallMinDepthTmp) { - if (pScreenCoord_1->screenPtAy[4].projected.fZ >= (double)pScreenCoord_1->screenPtAy[5].projected.fZ) - fRoof2SelectedDepth = pScreenCoord_1->screenPtAy[5].projected.fZ; + if (pScreenCoord_1->screenPtAy[4].projected.fZ >= + (double)pScreenCoord_1->screenPtAy[5].projected.fZ) + fRoof2SelectedDepth = + pScreenCoord_1->screenPtAy[5].projected.fZ; else - fRoof2SelectedDepth = pScreenCoord_1->screenPtAy[4].projected.fZ; + fRoof2SelectedDepth = + pScreenCoord_1->screenPtAy[4].projected.fZ; fRoof2DepthWall = fRoof2SelectedDepth; fRoof2DepthSelected = fRoof2SelectedDepth; } else { @@ -2014,64 +2251,86 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, } } LABEL_238: - if (GroundColour[iCurrentSect][GROUND_COLOUR_LLOWALL] != -1 && bGroundVisible) { - if (pNextGroundScreen->screenPtAy[2].projected.fZ <= (double)pNextGroundScreen->screenPtAy[1].projected.fZ) + if (GroundColour[iCurrentSect][GROUND_COLOUR_LLOWALL] != -1 && + bGroundVisible) { + if (pNextGroundScreen->screenPtAy[2].projected.fZ <= + (double)pNextGroundScreen->screenPtAy[1].projected.fZ) fLeftLowerWallDepth1 = pNextGroundScreen->screenPtAy[1].projected.fZ; else fLeftLowerWallDepth1 = pNextGroundScreen->screenPtAy[2].projected.fZ; fLeftLowerWallDepthNear = fLeftLowerWallDepth1; - if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= (double)pCurrentGroundScreen->screenPtAy[1].projected.fZ) + if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= + (double)pCurrentGroundScreen->screenPtAy[1].projected.fZ) fLeftLowerWallDepth2 = pCurrentGroundScreen->screenPtAy[1].projected.fZ; else fLeftLowerWallDepth2 = pCurrentGroundScreen->screenPtAy[2].projected.fZ; fLeftLowerWallDepthFar = fLeftLowerWallDepth2; if (fLeftLowerWallDepthNear <= (double)fLeftLowerWallDepth2) { - if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= (double)pCurrentGroundScreen->screenPtAy[1].projected.fZ) - fLeftLowerWallSelected = pCurrentGroundScreen->screenPtAy[1].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[2].projected.fZ <= + (double)pCurrentGroundScreen->screenPtAy[1].projected.fZ) + fLeftLowerWallSelected = + pCurrentGroundScreen->screenPtAy[1].projected.fZ; else - fLeftLowerWallSelected = pCurrentGroundScreen->screenPtAy[2].projected.fZ; + fLeftLowerWallSelected = + pCurrentGroundScreen->screenPtAy[2].projected.fZ; fLeftLowerWallDepthTmp2 = fLeftLowerWallSelected; } else { - if (pNextGroundScreen->screenPtAy[2].projected.fZ <= (double)pNextGroundScreen->screenPtAy[1].projected.fZ) - fLeftLowerWallSelected = pNextGroundScreen->screenPtAy[1].projected.fZ; + if (pNextGroundScreen->screenPtAy[2].projected.fZ <= + (double)pNextGroundScreen->screenPtAy[1].projected.fZ) + fLeftLowerWallSelected = + pNextGroundScreen->screenPtAy[1].projected.fZ; else - fLeftLowerWallSelected = pNextGroundScreen->screenPtAy[2].projected.fZ; + fLeftLowerWallSelected = + pNextGroundScreen->screenPtAy[2].projected.fZ; fLeftLowerWallDepthTmp1 = fLeftLowerWallSelected; } fLeftLowerWallDepthSelected = fLeftLowerWallSelected; - pLeftLowerWallCmd = &TrackView[num_bits]; // Add left lower wall polygon to render list + pLeftLowerWallCmd = + &TrackView[num_bits]; // Add left lower wall polygon to render list pLeftLowerWallCmd->nRenderPriority = 3; fLeftLowerWallCmdDepth = fLeftLowerWallDepthSelected; pLeftLowerWallCmd->nChunkIdx = iCurrentSect; pLeftLowerWallCmd->fZDepth = fLeftLowerWallCmdDepth; ++num_bits; } - if (GroundColour[iCurrentSect][GROUND_COLOUR_RLOWALL] != -1 && bGroundVisible) { - if (pNextGroundScreen->screenPtAy[3].projected.fZ <= (double)pNextGroundScreen->screenPtAy[4].projected.fZ) + if (GroundColour[iCurrentSect][GROUND_COLOUR_RLOWALL] != -1 && + bGroundVisible) { + if (pNextGroundScreen->screenPtAy[3].projected.fZ <= + (double)pNextGroundScreen->screenPtAy[4].projected.fZ) fRightLowerWallDepth1 = pNextGroundScreen->screenPtAy[4].projected.fZ; else fRightLowerWallDepth1 = pNextGroundScreen->screenPtAy[3].projected.fZ; fRightLowerWallDepthNear = fRightLowerWallDepth1; - if (pCurrentGroundScreen->screenPtAy[3].projected.fZ <= (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) - fRightLowerWallDepth2 = pCurrentGroundScreen->screenPtAy[4].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[3].projected.fZ <= + (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) + fRightLowerWallDepth2 = + pCurrentGroundScreen->screenPtAy[4].projected.fZ; else - fRightLowerWallDepth2 = pCurrentGroundScreen->screenPtAy[3].projected.fZ; + fRightLowerWallDepth2 = + pCurrentGroundScreen->screenPtAy[3].projected.fZ; fRightLowerWallDepthFar = fRightLowerWallDepth2; if (fRightLowerWallDepthNear <= (double)fRightLowerWallDepth2) { - if (pCurrentGroundScreen->screenPtAy[3].projected.fZ <= (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) - fRightLowerWallSelected = pCurrentGroundScreen->screenPtAy[4].projected.fZ; + if (pCurrentGroundScreen->screenPtAy[3].projected.fZ <= + (double)pCurrentGroundScreen->screenPtAy[4].projected.fZ) + fRightLowerWallSelected = + pCurrentGroundScreen->screenPtAy[4].projected.fZ; else - fRightLowerWallSelected = pCurrentGroundScreen->screenPtAy[3].projected.fZ; + fRightLowerWallSelected = + pCurrentGroundScreen->screenPtAy[3].projected.fZ; fRightLowerWallDepthTmp2 = fRightLowerWallSelected; } else { - if (pNextGroundScreen->screenPtAy[3].projected.fZ <= (double)pNextGroundScreen->screenPtAy[4].projected.fZ) - fRightLowerWallSelected = pNextGroundScreen->screenPtAy[4].projected.fZ; + if (pNextGroundScreen->screenPtAy[3].projected.fZ <= + (double)pNextGroundScreen->screenPtAy[4].projected.fZ) + fRightLowerWallSelected = + pNextGroundScreen->screenPtAy[4].projected.fZ; else - fRightLowerWallSelected = pNextGroundScreen->screenPtAy[3].projected.fZ; + fRightLowerWallSelected = + pNextGroundScreen->screenPtAy[3].projected.fZ; fRightLowerWallDepthTmp1 = fRightLowerWallSelected; } fRightLowerWallDepthSelected = fRightLowerWallSelected; - pRightLowerWallCmd = &TrackView[num_bits];// Add right lower wall polygon to render list + pRightLowerWallCmd = + &TrackView[num_bits]; // Add right lower wall polygon to render list pRightLowerWallCmd->nRenderPriority = 4; fRightLowerWallCmdDepth = fRightLowerWallDepthSelected; pRightLowerWallCmd->nChunkIdx = iCurrentSect; @@ -2082,39 +2341,51 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, if (Walls_On) { iLeftWallFlags = TrakColour[iCurrentSect][TRAK_COLOUR_LEFT_WALL]; if (iLeftWallFlags) { - if (TrackInfo[iCurrentSect].fRoofHeight >= 0.0 && TrackInfo[iNextSectionIndex].fRoofHeight >= 0.0) { + if (TrackInfo[iCurrentSect].fRoofHeight >= 0.0 && + TrackInfo[iNextSectionIndex].fRoofHeight >= 0.0) { if (iLeftWallFlags >= 0) { - if (pScreenCoord->screenPtAy[0].projected.fZ <= (double)pScreenCoord_1->screenPtAy[0].projected.fZ) - fRightWallDepthMax1 = pScreenCoord_1->screenPtAy[0].projected.fZ; + if (pScreenCoord->screenPtAy[0].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[0].projected.fZ) + fRightWallDepthMax1 = + pScreenCoord_1->screenPtAy[0].projected.fZ; else fRightWallDepthMax1 = pScreenCoord->screenPtAy[0].projected.fZ; fLeftWallDepthTmp3 = fRightWallDepthMax1; - if (pScreenCoord->screenPtAy[4].projected.fZ <= (double)pScreenCoord_1->screenPtAy[4].projected.fZ) - fRightWallDepthMax2 = pScreenCoord_1->screenPtAy[4].projected.fZ; + if (pScreenCoord->screenPtAy[4].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[4].projected.fZ) + fRightWallDepthMax2 = + pScreenCoord_1->screenPtAy[4].projected.fZ; else fRightWallDepthMax2 = pScreenCoord->screenPtAy[4].projected.fZ; fLeftWallDepthTmp4 = fRightWallDepthMax2; if (fLeftWallDepthTmp3 <= (double)fRightWallDepthMax2) { - if (pScreenCoord->screenPtAy[4].projected.fZ <= (double)pScreenCoord_1->screenPtAy[4].projected.fZ) - fRightWallDepthSelected = pScreenCoord_1->screenPtAy[4].projected.fZ; + if (pScreenCoord->screenPtAy[4].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[4].projected.fZ) + fRightWallDepthSelected = + pScreenCoord_1->screenPtAy[4].projected.fZ; else - fRightWallDepthSelected = pScreenCoord->screenPtAy[4].projected.fZ; + fRightWallDepthSelected = + pScreenCoord->screenPtAy[4].projected.fZ; fLeftWallDepthTmp7 = fRightWallDepthSelected; } else { - if (pScreenCoord->screenPtAy[0].projected.fZ <= (double)pScreenCoord_1->screenPtAy[0].projected.fZ) - fRightWallDepthSelected = pScreenCoord_1->screenPtAy[0].projected.fZ; + if (pScreenCoord->screenPtAy[0].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[0].projected.fZ) + fRightWallDepthSelected = + pScreenCoord_1->screenPtAy[0].projected.fZ; else - fRightWallDepthSelected = pScreenCoord->screenPtAy[0].projected.fZ; + fRightWallDepthSelected = + pScreenCoord->screenPtAy[0].projected.fZ; fLeftWallDepthTmp6 = fRightWallDepthSelected; } fLeftWallDepthTmp5 = fRightWallDepthSelected; fLeftWallRoofDepth = fRightWallDepthSelected; } else { - fLeftWallRoofDepth = (pScreenCoord->screenPtAy[1].projected.fZ - + pScreenCoord_1->screenPtAy[1].projected.fZ - + pScreenCoord->screenPtAy[4].projected.fZ - + pScreenCoord_1->screenPtAy[4].projected.fZ) - * 0.25f; + fLeftWallRoofDepth = + (pScreenCoord->screenPtAy[1].projected.fZ + + pScreenCoord_1->screenPtAy[1].projected.fZ + + pScreenCoord->screenPtAy[4].projected.fZ + + pScreenCoord_1->screenPtAy[4].projected.fZ) * + 0.25f; } pRightWallCmd = &TrackView[num_bits]; pRightWallCmd->nRenderPriority = 8; @@ -2123,31 +2394,40 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, pRightWallCmd->fZDepth = fRightWallCmdDepth; ++num_bits; } else { - if (pScreenCoord_1->screenPtAy[0].projected.fZ <= (double)pScreenCoord_1->screenPtAy[1].projected.fZ) + if (pScreenCoord_1->screenPtAy[0].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[1].projected.fZ) fLeftWallDepthMax1 = pScreenCoord_1->screenPtAy[1].projected.fZ; else fLeftWallDepthMax1 = pScreenCoord_1->screenPtAy[0].projected.fZ; fLeftWallDepth1 = fLeftWallDepthMax1; - if (pScreenCoord->screenPtAy[0].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) + if (pScreenCoord->screenPtAy[0].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) fLeftWallDepthMax2 = pScreenCoord->screenPtAy[1].projected.fZ; else fLeftWallDepthMax2 = pScreenCoord->screenPtAy[0].projected.fZ; fLeftWallDepth2 = fLeftWallDepthMax2; if (fLeftWallDepth1 <= (double)fLeftWallDepthMax2) { - if (pScreenCoord->screenPtAy[0].projected.fZ <= (double)pScreenCoord->screenPtAy[1].projected.fZ) - fLeftWallDepthSelected = pScreenCoord->screenPtAy[1].projected.fZ; + if (pScreenCoord->screenPtAy[0].projected.fZ <= + (double)pScreenCoord->screenPtAy[1].projected.fZ) + fLeftWallDepthSelected = + pScreenCoord->screenPtAy[1].projected.fZ; else - fLeftWallDepthSelected = pScreenCoord->screenPtAy[0].projected.fZ; + fLeftWallDepthSelected = + pScreenCoord->screenPtAy[0].projected.fZ; fLeftWallDepthTmp2 = fLeftWallDepthSelected; } else { - if (pScreenCoord_1->screenPtAy[0].projected.fZ <= (double)pScreenCoord_1->screenPtAy[1].projected.fZ) - fLeftWallDepthSelected = pScreenCoord_1->screenPtAy[1].projected.fZ; + if (pScreenCoord_1->screenPtAy[0].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[1].projected.fZ) + fLeftWallDepthSelected = + pScreenCoord_1->screenPtAy[1].projected.fZ; else - fLeftWallDepthSelected = pScreenCoord_1->screenPtAy[0].projected.fZ; + fLeftWallDepthSelected = + pScreenCoord_1->screenPtAy[0].projected.fZ; fLeftWallDepthTmp1 = fLeftWallDepthSelected; } fLeftWallFinalDepth = fLeftWallDepthSelected; - pLeftWallCmd = &TrackView[num_bits];// Add left wall polygon to render list + pLeftWallCmd = + &TrackView[num_bits]; // Add left wall polygon to render list pLeftWallCmd->fZDepth = fLeftWallFinalDepth; iLeftWallCmdIndex = num_bits; pLeftWallCmd->nRenderPriority = 0; @@ -2161,39 +2441,51 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, if (Walls_On) { iRightWallFlags = TrakColour[iCurrentSect][TRAK_COLOUR_RIGHT_WALL]; if (iRightWallFlags) { - if (TrackInfo[iCurrentSect].fRoofHeight >= 0.0 && TrackInfo[iNextSectionIndex].fRoofHeight >= 0.0) { + if (TrackInfo[iCurrentSect].fRoofHeight >= 0.0 && + TrackInfo[iNextSectionIndex].fRoofHeight >= 0.0) { if (iRightWallFlags >= 0) { - if (pScreenCoord_1->screenPtAy[3].projected.fZ <= (double)pScreenCoord->screenPtAy[3].projected.fZ) + if (pScreenCoord_1->screenPtAy[3].projected.fZ <= + (double)pScreenCoord->screenPtAy[3].projected.fZ) fRightWallRoofDepth1 = pScreenCoord->screenPtAy[3].projected.fZ; else - fRightWallRoofDepth1 = pScreenCoord_1->screenPtAy[3].projected.fZ; + fRightWallRoofDepth1 = + pScreenCoord_1->screenPtAy[3].projected.fZ; fRightWallDepthTmp3 = fRightWallRoofDepth1; - if (pScreenCoord_1->screenPtAy[5].projected.fZ <= (double)pScreenCoord->screenPtAy[5].projected.fZ) + if (pScreenCoord_1->screenPtAy[5].projected.fZ <= + (double)pScreenCoord->screenPtAy[5].projected.fZ) fRightWallRoofDepth2 = pScreenCoord->screenPtAy[5].projected.fZ; else - fRightWallRoofDepth2 = pScreenCoord_1->screenPtAy[5].projected.fZ; + fRightWallRoofDepth2 = + pScreenCoord_1->screenPtAy[5].projected.fZ; fRightWallDepthTmp4 = fRightWallRoofDepth2; if (fRightWallDepthTmp3 <= (double)fRightWallRoofDepth2) { - if (pScreenCoord_1->screenPtAy[5].projected.fZ <= (double)pScreenCoord->screenPtAy[5].projected.fZ) - fRightWallRoofSelected = pScreenCoord->screenPtAy[5].projected.fZ; + if (pScreenCoord_1->screenPtAy[5].projected.fZ <= + (double)pScreenCoord->screenPtAy[5].projected.fZ) + fRightWallRoofSelected = + pScreenCoord->screenPtAy[5].projected.fZ; else - fRightWallRoofSelected = pScreenCoord_1->screenPtAy[5].projected.fZ; + fRightWallRoofSelected = + pScreenCoord_1->screenPtAy[5].projected.fZ; fRightWallDepthTmp7 = fRightWallRoofSelected; } else { - if (pScreenCoord_1->screenPtAy[3].projected.fZ <= (double)pScreenCoord->screenPtAy[3].projected.fZ) - fRightWallRoofSelected = pScreenCoord->screenPtAy[3].projected.fZ; + if (pScreenCoord_1->screenPtAy[3].projected.fZ <= + (double)pScreenCoord->screenPtAy[3].projected.fZ) + fRightWallRoofSelected = + pScreenCoord->screenPtAy[3].projected.fZ; else - fRightWallRoofSelected = pScreenCoord_1->screenPtAy[3].projected.fZ; + fRightWallRoofSelected = + pScreenCoord_1->screenPtAy[3].projected.fZ; fRightWallDepthTmp6 = fRightWallRoofSelected; } fRightWallDepthTmp5 = fRightWallRoofSelected; fRightWallRoofDepth = fRightWallRoofSelected; } else { - fRightWallRoofDepth = (pScreenCoord_1->screenPtAy[2].projected.fZ - + pScreenCoord->screenPtAy[2].projected.fZ - + pScreenCoord_1->screenPtAy[5].projected.fZ - + pScreenCoord->screenPtAy[5].projected.fZ) - * 0.25f; + fRightWallRoofDepth = + (pScreenCoord_1->screenPtAy[2].projected.fZ + + pScreenCoord->screenPtAy[2].projected.fZ + + pScreenCoord_1->screenPtAy[5].projected.fZ + + pScreenCoord->screenPtAy[5].projected.fZ) * + 0.25f; } pRightWallRoofCmd = &TrackView[num_bits]; pRightWallRoofCmd->fZDepth = fRightWallRoofDepth; @@ -2202,31 +2494,42 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, pRightWallRoofCmd->nChunkIdx = iCurrentSect; num_bits = iRightWallRoofCmdIndex + 1; } else { - if (pScreenCoord_1->screenPtAy[2].projected.fZ <= (double)pScreenCoord_1->screenPtAy[3].projected.fZ) - fRightWallBasicDepth1 = pScreenCoord_1->screenPtAy[3].projected.fZ; + if (pScreenCoord_1->screenPtAy[2].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[3].projected.fZ) + fRightWallBasicDepth1 = + pScreenCoord_1->screenPtAy[3].projected.fZ; else - fRightWallBasicDepth1 = pScreenCoord_1->screenPtAy[2].projected.fZ; + fRightWallBasicDepth1 = + pScreenCoord_1->screenPtAy[2].projected.fZ; fRightWallDepth1 = fRightWallBasicDepth1; - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[3].projected.fZ) + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[3].projected.fZ) fRightWallBasicDepth2 = pScreenCoord->screenPtAy[3].projected.fZ; else fRightWallBasicDepth2 = pScreenCoord->screenPtAy[2].projected.fZ; fRightWallDepth2 = fRightWallBasicDepth2; if (fRightWallDepth1 <= (double)fRightWallBasicDepth2) { - if (pScreenCoord->screenPtAy[2].projected.fZ <= (double)pScreenCoord->screenPtAy[3].projected.fZ) - fRightWallBasicSelected = pScreenCoord->screenPtAy[3].projected.fZ; + if (pScreenCoord->screenPtAy[2].projected.fZ <= + (double)pScreenCoord->screenPtAy[3].projected.fZ) + fRightWallBasicSelected = + pScreenCoord->screenPtAy[3].projected.fZ; else - fRightWallBasicSelected = pScreenCoord->screenPtAy[2].projected.fZ; + fRightWallBasicSelected = + pScreenCoord->screenPtAy[2].projected.fZ; fRightWallDepthTmp2 = fRightWallBasicSelected; } else { - if (pScreenCoord_1->screenPtAy[2].projected.fZ <= (double)pScreenCoord_1->screenPtAy[3].projected.fZ) - fRightWallBasicSelected = pScreenCoord_1->screenPtAy[3].projected.fZ; + if (pScreenCoord_1->screenPtAy[2].projected.fZ <= + (double)pScreenCoord_1->screenPtAy[3].projected.fZ) + fRightWallBasicSelected = + pScreenCoord_1->screenPtAy[3].projected.fZ; else - fRightWallBasicSelected = pScreenCoord_1->screenPtAy[2].projected.fZ; + fRightWallBasicSelected = + pScreenCoord_1->screenPtAy[2].projected.fZ; fRightWallDepthTmp1 = fRightWallBasicSelected; } fRightWallFinalDepth = fRightWallBasicSelected; - pRightWallBasicCmd = &TrackView[num_bits];// Add right wall polygon to render list + pRightWallBasicCmd = + &TrackView[num_bits]; // Add right wall polygon to render list fRightWallBasicCmdDepth = fRightWallFinalDepth; iRightWallBasicCmdIndex = num_bits; pRightWallBasicCmd->nRenderPriority = 1; @@ -2241,7 +2544,7 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, } LABEL_357: render_queue_3d_set_legacy_count(render_queue_3d_global(), num_bits); - iCarIndex = 0; // Third phase: Process car objects for rendering + iCarIndex = 0; // Third phase: Process car objects for rendering if (numcars > 0) { iCarArrayIndex = 0; do { @@ -2253,16 +2556,18 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, iCarCommandIdx = car_draw_order[iCarArrayIndex].iCarIdx; { GameRenderCarPose pose = { - .position = Car[iCarCommandIdx].pos, - .yaw = Car[iCarCommandIdx].nYaw, - .pitch = Car[iCarCommandIdx].nPitch, - .roll = Car[iCarCommandIdx].nRoll, + .position = Car[iCarCommandIdx].pos, + .yaw = Car[iCarCommandIdx].nYaw, + .pitch = Car[iCarCommandIdx].nPitch, + .roll = Car[iCarCommandIdx].nRoll, }; GameRenderCarOptions options = { - .anim_frame = Car[iCarCommandIdx].byWheelAnimationFrame, - .color_remap = NULL, + .anim_frame = Car[iCarCommandIdx].byWheelAnimationFrame, + .color_remap = NULL, }; - pCarRenderCmd = render_queue_3d_add_car(render_queue_3d_global(), iCarCommandIdx, fOffsetTmp1, &pose, &options); + pCarRenderCmd = + render_queue_3d_add_car(render_queue_3d_global(), iCarCommandIdx, + fOffsetTmp1, &pose, &options); } if (pCarRenderCmd != NULL) { cars_drawn = iCarProcessingFlag + 1; @@ -2273,7 +2578,8 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, ++iCarArrayIndex; } while (iCarIndex < numcars); } - iCarsRenderedCount = 0; // Fourth phase: Count visible cars and determine names display + iCarsRenderedCount = + 0; // Fourth phase: Count visible cars and determine names display iCarLoopIndex = 0; NamesLeft = 0; VisibleCars = 0; @@ -2284,8 +2590,10 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, iIndexTmp3 = 12 * numcars; do { iCarStatusFlag = car_draw_order[uiCarIndexOffset / 0xC].iChunkIdx; - if ((iCarStatusFlag == -3 || iCarStatusFlag >= 0) && iCarIdx_1 != car_draw_order[uiCarIndexOffset / 0xC].iCarIdx) { - if (car_draw_order[uiCarIndexOffset / 0xC].fMinZDepth < (double)car_draw_order[uiCarArrayOffset / 0xC].fMinZDepth) { + if ((iCarStatusFlag == -3 || iCarStatusFlag >= 0) && + iCarIdx_1 != car_draw_order[uiCarIndexOffset / 0xC].iCarIdx) { + if (car_draw_order[uiCarIndexOffset / 0xC].fMinZDepth < + (double)car_draw_order[uiCarArrayOffset / 0xC].fMinZDepth) { if (human_control[car_draw_order[uiCarIndexOffset / 0xC].iCarIdx]) ++VisibleCars; ++NamesLeft; @@ -2328,28 +2636,32 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, goto LABEL_392; } LABEL_393: - pVisibleBuildingsPtr = &VisibleBuildings[0]; // Process building objects for rendering + pVisibleBuildingsPtr = + &VisibleBuildings[0]; // Process building objects for rendering if (VisibleBuildings[0].iBuildingIdx != -1) { do { - pBuildingRenderCmd = render_queue_3d_add_building(render_queue_3d_global(), - pVisibleBuildingsPtr->iBuildingIdx, - pVisibleBuildingsPtr->fDepth); + pBuildingRenderCmd = render_queue_3d_add_building( + render_queue_3d_global(), pVisibleBuildingsPtr->iBuildingIdx, + pVisibleBuildingsPtr->fDepth); if (pBuildingRenderCmd != NULL) num_bits = render_queue_3d_count(render_queue_3d_global()); ++pVisibleBuildingsPtr; } while (pVisibleBuildingsPtr->iBuildingIdx != -1); } - if (countdown > -72 && replaytype != 2 && game_type != 2 && !winner_mode)// Process starting lights for rendering (if countdown active) + if (countdown > -72 && replaytype != 2 && game_type != 2 && + !winner_mode) // Process starting lights for rendering (if countdown + // active) { iLightIndex = 0; iLightArrayOffset = 3 * iChaseCamIdx_1; do { - fLightZ = (SLight[0][iLightArrayOffset].currentPos.fX - viewx) * vk3 - + (SLight[0][iLightArrayOffset].currentPos.fY - viewy) * vk6 - + (SLight[0][iLightArrayOffset].currentPos.fZ - viewz) * vk9; + fLightZ = (SLight[0][iLightArrayOffset].currentPos.fX - viewx) * vk3 + + (SLight[0][iLightArrayOffset].currentPos.fY - viewy) * vk6 + + (SLight[0][iLightArrayOffset].currentPos.fZ - viewz) * vk9; if (fLightZ > 0.0) { fLightDepth = fLightZ; - pLightRenderCmd = render_queue_3d_add_start_light(render_queue_3d_global(), iLightIndex, fLightDepth); + pLightRenderCmd = render_queue_3d_add_start_light( + render_queue_3d_global(), iLightIndex, fLightDepth); if (pLightRenderCmd != NULL) num_bits = render_queue_3d_count(render_queue_3d_global()); } @@ -2357,22 +2669,26 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, ++iLightArrayOffset; } while (iLightIndex < 3); } - render_queue_3d_sort(render_queue_3d_global());// Fifth phase: Sort render list by Z-depth and render objects + render_queue_3d_sort( + render_queue_3d_global()); // Fifth phase: Sort render list by Z-depth and + // render objects iRenderObjectIndex = 0; if (num_bits > 0) { iIndexTmp1 = 144 * iChaseCamIdx_1; while (1) { pRenderCommand = &TrackView[num_bits - 1 - iRenderObjectIndex]; - pTypedRenderCommand = render_queue_3d_command_at(render_queue_3d_global(), num_bits - 1 - iRenderObjectIndex); + pTypedRenderCommand = render_queue_3d_command_at( + render_queue_3d_global(), num_bits - 1 - iRenderObjectIndex); fRenderDepth = pRenderCommand->fZDepth; iSectionNum = pRenderCommand->nChunkIdx; pScreenCoord_1 = NULL; pScreenCoord = NULL; pCurrentGroundScreen = NULL; pNextGroundScreen = NULL; - if (pRenderCommand->nRenderPriority != 11 && pRenderCommand->nRenderPriority != 14 - && iSectionNum >= 0 && iSectionNum < MAX_TRACK_CHUNKS //index checks added by ROLLER - && iNextSectionIndex >= 0 && iNextSectionIndex < MAX_TRACK_CHUNKS) { + if (pRenderCommand->nRenderPriority != 11 && + pRenderCommand->nRenderPriority != 14 && iSectionNum >= 0 && + iSectionNum < MAX_TRACK_CHUNKS // index checks added by ROLLER + && iNextSectionIndex >= 0 && iNextSectionIndex < MAX_TRACK_CHUNKS) { iNextSectionIndex = NextSect[iSectionNum]; pScreenCoord_1 = &TrackScreenXYZ[iSectionNum]; @@ -2381,387 +2697,450 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, pNextGroundScreen = &GroundScreenXYZ[iNextSectionIndex]; } switch (pRenderCommand->nRenderPriority) { - case 0: - case 8: - { - int sf = TrakColour[iSectionNum][TRAK_COLOUR_LEFT_WALL]; - int highWall = (sf < 0); - if (highWall) sf = -sf; - sf |= SURFACE_FLAG_FLIP_BACKFACE; - if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0) { - if (sf & SURFACE_FLAG_APPLY_TEXTURE) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - else - sf = SURFACE_FLAG_SKIP_RENDER; - } else if ((textures_off & TEX_OFF_GLASS_WALLS) != 0 && (sf & SURFACE_FLAG_TRANSPARENT) != 0) { - sf = SURFACE_FLAG_SKIP_RENDER; - } - if ((sf & SURFACE_FLAG_SKIP_RENDER) == 0) { - GameRenderVertex v[4]; - world_verts_left_wall(v, iNextSectionIndex, iSectionNum, highWall ? 2 : 0); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[3] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } - goto LABEL_1271; - case 1: - case 9: - { - int sf = TrakColour[iSectionNum][TRAK_COLOUR_RIGHT_WALL]; - int highWall = (sf < 0); - if (highWall) sf = -sf; - sf |= SURFACE_FLAG_FLIP_BACKFACE; - if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0) { - if (sf & SURFACE_FLAG_APPLY_TEXTURE) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - else - sf = SURFACE_FLAG_SKIP_RENDER; - } else if ((textures_off & TEX_OFF_GLASS_WALLS) != 0 && (sf & SURFACE_FLAG_TRANSPARENT) != 0) { - sf = SURFACE_FLAG_SKIP_RENDER; - } - if ((sf & SURFACE_FLAG_SKIP_RENDER) == 0) { - GameRenderVertex v[4]; - world_verts_right_wall(v, iNextSectionIndex, iSectionNum, highWall ? 3 : 4); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[4] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } - goto LABEL_1271; - LABEL_1271: - if (++iRenderObjectIndex >= num_bits) - return; - break; - case 2: - { - int sf = GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR]; - if (!facing_ok( - pNextGroundScreen->screenPtAy[2].projected.fX, - pNextGroundScreen->screenPtAy[2].projected.fY, - pNextGroundScreen->screenPtAy[2].projected.fZ, - pCurrentGroundScreen->screenPtAy[2].projected.fX, - pCurrentGroundScreen->screenPtAy[2].projected.fY, - pCurrentGroundScreen->screenPtAy[2].projected.fZ, - pCurrentGroundScreen->screenPtAy[3].projected.fX, - pCurrentGroundScreen->screenPtAy[3].projected.fY, - pCurrentGroundScreen->screenPtAy[3].projected.fZ, - pNextGroundScreen->screenPtAy[3].projected.fX, - pNextGroundScreen->screenPtAy[3].projected.fY, - pNextGroundScreen->screenPtAy[3].projected.fZ)) - goto LABEL_1271; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_ground_cross_first(v, iNextSectionIndex, iSectionNum, 3, 2); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[8] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } + case 0: + case 8: { + int sf = TrakColour[iSectionNum][TRAK_COLOUR_LEFT_WALL]; + int highWall = (sf < 0); + if (highWall) + sf = -sf; + sf |= SURFACE_FLAG_FLIP_BACKFACE; + if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0) { + if (sf & SURFACE_FLAG_APPLY_TEXTURE) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + else + sf = SURFACE_FLAG_SKIP_RENDER; + } else if ((textures_off & TEX_OFF_GLASS_WALLS) != 0 && + (sf & SURFACE_FLAG_TRANSPARENT) != 0) { + sf = SURFACE_FLAG_SKIP_RENDER; + } + if ((sf & SURFACE_FLAG_SKIP_RENDER) == 0) { + GameRenderVertex v[4]; + world_verts_left_wall(v, iNextSectionIndex, iSectionNum, + highWall ? 2 : 0); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[3] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 1: + case 9: { + int sf = TrakColour[iSectionNum][TRAK_COLOUR_RIGHT_WALL]; + int highWall = (sf < 0); + if (highWall) + sf = -sf; + sf |= SURFACE_FLAG_FLIP_BACKFACE; + if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0) { + if (sf & SURFACE_FLAG_APPLY_TEXTURE) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + else + sf = SURFACE_FLAG_SKIP_RENDER; + } else if ((textures_off & TEX_OFF_GLASS_WALLS) != 0 && + (sf & SURFACE_FLAG_TRANSPARENT) != 0) { + sf = SURFACE_FLAG_SKIP_RENDER; + } + if ((sf & SURFACE_FLAG_SKIP_RENDER) == 0) { + GameRenderVertex v[4]; + world_verts_right_wall(v, iNextSectionIndex, iSectionNum, + highWall ? 3 : 4); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[4] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + LABEL_1271: + if (++iRenderObjectIndex >= num_bits) + return; + break; + case 2: { + int sf = GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR]; + if (!facing_ok(pNextGroundScreen->screenPtAy[2].projected.fX, + pNextGroundScreen->screenPtAy[2].projected.fY, + pNextGroundScreen->screenPtAy[2].projected.fZ, + pCurrentGroundScreen->screenPtAy[2].projected.fX, + pCurrentGroundScreen->screenPtAy[2].projected.fY, + pCurrentGroundScreen->screenPtAy[2].projected.fZ, + pCurrentGroundScreen->screenPtAy[3].projected.fX, + pCurrentGroundScreen->screenPtAy[3].projected.fY, + pCurrentGroundScreen->screenPtAy[3].projected.fZ, + pNextGroundScreen->screenPtAy[3].projected.fX, + pNextGroundScreen->screenPtAy[3].projected.fY, + pNextGroundScreen->screenPtAy[3].projected.fZ)) goto LABEL_1271; - case 3: - { - int sf = GroundColour[iSectionNum][GROUND_COLOUR_LUOWALL]; - if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) - goto LABEL_1068; - if (!facing_ok( - pNextGroundScreen->screenPtAy[0].projected.fX, - pNextGroundScreen->screenPtAy[0].projected.fY, - pNextGroundScreen->screenPtAy[0].projected.fZ, - pCurrentGroundScreen->screenPtAy[0].projected.fX, - pCurrentGroundScreen->screenPtAy[0].projected.fY, - pCurrentGroundScreen->screenPtAy[0].projected.fZ, - pCurrentGroundScreen->screenPtAy[1].projected.fX, - pCurrentGroundScreen->screenPtAy[1].projected.fY, - pCurrentGroundScreen->screenPtAy[1].projected.fZ, - pNextGroundScreen->screenPtAy[1].projected.fX, - pNextGroundScreen->screenPtAy[1].projected.fY, - pNextGroundScreen->screenPtAy[1].projected.fZ) - && (sf & SURFACE_FLAG_CONCAVE) == 0) - goto LABEL_1068; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 0, 1); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[6] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_ground_cross_first(v, iNextSectionIndex, iSectionNum, 3, + 2); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[8] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 3: { + int sf = GroundColour[iSectionNum][GROUND_COLOUR_LUOWALL]; + if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) goto LABEL_1068; - LABEL_1068: - { - int sf = GroundColour[iSectionNum][GROUND_COLOUR_LLOWALL]; - if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) - goto LABEL_1271; - if (!facing_ok( - pNextGroundScreen->screenPtAy[1].projected.fX, - pNextGroundScreen->screenPtAy[1].projected.fY, - pNextGroundScreen->screenPtAy[1].projected.fZ, - pCurrentGroundScreen->screenPtAy[1].projected.fX, - pCurrentGroundScreen->screenPtAy[1].projected.fY, - pCurrentGroundScreen->screenPtAy[1].projected.fZ, - pCurrentGroundScreen->screenPtAy[2].projected.fX, - pCurrentGroundScreen->screenPtAy[2].projected.fY, - pCurrentGroundScreen->screenPtAy[2].projected.fZ, - pNextGroundScreen->screenPtAy[2].projected.fX, - pNextGroundScreen->screenPtAy[2].projected.fY, - pNextGroundScreen->screenPtAy[2].projected.fZ) - && (sf & SURFACE_FLAG_CONCAVE) == 0) - goto LABEL_1271; - if (sf == 65854) - sf += 1; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 1, 2); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[7] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } - goto LABEL_1271; - case 4: - { - int sf = GroundColour[iSectionNum][GROUND_COLOUR_RUOWALL]; - if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) - goto LABEL_1174; - if (!facing_ok( - pNextGroundScreen->screenPtAy[4].projected.fX, - pNextGroundScreen->screenPtAy[4].projected.fY, - pNextGroundScreen->screenPtAy[4].projected.fZ, - pCurrentGroundScreen->screenPtAy[4].projected.fX, - pCurrentGroundScreen->screenPtAy[4].projected.fY, - pCurrentGroundScreen->screenPtAy[4].projected.fZ, - pCurrentGroundScreen->screenPtAy[5].projected.fX, - pCurrentGroundScreen->screenPtAy[5].projected.fY, - pCurrentGroundScreen->screenPtAy[5].projected.fZ, - pNextGroundScreen->screenPtAy[5].projected.fX, - pNextGroundScreen->screenPtAy[5].projected.fY, - pNextGroundScreen->screenPtAy[5].projected.fZ) - && (sf & SURFACE_FLAG_CONCAVE) == 0) - goto LABEL_1174; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 4, 5); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[10] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } - goto LABEL_1174; - LABEL_1174: - { - int sf = GroundColour[iSectionNum][GROUND_COLOUR_RLOWALL]; - if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) - goto LABEL_1271; - if (!facing_ok( - pNextGroundScreen->screenPtAy[3].projected.fX, - pNextGroundScreen->screenPtAy[3].projected.fY, - pNextGroundScreen->screenPtAy[3].projected.fZ, - pCurrentGroundScreen->screenPtAy[3].projected.fX, - pCurrentGroundScreen->screenPtAy[3].projected.fY, - pCurrentGroundScreen->screenPtAy[3].projected.fZ, - pCurrentGroundScreen->screenPtAy[4].projected.fX, - pCurrentGroundScreen->screenPtAy[4].projected.fY, - pCurrentGroundScreen->screenPtAy[4].projected.fZ, - pNextGroundScreen->screenPtAy[4].projected.fX, - pNextGroundScreen->screenPtAy[4].projected.fY, - pNextGroundScreen->screenPtAy[4].projected.fZ) - && (sf & SURFACE_FLAG_CONCAVE) == 0) - goto LABEL_1271; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 3, 4); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[9] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } - goto LABEL_1271; - case 5: - { - int sf = TrakColour[iSectionNum][TRAK_COLOUR_CENTER]; - if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 3, 2); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[1] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } + if (!facing_ok(pNextGroundScreen->screenPtAy[0].projected.fX, + pNextGroundScreen->screenPtAy[0].projected.fY, + pNextGroundScreen->screenPtAy[0].projected.fZ, + pCurrentGroundScreen->screenPtAy[0].projected.fX, + pCurrentGroundScreen->screenPtAy[0].projected.fY, + pCurrentGroundScreen->screenPtAy[0].projected.fZ, + pCurrentGroundScreen->screenPtAy[1].projected.fX, + pCurrentGroundScreen->screenPtAy[1].projected.fY, + pCurrentGroundScreen->screenPtAy[1].projected.fZ, + pNextGroundScreen->screenPtAy[1].projected.fX, + pNextGroundScreen->screenPtAy[1].projected.fY, + pNextGroundScreen->screenPtAy[1].projected.fZ) && + (sf & SURFACE_FLAG_CONCAVE) == 0) + goto LABEL_1068; + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 0, 1); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[6] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1068; + LABEL_1068: { + int sf = GroundColour[iSectionNum][GROUND_COLOUR_LLOWALL]; + if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) goto LABEL_1271; - LABEL_1203: + if (!facing_ok(pNextGroundScreen->screenPtAy[1].projected.fX, + pNextGroundScreen->screenPtAy[1].projected.fY, + pNextGroundScreen->screenPtAy[1].projected.fZ, + pCurrentGroundScreen->screenPtAy[1].projected.fX, + pCurrentGroundScreen->screenPtAy[1].projected.fY, + pCurrentGroundScreen->screenPtAy[1].projected.fZ, + pCurrentGroundScreen->screenPtAy[2].projected.fX, + pCurrentGroundScreen->screenPtAy[2].projected.fY, + pCurrentGroundScreen->screenPtAy[2].projected.fZ, + pNextGroundScreen->screenPtAy[2].projected.fX, + pNextGroundScreen->screenPtAy[2].projected.fY, + pNextGroundScreen->screenPtAy[2].projected.fZ) && + (sf & SURFACE_FLAG_CONCAVE) == 0) goto LABEL_1271; - case 6: - { - int sf = TrakColour[iSectionNum][TRAK_COLOUR_LEFT_LANE]; - if (sf < 0) - sf = -sf; - if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 2, 0); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[0] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } + if (sf == 65854) + sf += 1; + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 1, 2); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[7] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 4: { + int sf = GroundColour[iSectionNum][GROUND_COLOUR_RUOWALL]; + if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) + goto LABEL_1174; + if (!facing_ok(pNextGroundScreen->screenPtAy[4].projected.fX, + pNextGroundScreen->screenPtAy[4].projected.fY, + pNextGroundScreen->screenPtAy[4].projected.fZ, + pCurrentGroundScreen->screenPtAy[4].projected.fX, + pCurrentGroundScreen->screenPtAy[4].projected.fY, + pCurrentGroundScreen->screenPtAy[4].projected.fZ, + pCurrentGroundScreen->screenPtAy[5].projected.fX, + pCurrentGroundScreen->screenPtAy[5].projected.fY, + pCurrentGroundScreen->screenPtAy[5].projected.fZ, + pNextGroundScreen->screenPtAy[5].projected.fX, + pNextGroundScreen->screenPtAy[5].projected.fY, + pNextGroundScreen->screenPtAy[5].projected.fZ) && + (sf & SURFACE_FLAG_CONCAVE) == 0) + goto LABEL_1174; + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 4, 5); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[10] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1174; + LABEL_1174: { + int sf = GroundColour[iSectionNum][GROUND_COLOUR_RLOWALL]; + if (sf == -1 || GroundColour[iSectionNum][GROUND_COLOUR_OFLOOR] == -1) goto LABEL_1271; - case 7: - { - int sf = TrakColour[iSectionNum][TRAK_COLOUR_RIGHT_LANE]; - if (sf < 0) - sf = -sf; - if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 4, 3); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[2] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } + if (!facing_ok(pNextGroundScreen->screenPtAy[3].projected.fX, + pNextGroundScreen->screenPtAy[3].projected.fY, + pNextGroundScreen->screenPtAy[3].projected.fZ, + pCurrentGroundScreen->screenPtAy[3].projected.fX, + pCurrentGroundScreen->screenPtAy[3].projected.fY, + pCurrentGroundScreen->screenPtAy[3].projected.fZ, + pCurrentGroundScreen->screenPtAy[4].projected.fX, + pCurrentGroundScreen->screenPtAy[4].projected.fY, + pCurrentGroundScreen->screenPtAy[4].projected.fZ, + pNextGroundScreen->screenPtAy[4].projected.fX, + pNextGroundScreen->screenPtAy[4].projected.fY, + pNextGroundScreen->screenPtAy[4].projected.fZ) && + (sf & SURFACE_FLAG_CONCAVE) == 0) goto LABEL_1271; - case 0xA: - { - int sf = TrakColour[iSectionNum][TRAK_COLOUR_ROOF]; - /* Single-section roof from NEXT section (negative surface type) */ - if (sf < 0) { - int renderSf = -sf; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (renderSf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - renderSf = remap_tex[(uint8)renderSf] + (renderSf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - tGroundPt *g = &GroundPt[iNextSectionIndex]; - v[0].x = g->pointAy[1].fX; v[0].y = g->pointAy[1].fY; v[0].z = g->pointAy[1].fZ; - v[1].x = g->pointAy[4].fX; v[1].y = g->pointAy[4].fY; v[1].z = g->pointAy[4].fZ; - v[2].x = g->pointAy[5].fX; v[2].y = g->pointAy[5].fY; v[2].z = g->pointAy[5].fZ; - v[3].x = g->pointAy[0].fX; v[3].y = g->pointAy[0].fY; v[3].z = g->pointAy[0].fZ; - v[0].u = 0; v[0].v = 0; v[1].u = 0; v[1].v = 0; - v[2].u = 0; v[2].v = 0; v[3].u = 0; v[3].v = 0; - TextureHandle h = (renderSf & SURFACE_FLAG_APPLY_TEXTURE) + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_ground_forward(v, iNextSectionIndex, iSectionNum, 3, 4); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) ? game_render_get_texture_handle(g_pGameRenderer, 0) : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[5] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, renderSf, subT); - } - } - /* Single-section roof from CUR section (very negative surface) */ - if (TrakColour[iSectionNum][TRAK_COLOUR_RIGHT_WALL] - && TrakColour[iSectionNum][TRAK_COLOUR_LEFT_WALL]) { - int idx = TrakColour[iNextSectionIndex][TRAK_COLOUR_ROOF]; - if (idx < -1) { - int renderSf = -idx; - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && (renderSf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - renderSf = remap_tex[(uint8)renderSf] + (renderSf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); - { - GameRenderVertex v[4]; - tGroundPt *g = &GroundPt[iSectionNum]; - v[0].x = g->pointAy[4].fX; v[0].y = g->pointAy[4].fY; v[0].z = g->pointAy[4].fZ; - v[1].x = g->pointAy[1].fX; v[1].y = g->pointAy[1].fY; v[1].z = g->pointAy[1].fZ; - v[2].x = g->pointAy[0].fX; v[2].y = g->pointAy[0].fY; v[2].z = g->pointAy[0].fZ; - v[3].x = g->pointAy[5].fX; v[3].y = g->pointAy[5].fY; v[3].z = g->pointAy[5].fZ; - v[0].u = 0; v[0].v = 0; v[1].u = 0; v[1].v = 0; - v[2].u = 0; v[2].v = 0; v[3].u = 0; v[3].v = 0; - TextureHandle h = (renderSf & SURFACE_FLAG_APPLY_TEXTURE) + float subT = (uint8)Subdivide[iSectionNum].subdivides[9] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 5: { + int sf = TrakColour[iSectionNum][TRAK_COLOUR_CENTER]; + if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 3, + 2); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[1] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + LABEL_1203: + goto LABEL_1271; + case 6: { + int sf = TrakColour[iSectionNum][TRAK_COLOUR_LEFT_LANE]; + if (sf < 0) + sf = -sf; + if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 2, + 0); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[0] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 7: { + int sf = TrakColour[iSectionNum][TRAK_COLOUR_RIGHT_LANE]; + if (sf < 0) + sf = -sf; + if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 4, + 3); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[2] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 0xA: { + int sf = TrakColour[iSectionNum][TRAK_COLOUR_ROOF]; + /* Single-section roof from NEXT section (negative surface type) */ + if (sf < 0) { + int renderSf = -sf; + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (renderSf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + renderSf = + remap_tex[(uint8)renderSf] + + (renderSf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + tGroundPt *g = &GroundPt[iNextSectionIndex]; + v[0].x = g->pointAy[1].fX; + v[0].y = g->pointAy[1].fY; + v[0].z = g->pointAy[1].fZ; + v[1].x = g->pointAy[4].fX; + v[1].y = g->pointAy[4].fY; + v[1].z = g->pointAy[4].fZ; + v[2].x = g->pointAy[5].fX; + v[2].y = g->pointAy[5].fY; + v[2].z = g->pointAy[5].fZ; + v[3].x = g->pointAy[0].fX; + v[3].y = g->pointAy[0].fY; + v[3].z = g->pointAy[0].fZ; + v[0].u = 0; + v[0].v = 0; + v[1].u = 0; + v[1].v = 0; + v[2].u = 0; + v[2].v = 0; + v[3].u = 0; + v[3].v = 0; + TextureHandle h = + (renderSf & SURFACE_FLAG_APPLY_TEXTURE) ? game_render_get_texture_handle(g_pGameRenderer, 0) : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[5] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, renderSf, subT); - } - } - } - /* Two-section roof quad (TrakPt source, always rendered) */ - if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0 && (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) - sf = remap_tex[(uint8)sf] + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + float subT = (uint8)Subdivide[iSectionNum].subdivides[5] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, renderSf, subT); + } + } + /* Single-section roof from CUR section (very negative surface) */ + if (TrakColour[iSectionNum][TRAK_COLOUR_RIGHT_WALL] && + TrakColour[iSectionNum][TRAK_COLOUR_LEFT_WALL]) { + int idx = TrakColour[iNextSectionIndex][TRAK_COLOUR_ROOF]; + if (idx < -1) { + int renderSf = -idx; + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0 && + (renderSf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + renderSf = remap_tex[(uint8)renderSf] + + (renderSf & + (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); { GameRenderVertex v[4]; - world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 1, 5); - TextureHandle h = (sf & SURFACE_FLAG_APPLY_TEXTURE) - ? game_render_get_texture_handle(g_pGameRenderer, 0) - : TEXTURE_HANDLE_INVALID; - float subT = (uint8)Subdivide[iSectionNum].subdivides[5] * subscale; - game_render_quad_world(g_pGameRenderer, v, h, sf, subT); - } - } - goto LABEL_1271; - case 0xB: - { - int iCarRenderIdx = iSectionNum; - GameRenderCarPose pose; - GameRenderCarOptions options; - const GameRenderCarPose *pCarPose; - const GameRenderCarOptions *pCarOptions; - if (pTypedRenderCommand != NULL && pTypedRenderCommand->kind == RENDER_COMMAND_3D_KIND_CAR) { - iCarRenderIdx = pTypedRenderCommand->payload.car.car_idx; - pCarPose = &pTypedRenderCommand->payload.car.pose; - pCarOptions = &pTypedRenderCommand->payload.car.options; - } else { - pose.position = Car[iSectionNum].pos; - pose.yaw = Car[iSectionNum].nYaw; - pose.pitch = Car[iSectionNum].nPitch; - pose.roll = Car[iSectionNum].nRoll; - options.anim_frame = Car[iSectionNum].byWheelAnimationFrame; - options.color_remap = NULL; - pCarPose = &pose; - pCarOptions = &options; + tGroundPt *g = &GroundPt[iSectionNum]; + v[0].x = g->pointAy[4].fX; + v[0].y = g->pointAy[4].fY; + v[0].z = g->pointAy[4].fZ; + v[1].x = g->pointAy[1].fX; + v[1].y = g->pointAy[1].fY; + v[1].z = g->pointAy[1].fZ; + v[2].x = g->pointAy[0].fX; + v[2].y = g->pointAy[0].fY; + v[2].z = g->pointAy[0].fZ; + v[3].x = g->pointAy[5].fX; + v[3].y = g->pointAy[5].fY; + v[3].z = g->pointAy[5].fZ; + v[0].u = 0; + v[0].v = 0; + v[1].u = 0; + v[1].v = 0; + v[2].u = 0; + v[2].v = 0; + v[3].u = 0; + v[3].v = 0; + TextureHandle h = + (renderSf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = + (uint8)Subdivide[iSectionNum].subdivides[5] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, renderSf, subT); } - if (CarsLeft < 7 && CarsLeft > -3 || winner_mode || replaytype == 2 || g_bForceMaxDraw) - game_render_draw_car(g_pGameRenderer, iCarRenderIdx, pCarPose, pCarOptions); - --CarsLeft; - if (names_on && (names_on == 1 || human_control[iCarRenderIdx])) - --NamesLeft; } - goto LABEL_1271; - case 0xC: - DrawTower(iSectionNum, pScrPtr_1); - goto LABEL_1271; - case 0xD: - DrawBuilding(iSectionNum, pScrPtr_1); - goto LABEL_1271; - case 0xE: - draw_start_light_cube_world(g_pGameRenderer, - &SLight[iChaseCamIdx_1][iSectionNum], - countdown, - worlddirn, - camera, - projection); - goto LABEL_1271; - default: - goto LABEL_1271; // Switch on render object type to call appropriate renderer + } + /* Two-section roof quad (TrakPt source, always rendered) */ + if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0 && + (sf & SURFACE_FLAG_APPLY_TEXTURE) != 0) + sf = remap_tex[(uint8)sf] + + (sf & (SURFACE_MASK_FLAGS ^ SURFACE_FLAG_APPLY_TEXTURE)); + { + GameRenderVertex v[4]; + world_verts_cross_first(v, TrakPt, iNextSectionIndex, iSectionNum, 1, + 5); + TextureHandle h = + (sf & SURFACE_FLAG_APPLY_TEXTURE) + ? game_render_get_texture_handle(g_pGameRenderer, 0) + : TEXTURE_HANDLE_INVALID; + float subT = (uint8)Subdivide[iSectionNum].subdivides[5] * subscale; + game_render_quad_world(g_pGameRenderer, v, h, sf, subT); + } + } + goto LABEL_1271; + case 0xB: { + int iCarRenderIdx = iSectionNum; + GameRenderCarPose pose; + GameRenderCarOptions options; + const GameRenderCarPose *pCarPose; + const GameRenderCarOptions *pCarOptions; + if (pTypedRenderCommand != NULL && + pTypedRenderCommand->kind == RENDER_COMMAND_3D_KIND_CAR) { + iCarRenderIdx = pTypedRenderCommand->payload.car.car_idx; + pCarPose = &pTypedRenderCommand->payload.car.pose; + pCarOptions = &pTypedRenderCommand->payload.car.options; + } else { + pose.position = Car[iSectionNum].pos; + pose.yaw = Car[iSectionNum].nYaw; + pose.pitch = Car[iSectionNum].nPitch; + pose.roll = Car[iSectionNum].nRoll; + options.anim_frame = Car[iSectionNum].byWheelAnimationFrame; + options.color_remap = NULL; + pCarPose = &pose; + pCarOptions = &options; + } + if (CarsLeft < 7 && CarsLeft > -3 || winner_mode || replaytype == 2 || + g_bForceMaxDraw) + game_render_draw_car(g_pGameRenderer, iCarRenderIdx, pCarPose, + pCarOptions); + --CarsLeft; + if (names_on && (names_on == 1 || human_control[iCarRenderIdx])) + --NamesLeft; + } + goto LABEL_1271; + case 0xC: + DrawTower(iSectionNum, pScrPtr_1); + goto LABEL_1271; + case 0xD: + DrawBuilding(iSectionNum, pScrPtr_1); + goto LABEL_1271; + case 0xE: + draw_start_light_cube_world(g_pGameRenderer, + &SLight[iChaseCamIdx_1][iSectionNum], + countdown, worlddirn, camera, projection); + goto LABEL_1271; + default: + goto LABEL_1271; // Switch on render object type to call appropriate + // renderer } } } @@ -2771,47 +3150,47 @@ void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, //------------------------------------------------------------------------------------------------- // Backface culling — expects VIEW-SPACE coordinates (camera at origin). -// Pass TrackScreenXYZ[].screenPtAy[n].projected.fX/fY/fZ, not world-space TrakPt[]. -// Returns 0 when polygon faces away (cull), -1 when facing toward (render). -//00027980 -int facing_ok(float fX0, float fY0, float fZ0, - float fX1, float fY1, float fZ1, - float fX2, float fY2, float fZ2, - float fX3, float fY3, float fZ3) -{ +// Pass TrackScreenXYZ[].screenPtAy[n].projected.fX/fY/fZ, not world-space +// TrakPt[]. Returns 0 when polygon faces away (cull), -1 when facing toward +// (render). +// 00027980 +int facing_ok(float fX0, float fY0, float fZ0, float fX1, float fY1, float fZ1, + float fX2, float fY2, float fZ2, float fX3, float fY3, + float fZ3) { float fDeltaX20; // [esp+20h] [ebp-4h] // Calculate X component of edge vector from vertex 0 to vertex 2 fDeltaX20 = fX2 - fX0; - // Compute the signed volume of the tetrahedron formed by the origin and three vertices - // This is equivalent to computing the triple scalar product: (V1-V0) \B7 ((V2-V0) \D7 (V3-V0)) - // Where V0=(fX0,fY0,fZ0), V1=(fX1,fY1,fZ1), V2=(fX2,fY2,fZ2), V3=(fX3,fY3,fZ3) + // Compute the signed volume of the tetrahedron formed by the origin and three + // vertices This is equivalent to computing the triple scalar product: (V1-V0) + // \B7 ((V2-V0) \D7 (V3-V0)) Where V0=(fX0,fY0,fZ0), V1=(fX1,fY1,fZ1), + // V2=(fX2,fY2,fZ2), V3=(fX3,fY3,fZ3) // The formula expands to a 3x3 determinant: // | (fX1-fX0) (fY1-fY0) (fZ1-fZ0) | // | (fX2-fX0) (fY2-fY0) (fZ2-fZ0) | // | (fX3-fX0) (fY3-fY0) (fZ3-fZ0) | - // Positive determinant = vertices ordered counter-clockwise when viewed from origin - // Negative determinant = vertices ordered clockwise when viewed from origin - return (((fY2 - fY0) * (fZ1 - fZ3) - (fZ2 - fZ0) * (fY1 - fY3)) * fX1 - + ((fZ2 - fZ0) * (fX1 - fX3) - (fZ1 - fZ3) * fDeltaX20) * fY1 - + ((fY1 - fY3) * fDeltaX20 - (fX1 - fX3) * (fY2 - fY0)) * fZ1 >= 0.0) - - 1; + // Positive determinant = vertices ordered counter-clockwise when viewed from + // origin Negative determinant = vertices ordered clockwise when viewed from + // origin + return (((fY2 - fY0) * (fZ1 - fZ3) - (fZ2 - fZ0) * (fY1 - fY3)) * fX1 + + ((fZ2 - fZ0) * (fX1 - fX3) - (fZ1 - fZ3) * fDeltaX20) * fY1 + + ((fY1 - fY3) * fDeltaX20 - (fX1 - fX3) * (fY2 - fY0)) * fZ1 >= + 0.0) - + 1; } //------------------------------------------------------------------------------------------------- -//00027A10 -int Zcmp(const void *pTrackView1, const void *pTrackView2) -{ +// 00027A10 +int Zcmp(const void *pTrackView1, const void *pTrackView2) { return render_queue_3d_compare_legacy_z_order(pTrackView1, pTrackView2); } //------------------------------------------------------------------------------------------------- -//00027A60 -void set_starts(unsigned int uiType) -{ +// 00027A60 +void set_starts(unsigned int uiType) { startsx[1] = 0; startsx[2] = 0; startsy[0] = 0; @@ -2819,39 +3198,39 @@ void set_starts(unsigned int uiType) if (gfx_size) { if (uiType) { if (uiType <= 1) { - startsx[0] = 0x3FF000; //64.0 - startsx[3] = 0x3FF000; //64.0 - startsy[2] = 0x1FF000; //31.875 - startsy[3] = 0x1FF000; //31.875 + startsx[0] = 0x3FF000; // 64.0 + startsx[3] = 0x3FF000; // 64.0 + startsy[2] = 0x1FF000; // 31.875 + startsy[3] = 0x1FF000; // 31.875 } else if (uiType == 2) { - startsx[0] = 0x1FF000; //31.875 - startsx[3] = 0x1FF000; //31.875 - startsy[2] = 0x3FF000; //64.0 - startsy[3] = 0x3FF000; //64.0 + startsx[0] = 0x1FF000; // 31.875 + startsx[3] = 0x1FF000; // 31.875 + startsy[2] = 0x3FF000; // 64.0 + startsy[3] = 0x3FF000; // 64.0 } } else { - startsx[0] = 0x1FF000; //31.875 - startsx[3] = 0x1FF000; //31.875 - startsy[2] = 0x1FF000; //31.875 - startsy[3] = 0x1FF000; //31.875 + startsx[0] = 0x1FF000; // 31.875 + startsx[3] = 0x1FF000; // 31.875 + startsy[2] = 0x1FF000; // 31.875 + startsy[3] = 0x1FF000; // 31.875 } } else if (uiType) { if (uiType <= 1) { - startsx[0] = 0x7FF000; //128.0 - startsx[3] = 0x7FF000; //128.0 - startsy[2] = 0x3FF000; //64.0 - startsy[3] = 0x3FF000; //64.0 + startsx[0] = 0x7FF000; // 128.0 + startsx[3] = 0x7FF000; // 128.0 + startsy[2] = 0x3FF000; // 64.0 + startsy[3] = 0x3FF000; // 64.0 } else if (uiType == 2) { - startsx[0] = 0x3FF000; //64.0 - startsx[3] = 0x3FF000; //64.0 - startsy[2] = 0x7FF000; //128.0 - startsy[3] = 0x7FF000; //128.0 + startsx[0] = 0x3FF000; // 64.0 + startsx[3] = 0x3FF000; // 64.0 + startsy[2] = 0x7FF000; // 128.0 + startsy[3] = 0x7FF000; // 128.0 } } else { - startsx[0] = 0x3FF000; //64.0 - startsx[3] = 0x3FF000; //64.0 - startsy[2] = 0x3FF000; //64.0 - startsy[3] = 0x3FF000; //64.0 + startsx[0] = 0x3FF000; // 64.0 + startsx[3] = 0x3FF000; // 64.0 + startsy[2] = 0x3FF000; // 64.0 + startsy[3] = 0x3FF000; // 64.0 } } diff --git a/PROJECTS/ROLLER/drawtrk3.h b/PROJECTS/ROLLER/drawtrk3.h index 44819aec..8b324f5f 100644 --- a/PROJECTS/ROLLER/drawtrk3.h +++ b/PROJECTS/ROLLER/drawtrk3.h @@ -54,10 +54,8 @@ int CalcVisibleTrack(int iCarIdx, unsigned int uiViewMode); void DrawTrack3(uint8 *pScrPtr, int iChaseCamIdx, int iCarIdx, const GameRenderCamera *camera, const GameRenderProjection *projection); -int facing_ok(float fX0, float fY0, float fZ0, - float fX1, float fY1, float fZ1, - float fX2, float fY2, float fZ2, - float fX3, float fY3, float fZ3); +int facing_ok(float fX0, float fY0, float fZ0, float fX1, float fY1, float fZ1, + float fX2, float fY2, float fZ2, float fX3, float fY3, float fZ3); int Zcmp(const void *pTrackView1, const void *pTrackView2); void set_starts(unsigned int uiType); diff --git a/PROJECTS/ROLLER/engines.c b/PROJECTS/ROLLER/engines.c index 3f6efdea..bb5bf46d 100644 --- a/PROJECTS/ROLLER/engines.c +++ b/PROJECTS/ROLLER/engines.c @@ -1,912 +1,652 @@ #include "engines.h" //------------------------------------------------------------------------------------------------- -//000A65EC -tRevCurve AUTO_A_revs[6] = -{ - { - { - { 28.579794f, 0.244f }, - { 45.727673f, 0.5f }, - { 58.792706f, 0.75f }, - { 88.189056f, 1.0f } - } - }, - { - { - { 46.641106f, 0.25f }, - { 69.158089f, 0.5f }, - { 95.947418f, 0.75f }, - { 143.92111f, 1.0f } - } - }, - { - { - { 71.157463f, 0.25f }, - { 108.1356f, 0.5f }, - { 146.38097f, 0.75f }, - { 219.5715f, 1.0f } - } - }, - { - { - { 100.15713f, 0.25f }, - { 156.87437f, 0.5f }, - { 211.12878f, 0.75f }, - { 316.69333f, 1.0f } - } - }, - { - { - { 147.34575f, 0.25f }, - { 229.5231f, 0.5f }, - { 303.11108f, 0.75f }, - { 454.66672f, 1.0f } - } - }, - { - { - { 217.4702f, 0.25f }, - { 319.59998f, 0.5f }, - { 429.11664f, 0.75f }, - { 623.75861f, 1.0f } - } - } -}; -float AUTO_A_spds[6] = { 48.0f, 69.0f, 106.0f, 153.0f, 199.0f, 260.0f }; -int AUTO_A_chgs[10] = { 66, 78, 100, 109, 154, 165, 225, 260, 307, 352 }; +// 000A65EC +tRevCurve AUTO_A_revs[6] = {{{{28.579794f, 0.244f}, + {45.727673f, 0.5f}, + {58.792706f, 0.75f}, + {88.189056f, 1.0f}}}, + {{{46.641106f, 0.25f}, + {69.158089f, 0.5f}, + {95.947418f, 0.75f}, + {143.92111f, 1.0f}}}, + {{{71.157463f, 0.25f}, + {108.1356f, 0.5f}, + {146.38097f, 0.75f}, + {219.5715f, 1.0f}}}, + {{{100.15713f, 0.25f}, + {156.87437f, 0.5f}, + {211.12878f, 0.75f}, + {316.69333f, 1.0f}}}, + {{{147.34575f, 0.25f}, + {229.5231f, 0.5f}, + {303.11108f, 0.75f}, + {454.66672f, 1.0f}}}, + {{{217.4702f, 0.25f}, + {319.59998f, 0.5f}, + {429.11664f, 0.75f}, + {623.75861f, 1.0f}}}}; +float AUTO_A_spds[6] = {48.0f, 69.0f, 106.0f, 153.0f, 199.0f, 260.0f}; +int AUTO_A_chgs[10] = {66, 78, 100, 109, 154, 165, 225, 260, 307, 352}; //------------------------------------------------------------------------------------------------- -//000A66EC -tRevCurve DESILVA_revs[6] = -{ - { - { - { 16.491211f, 0.25f }, - { 26.185932f, 0.5f }, - { 34.096203f, 0.75f }, - { 53.144299f, 1.0f } - } - }, - { - { - { 30.654739f, 0.25f }, - { 46.867813f, 0.5f }, - { 61.346893f, 0.75f }, - { 97.020332f, 1.0f } - } - }, - { - { - { 51.769516f, 0.25f }, - { 78.270706f, 0.5f }, - { 104.78295f, 0.75f }, - { 165.17439f, 1.0f } - } - }, - { - { - { 76.937088f, 0.25f }, - { 120.51019f, 0.5f }, - { 160.72777f, 0.75f }, - { 251.09177f, 1.0f } - } - }, - { - { - { 103.16528f, 0.25f }, - { 170.17467f, 0.5f }, - { 235.1971f, 0.75f }, - { 370.79565f, 1.0f } - } - }, - { - { - { 153.94896f, 0.25f }, - { 243.12111f, 0.5f }, - { 329.25421f, 0.75f }, - { 477.61697f, 1.0f } - } - } -}; -float DESILVA_spds[6] = { 51.0f, 91.0f, 130.0f, 170.0f, 209.0f, 254.0f }; +// 000A66EC +tRevCurve DESILVA_revs[6] = {{{{16.491211f, 0.25f}, + {26.185932f, 0.5f}, + {34.096203f, 0.75f}, + {53.144299f, 1.0f}}}, + {{{30.654739f, 0.25f}, + {46.867813f, 0.5f}, + {61.346893f, 0.75f}, + {97.020332f, 1.0f}}}, + {{{51.769516f, 0.25f}, + {78.270706f, 0.5f}, + {104.78295f, 0.75f}, + {165.17439f, 1.0f}}}, + {{{76.937088f, 0.25f}, + {120.51019f, 0.5f}, + {160.72777f, 0.75f}, + {251.09177f, 1.0f}}}, + {{{103.16528f, 0.25f}, + {170.17467f, 0.5f}, + {235.1971f, 0.75f}, + {370.79565f, 1.0f}}}, + {{{153.94896f, 0.25f}, + {243.12111f, 0.5f}, + {329.25421f, 0.75f}, + {477.61697f, 1.0f}}}}; +float DESILVA_spds[6] = {51.0f, 91.0f, 130.0f, 170.0f, 209.0f, 254.0f}; int DESILVA_chgs[10] = {41, 47, 71, 88, 116, 140, 175, 210, 236, 280}; //------------------------------------------------------------------------------------------------- -//000A67EC -tRevCurve PULSE_E_revs[6] = -{ - { - { - { 22.564655f, 0.25f }, - { 46.522068f, 0.5f }, - { 68.193947f, 0.75f }, - { 145.20439f, 1.0f } - } - }, - { - { - { 41.324272f, 0.25f }, - { 78.074791f, 0.5f }, - { 115.90099f, 0.75f }, - { 204.65367f, 1.0f } - } - }, - { - { - { 68.894485f, 0.25f }, - { 120.5897f, 0.5f }, - { 174.90921f, 0.75f }, - { 277.74957f, 1.0f } - } - }, - { - { - { 106.96906f, 0.25f }, - { 179.00517f, 0.5f }, - { 255.48692f, 0.75f }, - { 376.96317f, 1.0f } - } - }, - { - { - { 151.43668f, 0.25f }, - { 244.04697f, 0.5f }, - { 342.27097f, 0.75f }, - { 519.11011f, 1.0f } - } - }, - { - { - { 194.94302f, 0.25f }, - { 320.86929f, 0.5f }, - { 452.90363f, 0.75f }, - { 668.24536f, 1.0f } - } - } -}; -float PULSE_E_spds[6] = { 53.0f, 79.0f, 113.0f, 153.0f, 200.0f, 264.0f }; -int PULSE_E_chgs[10] = { 81, 88, 119, 127, 174, 193, 237, 255, 319, 334 }; +// 000A67EC +tRevCurve PULSE_E_revs[6] = {{{{22.564655f, 0.25f}, + {46.522068f, 0.5f}, + {68.193947f, 0.75f}, + {145.20439f, 1.0f}}}, + {{{41.324272f, 0.25f}, + {78.074791f, 0.5f}, + {115.90099f, 0.75f}, + {204.65367f, 1.0f}}}, + {{{68.894485f, 0.25f}, + {120.5897f, 0.5f}, + {174.90921f, 0.75f}, + {277.74957f, 1.0f}}}, + {{{106.96906f, 0.25f}, + {179.00517f, 0.5f}, + {255.48692f, 0.75f}, + {376.96317f, 1.0f}}}, + {{{151.43668f, 0.25f}, + {244.04697f, 0.5f}, + {342.27097f, 0.75f}, + {519.11011f, 1.0f}}}, + {{{194.94302f, 0.25f}, + {320.86929f, 0.5f}, + {452.90363f, 0.75f}, + {668.24536f, 1.0f}}}}; +float PULSE_E_spds[6] = {53.0f, 79.0f, 113.0f, 153.0f, 200.0f, 264.0f}; +int PULSE_E_chgs[10] = {81, 88, 119, 127, 174, 193, 237, 255, 319, 334}; //------------------------------------------------------------------------------------------------- -//000A68EC -tRevCurve GLOBAL_revs[5] = -{ - { - { - { 42.847168f, 0.25f }, - { 74.752739f, 0.5f }, - { 106.99044f, 0.75f }, - { 170.9856f, 1.0f } - } - }, - { - { - { 78.330338f, 0.25f }, - { 121.83336f, 0.5f }, - { 165.81944f, 0.75f }, - { 248.72916f, 1.0f } - } - }, - { - { - { 113.44698f, 0.25f }, - { 176.45299f, 0.5f }, - { 240.15871f, 0.75f }, - { 360.23816f, 1.0f } - } - }, - { - { - { 166.20938f, 0.25f }, - { 258.51852f, 0.5f }, - { 351.85266f, 0.75f }, - { 527.77905f, 1.0f } - } - }, - { - { - { 225.34633f, 0.25f }, - { 348.23734f, 0.5f }, - { 463.56949f, 0.75f }, - { 695.35406f, 1.0f } - } - } -}; -float GLOBAL_spds[5] = { 76.0f, 104.0f, 145.0f, 202.0f, 268.0f }; -int GLOBAL_chgs[8] = { 111, 132, 172, 189, 251, 279, 342, 367 }; +// 000A68EC +tRevCurve GLOBAL_revs[5] = {{{{42.847168f, 0.25f}, + {74.752739f, 0.5f}, + {106.99044f, 0.75f}, + {170.9856f, 1.0f}}}, + {{{78.330338f, 0.25f}, + {121.83336f, 0.5f}, + {165.81944f, 0.75f}, + {248.72916f, 1.0f}}}, + {{{113.44698f, 0.25f}, + {176.45299f, 0.5f}, + {240.15871f, 0.75f}, + {360.23816f, 1.0f}}}, + {{{166.20938f, 0.25f}, + {258.51852f, 0.5f}, + {351.85266f, 0.75f}, + {527.77905f, 1.0f}}}, + {{{225.34633f, 0.25f}, + {348.23734f, 0.5f}, + {463.56949f, 0.75f}, + {695.35406f, 1.0f}}}}; +float GLOBAL_spds[5] = {76.0f, 104.0f, 145.0f, 202.0f, 268.0f}; +int GLOBAL_chgs[8] = {111, 132, 172, 189, 251, 279, 342, 367}; //------------------------------------------------------------------------------------------------- -//000A69C0 -tRevCurve MILLION_revs[6] = -{ - { - { - { 27.8528f, 0.25f }, - { 44.56448f, 0.5f }, - { 57.29718f, 0.75f }, - { 85.945763f, 1.0f } - } - }, - { - { - { 49.540188f, 0.25f }, - { 73.456757f, 0.5f }, - { 101.91125f, 0.75f }, - { 152.86685f, 1.0f } - } - }, - { - { - { 82.735603f, 0.25f }, - { 125.73052f, 0.5f }, - { 170.19887f, 0.75f }, - { 255.29834f, 1.0f } - } - }, - { - { - { 125.48128f, 0.25f }, - { 192.80843f, 0.5f }, - { 258.133f, 0.75f }, - { 387.19974f, 1.0f } - } - }, - { - { - { 176.82304f, 0.25f }, - { 273.25223f, 0.5f }, - { 363.75009f, 0.75f }, - { 545.62506f, 1.0f } - } - }, - { - { - { 240.81444f, 0.25f }, - { 372.14053f, 0.5f }, - { 495.38925f, 0.75f }, - { 683.52258f, 1.0f } - } - } -}; -float MILLION_spds[6] = { 38.0f, 64.0f, 95.0f, 139.0f, 183.0f, 256.0f }; -int MILLION_chgs[10] = { 67, 75, 114, 135, 184, 205, 269, 304, 372, 394 }; +// 000A69C0 +tRevCurve MILLION_revs[6] = {{{{27.8528f, 0.25f}, + {44.56448f, 0.5f}, + {57.29718f, 0.75f}, + {85.945763f, 1.0f}}}, + {{{49.540188f, 0.25f}, + {73.456757f, 0.5f}, + {101.91125f, 0.75f}, + {152.86685f, 1.0f}}}, + {{{82.735603f, 0.25f}, + {125.73052f, 0.5f}, + {170.19887f, 0.75f}, + {255.29834f, 1.0f}}}, + {{{125.48128f, 0.25f}, + {192.80843f, 0.5f}, + {258.133f, 0.75f}, + {387.19974f, 1.0f}}}, + {{{176.82304f, 0.25f}, + {273.25223f, 0.5f}, + {363.75009f, 0.75f}, + {545.62506f, 1.0f}}}, + {{{240.81444f, 0.25f}, + {372.14053f, 0.5f}, + {495.38925f, 0.75f}, + {683.52258f, 1.0f}}}}; +float MILLION_spds[6] = {38.0f, 64.0f, 95.0f, 139.0f, 183.0f, 256.0f}; +int MILLION_chgs[10] = {67, 75, 114, 135, 184, 205, 269, 304, 372, 394}; //------------------------------------------------------------------------------------------------- -//000A6AC0 -tRevCurve MISSION_revs[6] = -{ - { - { - { 26.487736f, 0.25f }, - { 42.380379f, 0.5f }, - { 54.489052f, 0.75f }, - { 81.733566f, 1.0f } - } - }, - { - { - { 47.588108f, 0.25f }, - { 70.562271f, 0.5f }, - { 97.895538f, 0.75f }, - { 146.84329f, 1.0f } - } - }, - { - { - { 74.934036f, 0.25f }, - { 113.87476f, 0.5f }, - { 154.14993f, 0.75f }, - { 231.22496f, 1.0f } - } - }, - { - { - { 102.59023f, 0.25f }, - { 160.76428f, 0.5f }, - { 217.90971f, 0.75f }, - { 326.86475f, 1.0f } - } - }, - { - { - { 139.41597f, 0.25f }, - { 216.74489f, 0.5f }, - { 294.53867f, 0.75f }, - { 441.80795f, 1.0f } - } - }, - { - { - { 193.0443f, 0.25f }, - { 298.31931f, 0.5f }, - { 400.11057f, 0.75f }, - { 575.85114f, 1.0f } - } - } -}; -float MISSION_spds[6] = { 59.0, 81.0, 113.0, 151.0, 199.0, 258.0 }; -int MISSION_chgs[10] = { 64, 85, 105, 124, 160, 177, 215, 233, 293, 325 }; +// 000A6AC0 +tRevCurve MISSION_revs[6] = {{{{26.487736f, 0.25f}, + {42.380379f, 0.5f}, + {54.489052f, 0.75f}, + {81.733566f, 1.0f}}}, + {{{47.588108f, 0.25f}, + {70.562271f, 0.5f}, + {97.895538f, 0.75f}, + {146.84329f, 1.0f}}}, + {{{74.934036f, 0.25f}, + {113.87476f, 0.5f}, + {154.14993f, 0.75f}, + {231.22496f, 1.0f}}}, + {{{102.59023f, 0.25f}, + {160.76428f, 0.5f}, + {217.90971f, 0.75f}, + {326.86475f, 1.0f}}}, + {{{139.41597f, 0.25f}, + {216.74489f, 0.5f}, + {294.53867f, 0.75f}, + {441.80795f, 1.0f}}}, + {{{193.0443f, 0.25f}, + {298.31931f, 0.5f}, + {400.11057f, 0.75f}, + {575.85114f, 1.0f}}}}; +float MISSION_spds[6] = {59.0, 81.0, 113.0, 151.0, 199.0, 258.0}; +int MISSION_chgs[10] = {64, 85, 105, 124, 160, 177, 215, 233, 293, 325}; //------------------------------------------------------------------------------------------------- -//000A6BC0 -tRevCurve ZIZIN_revs[4] = -{ - { - { - { 42.982391f, 0.25f }, - { 71.525978f, 0.5f }, - { 96.917084f, 0.75f }, - { 151.12343f, 1.0f } - } - }, - { - { - { 76.295563f, 0.25f }, - { 116.25745f, 0.5f }, - { 161.82277f, 0.75f }, - { 269.93451f, 1.0f } - } - }, - { - { - { 123.29719f, 0.25f }, - { 186.44043f, 0.5f }, - { 260.57764f, 0.75f }, - { 388.90167f, 1.0f } - } - }, - { - { - { 185.10548f, 0.25f }, - { 283.26611f, 0.5f }, - { 387.93466f, 0.75f }, - { 591.70868f, 1.0f } - } - } -}; -float ZIZIN_spds[4] = { 86.0, 124.0, 181.0, 262.0 }; -int ZIZIN_chgs[6] = { 107, 128, 169, 195, 264, 292 }; +// 000A6BC0 +tRevCurve ZIZIN_revs[4] = {{{{42.982391f, 0.25f}, + {71.525978f, 0.5f}, + {96.917084f, 0.75f}, + {151.12343f, 1.0f}}}, + {{{76.295563f, 0.25f}, + {116.25745f, 0.5f}, + {161.82277f, 0.75f}, + {269.93451f, 1.0f}}}, + {{{123.29719f, 0.25f}, + {186.44043f, 0.5f}, + {260.57764f, 0.75f}, + {388.90167f, 1.0f}}}, + {{{185.10548f, 0.25f}, + {283.26611f, 0.5f}, + {387.93466f, 0.75f}, + {591.70868f, 1.0f}}}}; +float ZIZIN_spds[4] = {86.0, 124.0, 181.0, 262.0}; +int ZIZIN_chgs[6] = {107, 128, 169, 195, 264, 292}; //------------------------------------------------------------------------------------------------- -//000A6C68 -tRevCurve REISE_W_revs[5] = -{ - { - { - { 80.515694f, 0.25f }, - { 125.38533f, 0.5f }, - { 162.57413f, 0.75f }, - { 230.39226f, 1.0f } - } - }, - { - { - { 111.80281f, 0.25f }, - { 173.12297f, 0.5f }, - { 221.63953f, 0.75f }, - { 314.09692f, 1.0f } - } - }, - { - { - { 161.39061f, 0.25f }, - { 232.34853f, 0.5f }, - { 295.55991f, 0.75f }, - { 414.88751f, 1.0f } - } - }, - { - { - { 213.04604f, 0.25f }, - { 301.77139f, 0.5f }, - { 379.60611f, 0.75f }, - { 564.79596f, 1.0f } - } - }, - { - { - { 276.03412f, 0.25f }, - { 381.1362f, 0.5f }, - { 498.17691f, 0.75f }, - { 761.04614f, 1.0f } - } - } -}; -float REISE_W_spds[5] = { 79.0f, 105.0f, 140.0f, 191.0f, 277.0f }; -int REISE_W_chgs[8] = { 173, 191, 229, 251, 298, 316, 374, 383 }; +// 000A6C68 +tRevCurve REISE_W_revs[5] = {{{{80.515694f, 0.25f}, + {125.38533f, 0.5f}, + {162.57413f, 0.75f}, + {230.39226f, 1.0f}}}, + {{{111.80281f, 0.25f}, + {173.12297f, 0.5f}, + {221.63953f, 0.75f}, + {314.09692f, 1.0f}}}, + {{{161.39061f, 0.25f}, + {232.34853f, 0.5f}, + {295.55991f, 0.75f}, + {414.88751f, 1.0f}}}, + {{{213.04604f, 0.25f}, + {301.77139f, 0.5f}, + {379.60611f, 0.75f}, + {564.79596f, 1.0f}}}, + {{{276.03412f, 0.25f}, + {381.1362f, 0.5f}, + {498.17691f, 0.75f}, + {761.04614f, 1.0f}}}}; +float REISE_W_spds[5] = {79.0f, 105.0f, 140.0f, 191.0f, 277.0f}; +int REISE_W_chgs[8] = {173, 191, 229, 251, 298, 316, 374, 383}; //------------------------------------------------------------------------------------------------- -//000A6D3C -tRevCurve fast_revs[6] = -{ - { - { - { 19.491211f, 0.25f }, - { 31.185932f, 0.5f }, - { 40.096203f, 0.75f }, - { 60.144299f, 1.0f } - } - }, - { - { - { 35.654739f, 0.25f }, - { 52.867813f, 0.5f }, - { 73.346893f, 0.75f }, - { 110.02033f, 1.0f } - } - }, - { - { - { 56.769516f, 0.25f }, - { 86.270706f, 0.5f }, - { 116.78295f, 0.75f }, - { 175.17439f, 1.0f } - } - }, - { - { - { 84.937088f, 0.25f }, - { 130.51019f, 0.5f }, - { 174.72777f, 0.75f }, - { 262.09177f, 1.0f } - } - }, - { - { - { 120.16528f, 0.25f }, - { 181.17467f, 0.5f }, - { 247.1971f, 0.75f }, - { 370.79565f, 1.0f } - } - }, - { - { - { 162.94896f, 0.25f }, - { 246.12111f, 0.5f }, - { 341.25421f, 0.75f }, - { 510.61697f, 1.0f } - } - } -}; -float fast_spds[6] = { 55.0f, 86.0f, 139.0f, 185.0f, 229.0f, 285.0f }; -int fast_chgs[10] = { 47, 57, 79, 86, 125, 147, 176, 207, 236, 271 }; +// 000A6D3C +tRevCurve fast_revs[6] = {{{{19.491211f, 0.25f}, + {31.185932f, 0.5f}, + {40.096203f, 0.75f}, + {60.144299f, 1.0f}}}, + {{{35.654739f, 0.25f}, + {52.867813f, 0.5f}, + {73.346893f, 0.75f}, + {110.02033f, 1.0f}}}, + {{{56.769516f, 0.25f}, + {86.270706f, 0.5f}, + {116.78295f, 0.75f}, + {175.17439f, 1.0f}}}, + {{{84.937088f, 0.25f}, + {130.51019f, 0.5f}, + {174.72777f, 0.75f}, + {262.09177f, 1.0f}}}, + {{{120.16528f, 0.25f}, + {181.17467f, 0.5f}, + {247.1971f, 0.75f}, + {370.79565f, 1.0f}}}, + {{{162.94896f, 0.25f}, + {246.12111f, 0.5f}, + {341.25421f, 0.75f}, + {510.61697f, 1.0f}}}}; +float fast_spds[6] = {55.0f, 86.0f, 139.0f, 185.0f, 229.0f, 285.0f}; +int fast_chgs[10] = {47, 57, 79, 86, 125, 147, 176, 207, 236, 271}; //------------------------------------------------------------------------------------------------- -//000A6E3C -tCarEngines CarEngines = -{ - { - { - 6, - &AUTO_A_revs[0], - &AUTO_A_spds[0], - 5.6999998f, - &AUTO_A_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 7, - 14, - 4, - 7, - 2, - 72, - 10.0f, - 120.0f, - 1.7f, - 100.0f - }, - { - 6, - &DESILVA_revs[0], - &DESILVA_spds[0], - 4.9000001f, - &DESILVA_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 8, - 16, - 4, - 6, - 2, - 74, - 0.0f, - 100.0f, - 1.6f, - 75.0f - }, - { - 6, - &PULSE_E_revs[0], - &PULSE_E_spds[0], - 6.1999998f, - &PULSE_E_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 24, - 14, - 4, - 7, - 2, - 88, - -10.0f, - 60.0f, - 1.65f, - 100.0f - }, - { - 5, - &GLOBAL_revs[0], - &GLOBAL_spds[0], - 8.0f, - &GLOBAL_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 10, - 10, - 3, - 14, - 2, - 71, - -10.0f, - 100.0f, - 1.45f, - 150.0f - }, - { - 6, - &MILLION_revs[0], - &MILLION_spds[0], - 6.5999999f, - &MILLION_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 8, - 16, - 5, - 8, - 2, - 70, - 50.0f, - 250.0f, - 1.8f, - 125.0f - }, - { - 6, - &MISSION_revs[0], - &MISSION_spds[0], - 4.4000001f, - &MISSION_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 7, - 14, - 5, - 7, - 2, - 72, - 20.0f, - 140.0f, - 1.75f, - 90.0f - }, - { - 4, - &ZIZIN_revs[0], - &ZIZIN_spds[0], - 6.5999999f, - &ZIZIN_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 20, - 100, - 45, - 50, - 40, - 8, - 8, - 2, - 100, - -15.0f, - 40.0f, - 1.55f, - 100.0f - }, - { - 5, - &REISE_W_revs[0], - &REISE_W_spds[0], - 9.6999998f, - &REISE_W_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 12, - 12, - 6, - 16, - 2, - 70, - -5.0f, - 75.0f, - 1.5f, - 200.0f - }, - { - 6, - &fast_revs[0], - &fast_spds[0], - 2.9000001f, - &fast_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 10, - 10, - 3, - 14, - 2, - 71, - -10.0f, - 100.0f, - 1.45f, - 150.0f - }, - { - 6, - &fast_revs[0], - &fast_spds[0], - 1.9f, - &fast_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 8, - 16, - 5, - 8, - 2, - 72, - 50.0f, - 250.0f, - 1.0f, - 1000.0f - }, - { - 6, - &fast_revs[0], - &fast_spds[0], - 2.9000001f, - &fast_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 24, - 14, - 4, - 7, - 2, - 88, - -10.0f, - 60.0f, - 1.0f, - 1000.0f - }, - { - 6, - &fast_revs[0], - &fast_spds[0], - 2.9000001f, - &fast_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 8, - 16, - 5, - 8, - 2, - 72, - 50.0f, - 250.0f, - 1.0f, - 1000.0f - }, - { - 6, - &fast_revs[0], - &fast_spds[0], - 2.9000001f, - &fast_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 8, - 16, - 5, - 8, - 2, - 80, - 50.0f, - 250.0f, - 1.0f, - 1000.0f - }, - { - 6, - &fast_revs[0], - &fast_spds[0], - 2.9000001f, - &fast_chgs[0], - 1200, - 0.94999999f, - 0.97000003f, - 262144, - 4, - 80, - 4, - -80, - 8, - 8, - 10, - 100, - 30, - 8, - 16, - 5, - 8, - 2, - 70, - 50.0f, - 250.0f, - 0.40000001f, - 2000.0f - } - } -}; +// 000A6E3C +tCarEngines CarEngines = {{{6, + &AUTO_A_revs[0], + &AUTO_A_spds[0], + 5.6999998f, + &AUTO_A_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 7, + 14, + 4, + 7, + 2, + 72, + 10.0f, + 120.0f, + 1.7f, + 100.0f}, + {6, + &DESILVA_revs[0], + &DESILVA_spds[0], + 4.9000001f, + &DESILVA_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 8, + 16, + 4, + 6, + 2, + 74, + 0.0f, + 100.0f, + 1.6f, + 75.0f}, + {6, + &PULSE_E_revs[0], + &PULSE_E_spds[0], + 6.1999998f, + &PULSE_E_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 24, + 14, + 4, + 7, + 2, + 88, + -10.0f, + 60.0f, + 1.65f, + 100.0f}, + {5, + &GLOBAL_revs[0], + &GLOBAL_spds[0], + 8.0f, + &GLOBAL_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 10, + 10, + 3, + 14, + 2, + 71, + -10.0f, + 100.0f, + 1.45f, + 150.0f}, + {6, + &MILLION_revs[0], + &MILLION_spds[0], + 6.5999999f, + &MILLION_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 8, + 16, + 5, + 8, + 2, + 70, + 50.0f, + 250.0f, + 1.8f, + 125.0f}, + {6, + &MISSION_revs[0], + &MISSION_spds[0], + 4.4000001f, + &MISSION_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 7, + 14, + 5, + 7, + 2, + 72, + 20.0f, + 140.0f, + 1.75f, + 90.0f}, + {4, + &ZIZIN_revs[0], + &ZIZIN_spds[0], + 6.5999999f, + &ZIZIN_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 20, + 100, + 45, + 50, + 40, + 8, + 8, + 2, + 100, + -15.0f, + 40.0f, + 1.55f, + 100.0f}, + {5, + &REISE_W_revs[0], + &REISE_W_spds[0], + 9.6999998f, + &REISE_W_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 12, + 12, + 6, + 16, + 2, + 70, + -5.0f, + 75.0f, + 1.5f, + 200.0f}, + {6, + &fast_revs[0], + &fast_spds[0], + 2.9000001f, + &fast_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 10, + 10, + 3, + 14, + 2, + 71, + -10.0f, + 100.0f, + 1.45f, + 150.0f}, + {6, + &fast_revs[0], + &fast_spds[0], + 1.9f, + &fast_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 8, + 16, + 5, + 8, + 2, + 72, + 50.0f, + 250.0f, + 1.0f, + 1000.0f}, + {6, + &fast_revs[0], + &fast_spds[0], + 2.9000001f, + &fast_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 24, + 14, + 4, + 7, + 2, + 88, + -10.0f, + 60.0f, + 1.0f, + 1000.0f}, + {6, + &fast_revs[0], + &fast_spds[0], + 2.9000001f, + &fast_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 8, + 16, + 5, + 8, + 2, + 72, + 50.0f, + 250.0f, + 1.0f, + 1000.0f}, + {6, + &fast_revs[0], + &fast_spds[0], + 2.9000001f, + &fast_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 8, + 16, + 5, + 8, + 2, + 80, + 50.0f, + 250.0f, + 1.0f, + 1000.0f}, + {6, + &fast_revs[0], + &fast_spds[0], + 2.9000001f, + &fast_chgs[0], + 1200, + 0.94999999f, + 0.97000003f, + 262144, + 4, + 80, + 4, + -80, + 8, + 8, + 10, + 100, + 30, + 8, + 16, + 5, + 8, + 2, + 70, + 50.0f, + 250.0f, + 0.40000001f, + 2000.0f}}}; //------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/PROJECTS/ROLLER/engines.h b/PROJECTS/ROLLER/engines.h index 257790c1..9e79b01f 100644 --- a/PROJECTS/ROLLER/engines.h +++ b/PROJECTS/ROLLER/engines.h @@ -4,26 +4,23 @@ #include "types.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fPower; float fRPM; } tRevCurvePoint; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tRevCurvePoint points[4]; } tRevCurve; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iNumGears; tRevCurve *pRevs; - float *pSpds; ///< maximum speed at each gear + float *pSpds; ///< maximum speed at each gear float fDragCoefficient; int *pChgs; int iOscillationFreq; @@ -53,8 +50,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tCarEngine engines[14]; } tCarEngines; diff --git a/PROJECTS/ROLLER/frontend.h b/PROJECTS/ROLLER/frontend.h index 5dfcc813..9c7fd3bb 100644 --- a/PROJECTS/ROLLER/frontend.h +++ b/PROJECTS/ROLLER/frontend.h @@ -5,14 +5,13 @@ #include "func3.h" //------------------------------------------------------------------------------------------------- // 3D preview viewport (GPU backend only; software backend ignores these) -#define PREVIEW_X 248 -#define PREVIEW_W 300 -#define PREVIEW_H 330 -#define CAR_PREVIEW_Y 57 -#define TRACK_PREVIEW_Y 5 +#define PREVIEW_X 248 +#define PREVIEW_W 300 +#define PREVIEW_H 330 +#define CAR_PREVIEW_Y 57 +#define TRACK_PREVIEW_Y 5 -typedef struct -{ +typedef struct { int x; int y; } tPoint; diff --git a/PROJECTS/ROLLER/frontend_config.c b/PROJECTS/ROLLER/frontend_config.c index b4024e56..feeb3e2d 100644 --- a/PROJECTS/ROLLER/frontend_config.c +++ b/PROJECTS/ROLLER/frontend_config.c @@ -25,271 +25,270 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -//00042D40 -void select_configure() -{ - char *szString; // eax - int iCharIndex; // edx - int iCarIndex; // esi - const char *szCarName; // edi - uint8 byTextColor1; // al - uint8 byTextColor2; // al - uint8 byTextColor3; // al - uint8 byTextColor4; // al - char byChar; // al - int iFontWidth; // eax - uint8 byTextColor5; // al - uint8 byTextColor6; // al - uint8 byTextColor7; // al - int iTemp1; // edi - uint8 byTextColor8; // al - uint8 byTextColor9; // al - uint8 byColor; // al - int iSelectedCar_1; // edi - uint8 byColor_1; // al - uint8 byColor_2; // al - char byVolumeColor1; // al - char byVolumeColor2; // al - char byVolumeColor3; // al - char byVolumeColor4; // al - char byColor_3; // al - char byColor_4; // al - char byColor_5; // al - char byColor_6; // al - char byColor_7; // al - char byColor_9; // al - char byColor_8; // al - char byColor_10; // al - char byColor_11; // al - char byColor_13; // al - char byColor_12; // al - char byColor_14; // al - int byColor_15; // ebx - int byColor_16; // ebx - int byColor_17; // ebx - int iVolumeSelection_1; // ecx - int byColor_18; // ebx - int iConfigState_1; // edi - int iJoyCalibValue1; // ebx - char *szJoyStatus1; // edx - int iJoyCalibValue2; // ebx - char *szJoyStatus2; // edx - int iX2CalibrationVal; // ebx - char *szX2Text; // edx - int iConfigState_2; // edi - int iY2CalibrationVal; // ebx - char *szY2Text; // edx - int iKeyFound; // ebx - int iKeyIndex; // eax - int iKeyCounter; // edx - char byColor_19; // al - char byColor_20; // al - char byColor_21; // al - char byColor_22; // al - char byColor_23; // al - int iControlLoop; // esi +// 00042D40 +void select_configure() { + char *szString; // eax + int iCharIndex; // edx + int iCarIndex; // esi + const char *szCarName; // edi + uint8 byTextColor1; // al + uint8 byTextColor2; // al + uint8 byTextColor3; // al + uint8 byTextColor4; // al + char byChar; // al + int iFontWidth; // eax + uint8 byTextColor5; // al + uint8 byTextColor6; // al + uint8 byTextColor7; // al + int iTemp1; // edi + uint8 byTextColor8; // al + uint8 byTextColor9; // al + uint8 byColor; // al + int iSelectedCar_1; // edi + uint8 byColor_1; // al + uint8 byColor_2; // al + char byVolumeColor1; // al + char byVolumeColor2; // al + char byVolumeColor3; // al + char byVolumeColor4; // al + char byColor_3; // al + char byColor_4; // al + char byColor_5; // al + char byColor_6; // al + char byColor_7; // al + char byColor_9; // al + char byColor_8; // al + char byColor_10; // al + char byColor_11; // al + char byColor_13; // al + char byColor_12; // al + char byColor_14; // al + int byColor_15; // ebx + int byColor_16; // ebx + int byColor_17; // ebx + int iVolumeSelection_1; // ecx + int byColor_18; // ebx + int iConfigState_1; // edi + int iJoyCalibValue1; // ebx + char *szJoyStatus1; // edx + int iJoyCalibValue2; // ebx + char *szJoyStatus2; // edx + int iX2CalibrationVal; // ebx + char *szX2Text; // edx + int iConfigState_2; // edi + int iY2CalibrationVal; // ebx + char *szY2Text; // edx + int iKeyFound; // ebx + int iKeyIndex; // eax + int iKeyCounter; // edx + char byColor_19; // al + char byColor_20; // al + char byColor_21; // al + char byColor_22; // al + char byColor_23; // al + int iControlLoop; // esi const char *szControlName; // edi - uint8 byControlColor; // al - char byColor_24; // al - uint8 byColor_25; // al - char byColor_26; // al - int iControlIndex2; // esi - const char *szText; // edi - uint8 byColor_27; // al - uint8 byColor_28; // al - uint8 byColor_29; // al - uint8 byColor_30; // al - int iKeyCheckLoop; // eax - int iFoundKey; // ecx - int iKeySearchIndex; // edx - int iJoyValue1; // eax - int iJoyValue2; // eax - int iJoyValue3; // eax - int iJoyValue4; // eax - int iDuplicateCheck; // ebx - int i; // eax - int iEditIndex; // eax - int iControlState; // ebx - char byColor_31; // al - char byColor_32; // al - char *szText_1; // edx - char byColor_33; // al - char byColor_34; // al - char byColor_36; // al - char byColor_105; // al - char byColor_35; // al - char byColor_37; // al - char byColor_38; // al - char byColor_39; // al - char byColor_40; // al - char byColor_41; // al - char byColor_42; // al - char byColor_43; // al - char byColor_44; // al - char byColor_45; // al - char byColor_46; // al - char byColor_47; // al - char byColor_48; // al - char byColor_49; // al - char byColor_50; // al - char byColor_51; // al - char byColor_52; // al - char byColor_53; // al - char byColor_54; // al - char byColor_55; // al - char byColor_57; // al - char byColor_56; // al - char byColor_58; // al - char byColor_59; // al - char byColor_60; // al - char byColor_61; // al - char byColor_62; // al - char byColor_63; // al - char byColor_64; // al - char byColor_65; // al - char byColor_66; // al - char byColor_67; // al - char byColor_68; // al - char byColor_69; // al - char byColor_70; // al - char byColor_71; // al - char byColor_72; // al - char byColor_73; // al - char byColor_74; // al - int iReturnValue; // eax - char byColor_76; // al - char byColor_75; // al - char byColor_77; // al - char byColor_78; // al - char byColor_79; // al - char byColor_80; // al - char byColor_81; // al - char byColor_82; // al - char byColor_83; // al - char byColor_84; // al - char byColor_85; // al - char byColor_86; // al - char byColor_87; // al - char byColor_88; // al - char byColor_89; // al - char byColor_90; // al - char byColor_91; // al - char byColor_92; // al - char byColor_93; // al - char byColor_94; // al - char byColor_95; // al - char byColor_96; // di - uint8 byColor_97; // si - char *szMemPtr; // eax - int iFontChar; // edx - uint8 byColor_106; // al - uint8 byColor_98; // al - char byColor_99; // al - uint8 byColor_100; // al - char byColor_101; // al - uint8 byColor_102; // al - char byColor_103; // al - uint8 byColor_104; // al - int iNetworkState_1; // edi - int iX; // eax - int iPlayerIdx_1; // eax - //int iPlayersCarsOffset_1; // edx + uint8 byControlColor; // al + char byColor_24; // al + uint8 byColor_25; // al + char byColor_26; // al + int iControlIndex2; // esi + const char *szText; // edi + uint8 byColor_27; // al + uint8 byColor_28; // al + uint8 byColor_29; // al + uint8 byColor_30; // al + int iKeyCheckLoop; // eax + int iFoundKey; // ecx + int iKeySearchIndex; // edx + int iJoyValue1; // eax + int iJoyValue2; // eax + int iJoyValue3; // eax + int iJoyValue4; // eax + int iDuplicateCheck; // ebx + int i; // eax + int iEditIndex; // eax + int iControlState; // ebx + char byColor_31; // al + char byColor_32; // al + char *szText_1; // edx + char byColor_33; // al + char byColor_34; // al + char byColor_36; // al + char byColor_105; // al + char byColor_35; // al + char byColor_37; // al + char byColor_38; // al + char byColor_39; // al + char byColor_40; // al + char byColor_41; // al + char byColor_42; // al + char byColor_43; // al + char byColor_44; // al + char byColor_45; // al + char byColor_46; // al + char byColor_47; // al + char byColor_48; // al + char byColor_49; // al + char byColor_50; // al + char byColor_51; // al + char byColor_52; // al + char byColor_53; // al + char byColor_54; // al + char byColor_55; // al + char byColor_57; // al + char byColor_56; // al + char byColor_58; // al + char byColor_59; // al + char byColor_60; // al + char byColor_61; // al + char byColor_62; // al + char byColor_63; // al + char byColor_64; // al + char byColor_65; // al + char byColor_66; // al + char byColor_67; // al + char byColor_68; // al + char byColor_69; // al + char byColor_70; // al + char byColor_71; // al + char byColor_72; // al + char byColor_73; // al + char byColor_74; // al + int iReturnValue; // eax + char byColor_76; // al + char byColor_75; // al + char byColor_77; // al + char byColor_78; // al + char byColor_79; // al + char byColor_80; // al + char byColor_81; // al + char byColor_82; // al + char byColor_83; // al + char byColor_84; // al + char byColor_85; // al + char byColor_86; // al + char byColor_87; // al + char byColor_88; // al + char byColor_89; // al + char byColor_90; // al + char byColor_91; // al + char byColor_92; // al + char byColor_93; // al + char byColor_94; // al + char byColor_95; // al + char byColor_96; // di + uint8 byColor_97; // si + char *szMemPtr; // eax + int iFontChar; // edx + uint8 byColor_106; // al + uint8 byColor_98; // al + char byColor_99; // al + uint8 byColor_100; // al + char byColor_101; // al + uint8 byColor_102; // al + char byColor_103; // al + uint8 byColor_104; // al + int iNetworkState_1; // edi + int iX; // eax + int iPlayerIdx_1; // eax + // int iPlayersCarsOffset_1; // edx int iPlayerIdx; // eax - //int iPlayersCarsOffset; // edx - //uint32 uiTempCheatMode; // eax - unsigned int uiKeyCode; // eax + // int iPlayersCarsOffset; // edx + // uint32 uiTempCheatMode; // eax + unsigned int uiKeyCode; // eax unsigned int uiExtendedKey; // eax - int iMenuDir; // edi - int iMenuDir2; // edi - int iKeyInput; // eax - int iKeyChar; // ecx - unsigned int uiArrowKey; // eax - int iPrevSelectedCar; // edx - int iNextSelectedCar; // edx - int iNameLength_1; // eax - int iEditingName_1; // edi - int j; // ecx - int iPlayer2Car; // edx - int k; // ecx - int iDefaultNamesIdx_1; // edx - int iDefaultNamesCharItr; // ecx - int iDefaultNamesIdx; // edx - int m; // ecx - int n; // ecx - int iAIDriverIdx; // eax - //int v189; // ecx - //int iOffset; // eax - //char v191; // dl - int ii; // ecx - int iPlayer2Car_1; // edx - int jj; // ecx - int iAIDriverIdx_1; // eax - int v196; // ecx - int v197; // edx - int iNameLength_2; // edi - unsigned int uiKey_5; // eax - int iNextVolumeSelection; // edi - unsigned int uiKey; // eax - unsigned int uiKey_1; // eax - unsigned int uiKey_6; // eax + int iMenuDir; // edi + int iMenuDir2; // edi + int iKeyInput; // eax + int iKeyChar; // ecx + unsigned int uiArrowKey; // eax + int iPrevSelectedCar; // edx + int iNextSelectedCar; // edx + int iNameLength_1; // eax + int iEditingName_1; // edi + int j; // ecx + int iPlayer2Car; // edx + int k; // ecx + int iDefaultNamesIdx_1; // edx + int iDefaultNamesCharItr; // ecx + int iDefaultNamesIdx; // edx + int m; // ecx + int n; // ecx + int iAIDriverIdx; // eax + // int v189; // ecx + // int iOffset; // eax + // char v191; // dl + int ii; // ecx + int iPlayer2Car_1; // edx + int jj; // ecx + int iAIDriverIdx_1; // eax + int v196; // ecx + int v197; // edx + int iNameLength_2; // edi + unsigned int uiKey_5; // eax + int iNextVolumeSelection; // edi + unsigned int uiKey; // eax + unsigned int uiKey_1; // eax + unsigned int uiKey_6; // eax int iNextControlSelection; // edi - int iDisplayIndex; // edi - unsigned int uiKey_2; // eax - uint32 uiTexOffTemp_7; // eax - uint32 uiTexOffTemp; // edx - uint32 uiTexOffTemp_1; // eax - uint32 uiTexOffTemp_2; // ecx - uint32 uiTexOffTemp_3; // ebx - uint32 uiTexOffTemp_4; // edx - uint32 uiTexOffTemp_5; // eax - unsigned int uiKey_3; // eax - int iPlayerIndex; // esi - uint32 uiTexOffTemp_6; // edx - unsigned int uiKey_4; // eax + int iDisplayIndex; // edi + unsigned int uiKey_2; // eax + uint32 uiTexOffTemp_7; // eax + uint32 uiTexOffTemp; // edx + uint32 uiTexOffTemp_1; // eax + uint32 uiTexOffTemp_2; // ecx + uint32 uiTexOffTemp_3; // ebx + uint32 uiTexOffTemp_4; // edx + uint32 uiTexOffTemp_5; // eax + unsigned int uiKey_3; // eax + int iPlayerIndex; // esi + uint32 uiTexOffTemp_6; // edx + unsigned int uiKey_4; // eax unsigned int uiDataValue1; // edx - int iGameIndex; // ecx + int iGameIndex; // ecx unsigned int uiDataValue2; // eax - int iPlayerIndex2; // esi + int iPlayerIndex2; // esi unsigned int uiDataValue3; // eax - int iDataIndex; // edx - int iCounterVar; // ecx - char byTempFlag; // dl - bool kk; // zf - char byStatusFlag; // bl - int iResultValue; // eax - int iCalculation; // ebx - char byTempChar1; // [esp-10h] [ebp-16h] - char byTempChar2; // [esp-10h] [ebp-16h] - uint8 byTempValue; // [esp-8h] [ebp-Eh] - tJoyPos joyPos; // [esp+0h] [ebp-6h] BYREF - char szNewNameBuf[12]; // [esp+20h] [ebp+1Ah] BYREF - int iY; // [esp+2Ch] [ebp+26h] - int iTextPosX; // [esp+30h] [ebp+2Ah] - int iGraphicsState; // [esp+34h] [ebp+2Eh] - int iNetworkState; // [esp+38h] [ebp+32h] - int iControlsInEdit; // [esp+3Ch] [ebp+36h] - int iControlSelection; // [esp+40h] [ebp+3Ah] - int iVideoState; // [esp+44h] [ebp+3Eh] - int iVolumeSelection; // [esp+48h] [ebp+42h] - int iSelectedCar; // [esp+4Ch] [ebp+46h] - int iConfigState; // [esp+50h] [ebp+4Ah] - int iNameLength; // [esp+54h] [ebp+4Eh] - int iEditingName; // [esp+58h] [ebp+52h] - int iMenuSelection; // [esp+5Ch] [ebp+56h] - int iExitFlag; // [esp+60h] [ebp+5Ah] - int iCarDisplay; // [esp+64h] [ebp+5Eh] - int iDimmedColor; // [esp+68h] [ebp+62h] - int iActiveColor; // [esp+6Ch] [ebp+66h] - int iY_2; // [esp+70h] [ebp+6Ah] - int iY_1; // [esp+74h] [ebp+6Eh] - int iTextPosY; // [esp+78h] [ebp+72h] - int iNormalColor; // [esp+7Ch] [ebp+76h] - int iHighlightColor; // [esp+80h] [ebp+7Ah] - int iCarLoop; // [esp+84h] [ebp+7Eh] + int iDataIndex; // edx + int iCounterVar; // ecx + char byTempFlag; // dl + bool kk; // zf + char byStatusFlag; // bl + int iResultValue; // eax + int iCalculation; // ebx + char byTempChar1; // [esp-10h] [ebp-16h] + char byTempChar2; // [esp-10h] [ebp-16h] + uint8 byTempValue; // [esp-8h] [ebp-Eh] + tJoyPos joyPos; // [esp+0h] [ebp-6h] BYREF + char szNewNameBuf[12]; // [esp+20h] [ebp+1Ah] BYREF + int iY; // [esp+2Ch] [ebp+26h] + int iTextPosX; // [esp+30h] [ebp+2Ah] + int iGraphicsState; // [esp+34h] [ebp+2Eh] + int iNetworkState; // [esp+38h] [ebp+32h] + int iControlsInEdit; // [esp+3Ch] [ebp+36h] + int iControlSelection; // [esp+40h] [ebp+3Ah] + int iVideoState; // [esp+44h] [ebp+3Eh] + int iVolumeSelection; // [esp+48h] [ebp+42h] + int iSelectedCar; // [esp+4Ch] [ebp+46h] + int iConfigState; // [esp+50h] [ebp+4Ah] + int iNameLength; // [esp+54h] [ebp+4Eh] + int iEditingName; // [esp+58h] [ebp+52h] + int iMenuSelection; // [esp+5Ch] [ebp+56h] + int iExitFlag; // [esp+60h] [ebp+5Ah] + int iCarDisplay; // [esp+64h] [ebp+5Eh] + int iDimmedColor; // [esp+68h] [ebp+62h] + int iActiveColor; // [esp+6Ch] [ebp+66h] + int iY_2; // [esp+70h] [ebp+6Ah] + int iY_1; // [esp+74h] [ebp+6Eh] + int iTextPosY; // [esp+78h] [ebp+72h] + int iNormalColor; // [esp+7Ch] [ebp+76h] + int iHighlightColor; // [esp+80h] [ebp+7Ah] + int iCarLoop; // [esp+84h] [ebp+7Eh] // Init config menu fade_palette(0); @@ -342,2134 +341,2402 @@ void select_configure() } else { // draw menu selector menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); - menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, sel_posns[iMenuSelection].x, sel_posns[iMenuSelection].y, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, + sel_posns[iMenuSelection].x, sel_posns[iMenuSelection].y, + 0x8Fu, 0, pal_addr); } // menu options labels - menu_render_text(mr, 2, &config_buffer[3968], font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &config_buffer[256], font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &config_buffer[1664], font2_ascii, font2_offsets, sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &config_buffer[4032], font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &config_buffer[4096], font2_ascii, font2_offsets, sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &config_buffer[4160], font2_ascii, font2_offsets, sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &config_buffer[3968], font2_ascii, font2_offsets, + sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &config_buffer[256], font2_ascii, font2_offsets, + sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &config_buffer[1664], font2_ascii, font2_offsets, + sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &config_buffer[4032], font2_ascii, font2_offsets, + sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &config_buffer[4096], font2_ascii, font2_offsets, + sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &config_buffer[4160], font2_ascii, font2_offsets, + sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, + pal_addr); // network option if enabled if (network_on) - menu_render_text(mr, 2, &config_buffer[5568], font2_ascii, font2_offsets, sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &config_buffer[5568], font2_ascii, font2_offsets, + sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, + pal_addr); // Config state machine switch (iMenuSelection) { - case 0: - if (iEditingName == 1) { - iHighlightColor = 0xAB; - iNormalColor = 0xA5; - } else { - iHighlightColor = 0xA5; - iNormalColor = 0xAB; - } - if (iConfigState != 1) { - iHighlightColor = 0x8F; - iNormalColor = 0x8F; - } - if (iEditingName == 1) { - iTextPosX = 0; - szString = szNewNameBuf; - while (*szString) { - iCharIndex = (uint8)font1_ascii[(uint8)*szString++]; - if (iCharIndex == 255) - iTextPosX += 8; - else - iTextPosX += front_vga[15][iCharIndex].iWidth + 1; - } - iTextPosX += 430; - iY = 374 - 18 * iSelectedCar; + case 0: + if (iEditingName == 1) { + iHighlightColor = 0xAB; + iNormalColor = 0xA5; + } else { + iHighlightColor = 0xA5; + iNormalColor = 0xAB; + } + if (iConfigState != 1) { + iHighlightColor = 0x8F; + iNormalColor = 0x8F; + } + if (iEditingName == 1) { + iTextPosX = 0; + szString = szNewNameBuf; + while (*szString) { + iCharIndex = (uint8)font1_ascii[(uint8)*szString++]; + if (iCharIndex == 255) + iTextPosX += 8; + else + iTextPosX += front_vga[15][iCharIndex].iWidth + 1; } + iTextPosX += 430; + iY = 374 - 18 * iSelectedCar; + } - // Init car display loop - iCarLoop = 0; - iDimmedColor = iHighlightColor - 2; - iCarDisplay = 15; - iCarIndex = 18; - iActiveColor = iNormalColor - 4; - szCarName = comp_name[0]; - iTextPosY = 50; - - // Display all 16 cars in reverse order - do { - // Check if car slot is allocated to a player - if ((iCarLoop & 1) >= allocated_cars[iCarDisplay / 2]) { - // Car is available for Ai palyers - if (iCarIndex == iSelectedCar && iEditingName == 1) { - // Selected car with name being edited - menu_render_text(mr, 15, szCarName, font1_ascii, font1_offsets, 425, iTextPosY, iNormalColor, 2u, pal_addr); - if (iCarIndex == iSelectedCar) - byTextColor3 = iHighlightColor; - else - byTextColor3 = 0x8F; - menu_render_text(mr, 15, szNewNameBuf, font1_ascii, font1_offsets, 430, iTextPosY, byTextColor3, 0, pal_addr); - } else { - // Selected car with default name displayed - if (iCarIndex == iSelectedCar) - byTextColor4 = iNormalColor; - else - byTextColor4 = 0x8F; - menu_render_text(mr, 15, szCarName, font1_ascii, font1_offsets, 425, iTextPosY, byTextColor4, 2u, pal_addr); - if (iCarIndex == iSelectedCar) - byChar = iHighlightColor; - else - byChar = 0x8F; - - // Display AI name (using bit toggle for paired names) - byTempValue = byChar; - iFontWidth = iCarDisplay; - //LOBYTE(iFontWidth) = iCarDisplay ^ 1; - iFontWidth = iCarDisplay ^ 1; - menu_render_text(mr, 15, default_names[iFontWidth], font1_ascii, font1_offsets, 430, iTextPosY, byTempValue, 0, pal_addr); - } - } else { - // Car is allocated to a human player + // Init car display loop + iCarLoop = 0; + iDimmedColor = iHighlightColor - 2; + iCarDisplay = 15; + iCarIndex = 18; + iActiveColor = iNormalColor - 4; + szCarName = comp_name[0]; + iTextPosY = 50; + + // Display all 16 cars in reverse order + do { + // Check if car slot is allocated to a player + if ((iCarLoop & 1) >= allocated_cars[iCarDisplay / 2]) { + // Car is available for Ai palyers + if (iCarIndex == iSelectedCar && iEditingName == 1) { + // Selected car with name being edited + menu_render_text(mr, 15, szCarName, font1_ascii, font1_offsets, 425, + iTextPosY, iNormalColor, 2u, pal_addr); if (iCarIndex == iSelectedCar) - byTextColor1 = iActiveColor; - else - byTextColor1 = 0x8B; - menu_render_text(mr, 15, szCarName, font1_ascii, font1_offsets, 425, iTextPosY, byTextColor1, 2u, pal_addr); - if (iCarIndex == iSelectedCar) - byTextColor2 = iDimmedColor; - else - byTextColor2 = 0x7F; - - // Display human player name - menu_render_text(mr, 15, player_names[car_to_player[14 - (iCarLoop & 0xFE) + (iCarLoop & 1)]], font1_ascii, font1_offsets, 430, iTextPosY, byTextColor2, 0, pal_addr); - } - - // Move to next car - --iCarIndex; - szCarName += 15; - --iCarDisplay; - iTextPosY += 18; - ++iCarLoop; - } while (iCarLoop < 16); - - // Display player 2 configuration (if in 2-player mode) - if (player_type == 2) { - if (iSelectedCar == 2 && iEditingName == 1) { - // Player 2 name being edited - if (iSelectedCar == player_type) - byTextColor5 = iNormalColor; - else - byTextColor5 = 0x8F; - menu_render_text(mr, 15, &config_buffer[4288], font1_ascii, font1_offsets, 425, 338, byTextColor5, player_type, pal_addr); - if (iSelectedCar == 2) - byTextColor6 = iHighlightColor; + byTextColor3 = iHighlightColor; else - byTextColor6 = 0x8F; - menu_render_text(mr, 15, szNewNameBuf, font1_ascii, font1_offsets, 430, 338, byTextColor6, 0, pal_addr); + byTextColor3 = 0x8F; + menu_render_text(mr, 15, szNewNameBuf, font1_ascii, font1_offsets, + 430, iTextPosY, byTextColor3, 0, pal_addr); } else { - // Player 2 name display mode - if (iSelectedCar == 2) - byTextColor7 = iNormalColor; + // Selected car with default name displayed + if (iCarIndex == iSelectedCar) + byTextColor4 = iNormalColor; else - byTextColor7 = 0x8F; - iTemp1 = iSelectedCar; - menu_render_text(mr, 15, &config_buffer[4288], font1_ascii, font1_offsets, 425, 338, byTextColor7, 2u, pal_addr); - if (iTemp1 == 2) - byTextColor8 = iHighlightColor; + byTextColor4 = 0x8F; + menu_render_text(mr, 15, szCarName, font1_ascii, font1_offsets, 425, + iTextPosY, byTextColor4, 2u, pal_addr); + if (iCarIndex == iSelectedCar) + byChar = iHighlightColor; else - byTextColor8 = 0x8F; - menu_render_text(mr, 15, player_names[player2_car], font1_ascii, font1_offsets, 430, 338, byTextColor8, 0, pal_addr); + byChar = 0x8F; + + // Display AI name (using bit toggle for paired names) + byTempValue = byChar; + iFontWidth = iCarDisplay; + // LOBYTE(iFontWidth) = iCarDisplay ^ 1; + iFontWidth = iCarDisplay ^ 1; + menu_render_text(mr, 15, default_names[iFontWidth], font1_ascii, + font1_offsets, 430, iTextPosY, byTempValue, 0, + pal_addr); } + } else { + // Car is allocated to a human player + if (iCarIndex == iSelectedCar) + byTextColor1 = iActiveColor; + else + byTextColor1 = 0x8B; + menu_render_text(mr, 15, szCarName, font1_ascii, font1_offsets, 425, + iTextPosY, byTextColor1, 2u, pal_addr); + if (iCarIndex == iSelectedCar) + byTextColor2 = iDimmedColor; + else + byTextColor2 = 0x7F; + + // Display human player name + menu_render_text(mr, 15, + player_names[car_to_player[14 - (iCarLoop & 0xFE) + + (iCarLoop & 1)]], + font1_ascii, font1_offsets, 430, iTextPosY, + byTextColor2, 0, pal_addr); } - // Display player 1 configuration - if (iSelectedCar == 1 && iEditingName == 1) { - // Player 1 name being edited - menu_render_text(mr, 15, &config_buffer[4224], font1_ascii, font1_offsets, 425, 356, iNormalColor, 2u, pal_addr); - if (iSelectedCar == 1) - byTextColor9 = iHighlightColor; + // Move to next car + --iCarIndex; + szCarName += 15; + --iCarDisplay; + iTextPosY += 18; + ++iCarLoop; + } while (iCarLoop < 16); + + // Display player 2 configuration (if in 2-player mode) + if (player_type == 2) { + if (iSelectedCar == 2 && iEditingName == 1) { + // Player 2 name being edited + if (iSelectedCar == player_type) + byTextColor5 = iNormalColor; + else + byTextColor5 = 0x8F; + menu_render_text(mr, 15, &config_buffer[4288], font1_ascii, + font1_offsets, 425, 338, byTextColor5, player_type, + pal_addr); + if (iSelectedCar == 2) + byTextColor6 = iHighlightColor; else - byTextColor9 = 0x8F; - menu_render_text(mr, 15, szNewNameBuf, font1_ascii, font1_offsets, 430, 356, byTextColor9, 0, pal_addr); + byTextColor6 = 0x8F; + menu_render_text(mr, 15, szNewNameBuf, font1_ascii, font1_offsets, + 430, 338, byTextColor6, 0, pal_addr); } else { - // Player 1 name display mode - if (iSelectedCar == 1) - byColor = iNormalColor; + // Player 2 name display mode + if (iSelectedCar == 2) + byTextColor7 = iNormalColor; else - byColor = 0x8F; - iSelectedCar_1 = iSelectedCar; - menu_render_text(mr, 15, &config_buffer[4224], font1_ascii, font1_offsets, 425, 356, byColor, 2u, pal_addr); - if (iSelectedCar_1 == 1) - byColor_1 = iHighlightColor; + byTextColor7 = 0x8F; + iTemp1 = iSelectedCar; + menu_render_text(mr, 15, &config_buffer[4288], font1_ascii, + font1_offsets, 425, 338, byTextColor7, 2u, pal_addr); + if (iTemp1 == 2) + byTextColor8 = iHighlightColor; else - byColor_1 = 0x8F; - menu_render_text(mr, 15, player_names[player1_car], font1_ascii, font1_offsets, 430, 356, byColor_1, 0, pal_addr); + byTextColor8 = 0x8F; + menu_render_text(mr, 15, player_names[player2_car], font1_ascii, + font1_offsets, 430, 338, byTextColor8, 0, pal_addr); } + } - // Display "BACK" option - if (iSelectedCar) - byColor_2 = 0x8F; - else - byColor_2 = iNormalColor; - menu_render_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, 420, 374, byColor_2, 2u, pal_addr); - - // Display blinking cursor when editing names - if (iEditingName == 1) { - if ((frames & 0xFu) < 8) // blink cursor based on frame counter - menu_render_text(mr, 15, "_", font1_ascii, font1_offsets, iTextPosX, iY, 0xABu, 0, pal_addr); - szNewNameBuf[iNameLength] = 0; - } - goto RENDER_FRAME; // skip to end of switch - case 1: - // Audio/volume config - if (iConfigState != 2) - iVolumeSelection = -1; - - // Engine volume - if (iVolumeSelection == 1) - byVolumeColor1 = 0xAB; + // Display player 1 configuration + if (iSelectedCar == 1 && iEditingName == 1) { + // Player 1 name being edited + menu_render_text(mr, 15, &config_buffer[4224], font1_ascii, + font1_offsets, 425, 356, iNormalColor, 2u, pal_addr); + if (iSelectedCar == 1) + byTextColor9 = iHighlightColor; else - byVolumeColor1 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2304], font1_ascii, font1_offsets, 425, 80, byVolumeColor1, 2u, 200, 640, pal_addr); - - // SFX volume - if (iVolumeSelection == 2) - byVolumeColor2 = 0xAB; + byTextColor9 = 0x8F; + menu_render_text(mr, 15, szNewNameBuf, font1_ascii, font1_offsets, 430, + 356, byTextColor9, 0, pal_addr); + } else { + // Player 1 name display mode + if (iSelectedCar == 1) + byColor = iNormalColor; else - byVolumeColor2 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2368], font1_ascii, font1_offsets, 425, 104, byVolumeColor2, 2u, 200, 640, pal_addr); - - // Speech volume - if (iVolumeSelection == 3) - byVolumeColor3 = 0xAB; + byColor = 0x8F; + iSelectedCar_1 = iSelectedCar; + menu_render_text(mr, 15, &config_buffer[4224], font1_ascii, + font1_offsets, 425, 356, byColor, 2u, pal_addr); + if (iSelectedCar_1 == 1) + byColor_1 = iHighlightColor; else - byVolumeColor3 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2432], font1_ascii, font1_offsets, 425, 128, byVolumeColor3, 2u, 200, 640, pal_addr); + byColor_1 = 0x8F; + menu_render_text(mr, 15, player_names[player1_car], font1_ascii, + font1_offsets, 430, 356, byColor_1, 0, pal_addr); + } - // Music volume - if (iVolumeSelection == 4) - byVolumeColor4 = 0xAB; + // Display "BACK" option + if (iSelectedCar) + byColor_2 = 0x8F; + else + byColor_2 = iNormalColor; + menu_render_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, + 420, 374, byColor_2, 2u, pal_addr); + + // Display blinking cursor when editing names + if (iEditingName == 1) { + if ((frames & 0xFu) < 8) // blink cursor based on frame counter + menu_render_text(mr, 15, "_", font1_ascii, font1_offsets, iTextPosX, + iY, 0xABu, 0, pal_addr); + szNewNameBuf[iNameLength] = 0; + } + goto RENDER_FRAME; // skip to end of switch + case 1: + // Audio/volume config + if (iConfigState != 2) + iVolumeSelection = -1; + + // Engine volume + if (iVolumeSelection == 1) + byVolumeColor1 = 0xAB; + else + byVolumeColor1 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2304], font1_ascii, + font1_offsets, 425, 80, byVolumeColor1, 2u, 200, + 640, pal_addr); + + // SFX volume + if (iVolumeSelection == 2) + byVolumeColor2 = 0xAB; + else + byVolumeColor2 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2368], font1_ascii, + font1_offsets, 425, 104, byVolumeColor2, 2u, 200, + 640, pal_addr); + + // Speech volume + if (iVolumeSelection == 3) + byVolumeColor3 = 0xAB; + else + byVolumeColor3 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2432], font1_ascii, + font1_offsets, 425, 128, byVolumeColor3, 2u, 200, + 640, pal_addr); + + // Music volume + if (iVolumeSelection == 4) + byVolumeColor4 = 0xAB; + else + byVolumeColor4 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2496], font1_ascii, + font1_offsets, 425, 152, byVolumeColor4, 2u, 200, + 640, pal_addr); + + // Engine options + if (iVolumeSelection == 5) + byColor_3 = 0xAB; + else + byColor_3 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2560], font1_ascii, + font1_offsets, 425, 176, byColor_3, 2u, 200, 640, + pal_addr); + if (allengines) { + if (iVolumeSelection == 5) + byColor_4 = 0xAB; else - byVolumeColor4 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2496], font1_ascii, font1_offsets, 425, 152, byVolumeColor4, 2u, 200, 640, pal_addr); - - // Engine options + byColor_4 = 0x8F; + // ALL ENGINES + menu_render_scaled_text(mr, 15, &config_buffer[2752], font1_ascii, + font1_offsets, 430, 176, byColor_4, 0, 200, 640, + pal_addr); + } else { if (iVolumeSelection == 5) - byColor_3 = 0xAB; + byColor_5 = 0xAB; else - byColor_3 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2560], font1_ascii, font1_offsets, 425, 176, byColor_3, 2u, 200, 640, pal_addr); - if (allengines) { - if (iVolumeSelection == 5) - byColor_4 = 0xAB; - else - byColor_4 = 0x8F; - // ALL ENGINES - menu_render_scaled_text(mr, 15, &config_buffer[2752], font1_ascii, font1_offsets, 430, 176, byColor_4, 0, 200, 640, pal_addr); - } else { - if (iVolumeSelection == 5) - byColor_5 = 0xAB; - else - byColor_5 = 0x8F; - // STARTERS & TURBOS - menu_render_scaled_text(mr, 15, &config_buffer[2816], font1_ascii, font1_offsets, 430, 176, byColor_5, 0, 200, 640, pal_addr); - } + byColor_5 = 0x8F; + // STARTERS & TURBOS + menu_render_scaled_text(mr, 15, &config_buffer[2816], font1_ascii, + font1_offsets, 430, 176, byColor_5, 0, 200, 640, + pal_addr); + } - // Sound effects options + // Sound effects options + if (iVolumeSelection == 6) + byColor_6 = 0xAB; + else + byColor_6 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2880], font1_ascii, + font1_offsets, 425, 200, byColor_6, 2u, 200, 640, + pal_addr); + if (soundon) { if (iVolumeSelection == 6) - byColor_6 = 0xAB; + byColor_7 = 0xAB; else - byColor_6 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2880], font1_ascii, font1_offsets, 425, 200, byColor_6, 2u, 200, 640, pal_addr); - if (soundon) { - if (iVolumeSelection == 6) - byColor_7 = 0xAB; - else - byColor_7 = 0x8F; - // ON - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 430, 200, byColor_7, 0, 200, 640, pal_addr); - } else if (SoundCard) { - if (iVolumeSelection == 6) - byColor_8 = 0xAB; - else - byColor_8 = 0x8F; - // OFF - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 430, 200, byColor_8, soundon, 200, 640, pal_addr); - } else { - if (iVolumeSelection == 6) - byColor_9 = 0xAB; - else - byColor_9 = 0x8F; - // DISABLED - menu_render_scaled_text(mr, 15, &config_buffer[6848], font1_ascii, font1_offsets, 430, 200, byColor_9, soundon, 200, 640, pal_addr); - } + byColor_7 = 0x8F; + // ON + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 430, 200, byColor_7, 0, 200, 640, + pal_addr); + } else if (SoundCard) { + if (iVolumeSelection == 6) + byColor_8 = 0xAB; + else + byColor_8 = 0x8F; + // OFF + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 430, 200, byColor_8, soundon, + 200, 640, pal_addr); + } else { + if (iVolumeSelection == 6) + byColor_9 = 0xAB; + else + byColor_9 = 0x8F; + // DISABLED + menu_render_scaled_text(mr, 15, &config_buffer[6848], font1_ascii, + font1_offsets, 430, 200, byColor_9, soundon, + 200, 640, pal_addr); + } - // Music options + // Music options + if (iVolumeSelection == 7) + byColor_10 = 0xAB; + else + byColor_10 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2944], font1_ascii, + font1_offsets, 425, 224, byColor_10, 2u, 200, 640, + pal_addr); + if (musicon) { if (iVolumeSelection == 7) - byColor_10 = 0xAB; + byColor_11 = 0xAB; else - byColor_10 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2944], font1_ascii, font1_offsets, 425, 224, byColor_10, 2u, 200, 640, pal_addr); - if (musicon) { - if (iVolumeSelection == 7) - byColor_11 = 0xAB; - else - byColor_11 = 0x8F; - // ON - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 430, 224, byColor_11, 0, 200, 640, pal_addr); - } else if (MusicCard || MusicCD) { - if (iVolumeSelection == 7) - byColor_12 = 0xAB; - else - byColor_12 = 0x8F; - // OFF - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 430, 224, byColor_12, 0, 200, 640, pal_addr); - } else { - if (iVolumeSelection == 7) - byColor_13 = 0xAB; - else - byColor_13 = 0x8F; - // DISABLED - menu_render_scaled_text(mr, 15, &config_buffer[6848], font1_ascii, font1_offsets, 430, 224, byColor_13, musicon, 200, 640, pal_addr); - } + byColor_11 = 0x8F; + // ON + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 430, 224, byColor_11, 0, 200, + 640, pal_addr); + } else if (MusicCard || MusicCD) { + if (iVolumeSelection == 7) + byColor_12 = 0xAB; + else + byColor_12 = 0x8F; + // OFF + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 430, 224, byColor_12, 0, 200, + 640, pal_addr); + } else { + if (iVolumeSelection == 7) + byColor_13 = 0xAB; + else + byColor_13 = 0x8F; + // DISABLED + menu_render_scaled_text(mr, 15, &config_buffer[6848], font1_ascii, + font1_offsets, 430, 224, byColor_13, musicon, + 200, 640, pal_addr); + } + + // Back option + if (iVolumeSelection) + byColor_14 = 0x8F; + else + byColor_14 = 0xAB; + menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, + font1_offsets, 420, 248, byColor_14, 2u, 200, 640, + pal_addr); + + // Display volume bars + if (iVolumeSelection == 1) + byColor_15 = 0xAB; + else + byColor_15 = 0xA5; + front_volumebar(80, EngineVolume, byColor_15); + if (iVolumeSelection == 2) + byColor_16 = 0xAB; + else + byColor_16 = 0xA5; + front_volumebar(104, SFXVolume, byColor_16); + if (iVolumeSelection == 3) + byColor_17 = 0xAB; + else + byColor_17 = 0xA5; + iVolumeSelection_1 = iVolumeSelection; + front_volumebar(128, SpeechVolume, byColor_17); + if (iVolumeSelection_1 == 4) + byColor_18 = 0xAB; + else + byColor_18 = 0xA5; + front_volumebar(152, MusicVolume, byColor_18); + goto RENDER_FRAME; + case 2: + // Joystick calibration + if (iConfigState == 3) { + ReadJoys(&joyPos); + //_disable(); + + // Update calibration ranges for all axes + if (joyPos.iJ1XAxis < JAXmin) + JAXmin = joyPos.iJ1XAxis; + if (joyPos.iJ1XAxis > JAXmax) + JAXmax = joyPos.iJ1XAxis; + + if (joyPos.iJ1YAxis < JAYmin) + JAYmin = joyPos.iJ1YAxis; + if (joyPos.iJ1YAxis > JAYmax) + JAYmax = joyPos.iJ1YAxis; + + if (joyPos.iJ2XAxis < JBXmin) + JBXmin = joyPos.iJ2XAxis; + if (joyPos.iJ2XAxis > JBXmax) + JBXmax = joyPos.iJ2XAxis; + + if (joyPos.iJ2YAxis < JBYmin) + JBYmin = joyPos.iJ2YAxis; + if (joyPos.iJ2YAxis > JBYmax) + JBYmax = joyPos.iJ2YAxis; + + if (JAXmin == JAXmax) + JAXmax = JAXmin + 1; + if (JAYmin == JAYmax) + JAYmax = JAYmin + 1; + + if (JBXmin == JBXmax) + JBXmax = JBXmin + 1; + if (JBYmin == JBYmax) + JBYmax = JBYmin + 1; + //_enable(); + } - // Back option - if (iVolumeSelection) - byColor_14 = 0x8F; + // Display calibration instructions when active + if (iConfigState == 3) { + // MOVE JOYSTICKS TO FULL EXTENTS + menu_render_scaled_text(mr, 15, &config_buffer[2112], font1_ascii, + font1_offsets, 400, 60, 143, 1u, 200, 640, + pal_addr); + // THEN PRESS ANY KEY + menu_render_scaled_text(mr, 15, &config_buffer[2176], font1_ascii, + font1_offsets, 400, 78, 143, 1u, 200, 640, + pal_addr); + } + + iConfigState_1 = iConfigState; + + // X1 axis display + menu_render_scaled_text(mr, 15, &config_buffer[1728], font1_ascii, + font1_offsets, 400, 110, 143, 1u, 200, 640, + pal_addr); + if (iConfigState_1 == 3) { + // Show calibration bar + if (x1ok && JAXmax - JAXmin >= 100) + iJoyCalibValue1 = + 140 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin); + else + iJoyCalibValue1 = 0; + front_displaycalibrationbar(300, 128, iJoyCalibValue1); + } else { + // Show status text + if (x1ok) + szJoyStatus1 = &config_buffer[2048]; else - byColor_14 = 0xAB; - menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, 420, 248, byColor_14, 2u, 200, 640, pal_addr); + szJoyStatus1 = &config_buffer[1984]; + menu_render_scaled_text(mr, 15, szJoyStatus1, font1_ascii, + font1_offsets, 400, 128, 143, 1u, 200, 640, + pal_addr); + } - // Display volume bars - if (iVolumeSelection == 1) - byColor_15 = 0xAB; + // Y1 axis display + menu_render_scaled_text(mr, 15, &config_buffer[1792], font1_ascii, + font1_offsets, 400, 160, 143, 1u, 200, 640, + pal_addr); + if (iConfigState == 3) { + // Show Calibration bar + if (y1ok && JAYmax - JAYmin >= 100) + iJoyCalibValue2 = + 140 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); else - byColor_15 = 0xA5; - front_volumebar(80, EngineVolume, byColor_15); - if (iVolumeSelection == 2) - byColor_16 = 0xAB; + iJoyCalibValue2 = 0; + front_displaycalibrationbar(300, 178, iJoyCalibValue2); + } else { + // Show status text + if (y1ok) + szJoyStatus2 = &config_buffer[2048]; else - byColor_16 = 0xA5; - front_volumebar(104, SFXVolume, byColor_16); - if (iVolumeSelection == 3) - byColor_17 = 0xAB; + szJoyStatus2 = &config_buffer[1984]; + menu_render_scaled_text(mr, 15, szJoyStatus2, font1_ascii, + font1_offsets, 400, 178, 143, 1u, 200, 640, + pal_addr); + } + + // X2 axis display + menu_render_scaled_text(mr, 15, &config_buffer[1856], font1_ascii, + font1_offsets, 400, 210, 143, 1u, 200, 640, + pal_addr); + if (iConfigState == 3) { + // Calibration bar + if (x2ok && JBXmax - JBXmin >= 100) + iX2CalibrationVal = + 140 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); else - byColor_17 = 0xA5; - iVolumeSelection_1 = iVolumeSelection; - front_volumebar(128, SpeechVolume, byColor_17); - if (iVolumeSelection_1 == 4) - byColor_18 = 0xAB; + iX2CalibrationVal = 0; + front_displaycalibrationbar(300, 228, iX2CalibrationVal); + } else { + // status text + if (x2ok) + szX2Text = &config_buffer[2048]; else - byColor_18 = 0xA5; - front_volumebar(152, MusicVolume, byColor_18); - goto RENDER_FRAME; - case 2: - // Joystick calibration - if (iConfigState == 3) { - ReadJoys(&joyPos); - //_disable(); - - // Update calibration ranges for all axes - if (joyPos.iJ1XAxis < JAXmin) - JAXmin = joyPos.iJ1XAxis; - if (joyPos.iJ1XAxis > JAXmax) - JAXmax = joyPos.iJ1XAxis; - - if (joyPos.iJ1YAxis < JAYmin) - JAYmin = joyPos.iJ1YAxis; - if (joyPos.iJ1YAxis > JAYmax) - JAYmax = joyPos.iJ1YAxis; - - if (joyPos.iJ2XAxis < JBXmin) - JBXmin = joyPos.iJ2XAxis; - if (joyPos.iJ2XAxis > JBXmax) - JBXmax = joyPos.iJ2XAxis; - - if (joyPos.iJ2YAxis < JBYmin) - JBYmin = joyPos.iJ2YAxis; - if (joyPos.iJ2YAxis > JBYmax) - JBYmax = joyPos.iJ2YAxis; - - if (JAXmin == JAXmax) - JAXmax = JAXmin + 1; - if (JAYmin == JAYmax) - JAYmax = JAYmin + 1; - - if (JBXmin == JBXmax) - JBXmax = JBXmin + 1; - if (JBYmin == JBYmax) - JBYmax = JBYmin + 1; - //_enable(); - } + szX2Text = &config_buffer[1984]; + menu_render_scaled_text(mr, 15, szX2Text, font1_ascii, font1_offsets, + 400, 228, 143, 1u, 200, 640, pal_addr); + } - // Display calibration instructions when active - if (iConfigState == 3) { - // MOVE JOYSTICKS TO FULL EXTENTS - menu_render_scaled_text(mr, 15, &config_buffer[2112], font1_ascii, font1_offsets, 400, 60, 143, 1u, 200, 640, pal_addr); - // THEN PRESS ANY KEY - menu_render_scaled_text(mr, 15, &config_buffer[2176], font1_ascii, font1_offsets, 400, 78, 143, 1u, 200, 640, pal_addr); + iConfigState_2 = iConfigState; + + // Y2 axis display + menu_render_scaled_text(mr, 15, &config_buffer[1920], font1_ascii, + font1_offsets, 400, 260, 143, 1u, 200, 640, + pal_addr); + if (iConfigState_2 == 3) { + // Calibration bar + if (y2ok && JBYmax - JBYmin >= 100) + iY2CalibrationVal = + 140 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); + else + iY2CalibrationVal = 0; + front_displaycalibrationbar(300, 278, iY2CalibrationVal); + } else { + // Status text + if (y2ok) + szY2Text = &config_buffer[2048]; + else + szY2Text = &config_buffer[1984]; + menu_render_scaled_text(mr, 15, szY2Text, font1_ascii, font1_offsets, + 400, 278, 143, 1u, 200, 640, pal_addr); + } + goto RENDER_FRAME; + case 3: + // Keyboard control config + if (iConfigState == 4) { + if (controlrelease) { + // Check if all keys have been released + iKeyFound = -1; + iKeyIndex = 0; + iKeyCounter = 0; + do { + if (keyname[iKeyCounter] && keys[iKeyIndex]) + iKeyFound = 0; // key still pressed + ++iKeyIndex; + ++iKeyCounter; + } while (iKeyIndex < 128); + if (iKeyFound) // all keys released + controlrelease = 0; } + } else { + iControlSelection = -1; // reset control selection + } - iConfigState_1 = iConfigState; + // Display player 2 controls (if in 2 player mode) + if (player_type == 2) { + // Format player 2 control method string + if (manual_control[player2_car] == 2) + sprintf(buffer, "%s %s", &config_buffer[4480], &config_buffer[4544]); + else + sprintf(buffer, "%s %s", &config_buffer[4480], &config_buffer[4608]); + if (iControlSelection == 4) + byColor_19 = 0xAB; + else + byColor_19 = 0x8F; + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, + 60, byColor_19, 1u, 200, 640, pal_addr); + + // Player 2 customize controls option + if (iControlSelection == 3) + byColor_20 = 0xAB; + else + byColor_20 = 0x8F; + // CUSTOMIZE PLAYER 2 + menu_render_scaled_text(mr, 15, &config_buffer[704], font1_ascii, + font1_offsets, 420, 78, byColor_20, 1u, 200, + 640, pal_addr); + } - // X1 axis display - menu_render_scaled_text(mr, 15, &config_buffer[1728], font1_ascii, font1_offsets, 400, 110, 143, 1u, 200, 640, pal_addr); - if (iConfigState_1 == 3) { - // Show calibration bar - if (x1ok && JAXmax - JAXmin >= 100) - iJoyCalibValue1 = 140 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin); + // Display player 1 controls + if (manual_control[player1_car] == 2) + sprintf(buffer, "%s %s", &config_buffer[4416], &config_buffer[4544]); + else + sprintf(buffer, "%s %s", &config_buffer[4416], &config_buffer[4608]); + if (iControlSelection == 2) + byColor_21 = 0xAB; + else + byColor_21 = 0x8F; + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, + 96, byColor_21, 1u, 200, 640, pal_addr); + // Player 1 customize controls option + if (iControlSelection == 1) + byColor_22 = 0xAB; + else + byColor_22 = 0x8F; + // CUSTOMIZE PLAYER 1 + menu_render_scaled_text(mr, 15, &config_buffer[768], font1_ascii, + font1_offsets, 420, 114, byColor_22, 1u, 200, 640, + pal_addr); + + // Back option + if (iControlSelection) + byColor_23 = 0x8F; + else + byColor_23 = 0xAB; + menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, + font1_offsets, 420, 132, byColor_23, 1u, 200, 640, + pal_addr); + + // Display player 1 control customization screen + if (iControlSelection == 1 || iControlSelection == 2) { + iControlLoop = 0; + szControlName = &config_buffer[896]; // start of control name strings + iY_1 = 200; + // Display all 6 basic controls for player 1 + do { + if (iControlLoop == control_edit) + byControlColor = 0xAB; else - iJoyCalibValue1 = 0; - front_displaycalibrationbar(300, 128, iJoyCalibValue1); - } else { - // Show status text - if (x1ok) - szJoyStatus1 = &config_buffer[2048]; + byControlColor = 0x8F; + menu_render_text(mr, 15, szControlName, font1_ascii, font1_offsets, + 475, iY_1, byControlColor, 2u, pal_addr); + if (iControlLoop == control_edit) + byColor_24 = 0xAB; else - szJoyStatus1 = &config_buffer[1984]; - menu_render_scaled_text(mr, 15, szJoyStatus1, font1_ascii, font1_offsets, 400, 128, 143, 1u, 200, 640, pal_addr); - } - - // Y1 axis display - menu_render_scaled_text(mr, 15, &config_buffer[1792], font1_ascii, font1_offsets, 400, 160, 143, 1u, 200, 640, pal_addr); - if (iConfigState == 3) { - // Show Calibration bar - if (y1ok && JAYmax - JAYmin >= 100) - iJoyCalibValue2 = 140 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); + byColor_24 = 0x8F; + menu_render_scaled_text(mr, 15, keyname[userkey[iControlLoop]], + font1_ascii, font1_offsets, 480, iY_1, + byColor_24, 0, 200, 640, pal_addr); + szControlName += 64; // next control name + ++iControlLoop; + iY_1 += 18; + } while (iControlLoop < 6); + if (Players_Cars[player1_car] >= 8) { + if (control_edit == 12) + byColor_25 = 0xAB; else - iJoyCalibValue2 = 0; - front_displaycalibrationbar(300, 178, iJoyCalibValue2); - } else { - // Show status text - if (y1ok) - szJoyStatus2 = &config_buffer[2048]; + byColor_25 = 0x8F; + menu_render_text(mr, 15, "CHEAT:", font1_ascii, font1_offsets, 475, + 308, byColor_25, 2u, pal_addr); + if (control_edit == 12) + byColor_26 = 0xAB; else - szJoyStatus2 = &config_buffer[1984]; - menu_render_scaled_text(mr, 15, szJoyStatus2, font1_ascii, font1_offsets, 400, 178, 143, 1u, 200, 640, pal_addr); + byColor_26 = 0x8F; + menu_render_scaled_text(mr, 15, keyname[userkey[12]], font1_ascii, + font1_offsets, 480, 308, byColor_26, 0, 200, + 640, pal_addr); } - - // X2 axis display - menu_render_scaled_text(mr, 15, &config_buffer[1856], font1_ascii, font1_offsets, 400, 210, 143, 1u, 200, 640, pal_addr); - if (iConfigState == 3) { - // Calibration bar - if (x2ok && JBXmax - JBXmin >= 100) - iX2CalibrationVal = 140 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); + } + // Display Player 2 control customization screen + else if (iControlSelection == 3 || iControlSelection == 4) { + iControlIndex2 = 6; + szText = &config_buffer[1280]; + iY_2 = 200; + // Display all 6 controls for player 2 + do { + if (iControlIndex2 == control_edit) + byColor_27 = 0xAB; else - iX2CalibrationVal = 0; - front_displaycalibrationbar(300, 228, iX2CalibrationVal); - } else { - // status text - if (x2ok) - szX2Text = &config_buffer[2048]; + byColor_27 = 0x8F; + menu_render_text(mr, 15, szText, font1_ascii, font1_offsets, 475, + iY_2, byColor_27, 2u, pal_addr); + if (iControlIndex2 == control_edit) + byColor_28 = 0xAB; else - szX2Text = &config_buffer[1984]; - menu_render_scaled_text(mr, 15, szX2Text, font1_ascii, font1_offsets, 400, 228, 143, 1u, 200, 640, pal_addr); - } - - iConfigState_2 = iConfigState; - - // Y2 axis display - menu_render_scaled_text(mr, 15, &config_buffer[1920], font1_ascii, font1_offsets, 400, 260, 143, 1u, 200, 640, pal_addr); - if (iConfigState_2 == 3) { - // Calibration bar - if (y2ok && JBYmax - JBYmin >= 100) - iY2CalibrationVal = 140 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); + byColor_28 = 0x8F; + menu_render_text(mr, 15, keyname[userkey[iControlIndex2]], + font1_ascii, font1_offsets, 480, iY_2, byColor_28, 0, + pal_addr); + szText += 64; // Next control name + ++iControlIndex2; + iY_2 += 18; + } while (iControlIndex2 < 12); + + // Display cheat key option for player 2 + if (Players_Cars[player2_car] >= 8) { + if (control_edit == 13) + byColor_29 = 0xAB; else - iY2CalibrationVal = 0; - front_displaycalibrationbar(300, 278, iY2CalibrationVal); - } else { - // Status text - if (y2ok) - szY2Text = &config_buffer[2048]; + byColor_29 = 0x8F; + menu_render_text(mr, 15, "CHEAT:", font1_ascii, font1_offsets, 475, + 308, byColor_29, 2u, pal_addr); + if (control_edit == 13) + byColor_30 = 0xAB; else - szY2Text = &config_buffer[1984]; - menu_render_scaled_text(mr, 15, szY2Text, font1_ascii, font1_offsets, 400, 278, 143, 1u, 200, 640, pal_addr); + byColor_30 = 0x8F; + menu_render_text(mr, 15, keyname[userkey[13]], font1_ascii, + font1_offsets, 480, 308, byColor_30, 0, pal_addr); } + } + + // Handle active key mapping process + if (!iControlsInEdit || iConfigState != 4) goto RENDER_FRAME; - case 3: - // Keyboard control config - if (iConfigState == 4) { - if (controlrelease) { - // Check if all keys have been released - iKeyFound = -1; - iKeyIndex = 0; - iKeyCounter = 0; - do { - if (keyname[iKeyCounter] && keys[iKeyIndex]) - iKeyFound = 0; // key still pressed - ++iKeyIndex; - ++iKeyCounter; - } while (iKeyIndex < 128); - if (iKeyFound) // all keys released - controlrelease = 0; - } - } else { - iControlSelection = -1; // reset control selection - } - // Display player 2 controls (if in 2 player mode) - if (player_type == 2) { - // Format player 2 control method string - if (manual_control[player2_car] == 2) - sprintf(buffer, "%s %s", &config_buffer[4480], &config_buffer[4544]); - else - sprintf(buffer, "%s %s", &config_buffer[4480], &config_buffer[4608]); - if (iControlSelection == 4) - byColor_19 = 0xAB; - else - byColor_19 = 0x8F; - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 60, byColor_19, 1u, 200, 640, pal_addr); + // Key detection and mapping logic + iKeyCheckLoop = controlrelease; + if (controlrelease) + goto CHECK_CONTROL_INPUT; // wait for key release + + // Scan for pressed keys + iFoundKey = -1; + iKeySearchIndex = 0; + do { + if (keyname[iKeySearchIndex] && keys[iKeyCheckLoop]) + iFoundKey = iKeyCheckLoop; + ++iKeyCheckLoop; + ++iKeySearchIndex; + } while (iKeyCheckLoop < 128); + + // If no keyboard key pressed check joystick buttons + if (iFoundKey == -1) { + ReadJoys(&joyPos); + if (joyPos.iJ1Button1) + iFoundKey = 128; + if (joyPos.iJ1Button2) + iFoundKey = 129; + if (joyPos.iJ2Button1) + iFoundKey = 130; + if (joyPos.iJ2Button2) + iFoundKey = 131; + } - // Player 2 customize controls option - if (iControlSelection == 3) - byColor_20 = 0xAB; - else - byColor_20 = 0x8F; - // CUSTOMIZE PLAYER 2 - menu_render_scaled_text(mr, 15, &config_buffer[704], font1_ascii, font1_offsets, 420, 78, byColor_20, 1u, 200, 640, pal_addr); + // If still no input check joystick axis movements + if (iFoundKey == -1) { + if (y2ok) { + iJoyValue1 = + 100 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); + if (iJoyValue1 < -50) + iFoundKey = 138; + if (iJoyValue1 > 50) + iFoundKey = 139; } - - // Display player 1 controls - if (manual_control[player1_car] == 2) - sprintf(buffer, "%s %s", &config_buffer[4416], &config_buffer[4544]); - else - sprintf(buffer, "%s %s", &config_buffer[4416], &config_buffer[4608]); - if (iControlSelection == 2) - byColor_21 = 0xAB; - else - byColor_21 = 0x8F; - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 96, byColor_21, 1u, 200, 640, pal_addr); - // Player 1 customize controls option - if (iControlSelection == 1) - byColor_22 = 0xAB; - else - byColor_22 = 0x8F; - // CUSTOMIZE PLAYER 1 - menu_render_scaled_text(mr, 15, &config_buffer[768], font1_ascii, font1_offsets, 420, 114, byColor_22, 1u, 200, 640, pal_addr); - - // Back option - if (iControlSelection) - byColor_23 = 0x8F; - else - byColor_23 = 0xAB; - menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, 420, 132, byColor_23, 1u, 200, 640, pal_addr); - - // Display player 1 control customization screen - if (iControlSelection == 1 || iControlSelection == 2) { - iControlLoop = 0; - szControlName = &config_buffer[896]; // start of control name strings - iY_1 = 200; - // Display all 6 basic controls for player 1 - do { - if (iControlLoop == control_edit) - byControlColor = 0xAB; - else - byControlColor = 0x8F; - menu_render_text(mr, 15, szControlName, font1_ascii, font1_offsets, 475, iY_1, byControlColor, 2u, pal_addr); - if (iControlLoop == control_edit) - byColor_24 = 0xAB; - else - byColor_24 = 0x8F; - menu_render_scaled_text(mr, 15, keyname[userkey[iControlLoop]], font1_ascii, font1_offsets, 480, iY_1, byColor_24, 0, 200, 640, pal_addr); - szControlName += 64; // next control name - ++iControlLoop; - iY_1 += 18; - } while (iControlLoop < 6); - if (Players_Cars[player1_car] >= 8) { - if (control_edit == 12) - byColor_25 = 0xAB; - else - byColor_25 = 0x8F; - menu_render_text(mr, 15, "CHEAT:", font1_ascii, font1_offsets, 475, 308, byColor_25, 2u, pal_addr); - if (control_edit == 12) - byColor_26 = 0xAB; - else - byColor_26 = 0x8F; - menu_render_scaled_text(mr, 15, keyname[userkey[12]], font1_ascii, font1_offsets, 480, 308, byColor_26, 0, 200, 640, pal_addr); - } + if (x2ok) { + iJoyValue2 = + 100 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); + if (iJoyValue2 < -50) + iFoundKey = 136; + if (iJoyValue2 > 50) + iFoundKey = 137; } - // Display Player 2 control customization screen - else if (iControlSelection == 3 || iControlSelection == 4) { - iControlIndex2 = 6; - szText = &config_buffer[1280]; - iY_2 = 200; - // Display all 6 controls for player 2 - do { - if (iControlIndex2 == control_edit) - byColor_27 = 0xAB; - else - byColor_27 = 0x8F; - menu_render_text(mr, 15, szText, font1_ascii, font1_offsets, 475, iY_2, byColor_27, 2u, pal_addr); - if (iControlIndex2 == control_edit) - byColor_28 = 0xAB; - else - byColor_28 = 0x8F; - menu_render_text(mr, 15, keyname[userkey[iControlIndex2]], font1_ascii, font1_offsets, 480, iY_2, byColor_28, 0, pal_addr); - szText += 64; // Next control name - ++iControlIndex2; - iY_2 += 18; - } while (iControlIndex2 < 12); - - // Display cheat key option for player 2 - if (Players_Cars[player2_car] >= 8) { - if (control_edit == 13) - byColor_29 = 0xAB; - else - byColor_29 = 0x8F; - menu_render_text(mr, 15, "CHEAT:", font1_ascii, font1_offsets, 475, 308, byColor_29, 2u, pal_addr); - if (control_edit == 13) - byColor_30 = 0xAB; - else - byColor_30 = 0x8F; - menu_render_text(mr, 15, keyname[userkey[13]], font1_ascii, font1_offsets, 480, 308, byColor_30, 0, pal_addr); - } + if (y1ok) { + iJoyValue3 = + 100 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); + if (iJoyValue3 < -50) + iFoundKey = 134; + if (iJoyValue3 > 50) + iFoundKey = 135; } - - // Handle active key mapping process - if (!iControlsInEdit || iConfigState != 4) - goto RENDER_FRAME; - - // Key detection and mapping logic - iKeyCheckLoop = controlrelease; - if (controlrelease) - goto CHECK_CONTROL_INPUT; // wait for key release - - // Scan for pressed keys - iFoundKey = -1; - iKeySearchIndex = 0; - do { - if (keyname[iKeySearchIndex] && keys[iKeyCheckLoop]) - iFoundKey = iKeyCheckLoop; - ++iKeyCheckLoop; - ++iKeySearchIndex; - } while (iKeyCheckLoop < 128); - - // If no keyboard key pressed check joystick buttons - if (iFoundKey == -1) { - ReadJoys(&joyPos); - if (joyPos.iJ1Button1) - iFoundKey = 128; - if (joyPos.iJ1Button2) - iFoundKey = 129; - if (joyPos.iJ2Button1) - iFoundKey = 130; - if (joyPos.iJ2Button2) - iFoundKey = 131; - } - - // If still no input check joystick axis movements - if (iFoundKey == -1) { - if (y2ok) { - iJoyValue1 = 100 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); - if (iJoyValue1 < -50) - iFoundKey = 138; - if (iJoyValue1 > 50) - iFoundKey = 139; - } - if (x2ok) { - iJoyValue2 = 100 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); - if (iJoyValue2 < -50) - iFoundKey = 136; - if (iJoyValue2 > 50) - iFoundKey = 137; - } - if (y1ok) { - iJoyValue3 = 100 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); - if (iJoyValue3 < -50) - iFoundKey = 134; - if (iJoyValue3 > 50) - iFoundKey = 135; - } - if (x1ok) { - iJoyValue4 = 100 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin); - if (iJoyValue4 < -50) - iFoundKey = 132; - if (iJoyValue4 > 50) - iFoundKey = 133; - } + if (x1ok) { + iJoyValue4 = + 100 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin); + if (iJoyValue4 < -50) + iFoundKey = 132; + if (iJoyValue4 > 50) + iFoundKey = 133; } + } - // Validate input type compatibility for throttle controls - //TODO - //if ( iFoundKey != -1 - // && (control_edit == 1 || control_edit == 7) - // && (userkey[control_edit] <= 0x83u && iFoundKey > 131 || userkey[control_edit] > 0x83u && iFoundKey <= 131) ) { - ////if (iFoundKey != -1 - //// && (control_edit == 1 || control_edit == 7) - //// && (*((_BYTE *)&keyname[139] + control_edit + 3) <= 0x83u && iFoundKey > 131 || *((_BYTE *)&keyname[139] + control_edit + 3) > 0x83u && iFoundKey <= 131)) { - // iFoundKey = -1; // reject incompatible input type - //} - - if (iFoundKey == -1) + // Validate input type compatibility for throttle controls + // TODO + // if ( iFoundKey != -1 + // && (control_edit == 1 || control_edit == 7) + // && (userkey[control_edit] <= 0x83u && iFoundKey > 131 || + // userkey[control_edit] > 0x83u && iFoundKey <= 131) ) { + ////if (iFoundKey != -1 + //// && (control_edit == 1 || control_edit == 7) + //// && (*((_BYTE *)&keyname[139] + control_edit + 3) <= 0x83u && + /// iFoundKey > 131 || *((_BYTE *)&keyname[139] + control_edit + 3) > + /// 0x83u + ///&& iFoundKey <= 131)) { + // iFoundKey = -1; // reject incompatible input + // type + //} + + if (iFoundKey == -1) + goto CHECK_CONTROL_INPUT; + + // Check for duplicate key assignments + iDuplicateCheck = 0; + for (i = 0; i < control_edit; ++i) { + if (userkey[i] == iFoundKey) + iDuplicateCheck = -1; + } + if (iDuplicateCheck) + goto CHECK_CONTROL_INPUT; // Reject duplicate assignment + + // Assign the new key + iEditIndex = control_edit + 1; + iControlState = iControlsInEdit; + controlrelease = -1; + + userkey[control_edit] = iFoundKey; + //*((_BYTE *)&keyname[139] + iEditIndex + 3) = iFoundKey; + + // Handle completion logic for each player + control_edit = iEditIndex; + if (iControlState == 1) // Player 1 + { + if (iEditIndex < 6) + goto CHECK_CONTROL_INPUT; + // Check for cheat key mapping + if (Players_Cars[player1_car] >= 8 && control_edit < 12) { + control_edit = 12; // jump to cheat key goto CHECK_CONTROL_INPUT; - - // Check for duplicate key assignments - iDuplicateCheck = 0; - for (i = 0; i < control_edit; ++i) { - if (userkey[i] == iFoundKey) - iDuplicateCheck = -1; } - if (iDuplicateCheck) - goto CHECK_CONTROL_INPUT; // Reject duplicate assignment - - // Assign the new key - iEditIndex = control_edit + 1; - iControlState = iControlsInEdit; - controlrelease = -1; - - userkey[control_edit] = iFoundKey; - //*((_BYTE *)&keyname[139] + iEditIndex + 3) = iFoundKey; - - // Handle completion logic for each player - control_edit = iEditIndex; - if (iControlState == 1) // Player 1 - { - if (iEditIndex < 6) - goto CHECK_CONTROL_INPUT; - // Check for cheat key mapping - if (Players_Cars[player1_car] >= 8 && control_edit < 12) { - control_edit = 12; // jump to cheat key - goto CHECK_CONTROL_INPUT; - } - } else // Player 2 - { - if (iEditIndex < 12) - goto CHECK_CONTROL_INPUT; - if (Players_Cars[player2_car] >= 8 && control_edit < 13) { - control_edit = 13; // jump to cheat key - goto CHECK_CONTROL_INPUT; - } + } else // Player 2 + { + if (iEditIndex < 12) + goto CHECK_CONTROL_INPUT; + if (Players_Cars[player2_car] >= 8 && control_edit < 13) { + control_edit = 13; // jump to cheat key + goto CHECK_CONTROL_INPUT; } + } - // All controls mapped, exit editing mode + // All controls mapped, exit editing mode + iControlsInEdit = 0; + control_edit = -1; + enable_keyboard(); + CHECK_CONTROL_INPUT: + // Handle ESC key to restore original key mappings + if (keys[1]) { + memcpy(userkey, oldkeys, 0xCu); // restore original player 1 keys + memcpy(&userkey[12], &oldkeys[12], 2u); // restore original cheat keys + enable_keyboard(); iControlsInEdit = 0; control_edit = -1; - enable_keyboard(); - CHECK_CONTROL_INPUT: - // Handle ESC key to restore original key mappings - if (keys[1]) { - memcpy(userkey, oldkeys, 0xCu); // restore original player 1 keys - memcpy(&userkey[12], &oldkeys[12], 2u);// restore original cheat keys - enable_keyboard(); - iControlsInEdit = 0; - control_edit = -1; - check_joystick_usage(); - } - RENDER_FRAME: - // Display any received network messages - show_received_mesage(); - - // render (GPU) - menu_render_end_frame(mr); + check_joystick_usage(); + } + RENDER_FRAME: + // Display any received network messages + show_received_mesage(); - // Handle CHEAT_MODE_CLONES - if (switch_same > 0) { - // Clone all player cars to same type - iPlayerIdx = 0; - if (players > 0) { + // render (GPU) + menu_render_end_frame(mr); - for (iPlayerIdx = 0; iPlayerIdx < players; iPlayerIdx++) - { - Players_Cars[iPlayerIdx] = switch_same - 666; - } - //iPlayersCarsOffset = 0; - //do { - // iPlayersCarsOffset += 4; - // ++iPlayerIdx; - // *(int *)((char *)&infinite_laps + iPlayersCarsOffset) = switch_same - 666;// offset into Players_Cars - //} while (iPlayerIdx < players); + // Handle CHEAT_MODE_CLONES + if (switch_same > 0) { + // Clone all player cars to same type + iPlayerIdx = 0; + if (players > 0) { + for (iPlayerIdx = 0; iPlayerIdx < players; iPlayerIdx++) { + Players_Cars[iPlayerIdx] = switch_same - 666; } + // iPlayersCarsOffset = 0; + // do { + // iPlayersCarsOffset += 4; + // ++iPlayerIdx; + // *(int *)((char *)&infinite_laps + iPlayersCarsOffset) = + // switch_same - 666;// offset into Players_Cars + // } while (iPlayerIdx < players); + } - cheat_mode |= CHEAT_MODE_CLONES; - //uiTempCheatMode = cheat_mode; - //BYTE1(uiTempCheatMode) = BYTE1(cheat_mode) | 0x40; - //cheat_mode = uiTempCheatMode; - } else if (switch_same < 0) { - // Reset car cloning - switch_same = 0; - iPlayerIdx_1 = 0; - if (players > 0) { - - for (iPlayerIdx_1 = 0; iPlayerIdx_1 < players; iPlayerIdx_1++) - { - Players_Cars[iPlayerIdx_1] = -1; - } - //iPlayersCarsOffset_1 = 0; - //do { - // iPlayersCarsOffset_1 += 4; - // ++iPlayerIdx_1; - // *(int *)((char *)&infinite_laps + iPlayersCarsOffset_1) = -1;// offset into Players_Cars - //} while (iPlayerIdx_1 < players); - + cheat_mode |= CHEAT_MODE_CLONES; + // uiTempCheatMode = cheat_mode; + // BYTE1(uiTempCheatMode) = BYTE1(cheat_mode) | 0x40; + // cheat_mode = uiTempCheatMode; + } else if (switch_same < 0) { + // Reset car cloning + switch_same = 0; + iPlayerIdx_1 = 0; + if (players > 0) { + + for (iPlayerIdx_1 = 0; iPlayerIdx_1 < players; iPlayerIdx_1++) { + Players_Cars[iPlayerIdx_1] = -1; } - - cheat_mode &= ~CHEAT_MODE_CLONES; - //cheat_mode &= ~0x4000u; + // iPlayersCarsOffset_1 = 0; + // do { + // iPlayersCarsOffset_1 += 4; + // ++iPlayerIdx_1; + // *(int *)((char *)&infinite_laps + iPlayersCarsOffset_1) = -1;// + // offset into Players_Cars + // } while (iPlayerIdx_1 < players); } - // Process keyboard input when not editing controls - if (!iControlsInEdit) { - while (fatkbhit()) { - UpdateSDL(); - switch (iConfigState) { - case 0: // MAIN MENU NAVIGATION - uiKeyCode = fatgetch(); - if (uiKeyCode < 0xD) { - if (!uiKeyCode) // extended key + cheat_mode &= ~CHEAT_MODE_CLONES; + // cheat_mode &= ~0x4000u; + } + + // Process keyboard input when not editing controls + if (!iControlsInEdit) { + while (fatkbhit()) { + UpdateSDL(); + switch (iConfigState) { + case 0: // MAIN MENU NAVIGATION + uiKeyCode = fatgetch(); + if (uiKeyCode < 0xD) { + if (!uiKeyCode) // extended key + { + uiExtendedKey = fatgetch(); + if (uiExtendedKey >= 0x48) // Up arrow + { + if (uiExtendedKey <= 0x48) { + iMenuDir2 = --iMenuSelection; + // Skip network option if disabled + if (!network_on && iMenuDir2 == 6) + iMenuSelection = 5; + if (iMenuSelection < 0) + iMenuSelection = 0; + } else if (uiExtendedKey == 80) // Down arrow { - uiExtendedKey = fatgetch(); - if (uiExtendedKey >= 0x48)// Up arrow - { - if (uiExtendedKey <= 0x48) { - iMenuDir2 = --iMenuSelection; - // Skip network option if disabled - if (!network_on && iMenuDir2 == 6) - iMenuSelection = 5; - if (iMenuSelection < 0) - iMenuSelection = 0; - } else if (uiExtendedKey == 80)// Down arrow - { - iMenuDir = ++iMenuSelection; - // Skip network option if disabled - if (!network_on && iMenuDir == 6) - iMenuSelection = 7; - if (iMenuSelection > 7) - iMenuSelection = 7; - } - } + iMenuDir = ++iMenuSelection; + // Skip network option if disabled + if (!network_on && iMenuDir == 6) + iMenuSelection = 7; + if (iMenuSelection > 7) + iMenuSelection = 7; } - } else if (uiKeyCode <= 0xD) // enter key + } + } + } else if (uiKeyCode <= 0xD) // enter key + { + switch (iMenuSelection) { + case 0: // drivers + iConfigState = 1; + iSelectedCar = 0; + break; + case 1: // audio + iConfigState = 2; + iVolumeSelection = 0; + break; + case 2: // joystick + iConfigState = 3; + check_joystickpresence(); + break; + case 3: // controls + iConfigState = 4; + iControlSelection = 0; + iControlsInEdit = 0; + Joy1used = 0; + Joy2used = 0; + controlrelease = -1; + control_edit = -1; + break; + case 4: // video + iConfigState = 5; + iVideoState = 0; + break; + case 5: // graphics + iConfigState = 6; + iGraphicsState = 0; + break; + case 6: // network + iConfigState = 7; + iNetworkState = 0; + iEditingName = 0; + break; + case 7: // exit + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); + iExitFlag = -1; + break; + default: + continue; + } + } else if (uiKeyCode == 27) // ESC key + { + iExitFlag = -1; + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); + } + continue; + case 1: // DRIVER/CAR CONFIG + iKeyInput = fatgetch(); + iKeyChar = iKeyInput; + if ((unsigned int)iKeyInput < 8) { + if (iKeyInput) + goto HANDLE_CHAR_INPUT; // Handle character input + + // Handle arrow keys for car selection + uiArrowKey = fatgetch(); + if (!iEditingName && uiArrowKey >= 0x48) { + if (uiArrowKey <= 0x48) // up arrow { - switch (iMenuSelection) { - case 0: // drivers - iConfigState = 1; - iSelectedCar = 0; - break; - case 1: // audio - iConfigState = 2; - iVolumeSelection = 0; - break; - case 2: // joystick - iConfigState = 3; - check_joystickpresence(); - break; - case 3: // controls - iConfigState = 4; - iControlSelection = 0; - iControlsInEdit = 0; - Joy1used = 0; - Joy2used = 0; - controlrelease = -1; - control_edit = -1; - break; - case 4: // video - iConfigState = 5; - iVideoState = 0; - break; - case 5: // graphics - iConfigState = 6; - iGraphicsState = 0; - break; - case 6: // network - iConfigState = 7; - iNetworkState = 0; - iEditingName = 0; - break; - case 7: // exit - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); - iExitFlag = -1; - break; - default: - continue; - } - } else if (uiKeyCode == 27) // ESC key + iNextSelectedCar = ++iSelectedCar; + // Skip player 2 slot in single player mode + if (player_type != 2 && iNextSelectedCar == 2) + iSelectedCar = 3; + if (iSelectedCar > 18) + iSelectedCar = 18; + } else if (uiArrowKey == 80) // down arrow { - iExitFlag = -1; - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); + iPrevSelectedCar = --iSelectedCar; + // Skip player 2 slot in single player mode + if (player_type != 2 && iPrevSelectedCar == 2) + iSelectedCar = 1; + if (iSelectedCar < 0) + iSelectedCar = 0; } - continue; - case 1: // DRIVER/CAR CONFIG - iKeyInput = fatgetch(); - iKeyChar = iKeyInput; - if ((unsigned int)iKeyInput < 8) { - if (iKeyInput) - goto HANDLE_CHAR_INPUT; // Handle character input - - // Handle arrow keys for car selection - uiArrowKey = fatgetch(); - if (!iEditingName && uiArrowKey >= 0x48) { - if (uiArrowKey <= 0x48) // up arrow - { - iNextSelectedCar = ++iSelectedCar; - // Skip player 2 slot in single player mode - if (player_type != 2 && iNextSelectedCar == 2) - iSelectedCar = 3; - if (iSelectedCar > 18) - iSelectedCar = 18; - } else if (uiArrowKey == 80)// down arrow - { - iPrevSelectedCar = --iSelectedCar; - // Skip player 2 slot in single player mode - if (player_type != 2 && iPrevSelectedCar == 2) - iSelectedCar = 1; - if (iSelectedCar < 0) - iSelectedCar = 0; + } + } else if ((unsigned int)iKeyInput <= 8) // backspace + { + if (iEditingName) { + // Handle backspace in name editing + iNameLength_1 = iNameLength; + szNewNameBuf[iNameLength] = 0; + if (iNameLength_1 > 0) { + iNameLength = iNameLength_1 - 1; + szNewNameBuf[iNameLength_1 - 1] = 0; + } + } + } else if ((unsigned int)iKeyInput < 0xD) // regular character input + { + HANDLE_CHAR_INPUT: + if (iEditingName) { + // Convert lowercase to uppercase + if (iKeyInput >= 97 && iKeyInput <= 122) + iKeyChar = iKeyInput - 32; + + // Accept alphanumeric chars and space + if ((iKeyChar == 32 || iKeyChar >= 65 && iKeyChar <= 90 || + iKeyChar >= 48 && iKeyChar <= 57) && + iNameLength < 8) { + iNameLength_2 = iNameLength + 1; + szNewNameBuf[iNameLength] = iKeyChar; + iNameLength = iNameLength_2; + szNewNameBuf[iNameLength_2] = 0; + } + } + } else if ((unsigned int)iKeyInput <= 0xD) // enter key + { + iEditingName_1 = iEditingName; + if (iEditingName) { + // Save edited name + iEditingName = 0; + if (iSelectedCar) { + if ((unsigned int)iSelectedCar <= 1) { + + // Save player 1 name + + for (j = 0; j < 9; j++) { + player_names[player1_car][j] = szNewNameBuf[j]; } - } - } else if ((unsigned int)iKeyInput <= 8)// backspace - { - if (iEditingName) { - // Handle backspace in name editing - iNameLength_1 = iNameLength; - szNewNameBuf[iNameLength] = 0; - if (iNameLength_1 > 0) { - iNameLength = iNameLength_1 - 1; - szNewNameBuf[iNameLength_1 - 1] = 0; + // for (j = 0; j < 9; cheat_names[player1_car + 31][j + 8] = + // *((_BYTE *)&pJoyPos.iJ2YAxis + j + 3)) + // ++j; + + broadcast_mode = -669; + while (broadcast_mode) + UpdateSDL(); + if (!network_on) + waste = + CheckNames(player_names[player1_car], player1_car); + check_cars(); + } else { + if (iSelectedCar != 2) + goto SAVE_AI_DRIVER_NAME; + iPlayer2Car = player2_car; + + for (k = 0; k < 9; k++) { + player_names[player2_car][k] = szNewNameBuf[k]; } + // for (k = 0; k < 9; cheat_names[iPlayer2Car + 31][k + 8] = + // *((_BYTE *)&pJoyPos.iJ2YAxis + k + 3)) + // ++k; + + waste = CheckNames(player_names[iPlayer2Car], iPlayer2Car); + check_cars(); } - } else if ((unsigned int)iKeyInput < 0xD)// regular character input + } else // AI players { - HANDLE_CHAR_INPUT: - if (iEditingName) { - // Convert lowercase to uppercase - if (iKeyInput >= 97 && iKeyInput <= 122) - iKeyChar = iKeyInput - 32; - - // Accept alphanumeric chars and space - if ((iKeyChar == 32 || iKeyChar >= 65 && iKeyChar <= 90 || iKeyChar >= 48 && iKeyChar <= 57) && iNameLength < 8) { - iNameLength_2 = iNameLength + 1; - szNewNameBuf[iNameLength] = iKeyChar; - iNameLength = iNameLength_2; - szNewNameBuf[iNameLength_2] = 0; - } + SAVE_AI_DRIVER_NAME: + iDefaultNamesIdx_1 = iSelectedCar - 3; + iDefaultNamesIdx_1 = + (iSelectedCar - 3) ^ 1; // Toggle for paired AI drivers + // LOBYTE(iDefaultNamesIdx_1) = (iSelectedCar - 3) ^ 1;// + // Toggle for paired AI drivers + iDefaultNamesCharItr = 0; + iDefaultNamesIdx = iDefaultNamesIdx_1; + + do { + default_names[iDefaultNamesIdx][iDefaultNamesCharItr] = + szNewNameBuf[iDefaultNamesCharItr]; + ++iDefaultNamesCharItr; + } while (iDefaultNamesCharItr < 9); + // do { + // ++iDefaultNamesCharItr; + // *((_BYTE *)&team_col[15] + iDefaultNamesCharItr + + // iDefaultNamesIdx * 9 + 3) = *((_BYTE *)&pJoyPos.iJ2YAxis + // + iDefaultNamesCharItr + 3);// offset into default_names + // } while (iDefaultNamesCharItr < 9); + + // Set default name if empty + if (!default_names[iDefaultNamesIdx][0]) { + sprintf(buffer, "comp %i", iSelectedCar - 2); + name_copy(default_names[iDefaultNamesIdx], buffer); } - } else if ((unsigned int)iKeyInput <= 0xD)// enter key - { - iEditingName_1 = iEditingName; - if (iEditingName) { - // Save edited name - iEditingName = 0; - if (iSelectedCar) { - if ((unsigned int)iSelectedCar <= 1) { - - // Save player 1 name - - for (j = 0; j < 9; j++) - { - player_names[player1_car][j] = szNewNameBuf[j]; - } - //for (j = 0; j < 9; cheat_names[player1_car + 31][j + 8] = *((_BYTE *)&pJoyPos.iJ2YAxis + j + 3)) - // ++j; - - broadcast_mode = -669; - while (broadcast_mode) - UpdateSDL(); - if (!network_on) - waste = CheckNames(player_names[player1_car], player1_car); - check_cars(); - } else { - if (iSelectedCar != 2) - goto SAVE_AI_DRIVER_NAME; - iPlayer2Car = player2_car; - - for (k = 0; k < 9; k++) - { - player_names[player2_car][k] = szNewNameBuf[k]; - } - //for (k = 0; k < 9; cheat_names[iPlayer2Car + 31][k + 8] = *((_BYTE *)&pJoyPos.iJ2YAxis + k + 3)) - // ++k; - - waste = CheckNames(player_names[iPlayer2Car], iPlayer2Car); - check_cars(); - } - } else // AI players - { - SAVE_AI_DRIVER_NAME: - iDefaultNamesIdx_1 = iSelectedCar - 3; - iDefaultNamesIdx_1 = (iSelectedCar - 3) ^ 1;// Toggle for paired AI drivers - //LOBYTE(iDefaultNamesIdx_1) = (iSelectedCar - 3) ^ 1;// Toggle for paired AI drivers - iDefaultNamesCharItr = 0; - iDefaultNamesIdx = iDefaultNamesIdx_1; - - do - { - default_names[iDefaultNamesIdx][iDefaultNamesCharItr] = szNewNameBuf[iDefaultNamesCharItr]; - ++iDefaultNamesCharItr; - } - while (iDefaultNamesCharItr < 9); - //do { - // ++iDefaultNamesCharItr; - // *((_BYTE *)&team_col[15] + iDefaultNamesCharItr + iDefaultNamesIdx * 9 + 3) = *((_BYTE *)&pJoyPos.iJ2YAxis + iDefaultNamesCharItr + 3);// offset into default_names - //} while (iDefaultNamesCharItr < 9); - - // Set default name if empty - if (!default_names[iDefaultNamesIdx][0]) { - sprintf(buffer, "comp %i", iSelectedCar - 2); - name_copy(default_names[iDefaultNamesIdx], buffer); - } - broadcast_mode = -1; - while (broadcast_mode) - UpdateSDL(); + broadcast_mode = -1; + while (broadcast_mode) + UpdateSDL(); + } + } else { + // Start editing name + if (!iSelectedCar) + goto EXIT_NAME_EDITING; + iEditingName = 1; + if (iSelectedCar >= 3) { + // Check if AI car slot is editable + if ((((uint8)iSelectedCar - 3) & 1) != 0) + iEditingName = allocated_cars[(iSelectedCar - 3) / 2] <= 0; + else + iEditingName = allocated_cars[(iSelectedCar - 3) / 2] <= 1; + } + + if (iEditingName == 1) { + iNameLength = 0; + if ((unsigned int)iSelectedCar <= 1) // Load player 1 name + { + for (m = 0; m < 9; m++) { + szNewNameBuf[m] = player_names[player1_car][m]; } - } else { - // Start editing name - if (!iSelectedCar) - goto EXIT_NAME_EDITING; - iEditingName = 1; - if (iSelectedCar >= 3) { - // Check if AI car slot is editable - if ((((uint8)iSelectedCar - 3) & 1) != 0) - iEditingName = allocated_cars[(iSelectedCar - 3) / 2] <= 0; - else - iEditingName = allocated_cars[(iSelectedCar - 3) / 2] <= 1; + // for (m = 0; m < 9; *((_BYTE *)&pJoyPos.iJ2YAxis + m + 3) + // = cheat_names[player1_car + 31][m + 8]) + // ++m; + } else if (iSelectedCar == 2) // Load player 2 name + { + for (n = 0; n < 9; n++) { + szNewNameBuf[n] = player_names[player2_car][n]; } - - if (iEditingName == 1) { - iNameLength = 0; - if ((unsigned int)iSelectedCar <= 1)// Load player 1 name - { - for (m = 0; m < 9; m++) - { - szNewNameBuf[m] = player_names[player1_car][m]; - } - //for (m = 0; m < 9; *((_BYTE *)&pJoyPos.iJ2YAxis + m + 3) = cheat_names[player1_car + 31][m + 8]) - // ++m; - } else if (iSelectedCar == 2)// Load player 2 name - { - for (n = 0; n < 9; n++) - { - szNewNameBuf[n] = player_names[player2_car][n]; - } - //for (n = 0; n < 9; *((_BYTE *)&pJoyPos.iJ2YAxis + n + 3) = cheat_names[player2_car + 31][n + 8]) - // ++n; - } else // Load AI driver name - { - iAIDriverIdx = iSelectedCar - 3; - iAIDriverIdx ^= 1; // Toggle the lowest bit - for (int i = 0; i < 9; i++) - { - szNewNameBuf[i] = default_names[iAIDriverIdx][i]; - } - //iAIDriverIdx = iSelectedCar - 3; - //LOBYTE(iAIDriverIdx) = (iSelectedCar - 3) ^ 1; - //v189 = 0; - //iOffset = 9 * iAIDriverIdx; - //do { - // ++v189; - // v191 = default_names[0][iOffset++]; - // *((_BYTE *)&pJoyPos.iJ2YAxis + v189 + 3) = v191; - //} while (v189 < 9); - - } - - // Calculate current name length - while (szNewNameBuf[iNameLength]) - ++iNameLength; + // for (n = 0; n < 9; *((_BYTE *)&pJoyPos.iJ2YAxis + n + 3) + // = cheat_names[player2_car + 31][n + 8]) + // ++n; + } else // Load AI driver name + { + iAIDriverIdx = iSelectedCar - 3; + iAIDriverIdx ^= 1; // Toggle the lowest bit + for (int i = 0; i < 9; i++) { + szNewNameBuf[i] = default_names[iAIDriverIdx][i]; } - + // iAIDriverIdx = iSelectedCar - 3; + // LOBYTE(iAIDriverIdx) = (iSelectedCar - 3) ^ 1; + // v189 = 0; + // iOffset = 9 * iAIDriverIdx; + // do { + // ++v189; + // v191 = default_names[0][iOffset++]; + // *((_BYTE *)&pJoyPos.iJ2YAxis + v189 + 3) = v191; + // } while (v189 < 9); } - } else { - if (iKeyInput != 27) // ESC key - goto HANDLE_CHAR_INPUT; - iEditingName_1 = iEditingName; - if (iEditingName) { - // Cancel editing, restore original name - iEditingName = 0; - if (iSelectedCar) { - if ((unsigned int)iSelectedCar <= 1)// player 1 - { - - // Restore player 1 name - - for (ii = 0; ii < 9; ii++) - { - player_names[player1_car][ii] = szNewNameBuf[ii]; - } - //for (ii = 0; ii < 9; cheat_names[player1_car + 31][ii + 8] = *((_BYTE *)&pJoyPos.iJ2YAxis + ii + 3)) - // ++ii; - broadcast_mode = -669; - while (broadcast_mode) - UpdateSDL(); - if (!network_on) - waste = CheckNames(player_names[player1_car], player1_car); - } else { - if (iSelectedCar != 2)// player 2 - goto CANCEL_AI_NAME_EDIT; - iPlayer2Car_1 = player2_car; - - // Restore player 2 name - - for (jj = 0; jj < 9; jj++) - { - player_names[player2_car][jj] = szNewNameBuf[jj]; - } - //for (jj = 0; jj < 9; cheat_names[iPlayer2Car_1 + 31][jj + 8] = *((_BYTE *)&pJoyPos.iJ2YAxis + jj + 3)) - // ++jj; - waste = CheckNames(player_names[iPlayer2Car_1], iPlayer2Car_1); - } - } else // AI driver - { - CANCEL_AI_NAME_EDIT: - // Restore AI driver name - iAIDriverIdx_1 = iSelectedCar - 3; - iAIDriverIdx_1 ^= 1; // Toggle between paired AI drivers - for (v196 = 0; v196 < 9; v196++) - { - default_names[iAIDriverIdx_1][v196] = szNewNameBuf[v196]; - } - iAIDriverIdx_1 = iSelectedCar - 3; - iAIDriverIdx_1 = (iSelectedCar - 3) ^ 1; - //LOBYTE(iAIDriverIdx_1) = (iSelectedCar - 3) ^ 1; - v196 = 0; - v197 = iAIDriverIdx_1; + // Calculate current name length + while (szNewNameBuf[iNameLength]) + ++iNameLength; + } + } + } else { + if (iKeyInput != 27) // ESC key + goto HANDLE_CHAR_INPUT; + iEditingName_1 = iEditingName; + if (iEditingName) { + // Cancel editing, restore original name + iEditingName = 0; + if (iSelectedCar) { + if ((unsigned int)iSelectedCar <= 1) // player 1 + { - //do { - // ++v196; - // *((_BYTE *)&team_col[15] + v196 + v197 * 9 + 3) = *((_BYTE *)&pJoyPos.iJ2YAxis + v196 + 3); - //} while (v196 < 9); + // Restore player 1 name - if (!default_names[iAIDriverIdx_1][0]) { - sprintf(buffer, "comp %i", iSelectedCar - 2); - name_copy(default_names[v197], buffer); - } - broadcast_mode = -1; - while (broadcast_mode) - UpdateSDL(); + for (ii = 0; ii < 9; ii++) { + player_names[player1_car][ii] = szNewNameBuf[ii]; } + // for (ii = 0; ii < 9; cheat_names[player1_car + 31][ii + + // 8] = *((_BYTE *)&pJoyPos.iJ2YAxis + ii + 3)) + // ++ii; + broadcast_mode = -669; + while (broadcast_mode) + UpdateSDL(); + if (!network_on) + waste = + CheckNames(player_names[player1_car], player1_car); } else { - EXIT_NAME_EDITING: - iConfigState = iEditingName_1; - } - } - continue; - case 2: - // Audio/Volume config - uiKey_5 = fatgetch(); - if (uiKey_5 < 0xD) { - if (!uiKey_5) // Extended key - { - switch (fatgetch()) { - case 0x48: // UP arrow - if (iVolumeSelection) { - if (iVolumeSelection > 1) - --iVolumeSelection; - } else { - iVolumeSelection = 7; - } - break; - case 0x4B: // Left arrow - decrease volume - switch (iVolumeSelection) { - case 1: // Engine volume - EngineVolume -= 4; - if (EngineVolume < 0) - EngineVolume = 0; - break; - case 2: // SFX volume - SFXVolume -= 4; - if (SFXVolume < 0) - SFXVolume = 0; - break; - case 3: // Speech volume - SpeechVolume -= 4; - if (SpeechVolume < 0) - SpeechVolume = 0; - break; - case 4: // Music volume - MusicVolume -= 4; - if (MusicVolume < 0) - MusicVolume = 0; - // Update hardware volume - if (MusicCard) - MIDISetMasterVolume(MusicVolume); - //sosMIDISetMasterVolume(MusicVolume); - if (MusicCD) - goto SET_CD_VOLUME;// CONTINUE_AUDIO_INPUT: Continue processing audio menu input - break; - default: - continue; - } - break; - case 0x4D: // Right arrow - increase volume - switch (iVolumeSelection) { - case 1: // Engine volume - EngineVolume += 4; - if (EngineVolume >= 128) - EngineVolume = 127; - break; - case 2: // SFX volume - SFXVolume += 4; - if (SFXVolume >= 128) - SFXVolume = 127; - break; - case 3: // Speech volume - SpeechVolume += 4; - if (SpeechVolume >= 128) - SpeechVolume = 127; - break; - case 4: // Music volume - MusicVolume += 4; - if (MusicVolume >= 128) - MusicVolume = 127; - // Update hardware volume - if (MusicCard) - MIDISetMasterVolume(MusicVolume); - //sosMIDISetMasterVolume(MusicVolume); - if (MusicCD) - SET_CD_VOLUME: - SetAudioVolume(MusicVolume); - break; - default: - continue; - } - break; - case 0x50: // Down arrow - iNextVolumeSelection = iVolumeSelection; - if (iVolumeSelection > 0) { - ++iVolumeSelection; - if (iNextVolumeSelection + 1 > 7) - iVolumeSelection = 0; - } - break; - default: - continue; + if (iSelectedCar != 2) // player 2 + goto CANCEL_AI_NAME_EDIT; + iPlayer2Car_1 = player2_car; + + // Restore player 2 name + + for (jj = 0; jj < 9; jj++) { + player_names[player2_car][jj] = szNewNameBuf[jj]; } + // for (jj = 0; jj < 9; cheat_names[iPlayer2Car_1 + 31][jj + + // 8] = *((_BYTE *)&pJoyPos.iJ2YAxis + jj + 3)) + // ++jj; + waste = + CheckNames(player_names[iPlayer2Car_1], iPlayer2Car_1); } - } else if (uiKey_5 <= 0xD) // Enter key + } else // AI driver { + CANCEL_AI_NAME_EDIT: + // Restore AI driver name + iAIDriverIdx_1 = iSelectedCar - 3; + iAIDriverIdx_1 ^= 1; // Toggle between paired AI drivers + for (v196 = 0; v196 < 9; v196++) { + default_names[iAIDriverIdx_1][v196] = szNewNameBuf[v196]; + } + iAIDriverIdx_1 = iSelectedCar - 3; + iAIDriverIdx_1 = (iSelectedCar - 3) ^ 1; + // LOBYTE(iAIDriverIdx_1) = (iSelectedCar - 3) ^ 1; + v196 = 0; + v197 = iAIDriverIdx_1; + + // do { + // ++v196; + // *((_BYTE *)&team_col[15] + v196 + v197 * 9 + 3) = + // *((_BYTE *)&pJoyPos.iJ2YAxis + v196 + 3); + // } while (v196 < 9); + + if (!default_names[iAIDriverIdx_1][0]) { + sprintf(buffer, "comp %i", iSelectedCar - 2); + name_copy(default_names[v197], buffer); + } + broadcast_mode = -1; + while (broadcast_mode) + UpdateSDL(); + } + } else { + EXIT_NAME_EDITING: + iConfigState = iEditingName_1; + } + } + continue; + case 2: + // Audio/Volume config + uiKey_5 = fatgetch(); + if (uiKey_5 < 0xD) { + if (!uiKey_5) // Extended key + { + switch (fatgetch()) { + case 0x48: // UP arrow + if (iVolumeSelection) { + if (iVolumeSelection > 1) + --iVolumeSelection; + } else { + iVolumeSelection = 7; + } + break; + case 0x4B: // Left arrow - decrease volume switch (iVolumeSelection) { - case 0: // Back - goto EXIT_AUDIO_MENU; // Return to main menu - case 5: // Toggle engine mode - allengines = allengines == 0; - break; - case 6: // Toggle sound effects - if (SoundCard) { - kk = soundon != 0; - soundon = soundon == 0; - if (!kk) - loadfatalsample(); - } else { - soundon = 0; - } - break; - case 7: // Toggle music - if (MusicCard || MusicCD) { - musicon = musicon == 0; - reinitmusic(); - } else { - musicon = MusicCard; - } - break; - default: - continue; + case 1: // Engine volume + EngineVolume -= 4; + if (EngineVolume < 0) + EngineVolume = 0; + break; + case 2: // SFX volume + SFXVolume -= 4; + if (SFXVolume < 0) + SFXVolume = 0; + break; + case 3: // Speech volume + SpeechVolume -= 4; + if (SpeechVolume < 0) + SpeechVolume = 0; + break; + case 4: // Music volume + MusicVolume -= 4; + if (MusicVolume < 0) + MusicVolume = 0; + // Update hardware volume + if (MusicCard) + MIDISetMasterVolume(MusicVolume); + // sosMIDISetMasterVolume(MusicVolume); + if (MusicCD) + goto SET_CD_VOLUME; // CONTINUE_AUDIO_INPUT: Continue + // processing audio menu input + break; + default: + continue; } - } else if (uiKey_5 == 0x1B) // ESC key - { - EXIT_AUDIO_MENU_2: - iConfigState = 0; + break; + case 0x4D: // Right arrow - increase volume + switch (iVolumeSelection) { + case 1: // Engine volume + EngineVolume += 4; + if (EngineVolume >= 128) + EngineVolume = 127; + break; + case 2: // SFX volume + SFXVolume += 4; + if (SFXVolume >= 128) + SFXVolume = 127; + break; + case 3: // Speech volume + SpeechVolume += 4; + if (SpeechVolume >= 128) + SpeechVolume = 127; + break; + case 4: // Music volume + MusicVolume += 4; + if (MusicVolume >= 128) + MusicVolume = 127; + // Update hardware volume + if (MusicCard) + MIDISetMasterVolume(MusicVolume); + // sosMIDISetMasterVolume(MusicVolume); + if (MusicCD) + SET_CD_VOLUME: + SetAudioVolume(MusicVolume); + break; + default: + continue; + } + break; + case 0x50: // Down arrow + iNextVolumeSelection = iVolumeSelection; + if (iVolumeSelection > 0) { + ++iVolumeSelection; + if (iNextVolumeSelection + 1 > 7) + iVolumeSelection = 0; + } + break; + default: + continue; } - continue; - case 3: // JOYSTICK CALIBRATION INPUT - uiKey = fatgetch(); - if (uiKey < 0xD) { - if (!uiKey) - fatgetch(); // Consume extended key - } else if (uiKey <= 0xD || uiKey == 0x1B)// Enter or ESC - { - remove_uncalibrated(); - iConfigState = 0; // Return to main menu + } + } else if (uiKey_5 <= 0xD) // Enter key + { + switch (iVolumeSelection) { + case 0: // Back + goto EXIT_AUDIO_MENU; // Return to main menu + case 5: // Toggle engine mode + allengines = allengines == 0; + break; + case 6: // Toggle sound effects + if (SoundCard) { + kk = soundon != 0; + soundon = soundon == 0; + if (!kk) + loadfatalsample(); + } else { + soundon = 0; } + break; + case 7: // Toggle music + if (MusicCard || MusicCD) { + musicon = musicon == 0; + reinitmusic(); + } else { + musicon = MusicCard; + } + break; + default: continue; - case 4: // CONTROL CONFIG INPUT - uiKey_1 = fatgetch(); - if (uiKey_1 < 0xD) { - if (!uiKey_1) // Extended key + } + } else if (uiKey_5 == 0x1B) // ESC key + { + EXIT_AUDIO_MENU_2: + iConfigState = 0; + } + continue; + case 3: // JOYSTICK CALIBRATION INPUT + uiKey = fatgetch(); + if (uiKey < 0xD) { + if (!uiKey) + fatgetch(); // Consume extended key + } else if (uiKey <= 0xD || uiKey == 0x1B) // Enter or ESC + { + remove_uncalibrated(); + iConfigState = 0; // Return to main menu + } + continue; + case 4: // CONTROL CONFIG INPUT + uiKey_1 = fatgetch(); + if (uiKey_1 < 0xD) { + if (!uiKey_1) // Extended key + { + uiKey_6 = fatgetch(); + if (uiKey_6 >= 0x48) { + if (uiKey_6 <= 0x48) // Up arrow { - uiKey_6 = fatgetch(); - if (uiKey_6 >= 0x48) { - if (uiKey_6 <= 0x48) // Up arrow - { - if (!iControlsInEdit) { - iNextControlSelection = ++iControlSelection; - if (player_type == 2) { - if (iNextControlSelection > 4) - iControlSelection = 4; - } else if (iNextControlSelection > 2) { - iControlSelection = 2; - } - } - } else if (uiKey_6 == 80 && !iControlsInEdit && --iControlSelection < 0) { - iControlSelection = iControlsInEdit; + if (!iControlsInEdit) { + iNextControlSelection = ++iControlSelection; + if (player_type == 2) { + if (iNextControlSelection > 4) + iControlSelection = 4; + } else if (iNextControlSelection > 2) { + iControlSelection = 2; } } + } else if (uiKey_6 == 80 && !iControlsInEdit && + --iControlSelection < 0) { + iControlSelection = iControlsInEdit; } - } else if (uiKey_1 <= 0xD) // Enter key - { - switch (iControlSelection) { - case 0: // Back - goto EXIT_CONTROLS_MENU; // Return to main menu - case 1: // Customize Player 1 - control_edit = 0; - disable_keyboard(); - memcpy(oldkeys, userkey, 0xCu);// Backup current keys - memcpy(&oldkeys[12], &userkey[12], 2u);// Backup cheat keys - iControlsInEdit = 1; - controlrelease = -1; - break; - case 2: // Toggle player 1 control method - if (manual_control[player1_car] == 2) - manual_control[player1_car] = 1;// Switch to keyboard - else - manual_control[player1_car] = 2;// Switch to joystick - broadcast_mode = -1; - while (broadcast_mode) - UpdateSDL(); - break; - case 3: // Customize player 2 - iControlsInEdit = 2; - control_edit = 6; // Start with player 2 controls - disable_keyboard(); - memcpy(oldkeys, userkey, 0xCu);// backup current keys - memcpy(&oldkeys[12], &userkey[12], 2u);// backup cheat keys - controlrelease = -1; - break; - case 4: - if (manual_control[player2_car] == 2) - manual_control[player2_car] = 1;// switch to keyboard - else - manual_control[player2_car] = 2;// switch to joystick - break; - default: - continue; + } + } + } else if (uiKey_1 <= 0xD) // Enter key + { + switch (iControlSelection) { + case 0: // Back + goto EXIT_CONTROLS_MENU; // Return to main menu + case 1: // Customize Player 1 + control_edit = 0; + disable_keyboard(); + memcpy(oldkeys, userkey, 0xCu); // Backup current keys + memcpy(&oldkeys[12], &userkey[12], 2u); // Backup cheat keys + iControlsInEdit = 1; + controlrelease = -1; + break; + case 2: // Toggle player 1 control method + if (manual_control[player1_car] == 2) + manual_control[player1_car] = 1; // Switch to keyboard + else + manual_control[player1_car] = 2; // Switch to joystick + broadcast_mode = -1; + while (broadcast_mode) + UpdateSDL(); + break; + case 3: // Customize player 2 + iControlsInEdit = 2; + control_edit = 6; // Start with player 2 controls + disable_keyboard(); + memcpy(oldkeys, userkey, 0xCu); // backup current keys + memcpy(&oldkeys[12], &userkey[12], 2u); // backup cheat keys + controlrelease = -1; + break; + case 4: + if (manual_control[player2_car] == 2) + manual_control[player2_car] = 1; // switch to keyboard + else + manual_control[player2_car] = 2; // switch to joystick + break; + default: + continue; + } + } else if (uiKey_1 == 27) { + iConfigState = 0; + } + continue; + case 5: // VIDEO + uiKey_2 = fatgetch(); + if (uiKey_2 < 0xD) { + if (!uiKey_2) { + switch (fatgetch()) { + case 0x48: + if (++iVideoState > 16) + iVideoState = 16; + break; + case 0x4B: + if (iVideoState == 2) { + if (game_svga) { + game_size -= 16; + if (game_size < 64) + game_size = 64; + } else { + game_size -= 8; + if (game_size < 32) + game_size = 32; + } } - } else if (uiKey_1 == 27) { - iConfigState = 0; + break; + case 0x4D: + if (iVideoState == 2) { + if (game_svga) { + game_size += 16; + if (game_size > 128) + game_size = 128; + } else { + game_size += 8; + if (game_size > 64) + game_size = 64; + } + } + break; + case 0x50: + if (--iVideoState < 0) + iVideoState = 0; + break; + default: + continue; + } + } + } else if (uiKey_2 <= 0xD) { + switch (iVideoState) { + case 0: + iConfigState = 0; + break; + case 1: + if (game_svga) { + game_svga = 0; + game_size /= 2; + } else if (svga_possible && !no_mem) { + game_svga = -1; + game_size *= 2; } + break; + case 2: + if (game_svga) { + game_size += 16; + if (game_size > 128) + game_size = 64; + } else { + game_size += 8; + if (game_size > 64) + game_size = 32; + } + break; + case 3: + if (view_limit) { + view_limit = 0; + } else if (machine_speed >= 2800) { + view_limit = 32; + } else { + view_limit = 24; + } + break; + case 4: // PANEL ON + if ((textures_off & TEX_OFF_PANEL_OFF) != 0) { + uiTexOffTemp_7 = textures_off; + uiTexOffTemp_7 = textures_off ^ TEX_OFF_PANEL_OFF; + // LOBYTE(uiTexOffTemp_7) = textures_off ^ 0x20; + textures_off = uiTexOffTemp_7 | TEX_OFF_PANEL_RESTRICTED; + } else if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) { + textures_off ^= TEX_OFF_PANEL_RESTRICTED; + } else { + textures_off |= TEX_OFF_PANEL_OFF; + } + break; + case 5: + uiTexOffTemp = textures_off; + uiTexOffTemp = textures_off ^ TEX_OFF_CLOUDS; + // LOBYTE(uiTexOffTemp) = textures_off ^ 8; + textures_off = uiTexOffTemp; + break; + case 6: + uiTexOffTemp_1 = textures_off; + uiTexOffTemp_1 = textures_off ^ TEX_OFF_SHADOWS; + // BYTE1(uiTexOffTemp_1) = BYTE1(textures_off) ^ 1; + textures_off = uiTexOffTemp_1; + break; + case 7: + textures_off ^= TEX_OFF_ROAD_TEXTURES; + break; + case 8: + textures_off ^= TEX_OFF_BUILDING_TEXTURES; + break; + case 9: + uiTexOffTemp_2 = textures_off; + uiTexOffTemp_2 = textures_off ^ TEX_OFF_GROUND_TEXTURES; + // LOBYTE(uiTexOffTemp_2) = textures_off ^ 1; + textures_off = uiTexOffTemp_2; + break; + case 10: + uiTexOffTemp_3 = textures_off; + uiTexOffTemp_3 = textures_off ^ TEX_OFF_WALL_TEXTURES; + // LOBYTE(uiTexOffTemp_3) = textures_off ^ 4; + textures_off = uiTexOffTemp_3; + break; + case 11: + uiTexOffTemp_4 = textures_off; + uiTexOffTemp_4 = textures_off ^ TEX_OFF_CAR_TEXTURES; + // LOBYTE(uiTexOffTemp_4) = textures_off ^ 0x40; + textures_off = uiTexOffTemp_4; + break; + case 12: + uiTexOffTemp_5 = textures_off; + uiTexOffTemp_5 = textures_off ^ TEX_OFF_HORIZON; + // LOBYTE(uiTexOffTemp_5) = textures_off ^ 0x10; + textures_off = uiTexOffTemp_5; + break; + case 13: + textures_off ^= TEX_OFF_GLASS_WALLS; + break; + case 14: + textures_off ^= TEX_OFF_BUILDINGS; + break; + case 15: + if (++names_on > 2) + names_on = 0; + break; + case 16: + textures_off ^= TEX_OFF_PERSPECTIVE_CORRECTION; + break; + default: continue; - case 5: // VIDEO - uiKey_2 = fatgetch(); - if (uiKey_2 < 0xD) { - if (!uiKey_2) { - switch (fatgetch()) { - case 0x48: - if (++iVideoState > 16) - iVideoState = 16; - break; - case 0x4B: - if (iVideoState == 2) { - if (game_svga) { - game_size -= 16; - if (game_size < 64) - game_size = 64; - } else { - game_size -= 8; - if (game_size < 32) - game_size = 32; - } - } - break; - case 0x4D: - if (iVideoState == 2) { - if (game_svga) { - game_size += 16; - if (game_size > 128) - game_size = 128; - } else { - game_size += 8; - if (game_size > 64) - game_size = 64; - } - } - break; - case 0x50: - if (--iVideoState < 0) - iVideoState = 0; - break; - default: - continue; - } - } - } else if (uiKey_2 <= 0xD) { - switch (iVideoState) { - case 0: - iConfigState = 0; - break; - case 1: - if (game_svga) { - game_svga = 0; - game_size /= 2; - } else if (svga_possible && !no_mem) { - game_svga = -1; - game_size *= 2; - } - break; - case 2: - if (game_svga) { - game_size += 16; - if (game_size > 128) - game_size = 64; - } else { - game_size += 8; - if (game_size > 64) - game_size = 32; - } - break; - case 3: - if (view_limit) { - view_limit = 0; - } else if (machine_speed >= 2800) { - view_limit = 32; - } else { - view_limit = 24; - } - break; - case 4: //PANEL ON - if ((textures_off & TEX_OFF_PANEL_OFF) != 0) { - uiTexOffTemp_7 = textures_off; - uiTexOffTemp_7 = textures_off ^ TEX_OFF_PANEL_OFF; - //LOBYTE(uiTexOffTemp_7) = textures_off ^ 0x20; - textures_off = uiTexOffTemp_7 | TEX_OFF_PANEL_RESTRICTED; - } else if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) { - textures_off ^= TEX_OFF_PANEL_RESTRICTED; - } else { - textures_off |= TEX_OFF_PANEL_OFF; - } - break; - case 5: - uiTexOffTemp = textures_off; - uiTexOffTemp = textures_off ^ TEX_OFF_CLOUDS; - //LOBYTE(uiTexOffTemp) = textures_off ^ 8; - textures_off = uiTexOffTemp; - break; - case 6: - uiTexOffTemp_1 = textures_off; - uiTexOffTemp_1 = textures_off ^ TEX_OFF_SHADOWS; - //BYTE1(uiTexOffTemp_1) = BYTE1(textures_off) ^ 1; - textures_off = uiTexOffTemp_1; - break; - case 7: - textures_off ^= TEX_OFF_ROAD_TEXTURES; - break; - case 8: - textures_off ^= TEX_OFF_BUILDING_TEXTURES; - break; - case 9: - uiTexOffTemp_2 = textures_off; - uiTexOffTemp_2 = textures_off ^ TEX_OFF_GROUND_TEXTURES; - //LOBYTE(uiTexOffTemp_2) = textures_off ^ 1; - textures_off = uiTexOffTemp_2; - break; - case 10: - uiTexOffTemp_3 = textures_off; - uiTexOffTemp_3 = textures_off ^ TEX_OFF_WALL_TEXTURES; - //LOBYTE(uiTexOffTemp_3) = textures_off ^ 4; - textures_off = uiTexOffTemp_3; - break; - case 11: - uiTexOffTemp_4 = textures_off; - uiTexOffTemp_4 = textures_off ^ TEX_OFF_CAR_TEXTURES; - //LOBYTE(uiTexOffTemp_4) = textures_off ^ 0x40; - textures_off = uiTexOffTemp_4; - break; - case 12: - uiTexOffTemp_5 = textures_off; - uiTexOffTemp_5 = textures_off ^ TEX_OFF_HORIZON; - //LOBYTE(uiTexOffTemp_5) = textures_off ^ 0x10; - textures_off = uiTexOffTemp_5; - break; - case 13: - textures_off ^= TEX_OFF_GLASS_WALLS; - break; - case 14: - textures_off ^= TEX_OFF_BUILDINGS; - break; - case 15: - if (++names_on > 2) - names_on = 0; - break; - case 16: - textures_off ^= TEX_OFF_PERSPECTIVE_CORRECTION; - break; - default: - continue; + } + } else if (uiKey_2 == 27) { + EXIT_AUDIO_MENU: + iConfigState = 0; + } + continue; + case 6: // GRAPHICS + uiKey_3 = fatgetch(); + if (uiKey_3 < 0xD) { + if (!uiKey_3) { + switch (fatgetch()) { + case 0x48: + iPlayerIndex = ++iGraphicsState; + if (player_type == 2) { + if (iPlayerIndex > 6) + iGraphicsState = 6; + } else if (iPlayerIndex > 5) { + iGraphicsState = 5; } - } else if (uiKey_2 == 27) { - EXIT_AUDIO_MENU: - iConfigState = 0; + break; + case 0x50: + if (--iGraphicsState < 0) + iGraphicsState = 0; + break; + default: + continue; } + } + } else if (uiKey_3 <= 0xD) { + switch (iGraphicsState) { + case 0: + goto EXIT_AUDIO_MENU_2; + case 1: + false_starts = false_starts == 0; + broadcast_mode = -1; + while (broadcast_mode) + UpdateSDL(); + break; + case 2: + if (lots_of_mem) + p_tex_size = p_tex_size != 1; + break; + case 3: + replay_record = replay_record == 0; + break; + case 4: + uiTexOffTemp_6 = textures_off; + uiTexOffTemp_6 = textures_off ^ TEX_OFF_KMH; + // BYTE1(uiTexOffTemp_6) = BYTE1(textures_off) ^ 4; + textures_off = uiTexOffTemp_6; + break; + case 5: + do { + if (++game_view[0] == 9) + game_view[0] = 0; + } while (!AllowedViews[game_view[0]]); + break; + case 6: + do { + if (++game_view[1] == 9) + game_view[1] = 0; + } while (!AllowedViews[game_view[1]]); + break; + default: continue; - case 6: // GRAPHICS - uiKey_3 = fatgetch(); - if (uiKey_3 < 0xD) { - if (!uiKey_3) { - switch (fatgetch()) { - case 0x48: - iPlayerIndex = ++iGraphicsState; - if (player_type == 2) { - if (iPlayerIndex > 6) - iGraphicsState = 6; - } else if (iPlayerIndex > 5) { - iGraphicsState = 5; - } - break; - case 0x50: - if (--iGraphicsState < 0) - iGraphicsState = 0; - break; - default: - continue; - } - } - } else if (uiKey_3 <= 0xD) { - switch (iGraphicsState) { - case 0: - goto EXIT_AUDIO_MENU_2; - case 1: - false_starts = false_starts == 0; - broadcast_mode = -1; - while (broadcast_mode) - UpdateSDL(); - break; - case 2: - if (lots_of_mem) - p_tex_size = p_tex_size != 1; - break; - case 3: - replay_record = replay_record == 0; - break; - case 4: - uiTexOffTemp_6 = textures_off; - uiTexOffTemp_6 = textures_off ^ TEX_OFF_KMH; - //BYTE1(uiTexOffTemp_6) = BYTE1(textures_off) ^ 4; - textures_off = uiTexOffTemp_6; - break; - case 5: - do { - if (++game_view[0] == 9) - game_view[0] = 0; - } while (!AllowedViews[game_view[0]]); - break; - case 6: - do { - if (++game_view[1] == 9) - game_view[1] = 0; - } while (!AllowedViews[game_view[1]]); - break; - default: - continue; - } - } else if (uiKey_3 == 27) { - EXIT_CONTROLS_MENU: - iDisplayIndex = 0; - goto LABEL_900; + } + } else if (uiKey_3 == 27) { + EXIT_CONTROLS_MENU: + iDisplayIndex = 0; + goto LABEL_900; + } + continue; + case 7: // NETWORK + uiKey_4 = fatgetch(); + uiDataValue1 = uiKey_4; + iGameIndex = uiKey_4; + if (uiKey_4 < 8) { + if (uiKey_4) + goto LABEL_1028; + iPlayerIndex2 = iEditingName; + uiDataValue3 = fatgetch(); + if (!iPlayerIndex2 && uiDataValue3 >= 0x48) { + if (uiDataValue3 <= 0x48) { + if (++iNetworkState > 5) + iNetworkState = 5; + } else if (uiDataValue3 == 80 && --iNetworkState < 0) { + iNetworkState = uiDataValue1; } - continue; - case 7: // NETWORK - uiKey_4 = fatgetch(); - uiDataValue1 = uiKey_4; - iGameIndex = uiKey_4; - if (uiKey_4 < 8) { - if (uiKey_4) - goto LABEL_1028; - iPlayerIndex2 = iEditingName; - uiDataValue3 = fatgetch(); - if (!iPlayerIndex2 && uiDataValue3 >= 0x48) { - if (uiDataValue3 <= 0x48) { - if (++iNetworkState > 5) - iNetworkState = 5; - } else if (uiDataValue3 == 80 && --iNetworkState < 0) { - iNetworkState = uiDataValue1; - } + } + } else { + uiDataValue2 = 14 * (4 - iNetworkState); + if (uiDataValue1 <= 8) { + if (iEditingName) { + iDataIndex = iNameLength; + network_messages[0][iNameLength + uiDataValue2] = 0; + if (iDataIndex > 0) { + iNameLength = iDataIndex - 1; + network_messages[0][iDataIndex - 1 + uiDataValue2] = 0; } - } else { - uiDataValue2 = 14 * (4 - iNetworkState); - if (uiDataValue1 <= 8) { - if (iEditingName) { - iDataIndex = iNameLength; - network_messages[0][iNameLength + uiDataValue2] = 0; - if (iDataIndex > 0) { - iNameLength = iDataIndex - 1; - network_messages[0][iDataIndex - 1 + uiDataValue2] = 0; + } + } else { + if (uiDataValue1 < 0xD) + goto LABEL_1028; + if (uiDataValue1 <= 0xD) { + if (iEditingName) { + iEditingName = uiDataValue1 ^ iGameIndex; + } else if (iNetworkState) { + if (iNetworkState == 5) { + select_messages(); + } else { + iNameLength = iEditingName; + iCounterVar = 14 * (4 - iNetworkState); + byTempFlag = network_messages[uiDataValue2 / 0xE][0]; + iEditingName = 1; + for (kk = byTempFlag == 0; !kk; kk = byStatusFlag == 0) { + byStatusFlag = network_messages[0][++iCounterVar]; + ++iNameLength; } } } else { - if (uiDataValue1 < 0xD) - goto LABEL_1028; - if (uiDataValue1 <= 0xD) { - if (iEditingName) { - iEditingName = uiDataValue1 ^ iGameIndex; - } else if (iNetworkState) { - if (iNetworkState == 5) { - select_messages(); - } else { - iNameLength = iEditingName; - iCounterVar = 14 * (4 - iNetworkState); - byTempFlag = network_messages[uiDataValue2 / 0xE][0]; - iEditingName = 1; - for (kk = byTempFlag == 0; !kk; kk = byStatusFlag == 0) { - byStatusFlag = network_messages[0][++iCounterVar]; - ++iNameLength; - } - } - } else { - iConfigState = iEditingName; - } - } else if (uiDataValue1 == 27) { - iDisplayIndex = iEditingName; - if (iEditingName) - iEditingName = 0; - else - LABEL_900: - iConfigState = iDisplayIndex; - } else { - LABEL_1028: - if (iEditingName && iNameLength < 13) { - if (iGameIndex >= 97 && iGameIndex <= 122) - iGameIndex -= 32; - if (iGameIndex >= 65 && iGameIndex <= 90 || iGameIndex >= 48 && iGameIndex <= 57 || iGameIndex == 32 || iGameIndex == 46 || iGameIndex == 39) { - iResultValue = 14 * (4 - iNetworkState); - iCalculation = iNameLength + 1; - network_messages[0][iNameLength + iResultValue] = iGameIndex; - iNameLength = iCalculation; - network_messages[0][iCalculation + iResultValue] = 0; - } - } + iConfigState = iEditingName; + } + } else if (uiDataValue1 == 27) { + iDisplayIndex = iEditingName; + if (iEditingName) + iEditingName = 0; + else + LABEL_900: + iConfigState = iDisplayIndex; + } else { + LABEL_1028: + if (iEditingName && iNameLength < 13) { + if (iGameIndex >= 97 && iGameIndex <= 122) + iGameIndex -= 32; + if (iGameIndex >= 65 && iGameIndex <= 90 || + iGameIndex >= 48 && iGameIndex <= 57 || + iGameIndex == 32 || iGameIndex == 46 || + iGameIndex == 39) { + iResultValue = 14 * (4 - iNetworkState); + iCalculation = iNameLength + 1; + network_messages[0][iNameLength + iResultValue] = + iGameIndex; + iNameLength = iCalculation; + network_messages[0][iCalculation + iResultValue] = 0; } } } - break; - default: - continue; + } } + break; + default: + continue; } } - if (!iExitFlag) - continue; - // GPU fade-out - { - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_fade(mr, 0, 32); - menu_render_fade_wait(mr, fade_redraw_bg, mr); - palette_brightness = 0; - for (int i = 0; i < 256; i++) { - pal_addr[i].byR = 0; - pal_addr[i].byB = 0; - pal_addr[i].byG = 0; - } + } + if (!iExitFlag) + continue; + // GPU fade-out + { + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_fade(mr, 0, 32); + menu_render_fade_wait(mr, fade_redraw_bg, mr); + palette_brightness = 0; + for (int i = 0; i < 256; i++) { + pal_addr[i].byR = 0; + pal_addr[i].byB = 0; + pal_addr[i].byG = 0; } - front_fade = 0; - return; - case 4: - if (iConfigState != 5) - iVideoState = -1; + } + front_fade = 0; + return; + case 4: + if (iConfigState != 5) + iVideoState = -1; + if (iVideoState == 16) + byColor_31 = 0xAB; + else + byColor_31 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[6912], font1_ascii, + font1_offsets, 435, 60, byColor_31, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_PERSPECTIVE_CORRECTION) != 0) { + if (iVideoState == 16) + byColor_32 = 0xAB; + else + byColor_32 = 0x8F; + byTempChar1 = byColor_32; + szText_1 = &config_buffer[2688]; + } else { if (iVideoState == 16) - byColor_31 = 0xAB; + byColor_33 = 0xAB; else - byColor_31 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[6912], font1_ascii, font1_offsets, 435, 60, byColor_31, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_PERSPECTIVE_CORRECTION) != 0) { - if (iVideoState == 16) - byColor_32 = 0xAB; + byColor_33 = 0x8F; + byTempChar1 = byColor_33; + szText_1 = &config_buffer[2624]; + } + menu_render_scaled_text(mr, 15, szText_1, font1_ascii, font1_offsets, 440, + 60, byTempChar1, 0, 200, 640, pal_addr); + sprintf(buffer, "%s:", &config_buffer[3968]); + if (iVideoState == 15) + byColor_34 = 0xAB; + else + byColor_34 = 0x8F; + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 435, + 80, byColor_34, 2u, 200, 640, pal_addr); + if (names_on) { + if (names_on == 2) { + if (iVideoState == 15) + byColor_105 = 0xAB; else - byColor_32 = 0x8F; - byTempChar1 = byColor_32; - szText_1 = &config_buffer[2688]; + byColor_105 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2816], font1_ascii, + font1_offsets, 440, 80, byColor_105, 0, 200, + 640, pal_addr); } else { - if (iVideoState == 16) - byColor_33 = 0xAB; + if (iVideoState == 15) + byColor_35 = 0xAB; else - byColor_33 = 0x8F; - byTempChar1 = byColor_33; - szText_1 = &config_buffer[2624]; + byColor_35 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 80, byColor_35, 0, 200, + 640, pal_addr); } - menu_render_scaled_text(mr, 15, szText_1, font1_ascii, font1_offsets, 440, 60, byTempChar1, 0, 200, 640, pal_addr); - sprintf(buffer, "%s:", &config_buffer[3968]); + } else { if (iVideoState == 15) - byColor_34 = 0xAB; + byColor_36 = 0xAB; else - byColor_34 = 0x8F; - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 435, 80, byColor_34, 2u, 200, 640, pal_addr); - if (names_on) { - if (names_on == 2) { - if (iVideoState == 15) - byColor_105 = 0xAB; - else - byColor_105 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2816], font1_ascii, font1_offsets, 440, 80, byColor_105, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 15) - byColor_35 = 0xAB; - else - byColor_35 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 80, byColor_35, 0, 200, 640, pal_addr); - } - } else { - if (iVideoState == 15) - byColor_36 = 0xAB; - else - byColor_36 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 80, byColor_36, 0, 200, 640, pal_addr); - } + byColor_36 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 80, byColor_36, 0, 200, 640, + pal_addr); + } + if (iVideoState == 14) + byColor_37 = 0xAB; + else + byColor_37 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3008], font1_ascii, + font1_offsets, 435, 100, byColor_37, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_BUILDINGS) != 0) { if (iVideoState == 14) - byColor_37 = 0xAB; + byColor_38 = 0xAB; else - byColor_37 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3008], font1_ascii, font1_offsets, 435, 100, byColor_37, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_BUILDINGS) != 0) { - if (iVideoState == 14) - byColor_38 = 0xAB; - else - byColor_38 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 100, byColor_38, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 14) - byColor_39 = 0xAB; - else - byColor_39 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 100, byColor_39, 0, 200, 640, pal_addr); - } + byColor_38 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 100, byColor_38, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 14) + byColor_39 = 0xAB; + else + byColor_39 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 100, byColor_39, 0, 200, + 640, pal_addr); + } + if (iVideoState == 13) + byColor_40 = 0xAB; + else + byColor_40 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3072], font1_ascii, + font1_offsets, 435, 120, byColor_40, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_GLASS_WALLS) != 0) { if (iVideoState == 13) - byColor_40 = 0xAB; + byColor_41 = 0xAB; else - byColor_40 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3072], font1_ascii, font1_offsets, 435, 120, byColor_40, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_GLASS_WALLS) != 0) { - if (iVideoState == 13) - byColor_41 = 0xAB; - else - byColor_41 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 120, byColor_41, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 13) - byColor_42 = 0xAB; - else - byColor_42 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 120, byColor_42, 0, 200, 640, pal_addr); - } + byColor_41 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 120, byColor_41, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 13) + byColor_42 = 0xAB; + else + byColor_42 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 120, byColor_42, 0, 200, + 640, pal_addr); + } + if (iVideoState == 12) + byColor_43 = 0xAB; + else + byColor_43 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3200], font1_ascii, + font1_offsets, 435, 140, byColor_43, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_HORIZON) != 0) { if (iVideoState == 12) - byColor_43 = 0xAB; + byColor_44 = 0xAB; else - byColor_43 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3200], font1_ascii, font1_offsets, 435, 140, byColor_43, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_HORIZON) != 0) { - if (iVideoState == 12) - byColor_44 = 0xAB; - else - byColor_44 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 140, byColor_44, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 12) - byColor_45 = 0xAB; - else - byColor_45 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 140, byColor_45, 0, 200, 640, pal_addr); - } + byColor_44 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 140, byColor_44, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 12) + byColor_45 = 0xAB; + else + byColor_45 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 140, byColor_45, 0, 200, + 640, pal_addr); + } + if (iVideoState == 11) + byColor_46 = 0xAB; + else + byColor_46 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3136], font1_ascii, + font1_offsets, 435, 160, byColor_46, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_CAR_TEXTURES) != 0) { if (iVideoState == 11) - byColor_46 = 0xAB; + byColor_47 = 0xAB; else - byColor_46 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3136], font1_ascii, font1_offsets, 435, 160, byColor_46, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_CAR_TEXTURES) != 0) { - if (iVideoState == 11) - byColor_47 = 0xAB; - else - byColor_47 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 160, byColor_47, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 11) - byColor_48 = 0xAB; - else - byColor_48 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 160, byColor_48, 0, 200, 640, pal_addr); - } + byColor_47 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 160, byColor_47, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 11) + byColor_48 = 0xAB; + else + byColor_48 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 160, byColor_48, 0, 200, + 640, pal_addr); + } + if (iVideoState == 10) + byColor_49 = 0xAB; + else + byColor_49 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3264], font1_ascii, + font1_offsets, 435, 180, byColor_49, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0) { if (iVideoState == 10) - byColor_49 = 0xAB; + byColor_50 = 0xAB; else - byColor_49 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3264], font1_ascii, font1_offsets, 435, 180, byColor_49, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_WALL_TEXTURES) != 0) { - if (iVideoState == 10) - byColor_50 = 0xAB; - else - byColor_50 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 180, byColor_50, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 10) - byColor_51 = 0xAB; - else - byColor_51 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 180, byColor_51, 0, 200, 640, pal_addr); - } + byColor_50 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 180, byColor_50, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 10) + byColor_51 = 0xAB; + else + byColor_51 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 180, byColor_51, 0, 200, + 640, pal_addr); + } + if (iVideoState == 9) + byColor_52 = 0xAB; + else + byColor_52 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3328], font1_ascii, + font1_offsets, 435, 200, byColor_52, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0) { if (iVideoState == 9) - byColor_52 = 0xAB; + byColor_53 = 0xAB; else - byColor_52 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3328], font1_ascii, font1_offsets, 435, 200, byColor_52, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_GROUND_TEXTURES) != 0) { - if (iVideoState == 9) - byColor_53 = 0xAB; - else - byColor_53 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 200, byColor_53, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 9) - byColor_54 = 0xAB; - else - byColor_54 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 200, byColor_54, 0, 200, 640, pal_addr); - } + byColor_53 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 200, byColor_53, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 9) + byColor_54 = 0xAB; + else + byColor_54 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 200, byColor_54, 0, 200, + 640, pal_addr); + } + if (iVideoState == 8) + byColor_55 = 0xAB; + else + byColor_55 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3392], font1_ascii, + font1_offsets, 435, 220, byColor_55, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_BUILDING_TEXTURES) == 0) { if (iVideoState == 8) - byColor_55 = 0xAB; + byColor_56 = 0xAB; else - byColor_55 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3392], font1_ascii, font1_offsets, 435, 220, byColor_55, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_BUILDING_TEXTURES) == 0) { - if (iVideoState == 8) - byColor_56 = 0xAB; - else - byColor_56 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 220, byColor_56, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 8) - byColor_57 = 0xAB; - else - byColor_57 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 220, byColor_57, 0, 200, 640, pal_addr); - } + byColor_56 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 220, byColor_56, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 8) + byColor_57 = 0xAB; + else + byColor_57 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 220, byColor_57, 0, 200, + 640, pal_addr); + } + if (iVideoState == 7) + byColor_58 = 0xAB; + else + byColor_58 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3456], font1_ascii, + font1_offsets, 435, 240, byColor_58, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0) { if (iVideoState == 7) - byColor_58 = 0xAB; + byColor_59 = 0xAB; else - byColor_58 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3456], font1_ascii, font1_offsets, 435, 240, byColor_58, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_ROAD_TEXTURES) != 0) { - if (iVideoState == 7) - byColor_59 = 0xAB; - else - byColor_59 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 240, byColor_59, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 7) - byColor_60 = 0xAB; - else - byColor_60 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 240, byColor_60, 0, 200, 640, pal_addr); - } + byColor_59 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 240, byColor_59, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 7) + byColor_60 = 0xAB; + else + byColor_60 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 240, byColor_60, 0, 200, + 640, pal_addr); + } + if (iVideoState == 6) + byColor_61 = 0xAB; + else + byColor_61 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3520], font1_ascii, + font1_offsets, 435, 260, byColor_61, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_SHADOWS) != 0) { if (iVideoState == 6) - byColor_61 = 0xAB; + byColor_62 = 0xAB; else - byColor_61 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3520], font1_ascii, font1_offsets, 435, 260, byColor_61, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_SHADOWS) != 0) { - if (iVideoState == 6) - byColor_62 = 0xAB; - else - byColor_62 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 260, byColor_62, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 6) - byColor_63 = 0xAB; - else - byColor_63 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 260, byColor_63, 0, 200, 640, pal_addr); - } + byColor_62 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 260, byColor_62, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 6) + byColor_63 = 0xAB; + else + byColor_63 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 260, byColor_63, 0, 200, + 640, pal_addr); + } + if (iVideoState == 5) + byColor_64 = 0xAB; + else + byColor_64 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3584], font1_ascii, + font1_offsets, 435, 280, byColor_64, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_CLOUDS) != 0) { if (iVideoState == 5) - byColor_64 = 0xAB; + byColor_65 = 0xAB; else - byColor_64 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3584], font1_ascii, font1_offsets, 435, 280, byColor_64, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_CLOUDS) != 0) { - if (iVideoState == 5) - byColor_65 = 0xAB; - else - byColor_65 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 280, byColor_65, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 5) - byColor_66 = 0xAB; - else - byColor_66 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 280, byColor_66, 0, 200, 640, pal_addr); - } + byColor_65 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 280, byColor_65, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 5) + byColor_66 = 0xAB; + else + byColor_66 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 280, byColor_66, 0, 200, + 640, pal_addr); + } + if (iVideoState == 4) + byColor_67 = 0xAB; + else + byColor_67 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3648], font1_ascii, + font1_offsets, 435, 300, byColor_67, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_PANEL_OFF) != 0) { if (iVideoState == 4) - byColor_67 = 0xAB; + byColor_68 = 0xAB; else - byColor_67 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3648], font1_ascii, font1_offsets, 435, 300, byColor_67, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_PANEL_OFF) != 0) { - if (iVideoState == 4) - byColor_68 = 0xAB; - else - byColor_68 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 300, byColor_68, 0, 200, 640, pal_addr); - } else if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) { - if (iVideoState == 4) - byColor_69 = 0xAB; - else - byColor_69 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3776], font1_ascii, font1_offsets, 440, 300, byColor_69, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 4) - byColor_70 = 0xAB; - else - byColor_70 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 300, byColor_70, 0, 200, 640, pal_addr); - } + byColor_68 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 300, byColor_68, 0, 200, + 640, pal_addr); + } else if ((textures_off & TEX_OFF_PANEL_RESTRICTED) != 0) { + if (iVideoState == 4) + byColor_69 = 0xAB; + else + byColor_69 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3776], font1_ascii, + font1_offsets, 440, 300, byColor_69, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 4) + byColor_70 = 0xAB; + else + byColor_70 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 300, byColor_70, 0, 200, + 640, pal_addr); + } + if (iVideoState == 3) + byColor_71 = 0xAB; + else + byColor_71 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3712], font1_ascii, + font1_offsets, 435, 320, byColor_71, 2u, 200, 640, + pal_addr); + if (view_limit) { if (iVideoState == 3) - byColor_71 = 0xAB; + byColor_72 = 0xAB; else - byColor_71 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3712], font1_ascii, font1_offsets, 435, 320, byColor_71, 2u, 200, 640, pal_addr); - if (view_limit) { - if (iVideoState == 3) - byColor_72 = 0xAB; - else - byColor_72 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3776], font1_ascii, font1_offsets, 440, 320, byColor_72, 0, 200, 640, pal_addr); - } else { - if (iVideoState == 3) - byColor_73 = 0xAB; - else - byColor_73 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3840], font1_ascii, font1_offsets, 440, 320, byColor_73, 0, 200, 640, pal_addr); - } - if (iVideoState == 2) - byColor_74 = 0xAB; + byColor_72 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3776], font1_ascii, + font1_offsets, 440, 320, byColor_72, 0, 200, + 640, pal_addr); + } else { + if (iVideoState == 3) + byColor_73 = 0xAB; else - byColor_74 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[3904], font1_ascii, font1_offsets, 435, 340, byColor_74, 2u, 200, 640, pal_addr); - if (game_svga) - iReturnValue = (100 * game_size) >> 7; - //iReturnValue = (100 * game_size) % 128; - //iReturnValue = (100 * game_size - (__CFSHL__((100 * game_size) >> 31, 7) + ((100 * game_size) >> 31 << 7))) >> 7; + byColor_73 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3840], font1_ascii, + font1_offsets, 440, 320, byColor_73, 0, 200, + 640, pal_addr); + } + if (iVideoState == 2) + byColor_74 = 0xAB; + else + byColor_74 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[3904], font1_ascii, + font1_offsets, 435, 340, byColor_74, 2u, 200, 640, + pal_addr); + if (game_svga) + iReturnValue = (100 * game_size) >> 7; + // iReturnValue = (100 * game_size) % 128; + // iReturnValue = (100 * game_size - (__CFSHL__((100 * game_size) >> 31, + // 7) + ((100 * game_size) >> 31 << 7))) >> 7; + else + iReturnValue = (100 * game_size) >> 6; + // iReturnValue = (100 * game_size) % 64; + // iReturnValue = (100 * game_size - (__CFSHL__((100 * game_size) >> 31, + // 6) + ((100 * game_size) >> 31 << 6))) >> 6; + sprintf(buffer, "%i %%", iReturnValue); + if (iVideoState == 2) + byColor_76 = 0xAB; + else + byColor_76 = 0x8F; + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 440, + 340, byColor_76, 0, 200, 640, pal_addr); + if (game_svga) { + if (iVideoState == 1) + byColor_75 = 0xAB; else - iReturnValue = (100 * game_size) >> 6; - //iReturnValue = (100 * game_size) % 64; - //iReturnValue = (100 * game_size - (__CFSHL__((100 * game_size) >> 31, 6) + ((100 * game_size) >> 31 << 6))) >> 6; - sprintf(buffer, "%i %%", iReturnValue); - if (iVideoState == 2) - byColor_76 = 0xAB; + byColor_75 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[512], font1_ascii, + font1_offsets, 440, 360, byColor_75, 1u, 20, + 640, pal_addr); + } else { + if (iVideoState == 1) + byColor_77 = 0xAB; else - byColor_76 = 0x8F; - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 440, 340, byColor_76, 0, 200, 640, pal_addr); - if (game_svga) { - if (iVideoState == 1) - byColor_75 = 0xAB; - else - byColor_75 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[512], font1_ascii, font1_offsets, 440, 360, byColor_75, 1u, 20, 640, pal_addr); - } else { - if (iVideoState == 1) - byColor_77 = 0xAB; - else - byColor_77 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[448], font1_ascii, font1_offsets, 440, 360, byColor_77, 1u, 200, 640, pal_addr); - } - if (iVideoState) - byColor_78 = 0x8F; + byColor_77 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[448], font1_ascii, + font1_offsets, 440, 360, byColor_77, 1u, 200, + 640, pal_addr); + } + if (iVideoState) + byColor_78 = 0x8F; + else + byColor_78 = 0xAB; + menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, + font1_offsets, 430, 380, byColor_78, 2u, 200, 640, + pal_addr); + goto RENDER_FRAME; + case 5: + if (iConfigState != 6) + iGraphicsState = -1; + if (player_type == 2) { + sprintf(buffer, "%s %s", &config_buffer[4480], &config_buffer[4864]); + if (iGraphicsState == 6) + byColor_79 = 0xAB; else - byColor_78 = 0xAB; - menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, 430, 380, byColor_78, 2u, 200, 640, pal_addr); - goto RENDER_FRAME; - case 5: - if (iConfigState != 6) - iGraphicsState = -1; - if (player_type == 2) { - sprintf(buffer, "%s %s", &config_buffer[4480], &config_buffer[4864]); - if (iGraphicsState == 6) - byColor_79 = 0xAB; - else - byColor_79 = 0x8F; - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 435, 78, byColor_79, 2u, 200, 640, pal_addr); - if (iGraphicsState == 6) - byColor_80 = 0xAB; - else - byColor_80 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[64 * game_view[1] + 4928], font1_ascii, font1_offsets, 440, 78, byColor_80, 0, 200, 640, pal_addr); - } - sprintf(buffer, "%s %s", &config_buffer[4416], &config_buffer[4864]); - if (iGraphicsState == 5) - byColor_81 = 0xAB; + byColor_79 = 0x8F; + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 435, + 78, byColor_79, 2u, 200, 640, pal_addr); + if (iGraphicsState == 6) + byColor_80 = 0xAB; else - byColor_81 = 0x8F; - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 435, 96, byColor_81, 2u, 200, 640, pal_addr); - if (iGraphicsState == 5) - byColor_82 = 0xAB; + byColor_80 = 0x8F; + menu_render_scaled_text( + mr, 15, &config_buffer[64 * game_view[1] + 4928], font1_ascii, + font1_offsets, 440, 78, byColor_80, 0, 200, 640, pal_addr); + } + sprintf(buffer, "%s %s", &config_buffer[4416], &config_buffer[4864]); + if (iGraphicsState == 5) + byColor_81 = 0xAB; + else + byColor_81 = 0x8F; + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 435, + 96, byColor_81, 2u, 200, 640, pal_addr); + if (iGraphicsState == 5) + byColor_82 = 0xAB; + else + byColor_82 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[64 * game_view[0] + 4928], + font1_ascii, font1_offsets, 440, 96, byColor_82, + 0, 200, 640, pal_addr); + if (iGraphicsState == 4) + byColor_83 = 0xAB; + else + byColor_83 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[5440], font1_ascii, + font1_offsets, 435, 114, byColor_83, 2u, 200, 640, + pal_addr); + if ((textures_off & TEX_OFF_KMH) != 0) { + if (iGraphicsState == 4) + byColor_84 = 0xAB; else - byColor_82 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[64 * game_view[0] + 4928], font1_ascii, font1_offsets, 440, 96, byColor_82, 0, 200, 640, pal_addr); + byColor_84 = 0x8F; + menu_render_scaled_text(mr, 15, "KMH", font1_ascii, font1_offsets, 440, + 114, byColor_84, 0, 200, 640, pal_addr); + } else { if (iGraphicsState == 4) - byColor_83 = 0xAB; + byColor_85 = 0xAB; else - byColor_83 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[5440], font1_ascii, font1_offsets, 435, 114, byColor_83, 2u, 200, 640, pal_addr); - if ((textures_off & TEX_OFF_KMH) != 0) { - if (iGraphicsState == 4) - byColor_84 = 0xAB; - else - byColor_84 = 0x8F; - menu_render_scaled_text(mr, 15, "KMH", font1_ascii, font1_offsets, 440, 114, byColor_84, 0, 200, 640, pal_addr); - } else { - if (iGraphicsState == 4) - byColor_85 = 0xAB; - else - byColor_85 = 0x8F; - menu_render_scaled_text(mr, 15, "MPH", font1_ascii, font1_offsets, 440, 114, byColor_85, 0, 200, 640, pal_addr); - } + byColor_85 = 0x8F; + menu_render_scaled_text(mr, 15, "MPH", font1_ascii, font1_offsets, 440, + 114, byColor_85, 0, 200, 640, pal_addr); + } + if (iGraphicsState == 3) + byColor_86 = 0xAB; + else + byColor_86 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[5504], font1_ascii, + font1_offsets, 435, 132, byColor_86, 2u, 200, 640, + pal_addr); + if (replay_record) { if (iGraphicsState == 3) - byColor_86 = 0xAB; - else - byColor_86 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[5504], font1_ascii, font1_offsets, 435, 132, byColor_86, 2u, 200, 640, pal_addr); - if (replay_record) { - if (iGraphicsState == 3) - byColor_87 = 0xAB; - else - byColor_87 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 132, byColor_87, 0, 200, 640, pal_addr); - } else { - if (iGraphicsState == 3) - byColor_88 = 0xAB; - else - byColor_88 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 132, byColor_88, 0, 200, 640, pal_addr); - } - if (iGraphicsState == 2) - byColor_89 = 0xAB; - else - byColor_89 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[4672], font1_ascii, font1_offsets, 435, 150, byColor_89, 2u, 200, 640, pal_addr); - if (p_tex_size == 1) { - if (iGraphicsState == 2) - byColor_90 = 0xAB; - else - byColor_90 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[4736], font1_ascii, font1_offsets, 440, 150, byColor_90, 0, 200, 640, pal_addr); - } else { - if (iGraphicsState == 2) - byColor_91 = 0xAB; - else - byColor_91 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[4800], font1_ascii, font1_offsets, 440, 150, byColor_91, 0, 200, 640, pal_addr); - } - if (iGraphicsState == 1) - byColor_92 = 0xAB; - else - byColor_92 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[5888], font1_ascii, font1_offsets, 435, 168, byColor_92, 2u, 200, 640, pal_addr); - if (false_starts) { - if (iGraphicsState == 1) - byColor_93 = 0xAB; - else - byColor_93 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, font1_offsets, 440, 168, byColor_93, 0, 200, 640, pal_addr); - } else { - if (iGraphicsState == 1) - byColor_94 = 0xAB; - else - byColor_94 = 0x8F; - menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, font1_offsets, 440, 168, byColor_94, 0, 200, 640, pal_addr); - } - if (iGraphicsState) - byColor_95 = 0x8F; - else - byColor_95 = 0xAB; - menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, 430, 186, byColor_95, 2u, 200, 640, pal_addr); - goto RENDER_FRAME; - case 6: - if (iEditingName == 1) { - byColor_96 = 0xAB; - byColor_97 = 0xA5; - } else { - byColor_96 = 0xA5; - byColor_97 = 0xAB; - } - if (iConfigState != 7) { - byColor_96 = 0x8F; - byColor_97 = 0x8F; - } - if (iEditingName == 1) { - iTextPosX = 0; - for (szMemPtr = network_messages[4 - iNetworkState]; *szMemPtr; ++szMemPtr) { - iFontChar = (uint8)font1_ascii[(uint8)*szMemPtr]; - if (iFontChar == 255) - iTextPosX += 8; - else - iTextPosX += front_vga[15][iFontChar].iWidth + 1; - } - iTextPosX += 390; - iY = 140 - 18 * iNetworkState; - } - if (iNetworkState == 5) - byColor_106 = byColor_97; - else - byColor_106 = 0x8F; - menu_render_text(mr, 15, &language_buffer[7296], font1_ascii, font1_offsets, 390, 50, byColor_106, 1u, pal_addr); - if (iNetworkState == 4) - byColor_98 = byColor_97; + byColor_87 = 0xAB; else - byColor_98 = 0x8F; - menu_render_text(mr, 15, &config_buffer[5632], font1_ascii, font1_offsets, 385, 68, byColor_98, 2u, pal_addr); - if (iNetworkState == 4) - byColor_99 = byColor_96; - else - byColor_99 = 0x8F; - menu_render_scaled_text(mr, 15, network_messages[0], font1_ascii, font1_offsets, 390, 68, byColor_99, 0, 200, 630, pal_addr); - if (iNetworkState == 3) - byColor_100 = byColor_97; + byColor_87 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 132, byColor_87, 0, 200, + 640, pal_addr); + } else { + if (iGraphicsState == 3) + byColor_88 = 0xAB; else - byColor_100 = 0x8F; - menu_render_text(mr, 15, &config_buffer[5696], font1_ascii, font1_offsets, 385, 86, byColor_100, 2u, pal_addr); - if (iNetworkState == 3) - byColor_101 = byColor_96; + byColor_88 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 132, byColor_88, 0, 200, + 640, pal_addr); + } + if (iGraphicsState == 2) + byColor_89 = 0xAB; + else + byColor_89 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[4672], font1_ascii, + font1_offsets, 435, 150, byColor_89, 2u, 200, 640, + pal_addr); + if (p_tex_size == 1) { + if (iGraphicsState == 2) + byColor_90 = 0xAB; else - byColor_101 = 0x8F; - menu_render_scaled_text(mr, 15, network_messages[1], font1_ascii, font1_offsets, 390, 86, byColor_101, 0, 200, 630, pal_addr); - if (iNetworkState == 2) - byColor_102 = byColor_97; + byColor_90 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[4736], font1_ascii, + font1_offsets, 440, 150, byColor_90, 0, 200, + 640, pal_addr); + } else { + if (iGraphicsState == 2) + byColor_91 = 0xAB; else - byColor_102 = 0x8F; - menu_render_text(mr, 15, &config_buffer[5760], font1_ascii, font1_offsets, 385, 104, byColor_102, 2u, pal_addr); - if (iNetworkState == 2) - byColor_103 = byColor_96; + byColor_91 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[4800], font1_ascii, + font1_offsets, 440, 150, byColor_91, 0, 200, + 640, pal_addr); + } + if (iGraphicsState == 1) + byColor_92 = 0xAB; + else + byColor_92 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[5888], font1_ascii, + font1_offsets, 435, 168, byColor_92, 2u, 200, 640, + pal_addr); + if (false_starts) { + if (iGraphicsState == 1) + byColor_93 = 0xAB; else - byColor_103 = 0x8F; - menu_render_scaled_text(mr, 15, network_messages[2], font1_ascii, font1_offsets, 390, 104, byColor_103, 0, 200, 630, pal_addr); - if (iNetworkState == 1) - byColor_104 = byColor_97; + byColor_93 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2624], font1_ascii, + font1_offsets, 440, 168, byColor_93, 0, 200, + 640, pal_addr); + } else { + if (iGraphicsState == 1) + byColor_94 = 0xAB; else - byColor_104 = 0x8F; - menu_render_text(mr, 15, &config_buffer[5824], font1_ascii, font1_offsets, 385, 122, byColor_104, 2u, pal_addr); - if (iNetworkState != 1) - byColor_96 = 0x8F; - byTempChar2 = byColor_96; - iNetworkState_1 = iNetworkState; - menu_render_scaled_text(mr, 15, network_messages[3], font1_ascii, font1_offsets, 390, 122, byTempChar2, 0, 200, 630, pal_addr); - if (iNetworkState_1) - byColor_97 = 0x8F; - menu_render_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, 390, 140, byColor_97, 1u, pal_addr); - if (iEditingName == 1 && (frames & 0xFu) < 8) { - iX = stringwidth(network_messages[4 - iNetworkState]) + 390; - if (iX <= 620) - menu_render_text(mr, 15, "_", font1_ascii, font1_offsets, iX, iY, 0xABu, 0, pal_addr); + byColor_94 = 0x8F; + menu_render_scaled_text(mr, 15, &config_buffer[2688], font1_ascii, + font1_offsets, 440, 168, byColor_94, 0, 200, + 640, pal_addr); + } + if (iGraphicsState) + byColor_95 = 0x8F; + else + byColor_95 = 0xAB; + menu_render_scaled_text(mr, 15, &config_buffer[832], font1_ascii, + font1_offsets, 430, 186, byColor_95, 2u, 200, 640, + pal_addr); + goto RENDER_FRAME; + case 6: + if (iEditingName == 1) { + byColor_96 = 0xAB; + byColor_97 = 0xA5; + } else { + byColor_96 = 0xA5; + byColor_97 = 0xAB; + } + if (iConfigState != 7) { + byColor_96 = 0x8F; + byColor_97 = 0x8F; + } + if (iEditingName == 1) { + iTextPosX = 0; + for (szMemPtr = network_messages[4 - iNetworkState]; *szMemPtr; + ++szMemPtr) { + iFontChar = (uint8)font1_ascii[(uint8)*szMemPtr]; + if (iFontChar == 255) + iTextPosX += 8; else - menu_render_text(mr, 15, "_", font1_ascii, font1_offsets, 621, iY, 0xABu, 0, pal_addr); + iTextPosX += front_vga[15][iFontChar].iWidth + 1; } - goto RENDER_FRAME; - default: - goto RENDER_FRAME; + iTextPosX += 390; + iY = 140 - 18 * iNetworkState; + } + if (iNetworkState == 5) + byColor_106 = byColor_97; + else + byColor_106 = 0x8F; + menu_render_text(mr, 15, &language_buffer[7296], font1_ascii, + font1_offsets, 390, 50, byColor_106, 1u, pal_addr); + if (iNetworkState == 4) + byColor_98 = byColor_97; + else + byColor_98 = 0x8F; + menu_render_text(mr, 15, &config_buffer[5632], font1_ascii, font1_offsets, + 385, 68, byColor_98, 2u, pal_addr); + if (iNetworkState == 4) + byColor_99 = byColor_96; + else + byColor_99 = 0x8F; + menu_render_scaled_text(mr, 15, network_messages[0], font1_ascii, + font1_offsets, 390, 68, byColor_99, 0, 200, 630, + pal_addr); + if (iNetworkState == 3) + byColor_100 = byColor_97; + else + byColor_100 = 0x8F; + menu_render_text(mr, 15, &config_buffer[5696], font1_ascii, font1_offsets, + 385, 86, byColor_100, 2u, pal_addr); + if (iNetworkState == 3) + byColor_101 = byColor_96; + else + byColor_101 = 0x8F; + menu_render_scaled_text(mr, 15, network_messages[1], font1_ascii, + font1_offsets, 390, 86, byColor_101, 0, 200, 630, + pal_addr); + if (iNetworkState == 2) + byColor_102 = byColor_97; + else + byColor_102 = 0x8F; + menu_render_text(mr, 15, &config_buffer[5760], font1_ascii, font1_offsets, + 385, 104, byColor_102, 2u, pal_addr); + if (iNetworkState == 2) + byColor_103 = byColor_96; + else + byColor_103 = 0x8F; + menu_render_scaled_text(mr, 15, network_messages[2], font1_ascii, + font1_offsets, 390, 104, byColor_103, 0, 200, 630, + pal_addr); + if (iNetworkState == 1) + byColor_104 = byColor_97; + else + byColor_104 = 0x8F; + menu_render_text(mr, 15, &config_buffer[5824], font1_ascii, font1_offsets, + 385, 122, byColor_104, 2u, pal_addr); + if (iNetworkState != 1) + byColor_96 = 0x8F; + byTempChar2 = byColor_96; + iNetworkState_1 = iNetworkState; + menu_render_scaled_text(mr, 15, network_messages[3], font1_ascii, + font1_offsets, 390, 122, byTempChar2, 0, 200, 630, + pal_addr); + if (iNetworkState_1) + byColor_97 = 0x8F; + menu_render_text(mr, 15, &config_buffer[832], font1_ascii, font1_offsets, + 390, 140, byColor_97, 1u, pal_addr); + if (iEditingName == 1 && (frames & 0xFu) < 8) { + iX = stringwidth(network_messages[4 - iNetworkState]) + 390; + if (iX <= 620) + menu_render_text(mr, 15, "_", font1_ascii, font1_offsets, iX, iY, + 0xABu, 0, pal_addr); + else + menu_render_text(mr, 15, "_", font1_ascii, font1_offsets, 621, iY, + 0xABu, 0, pal_addr); + } + goto RENDER_FRAME; + default: + goto RENDER_FRAME; } } } //------------------------------------------------------------------------------------------------- -//00046EA0 -void front_displaycalibrationbar(int iY, int iX, int iValue) -{ +// 00046EA0 +void front_displaycalibrationbar(int iY, int iX, int iValue) { int iClampedValue; // edi uint8 *pScreenPos; // ecx int iIndicatorPos; // edi - int i; // esi - int iScreenWidth; // ebp + int i; // esi + int iScreenWidth; // ebp iClampedValue = iValue; if (iValue < -100) @@ -2502,24 +2769,29 @@ void front_displaycalibrationbar(int iY, int iX, int iValue) } //------------------------------------------------------------------------------------------------- -//00046F40 -void front_volumebar(int iY, int iVolumeLevel, int iFillColor) -{ +// 00046F40 +void front_volumebar(int iY, int iVolumeLevel, int iFillColor) { uint8 *pbyScreenPos; // ecx - int iRow; // esi - int iScreenWidth; // eax - - pbyScreenPos = &scrbuf[winw * iY + 430]; // Calculate starting position in screen buffer (430 pixels from left edge) - for (iRow = 0; iRow < 17; ++iRow) // Draw 17 rows for the volume bar - { // Skip first and last row (draw border on those) + int iRow; // esi + int iScreenWidth; // eax + + pbyScreenPos = + &scrbuf[winw * iY + 430]; // Calculate starting position in screen buffer + // (430 pixels from left edge) + for (iRow = 0; iRow < 17; ++iRow) // Draw 17 rows for the volume bar + { // Skip first and last row (draw border on those) if (iRow && iRow != 16) { - *pbyScreenPos = 0x8F; // Draw left border (0x8F is white in PALETTE.PAL) - memset(pbyScreenPos + 1, iFillColor, 160 * iVolumeLevel / 127);// Fill volume bar based on level (160 * volume / 127 pixels wide) + *pbyScreenPos = 0x8F; // Draw left border (0x8F is white in PALETTE.PAL) + memset(pbyScreenPos + 1, iFillColor, + 160 * iVolumeLevel / 127); // Fill volume bar based on level (160 * + // volume / 127 pixels wide) iScreenWidth = winw; - pbyScreenPos[161] = 0x8F; // Draw right border (0x8F is white in PALETTE.PAL) + pbyScreenPos[161] = + 0x8F; // Draw right border (0x8F is white in PALETTE.PAL) pbyScreenPos += iScreenWidth; } else { - memset(pbyScreenPos, 0x8F, 0xA2u); // Draw top/bottom border - fill entire width (162 pixels) with border color + memset(pbyScreenPos, 0x8F, 0xA2u); // Draw top/bottom border - fill entire + // width (162 pixels) with border color pbyScreenPos += winw; } } diff --git a/PROJECTS/ROLLER/frontend_data.c b/PROJECTS/ROLLER/frontend_data.c index 19ed8e3f..84e327cc 100644 --- a/PROJECTS/ROLLER/frontend_data.c +++ b/PROJECTS/ROLLER/frontend_data.c @@ -25,510 +25,353 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -//symbol names added by ROLLER -char szSelectEng[] = "select.eng"; //000A1980 -char szConfigEng[] = "config.eng"; //000A198C -//char szFArielRaw[] = "FARIEL.RAW"; //000A1A70 -//char szFDesilvaRaw[] = "FDESILVA.RAW"; //000A1A7C -//char szFPulseRaw[] = "FPULSE.RAW"; //000A1A8C -//char szFGlobalRaw[] = "FGLOBAL.RAW"; //000A1A98 -//char szFMillionRaw[] = "FMILLION.RAW"; //000A1AA4 -//char szFMissionRaw[] = "FMISSION.RAW"; //000A1AB4 -//char szFZizinRaw[] = "FZIZIN.RAW"; //000A1AC4 -//char szFReiseRaw[] = "FREISE.RAW"; //000A1AD0 +// symbol names added by ROLLER +char szSelectEng[] = "select.eng"; // 000A1980 +char szConfigEng[] = "config.eng"; // 000A198C +// char szFArielRaw[] = "FARIEL.RAW"; //000A1A70 +// char szFDesilvaRaw[] = "FDESILVA.RAW"; //000A1A7C +// char szFPulseRaw[] = "FPULSE.RAW"; //000A1A8C +// char szFGlobalRaw[] = "FGLOBAL.RAW"; //000A1A98 +// char szFMillionRaw[] = "FMILLION.RAW"; //000A1AA4 +// char szFMissionRaw[] = "FMISSION.RAW"; //000A1AB4 +// char szFZizinRaw[] = "FZIZIN.RAW"; //000A1AC4 +// char szFReiseRaw[] = "FREISE.RAW"; //000A1AD0 //------------------------------------------------------------------------------------------------- -int false_starts = -1; //000A4AB8 -float TrackZs[25] = //000A4A54 -{ - 400000.0, 800000.0, 400000.0, 500000.0, 400000.0, - 400000.0, 500000.0, 500000.0, 400000.0, 400000.0, - 400000.0, 800000.0, 800000.0, 800000.0, 800000.0, - 800000.0, 800000.0, 800000.0, 400000.0, 500000.0, - 400000.0, 400000.0, 500000.0, 500000.0, 400000.0 -}; -int death_race = 0; //000A4ABC -int head_x = 186; //000A4AC0 -int head_y = 8; //000A4AC4 -char network_messages[5][14] = { //000A4AC8 - "SLOWCOACH", - "OUT OF MY WAY", - "YOU DIE", - "SUCKER", - "I WON!" -}; -int competitors = 16; //000A4B70 -int manual_control[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; //000A4B74 -int smallcars[2][16] = //000A4BB4 -{ - { 1, 2, 3, 6, 4, 5, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 12, 13, 14, 15, 16, 17, 18, 19, 1, 1, 1, 1, 1, 1, 1, 1 } -}; -int infinite_laps = 0; //000A4C34 -int Players_Cars[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }; //000A4C38 -int points[16] = { 25, 18, 16, 14, 12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; //000A4C78 -int player_type = 0; //000A4CB8 -int cup_won = 0; //000A4CBC -int game_type = 0; //000A4CC0 -int car_pies[112] = //000A4CC4 -{ - 4, 5, 3, 4, 3, 6, 4, - 1, 8, 2, 3, 4, 4, 8, - 5, 3, 4, 2, 7, 5, 4, - 6, 2, 7, 6, 6, 1, 2, - 7, 7, 6, 7, 1, 8, 3, - 2, 6, 1, 4, 2, 7, 7, - 3, 4, 5, 1, 8, 3, 4, - 8, 1, 8, 7, 5, 2, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1 -}; -int track_laps[25][6] = //000A4E84 -{ - { 12, 10, 8, 6, 4, 2 }, - { 10, 8, 7, 5, 4, 2 }, - { 18, 15, 12, 10, 7, 4 }, - { 15, 13, 10, 8, 5, 3 }, - { 18, 15, 12, 10, 7, 4 }, - { 23, 19, 16, 12, 9, 5 }, - { 15, 13, 10, 8, 5, 3 }, - { 15, 13, 10, 8, 5, 3 }, - { 17, 14, 11, 9, 6, 3 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 }, - { 12, 10, 8, 6, 4, 2 } -}; -char race_posn[16][5] = //000A5200 -{ - " 1st", - " 2nd", - " 3rd", - " 4th", - " 5th", - " 6th", - " 7th", - " 8th", - " 9th", - "10th", - "11th", - "12th", - "13th", - "14th", - "15th", - "last" -}; -int Selected_Drives[9] = { 0, 2, 0, 5, 3, 4, 1, 0, 6 }; //000A5250 -int Selected_Play[9] = { 0, 0, 2, 0, 0, 0, 0, 1, 0 }; //000A5274 -int DuoViews[9] = { -1, -1, 0, -1, 0, 0, 0, 0, 0 }; //000A5298 -int AllowedViews[9] = { -1, -1, -1, -1, 0, 0, 0, -1, 0 }; //000A52BC -int ReplayViews[9] = { -1, -1, -1, -1, -1, 0, -1, -1, 0 }; //000A52E0 -int replay_record = 1; //000A5304 -int last_replay = -1; //000A5308 -int last_type = 0; //000A530C -int SelectedView[2] = { 0, 0 }; //000A5310 -int network_champ_on = 0; //000A5318 -void *font_vga = NULL; //000A531C -void *title_vga = NULL; //000A5320 -tBlockHeader *front_vga[16] = { NULL }; //000A5324 -int font1_offsets[104] = //000A5364 -{ - 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, 0, 0, - 0, -2, 0, 0, 0, 0, 0, 0, -2, -2, 0, 0, - -2, -2, 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, - 0, 0, 0, 0, 0, 0, -2, 0, -1, -4, 0, -4, - 0, -4, -4, -4, -4, -4, -5, 0, -4, -4, -4, - -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, 0, - -4, 0, -4, -4, -4, -4, -4, 0, 0, 0 -}; -char font1_ascii[256] = //000A5504 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3E, 0x27, 0x28, 0x2A, 0x3D, - 0x2C, 0x2D, 0x2B, 0x2F, 0x3F, 0x38, 0x40, 0x41, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x32, 0x3C, - 0x35, 0x39, 0x36, 0x37, 0x33, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x3A, 0x43, 0x3B, 0x29, 0x2E, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x30, 0x42, 0x31, 0x34, 0xFF, 0x67, 0xFF, - 0xFF, 0x4B, 0x4D, 0x4A, 0x4C, 0xFF, 0x52, 0x53, 0x50, 0x57, - 0x56, 0x54, 0x4D, 0x4E, 0x51, 0x4F, 0x4F, 0x5A, 0x5C, 0x5A, - 0x62, 0x61, 0x47, 0x5B, 0x63, 0xFF, 0x26, 0xFF, 0xFF, 0x44, - 0x49, 0x55, 0x58, 0x60, 0x5E, 0x5E, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x45, 0x46, 0x5D, 0x64, 0x65, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x66, 0xFF, 0xFF, 0xFF, 0xFF, - 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5F, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -int font2_offsets[96] = //000A5604 -{ - 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, 0, 0, - 0, -1, 0, 0, 0, -2, 0, 0, -2, -2, 0, 0, - 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0, -1, - 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, - -2, -2, -2, -2, -2, -2, -2, -2, -2, 0, 0, 0, - -2, -2, -2, -3, -2, -2, 0, 0, 0, 0, 0, 0 -}; -char font2_ascii[256] = //000A5784 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3C, 0x27, 0x28, 0x2A, 0x3B, - 0x2C, 0x2D, 0x2B, 0x2F, 0x37, 0x3F, 0x38, 0x39, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x5A, 0x3A, - 0x36, 0x40, 0x35, 0x34, 0x31, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x3D, 0xFF, 0x3E, 0x29, 0x2E, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x32, 0xFF, 0x33, 0x30, 0xFF, 0x42, 0xFF, - 0xFF, 0x44, 0x46, 0x43, 0xFF, 0xFF, 0xFF, 0x48, 0x59, 0x4A, - 0xFF, 0x4B, 0xFF, 0xFF, 0x49, 0xFF, 0x41, 0x4E, 0x50, 0x4C, - 0x56, 0x58, 0xFF, 0xFF, 0x57, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x45, 0x49, 0x4F, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0x54, 0x53, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x51, 0xFF, 0xFF, 0xFF, 0xFF, - 0x52, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -int font3_offsets[72] = //000A5884 -{ - 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, 0, 0, - -1, -6, 0, -6, 0, -6, -6, -6, -6, -6, -7, 0, - 0, -6, -6, -6, -6, -6, -6, -6, -6, 0, -6, -6, - -6, -6, -6, -6, 0, -6, -6, -6, -6, -6, 0, 0 -}; -char font3_ascii[256] = //000A59A4 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0xFF, - 0xFF, 0x2B, 0x2D, 0x2A, 0x2C, 0xFF, 0x33, 0x34, 0x32, 0x38, - 0x37, 0x35, 0x2D, 0x2E, 0x31, 0x2F, 0x2F, 0x3D, 0x3F, 0x3C, - 0x43, 0x42, 0x27, 0x3E, 0x44, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x29, 0x36, 0x3B, 0x41, 0x3A, 0x3A, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x25, 0x26, 0x39, 0x45, 0x46, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, - 0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -int font4_offsets[80] = //000A5AA4 -{ - 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, 0, 0, - 0, 0, -5, 0, 0, 0, 0, 0, -7, 0, 0, -6, - 0, -7, -7, -7, -7, -7, -10, 0, -7, -7, -7, -7, - -7, -7, -7, -7, -7, -1, -7, -7, -7, -7, -7, 0, - -7, -7, -6, -6, -6, 0, 0, 0 -}; -int font5_offsets[80] = //000A5BE4 -{ - 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, 0, 0, - 0, 0, -2, 0, 0, 0, 0, 0, -5, 0, 0, -5, - 0, -5, -5, -5, -5, -5, -7, 0, -5, -5, -5, -5, - -5, -5, -5, -5, -5, -1, -5, -5, -5, -5, -5, 0, - -5, -5, -5, -5, -5, 0, 0, 0 -}; -char font4_ascii[256] = //000A5D24 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x29, 0x24, 0x2A, 0x25, 0xFF, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x27, 0xFF, - 0xFF, 0x2B, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0xFF, 0xFF, 0xFF, 0x26, 0x28, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x33, 0x36, 0x32, 0x34, 0xFF, 0x3A, 0x3B, 0x39, 0x3F, - 0x3E, 0x3C, 0x35, 0x36, 0x38, 0x37, 0x37, 0x4A, 0x4C, 0x48, - 0x44, 0xFF, 0x2F, 0x4B, 0x45, 0xFF, 0xFF, 0xFF, 0xFF, 0x2D, - 0x31, 0x3D, 0x49, 0x42, 0x40, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x2C, 0x2E, 0xFF, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, - 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; +int false_starts = -1; // 000A4AB8 +float TrackZs[25] = // 000A4A54 + {400000.0, 800000.0, 400000.0, 500000.0, 400000.0, 400000.0, 500000.0, + 500000.0, 400000.0, 400000.0, 400000.0, 800000.0, 800000.0, 800000.0, + 800000.0, 800000.0, 800000.0, 800000.0, 400000.0, 500000.0, 400000.0, + 400000.0, 500000.0, 500000.0, 400000.0}; +int death_race = 0; // 000A4ABC +int head_x = 186; // 000A4AC0 +int head_y = 8; // 000A4AC4 +char network_messages[5][14] = { // 000A4AC8 + "SLOWCOACH", "OUT OF MY WAY", "YOU DIE", "SUCKER", "I WON!"}; +int competitors = 16; // 000A4B70 +int manual_control[16] = {1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1}; // 000A4B74 +int smallcars[2][16] = // 000A4BB4 + {{1, 2, 3, 6, 4, 5, 7, 8, 1, 1, 1, 1, 1, 1, 1, 1}, + {12, 13, 14, 15, 16, 17, 18, 19, 1, 1, 1, 1, 1, 1, 1, 1}}; +int infinite_laps = 0; // 000A4C34 +int Players_Cars[16] = {0, 0, 1, 1, 2, 2, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7}; // 000A4C38 +int points[16] = {25, 18, 16, 14, 12, 10, 9, 8, + 7, 6, 5, 4, 3, 2, 1, 0}; // 000A4C78 +int player_type = 0; // 000A4CB8 +int cup_won = 0; // 000A4CBC +int game_type = 0; // 000A4CC0 +int car_pies[112] = // 000A4CC4 + {4, 5, 3, 4, 3, 6, 4, 1, 8, 2, 3, 4, 4, 8, 5, 3, 4, 2, 7, 5, 4, 6, 2, + 7, 6, 6, 1, 2, 7, 7, 6, 7, 1, 8, 3, 2, 6, 1, 4, 2, 7, 7, 3, 4, 5, 1, + 8, 3, 4, 8, 1, 8, 7, 5, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +int track_laps[25][6] = // 000A4E84 + {{12, 10, 8, 6, 4, 2}, {10, 8, 7, 5, 4, 2}, {18, 15, 12, 10, 7, 4}, + {15, 13, 10, 8, 5, 3}, {18, 15, 12, 10, 7, 4}, {23, 19, 16, 12, 9, 5}, + {15, 13, 10, 8, 5, 3}, {15, 13, 10, 8, 5, 3}, {17, 14, 11, 9, 6, 3}, + {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, + {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, + {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, + {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, + {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, {12, 10, 8, 6, 4, 2}, + {12, 10, 8, 6, 4, 2}}; +char race_posn[16][5] = // 000A5200 + {" 1st", " 2nd", " 3rd", " 4th", " 5th", " 6th", " 7th", " 8th", + " 9th", "10th", "11th", "12th", "13th", "14th", "15th", "last"}; +int Selected_Drives[9] = {0, 2, 0, 5, 3, 4, 1, 0, 6}; // 000A5250 +int Selected_Play[9] = {0, 0, 2, 0, 0, 0, 0, 1, 0}; // 000A5274 +int DuoViews[9] = {-1, -1, 0, -1, 0, 0, 0, 0, 0}; // 000A5298 +int AllowedViews[9] = {-1, -1, -1, -1, 0, 0, 0, -1, 0}; // 000A52BC +int ReplayViews[9] = {-1, -1, -1, -1, -1, 0, -1, -1, 0}; // 000A52E0 +int replay_record = 1; // 000A5304 +int last_replay = -1; // 000A5308 +int last_type = 0; // 000A530C +int SelectedView[2] = {0, 0}; // 000A5310 +int network_champ_on = 0; // 000A5318 +void *font_vga = NULL; // 000A531C +void *title_vga = NULL; // 000A5320 +tBlockHeader *front_vga[16] = {NULL}; // 000A5324 +int font1_offsets[104] = // 000A5364 + {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, 0, 0, + 0, -2, 0, 0, 0, 0, 0, 0, -2, -2, 0, 0, -2, -2, 0, 0, 0, 0, + 0, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, -2, 0, -1, -4, 0, -4, + 0, -4, -4, -4, -4, -4, -5, 0, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, + -4, -4, -4, 0, -4, 0, -4, -4, -4, -4, -4, 0, 0, 0}; +char font1_ascii[256] = // 000A5504 + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3E, + 0x27, 0x28, 0x2A, 0x3D, 0x2C, 0x2D, 0x2B, 0x2F, 0x3F, 0x38, 0x40, 0x41, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x32, 0x3C, + 0x35, 0x39, 0x36, 0x37, 0x33, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x3A, 0x43, 0x3B, 0x29, 0x2E, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x30, 0x42, 0x31, 0x34, 0xFF, 0x67, 0xFF, 0xFF, 0x4B, + 0x4D, 0x4A, 0x4C, 0xFF, 0x52, 0x53, 0x50, 0x57, 0x56, 0x54, 0x4D, 0x4E, + 0x51, 0x4F, 0x4F, 0x5A, 0x5C, 0x5A, 0x62, 0x61, 0x47, 0x5B, 0x63, 0xFF, + 0x26, 0xFF, 0xFF, 0x44, 0x49, 0x55, 0x58, 0x60, 0x5E, 0x5E, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x45, 0x46, 0x5D, 0x64, 0x65, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x66, 0xFF, 0xFF, + 0xFF, 0xFF, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5F, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; +int font2_offsets[96] = // 000A5604 + {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, 0, 0, 0, -1, 0, 0, 0, -2, 0, 0, -2, -2, 0, 0, + 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, + 0, 0, 0, -2, -2, -2, -2, 0, -2, -2, -2, -2, -2, -2, -2, -2, + -2, 0, 0, 0, -2, -2, -2, -3, -2, -2, 0, 0, 0, 0, 0, 0}; +char font2_ascii[256] = // 000A5784 + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3C, + 0x27, 0x28, 0x2A, 0x3B, 0x2C, 0x2D, 0x2B, 0x2F, 0x37, 0x3F, 0x38, 0x39, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x5A, 0x3A, + 0x36, 0x40, 0x35, 0x34, 0x31, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x3D, 0xFF, 0x3E, 0x29, 0x2E, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x32, 0xFF, 0x33, 0x30, 0xFF, 0x42, 0xFF, 0xFF, 0x44, + 0x46, 0x43, 0xFF, 0xFF, 0xFF, 0x48, 0x59, 0x4A, 0xFF, 0x4B, 0xFF, 0xFF, + 0x49, 0xFF, 0x41, 0x4E, 0x50, 0x4C, 0x56, 0x58, 0xFF, 0xFF, 0x57, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x45, 0x49, 0x4F, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x47, 0x54, 0x53, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x51, 0xFF, 0xFF, + 0xFF, 0xFF, 0x52, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; +int font3_offsets[72] = // 000A5884 + {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, 0, 0, + -1, -6, 0, -6, 0, -6, -6, -6, -6, -6, -7, 0, 0, -6, -6, -6, -6, -6, + -6, -6, -6, 0, -6, -6, -6, -6, -6, -6, 0, -6, -6, -6, -6, -6, 0, 0}; +char font3_ascii[256] = // 000A59A4 + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0xFF, 0xFF, 0x2B, + 0x2D, 0x2A, 0x2C, 0xFF, 0x33, 0x34, 0x32, 0x38, 0x37, 0x35, 0x2D, 0x2E, + 0x31, 0x2F, 0x2F, 0x3D, 0x3F, 0x3C, 0x43, 0x42, 0x27, 0x3E, 0x44, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x29, 0x36, 0x3B, 0x41, 0x3A, 0x3A, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x25, 0x26, 0x39, 0x45, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, + 0xFF, 0xFF, 0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; +int font4_offsets[80] = // 000A5AA4 + {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, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, -7, 0, 0, -6, + 0, -7, -7, -7, -7, -7, -10, 0, -7, -7, -7, -7, -7, -7, -7, -7, + -7, -1, -7, -7, -7, -7, -7, 0, -7, -7, -6, -6, -6, 0, 0, 0}; +int font5_offsets[80] = // 000A5BE4 + {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, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, -5, 0, 0, -5, + 0, -5, -5, -5, -5, -5, -7, 0, -5, -5, -5, -5, -5, -5, -5, -5, + -5, -1, -5, -5, -5, -5, -5, 0, -5, -5, -5, -5, -5, 0, 0, 0}; +char font4_ascii[256] = // 000A5D24 + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x29, 0x24, 0x2A, 0x25, 0xFF, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x27, 0xFF, + 0xFF, 0x2B, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0x26, 0x28, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x33, + 0x36, 0x32, 0x34, 0xFF, 0x3A, 0x3B, 0x39, 0x3F, 0x3E, 0x3C, 0x35, 0x36, + 0x38, 0x37, 0x37, 0x4A, 0x4C, 0x48, 0x44, 0xFF, 0x2F, 0x4B, 0x45, 0xFF, + 0xFF, 0xFF, 0xFF, 0x2D, 0x31, 0x3D, 0x49, 0x42, 0x40, 0x40, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x2C, 0x2E, 0xFF, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, + 0xFF, 0xFF, 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; char font1_ascii_br[256] = // Fatal Brazilian/Saspanish - object_3_variable_1644 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3E, 0x27, 0x28, 0x2A, 0x3D, - 0x2C, 0x2D, 0x2B, 0x2F, 0x3F, 0x38, 0x40, 0x41, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x32, 0x3C, - 0x35, 0x39, 0x36, 0x37, 0x33, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x3A, 0x43, 0x3B, 0x29, 0x2E, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x30, 0x42, 0x31, 0x34, 0xFF, 0x67, 0xFF, - 0xFF, 0x4B, 0x4D, 0x4A, 0x4C, 0xFF, 0x52, 0x53, 0x50, 0x57, - 0x56, 0x54, 0x4D, 0x4E, 0x51, 0x4F, 0x4F, 0x5A, 0x5C, 0x5A, - 0x62, 0x61, 0x47, 0x5B, 0x63, 0xFF, 0x26, 0xFF, 0xFF, 0x44, - 0x49, 0x55, 0x58, 0x60, 0x5E, 0x5E, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x49, 0x4A, 0x4B, 0x4C, 0x65, 0xFF, 0xFF, 0x67, - 0x50, 0x51, 0x52, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x5E, - 0xFF, 0x59, 0xFF, 0x5B, 0xFF, 0xFF, 0xFF, 0x60, 0x61, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x66, 0xFF, 0xFF, 0xFF, 0xFF, - 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3E, + 0x27, 0x28, 0x2A, 0x3D, 0x2C, 0x2D, 0x2B, 0x2F, 0x3F, 0x38, 0x40, 0x41, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x32, 0x3C, + 0x35, 0x39, 0x36, 0x37, 0x33, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x3A, 0x43, 0x3B, 0x29, 0x2E, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x30, 0x42, 0x31, 0x34, 0xFF, 0x67, 0xFF, 0xFF, 0x4B, + 0x4D, 0x4A, 0x4C, 0xFF, 0x52, 0x53, 0x50, 0x57, 0x56, 0x54, 0x4D, 0x4E, + 0x51, 0x4F, 0x4F, 0x5A, 0x5C, 0x5A, 0x62, 0x61, 0x47, 0x5B, 0x63, 0xFF, + 0x26, 0xFF, 0xFF, 0x44, 0x49, 0x55, 0x58, 0x60, 0x5E, 0x5E, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x49, 0x4A, 0x4B, 0x4C, 0x65, 0xFF, 0xFF, 0x67, 0x50, 0x51, 0x52, 0xFF, + 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x5E, 0xFF, 0x59, 0xFF, 0x5B, 0xFF, 0xFF, + 0xFF, 0x60, 0x61, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x66, 0xFF, 0xFF, + 0xFF, 0xFF, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; char font2_ascii_br[256] = // Fatal Brazilian/Saspanish - object_3_variable_1646 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3C, 0x27, 0x28, 0x2A, 0x3B, - 0x2C, 0x2D, 0x2B, 0x2F, 0x37, 0x3F, 0x38, 0x39, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x5A, 0x3A, - 0x36, 0x40, 0x35, 0x34, 0x31, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x3D, 0xFF, 0x3E, 0x29, 0x2E, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x32, 0xFF, 0x33, 0x30, 0xFF, 0x42, 0xFF, - 0xFF, 0x44, 0x46, 0x0D, 0xFF, 0xFF, 0xFF, 0x48, 0x59, 0x4A, - 0xFF, 0x4B, 0xFF, 0xFF, 0x49, 0xFF, 0x41, 0x4E, 0x50, 0x4C, - 0x56, 0x58, 0xFF, 0xFF, 0x57, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x45, 0x49, 0x4F, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x45, 0x43, 0x44, 0x46, 0x53, 0xFF, 0xFF, 0x42, - 0x49, 0x59, 0x5B, 0xFF, 0xFF, 0x4A, 0xFF, 0xFF, 0xFF, 0x5C, - 0xFF, 0x4D, 0xFF, 0x50, 0xFF, 0xFF, 0xFF, 0x55, 0x58, 0x26, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x51, 0xFF, 0xFF, 0xFF, 0xFF, - 0x52, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4A, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0x25, 0x3C, + 0x27, 0x28, 0x2A, 0x3B, 0x2C, 0x2D, 0x2B, 0x2F, 0x37, 0x3F, 0x38, 0x39, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x5A, 0x3A, + 0x36, 0x40, 0x35, 0x34, 0x31, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x3D, 0xFF, 0x3E, 0x29, 0x2E, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x32, 0xFF, 0x33, 0x30, 0xFF, 0x42, 0xFF, 0xFF, 0x44, + 0x46, 0x0D, 0xFF, 0xFF, 0xFF, 0x48, 0x59, 0x4A, 0xFF, 0x4B, 0xFF, 0xFF, + 0x49, 0xFF, 0x41, 0x4E, 0x50, 0x4C, 0x56, 0x58, 0xFF, 0xFF, 0x57, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x45, 0x49, 0x4F, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x45, 0x43, 0x44, 0x46, 0x53, 0xFF, 0xFF, 0x42, 0x49, 0x59, 0x5B, 0xFF, + 0xFF, 0x4A, 0xFF, 0xFF, 0xFF, 0x5C, 0xFF, 0x4D, 0xFF, 0x50, 0xFF, 0xFF, + 0xFF, 0x55, 0x58, 0x26, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x51, 0xFF, 0xFF, + 0xFF, 0xFF, 0x52, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4A, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; char font3_ascii_br[256] = // Fatal Brazilian/Saspanish - object_3_variable_1648 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x24, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0xFF, - 0xFF, 0x2B, 0x2D, 0x2A, 0x2C, 0xFF, 0x33, 0x34, 0x32, 0x38, - 0x37, 0x35, 0x2D, 0x2E, 0x31, 0x2F, 0x2F, 0x3D, 0x3F, 0x3C, - 0x43, 0x42, 0x27, 0x3E, 0x44, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x29, 0x36, 0x3B, 0x41, 0x3A, 0x3A, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x29, 0x2A, 0x2B, 0x2C, 0x46, 0xFF, 0xFF, 0x30, - 0x31, 0x32, 0x33, 0xFF, 0xFF, 0x36, 0xFF, 0xFF, 0xFF, 0x3A, - 0xFF, 0x3C, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x41, 0x42, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, - 0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x36, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0xFF, 0xFF, 0x2B, + 0x2D, 0x2A, 0x2C, 0xFF, 0x33, 0x34, 0x32, 0x38, 0x37, 0x35, 0x2D, 0x2E, + 0x31, 0x2F, 0x2F, 0x3D, 0x3F, 0x3C, 0x43, 0x42, 0x27, 0x3E, 0x44, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x29, 0x36, 0x3B, 0x41, 0x3A, 0x3A, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x29, 0x2A, 0x2B, 0x2C, 0x46, 0xFF, 0xFF, 0x30, 0x31, 0x32, 0x33, 0xFF, + 0xFF, 0x36, 0xFF, 0xFF, 0xFF, 0x3A, 0xFF, 0x3C, 0xFF, 0x3E, 0xFF, 0xFF, + 0xFF, 0x41, 0x42, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, + 0xFF, 0xFF, 0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x36, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; char font4_ascii_br[256] = // Fatal Brazilian/Saspanish - object_3_variable_1651 -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x29, 0x24, 0x2A, 0x25, 0xFF, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x27, 0xFF, - 0xFF, 0x2B, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0xFF, 0xFF, 0xFF, 0x26, 0x28, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0x33, 0x36, 0x32, 0x34, 0xFF, 0x3A, 0x3B, 0x39, 0x3F, - 0x3E, 0x3C, 0x35, 0x36, 0x38, 0x37, 0x37, 0x4A, 0x4C, 0x48, - 0x44, 0xFF, 0x2F, 0x4B, 0x45, 0xFF, 0xFF, 0xFF, 0xFF, 0x2D, - 0x31, 0x3D, 0x49, 0x42, 0x40, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x31, 0x32, 0x33, 0x34, 0xFF, 0xFF, 0xFF, 0x4D, - 0x38, 0x39, 0x3A, 0xFF, 0xFF, 0x3D, 0xFF, 0xFF, 0xFF, 0x40, - 0xFF, 0x49, 0xFF, 0x4B, 0xFF, 0xFF, 0xFF, 0x42, 0x43, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, - 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3D, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -tPoint sel_posns[12] = -{ - { 33, 60 }, - { 33, 82 }, - { 33, 104 }, - { 33, 126 }, - { 33, 148 }, - { 33, 170 }, - { 33, 192 }, - { 33, 214 }, - { 33, 236 }, - { 33, 258 }, - { 33, 280 }, - { 33, 336 } -}; -int no_clear = 0; //000A5E84 -char *descript[8] = //000A5E88 -{ - "FARIEL.RAW", - "FDESILVA.RAW", - "FPULSE.RAW", - "FGLOBAL.RAW", - "FMILLION.RAW", - "FMISSION.RAW", - "FZIZIN.RAW", - "FREISE.RAW" -}; -char comp_name[16][15] = //000A5EA8 -{ - "REISE WAGON 2:", - "REISE WAGON 1:", - "ZIZIN 2:", - "ZIZIN 1:", - "MISSION 2:", - "MISSION 1:", - "MILLION 2:", - "MILLION 1:", - "GLOBAL 2:", - "GLOBAL 1:", - "PULSE 2:", - "PULSE 1:", - "DESILVA 2:", - "DESILVA 1:", - "AUTO ARIEL 2:", - "AUTO ARIEL 1:" -}; -int network_test = 0; //000A5F98 -char cheat_names[32][9]; //0016F8F0 -char player_names[16][9]; //0016FA10 -int DeathView[2]; //0016FAA0 -int teamorder[8]; //0016FAA8 -int champorder[16]; //0016FAC8 -int team_wins[16]; //0016FB08 -int human_control[16]; //0016FB48 -int total_wins[16]; //0016FB88 -int allocated_cars[14]; //0016FBC8 -int team_kills[16]; //0016FC00 -int total_kills[16]; //0016FC40 -int team_points[8]; //0016FC80 -int championship_points[16]; //0016FCA0 -int team_fasts[16]; //0016FCE0 -int total_fasts[16]; //0016FD20 -int non_competitors[16]; //0016FDE0 -int player_started[16]; //0016FE20 -int player_invul[16]; //0016FE60 -int p_texs_off; //0016FEA0 -int p_tex_size; //0016FEA4 -int quit_game; //0016FEA8 -int players; //0016FEAC -int front_fade; //0016FEB0 -int frontend_on; //0016FEB4 -int cd_cheat; //0016FEB8 -//net_test //0016FEBC -int my_control; //0016FEC0 -int my_car; //0016FEC4 -int my_number; //0016FEC8 -int my_invul; //0016FECC -int FastestLap; //0016FED0 -int racers; //0016FED4 -uint32 cheat_mode; //0016FED8 -int Race; //0016FEDC -int switch_types; //0016FEE0 -int players_waiting; //0016FEE4 -int switch_sets; //0016FEE8 -int time_to_start; //0016FEEC -int I_Quit; //0016FEF0 -int StartPressed; //0016FEF4 -int waste; //0016FEF8 -int switch_same; //0016FEFC -int car_request; //0016FF00 -uint8 oldkeys[14]; //0016FF04 -char my_name[14]; //0016FF12 + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x29, 0x24, 0x2A, 0x25, 0xFF, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x27, 0xFF, + 0xFF, 0x2B, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0x26, 0x28, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x33, + 0x36, 0x32, 0x34, 0xFF, 0x3A, 0x3B, 0x39, 0x3F, 0x3E, 0x3C, 0x35, 0x36, + 0x38, 0x37, 0x37, 0x4A, 0x4C, 0x48, 0x44, 0xFF, 0x2F, 0x4B, 0x45, 0xFF, + 0xFF, 0xFF, 0xFF, 0x2D, 0x31, 0x3D, 0x49, 0x42, 0x40, 0x40, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x31, 0x32, 0x33, 0x34, 0xFF, 0xFF, 0xFF, 0x4D, 0x38, 0x39, 0x3A, 0xFF, + 0xFF, 0x3D, 0xFF, 0xFF, 0xFF, 0x40, 0xFF, 0x49, 0xFF, 0x4B, 0xFF, 0xFF, + 0xFF, 0x42, 0x43, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, + 0xFF, 0xFF, 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3D, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; +tPoint sel_posns[12] = {{33, 60}, {33, 82}, {33, 104}, {33, 126}, + {33, 148}, {33, 170}, {33, 192}, {33, 214}, + {33, 236}, {33, 258}, {33, 280}, {33, 336}}; +int no_clear = 0; // 000A5E84 +char *descript[8] = // 000A5E88 + {"FARIEL.RAW", "FDESILVA.RAW", "FPULSE.RAW", "FGLOBAL.RAW", + "FMILLION.RAW", "FMISSION.RAW", "FZIZIN.RAW", "FREISE.RAW"}; +char comp_name[16][15] = // 000A5EA8 + {"REISE WAGON 2:", "REISE WAGON 1:", "ZIZIN 2:", "ZIZIN 1:", + "MISSION 2:", "MISSION 1:", "MILLION 2:", "MILLION 1:", + "GLOBAL 2:", "GLOBAL 1:", "PULSE 2:", "PULSE 1:", + "DESILVA 2:", "DESILVA 1:", "AUTO ARIEL 2:", "AUTO ARIEL 1:"}; +int network_test = 0; // 000A5F98 +char cheat_names[32][9]; // 0016F8F0 +char player_names[16][9]; // 0016FA10 +int DeathView[2]; // 0016FAA0 +int teamorder[8]; // 0016FAA8 +int champorder[16]; // 0016FAC8 +int team_wins[16]; // 0016FB08 +int human_control[16]; // 0016FB48 +int total_wins[16]; // 0016FB88 +int allocated_cars[14]; // 0016FBC8 +int team_kills[16]; // 0016FC00 +int total_kills[16]; // 0016FC40 +int team_points[8]; // 0016FC80 +int championship_points[16]; // 0016FCA0 +int team_fasts[16]; // 0016FCE0 +int total_fasts[16]; // 0016FD20 +int non_competitors[16]; // 0016FDE0 +int player_started[16]; // 0016FE20 +int player_invul[16]; // 0016FE60 +int p_texs_off; // 0016FEA0 +int p_tex_size; // 0016FEA4 +int quit_game; // 0016FEA8 +int players; // 0016FEAC +int front_fade; // 0016FEB0 +int frontend_on; // 0016FEB4 +int cd_cheat; // 0016FEB8 +// net_test //0016FEBC +int my_control; // 0016FEC0 +int my_car; // 0016FEC4 +int my_number; // 0016FEC8 +int my_invul; // 0016FECC +int FastestLap; // 0016FED0 +int racers; // 0016FED4 +uint32 cheat_mode; // 0016FED8 +int Race; // 0016FEDC +int switch_types; // 0016FEE0 +int players_waiting; // 0016FEE4 +int switch_sets; // 0016FEE8 +int time_to_start; // 0016FEEC +int I_Quit; // 0016FEF0 +int StartPressed; // 0016FEF4 +int waste; // 0016FEF8 +int switch_same; // 0016FEFC +int car_request; // 0016FF00 +uint8 oldkeys[14]; // 0016FF04 +char my_name[14]; // 0016FF12 //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/frontend_network.c b/PROJECTS/ROLLER/frontend_network.c index 4b7219db..9e055a93 100644 --- a/PROJECTS/ROLLER/frontend_network.c +++ b/PROJECTS/ROLLER/frontend_network.c @@ -25,41 +25,39 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif -static int NetworkGridRand(int *pSeed) -{ +static int NetworkGridRand(int *pSeed) { uint32 uiSeed = (uint32)*pSeed; uiSeed = uiSeed * 1103515245u + 12345u; *pSeed = (int)uiSeed; return (int)((uiSeed >> 16) & 0x7FFFu); } -static int NetworkGridRandRange(int iRange, int *pSeed) -{ +static int NetworkGridRandRange(int iRange, int *pSeed) { return (int)(((uint32)iRange * (uint32)NetworkGridRand(pSeed)) >> 15); } //------------------------------------------------------------------------------------------------- -//00049C70 -void NetworkWait() -{ - int iPlayerLoop1; // esi - int iPlayerLoop2; // esi - int iPlayerDisplayLoop; // ebp - int iPlayerIndex; // esi - int iTextYPos; // edi - int iCarType; // ecx - int iCarTypeForSprite; // ebx +// 00049C70 +void NetworkWait() { + int iPlayerLoop1; // esi + int iPlayerLoop2; // esi + int iPlayerDisplayLoop; // ebp + int iPlayerIndex; // esi + int iTextYPos; // edi + int iCarType; // ecx + int iCarTypeForSprite; // ebx unsigned int uiKeyPressed; // eax - int iSavedScrSize; // [esp+0h] [ebp-2Ch] - int iCarSpriteYOffset; // [esp+4h] [ebp-28h] - int iContinueLoop; // [esp+8h] [ebp-24h] + int iSavedScrSize; // [esp+0h] [ebp-2Ch] + int iCarSpriteYOffset; // [esp+4h] [ebp-28h] + int iContinueLoop; // [esp+8h] [ebp-24h] char *szCurrentPlayerName; // [esp+Ch] [ebp-20h] - int iY; // [esp+10h] [ebp-1Ch] + int iY; // [esp+10h] [ebp-1Ch] - iSavedScrSize = scr_size; // Initialize network wait screen - save screen size and setup display + iSavedScrSize = scr_size; // Initialize network wait screen - save screen size + // and setup display front_fade = 0; tick_on = -1; frontend_on = -1; @@ -69,7 +67,9 @@ void NetworkWait() SVGA_ON = -1; network_test = 1; init_screen(); - front_vga[0] = (tBlockHeader *)load_picture("result.bm");// Load UI graphics: result screen, fonts, car sprites, and text tables + front_vga[0] = (tBlockHeader *)load_picture( + "result.bm"); // Load UI graphics: result screen, fonts, car sprites, and + // text tables front_vga[1] = (tBlockHeader *)load_picture("font2.bm"); front_vga[2] = (tBlockHeader *)load_picture("smallcar.bm"); front_vga[3] = (tBlockHeader *)load_picture("tabtext.bm"); @@ -95,7 +95,8 @@ void NetworkWait() UpdateSDL(); if (!iContinueLoop) goto LABEL_83; - if (switch_types) // Handle game type switching (championship/single race/team game) + if (switch_types) // Handle game type switching (championship/single + // race/team game) { game_type = switch_types - 1; if (switch_types == 1 && competitors == 1) @@ -107,25 +108,28 @@ void NetworkWait() network_champ_on = 0; } if (switch_same <= 0) - break; // Check for same-car mode activation + break; // Check for same-car mode activation // Force all players to use the same car type in same-car mode for (iPlayerLoop2 = 0; iPlayerLoop2 < players; iPlayerLoop2++) { - Players_Cars[iPlayerLoop2] = switch_same - 666; // Convert switch value to car type + Players_Cars[iPlayerLoop2] = + switch_same - 666; // Convert switch value to car type } - //iPlayerLoop2 = 0; - //if (players > 0) { - // iArrayOffset2 = 0; // Set same-car mode for all players (switch_same - 666 magic number) - // do { - // iArrayOffset2 += 4; - // ++iPlayerLoop2; - // *(int *)((char *)&infinite_laps + iArrayOffset2) = switch_same - 666; - // } while (iPlayerLoop2 < players); - //} + // iPlayerLoop2 = 0; + // if (players > 0) { + // iArrayOffset2 = 0; // Set same-car mode for all + // players (switch_same - 666 magic number) do { + // iArrayOffset2 += 4; + // ++iPlayerLoop2; + // *(int *)((char *)&infinite_laps + iArrayOffset2) = switch_same - + // 666; + // } while (iPlayerLoop2 < players); + // } cheat_mode |= CHEAT_MODE_CLONES; - if (Players_Cars[player1_car] < 0) // Check if player1 car is invalid (negative) - disconnect from network + if (Players_Cars[player1_car] < 0) // Check if player1 car is invalid + // (negative) - disconnect from network { StartPressed = 0; time_to_start = 0; @@ -138,96 +142,116 @@ void NetworkWait() } LABEL_26: check_cars(); - { // RENDER FRAME (GPU) - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_frame(mr); - menu_render_background(mr, 0); // Main network lobby display loop - show waiting screen - sprintf(buffer, "%s: %i", &language_buffer[64], players); - menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 16, 4, 0x8Fu, 0, pal_addr); - sprintf(buffer, "%s: %i", &language_buffer[256], TrackLoad); - menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 16, 24, 0x8Fu, 0, pal_addr); - if (game_type) // Display game type text based on current mode - { - if ((unsigned int)game_type <= 1) { - sprintf(buffer, "%s", &language_buffer[3520]); - } else if (game_type == 2) { - sprintf(buffer, "%s", &language_buffer[3712]); + { // RENDER FRAME (GPU) + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_frame(mr); + menu_render_background( + mr, 0); // Main network lobby display loop - show waiting screen + sprintf(buffer, "%s: %i", &language_buffer[64], players); + menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 16, 4, + 0x8Fu, 0, pal_addr); + sprintf(buffer, "%s: %i", &language_buffer[256], TrackLoad); + menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 16, 24, + 0x8Fu, 0, pal_addr); + if (game_type) // Display game type text based on current mode + { + if ((unsigned int)game_type <= 1) { + sprintf(buffer, "%s", &language_buffer[3520]); + } else if (game_type == 2) { + sprintf(buffer, "%s", &language_buffer[3712]); + } + } else { + sprintf(buffer, "%s", &language_buffer[3648]); } - } else { - sprintf(buffer, "%s", &language_buffer[3648]); - } - menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 200, 4, 0x8Fu, 1u, pal_addr); - if (players_waiting == network_on) // Show flashing "Ready to start" message when all players connected - { - if ((frames & 0xFu) < 8) - menu_render_text(mr, 1, &language_buffer[4800], font2_ascii, font2_offsets, 200, 22, 0x8Fu, 1u, pal_addr); - if (time_to_start) - iContinueLoop = 0; - } - iPlayerDisplayLoop = 0; - if (players > 0) { - iPlayerIndex = 0; // Display player list with names, car selections, and connection status - iY = 44; - szCurrentPlayerName = player_names[0]; - iTextYPos = 49; - do { // Show flashing indicator for player1, solid for others - if (player_started[iPlayerIndex] && (!iPlayerDisplayLoop && (frames & 0xFu) < 8 || iPlayerDisplayLoop > 0)) - menu_render_sprite(mr, 2, 0, 13, iY, 0, pal_addr); - sprintf(buffer, "%i", iPlayerDisplayLoop + 1); - iCarSpriteYOffset = 22 * iPlayerDisplayLoop; - menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 33, iTextYPos, 0x8Fu, 0, pal_addr); - sprintf(buffer, "%s", szCurrentPlayerName); - menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 85, iTextYPos, 0x8Fu, 0, pal_addr); - iCarType = Players_Cars[iPlayerIndex]; - if (iCarType >= 0) // Display car company name and sprite if valid car selected - { - sprintf(buffer, "%s", CompanyNames[iCarType]); - menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 218, iTextYPos, 0x8Fu, 0, pal_addr); - iCarTypeForSprite = Players_Cars[iPlayerIndex]; - if (iCarTypeForSprite < 8) { - if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) - menu_render_sprite(mr, 2, smallcars[1][iCarTypeForSprite], 165, iCarSpriteYOffset + 46, 0, pal_addr); - else - menu_render_sprite(mr, 2, smallcars[0][iCarTypeForSprite], 165, iCarSpriteYOffset + 46, 0, pal_addr); + menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 200, 4, + 0x8Fu, 1u, pal_addr); + if (players_waiting == network_on) // Show flashing "Ready to start" + // message when all players connected + { + if ((frames & 0xFu) < 8) + menu_render_text(mr, 1, &language_buffer[4800], font2_ascii, + font2_offsets, 200, 22, 0x8Fu, 1u, pal_addr); + if (time_to_start) + iContinueLoop = 0; + } + iPlayerDisplayLoop = 0; + if (players > 0) { + iPlayerIndex = 0; // Display player list with names, car selections, + // and connection status + iY = 44; + szCurrentPlayerName = player_names[0]; + iTextYPos = 49; + do { // Show flashing indicator for player1, solid for others + if (player_started[iPlayerIndex] && + (!iPlayerDisplayLoop && (frames & 0xFu) < 8 || + iPlayerDisplayLoop > 0)) + menu_render_sprite(mr, 2, 0, 13, iY, 0, pal_addr); + sprintf(buffer, "%i", iPlayerDisplayLoop + 1); + iCarSpriteYOffset = 22 * iPlayerDisplayLoop; + menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 33, + iTextYPos, 0x8Fu, 0, pal_addr); + sprintf(buffer, "%s", szCurrentPlayerName); + menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 85, + iTextYPos, 0x8Fu, 0, pal_addr); + iCarType = Players_Cars[iPlayerIndex]; + if (iCarType >= + 0) // Display car company name and sprite if valid car selected + { + sprintf(buffer, "%s", CompanyNames[iCarType]); + menu_render_text(mr, 1, buffer, font2_ascii, font2_offsets, 218, + iTextYPos, 0x8Fu, 0, pal_addr); + iCarTypeForSprite = Players_Cars[iPlayerIndex]; + if (iCarTypeForSprite < 8) { + if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) + menu_render_sprite(mr, 2, smallcars[1][iCarTypeForSprite], + 165, iCarSpriteYOffset + 46, 0, pal_addr); + else + menu_render_sprite(mr, 2, smallcars[0][iCarTypeForSprite], + 165, iCarSpriteYOffset + 46, 0, pal_addr); + } else { + menu_render_text(mr, 1, "CHEAT", font2_ascii, font2_offsets, + 165, iTextYPos, 0x8Fu, 0, pal_addr); + } } else { - menu_render_text(mr, 1, "CHEAT", font2_ascii, font2_offsets, 165, iTextYPos, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 1, &language_buffer[4160], font2_ascii, + font2_offsets, 218, iTextYPos, 0x8Fu, 0, + pal_addr); } - } else { - menu_render_text(mr, 1, &language_buffer[4160], font2_ascii, font2_offsets, 218, iTextYPos, 0x8Fu, 0, pal_addr); + ++iPlayerIndex; + iTextYPos += 22; + ++iPlayerDisplayLoop; + iY += 22; + szCurrentPlayerName += 9; + } while (iPlayerDisplayLoop < players); + } + if (time_to_start) + iContinueLoop = 0; + if (iContinueLoop) { + show_received_mesage(); + menu_render_end_frame(mr); + if (!front_fade) { + front_fade = + -1; // Initialize screen fade and network synchronization + menu_render_begin_fade(mr, 1, 32); + broadcast_mode = -668; + while (broadcast_mode) + UpdateSDL(); + broadcast_mode = -668; + while (broadcast_mode) + UpdateSDL(); + frames = 0; } - ++iPlayerIndex; - iTextYPos += 22; - ++iPlayerDisplayLoop; - iY += 22; - szCurrentPlayerName += 9; - } while (iPlayerDisplayLoop < players); - } - if (time_to_start) - iContinueLoop = 0; - if (iContinueLoop) { - show_received_mesage(); - menu_render_end_frame(mr); - if (!front_fade) { - front_fade = -1; // Initialize screen fade and network synchronization - menu_render_begin_fade(mr, 1, 32); - broadcast_mode = -668; - while (broadcast_mode) - UpdateSDL(); - broadcast_mode = -668; - while (broadcast_mode) - UpdateSDL(); - frames = 0; } } - } - while (fatkbhit()) // Handle keyboard input for network lobby + while (fatkbhit()) // Handle keyboard input for network lobby { UpdateSDL(); uiKeyPressed = fatgetch(); if (uiKeyPressed < 0xD) { if (!uiKeyPressed) fatgetch(); - } else if (uiKeyPressed <= 0xD) { // Enter key pressed - start race if all players ready + } else if (uiKeyPressed <= + 0xD) { // Enter key pressed - start race if all players ready if (players_waiting == network_on && !time_to_start) { iContinueLoop = 0; broadcast_mode = -671; @@ -241,7 +265,8 @@ void NetworkWait() UpdateSDL(); time_to_start = -1; } - } else if (uiKeyPressed == 27 && !time_to_start && !restart_net)// Escape key pressed - leave network game + } else if (uiKeyPressed == 27 && !time_to_start && + !restart_net) // Escape key pressed - leave network game { StartPressed = 0; time_to_start = 0; @@ -258,17 +283,17 @@ void NetworkWait() goto LABEL_26; for (iPlayerLoop1 = 0; iPlayerLoop1 < players; iPlayerLoop1++) { - Players_Cars[iPlayerLoop1] = -1; + Players_Cars[iPlayerLoop1] = -1; } - //iPlayerLoop1 = 0; // Reset same-car mode - clear player settings - //if (players > 0) { - // iArrayOffset1 = 0; - // do { - // iArrayOffset1 += 4; - // ++iPlayerLoop1; - // *(int *)((char *)&infinite_laps + iArrayOffset1) = -1; - // } while (iPlayerLoop1 < players); - //} + // iPlayerLoop1 = 0; // Reset same-car mode - + // clear player settings if (players > 0) { + // iArrayOffset1 = 0; + // do { + // iArrayOffset1 += 4; + // ++iPlayerLoop1; + // *(int *)((char *)&infinite_laps + iArrayOffset1) = -1; + // } while (iPlayerLoop1 < players); + // } cheat_mode &= ~CHEAT_MODE_CLONES; @@ -283,9 +308,9 @@ void NetworkWait() } LABEL_83: int iTimer = ticks + 18; - while (iTimer > ticks) // Wait loop for network synchronization timing + while (iTimer > ticks) // Wait loop for network synchronization timing ; - if (time_to_start) // Final network synchronization before race starts + if (time_to_start) // Final network synchronization before race starts { broadcast_mode = -314; while (broadcast_mode) { @@ -293,14 +318,16 @@ void NetworkWait() BroadcastNews(); UpdateSDL(); } - if (wConsoleNode == master) // Master node waits for all client records, then broadcasts seed + if (wConsoleNode == master) // Master node waits for all client records, + // then broadcasts seed { int iLastRecordWaitLog = -1000; while (received_records < network_on) { if (frames - iLastRecordWaitLog >= 36) { iLastRecordWaitLog = frames; - SDL_Log("[NET-START] master waiting for records received=%d expected=%d", - received_records, network_on); + SDL_Log( + "[NET-START] master waiting for records received=%d expected=%d", + received_records, network_on); } CheckNewNodes(); UpdateSDL(); @@ -311,12 +338,14 @@ void NetworkWait() BroadcastNews(); UpdateSDL(); } - } else { // Client nodes wait for random seed from master + } else { // Client nodes wait for random seed from master int iLastRecordResend = -1000; while (!received_seed) { if (frames - iLastRecordResend >= 36) { iLastRecordResend = frames; - SDL_Log("[NET-START] slave waiting for seed; resending record to master=%d", master); + SDL_Log("[NET-START] slave waiting for seed; resending record to " + "master=%d", + master); send_record_to_master(TrackLoad); } CheckNewNodes(); @@ -324,7 +353,8 @@ void NetworkWait() } } } - check_cars(); // Cleanup: fade screen, free graphics memory, restore screen size + check_cars(); // Cleanup: fade screen, free graphics memory, restore screen + // size // GPU fade-out { MenuRenderer *mr = GetMenuRenderer(); @@ -347,34 +377,33 @@ void NetworkWait() } //------------------------------------------------------------------------------------------------- -//0004AB30 -void restart_net_game() -{ +// 0004AB30 +void restart_net_game() { int iActualCompetitors; // edi - int iGridIndex; // edx - int iCompetitorLoop; // ecx - int i; // eax - int iTotalCars; // esi - int iCarIndex; // edx - int iGridOffset; // ecx - int iNonCompSearch; // eax - int j; // eax - int iAISearch; // ebx - int iRandRange; // eax - int iFirstSwapPos; // ecx - int iSecondRand; // eax - int iSecondSwapPos; // eax - int iTempCarId; // ebp - int k; // esi - int iHandicapPos; // edx - int iHumanPos; // ebx - int iOrderLoop; // eax - int m; // eax - int iAICarId; // ecx - int iHumanCarId; // edx - int iMaxCarOffset; // [esp+4h] [ebp-1Ch] + int iGridIndex; // edx + int iCompetitorLoop; // ecx + int i; // eax + int iTotalCars; // esi + int iCarIndex; // edx + int iGridOffset; // ecx + int iNonCompSearch; // eax + int j; // eax + int iAISearch; // ebx + int iRandRange; // eax + int iFirstSwapPos; // ecx + int iSecondRand; // eax + int iSecondSwapPos; // eax + int iTempCarId; // ebp + int k; // esi + int iHandicapPos; // edx + int iHumanPos; // ebx + int iOrderLoop; // eax + int m; // eax + int iAICarId; // ecx + int iHumanCarId; // edx + int iMaxCarOffset; // [esp+4h] [ebp-1Ch] - SVGA_ON = -1; // Initialize graphics and game state + SVGA_ON = -1; // Initialize graphics and game state init_screen(); winx = 0; winy = 0; @@ -385,23 +414,25 @@ void restart_net_game() time_to_start = 0; StartPressed = 0; tick_on = -1; - load_language_file(szSelectEng, 0); // Load language files for interface + load_language_file(szSelectEng, 0); // Load language files for interface load_language_file(szConfigEng, 1); remove_messages(-1); - reset_network(0); // Reset network and wait for broadcast mode to clear + reset_network(0); // Reset network and wait for broadcast mode to clear broadcast_mode = -667; while (broadcast_mode) UpdateSDL(); no_clear = 0; if (!quit_game && !intro) { - check_cars(); // Check cars and wait for network if not quitting or in intro + check_cars(); // Check cars and wait for network if not quitting or in intro NetworkWait(); } if (replaytype != 2 && !quit_game) AllocateCars(); - Race = ((uint8)TrackLoad - 1) & 7; // Calculate current race number (0-7) + Race = ((uint8)TrackLoad - 1) & 7; // Calculate current race number (0-7) if (game_type == 1 && !Race) { - memset(championship_points, 0, sizeof(championship_points));// Reset championship statistics for new championship + memset(championship_points, 0, + sizeof(championship_points)); // Reset championship statistics for + // new championship memset(team_points, 0, sizeof(team_points)); memset(total_kills, 0, sizeof(total_kills)); memset(total_fasts, 0, sizeof(total_fasts)); @@ -411,7 +442,8 @@ void restart_net_game() memset(team_wins, 0, sizeof(team_wins)); } iActualCompetitors = competitors; - if (competitors == 2) // Determine actual number of competitors based on game type + if (competitors == + 2) // Determine actual number of competitors based on game type { iActualCompetitors = players; if (players < 2) @@ -420,8 +452,10 @@ void restart_net_game() if (competitors == 1) iActualCompetitors = players; iGridIndex = 0; - if (iActualCompetitors > 0) { // Fill grid with competing cars (skip non-competitors) - for (iCompetitorLoop = 0; iCompetitorLoop < iActualCompetitors; ++iCompetitorLoop) { + if (iActualCompetitors > + 0) { // Fill grid with competing cars (skip non-competitors) + for (iCompetitorLoop = 0; iCompetitorLoop < iActualCompetitors; + ++iCompetitorLoop) { for (i = iGridIndex; non_competitors[i]; ++i) ++iGridIndex; grid[iCompetitorLoop] = iGridIndex++; @@ -430,10 +464,12 @@ void restart_net_game() iTotalCars = iActualCompetitors; iCarIndex = 0; if (iActualCompetitors < numcars) { - iGridOffset = 4 * iActualCompetitors; // Fill remaining grid positions with AI cars + iGridOffset = + 4 * iActualCompetitors; // Fill remaining grid positions with AI cars iMaxCarOffset = 4 * numcars; do { - for (iNonCompSearch = iCarIndex; !non_competitors[iNonCompSearch]; ++iNonCompSearch) + for (iNonCompSearch = iCarIndex; !non_competitors[iNonCompSearch]; + ++iNonCompSearch) ++iCarIndex; ++iTotalCars; grid[iGridOffset / 4u] = iCarIndex; @@ -444,31 +480,47 @@ void restart_net_game() if (game_type == 1 && Race > 0) { if (iActualCompetitors > 0) { for (j = 0; j < iActualCompetitors; ++j) { - grid[j] = champorder[j]; + grid[j] = champorder[j]; } - //for (j = 0; j < iActualCompetitors; finished_car[j + 15] = teamorder[j + 7]) - // ++j; + // for (j = 0; j < iActualCompetitors; finished_car[j + 15] = teamorder[j + // + 7]) + // ++j; } } else { racers = iActualCompetitors; int iNetworkGridSeed = random_seed; - for (iAISearch = 0; iAISearch < 6 * iActualCompetitors; grid[iSecondSwapPos] = iTempCarId)// Shuffle grid positions randomly for non-championship races + for (iAISearch = 0; iAISearch < 6 * iActualCompetitors; + grid[iSecondSwapPos] = iTempCarId) // Shuffle grid positions randomly + // for non-championship races { iRandRange = network_on ? 0 : ROLLERrandRaw(); - //iFirstSwapPos = iRandRange % iActualCompetitors; // Get random position within grid bounds - iFirstSwapPos = network_on ? NetworkGridRandRange(iActualCompetitors, &iNetworkGridSeed) : GetHighOrderRand(iActualCompetitors, iRandRange); - //iFirstSwapPos = (iActualCompetitors * iRandRange - (__CFSHL__((iActualCompetitors * iRandRange) >> 31, 15) + ((iActualCompetitors * iRandRange) >> 31 << 15))) >> 15; + // iFirstSwapPos = iRandRange % iActualCompetitors; // Get random + // position within grid bounds + iFirstSwapPos = + network_on + ? NetworkGridRandRange(iActualCompetitors, &iNetworkGridSeed) + : GetHighOrderRand(iActualCompetitors, iRandRange); + // iFirstSwapPos = (iActualCompetitors * iRandRange - + // (__CFSHL__((iActualCompetitors * iRandRange) >> 31, 15) + + // ((iActualCompetitors * iRandRange) >> 31 << 15))) >> 15; iSecondRand = network_on ? 0 : ROLLERrandRaw(); - //iSecondSwapPos = iSecondRand % iActualCompetitors; // Get second random position within grid bounds - iSecondSwapPos = network_on ? NetworkGridRandRange(iActualCompetitors, &iNetworkGridSeed) : GetHighOrderRand(iActualCompetitors, iSecondRand); - //iSecondSwapPos = (iActualCompetitors * iSecondRand - (__CFSHL__((iActualCompetitors * iSecondRand) >> 31, 15) + ((iActualCompetitors * iSecondRand) >> 31 << 15))) >> 15; + // iSecondSwapPos = iSecondRand % iActualCompetitors; // Get second + // random position within grid bounds + iSecondSwapPos = + network_on + ? NetworkGridRandRange(iActualCompetitors, &iNetworkGridSeed) + : GetHighOrderRand(iActualCompetitors, iSecondRand); + // iSecondSwapPos = (iActualCompetitors * iSecondRand - + // (__CFSHL__((iActualCompetitors * iSecondRand) >> 31, 15) + + // ((iActualCompetitors * iSecondRand) >> 31 << 15))) >> 15; iTempCarId = grid[iFirstSwapPos]; grid[iFirstSwapPos] = grid[iSecondSwapPos]; ++iAISearch; } iActualCompetitors = racers; - for (k = 0; k < players; ++k) // Position human players based on difficulty level - { // Calculate starting position handicap based on level + for (k = 0; k < players; + ++k) // Position human players based on difficulty level + { // Calculate starting position handicap based on level if (level && (cheat_mode & 2) == 0) iHandicapPos = iActualCompetitors - 2 * level * players; else @@ -476,10 +528,12 @@ void restart_net_game() if (iHandicapPos < 0) iHandicapPos = 0; iHumanPos = 0; - for (iOrderLoop = 0; !human_control[grid[iOrderLoop]]; ++iOrderLoop)// Find human player in grid and ensure proper positioning + for (iOrderLoop = 0; !human_control[grid[iOrderLoop]]; + ++iOrderLoop) // Find human player in grid and ensure proper + // positioning ++iHumanPos; if (iHumanPos < iHandicapPos) { - for (m = iHandicapPos; ; ++m) { + for (m = iHandicapPos;; ++m) { iAICarId = grid[m]; if (!human_control[iAICarId]) break; @@ -491,7 +545,7 @@ void restart_net_game() } } } - StartPressed = 0; // Finalize restart state + StartPressed = 0; // Finalize restart state restart_net = 0; racers = iActualCompetitors; } diff --git a/PROJECTS/ROLLER/frontend_screens.c b/PROJECTS/ROLLER/frontend_screens.c index e3f5792c..6ea1b286 100644 --- a/PROJECTS/ROLLER/frontend_screens.c +++ b/PROJECTS/ROLLER/frontend_screens.c @@ -26,25 +26,23 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif -static int NetworkGridRand(int *pSeed) -{ +static int NetworkGridRand(int *pSeed) { uint32 uiSeed = (uint32)*pSeed; uiSeed = uiSeed * 1103515245u + 12345u; *pSeed = (int)uiSeed; return (int)((uiSeed >> 16) & 0x7FFFu); } -static int NetworkGridRandRange(int iRange, int *pSeed) -{ +static int NetworkGridRandRange(int iRange, int *pSeed) { return (int)(((uint32)iRange * (uint32)NetworkGridRand(pSeed)) >> 15); } -// Replace accented characters with non-accented equivalents in the font table - add by ROLLER -void font_ascii_replace_accent(char *font) -{ +// Replace accented characters with non-accented equivalents in the font table - +// add by ROLLER +void font_ascii_replace_accent(char *font) { font[0xc7] = font['C']; // Ç font[0xe7] = font['c']; // ç @@ -82,9 +80,8 @@ void font_ascii_replace_accent(char *font) } //------------------------------------------------------------------------------------------------- -//0003F5B0 -void title_screens() -{ +// 0003F5B0 +void title_screens() { winx = 0; winy = 0; winw = XMAX; @@ -105,9 +102,10 @@ void title_screens() bool bHasTitle = ROLLERfexists("title.bm") && ROLLERfexists("title.pal"); setpal(bHasTitle ? "title.pal" : "whipped.pal"); - front_vga[0] = (tBlockHeader*)load_picture(bHasTitle ? "title.bm" : "whipped.bm"); + front_vga[0] = + (tBlockHeader *)load_picture(bHasTitle ? "title.bm" : "whipped.bm"); - if (front_vga[0] && scrbuf) //check added by ROLLER + if (front_vga[0] && scrbuf) // check added by ROLLER display_picture(scrbuf, front_vga[0]); copypic(scrbuf, screen); @@ -118,12 +116,15 @@ void title_screens() disable_keyboard(); if ((cheat_mode & (CHEAT_MODE_KILLER_OPPONENTS | CHEAT_MODE_DEATH_MODE)) != 0) waitsampledone(SOUND_SAMPLE_FATAL); - fre((void**)&front_vga[0]); + fre((void **)&front_vga[0]); freefatalsample(); - // Add by ROLLER, check language to change font table to support Brazilian / Saspanish. - if (strcmp(languagename, "Brazilian") == 0 || strcmp(languagename, "Saspanish") == 0) { - SDL_Log("Language: update font1_ascii and font2_ascii to support '%s'", languagename); + // Add by ROLLER, check language to change font table to support Brazilian / + // Saspanish. + if (strcmp(languagename, "Brazilian") == 0 || + strcmp(languagename, "Saspanish") == 0) { + SDL_Log("Language: update font1_ascii and font2_ascii to support '%s'", + languagename); memcpy(font1_ascii, font1_ascii_br, 256); memcpy(font2_ascii, font2_ascii_br, 256); memcpy(font3_ascii, font3_ascii_br, 256); @@ -134,9 +135,8 @@ void title_screens() } //------------------------------------------------------------------------------------------------- -//0003F6B0 -void copy_screens() -{ +// 0003F6B0 +void copy_screens() { SVGA_ON = -1; init_screen(); winx = 0; @@ -160,18 +160,17 @@ void copy_screens() UpdateSDLWindow(); } #endif - fre((void**)&front_vga[0]); + fre((void **)&front_vga[0]); fade_palette(0); } -// Fade callback: redraws menu background so fade overlay is visible over content -void fade_redraw_bg(void *ctx) -{ +// Fade callback: redraws menu background so fade overlay is visible over +// content +void fade_redraw_bg(void *ctx) { menu_render_background((MenuRenderer *)ctx, 0); } -void snapshot_setup_frontend_menu_state(int iGameType) -{ +void snapshot_setup_frontend_menu_state(int iGameType) { load_language_file(szSelectEng, 0); load_language_file(szConfigEng, 1); @@ -203,13 +202,13 @@ void snapshot_setup_frontend_menu_state(int iGameType) mirror = 0; setpal("frontend.pal"); - front_vga[0] = (tBlockHeader*)load_picture("frontend.bm"); - front_vga[1] = (tBlockHeader*)load_picture("selhead.bm"); - front_vga[2] = (tBlockHeader*)load_picture("font2.bm"); - front_vga[4] = (tBlockHeader*)load_picture("opticon2.bm"); - front_vga[5] = (tBlockHeader*)load_picture("selicons.bm"); - front_vga[6] = (tBlockHeader*)load_picture("selexit.bm"); - front_vga[15] = (tBlockHeader*)load_picture("font1.bm"); + front_vga[0] = (tBlockHeader *)load_picture("frontend.bm"); + front_vga[1] = (tBlockHeader *)load_picture("selhead.bm"); + front_vga[2] = (tBlockHeader *)load_picture("font2.bm"); + front_vga[4] = (tBlockHeader *)load_picture("opticon2.bm"); + front_vga[5] = (tBlockHeader *)load_picture("selicons.bm"); + front_vga[6] = (tBlockHeader *)load_picture("selexit.bm"); + front_vga[15] = (tBlockHeader *)load_picture("font1.bm"); FindShades(); check_cars(); @@ -236,79 +235,74 @@ void snapshot_setup_frontend_menu_state(int iGameType) } } -void snapshot_render_menu_main(void) -{ - select_screen(); -} - +void snapshot_render_menu_main(void) { select_screen(); } //------------------------------------------------------------------------------------------------- -//0003F7B0 -void select_screen() -{ - int iMenuSelection; // esi - int iContinue; // ebp - int iQuitConfirmed; // edi - int iPlayer1Car; // eax - int iNoClear; // eax - int iPlayer; // edx - uint8 *pBuf; // edx - int iPlayer1Car2; // eax - eCarType carType; // eax - eCarType carType2; // ebx - int iCarTexLoaded; // ecx - int iLoadCarTextures; // edx - void **ppCartexVgaItr2; // edx - eCarType cartype3; // eax - eCarType cartype4; // ebx - int iCarTexLoaded2; // edx - int iCurLaps; // eax - double dRecordLap; // st7 - int iMinutes; // ecx - int iSeconds; // ebx - int iBlockIdx2; // ebx - int iPlayerIdx; // edx - int iPlayerIdx2; // eax - uint8 **ppCartexVgaItr_2; // edx +// 0003F7B0 +void select_screen() { + int iMenuSelection; // esi + int iContinue; // ebp + int iQuitConfirmed; // edi + int iPlayer1Car; // eax + int iNoClear; // eax + int iPlayer; // edx + uint8 *pBuf; // edx + int iPlayer1Car2; // eax + eCarType carType; // eax + eCarType carType2; // ebx + int iCarTexLoaded; // ecx + int iLoadCarTextures; // edx + void **ppCartexVgaItr2; // edx + eCarType cartype3; // eax + eCarType cartype4; // ebx + int iCarTexLoaded2; // edx + int iCurLaps; // eax + double dRecordLap; // st7 + int iMinutes; // ecx + int iSeconds; // ebx + int iBlockIdx2; // ebx + int iPlayerIdx; // edx + int iPlayerIdx2; // eax + uint8 **ppCartexVgaItr_2; // edx void **ppCartexVgaToFree_1; // eax - eCarType carType_2; // eax - eCarType carTypeBackup; // ebx - int iCarTexLoaded_1; // edx - int iCarIdx; // ecx - int iPlayerIdx_1; // eax - int iPlayerOffset; // edx - uint8 **ppCartexVgaItr_1; // edx - void **ppCartexVgaToFree; // eax - eCarType iCar; // eax - eCarType carTypeToLoad; // ebx - int iCartexLoaded; // ecx - int iLoadCarTextures_1; // edx - uint8 byKey; // al - uint8 byKey2; // al + eCarType carType_2; // eax + eCarType carTypeBackup; // ebx + int iCarTexLoaded_1; // edx + int iCarIdx; // ecx + int iPlayerIdx_1; // eax + int iPlayerOffset; // edx + uint8 **ppCartexVgaItr_1; // edx + void **ppCartexVgaToFree; // eax + eCarType iCar; // eax + eCarType carTypeToLoad; // ebx + int iCartexLoaded; // ecx + int iLoadCarTextures_1; // edx + uint8 byKey; // al + uint8 byKey2; // al void **ppCartexVgaToFree_2; // edx - eCarType carType_1; // eax - eCarType carTypeSelected; // ebx - int iCartexLoaded2; // edx - int16 nNewYaw; // ax - int iControl; // edx - int j; // eax - int iNonCompetitorIdx; // edx - int iRacersIdx; // esi - int iNonCompetitorIdx2; // edx - int m; // esi - int iTargetPos; // edx - int iHumanIdx; // ebx - int iGridIdx; // eax - int iNonHumanIdx; // eax - int iSwapGrid1; // ecx - int iSwapGrid2; // edx - int iInitScreen; // [esp+0h] [ebp-54h] - int16 nFrames; // [esp+4h] [ebp-50h] - int iRotation; // [esp+Ch] [ebp-48h] - int iBlockIdx; // [esp+10h] [ebp-44h] - int iLoadCarTex2; // [esp+2Ch] [ebp-28h] - int iLoadCarTexFlag; // [esp+30h] [ebp-24h] - int iLoadCarTextures2; // [esp+34h] [ebp-20h] + eCarType carType_1; // eax + eCarType carTypeSelected; // ebx + int iCartexLoaded2; // edx + int16 nNewYaw; // ax + int iControl; // edx + int j; // eax + int iNonCompetitorIdx; // edx + int iRacersIdx; // esi + int iNonCompetitorIdx2; // edx + int m; // esi + int iTargetPos; // edx + int iHumanIdx; // ebx + int iGridIdx; // eax + int iNonHumanIdx; // eax + int iSwapGrid1; // ecx + int iSwapGrid2; // edx + int iInitScreen; // [esp+0h] [ebp-54h] + int16 nFrames; // [esp+4h] [ebp-50h] + int iRotation; // [esp+Ch] [ebp-48h] + int iBlockIdx; // [esp+10h] [ebp-44h] + int iLoadCarTex2; // [esp+2Ch] [ebp-28h] + int iLoadCarTexFlag; // [esp+30h] [ebp-24h] + int iLoadCarTextures2; // [esp+34h] [ebp-20h] // Initialize game state time_to_start = 0; @@ -322,7 +316,7 @@ void select_screen() cup_won = (textures_off & TEX_OFF_PREMIER_CUP_AVAILABLE) != 0; if ((textures_off & TEX_OFF_BONUS_CUP_AVAILABLE) != 0) { cup_won |= 2; - //LOBYTE(cup_won) = cup_won | 2; + // LOBYTE(cup_won) = cup_won | 2; } loadfatalsample(); iContinue = 0; @@ -339,13 +333,13 @@ void select_screen() p_tex_size = gfx_size; // Load graphical assets - front_vga[0] = (tBlockHeader*)load_picture("frontend.bm"); - front_vga[1] = (tBlockHeader*)load_picture("selhead.bm"); - front_vga[2] = (tBlockHeader*)load_picture("font2.bm"); - front_vga[3] = (tBlockHeader*)load_picture("carnames.bm"); - front_vga[4] = (tBlockHeader*)load_picture("opticon2.bm"); - front_vga[5] = (tBlockHeader*)load_picture("selicons.bm"); - front_vga[6] = (tBlockHeader*)load_picture("selexit.bm"); + front_vga[0] = (tBlockHeader *)load_picture("frontend.bm"); + front_vga[1] = (tBlockHeader *)load_picture("selhead.bm"); + front_vga[2] = (tBlockHeader *)load_picture("font2.bm"); + front_vga[3] = (tBlockHeader *)load_picture("carnames.bm"); + front_vga[4] = (tBlockHeader *)load_picture("opticon2.bm"); + front_vga[5] = (tBlockHeader *)load_picture("selicons.bm"); + front_vga[6] = (tBlockHeader *)load_picture("selexit.bm"); front_vga[15] = (tBlockHeader *)load_picture("font1.bm"); fade_palette(0); @@ -414,24 +408,25 @@ void select_screen() if (pBuf) gfx_size = no_mem; else - LABEL_24: - gfx_size = 1; + LABEL_24: + gfx_size = 1; fre((void **)&front_vga[7]); set_starts(0); car_texs_loaded[0] = 0; for (int i = 1; i < 16; ++i) { car_texs_loaded[i] = -1; } - //for (i = 2; i != 16; SmokePt[i + 1023] = -1)// reference to car_texs_loaded + // for (i = 2; i != 16; SmokePt[i + 1023] = -1)// reference to + // car_texs_loaded //{ - // i += 7; - // SmokePt[i + 1017] = -1; - // SmokePt[i + 1018] = -1; - // SmokePt[i + 1019] = -1; - // SmokePt[i + 1020] = -1; - // SmokePt[i + 1021] = -1; - // SmokePt[i + 1022] = -1; - //} + // i += 7; + // SmokePt[i + 1017] = -1; + // SmokePt[i + 1018] = -1; + // SmokePt[i + 1019] = -1; + // SmokePt[i + 1020] = -1; + // SmokePt[i + 1021] = -1; + // SmokePt[i + 1022] = -1; + // } iPlayer1Car2 = Players_Cars[player1_car]; iBlockIdx = iPlayer1Car2; LoadCarTextures = 0; @@ -503,7 +498,8 @@ void select_screen() fade_music_finish(0); palette_brightness = 0; // Zero pal_addr so software screens see a black palette - // (GPU fade-out doesn't touch pal_addr, but fade_palette(0) expects it zeroed) + // (GPU fade-out doesn't touch pal_addr, but fade_palette(0) expects it + // zeroed) for (int i = 0; i < 256; i++) { pal_addr[i].byR = 0; pal_addr[i].byB = 0; @@ -516,23 +512,23 @@ void select_screen() Players_Cars[player1_car] = iBlockIdx; for (int i = 0; i < 16; ++i) { - fre((void**)&front_vga[i]); + fre((void **)&front_vga[i]); } - //ppFrontVgaItr = front_vga; - //do { - // pFrontVgaToFre = (void **)ppFrontVgaItr++; - // fre(pFrontVgaToFre); - //} while (ppFrontVgaItr != &front_vga[16]); + // ppFrontVgaItr = front_vga; + // do { + // pFrontVgaToFre = (void **)ppFrontVgaItr++; + // fre(pFrontVgaToFre); + // } while (ppFrontVgaItr != &front_vga[16]); if (iBlockIdx >= CAR_DESIGN_AUTO) { for (int i = 0; i < 16; ++i) { - fre((void**)&cartex_vga[i]); + fre((void **)&cartex_vga[i]); } - //ppCartexVgaItr = cartex_vga; - //do { - // pCartexVgaToFre = (void **)ppCartexVgaItr++; - // fre(pCartexVgaToFre); - //} while (ppCartexVgaItr != &cartex_vga[16]); + // ppCartexVgaItr = cartex_vga; + // do { + // pCartexVgaToFre = (void **)ppCartexVgaItr++; + // fre(pCartexVgaToFre); + // } while (ppCartexVgaItr != &cartex_vga[16]); remove_mapsels(); } gfx_size = p_tex_size; @@ -627,38 +623,65 @@ void select_screen() menu_render_sprite(mr, 6, 3, 52, 334, 0, pal_addr); } else { menu_render_sprite(mr, 6, 1, 52, 334, 0, pal_addr); - menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, sel_posns[iMenuSelection].x, sel_posns[iMenuSelection].y, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, + sel_posns[iMenuSelection].x, sel_posns[iMenuSelection].y, + 0x8Fu, 0, pal_addr); } if (game_type == 1) { - menu_render_text(mr, 2, language_buffer, font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, language_buffer, font2_ascii, font2_offsets, + sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, + pal_addr); if (Race) - menu_render_text(mr, 2, &language_buffer[128], font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[128], font2_ascii, + font2_offsets, sel_posns[3].x + 132, + sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); else - menu_render_text(mr, 2, &language_buffer[64], font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[64], font2_ascii, + font2_offsets, sel_posns[3].x + 132, + sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); } else { - menu_render_text(mr, 2, &language_buffer[256], font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[320], font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[256], font2_ascii, font2_offsets, + sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &language_buffer[320], font2_ascii, font2_offsets, + sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, + pal_addr); } - menu_render_text(mr, 2, &language_buffer[192], font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, config_buffer, font2_ascii, font2_offsets, sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[384], font2_ascii, font2_offsets, sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[448], font2_ascii, font2_offsets, sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[512], font2_ascii, font2_offsets, sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &config_buffer[640], font2_ascii, font2_offsets, sel_posns[7].x + 132, sel_posns[7].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[192], font2_ascii, font2_offsets, + sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, config_buffer, font2_ascii, font2_offsets, + sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &language_buffer[384], font2_ascii, font2_offsets, + sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &language_buffer[448], font2_ascii, font2_offsets, + sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &language_buffer[512], font2_ascii, font2_offsets, + sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, &config_buffer[640], font2_ascii, font2_offsets, + sel_posns[7].x + 132, sel_posns[7].y + 7, 0x8Fu, 2u, + pal_addr); if (game_type == 1) { menu_render_sprite(mr, 14, (TrackLoad - 1) / 8, 500, 300, 0, pal_addr); if (TrackLoad <= 0) { if (TrackLoad) - menu_render_text(mr, 2, "EDITOR", font2_ascii, font2_offsets, 190, 350, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 2, "EDITOR", font2_ascii, font2_offsets, 190, + 350, 0x8Fu, 0, pal_addr); else - menu_render_text(mr, 2, "TRACK ZERO", font2_ascii, font2_offsets, 190, 350, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 2, "TRACK ZERO", font2_ascii, font2_offsets, 190, + 350, 0x8Fu, 0, pal_addr); } else if (TrackLoad >= 17) { menu_render_sprite(mr, 13, TrackLoad - 17, 190, 356, 0, pal_addr); } else { menu_render_sprite(mr, 3, TrackLoad - 1, 190, 356, 0, pal_addr); } menu_render_load_track_mesh(mr, palette); - menu_render_draw_track_preview(mr, cur_TrackZ, 1280, iRotation, PREVIEW_X, TRACK_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + menu_render_draw_track_preview(mr, cur_TrackZ, 1280, iRotation, PREVIEW_X, + TRACK_PREVIEW_Y, PREVIEW_W, PREVIEW_H); menu_render_set_layer(mr, MENU_LAYER_FOREGROUND); if (game_type < 2) { iCurLaps = cur_laps[level]; @@ -666,8 +689,10 @@ void select_screen() if (competitors == 2) NoOfLaps = iCurLaps / 2; sprintf(buffer, "%s: %i", &language_buffer[4544], NoOfLaps); - menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 16, 0x8Fu, 1u, pal_addr); - menu_render_text(mr, 15, &language_buffer[4608], font1_ascii, font1_offsets, 420, 34, 0x8Fu, 1u, pal_addr); + menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 16, + 0x8Fu, 1u, pal_addr); + menu_render_text(mr, 15, &language_buffer[4608], font1_ascii, + font1_offsets, 420, 34, 0x8Fu, 1u, pal_addr); if (RecordCars[TrackLoad] < 0) { sprintf(buffer, "%s", RecordNames[TrackLoad]); } else { @@ -677,41 +702,41 @@ void select_screen() iMinutes = iLapTime / 6000; iSeconds = (iLapTime / 100) % 60; int iHundredths = iLapTime % 100; - sprintf( - buffer, - "%s - %s - %02i:%02i:%02i", - RecordNames[TrackLoad], - CompanyNames[RecordCars[TrackLoad] & 0xF], - iMinutes, - iSeconds, - iHundredths); + sprintf(buffer, "%s - %s - %02i:%02i:%02i", RecordNames[TrackLoad], + CompanyNames[RecordCars[TrackLoad] & 0xF], iMinutes, iSeconds, + iHundredths); - //dRecordLap = RecordLaps[TrackLoad] * 100.0; + // dRecordLap = RecordLaps[TrackLoad] * 100.0; ////_CHP(); - //SET_LODWORD(llRecordLap, (int)dRecordLap); - //SET_HIDWORD(llRecordLap, (int)dRecordLap >> 31); - //iMinutes = llRecordLap / 6000; - //SET_LODWORD(llRecordLap, (int)dRecordLap); - //iSeconds = (int)(llRecordLap / 100) % 60; - //SET_LODWORD(llRecordLap, (int)dRecordLap); - //sprintf( - // buffer, - // "%s - %s - %02i:%02i:%02i", - // RecordNames[TrackLoad], - // CompanyNames[RecordCars[TrackLoad] & 0xF], - // iMinutes, - // iSeconds, - // (unsigned int)(llRecordLap % 100)); + // SET_LODWORD(llRecordLap, (int)dRecordLap); + // SET_HIDWORD(llRecordLap, (int)dRecordLap >> 31); + // iMinutes = llRecordLap / 6000; + // SET_LODWORD(llRecordLap, (int)dRecordLap); + // iSeconds = (int)(llRecordLap / 100) % 60; + // SET_LODWORD(llRecordLap, (int)dRecordLap); + // sprintf( + // buffer, + // "%s - %s - %02i:%02i:%02i", + // RecordNames[TrackLoad], + // CompanyNames[RecordCars[TrackLoad] & 0xF], + // iMinutes, + // iSeconds, + // (unsigned int)(llRecordLap % 100)); } - menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 52, 0x8Fu, 1u, pal_addr); + menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 52, + 0x8Fu, 1u, pal_addr); } } else if (iBlockIdx >= CAR_DESIGN_AUTO) { if (iBlockIdx == CAR_DESIGN_F1WACK) { menu_render_load_car_mesh(mr, CAR_DESIGN_F1WACK, palette); - menu_render_draw_car_preview(mr, 1280.0f, 6000.0f, Car[0].nYaw, PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + menu_render_draw_car_preview(mr, 1280.0f, 6000.0f, Car[0].nYaw, + PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, + PREVIEW_H); } else { menu_render_load_car_mesh(mr, iBlockIdx, palette); - menu_render_draw_car_preview(mr, 1280.0f, 2200.0f, Car[0].nYaw, PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + menu_render_draw_car_preview(mr, 1280.0f, 2200.0f, Car[0].nYaw, + PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, + PREVIEW_H); } if (iBlockIdx < CAR_DESIGN_SUICYCO) menu_render_sprite(mr, 3, iBlockIdx, 190, 356, 0, pal_addr); @@ -720,36 +745,38 @@ void select_screen() menu_render_sprite(mr, 5, player_type, -4, 247, 0, pal_addr); menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); switch (iMenuSelection) { - case 1: - if (game_type == 1) - iBlockIdx2 = 8; - else - iBlockIdx2 = 1; - menu_render_sprite(mr, 4, iBlockIdx2, 76, 257, -1, pal_addr); - break; - case 3: - if (game_type == 1 && Race > 0) - goto LABEL_102; - menu_render_sprite(mr, 4, 3, 76, 257, -1, pal_addr); - break; - case 6: - LABEL_102: - menu_render_sprite(mr, 4, 9, 76, 257, -1, pal_addr); - break; - case 7: - menu_render_sprite(mr, 4, 6, 76, 257, -1, pal_addr); - break; - case 8: - menu_render_sprite(mr, 4, 7, 76, 257, -1, pal_addr); - break; - default: - menu_render_sprite(mr, 4, iMenuSelection, 76, 257, -1, pal_addr); - break; + case 1: + if (game_type == 1) + iBlockIdx2 = 8; + else + iBlockIdx2 = 1; + menu_render_sprite(mr, 4, iBlockIdx2, 76, 257, -1, pal_addr); + break; + case 3: + if (game_type == 1 && Race > 0) + goto LABEL_102; + menu_render_sprite(mr, 4, 3, 76, 257, -1, pal_addr); + break; + case 6: + LABEL_102: + menu_render_sprite(mr, 4, 9, 76, 257, -1, pal_addr); + break; + case 7: + menu_render_sprite(mr, 4, 6, 76, 257, -1, pal_addr); + break; + case 8: + menu_render_sprite(mr, 4, 7, 76, 257, -1, pal_addr); + break; + default: + menu_render_sprite(mr, 4, iMenuSelection, 76, 257, -1, pal_addr); + break; } if (iBlockIdx < CAR_DESIGN_AUTO) - menu_render_text(mr, 15, &language_buffer[4160], font1_ascii, font1_offsets, 400, 200, 0xE7u, 1u, pal_addr); + menu_render_text(mr, 15, &language_buffer[4160], font1_ascii, + font1_offsets, 400, 200, 0xE7u, 1u, pal_addr); if (iQuitConfirmed) - menu_render_text(mr, 15, &language_buffer[3456], font1_ascii, font1_offsets, 400, 250, 0xE7u, 1u, pal_addr); + menu_render_text(mr, 15, &language_buffer[3456], font1_ascii, + font1_offsets, 400, 250, 0xE7u, 1u, pal_addr); show_received_mesage(); menu_render_end_frame(mr); if (SnapshotShouldStop()) @@ -791,9 +818,9 @@ void select_screen() } cheat_mode |= CHEAT_MODE_CLONES; - //iCheatMode = cheat_mode; - //BYTE1(iCheatMode) = BYTE1(cheat_mode) | 0x40; - //cheat_mode = iCheatMode; + // iCheatMode = cheat_mode; + // BYTE1(iCheatMode) = BYTE1(cheat_mode) | 0x40; + // cheat_mode = iCheatMode; iBlockIdx = switch_same - 666; } else if (switch_same < 0) { @@ -808,9 +835,9 @@ void select_screen() } cheat_mode &= ~CHEAT_MODE_CLONES; - //iCheatMode2 = cheat_mode; - //BYTE1(iCheatMode2) = BYTE1(cheat_mode) & 0xBF; - //cheat_mode = iCheatMode2; + // iCheatMode2 = cheat_mode; + // BYTE1(iCheatMode2) = BYTE1(cheat_mode) & 0xBF; + // cheat_mode = iCheatMode2; } if (switch_sets) { if (game_type != 1 && iBlockIdx >= CAR_DESIGN_AUTO) { @@ -844,7 +871,7 @@ void select_screen() UpdateSDL(); if (!fatkbhit()) { nNewYaw = Car[0].nYaw + 32 * nFrames; - //HIBYTE(nNewYaw) &= 0x3Fu; + // HIBYTE(nNewYaw) &= 0x3Fu; nNewYaw &= 0x3FFF; Car[0].nYaw = nNewYaw; iRotation = ((uint16)iRotation + 32 * nFrames) & 0x3FFF; @@ -855,7 +882,7 @@ void select_screen() if (iQuitConfirmed) break; if (byKey) { - if (byKey == 13) // KEY_ENTER + if (byKey == 13) // KEY_ENTER { if (iBlockIdx >= CAR_DESIGN_AUTO) { ppCartexVgaToFree_2 = (void **)cartex_vga; @@ -865,7 +892,8 @@ void select_screen() while (ppCartexVgaToFree_2 != (void **)&cartex_vga[16]); remove_mapsels(); } - if ((iMenuSelection >= 0 && iMenuSelection <= 5) || iMenuSelection == 7) + if ((iMenuSelection >= 0 && iMenuSelection <= 5) || + iMenuSelection == 7) sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // GPU fade-out before leaving main menu to sub-menus // (main menu is GPU-rendered, scrbuf is stale, so software @@ -886,61 +914,61 @@ void select_screen() fre((void **)&front_vga[14]); } switch (iMenuSelection) { - case 0: - select_car(); - break; - case 1: - if (game_type == 1) - select_disk(); - else - select_track(); - break; - case 2: - select_configure(); - break; - case 3: - if (game_type == 1 && Race > 0) { - last_type = game_type; - game_type = 3; - iContinue = -1; - } else { - select_players(); - } - break; - case 4: - select_type(); - break; - case 5: - iContinue = -1; - replaytype = 2; - break; - case 6: + case 0: + select_car(); + break; + case 1: + if (game_type == 1) + select_disk(); + else + select_track(); + break; + case 2: + select_configure(); + break; + case 3: + if (game_type == 1 && Race > 0) { last_type = game_type; - game_type = 4; + game_type = 3; iContinue = -1; - break; - case 7: - iQuitConfirmed = -1; - break; - case 8: - if (iBlockIdx >= CAR_DESIGN_AUTO) { - iContinue = -1; - sfxsample(SOUND_SAMPLE_START, 0x8000); - netCD = 0; - int iTargetTicks = ticks + 108; - if (soundon && iTargetTicks > ticks) { - while (iTargetTicks > ticks) - UpdateSDL(); - } - while (fatkbhit()) { + } else { + select_players(); + } + break; + case 4: + select_type(); + break; + case 5: + iContinue = -1; + replaytype = 2; + break; + case 6: + last_type = game_type; + game_type = 4; + iContinue = -1; + break; + case 7: + iQuitConfirmed = -1; + break; + case 8: + if (iBlockIdx >= CAR_DESIGN_AUTO) { + iContinue = -1; + sfxsample(SOUND_SAMPLE_START, 0x8000); + netCD = 0; + int iTargetTicks = ticks + 108; + if (soundon && iTargetTicks > ticks) { + while (iTargetTicks > ticks) UpdateSDL(); - fatgetch(); - } - replaytype = replay_record; } - break; - default: - break; + while (fatkbhit()) { + UpdateSDL(); + fatgetch(); + } + replaytype = replay_record; + } + break; + default: + break; } fre((void **)&front_vga[3]); fre((void **)&front_vga[13]); @@ -975,11 +1003,11 @@ void select_screen() } else { byKey2 = fatgetch(); if (byKey2 >= 0x48u) { - if (byKey2 <= 0x48u) // KEY_DOWN + if (byKey2 <= 0x48u) // KEY_DOWN { if (--iMenuSelection < 0) iMenuSelection = 0; - } else if (byKey2 == 80 && ++iMenuSelection > 8)// KEY_UP + } else if (byKey2 == 80 && ++iMenuSelection > 8) // KEY_UP { iMenuSelection = 8; } @@ -1017,9 +1045,9 @@ void select_screen() netCD = -1; } else { localCD = cdpresent(); - //removed by ROLLER, don't error for no CD - //if (!localCD) - // cd_error = -1; + // removed by ROLLER, don't error for no CD + // if (!localCD) + // cd_error = -1; } } Race = ((uint8)TrackLoad - 1) & 7; @@ -1046,11 +1074,9 @@ void select_screen() if (racers > 0) { int iMaxRacers = racers; int iNonCompetitorIdx = 0; - for (int i = 0; i < iMaxRacers; i++) - { + for (int i = 0; i < iMaxRacers; i++) { // Skip occupied non-competitor slots - while (non_competitors[iNonCompetitorIdx] != 0) - { + while (non_competitors[iNonCompetitorIdx] != 0) { iNonCompetitorIdx++; } // Store the index of the first available non-competitor slot @@ -1058,24 +1084,23 @@ void select_screen() // Move to next slot for next iteration iNonCompetitorIdx++; } - //iMaxRacerOffset = 4 * racers; - //iGridOffset = 0; - //do { - // for (j = 4 * iNonCompetitorIdx; *(int *)((char *)non_competitors + j); j += 4) - // ++iNonCompetitorIdx; - // grid[iGridOffset / 4u] = iNonCompetitorIdx; - // iGridOffset += 4; - // ++iNonCompetitorIdx; - //} while (iGridOffset < iMaxRacerOffset); + // iMaxRacerOffset = 4 * racers; + // iGridOffset = 0; + // do { + // for (j = 4 * iNonCompetitorIdx; *(int *)((char *)non_competitors + + // j); j += 4) + // ++iNonCompetitorIdx; + // grid[iGridOffset / 4u] = iNonCompetitorIdx; + // iGridOffset += 4; + // ++iNonCompetitorIdx; + // } while (iGridOffset < iMaxRacerOffset); } iRacersIdx = racers; iNonCompetitorIdx2 = 0; if (racers < numcars) { - for (int i = racers; i < numcars; i++) - { + for (int i = racers; i < numcars; i++) { // Skip empty non-competitor slots (find occupied ones) - while (non_competitors[iNonCompetitorIdx2] == 0) - { + while (non_competitors[iNonCompetitorIdx2] == 0) { iNonCompetitorIdx2++; } iRacersIdx++; @@ -1084,60 +1109,63 @@ void select_screen() // Move to next slot for next iteration iNonCompetitorIdx2++; } - //iRacersOffset2 = 4 * racers; - //iMaxRacersOffset2 = 4 * numcars; - //do { - // for (j = 4 * iNonCompetitorIdx2; !*(int *)((char *)non_competitors + j); j += 4) - // ++iNonCompetitorIdx2; - // ++iRacersIdx; - // grid[iRacersOffset2 / 4u] = iNonCompetitorIdx2; - // iRacersOffset2 += 4; - // ++iNonCompetitorIdx2; - //} while (iRacersOffset2 < iMaxRacersOffset2); + // iRacersOffset2 = 4 * racers; + // iMaxRacersOffset2 = 4 * numcars; + // do { + // for (j = 4 * iNonCompetitorIdx2; !*(int *)((char *)non_competitors + + // j); j += 4) + // ++iNonCompetitorIdx2; + // ++iRacersIdx; + // grid[iRacersOffset2 / 4u] = iNonCompetitorIdx2; + // iRacersOffset2 += 4; + // ++iNonCompetitorIdx2; + // } while (iRacersOffset2 < iMaxRacersOffset2); } if (game_type == 1 && Race > 0) { if (racers > 0) { - for (int i = 0; i <= racers; i++) - { + for (int i = 0; i <= racers; i++) { grid[i] = champorder[i]; } - //iRacersBytes = 4 * racers; - //iOffset = 0; - //do { - // iOffset += 4; - // // offsets into grid and champorder - // finished_car[iOffset / 4 + 15] = teamorder[iOffset / 4 + 7]; - //} while ((int)iOffset < iRacersBytes); + // iRacersBytes = 4 * racers; + // iOffset = 0; + // do { + // iOffset += 4; + // // offsets into grid and champorder + // finished_car[iOffset / 4 + 15] = teamorder[iOffset / 4 + 7]; + // } while ((int)iOffset < iRacersBytes); } } else { int iShuffleIterations = 6 * racers; int iNetworkGridSeed = random_seed; - for (int k = 0; k < iShuffleIterations; k++) - { - // Generate two random indices within the racers range - //int iRandIdx1 = ROLLERrandRaw() % racers; - //int iRandIdx2 = ROLLERrandRaw() % racers; - int iRandIdx1 = network_on ? NetworkGridRandRange(racers, &iNetworkGridSeed) : GetHighOrderRand(racers, ROLLERrandRaw()); - int iRandIdx2 = network_on ? NetworkGridRandRange(racers, &iNetworkGridSeed) : GetHighOrderRand(racers, ROLLERrandRaw()); + for (int k = 0; k < iShuffleIterations; k++) { + // Generate two random indices within the racers range + // int iRandIdx1 = ROLLERrandRaw() % racers; + // int iRandIdx2 = ROLLERrandRaw() % racers; + int iRandIdx1 = network_on + ? NetworkGridRandRange(racers, &iNetworkGridSeed) + : GetHighOrderRand(racers, ROLLERrandRaw()); + int iRandIdx2 = network_on + ? NetworkGridRandRange(racers, &iNetworkGridSeed) + : GetHighOrderRand(racers, ROLLERrandRaw()); - // Swap grid elements - int iGridTemp = grid[iRandIdx1]; - grid[iRandIdx1] = grid[iRandIdx2]; - grid[iRandIdx2] = iGridTemp; + // Swap grid elements + int iGridTemp = grid[iRandIdx1]; + grid[iRandIdx1] = grid[iRandIdx2]; + grid[iRandIdx2] = iGridTemp; } - //iRacers = racers; - //iRacersOffset = 6 * racers; - //for (k = 0; k < iRacersOffset; grid[j] = iGridTemp) { - // iRandVal1 = rand(j); - // iRandIdx1 = (iRacers * iRandVal1 - // - (__CFSHL__((iRacers * iRandVal1) >> 31, 15) - // + ((iRacers * iRandVal1) >> 31 << 15))) >> 15; - // iRandVal2 = rand(iRandIdx1); - // j = (iRacers * iRandVal2 - (__CFSHL__((iRacers * iRandVal2) >> 31, 15) + ((iRacers * iRandVal2) >> 31 << 15))) >> 15; - // iGridTemp = grid[iRandIdx1]; - // grid[iRandIdx1] = grid[j]; - // ++k; - //} + // iRacers = racers; + // iRacersOffset = 6 * racers; + // for (k = 0; k < iRacersOffset; grid[j] = iGridTemp) { + // iRandVal1 = rand(j); + // iRandIdx1 = (iRacers * iRandVal1 + // - (__CFSHL__((iRacers * iRandVal1) >> 31, 15) + // + ((iRacers * iRandVal1) >> 31 << 15))) >> 15; + // iRandVal2 = rand(iRandIdx1); + // j = (iRacers * iRandVal2 - (__CFSHL__((iRacers * iRandVal2) >> 31, + // 15) + ((iRacers * iRandVal2) >> 31 << 15))) >> 15; iGridTemp = + // grid[iRandIdx1]; grid[iRandIdx1] = grid[j]; + // ++k; + // } for (m = 0; m < players; ++m) { // calculate target starting pos based on difficulty @@ -1156,7 +1184,7 @@ void select_screen() // if human is starting too far back, move them forward if (iHumanIdx < iTargetPos) { // Find first non-human player at or after target pos - for (iNonHumanIdx = iTargetPos; ; ++iNonHumanIdx) { + for (iNonHumanIdx = iTargetPos;; ++iNonHumanIdx) { iSwapGrid1 = grid[iNonHumanIdx]; if (!human_control[iSwapGrid1]) break; @@ -1167,7 +1195,6 @@ void select_screen() grid[iNonHumanIdx] = iSwapGrid2; } } - } } StartPressed = 0; diff --git a/PROJECTS/ROLLER/frontend_select_car.c b/PROJECTS/ROLLER/frontend_select_car.c index d632a94c..c4593b43 100644 --- a/PROJECTS/ROLLER/frontend_select_car.c +++ b/PROJECTS/ROLLER/frontend_select_car.c @@ -26,11 +26,10 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif -static void snapshot_setup_frontend_scene(void) -{ +static void snapshot_setup_frontend_scene(void) { load_language_file(szSelectEng, 0); load_language_file(szConfigEng, 1); frontend_on = -1; @@ -54,72 +53,72 @@ static void snapshot_setup_frontend_scene(void) FindShades(); } -void snapshot_render_menu_select_car(void) -{ +void snapshot_render_menu_select_car(void) { snapshot_setup_frontend_menu_state(0); select_car(); } - //------------------------------------------------------------------------------------------------- -//00041CA0 -void select_car() -{ - eCarType currentCarType; // ebx - int iSelectedCar; // ebp - int iPlayer1Car; // edi - eCarType carType; // eax - int iLoadCarTextures; // edx - int iCartexLoaded; // esi - int iCarIdx; // eax - int iCarPieOffset; // edx - int iInvertedPieValue; // ebx - int iCurrentCarSelectorPos; // esi - int iPlayerNameX; // eax - int iAnimationCounter; // eax - int iPieChartIndex; // edx - int iCarStatsOffset; // ebx - int iCurrentPieValue; // ecx - int iNextPieValue; // ecx - int iNewZoomDistance; // ebx - int iCarAllocationStatus; // edx - int iCarDesignIndex; // eax - uint8 **ppTextureArray; // edi - void **ppCurrentTexture; // eax - int iPlayerCarIndex; // eax - eCarType eNewCarType; // eax - int iTextureLoadedStatus; // ecx - int iLoadTextureFlag; // edx - int iPlayerLoopCounter; // edx +// 00041CA0 +void select_car() { + eCarType currentCarType; // ebx + int iSelectedCar; // ebp + int iPlayer1Car; // edi + eCarType carType; // eax + int iLoadCarTextures; // edx + int iCartexLoaded; // esi + int iCarIdx; // eax + int iCarPieOffset; // edx + int iInvertedPieValue; // ebx + int iCurrentCarSelectorPos; // esi + int iPlayerNameX; // eax + int iAnimationCounter; // eax + int iPieChartIndex; // edx + int iCarStatsOffset; // ebx + int iCurrentPieValue; // ecx + int iNextPieValue; // ecx + int iNewZoomDistance; // ebx + int iCarAllocationStatus; // edx + int iCarDesignIndex; // eax + uint8 **ppTextureArray; // edi + void **ppCurrentTexture; // eax + int iPlayerCarIndex; // eax + eCarType eNewCarType; // eax + int iTextureLoadedStatus; // ecx + int iLoadTextureFlag; // edx + int iPlayerLoopCounter; // edx unsigned int uiNavigationDirection; // ebx - uint8 byInputKey; // al - int16 nRotationAngle; // ax - uint8 **ppCleanupTextureArray; // edx - void **ppCleanupTexture; // eax - float fCarDrawDistance; // [esp+0h] [ebp-80h] - unsigned int uiPlayerIndex; // [esp+8h] [ebp-78h] - int blockIdxAy[7]; // [esp+Ch] [ebp-74h] BYREF - int iStatAnimationFrame; // [esp+28h] [ebp-58h] - int iOriginalCarSelection; // [esp+2Ch] [ebp-54h] - int iActivePlayer; // [esp+30h] [ebp-50h] - int iDelayBeforeRotation; // [esp+34h] [ebp-4Ch] - int iZoomSpeed; // [esp+38h] [ebp-48h] - int iZoomDistance; // [esp+3Ch] [ebp-44h] - int byMenuExitFlag; // [esp+40h] [ebp-40h] - unsigned int uiNetworkPlayerIndex; // [esp+44h] [ebp-3Ch] - char *szPlayerName; // [esp+48h] [ebp-38h] - char *szCurrentCompanyName = '\0'; // [esp+4Ch] [ebp-34h] - int iTargetPieValue; // [esp+50h] [ebp-30h] - int iNextCarIndex; // [esp+58h] [ebp-28h] - unsigned int uiNetworkLoop; // [esp+5Ch] [ebp-24h] - int iPieChartY; // [esp+60h] [ebp-20h] - int iNetworkPlayerCount; // [esp+64h] [ebp-1Ch] + uint8 byInputKey; // al + int16 nRotationAngle; // ax + uint8 **ppCleanupTextureArray; // edx + void **ppCleanupTexture; // eax + float fCarDrawDistance; // [esp+0h] [ebp-80h] + unsigned int uiPlayerIndex; // [esp+8h] [ebp-78h] + int blockIdxAy[7]; // [esp+Ch] [ebp-74h] BYREF + int iStatAnimationFrame; // [esp+28h] [ebp-58h] + int iOriginalCarSelection; // [esp+2Ch] [ebp-54h] + int iActivePlayer; // [esp+30h] [ebp-50h] + int iDelayBeforeRotation; // [esp+34h] [ebp-4Ch] + int iZoomSpeed; // [esp+38h] [ebp-48h] + int iZoomDistance; // [esp+3Ch] [ebp-44h] + int byMenuExitFlag; // [esp+40h] [ebp-40h] + unsigned int uiNetworkPlayerIndex; // [esp+44h] [ebp-3Ch] + char *szPlayerName; // [esp+48h] [ebp-38h] + char *szCurrentCompanyName = '\0'; // [esp+4Ch] [ebp-34h] + int iTargetPieValue; // [esp+50h] [ebp-30h] + int iNextCarIndex; // [esp+58h] [ebp-28h] + unsigned int uiNetworkLoop; // [esp+5Ch] [ebp-24h] + int iPieChartY; // [esp+60h] [ebp-20h] + int iNetworkPlayerCount; // [esp+64h] [ebp-1Ch] int iFrontendSpeechPending; - fade_palette(0); // Initialize screen fade and prepare UI graphics + fade_palette(0); // Initialize screen fade and prepare UI graphics front_fade = 0; - front_vga[3] = (tBlockHeader*)load_picture("carnames.bm"); // Load car company name graphics (carnames.bm) and car selection UI (selcar2.bm) - front_vga[7] = (tBlockHeader*)load_picture("selcar2.bm"); // Load car selection UI bitmap + front_vga[3] = (tBlockHeader *)load_picture( + "carnames.bm"); // Load car company name graphics (carnames.bm) and car + // selection UI (selcar2.bm) + front_vga[7] = (tBlockHeader *)load_picture( + "selcar2.bm"); // Load car selection UI bitmap // Restore palette and create GPU textures for sub-menu rendering { extern tColor palette[]; @@ -132,10 +131,14 @@ void select_car() } } car_request = 0; - byMenuExitFlag = 0; // Initialize selection state: byMenuExitFlag=0 (stay in menu), iOriginalCarSelection=-1 (no backup) - iOriginalCarSelection = -1; // byExitCode = 0 - stay in selection, -1 = exit to menu - iPlayer1Car = Players_Cars[player1_car]; // iSavedCarIndex = -1 initially, stores original car selection - if (game_type == 1) // Championship mode: restrict car changes except for first race (Race == 0) + byMenuExitFlag = 0; // Initialize selection state: byMenuExitFlag=0 (stay in + // menu), iOriginalCarSelection=-1 (no backup) + iOriginalCarSelection = + -1; // byExitCode = 0 - stay in selection, -1 = exit to menu + iPlayer1Car = Players_Cars[player1_car]; // iSavedCarIndex = -1 initially, + // stores original car selection + if (game_type == 1) // Championship mode: restrict car changes except for + // first race (Race == 0) { Race = ((uint8)TrackLoad - 1) & 7; if ((((uint8)TrackLoad - 1) & 7) != 0) @@ -147,7 +150,9 @@ void select_car() iLoadCarTextures = 1; iCartexLoaded = car_texs_loaded[carType]; if (iCartexLoaded == -1) { - LoadCarTexture(carType, 1u); // Car texture not loaded yet - load it now and mark as loaded + LoadCarTexture( + carType, + 1u); // Car texture not loaded yet - load it now and mark as loaded iLoadCarTextures = 2; car_texmap[iPlayer1Car] = 1; car_texs_loaded[currentCarType] = 1; @@ -156,12 +161,14 @@ void select_car() } LoadCarTextures = iLoadCarTextures; } - if (iPlayer1Car < CAR_DESIGN_AUTO) // Initialize car statistics pie chart display blocks (7 stats: Speed, Acceleration, etc.) + if (iPlayer1Car < + CAR_DESIGN_AUTO) // Initialize car statistics pie chart display blocks (7 + // stats: Speed, Acceleration, etc.) { for (int i = 0; i < 7; ++i) { blockIdxAy[i] = 8; } - //memset(blockIdxAy, 8, 7 * sizeof(int)); + // memset(blockIdxAy, 8, 7 * sizeof(int)); //_STOSD(blockIdxAy, 8, currentCarType * 4, 7u); } else { iCarIdx = 0; @@ -172,22 +179,25 @@ void select_car() blockIdxAy[iCarIdx - 1] = iInvertedPieValue; } while (iCarIdx < 7); } - iZoomDistance = 2000; // Setup 3D car zoom animation: start at 2000 units, zoom out to 40000 (-2000 speed) + iZoomDistance = 2000; // Setup 3D car zoom animation: start at 2000 units, + // zoom out to 40000 (-2000 speed) iZoomSpeed = -2000; - if (iPlayer1Car >= CAR_DESIGN_SUICYCO) // Position car selector cursor + if (iPlayer1Car >= CAR_DESIGN_SUICYCO) // Position car selector cursor iCurrentCarSelectorPos = 8; else iCurrentCarSelectorPos = iPlayer1Car; - if (iCurrentCarSelectorPos < 0) // Clamp car selector position to valid range (0-8, where 8 = random) + if (iCurrentCarSelectorPos < + 0) // Clamp car selector position to valid range (0-8, where 8 = random) iCurrentCarSelectorPos = 8; - iDelayBeforeRotation = 36; // 36-frame delay before starting car rotation animation + iDelayBeforeRotation = + 36; // 36-frame delay before starting car rotation animation iActivePlayer = 0; iFrontendSpeechPending = 0; frames = 0; if (!byMenuExitFlag) { - if (iOriginalCarSelection >= 0) //check added by ROLLER for zig build + if (iOriginalCarSelection >= 0) // check added by ROLLER for zig build szCurrentCompanyName = CompanyNames[iOriginalCarSelection]; - do { // Handle game type switches (race type, championship, etc.) + do { // Handle game type switches (race type, championship, etc.) if (switch_types) { game_type = switch_types - 1; if (switch_types == 1 && competitors == 1) @@ -201,113 +211,153 @@ void select_car() iStatAnimationFrame = frames; frames = 0; int bStartedFadeIn = 0; - if (SoundCard && front_fade && iFrontendSpeechPending && sfxplaying(SOUND_SAMPLE_CARIN) == 0) { + if (SoundCard && front_fade && iFrontendSpeechPending && + sfxplaying(SOUND_SAMPLE_CARIN) == 0) { frontendsample(0x8000); iFrontendSpeechPending = 0; } - { // RENDER FRAME (GPU) - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_frame(mr); - if (!front_fade) { - front_fade = -1; - bStartedFadeIn = -1; - menu_render_begin_fade(mr, 1, 32); - } - menu_render_background(mr, 0); - if (player_type == 2) // Two-player mode - { - if (iActivePlayer) - menu_render_sprite(mr, 1, 6, head_x, head_y, 0, pal_addr); - else - menu_render_sprite(mr, 1, 5, head_x, head_y, 0, pal_addr); - menu_render_sprite(mr, 1, 7, 200, 56, 0, pal_addr); - } else { - menu_render_sprite(mr, 1, 1, head_x, head_y, 0, pal_addr); - } - menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); - if (iPlayer1Car < CAR_DESIGN_AUTO) { - menu_render_text(mr, 15, &language_buffer[4160], font1_ascii, font1_offsets, 400, 200, 0xE7u, 1u, pal_addr); - } else { // 3D car preview (GPU mesh rendering) - menu_render_load_car_mesh(mr, iPlayer1Car, palette); - if (iPlayer1Car == CAR_DESIGN_F1WACK) { - menu_render_draw_car_preview(mr, 1280.0f, 6000.0f, Car[0].nYaw, PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, PREVIEW_H); - } else if (iDelayBeforeRotation) { - menu_render_draw_car_preview(mr, 1280.0f, 2200.0f, Car[0].nYaw, PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + { // RENDER FRAME (GPU) + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_frame(mr); + if (!front_fade) { + front_fade = -1; + bStartedFadeIn = -1; + menu_render_begin_fade(mr, 1, 32); + } + menu_render_background(mr, 0); + if (player_type == 2) // Two-player mode + { + if (iActivePlayer) + menu_render_sprite(mr, 1, 6, head_x, head_y, 0, pal_addr); + else + menu_render_sprite(mr, 1, 5, head_x, head_y, 0, pal_addr); + menu_render_sprite(mr, 1, 7, 200, 56, 0, pal_addr); } else { - fCarDrawDistance = (float)iZoomDistance; - menu_render_draw_car_preview(mr, 1280.0f, fCarDrawDistance, Car[0].nYaw, PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + menu_render_sprite(mr, 1, 1, head_x, head_y, 0, pal_addr); } - if (iPlayer1Car < CAR_DESIGN_SUICYCO) - menu_render_sprite(mr, 3, iPlayer1Car, 190, 356, 0, pal_addr); - } - menu_render_set_layer(mr, MENU_LAYER_FOREGROUND); - menu_render_sprite(mr, 7, 0, 560, 20, 0, pal_addr); - uiNetworkLoop = 0; - iPieChartY = 19; // Draw 7 pie chart segments - do { - menu_render_sprite(mr, 7, blockIdxAy[uiNetworkLoop / 4], 568, iPieChartY, 0, pal_addr); - uiNetworkLoop += 4; - iPieChartY += 51; - } while (uiNetworkLoop != 28); - menu_render_sprite(mr, 5, player_type, -4, 247, 0, pal_addr); - menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); - menu_render_sprite(mr, 4, 0, 76, 257, -1, pal_addr); - if (iCurrentCarSelectorPos >= 8) // Draw car selection cursor - { - menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); - } else { - menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); - menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, sel_posns[iCurrentCarSelectorPos].x, sel_posns[iCurrentCarSelectorPos].y, 0x8Fu, 0, pal_addr); - } - menu_render_text(mr, 2, "AUTO ARIEL", font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "DESILVA", font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "PULSE", font2_ascii, font2_offsets, sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "GLOBAL", font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "MILLION PLUS", font2_ascii, font2_offsets, sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "MISSION", font2_ascii, font2_offsets, sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "ZIZIN", font2_ascii, font2_offsets, sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "REISE WAGON", font2_ascii, font2_offsets, sel_posns[7].x + 132, sel_posns[7].y + 7, 0x8Fu, 2u, pal_addr); - if (iCurrentCarSelectorPos < 8 && network_on && (cheat_mode & 0x4000) == 0)// Network mode - { - menu_render_text(mr, 15, &language_buffer[4672], font1_ascii, font1_offsets, 380, 380, 0x8Fu, 2u, pal_addr); - if (allocated_cars[iCurrentCarSelectorPos]) { - iPlayerNameX = 385; - iNetworkPlayerCount = 0; - if (players > 0) { - uiNetworkPlayerIndex = 0; - szPlayerName = player_names[0]; - do { - if (iCurrentCarSelectorPos == Players_Cars[uiNetworkPlayerIndex / 4]) { - if (iPlayerNameX == 385) - uiPlayerIndex = 0; - else - uiPlayerIndex = 2; - menu_render_text(mr, 15, szPlayerName, font1_ascii, font1_offsets, iPlayerNameX, 380, 0x8Fu, uiPlayerIndex, pal_addr); - iPlayerNameX = 620; - } - uiNetworkPlayerIndex += 4; - szPlayerName += 9; - ++iNetworkPlayerCount; - } while (iNetworkPlayerCount < players); + menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); + if (iPlayer1Car < CAR_DESIGN_AUTO) { + menu_render_text(mr, 15, &language_buffer[4160], font1_ascii, + font1_offsets, 400, 200, 0xE7u, 1u, pal_addr); + } else { // 3D car preview (GPU mesh rendering) + menu_render_load_car_mesh(mr, iPlayer1Car, palette); + if (iPlayer1Car == CAR_DESIGN_F1WACK) { + menu_render_draw_car_preview(mr, 1280.0f, 6000.0f, Car[0].nYaw, + PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, + PREVIEW_H); + } else if (iDelayBeforeRotation) { + menu_render_draw_car_preview(mr, 1280.0f, 2200.0f, Car[0].nYaw, + PREVIEW_X, CAR_PREVIEW_Y, PREVIEW_W, + PREVIEW_H); + } else { + fCarDrawDistance = (float)iZoomDistance; + menu_render_draw_car_preview(mr, 1280.0f, fCarDrawDistance, + Car[0].nYaw, PREVIEW_X, CAR_PREVIEW_Y, + PREVIEW_W, PREVIEW_H); } + if (iPlayer1Car < CAR_DESIGN_SUICYCO) + menu_render_sprite(mr, 3, iPlayer1Car, 190, 356, 0, pal_addr); + } + menu_render_set_layer(mr, MENU_LAYER_FOREGROUND); + menu_render_sprite(mr, 7, 0, 560, 20, 0, pal_addr); + uiNetworkLoop = 0; + iPieChartY = 19; // Draw 7 pie chart segments + do { + menu_render_sprite(mr, 7, blockIdxAy[uiNetworkLoop / 4], 568, + iPieChartY, 0, pal_addr); + uiNetworkLoop += 4; + iPieChartY += 51; + } while (uiNetworkLoop != 28); + menu_render_sprite(mr, 5, player_type, -4, 247, 0, pal_addr); + menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); + menu_render_sprite(mr, 4, 0, 76, 257, -1, pal_addr); + if (iCurrentCarSelectorPos >= 8) // Draw car selection cursor + { + menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); } else { - menu_render_text(mr, 15, &language_buffer[4736], font1_ascii, font1_offsets, 385, 380, 0x83u, 0, pal_addr); + menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); + menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, + sel_posns[iCurrentCarSelectorPos].x, + sel_posns[iCurrentCarSelectorPos].y, 0x8Fu, 0, + pal_addr); } + menu_render_text(mr, 2, "AUTO ARIEL", font2_ascii, font2_offsets, + sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "DESILVA", font2_ascii, font2_offsets, + sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "PULSE", font2_ascii, font2_offsets, + sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "GLOBAL", font2_ascii, font2_offsets, + sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "MILLION PLUS", font2_ascii, font2_offsets, + sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "MISSION", font2_ascii, font2_offsets, + sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "ZIZIN", font2_ascii, font2_offsets, + sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "REISE WAGON", font2_ascii, font2_offsets, + sel_posns[7].x + 132, sel_posns[7].y + 7, 0x8Fu, 2u, + pal_addr); + if (iCurrentCarSelectorPos < 8 && network_on && + (cheat_mode & 0x4000) == 0) // Network mode + { + menu_render_text(mr, 15, &language_buffer[4672], font1_ascii, + font1_offsets, 380, 380, 0x8Fu, 2u, pal_addr); + if (allocated_cars[iCurrentCarSelectorPos]) { + iPlayerNameX = 385; + iNetworkPlayerCount = 0; + if (players > 0) { + uiNetworkPlayerIndex = 0; + szPlayerName = player_names[0]; + do { + if (iCurrentCarSelectorPos == + Players_Cars[uiNetworkPlayerIndex / 4]) { + if (iPlayerNameX == 385) + uiPlayerIndex = 0; + else + uiPlayerIndex = 2; + menu_render_text(mr, 15, szPlayerName, font1_ascii, + font1_offsets, iPlayerNameX, 380, 0x8Fu, + uiPlayerIndex, pal_addr); + iPlayerNameX = 620; + } + uiNetworkPlayerIndex += 4; + szPlayerName += 9; + ++iNetworkPlayerCount; + } while (iNetworkPlayerCount < players); + } + } else { + menu_render_text(mr, 15, &language_buffer[4736], font1_ascii, + font1_offsets, 385, 380, 0x83u, 0, pal_addr); + } + } + if (iOriginalCarSelection >= + 0) // Display current player's selected car company name at bottom + { + if (iActivePlayer) + sprintf(buffer, "%s %s", &language_buffer[2880], + CompanyNames[Players_Cars[player2_car]]); + else + sprintf(buffer, "%s %s", &language_buffer[2816], + szCurrentCompanyName); + menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, + 375, 316, 231, 1u, 170, 550, pal_addr); + } + show_received_mesage(); + menu_render_end_frame(mr); + if (SnapshotShouldStop()) + return; } - if (iOriginalCarSelection >= 0) // Display current player's selected car company name at bottom - { - if (iActivePlayer) - sprintf(buffer, "%s %s", &language_buffer[2880], CompanyNames[Players_Cars[player2_car]]); - else - sprintf(buffer, "%s %s", &language_buffer[2816], szCurrentCompanyName); - menu_render_scaled_text(mr, 15, buffer, font1_ascii, font1_offsets, 375, 316, 231, 1u, 170, 550, pal_addr); - } - show_received_mesage(); - menu_render_end_frame(mr); - if (SnapshotShouldStop()) - return; - } - iAnimationCounter = iDelayBeforeRotation; // ANIMATION UPDATE: Rotate pie chart segments during delay period + iAnimationCounter = + iDelayBeforeRotation; // ANIMATION UPDATE: Rotate pie chart segments + // during delay period if (iDelayBeforeRotation) { if (iPlayer1Car >= CAR_DESIGN_AUTO) { iPieChartIndex = 0; @@ -327,34 +377,41 @@ void select_car() } } else { for (int i = 0; i < 7; i++) { - blockIdxAy[i]++; - if (blockIdxAy[i] > 8) { - blockIdxAy[i] = 1; - } + blockIdxAy[i]++; + if (blockIdxAy[i] > 8) { + blockIdxAy[i] = 1; + } } - //do { - // int iIncrementedPieValue = *(int *)((char *)blockIdxAy + iAnimationCounter) + 1; - // *(int *)((char *)blockIdxAy + iAnimationCounter) = iIncrementedPieValue; - // if (iIncrementedPieValue > 8) - // *(int *)((char *)blockIdxAy + iAnimationCounter) = 1; - // iAnimationCounter += 4; - //} while (iAnimationCounter != 28); + // do { + // int iIncrementedPieValue = *(int *)((char *)blockIdxAy + + // iAnimationCounter) + 1; + // *(int *)((char *)blockIdxAy + iAnimationCounter) = + // iIncrementedPieValue; if (iIncrementedPieValue > 8) + // *(int *)((char *)blockIdxAy + iAnimationCounter) = 1; + // iAnimationCounter += 4; + // } while (iAnimationCounter != 28); } - if (!iDelayBeforeRotation) // ZOOM ANIMATION: Handle 3D car zoom in/out with car switching logic + if (!iDelayBeforeRotation) // ZOOM ANIMATION: Handle 3D car zoom in/out + // with car switching logic { iNewZoomDistance = iStatAnimationFrame * iZoomSpeed + iZoomDistance; iZoomDistance = iNewZoomDistance; - if (iNewZoomDistance <= 40000) // Handle car zoom in/out animation and car selection + if (iNewZoomDistance <= + 40000) // Handle car zoom in/out animation and car selection { if (iNewZoomDistance < 4000) { iZoomDistance = 4000; iDelayBeforeRotation = 72; } } else { - iCarAllocationStatus = allocated_cars[iSelectedCar];// Zoom reached maximum - switch cars if available, otherwise restore previous car + iCarAllocationStatus = + allocated_cars[iSelectedCar]; // Zoom reached maximum - switch + // cars if available, otherwise + // restore previous car iZoomDistance = 40000; iZoomSpeed = -iZoomSpeed; - if (iCarAllocationStatus < 2) { // Free old car textures and load new car's textures + if (iCarAllocationStatus < + 2) { // Free old car textures and load new car's textures if (iPlayer1Car >= CAR_DESIGN_AUTO) { iCarDesignIndex = iPlayer1Car; ppTextureArray = cartex_vga; @@ -382,29 +439,29 @@ void select_car() iTextureLoadedStatus = car_texs_loaded[eNewCarType]; if (iTextureLoadedStatus == -1) { - // Texture not loaded yet - load it now - LoadCarTexture(eNewCarType, 1u); - car_texmap[iPlayer1Car] = 1; - car_texs_loaded[eNewCarType] = 1; - iLoadTextureFlag = 2; + // Texture not loaded yet - load it now + LoadCarTexture(eNewCarType, 1u); + car_texmap[iPlayer1Car] = 1; + car_texs_loaded[eNewCarType] = 1; + iLoadTextureFlag = 2; } else { - // Texture already loaded - use existing - car_texmap[iPlayer1Car] = iTextureLoadedStatus; - iLoadTextureFlag = 1; + // Texture already loaded - use existing + car_texmap[iPlayer1Car] = iTextureLoadedStatus; + iLoadTextureFlag = 1; } - //eNewCarType = CarDesigns[iPlayer1Car].carType; - //eCarTypeBackup = eNewCarType; - //uiCarArrayOffset = 4 * iPlayer1Car; - //iTextureLoadedStatus = car_texs_loaded[eNewCarType]; - //iLoadTextureFlag = 1; - //if (iTextureLoadedStatus == -1) { - // LoadCarTexture(eNewCarType, 1u); - // car_texmap[uiCarArrayOffset / 4] = 1; - // car_texs_loaded[eCarTypeBackup] = 1; - // iLoadTextureFlag = 2; - //} else { - // car_texmap[uiCarArrayOffset / 4] = iTextureLoadedStatus; - //} + // eNewCarType = CarDesigns[iPlayer1Car].carType; + // eCarTypeBackup = eNewCarType; + // uiCarArrayOffset = 4 * iPlayer1Car; + // iTextureLoadedStatus = car_texs_loaded[eNewCarType]; + // iLoadTextureFlag = 1; + // if (iTextureLoadedStatus == -1) { + // LoadCarTexture(eNewCarType, 1u); + // car_texmap[uiCarArrayOffset / 4] = 1; + // car_texs_loaded[eCarTypeBackup] = 1; + // iLoadTextureFlag = 2; + // } else { + // car_texmap[uiCarArrayOffset / 4] = iTextureLoadedStatus; + // } LoadCarTextures = iLoadTextureFlag; if (!network_on) check_cars(); @@ -434,7 +491,8 @@ void select_car() frames = 0; } } - if (car_request < 0) // NETWORK CAR REQUESTS: Handle incoming car selection requests from other players + if (car_request < 0) // NETWORK CAR REQUESTS: Handle incoming car + // selection requests from other players { iDelayBeforeRotation = 0; iZoomSpeed = 2000; @@ -445,7 +503,8 @@ void select_car() if ((cheat_mode & 0x4000) != 0) switch_same = iSelectedCar + 666; } - if (switch_same > 0) // CHEAT MODE: Handle "switch_same" command to force all players to same car + if (switch_same > 0) // CHEAT MODE: Handle "switch_same" command to force + // all players to same car { if (switch_same - 666 != Players_Cars[player1_car]) { iSelectedCar = switch_same - 666; @@ -455,19 +514,21 @@ void select_car() iFrontendSpeechPending = 0; if (players > 0) { - for (iPlayerLoopCounter = 0; iPlayerLoopCounter < players; iPlayerLoopCounter++) { - Players_Cars[iPlayerLoopCounter] = switch_same - 666; - } + for (iPlayerLoopCounter = 0; iPlayerLoopCounter < players; + iPlayerLoopCounter++) { + Players_Cars[iPlayerLoopCounter] = switch_same - 666; + } } - //iPlayerLoopCounter = 0; - //if (players > 0) { - // iPlayerArrayOffset = 0; - // do { - // iPlayerArrayOffset += 4; - // ++iPlayerLoopCounter; - // *(int *)((char *)&infinite_laps + iPlayerArrayOffset) = switch_same - 666;// offset into Players_Cars - // } while (iPlayerLoopCounter < players); - //} + // iPlayerLoopCounter = 0; + // if (players > 0) { + // iPlayerArrayOffset = 0; + // do { + // iPlayerArrayOffset += 4; + // ++iPlayerLoopCounter; + // *(int *)((char *)&infinite_laps + iPlayerArrayOffset) = + // switch_same - 666;// offset into Players_Cars + // } while (iPlayerLoopCounter < players); + // } cheat_mode |= CHEAT_MODE_CLONES; } @@ -488,7 +549,8 @@ void select_car() iFrontendSpeechPending = 0; switch_sets = 0; } - if (bStartedFadeIn) // Screen fade-in: Load car voice sample and start playback + if (bStartedFadeIn) // Screen fade-in: Load car voice sample and start + // playback { if (iPlayer1Car >= CAR_DESIGN_AUTO && iPlayer1Car < CAR_DESIGN_SUICYCO) loadfrontendsample(descript[iPlayer1Car]); @@ -498,41 +560,49 @@ void select_car() } uiNavigationDirection = 0; iNextCarIndex = iCurrentCarSelectorPos + 1; - while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle all user input and navigation + while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle all user input and + // navigation { byInputKey = fatgetch(); if (byInputKey < 0x20u) { if (byInputKey < 0xDu) { if (!byInputKey) { switch ((uint8)fatgetch()) { - case 0x48u: - case 0x4Bu: - goto LABEL_152; // Arrow keys: Handle up/down/left/right navigation between cars - case 0x4Du: - case 0x50u: - goto LABEL_153; - default: - continue; + case 0x48u: + case 0x4Bu: + goto LABEL_152; // Arrow keys: Handle up/down/left/right + // navigation between cars + case 0x4Du: + case 0x50u: + goto LABEL_153; + default: + continue; } } - } else if (byInputKey <= 0xDu) // Enter key: Confirm car selection or trigger car switching animation + } else if (byInputKey <= 0xDu) // Enter key: Confirm car selection or + // trigger car switching animation { - if (iCurrentCarSelectorPos != 8 && iCurrentCarSelectorPos != iPlayer1Car || iCurrentCarSelectorPos == 8) { + if (iCurrentCarSelectorPos != 8 && + iCurrentCarSelectorPos != iPlayer1Car || + iCurrentCarSelectorPos == 8) { remove_frontendspeech(); iFrontendSpeechPending = 0; sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); } - if (iCurrentCarSelectorPos == iPlayer1Car - && SoundCard - && frontendspeechhandle != -1 - && DIGISampleDone(frontendspeechhandle)) { //DIGISampleDone(*(int *)&DIGIHandle, frontendspeechhandle)) { + if (iCurrentCarSelectorPos == iPlayer1Car && SoundCard && + frontendspeechhandle != -1 && + DIGISampleDone( + frontendspeechhandle)) { // DIGISampleDone(*(int + // *)&DIGIHandle, + // frontendspeechhandle)) { frontendspeechhandle = -1; frontendsample(0x8000); } if (iCurrentCarSelectorPos == 8) { byMenuExitFlag = -1; - } else if (iPlayer1Car != iCurrentCarSelectorPos - && (allocated_cars[iCurrentCarSelectorPos] < 2 || game_type == 1 && Race > 0)) { + } else if (iPlayer1Car != iCurrentCarSelectorPos && + (allocated_cars[iCurrentCarSelectorPos] < 2 || + game_type == 1 && Race > 0)) { if (network_on) { car_request = iNextCarIndex; broadcast_mode = -9999; @@ -546,14 +616,15 @@ void select_car() iFrontendSpeechPending = 0; } } - } else if (byInputKey == 27) // Escape key: Exit to main menu + } else if (byInputKey == 27) // Escape key: Exit to main menu { byMenuExitFlag = -1; remove_frontendspeech(); iFrontendSpeechPending = 0; sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); } - } else if (byInputKey <= 0x20u) { // Space key: Switch between Player 1 and Player 2 in two-player mode + } else if (byInputKey <= 0x20u) { // Space key: Switch between Player 1 + // and Player 2 in two-player mode if (player_type == 2) { if (iActivePlayer) { iActivePlayer = 0; @@ -571,8 +642,8 @@ void select_car() } } else if (byInputKey < 0x2Du) { if (byInputKey == 43) - LABEL_153: - uiNavigationDirection = 1; + LABEL_153: + uiNavigationDirection = 1; } else { if (byInputKey <= 0x2Du) goto LABEL_152; @@ -580,14 +651,14 @@ void select_car() if (byInputKey <= 0x3Du) goto LABEL_153; if (byInputKey == 95) - LABEL_152: - uiNavigationDirection = 2; + LABEL_152: + uiNavigationDirection = 2; } } UpdateSDL(); - } - if (uiNavigationDirection) // Apply navigation input to move car selector cursor + if (uiNavigationDirection) // Apply navigation input to move car selector + // cursor { if (uiNavigationDirection > 1) { if (--iCurrentCarSelectorPos < 0) @@ -596,12 +667,15 @@ void select_car() iCurrentCarSelectorPos = 8; } } - nRotationAngle = Car[0].nYaw + 32 * iStatAnimationFrame;// Update 3D car rotation angle for spinning animation + nRotationAngle = Car[0].nYaw + + 32 * iStatAnimationFrame; // Update 3D car rotation angle + // for spinning animation nRotationAngle &= 0x3FFFu; Car[0].nYaw = nRotationAngle; UpdateSDL(); - } while (!byMenuExitFlag); // MAIN SELECTION LOOP - Handle UI rendering, input, and car switching + } while (!byMenuExitFlag); // MAIN SELECTION LOOP - Handle UI rendering, + // input, and car switching } // GPU fade-out { diff --git a/PROJECTS/ROLLER/frontend_select_disk.c b/PROJECTS/ROLLER/frontend_select_disk.c index 39ebef07..40a1d396 100644 --- a/PROJECTS/ROLLER/frontend_select_disk.c +++ b/PROJECTS/ROLLER/frontend_select_disk.c @@ -26,50 +26,47 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif -void snapshot_render_menu_select_disk(void) -{ +void snapshot_render_menu_select_disk(void) { snapshot_setup_frontend_menu_state(1); select_disk(); } - //------------------------------------------------------------------------------------------------- -//000411D0 -void select_disk() -{ - int iSelectedSlot; // esi - unsigned int uiMenuMode; // edi - unsigned int uiCupIndex; // eax - uint8 bySlotColor; // al - int iSlotNumber; // ecx +// 000411D0 +void select_disk() { + int iSelectedSlot; // esi + unsigned int uiMenuMode; // edi + unsigned int uiCupIndex; // eax + uint8 bySlotColor; // al + int iSlotNumber; // ecx unsigned int uiSaveCupIndex; // eax - uint8 byCupColor1; // al - uint8 byCupColor2; // al - uint8 byCupColor3; // al - uint8 byTrackColor; // al - uint8 byDifficultyColor; // al - uint8 byLevelColor; // al - uint8 byDamageColor; // al - uint8 byPlayerTypeColor; // al - uint8 byEmptySlotColor; // al - uint32 uiUpdatedCheatFlags; // eax - int iCheatSetLoop; // ebx - uint8 byInputKey; // al - uint8 byExtendedKey; // al - int iSlotYPosition; // [esp+0h] [ebp-24h] - int iChampResult; // [esp+4h] [ebp-20h] - int iExitFlag; // [esp+8h] [ebp-1Ch] - int iSaveTrackNumber; // [esp+Ch] [ebp-18h] - int iY; // [esp+10h] [ebp-14h] - int iSaveArrayIndex; // [esp+14h] [ebp-10h] - int iStatusMessage; // [esp+18h] [ebp-Ch] - int iSlotLoop; // [esp+1Ch] [ebp-8h] - int iMenuCursor; // [esp+20h] [ebp-4h] + uint8 byCupColor1; // al + uint8 byCupColor2; // al + uint8 byCupColor3; // al + uint8 byTrackColor; // al + uint8 byDifficultyColor; // al + uint8 byLevelColor; // al + uint8 byDamageColor; // al + uint8 byPlayerTypeColor; // al + uint8 byEmptySlotColor; // al + uint32 uiUpdatedCheatFlags; // eax + int iCheatSetLoop; // ebx + uint8 byInputKey; // al + uint8 byExtendedKey; // al + int iSlotYPosition; // [esp+0h] [ebp-24h] + int iChampResult; // [esp+4h] [ebp-20h] + int iExitFlag; // [esp+8h] [ebp-1Ch] + int iSaveTrackNumber; // [esp+Ch] [ebp-18h] + int iY; // [esp+10h] [ebp-14h] + int iSaveArrayIndex; // [esp+14h] [ebp-10h] + int iStatusMessage; // [esp+18h] [ebp-Ch] + int iSlotLoop; // [esp+1Ch] [ebp-8h] + int iMenuCursor; // [esp+20h] [ebp-4h] - fade_palette(0); // Initialize screen fade and menu state variables + fade_palette(0); // Initialize screen fade and menu state variables uiMenuMode = 0; front_fade = 0; // Restore palette for GPU rendering @@ -81,8 +78,9 @@ void select_disk() iExitFlag = 0; iMenuCursor = 2; iStatusMessage = 0; - check_saves(); // Check save file status and scan for existing championship saves - do { // Handle game type switches and updates + check_saves(); // Check save file status and scan for existing championship + // saves + do { // Handle game type switches and updates if (switch_types) { game_type = switch_types - 1; if (switch_types == 1 && competitors == 1) @@ -95,218 +93,297 @@ void select_disk() } if (!uiMenuMode) iSelectedSlot = 0; - { // RENDER FRAME (GPU) - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_frame(mr); - if (!front_fade) { - front_fade = -1; - menu_render_begin_fade(mr, 1, 32); - } - menu_render_background(mr, 0); - menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); - menu_render_sprite(mr, 1, 0, head_x, head_y, 0, pal_addr); - if (iMenuCursor >= 2) // Draw selection cursor - { - menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); - } else { - menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); - menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, sel_posns[iMenuCursor].x, sel_posns[iMenuCursor].y, 0x8Fu, 0, pal_addr); - } - menu_render_text(mr, 2, &language_buffer[576], font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); // Display main menu options: "Load Game" and "Save Game" - menu_render_text(mr, 2, &language_buffer[640], font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 15, &language_buffer[704], font1_ascii, font1_offsets, 400, 270, 0xABu, 1u, pal_addr);// CURRENT GAME INFO: Display current championship settings and progress - menu_render_text(mr, 15, &language_buffer[768], font1_ascii, font1_offsets, 400, 290, 0x8Fu, 2u, pal_addr); - uiCupIndex = (TrackLoad - 1) / 8; - //uiCupIndex = (TrackLoad - 1 - (__CFSHL__((TrackLoad - 1) >> 31, 3) + 8 * ((TrackLoad - 1) >> 31))) >> 3;// Show current cup name based on track group - if (uiCupIndex) { - if (uiCupIndex <= 1) { - menu_render_text(mr, 15, &language_buffer[896], font1_ascii, font1_offsets, 405, 290, 0x8Fu, 0, pal_addr); - goto LABEL_20; + { // RENDER FRAME (GPU) + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_frame(mr); + if (!front_fade) { + front_fade = -1; + menu_render_begin_fade(mr, 1, 32); } - if (uiCupIndex == 2) { - menu_render_text(mr, 15, &language_buffer[4928], font1_ascii, font1_offsets, 405, 290, 0x8Fu, 0, pal_addr); - goto LABEL_20; - } - } - menu_render_text(mr, 15, &language_buffer[832], font1_ascii, font1_offsets, 405, 290, 0x8Fu, 0, pal_addr); - LABEL_20: - menu_render_text(mr, 15, &language_buffer[960], font1_ascii, font1_offsets, 400, 308, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 15, CompanyNames[Race], font1_ascii, font1_offsets, 405, 308, 0x8Fu, 0, pal_addr); - menu_render_text(mr, 15, &language_buffer[1024], font1_ascii, font1_offsets, 400, 326, 0x8Fu, 2u, pal_addr); - if ((unsigned int)competitors < 8) { - if (competitors == 2) - menu_render_text(mr, 15, &language_buffer[1088], font1_ascii, font1_offsets, 405, 326, 0x8Fu, 0, pal_addr); - } else if ((unsigned int)competitors <= 8) { - menu_render_text(mr, 15, &language_buffer[1152], font1_ascii, font1_offsets, 405, 326, 0x8Fu, 0, pal_addr); - } else if (competitors == 16) { - menu_render_text(mr, 15, &language_buffer[1216], font1_ascii, font1_offsets, 405, 326, 0x8Fu, 0, pal_addr); - } - menu_render_text(mr, 15, &language_buffer[1280], font1_ascii, font1_offsets, 400, 344, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 15, &language_buffer[64 * level + 1472], font1_ascii, font1_offsets, 405, 344, 0x8Fu, 0, pal_addr); - menu_render_text(mr, 15, &language_buffer[1344], font1_ascii, font1_offsets, 400, 362, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 15, &language_buffer[64 * damage_level + 1856], font1_ascii, font1_offsets, 405, 362, 0x8Fu, 0, pal_addr); - menu_render_text(mr, 15, &language_buffer[1408], font1_ascii, font1_offsets, 400, 380, 0x8Fu, 2u, pal_addr); - if (player_type == 1 && net_type) { - if ((unsigned int)net_type >= (unsigned int)player_type && (unsigned int)net_type <= 2) - menu_render_text(mr, 15, &language_buffer[2304], font1_ascii, font1_offsets, 405, 380, 0x8Fu, 0, pal_addr); - } else { - menu_render_text(mr, 15, &language_buffer[64 * player_type + 2112], font1_ascii, font1_offsets, 405, 380, 0x8Fu, 0, pal_addr); - } - iSlotLoop = 0; // SAVE SLOT DISPLAY: Show all 4 championship save slots with their details - iSlotYPosition = 56; - iSaveArrayIndex = 0; - iY = 74; - do { - sprintf(buffer, "%s %i:", &language_buffer[2432], iSlotLoop + 1);// Display slot number with highlighting for currently selected slot - if (iSelectedSlot == iSlotLoop + 1) - bySlotColor = 0xAB; - else - bySlotColor = 0x8F; - menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 300, iSlotYPosition, bySlotColor, 2u, pal_addr); - iSlotNumber = iSlotLoop + 1; - if (save_status[iSaveArrayIndex].iSlotUsed)// Show save slot contents: cup, track, difficulty, damage, player type + menu_render_background(mr, 0); + menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); + menu_render_sprite(mr, 1, 0, head_x, head_y, 0, pal_addr); + if (iMenuCursor >= 2) // Draw selection cursor { - uiSaveCupIndex = (save_status[iSaveArrayIndex].iPackedTrack - 1) / 8; - iSaveTrackNumber = ((save_status[iSaveArrayIndex].iPackedTrack - 1) % 8) + 1; - //uiSaveCupIndex = (save_status[iSaveArrayIndex].iPackedTrack - // - 1 - // - (__CFSHL__((save_status[iSaveArrayIndex].iPackedTrack - 1) >> 31, 3) - // + 8 * ((save_status[iSaveArrayIndex].iPackedTrack - 1) >> 31))) >> 3; - //iSaveTrackNumber = ((LOBYTE(save_status[iSaveArrayIndex].iPackedTrack) - 1) & 7) + 1; - if (uiSaveCupIndex) { - if (uiSaveCupIndex <= 1) { - if (iSelectedSlot == iSlotNumber) - byCupColor2 = 0xAB; - else - byCupColor2 = 0x8F; - menu_render_text(mr, 15, &language_buffer[896], font1_ascii, font1_offsets, 305, iSlotYPosition, byCupColor2, 0, pal_addr); - } else if (uiSaveCupIndex == 2) { + menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); + } else { + menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); + menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, + sel_posns[iMenuCursor].x, sel_posns[iMenuCursor].y, + 0x8Fu, 0, pal_addr); + } + menu_render_text( + mr, 2, &language_buffer[576], font2_ascii, font2_offsets, + sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, + pal_addr); // Display main menu options: "Load Game" and "Save Game" + menu_render_text(mr, 2, &language_buffer[640], font2_ascii, font2_offsets, + sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 15, &language_buffer[704], font1_ascii, + font1_offsets, 400, 270, 0xABu, 1u, + pal_addr); // CURRENT GAME INFO: Display current + // championship settings and progress + menu_render_text(mr, 15, &language_buffer[768], font1_ascii, + font1_offsets, 400, 290, 0x8Fu, 2u, pal_addr); + uiCupIndex = (TrackLoad - 1) / 8; + // uiCupIndex = (TrackLoad - 1 - (__CFSHL__((TrackLoad - 1) >> 31, 3) + 8 + // * ((TrackLoad - 1) >> 31))) >> 3;// Show current cup name based on + // track group + if (uiCupIndex) { + if (uiCupIndex <= 1) { + menu_render_text(mr, 15, &language_buffer[896], font1_ascii, + font1_offsets, 405, 290, 0x8Fu, 0, pal_addr); + goto LABEL_20; + } + if (uiCupIndex == 2) { + menu_render_text(mr, 15, &language_buffer[4928], font1_ascii, + font1_offsets, 405, 290, 0x8Fu, 0, pal_addr); + goto LABEL_20; + } + } + menu_render_text(mr, 15, &language_buffer[832], font1_ascii, + font1_offsets, 405, 290, 0x8Fu, 0, pal_addr); + LABEL_20: + menu_render_text(mr, 15, &language_buffer[960], font1_ascii, + font1_offsets, 400, 308, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 15, CompanyNames[Race], font1_ascii, font1_offsets, + 405, 308, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 15, &language_buffer[1024], font1_ascii, + font1_offsets, 400, 326, 0x8Fu, 2u, pal_addr); + if ((unsigned int)competitors < 8) { + if (competitors == 2) + menu_render_text(mr, 15, &language_buffer[1088], font1_ascii, + font1_offsets, 405, 326, 0x8Fu, 0, pal_addr); + } else if ((unsigned int)competitors <= 8) { + menu_render_text(mr, 15, &language_buffer[1152], font1_ascii, + font1_offsets, 405, 326, 0x8Fu, 0, pal_addr); + } else if (competitors == 16) { + menu_render_text(mr, 15, &language_buffer[1216], font1_ascii, + font1_offsets, 405, 326, 0x8Fu, 0, pal_addr); + } + menu_render_text(mr, 15, &language_buffer[1280], font1_ascii, + font1_offsets, 400, 344, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 15, &language_buffer[64 * level + 1472], font1_ascii, + font1_offsets, 405, 344, 0x8Fu, 0, pal_addr); + menu_render_text(mr, 15, &language_buffer[1344], font1_ascii, + font1_offsets, 400, 362, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 15, &language_buffer[64 * damage_level + 1856], + font1_ascii, font1_offsets, 405, 362, 0x8Fu, 0, + pal_addr); + menu_render_text(mr, 15, &language_buffer[1408], font1_ascii, + font1_offsets, 400, 380, 0x8Fu, 2u, pal_addr); + if (player_type == 1 && net_type) { + if ((unsigned int)net_type >= (unsigned int)player_type && + (unsigned int)net_type <= 2) + menu_render_text(mr, 15, &language_buffer[2304], font1_ascii, + font1_offsets, 405, 380, 0x8Fu, 0, pal_addr); + } else { + menu_render_text(mr, 15, &language_buffer[64 * player_type + 2112], + font1_ascii, font1_offsets, 405, 380, 0x8Fu, 0, + pal_addr); + } + iSlotLoop = 0; // SAVE SLOT DISPLAY: Show all 4 championship save slots + // with their details + iSlotYPosition = 56; + iSaveArrayIndex = 0; + iY = 74; + do { + sprintf(buffer, "%s %i:", &language_buffer[2432], + iSlotLoop + 1); // Display slot number with highlighting for + // currently selected slot + if (iSelectedSlot == iSlotLoop + 1) + bySlotColor = 0xAB; + else + bySlotColor = 0x8F; + menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 300, + iSlotYPosition, bySlotColor, 2u, pal_addr); + iSlotNumber = iSlotLoop + 1; + if (save_status[iSaveArrayIndex] + .iSlotUsed) // Show save slot contents: cup, track, difficulty, + // damage, player type + { + uiSaveCupIndex = (save_status[iSaveArrayIndex].iPackedTrack - 1) / 8; + iSaveTrackNumber = + ((save_status[iSaveArrayIndex].iPackedTrack - 1) % 8) + 1; + // uiSaveCupIndex = (save_status[iSaveArrayIndex].iPackedTrack + // - 1 + // - + // (__CFSHL__((save_status[iSaveArrayIndex].iPackedTrack + // - 1) >> 31, 3) + // + 8 * + // ((save_status[iSaveArrayIndex].iPackedTrack - 1) + // >> 31))) >> 3; + // iSaveTrackNumber = + // ((LOBYTE(save_status[iSaveArrayIndex].iPackedTrack) - 1) & 7) + 1; + if (uiSaveCupIndex) { + if (uiSaveCupIndex <= 1) { + if (iSelectedSlot == iSlotNumber) + byCupColor2 = 0xAB; + else + byCupColor2 = 0x8F; + menu_render_text(mr, 15, &language_buffer[896], font1_ascii, + font1_offsets, 305, iSlotYPosition, byCupColor2, + 0, pal_addr); + } else if (uiSaveCupIndex == 2) { + if (iSelectedSlot == iSlotNumber) + byCupColor3 = 0xAB; + else + byCupColor3 = 0x8F; + menu_render_text(mr, 15, &language_buffer[4928], font1_ascii, + font1_offsets, 305, iSlotYPosition, byCupColor3, + 0, pal_addr); + } + } else { if (iSelectedSlot == iSlotNumber) - byCupColor3 = 0xAB; + byCupColor1 = 0xAB; else - byCupColor3 = 0x8F; - menu_render_text(mr, 15, &language_buffer[4928], font1_ascii, font1_offsets, 305, iSlotYPosition, byCupColor3, 0, pal_addr); + byCupColor1 = 0x8F; + menu_render_text(mr, 15, &language_buffer[832], font1_ascii, + font1_offsets, 305, iSlotYPosition, byCupColor1, 0, + pal_addr); } - } else { + sprintf(buffer, "%s %i", &language_buffer[256], iSaveTrackNumber); + if (iSelectedSlot == iSlotLoop + 1) + byTrackColor = 0xAB; + else + byTrackColor = 0x8F; + menu_render_text(mr, 15, "-", font1_ascii, font1_offsets, 470, + iSlotYPosition, byTrackColor, 0, pal_addr); + if (iSelectedSlot == iSlotLoop + 1) + byDifficultyColor = 0xAB; + else + byDifficultyColor = 0x8F; + menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 480, + iSlotYPosition, byDifficultyColor, 0, pal_addr); + if (iSelectedSlot == iSlotLoop + 1) + byLevelColor = 0xAB; + else + byLevelColor = 0x8F; + menu_render_text( + mr, 15, + &language_buffer[64 * save_status[iSaveArrayIndex].iDifficulty + + 1472], + font1_ascii, font1_offsets, 460, iY, byLevelColor, 2u, pal_addr); + if (iSelectedSlot == iSlotLoop + 1) + byDamageColor = 0xAB; + else + byDamageColor = 0x8F; + menu_render_text(mr, 15, "-", font1_ascii, font1_offsets, 470, iY, + byDamageColor, 0, pal_addr); + if (iSelectedSlot == iSlotLoop + 1) + byPlayerTypeColor = 0xAB; + else + byPlayerTypeColor = 0x8F; + menu_render_text( + mr, 15, + &language_buffer[64 * save_status[iSaveArrayIndex].iPlayerType + + 2112], + font1_ascii, font1_offsets, 480, iY, byPlayerTypeColor, 0, + pal_addr); + } else { // Display "Empty" for unused save slots if (iSelectedSlot == iSlotNumber) - byCupColor1 = 0xAB; + byEmptySlotColor = 0xAB; else - byCupColor1 = 0x8F; - menu_render_text(mr, 15, &language_buffer[832], font1_ascii, font1_offsets, 305, iSlotYPosition, byCupColor1, 0, pal_addr); + byEmptySlotColor = 0x8F; + menu_render_text(mr, 15, &language_buffer[2496], font1_ascii, + font1_offsets, 305, iSlotYPosition, byEmptySlotColor, + 0, pal_addr); } - sprintf(buffer, "%s %i", &language_buffer[256], iSaveTrackNumber); - if (iSelectedSlot == iSlotLoop + 1) - byTrackColor = 0xAB; - else - byTrackColor = 0x8F; - menu_render_text(mr, 15, "-", font1_ascii, font1_offsets, 470, iSlotYPosition, byTrackColor, 0, pal_addr); - if (iSelectedSlot == iSlotLoop + 1) - byDifficultyColor = 0xAB; - else - byDifficultyColor = 0x8F; - menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 480, iSlotYPosition, byDifficultyColor, 0, pal_addr); - if (iSelectedSlot == iSlotLoop + 1) - byLevelColor = 0xAB; - else - byLevelColor = 0x8F; - menu_render_text(mr, 15, &language_buffer[64 * save_status[iSaveArrayIndex].iDifficulty + 1472], font1_ascii, font1_offsets, 460, iY, byLevelColor, 2u, pal_addr); - if (iSelectedSlot == iSlotLoop + 1) - byDamageColor = 0xAB; - else - byDamageColor = 0x8F; - menu_render_text(mr, 15, "-", font1_ascii, font1_offsets, 470, iY, byDamageColor, 0, pal_addr); - if (iSelectedSlot == iSlotLoop + 1) - byPlayerTypeColor = 0xAB; - else - byPlayerTypeColor = 0x8F; - menu_render_text(mr, 15, &language_buffer[64 * save_status[iSaveArrayIndex].iPlayerType + 2112], font1_ascii, font1_offsets, 480, iY, byPlayerTypeColor, 0, pal_addr); - } else { // Display "Empty" for unused save slots - if (iSelectedSlot == iSlotNumber) - byEmptySlotColor = 0xAB; - else - byEmptySlotColor = 0x8F; - menu_render_text(mr, 15, &language_buffer[2496], font1_ascii, font1_offsets, 305, iSlotYPosition, byEmptySlotColor, 0, pal_addr); - } - iSlotYPosition += 40; - ++iSaveArrayIndex; - iY += 40; - ++iSlotLoop; - } while (iSlotLoop < 4); - switch (iStatusMessage) { + iSlotYPosition += 40; + ++iSaveArrayIndex; + iY += 40; + ++iSlotLoop; + } while (iSlotLoop < 4); + switch (iStatusMessage) { case 0: - if (network_on) // Case 0: Network save restriction message - menu_render_text(mr, 15, &language_buffer[4864], font1_ascii, font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); + if (network_on) // Case 0: Network save restriction message + menu_render_text(mr, 15, &language_buffer[4864], font1_ascii, + font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); break; case 1: - if (iChampResult) // Case 1: Load operation messages (success/confirmation) - menu_render_text(mr, 15, &language_buffer[2624], font1_ascii, font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); + if (iChampResult) // Case 1: Load operation messages + // (success/confirmation) + menu_render_text(mr, 15, &language_buffer[2624], font1_ascii, + font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); else - menu_render_text(mr, 15, &language_buffer[2560], font1_ascii, font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); + menu_render_text(mr, 15, &language_buffer[2560], font1_ascii, + font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); break; case 2: - menu_render_text(mr, 15, &language_buffer[2688], font1_ascii, font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); // Case 2: Save operation success message + menu_render_text(mr, 15, &language_buffer[2688], font1_ascii, + font1_offsets, 400, 230, 0xE7u, 1u, + pal_addr); // Case 2: Save operation success message break; case 4: - menu_render_text(mr, 15, &language_buffer[2752], font1_ascii, font1_offsets, 400, 230, 0xE7u, 1u, pal_addr); // Case 4: Empty slot selected (no save to load) + menu_render_text( + mr, 15, &language_buffer[2752], font1_ascii, font1_offsets, 400, + 230, 0xE7u, 1u, + pal_addr); // Case 4: Empty slot selected (no save to load) break; default: - break; // STATUS MESSAGES: Display operation results and warnings - } - show_received_mesage(); - menu_render_end_frame(mr); - if (SnapshotShouldStop()) - return; + break; // STATUS MESSAGES: Display operation results and warnings + } + show_received_mesage(); + menu_render_end_frame(mr); + if (SnapshotShouldStop()) + return; } - if (switch_same > 0) // CHEAT MODE HANDLING: Process switch_same command for player synchronization + if (switch_same > 0) // CHEAT MODE HANDLING: Process switch_same command for + // player synchronization { iCheatSetLoop = 0; if (players > 0) { - for (int i = 0; i < players; i++) - { - Players_Cars[i] = switch_same - 666; + for (int i = 0; i < players; i++) { + Players_Cars[i] = switch_same - 666; } - //iPlayersCarsOffset = 0; - //do { - // iPlayersCarsOffset += 4; - // ++iCheatSetLoop; - // *(int *)((char *)&infinite_laps + iPlayersCarsOffset) = switch_same - 666;// offset into Players_Cars - //} while (iCheatSetLoop < players); + // iPlayersCarsOffset = 0; + // do { + // iPlayersCarsOffset += 4; + // ++iCheatSetLoop; + // *(int *)((char *)&infinite_laps + iPlayersCarsOffset) = switch_same + // - 666;// offset into Players_Cars + // } while (iCheatSetLoop < players); } uiUpdatedCheatFlags = cheat_mode; - //BYTE1(uiUpdatedCheatFlags) = BYTE1(cheat_mode) | 0x40;// |= CHEAT_MODE_CLONES; + // BYTE1(uiUpdatedCheatFlags) = BYTE1(cheat_mode) | 0x40;// |= + // CHEAT_MODE_CLONES; uiUpdatedCheatFlags |= CHEAT_MODE_CLONES; } else { if (switch_same >= 0) goto LABEL_95; switch_same = 0; - for (int i = 0; i < players; i++) - { - Players_Cars[i] = -1; + for (int i = 0; i < players; i++) { + Players_Cars[i] = -1; } - //iCheatResetLoop = 0; - //if (players > 0) { - // iCheatResetOffset = 0; - // do { - // iCheatResetOffset += 4; - // ++iCheatResetLoop; - // *(int *)((char *)&infinite_laps + iCheatResetOffset) = -1;// offset into Players_Cars - // } while (iCheatResetLoop < players); - //} + // iCheatResetLoop = 0; + // if (players > 0) { + // iCheatResetOffset = 0; + // do { + // iCheatResetOffset += 4; + // ++iCheatResetLoop; + // *(int *)((char *)&infinite_laps + iCheatResetOffset) = -1;// offset + // into Players_Cars + // } while (iCheatResetLoop < players); + // } uiUpdatedCheatFlags = cheat_mode; - //BYTE1(uiUpdatedCheatFlags) = BYTE1(cheat_mode) & 0xBF;// &= ~CHEAT_MODE_CLONES + // BYTE1(uiUpdatedCheatFlags) = BYTE1(cheat_mode) & 0xBF;// &= + // ~CHEAT_MODE_CLONES uiUpdatedCheatFlags &= ~CHEAT_MODE_CLONES; } cheat_mode = uiUpdatedCheatFlags; LABEL_95: - while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle navigation and save/load operations + while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle navigation and + // save/load operations { byInputKey = fatgetch(); - if (byInputKey < 0xDu) { // Arrow keys: Navigate between menu options and save slots + if (byInputKey < + 0xDu) { // Arrow keys: Navigate between menu options and save slots if (!byInputKey) { byExtendedKey = fatgetch(); if (byExtendedKey >= 0x48u) { - if (byExtendedKey <= 0x48u) { // Up arrow: Move up in save slot selection or main menu + if (byExtendedKey <= 0x48u) { // Up arrow: Move up in save slot + // selection or main menu if (uiMenuMode) { if (iSelectedSlot > 1) { iStatusMessage = 0; @@ -316,7 +393,8 @@ void select_disk() iStatusMessage = 0; --iMenuCursor; } - } else if (byExtendedKey == 80) { // Down arrow: Move down in save slot selection or main menu + } else if (byExtendedKey == 80) { // Down arrow: Move down in save + // slot selection or main menu if (uiMenuMode) { if (iSelectedSlot < 4) { iStatusMessage = 0; @@ -329,17 +407,20 @@ void select_disk() } } } - } else if (byInputKey <= 0xDu) { // Enter key: Execute save/load operation based on current menu and selection + } else if (byInputKey <= 0xDu) { // Enter key: Execute save/load operation + // based on current menu and selection if (uiMenuMode) { if (uiMenuMode <= 1) { - save_champ(iSelectedSlot); // SAVE operation: Save current championship to selected slot + save_champ(iSelectedSlot); // SAVE operation: Save current + // championship to selected slot uiMenuMode = 0; check_saves(); iStatusMessage = 2; } else { iStatusMessage = 1; if (save_status[iSelectedSlot - 1].iSlotUsed) { - uiMenuMode = 0; // LOAD operation: Load championship from selected slot + uiMenuMode = + 0; // LOAD operation: Load championship from selected slot iChampResult = load_champ(iSelectedSlot); } else { iStatusMessage = 4; @@ -347,16 +428,19 @@ void select_disk() } } else if (iMenuCursor) { if ((unsigned int)iMenuCursor <= 1) { - uiMenuMode = 2; // \"Save Game\" selected: Enter save slot selection mode + uiMenuMode = + 2; // \"Save Game\" selected: Enter save slot selection mode iSelectedSlot = 1; } else if (iMenuCursor == 2) { goto LABEL_128; } } else { - uiMenuMode = 1; // \"Load Game\" selected: Enter save slot selection mode + uiMenuMode = + 1; // \"Load Game\" selected: Enter save slot selection mode iSelectedSlot = 1; } - } else if (byInputKey == 27) { // Escape key: Cancel operation or exit to main menu + } else if (byInputKey == + 27) { // Escape key: Cancel operation or exit to main menu if (uiMenuMode) { uiMenuMode = 0; iStatusMessage = 0; @@ -368,7 +452,8 @@ void select_disk() UpdateSDL(); } UpdateSDL(); - } while (!iExitFlag); // MAIN MENU LOOP - Handle UI rendering and input processing + } while ( + !iExitFlag); // MAIN MENU LOOP - Handle UI rendering and input processing // GPU fade-out { MenuRenderer *mr = GetMenuRenderer(); diff --git a/PROJECTS/ROLLER/frontend_select_players.c b/PROJECTS/ROLLER/frontend_select_players.c index 0149b3d3..e49a4ee4 100644 --- a/PROJECTS/ROLLER/frontend_select_players.c +++ b/PROJECTS/ROLLER/frontend_select_players.c @@ -25,36 +25,36 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -//00047000 -void select_players() -{ +// 00047000 +void select_players() { unsigned int uiSelectedPlayerType; // esi - int iNetworkStatus; // edi - uint32 uiCheatArrayOffset; // eax - int iCheatPlayerLoop; // edx - int iCheatPlayerIndex; // edx - int iPlayerCarIndex; // ecx - char byMenuColor1; // al - char byMenuColor2; // al - char byMenuColor3; // al - char byMenuColor4; // al - char byMenuColor5; // al - uint8 byInputKey; // al - uint8 byExtendedKey; // al - int iNetworkMode; // [esp+8h] [ebp-20h] - int iPlayerIndex; // [esp+Ch] [ebp-1Ch] - int iY; // [esp+10h] [ebp-18h] - int iComPortStatus; // [esp+14h] [ebp-14h] - char *szText; // [esp+18h] [ebp-10h] - int iPlayerListCount; // [esp+1Ch] [ebp-Ch] - int iNetworkSetupFlag; // [esp+20h] [ebp-8h] - int iExitFlag; // [esp+24h] [ebp-4h] + int iNetworkStatus; // edi + uint32 uiCheatArrayOffset; // eax + int iCheatPlayerLoop; // edx + int iCheatPlayerIndex; // edx + int iPlayerCarIndex; // ecx + char byMenuColor1; // al + char byMenuColor2; // al + char byMenuColor3; // al + char byMenuColor4; // al + char byMenuColor5; // al + uint8 byInputKey; // al + uint8 byExtendedKey; // al + int iNetworkMode; // [esp+8h] [ebp-20h] + int iPlayerIndex; // [esp+Ch] [ebp-1Ch] + int iY; // [esp+10h] [ebp-18h] + int iComPortStatus; // [esp+14h] [ebp-14h] + char *szText; // [esp+18h] [ebp-10h] + int iPlayerListCount; // [esp+1Ch] [ebp-Ch] + int iNetworkSetupFlag; // [esp+20h] [ebp-8h] + int iExitFlag; // [esp+24h] [ebp-4h] - iComPortStatus = 0;// gss16550(2); // Initialize COM port status and screen fade + iComPortStatus = 0; // gss16550(2); // Initialize COM port + // status and screen fade iExitFlag = 0; fade_palette(0); uiSelectedPlayerType = player_type; @@ -65,7 +65,8 @@ void select_players() memcpy(pal_addr, palette, 256 * sizeof(tColor)); palette_brightness = 32; } - if (player_type == 1 && net_type) // Map network types to player selection modes: Serial=3, Modem=4 + if (player_type == 1 && net_type) // Map network types to player selection + // modes: Serial=3, Modem=4 { if ((unsigned int)net_type <= 1) { uiSelectedPlayerType = 3; @@ -74,12 +75,14 @@ void select_players() } } iNetworkSetupFlag = 0; - if (uiSelectedPlayerType == 1 || uiSelectedPlayerType == 3 || uiSelectedPlayerType == 4)// Set network mode flag: -1 for single player and network modes, 0 for two-player + if (uiSelectedPlayerType == 1 || uiSelectedPlayerType == 3 || + uiSelectedPlayerType == 4) // Set network mode flag: -1 for single player + // and network modes, 0 for two-player iNetworkMode = -1; else iNetworkMode = 0; iNetworkStatus = 0; - do { // Handle game type switches (race type, championship, etc.) + do { // Handle game type switches (race type, championship, etc.) if (switch_types) { game_type = switch_types - 1; if (switch_types == 1 && competitors == 1) @@ -90,276 +93,333 @@ void select_players() else network_champ_on = 0; } - { // RENDER FRAME (GPU) - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_frame(mr); - if (!front_fade) { - front_fade = -1; - menu_render_begin_fade(mr, 1, 32); - } - menu_render_background(mr, 0); - menu_render_sprite(mr, 1, 3, head_x, head_y, 0, pal_addr); - menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); - menu_render_sprite(mr, 5, uiSelectedPlayerType, -4, 247, 0, pal_addr); - menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); - menu_render_sprite(mr, 4, 4, 76, 257, -1, pal_addr); - menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); - if (iNetworkStatus && (uiSelectedPlayerType == 1 || uiSelectedPlayerType == 3 || uiSelectedPlayerType == 4))// Show connection status message for network modes - menu_render_scaled_text(mr, 15, &language_buffer[4992], font1_ascii, font1_offsets, 400, 300, 231, 1u, 200, 640, pal_addr); - if ((uiSelectedPlayerType == 3 || uiSelectedPlayerType == 4) && !iComPortStatus)// Show COM port error message if networking failed to initialize - menu_render_scaled_text(mr, 15, &language_buffer[8064], font1_ascii, font1_offsets, 400, 300, 231, 1u, 200, 640, pal_addr); - do { - uiCheatArrayOffset = broadcast_mode; - UpdateSDL(); - } while (broadcast_mode); - if (switch_same > 0) // CHEAT MODE HANDLING: Process switch_same command for car synchronization - { - for (iCheatPlayerIndex = 0; iCheatPlayerIndex < players; ++iCheatPlayerIndex) - { - Players_Cars[iCheatPlayerIndex] = switch_same - 666; + { // RENDER FRAME (GPU) + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_frame(mr); + if (!front_fade) { + front_fade = -1; + menu_render_begin_fade(mr, 1, 32); } - //for (iCheatPlayerIndex = 0; - // iCheatPlayerIndex < players; - // *(int *)((char *)&infinite_laps + uiCheatArrayOffset) = switch_same - 666) { - // uiCheatArrayOffset += 4; - // ++iCheatPlayerIndex; - //} - if ((cheat_mode & 0x4000) == 0) - broadcast_mode = -1; - while (broadcast_mode) + menu_render_background(mr, 0); + menu_render_sprite(mr, 1, 3, head_x, head_y, 0, pal_addr); + menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); + menu_render_sprite(mr, 5, uiSelectedPlayerType, -4, 247, 0, pal_addr); + menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); + menu_render_sprite(mr, 4, 4, 76, 257, -1, pal_addr); + menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); + if (iNetworkStatus && + (uiSelectedPlayerType == 1 || uiSelectedPlayerType == 3 || + uiSelectedPlayerType == + 4)) // Show connection status message for network modes + menu_render_scaled_text(mr, 15, &language_buffer[4992], font1_ascii, + font1_offsets, 400, 300, 231, 1u, 200, 640, + pal_addr); + if ((uiSelectedPlayerType == 3 || uiSelectedPlayerType == 4) && + !iComPortStatus) // Show COM port error message if networking failed + // to initialize + menu_render_scaled_text(mr, 15, &language_buffer[8064], font1_ascii, + font1_offsets, 400, 300, 231, 1u, 200, 640, + pal_addr); + do { + uiCheatArrayOffset = broadcast_mode; UpdateSDL(); - cheat_mode |= CHEAT_MODE_CLONES; - } else if (switch_same < 0) { - switch_same = broadcast_mode; - for (iCheatPlayerLoop = 0; iCheatPlayerLoop < players; ++iCheatPlayerLoop) + } while (broadcast_mode); + if (switch_same > 0) // CHEAT MODE HANDLING: Process switch_same command + // for car synchronization { - Players_Cars[iCheatPlayerLoop] = -1; - } - //for (iCheatPlayerLoop = 0; iCheatPlayerLoop < players; *(int *)((char *)&infinite_laps + uiCheatArrayOffset) = -1) { - // uiCheatArrayOffset += 4; - // ++iCheatPlayerLoop; - //} - cheat_mode &= ~CHEAT_MODE_CLONES; - } - if (iNetworkMode) // NETWORK MODE UI: Show connection info and player list - { - if (iNetworkSetupFlag) { - while (broadcast_mode) - UpdateSDL(); - broadcast_mode = -667; + for (iCheatPlayerIndex = 0; iCheatPlayerIndex < players; + ++iCheatPlayerIndex) { + Players_Cars[iCheatPlayerIndex] = switch_same - 666; + } + // for (iCheatPlayerIndex = 0; + // iCheatPlayerIndex < players; + // *(int *)((char *)&infinite_laps + uiCheatArrayOffset) = + // switch_same - 666) { + // uiCheatArrayOffset += 4; + // ++iCheatPlayerIndex; + // } + if ((cheat_mode & 0x4000) == 0) + broadcast_mode = -1; while (broadcast_mode) UpdateSDL(); - iNetworkSetupFlag = 0; - } - if (net_type) { - if ((unsigned int)net_type <= 1) { - menu_render_scaled_text(mr, 15, &language_buffer[5056], font1_ascii, font1_offsets, 400, 60, 143, 1u, 200, 640, pal_addr); - } else if (net_type == 2) { - menu_render_scaled_text(mr, 15, &language_buffer[5120], font1_ascii, font1_offsets, 400, 60, 143, 1u, 200, 640, pal_addr); + cheat_mode |= CHEAT_MODE_CLONES; + } else if (switch_same < 0) { + switch_same = broadcast_mode; + for (iCheatPlayerLoop = 0; iCheatPlayerLoop < players; + ++iCheatPlayerLoop) { + Players_Cars[iCheatPlayerLoop] = -1; } - } else { - menu_render_scaled_text(mr, 15, &language_buffer[4096], font1_ascii, font1_offsets, 400, 60, 143, 1u, 200, 640, pal_addr); + // for (iCheatPlayerLoop = 0; iCheatPlayerLoop < players; *(int *)((char + // *)&infinite_laps + uiCheatArrayOffset) = -1) { + // uiCheatArrayOffset += 4; + // ++iCheatPlayerLoop; + // } + cheat_mode &= ~CHEAT_MODE_CLONES; } - iPlayerListCount = 0; - if (network_on > 0) // Display connected players and their selected cars + if (iNetworkMode) // NETWORK MODE UI: Show connection info and player list { - iPlayerIndex = 0; - iY = 80; - szText = player_names[0]; - do { - menu_render_scaled_text(mr, 15, szText, font1_ascii, font1_offsets, 336, iY, 143, 2u, 200, 640, pal_addr); - iPlayerCarIndex = Players_Cars[iPlayerIndex]; - if (iPlayerCarIndex < 0) - menu_render_scaled_text(mr, 15, &language_buffer[4160], font1_ascii, font1_offsets, 340, iY, 131, 0, 200, 640, pal_addr); - else - menu_render_scaled_text(mr, 15, CompanyNames[iPlayerCarIndex], font1_ascii, font1_offsets, 342, iY, 143, 0, 200, 640, pal_addr); - ++iPlayerIndex; - szText += 9; - iY += 18; - ++iPlayerListCount; + if (iNetworkSetupFlag) { + while (broadcast_mode) + UpdateSDL(); + broadcast_mode = -667; + while (broadcast_mode) + UpdateSDL(); + iNetworkSetupFlag = 0; + } + if (net_type) { + if ((unsigned int)net_type <= 1) { + menu_render_scaled_text(mr, 15, &language_buffer[5056], font1_ascii, + font1_offsets, 400, 60, 143, 1u, 200, 640, + pal_addr); + } else if (net_type == 2) { + menu_render_scaled_text(mr, 15, &language_buffer[5120], font1_ascii, + font1_offsets, 400, 60, 143, 1u, 200, 640, + pal_addr); + } + } else { + menu_render_scaled_text(mr, 15, &language_buffer[4096], font1_ascii, + font1_offsets, 400, 60, 143, 1u, 200, 640, + pal_addr); + } + iPlayerListCount = 0; + if (network_on > 0) // Display connected players and their selected cars + { + iPlayerIndex = 0; + iY = 80; + szText = player_names[0]; + do { + menu_render_scaled_text(mr, 15, szText, font1_ascii, font1_offsets, + 336, iY, 143, 2u, 200, 640, pal_addr); + iPlayerCarIndex = Players_Cars[iPlayerIndex]; + if (iPlayerCarIndex < 0) + menu_render_scaled_text(mr, 15, &language_buffer[4160], + font1_ascii, font1_offsets, 340, iY, 131, + 0, 200, 640, pal_addr); + else + menu_render_scaled_text(mr, 15, CompanyNames[iPlayerCarIndex], + font1_ascii, font1_offsets, 342, iY, 143, + 0, 200, 640, pal_addr); + ++iPlayerIndex; + szText += 9; + iY += 18; + ++iPlayerListCount; - UpdateSDL(); - } while (iPlayerListCount < network_on); - } - if (net_type) { - if ((unsigned int)net_type <= 1) { - menu_render_scaled_text(mr, 15, &language_buffer[5184], font1_ascii, font1_offsets, 400, 380, 231, 1u, 200, 640, pal_addr); - } else if (net_type == 2) { - menu_render_scaled_text(mr, 15, &language_buffer[5248], font1_ascii, font1_offsets, 400, 380, 231, 1u, 200, 640, pal_addr); + UpdateSDL(); + } while (iPlayerListCount < network_on); + } + if (net_type) { + if ((unsigned int)net_type <= 1) { + menu_render_scaled_text(mr, 15, &language_buffer[5184], font1_ascii, + font1_offsets, 400, 380, 231, 1u, 200, 640, + pal_addr); + } else if (net_type == 2) { + menu_render_scaled_text(mr, 15, &language_buffer[5248], font1_ascii, + font1_offsets, 400, 380, 231, 1u, 200, 640, + pal_addr); + } + } else { + menu_render_scaled_text(mr, 15, &language_buffer[4224], font1_ascii, + font1_offsets, 400, 380, 231, 1u, 200, 640, + pal_addr); } + menu_render_scaled_text(mr, 15, &language_buffer[7104], font1_ascii, + font1_offsets, 400, 360, 231, 1u, 200, 640, + pal_addr); } else { - menu_render_scaled_text(mr, 15, &language_buffer[4224], font1_ascii, font1_offsets, 400, 380, 231, 1u, 200, 640, pal_addr); + menu_render_scaled_text( + mr, 15, &language_buffer[2944], font1_ascii, font1_offsets, 400, 75, + 143, 1u, 200, 640, pal_addr); // MENU MODE UI: Show player selection + // options with highlighting + menu_render_scaled_text(mr, 15, &language_buffer[3008], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, 640, + pal_addr); + if (uiSelectedPlayerType) // Highlight current selection + byMenuColor1 = 0x8F; + else + byMenuColor1 = 0xAB; + menu_render_scaled_text(mr, 15, &language_buffer[2112], font1_ascii, + font1_offsets, 400, 135, byMenuColor1, 1u, 200, + 640, pal_addr); + if (uiSelectedPlayerType == 2) + byMenuColor2 = 0xAB; + else + byMenuColor2 = 0x8F; + menu_render_scaled_text(mr, 15, &language_buffer[2240], font1_ascii, + font1_offsets, 400, 153, byMenuColor2, 1u, 200, + 640, pal_addr); + if (uiSelectedPlayerType == 1) + byMenuColor3 = 0xAB; + else + byMenuColor3 = 0x8F; + menu_render_scaled_text(mr, 15, &language_buffer[2176], font1_ascii, + font1_offsets, 400, 171, byMenuColor3, 1u, 200, + 640, pal_addr); + if (uiSelectedPlayerType == 3) + byMenuColor4 = 0xAB; + else + byMenuColor4 = 0x8F; + menu_render_scaled_text(mr, 15, &language_buffer[2304], font1_ascii, + font1_offsets, 400, 189, byMenuColor4, 1u, 200, + 640, pal_addr); + if (uiSelectedPlayerType == 4) + byMenuColor5 = 0xAB; + else + byMenuColor5 = 0x8F; + menu_render_scaled_text(mr, 15, &language_buffer[2368], font1_ascii, + font1_offsets, 400, 207, byMenuColor5, 1u, 200, + 640, pal_addr); } - menu_render_scaled_text(mr, 15, &language_buffer[7104], font1_ascii, font1_offsets, 400, 360, 231, 1u, 200, 640, pal_addr); - } else { - menu_render_scaled_text(mr, 15, &language_buffer[2944], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr);// MENU MODE UI: Show player selection options with highlighting - menu_render_scaled_text(mr, 15, &language_buffer[3008], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640, pal_addr); - if (uiSelectedPlayerType) // Highlight current selection - byMenuColor1 = 0x8F; - else - byMenuColor1 = 0xAB; - menu_render_scaled_text(mr, 15, &language_buffer[2112], font1_ascii, font1_offsets, 400, 135, byMenuColor1, 1u, 200, 640, pal_addr); - if (uiSelectedPlayerType == 2) - byMenuColor2 = 0xAB; - else - byMenuColor2 = 0x8F; - menu_render_scaled_text(mr, 15, &language_buffer[2240], font1_ascii, font1_offsets, 400, 153, byMenuColor2, 1u, 200, 640, pal_addr); - if (uiSelectedPlayerType == 1) - byMenuColor3 = 0xAB; - else - byMenuColor3 = 0x8F; - menu_render_scaled_text(mr, 15, &language_buffer[2176], font1_ascii, font1_offsets, 400, 171, byMenuColor3, 1u, 200, 640, pal_addr); - if (uiSelectedPlayerType == 3) - byMenuColor4 = 0xAB; - else - byMenuColor4 = 0x8F; - menu_render_scaled_text(mr, 15, &language_buffer[2304], font1_ascii, font1_offsets, 400, 189, byMenuColor4, 1u, 200, 640, pal_addr); - if (uiSelectedPlayerType == 4) - byMenuColor5 = 0xAB; - else - byMenuColor5 = 0x8F; - menu_render_scaled_text(mr, 15, &language_buffer[2368], font1_ascii, font1_offsets, 400, 207, byMenuColor5, 1u, 200, 640, pal_addr); - } - show_received_mesage(); - menu_render_end_frame(mr); - } // end RENDER FRAME (GPU) - while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle navigation and selection + show_received_mesage(); + menu_render_end_frame(mr); + } // end RENDER FRAME (GPU) + while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle navigation and + // selection { byInputKey = fatgetch(); if (byInputKey < 0x4Du) { - if (byInputKey < 0xDu) { // Handle extended keys (arrow keys for navigation) + if (byInputKey < + 0xDu) { // Handle extended keys (arrow keys for navigation) if (!byInputKey) { byExtendedKey = fatgetch(); if (byExtendedKey >= 0x48u) { - if (byExtendedKey <= 0x48u) { // Up arrow: Navigate through player selection options + if (byExtendedKey <= 0x48u) { // Up arrow: Navigate through player + // selection options if (!iNetworkMode) { switch (uiSelectedPlayerType) { - case 1u: - uiSelectedPlayerType = 2; - iNetworkStatus = 0; - break; - case 2u: - uiSelectedPlayerType = 0; - iNetworkStatus = 0; - break; - case 3u: - uiSelectedPlayerType = 1; - iNetworkStatus = 0; - break; - case 4u: - uiSelectedPlayerType = 3; - iNetworkStatus = 0; - break; - default: - continue; - } - } - } else if (byExtendedKey == 80 && !iNetworkMode)// Down arrow: Navigate through player selection options - { - switch (uiSelectedPlayerType) { - case 0u: + case 1u: uiSelectedPlayerType = 2; iNetworkStatus = 0; break; - case 1u: - uiSelectedPlayerType = 3; + case 2u: + uiSelectedPlayerType = 0; iNetworkStatus = 0; break; - case 2u: + case 3u: uiSelectedPlayerType = 1; iNetworkStatus = 0; break; - case 3u: - uiSelectedPlayerType = 4; + case 4u: + uiSelectedPlayerType = 3; iNetworkStatus = 0; break; default: continue; + } + } + } else if (byExtendedKey == 80 && + !iNetworkMode) // Down arrow: Navigate through player + // selection options + { + switch (uiSelectedPlayerType) { + case 0u: + uiSelectedPlayerType = 2; + iNetworkStatus = 0; + break; + case 1u: + uiSelectedPlayerType = 3; + iNetworkStatus = 0; + break; + case 2u: + uiSelectedPlayerType = 1; + iNetworkStatus = 0; + break; + case 3u: + uiSelectedPlayerType = 4; + iNetworkStatus = 0; + break; + default: + continue; } } } } - } else if (byInputKey <= 0xDu || byInputKey == 27)// Enter/Escape: Confirm selection or exit menu + } else if (byInputKey <= 0xDu || + byInputKey == + 27) // Enter/Escape: Confirm selection or exit menu { switch (uiSelectedPlayerType) { - case 0u: - case 2u: - goto LABEL_128; - case 1u: - case 3u: - case 4u: - if (uiSelectedPlayerType != 1 && !iComPortStatus) - continue; - if (uiSelectedPlayerType == 1) - net_type = 0; - if (uiSelectedPlayerType == 3) - net_type = 1; - if (uiSelectedPlayerType == 4) - net_type = 2; - ROLLERCommsSetType(net_type); - if (iNetworkMode) { - LABEL_128: - iExitFlag = -1; - continue; - } - if (iNetworkStatus) - goto LABEL_159; - if (net_type) // NETWORK SETUP: Initialize communication for selected network type - { - if ((unsigned int)net_type <= 1) { - if (select_comport(uiSelectedPlayerType)) - goto LABEL_153; - } else { - if (net_type != 2) - goto LABEL_156; - if (select_modemstuff(uiSelectedPlayerType)) { - LABEL_153: - network_slot = 0; - goto LABEL_156; - } - } - network_on = 0; - network_slot = -1; + case 0u: + case 2u: + goto LABEL_128; + case 1u: + case 3u: + case 4u: + if (uiSelectedPlayerType != 1 && !iComPortStatus) + continue; + if (uiSelectedPlayerType == 1) + net_type = 0; + if (uiSelectedPlayerType == 3) + net_type = 1; + if (uiSelectedPlayerType == 4) + net_type = 2; + ROLLERCommsSetType(net_type); + if (iNetworkMode) { + LABEL_128: + iExitFlag = -1; + continue; + } + if (iNetworkStatus) + goto LABEL_159; + if (net_type) // NETWORK SETUP: Initialize communication for + // selected network type + { + if ((unsigned int)net_type <= 1) { + if (select_comport(uiSelectedPlayerType)) + goto LABEL_153; } else { - network_slot = select_netslot();// IPX network: Select network slot and handle connection - if (network_slot >= 0) { - broadcast_mode = -1; - while (broadcast_mode) - UpdateSDL(); - } else if (network_slot == -2) { - broadcast_mode = -666; - while (broadcast_mode) - UpdateSDL(); - close_network(); - } else { - iNetworkStatus = -1; + if (net_type != 2) + goto LABEL_156; + if (select_modemstuff(uiSelectedPlayerType)) { + LABEL_153: + network_slot = 0; + goto LABEL_156; } } - LABEL_156: - if (uiSelectedPlayerType == 3 && network_slot >= 0) - Initialise_Network(0); - LABEL_159: - if (network_on) { - iNetworkSetupFlag = -1; - iNetworkMode = -1; + network_on = 0; + network_slot = -1; + } else { + network_slot = select_netslot(); // IPX network: Select network + // slot and handle connection + if (network_slot >= 0) { + broadcast_mode = -1; + while (broadcast_mode) + UpdateSDL(); + } else if (network_slot == -2) { + broadcast_mode = -666; + while (broadcast_mode) + UpdateSDL(); + close_network(); + } else { + iNetworkStatus = -1; } - break; - default: - continue; + } + LABEL_156: + if (uiSelectedPlayerType == 3 && network_slot >= 0) + Initialise_Network(0); + LABEL_159: + if (network_on) { + iNetworkSetupFlag = -1; + iNetworkMode = -1; + } + break; + default: + continue; } } } else if (byInputKey <= 0x4Du) { LABEL_119: if (network_on) select_messages(); - } else if (byInputKey < 0x6Du) // M/m keys: Open message selection (network mode only) + } else if (byInputKey < + 0x6Du) // M/m keys: Open message selection (network mode only) { if (byInputKey == 81) goto LABEL_121; } else { if (byInputKey <= 0x6Du) goto LABEL_119; - if (byInputKey == 113) { // Q/q keys: Quit network and return to player selection + if (byInputKey == + 113) { // Q/q keys: Quit network and return to player selection LABEL_121: if (network_on) { broadcast_mode = -666; @@ -377,8 +437,10 @@ void select_players() UpdateSDL(); } UpdateSDL(); - } while (!iExitFlag); // MAIN SELECTION LOOP - Handle UI rendering and input processing - if (uiSelectedPlayerType < 3) // CLEANUP: Set final player type and network settings based on selection + } while (!iExitFlag); // MAIN SELECTION LOOP - Handle UI rendering and input + // processing + if (uiSelectedPlayerType < 3) // CLEANUP: Set final player type and network + // settings based on selection { if (uiSelectedPlayerType != 1) goto LABEL_169; diff --git a/PROJECTS/ROLLER/frontend_select_track.c b/PROJECTS/ROLLER/frontend_select_track.c index 97233797..2896605b 100644 --- a/PROJECTS/ROLLER/frontend_select_track.c +++ b/PROJECTS/ROLLER/frontend_select_track.c @@ -26,49 +26,48 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif -void snapshot_render_menu_select_track(void) -{ +void snapshot_render_menu_select_track(void) { snapshot_setup_frontend_menu_state(0); select_track(); } - //------------------------------------------------------------------------------------------------- -//00049070 -void select_track() -{ - int iAnimationTimer; // edi - int iSelectedTrack; // ebp - int iCurrentTrack; // esi - int iLapsForLevel; // eax - double dZoomInterpolation; // st7 +// 00049070 +void select_track() { + int iAnimationTimer; // edi + int iSelectedTrack; // ebp + int iCurrentTrack; // esi + int iLapsForLevel; // eax + double dZoomInterpolation; // st7 unsigned int uiKeyDirection; // ecx - uint8 byKey; // al - uint8 byKey_1; // al - float fZ_1; // [esp+4h] [ebp-4Ch] - float fTargetZoom; // [esp+8h] [ebp-48h] - int iFrameCount; // [esp+Ch] [ebp-44h] - int iBlockIdx; // [esp+10h] [ebp-40h] - int iSoundFlag; // [esp+14h] [ebp-3Ch] - int iYaw; // [esp+18h] [ebp-38h] - int iPrevTrackLoad; // [esp+1Ch] [ebp-34h] - float fZ; // [esp+20h] [ebp-30h] - int iCupOffset; // [esp+24h] [ebp-2Ch] - int iTrackInCup; // [esp+28h] [ebp-28h] - int iExitFlag; // [esp+2Ch] [ebp-24h] - int iCalculatedTrack; // [esp+30h] [ebp-20h] + uint8 byKey; // al + uint8 byKey_1; // al + float fZ_1; // [esp+4h] [ebp-4Ch] + float fTargetZoom; // [esp+8h] [ebp-48h] + int iFrameCount; // [esp+Ch] [ebp-44h] + int iBlockIdx; // [esp+10h] [ebp-40h] + int iSoundFlag; // [esp+14h] [ebp-3Ch] + int iYaw; // [esp+18h] [ebp-38h] + int iPrevTrackLoad; // [esp+1Ch] [ebp-34h] + float fZ; // [esp+20h] [ebp-30h] + int iCupOffset; // [esp+24h] [ebp-2Ch] + int iTrackInCup; // [esp+28h] [ebp-28h] + int iExitFlag; // [esp+2Ch] [ebp-24h] + int iCalculatedTrack; // [esp+30h] [ebp-20h] int iFrontendSpeechPending; iAnimationTimer = 36; - fade_palette(0); // Initialize track selection screen - fade out and reset state + fade_palette( + 0); // Initialize track selection screen - fade out and reset state iSoundFlag = 0; front_fade = 0; iExitFlag = 0; iFrontendSpeechPending = 0; - if (TrackLoad > 0) // Set initial track selection based on current TrackLoad and game type + if (TrackLoad > + 0) // Set initial track selection based on current TrackLoad and game type { iSelectedTrack = ((uint8)TrackLoad - 1) & 7; if (game_type == 1) @@ -77,7 +76,8 @@ void select_track() iSelectedTrack = 0; } iCurrentTrack = TrackLoad; - fre((void **)&front_vga[3]); // Load track selection UI graphics and 3D track preview + fre((void **)&front_vga[3]); // Load track selection UI graphics and 3D track + // preview if (TrackLoad >= 0) loadtrack(TrackLoad, -1); front_vga[3] = (tBlockHeader *)load_picture("trkname.bm"); @@ -100,19 +100,20 @@ void select_track() fZ = cur_TrackZ; fZ_1 = cur_TrackZ; fTargetZoom = -(cur_TrackZ + -10000000.0f) * 0.05f; - do { // Main track selection display loop + do { // Main track selection display loop if (game_type == 1) iSelectedTrack = 8; iFrameCount = frames; frames = 0; int bStartedFadeIn = 0; iPrevTrackLoad = TrackLoad; - if (SoundCard && front_fade && iFrontendSpeechPending && sfxplaying(SOUND_SAMPLE_TRACK) == 0) - { + if (SoundCard && front_fade && iFrontendSpeechPending && + sfxplaying(SOUND_SAMPLE_TRACK) == 0) { frontendsample(0x8000); iFrontendSpeechPending = 0; } - if (switch_types) // Handle game type switching (championship/single race/team game) + if (switch_types) // Handle game type switching (championship/single + // race/team game) { game_type = switch_types - 1; if (switch_types == 1 && competitors == 1) @@ -123,147 +124,179 @@ void select_track() else network_champ_on = 0; } - { // RENDER FRAME (GPU) - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_frame(mr); - if (!front_fade) { - front_fade = -1; - bStartedFadeIn = -1; - menu_render_begin_fade(mr, 1, 32); - } - menu_render_background(mr, 0); - menu_render_sprite(mr, 1, 2, head_x, head_y, 0, pal_addr); - if (cup_won) // Show cup trophy if championship won - menu_render_sprite(mr, 1, 8, 480, 388, 0, pal_addr); - menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); - menu_render_sprite(mr, 5, player_type, -4, 247, 0, pal_addr);// Display player type and game type indicators - menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); - menu_render_sprite(mr, 4, 1, 76, 257, -1, pal_addr); - if (iSelectedTrack >= 8) // Draw track selector: championship view or individual track selector - { - menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); - } else { - menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); - menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, sel_posns[iSelectedTrack].x, sel_posns[iSelectedTrack].y, 0x8Fu, 0, pal_addr); - } - menu_render_text(mr, 2, "AUTO ARIEL", font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr);// Display hardcoded track names (should use track name data) - menu_render_text(mr, 2, "DESILVA", font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "PULSE", font2_ascii, font2_offsets, sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "GLOBAL", font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "MILLION PLUS", font2_ascii, font2_offsets, sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "MISSION", font2_ascii, font2_offsets, sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "ZIZIN", font2_ascii, font2_offsets, sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, "REISE WAGON", font2_ascii, font2_offsets, sel_posns[7].x + 132, sel_posns[7].y + 7, 0x8Fu, 2u, pal_addr); - iBlockIdx = (TrackLoad - 1) / 8; // Calculate cup icon index (8 tracks per cup) - //iBlockIdx = (TrackLoad - 1 - (__CFSHL__((TrackLoad - 1) >> 31, 3) + 8 * ((TrackLoad - 1) >> 31))) >> 3;// Calculate cup icon index for display - if (TrackLoad >= 0) { // Render 3D track preview - menu_render_load_track_mesh(mr, palette); - if (iAnimationTimer) - menu_render_draw_track_preview(mr, fZ, 1280, iYaw, PREVIEW_X, TRACK_PREVIEW_Y, PREVIEW_W, PREVIEW_H); - else - menu_render_draw_track_preview(mr, fZ_1, 1280, iYaw, PREVIEW_X, TRACK_PREVIEW_Y, PREVIEW_W, PREVIEW_H); - menu_render_set_layer(mr, MENU_LAYER_FOREGROUND); - if (game_type >= 2) // Set number of laps based on game type and difficulty level + { // RENDER FRAME (GPU) + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_frame(mr); + if (!front_fade) { + front_fade = -1; + bStartedFadeIn = -1; + menu_render_begin_fade(mr, 1, 32); + } + menu_render_background(mr, 0); + menu_render_sprite(mr, 1, 2, head_x, head_y, 0, pal_addr); + if (cup_won) // Show cup trophy if championship won + menu_render_sprite(mr, 1, 8, 480, 388, 0, pal_addr); + menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); + menu_render_sprite( + mr, 5, player_type, -4, 247, 0, + pal_addr); // Display player type and game type indicators + menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); + menu_render_sprite(mr, 4, 1, 76, 257, -1, pal_addr); + if (iSelectedTrack >= 8) // Draw track selector: championship view or + // individual track selector { - NoOfLaps = 5; + menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); } else { - iLapsForLevel = cur_laps[level]; - NoOfLaps = iLapsForLevel; - if (competitors == 2) - NoOfLaps = iLapsForLevel / 2; + menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); + menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, + sel_posns[iSelectedTrack].x, + sel_posns[iSelectedTrack].y, 0x8Fu, 0, pal_addr); } - sprintf(buffer, "%s: %i", &language_buffer[4544], NoOfLaps); - menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 16, 0x8Fu, 1u, pal_addr); - menu_render_text(mr, 15, &language_buffer[4608], font1_ascii, font1_offsets, 420, 34, 0x8Fu, 1u, pal_addr); - if (RecordCars[TrackLoad] < 0) // Display track record holder and lap time + menu_render_text(mr, 2, "AUTO ARIEL", font2_ascii, font2_offsets, + sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, + pal_addr); // Display hardcoded track names (should use + // track name data) + menu_render_text(mr, 2, "DESILVA", font2_ascii, font2_offsets, + sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "PULSE", font2_ascii, font2_offsets, + sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "GLOBAL", font2_ascii, font2_offsets, + sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "MILLION PLUS", font2_ascii, font2_offsets, + sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "MISSION", font2_ascii, font2_offsets, + sel_posns[5].x + 132, sel_posns[5].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "ZIZIN", font2_ascii, font2_offsets, + sel_posns[6].x + 132, sel_posns[6].y + 7, 0x8Fu, 2u, + pal_addr); + menu_render_text(mr, 2, "REISE WAGON", font2_ascii, font2_offsets, + sel_posns[7].x + 132, sel_posns[7].y + 7, 0x8Fu, 2u, + pal_addr); + iBlockIdx = + (TrackLoad - 1) / 8; // Calculate cup icon index (8 tracks per cup) + // iBlockIdx = (TrackLoad - 1 - (__CFSHL__((TrackLoad - 1) >> 31, 3) + 8 * + // ((TrackLoad - 1) >> 31))) >> 3;// Calculate cup icon index for display + if (TrackLoad >= 0) { // Render 3D track preview + menu_render_load_track_mesh(mr, palette); + if (iAnimationTimer) + menu_render_draw_track_preview(mr, fZ, 1280, iYaw, PREVIEW_X, + TRACK_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + else + menu_render_draw_track_preview(mr, fZ_1, 1280, iYaw, PREVIEW_X, + TRACK_PREVIEW_Y, PREVIEW_W, PREVIEW_H); + menu_render_set_layer(mr, MENU_LAYER_FOREGROUND); + if (game_type >= + 2) // Set number of laps based on game type and difficulty level + { + NoOfLaps = 5; + } else { + iLapsForLevel = cur_laps[level]; + NoOfLaps = iLapsForLevel; + if (competitors == 2) + NoOfLaps = iLapsForLevel / 2; + } + sprintf(buffer, "%s: %i", &language_buffer[4544], NoOfLaps); + menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 16, + 0x8Fu, 1u, pal_addr); + menu_render_text(mr, 15, &language_buffer[4608], font1_ascii, + font1_offsets, 420, 34, 0x8Fu, 1u, pal_addr); + if (RecordCars[TrackLoad] < + 0) // Display track record holder and lap time + { + sprintf(buffer, "%s", RecordNames[TrackLoad]); + } else { + // Format lap time as MM:SS:CC (minutes:seconds:centiseconds) + int iTotalCentiseconds = (int)(RecordLaps[TrackLoad] * 100.0); + int iRecordMinutes = iTotalCentiseconds / 6000; + int iRecordSeconds = (iTotalCentiseconds / 100) % 60; + int iRecordCentiseconds = iTotalCentiseconds % 100; + + sprintf(buffer, "%s - %s - %02i:%02i:%02i", RecordNames[TrackLoad], + CompanyNames[RecordCars[TrackLoad] & 0xF], iRecordMinutes, + iRecordSeconds, iRecordCentiseconds); + // dRecordTimeFloat = RecordLaps[TrackLoad] * 100.0;// Format lap time + // as MM:SS:CC (minutes:seconds:centiseconds) _CHP(); + // LODWORD(llTimeCalc) = (int)dRecordTimeFloat; + // HIDWORD(llTimeCalc) = (int)dRecordTimeFloat >> 31; + // iRecordMinutes = llTimeCalc / 6000; + // LODWORD(llTimeCalc) = (int)dRecordTimeFloat; + // iRecordSeconds = (int)(llTimeCalc / 100) % 60; + // LODWORD(llTimeCalc) = (int)dRecordTimeFloat; + // sprintf( + // buffer, + // "%s - %s - %02i:%02i:%02i", + // RecordNames[TrackLoad], + // CompanyNames[RecordCars[TrackLoad] & 0xF], + // iRecordMinutes, + // iRecordSeconds, + // (unsigned int)(llTimeCalc % 100)); + } + menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 52, + 0x8Fu, 1u, pal_addr); + } + menu_render_sprite(mr, 14, iBlockIdx, 500, 300, 0, + pal_addr); // Display cup icon and track name/type + if (TrackLoad <= 0) { + if (TrackLoad) + menu_render_text(mr, 2, "EDITOR", font2_ascii, font2_offsets, 190, + 350, 0x8Fu, 0, pal_addr); + else + menu_render_text(mr, 2, "TRACK ZERO", font2_ascii, font2_offsets, 190, + 350, 0x8Fu, 0, pal_addr); + } else if (TrackLoad >= 17) // Display track name: bonus tracks (17+), + // regular tracks (1-16), or special tracks { - sprintf(buffer, "%s", RecordNames[TrackLoad]); + menu_render_sprite(mr, 13, TrackLoad - 17, 190, 356, 0, pal_addr); } else { - // Format lap time as MM:SS:CC (minutes:seconds:centiseconds) - int iTotalCentiseconds = (int)(RecordLaps[TrackLoad] * 100.0); - int iRecordMinutes = iTotalCentiseconds / 6000; - int iRecordSeconds = (iTotalCentiseconds / 100) % 60; - int iRecordCentiseconds = iTotalCentiseconds % 100; - - sprintf(buffer, "%s - %s - %02i:%02i:%02i", - RecordNames[TrackLoad], - CompanyNames[RecordCars[TrackLoad] & 0xF], - iRecordMinutes, - iRecordSeconds, - iRecordCentiseconds); - //dRecordTimeFloat = RecordLaps[TrackLoad] * 100.0;// Format lap time as MM:SS:CC (minutes:seconds:centiseconds) - //_CHP(); - //LODWORD(llTimeCalc) = (int)dRecordTimeFloat; - //HIDWORD(llTimeCalc) = (int)dRecordTimeFloat >> 31; - //iRecordMinutes = llTimeCalc / 6000; - //LODWORD(llTimeCalc) = (int)dRecordTimeFloat; - //iRecordSeconds = (int)(llTimeCalc / 100) % 60; - //LODWORD(llTimeCalc) = (int)dRecordTimeFloat; - //sprintf( - // buffer, - // "%s - %s - %02i:%02i:%02i", - // RecordNames[TrackLoad], - // CompanyNames[RecordCars[TrackLoad] & 0xF], - // iRecordMinutes, - // iRecordSeconds, - // (unsigned int)(llTimeCalc % 100)); + menu_render_sprite(mr, 3, TrackLoad - 1, 190, 356, 0, pal_addr); } - menu_render_text(mr, 15, buffer, font1_ascii, font1_offsets, 420, 52, 0x8Fu, 1u, pal_addr); - } - menu_render_sprite(mr, 14, iBlockIdx, 500, 300, 0, pal_addr);// Display cup icon and track name/type - if (TrackLoad <= 0) { - if (TrackLoad) - menu_render_text(mr, 2, "EDITOR", font2_ascii, font2_offsets, 190, 350, 0x8Fu, 0, pal_addr); - else - menu_render_text(mr, 2, "TRACK ZERO", font2_ascii, font2_offsets, 190, 350, 0x8Fu, 0, pal_addr); - } else if (TrackLoad >= 17) // Display track name: bonus tracks (17+), regular tracks (1-16), or special tracks - { - menu_render_sprite(mr, 13, TrackLoad - 17, 190, 356, 0, pal_addr); - } else { - menu_render_sprite(mr, 3, TrackLoad - 1, 190, 356, 0, pal_addr); - } - show_received_mesage(); - menu_render_end_frame(mr); - if (SnapshotShouldStop()) - return; + show_received_mesage(); + menu_render_end_frame(mr); + if (SnapshotShouldStop()) + return; } - if (switch_same > 0) // Handle same-car mode activation/deactivation + if (switch_same > 0) // Handle same-car mode activation/deactivation { for (int i = 0; i < players; i++) { - Players_Cars[i] = switch_same - 666; + Players_Cars[i] = switch_same - 666; } - //iPlayerLoop2 = 0; // Activate same-car mode: set all players to same car type - //if (players > 0) { - // iArrayOffset2 = 0; - // do { - // iArrayOffset2 += 4; - // ++iPlayerLoop2; - // *(int *)((char *)&infinite_laps + iArrayOffset2) = switch_same - 666; - // } while (iPlayerLoop2 < players); - //} + // iPlayerLoop2 = 0; // Activate same-car mode: + // set all players to same car type if (players > 0) { + // iArrayOffset2 = 0; + // do { + // iArrayOffset2 += 4; + // ++iPlayerLoop2; + // *(int *)((char *)&infinite_laps + iArrayOffset2) = switch_same - + // 666; + // } while (iPlayerLoop2 < players); + // } cheat_mode |= CHEAT_MODE_CLONES; } else if (switch_same < 0) { switch_same = 0; for (int i = 0; i < players; i++) { - Players_Cars[i] = -1; + Players_Cars[i] = -1; } - //iPlayerLoop1 = 0; // Deactivate same-car mode: reset all player car selections - //switch_same = 0; - //if (players > 0) { - // iArrayOffset1 = 0; - // do { - // iArrayOffset1 += 4; - // ++iPlayerLoop1; - // *(int *)((char *)&infinite_laps + iArrayOffset1) = -1; - // } while (iPlayerLoop1 < players); - //} + // iPlayerLoop1 = 0; // Deactivate same-car mode: + // reset all player car selections switch_same = 0; if (players > 0) { + // iArrayOffset1 = 0; + // do { + // iArrayOffset1 += 4; + // ++iPlayerLoop1; + // *(int *)((char *)&infinite_laps + iArrayOffset1) = -1; + // } while (iPlayerLoop1 < players); + // } cheat_mode &= ~CHEAT_MODE_CLONES; } - if (!iAnimationTimer) // Handle 3D camera zoom animation + if (!iAnimationTimer) // Handle 3D camera zoom animation { dZoomInterpolation = (double)iFrameCount * fTargetZoom + fZ_1; fZ_1 = (float)dZoomInterpolation; @@ -271,10 +304,11 @@ void select_track() if (fZ_1 < fZ) { fZ_1 = fZ; iAnimationTimer = 72; - fTargetZoom = -fTargetZoom; // Reverse zoom direction + fTargetZoom = -fTargetZoom; // Reverse zoom direction } } else { - fZ_1 = 10000000.0; // Camera reached max zoom - load new track and reset animation + fZ_1 = 10000000.0; // Camera reached max zoom - load new track and reset + // animation if (iCurrentTrack == TrackLoad) iPrevTrackLoad = -1; TrackLoad = iCurrentTrack; @@ -296,14 +330,16 @@ void select_track() frames = 0; } } - if (bStartedFadeIn) // Initialize screen fade and track voice sample on first display + if (bStartedFadeIn) // Initialize screen fade and track voice sample on + // first display { loadtracksample(TrackLoad); iFrontendSpeechPending = 0; frontendsample(0x8000); frames = 0; } - if (TrackLoad != iPrevTrackLoad) // Track changed - play selection sound and reset animation + if (TrackLoad != iPrevTrackLoad) // Track changed - play selection sound and + // reset animation { if (!iSoundFlag) { sfxsample(SOUND_SAMPLE_TRACK, 0x8000); @@ -313,17 +349,18 @@ void select_track() iCurrentTrack = TrackLoad; iAnimationTimer = 0; } - iCupOffset = 8 * iBlockIdx; // Calculate track selection values for input handling + iCupOffset = + 8 * iBlockIdx; // Calculate track selection values for input handling iTrackInCup = iSelectedTrack + 1; uiKeyDirection = 0; iCalculatedTrack = 8 * iBlockIdx + iSelectedTrack + 1; - while (fatkbhit()) // Process keyboard input for track selection + while (fatkbhit()) // Process keyboard input for track selection { UpdateSDL(); byKey = fatgetch(); if (byKey < 0xDu) { if (!byKey) { - byKey_1 = fatgetch(); // Handle arrow keys: Up (0x48) and Down (0x50) + byKey_1 = fatgetch(); // Handle arrow keys: Up (0x48) and Down (0x50) if (byKey_1 >= 0x48u) { if (byKey_1 <= 0x48u) { uiKeyDirection = 2; @@ -332,41 +369,51 @@ void select_track() } } } - } else if (byKey <= 0xDu) { // Enter key pressed - confirm track selection - if (iSelectedTrack != 8 && iCurrentTrack != iCalculatedTrack || iSelectedTrack == 8) { + } else if (byKey <= 0xDu) { // Enter key pressed - confirm track selection + if (iSelectedTrack != 8 && iCurrentTrack != iCalculatedTrack || + iSelectedTrack == 8) { remove_frontendspeech(); iFrontendSpeechPending = 0; sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); } - //if (iCurrentTrack == iCalculatedTrack && SoundCard && frontendspeechhandle != -1 && sosDIGISampleDone(*(int *)&DIGIHandle, frontendspeechhandle)) { - if (iCurrentTrack == iCalculatedTrack && SoundCard && frontendspeechhandle != -1 && DIGISampleDone(frontendspeechhandle)) { + // if (iCurrentTrack == iCalculatedTrack && SoundCard && + // frontendspeechhandle != -1 && sosDIGISampleDone(*(int *)&DIGIHandle, + // frontendspeechhandle)) { + if (iCurrentTrack == iCalculatedTrack && SoundCard && + frontendspeechhandle != -1 && + DIGISampleDone(frontendspeechhandle)) { frontendspeechhandle = -1; frontendsample(0x8000); } if (iSelectedTrack == 8) { iExitFlag = -1; - } else if (game_type != 1 && iCurrentTrack != iCupOffset + iTrackInCup) { + } else if (game_type != 1 && + iCurrentTrack != iCupOffset + iTrackInCup) { sfxsample(SOUND_SAMPLE_TRACK, 0x8000); iFrontendSpeechPending = 0; iCurrentTrack = iCupOffset + iTrackInCup; if (iAnimationTimer) { iAnimationTimer = 0; } else if (fTargetZoom < 0.0) { - fTargetZoom = -fTargetZoom; // Reverse zoom direction + fTargetZoom = -fTargetZoom; // Reverse zoom direction } } } else if (byKey >= 0x1Bu) { if (byKey <= 0x1Bu) { - remove_frontendspeech(); // Escape key pressed - exit track selection + remove_frontendspeech(); // Escape key pressed - exit track selection iFrontendSpeechPending = 0; sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); iExitFlag = -1; - } else if (byKey == 32 && game_type != 1 && TrackLoad > 0)// Space key pressed - cycle through cup categories + } else if (byKey == 32 && game_type != 1 && + TrackLoad > + 0) // Space key pressed - cycle through cup categories { iCurrentTrack += 8; sfxsample(SOUND_SAMPLE_TRACK, 0x8000); iFrontendSpeechPending = 0; - if (iCurrentTrack > 8 && iCurrentTrack < 17 && (cup_won & 1) == 0)// Skip locked cup categories based on championship progress + if (iCurrentTrack > 8 && iCurrentTrack < 17 && + (cup_won & 1) == 0) // Skip locked cup categories based on + // championship progress iCurrentTrack += 8; if (iCurrentTrack > 16 && iCurrentTrack < 25 && (cup_won & 2) == 0) iCurrentTrack += 8; @@ -375,12 +422,12 @@ void select_track() if (iAnimationTimer) { iAnimationTimer = 0; } else if (fTargetZoom < 0.0) { - fTargetZoom = -fTargetZoom; // Reverse zoom direction + fTargetZoom = -fTargetZoom; // Reverse zoom direction } } } } - if (uiKeyDirection) // Process up/down arrow key movement in track list + if (uiKeyDirection) // Process up/down arrow key movement in track list { if (uiKeyDirection > 1) { if (game_type != 1 && --iSelectedTrack < 0) diff --git a/PROJECTS/ROLLER/frontend_select_type.c b/PROJECTS/ROLLER/frontend_select_type.c index 7bec86d7..908dc5ec 100644 --- a/PROJECTS/ROLLER/frontend_select_type.c +++ b/PROJECTS/ROLLER/frontend_select_type.c @@ -26,76 +26,78 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif -void snapshot_render_menu_select_type(void) -{ +void snapshot_render_menu_select_type(void) { snapshot_setup_frontend_menu_state(0); for (int i = 0; i < 5; ++i) - SnapshotQueueRawKey(0x48); // Up arrow: real input path from Exit to Game Type. + SnapshotQueueRawKey( + 0x48); // Up arrow: real input path from Exit to Game Type. select_type(); } - //------------------------------------------------------------------------------------------------- -//00047AE0 -void select_type() -{ - int iMenuSelection; // edi - int iCurrentOption; // esi - char *pszTextBuffer; // edx - char byGameModeColor1; // al - char byGameModeColor2; // al - char byGameModeColor3; // al - char byDifficultyColor1; // al - char byDifficultyColor2; // al - char byDifficultyColor3; // al - char byDifficultyColor4; // al - char byDifficultyColor5; // al - char byDifficultyColor6; // al - char byCompetitorColor1; // al - char byCompetitorColor2; // al - char byCompetitorColor3; // al - char byDamageColor1; // al - char byDamageColor2; // al - char byDamageColor3; // al - char byTextureColor1; // al - char byTextureColor2; // al +// 00047AE0 +void select_type() { + int iMenuSelection; // edi + int iCurrentOption; // esi + char *pszTextBuffer; // edx + char byGameModeColor1; // al + char byGameModeColor2; // al + char byGameModeColor3; // al + char byDifficultyColor1; // al + char byDifficultyColor2; // al + char byDifficultyColor3; // al + char byDifficultyColor4; // al + char byDifficultyColor5; // al + char byDifficultyColor6; // al + char byCompetitorColor1; // al + char byCompetitorColor2; // al + char byCompetitorColor3; // al + char byDamageColor1; // al + char byDamageColor2; // al + char byDamageColor3; // al + char byTextureColor1; // al + char byTextureColor2; // al uint32 uiUpdatedCheatFlags; // eax - int iCheatSetLoop; // eax - uint8 byInputKey; // al - uint8 byExtendedKey; // al - int iCupIncrement; // edx - int iTrackUpperLimit; // edx - int iTrackLowerLimit; // ebx - int iTextYPosition; // [esp-14h] [ebp-48h] - char byFinalTextColor; // [esp-10h] [ebp-44h] - int iCheatModesAvailable; // [esp+0h] [ebp-34h] - int iExitFlag; // [esp+4h] [ebp-30h] - int iSkipColor; // [esp+8h] [ebp-2Ch] + int iCheatSetLoop; // eax + uint8 byInputKey; // al + uint8 byExtendedKey; // al + int iCupIncrement; // edx + int iTrackUpperLimit; // edx + int iTrackLowerLimit; // ebx + int iTextYPosition; // [esp-14h] [ebp-48h] + char byFinalTextColor; // [esp-10h] [ebp-44h] + int iCheatModesAvailable; // [esp+0h] [ebp-34h] + int iExitFlag; // [esp+4h] [ebp-30h] + int iSkipColor; // [esp+8h] [ebp-2Ch] char byCompetitorMenuColor; // [esp+Ch] [ebp-28h] - char byTextColor; // [esp+10h] [ebp-24h] - char byDamageMenuColor; // [esp+14h] [ebp-20h] - char byTextureMenuColor; // [esp+18h] [ebp-1Ch] + char byTextColor; // [esp+10h] [ebp-24h] + char byDamageMenuColor; // [esp+14h] [ebp-20h] + char byTextureMenuColor; // [esp+18h] [ebp-1Ch] char byDifficultyMenuColor; // [esp+1Ch] [ebp-18h] - int iNetworkDisplayY; // [esp+20h] [ebp-14h] - int iY; // [esp+24h] [ebp-10h] - char *szText; // [esp+28h] [ebp-Ch] - int iNetworkPlayerCount; // [esp+2Ch] [ebp-8h] - int iBlockIdx; // [esp+30h] [ebp-4h] + int iNetworkDisplayY; // [esp+20h] [ebp-14h] + int iY; // [esp+24h] [ebp-10h] + char *szText; // [esp+28h] [ebp-Ch] + int iNetworkPlayerCount; // [esp+2Ch] [ebp-8h] + int iBlockIdx; // [esp+30h] [ebp-4h] - iExitFlag = 0; // Initialize exit flag and check game restrictions - if (game_type == 1 && Race > 0) // Championship mode after first race - restrict options to track selection only + iExitFlag = 0; // Initialize exit flag and check game restrictions + if (game_type == 1 && Race > 0) // Championship mode after first race - + // restrict options to track selection only iSkipColor = -1; else iSkipColor = 0; - if ((cheat_mode & TEX_OFF_SHADOWS) != 0 || (textures_off & TEX_OFF_CAR_SET_AVAILABLE) != 0) + if ((cheat_mode & TEX_OFF_SHADOWS) != 0 || + (textures_off & TEX_OFF_CAR_SET_AVAILABLE) != 0) iCheatModesAvailable = -1; else iCheatModesAvailable = 0; - iBlockIdx = (TrackLoad - 1) / 8;// Calculate cup index from current track (TrackLoad): cups are groups of 8 tracks - front_vga[14] = (tBlockHeader *)load_picture("cupicons.bm"); // Load cup icons graphics and initialize screen + iBlockIdx = (TrackLoad - 1) / 8; // Calculate cup index from current track + // (TrackLoad): cups are groups of 8 tracks + front_vga[14] = (tBlockHeader *)load_picture( + "cupicons.bm"); // Load cup icons graphics and initialize screen iMenuSelection = 0; fade_palette(0); front_fade = 0; @@ -111,7 +113,7 @@ void select_type() } frames = 0; iCurrentOption = 5; - do { // Handle game type switches and updates + do { // Handle game type switches and updates if (switch_types) { game_type = switch_types - 1; if (switch_types == 1 && competitors == 1) @@ -122,92 +124,144 @@ void select_type() else network_champ_on = 0; } - { // RENDER FRAME (GPU) - MenuRenderer *mr = GetMenuRenderer(); - menu_render_begin_frame(mr); - if (!front_fade) { - front_fade = -1; - menu_render_begin_fade(mr, 1, 32); - } - menu_render_background(mr, 0); - menu_render_sprite(mr, 1, 4, head_x, head_y, 0, pal_addr); - menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); - menu_render_sprite(mr, 5, player_type, -4, 247, 0, pal_addr); - menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); - menu_render_sprite(mr, 4, 4, 76, 257, -1, pal_addr); - if (cup_won && !iSkipColor) - menu_render_sprite(mr, 1, 8, 200, 56, 0, pal_addr); - if (iCurrentOption >= 5) // Draw selection cursor or \"Random\" indicator (option 5 = Random) - { - menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); - } else { - menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); - menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, sel_posns[iCurrentOption].x, sel_posns[iCurrentOption].y, 0x8Fu, 0, pal_addr); - } - if (iSkipColor) // OPTION LABELS: Display main option categories (Game Type/Difficulty/etc.) - { - menu_render_text(mr, 2, &language_buffer[3136], font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); - } else { - menu_render_text(mr, 2, &language_buffer[384], font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[3200], font2_ascii, font2_offsets, sel_posns[1].x + 132, sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[3264], font2_ascii, font2_offsets, sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u, pal_addr); - menu_render_text(mr, 2, &language_buffer[3328], font2_ascii, font2_offsets, sel_posns[3].x + 132, sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); - if (iCheatModesAvailable) - menu_render_text(mr, 2, &language_buffer[4288], font2_ascii, font2_offsets, sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u, pal_addr); - } - menu_render_sprite(mr, 14, iBlockIdx, 500, 300, 0, pal_addr);// Display cup icon corresponding to current track selection - if (iSkipColor) // CHAMPIONSHIP MODE UI: Show current settings and restrictions - { - menu_render_scaled_text(mr, 15, &language_buffer[3392], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr); - menu_render_scaled_text(mr, 15, &language_buffer[1280], font1_ascii, font1_offsets, 400, 100, 143, 2u, 200, 640, pal_addr); - if ((cheat_mode & 2) != 0) - menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, font1_offsets, 405, 100, 143, 0, 200, 640, pal_addr); - else - menu_render_scaled_text(mr, 15, &language_buffer[64 * level + 1472], font1_ascii, font1_offsets, 405, 100, 143, 0, 200, 640, pal_addr); - menu_render_scaled_text(mr, 15, &language_buffer[1344], font1_ascii, font1_offsets, 400, 118, 143, 2u, 200, 640, pal_addr); - if ((cheat_mode & 2) != 0) - menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, font1_offsets, 405, 118, 143, 0, 200, 640, pal_addr); - else - menu_render_scaled_text(mr, 15, &language_buffer[64 * damage_level + 1856], font1_ascii, font1_offsets, 405, 118, 143, 0, 200, 640, pal_addr); - menu_render_scaled_text(mr, 15, &language_buffer[1024], font1_ascii, font1_offsets, 400, 136, 143, 2u, 200, 640, pal_addr); - if ((unsigned int)competitors < 8) { - if (competitors == 2) - menu_render_scaled_text(mr, 15, &language_buffer[1088], font1_ascii, font1_offsets, 405, 136, 143, 0, 200, 640, pal_addr); - } else if ((unsigned int)competitors <= 8) { - menu_render_scaled_text(mr, 15, &language_buffer[1152], font1_ascii, font1_offsets, 405, 136, 143, 0, 200, 640, pal_addr); - } else if (competitors == 16) { - menu_render_scaled_text(mr, 15, &language_buffer[1216], font1_ascii, font1_offsets, 405, 136, 143, 0, 200, 640, pal_addr); + { // RENDER FRAME (GPU) + MenuRenderer *mr = GetMenuRenderer(); + menu_render_begin_frame(mr); + if (!front_fade) { + front_fade = -1; + menu_render_begin_fade(mr, 1, 32); + } + menu_render_background(mr, 0); + menu_render_sprite(mr, 1, 4, head_x, head_y, 0, pal_addr); + menu_render_sprite(mr, 6, 0, 36, 2, 0, pal_addr); + menu_render_sprite(mr, 5, player_type, -4, 247, 0, pal_addr); + menu_render_sprite(mr, 5, game_type + 5, 135, 247, 0, pal_addr); + menu_render_sprite(mr, 4, 4, 76, 257, -1, pal_addr); + if (cup_won && !iSkipColor) + menu_render_sprite(mr, 1, 8, 200, 56, 0, pal_addr); + if (iCurrentOption >= 5) // Draw selection cursor or \"Random\" indicator + // (option 5 = Random) + { + menu_render_sprite(mr, 6, 4, 62, 336, -1, pal_addr); + } else { + menu_render_sprite(mr, 6, 2, 62, 336, -1, pal_addr); + menu_render_text(mr, 2, "~", font2_ascii, font2_offsets, + sel_posns[iCurrentOption].x, + sel_posns[iCurrentOption].y, 0x8Fu, 0, pal_addr); } - if (network_on) // NETWORK MODE: Display connected players list + if (iSkipColor) // OPTION LABELS: Display main option categories (Game + // Type/Difficulty/etc.) { - menu_render_scaled_text(mr, 15, &language_buffer[4672], font1_ascii, font1_offsets, 400, 154, 143, 1u, 200, 640, pal_addr); - iNetworkPlayerCount = 0; - if (players > 0) { - szText = player_names[0]; - iY = 28; - iNetworkDisplayY = 172; - do { - if (iNetworkPlayerCount >= 8) - menu_render_scaled_text(mr, 15, szText, font1_ascii, font1_offsets, 405, iY, 143, 0, 200, 640, pal_addr); - else - menu_render_scaled_text(mr, 15, szText, font1_ascii, font1_offsets, 400, iNetworkDisplayY, 143, 2u, 200, 640, pal_addr); - szText += 9; - iY += 18; - iNetworkDisplayY += 18; - ++iNetworkPlayerCount; + menu_render_text(mr, 2, &language_buffer[3136], font2_ascii, + font2_offsets, sel_posns[0].x + 132, + sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); + } else { + menu_render_text(mr, 2, &language_buffer[384], font2_ascii, + font2_offsets, sel_posns[0].x + 132, + sel_posns[0].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[3200], font2_ascii, + font2_offsets, sel_posns[1].x + 132, + sel_posns[1].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[3264], font2_ascii, + font2_offsets, sel_posns[2].x + 132, + sel_posns[2].y + 7, 0x8Fu, 2u, pal_addr); + menu_render_text(mr, 2, &language_buffer[3328], font2_ascii, + font2_offsets, sel_posns[3].x + 132, + sel_posns[3].y + 7, 0x8Fu, 2u, pal_addr); + if (iCheatModesAvailable) + menu_render_text(mr, 2, &language_buffer[4288], font2_ascii, + font2_offsets, sel_posns[4].x + 132, + sel_posns[4].y + 7, 0x8Fu, 2u, pal_addr); + } + menu_render_sprite(mr, 14, iBlockIdx, 500, 300, 0, + pal_addr); // Display cup icon corresponding to current + // track selection + if (iSkipColor) // CHAMPIONSHIP MODE UI: Show current settings and + // restrictions + { + menu_render_scaled_text(mr, 15, &language_buffer[3392], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, 640, + pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1280], font1_ascii, + font1_offsets, 400, 100, 143, 2u, 200, 640, + pal_addr); + if ((cheat_mode & 2) != 0) + menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, + font1_offsets, 405, 100, 143, 0, 200, 640, + pal_addr); + else + menu_render_scaled_text(mr, 15, &language_buffer[64 * level + 1472], + font1_ascii, font1_offsets, 405, 100, 143, 0, + 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1344], font1_ascii, + font1_offsets, 400, 118, 143, 2u, 200, 640, + pal_addr); + if ((cheat_mode & 2) != 0) + menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, + font1_offsets, 405, 118, 143, 0, 200, 640, + pal_addr); + else + menu_render_scaled_text( + mr, 15, &language_buffer[64 * damage_level + 1856], font1_ascii, + font1_offsets, 405, 118, 143, 0, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1024], font1_ascii, + font1_offsets, 400, 136, 143, 2u, 200, 640, + pal_addr); + if ((unsigned int)competitors < 8) { + if (competitors == 2) + menu_render_scaled_text(mr, 15, &language_buffer[1088], font1_ascii, + font1_offsets, 405, 136, 143, 0, 200, 640, + pal_addr); + } else if ((unsigned int)competitors <= 8) { + menu_render_scaled_text(mr, 15, &language_buffer[1152], font1_ascii, + font1_offsets, 405, 136, 143, 0, 200, 640, + pal_addr); + } else if (competitors == 16) { + menu_render_scaled_text(mr, 15, &language_buffer[1216], font1_ascii, + font1_offsets, 405, 136, 143, 0, 200, 640, + pal_addr); + } + if (network_on) // NETWORK MODE: Display connected players list + { + menu_render_scaled_text(mr, 15, &language_buffer[4672], font1_ascii, + font1_offsets, 400, 154, 143, 1u, 200, 640, + pal_addr); + iNetworkPlayerCount = 0; + if (players > 0) { + szText = player_names[0]; + iY = 28; + iNetworkDisplayY = 172; + do { + if (iNetworkPlayerCount >= 8) + menu_render_scaled_text(mr, 15, szText, font1_ascii, + font1_offsets, 405, iY, 143, 0, 200, + 640, pal_addr); + else + menu_render_scaled_text(mr, 15, szText, font1_ascii, + font1_offsets, 400, iNetworkDisplayY, + 143, 2u, 200, 640, pal_addr); + szText += 9; + iY += 18; + iNetworkDisplayY += 18; + ++iNetworkPlayerCount; - UpdateSDL(); - } while (iNetworkPlayerCount < players); + UpdateSDL(); + } while (iNetworkPlayerCount < players); + } } } - } - switch (iCurrentOption) { + switch (iCurrentOption) { case 0: - if (!iSkipColor) // Option 0 - Game Type: Show race modes with highlighting for current selection + if (!iSkipColor) // Option 0 - Game Type: Show race modes with + // highlighting for current selection { - menu_render_scaled_text(mr, 15, &language_buffer[384], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[384], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, 640, + pal_addr); if (iMenuSelection == 1) { - menu_render_scaled_text(mr, 15, &language_buffer[3584], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3584], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, 640, + pal_addr); byTextColor = -85; } else { byTextColor = -87; @@ -216,12 +270,16 @@ void select_type() byGameModeColor1 = -113; else byGameModeColor1 = byTextColor; - menu_render_scaled_text(mr, 15, &language_buffer[3648], font1_ascii, font1_offsets, 400, 135, byGameModeColor1, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3648], font1_ascii, + font1_offsets, 400, 135, byGameModeColor1, 1u, + 200, 640, pal_addr); if (game_type == 1) byGameModeColor2 = byTextColor; else byGameModeColor2 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[3520], font1_ascii, font1_offsets, 400, 153, byGameModeColor2, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3520], font1_ascii, + font1_offsets, 400, 153, byGameModeColor2, 1u, + 200, 640, pal_addr); if (game_type == 2) byGameModeColor3 = byTextColor; else @@ -232,7 +290,9 @@ void select_type() goto LABEL_130; } if (iMenuSelection == 6) { - menu_render_scaled_text(mr, 15, &language_buffer[3456], font1_ascii, font1_offsets, 400, 320, 231, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3456], font1_ascii, + font1_offsets, 400, 320, 231, 1u, 200, 640, + pal_addr); byFinalTextColor = -25; iTextYPosition = 338; pszTextBuffer = &language_buffer[3520]; @@ -240,9 +300,14 @@ void select_type() } break; case 1: - menu_render_scaled_text(mr, 15, &language_buffer[3776], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr);// Option 1 - Difficulty: Show skill levels with cheat mode override + menu_render_scaled_text(mr, 15, &language_buffer[3776], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, 640, + pal_addr); // Option 1 - Difficulty: Show skill + // levels with cheat mode override if (iMenuSelection == 2) { - menu_render_scaled_text(mr, 15, &language_buffer[3840], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3840], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, 640, + pal_addr); byDifficultyMenuColor = -85; } else { byDifficultyMenuColor = -87; @@ -252,27 +317,37 @@ void select_type() byDifficultyColor1 = byDifficultyMenuColor; else byDifficultyColor1 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1792], font1_ascii, font1_offsets, 400, 135, byDifficultyColor1, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1792], font1_ascii, + font1_offsets, 400, 135, byDifficultyColor1, + 1u, 200, 640, pal_addr); if (level == 4) byDifficultyColor2 = byDifficultyMenuColor; else byDifficultyColor2 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1728], font1_ascii, font1_offsets, 400, 153, byDifficultyColor2, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1728], font1_ascii, + font1_offsets, 400, 153, byDifficultyColor2, + 1u, 200, 640, pal_addr); if (level == 3) byDifficultyColor3 = byDifficultyMenuColor; else byDifficultyColor3 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1664], font1_ascii, font1_offsets, 400, 171, byDifficultyColor3, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1664], font1_ascii, + font1_offsets, 400, 171, byDifficultyColor3, + 1u, 200, 640, pal_addr); if (level == 2) byDifficultyColor4 = byDifficultyMenuColor; else byDifficultyColor4 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1600], font1_ascii, font1_offsets, 400, 189, byDifficultyColor4, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1600], font1_ascii, + font1_offsets, 400, 189, byDifficultyColor4, + 1u, 200, 640, pal_addr); if (level == 1) byDifficultyColor5 = byDifficultyMenuColor; else byDifficultyColor5 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1536], font1_ascii, font1_offsets, 400, 207, byDifficultyColor5, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1536], font1_ascii, + font1_offsets, 400, 207, byDifficultyColor5, + 1u, 200, 640, pal_addr); if (level) byDifficultyColor6 = -113; else @@ -282,12 +357,20 @@ void select_type() pszTextBuffer = &language_buffer[1472]; goto LABEL_130; } - menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, font1_offsets, 400, 135, byDifficultyMenuColor, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, + font1_offsets, 400, 135, byDifficultyMenuColor, + 1u, 200, 640, pal_addr); break; case 2: - menu_render_scaled_text(mr, 15, &language_buffer[3904], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr);// Option 2 - Competitors: Show number of opponent cars (2/8/16 or \"Just Me\") + menu_render_scaled_text( + mr, 15, &language_buffer[3904], font1_ascii, font1_offsets, 400, 75, + 143, 1u, 200, 640, + pal_addr); // Option 2 - Competitors: Show number of opponent cars + // (2/8/16 or \"Just Me\") if (iMenuSelection == 3) { - menu_render_scaled_text(mr, 15, &language_buffer[3008], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3008], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, 640, + pal_addr); byDamageMenuColor = -85; } else { byDamageMenuColor = -87; @@ -297,12 +380,16 @@ void select_type() byCompetitorColor1 = byDamageMenuColor; else byCompetitorColor1 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1088], font1_ascii, font1_offsets, 400, 135, byCompetitorColor1, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1088], font1_ascii, + font1_offsets, 400, 135, byCompetitorColor1, + 1u, 200, 640, pal_addr); if (competitors == 8) byCompetitorColor2 = byDamageMenuColor; else byCompetitorColor2 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1152], font1_ascii, font1_offsets, 400, 153, byCompetitorColor2, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1152], font1_ascii, + font1_offsets, 400, 153, byCompetitorColor2, + 1u, 200, 640, pal_addr); if (competitors == 16) byCompetitorColor3 = byDamageMenuColor; else @@ -312,12 +399,19 @@ void select_type() pszTextBuffer = &language_buffer[1216]; goto LABEL_130; } - menu_render_scaled_text(mr, 15, &language_buffer[3968], font1_ascii, font1_offsets, 400, 135, byDamageMenuColor, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3968], font1_ascii, + font1_offsets, 400, 135, byDamageMenuColor, 1u, + 200, 640, pal_addr); break; case 3: - menu_render_scaled_text(mr, 15, &language_buffer[4032], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr); // Option 3 - Damage: Show car damage levels (None/Cosmetic/Realistic) + menu_render_scaled_text(mr, 15, &language_buffer[4032], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, 640, + pal_addr); // Option 3 - Damage: Show car damage + // levels (None/Cosmetic/Realistic) if (iMenuSelection == 4) { - menu_render_scaled_text(mr, 15, &language_buffer[3840], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[3840], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, 640, + pal_addr); byTextureMenuColor = -85; } else { byTextureMenuColor = -87; @@ -327,12 +421,16 @@ void select_type() byDamageColor1 = -113; else byDamageColor1 = byTextureMenuColor; - menu_render_scaled_text(mr, 15, &language_buffer[1856], font1_ascii, font1_offsets, 400, 135, byDamageColor1, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1856], font1_ascii, + font1_offsets, 400, 135, byDamageColor1, 1u, + 200, 640, pal_addr); if (damage_level == 1) byDamageColor2 = byTextureMenuColor; else byDamageColor2 = -113; - menu_render_scaled_text(mr, 15, &language_buffer[1920], font1_ascii, font1_offsets, 400, 153, byDamageColor2, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[1920], font1_ascii, + font1_offsets, 400, 153, byDamageColor2, 1u, + 200, 640, pal_addr); if (damage_level == 2) byDamageColor3 = byTextureMenuColor; else @@ -342,12 +440,19 @@ void select_type() pszTextBuffer = &language_buffer[1984]; goto LABEL_130; } - menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, font1_offsets, 400, 135, byTextureMenuColor, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[2048], font1_ascii, + font1_offsets, 400, 135, byTextureMenuColor, 1u, + 200, 640, pal_addr); break; case 4: - menu_render_scaled_text(mr, 15, &language_buffer[4288], font1_ascii, font1_offsets, 400, 75, 143, 1u, 200, 640, pal_addr);// Option 4 - Textures: Show texture quality options (On/Off) + menu_render_scaled_text(mr, 15, &language_buffer[4288], font1_ascii, + font1_offsets, 400, 75, 143, 1u, 200, 640, + pal_addr); // Option 4 - Textures: Show texture + // quality options (On/Off) if (iMenuSelection == 5) { - menu_render_scaled_text(mr, 15, &language_buffer[4480], font1_ascii, font1_offsets, 400, 93, 143, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[4480], font1_ascii, + font1_offsets, 400, 93, 143, 1u, 200, 640, + pal_addr); byCompetitorMenuColor = -85; } else { byCompetitorMenuColor = -87; @@ -356,7 +461,9 @@ void select_type() byTextureColor1 = -113; else byTextureColor1 = byCompetitorMenuColor; - menu_render_scaled_text(mr, 15, &language_buffer[4352], font1_ascii, font1_offsets, 400, 135, byTextureColor1, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, &language_buffer[4352], font1_ascii, + font1_offsets, 400, 135, byTextureColor1, 1u, + 200, 640, pal_addr); if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) byTextureColor2 = byCompetitorMenuColor; else @@ -365,30 +472,35 @@ void select_type() iTextYPosition = 153; pszTextBuffer = &language_buffer[4416]; LABEL_130: - menu_render_scaled_text(mr, 15, pszTextBuffer, font1_ascii, font1_offsets, 400, iTextYPosition, byFinalTextColor, 1u, 200, 640, pal_addr); + menu_render_scaled_text(mr, 15, pszTextBuffer, font1_ascii, + font1_offsets, 400, iTextYPosition, + byFinalTextColor, 1u, 200, 640, pal_addr); break; default: - break; // OPTION-SPECIFIC UI: Display details for currently selected option - } - show_received_mesage(); - menu_render_end_frame(mr); - if (SnapshotShouldStop()) - return; + break; // OPTION-SPECIFIC UI: Display details for currently selected + // option + } + show_received_mesage(); + menu_render_end_frame(mr); + if (SnapshotShouldStop()) + return; } - if (switch_same > 0) // CHEAT MODE HANDLING: Process switch_same command for player synchronization + if (switch_same > 0) // CHEAT MODE HANDLING: Process switch_same command for + // player synchronization { iCheatSetLoop = 0; if (players > 0) { // Set all players to the same car in cheat mode for (int i = 0; i < players; i++) { - Players_Cars[i] = switch_same - 666; + Players_Cars[i] = switch_same - 666; } - //iCheatArrayOffset2 = 0; - //do { - // iCheatArrayOffset2 += 4; - // ++iCheatSetLoop; - // *(int *)((char *)&infinite_laps + iCheatArrayOffset2) = switch_same - 666; - //} while (iCheatSetLoop < players); + // iCheatArrayOffset2 = 0; + // do { + // iCheatArrayOffset2 += 4; + // ++iCheatSetLoop; + // *(int *)((char *)&infinite_laps + iCheatArrayOffset2) = switch_same + // - 666; + // } while (iCheatSetLoop < players); } uiUpdatedCheatFlags = cheat_mode; uiUpdatedCheatFlags |= CHEAT_MODE_CLONES; @@ -399,27 +511,28 @@ void select_type() for (int i = 0; i < players; i++) { Players_Cars[i] = -1; } - //iCheatResetLoop1 = 0; - //switch_same = 0; - //if (players > 0) { - // iCheatArrayOffset1 = 0; - // do { - // iCheatArrayOffset1 += 4; - // ++iCheatResetLoop1; - // *(int *)((char *)&infinite_laps + iCheatArrayOffset1) = -1; - // } while (iCheatResetLoop1 < players); - //} + // iCheatResetLoop1 = 0; + // switch_same = 0; + // if (players > 0) { + // iCheatArrayOffset1 = 0; + // do { + // iCheatArrayOffset1 += 4; + // ++iCheatResetLoop1; + // *(int *)((char *)&infinite_laps + iCheatArrayOffset1) = -1; + // } while (iCheatResetLoop1 < players); + // } uiUpdatedCheatFlags = cheat_mode; uiUpdatedCheatFlags &= ~CHEAT_MODE_CLONES; } cheat_mode = uiUpdatedCheatFlags; - LABEL_142: - ; - while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle navigation and option changes + LABEL_142:; + while (fatkbhit()) // KEYBOARD INPUT PROCESSING: Handle navigation and + // option changes { byInputKey = fatgetch(); if (byInputKey < 0x1Bu) { - if (byInputKey) { // Enter key: Confirm selection or navigate into sub-options + if (byInputKey) { // Enter key: Confirm selection or navigate into + // sub-options if (byInputKey == 13) { sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); if (iMenuSelection) { @@ -433,142 +546,148 @@ void select_type() UpdateSDL(); } else { switch (iCurrentOption) { - case 0: - if (iSkipColor) - iMenuSelection = 6; - else - iMenuSelection = 1; - break; - case 1: - iMenuSelection = 2; - break; - case 2: - iMenuSelection = 3; - break; - case 3: - iMenuSelection = 4; - break; - case 4: - iMenuSelection = 5; - break; - case 5: - goto LABEL_248; - default: - continue; + case 0: + if (iSkipColor) + iMenuSelection = 6; + else + iMenuSelection = 1; + break; + case 1: + iMenuSelection = 2; + break; + case 2: + iMenuSelection = 3; + break; + case 3: + iMenuSelection = 4; + break; + case 4: + iMenuSelection = 5; + break; + case 5: + goto LABEL_248; + default: + continue; } } } } else { - byExtendedKey = fatgetch(); // Arrow keys: Navigate through options and change values + byExtendedKey = fatgetch(); // Arrow keys: Navigate through options + // and change values switch (iMenuSelection) { - case 0: - if (byExtendedKey >= 0x48u) // Main menu navigation: Up/Down arrows move between option categories - { - if (byExtendedKey <= 0x48u) { - if (iSkipColor) { + case 0: + if (byExtendedKey >= 0x48u) // Main menu navigation: Up/Down arrows + // move between option categories + { + if (byExtendedKey <= 0x48u) { + if (iSkipColor) { + iCurrentOption = 0; + } else { + --iCurrentOption; + if (!iCheatModesAvailable && iCurrentOption == 4) + iCurrentOption = 3; + if (iCurrentOption < 0) iCurrentOption = 0; - } else { - --iCurrentOption; - if (!iCheatModesAvailable && iCurrentOption == 4) - iCurrentOption = 3; - if (iCurrentOption < 0) - iCurrentOption = 0; - } - } else if (byExtendedKey == 80) { - if (iSkipColor) { + } + } else if (byExtendedKey == 80) { + if (iSkipColor) { + iCurrentOption = 5; + } else { + if (iCheatModesAvailable) { + ++iCurrentOption; + } else if (++iCurrentOption > 3) { iCurrentOption = 5; - } else { - if (iCheatModesAvailable) { - ++iCurrentOption; - } else if (++iCurrentOption > 3) { - iCurrentOption = 5; - } - if (iCurrentOption > 5) - iCurrentOption = 5; } + if (iCurrentOption > 5) + iCurrentOption = 5; } } - break; - case 1: - if (byExtendedKey >= 0x48u) // Game Type option: Navigate between race modes and adjust competitors - { - if (byExtendedKey <= 0x48u) { - if (--game_type < 0) - game_type = 0; + } + break; + case 1: + if (byExtendedKey >= 0x48u) // Game Type option: Navigate between + // race modes and adjust competitors + { + if (byExtendedKey <= 0x48u) { + if (--game_type < 0) + game_type = 0; + if (competitors == 1) + goto LABEL_187; + } else if (byExtendedKey == 80) { + if (++game_type < 2) { if (competitors == 1) - goto LABEL_187; - } else if (byExtendedKey == 80) { - if (++game_type < 2) { - if (competitors == 1) - competitors = 16; - } else { - game_type = 2; - competitors = 1; - } + competitors = 16; + } else { + game_type = 2; + competitors = 1; } } - break; - case 2: - if (byExtendedKey >= 0x48u) { - if (byExtendedKey <= 0x48u) { - if (levels[++level] <= 0.0) - --level; - } else if (byExtendedKey == 80 && --level < 0) { - level = 0; - } + } + break; + case 2: + if (byExtendedKey >= 0x48u) { + if (byExtendedKey <= 0x48u) { + if (levels[++level] <= 0.0) + --level; + } else if (byExtendedKey == 80 && --level < 0) { + level = 0; } - break; - case 3: - if (byExtendedKey >= 0x48u) { - if (byExtendedKey <= 0x48u) { - if (game_type < 2 && (unsigned int)competitors >= 8) { - if ((unsigned int)competitors <= 8) { - competitors = 2; - } else if (competitors == 16) { - competitors = 8; - } - } - } else if (byExtendedKey == 80 && game_type < 2 && (unsigned int)competitors >= 2) { - if ((unsigned int)competitors <= 2) { + } + break; + case 3: + if (byExtendedKey >= 0x48u) { + if (byExtendedKey <= 0x48u) { + if (game_type < 2 && (unsigned int)competitors >= 8) { + if ((unsigned int)competitors <= 8) { + competitors = 2; + } else if (competitors == 16) { competitors = 8; - } else if (competitors == 8) { - LABEL_187: - competitors = 16; } } - } - break; - case 4: - if (byExtendedKey >= 0x48u) { - if (byExtendedKey <= 0x48u) { - if (--damage_level < 0) - damage_level = 0; - } else if (byExtendedKey == 80 && ++damage_level > 2) { - damage_level = 2; + } else if (byExtendedKey == 80 && game_type < 2 && + (unsigned int)competitors >= 2) { + if ((unsigned int)competitors <= 2) { + competitors = 8; + } else if (competitors == 8) { + LABEL_187: + competitors = 16; } } - break; - case 5: - if (byExtendedKey >= 0x48u) { - if (byExtendedKey <= 0x48u) { - textures_off &= ~TEX_OFF_ADVANCED_CARS; - } else if (byExtendedKey == 80) { - textures_off |= TEX_OFF_ADVANCED_CARS; - } + } + break; + case 4: + if (byExtendedKey >= 0x48u) { + if (byExtendedKey <= 0x48u) { + if (--damage_level < 0) + damage_level = 0; + } else if (byExtendedKey == 80 && ++damage_level > 2) { + damage_level = 2; } - break; - default: - continue; + } + break; + case 5: + if (byExtendedKey >= 0x48u) { + if (byExtendedKey <= 0x48u) { + textures_off &= ~TEX_OFF_ADVANCED_CARS; + } else if (byExtendedKey == 80) { + textures_off |= TEX_OFF_ADVANCED_CARS; + } + } + break; + default: + continue; } } - } else if (byInputKey <= 0x1Bu) // Escape key: Exit to main menu or back to option selection + } else if (byInputKey <= 0x1Bu) // Escape key: Exit to main menu or back + // to option selection { if (iMenuSelection) iMenuSelection = 0; else - LABEL_248: - iExitFlag = -1; - } else if (byInputKey < 0x59u) { // Space key: Cycle through cups (track groups) if not in championship + LABEL_248: + iExitFlag = -1; + } else if (byInputKey < 0x59u) { // Space key: Cycle through cups (track + // groups) if not in championship if (byInputKey == 32 && !iSkipColor) { iCupIncrement = ++iBlockIdx; if ((cup_won & 1) == 0 && iCupIncrement == 1) @@ -582,7 +701,9 @@ void select_type() while (broadcast_mode) UpdateSDL(); } - } else if (byInputKey <= 0x59u || byInputKey == 121) { // Y/y key: \"Yes\" - confirm championship exit and reset to race mode + } else if (byInputKey <= 0x59u || + byInputKey == 121) { // Y/y key: \"Yes\" - confirm championship + // exit and reset to race mode if (iSkipColor) { if (iMenuSelection == 6) { game_type = 0; @@ -610,13 +731,16 @@ void select_type() UpdateSDL(); } UpdateSDL(); - } while (!iExitFlag); // MAIN SELECTION LOOP - Handle UI rendering and input processing - if (!iSkipColor) // CLEANUP: Set final game parameters and track selection based on options + } while (!iExitFlag); // MAIN SELECTION LOOP - Handle UI rendering and input + // processing + if (!iSkipColor) // CLEANUP: Set final game parameters and track selection + // based on options { network_champ_on = 0; iTrackUpperLimit = 8 * iBlockIdx + 8; iTrackLowerLimit = 8 * iBlockIdx + 1; - if (game_type) // Initialize championship mode: reset all statistics and set starting track + if (game_type) // Initialize championship mode: reset all statistics and set + // starting track { if ((unsigned int)game_type <= 1) { Race = 0; diff --git a/PROJECTS/ROLLER/frontend_util.c b/PROJECTS/ROLLER/frontend_util.c index cf1815aa..5837fcac 100644 --- a/PROJECTS/ROLLER/frontend_util.c +++ b/PROJECTS/ROLLER/frontend_util.c @@ -25,27 +25,20 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -//00049C50 -void save_params() -{ - p_tex_size = gfx_size; -} +// 00049C50 +void save_params() { p_tex_size = gfx_size; } //------------------------------------------------------------------------------------------------- -//00049C60 -void reset_params() -{ - gfx_size = p_tex_size; -} +// 00049C60 +void reset_params() { gfx_size = p_tex_size; } //------------------------------------------------------------------------------------------------- -//0004A440 -void loadcheatnames() -{ +// 0004A440 +void loadcheatnames() { char buffer[0x400]; // Temporary buffer for file contents FILE *fp; int iSize; @@ -93,18 +86,17 @@ void loadcheatnames() } //------------------------------------------------------------------------------------------------- -//0004A5C0 -int CheckNames(char *szPlayerName, int iPlayerIdx) -{ +// 0004A5C0 +int CheckNames(char *szPlayerName, int iPlayerIdx) { int iCheatIdx = 0; // Decode cheat names list - decode((uint8*)cheat_names, 288, 43, 87); + decode((uint8 *)cheat_names, 288, 43, 87); // Skip processing if cheat list is empty if (cheat_names[0][0] == '#') { // Re-encode cheat names - decode((uint8*)cheat_names, 288, 43, 87); + decode((uint8 *)cheat_names, 288, 43, 87); return 0; } @@ -112,165 +104,165 @@ int CheckNames(char *szPlayerName, int iPlayerIdx) // Process all cheat names until terminator '#' while (*szCurrCheat != '#') { - // Check if player name matches current cheat name + // Check if player name matches current cheat name if (name_cmp(szPlayerName, szCurrCheat)) { // Handle cheats if (iCheatIdx <= 25) { switch (iCheatIdx) { - case 0: //SUICYCO (cheat car, explode opponent) - Players_Cars[iPlayerIdx] = CAR_DESIGN_SUICYCO; - name_copy(szPlayerName, "DAMIAN"); - cheat_mode |= CHEAT_MODE_CHEAT_CAR; - break; - case 1: //MAYTE (cheat car, top speed) - Players_Cars[iPlayerIdx] = CAR_DESIGN_MAYTE; - name_copy(szPlayerName, "DAMON"); - cheat_mode |= CHEAT_MODE_CHEAT_CAR; - break; - case 2: //2X4B523P (cheat car, flip opponent) - Players_Cars[iPlayerIdx] = CAR_DESIGN_2X4B523P; - name_copy(szPlayerName, "GRAHAM"); - cheat_mode |= CHEAT_MODE_CHEAT_CAR; - break; - case 3: //TINKLE (cheat car, jump opponent) - Players_Cars[iPlayerIdx] = CAR_DESIGN_TINKLE; - name_copy(szPlayerName, "KEV"); - cheat_mode |= CHEAT_MODE_CHEAT_CAR; - break; - case 4: //LOVEBUN (formula car) - Players_Cars[iPlayerIdx] = CAR_DESIGN_F1WACK; - name_copy(szPlayerName, "LISA"); - cheat_mode |= CHEAT_MODE_CHEAT_CAR; - break; - case 5: //DR DEATH (death mode) - name_copy(szPlayerName, "PAT"); - cheat_mode |= CHEAT_MODE_DEATH_MODE; - break; - case 6: //SUPERMAN (invincible human car) - name_copy(szPlayerName, "MARK"); - cheat_mode |= CHEAT_MODE_INVINCIBLE; - player_invul[iPlayerIdx] = -1; - break; - case 7: //REMOVE - name_copy(szPlayerName, "MR BRUSH"); - if (cheat_mode & CHEAT_MODE_CLONES) { - // Handle player cars and infinite laps - short nPlayer1Car = (short)player1_car; - if ((short)nPlayer1Car == iPlayerIdx) { - for (int i = 0; i < players; i++) { - infinite_laps = -1; - } - } else { - for (int i = 0; i < players; i++) { - if (i != (int)nPlayer1Car) { - Players_Cars[i] = -1; - } - } + case 0: // SUICYCO (cheat car, explode opponent) + Players_Cars[iPlayerIdx] = CAR_DESIGN_SUICYCO; + name_copy(szPlayerName, "DAMIAN"); + cheat_mode |= CHEAT_MODE_CHEAT_CAR; + break; + case 1: // MAYTE (cheat car, top speed) + Players_Cars[iPlayerIdx] = CAR_DESIGN_MAYTE; + name_copy(szPlayerName, "DAMON"); + cheat_mode |= CHEAT_MODE_CHEAT_CAR; + break; + case 2: // 2X4B523P (cheat car, flip opponent) + Players_Cars[iPlayerIdx] = CAR_DESIGN_2X4B523P; + name_copy(szPlayerName, "GRAHAM"); + cheat_mode |= CHEAT_MODE_CHEAT_CAR; + break; + case 3: // TINKLE (cheat car, jump opponent) + Players_Cars[iPlayerIdx] = CAR_DESIGN_TINKLE; + name_copy(szPlayerName, "KEV"); + cheat_mode |= CHEAT_MODE_CHEAT_CAR; + break; + case 4: // LOVEBUN (formula car) + Players_Cars[iPlayerIdx] = CAR_DESIGN_F1WACK; + name_copy(szPlayerName, "LISA"); + cheat_mode |= CHEAT_MODE_CHEAT_CAR; + break; + case 5: // DR DEATH (death mode) + name_copy(szPlayerName, "PAT"); + cheat_mode |= CHEAT_MODE_DEATH_MODE; + break; + case 6: // SUPERMAN (invincible human car) + name_copy(szPlayerName, "MARK"); + cheat_mode |= CHEAT_MODE_INVINCIBLE; + player_invul[iPlayerIdx] = -1; + break; + case 7: // REMOVE + name_copy(szPlayerName, "MR BRUSH"); + if (cheat_mode & CHEAT_MODE_CLONES) { + // Handle player cars and infinite laps + short nPlayer1Car = (short)player1_car; + if ((short)nPlayer1Car == iPlayerIdx) { + for (int i = 0; i < players; i++) { + infinite_laps = -1; } - switch_same = -1; - } - if (cheat_mode & CHEAT_MODE_50HZ_TIMER) { - release_ticktimer(); - claim_ticktimer(36); - } - cheat_mode = 0; - player_invul[iPlayerIdx] = 0; - CalcCarSizes(); - break; - case 8: //TOPTUNES (alternate voice) - name_copy(szPlayerName, "DJ SFX"); - cheat_samples = -1; - releasesamples(); - loadfatalsample(); - break; - case 9: //GOLDBOY (unlock premier cup) - name_copy(szPlayerName, "PHIL"); - cup_won |= 1; - textures_off |= TEX_OFF_PREMIER_CUP_AVAILABLE; - break; - case 10: //CUP WON (view end sequence) - name_copy(szPlayerName, "LAZY"); - cheat_mode |= CHEAT_MODE_END_SEQUENCE; - break; - case 11: //I WON (view race history) - name_copy(szPlayerName, "IDOL"); - cheat_mode |= CHEAT_MODE_RACE_HISTORY; - break; - case 12: //CINEMA (widescreen) - name_copy(szPlayerName, "LUMIERE"); - cheat_mode |= CHEAT_MODE_WIDESCREEN; - break; - case 13: //ROLL EM (view credits) - name_copy(szPlayerName, "MR CRED"); - cheat_mode |= CHEAT_MODE_CREDITS; - break; - case 14: //FORMULA1 (advanced car set) - name_copy(szPlayerName, "NEIL"); - cheat_mode |= CHEAT_MODE_ADVANCED_CARS; - break; - case 15: //MREPRISE (bonus cup unlocked) - name_copy(szPlayerName, "MR BONUS"); - textures_off |= TEX_OFF_BONUS_CUP_AVAILABLE; - cup_won |= 2; - break; - case 16: //DUEL (killer opponents) - name_copy(szPlayerName, "MR EVIL"); - cheat_mode |= CHEAT_MODE_KILLER_OPPONENTS; - break; - case 17: //PROCESS - { - float A, B; - memcpy(&A, (uint32_t[]) { 1249905654 }, 4); - memcpy(&B, (uint32_t[]) { 1245708284 }, 4); - float res_float = (float)((float)(A / B) * 3145727.0f); - uint32_t res_bits; - memcpy(&res_bits, &res_float, 4); - if (res_bits == 1249905654u) { - name_copy(szPlayerName, "TYPE B"); } else { - name_copy(szPlayerName, "TYPE A"); + for (int i = 0; i < players; i++) { + if (i != (int)nPlayer1Car) { + Players_Cars[i] = -1; + } + } } - break; + switch_same = -1; } - case 18: //MRFROSTY (icy roads) - name_copy(szPlayerName, "SNOWMAN"); - cheat_mode |= CHEAT_MODE_ICY_ROAD; - break; - case 19: //MR ZOOM (50Hz timer) - name_copy(szPlayerName, "SPEEDY"); - cheat_mode |= CHEAT_MODE_50HZ_TIMER; + if (cheat_mode & CHEAT_MODE_50HZ_TIMER) { release_ticktimer(); - claim_ticktimer(50); - break; - case 20: //TACHYONS (100Hz timer) - name_copy(szPlayerName, "NUCLEAR!"); - cheat_mode |= CHEAT_MODE_100HZ_TIMER | CHEAT_MODE_50HZ_TIMER; - release_ticktimer(); - claim_ticktimer(100); - break; - case 21: //YOTARACE (double track size) - name_copy(szPlayerName, "GULLIVER"); - cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; - break; - case 22: //CLONES - //removed? - //cheat_mode |= CHEAT_MODE_CLONES - break; - case 23: //TINYTOTS (tiny cars) - name_copy(szPlayerName, "TINYTIM"); - cheat_mode |= CHEAT_MODE_TINY_CARS; - CalcCarSizes(); - break; - case 24: //WARPGATE (warp) - name_copy(szPlayerName, "HEADACHE"); - cheat_mode |= CHEAT_MODE_WARP; - break; - case 25: //FREAKY (invert colors) - name_copy(szPlayerName, "PAINTER"); - cheat_mode |= CHEAT_MODE_FREAKY; - break; - default: - break; + claim_ticktimer(36); + } + cheat_mode = 0; + player_invul[iPlayerIdx] = 0; + CalcCarSizes(); + break; + case 8: // TOPTUNES (alternate voice) + name_copy(szPlayerName, "DJ SFX"); + cheat_samples = -1; + releasesamples(); + loadfatalsample(); + break; + case 9: // GOLDBOY (unlock premier cup) + name_copy(szPlayerName, "PHIL"); + cup_won |= 1; + textures_off |= TEX_OFF_PREMIER_CUP_AVAILABLE; + break; + case 10: // CUP WON (view end sequence) + name_copy(szPlayerName, "LAZY"); + cheat_mode |= CHEAT_MODE_END_SEQUENCE; + break; + case 11: // I WON (view race history) + name_copy(szPlayerName, "IDOL"); + cheat_mode |= CHEAT_MODE_RACE_HISTORY; + break; + case 12: // CINEMA (widescreen) + name_copy(szPlayerName, "LUMIERE"); + cheat_mode |= CHEAT_MODE_WIDESCREEN; + break; + case 13: // ROLL EM (view credits) + name_copy(szPlayerName, "MR CRED"); + cheat_mode |= CHEAT_MODE_CREDITS; + break; + case 14: // FORMULA1 (advanced car set) + name_copy(szPlayerName, "NEIL"); + cheat_mode |= CHEAT_MODE_ADVANCED_CARS; + break; + case 15: // MREPRISE (bonus cup unlocked) + name_copy(szPlayerName, "MR BONUS"); + textures_off |= TEX_OFF_BONUS_CUP_AVAILABLE; + cup_won |= 2; + break; + case 16: // DUEL (killer opponents) + name_copy(szPlayerName, "MR EVIL"); + cheat_mode |= CHEAT_MODE_KILLER_OPPONENTS; + break; + case 17: // PROCESS + { + float A, B; + memcpy(&A, (uint32_t[]){1249905654}, 4); + memcpy(&B, (uint32_t[]){1245708284}, 4); + float res_float = (float)((float)(A / B) * 3145727.0f); + uint32_t res_bits; + memcpy(&res_bits, &res_float, 4); + if (res_bits == 1249905654u) { + name_copy(szPlayerName, "TYPE B"); + } else { + name_copy(szPlayerName, "TYPE A"); + } + break; + } + case 18: // MRFROSTY (icy roads) + name_copy(szPlayerName, "SNOWMAN"); + cheat_mode |= CHEAT_MODE_ICY_ROAD; + break; + case 19: // MR ZOOM (50Hz timer) + name_copy(szPlayerName, "SPEEDY"); + cheat_mode |= CHEAT_MODE_50HZ_TIMER; + release_ticktimer(); + claim_ticktimer(50); + break; + case 20: // TACHYONS (100Hz timer) + name_copy(szPlayerName, "NUCLEAR!"); + cheat_mode |= CHEAT_MODE_100HZ_TIMER | CHEAT_MODE_50HZ_TIMER; + release_ticktimer(); + claim_ticktimer(100); + break; + case 21: // YOTARACE (double track size) + name_copy(szPlayerName, "GULLIVER"); + cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; + break; + case 22: // CLONES + // removed? + // cheat_mode |= CHEAT_MODE_CLONES + break; + case 23: // TINYTOTS (tiny cars) + name_copy(szPlayerName, "TINYTIM"); + cheat_mode |= CHEAT_MODE_TINY_CARS; + CalcCarSizes(); + break; + case 24: // WARPGATE (warp) + name_copy(szPlayerName, "HEADACHE"); + cheat_mode |= CHEAT_MODE_WARP; + break; + case 25: // FREAKY (invert colors) + name_copy(szPlayerName, "PAINTER"); + cheat_mode |= CHEAT_MODE_FREAKY; + break; + default: + break; } } } @@ -282,7 +274,7 @@ int CheckNames(char *szPlayerName, int iPlayerIdx) } break; } - //cheats added by ROLLER + // cheats added by ROLLER else if (name_cmp(szPlayerName, "CHRSTINE")) { Players_Cars[iPlayerIdx] = CAR_DESIGN_DEATH; name_copy(szPlayerName, "MR EVIL"); @@ -295,7 +287,7 @@ int CheckNames(char *szPlayerName, int iPlayerIdx) iCheatIdx++; } // Re-encode cheat names - decode((uint8*)cheat_names, 288, 43, 87); + decode((uint8 *)cheat_names, 288, 43, 87); return 0; } diff --git a/PROJECTS/ROLLER/func2.c b/PROJECTS/ROLLER/func2.c index 515b92da..b7340ab3 100644 --- a/PROJECTS/ROLLER/func2.c +++ b/PROJECTS/ROLLER/func2.c @@ -30,7 +30,7 @@ #define getcwd _getcwd #else #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- @@ -137,378 +137,352 @@ char szMph[4] = "mph"; //------------------------------------------------------------------------------------------------- -int dam_remap[256] = //000A35E4 -{ - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, 8, 7, 6, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 5, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 13, 12, 11, 10, 9, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 4, 3, 2, 1 +int dam_remap[256] = // 000A35E4 + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 7, + 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, + 12, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 4, 3, 2, 1}; +int write_key = 0; // 000A39E4 +int read_key = 0; // 000A39E8 +int zoom_ascii_variable_1 = 0; // 000A3AEC no symbols for these? +int zoom_ascii_variable_2 = 0; // 000A3AF0 no symbols for these? +int zoom_ascii_variable_3 = 0; // 000A3AF4 no symbols for these? +uint8 mapping[] = // 000A3AF8 + {0x7F, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, + 0x2D, 0x3D, 0x08, 0x09, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, + 0x4F, 0x50, 0x5B, 0x5D, 0x0D, 0x7F, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, + 0x4A, 0x4B, 0x4C, 0x3B, 0x27, 0x60, 0x7F, 0x23, 0x5A, 0x58, 0x43, 0x56, + 0x42, 0x4E, 0x4D, 0x2C, 0x2E, 0x2F, 0x7F, 0x7F, 0x7F, 0x20, 0x7F, 0xC5, + 0xC4, 0xC3, 0xC2, 0xC1, 0xC0, 0xBF, 0xBE, 0xBD, 0xBC, 0x7F, 0x7F, 0xB9, + 0xB8, 0xB7, 0x2D, 0xB5, 0x7F, 0xB3, 0x7F, 0xB1, 0xB0, 0xAF, 0xAE, 0xAD, + 0x7F, 0x7F, 0x5C, 0xBB, 0xBA, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, + 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F}; +int twoparter = 0; // 000A3B78 +int font6_offsets[88] = // 000A3B7C + {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, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, -2, + -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, 0, -3, -1, + -3, -3, -3, -3, -3, 0, 0, -3, -3, -3, -3, 0, 0, 0, 0, 0}; +char font6_ascii[256] = // 000A3CDC + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x31, + 0xFF, 0x53, 0xFF, 0x30, 0xFF, 0xFF, 0x2B, 0x2D, 0x27, 0x2C, 0x26, 0x28, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x2F, 0xFF, + 0xFF, 0x24, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x29, 0x25, 0x2A, 0xFF, 0x32, + 0x2E, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4D, 0xFF, 0xFF, 0x37, + 0x38, 0x36, 0x39, 0xFF, 0x3E, 0x3F, 0x3D, 0x43, 0x42, 0x40, 0x38, 0x3A, + 0x3C, 0x3B, 0x3B, 0x50, 0x51, 0x4F, 0x49, 0x48, 0x34, 0x52, 0x4A, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x35, 0x41, 0x4E, 0x47, 0x45, 0x45, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x33, 0xFF, 0x44, 0x4B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4C, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x46, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; +char ascii_conv3[256] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0xFF, 0xFF, + 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, + 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0x27, + 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x25, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; +char *keyname[140] = { + // 000A3EDC + NULL, /* 0x00 */ + NULL, /* 0x01 */ + szKey1, /* 0x02 */ + szKey2, /* 0x03 */ + szKey3, /* 0x04 */ + szKey4, /* 0x05 */ + szKey5, /* 0x06 */ + szKey6, /* 0x07 */ + szKey7, /* 0x08 */ + szKey8, /* 0x09 */ + szKey9, /* 0x0A */ + szKey0, /* 0x0B */ + szKeyMinus, /* 0x0C */ + szKeyPlus, /* 0x0D */ + szKeyBackspace, /* 0x0E */ + szKeyTab, /* 0x0F */ + szKeyQ, /* 0x10 */ + szKeyW, /* 0x11 */ + szKeyE, /* 0x12 */ + szKeyR, /* 0x13 */ + szKeyT, /* 0x14 */ + szKeyY, /* 0x15 */ + szKeyU, /* 0x16 */ + szKeyI, /* 0x17 */ + szKeyO, /* 0x18 */ + szKeyP, /* 0x19 */ + szKeyLeftBracket, /* 0x1A */ + szKeyRightBracket, /* 0x1B */ + szKeyEnter, /* 0x1C */ + szKeyControl, /* 0x1D */ + szKeyA, /* 0x1E */ + szKeyS, /* 0x1F */ + szKeyD, /* 0x20 */ + szKeyF, /* 0x21 */ + szKeyG, /* 0x22 */ + szKeyH, /* 0x23 */ + szKeyJ, /* 0x24 */ + szKeyK, /* 0x25 */ + szKeyL, /* 0x26 */ + szKeySemicolon, /* 0x27 */ + szKeyQuote, /* 0x28 */ + szKeyTilde, /* 0x29 */ + szKeyLeftShift, /* 0x2A */ + szKeyBackslash, /* 0x2B */ + szKeyZ, /* 0x2C */ + szKeyX, /* 0x2D */ + szKeyC, /* 0x2E */ + szKeyV, /* 0x2F */ + szKeyB, /* 0x30 */ + szKeyN, /* 0x31 */ + szKeyM, /* 0x32 */ + szKeyComma, /* 0x33 */ + szKeyPeriod, /* 0x34 */ + szKeySlash, /* 0x35 */ + szKeyRightShift, /* 0x36 */ + szKeyNumMult, /* 0x37 */ + szKeyAlt, /* 0x38 */ + szKeySpace, /* 0x39 */ + szKeyCapsLock, /* 0x3A */ + szKeyF1, /* 0x3B */ + szKeyF2, /* 0x3C */ + szKeyF3, /* 0x3D */ + szKeyF4, /* 0x3E */ + szKeyF5, /* 0x3F */ + szKeyF6, /* 0x40 */ + szKeyF7, /* 0x41 */ + szKeyF8, /* 0x42 */ + szKeyF9, /* 0x43 */ + szKeyF10, /* 0x44 */ + szKeyNumLock, /* 0x45 */ + szKeyScrollLock, /* 0x46 */ + szKeyHome, /* 0x47 */ + szKeyUpArrow, /* 0x48 */ + szKeyPageUp, /* 0x49 */ + szKeyNumMinus, /* 0x4A */ + szKeyLeftArrow, /* 0x4B */ + szKeyCenter, /* 0x4C */ + szKeyRightArrow, /* 0x4D */ + szKeyNumPlus, /* 0x4E */ + szKeyEnd, /* 0x4F */ + szKeyDownArrow, /* 0x50 */ + szKeyPageDown, /* 0x51 */ + szKeyInsert, /* 0x52 */ + szKeyDelete, /* 0x53 */ + NULL, /* 0x54 */ + NULL, /* 0x55 */ + NULL, /* 0x56 */ + szKeyF11, /* 0x57 */ + szKeyF12, /* 0x58 */ + NULL, /* 0x59 */ + NULL, /* 0x5A */ + NULL, /* 0x5B */ + NULL, /* 0x5C */ + NULL, /* 0x5D */ + NULL, /* 0x5E */ + NULL, /* 0x5F */ + NULL, /* 0x60 */ + NULL, /* 0x61 */ + NULL, /* 0x62 */ + NULL, /* 0x63 */ + NULL, /* 0x64 */ + NULL, /* 0x65 */ + NULL, /* 0x66 */ + NULL, /* 0x67 */ + NULL, /* 0x68 */ + NULL, /* 0x69 */ + NULL, /* 0x6A */ + NULL, /* 0x6B */ + NULL, /* 0x6C */ + NULL, /* 0x6D */ + NULL, /* 0x6E */ + NULL, /* 0x6F */ + NULL, /* 0x70 */ + NULL, /* 0x71 */ + NULL, /* 0x72 */ + NULL, /* 0x73 */ + NULL, /* 0x74 */ + NULL, /* 0x75 */ + NULL, /* 0x76 */ + NULL, /* 0x77 */ + NULL, /* 0x78 */ + NULL, /* 0x79 */ + NULL, /* 0x7A */ + NULL, /* 0x7B */ + NULL, /* 0x7C */ + NULL, /* 0x7D */ + NULL, /* 0x7E */ + NULL, /* 0x7F */ + szKeyJoy1Fire1, /* 0x80 */ + szKeyJoy1Fire2, /* 0x81 */ + szKeyJoy2Fire1, /* 0x82 */ + szKeyJoy2Fire2, /* 0x83 */ + szKeyJoy1Up, /* 0x84 */ + szKeyJoy1Down, /* 0x85 */ + szKeyJoy1Left, /* 0x86 */ + szKeyJoy1Right, /* 0x87 */ + szKeyJoy2Up, /* 0x88 */ + szKeyJoy2Down, /* 0x89 */ + szKeyJoy2Left, /* 0x8A */ + szKeyJoy2Right /* 0x8B */ }; -int write_key = 0; //000A39E4 -int read_key = 0; //000A39E8 -int zoom_ascii_variable_1 = 0; //000A3AEC no symbols for these? -int zoom_ascii_variable_2 = 0; //000A3AF0 no symbols for these? -int zoom_ascii_variable_3 = 0; //000A3AF4 no symbols for these? -uint8 mapping[] = //000A3AF8 -{ - 0x7F, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x30, 0x2D, 0x3D, 0x08, 0x09, 0x51, 0x57, 0x45, 0x52, - 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x5B, 0x5D, 0x0D, 0x7F, - 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3B, - 0x27, 0x60, 0x7F, 0x23, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, - 0x4D, 0x2C, 0x2E, 0x2F, 0x7F, 0x7F, 0x7F, 0x20, 0x7F, 0xC5, - 0xC4, 0xC3, 0xC2, 0xC1, 0xC0, 0xBF, 0xBE, 0xBD, 0xBC, 0x7F, - 0x7F, 0xB9, 0xB8, 0xB7, 0x2D, 0xB5, 0x7F, 0xB3, 0x7F, 0xB1, - 0xB0, 0xAF, 0xAE, 0xAD, 0x7F, 0x7F, 0x5C, 0xBB, 0xBA, 0x7F, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, - 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F -}; -int twoparter = 0; //000A3B78 -int font6_offsets[88] = //000A3B7C -{ - 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, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -3, -2, -3, -3, - -3, -3, -3, -3, -3, -3, -3, -3, - -3, -3, -3, -3, -3, 0, -3, -1, - -3, -3, -3, -3, -3, 0, 0, -3, - -3, -3, -3, 0, 0, 0, 0, 0 -}; -char font6_ascii[256] = //000A3CDC -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x31, 0xFF, 0x53, 0xFF, 0x30, - 0xFF, 0xFF, 0x2B, 0x2D, 0x27, 0x2C, 0x26, 0x28, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x2F, 0xFF, - 0xFF, 0x24, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0x29, 0x25, 0x2A, 0xFF, 0x32, 0x2E, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4D, 0xFF, - 0xFF, 0x37, 0x38, 0x36, 0x39, 0xFF, 0x3E, 0x3F, 0x3D, 0x43, - 0x42, 0x40, 0x38, 0x3A, 0x3C, 0x3B, 0x3B, 0x50, 0x51, 0x4F, - 0x49, 0x48, 0x34, 0x52, 0x4A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x35, 0x41, 0x4E, 0x47, 0x45, 0x45, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0x33, 0xFF, 0x44, 0x4B, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4C, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x46, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -char ascii_conv3[256] = -{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x26, 0xFF, 0xFF, 0x1A, 0x1B, - 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, - 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0x27, 0xFF, 0x00, 0x01, 0x02, - 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x25, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -char *keyname[140] = { //000A3EDC - NULL, /* 0x00 */ - NULL, /* 0x01 */ - szKey1, /* 0x02 */ - szKey2, /* 0x03 */ - szKey3, /* 0x04 */ - szKey4, /* 0x05 */ - szKey5, /* 0x06 */ - szKey6, /* 0x07 */ - szKey7, /* 0x08 */ - szKey8, /* 0x09 */ - szKey9, /* 0x0A */ - szKey0, /* 0x0B */ - szKeyMinus, /* 0x0C */ - szKeyPlus, /* 0x0D */ - szKeyBackspace, /* 0x0E */ - szKeyTab, /* 0x0F */ - szKeyQ, /* 0x10 */ - szKeyW, /* 0x11 */ - szKeyE, /* 0x12 */ - szKeyR, /* 0x13 */ - szKeyT, /* 0x14 */ - szKeyY, /* 0x15 */ - szKeyU, /* 0x16 */ - szKeyI, /* 0x17 */ - szKeyO, /* 0x18 */ - szKeyP, /* 0x19 */ - szKeyLeftBracket, /* 0x1A */ - szKeyRightBracket, /* 0x1B */ - szKeyEnter, /* 0x1C */ - szKeyControl, /* 0x1D */ - szKeyA, /* 0x1E */ - szKeyS, /* 0x1F */ - szKeyD, /* 0x20 */ - szKeyF, /* 0x21 */ - szKeyG, /* 0x22 */ - szKeyH, /* 0x23 */ - szKeyJ, /* 0x24 */ - szKeyK, /* 0x25 */ - szKeyL, /* 0x26 */ - szKeySemicolon, /* 0x27 */ - szKeyQuote, /* 0x28 */ - szKeyTilde, /* 0x29 */ - szKeyLeftShift, /* 0x2A */ - szKeyBackslash, /* 0x2B */ - szKeyZ, /* 0x2C */ - szKeyX, /* 0x2D */ - szKeyC, /* 0x2E */ - szKeyV, /* 0x2F */ - szKeyB, /* 0x30 */ - szKeyN, /* 0x31 */ - szKeyM, /* 0x32 */ - szKeyComma, /* 0x33 */ - szKeyPeriod, /* 0x34 */ - szKeySlash, /* 0x35 */ - szKeyRightShift, /* 0x36 */ - szKeyNumMult, /* 0x37 */ - szKeyAlt, /* 0x38 */ - szKeySpace, /* 0x39 */ - szKeyCapsLock, /* 0x3A */ - szKeyF1, /* 0x3B */ - szKeyF2, /* 0x3C */ - szKeyF3, /* 0x3D */ - szKeyF4, /* 0x3E */ - szKeyF5, /* 0x3F */ - szKeyF6, /* 0x40 */ - szKeyF7, /* 0x41 */ - szKeyF8, /* 0x42 */ - szKeyF9, /* 0x43 */ - szKeyF10, /* 0x44 */ - szKeyNumLock, /* 0x45 */ - szKeyScrollLock, /* 0x46 */ - szKeyHome, /* 0x47 */ - szKeyUpArrow, /* 0x48 */ - szKeyPageUp, /* 0x49 */ - szKeyNumMinus, /* 0x4A */ - szKeyLeftArrow, /* 0x4B */ - szKeyCenter, /* 0x4C */ - szKeyRightArrow, /* 0x4D */ - szKeyNumPlus, /* 0x4E */ - szKeyEnd, /* 0x4F */ - szKeyDownArrow, /* 0x50 */ - szKeyPageDown, /* 0x51 */ - szKeyInsert, /* 0x52 */ - szKeyDelete, /* 0x53 */ - NULL, /* 0x54 */ - NULL, /* 0x55 */ - NULL, /* 0x56 */ - szKeyF11, /* 0x57 */ - szKeyF12, /* 0x58 */ - NULL, /* 0x59 */ - NULL, /* 0x5A */ - NULL, /* 0x5B */ - NULL, /* 0x5C */ - NULL, /* 0x5D */ - NULL, /* 0x5E */ - NULL, /* 0x5F */ - NULL, /* 0x60 */ - NULL, /* 0x61 */ - NULL, /* 0x62 */ - NULL, /* 0x63 */ - NULL, /* 0x64 */ - NULL, /* 0x65 */ - NULL, /* 0x66 */ - NULL, /* 0x67 */ - NULL, /* 0x68 */ - NULL, /* 0x69 */ - NULL, /* 0x6A */ - NULL, /* 0x6B */ - NULL, /* 0x6C */ - NULL, /* 0x6D */ - NULL, /* 0x6E */ - NULL, /* 0x6F */ - NULL, /* 0x70 */ - NULL, /* 0x71 */ - NULL, /* 0x72 */ - NULL, /* 0x73 */ - NULL, /* 0x74 */ - NULL, /* 0x75 */ - NULL, /* 0x76 */ - NULL, /* 0x77 */ - NULL, /* 0x78 */ - NULL, /* 0x79 */ - NULL, /* 0x7A */ - NULL, /* 0x7B */ - NULL, /* 0x7C */ - NULL, /* 0x7D */ - NULL, /* 0x7E */ - NULL, /* 0x7F */ - szKeyJoy1Fire1, /* 0x80 */ - szKeyJoy1Fire2, /* 0x81 */ - szKeyJoy2Fire1, /* 0x82 */ - szKeyJoy2Fire2, /* 0x83 */ - szKeyJoy1Up, /* 0x84 */ - szKeyJoy1Down, /* 0x85 */ - szKeyJoy1Left, /* 0x86 */ - szKeyJoy1Right, /* 0x87 */ - szKeyJoy2Up, /* 0x88 */ - szKeyJoy2Down, /* 0x89 */ - szKeyJoy2Left, /* 0x8A */ - szKeyJoy2Right /* 0x8B */ -}; -int userkey[14] = {44u, 45u, 20u, 33u, 19u, 32u, 79u, 80u, 73u, 77u, 72u, 76u, 21u, 79u}; //000A410C -uint8 key_buffer[64]; //0013FB90 -int new_zoom[2]; //0013FBD0 -char config_buffer[8192]; //0013FBD8 -char language_buffer[8192]; //00141BD8 -int zoom_x; //00143BD8 -int zoom_y; //00143BDC -int no_mem; //00143BE0 -uint8 *screen_pointer; //00143BE4 -int lots_of_mem; //00143BE8 +int userkey[14] = {44u, 45u, 20u, 33u, 19u, 32u, 79u, + 80u, 73u, 77u, 72u, 76u, 21u, 79u}; // 000A410C +uint8 key_buffer[64]; // 0013FB90 +int new_zoom[2]; // 0013FBD0 +char config_buffer[8192]; // 0013FBD8 +char language_buffer[8192]; // 00141BD8 +int zoom_x; // 00143BD8 +int zoom_y; // 00143BDC +int no_mem; // 00143BE0 +uint8 *screen_pointer; // 00143BE4 +int lots_of_mem; // 00143BE8 //------------------------------------------------------------------------------------------------- -//00015E60 -void draw_smoke(uint8 *pScrBuf, int iPlayerCarIdx) -{ - bool bIsPlayer2; // ebx - int iSelectedView; // ecx - int iScreenOffsetY; // ebp - tCarSpray *pCarSpray; // esi - double dPosX; // st7 - double dPosY; // st7 - double dCalcX; // st7 - double dCalcY; // st7 - double dSize; // st7 - int iSize; // ecx - int iColor; // eax - double dPosX2; // st7 - double dPosY2; // st7 - double dSize2; // st7 - int iSize2; // ebx - int iScreenY; // edx - int uiColor2; // eax - int iScreenY1; // [esp+0h] [ebp-34h] - int iScreenX2; // [esp+0h] [ebp-34h] - int iScreenX1; // [esp+4h] [ebp-30h] - int iScreenY2; // [esp+4h] [ebp-30h] +// 00015E60 +void draw_smoke(uint8 *pScrBuf, int iPlayerCarIdx) { + bool bIsPlayer2; // ebx + int iSelectedView; // ecx + int iScreenOffsetY; // ebp + tCarSpray *pCarSpray; // esi + double dPosX; // st7 + double dPosY; // st7 + double dCalcX; // st7 + double dCalcY; // st7 + double dSize; // st7 + int iSize; // ecx + int iColor; // eax + double dPosX2; // st7 + double dPosY2; // st7 + double dSize2; // st7 + int iSize2; // ebx + int iScreenY; // edx + int uiColor2; // eax + int iScreenY1; // [esp+0h] [ebp-34h] + int iScreenX2; // [esp+0h] [ebp-34h] + int iScreenX1; // [esp+4h] [ebp-30h] + int iScreenY2; // [esp+4h] [ebp-30h] tCarSpray *pNextCarSpray; // [esp+8h] [ebp-2Ch] - int iPosX; // [esp+10h] [ebp-24h] - int iPosY; // [esp+14h] [ebp-20h] - int iAdjustedScreenY; // [esp+14h] [ebp-20h] - int iSize3; // [esp+1Ch] [ebp-18h] - - bIsPlayer2 = iPlayerCarIdx != ViewType[0]; // Check if this is player 2 (not player 1) - iSelectedView = SelectedView[bIsPlayer2]; // Get the selected view mode for this player - if (!iSelectedView || iSelectedView == 2 || iSelectedView == 7)// Only render smoke in cockpit (0), in-car (2), or behind-car (7) views + int iPosX; // [esp+10h] [ebp-24h] + int iPosY; // [esp+14h] [ebp-20h] + int iAdjustedScreenY; // [esp+14h] [ebp-20h] + int iSize3; // [esp+1Ch] [ebp-18h] + + bIsPlayer2 = + iPlayerCarIdx != ViewType[0]; // Check if this is player 2 (not player 1) + iSelectedView = + SelectedView[bIsPlayer2]; // Get the selected view mode for this player + if (!iSelectedView || iSelectedView == 2 || + iSelectedView == 7) // Only render smoke in cockpit (0), in-car (2), or + // behind-car (7) views { set_starts(0); - if (player_type == 2) // Two player mode - adjust car index for player 2 + if (player_type == 2) // Two player mode - adjust car index for player 2 { iPlayerCarIdx = bIsPlayer2 + 16; - } else if ((cheat_mode & 0x40) == 0) // CHEAT_MODE_WIDESCREEN + } else if ((cheat_mode & 0x40) == 0) // CHEAT_MODE_WIDESCREEN { iScreenOffsetY = 0; goto RENDER_PARTICLES; } - iScreenOffsetY = -winh / 2; // Widescreen mode - offset Y by half screen height + iScreenOffsetY = + -winh / 2; // Widescreen mode - offset Y by half screen height RENDER_PARTICLES: - pCarSpray = CarSpray[iPlayerCarIdx]; // Get pointer to this car's spray particle array - pNextCarSpray = pCarSpray + 32; // Set end pointer for 32 spray particles per car - while (1) { // Check if particle is alive (lifetime > 0) - if (pCarSpray->iLifeTime > 0) { // Particle type 1 = smoke trail + pCarSpray = CarSpray[iPlayerCarIdx]; // Get pointer to this car's spray + // particle array + pNextCarSpray = + pCarSpray + 32; // Set end pointer for 32 spray particles per car + while (1) { // Check if particle is alive (lifetime > 0) + if (pCarSpray->iLifeTime > 0) { // Particle type 1 = smoke trail if ((uint8)pCarSpray->iType == 1) { - dPosX = pCarSpray->position.fX; // Get particle X position + dPosX = pCarSpray->position.fX; // Get particle X position //_CHP(); iPosX = (int)dPosX; - dPosY = pCarSpray->position.fY; // Get particle Y position + dPosY = pCarSpray->position.fY; // Get particle Y position //_CHP(); iPosY = (int)dPosY; - dCalcX = (double)iPosX + pCarSpray->velocity.fX;// Calculate screen X with velocity offset + dCalcX = + (double)iPosX + + pCarSpray->velocity.fX; // Calculate screen X with velocity offset //_CHP(); iScreenX1 = (int)dCalcX; - dCalcY = (double)iPosY - pCarSpray->velocity.fY;// Calculate screen Y with velocity offset (subtract for screen coords) + dCalcY = + (double)iPosY - + pCarSpray->velocity.fY; // Calculate screen Y with velocity offset + // (subtract for screen coords) //_CHP(); iScreenY1 = (int)dCalcY; - dSize = pCarSpray->fSize; // Get particle size for polygon rendering + dSize = pCarSpray->fSize; // Get particle size for polygon rendering //_CHP(); iAdjustedScreenY = iScreenOffsetY + iPosY; iSize = (int)dSize; if ((int)dSize <= 0 || iSize >= 100) - goto NEXT_PARTICLE; // Skip if size invalid (too small or too large) - CarPol.vertices[1].x = iScreenX1 - iSize;// Set up polygon vertices for square smoke particle + goto NEXT_PARTICLE; // Skip if size invalid (too small or too large) + CarPol.vertices[1].x = + iScreenX1 - + iSize; // Set up polygon vertices for square smoke particle CarPol.vertices[2].x = iPosX - iSize; CarPol.vertices[2].y = iAdjustedScreenY; CarPol.vertices[3].x = iSize + iPosX; CarPol.vertices[0].y = iScreenOffsetY + iScreenY1; CarPol.vertices[3].y = iAdjustedScreenY; - iColor = pCarSpray->iColor; // Get particle color/surface type + iColor = pCarSpray->iColor; // Get particle color/surface type CarPol.vertices[1].y = iScreenOffsetY + iScreenY1; iColor |= SURFACE_FLAG_FLIP_BACKFACE; - //BYTE1(iColor) |= 0x20u; // SURFACE_FLAG_FLIP_BACKFACE + // BYTE1(iColor) |= 0x20u; // SURFACE_FLAG_FLIP_BACKFACE CarPol.vertices[0].x = iSize + iScreenX1; CarPol.iSurfaceType = iColor; CarPol.uiNumVerts = 4; - if ((iColor & 0x100) == 0) // SURFACE_FLAG_APPLY_TEXTURE + if ((iColor & 0x100) == 0) // SURFACE_FLAG_APPLY_TEXTURE { RENDER_POLYFLAT: - game_render_quad_screen(g_pGameRenderer, &CarPol, TEXTURE_HANDLE_INVALID, NULL); // Render flat (untextured) polygon + game_render_quad_screen(g_pGameRenderer, &CarPol, + TEXTURE_HANDLE_INVALID, + NULL); // Render flat (untextured) polygon goto NEXT_PARTICLE; } } else { - dPosX2 = pCarSpray->position.fX; // Particle type 2 = firework particle + dPosX2 = + pCarSpray->position.fX; // Particle type 2 = firework particle //_CHP(); iScreenX2 = (int)dPosX2; dPosY2 = pCarSpray->position.fY; @@ -521,7 +495,9 @@ void draw_smoke(uint8 *pScrBuf, int iPlayerCarIdx) iScreenY = iScreenOffsetY + iScreenY2; if ((int)dSize2 <= 0 || iSize2 >= 100) goto NEXT_PARTICLE; - CarPol.vertices[0].x = iScreenX2 + iSize2;// Set up square polygon vertices for firework particle + CarPol.vertices[0].x = + iScreenX2 + + iSize2; // Set up square polygon vertices for firework particle CarPol.vertices[1].x = iScreenX2 - iSize3; CarPol.vertices[2].x = iScreenX2 - iSize3; CarPol.vertices[2].y = iSize3 + iScreenY; @@ -532,15 +508,19 @@ void draw_smoke(uint8 *pScrBuf, int iPlayerCarIdx) CarPol.iSurfaceType = uiColor2; CarPol.vertices[1].y = iScreenY - iSize3; CarPol.uiNumVerts = 4; - if ((uiColor2 & 0x100) == 0) // SURFACE_FLAG_APPLY_TEXTURE - goto RENDER_POLYFLAT; // Check texture flag - 0x100 bit indicates textured polygon + if ((uiColor2 & 0x100) == 0) // SURFACE_FLAG_APPLY_TEXTURE + goto RENDER_POLYFLAT; // Check texture flag - 0x100 bit indicates + // textured polygon } - game_render_quad_screen(g_pGameRenderer, &CarPol, game_render_get_texture_handle(g_pGameRenderer, 18), NULL); // Render textured polygon using car texture + game_render_quad_screen( + g_pGameRenderer, &CarPol, + game_render_get_texture_handle(g_pGameRenderer, 18), + NULL); // Render textured polygon using car texture } NEXT_PARTICLE: - if (++pCarSpray == pNextCarSpray) // Move to next spray particle + if (++pCarSpray == pNextCarSpray) // Move to next spray particle { - set_starts(0); // Processed all 32 particles for this car + set_starts(0); // Processed all 32 particles for this car return; } } @@ -548,157 +528,162 @@ void draw_smoke(uint8 *pScrBuf, int iPlayerCarIdx) } //------------------------------------------------------------------------------------------------- -//00016120 -void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) -{ - int iCarIndex; // ecx - uint8 byCarDesignIdx; // dl - int iAmmoBarIdx; // ebp - uint8 *byAmmoBarPtr; // esi - int iAmmoBarRowIdx; // edi - uint8 *byAmmoBarRowPtr; // esi - int iWinWidth; // eax - char *szSpeedUnit; // edx - int8 byGearAyMax; // dh - uint8 *byRPMBarPtr; // ecx - double dRPMRatio; // st7 - int i; // esi - int iRPMBarIdx; // edx - uint8 *byRPMBarFillPtr; // eax - unsigned int uiRPMBarWidth; // ebx - uint8 *byDamageBarPtr; // ecx - double dDamage; // st7 - int j; // esi - int iDamageBarIdx; // edx - uint8 *byDamageBarFillPtr; // eax +// 00016120 +void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) { + int iCarIndex; // ecx + uint8 byCarDesignIdx; // dl + int iAmmoBarIdx; // ebp + uint8 *byAmmoBarPtr; // esi + int iAmmoBarRowIdx; // edi + uint8 *byAmmoBarRowPtr; // esi + int iWinWidth; // eax + char *szSpeedUnit; // edx + int8 byGearAyMax; // dh + uint8 *byRPMBarPtr; // ecx + double dRPMRatio; // st7 + int i; // esi + int iRPMBarIdx; // edx + uint8 *byRPMBarFillPtr; // eax + unsigned int uiRPMBarWidth; // ebx + uint8 *byDamageBarPtr; // ecx + double dDamage; // st7 + int j; // esi + int iDamageBarIdx; // edx + uint8 *byDamageBarFillPtr; // eax unsigned int uiDamageBarWidth; // ebx - int byLap; // eax - int iLapNumber; // edi - int iLapTimeYPos; // esi - int iTrialTimeIdx; // ebp - double dLapTime; // st7 - //int64 llLapTimeInt; // rtt + int byLap; // eax + int iLapNumber; // edi + int iLapTimeYPos; // esi + int iTrialTimeIdx; // ebp + double dLapTime; // st7 + // int64 llLapTimeInt; // rtt double dRunningLapTime; // st7 - //int64 llRunningLapTimeInt; // rtt - int iMainCarIdx; // ecx - int iAmmoBarIdx2; // ebp - uint8 *byAmmoBarPtr2; // esi - uint8 *byAmmoBarRowPtr2; // esi - int iAmmoBarRowIdx2; // edi - int iWinWidth2; // eax - long double dSpeedometer; // st7 - int iSpeedDisplayValue; // ebx - int iSpeedDigitIdx; // esi - int iDigitArrayIdx; // ecx - int iLastDigitIdx; // esi - tBlockHeader *pBlockHdr; // eax - int iScaledSize; // esi - int iWidth; // ebp - uint8 *byDigitPixelPtr; // edi - uint8 *bySpriteDataPtr; // edx - int iPixelXOffset; // eax - int iPixelXIdx; // ebx - int iSpeedUnitBlkIdx; // ebx - tBlockHeader *pLifeIconBlockHdr; // esi - int iLifeIconIdx; // edi - int iLifeIconYPos; // ebp - int iKillsDisplayValue; // ecx - tBlockHeader *pKillBlockHdr; // edx - int iKillIconIdx; // ebx - tBlockHeader *pPositionBlockHdr; // edi - int iRacePosition; // ecx - int iKillIconLoopIdx; // esi - int iCarIdxForKills; // ebp - uint8 *byKillIconPtr; // eax - int byKills; // ecx - uint8 *byKillsScreenPtr; // ebp - tBlockHeader *pKillsDigitBlockHdr; // edi - int iGearCarIdx; // edi - uint8 *byGearScreenPtr; // ebp - tBlockHeader *pLapBlockHdr; // esi - int iCurrentLap; // ecx - tBlockHeader *pLapDigitBlockHdr; // ebp - int iLapDigitWidth; // edx - int iLapXOffset; // eax - uint8 *byLapDisplayPtr; // edi - int iLapDigitIdx; // ebx - uint8 *byRaceScreenPtr; // esi - int iTimingCarIdx; // ebp + // int64 llRunningLapTimeInt; // rtt + int iMainCarIdx; // ecx + int iAmmoBarIdx2; // ebp + uint8 *byAmmoBarPtr2; // esi + uint8 *byAmmoBarRowPtr2; // esi + int iAmmoBarRowIdx2; // edi + int iWinWidth2; // eax + long double dSpeedometer; // st7 + int iSpeedDisplayValue; // ebx + int iSpeedDigitIdx; // esi + int iDigitArrayIdx; // ecx + int iLastDigitIdx; // esi + tBlockHeader *pBlockHdr; // eax + int iScaledSize; // esi + int iWidth; // ebp + uint8 *byDigitPixelPtr; // edi + uint8 *bySpriteDataPtr; // edx + int iPixelXOffset; // eax + int iPixelXIdx; // ebx + int iSpeedUnitBlkIdx; // ebx + tBlockHeader *pLifeIconBlockHdr; // esi + int iLifeIconIdx; // edi + int iLifeIconYPos; // ebp + int iKillsDisplayValue; // ecx + tBlockHeader *pKillBlockHdr; // edx + int iKillIconIdx; // ebx + tBlockHeader *pPositionBlockHdr; // edi + int iRacePosition; // ecx + int iKillIconLoopIdx; // esi + int iCarIdxForKills; // ebp + uint8 *byKillIconPtr; // eax + int byKills; // ecx + uint8 *byKillsScreenPtr; // ebp + tBlockHeader *pKillsDigitBlockHdr; // edi + int iGearCarIdx; // edi + uint8 *byGearScreenPtr; // ebp + tBlockHeader *pLapBlockHdr; // esi + int iCurrentLap; // ecx + tBlockHeader *pLapDigitBlockHdr; // ebp + int iLapDigitWidth; // edx + int iLapXOffset; // eax + uint8 *byLapDisplayPtr; // edi + int iLapDigitIdx; // ebx + uint8 *byRaceScreenPtr; // esi + int iTimingCarIdx; // ebp tBlockHeader *pPositionDigitBlockHdr; // esi - int iPositionValue; // ecx - int iPositionDigitWidth; // edx - int iPositionXOffset; // eax - uint8 *byPositionDisplayPtr; // edi - int iPositionDigitIdx; // ebx - int iPositionCarIdx; // ecx - int iLapNum2; // edi - int iLapTimeYPos2; // esi - int iTrialTimeIdx2; // ebp - double dLapTime2; // st7 - //int64 llLapTimeInt2; // rtt + int iPositionValue; // ecx + int iPositionDigitWidth; // edx + int iPositionXOffset; // eax + uint8 *byPositionDisplayPtr; // edi + int iPositionDigitIdx; // ebx + int iPositionCarIdx; // ecx + int iLapNum2; // edi + int iLapTimeYPos2; // esi + int iTrialTimeIdx2; // ebp + double dLapTime2; // st7 + // int64 llLapTimeInt2; // rtt double dRunningLapTime2; // st7 - //int64 llRunningLapTimeInt2; // rtt - int iSelectedView; // ebp - int iTimingXPos; // esi - int iLapTimeCarIdx; // edi - int iTimingBaseXPos; // edi - double dAheadTimeLaps; // st7 - double dBehindTimeLaps; // st7 - char *szMessageSender; // [esp+4h] [ebp-A4h] - int iDigitArray[3]; // [esp+8h] [ebp-A0h] - uint8 *byScreenPtr; // [esp+14h] [ebp-94h] - int iCarIndex_1; // [esp+18h] [ebp-90h] - uint8 *bySpriteRowPtr; // [esp+1Ch] [ebp-8Ch] - uint8 *byPixelRowPtr; // [esp+20h] [ebp-88h] - int iCarIdx; // [esp+24h] [ebp-84h] - float fAheadTime; // [esp+28h] [ebp-80h] BYREF - float fBehindTime; // [esp+2Ch] [ebp-7Ch] BYREF - float fBestLapTime; // [esp+30h] [ebp-78h] - int iBaseXPos; // [esp+34h] [ebp-74h] - int iLapsAheadCnt; // [esp+38h] [ebp-70h] + // int64 llRunningLapTimeInt2; // rtt + int iSelectedView; // ebp + int iTimingXPos; // esi + int iLapTimeCarIdx; // edi + int iTimingBaseXPos; // edi + double dAheadTimeLaps; // st7 + double dBehindTimeLaps; // st7 + char *szMessageSender; // [esp+4h] [ebp-A4h] + int iDigitArray[3]; // [esp+8h] [ebp-A0h] + uint8 *byScreenPtr; // [esp+14h] [ebp-94h] + int iCarIndex_1; // [esp+18h] [ebp-90h] + uint8 *bySpriteRowPtr; // [esp+1Ch] [ebp-8Ch] + uint8 *byPixelRowPtr; // [esp+20h] [ebp-88h] + int iCarIdx; // [esp+24h] [ebp-84h] + float fAheadTime; // [esp+28h] [ebp-80h] BYREF + float fBehindTime; // [esp+2Ch] [ebp-7Ch] BYREF + float fBestLapTime; // [esp+30h] [ebp-78h] + int iBaseXPos; // [esp+34h] [ebp-74h] + int iLapsAheadCnt; // [esp+38h] [ebp-70h] tBlockHeader *pSpeedDigitBlockHdr; // [esp+3Ch] [ebp-6Ch] - int iHeight; // [esp+40h] [ebp-68h] - int iSavedScrSize; // [esp+44h] [ebp-64h] - int iSpeedometerValue; // [esp+48h] [ebp-60h] - int iTotalDigitWidth; // [esp+4Ch] [ebp-5Ch] - uint8 *bySpeedometerPtr; // [esp+50h] [ebp-58h] - tBlockHeader *pDigitBlockHdr; // [esp+54h] [ebp-54h] - unsigned int uiCarDataOffset; // [esp+58h] [ebp-50h] - uint8 *byAmmoBarPtr3; // [esp+5Ch] [ebp-4Ch] - unsigned int uiCarDataOffset2; // [esp+60h] [ebp-48h] - unsigned int uiCarDataOffset3; // [esp+64h] [ebp-44h] - unsigned int uiCarDataOffset4; // [esp+68h] [ebp-40h] - unsigned int uiCarDataOffset5; // [esp+6Ch] [ebp-3Ch] - uint8 *byAmmoBarPtr4; // [esp+70h] [ebp-38h] - unsigned int uiDigitArrayOffset; // [esp+74h] [ebp-34h] - int iBehindLapCnt; // [esp+78h] [ebp-30h] - tBlockHeader *pLapDigitBlockHdr2; // [esp+7Ch] [ebp-2Ch] - int iLastDigitIdx2; // [esp+80h] [ebp-28h] - int iDamage; // [esp+84h] [ebp-24h] - int v126; // [esp+88h] [ebp-20h] - int iTimeMinutes; // [esp+8Ch] [ebp-1Ch] - int iSpriteRowIdx; // [esp+90h] [ebp-18h] + int iHeight; // [esp+40h] [ebp-68h] + int iSavedScrSize; // [esp+44h] [ebp-64h] + int iSpeedometerValue; // [esp+48h] [ebp-60h] + int iTotalDigitWidth; // [esp+4Ch] [ebp-5Ch] + uint8 *bySpeedometerPtr; // [esp+50h] [ebp-58h] + tBlockHeader *pDigitBlockHdr; // [esp+54h] [ebp-54h] + unsigned int uiCarDataOffset; // [esp+58h] [ebp-50h] + uint8 *byAmmoBarPtr3; // [esp+5Ch] [ebp-4Ch] + unsigned int uiCarDataOffset2; // [esp+60h] [ebp-48h] + unsigned int uiCarDataOffset3; // [esp+64h] [ebp-44h] + unsigned int uiCarDataOffset4; // [esp+68h] [ebp-40h] + unsigned int uiCarDataOffset5; // [esp+6Ch] [ebp-3Ch] + uint8 *byAmmoBarPtr4; // [esp+70h] [ebp-38h] + unsigned int uiDigitArrayOffset; // [esp+74h] [ebp-34h] + int iBehindLapCnt; // [esp+78h] [ebp-30h] + tBlockHeader *pLapDigitBlockHdr2; // [esp+7Ch] [ebp-2Ch] + int iLastDigitIdx2; // [esp+80h] [ebp-28h] + int iDamage; // [esp+84h] [ebp-24h] + int v126; // [esp+88h] [ebp-20h] + int iTimeMinutes; // [esp+8Ch] [ebp-1Ch] + int iSpriteRowIdx; // [esp+90h] [ebp-18h] byScreenPtr = pScrBuf; iCarIndex_1 = iPlayerCarIdx; iCarIdx = ViewType[0] != iPlayerCarIdx; - if (winh < 200 || (textures_off & TEX_OFF_PANEL_RESTRICTED) != 0)// TEX_OFF_PANEL_RESTRICTED + if (winh < 200 || (textures_off & TEX_OFF_PANEL_RESTRICTED) != + 0) // TEX_OFF_PANEL_RESTRICTED { iSavedScrSize = scr_size; iCarIndex = iCarIndex_1; - byCarDesignIdx = Car[iCarIndex_1].byCarDesignIdx;// Get car design index for ammo display + byCarDesignIdx = + Car[iCarIndex_1] + .byCarDesignIdx; // Get car design index for ammo display scr_size = 64; - if (byCarDesignIdx >= 8u) // Check if car has cheat weapons (design index 8+) + if (byCarDesignIdx >= + 8u) // Check if car has cheat weapons (design index 8+) { iAmmoBarIdx = 0; byAmmoBarPtr4 = byScreenPtr + 1; do { - byAmmoBarPtr = &byAmmoBarPtr4[winw * (winh - 8)];// Draw ammo bar border (top) + byAmmoBarPtr = + &byAmmoBarPtr4[winw * (winh - 8)]; // Draw ammo bar border (top) memset(byAmmoBarPtr, 112, 7u); iAmmoBarRowIdx = 0; byAmmoBarRowPtr = &byAmmoBarPtr[winw]; do { - *byAmmoBarRowPtr = 112; // Draw ammo bar fill based on remaining ammunition + *byAmmoBarRowPtr = + 112; // Draw ammo bar fill based on remaining ammunition if (Car[iCarIndex].byCheatAmmo > iAmmoBarIdx) memset(byAmmoBarRowPtr + 1, 171, 5u); iWinWidth = winw; @@ -711,19 +696,27 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) byAmmoBarPtr4 += 8; } while (iAmmoBarIdx < 8); } - if ((textures_off & TEX_OFF_KMH) != 0) // TEX_OFF_KMH + if ((textures_off & TEX_OFF_KMH) != 0) // TEX_OFF_KMH { - sprintf(buffer, "%3.0f", (double)fabs(Car[iCarIndex_1].fFinalSpeed * 15.0 * 0.041666668));// Display speed in km/h (convert from internal units) + sprintf(buffer, "%3.0f", + (double)fabs(Car[iCarIndex_1].fFinalSpeed * 15.0 * + 0.041666668)); // Display speed in km/h (convert from + // internal units) mini_prt_string(rev_vga[0], buffer, winw - 34, winh - 8); szSpeedUnit = szKmh; } else { - sprintf(buffer, "%3.0f", (double)fabs(Car[iCarIndex_1].fFinalSpeed * 0.3333333333333333));// Display speed in mph (convert from internal units) + sprintf( + buffer, "%3.0f", + (double)fabs(Car[iCarIndex_1].fFinalSpeed * + 0.3333333333333333)); // Display speed in mph (convert + // from internal units) mini_prt_string(rev_vga[0], buffer, winw - 34, winh - 8); szSpeedUnit = szMph; } mini_prt_string(rev_vga[0], szSpeedUnit, winw - 18, winh - 8); mini_prt_right(rev_vga[0], &language_buffer[1536], winw - 10, winh - 16); - byGearAyMax = Car[iCarIndex_1].byGearAyMax; // Display current gear (N, R, or 1-max) + byGearAyMax = + Car[iCarIndex_1].byGearAyMax; // Display current gear (N, R, or 1-max) if (byGearAyMax < 0) { if (byGearAyMax == -1) sprintf(buffer, "N"); @@ -735,7 +728,8 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) mini_prt_string(rev_vga[0], buffer, winw - 8, winh - 16); mini_prt_string(rev_vga[0], "R", winw - 30, winh - 24); byRPMBarPtr = &byScreenPtr[winw - 24 + winw * (winh - 24)]; - dRPMRatio = Car[iCarIndex_1].fRPMRatio * 21.0;// Calculate RPM bar length from camera distance + dRPMRatio = Car[iCarIndex_1].fRPMRatio * + 21.0; // Calculate RPM bar length from camera distance //_CHP(); v126 = (int)dRPMRatio; if ((int)dRPMRatio > 20) @@ -758,7 +752,9 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) do_blip(iCarIdx); mini_prt_string(rev_vga[0], "D", winw - 30, winh - 32); byDamageBarPtr = &byScreenPtr[winw - 24 + winw * (winh - 32)]; - dDamage = (100.0 - Car[iCarIndex_1].fHealth) * 21.0 * 0.0099999998;// Calculate damage bar length from car health (100 - health) + dDamage = (100.0 - Car[iCarIndex_1].fHealth) * 21.0 * + 0.0099999998; // Calculate damage bar length from car health (100 + // - health) //_CHP(); iDamage = (int)dDamage; if ((int)dDamage > 20) @@ -797,54 +793,57 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) mini_prt_string(rev_vga[0], buffer, 2, iLapTimeYPos); if (iLapNumber < (char)Car[uiCarDataOffset / 0x134].byLap) { dLapTime = trial_times[iTrialTimeIdx / sizeof(float)] * 100.0; - //dLapTime = *(float *)((char *)trial_times + iTrialTimeIdx) * 100.0; + // dLapTime = *(float *)((char *)trial_times + iTrialTimeIdx) * 100.0; //_CHP(); int iLapTimeCentiseconds = (int)dLapTime; - int iMinutes = iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds + int iMinutes = + iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds int iSeconds = (iLapTimeCentiseconds / 100) % 60; int iCentiseconds = iLapTimeCentiseconds % 100; sprintf(buffer, "%02d:%02d:%02d", iMinutes, iSeconds, iCentiseconds); mini_prt_string(rev_vga[0], buffer, 30, iLapTimeYPos); - //buffer[8] = 0; - //LODWORD(llLapTimeInt) = (int)dLapTime; - //HIDWORD(llLapTimeInt) = (int)dLapTime >> 31; - //buffer[7] = llLapTimeInt % 10 + 48; - //LODWORD(llLapTimeInt) = (int)dLapTime; - //buffer[6] = (int)(llLapTimeInt / 10) % 10 + 48; - //buffer[5] = 58; - //buffer[4] = (int)(llLapTimeInt / 10) / 10 % 10 + 48; - //buffer[3] = (int)(llLapTimeInt / 10) / 10 / 10 % 6 + 48; - //iTimeMinutes = (int)(llLapTimeInt / 10) / 10 / 10 / 6; - //buffer[1] = iTimeMinutes % 10 + 48; - //buffer[2] = 58; - //buffer[0] = iTimeMinutes / 10 % 10 + 48; - //mini_prt_string(rev_vga[0], buffer, 30, iLapTimeYPos); + // buffer[8] = 0; + // LODWORD(llLapTimeInt) = (int)dLapTime; + // HIDWORD(llLapTimeInt) = (int)dLapTime >> 31; + // buffer[7] = llLapTimeInt % 10 + 48; + // LODWORD(llLapTimeInt) = (int)dLapTime; + // buffer[6] = (int)(llLapTimeInt / 10) % 10 + 48; + // buffer[5] = 58; + // buffer[4] = (int)(llLapTimeInt / 10) / 10 % 10 + 48; + // buffer[3] = (int)(llLapTimeInt / 10) / 10 / 10 % 6 + 48; + // iTimeMinutes = (int)(llLapTimeInt / 10) / 10 / 10 / 6; + // buffer[1] = iTimeMinutes % 10 + 48; + // buffer[2] = 58; + // buffer[0] = iTimeMinutes / 10 % 10 + 48; + // mini_prt_string(rev_vga[0], buffer, 30, iLapTimeYPos); } if (iLapNumber == (char)Car[uiCarDataOffset3 / 0x134].byLap) { - dRunningLapTime = Car[uiCarDataOffset3 / 0x134].fRunningLapTime * 100.0; + dRunningLapTime = + Car[uiCarDataOffset3 / 0x134].fRunningLapTime * 100.0; //_CHP(); int iLapTimeCentiseconds = (int)dRunningLapTime; - int iMinutes = iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds + int iMinutes = + iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds int iSeconds = (iLapTimeCentiseconds / 100) % 60; int iCentiseconds = iLapTimeCentiseconds % 100; sprintf(buffer, "%02d:%02d:%02d", iMinutes, iSeconds, iCentiseconds); mini_prt_string(rev_vga[0], buffer, 30, iLapTimeYPos); - //LODWORD(llRunningLapTimeInt) = (int)dRunningLapTime; - //HIDWORD(llRunningLapTimeInt) = (int)dRunningLapTime >> 31; - //buffer[7] = llRunningLapTimeInt % 10 + 48; - //LODWORD(llRunningLapTimeInt) = (int)dRunningLapTime; - //buffer[5] = 58; - //buffer[6] = (int)(llRunningLapTimeInt / 10) % 10 + 48; - //buffer[4] = (int)(llRunningLapTimeInt / 10) / 10 % 10 + 48; - //buffer[2] = 58; - //buffer[3] = (int)(llRunningLapTimeInt / 10) / 10 / 10 % 6 + 48; - //iTimeMinutes = (int)(llRunningLapTimeInt / 10) / 10 / 10 / 6; - //buffer[1] = iTimeMinutes % 10 + 48; - //buffer[8] = 0; - //buffer[0] = iTimeMinutes / 10 % 10 + 48; - //mini_prt_string(rev_vga[0], buffer, 30, iLapTimeYPos); + // LODWORD(llRunningLapTimeInt) = (int)dRunningLapTime; + // HIDWORD(llRunningLapTimeInt) = (int)dRunningLapTime >> 31; + // buffer[7] = llRunningLapTimeInt % 10 + 48; + // LODWORD(llRunningLapTimeInt) = (int)dRunningLapTime; + // buffer[5] = 58; + // buffer[6] = (int)(llRunningLapTimeInt / 10) % 10 + 48; + // buffer[4] = (int)(llRunningLapTimeInt / 10) / 10 % 10 + 48; + // buffer[2] = 58; + // buffer[3] = (int)(llRunningLapTimeInt / 10) / 10 / 10 % 6 + 48; + // iTimeMinutes = (int)(llRunningLapTimeInt / 10) / 10 / 10 / 6; + // buffer[1] = iTimeMinutes % 10 + 48; + // buffer[8] = 0; + // buffer[0] = iTimeMinutes / 10 % 10 + 48; + // mini_prt_string(rev_vga[0], buffer, 30, iLapTimeYPos); } iTrialTimeIdx += 4; ++iLapNumber; @@ -863,7 +862,8 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) } else { if (showversion) prt_string(rev_vga[1], VersionString, 150, 190); - iMainCarIdx = iCarIndex_1; // Full resolution panel mode - render detailed HUD elements + iMainCarIdx = iCarIndex_1; // Full resolution panel mode - render detailed + // HUD elements if (Car[iCarIndex_1].byCarDesignIdx >= 8u) { iAmmoBarIdx2 = 0; byAmmoBarPtr3 = byScreenPtr + 1; @@ -884,17 +884,25 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) byAmmoBarPtr3 += 8; } while (iAmmoBarIdx2 < 8); } - if (player_type == 2 || (cheat_mode & CHEAT_MODE_WIDESCREEN) != 0)// CHEAT_MODE_WIDESCREEN - iBaseXPos = (3 * winw / 16) + 157; // Calculate speedometer X position (adjusted for widescreen) - //iBaseXPos = ((winw - (__CFSHL__(winw >> 31, 2) + 4 * (winw >> 31))) >> 2) + 157;// Calculate base X position for speedometer (adjusted for widescreen) + if (player_type == 2 || + (cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) // CHEAT_MODE_WIDESCREEN + iBaseXPos = + (3 * winw / 16) + + 157; // Calculate speedometer X position (adjusted for widescreen) + // iBaseXPos = ((winw - (__CFSHL__(winw >> 31, 2) + 4 * (winw >> 31))) >> 2) + // + 157;// Calculate base X position for speedometer (adjusted for + // widescreen) else iBaseXPos = 157; pDigitBlockHdr = rev_vga[2]; pSpeedDigitBlockHdr = rev_vga[2]; - if ((textures_off & TEX_OFF_KMH) != 0) // TEX_OFF_KMH - dSpeedometer = fabs(Car[iCarIndex_1].fFinalSpeed * 0.33333334) * 15.0 * 0.125;// Calculate speedometer value (km/h with additional scaling factor) + if ((textures_off & TEX_OFF_KMH) != 0) // TEX_OFF_KMH + dSpeedometer = fabs(Car[iCarIndex_1].fFinalSpeed * 0.33333334) * 15.0 * + 0.125; // Calculate speedometer value (km/h with additional + // scaling factor) else - dSpeedometer = fabs(Car[iCarIndex_1].fFinalSpeed * 0.33333334);// Calculate speedometer value (mph) + dSpeedometer = fabs(Car[iCarIndex_1].fFinalSpeed * + 0.33333334); // Calculate speedometer value (mph) //_CHP(); iSpeedometerValue = (int)dSpeedometer; iSpeedDisplayValue = (int)dSpeedometer; @@ -902,20 +910,26 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) iDigitArrayIdx = 0; iTotalDigitWidth = 0; do { - iDigitArray[iDigitArrayIdx] = iSpeedDisplayValue % 10;// Extract individual digits and calculate total width for centering - iTotalDigitWidth += pSpeedDigitBlockHdr[iSpeedDisplayValue % 10 + 9].iWidth - 1; + iDigitArray[iDigitArrayIdx] = + iSpeedDisplayValue % 10; // Extract individual digits and calculate + // total width for centering + iTotalDigitWidth += + pSpeedDigitBlockHdr[iSpeedDisplayValue % 10 + 9].iWidth - 1; ++iDigitArrayIdx; ++iSpeedDigitIdx; iSpeedDisplayValue /= 10; } while (iSpeedDisplayValue > 0); iLastDigitIdx = iSpeedDigitIdx - 1; iLastDigitIdx2 = iLastDigitIdx; - bySpeedometerPtr = &byScreenPtr[winw * ((155 * scr_size) >> 6) + winw - ((44 * scr_size) >> 6)]; + bySpeedometerPtr = &byScreenPtr[winw * ((155 * scr_size) >> 6) + winw - + ((44 * scr_size) >> 6)]; if (iTotalDigitWidth > 0) { uiDigitArrayOffset = 4 * iLastDigitIdx; do { - iSpriteRowIdx = 0; // Render each digit sprite with scaling - pBlockHdr = &pSpeedDigitBlockHdr[iDigitArray[uiDigitArrayOffset / 4] + 9];// Render speedometer digits using sprite blocks + iSpriteRowIdx = 0; // Render each digit sprite with scaling + pBlockHdr = &pSpeedDigitBlockHdr[iDigitArray[uiDigitArrayOffset / 4] + + 9]; // Render speedometer digits using + // sprite blocks iScaledSize = scr_size; iWidth = pBlockHdr->iWidth; iHeight = pBlockHdr->iHeight; @@ -939,7 +953,8 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) } } iScaledSize -= 64; - for (bySpriteDataPtr = bySpriteRowPtr; iScaledSize <= 0; ++iSpriteRowIdx) { + for (bySpriteDataPtr = bySpriteRowPtr; iScaledSize <= 0; + ++iSpriteRowIdx) { bySpriteDataPtr += iWidth; iScaledSize += scr_size; } @@ -951,17 +966,22 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) --iLastDigitIdx2; } while (iTotalDigitWidth > 0); } - if ((textures_off & TEX_OFF_KMH) != 0) // TEX_OFF_KMH + if ((textures_off & TEX_OFF_KMH) != 0) // TEX_OFF_KMH iSpeedUnitBlkIdx = 32; else iSpeedUnitBlkIdx = 33; - game_render_print_block(g_pGameRenderer, 2, iSpeedUnitBlkIdx, &byScreenPtr[winw * ((172 * scr_size) >> 6) + winw - ((25 * scr_size) >> 6)]);// Display speed unit icon (km/h or mph) + game_render_print_block( + g_pGameRenderer, 2, iSpeedUnitBlkIdx, + &byScreenPtr[winw * ((172 * scr_size) >> 6) + winw - + ((25 * scr_size) >> + 6)]); // Display speed unit icon (km/h or mph) pLifeIconBlockHdr = rev_vga[4]; iLifeIconIdx = 0; iLifeIconYPos = 54; uiCarDataOffset5 = 308 * iCarIndex_1; iKillsDisplayValue = Car[iCarIndex_1].byCarDesignIdx; - while (iLifeIconIdx < (char)Car[uiCarDataOffset5 / 0x134].byLives) { // Draw life icons for current car + while (iLifeIconIdx < (char)Car[uiCarDataOffset5 / 0x134] + .byLives) { // Draw life icons for current car if (iKillsDisplayValue >= 8) { iKillIconIdx = 8; pKillBlockHdr = pLifeIconBlockHdr; @@ -969,35 +989,55 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) pKillBlockHdr = pLifeIconBlockHdr; iKillIconIdx = iKillsDisplayValue; } - game_render_print_block(g_pGameRenderer, 4, iKillIconIdx, &byScreenPtr[winw * ((iLifeIconYPos * scr_size) >> 6) + ((8 * scr_size) >> 6)]); + game_render_print_block( + g_pGameRenderer, 4, iKillIconIdx, + &byScreenPtr[winw * ((iLifeIconYPos * scr_size) >> 6) + + ((8 * scr_size) >> 6)]); iLifeIconYPos += 20; ++iLifeIconIdx; } pPositionBlockHdr = rev_vga[4]; - if (Car[uiCarDataOffset5 / 0x134].byKills >= 9u)// Display kills - either as individual icons or as two-digit number + if (Car[uiCarDataOffset5 / 0x134].byKills >= + 9u) // Display kills - either as individual icons or as two-digit number { - game_render_print_block(g_pGameRenderer, 4, 8, &byScreenPtr[winw * ((178 * scr_size) >> 6) + winw - ((144 * scr_size) >> 6)]); + game_render_print_block(g_pGameRenderer, 4, 8, + &byScreenPtr[winw * ((178 * scr_size) >> 6) + + winw - ((144 * scr_size) >> 6)]); byKills = Car[uiCarDataOffset5 / 0x134].byKills; byKillsScreenPtr = byScreenPtr; pKillsDigitBlockHdr = rev_vga[2]; - game_render_print_block(g_pGameRenderer, 2, byKills / 10 + 9, &byScreenPtr[winw * ((178 * scr_size) >> 6) + winw - ((122 * scr_size) >> 6)]); - game_render_print_block(g_pGameRenderer, 2, byKills % 10 + 9, &byKillsScreenPtr[winw * ((178 * scr_size) >> 6) + winw - ((110 * scr_size) >> 6)]); + game_render_print_block(g_pGameRenderer, 2, byKills / 10 + 9, + &byScreenPtr[winw * ((178 * scr_size) >> 6) + + winw - ((122 * scr_size) >> 6)]); + game_render_print_block( + g_pGameRenderer, 2, byKills % 10 + 9, + &byKillsScreenPtr[winw * ((178 * scr_size) >> 6) + winw - + ((110 * scr_size) >> 6)]); } else { iRacePosition = 100; iKillIconLoopIdx = 0; iCarIdxForKills = iCarIndex_1; while (iKillIconLoopIdx < Car[iCarIdxForKills].byKills) { ++iKillIconLoopIdx; - byKillIconPtr = &byScreenPtr[winw * ((178 * scr_size) >> 6) + winw - ((iRacePosition * scr_size) >> 6)]; + byKillIconPtr = &byScreenPtr[winw * ((178 * scr_size) >> 6) + winw - + ((iRacePosition * scr_size) >> 6)]; iRacePosition += 22; game_render_print_block(g_pGameRenderer, 4, 8, byKillIconPtr); } } iGearCarIdx = iCarIndex_1; - print_damage(&byScreenPtr[winw * (scr_size << 7 >> 6) + winw - ((80 * scr_size) >> 6)], rev_vga[2], iCarIdx);// Display damage indicator and gear display + print_damage(&byScreenPtr[winw * (scr_size << 7 >> 6) + winw - + ((80 * scr_size) >> 6)], + rev_vga[2], + iCarIdx); // Display damage indicator and gear display byGearScreenPtr = byScreenPtr; - game_render_print_block(g_pGameRenderer, 2, (char)Car[iGearCarIdx].byGearAyMax + 3, &byScreenPtr[winw * ((181 * scr_size) >> 6) + winw - ((14 * scr_size) >> 6)]); - game_render_print_block(g_pGameRenderer, 2, 19, &byGearScreenPtr[winw * ((21 * scr_size) >> 6) + winw - ((67 * scr_size) >> 6)]); + game_render_print_block(g_pGameRenderer, 2, + (char)Car[iGearCarIdx].byGearAyMax + 3, + &byScreenPtr[winw * ((181 * scr_size) >> 6) + winw - + ((14 * scr_size) >> 6)]); + game_render_print_block(g_pGameRenderer, 2, 19, + &byGearScreenPtr[winw * ((21 * scr_size) >> 6) + + winw - ((67 * scr_size) >> 6)]); pLapBlockHdr = rev_vga[2]; iCurrentLap = (char)Car[iGearCarIdx].byLap; pLapDigitBlockHdr = rev_vga[2]; @@ -1006,24 +1046,31 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) if (iCurrentLap > 99) iCurrentLap = 99; if (iCurrentLap >= 10) - iLapDigitWidth = rev_vga[2][iCurrentLap / 10 + 22].iWidth + rev_vga[2][iCurrentLap % 10 + 22].iWidth - 1; + iLapDigitWidth = rev_vga[2][iCurrentLap / 10 + 22].iWidth + + rev_vga[2][iCurrentLap % 10 + 22].iWidth - 1; else iLapDigitWidth = rev_vga[2][iCurrentLap + 22].iWidth; iLapXOffset = (scr_size * (iLapDigitWidth / 2 + 36)) >> 6; - byLapDisplayPtr = &byScreenPtr[winw * ((25 * scr_size) >> 6) + winw - iLapXOffset]; + byLapDisplayPtr = + &byScreenPtr[winw * ((25 * scr_size) >> 6) + winw - iLapXOffset]; if (iCurrentLap >= 10) { iTimeMinutes = iCurrentLap / 10 + 22; - game_render_print_block(g_pGameRenderer, 2, iTimeMinutes, &byScreenPtr[winw * ((25 * scr_size) >> 6) + winw - iLapXOffset]); - byLapDisplayPtr += winw * (pLapDigitBlockHdr[iTimeMinutes].iWidth - 1) / 320; + game_render_print_block( + g_pGameRenderer, 2, iTimeMinutes, + &byScreenPtr[winw * ((25 * scr_size) >> 6) + winw - iLapXOffset]); + byLapDisplayPtr += + winw * (pLapDigitBlockHdr[iTimeMinutes].iWidth - 1) / 320; iLapDigitIdx = iCurrentLap % 10 + 22; } else { iLapDigitIdx = iCurrentLap + 22; } game_render_print_block(g_pGameRenderer, 2, iLapDigitIdx, byLapDisplayPtr); byRaceScreenPtr = byScreenPtr; - game_render_print_block(g_pGameRenderer, 2, 20, &byScreenPtr[winw * ((5 * scr_size) >> 6) + winw - ((52 * scr_size) >> 6)]); + game_render_print_block(g_pGameRenderer, 2, 20, + &byScreenPtr[winw * ((5 * scr_size) >> 6) + winw - + ((52 * scr_size) >> 6)]); iTimingCarIdx = iCarIndex_1; - if (game_type >= 2) // Time trial mode - display lap times for multiple laps + if (game_type >= 2) // Time trial mode - display lap times for multiple laps { iLapNum2 = 1; uiCarDataOffset4 = 308 * iCarIndex_1; @@ -1035,76 +1082,89 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) mini_prt_string(rev_vga[0], buffer, 8, iLapTimeYPos2); if (iLapNum2 < (char)Car[uiCarDataOffset2 / 0x134].byLap) { dLapTime2 = trial_times[iTrialTimeIdx2 / sizeof(float)] * 100.0; - //dLapTime2 = *(float *)((char *)trial_times + iTrialTimeIdx2) * 100.0; - //_CHP(); + // dLapTime2 = *(float *)((char *)trial_times + iTrialTimeIdx2) * + // 100.0; _CHP(); int iLapTimeCentiseconds = (int)dLapTime2; - int iMinutes = iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds + int iMinutes = + iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds int iSeconds = (iLapTimeCentiseconds / 100) % 60; int iCentiseconds = iLapTimeCentiseconds % 100; sprintf(buffer, "%02d:%02d:%02d", iMinutes, iSeconds, iCentiseconds); mini_prt_string(rev_vga[0], buffer, 40, iLapTimeYPos2); - //buffer[8] = 0; - //LODWORD(llLapTimeInt2) = (int)dLapTime2; - //HIDWORD(llLapTimeInt2) = (int)dLapTime2 >> 31; - //buffer[7] = llLapTimeInt2 % 10 + 48; - //LODWORD(llLapTimeInt2) = (int)dLapTime2; - //buffer[6] = (int)(llLapTimeInt2 / 10) % 10 + 48; - //buffer[5] = 58; - //buffer[4] = (int)(llLapTimeInt2 / 10) / 10 % 10 + 48; - //buffer[3] = (int)(llLapTimeInt2 / 10) / 10 / 10 % 6 + 48; - //buffer[2] = 58; - //iTimeMinutes = (int)(llLapTimeInt2 / 10) / 10 / 10 / 6; - //buffer[1] = iTimeMinutes % 10 + 48; - //buffer[0] = iTimeMinutes / 10 % 10 + 48; - //mini_prt_string(rev_vga[0], buffer, 40, iLapTimeYPos2); + // buffer[8] = 0; + // LODWORD(llLapTimeInt2) = (int)dLapTime2; + // HIDWORD(llLapTimeInt2) = (int)dLapTime2 >> 31; + // buffer[7] = llLapTimeInt2 % 10 + 48; + // LODWORD(llLapTimeInt2) = (int)dLapTime2; + // buffer[6] = (int)(llLapTimeInt2 / 10) % 10 + 48; + // buffer[5] = 58; + // buffer[4] = (int)(llLapTimeInt2 / 10) / 10 % 10 + 48; + // buffer[3] = (int)(llLapTimeInt2 / 10) / 10 / 10 % 6 + 48; + // buffer[2] = 58; + // iTimeMinutes = (int)(llLapTimeInt2 / 10) / 10 / 10 / 6; + // buffer[1] = iTimeMinutes % 10 + 48; + // buffer[0] = iTimeMinutes / 10 % 10 + 48; + // mini_prt_string(rev_vga[0], buffer, 40, iLapTimeYPos2); } if (iLapNum2 == (char)Car[uiCarDataOffset4 / 0x134].byLap) { - dRunningLapTime2 = Car[uiCarDataOffset4 / 0x134].fRunningLapTime * 100.0;// Display current running lap time + dRunningLapTime2 = Car[uiCarDataOffset4 / 0x134].fRunningLapTime * + 100.0; // Display current running lap time //_CHP(); int iLapTimeCentiseconds = (int)dRunningLapTime2; - int iMinutes = iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds + int iMinutes = + iLapTimeCentiseconds / 6000; // 60 seconds * 100 centiseconds int iSeconds = (iLapTimeCentiseconds / 100) % 60; int iCentiseconds = iLapTimeCentiseconds % 100; sprintf(buffer, "%02d:%02d:%02d", iMinutes, iSeconds, iCentiseconds); mini_prt_string(rev_vga[0], buffer, 40, iLapTimeYPos2); - //LODWORD(llRunningLapTimeInt2) = (int)dRunningLapTime2; - //HIDWORD(llRunningLapTimeInt2) = (int)dRunningLapTime2 >> 31; - //buffer[7] = llRunningLapTimeInt2 % 10 + 48; - //LODWORD(llRunningLapTimeInt2) = (int)dRunningLapTime2; - //buffer[6] = (int)(llRunningLapTimeInt2 / 10) % 10 + 48; - //buffer[4] = (int)(llRunningLapTimeInt2 / 10) / 10 % 10 + 48; - //buffer[3] = (int)(llRunningLapTimeInt2 / 10) / 10 / 10 % 6 + 48; - //iTimeMinutes = (int)(llRunningLapTimeInt2 / 10) / 10 / 10 / 6; - //buffer[1] = iTimeMinutes % 10 + 48; - //buffer[8] = 0; - //buffer[5] = 58; - //buffer[2] = 58; - //buffer[0] = iTimeMinutes / 10 % 10 + 48; - //mini_prt_string(rev_vga[0], buffer, 40, iLapTimeYPos2); + // LODWORD(llRunningLapTimeInt2) = (int)dRunningLapTime2; + // HIDWORD(llRunningLapTimeInt2) = (int)dRunningLapTime2 >> 31; + // buffer[7] = llRunningLapTimeInt2 % 10 + 48; + // LODWORD(llRunningLapTimeInt2) = (int)dRunningLapTime2; + // buffer[6] = (int)(llRunningLapTimeInt2 / 10) % 10 + 48; + // buffer[4] = (int)(llRunningLapTimeInt2 / 10) / 10 % 10 + 48; + // buffer[3] = (int)(llRunningLapTimeInt2 / 10) / 10 / 10 % 6 + 48; + // iTimeMinutes = (int)(llRunningLapTimeInt2 / 10) / 10 / 10 / 6; + // buffer[1] = iTimeMinutes % 10 + 48; + // buffer[8] = 0; + // buffer[5] = 58; + // buffer[2] = 58; + // buffer[0] = iTimeMinutes / 10 % 10 + 48; + // mini_prt_string(rev_vga[0], buffer, 40, iLapTimeYPos2); } iTrialTimeIdx2 += 4; ++iLapNum2; iLapTimeYPos2 += 8; } while (iLapNum2 < 6); } else { - game_render_print_block(g_pGameRenderer, 2, 21, &byRaceScreenPtr[winw * ((8 * scr_size) >> 6)]);// Race mode - display position and lap information + game_render_print_block( + g_pGameRenderer, 2, 21, + &byRaceScreenPtr[winw * ((8 * scr_size) >> + 6)]); // Race mode - display position and lap + // information pPositionDigitBlockHdr = rev_vga[2]; iPositionValue = Car[iTimingCarIdx].byRacePosition + 1; pLapDigitBlockHdr2 = rev_vga[2]; if (iPositionValue >= 10) - iPositionDigitWidth = rev_vga[2][23].iWidth + rev_vga[2][iPositionValue % 10 + 22].iWidth - 1; + iPositionDigitWidth = rev_vga[2][23].iWidth + + rev_vga[2][iPositionValue % 10 + 22].iWidth - 1; else iPositionDigitWidth = rev_vga[2][iPositionValue + 22].iWidth; iPositionXOffset = (scr_size * (59 - iPositionDigitWidth / 2)) >> 6; - byPositionDisplayPtr = &byScreenPtr[winw * ((12 * scr_size) >> 6) + iPositionXOffset]; + byPositionDisplayPtr = + &byScreenPtr[winw * ((12 * scr_size) >> 6) + iPositionXOffset]; if (iPositionValue >= 10) { - game_render_print_block(g_pGameRenderer, 2, 23, &byScreenPtr[winw * ((12 * scr_size) >> 6) + iPositionXOffset]); - byPositionDisplayPtr += (scr_size * (pLapDigitBlockHdr2[23].iWidth - 1)) >> 6; + game_render_print_block( + g_pGameRenderer, 2, 23, + &byScreenPtr[winw * ((12 * scr_size) >> 6) + iPositionXOffset]); + byPositionDisplayPtr += + (scr_size * (pLapDigitBlockHdr2[23].iWidth - 1)) >> 6; iPositionDigitIdx = iPositionValue % 10 + 22; } else { iPositionDigitIdx = iPositionValue + 22; } - game_render_print_block(g_pGameRenderer, 2, iPositionDigitIdx, byPositionDisplayPtr); + game_render_print_block(g_pGameRenderer, 2, iPositionDigitIdx, + byPositionDisplayPtr); iPositionCarIdx = iCarIndex_1; print_pos(4, 9, Car[iCarIndex_1].byRacePosition - 1); print_pos(4, 42, Car[iPositionCarIdx].byRacePosition + 1); @@ -1122,9 +1182,12 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) fBestLapTime = -1.0; iTimingBaseXPos = iBaseXPos; ShowATime(fBestLapTime, iBaseXPos, 14); - calculate_aheadbehindtime(iCarIndex_1, &fAheadTime, &fBehindTime);// Calculate time ahead/behind other players + calculate_aheadbehindtime( + iCarIndex_1, &fAheadTime, + &fBehindTime); // Calculate time ahead/behind other players prt_right(rev_vga[1], &language_buffer[128], iTimingBaseXPos - 2, 24); - if (fAheadTime >= 10000000.0) // Display large time differences as lap counts instead of time + if (fAheadTime >= 10000000.0) // Display large time differences as lap + // counts instead of time { dAheadTimeLaps = fAheadTime * 0.0000001; //_CHP(); @@ -1152,7 +1215,9 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) } } } - if (network_on && players > 1) // Display network chat message sender name if in multiplayer + if (network_on && + players > + 1) // Display network chat message sender name if in multiplayer { if (network_mes_mode >= 0) szMessageSender = driver_names[network_mes_mode]; @@ -1162,322 +1227,395 @@ void test_panel(uint8 *pScrBuf, int iPlayerCarIdx) prt_string(rev_vga[1], buffer, 2, winh - 12); } } - showmap(byScreenPtr, iCarIndex_1); // Finally render the minimap overlay + showmap(byScreenPtr, iCarIndex_1); // Finally render the minimap overlay } //------------------------------------------------------------------------------------------------- -//00017770 -void ZoomString(const char *szStr, const char *mappingTable, tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets) -{ - int iSelectedView1; // esi - int iSelectedView2; // esi - int iCharIndex; // edx - double dCharWidth; // st7 - double dNewTextWidth; // st7 - double dScaledWidth; // st7 +// 00017770 +void ZoomString(const char *szStr, const char *mappingTable, + tBlockHeader *pBlockHeader, int iPlayerIdx, + int *pCharVOffsets) { + int iSelectedView1; // esi + int iSelectedView2; // esi + int iCharIndex; // edx + double dCharWidth; // st7 + double dNewTextWidth; // st7 + double dScaledWidth; // st7 const char *pbyCurrentChar; // esi - int iCharCode; // edx - uint8 byFontIndex; // bl - double dSpaceWidth; // st7 - int iSavedZoomY; // [esp+4h] [ebp-24h] - int iTotalWidth; // [esp+10h] [ebp-18h] - float fZoomFactor; // [esp+14h] [ebp-14h] - int iStringDone; // [esp+18h] [ebp-10h] - - if (game_scale[iPlayerIdx] < 32768.0 && zoom_size[iPlayerIdx] || !zoom_size[iPlayerIdx] && game_scale[iPlayerIdx] < 1024.0) { // Check for 2-player mode or widescreen cheat - if (player_type == 2 || (cheat_mode & CHEAT_MODE_WIDESCREEN) != 0)// CHEAT_MODE_WIDESCREEN - zoom_x = 320; // Set zoom center X to 320 for 2-player/widescreen + int iCharCode; // edx + uint8 byFontIndex; // bl + double dSpaceWidth; // st7 + int iSavedZoomY; // [esp+4h] [ebp-24h] + int iTotalWidth; // [esp+10h] [ebp-18h] + float fZoomFactor; // [esp+14h] [ebp-14h] + int iStringDone; // [esp+18h] [ebp-10h] + + if (game_scale[iPlayerIdx] < 32768.0 && zoom_size[iPlayerIdx] || + !zoom_size[iPlayerIdx] && + game_scale[iPlayerIdx] < + 1024.0) { // Check for 2-player mode or widescreen cheat + if (player_type == 2 || + (cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) // CHEAT_MODE_WIDESCREEN + zoom_x = 320; // Set zoom center X to 320 for 2-player/widescreen else - zoom_x = 160; // Set zoom center X to 160 for single player - if (zoom_size[iPlayerIdx]) // Check if large zoom mode is enabled - { // Check if in intro or 2-player mode + zoom_x = 160; // Set zoom center X to 160 for single player + if (zoom_size[iPlayerIdx]) // Check if large zoom mode is enabled + { // Check if in intro or 2-player mode if (intro || player_type == 2) { - zoom_y = 84; // Set zoom Y to 84 for intro/2-player large zoom + zoom_y = 84; // Set zoom Y to 84 for intro/2-player large zoom } else { - iSelectedView1 = SelectedView[iPlayerIdx];// Get selected view for this player - if (iSelectedView1 == 1 || iSelectedView1 == 3)// Check if view 1 or 3 (cockpit/bumper views) - zoom_y = 130; // Set zoom Y to 130 for cockpit/bumper large zoom + iSelectedView1 = + SelectedView[iPlayerIdx]; // Get selected view for this player + if (iSelectedView1 == 1 || + iSelectedView1 == 3) // Check if view 1 or 3 (cockpit/bumper views) + zoom_y = 130; // Set zoom Y to 130 for cockpit/bumper large zoom else - zoom_y = 52; // Set zoom Y to 52 for external views large zoom + zoom_y = 52; // Set zoom Y to 52 for external views large zoom } - } else if (intro || player_type == 2) // Normal zoom: check intro or 2-player mode + } else if (intro || + player_type == 2) // Normal zoom: check intro or 2-player mode { - zoom_y = 95; // Set zoom Y to 95 for intro/2-player normal zoom + zoom_y = 95; // Set zoom Y to 95 for intro/2-player normal zoom } else { - iSelectedView2 = SelectedView[iPlayerIdx];// Get selected view for normal zoom - if (iSelectedView2 == 1 || iSelectedView2 == 3)// Check if view 1 or 3 for normal zoom - zoom_y = 130; // Set zoom Y to 130 for cockpit/bumper normal zoom + iSelectedView2 = + SelectedView[iPlayerIdx]; // Get selected view for normal zoom + if (iSelectedView2 == 1 || + iSelectedView2 == 3) // Check if view 1 or 3 for normal zoom + zoom_y = 130; // Set zoom Y to 130 for cockpit/bumper normal zoom else - zoom_y = 63; // Set zoom Y to 63 for external views normal zoom + zoom_y = 63; // Set zoom Y to 63 for external views normal zoom } char *szCurrentChar = (char *)szStr; - for (iTotalWidth = 0; *szCurrentChar; iTotalWidth = (int)dNewTextWidth)// Calculate total text width for centering + for (iTotalWidth = 0; *szCurrentChar; + iTotalWidth = + (int)dNewTextWidth) // Calculate total text width for centering { - iCharIndex = (uint8)mappingTable[*(uint8 *)szCurrentChar];// Get font index for current character - if (iCharIndex == 255) // Check if character is invalid (255 = space) - dCharWidth = 512.0; // Use fixed 512.0 width for space character + iCharIndex = (uint8)mappingTable[*( + uint8 *)szCurrentChar]; // Get font index for current character + if (iCharIndex == 255) // Check if character is invalid (255 = space) + dCharWidth = 512.0; // Use fixed 512.0 width for space character else - dCharWidth = (double)((pBlockHeader[iCharIndex].iWidth + 1) << 6);// Get character width from font data, add 1 pixel spacing - dNewTextWidth = dCharWidth / game_scale[iPlayerIdx] + (double)iTotalWidth;// Scale character width and accumulate total + dCharWidth = (double)((pBlockHeader[iCharIndex].iWidth + 1) + << 6); // Get character width from font data, add + // 1 pixel spacing + dNewTextWidth = + dCharWidth / game_scale[iPlayerIdx] + + (double)iTotalWidth; // Scale character width and accumulate total //_CHP(); ++szCurrentChar; } - if (iTotalWidth <= 310) // Check if total width fits within 310 pixels + if (iTotalWidth <= 310) // Check if total width fits within 310 pixels { - fZoomFactor = game_scale[iPlayerIdx]; // Use normal game scale factor + fZoomFactor = game_scale[iPlayerIdx]; // Use normal game scale factor } else { - dScaledWidth = (double)((iTotalWidth << 6) / 310);// Calculate compressed scale to fit in 310 pixels - iTotalWidth = 310; // Clamp total width to 310 pixels - fZoomFactor = (float)dScaledWidth; // Store compressed zoom factor + dScaledWidth = + (double)((iTotalWidth << 6) / + 310); // Calculate compressed scale to fit in 310 pixels + iTotalWidth = 310; // Clamp total width to 310 pixels + fZoomFactor = (float)dScaledWidth; // Store compressed zoom factor } - pbyCurrentChar = szStr; // Initialize text pointer for rendering - zoom_x -= iTotalWidth / 2; // Center text horizontally by subtracting half width - iStringDone = 0; // Initialize string completion flag - do { // Check if current character is not null terminator - if (*pbyCurrentChar) { // Check if character is not newline + pbyCurrentChar = szStr; // Initialize text pointer for rendering + zoom_x -= + iTotalWidth / 2; // Center text horizontally by subtracting half width + iStringDone = 0; // Initialize string completion flag + do { // Check if current character is not null terminator + if (*pbyCurrentChar) { // Check if character is not newline if (*pbyCurrentChar != '\n') { - iCharCode = *(uint8 *)pbyCurrentChar;// Get character code as unsigned byte - byFontIndex = mappingTable[iCharCode];// Look up font index in mapping table - if (byFontIndex == 0xFF) // Check if font index is invalid (0xFF) + iCharCode = + *(uint8 *)pbyCurrentChar; // Get character code as unsigned byte + byFontIndex = + mappingTable[iCharCode]; // Look up font index in mapping table + if (byFontIndex == 0xFF) // Check if font index is invalid (0xFF) { - dSpaceWidth = 512.0 / game_scale[iPlayerIdx] + (double)zoom_x;// Calculate space width and advance zoom X + dSpaceWidth = + 512.0 / game_scale[iPlayerIdx] + + (double)zoom_x; // Calculate space width and advance zoom X //_CHP(); - zoom_x = (int)dSpaceWidth; // Update global zoom X position + zoom_x = (int)dSpaceWidth; // Update global zoom X position } else { - iSavedZoomY = zoom_y; // Save current zoom Y position - zoom_y += pCharVOffsets[byFontIndex];// Adjust zoom Y by character vertical offset - zoom_letter(pBlockHeader, iCharCode, &zoom_x, &zoom_y, mappingTable, fZoomFactor);// Render the character with zoom scaling - zoom_y = iSavedZoomY; // Restore original zoom Y position + iSavedZoomY = zoom_y; // Save current zoom Y position + zoom_y += pCharVOffsets[byFontIndex]; // Adjust zoom Y by character + // vertical offset + zoom_letter(pBlockHeader, iCharCode, &zoom_x, &zoom_y, mappingTable, + fZoomFactor); // Render the character with zoom scaling + zoom_y = iSavedZoomY; // Restore original zoom Y position } } } else { - iStringDone = -1; // Set string done flag (null terminator found) + iStringDone = -1; // Set string done flag (null terminator found) } - ++pbyCurrentChar; // Move to next character in string - } while (!iStringDone); // Continue until string is complete + ++pbyCurrentChar; // Move to next character in string + } while (!iStringDone); // Continue until string is complete } } //------------------------------------------------------------------------------------------------- -//00017A10 -void ZoomSub(const char *szText, const char *mappingTable, tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets) -{ - double dZoomDivisor; // st7 - double dNewZoomY; // st7 - const char *pbyTextPtr; // eax - int iCharIndex; // edx - double dCharWidth; // st7 - double dNewTextWidth; // st7 - double dScaledWidth; // st7 +// 00017A10 +void ZoomSub(const char *szText, const char *mappingTable, + tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets) { + double dZoomDivisor; // st7 + double dNewZoomY; // st7 + const char *pbyTextPtr; // eax + int iCharIndex; // edx + double dCharWidth; // st7 + double dNewTextWidth; // st7 + double dScaledWidth; // st7 const char *pbyCurrentChar; // esi - int iCharCode; // edx - uint8 byFontIndex; // bl - double dSpaceWidth; // st7 - int iSavedZoomY; // [esp+4h] [ebp-24h] - float fZoomFactor; // [esp+10h] [ebp-18h] - int iStringDone; // [esp+14h] [ebp-14h] - int iTotalWidth; // [esp+18h] [ebp-10h] - - if (game_scale[iPlayerIdx] < 1024.0) { // Check for 2-player mode or cheat flag 0x40 - if (player_type == 2 || (cheat_mode & CHEAT_MODE_WIDESCREEN) != 0)// CHEAT_MODE_WIDESCREEN - zoom_x = 320; // Set zoom center X to 320 for 2-player/cheat mode + int iCharCode; // edx + uint8 byFontIndex; // bl + double dSpaceWidth; // st7 + int iSavedZoomY; // [esp+4h] [ebp-24h] + float fZoomFactor; // [esp+10h] [ebp-18h] + int iStringDone; // [esp+14h] [ebp-14h] + int iTotalWidth; // [esp+18h] [ebp-10h] + + if (game_scale[iPlayerIdx] < + 1024.0) { // Check for 2-player mode or cheat flag 0x40 + if (player_type == 2 || + (cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) // CHEAT_MODE_WIDESCREEN + zoom_x = 320; // Set zoom center X to 320 for 2-player/cheat mode else - zoom_x = 160; // Set zoom center X to 160 for single player - if (zoom_size[iPlayerIdx]) // Check zoom size setting for this player - dZoomDivisor = 2048.0; // Use 2048.0 divisor for large zoom + zoom_x = 160; // Set zoom center X to 160 for single player + if (zoom_size[iPlayerIdx]) // Check zoom size setting for this player + dZoomDivisor = 2048.0; // Use 2048.0 divisor for large zoom else - dZoomDivisor = 1024.0; // Use 1024.0 divisor for normal zoom - dNewZoomY = dZoomDivisor / game_scale[iPlayerIdx] + (double)zoom_y;// Calculate new zoom Y position with scaling + dZoomDivisor = 1024.0; // Use 1024.0 divisor for normal zoom + dNewZoomY = dZoomDivisor / game_scale[iPlayerIdx] + + (double)zoom_y; // Calculate new zoom Y position with scaling //_CHP(); - zoom_y = (int)dNewZoomY; // Update global zoom Y position + zoom_y = (int)dNewZoomY; // Update global zoom Y position - pbyTextPtr = szText; // MISSING compiler artifact + pbyTextPtr = szText; // MISSING compiler artifact - for (iTotalWidth = 0; *pbyTextPtr; iTotalWidth = (int)dNewTextWidth)// Calculate total text width for centering + for (iTotalWidth = 0; *pbyTextPtr; + iTotalWidth = + (int)dNewTextWidth) // Calculate total text width for centering { - iCharIndex = (uint8)mappingTable[*(uint8 *)pbyTextPtr];// Get font index for current character - if (iCharIndex == 255) // Check if character is invalid (255 = space) - dCharWidth = 512.0; // Use fixed 512.0 width for space character + iCharIndex = (uint8)mappingTable[*( + uint8 *)pbyTextPtr]; // Get font index for current character + if (iCharIndex == 255) // Check if character is invalid (255 = space) + dCharWidth = 512.0; // Use fixed 512.0 width for space character else - dCharWidth = (double)((pBlockHeader[iCharIndex].iWidth + 1) << 6);// Get character width from font data, add 1 pixel spacing - dNewTextWidth = dCharWidth / game_scale[iPlayerIdx] + (double)iTotalWidth;// Scale character width and accumulate total + dCharWidth = (double)((pBlockHeader[iCharIndex].iWidth + 1) + << 6); // Get character width from font data, add + // 1 pixel spacing + dNewTextWidth = + dCharWidth / game_scale[iPlayerIdx] + + (double)iTotalWidth; // Scale character width and accumulate total pbyTextPtr++; //_CHP(); } - if (iTotalWidth <= 310) // Check if total width fits within 310 pixels + if (iTotalWidth <= 310) // Check if total width fits within 310 pixels { - fZoomFactor = game_scale[iPlayerIdx]; // Use normal game scale factor + fZoomFactor = game_scale[iPlayerIdx]; // Use normal game scale factor } else { - dScaledWidth = (double)((iTotalWidth << 6) / 310);// Calculate compressed scale to fit in 310 pixels - iTotalWidth = 310; // Clamp total width to 310 pixels - fZoomFactor = (float)dScaledWidth; // Store compressed zoom factor + dScaledWidth = + (double)((iTotalWidth << 6) / + 310); // Calculate compressed scale to fit in 310 pixels + iTotalWidth = 310; // Clamp total width to 310 pixels + fZoomFactor = (float)dScaledWidth; // Store compressed zoom factor } - pbyCurrentChar = szText; // Initialize text pointer for rendering - zoom_x -= iTotalWidth / 2; // Center text horizontally by subtracting half width - iStringDone = 0; // Initialize string completion flag - do { // Check if current character is not null terminator - if (*pbyCurrentChar) { // Check if character is not newline (10) + pbyCurrentChar = szText; // Initialize text pointer for rendering + zoom_x -= + iTotalWidth / 2; // Center text horizontally by subtracting half width + iStringDone = 0; // Initialize string completion flag + do { // Check if current character is not null terminator + if (*pbyCurrentChar) { // Check if character is not newline (10) if (*pbyCurrentChar != '\n') { - iCharCode = *(uint8 *)pbyCurrentChar;// Get character code as unsigned byte - byFontIndex = mappingTable[iCharCode];// Look up font index in mapping table - if (byFontIndex == 0xFF) // Check if font index is invalid (0xFF) + iCharCode = + *(uint8 *)pbyCurrentChar; // Get character code as unsigned byte + byFontIndex = + mappingTable[iCharCode]; // Look up font index in mapping table + if (byFontIndex == 0xFF) // Check if font index is invalid (0xFF) { - dSpaceWidth = 512.0 / game_scale[iPlayerIdx] + (double)zoom_x;// Calculate space width and advance zoom X + dSpaceWidth = + 512.0 / game_scale[iPlayerIdx] + + (double)zoom_x; // Calculate space width and advance zoom X //_CHP(); - zoom_x = (int)dSpaceWidth; // Update global zoom X position + zoom_x = (int)dSpaceWidth; // Update global zoom X position } else { - iSavedZoomY = zoom_y; // Save current zoom Y position - zoom_y += pCharVOffsets[byFontIndex];// Adjust zoom Y by character vertical offset - zoom_letter(pBlockHeader, iCharCode, &zoom_x, &zoom_y, mappingTable, fZoomFactor);// Render the character with zoom scaling - zoom_y = iSavedZoomY; // Restore original zoom Y position + iSavedZoomY = zoom_y; // Save current zoom Y position + zoom_y += pCharVOffsets[byFontIndex]; // Adjust zoom Y by character + // vertical offset + zoom_letter(pBlockHeader, iCharCode, &zoom_x, &zoom_y, mappingTable, + fZoomFactor); // Render the character with zoom scaling + zoom_y = iSavedZoomY; // Restore original zoom Y position } } } else { - iStringDone = -1; // Set string done flag (null terminator found) + iStringDone = -1; // Set string done flag (null terminator found) } - ++pbyCurrentChar; // Move to next character in string - } while (!iStringDone); // Continue until string is complete + ++pbyCurrentChar; // Move to next character in string + } while (!iStringDone); // Continue until string is complete } } //------------------------------------------------------------------------------------------------- -//00017C10 -void zoom_letter(tBlockHeader *pBlockHeader, uint8 byCharCode, int *puiXPos, int *puiYPos, const char *mappingTable, float fZoomFactor) -{ - int byCharIndex; // esi - int iScreenWidth; // ebx - int iCharWidth; // edi - uint8 *pbyScreenPos; // ecx - int iXOffset; // edx - uint8 *pbyCharData; // eax - int iRow; // ebp - uint8 *pbyPixel; // esi - int iCol; // edx - int iScaledWidth; // eax - int *puiXPos_1; // edx - int iCharHeight; // [esp+Ch] [ebp-20h] - uint8 *pbyRowStart; // [esp+10h] [ebp-1Ch] +// 00017C10 +void zoom_letter(tBlockHeader *pBlockHeader, uint8 byCharCode, int *puiXPos, + int *puiYPos, const char *mappingTable, float fZoomFactor) { + int byCharIndex; // esi + int iScreenWidth; // ebx + int iCharWidth; // edi + uint8 *pbyScreenPos; // ecx + int iXOffset; // edx + uint8 *pbyCharData; // eax + int iRow; // ebp + uint8 *pbyPixel; // esi + int iCol; // edx + int iScaledWidth; // eax + int *puiXPos_1; // edx + int iCharHeight; // [esp+Ch] [ebp-20h] + uint8 *pbyRowStart; // [esp+10h] [ebp-1Ch] uint8 *pbyCharRowStart; // [esp+14h] [ebp-18h] - int iVertZoom; // [esp+18h] [ebp-14h] - int iHorizZoom; // [esp+1Ch] [ebp-10h] + int iVertZoom; // [esp+18h] [ebp-14h] + int iHorizZoom; // [esp+1Ch] [ebp-10h] - byCharIndex = (uint8)mappingTable[byCharCode];// Get character index from font table - if (byCharIndex == 255) // Check if character is invalid (255 = no character) + byCharIndex = + (uint8)mappingTable[byCharCode]; // Get character index from font table + if (byCharIndex == 255) // Check if character is invalid (255 = no character) { - *puiXPos += 8; // Advance X position by space width (8 pixels) - } else { // Check if using special ASCII conversion font + *puiXPos += 8; // Advance X position by space width (8 pixels) + } else { // Check if using special ASCII conversion font if (mappingTable == ascii_conv3) - iScreenWidth = 64; // Use fixed 64-pixel width for ASCII conversion + iScreenWidth = 64; // Use fixed 64-pixel width for ASCII conversion else - iScreenWidth = scr_size; // Use normal screen size for scaling - iCharWidth = pBlockHeader[byCharIndex].iWidth;// Get character width from font data (12-byte struct per char) - iCharHeight = pBlockHeader[byCharIndex].iHeight;// Get character height from font data (+4 offset) - - pbyCharData = (uint8 *)pBlockHeader + pBlockHeader[byCharIndex].iDataOffset; //MISSING decompiler artifact - - pbyScreenPos = &screen_pointer[winw * ((scr_size * *puiYPos) >> 6)];// Calculate screen position: Y offset with scaling - iXOffset = scr_size * *puiXPos; // Calculate X offset with scaling + iScreenWidth = scr_size; // Use normal screen size for scaling + iCharWidth = + pBlockHeader[byCharIndex].iWidth; // Get character width from font data + // (12-byte struct per char) + iCharHeight = + pBlockHeader[byCharIndex] + .iHeight; // Get character height from font data (+4 offset) + + pbyCharData = + (uint8 *)pBlockHeader + + pBlockHeader[byCharIndex].iDataOffset; // MISSING decompiler artifact + + pbyScreenPos = &screen_pointer[winw * ((scr_size * *puiYPos) >> + 6)]; // Calculate screen position: Y + // offset with scaling + iXOffset = scr_size * *puiXPos; // Calculate X offset with scaling //_CHP(); - iVertZoom = iScreenWidth; // Initialize vertical zoom counter - iRow = 0; // Initialize row counter - for (pbyPixel = &pbyScreenPos[iXOffset >> 6]; iRow < iCharHeight; pbyPixel = &pbyRowStart[winw])// Loop through each row of the character + iVertZoom = iScreenWidth; // Initialize vertical zoom counter + iRow = 0; // Initialize row counter + for (pbyPixel = &pbyScreenPos[iXOffset >> 6]; iRow < iCharHeight; + pbyPixel = + &pbyRowStart[winw]) // Loop through each row of the character { - iHorizZoom = iScreenWidth; // Reset horizontal zoom counter for this row + iHorizZoom = iScreenWidth; // Reset horizontal zoom counter for this row pbyRowStart = pbyPixel; pbyCharRowStart = pbyCharData; - iCol = 0; // Initialize column counter - while (iCol < iCharWidth) // Loop through each column of the character - { // Check if pixel is set in character data + iCol = 0; // Initialize column counter + while (iCol < iCharWidth) // Loop through each column of the character + { // Check if pixel is set in character data if (*pbyCharData) - *pbyPixel = *pbyCharData; // Copy pixel to screen buffer + *pbyPixel = *pbyCharData; // Copy pixel to screen buffer //_CHP(); - iHorizZoom = (int)((double)iHorizZoom - fZoomFactor);// Apply horizontal zoom scaling - ++pbyPixel; // Move to next screen pixel - for (; iHorizZoom <= 0; iHorizZoom += iScreenWidth)// Check if zoom counter requires advancing char data + iHorizZoom = (int)((double)iHorizZoom - + fZoomFactor); // Apply horizontal zoom scaling + ++pbyPixel; // Move to next screen pixel + for (; iHorizZoom <= 0; + iHorizZoom += + iScreenWidth) // Check if zoom counter requires advancing char data { - ++pbyCharData; // Advance to next character data pixel + ++pbyCharData; // Advance to next character data pixel ++iCol; } } //_CHP(); - iVertZoom = (int)((double)iVertZoom - fZoomFactor);// Apply vertical zoom scaling - for (pbyCharData = pbyCharRowStart; iVertZoom <= 0; iVertZoom += iScreenWidth)// Check if zoom counter requires advancing to next row + iVertZoom = + (int)((double)iVertZoom - fZoomFactor); // Apply vertical zoom scaling + for (pbyCharData = pbyCharRowStart; iVertZoom <= 0; + iVertZoom += + iScreenWidth) // Check if zoom counter requires advancing to next row { - ++iRow; // Move to next character row - pbyCharData += iCharWidth; // Skip to next row in character data + ++iRow; // Move to next character row + pbyCharData += iCharWidth; // Skip to next row in character data } } - if (mappingTable == ascii_conv3) // Handle different width calculation for ASCII conversion + if (mappingTable == + ascii_conv3) // Handle different width calculation for ASCII conversion { - iScaledWidth = ((int)((double)(iCharWidth << 6) / fZoomFactor) << 6) / scr_size;// Calculate scaled width with screen size division + iScaledWidth = + ((int)((double)(iCharWidth << 6) / fZoomFactor) << 6) / + scr_size; // Calculate scaled width with screen size division puiXPos_1 = puiXPos; } else { puiXPos_1 = puiXPos; - iScaledWidth = (int)((double)(iCharWidth << 6) / fZoomFactor);// Calculate scaled width without screen size division + iScaledWidth = (int)((double)(iCharWidth << 6) / + fZoomFactor); // Calculate scaled width without + // screen size division } - *puiXPos_1 += iScaledWidth; // Advance X position by calculated character width + *puiXPos_1 += + iScaledWidth; // Advance X position by calculated character width } } //------------------------------------------------------------------------------------------------- -//00017DA0 -void print_block(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx) -{ - int iScreenSize; // edi - int iRowScaleAccum; // ebp +// 00017DA0 +void print_block(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx) { + int iScreenSize; // edi + int iRowScaleAccum; // ebp uint8 *pszSourceData; // ebx int iFullBytesPerRow; // ebp int iRemainingPixels; // edx - int j; // eax - uint8 byPixel; // cl - uint8 *pszSrc1; // ebx - uint8 *pszDest1; // esi - uint8 byPixel1; // cl - uint8 *pszSrc2; // ebx - uint8 *pbyDest2; // esi - uint8 byPixel2; // cl - uint8 *pszSrc3; // ebx - uint8 *pbyDest3; // esi - uint8 byPixel3; // cl - char *pszSrc4; // ebx - uint8 *pbyDest4; // esi - uint8 byPixel4; // cl - char *pszSrc5; // ebx - uint8 *pbyDest5; // esi - uint8 byPixel5; // cl - char *pszSrc6; // ebx - uint8 *pbyDest6; // esi - uint8 byPixel6; // cl - uint8 *pszSrc7; // ebx - uint8 *pbyDest7; // esi - uint8 byPixel7; // cl - int k; // eax - uint8 byRemPixel; // cl - int iColScaleAccum; // eax - int iXPos; // edx - int iWidth; // [esp+0h] [ebp-28h] - uint8 *pszRowStart; // [esp+4h] [ebp-24h] - uint8 *pszDestRow; // [esp+8h] [ebp-20h] - int iHeight; // [esp+Ch] [ebp-1Ch] - int i; // [esp+10h] [ebp-18h] - int m; // [esp+14h] [ebp-14h] - - iScreenSize = scr_size; // Store current screen scaling size - iWidth = pBlockHeader[iBlockIdx].iWidth; // Extract block dimensions from header + int j; // eax + uint8 byPixel; // cl + uint8 *pszSrc1; // ebx + uint8 *pszDest1; // esi + uint8 byPixel1; // cl + uint8 *pszSrc2; // ebx + uint8 *pbyDest2; // esi + uint8 byPixel2; // cl + uint8 *pszSrc3; // ebx + uint8 *pbyDest3; // esi + uint8 byPixel3; // cl + char *pszSrc4; // ebx + uint8 *pbyDest4; // esi + uint8 byPixel4; // cl + char *pszSrc5; // ebx + uint8 *pbyDest5; // esi + uint8 byPixel5; // cl + char *pszSrc6; // ebx + uint8 *pbyDest6; // esi + uint8 byPixel6; // cl + uint8 *pszSrc7; // ebx + uint8 *pbyDest7; // esi + uint8 byPixel7; // cl + int k; // eax + uint8 byRemPixel; // cl + int iColScaleAccum; // eax + int iXPos; // edx + int iWidth; // [esp+0h] [ebp-28h] + uint8 *pszRowStart; // [esp+4h] [ebp-24h] + uint8 *pszDestRow; // [esp+8h] [ebp-20h] + int iHeight; // [esp+Ch] [ebp-1Ch] + int i; // [esp+10h] [ebp-18h] + int m; // [esp+14h] [ebp-14h] + + iScreenSize = scr_size; // Store current screen scaling size + iWidth = + pBlockHeader[iBlockIdx].iWidth; // Extract block dimensions from header iHeight = pBlockHeader[iBlockIdx].iHeight; iRowScaleAccum = scr_size; - pszSourceData = (uint8 *)pBlockHeader + pBlockHeader[iBlockIdx].iDataOffset;// Calculate pointer to block pixel data - if (scr_size == 64) // Branch: 64 = 1:1 pixel mode, else = scaled mode + pszSourceData = (uint8 *)pBlockHeader + + pBlockHeader[iBlockIdx] + .iDataOffset; // Calculate pointer to block pixel data + if (scr_size == 64) // Branch: 64 = 1:1 pixel mode, else = scaled mode { - iFullBytesPerRow = iWidth / 8; // Number of complete 8-pixel chunks per row - //iFullBytesPerRow = (iWidth - (__CFSHL__(iWidth >> 31, 3) + 8 * (iWidth >> 31))) >> 3;// Calculate 8-pixel chunks per row (optimized copying) - iRemainingPixels = iWidth % 8; // Calculate remaining pixels after 8-pixel chunks - for (i = 0; i < iHeight; ++i) // Process each row of the block - { // Process 8-pixel chunks for efficiency (unrolled loop) + iFullBytesPerRow = iWidth / 8; // Number of complete 8-pixel chunks per row + // iFullBytesPerRow = (iWidth - (__CFSHL__(iWidth >> 31, 3) + 8 * (iWidth >> + // 31))) >> 3;// Calculate 8-pixel chunks per row (optimized copying) + iRemainingPixels = + iWidth % 8; // Calculate remaining pixels after 8-pixel chunks + for (i = 0; i < iHeight; ++i) // Process each row of the block + { // Process 8-pixel chunks for efficiency (unrolled loop) for (j = 0; j < iFullBytesPerRow; pDest = pbyDest7 + 1) { - byPixel = *pszSourceData; // Copy 8 pixels in sequence, skipping transparent (0) pixels + byPixel = *pszSourceData; // Copy 8 pixels in sequence, skipping + // transparent (0) pixels pszSrc1 = pszSourceData + 1; if (byPixel) *pDest = byPixel; @@ -1518,35 +1656,39 @@ void print_block(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx) *pbyDest7 = byPixel7; ++j; } - for (k = 0; k < iRemainingPixels; ++pDest)// Handle remaining pixels (width % 8) + for (k = 0; k < iRemainingPixels; + ++pDest) // Handle remaining pixels (width % 8) { byRemPixel = *pszSourceData++; if (byRemPixel) *pDest = byRemPixel; ++k; } - pDest += winw - iWidth; // Advance to next row (skip to start of next line) + pDest += + winw - iWidth; // Advance to next row (skip to start of next line) } - } else { // Scaled rendering mode - complex pixel interpolation + } else { // Scaled rendering mode - complex pixel interpolation for (m = 0; iHeight > m; pDest = &pszDestRow[winw]) { - iColScaleAccum = iScreenSize; // Process each row with scaling + iColScaleAccum = iScreenSize; // Process each row with scaling pszDestRow = pDest; pszRowStart = pszSourceData; iXPos = 0; - while (iXPos < iWidth) // Process each column with horizontal scaling - { // Copy non-transparent pixels only + while (iXPos < iWidth) // Process each column with horizontal scaling + { // Copy non-transparent pixels only if (*pszSourceData) *pDest = *pszSourceData; - iColScaleAccum -= 64; // Update column scaling accumulator + iColScaleAccum -= 64; // Update column scaling accumulator ++pDest; - for (; iColScaleAccum <= 0; ++iXPos) // When accumulator depleted, advance source pixel + for (; iColScaleAccum <= 0; + ++iXPos) // When accumulator depleted, advance source pixel { ++pszSourceData; iColScaleAccum += iScreenSize; } } - iRowScaleAccum -= 64; // Update row scaling accumulator - for (pszSourceData = pszRowStart; iRowScaleAccum <= 0; ++m)// When row accumulator depleted, advance to next source row + iRowScaleAccum -= 64; // Update row scaling accumulator + for (pszSourceData = pszRowStart; iRowScaleAccum <= 0; + ++m) // When row accumulator depleted, advance to next source row { pszSourceData += iWidth; iRowScaleAccum += iScreenSize; @@ -1557,67 +1699,77 @@ void print_block(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx) } //------------------------------------------------------------------------------------------------- -//00017F30 -void print_damage(uint8 *pDest, tBlockHeader *pBlockHeader, int iCarIdx) -{ - int iScreenSize; // esi - int iViewType; // ecx - double dRPMBar; // st7 +// 00017F30 +void print_damage(uint8 *pDest, tBlockHeader *pBlockHeader, int iCarIdx) { + int iScreenSize; // esi + int iViewType; // ecx + double dRPMBar; // st7 uint8 *pbySourceData; // edx - double dDamage; // st7 - int iScreenSizeTemp; // esi - int j; // eax - uint8 byPixel; // cl - int iScaleAccum; // eax - int iXPos; // ebx - uint8 *pbyRowStart; // [esp+0h] [ebp-38h] - int k; // [esp+4h] [ebp-34h] - int iWidth; // [esp+8h] [ebp-30h] - int iRowScaleAccum; // [esp+Ch] [ebp-2Ch] - int iHeight; // [esp+10h] [ebp-28h] - int i; // [esp+14h] [ebp-24h] - int iRPMBar; // [esp+18h] [ebp-20h] - int iDamage; // [esp+1Ch] [ebp-1Ch] - uint8 *pbyDestPixel; // [esp+20h] [ebp-18h] + double dDamage; // st7 + int iScreenSizeTemp; // esi + int j; // eax + uint8 byPixel; // cl + int iScaleAccum; // eax + int iXPos; // ebx + uint8 *pbyRowStart; // [esp+0h] [ebp-38h] + int k; // [esp+4h] [ebp-34h] + int iWidth; // [esp+8h] [ebp-30h] + int iRowScaleAccum; // [esp+Ch] [ebp-2Ch] + int iHeight; // [esp+10h] [ebp-28h] + int i; // [esp+14h] [ebp-24h] + int iRPMBar; // [esp+18h] [ebp-20h] + int iDamage; // [esp+1Ch] [ebp-1Ch] + uint8 *pbyDestPixel; // [esp+20h] [ebp-18h] uint8 byCurrentPixel; // [esp+24h] [ebp-14h] - iScreenSize = scr_size; // Get current screen/sprite scaling size - iViewType = ViewType[iCarIdx]; // Get view type for the specified car + iScreenSize = scr_size; // Get current screen/sprite scaling size + iViewType = ViewType[iCarIdx]; // Get view type for the specified car dRPMBar = Car[iViewType].fRPMRatio * 48.0; //_CHP(); iRPMBar = (int)dRPMBar; - iWidth = pBlockHeader->iWidth; // Extract sprite dimensions from sprite data header + iWidth = + pBlockHeader->iWidth; // Extract sprite dimensions from sprite data header iHeight = pBlockHeader->iHeight; iRowScaleAccum = iScreenSize; - pbySourceData = (uint8 *)pBlockHeader + pBlockHeader->iDataOffset;// Get pointer to sprite pixel data (header + offset) - if (Car[iViewType].fHealth <= 0.0) // Check if car is destroyed (health <= 0) + pbySourceData = + (uint8 *)pBlockHeader + + pBlockHeader + ->iDataOffset; // Get pointer to sprite pixel data (header + offset) + if (Car[iViewType].fHealth <= 0.0) // Check if car is destroyed (health <= 0) { - iDamage = 13; // Car is destroyed - use maximum damage level (13) + iDamage = 13; // Car is destroyed - use maximum damage level (13) } else { - dDamage = (100.0 - Car[iViewType].fHealth) * 0.01 * 13.0;// Calculate damage level: (100-health)% * 13 damage levels + dDamage = (100.0 - Car[iViewType].fHealth) * 0.01 * + 13.0; // Calculate damage level: (100-health)% * 13 damage levels //_CHP(); iDamage = (int)dDamage; } do_blip(iCarIdx); - if (iScreenSize == 64) // Check if using 64-pixel scaling (1:1 pixel copy mode) + if (iScreenSize == + 64) // Check if using 64-pixel scaling (1:1 pixel copy mode) { iScreenSizeTemp = scr_size; - for (i = 0; i < iHeight; pDest += winw - iWidth)// 1:1 scaling - simple row-by-row pixel copy loop - { // Copy each pixel in the current row + for (i = 0; i < iHeight; + pDest += + winw - iWidth) // 1:1 scaling - simple row-by-row pixel copy loop + { // Copy each pixel in the current row for (j = 0; j < iWidth; ++pDest) { - byPixel = *pbySourceData++; // Read source pixel and advance pointer - if (byPixel) // Skip transparent pixels (value 0) - { // Check if pixel is damage-mappable (>= 0x31 = 49) - if (byPixel >= 0x31u) { // Apply damage mapping if damage level allows it + byPixel = *pbySourceData++; // Read source pixel and advance pointer + if (byPixel) // Skip transparent pixels (value 0) + { // Check if pixel is damage-mappable (>= 0x31 = 49) + if (byPixel >= + 0x31u) { // Apply damage mapping if damage level allows it if (iDamage >= dam_remap[byPixel]) *pDest = byPixel; else - *pDest = 0x7B; // Use default damaged color if damage too low (0x7B is grey) - } else if (byPixel > iRPMBar) // For non-damage pixels, check zoom threshold + *pDest = 0x7B; // Use default damaged color if damage too low + // (0x7B is grey) + } else if (byPixel > + iRPMBar) // For non-damage pixels, check zoom threshold { - *pDest = 0xED; // 0xED = dark blue in PALETTE.PAL + *pDest = 0xED; // 0xED = dark blue in PALETTE.PAL } else { - *pDest = 0xF3; // 0xF3 = blue in PALETTE.PAL + *pDest = 0xF3; // 0xF3 = blue in PALETTE.PAL } } ++j; @@ -1625,38 +1777,44 @@ void print_damage(uint8 *pDest, tBlockHeader *pBlockHeader, int iCarIdx) ++i; } } else { - iScreenSizeTemp = scr_size; // Scaled rendering mode - more complex pixel interpolation - for (k = 0; k < iHeight; pDest = &pbyDestPixel[winw])// Process each row of the scaled sprite + iScreenSizeTemp = + scr_size; // Scaled rendering mode - more complex pixel interpolation + for (k = 0; k < iHeight; + pDest = &pbyDestPixel[winw]) // Process each row of the scaled sprite { iScaleAccum = iScreenSizeTemp; pbyDestPixel = pDest; pbyRowStart = pbySourceData; iXPos = 0; - while (iXPos < iWidth) // Process each column in the current row + while (iXPos < iWidth) // Process each column in the current row { byCurrentPixel = *pbySourceData; - if (*pbySourceData) { // Same damage mapping logic as 1:1 mode + if (*pbySourceData) { // Same damage mapping logic as 1:1 mode if (*pbySourceData >= 0x31u) { if (iDamage >= dam_remap[byCurrentPixel]) *pDest = byCurrentPixel; else - *pDest = 0x7B; // 0x7B = grey + *pDest = 0x7B; // 0x7B = grey } else if (byCurrentPixel > iRPMBar) { - *pDest = 0xED; // 0xED = dark blue + *pDest = 0xED; // 0xED = dark blue } else { - *pDest = 0xF3; // 0xF3 = blue + *pDest = 0xF3; // 0xF3 = blue } } - iScaleAccum -= 64; // Advance scaling accumulator and destination pixel + iScaleAccum -= 64; // Advance scaling accumulator and destination pixel ++pDest; - for (; iScaleAccum <= 0; ++iXPos) // When scale accumulator depleted, advance source pixel + for (; iScaleAccum <= 0; + ++iXPos) // When scale accumulator depleted, advance source pixel { ++pbySourceData; iScaleAccum += iScreenSizeTemp; } } - pbySourceData = pbyRowStart; // Reset source pointer to start of current row - for (iRowScaleAccum -= 64; iRowScaleAccum <= 0; ++k)// When row scale accumulator depleted, advance to next source row + pbySourceData = + pbyRowStart; // Reset source pointer to start of current row + for (iRowScaleAccum -= 64; iRowScaleAccum <= 0; + ++k) // When row scale accumulator depleted, advance to next source + // row { pbySourceData += iWidth; iRowScaleAccum += iScreenSizeTemp; @@ -1667,39 +1825,38 @@ void print_damage(uint8 *pDest, tBlockHeader *pBlockHeader, int iCarIdx) } //------------------------------------------------------------------------------------------------- -//00018130 -void print_pos(int iX, int iY, int iDriverIdx) -{ +// 00018130 +void print_pos(int iX, int iY, int iDriverIdx) { if (iDriverIdx >= 0 && iDriverIdx < racers) { - mini_prt_string(rev_vga[0], &language_buffer[64 * iDriverIdx + 384], iX, iY); + mini_prt_string(rev_vga[0], &language_buffer[64 * iDriverIdx + 384], iX, + iY); mini_prt_right(rev_vga[0], driver_names[carorder[iDriverIdx]], iX + 70, iY); } } //------------------------------------------------------------------------------------------------- -//00018190 -void free_game_memory() -{ - fre((void**)&building_vga); - fre((void**)&horizon_vga); +// 00018190 +void free_game_memory() { + fre((void **)&building_vga); + fre((void **)&horizon_vga); for (int i = 0; i < 16; ++i) { - fre((void**)&cartex_vga[i]); - fre((void**)&rev_vga[i]); + fre((void **)&cartex_vga[i]); + fre((void **)&rev_vga[i]); } - fre((void**)&cargen_vga); + fre((void **)&cargen_vga); remove_mapsels(); - fre((void**)&mirbuf); + fre((void **)&mirbuf); } //------------------------------------------------------------------------------------------------- -//00018200 -int readmode() -{ +// 00018200 +int readmode() { return 0; /* REGS regs; // [esp+0h] [ebp-24h] BYREF - // int386 calling interrupt 0x10 (16 in decimal) which is the BIOS video services interrupt. + // int386 calling interrupt 0x10 (16 in decimal) which is the BIOS video + services interrupt. // because regs.h.ah = 15;, it asks for the current video mode. // current video mode is returned in regs.h.al regs.h.ah = 15; @@ -1708,16 +1865,15 @@ int readmode() } //------------------------------------------------------------------------------------------------- -//00018250 -void key_handler(uint8 byScancode) -{ +// 00018250 +void key_handler(uint8 byScancode) { // Handle key press/release if (byScancode & 0x80) { // Key release uint8 byCode = byScancode & 0x7F; keys[byCode] = 0; } else { - // Key press + // Key press keys[byScancode] = 1; // Pause sequence detection @@ -1726,8 +1882,7 @@ void key_handler(uint8 byScancode) zoom_ascii_variable_2 = zoom_ascii_variable_3; zoom_ascii_variable_3 = byScancode; - if (zoom_ascii_variable_1 == 0xE1 && - zoom_ascii_variable_2 == 0x1D && + if (zoom_ascii_variable_1 == 0xE1 && zoom_ascii_variable_2 == 0x1D && zoom_ascii_variable_3 == 0x45) { pause_request = 0xFFFFFFFF; } @@ -1743,7 +1898,7 @@ void key_handler(uint8 byScancode) } else { // Normal keys uint32 uiNext = (write_key + 1) % 64; - if (uiNext != read_key) { // Only store if buffer not full + if (uiNext != read_key) { // Only store if buffer not full key_buffer[write_key] = byScancode; write_key = uiNext; } @@ -1752,17 +1907,15 @@ void key_handler(uint8 byScancode) } //------------------------------------------------------------------------------------------------- -//00018370 -void claim_key_int() -{ +// 00018370 +void claim_key_int() { //_prev_int_9 = dos_getvect(9); // Save current INT 9 handler - //dos_setvect(9, key_handler_); + // dos_setvect(9, key_handler_); } //------------------------------------------------------------------------------------------------- -//000183A0 -int fatkbhit() -{ +// 000183A0 +int fatkbhit() { if (write_key == read_key && !twoparter) return read_key ^ write_key; else @@ -1770,22 +1923,21 @@ int fatkbhit() } //------------------------------------------------------------------------------------------------- -//000183D0 -int fatgetch() -{ +// 000183D0 +int fatgetch() { int iTwoParter; // edx - int iResult; // eax + int iResult; // eax iTwoParter = twoparter; // If we have a stored key part from a previous call if (twoparter) { iResult = twoparter; - iTwoParter = 0; // clear stored value + iTwoParter = 0; // clear stored value } else { // Wait until keys are available in the buffer while (write_key == read_key) - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER // Read next scancode from buffer and get mapped character int iTestReadKey = read_key++; @@ -1800,27 +1952,26 @@ int fatgetch() // Handle special keys if (iResult < 0) { - iTwoParter = -iResult; // Convert to positive value - iResult = 0; // Return 0 for this call, special key value will be returned next call + iTwoParter = -iResult; // Convert to positive value + iResult = 0; // Return 0 for this call, special key value will be returned + // next call } } - twoparter = iTwoParter; // Store special key for next call + twoparter = iTwoParter; // Store special key for next call return iResult; } //------------------------------------------------------------------------------------------------- -//00018430 -void release_key_int() -{ - //dos_setvect(9, _prev_int_9); +// 00018430 +void release_key_int() { + // dos_setvect(9, _prev_int_9); } //------------------------------------------------------------------------------------------------- -//00018450 -void clear_border(int x, int y, int iWidth, int iLines) -{ - //added by ROLLER - // During gameplay, game_render_end_frame handles presentation +// 00018450 +void clear_border(int x, int y, int iWidth, int iLines) { + // added by ROLLER + // During gameplay, game_render_end_frame handles presentation if (!g_pGameRenderer) UpdateSDLWindow(); return; @@ -1828,7 +1979,7 @@ void clear_border(int x, int y, int iWidth, int iLines) int iOldWinX; // edi int iOldWinY; // ebp int iOldWinH; // esi - int iLine; // ebx + int iLine; // ebx int iOldWinW; // [esp+0h] [ebp-10h] iOldWinX = winx; @@ -1856,38 +2007,36 @@ void clear_border(int x, int y, int iWidth, int iLines) } //------------------------------------------------------------------------------------------------- -//000184E0 -void DisplayFree() -{ - //DPMI_MemInfo memInfo; // [esp+0h] [ebp-88h] BYREF - //union REGS regs; // [esp+50h] [ebp-38h] BYREF - //struct SREGS sregs; // [esp+6Ch] [ebp-1Ch] BYREF +// 000184E0 +void DisplayFree() { + // DPMI_MemInfo memInfo; // [esp+0h] [ebp-88h] BYREF + // union REGS regs; // [esp+50h] [ebp-38h] BYREF + // struct SREGS sregs; // [esp+6Ch] [ebp-1Ch] BYREF // - //memset(&sregs, 0, sizeof(sregs)); - //regs.x.eax = 0x500; - //sregs.es = __DS__; - //regs.x.edi = (unsigned int)&memInfo; - //int386x(0x31, ®s, ®s, &sregs); - //printf("\nLargest block: %d\n", memInfo.largestFreeBlock); - //printf("Total free : %d\n\n", memInfo.freeLinearPages << 12); - //no_mem = 0; - //lots_of_mem = 0; - //if ((int)(memInfo.freeLinearPages << 12) >= 4500000) { - // printf("RUNNING 8 MEG VERSION.\n"); - // gfx_size = 0; - // lots_of_mem = -1; - //} else { - // printf("RUNNING 4 MEG VERSION.\n"); - // gfx_size = 1; - // if ((int)(memInfo.freeLinearPages << 12) < 2000000) - // no_mem = -1; - //} + // memset(&sregs, 0, sizeof(sregs)); + // regs.x.eax = 0x500; + // sregs.es = __DS__; + // regs.x.edi = (unsigned int)&memInfo; + // int386x(0x31, ®s, ®s, &sregs); + // printf("\nLargest block: %d\n", memInfo.largestFreeBlock); + // printf("Total free : %d\n\n", memInfo.freeLinearPages << 12); + // no_mem = 0; + // lots_of_mem = 0; + // if ((int)(memInfo.freeLinearPages << 12) >= 4500000) { + // printf("RUNNING 8 MEG VERSION.\n"); + // gfx_size = 0; + // lots_of_mem = -1; + // } else { + // printf("RUNNING 4 MEG VERSION.\n"); + // gfx_size = 1; + // if ((int)(memInfo.freeLinearPages << 12) < 2000000) + // no_mem = -1; + // } } //------------------------------------------------------------------------------------------------- -//000185C0 -void setdirectory(const char *szAppPath) -{ +// 000185C0 +void setdirectory(const char *szAppPath) { char szLocalDir[256]; if (szAppPath) { @@ -1900,16 +2049,17 @@ void setdirectory(const char *szAppPath) // Trim trailing slashes size_t lenLocalDir = strlen(szLocalDir); - while (lenLocalDir > 0 && szLocalDir[lenLocalDir - 1] == '/' || szLocalDir[lenLocalDir - 1] == '\\') { + while (lenLocalDir > 0 && szLocalDir[lenLocalDir - 1] == '/' || + szLocalDir[lenLocalDir - 1] == '\\') { lenLocalDir -= 1; } szLocalDir[lenLocalDir] = '\0'; #ifdef IS_WINDOWS // Set current drive based on first letter of path (e.g., 'C' -> drive 3) - char cDriveLetter = szLocalDir[0] & 0xDF; // Convert to uppercase - int iDrive = (int)(cDriveLetter - 'A' + 1); // 'A' => 1, 'C' => 3, etc. - //dos_setdrive(iDrive, 0); + char cDriveLetter = szLocalDir[0] & 0xDF; // Convert to uppercase + int iDrive = (int)(cDriveLetter - 'A' + 1); // 'A' => 1, 'C' => 3, etc. + // dos_setdrive(iDrive, 0); _chdrive(iDrive); #endif @@ -1918,29 +2068,28 @@ void setdirectory(const char *szAppPath) // set dir to FATDATA if (chdir("FATDATA") != 0) - chdir("fatdata"); //linux compatibility + chdir("fatdata"); // linux compatibility } //------------------------------------------------------------------------------------------------- -//00018640 -void FindShades() -{ - int iR; // ecx - int iB; // edi - int iG; // esi +// 00018640 +void FindShades() { + int iR; // ecx + int iB; // edi + int iG; // esi int iColorOffset; // ebp - int iR2; // esi - int iB2; // edx - int iDeltaR; // edi - int iG2; // ebx - int iDeltaB; // ecx - int iDeltaG; // eax - int iMaxOffset; // [esp+0h] [ebp-34h] - int iColorIdx; // [esp+4h] [ebp-30h] - int iColor; // [esp+8h] [ebp-2Ch] - int iStepB; // [esp+Ch] [ebp-28h] - int iStepG; // [esp+10h] [ebp-24h] - int iStepR; // [esp+18h] [ebp-1Ch] + int iR2; // esi + int iB2; // edx + int iDeltaR; // edi + int iG2; // ebx + int iDeltaB; // ecx + int iDeltaG; // eax + int iMaxOffset; // [esp+0h] [ebp-34h] + int iColorIdx; // [esp+4h] [ebp-30h] + int iColor; // [esp+8h] [ebp-2Ch] + int iStepB; // [esp+Ch] [ebp-28h] + int iStepG; // [esp+10h] [ebp-24h] + int iStepR; // [esp+18h] [ebp-1Ch] iColorIdx = 1; iMaxOffset = 1025; @@ -1969,13 +2118,13 @@ void FindShades() if (iG < 0) iG = 0; shade_palette[iColorOffset] = nearest_colour(iR, iB, iG); - iColorOffset += 256; // Move to next shade block (256-byte stride) + iColorOffset += 256; // Move to next shade block (256-byte stride) } while (iColorOffset != iMaxOffset); // Generate special blend shade using color 0xDB as reference iR2 = palette[iColor].byR; iB2 = palette[iColor].byB; - iDeltaR = palette[0xDB].byR - iR2; // teal in PALETTE.PAL + iDeltaR = palette[0xDB].byR - iR2; // teal in PALETTE.PAL iG2 = palette[iColor].byG; // Clamp deltas to [-15, 15] @@ -1995,18 +2144,18 @@ void FindShades() iDeltaG = 15; // Store in Block 4 (overwriting last progressive shade) - shade_palette[iColorIdx++ + 0x400] = nearest_colour(iDeltaR + iR2, iDeltaB + iB2, iDeltaG + iG2); + shade_palette[iColorIdx++ + 0x400] = + nearest_colour(iDeltaR + iR2, iDeltaB + iB2, iDeltaG + iG2); ++iColor; ++iMaxOffset; } while (iColorIdx < 256); } //------------------------------------------------------------------------------------------------- -//000187C0 -int nearest_colour(int iR, int iB, int iG) -{ +// 000187C0 +int nearest_colour(int iR, int iB, int iG) { int iBestIndex = 0; - int iBestDistance = 1024; // large initial value + int iBestDistance = 1024; // large initial value int rDiff, bDiff, gDiff; int iDistance; @@ -2027,48 +2176,53 @@ int nearest_colour(int iR, int iB, int iG) } //------------------------------------------------------------------------------------------------- -//00018860 -void select_view(int iPlayer) -{ - int iCurrentViewIndex; // ebx - int iPlayerIndex; // eax +// 00018860 +void select_view(int iPlayer) { + int iCurrentViewIndex; // ebx + int iPlayerIndex; // eax int iViewIndexForDrive; // edx - int iDriveType; // ebx - - iCurrentViewIndex = SelectedView[iPlayer]; // Get the selected view index for this player - if (iCurrentViewIndex == 2 || iCurrentViewIndex == 7)// Check if view is cockpit (2) or external (7) - these require screen size adjustment - { // Set screen size based on graphics mode - SVGA gets larger screen + int iDriveType; // ebx + + iCurrentViewIndex = + SelectedView[iPlayer]; // Get the selected view index for this player + if (iCurrentViewIndex == 2 || + iCurrentViewIndex == 7) // Check if view is cockpit (2) or external (7) - + // these require screen size adjustment + { // Set screen size based on graphics mode - SVGA gets larger screen if (SVGA_ON) scr_size = 128; else scr_size = 64; } - iPlayerIndex = iPlayer; // Look up drive configuration for selected view + iPlayerIndex = iPlayer; // Look up drive configuration for selected view iViewIndexForDrive = SelectedView[iPlayerIndex]; iDriveType = Selected_Drives[iViewIndexForDrive]; SET_LOBYTE(iViewIndexForDrive, Selected_Play[iViewIndexForDrive]); DriveView[iPlayerIndex] = iDriveType; Play_View = iViewIndexForDrive; - if (iDriveType == 5) // Drive type 5: Chase camera - enable chase view and switch to drive type 2 + if (iDriveType == 5) // Drive type 5: Chase camera - enable chase view and + // switch to drive type 2 { chaseview[iPlayerIndex] = 1; DriveView[iPlayerIndex] = 2; - } else if (iDriveType == 2) // Drive type 2: Standard view - disable chase camera + } else if (iDriveType == + 2) // Drive type 2: Standard view - disable chase camera { chaseview[iPlayerIndex] = 0; } - if ((cheat_mode & CHEAT_MODE_WIDESCREEN) != 0) // CHEAT_MODE_WIDESCREEN: clear screen borders for full display + if ((cheat_mode & CHEAT_MODE_WIDESCREEN) != + 0) // CHEAT_MODE_WIDESCREEN: clear screen borders for full display clear_borders = -1; } //------------------------------------------------------------------------------------------------- -//00018910 -void mini_prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) -{ - int iDone; // ebp +// 00018910 +void mini_prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY) { + int iDone; // ebp int iSavedYPos; // [esp+0h] [ebp-18h] - int iYPos; // [esp+4h] [ebp-14h] BYREF - int iXPos; // [esp+8h] [ebp-10h] BYREF + int iYPos; // [esp+4h] [ebp-14h] BYREF + int iXPos; // [esp+8h] [ebp-10h] BYREF iDone = 0; iXPos = (scr_size * iX) >> 6; @@ -2090,13 +2244,13 @@ void mini_prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int } //------------------------------------------------------------------------------------------------- -//00018990 -void mini_prt_string_rev(tBlockHeader *pBlockHeader, const char *szText, int iX, int iY) -{ - int iDone; // ebp +// 00018990 +void mini_prt_string_rev(tBlockHeader *pBlockHeader, const char *szText, int iX, + int iY) { + int iDone; // ebp int iSavedYPos; // [esp+0h] [ebp-18h] - int piYPos; // [esp+4h] [ebp-14h] BYREF - int piXPos; // [esp+8h] [ebp-10h] BYREF + int piYPos; // [esp+4h] [ebp-14h] BYREF + int piXPos; // [esp+8h] [ebp-10h] BYREF iDone = 0; piXPos = (scr_size * iX) >> 6; @@ -2118,16 +2272,16 @@ void mini_prt_string_rev(tBlockHeader *pBlockHeader, const char *szText, int iX, } //------------------------------------------------------------------------------------------------- -//00018A10 -void mini_prt_right(tBlockHeader *pBlockHeader, const char *szText, int iX, int iY) -{ - const char *i; // esi - int iCharIdx; // eax +// 00018A10 +void mini_prt_right(tBlockHeader *pBlockHeader, const char *szText, int iX, + int iY) { + const char *i; // esi + int iCharIdx; // eax const char *pCurrChar; // esi - int iDone; // ebp - int iSavedYPos; // [esp+0h] [ebp-18h] - int iYPos; // [esp+4h] [ebp-14h] BYREF - int iXPos; // [esp+8h] [ebp-10h] BYREF + int iDone; // ebp + int iSavedYPos; // [esp+0h] [ebp-18h] + int iYPos; // [esp+4h] [ebp-14h] BYREF + int iXPos; // [esp+8h] [ebp-10h] BYREF iXPos = iX; iYPos = iY; @@ -2159,56 +2313,66 @@ void mini_prt_right(tBlockHeader *pBlockHeader, const char *szText, int iX, int } //------------------------------------------------------------------------------------------------- -//00018AE0 -void mini_prt_centre(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) -{ - const char *i; // esi - int iCharIdx; // eax +// 00018AE0 +void mini_prt_centre(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY) { + const char *i; // esi + int iCharIdx; // eax const char *pCharItr; // esi - int iDone; // ebp - int iSavedYPos; // [esp+0h] [ebp-18h] - int iYPos; // [esp+4h] [ebp-14h] BYREF - int iXPos; // [esp+8h] [ebp-10h] BYREF + int iDone; // ebp + int iSavedYPos; // [esp+0h] [ebp-18h] + int iYPos; // [esp+4h] [ebp-14h] BYREF + int iXPos; // [esp+8h] [ebp-10h] BYREF - iXPos = iX; // Initialize position variables from parameters + iXPos = iX; // Initialize position variables from parameters iYPos = iY; - for (i = szStr; *i; ++i) // First pass: calculate total text width for centering + for (i = szStr; *i; + ++i) // First pass: calculate total text width for centering { - iCharIdx = (uint8)ascii_conv3[*(uint8 *)i];// Get character index from ascii_conv3 table (mini font) - if (iCharIdx == 255) // Space character: subtract 4 pixels from X position + iCharIdx = (uint8)ascii_conv3[*( + uint8 *)i]; // Get character index from ascii_conv3 table (mini font) + if (iCharIdx == 255) // Space character: subtract 4 pixels from X position iXPos -= 4; else - iXPos -= pBlockHeader[iCharIdx].iWidth / 2;// Regular character: subtract half character width for centering calculation + iXPos -= pBlockHeader[iCharIdx].iWidth / + 2; // Regular character: subtract half character width for + // centering calculation } - iXPos = (scr_size * iXPos) >> 6; // Apply scaling to calculated X offset and convert to screen coordinates - pCharItr = szStr; // Initialize string iterator for second pass (actual rendering) + iXPos = (scr_size * iXPos) >> 6; // Apply scaling to calculated X offset and + // convert to screen coordinates + pCharItr = + szStr; // Initialize string iterator for second pass (actual rendering) iDone = 0; - iYPos = (scr_size * iYPos) >> 6; // Apply scaling to Y position - do { // Check for end of string (null terminator) - if (*pCharItr) { // Skip newline characters (not rendered in mini font) + iYPos = (scr_size * iYPos) >> 6; // Apply scaling to Y position + do { // Check for end of string (null terminator) + if (*pCharItr) { // Skip newline characters (not rendered in mini font) if (*pCharItr != '\n') { - iSavedYPos = iYPos; // Save Y position for restoration after character rendering - if (*pCharItr == -118) // Special character 0x8A (138): render 2 pixels higher (superscript effect) + iSavedYPos = + iYPos; // Save Y position for restoration after character rendering + if (*pCharItr == -118) // Special character 0x8A (138): render 2 pixels + // higher (superscript effect) iYPos -= 2; - prt_letter(pBlockHeader, *pCharItr, &iXPos, &iYPos, -1);// Render character using prt_letter with ascii_conv3 font (fontType=-1) - iYPos = iSavedYPos; // Restore Y position after character rendering + prt_letter(pBlockHeader, *pCharItr, &iXPos, &iYPos, + -1); // Render character using prt_letter with ascii_conv3 + // font (fontType=-1) + iYPos = iSavedYPos; // Restore Y position after character rendering } } else { - iDone = -1; // End of string reached: set done flag to exit loop + iDone = -1; // End of string reached: set done flag to exit loop } - ++pCharItr; // Advance to next character in string - } while (!iDone); // Second pass: render each character at calculated centered position + ++pCharItr; // Advance to next character in string + } while (!iDone); // Second pass: render each character at calculated centered + // position } //------------------------------------------------------------------------------------------------- -//00018BB0 -void prt_right(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) -{ +// 00018BB0 +void prt_right(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) { char *pCurrChar; // esi - int iCharIdx; // eax - int iDone; // ebp - int iYPos; // [esp+0h] [ebp-14h] BYREF - int iXPos; // [esp+4h] [ebp-10h] BYREF + int iCharIdx; // eax + int iDone; // ebp + int iYPos; // [esp+0h] [ebp-14h] BYREF + int iXPos; // [esp+4h] [ebp-10h] BYREF pCurrChar = (char *)szStr; iXPos = iX; @@ -2235,10 +2399,9 @@ void prt_right(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) } //------------------------------------------------------------------------------------------------- -//00018C50 -void prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) -{ - int iDone; // ebp +// 00018C50 +void prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) { + int iDone; // ebp int piYPos; // [esp+0h] [ebp-14h] BYREF int piXPos; // [esp+4h] [ebp-10h] BYREF @@ -2257,63 +2420,77 @@ void prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY) } //------------------------------------------------------------------------------------------------- -//00018CB0 -void prt_letter(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPos, int iFontType) -{ - int iSavedScrSize; // esi - uint8 iCharIndex; // edi - int iYOffset; // edx +// 00018CB0 +void prt_letter(tBlockHeader *pBlockHeader, char byChar, int *piXPos, + int *piYPos, int iFontType) { + int iSavedScrSize; // esi + uint8 iCharIndex; // edi + int iYOffset; // edx tBlockHeader *pCharData; // eax - int iCharWidth; // edi - uint8 *pCharBitmap; // ebx - uint8 *pScreenDest; // eax - int iRowIdx; // ebp - int i; // edx - uint8 byPixel; // cl - uint8 *pRowStart; // edx - int iScaleAccum; // edi - uint8 *pScaledDest; // ebp - int iTempScale; // eax - int iScaledColIdx; // ebx - uint8 *pScaledRowBase; // [esp+0h] [ebp-28h] - int iCharHeight; // [esp+8h] [ebp-20h] - int iCharWidth2; // [esp+Ch] [ebp-1Ch] - uint8 *pBitmapRowStart; // [esp+10h] [ebp-18h] - int iRowIdx2; // [esp+14h] [ebp-14h] - int iScaledCharWidth; // [esp+18h] [ebp-10h] - - iSavedScrSize = scr_size; // Save current screen scaling factor - if (iFontType) // Check font type selection: a5 != 0 uses ascii_conv3, a5 == 0 uses font6 + int iCharWidth; // edi + uint8 *pCharBitmap; // ebx + uint8 *pScreenDest; // eax + int iRowIdx; // ebp + int i; // edx + uint8 byPixel; // cl + uint8 *pRowStart; // edx + int iScaleAccum; // edi + uint8 *pScaledDest; // ebp + int iTempScale; // eax + int iScaledColIdx; // ebx + uint8 *pScaledRowBase; // [esp+0h] [ebp-28h] + int iCharHeight; // [esp+8h] [ebp-20h] + int iCharWidth2; // [esp+Ch] [ebp-1Ch] + uint8 *pBitmapRowStart; // [esp+10h] [ebp-18h] + int iRowIdx2; // [esp+14h] [ebp-14h] + int iScaledCharWidth; // [esp+18h] [ebp-10h] + + iSavedScrSize = scr_size; // Save current screen scaling factor + if (iFontType) // Check font type selection: a5 != 0 uses ascii_conv3, a5 == 0 + // uses font6 { - iCharIndex = (uint8)ascii_conv3[(uint8)byChar];// Use alternate font (ascii_conv3) with no Y offset + iCharIndex = (uint8)ascii_conv3[( + uint8)byChar]; // Use alternate font (ascii_conv3) with no Y offset iYOffset = 0; } else { - iCharIndex = (uint8)font6_ascii[(uint8)byChar];// Use default font6 with Y offset from font6_offsets table + iCharIndex = + (uint8)font6_ascii[(uint8)byChar]; // Use default font6 with Y offset + // from font6_offsets table iYOffset = 0; } - if (iCharIndex == 255) { // Space/unmapped sentinel: advance X and return before touching glyph data + if (iCharIndex == 255) { // Space/unmapped sentinel: advance X and return + // before touching glyph data *piXPos += (4 * iSavedScrSize) >> 6; scr_size = iSavedScrSize; return; } if (!iFontType) iYOffset = font6_offsets[iCharIndex]; - pCharData = &pBlockHeader[iCharIndex]; // Get character data: width, height, bitmap offset (12 bytes per character) - if (scr_size != 64) // Branch: scr_size == 64 uses simple blitting, != 64 uses scaled rendering - { // Scaled path + pCharData = + &pBlockHeader[iCharIndex]; // Get character data: width, height, bitmap + // offset (12 bytes per character) + if (scr_size != 64) // Branch: scr_size == 64 uses simple blitting, != 64 uses + // scaled rendering + { // Scaled path iScaledCharWidth = pCharData->iWidth; iCharWidth2 = pCharData->iHeight; pRowStart = (uint8 *)pBlockHeader + pCharData->iDataOffset; iScaleAccum = scr_size; - pScaledRowBase = &screen_pointer[*piXPos + winw * *piYPos];// Calculate destination screen pointer for scaled rendering - for (iRowIdx2 = 0; iRowIdx2 < iCharWidth2; pScaledRowBase += winw)// Scaled rendering: outer loop for each row of the character + pScaledRowBase = + &screen_pointer[*piXPos + + winw * *piYPos]; // Calculate destination screen pointer + // for scaled rendering + for (iRowIdx2 = 0; iRowIdx2 < iCharWidth2; + pScaledRowBase += + winw) // Scaled rendering: outer loop for each row of the character { pScaledDest = pScaledRowBase; pBitmapRowStart = pRowStart; iTempScale = iSavedScrSize; iScaledColIdx = 0; - while (iScaledColIdx < iScaledCharWidth)// Inner loop: render each column with scaling algorithm - { // Non-zero pixel: copy to screen buffer (transparent = 0) + while (iScaledColIdx < iScaledCharWidth) // Inner loop: render each column + // with scaling algorithm + { // Non-zero pixel: copy to screen buffer (transparent = 0) if (*pRowStart) *pScaledDest = *pRowStart; iTempScale -= 64; @@ -2329,11 +2506,13 @@ void prt_letter(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPo iScaleAccum += iSavedScrSize; } } - *piXPos += (iSavedScrSize * iScaledCharWidth) >> 6;// Scaled path: advance X by scaled character width + *piXPos += (iSavedScrSize * iScaledCharWidth) >> + 6; // Scaled path: advance X by scaled character width goto CLEANUP_AND_RETURN; } if (iCharIndex == 255) { - *piXPos += 4; // Unscaled path: Space character advances X by 4 pixels (dead, space handled above) + *piXPos += 4; // Unscaled path: Space character advances X by 4 pixels + // (dead, space handled above) CLEANUP_AND_RETURN: scr_size = iSavedScrSize; return; @@ -2341,68 +2520,82 @@ void prt_letter(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPo iCharHeight = pCharData->iHeight; iCharWidth = pCharData->iWidth; pCharBitmap = (uint8 *)pBlockHeader + pCharData->iDataOffset; - pScreenDest = &screen_pointer[*piXPos + winw * (*piYPos + iYOffset)];// Calculate screen destination for unscaled 1:1 rendering - for (iRowIdx = 0; iRowIdx < iCharHeight; pScreenDest += winw - iCharWidth)// Unscaled rendering: simple row-by-row bitmap copy + pScreenDest = + &screen_pointer[*piXPos + + winw * + (*piYPos + iYOffset)]; // Calculate screen destination + // for unscaled 1:1 rendering + for (iRowIdx = 0; iRowIdx < iCharHeight; + pScreenDest += + winw - iCharWidth) // Unscaled rendering: simple row-by-row bitmap copy { for (i = 0; i < iCharWidth; ++pScreenDest) { - byPixel = *pCharBitmap++; // Copy non-zero pixels (0 = transparent) + byPixel = *pCharBitmap++; // Copy non-zero pixels (0 = transparent) if (byPixel) *pScreenDest = byPixel; ++i; } ++iRowIdx; } - *piXPos += iCharWidth; // Advance X position by character width - scr_size = 64; // Reset scr_size to 64 (unscaled mode) + *piXPos += iCharWidth; // Advance X position by character width + scr_size = 64; // Reset scr_size to 64 (unscaled mode) } //------------------------------------------------------------------------------------------------- -//00018E80 -void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPos, int iFontType) -{ - int iSavedScrSize; // esi - int byCharIndex; // edi - int iYOffset; // edx +// 00018E80 +void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, + int *piYPos, int iFontType) { + int iSavedScrSize; // esi + int byCharIndex; // edi + int iYOffset; // edx tBlockHeader *pCharData; // eax - int iCharWidth; // edi - uint8 *pCharBitmap; // ebx - uint8 *pScreenDest; // eax - int iRowIdx; // ebp - int i; // edx - uint8 byPixel; // cl - uint8 *pRowStart; // edx - int iScrSize; // edi - uint8 *pScaledDest; // ebp - int iTempScale; // eax - int iScaledColIdx; // ebx - uint8 *pScaledRowBase; // [esp+0h] [ebp-28h] - int iCharHeight; // [esp+8h] [ebp-20h] - int iHeight; // [esp+Ch] [ebp-1Ch] - uint8 *pBitmapRowStart; // [esp+10h] [ebp-18h] - int iRowIdx2; // [esp+14h] [ebp-14h] - int iWidth; // [esp+18h] [ebp-10h] - - iSavedScrSize = scr_size; // Save current screen scaling factor - if (iFontType) // Font selection: iFontType != 0 uses ascii_conv3, == 0 uses font6 + int iCharWidth; // edi + uint8 *pCharBitmap; // ebx + uint8 *pScreenDest; // eax + int iRowIdx; // ebp + int i; // edx + uint8 byPixel; // cl + uint8 *pRowStart; // edx + int iScrSize; // edi + uint8 *pScaledDest; // ebp + int iTempScale; // eax + int iScaledColIdx; // ebx + uint8 *pScaledRowBase; // [esp+0h] [ebp-28h] + int iCharHeight; // [esp+8h] [ebp-20h] + int iHeight; // [esp+Ch] [ebp-1Ch] + uint8 *pBitmapRowStart; // [esp+10h] [ebp-18h] + int iRowIdx2; // [esp+14h] [ebp-14h] + int iWidth; // [esp+18h] [ebp-10h] + + iSavedScrSize = scr_size; // Save current screen scaling factor + if (iFontType) // Font selection: iFontType != 0 uses ascii_conv3, == 0 uses + // font6 { - byCharIndex = (uint8)ascii_conv3[(uint8)byChar];// Use alternate font (ascii_conv3) with no Y offset + byCharIndex = (uint8)ascii_conv3[( + uint8)byChar]; // Use alternate font (ascii_conv3) with no Y offset iYOffset = 0; } else { - byCharIndex = (uint8)font6_ascii[(uint8)byChar];// Use default font6 with Y offset from font6_offsets table + byCharIndex = + (uint8)font6_ascii[(uint8)byChar]; // Use default font6 with Y offset + // from font6_offsets table iYOffset = 0; } - if (byCharIndex == 255) { // Space/unmapped sentinel: move X and return before touching glyph data + if (byCharIndex == 255) { // Space/unmapped sentinel: move X and return before + // touching glyph data *piXPos -= (4 * iSavedScrSize) >> 6; scr_size = iSavedScrSize; return; } if (!iFontType) iYOffset = font6_offsets[byCharIndex]; - pCharData = &pBlockHeader[byCharIndex]; // Get character data block: width, height, bitmap offset - if (scr_size != 64) // Branch: scr_size == 64 uses simple reverse blitting, != 64 uses scaled reverse rendering - { // Scaled path: Check for space character (index 255) + pCharData = &pBlockHeader[byCharIndex]; // Get character data block: width, + // height, bitmap offset + if (scr_size != 64) // Branch: scr_size == 64 uses simple reverse blitting, != + // 64 uses scaled reverse rendering + { // Scaled path: Check for space character (index 255) if (byCharIndex == 255) { - *piXPos -= (4 * scr_size) >> 6; // Space character: move X leftward by scaled width (4 * scr_size / 64) + *piXPos -= (4 * scr_size) >> 6; // Space character: move X leftward by + // scaled width (4 * scr_size / 64) scr_size = iSavedScrSize; return; } @@ -2410,19 +2603,26 @@ void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *p iHeight = pCharData->iHeight; pRowStart = (uint8 *)pBlockHeader + pCharData->iDataOffset; iScrSize = scr_size; - pScaledRowBase = &screen_pointer[*piXPos + winw * *piYPos];// Calculate destination screen pointer for scaled reverse rendering - for (iRowIdx2 = 0; iRowIdx2 < iHeight; pScaledRowBase += winw)// Scaled reverse rendering: outer loop for each row + pScaledRowBase = + &screen_pointer[*piXPos + + winw * *piYPos]; // Calculate destination screen pointer + // for scaled reverse rendering + for (iRowIdx2 = 0; iRowIdx2 < iHeight; + pScaledRowBase += + winw) // Scaled reverse rendering: outer loop for each row { pScaledDest = pScaledRowBase; pBitmapRowStart = pRowStart; iTempScale = iSavedScrSize; iScaledColIdx = 0; - while (iScaledColIdx < iWidth) // Inner loop: render each column right-to-left with scaling - { // Non-zero pixel: copy to screen buffer (transparent = 0) + while ( + iScaledColIdx < + iWidth) // Inner loop: render each column right-to-left with scaling + { // Non-zero pixel: copy to screen buffer (transparent = 0) if (*pRowStart) *pScaledDest = *pRowStart; iTempScale -= 64; - --pScaledDest; // Move destination pointer leftward (reverse direction) + --pScaledDest; // Move destination pointer leftward (reverse direction) for (; iTempScale <= 0; ++iScaledColIdx) { ++pRowStart; iTempScale += iSavedScrSize; @@ -2434,11 +2634,12 @@ void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *p iScrSize += iSavedScrSize; } } - *piXPos -= (iSavedScrSize * iWidth) >> 6; // Scaled path: move X leftward by scaled character width + *piXPos -= (iSavedScrSize * iWidth) >> + 6; // Scaled path: move X leftward by scaled character width goto CLEANUP_AND_RETURN; } if (byCharIndex == 255) { - *piXPos -= 4; // Unscaled path: Space character moves X leftward by 4 pixels + *piXPos -= 4; // Unscaled path: Space character moves X leftward by 4 pixels CLEANUP_AND_RETURN: scr_size = iSavedScrSize; return; @@ -2446,25 +2647,33 @@ void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *p iCharHeight = pCharData->iHeight; iCharWidth = pCharData->iWidth; pCharBitmap = (uint8 *)pBlockHeader + pCharData->iDataOffset; - pScreenDest = &screen_pointer[*piXPos + winw * (*piYPos + iYOffset)];// Calculate screen destination for unscaled reverse rendering - for (iRowIdx = 0; iRowIdx < iCharHeight; pScreenDest += iCharWidth + winw)// Unscaled reverse rendering: row-by-row bitmap copy right-to-left + pScreenDest = + &screen_pointer[*piXPos + + winw * (*piYPos + + iYOffset)]; // Calculate screen destination for + // unscaled reverse rendering + for (iRowIdx = 0; iRowIdx < iCharHeight; + pScreenDest += + iCharWidth + + winw) // Unscaled reverse rendering: row-by-row bitmap copy right-to-left { for (i = 0; i < iCharWidth; --pScreenDest) { - byPixel = *pCharBitmap++; // Copy non-zero pixels, decrement screen pointer (reverse direction) + byPixel = *pCharBitmap++; // Copy non-zero pixels, decrement screen + // pointer (reverse direction) if (byPixel) *pScreenDest = byPixel; ++i; } ++iRowIdx; } - *piXPos -= iCharWidth; // Move X position leftward by character width - scr_size = 64; // Reset scr_size to 64 (unscaled mode) + *piXPos -= iCharWidth; // Move X position leftward by character width + scr_size = 64; // Reset scr_size to 64 (unscaled mode) } //------------------------------------------------------------------------------------------------- -//00019050 -void prt_stringcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, uint8 byColor) -{ +// 00019050 +void prt_stringcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY, uint8 byColor) { int iDone; // ebp int iYPos; // [esp+0h] [ebp-14h] BYREF int iXPos; // [esp+4h] [ebp-10h] BYREF @@ -2484,15 +2693,15 @@ void prt_stringcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY } //------------------------------------------------------------------------------------------------- -//000190B0 -void prt_rightcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, uint8 byColor) -{ - const char *i; // esi - int iCharIdx; // eax +// 000190B0 +void prt_rightcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, + uint8 byColor) { + const char *i; // esi + int iCharIdx; // eax const char *pCharItr; // esi - int iDone; // ebp - int iYPos; // [esp+0h] [ebp-14h] BYREF - int iXPos; // [esp+4h] [ebp-10h] BYREF + int iDone; // ebp + int iYPos; // [esp+0h] [ebp-14h] BYREF + int iXPos; // [esp+4h] [ebp-10h] BYREF iXPos = iX; iYPos = iY; @@ -2519,17 +2728,17 @@ void prt_rightcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, } //------------------------------------------------------------------------------------------------- -//00019160 -void prt_centrecol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, Uint8 byColor) -{ +// 00019160 +void prt_centrecol(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY, Uint8 byColor) { const char *pCurrChar; // esi - const char *pCharItr; // eax - char c; // bl - int iWidth; // edx - int iCharIdx; // ebx - int iDone; // ebp - int iYPos; // [esp+0h] [ebp-14h] BYREF - int iXPos; // [esp+4h] [ebp-10h] BYREF + const char *pCharItr; // eax + char c; // bl + int iWidth; // edx + int iCharIdx; // ebx + int iDone; // ebp + int iYPos; // [esp+0h] [ebp-14h] BYREF + int iXPos; // [esp+4h] [ebp-10h] BYREF pCurrChar = szStr; iXPos = iX; @@ -2561,967 +2770,1015 @@ void prt_centrecol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY } //------------------------------------------------------------------------------------------------- -//00019210 -void prt_lettercol(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPos, uint8 byColor) -{ - int iSavedScrSize; // esi - int byCharIndex; // ebx - uint8 *pCharBitmap; // edx - int iScaleAccum; // ebp - uint8 *pScreenDest; // edi - int iTempScale; // eax - int iColIdx; // ebx - uint8 byPixel; // cl - int iHeight; // [esp+0h] [ebp-24h] - int iRowIdx; // [esp+4h] [ebp-20h] +// 00019210 +void prt_lettercol(tBlockHeader *pBlockHeader, char byChar, int *piXPos, + int *piYPos, uint8 byColor) { + int iSavedScrSize; // esi + int byCharIndex; // ebx + uint8 *pCharBitmap; // edx + int iScaleAccum; // ebp + uint8 *pScreenDest; // edi + int iTempScale; // eax + int iColIdx; // ebx + uint8 byPixel; // cl + int iHeight; // [esp+0h] [ebp-24h] + int iRowIdx; // [esp+4h] [ebp-20h] uint8 *pBitmapRowStart; // [esp+Ch] [ebp-18h] - uint8 *pRowBase; // [esp+10h] [ebp-14h] - int iWidth; // [esp+14h] [ebp-10h] + uint8 *pRowBase; // [esp+10h] [ebp-14h] + int iWidth; // [esp+14h] [ebp-10h] - iSavedScrSize = scr_size; // Save current screen scaling factor - byCharIndex = (uint8)font6_ascii[(uint8)byChar];// Only uses font6_ascii (no alternate font support) - if (byCharIndex == 255) // Check for space character (index 255) + iSavedScrSize = scr_size; // Save current screen scaling factor + byCharIndex = (uint8)font6_ascii[( + uint8)byChar]; // Only uses font6_ascii (no alternate font support) + if (byCharIndex == 255) // Check for space character (index 255) { - *piXPos += (4 * scr_size) >> 6; // Space character: advance X by scaled width (4 * scr_size / 64) + *piXPos += + (4 * scr_size) >> + 6; // Space character: advance X by scaled width (4 * scr_size / 64) } else { - iWidth = pBlockHeader[byCharIndex].iWidth; // Get character dimensions from font data + iWidth = pBlockHeader[byCharIndex] + .iWidth; // Get character dimensions from font data iHeight = pBlockHeader[byCharIndex].iHeight; - pCharBitmap = (uint8 *)pBlockHeader + pBlockHeader[byCharIndex].iDataOffset;// Get pointer to character bitmap data + pCharBitmap = (uint8 *)pBlockHeader + + pBlockHeader[byCharIndex] + .iDataOffset; // Get pointer to character bitmap data iScaleAccum = scr_size; - pRowBase = &screen_pointer[*piXPos + winw * (font6_offsets[byCharIndex] + *piYPos)];// Calculate screen destination with Y offset from font6_offsets - for (iRowIdx = 0; iRowIdx < iHeight; pRowBase += winw)// Scaled rendering: outer loop for each row of character + pRowBase = + &screen_pointer[*piXPos + + winw * (font6_offsets[byCharIndex] + + *piYPos)]; // Calculate screen destination with + // Y offset from font6_offsets + for (iRowIdx = 0; iRowIdx < iHeight; + pRowBase += + winw) // Scaled rendering: outer loop for each row of character { pScreenDest = pRowBase; pBitmapRowStart = pCharBitmap; iTempScale = iSavedScrSize; iColIdx = 0; - while (iColIdx < iWidth) // Inner loop: render each column with scaling and color substitution + while (iColIdx < iWidth) // Inner loop: render each column with scaling + // and color substitution { - byPixel = *pCharBitmap; // Read pixel from bitmap and check for non-zero (non-transparent) - if (*pCharBitmap) { // Color substitution: replace 0x8F (143) with custom color (a5) + byPixel = *pCharBitmap; // Read pixel from bitmap and check for non-zero + // (non-transparent) + if (*pCharBitmap) { // Color substitution: replace 0x8F (143) with + // custom color (a5) if (byPixel == 0x8F) byPixel = byColor; - *pScreenDest = byPixel; // Write pixel to screen buffer + *pScreenDest = byPixel; // Write pixel to screen buffer } - iTempScale -= 64; // Scaling algorithm: decrement scale accumulator + iTempScale -= 64; // Scaling algorithm: decrement scale accumulator ++pScreenDest; - for (; iTempScale <= 0; ++iColIdx) // Scale loop: advance bitmap pointer when scale threshold reached + for (; iTempScale <= 0; ++iColIdx) // Scale loop: advance bitmap pointer + // when scale threshold reached { ++pCharBitmap; iTempScale += iSavedScrSize; } } - iScaleAccum -= 64; // Row scaling: decrement row scale accumulator - for (pCharBitmap = pBitmapRowStart; iScaleAccum <= 0; ++iRowIdx)// Row scale loop: advance to next bitmap row when threshold reached + iScaleAccum -= 64; // Row scaling: decrement row scale accumulator + for (pCharBitmap = pBitmapRowStart; iScaleAccum <= 0; + ++iRowIdx) // Row scale loop: advance to next bitmap row when + // threshold reached { pCharBitmap += iWidth; iScaleAccum += iSavedScrSize; } } - *piXPos += (iSavedScrSize * iWidth) >> 6; // Advance X position by scaled character width + *piXPos += (iSavedScrSize * iWidth) >> + 6; // Advance X position by scaled character width } - scr_size = iSavedScrSize; // Restore original screen size + scr_size = iSavedScrSize; // Restore original screen size } //------------------------------------------------------------------------------------------------- -//00019360 -void display_paused() -{ - char byMenuColor; // al - char byMenuItemColor; // al - const char *pszMenuText; // edx - char byOption2Color; // al - char byOption3Color; // al - char byOption4Color; // al - char byOption5Color; // al - char byOption6Color; // al - int iKeyReleaseCheck; // ebx - int iKeyIndex; // eax - int iNameIndex; // edx - char byControlColor1; // al - char byControlColor2; // al - char byControlColor3; // al - int iYPosition; // edi - int iControlIndex; // esi - char byKeyDisplayColor1; // al - char byKeyDisplayColor2; // al - int iControlIndex2; // esi - int iYPosition2; // edi - char byKeyColor1; // al - char byKeyColor2; // al - int iKeyPressed; // ebx - int iKeyLoop; // eax - int iNameLoop; // edx - int iJoy2YCalc; // eax - int iJoy2XCalc; // eax - int iJoy1YCalc; // eax - int iJoy1XCalc; // eax - int iDuplicateCheck; // esi - int i; // eax - int iControlNext; // eax - int iControlSelect; // edi - char byCalibColor1; // al - char byCalibColor2; // al - char byCalibColor3; // al - int iJoy1XBar; // ebx - const char *pszJoy1XStatus; // edx - char byJoy1XColor; // al - int iJoy1YBar; // ebx - const char *pszJoy1YStatus; // edx - char byJoy1YColor; // al - int iJoy2XBar; // ebx - const char *pszJoy2XStatus; // edx - char byJoy2XColor; // al - int iJoy2YBar; // ebx - const char *pszJoy2YStatus; // edx - char bySoundColor1; // al - char bySoundColor2; // al - char bySoundColor3; // al - char bySoundColor4; // al - char bySoundColor5; // al - char byEngineColor; // al - const char *pszEngineText; // edx - char bySoundOnColor; // al - char bySoundStatus1; // al - const char *pszSoundStatus1; // edx - char byMusicColor; // al - char byMusicStatus; // al - const char *pszMusicStatus; // edx - char byBackColor; // al - char byPerspectiveColor; // al - char byPerspectiveOnOff; // al +// 00019360 +void display_paused() { + char byMenuColor; // al + char byMenuItemColor; // al + const char *pszMenuText; // edx + char byOption2Color; // al + char byOption3Color; // al + char byOption4Color; // al + char byOption5Color; // al + char byOption6Color; // al + int iKeyReleaseCheck; // ebx + int iKeyIndex; // eax + int iNameIndex; // edx + char byControlColor1; // al + char byControlColor2; // al + char byControlColor3; // al + int iYPosition; // edi + int iControlIndex; // esi + char byKeyDisplayColor1; // al + char byKeyDisplayColor2; // al + int iControlIndex2; // esi + int iYPosition2; // edi + char byKeyColor1; // al + char byKeyColor2; // al + int iKeyPressed; // ebx + int iKeyLoop; // eax + int iNameLoop; // edx + int iJoy2YCalc; // eax + int iJoy2XCalc; // eax + int iJoy1YCalc; // eax + int iJoy1XCalc; // eax + int iDuplicateCheck; // esi + int i; // eax + int iControlNext; // eax + int iControlSelect; // edi + char byCalibColor1; // al + char byCalibColor2; // al + char byCalibColor3; // al + int iJoy1XBar; // ebx + const char *pszJoy1XStatus; // edx + char byJoy1XColor; // al + int iJoy1YBar; // ebx + const char *pszJoy1YStatus; // edx + char byJoy1YColor; // al + int iJoy2XBar; // ebx + const char *pszJoy2XStatus; // edx + char byJoy2XColor; // al + int iJoy2YBar; // ebx + const char *pszJoy2YStatus; // edx + char bySoundColor1; // al + char bySoundColor2; // al + char bySoundColor3; // al + char bySoundColor4; // al + char bySoundColor5; // al + char byEngineColor; // al + const char *pszEngineText; // edx + char bySoundOnColor; // al + char bySoundStatus1; // al + const char *pszSoundStatus1; // edx + char byMusicColor; // al + char byMusicStatus; // al + const char *pszMusicStatus; // edx + char byBackColor; // al + char byPerspectiveColor; // al + char byPerspectiveOnOff; // al const char *pszPerspectiveText; // edx - char byNamesColor; // al - char byNamesOnOff; // al - const char *pszNamesText; // edx - char byBuildingsColor; // al - char byBuildingStatus; // al - const char *pszBuildingText; // edx - char byGlassColor; // al - char byGlassStatus; // al - const char *pszGlassText; // edx - char byHorizonColor; // al - char byHorizonStatus; // al - const char *pszHorizonText; // edx - char byCarTexColor; // al - char byCarTexStatus; // al - const char *pszCarTexText; // edx - char byWallTexColor; // al - char byWallTexStatus; // al - const char *pszWallTexText; // edx - char byGroundTexColor; // al - char byGroundTexStatus; // al - const char *pszGroundTexText; // edx - char byBuildingTexColor; // al - char byBuildingTexStatus; // al + char byNamesColor; // al + char byNamesOnOff; // al + const char *pszNamesText; // edx + char byBuildingsColor; // al + char byBuildingStatus; // al + const char *pszBuildingText; // edx + char byGlassColor; // al + char byGlassStatus; // al + const char *pszGlassText; // edx + char byHorizonColor; // al + char byHorizonStatus; // al + const char *pszHorizonText; // edx + char byCarTexColor; // al + char byCarTexStatus; // al + const char *pszCarTexText; // edx + char byWallTexColor; // al + char byWallTexStatus; // al + const char *pszWallTexText; // edx + char byGroundTexColor; // al + char byGroundTexStatus; // al + const char *pszGroundTexText; // edx + char byBuildingTexColor; // al + char byBuildingTexStatus; // al const char *pszBuildingTexText; // edx - char byRoadTexColor; // al - char byRoadTexStatus; // al - const char *pszRoadTexText; // edx - char byShadowsColor; // al - char byShadowsStatus; // al - const char *pszShadowsText; // edx - char byCloudsColor; // al - char byCloudsStatus; // al - const char *pszCloudsText; // edx - char byPanelColor; // al - char byPanelStatus; // al - const char *pszPanelText; // edx - char byViewLimitColor; // al - char byViewLimitStatus; // al - const char *pszViewLimitText; // edx - char bySizeColor; // al - int iSizePercent; // eax - char bySizeDisplayColor; // al - char bySVGAColor; // al - const char *pszSVGAText; // edx - char byExitColor; // al - tJoyPos joyPos; // [esp+0h] [ebp-28h] BYREF - const char *pszConfigText1; // [esp+20h] [ebp-8h] - const char *pszConfigText2; // [esp+24h] [ebp-4h] + char byRoadTexColor; // al + char byRoadTexStatus; // al + const char *pszRoadTexText; // edx + char byShadowsColor; // al + char byShadowsStatus; // al + const char *pszShadowsText; // edx + char byCloudsColor; // al + char byCloudsStatus; // al + const char *pszCloudsText; // edx + char byPanelColor; // al + char byPanelStatus; // al + const char *pszPanelText; // edx + char byViewLimitColor; // al + char byViewLimitStatus; // al + const char *pszViewLimitText; // edx + char bySizeColor; // al + int iSizePercent; // eax + char bySizeDisplayColor; // al + char bySVGAColor; // al + const char *pszSVGAText; // edx + char byExitColor; // al + tJoyPos joyPos; // [esp+0h] [ebp-28h] BYREF + const char *pszConfigText1; // [esp+20h] [ebp-8h] + const char *pszConfigText2; // [esp+24h] [ebp-4h] switch (pausewindow) { - case 0: - blankwindow(0, 0, 320, 200); - prt_centrecol(rev_vga[1], config_buffer, 160, 16, 171); - if (req_edit) - byMenuColor = 0x83; // Grey color (0x83) for non-selected menu items - else - byMenuColor = 0x8F; // White color (0x8F) for selected menu items - prt_centrecol(rev_vga[1], &config_buffer[64], 160, 36, byMenuColor); - if (replaytype == 2) { - if (req_edit == 1) - byMenuItemColor = 0x8F; - else - byMenuItemColor = 0x83; - pszMenuText = &config_buffer[192]; - } else { - if (req_edit == 1) - byMenuItemColor = 0x8F; - else - byMenuItemColor = 0x83; - pszMenuText = &config_buffer[128]; - } - prt_centrecol(rev_vga[1], pszMenuText, 160, 48, byMenuItemColor); - if (req_edit == 2) - byOption2Color = (char)0x8F; + case 0: + blankwindow(0, 0, 320, 200); + prt_centrecol(rev_vga[1], config_buffer, 160, 16, 171); + if (req_edit) + byMenuColor = 0x83; // Grey color (0x83) for non-selected menu items + else + byMenuColor = 0x8F; // White color (0x8F) for selected menu items + prt_centrecol(rev_vga[1], &config_buffer[64], 160, 36, byMenuColor); + if (replaytype == 2) { + if (req_edit == 1) + byMenuItemColor = 0x8F; else - byOption2Color = 0x83; - prt_centrecol(rev_vga[1], &config_buffer[256], 160, 60, byOption2Color); - if (req_edit == 3) - byOption3Color = 0x8F; + byMenuItemColor = 0x83; + pszMenuText = &config_buffer[192]; + } else { + if (req_edit == 1) + byMenuItemColor = 0x8F; else - byOption3Color = 0x83; - prt_centrecol(rev_vga[1], &config_buffer[320], 160, 72, byOption3Color); - if (req_edit == 4) - byOption4Color = 0x8F; + byMenuItemColor = 0x83; + pszMenuText = &config_buffer[128]; + } + prt_centrecol(rev_vga[1], pszMenuText, 160, 48, byMenuItemColor); + if (req_edit == 2) + byOption2Color = (char)0x8F; + else + byOption2Color = 0x83; + prt_centrecol(rev_vga[1], &config_buffer[256], 160, 60, byOption2Color); + if (req_edit == 3) + byOption3Color = 0x8F; + else + byOption3Color = 0x83; + prt_centrecol(rev_vga[1], &config_buffer[320], 160, 72, byOption3Color); + if (req_edit == 4) + byOption4Color = 0x8F; + else + byOption4Color = 0x83; + prt_centrecol(rev_vga[1], &config_buffer[384], 160, 84, byOption4Color); + if (req_edit == 5) + byOption5Color = 0x8F; + else + byOption5Color = 0x83; + prt_centrecol(rev_vga[1], &config_buffer[576], 160, 96, byOption5Color); + if (req_edit == 6) + byOption6Color = 0x8F; + else + byOption6Color = 0x83; + prt_centrecol(rev_vga[1], &config_buffer[640], 160, 108, byOption6Color); + break; + case 1: + blankwindow(0, 0, 320, 200); // Case 1: Joystick calibration window + if (calibrate_mode) { + ReadJoys(&joyPos); // Read joystick positions for calibration + //_disable(); + if (joyPos.iJ1XAxis < + JAXmin) // Update joystick 1 X-axis min/max calibration values + JAXmin = joyPos.iJ1XAxis; + if (joyPos.iJ1XAxis > JAXmax) + JAXmax = joyPos.iJ1XAxis; + if (joyPos.iJ1YAxis < + JAYmin) // Update joystick 1 Y-axis min/max calibration values + JAYmin = joyPos.iJ1YAxis; + if (joyPos.iJ1YAxis > JAYmax) + JAYmax = joyPos.iJ1YAxis; + if (joyPos.iJ2XAxis < + JBXmin) // Update joystick 2 X-axis min/max calibration values + JBXmin = joyPos.iJ2XAxis; + if (joyPos.iJ2XAxis > JBXmax) + JBXmax = joyPos.iJ2XAxis; + if (joyPos.iJ2YAxis < + JBYmin) // Update joystick 2 Y-axis min/max calibration values + JBYmin = joyPos.iJ2YAxis; + if (joyPos.iJ2YAxis > JBYmax) + JBYmax = joyPos.iJ2YAxis; + if (JAXmin == JAXmax) // Ensure min != max to avoid division by zero + JAXmax = JAXmin + 1; + if (JAYmin == JAYmax) + JAYmax = JAYmin + 1; + if (JBXmin == JBXmax) + JBXmax = JBXmin + 1; + if (JBYmin == JBYmax) + JBYmax = JBYmin + 1; + //_enable(); + } + prt_centrecol(rev_vga[1], &config_buffer[320], 160, 16, 171); + if (calibrate_select != 1 || calibrate_mode) + byCalibColor1 = 0x83; + else + byCalibColor1 = 0x8F; + prt_centrecol(rev_vga[1], &config_buffer[1664], 160, 36, byCalibColor1); + if (calibrate_select || calibrate_mode) + byCalibColor2 = 0x83; + else + byCalibColor2 = 0x8F; + prt_centrecol(rev_vga[1], &config_buffer[832], 160, 48, byCalibColor2); + if (calibrate_mode) + byCalibColor3 = 0x8F; + else + byCalibColor3 = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[1728], 176, 68, byCalibColor3); + if (calibrate_mode) { + if (x1ok && JAXmax - JAXmin >= 100) + iJoy1XBar = + 140 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin); else - byOption4Color = 0x83; - prt_centrecol(rev_vga[1], &config_buffer[384], 160, 84, byOption4Color); - if (req_edit == 5) - byOption5Color = 0x8F; + iJoy1XBar = 0; + displaycalibrationbar(180, 68, iJoy1XBar); + } else { + if (x1ok) + pszJoy1XStatus = &config_buffer[2048]; else - byOption5Color = 0x83; - prt_centrecol(rev_vga[1], &config_buffer[576], 160, 96, byOption5Color); - if (req_edit == 6) - byOption6Color = 0x8F; + pszJoy1XStatus = &config_buffer[1984]; + prt_stringcol(rev_vga[1], pszJoy1XStatus, 180, 68, 131); + } + if (calibrate_mode) + byJoy1XColor = 0x8F; + else + byJoy1XColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[1792], 176, 80, byJoy1XColor); + if (calibrate_mode) { + if (y1ok && JAYmax - JAYmin >= 100) + iJoy1YBar = + 140 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); else - byOption6Color = 0x83; - prt_centrecol(rev_vga[1], &config_buffer[640], 160, 108, byOption6Color); - break; - case 1: - blankwindow(0, 0, 320, 200); // Case 1: Joystick calibration window - if (calibrate_mode) { - ReadJoys(&joyPos); // Read joystick positions for calibration - //_disable(); - if (joyPos.iJ1XAxis < JAXmin) // Update joystick 1 X-axis min/max calibration values - JAXmin = joyPos.iJ1XAxis; - if (joyPos.iJ1XAxis > JAXmax) - JAXmax = joyPos.iJ1XAxis; - if (joyPos.iJ1YAxis < JAYmin) // Update joystick 1 Y-axis min/max calibration values - JAYmin = joyPos.iJ1YAxis; - if (joyPos.iJ1YAxis > JAYmax) - JAYmax = joyPos.iJ1YAxis; - if (joyPos.iJ2XAxis < JBXmin) // Update joystick 2 X-axis min/max calibration values - JBXmin = joyPos.iJ2XAxis; - if (joyPos.iJ2XAxis > JBXmax) - JBXmax = joyPos.iJ2XAxis; - if (joyPos.iJ2YAxis < JBYmin) // Update joystick 2 Y-axis min/max calibration values - JBYmin = joyPos.iJ2YAxis; - if (joyPos.iJ2YAxis > JBYmax) - JBYmax = joyPos.iJ2YAxis; - if (JAXmin == JAXmax) // Ensure min != max to avoid division by zero - JAXmax = JAXmin + 1; - if (JAYmin == JAYmax) - JAYmax = JAYmin + 1; - if (JBXmin == JBXmax) - JBXmax = JBXmin + 1; - if (JBYmin == JBYmax) - JBYmax = JBYmin + 1; - //_enable(); - } - prt_centrecol(rev_vga[1], &config_buffer[320], 160, 16, 171); - if (calibrate_select != 1 || calibrate_mode) - byCalibColor1 = 0x83; + iJoy1YBar = 0; + displaycalibrationbar(180, 80, iJoy1YBar); + } else { + if (y1ok) + pszJoy1YStatus = &config_buffer[2048]; else - byCalibColor1 = 0x8F; - prt_centrecol(rev_vga[1], &config_buffer[1664], 160, 36, byCalibColor1); - if (calibrate_select || calibrate_mode) - byCalibColor2 = 0x83; + pszJoy1YStatus = &config_buffer[1984]; + prt_stringcol(rev_vga[1], pszJoy1YStatus, 180, 80, 131); + } + if (calibrate_mode) + byJoy1YColor = 0x8F; + else + byJoy1YColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[1856], 176, 92, byJoy1YColor); + if (calibrate_mode) { + if (x2ok && JBXmax - JBXmin >= 100) + iJoy2XBar = + 140 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); else - byCalibColor2 = 0x8F; - prt_centrecol(rev_vga[1], &config_buffer[832], 160, 48, byCalibColor2); - if (calibrate_mode) - byCalibColor3 = 0x8F; + iJoy2XBar = 0; + displaycalibrationbar(180, 92, iJoy2XBar); + } else { + if (x2ok) + pszJoy2XStatus = &config_buffer[2048]; else - byCalibColor3 = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[1728], 176, 68, byCalibColor3); - if (calibrate_mode) { - if (x1ok && JAXmax - JAXmin >= 100) - iJoy1XBar = 140 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin); - else - iJoy1XBar = 0; - displaycalibrationbar(180, 68, iJoy1XBar); - } else { - if (x1ok) - pszJoy1XStatus = &config_buffer[2048]; - else - pszJoy1XStatus = &config_buffer[1984]; - prt_stringcol(rev_vga[1], pszJoy1XStatus, 180, 68, 131); - } - if (calibrate_mode) - byJoy1XColor = 0x8F; + pszJoy2XStatus = &config_buffer[1984]; + prt_stringcol(rev_vga[1], pszJoy2XStatus, 180, 92, 131); + } + if (calibrate_mode) + byJoy2XColor = 0x8F; + else + byJoy2XColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[1920], 176, 104, byJoy2XColor); + if (calibrate_mode) { + if (y2ok && JBYmax - JBYmin >= 100) + iJoy2YBar = + 140 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); else - byJoy1XColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[1792], 176, 80, byJoy1XColor); - if (calibrate_mode) { - if (y1ok && JAYmax - JAYmin >= 100) - iJoy1YBar = 140 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); - else - iJoy1YBar = 0; - displaycalibrationbar(180, 80, iJoy1YBar); - } else { - if (y1ok) - pszJoy1YStatus = &config_buffer[2048]; - else - pszJoy1YStatus = &config_buffer[1984]; - prt_stringcol(rev_vga[1], pszJoy1YStatus, 180, 80, 131); - } - if (calibrate_mode) - byJoy1YColor = 0x8F; + iJoy2YBar = 0; + displaycalibrationbar(180, 104, iJoy2YBar); + } else { + if (y2ok) + pszJoy2YStatus = &config_buffer[2048]; else - byJoy1YColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[1856], 176, 92, byJoy1YColor); - if (calibrate_mode) { - if (x2ok && JBXmax - JBXmin >= 100) - iJoy2XBar = 140 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); + pszJoy2YStatus = &config_buffer[1984]; + prt_stringcol(rev_vga[1], pszJoy2YStatus, 180, 104, 131); + } + if (calibrate_mode) { + prt_centrecol(rev_vga[1], &config_buffer[2112], 160, 124, 143); + prt_centrecol(rev_vga[1], &config_buffer[2176], 160, 136, 143); + } + break; + case 2: + if (controlrelease) // Case 2: Controls configuration window + { + iKeyReleaseCheck = -1; + iKeyIndex = 0; // Check if all controls are released + iNameIndex = 0; + do { + if (keyname[iNameIndex] && keys[iKeyIndex]) + iKeyReleaseCheck = 0; + ++iKeyIndex; + ++iNameIndex; + } while (iKeyIndex < 128); + if (iKeyReleaseCheck) + controlrelease = 0; + } + blankwindow(0, 0, 320, 200); + prt_centrecol(rev_vga[1], &config_buffer[384], 160, 16, 171); + if (control_select != 2 || define_mode) + byControlColor1 = 0x83; + else + byControlColor1 = 0x8F; + prt_centrecol(rev_vga[1], &config_buffer[704], 160, 36, byControlColor1); + if (control_select != 1 || define_mode) + byControlColor2 = 0x83; + else + byControlColor2 = 0x8F; + prt_centrecol(rev_vga[1], &config_buffer[768], 160, 48, byControlColor2); + if (control_select || define_mode) + byControlColor3 = 0x83; + else + byControlColor3 = 0x8F; + prt_centrecol(rev_vga[1], &config_buffer[832], 160, 60, byControlColor3); + if (control_select > 1) { + iControlIndex2 = 6; + iYPosition2 = 80; + pszConfigText1 = &config_buffer[1280]; + do { + if (iControlIndex2 == control_edit) + byKeyColor1 = 0x8F; else - iJoy2XBar = 0; - displaycalibrationbar(180, 92, iJoy2XBar); - } else { - if (x2ok) - pszJoy2XStatus = &config_buffer[2048]; + byKeyColor1 = + 0x7B; // Dark grey color (0x7B) for non-selected control items + prt_rightcol(rev_vga[1], pszConfigText1, 198, iYPosition2, byKeyColor1); + if (iControlIndex2 == control_edit) + byKeyColor2 = 0x8F; else - pszJoy2XStatus = &config_buffer[1984]; - prt_stringcol(rev_vga[1], pszJoy2XStatus, 180, 92, 131); - } - if (calibrate_mode) - byJoy2XColor = 0x8F; - else - byJoy2XColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[1920], 176, 104, byJoy2XColor); - if (calibrate_mode) { - if (y2ok && JBYmax - JBYmin >= 100) - iJoy2YBar = 140 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); + byKeyColor2 = 0x7B; + prt_stringcol(rev_vga[1], keyname[userkey[iControlIndex2++]], 200, + iYPosition2, byKeyColor2); + iYPosition2 += 12; + pszConfigText1 += 64; + } while (iControlIndex2 < 12); + } else { + iYPosition = 80; + iControlIndex = 0; + pszConfigText2 = &config_buffer[896]; + do { + if (iControlIndex == control_edit) + byKeyDisplayColor1 = 0x8F; else - iJoy2YBar = 0; - displaycalibrationbar(180, 104, iJoy2YBar); - } else { - if (y2ok) - pszJoy2YStatus = &config_buffer[2048]; + byKeyDisplayColor1 = 0x7B; + prt_rightcol(rev_vga[1], pszConfigText2, 198, iYPosition, + byKeyDisplayColor1); + if (iControlIndex == control_edit) + byKeyDisplayColor2 = 0x8F; else - pszJoy2YStatus = &config_buffer[1984]; - prt_stringcol(rev_vga[1], pszJoy2YStatus, 180, 104, 131); - } - if (calibrate_mode) { - prt_centrecol(rev_vga[1], &config_buffer[2112], 160, 124, 143); - prt_centrecol(rev_vga[1], &config_buffer[2176], 160, 136, 143); - } - break; - case 2: - if (controlrelease) // Case 2: Controls configuration window - { - iKeyReleaseCheck = -1; - iKeyIndex = 0; // Check if all controls are released - iNameIndex = 0; - do { - if (keyname[iNameIndex] && keys[iKeyIndex]) - iKeyReleaseCheck = 0; - ++iKeyIndex; - ++iNameIndex; - } while (iKeyIndex < 128); - if (iKeyReleaseCheck) - controlrelease = 0; - } - blankwindow(0, 0, 320, 200); - prt_centrecol(rev_vga[1], &config_buffer[384], 160, 16, 171); - if (control_select != 2 || define_mode) - byControlColor1 = 0x83; - else - byControlColor1 = 0x8F; - prt_centrecol(rev_vga[1], &config_buffer[704], 160, 36, byControlColor1); - if (control_select != 1 || define_mode) - byControlColor2 = 0x83; - else - byControlColor2 = 0x8F; - prt_centrecol(rev_vga[1], &config_buffer[768], 160, 48, byControlColor2); - if (control_select || define_mode) - byControlColor3 = 0x83; - else - byControlColor3 = 0x8F; - prt_centrecol(rev_vga[1], &config_buffer[832], 160, 60, byControlColor3); - if (control_select > 1) { - iControlIndex2 = 6; - iYPosition2 = 80; - pszConfigText1 = &config_buffer[1280]; - do { - if (iControlIndex2 == control_edit) - byKeyColor1 = 0x8F; - else - byKeyColor1 = 0x7B; // Dark grey color (0x7B) for non-selected control items - prt_rightcol(rev_vga[1], pszConfigText1, 198, iYPosition2, byKeyColor1); - if (iControlIndex2 == control_edit) - byKeyColor2 = 0x8F; - else - byKeyColor2 = 0x7B; - prt_stringcol(rev_vga[1], keyname[userkey[iControlIndex2++]], 200, iYPosition2, byKeyColor2); - iYPosition2 += 12; - pszConfigText1 += 64; - } while (iControlIndex2 < 12); - } else { - iYPosition = 80; - iControlIndex = 0; - pszConfigText2 = &config_buffer[896]; + byKeyDisplayColor2 = 0x7B; + prt_stringcol(rev_vga[1], keyname[userkey[iControlIndex++]], 200, + iYPosition, byKeyDisplayColor2); + iYPosition += 12; + pszConfigText2 += 64; + } while (iControlIndex < 6); + } + if (define_mode) { + if (!controlrelease) { + iKeyPressed = -1; // Scan for pressed keys when in define mode + iKeyLoop = 0; + iNameLoop = 0; do { - if (iControlIndex == control_edit) - byKeyDisplayColor1 = 0x8F; - else - byKeyDisplayColor1 = 0x7B; - prt_rightcol(rev_vga[1], pszConfigText2, 198, iYPosition, byKeyDisplayColor1); - if (iControlIndex == control_edit) - byKeyDisplayColor2 = 0x8F; - else - byKeyDisplayColor2 = 0x7B; - prt_stringcol(rev_vga[1], keyname[userkey[iControlIndex++]], 200, iYPosition, byKeyDisplayColor2); - iYPosition += 12; - pszConfigText2 += 64; - } while (iControlIndex < 6); - } - if (define_mode) { - if (!controlrelease) { - iKeyPressed = -1; // Scan for pressed keys when in define mode - iKeyLoop = 0; - iNameLoop = 0; - do { - if (keyname[iNameLoop] && keys[iKeyLoop]) - iKeyPressed = iKeyLoop; - ++iKeyLoop; - ++iNameLoop; - } while (iKeyLoop < 128); - if (iKeyPressed == -1) { - ReadJoys(&joyPos); // Check joystick buttons if no keyboard input detected - if (joyPos.iJ1Button1) // Joystick button mappings: 128=J1X, 129=J1Y, 130=J2X, 131=J2Y - iKeyPressed = 128; - if (joyPos.iJ1Button2) - iKeyPressed = 129; - if (joyPos.iJ2Button1) - iKeyPressed = 130; - if (joyPos.iJ2Button2) - iKeyPressed = 131; + if (keyname[iNameLoop] && keys[iKeyLoop]) + iKeyPressed = iKeyLoop; + ++iKeyLoop; + ++iNameLoop; + } while (iKeyLoop < 128); + if (iKeyPressed == -1) { + ReadJoys( + &joyPos); // Check joystick buttons if no keyboard input detected + if (joyPos.iJ1Button1) // Joystick button mappings: 128=J1X, 129=J1Y, + // 130=J2X, 131=J2Y + iKeyPressed = 128; + if (joyPos.iJ1Button2) + iKeyPressed = 129; + if (joyPos.iJ2Button1) + iKeyPressed = 130; + if (joyPos.iJ2Button2) + iKeyPressed = 131; + } + if (iKeyPressed == -1) { + if (y2ok) { + iJoy2YCalc = 100 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / + (JBYmax - JBYmin); + if (iJoy2YCalc < -50) + iKeyPressed = 138; + if (iJoy2YCalc > 50) + iKeyPressed = 139; } - if (iKeyPressed == -1) { - if (y2ok) { - iJoy2YCalc = 100 * (2 * joyPos.iJ2YAxis - JBYmax - JBYmin) / (JBYmax - JBYmin); - if (iJoy2YCalc < -50) - iKeyPressed = 138; - if (iJoy2YCalc > 50) - iKeyPressed = 139; - } - if (x2ok) { - iJoy2XCalc = 100 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / (JBXmax - JBXmin); - if (iJoy2XCalc < -50) - iKeyPressed = 136; - if (iJoy2XCalc > 50) - iKeyPressed = 137; - } - if (y1ok) { - iJoy1YCalc = 100 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / (JAYmax - JAYmin); - if (iJoy1YCalc < -50) - iKeyPressed = 134; - if (iJoy1YCalc > 50) - iKeyPressed = 135; - } - if (x1ok) { - iJoy1XCalc = 100 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / (JAXmax - JAXmin);// Calculate joystick axis positions: 132-139 are axis directions - if (iJoy1XCalc < -50) - iKeyPressed = 132; - if (iJoy1XCalc > 50) - iKeyPressed = 133; - } + if (x2ok) { + iJoy2XCalc = 100 * (2 * joyPos.iJ2XAxis - JBXmax - JBXmin) / + (JBXmax - JBXmin); + if (iJoy2XCalc < -50) + iKeyPressed = 136; + if (iJoy2XCalc > 50) + iKeyPressed = 137; } - if (iKeyPressed != -1 && (control_edit == 1 || control_edit == 7) && (userkey[control_edit] <= 0x83u) != (iKeyPressed <= 131)) { - iKeyPressed = -1; // Reject mixed keyboard/joystick input types + if (y1ok) { + iJoy1YCalc = 100 * (2 * joyPos.iJ1YAxis - JAYmax - JAYmin) / + (JAYmax - JAYmin); + if (iJoy1YCalc < -50) + iKeyPressed = 134; + if (iJoy1YCalc > 50) + iKeyPressed = 135; } - //if (iKeyPressed != -1 - // && (control_edit == 1 || control_edit == 7) - // && (*((char *)&keyname[139] + control_edit + 3) <= 0x83u && iKeyPressed > 131 || *((char *)&keyname[139] + control_edit + 3) > 0x83u && iKeyPressed <= 131)) { - // iKeyPressed = -1; - //} - if (iKeyPressed != -1) { - iDuplicateCheck = 0; - for (i = 0; i < control_edit; ++i) { - if (userkey[i] == iKeyPressed) - iDuplicateCheck = -1; - } - if (!iDuplicateCheck) { - iControlNext = control_edit + 1; - iControlSelect = control_select; - controlrelease = -1; - userkey[control_edit] = iKeyPressed; - //*((char *)&keyname[139] + iControlNext + 3) = iKeyPressed; - control_edit = iControlNext; - if (iControlSelect == 1) { - if (iControlNext == 6) { - define_mode = 0; - control_edit = -1; - while (fatkbhit()) - fatgetch(); - } - } else if (iControlNext == 12) { - control_edit = -1; + if (x1ok) { + iJoy1XCalc = + 100 * (2 * joyPos.iJ1XAxis - JAXmax - JAXmin) / + (JAXmax - JAXmin); // Calculate joystick axis positions: 132-139 + // are axis directions + if (iJoy1XCalc < -50) + iKeyPressed = 132; + if (iJoy1XCalc > 50) + iKeyPressed = 133; + } + } + if (iKeyPressed != -1 && (control_edit == 1 || control_edit == 7) && + (userkey[control_edit] <= 0x83u) != (iKeyPressed <= 131)) { + iKeyPressed = -1; // Reject mixed keyboard/joystick input types + } + // if (iKeyPressed != -1 + // && (control_edit == 1 || control_edit == 7) + // && (*((char *)&keyname[139] + control_edit + 3) <= 0x83u && + // iKeyPressed > 131 || *((char *)&keyname[139] + control_edit + 3) > + // 0x83u && iKeyPressed <= 131)) { iKeyPressed = -1; + // } + if (iKeyPressed != -1) { + iDuplicateCheck = 0; + for (i = 0; i < control_edit; ++i) { + if (userkey[i] == iKeyPressed) + iDuplicateCheck = -1; + } + if (!iDuplicateCheck) { + iControlNext = control_edit + 1; + iControlSelect = control_select; + controlrelease = -1; + userkey[control_edit] = iKeyPressed; + //*((char *)&keyname[139] + iControlNext + 3) = iKeyPressed; + control_edit = iControlNext; + if (iControlSelect == 1) { + if (iControlNext == 6) { define_mode = 0; + control_edit = -1; while (fatkbhit()) fatgetch(); } + } else if (iControlNext == 12) { + control_edit = -1; + define_mode = 0; + while (fatkbhit()) + fatgetch(); } } } - if (keys[WHIP_SCANCODE_ESCAPE]) { - define_mode = 0; - memcpy(userkey, oldkeys, 0xCu); - memcpy(&userkey[12], &oldkeys[12], 2u); - while (fatkbhit()) - fatgetch(); - pausewindow = 0; - check_joystick_usage(); - } } - break; - case 3: - blankwindow(0, 0, 320, 200); // Case 3: Graphics settings window - prt_centrecol(rev_vga[1], &config_buffer[576], 160, 12, 171); + if (keys[WHIP_SCANCODE_ESCAPE]) { + define_mode = 0; + memcpy(userkey, oldkeys, 0xCu); + memcpy(&userkey[12], &oldkeys[12], 2u); + while (fatkbhit()) + fatgetch(); + pausewindow = 0; + check_joystick_usage(); + } + } + break; + case 3: + blankwindow(0, 0, 320, 200); // Case 3: Graphics settings window + prt_centrecol(rev_vga[1], &config_buffer[576], 160, 12, 171); + if (graphic_mode == 16) + byPerspectiveColor = 0x8F; + else + byPerspectiveColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[6912], 187, 26, byPerspectiveColor); + if ((textures_off & 0x80000) != + 0) // TEX_OFF_PERSPECTIVE_CORRECTION texture flag check + { if (graphic_mode == 16) - byPerspectiveColor = 0x8F; + byPerspectiveOnOff = 0x8F; else - byPerspectiveColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[6912], 187, 26, byPerspectiveColor); - if ((textures_off & 0x80000) != 0) // TEX_OFF_PERSPECTIVE_CORRECTION texture flag check - { - if (graphic_mode == 16) - byPerspectiveOnOff = 0x8F; - else - byPerspectiveOnOff = 0x83; - pszPerspectiveText = &config_buffer[2688]; - } else { - if (graphic_mode == 16) - byPerspectiveOnOff = 0x8F; - else - byPerspectiveOnOff = 0x83; - pszPerspectiveText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszPerspectiveText, 190, 26, byPerspectiveOnOff); - sprintf(buffer, "%s:", &config_buffer[3968]); - if (graphic_mode == 15) - byNamesColor = 0x8F; + byPerspectiveOnOff = 0x83; + pszPerspectiveText = &config_buffer[2688]; + } else { + if (graphic_mode == 16) + byPerspectiveOnOff = 0x8F; else - byNamesColor = 0x83; - prt_rightcol(rev_vga[1], buffer, 187, 36, byNamesColor); - if (names_on) { - if (names_on == 2) { - if (graphic_mode == 15) - byNamesOnOff = 0x8F; - else - byNamesOnOff = 0x83; - pszNamesText = &config_buffer[2816]; - } else { - if (graphic_mode == 15) - byNamesOnOff = 0x8F; - else - byNamesOnOff = 0x83; - pszNamesText = &config_buffer[2624]; - } + byPerspectiveOnOff = 0x83; + pszPerspectiveText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszPerspectiveText, 190, 26, byPerspectiveOnOff); + sprintf(buffer, "%s:", &config_buffer[3968]); + if (graphic_mode == 15) + byNamesColor = 0x8F; + else + byNamesColor = 0x83; + prt_rightcol(rev_vga[1], buffer, 187, 36, byNamesColor); + if (names_on) { + if (names_on == 2) { + if (graphic_mode == 15) + byNamesOnOff = 0x8F; + else + byNamesOnOff = 0x83; + pszNamesText = &config_buffer[2816]; } else { if (graphic_mode == 15) byNamesOnOff = 0x8F; else byNamesOnOff = 0x83; - pszNamesText = &config_buffer[2688]; + pszNamesText = &config_buffer[2624]; } - prt_stringcol(rev_vga[1], pszNamesText, 190, 36, byNamesOnOff); + } else { + if (graphic_mode == 15) + byNamesOnOff = 0x8F; + else + byNamesOnOff = 0x83; + pszNamesText = &config_buffer[2688]; + } + prt_stringcol(rev_vga[1], pszNamesText, 190, 36, byNamesOnOff); + if (graphic_mode == 14) + byBuildingsColor = 0x8F; + else + byBuildingsColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3008], 187, 46, byBuildingsColor); + if ((textures_off & 0x200) != 0) // TEX_OFF_BUILDINGS texture flag check + { if (graphic_mode == 14) - byBuildingsColor = 0x8F; + byBuildingStatus = 0x8F; else - byBuildingsColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3008], 187, 46, byBuildingsColor); - if ((textures_off & 0x200) != 0) // TEX_OFF_BUILDINGS texture flag check - { - if (graphic_mode == 14) - byBuildingStatus = 0x8F; - else - byBuildingStatus = 0x83; - pszBuildingText = &config_buffer[2688]; - } else { - if (graphic_mode == 14) - byBuildingStatus = 0x8F; - else - byBuildingStatus = 0x83; - pszBuildingText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszBuildingText, 190, 46, byBuildingStatus); + byBuildingStatus = 0x83; + pszBuildingText = &config_buffer[2688]; + } else { + if (graphic_mode == 14) + byBuildingStatus = 0x8F; + else + byBuildingStatus = 0x83; + pszBuildingText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszBuildingText, 190, 46, byBuildingStatus); + if (graphic_mode == 13) + byGlassColor = 0x8F; + else + byGlassColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3072], 187, 56, byGlassColor); + if ((textures_off & 0x800) != 0) // TEX_OFF_GLASS_WALLS texture flag check + { if (graphic_mode == 13) - byGlassColor = 0x8F; + byGlassStatus = 0x8F; else - byGlassColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3072], 187, 56, byGlassColor); - if ((textures_off & 0x800) != 0) // TEX_OFF_GLASS_WALLS texture flag check - { - if (graphic_mode == 13) - byGlassStatus = 0x8F; - else - byGlassStatus = 0x83; - pszGlassText = &config_buffer[2688]; - } else { - if (graphic_mode == 13) - byGlassStatus = 0x8F; - else - byGlassStatus = 0x83; - pszGlassText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszGlassText, 190, 56, byGlassStatus); + byGlassStatus = 0x83; + pszGlassText = &config_buffer[2688]; + } else { + if (graphic_mode == 13) + byGlassStatus = 0x8F; + else + byGlassStatus = 0x83; + pszGlassText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszGlassText, 190, 56, byGlassStatus); + if (graphic_mode == 12) + byHorizonColor = 0x8F; + else + byHorizonColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3200], 187, 66, byHorizonColor); + if ((textures_off & 0x10) != 0) // TEX_OFF_HORIZON texture flag check + { if (graphic_mode == 12) - byHorizonColor = 0x8F; + byHorizonStatus = 0x8F; else - byHorizonColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3200], 187, 66, byHorizonColor); - if ((textures_off & 0x10) != 0) // TEX_OFF_HORIZON texture flag check - { - if (graphic_mode == 12) - byHorizonStatus = 0x8F; - else - byHorizonStatus = 0x83; - pszHorizonText = &config_buffer[2688]; - } else { - if (graphic_mode == 12) - byHorizonStatus = 0x8F; - else - byHorizonStatus = 0x83; - pszHorizonText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszHorizonText, 190, 66, byHorizonStatus); + byHorizonStatus = 0x83; + pszHorizonText = &config_buffer[2688]; + } else { + if (graphic_mode == 12) + byHorizonStatus = 0x8F; + else + byHorizonStatus = 0x83; + pszHorizonText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszHorizonText, 190, 66, byHorizonStatus); + if (graphic_mode == 11) + byCarTexColor = 0x8F; + else + byCarTexColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3136], 187, 76, byCarTexColor); + if ((textures_off & 0x40) != 0) // TEX_OFF_CAR_TEXTURES texture flag check + { if (graphic_mode == 11) - byCarTexColor = 0x8F; + byCarTexStatus = 0x8F; else - byCarTexColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3136], 187, 76, byCarTexColor); - if ((textures_off & 0x40) != 0) // TEX_OFF_CAR_TEXTURES texture flag check - { - if (graphic_mode == 11) - byCarTexStatus = 0x8F; - else - byCarTexStatus = 0x83; - pszCarTexText = &config_buffer[2688]; - } else { - if (graphic_mode == 11) - byCarTexStatus = 0x8F; - else - byCarTexStatus = 0x83; - pszCarTexText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszCarTexText, 190, 76, byCarTexStatus); + byCarTexStatus = 0x83; + pszCarTexText = &config_buffer[2688]; + } else { + if (graphic_mode == 11) + byCarTexStatus = 0x8F; + else + byCarTexStatus = 0x83; + pszCarTexText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszCarTexText, 190, 76, byCarTexStatus); + if (graphic_mode == 10) + byWallTexColor = 0x8F; + else + byWallTexColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3264], 187, 86, byWallTexColor); + if ((textures_off & 4) != 0) // TEX_OFF_WALL_TEXTURES texture flag check + { if (graphic_mode == 10) - byWallTexColor = 0x8F; + byWallTexStatus = 0x8F; else - byWallTexColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3264], 187, 86, byWallTexColor); - if ((textures_off & 4) != 0) // TEX_OFF_WALL_TEXTURES texture flag check - { - if (graphic_mode == 10) - byWallTexStatus = 0x8F; - else - byWallTexStatus = 0x83; - pszWallTexText = &config_buffer[2688]; - } else { - if (graphic_mode == 10) - byWallTexStatus = 0x8F; - else - byWallTexStatus = 0x83; - pszWallTexText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszWallTexText, 190, 86, byWallTexStatus); + byWallTexStatus = 0x83; + pszWallTexText = &config_buffer[2688]; + } else { + if (graphic_mode == 10) + byWallTexStatus = 0x8F; + else + byWallTexStatus = 0x83; + pszWallTexText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszWallTexText, 190, 86, byWallTexStatus); + if (graphic_mode == 9) + byGroundTexColor = 0x8F; + else + byGroundTexColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3328], 187, 96, byGroundTexColor); + if ((textures_off & 1) != 0) // TEX_OFF_GROUND_TEXTURES texture flag check + { if (graphic_mode == 9) - byGroundTexColor = 0x8F; + byGroundTexStatus = 0x8F; else - byGroundTexColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3328], 187, 96, byGroundTexColor); - if ((textures_off & 1) != 0) // TEX_OFF_GROUND_TEXTURES texture flag check - { - if (graphic_mode == 9) - byGroundTexStatus = 0x8F; - else - byGroundTexStatus = 0x83; - pszGroundTexText = &config_buffer[2688]; - } else { - if (graphic_mode == 9) - byGroundTexStatus = 0x8F; - else - byGroundTexStatus = 0x83; - pszGroundTexText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszGroundTexText, 190, 96, byGroundTexStatus); + byGroundTexStatus = 0x83; + pszGroundTexText = &config_buffer[2688]; + } else { + if (graphic_mode == 9) + byGroundTexStatus = 0x8F; + else + byGroundTexStatus = 0x83; + pszGroundTexText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszGroundTexText, 190, 96, byGroundTexStatus); + if (graphic_mode == 8) + byBuildingTexColor = 0x8F; + else + byBuildingTexColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3392], 187, 106, + byBuildingTexColor); + if ((textures_off & 0x80u) == + 0) // TEX_OFF_BUILDING_TEXTURES texture flag check + { if (graphic_mode == 8) - byBuildingTexColor = 0x8F; + byBuildingTexStatus = 0x8F; else - byBuildingTexColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3392], 187, 106, byBuildingTexColor); - if ((textures_off & 0x80u) == 0) // TEX_OFF_BUILDING_TEXTURES texture flag check - { - if (graphic_mode == 8) - byBuildingTexStatus = 0x8F; - else - byBuildingTexStatus = 0x83; - pszBuildingTexText = &config_buffer[2624]; - } else { - if (graphic_mode == 8) - byBuildingTexStatus = 0x8F; - else - byBuildingTexStatus = 0x83; - pszBuildingTexText = &config_buffer[2688]; - } - prt_stringcol(rev_vga[1], pszBuildingTexText, 190, 106, byBuildingTexStatus); + byBuildingTexStatus = 0x83; + pszBuildingTexText = &config_buffer[2624]; + } else { + if (graphic_mode == 8) + byBuildingTexStatus = 0x8F; + else + byBuildingTexStatus = 0x83; + pszBuildingTexText = &config_buffer[2688]; + } + prt_stringcol(rev_vga[1], pszBuildingTexText, 190, 106, + byBuildingTexStatus); + if (graphic_mode == 7) + byRoadTexColor = 0x8F; + else + byRoadTexColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3456], 187, 116, byRoadTexColor); + if ((textures_off & 2) != 0) // TEX_OFF_ROAD_TEXTURES texture flag check + { if (graphic_mode == 7) - byRoadTexColor = 0x8F; + byRoadTexStatus = 0x8F; else - byRoadTexColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3456], 187, 116, byRoadTexColor); - if ((textures_off & 2) != 0) // TEX_OFF_ROAD_TEXTURES texture flag check - { - if (graphic_mode == 7) - byRoadTexStatus = 0x8F; - else - byRoadTexStatus = 0x83; - pszRoadTexText = &config_buffer[2688]; - } else { - if (graphic_mode == 7) - byRoadTexStatus = 0x8F; - else - byRoadTexStatus = 0x83; - pszRoadTexText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszRoadTexText, 190, 116, byRoadTexStatus); + byRoadTexStatus = 0x83; + pszRoadTexText = &config_buffer[2688]; + } else { + if (graphic_mode == 7) + byRoadTexStatus = 0x8F; + else + byRoadTexStatus = 0x83; + pszRoadTexText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszRoadTexText, 190, 116, byRoadTexStatus); + if (graphic_mode == 6) + byShadowsColor = 0x8F; + else + byShadowsColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3520], 187, 126, byShadowsColor); + if ((textures_off & 0x100) != 0) // TEX_OFF_SHADOWS texture flag check + { if (graphic_mode == 6) - byShadowsColor = 0x8F; + byShadowsStatus = 0x8F; else - byShadowsColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3520], 187, 126, byShadowsColor); - if ((textures_off & 0x100) != 0) // TEX_OFF_SHADOWS texture flag check - { - if (graphic_mode == 6) - byShadowsStatus = 0x8F; - else - byShadowsStatus = 0x83; - pszShadowsText = &config_buffer[2688]; - } else { - if (graphic_mode == 6) - byShadowsStatus = 0x8F; - else - byShadowsStatus = 0x83; - pszShadowsText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszShadowsText, 190, 126, byShadowsStatus); + byShadowsStatus = 0x83; + pszShadowsText = &config_buffer[2688]; + } else { + if (graphic_mode == 6) + byShadowsStatus = 0x8F; + else + byShadowsStatus = 0x83; + pszShadowsText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszShadowsText, 190, 126, byShadowsStatus); + if (graphic_mode == 5) + byCloudsColor = 0x8F; + else + byCloudsColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3584], 187, 136, byCloudsColor); + if ((textures_off & 8) != 0) // TEX_OFF_CLOUDS texture flag check + { if (graphic_mode == 5) - byCloudsColor = 0x8F; + byCloudsStatus = 0x8F; else - byCloudsColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3584], 187, 136, byCloudsColor); - if ((textures_off & 8) != 0) // TEX_OFF_CLOUDS texture flag check - { - if (graphic_mode == 5) - byCloudsStatus = 0x8F; - else - byCloudsStatus = 0x83; - pszCloudsText = &config_buffer[2688]; - } else { - if (graphic_mode == 5) - byCloudsStatus = 0x8F; - else - byCloudsStatus = 0x83; - pszCloudsText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszCloudsText, 190, 136, byCloudsStatus); + byCloudsStatus = 0x83; + pszCloudsText = &config_buffer[2688]; + } else { + if (graphic_mode == 5) + byCloudsStatus = 0x8F; + else + byCloudsStatus = 0x83; + pszCloudsText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszCloudsText, 190, 136, byCloudsStatus); + if (graphic_mode == 4) + byPanelColor = 0x8F; + else + byPanelColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3648], 187, 146, byPanelColor); + if ((textures_off & 0x20) != + 0) // TEX_OFF_PANEL_OFF and TEX_OFF_PANEL_RESTRICTED flags check + { if (graphic_mode == 4) - byPanelColor = 0x8F; + byPanelStatus = 0x8F; else - byPanelColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3648], 187, 146, byPanelColor); - if ((textures_off & 0x20) != 0) // TEX_OFF_PANEL_OFF and TEX_OFF_PANEL_RESTRICTED flags check - { - if (graphic_mode == 4) - byPanelStatus = 0x8F; - else - byPanelStatus = 0x83; - pszPanelText = &config_buffer[2688]; - } else if ((textures_off & 0x40000) != 0) // TEX_OFF_PANEL_RESTRICTED - { - if (graphic_mode == 4) - byPanelStatus = 0x8F; - else - byPanelStatus = 0x83; - pszPanelText = &config_buffer[3776]; - } else { - if (graphic_mode == 4) - byPanelStatus = 0x8F; - else - byPanelStatus = 0x83; - pszPanelText = &config_buffer[2624]; - } - prt_stringcol(rev_vga[1], pszPanelText, 190, 146, byPanelStatus); - if (graphic_mode == 3) - byViewLimitColor = 0x8F; + byPanelStatus = 0x83; + pszPanelText = &config_buffer[2688]; + } else if ((textures_off & 0x40000) != 0) // TEX_OFF_PANEL_RESTRICTED + { + if (graphic_mode == 4) + byPanelStatus = 0x8F; else - byViewLimitColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3712], 187, 156, byViewLimitColor); - if (view_limit) { - if (graphic_mode == 3) - byViewLimitStatus = 0x8F; - else - byViewLimitStatus = 0x83; - pszViewLimitText = &config_buffer[3776]; - } else { - if (graphic_mode == 3) - byViewLimitStatus = 0x8F; - else - byViewLimitStatus = 0x83; - pszViewLimitText = &config_buffer[3840]; - } - prt_stringcol(rev_vga[1], pszViewLimitText, 190, 156, byViewLimitStatus); - if (graphic_mode == 2) - bySizeColor = 0x8F; + byPanelStatus = 0x83; + pszPanelText = &config_buffer[3776]; + } else { + if (graphic_mode == 4) + byPanelStatus = 0x8F; else - bySizeColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[3904], 187, 166, bySizeColor); - if (SVGA_ON) - iSizePercent = (100 * req_size) / 128; - //iSizePercent = (100 * req_size - (__CFSHL__((100 * req_size) >> 31, 7) + ((100 * req_size) >> 31 << 7))) >> 7;// Calculate display percentage for SVGA mode (divide by 128) vs VGA (divide by 64) + byPanelStatus = 0x83; + pszPanelText = &config_buffer[2624]; + } + prt_stringcol(rev_vga[1], pszPanelText, 190, 146, byPanelStatus); + if (graphic_mode == 3) + byViewLimitColor = 0x8F; + else + byViewLimitColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3712], 187, 156, byViewLimitColor); + if (view_limit) { + if (graphic_mode == 3) + byViewLimitStatus = 0x8F; else - iSizePercent = (100 * req_size) / 64; - //iSizePercent = (100 * req_size - (__CFSHL__((100 * req_size) >> 31, 6) + ((100 * req_size) >> 31 << 6))) >> 6; - sprintf(buffer, "%3i %%", iSizePercent); - if (graphic_mode == 2) - bySizeDisplayColor = 0x8F; + byViewLimitStatus = 0x83; + pszViewLimitText = &config_buffer[3776]; + } else { + if (graphic_mode == 3) + byViewLimitStatus = 0x8F; else - bySizeDisplayColor = 0x83; - prt_stringcol(rev_vga[1], buffer, 190, 166, bySizeDisplayColor); - if (SVGA_ON) { - if (graphic_mode == 1) - bySVGAColor = 0x8F; - else - bySVGAColor = 0x83; - pszSVGAText = &config_buffer[512]; - } else { - if (graphic_mode == 1) - bySVGAColor = 0x8F; - else - bySVGAColor = 0x83; - pszSVGAText = &config_buffer[448]; - } - prt_centrecol(rev_vga[1], pszSVGAText, 160, 176, bySVGAColor); - if (graphic_mode) - byExitColor = 0x83; + byViewLimitStatus = 0x83; + pszViewLimitText = &config_buffer[3840]; + } + prt_stringcol(rev_vga[1], pszViewLimitText, 190, 156, byViewLimitStatus); + if (graphic_mode == 2) + bySizeColor = 0x8F; + else + bySizeColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[3904], 187, 166, bySizeColor); + if (SVGA_ON) + iSizePercent = (100 * req_size) / 128; + // iSizePercent = (100 * req_size - (__CFSHL__((100 * req_size) >> 31, 7) + + // ((100 * req_size) >> 31 << 7))) >> 7;// Calculate display percentage for + // SVGA mode (divide by 128) vs VGA (divide by 64) + else + iSizePercent = (100 * req_size) / 64; + // iSizePercent = (100 * req_size - (__CFSHL__((100 * req_size) >> 31, 6) + + // ((100 * req_size) >> 31 << 6))) >> 6; + sprintf(buffer, "%3i %%", iSizePercent); + if (graphic_mode == 2) + bySizeDisplayColor = 0x8F; + else + bySizeDisplayColor = 0x83; + prt_stringcol(rev_vga[1], buffer, 190, 166, bySizeDisplayColor); + if (SVGA_ON) { + if (graphic_mode == 1) + bySVGAColor = 0x8F; else - byExitColor = 0x8F; - prt_rightcol(rev_vga[1], &config_buffer[832], 187, 186, byExitColor); - break; - case 4: - blankwindow(0, 0, 320, 200); // Case 4: Sound settings window - prt_centrecol(rev_vga[1], &config_buffer[2240], 160, 16, 171); - if (sound_edit == 1) - bySoundColor1 = 0x8F; + bySVGAColor = 0x83; + pszSVGAText = &config_buffer[512]; + } else { + if (graphic_mode == 1) + bySVGAColor = 0x8F; else - bySoundColor1 = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2304], 172, 48, bySoundColor1); - volumebar(48, EngineVolume); // Display engine volume bar at Y position 48 - if (sound_edit == 2) - bySoundColor2 = 0x8F; + bySVGAColor = 0x83; + pszSVGAText = &config_buffer[448]; + } + prt_centrecol(rev_vga[1], pszSVGAText, 160, 176, bySVGAColor); + if (graphic_mode) + byExitColor = 0x83; + else + byExitColor = 0x8F; + prt_rightcol(rev_vga[1], &config_buffer[832], 187, 186, byExitColor); + break; + case 4: + blankwindow(0, 0, 320, 200); // Case 4: Sound settings window + prt_centrecol(rev_vga[1], &config_buffer[2240], 160, 16, 171); + if (sound_edit == 1) + bySoundColor1 = 0x8F; + else + bySoundColor1 = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2304], 172, 48, bySoundColor1); + volumebar(48, EngineVolume); // Display engine volume bar at Y position 48 + if (sound_edit == 2) + bySoundColor2 = 0x8F; + else + bySoundColor2 = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2368], 172, 60, bySoundColor2); + volumebar(60, SFXVolume); // Display SFX volume bar at Y position 60 + if (sound_edit == 3) + bySoundColor3 = 0x8F; + else + bySoundColor3 = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2432], 172, 72, bySoundColor3); + volumebar(72, SpeechVolume); // Display speech volume bar at Y position 72 + if (sound_edit == 4) + bySoundColor4 = 0x8F; + else + bySoundColor4 = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2496], 172, 84, bySoundColor4); + volumebar(84, MusicVolume); // Display music volume bar at Y position 84 + if (sound_edit == 5) + bySoundColor5 = 0x8F; + else + bySoundColor5 = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2560], 172, 96, bySoundColor5); + if (allengines) { + if (sound_edit == 5) + byEngineColor = 0x8F; else - bySoundColor2 = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2368], 172, 60, bySoundColor2); - volumebar(60, SFXVolume); // Display SFX volume bar at Y position 60 - if (sound_edit == 3) - bySoundColor3 = 0x8F; + byEngineColor = 0x83; + pszEngineText = &config_buffer[2752]; + } else { + if (sound_edit == 5) + byEngineColor = 0x8F; else - bySoundColor3 = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2432], 172, 72, bySoundColor3); - volumebar(72, SpeechVolume); // Display speech volume bar at Y position 72 - if (sound_edit == 4) - bySoundColor4 = 0x8F; + byEngineColor = 0x83; + pszEngineText = &config_buffer[2816]; + } + prt_stringcol(rev_vga[1], pszEngineText, 175, 96, byEngineColor); + if (sound_edit == 6) + bySoundOnColor = 0x8F; + else + bySoundOnColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2880], 172, 108, bySoundOnColor); + if (soundon) { + if (sound_edit == 6) + bySoundStatus1 = 0x8F; else - bySoundColor4 = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2496], 172, 84, bySoundColor4); - volumebar(84, MusicVolume); // Display music volume bar at Y position 84 - if (sound_edit == 5) - bySoundColor5 = 0x8F; + bySoundStatus1 = 0x83; + pszSoundStatus1 = &config_buffer[2624]; + } else if (SoundCard) { + if (sound_edit == 6) + bySoundStatus1 = 0x8F; else - bySoundColor5 = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2560], 172, 96, bySoundColor5); - if (allengines) { - if (sound_edit == 5) - byEngineColor = 0x8F; - else - byEngineColor = 0x83; - pszEngineText = &config_buffer[2752]; - } else { - if (sound_edit == 5) - byEngineColor = 0x8F; - else - byEngineColor = 0x83; - pszEngineText = &config_buffer[2816]; - } - prt_stringcol(rev_vga[1], pszEngineText, 175, 96, byEngineColor); + bySoundStatus1 = 0x83; + pszSoundStatus1 = &config_buffer[2688]; + } else { if (sound_edit == 6) - bySoundOnColor = 0x8F; + bySoundStatus1 = 0x8F; else - bySoundOnColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2880], 172, 108, bySoundOnColor); - if (soundon) { - if (sound_edit == 6) - bySoundStatus1 = 0x8F; - else - bySoundStatus1 = 0x83; - pszSoundStatus1 = &config_buffer[2624]; - } else if (SoundCard) { - if (sound_edit == 6) - bySoundStatus1 = 0x8F; - else - bySoundStatus1 = 0x83; - pszSoundStatus1 = &config_buffer[2688]; - } else { - if (sound_edit == 6) - bySoundStatus1 = 0x8F; - else - bySoundStatus1 = 0x83; - pszSoundStatus1 = &config_buffer[6848]; - } - prt_stringcol(rev_vga[1], pszSoundStatus1, 175, 108, bySoundStatus1); + bySoundStatus1 = 0x83; + pszSoundStatus1 = &config_buffer[6848]; + } + prt_stringcol(rev_vga[1], pszSoundStatus1, 175, 108, bySoundStatus1); + if (sound_edit == 7) + byMusicColor = 0x8F; + else + byMusicColor = 0x83; + prt_rightcol(rev_vga[1], &config_buffer[2944], 172, 120, byMusicColor); + if (musicon) { if (sound_edit == 7) - byMusicColor = 0x8F; + byMusicStatus = 0x8F; else - byMusicColor = 0x83; - prt_rightcol(rev_vga[1], &config_buffer[2944], 172, 120, byMusicColor); - if (musicon) { - if (sound_edit == 7) - byMusicStatus = 0x8F; - else - byMusicStatus = 0x83; - pszMusicStatus = &config_buffer[2624]; - } else if (MusicCard || MusicCD) { - if (sound_edit == 7) - byMusicStatus = 0x8F; - else - byMusicStatus = 0x83; - pszMusicStatus = &config_buffer[2688]; - } else { - if (sound_edit == 7) - byMusicStatus = 0x8F; - else - byMusicStatus = 0x83; - pszMusicStatus = &config_buffer[6848]; - } - prt_stringcol(rev_vga[1], pszMusicStatus, 175, 120, byMusicStatus); - if (sound_edit) - byBackColor = 0x83; + byMusicStatus = 0x83; + pszMusicStatus = &config_buffer[2624]; + } else if (MusicCard || MusicCD) { + if (sound_edit == 7) + byMusicStatus = 0x8F; else - byBackColor = 0x8F; - prt_rightcol(rev_vga[1], &config_buffer[832], 172, 132, byBackColor); - break; - default: - return; // Switch on pause window mode: 0=main menu, 1=joystick calibration, 2=controls, 3=graphics, 4=sound + byMusicStatus = 0x83; + pszMusicStatus = &config_buffer[2688]; + } else { + if (sound_edit == 7) + byMusicStatus = 0x8F; + else + byMusicStatus = 0x83; + pszMusicStatus = &config_buffer[6848]; + } + prt_stringcol(rev_vga[1], pszMusicStatus, 175, 120, byMusicStatus); + if (sound_edit) + byBackColor = 0x83; + else + byBackColor = 0x8F; + prt_rightcol(rev_vga[1], &config_buffer[832], 172, 132, byBackColor); + break; + default: + return; // Switch on pause window mode: 0=main menu, 1=joystick calibration, + // 2=controls, 3=graphics, 4=sound } } //------------------------------------------------------------------------------------------------- -//0001ABF0 -void enable_keyboard() -{ +// 0001ABF0 +void enable_keyboard() { // Process all pending events first to ensure buffer is current UpdateSDL(); @@ -3532,9 +3789,8 @@ void enable_keyboard() } //------------------------------------------------------------------------------------------------- -//0001AC30 -void disable_keyboard() -{ +// 0001AC30 +void disable_keyboard() { // Process all pending events first to ensure buffer is current UpdateSDL(); @@ -3545,9 +3801,8 @@ void disable_keyboard() } //------------------------------------------------------------------------------------------------- -//0001AC70 -void save_fatal_config() -{ +// 0001AC70 +void save_fatal_config() { FILE *fp = ROLLERfopen("FATAL.INI", "w"); fprintf(fp, "EngineVolume=%d\n", (4 * ((EngineVolume + 1) / 4))); fprintf(fp, "SFXVolume=%d\n", (4 * ((SFXVolume + 1) / 4))); @@ -3671,7 +3926,7 @@ void save_fatal_config() fwrite(pBuf, 1, uiSize, fp); fclose(fp); } - fre((void**)&pBuf); + fre((void **)&pBuf); } else { fclose(fp); ROLLERremove("FATAL.INI"); @@ -3680,89 +3935,88 @@ void save_fatal_config() } //------------------------------------------------------------------------------------------------- -//0001B4A0 -void load_fatal_config() -{ - FILE *pFile; // eax - FILE *pFile2; // edi - int iLength; // ebp - char *pData; // eax - int i; // eax - char *pBuffer; // ebx - char *szEnd; // eax - char cEnd; // dh - char *pBuffer2; // ebx - char *szEnd2; // eax - char cEnd2; // cl - char *pBuffer3; // ebx - char *szEnd3; // eax - char cEnd3; // dl - char *pBuffer4; // ebx - char *szEnd4; // eax - char cEnd4; // cl - char *pBuffer5; // ebx - char *szEnd5; // eax - char cEnd5; // dl - char *pBuffer6; // ebx - char *szEnd6; // eax - char cEnd6; // cl - char *pBuffer7; // ebx - char *szEnd7; // eax - char cEnd7; // dl - char *pBuffer8; // ebx - char *szEnd8; // eax - char cBuffer8; // cl - char *pBuffer9; // ebx - char *szEnd9; // eax - char cEnd9; // dl - char *pBuffer10; // ebx - char *szEnd10; // eax - char cEnd10; // cl - char *pBuffer11; // ebx - char *szEnd11; // eax - char cEnd11; // dl - char *pBuffer12; // ebx - char *szEnd12; // eax - char cEnd12; // cl - char *pBuffer13; // ebx - char *szEnd13; // eax - char cEnd13; // dl - char *pBuffer14; // ebx - char *szEnd14; // eax - char cEnd14; // cl - char *pBuffer15; // ebx - char *szEnd15; // eax - char cEnd15; // dl - char *pBuffer16; // ebx - char *szEnd16; // eax - char cEnd16; // cl - char *pBuffer17; // ebx - char *szEnd17; // eax - char cEnd17; // dl - char *pBuffer18; // ebx - char *szEnd18; // eax - char cEnd18; // cl - char *szSLOWCOACH; // ebx - char *szEnd19; // eax - char cEnd19; // dl - char *szOutOfMyWay; // ebx - char *szEnd20; // eax - char cEnd20; // dh - char *szYouDie; // ebx - char *szEnd21; // eax - char cEnd21; // cl - char *szSucker; // ebx - char *szEnd22; // eax - char cEnd22; // ch +// 0001B4A0 +void load_fatal_config() { + FILE *pFile; // eax + FILE *pFile2; // edi + int iLength; // ebp + char *pData; // eax + int i; // eax + char *pBuffer; // ebx + char *szEnd; // eax + char cEnd; // dh + char *pBuffer2; // ebx + char *szEnd2; // eax + char cEnd2; // cl + char *pBuffer3; // ebx + char *szEnd3; // eax + char cEnd3; // dl + char *pBuffer4; // ebx + char *szEnd4; // eax + char cEnd4; // cl + char *pBuffer5; // ebx + char *szEnd5; // eax + char cEnd5; // dl + char *pBuffer6; // ebx + char *szEnd6; // eax + char cEnd6; // cl + char *pBuffer7; // ebx + char *szEnd7; // eax + char cEnd7; // dl + char *pBuffer8; // ebx + char *szEnd8; // eax + char cBuffer8; // cl + char *pBuffer9; // ebx + char *szEnd9; // eax + char cEnd9; // dl + char *pBuffer10; // ebx + char *szEnd10; // eax + char cEnd10; // cl + char *pBuffer11; // ebx + char *szEnd11; // eax + char cEnd11; // dl + char *pBuffer12; // ebx + char *szEnd12; // eax + char cEnd12; // cl + char *pBuffer13; // ebx + char *szEnd13; // eax + char cEnd13; // dl + char *pBuffer14; // ebx + char *szEnd14; // eax + char cEnd14; // cl + char *pBuffer15; // ebx + char *szEnd15; // eax + char cEnd15; // dl + char *pBuffer16; // ebx + char *szEnd16; // eax + char cEnd16; // cl + char *pBuffer17; // ebx + char *szEnd17; // eax + char cEnd17; // dl + char *pBuffer18; // ebx + char *szEnd18; // eax + char cEnd18; // cl + char *szSLOWCOACH; // ebx + char *szEnd19; // eax + char cEnd19; // dl + char *szOutOfMyWay; // ebx + char *szEnd20; // eax + char cEnd20; // dh + char *szYouDie; // ebx + char *szEnd21; // eax + char cEnd21; // cl + char *szSucker; // ebx + char *szEnd22; // eax + char cEnd22; // ch char *pModemInitstring; // ebx - char *szEnd23; // eax - char cEnd23; // dl - char *pModemPhone; // ebx - char *szEnd24; // eax - char cEnd24; // dh - int iTemp; // [esp+0h] [ebp-24h] BYREF - char *pData2; // [esp+4h] [ebp-20h] BYREF - int iTemp2[7]; // [esp+8h] [ebp-1Ch] BYREF // not an array + char *szEnd23; // eax + char cEnd23; // dl + char *pModemPhone; // ebx + char *szEnd24; // eax + char cEnd24; // dh + int iTemp; // [esp+0h] [ebp-24h] BYREF + char *pData2; // [esp+4h] [ebp-20h] BYREF + int iTemp2[7]; // [esp+8h] [ebp-1Ch] BYREF // not an array JAXmin = 10000; JAXmax = -10000; @@ -3845,20 +4099,32 @@ void load_fatal_config() getconfigvalue(pData2, "Names", &names_on, 0, 2); // Read keyboard mappings - getconfigvalueuc(pData2, "P1left", (uint8*)&userkey[USERKEY_P1LEFT], 0, 139); - getconfigvalueuc(pData2, "P1right", (uint8*)&userkey[USERKEY_P1RIGHT], 0, 139); - getconfigvalueuc(pData2, "P1up", (uint8*)&userkey[USERKEY_P1UP], 0, 139); - getconfigvalueuc(pData2, "P1down", (uint8*)&userkey[USERKEY_P1DOWN], 0, 139); - getconfigvalueuc(pData2, "P1upgear", (uint8*)&userkey[USERKEY_P1UPGEAR], 0, 139); - getconfigvalueuc(pData2, "P1downgear", (uint8*)&userkey[USERKEY_P1DOWNGEAR], 0, 139); - getconfigvalueuc(pData2, "P1cheat", (uint8*)&userkey[USERKEY_P1CHEAT], 0, 139); - getconfigvalueuc(pData2, "P2left", (uint8*)&userkey[USERKEY_P2LEFT], 0, 139); - getconfigvalueuc(pData2, "P2right", (uint8*)&userkey[USERKEY_P2RIGHT], 0, 139); - getconfigvalueuc(pData2, "P2up", (uint8*)&userkey[USERKEY_P2UP], 0, 139); - getconfigvalueuc(pData2, "P2down", (uint8*)&userkey[USERKEY_P2DOWN], 0, 139); - getconfigvalueuc(pData2, "P2upgear", (uint8*)&userkey[USERKEY_P2UPGEAR], 0, 139); - getconfigvalueuc(pData2, "P2downgear", (uint8*)&userkey[USERKEY_P2DOWNGEAR], 0, 139); - getconfigvalueuc(pData2, "P2cheat", (uint8*)&userkey[USERKEY_P2CHEAT], 0, 139); + getconfigvalueuc(pData2, "P1left", (uint8 *)&userkey[USERKEY_P1LEFT], 0, + 139); + getconfigvalueuc(pData2, "P1right", (uint8 *)&userkey[USERKEY_P1RIGHT], 0, + 139); + getconfigvalueuc(pData2, "P1up", (uint8 *)&userkey[USERKEY_P1UP], 0, 139); + getconfigvalueuc(pData2, "P1down", (uint8 *)&userkey[USERKEY_P1DOWN], 0, + 139); + getconfigvalueuc(pData2, "P1upgear", (uint8 *)&userkey[USERKEY_P1UPGEAR], + 0, 139); + getconfigvalueuc(pData2, "P1downgear", + (uint8 *)&userkey[USERKEY_P1DOWNGEAR], 0, 139); + getconfigvalueuc(pData2, "P1cheat", (uint8 *)&userkey[USERKEY_P1CHEAT], 0, + 139); + getconfigvalueuc(pData2, "P2left", (uint8 *)&userkey[USERKEY_P2LEFT], 0, + 139); + getconfigvalueuc(pData2, "P2right", (uint8 *)&userkey[USERKEY_P2RIGHT], 0, + 139); + getconfigvalueuc(pData2, "P2up", (uint8 *)&userkey[USERKEY_P2UP], 0, 139); + getconfigvalueuc(pData2, "P2down", (uint8 *)&userkey[USERKEY_P2DOWN], 0, + 139); + getconfigvalueuc(pData2, "P2upgear", (uint8 *)&userkey[USERKEY_P2UPGEAR], + 0, 139); + getconfigvalueuc(pData2, "P2downgear", + (uint8 *)&userkey[USERKEY_P2DOWNGEAR], 0, 139); + getconfigvalueuc(pData2, "P2cheat", (uint8 *)&userkey[USERKEY_P2CHEAT], 0, + 139); // Read joystick config getconfigvalue(pData2, "Joy1X", &iTemp, 0, 1); @@ -4017,8 +4283,8 @@ void load_fatal_config() if (game_type == 1) TrackLoad = 8 * ((TrackLoad - 1) >> 3) + 1; - //added by ROLLER, compatibility with other releases - //TODO find out how other exes handle this + // added by ROLLER, compatibility with other releases + // TODO find out how other exes handle this if (TrackLoad < 1) TrackLoad = 1; @@ -4379,9 +4645,9 @@ void load_fatal_config() } //------------------------------------------------------------------------------------------------- -//0001C5A0 -void getconfigvalue(const char *szConfigText, const char *szVarName, int *piOutVal, int iMin, int iMax) -{ +// 0001C5A0 +void getconfigvalue(const char *szConfigText, const char *szVarName, + int *piOutVal, int iMin, int iMax) { int iTempVal; const char *szValue = FindConfigVar(szConfigText, szVarName); @@ -4398,9 +4664,9 @@ void getconfigvalue(const char *szConfigText, const char *szVarName, int *piOutV } //------------------------------------------------------------------------------------------------- -//0001C5E0 -void getconfigvalueuc(const char *szConfigText, const char *szVarName, uint8 *pbyOutVal, int iMin, int iMax) -{ +// 0001C5E0 +void getconfigvalueuc(const char *szConfigText, const char *szVarName, + uint8 *pbyOutVal, int iMin, int iMax) { short nTempVal; const char *szValue = FindConfigVar(szConfigText, szVarName); @@ -4416,62 +4682,79 @@ void getconfigvalueuc(const char *szConfigText, const char *szVarName, uint8 *pb } //------------------------------------------------------------------------------------------------- -//0001C650 -void displaycalibrationbar(int iX, int iY, int iValue) -{ - int iWinW; // esi - int iUseValue; // ebp - uint8 *pScrBuf; // ecx - int iSliderPos; // ebp - int iRowIdx; // edi - int iSliderXPos; // eax - int iSliderPos2; // ebp - int iRowIdx2; // edi +// 0001C650 +void displaycalibrationbar(int iX, int iY, int iValue) { + int iWinW; // esi + int iUseValue; // ebp + uint8 *pScrBuf; // ecx + int iSliderPos; // ebp + int iRowIdx; // edi + int iSliderXPos; // eax + int iSliderPos2; // ebp + int iRowIdx2; // edi int iSliderXPos2; // eax - int iSavedWinw; // [esp+0h] [ebp-1Ch] + int iSavedWinw; // [esp+0h] [ebp-1Ch] - iWinW = winw; // Save window width for restoration + iWinW = winw; // Save window width for restoration iUseValue = iValue; - if (iValue < -100) // Clamp calibration value to valid range [-100, +100] + if (iValue < -100) // Clamp calibration value to valid range [-100, +100] iUseValue = -100; if (iUseValue > 100) iUseValue = 100; - pScrBuf = &scrbuf[winw * iX / 320 + winw * ((iY * scr_size) >> 6)];// Calculate screen buffer position: scaled X and Y coordinates - iSavedWinw = (10 * scr_size) >> 6; // Calculate scaled bar height (10 * scr_size / 64) - if (current_mode) // Branch based on current_mode: different rendering styles + pScrBuf = &scrbuf[winw * iX / 320 + + winw * ((iY * scr_size) >> + 6)]; // Calculate screen buffer position: scaled X + // and Y coordinates + iSavedWinw = + (10 * scr_size) >> 6; // Calculate scaled bar height (10 * scr_size / 64) + if (current_mode) // Branch based on current_mode: different rendering styles { - iSliderPos = iUseValue + 103; // Mode 1: Calculate slider position (calibration value + 103) - for (iRowIdx = 0; iRowIdx < iSavedWinw; ++iRowIdx) { // Skip top and bottom border rows + iSliderPos = + iUseValue + + 103; // Mode 1: Calculate slider position (calibration value + 103) + for (iRowIdx = 0; iRowIdx < iSavedWinw; + ++iRowIdx) { // Skip top and bottom border rows if (iRowIdx && iRowIdx != iSavedWinw - 1) { - *pScrBuf = 0x8F; // Draw left border (color 0x8F = white) - pScrBuf[206 * iWinW / 640] = 0x8F; // Draw right border (color 0x8F = white) - iSliderXPos = iWinW * iSliderPos / 640; // Calculate slider position in pixels - pScrBuf[iSliderXPos] = 0xAB; // Draw slider indicator (center pixel, color 0xAB = orange) - pScrBuf[iSliderXPos - 1] = -85; // Draw slider sides (color 0xAB = orange) + *pScrBuf = 0x8F; // Draw left border (color 0x8F = white) + pScrBuf[206 * iWinW / 640] = + 0x8F; // Draw right border (color 0x8F = white) + iSliderXPos = + iWinW * iSliderPos / 640; // Calculate slider position in pixels + pScrBuf[iSliderXPos] = + 0xAB; // Draw slider indicator (center pixel, color 0xAB = orange) + pScrBuf[iSliderXPos - 1] = + -85; // Draw slider sides (color 0xAB = orange) pScrBuf[iSliderXPos - 2] = 0xAB; pScrBuf[iSliderXPos + 1] = 0xAB; pScrBuf[iSliderXPos + 2] = 0xAB; - pScrBuf[103 * iWinW / 640] = 0xE7; // Draw slider scale marks (color 0xE7 = red) + pScrBuf[103 * iWinW / 640] = + 0xE7; // Draw slider scale marks (color 0xE7 = red) pScrBuf[104 * iWinW / 640] = 0xE7; pScrBuf[102 * iWinW / 640] = 0xE7; } else { - winw = iWinW; // Top/bottom border: fill entire bar width with border color + winw = + iWinW; // Top/bottom border: fill entire bar width with border color memset(pScrBuf, 143, 104 * iWinW / 320 - 1); iWinW = winw; } pScrBuf += iWinW; } } else { - iSliderPos2 = iUseValue + 105; // Mode 0: Calculate slider position (calibration value + 105) + iSliderPos2 = + iUseValue + + 105; // Mode 0: Calculate slider position (calibration value + 105) for (iRowIdx2 = 0; iRowIdx2 < iSavedWinw; ++iRowIdx2) { if (iRowIdx2 && iRowIdx2 != iSavedWinw - 1) { - *pScrBuf = 0x8F; // Mode 0: Draw borders with color 0x8F (white) + *pScrBuf = 0x8F; // Mode 0: Draw borders with color 0x8F (white) pScrBuf[208 * iWinW / 640] = 0x8F; - iSliderXPos2 = iWinW * iSliderPos2 / 640;// Mode 0: Draw slider indicator at calculated position - pScrBuf[iSliderXPos2] = 0xAB; // 0xAB = orange + iSliderXPos2 = + iWinW * iSliderPos2 / + 640; // Mode 0: Draw slider indicator at calculated position + pScrBuf[iSliderXPos2] = 0xAB; // 0xAB = orange pScrBuf[iSliderXPos2 - 1] = 0xAB; pScrBuf[iSliderXPos2 + 1] = 0xAB; - pScrBuf[105 * iWinW / 640] = 0xE7; // Mode 0: Draw center scale mark (color 0xE7 = orange) + pScrBuf[105 * iWinW / 640] = + 0xE7; // Mode 0: Draw center scale mark (color 0xE7 = orange) } else { winw = iWinW; memset(pScrBuf, 143, 104 * iWinW / 320 + 1); @@ -4480,13 +4763,12 @@ void displaycalibrationbar(int iX, int iY, int iValue) pScrBuf += iWinW; } } - winw = iWinW; // Restore original window width + winw = iWinW; // Restore original window width } //------------------------------------------------------------------------------------------------- -//0001C830 -void blankwindow(int iX1, int iY1, int iX2, int iY2) -{ +// 0001C830 +void blankwindow(int iX1, int iY1, int iX2, int iY2) { tPolyParams poly; // [esp+0h] [ebp-34h] BYREF if (SVGA_ON) { @@ -4503,44 +4785,53 @@ void blankwindow(int iX1, int iY1, int iX2, int iY2) poly.vertices[2].y = iY2; poly.vertices[3].x = iX2; poly.vertices[3].y = iY2; - poly.iSurfaceType = SURFACE_FLAG_TRANSPARENT | 0x000003; //0x200003 + poly.iSurfaceType = SURFACE_FLAG_TRANSPARENT | 0x000003; // 0x200003 poly.uiNumVerts = 4; POLYFLAT(scrbuf, &poly); } //------------------------------------------------------------------------------------------------- -//0001C890 -void volumebar(int iX, int iVolume) -{ - uint8 *pScreenRow; // ecx - int iRowIdx; // esi - int iBarHeight; // ebp +// 0001C890 +void volumebar(int iX, int iVolume) { + uint8 *pScreenRow; // ecx + int iRowIdx; // esi + int iBarHeight; // ebp unsigned int uiVolumeWidth; // edi - pScreenRow = &scrbuf[175 * winw / 320 + ((scr_size * iX) >> 6) * winw];// Calculate screen position: Y=175*winw/320, X=scaled position + pScreenRow = + &scrbuf[175 * winw / 320 + ((scr_size * iX) >> 6) * + winw]; // Calculate screen position: + // Y=175*winw/320, X=scaled position iRowIdx = 0; - iBarHeight = (10 * scr_size) >> 6; // Calculate scaled bar height (10 * scr_size / 64) - uiVolumeWidth = 100 * iVolume / 127 * winw / 320;// Calculate volume fill width: volume level (0-127) mapped to 0-100 pixels scaled - if (iBarHeight > 0) // Main rendering loop for each row of the volume bar + iBarHeight = + (10 * scr_size) >> 6; // Calculate scaled bar height (10 * scr_size / 64) + uiVolumeWidth = 100 * iVolume / 127 * winw / + 320; // Calculate volume fill width: volume level (0-127) + // mapped to 0-100 pixels scaled + if (iBarHeight > 0) // Main rendering loop for each row of the volume bar { - do { // Skip top and bottom rows (draw border only on middle rows) + do { // Skip top and bottom rows (draw border only on middle rows) if (iRowIdx && iRowIdx != iBarHeight - 1) { - *pScreenRow = 0x70; // Draw left border (0x70 is black in PALETTE.PAL) - memset(pScreenRow + 1, 0xAB, uiVolumeWidth);// Fill volume level area (0xAB is orange in PALETTE.PAL) - pScreenRow[101 * winw / 320] = 0x70; // Draw right border (0x70 is black in PALETTE.PAL) + *pScreenRow = 0x70; // Draw left border (0x70 is black in PALETTE.PAL) + memset(pScreenRow + 1, 0xAB, + uiVolumeWidth); // Fill volume level area (0xAB is orange in + // PALETTE.PAL) + pScreenRow[101 * winw / 320] = + 0x70; // Draw right border (0x70 is black in PALETTE.PAL) } else { - memset(pScreenRow, 0x70, 102 * winw / 320);// Top/bottom rows: fill entire width with border color (0x70 is black in PALETTE.PAL) + memset(pScreenRow, 0x70, + 102 * winw / 320); // Top/bottom rows: fill entire width with + // border color (0x70 is black in PALETTE.PAL) } - pScreenRow += winw; // Move to next screen row + pScreenRow += winw; // Move to next screen row ++iRowIdx; } while (iRowIdx < iBarHeight); } } //------------------------------------------------------------------------------------------------- -//0001C980 -void remove_uncalibrated() -{ +// 0001C980 +void remove_uncalibrated() { if (JAXmax - JAXmin < 100) x1ok = 0; if (JAYmax - JAYmin < 100) @@ -4561,40 +4852,40 @@ void remove_uncalibrated() } //------------------------------------------------------------------------------------------------- -//0001CA60 -void LoadRecords() -{ - int iFileHandle; // edx +// 0001CA60 +void LoadRecords() { + int iFileHandle; // edx int iFileHandle2; // ebp - //int iRecordNamePos; // edx - //int iRecordIdx3; // eax - //int iRecordNamePos2; // edx - //char *szRecordName2; // edi - //char *szRecordName3; // edi - int iFileLength; // eax + // int iRecordNamePos; // edx + // int iRecordIdx3; // eax + // int iRecordNamePos2; // edx + // char *szRecordName2; // edi + // char *szRecordName3; // edi + int iFileLength; // eax int iFileLength2; // ecx - //int iRecordNameIdx2; // edx - //int iRecordIdx2; // eax - //int iRecordNameIdx3; // edx - //char *szRecordName4; // edi - int *pIntBuf; // ebx + // int iRecordNameIdx2; // edx + // int iRecordIdx2; // eax + // int iRecordNameIdx3; // edx + // char *szRecordName4; // edi + int *pIntBuf; // ebx int iRecordNameIdx; // ebp - int iRecordIdx; // ecx - //int iRecordCarVal; // eax - //int iRecordNamePos4; // esi + int iRecordIdx; // ecx + // int iRecordCarVal; // eax + // int iRecordNamePos4; // esi int iRecordNameCharPos; // eax - //char byNameChar; // dl - uint8 *pBuf; // [esp+0h] [ebp-24h] BYREF + // char byNameChar; // dl + uint8 *pBuf; // [esp+0h] [ebp-24h] BYREF int iMaxRecords; // [esp+4h] [ebp-20h] - //int iRecordNamePos3; // [esp+8h] [ebp-1Ch] + // int iRecordNamePos3; // [esp+8h] [ebp-1Ch] iFileLength = ROLLERfilelength("dgkfc.rec"); - iFileHandle = ROLLERopen("dgkfc.rec", O_BINARY); // 0x200 = O_BINARY in WATCOM/h/fcntl.h + iFileHandle = + ROLLERopen("dgkfc.rec", O_BINARY); // 0x200 = O_BINARY in WATCOM/h/fcntl.h iFileHandle2 = iFileHandle; if (iFileHandle == -1) { - //loop without optimizations + // loop without optimizations for (int i = 0; i < 25; ++i) { int iRecordNamesPos = 9 * i; strcpy(RecordNames[iRecordNamesPos], "-----"); @@ -4602,37 +4893,37 @@ void LoadRecords() RecordCars[i] = -1; RecordKills[i] = 0; } - //iRecordNamePos = 9; - //RecordCars[0] = -1; - //RecordLaps[0] = 128.0; - //RecordKills[0] = 0; - //iRecordIdx3 = 1; - //strcpy(RecordNames[0], "----"); - //do { - // RecordLaps[iRecordIdx3] = 128.0; - // RecordCars[iRecordIdx3] = -1; - // RecordKills[iRecordIdx3] = 0; - // strcpy(&RecordNames[0][iRecordNamePos], "----"); - // iRecordNamePos2 = iRecordNamePos + 9; - // RecordCars[iRecordIdx3 + 1] = -1; - // RecordLaps[iRecordIdx3 + 1] = 128.0; - // szRecordName2 = &RecordNames[0][iRecordNamePos2]; - // RecordKills[iRecordIdx3 + 1] = 0; - // iRecordNamePos2 += 9; - // strcpy(szRecordName2, "----"); - // iRecordIdx3 += 3; - // szRecordName3 = &RecordNames[0][iRecordNamePos2]; - // RecordLaps[iRecordIdx3 + 24] = NAN; - // *(int *)((char *)&updates + iRecordIdx3 * 4) = 0x43000000; - // RecordCars[iRecordIdx3 + 24] = 0; - // iRecordNamePos = iRecordNamePos2 + 9; - // strcpy(szRecordName3, "----"); - //} while (iRecordIdx3 != 25); + // iRecordNamePos = 9; + // RecordCars[0] = -1; + // RecordLaps[0] = 128.0; + // RecordKills[0] = 0; + // iRecordIdx3 = 1; + // strcpy(RecordNames[0], "----"); + // do { + // RecordLaps[iRecordIdx3] = 128.0; + // RecordCars[iRecordIdx3] = -1; + // RecordKills[iRecordIdx3] = 0; + // strcpy(&RecordNames[0][iRecordNamePos], "----"); + // iRecordNamePos2 = iRecordNamePos + 9; + // RecordCars[iRecordIdx3 + 1] = -1; + // RecordLaps[iRecordIdx3 + 1] = 128.0; + // szRecordName2 = &RecordNames[0][iRecordNamePos2]; + // RecordKills[iRecordIdx3 + 1] = 0; + // iRecordNamePos2 += 9; + // strcpy(szRecordName2, "----"); + // iRecordIdx3 += 3; + // szRecordName3 = &RecordNames[0][iRecordNamePos2]; + // RecordLaps[iRecordIdx3 + 24] = NAN; + // *(int *)((char *)&updates + iRecordIdx3 * 4) = 0x43000000; + // RecordCars[iRecordIdx3 + 24] = 0; + // iRecordNamePos = iRecordNamePos2 + 9; + // strcpy(szRecordName3, "----"); + // } while (iRecordIdx3 != 25); //// end loop } else { pBuf = (uint8 *)getbuffer(1024u); - //iFileLength = filelength(iFileHandle); + // iFileLength = filelength(iFileHandle); iFileLength2 = iFileLength; if (iFileLength == 336 || iFileLength == 504) { read(iFileHandle, pBuf, iFileLength); @@ -4643,21 +4934,23 @@ void LoadRecords() if (iFileLength2 / 21 >= 1) { iRecordIdx = 1; do { - RecordLaps[iRecordIdx] = (float)ReadUnalignedInt((void*)pIntBuf) * 0.01f; + RecordLaps[iRecordIdx] = + (float)ReadUnalignedInt((void *)pIntBuf) * 0.01f; RecordCars[iRecordIdx] = ReadUnalignedInt(&pIntBuf[1]); RecordKills[iRecordIdx] = ReadUnalignedInt(&pIntBuf[2]); pIntBuf += 3; iRecordNameCharPos = 9 * iRecordNameIdx; // Copy 9-character record name - memcpy(RecordNames[iRecordNameIdx], (uint8*)pIntBuf, 9); - pIntBuf = (int*)((uint8*)pIntBuf + 9); - //do { - // ++iRecordNameCharPos; - // byNameChar = *(_BYTE *)pIntBuf; - // pIntBuf = (int *)((char *)pIntBuf + 1); - // *((_BYTE *)&fudge_wait + iRecordNameCharPos + 3) = byNameChar;// this is an offset into RecordNames - //} while (iRecordNameCharPos != iRecordNamePos4); + memcpy(RecordNames[iRecordNameIdx], (uint8 *)pIntBuf, 9); + pIntBuf = (int *)((uint8 *)pIntBuf + 9); + // do { + // ++iRecordNameCharPos; + // byNameChar = *(_BYTE *)pIntBuf; + // pIntBuf = (int *)((char *)pIntBuf + 1); + // *((_BYTE *)&fudge_wait + iRecordNameCharPos + 3) = byNameChar;// + // this is an offset into RecordNames + // } while (iRecordNameCharPos != iRecordNamePos4); if (RecordLaps[iRecordIdx] < 0.4) { RecordLaps[iRecordIdx] = 128.0; @@ -4672,7 +4965,7 @@ void LoadRecords() fre((void **)&pBuf); } else { - //loop without optimizations + // loop without optimizations for (int i = 0; i < 25; ++i) { int iRecordNamesPos = 9 * i; strcpy(RecordNames[iRecordNamesPos], "----"); @@ -4680,31 +4973,31 @@ void LoadRecords() RecordCars[i] = -1; RecordKills[i] = 0; } - //iRecordNameIdx2 = 9; - //iRecordIdx2 = 1; - //RecordKills[0] = 0; - //RecordLaps[0] = 128.0; - //RecordCars[0] = -1; - //strcpy(RecordNames[0], "----"); - //do { - // RecordLaps[iRecordIdx2] = 128.0; - // RecordKills[iRecordIdx2] = 0; - // RecordCars[iRecordIdx2] = -1; - // strcpy(&RecordNames[0][iRecordNameIdx2], "----"); - // iRecordNameIdx3 = iRecordNameIdx2 + 9; - // RecordLaps[iRecordIdx2 + 1] = 128.0; - // RecordKills[iRecordIdx2 + 1] = 0; - // RecordCars[iRecordIdx2 + 1] = -1; - // iRecordIdx2 += 3; - // strcpy(&RecordNames[0][iRecordNameIdx3], "----"); - // iRecordNameIdx3 += 9; - // *(int *)((char *)&updates + iRecordIdx2 * 4) = 0x43000000; - // RecordCars[iRecordIdx2 + 24] = 0; - // szRecordName4 = &RecordNames[0][iRecordNameIdx3]; - // RecordLaps[iRecordIdx2 + 24] = NAN; - // iRecordNameIdx2 = iRecordNameIdx3 + 9; - // strcpy(szRecordName4, "----"); - //} while (iRecordIdx2 != 25); + // iRecordNameIdx2 = 9; + // iRecordIdx2 = 1; + // RecordKills[0] = 0; + // RecordLaps[0] = 128.0; + // RecordCars[0] = -1; + // strcpy(RecordNames[0], "----"); + // do { + // RecordLaps[iRecordIdx2] = 128.0; + // RecordKills[iRecordIdx2] = 0; + // RecordCars[iRecordIdx2] = -1; + // strcpy(&RecordNames[0][iRecordNameIdx2], "----"); + // iRecordNameIdx3 = iRecordNameIdx2 + 9; + // RecordLaps[iRecordIdx2 + 1] = 128.0; + // RecordKills[iRecordIdx2 + 1] = 0; + // RecordCars[iRecordIdx2 + 1] = -1; + // iRecordIdx2 += 3; + // strcpy(&RecordNames[0][iRecordNameIdx3], "----"); + // iRecordNameIdx3 += 9; + // *(int *)((char *)&updates + iRecordIdx2 * 4) = 0x43000000; + // RecordCars[iRecordIdx2 + 24] = 0; + // szRecordName4 = &RecordNames[0][iRecordNameIdx3]; + // RecordLaps[iRecordIdx2 + 24] = NAN; + // iRecordNameIdx2 = iRecordNameIdx3 + 9; + // strcpy(szRecordName4, "----"); + // } while (iRecordIdx2 != 25); //// end loop close(iFileHandle2); @@ -4714,10 +5007,9 @@ void LoadRecords() } //------------------------------------------------------------------------------------------------- -//0001CD30 -void SaveRecords() -{ - uint8 *pBuffer = getbuffer(0x400); // Get a 1KB buffer +// 0001CD30 +void SaveRecords() { + uint8 *pBuffer = getbuffer(0x400); // Get a 1KB buffer uint8 *pWritePtr = pBuffer; int iNumBytes = 0; @@ -4752,25 +5044,23 @@ void SaveRecords() fclose(f); } - fre((void**)&pBuffer); // Free the allocated buffer + fre((void **)&pBuffer); // Free the allocated buffer } //------------------------------------------------------------------------------------------------- -//0001CE40 -uint8 *copy_int(uint8 *pDest, uint32 uiValue) -{ +// 0001CE40 +uint8 *copy_int(uint8 *pDest, uint32 uiValue) { pDest += 3; - pDest[-3] = (uint8)(uiValue); // Byte 0 (LSB) - pDest[-2] = (uint8)(uiValue >> 8); // Byte 1 - pDest[-1] = (uint8)(uiValue >> 16); // Byte 2 - pDest[0] = (uint8)(uiValue >> 24); // Byte 3 (MSB) - return pDest + 1; // Equivalent to original eax + 4 + pDest[-3] = (uint8)(uiValue); // Byte 0 (LSB) + pDest[-2] = (uint8)(uiValue >> 8); // Byte 1 + pDest[-1] = (uint8)(uiValue >> 16); // Byte 2 + pDest[0] = (uint8)(uiValue >> 24); // Byte 3 (MSB) + return pDest + 1; // Equivalent to original eax + 4 } //------------------------------------------------------------------------------------------------- -//0001CE80 -void ShowATime(float fTime, int iX, int iY) -{ +// 0001CE80 +void ShowATime(float fTime, int iX, int iY) { int iTime; // [esp+0h] [ebp-1Ch] //_CHP(); @@ -4823,96 +5113,106 @@ void ShowATime(float fTime, int iX, int iY) } //------------------------------------------------------------------------------------------------- -//0001D090 -void setmodex() -{ // INT 10h with AX=13h - Set VGA mode 13h (320x200x256) as base - //__asm { int 10h; INT 10h with AX = 13h - Set VGA mode 13h(320x200x256) as base } - //modexsethardware(); // Configure VGA hardware registers for Mode X tweaks - //__outword(0x3C4u, 0xF02u); // Set Sequencer register 02h to 0Fh - enable all 4 bit planes - //memset(screen, 0, 0x10000u); // Clear video memory (64KB) - initialize screen buffer to black +// 0001D090 +void setmodex() { // INT 10h with AX=13h - Set VGA mode 13h (320x200x256) as + // base + //__asm { int 10h; INT 10h with AX = 13h - Set VGA mode + // 13h(320x200x256) as base } modexsethardware(); // Configure + // VGA hardware registers for Mode X tweaks + //__outword(0x3C4u, 0xF02u); // Set + // Sequencer register 02h to 0Fh - enable all 4 bit planes + // memset(screen, 0, 0x10000u); // Clear + // video memory (64KB) - initialize screen buffer to black } //------------------------------------------------------------------------------------------------- -//0001D0C0 -void modexsethardware() -{ - //uint8 bySequencerMemMode; // al - //uint8 byGraphicsMode; // al - //uint8 byMemoryMap; // al - //uint8 byMaxScanLine; // al - //uint8 byUnderlineLocation; // al - //uint8 byModeControl; // al +// 0001D0C0 +void modexsethardware() { + // uint8 bySequencerMemMode; // al + // uint8 byGraphicsMode; // al + // uint8 byMemoryMap; // al + // uint8 byMaxScanLine; // al + // uint8 byUnderlineLocation; // al + // uint8 byModeControl; // al // - //__outbyte(0x3C4u, 4u); // Sequencer Register 04h (Memory Mode) - configure memory access mode - //bySequencerMemMode = __inbyte(0x3C5u); - //__outbyte(0x3C5u, bySequencerMemMode & 3 | 4);// Clear Chain-4 mode, enable planar memory organization for Mode X - //__outbyte(0x3CEu, 5u); // Graphics Controller Register 05h (Graphics Mode) - set read/write mode - //byGraphicsMode = __inbyte(0x3CFu); - //__outbyte(0x3CFu, byGraphicsMode & 0xEF); // Clear bit 4 (Host Odd/Even) - disable odd/even addressing - //__outbyte(0x3CEu, 6u); // Graphics Controller Register 06h (Memory Map) - set memory mapping - //byMemoryMap = __inbyte(0x3CFu); - //__outbyte(0x3CFu, byMemoryMap & 0xFD); // Clear bit 1 (Chain Odd/Even) - disable odd/even chaining - //__outbyte(0x3D4u, 9u); // CRTC Register 09h (Maximum Scan Line) - configure scan line behavior - //byMaxScanLine = __inbyte(0x3D5u); - //__outbyte(0x3D5u, byMaxScanLine & 0xE0); // Clear bits 4-0 (Max Scan Line) - set to 0 for single-scan lines - //__outbyte(0x3D4u, 0x14u); // CRTC Register 14h (Underline Location) - configure memory addressing - //byUnderlineLocation = __inbyte(0x3D5u); - //__outbyte(0x3D5u, byUnderlineLocation & 0xBF);// Clear bit 6 (Double Word) - disable double word addressing mode - //__outbyte(0x3D4u, 0x17u); // CRTC Register 17h (Mode Control) - configure display timing mode - //byModeControl = __inbyte(0x3D5u); + //__outbyte(0x3C4u, 4u); // Sequencer Register 04h + //(Memory Mode) - configure memory access mode bySequencerMemMode = + // __inbyte(0x3C5u); + //__outbyte(0x3C5u, bySequencerMemMode & 3 | 4);// Clear Chain-4 mode, enable + // planar memory organization for Mode X + //__outbyte(0x3CEu, 5u); // Graphics Controller + // Register 05h (Graphics Mode) - set read/write mode byGraphicsMode = + // __inbyte(0x3CFu); + //__outbyte(0x3CFu, byGraphicsMode & 0xEF); // Clear bit 4 (Host Odd/Even) + //- disable odd/even addressing + //__outbyte(0x3CEu, 6u); // Graphics Controller + // Register 06h (Memory Map) - set memory mapping byMemoryMap = + // __inbyte(0x3CFu); + //__outbyte(0x3CFu, byMemoryMap & 0xFD); // Clear bit 1 (Chain + // Odd/Even) - disable odd/even chaining + //__outbyte(0x3D4u, 9u); // CRTC Register 09h (Maximum + // Scan Line) - configure scan line behavior byMaxScanLine = __inbyte(0x3D5u); + //__outbyte(0x3D5u, byMaxScanLine & 0xE0); // Clear bits 4-0 (Max Scan + // Line) - set to 0 for single-scan lines + //__outbyte(0x3D4u, 0x14u); // CRTC Register 14h + //(Underline Location) - configure memory addressing byUnderlineLocation = + // __inbyte(0x3D5u); + //__outbyte(0x3D5u, byUnderlineLocation & 0xBF);// Clear bit 6 (Double Word) - + // disable double word addressing mode + //__outbyte(0x3D4u, 0x17u); // CRTC Register 17h (Mode + // Control) - configure display timing mode byModeControl = __inbyte(0x3D5u); //__outbyte(0x3D5u, byModeControl | 0x40); } //------------------------------------------------------------------------------------------------- -//0001D140 -void modexclearscreen() -{ - //__outword(0x3C4u, 0xF02u); // Set Sequencer Map Mask to 0Fh - enable writing to all 4 bit planes - //memset(screen, 0, 0x10000u); // Clear all 64KB of video memory to black (color 0) +// 0001D140 +void modexclearscreen() { + //__outword(0x3C4u, 0xF02u); // Set Sequencer Map Mask to + // 0Fh - enable writing to all 4 bit planes memset(screen, 0, 0x10000u); // + // Clear all 64KB of video memory to black (color 0) } //------------------------------------------------------------------------------------------------- -//0001D170 -void copyscreenmodex(uint8 *pSrc, uint8 *pDest) -{ +// 0001D170 +void copyscreenmodex(uint8 *pSrc, uint8 *pDest) { int x, iBlock; for (x = 0; x < 320; x++) { - int iPlane = x & 3; // Determine current plane (0-3) - int iPlaneMask = 1 << iPlane; // Create bit mask for the plane + int iPlane = x & 3; // Determine current plane (0-3) + int iPlaneMask = 1 << iPlane; // Create bit mask for the plane // Set VGA sequencer map mask - //outportb(0x3C4, 2); // Select map mask register - //outportb(0x3C5, iPlaneMask); // Enable writes to current plane + // outportb(0x3C4, 2); // Select map mask register + // outportb(0x3C5, iPlaneMask); // Enable writes to current plane - unsigned char *pSrcCol = pSrc + (x << 1); // Source column (every other pixel) + unsigned char *pSrcCol = + pSrc + (x << 1); // Source column (every other pixel) unsigned char *pDestCol = pDest + (x >> 2); // Destination column group // Process 80 blocks (each block = 5 rows) for (iBlock = 0; iBlock < 80; iBlock++) { - // Write 5 rows in unrolled fashion - pDestCol[0] = pSrcCol[0]; // Row 0 - pDestCol[80] = pSrcCol[640]; // Row 1 - pDestCol[160] = pSrcCol[1280]; // Row 2 - pDestCol[240] = pSrcCol[1920]; // Row 3 - pDestCol[320] = pSrcCol[2560]; // Row 4 - - pSrcCol += 3200; // Advance source by 5 rows (5 * 640) - pDestCol += 400; // Advance destination by 5 rows (5 * 80) + // Write 5 rows in unrolled fashion + pDestCol[0] = pSrcCol[0]; // Row 0 + pDestCol[80] = pSrcCol[640]; // Row 1 + pDestCol[160] = pSrcCol[1280]; // Row 2 + pDestCol[240] = pSrcCol[1920]; // Row 3 + pDestCol[320] = pSrcCol[2560]; // Row 4 + + pSrcCol += 3200; // Advance source by 5 rows (5 * 640) + pDestCol += 400; // Advance destination by 5 rows (5 * 80) } } } //------------------------------------------------------------------------------------------------- -//0001D220 -void start_zoom(const char *szStr, int iPlayerIdx) -{ +// 0001D220 +void start_zoom(const char *szStr, int iPlayerIdx) { int iPlayerIdx_1; // edx - int iGameCount; // ebp - char *pszDest; // edi - char c0; // al - char c1; // al - char c0_1; // al - char c1_1; // al + int iGameCount; // ebp + char *pszDest; // edi + char c0; // al + char c1; // al + char c0_1; // al + char c1_1; // al iPlayerIdx_1 = iPlayerIdx; iGameCount = game_count[iPlayerIdx_1]; @@ -4946,7 +5246,9 @@ void start_zoom(const char *szStr, int iPlayerIdx) } while (c1_1); if (game_count[iPlayerIdx_1] == -1) { game_count[iPlayerIdx_1] = 0; - } else if (game_scale[iPlayerIdx_1] == 64.0f) //if (LODWORD(game_scale[iPlayerIdx_1]) == 0x42800000)// 64.0f + } else if (game_scale[iPlayerIdx_1] == + 64.0f) // if (LODWORD(game_scale[iPlayerIdx_1]) == + // 0x42800000)// 64.0f { game_count[iPlayerIdx_1] = 72; } @@ -4954,15 +5256,14 @@ void start_zoom(const char *szStr, int iPlayerIdx) } //------------------------------------------------------------------------------------------------- -//0001D2F0 -void small_zoom(const char *szStr) -{ - char *pszDest; // edi - char c0; // al - char c1; // al +// 0001D2F0 +void small_zoom(const char *szStr) { + char *pszDest; // edi + char c0; // al + char c1; // al char *pszDest_1; // edi - char c0_1; // al - char c1_1; // al + char c0_1; // al + char c1_1; // al new_zoom[0] = 0; if (game_count[0] == -2) { @@ -4999,7 +5300,8 @@ void small_zoom(const char *szStr) } while (c1_1); if (game_count[0] == -1) { game_count[0] = 0; - } else if (game_scale[0] == 64.0f) //else if (LODWORD(game_scale[0]) == 0x42800000)// 64.0f + } else if (game_scale[0] == + 64.0f) // else if (LODWORD(game_scale[0]) == 0x42800000)// 64.0f { game_count[0] = 72; } @@ -5007,12 +5309,11 @@ void small_zoom(const char *szStr) } //------------------------------------------------------------------------------------------------- -//0001D3D0 -void subzoom(const char *szStr) -{ +// 0001D3D0 +void subzoom(const char *szStr) { char *pszDest; // edi - char c0; // al - char c1; // al + char c0; // al + char c1; // al if (new_zoom[0]) { pszDest = zoom_sub[0]; @@ -5031,9 +5332,8 @@ void subzoom(const char *szStr) } //------------------------------------------------------------------------------------------------- -//0001D410 -void make_time(char *szTimeStr, float fTime) -{ +// 0001D410 +void make_time(char *szTimeStr, float fTime) { int iTime; // [esp+0h] [ebp-14h] //_CHP(); @@ -5056,9 +5356,8 @@ void make_time(char *szTimeStr, float fTime) } //------------------------------------------------------------------------------------------------- -//0001D520 -void check_machine_speed() -{ +// 0001D520 +void check_machine_speed() { int iCounter = 0; int iTarget = frames + 4; int iTimeout = frames + 13; @@ -5067,7 +5366,7 @@ void check_machine_speed() while (frames != iTarget) ; -// Count how many iterations until frames reaches frames + 13 + // Count how many iterations until frames reaches frames + 13 while (frames != iTimeout) { iCounter++; } @@ -5077,9 +5376,8 @@ void check_machine_speed() } //------------------------------------------------------------------------------------------------- -//0001D570 -void load_language_file(char *szFilename, int iUseConfigBuffer) -{ +// 0001D570 +void load_language_file(char *szFilename, int iUseConfigBuffer) { FILE *pFile; char *szExt; char *szTextExt; @@ -5093,7 +5391,7 @@ void load_language_file(char *szFilename, int iUseConfigBuffer) szTextExt = (char *)TextExt + language * 4; // copy this text extension after the ".eng" part in the filename - szFileExt = szExt + 1; // skip the dot + szFileExt = szExt + 1; // skip the dot while (*szTextExt) { *szFileExt++ = *szTextExt++; if (*szTextExt == 0) @@ -5105,14 +5403,14 @@ void load_language_file(char *szFilename, int iUseConfigBuffer) // try opening the language file if (!ROLLERfexists(szFilename)) { - //Added by ROLLER: compatibility with US release + // Added by ROLLER: compatibility with US release ReplaceExtension(szFilename, ".USA"); } pFile = ROLLERfopen(szFilename, "r"); if (!pFile) { ErrorBoxExit("Unable to open file: %s", szFilename); - //printf("Unable to open file: %s\n", szFilename); - //doexit(1); + // printf("Unable to open file: %s\n", szFilename); + // doexit(1); } int iEndFound = 0; @@ -5120,7 +5418,8 @@ void load_language_file(char *szFilename, int iUseConfigBuffer) while (!iEndFound) { // fead a line into buffer - if (!fgets(buffer, 128, pFile)) break; //512 in original code but buffer is only 128 in size + if (!fgets(buffer, 128, pFile)) + break; // 512 in original code but buffer is only 128 in size // check for "END" keyword if (buffer[0] == 'E' && buffer[1] == 'N' && buffer[2] == 'D') { @@ -5137,7 +5436,7 @@ void load_language_file(char *szFilename, int iUseConfigBuffer) } // copy characters between quotes to dest - char *szSrc = buffer + 1; // skip first character + char *szSrc = buffer + 1; // skip first character while (*szSrc != '"' && *szSrc != '\0') { *szDest++ = *szSrc++; } @@ -5151,11 +5450,10 @@ void load_language_file(char *szFilename, int iUseConfigBuffer) } //------------------------------------------------------------------------------------------------- -//0001D660 -void do_blip(int iCarIdx) -{ +// 0001D660 +void do_blip(int iCarIdx) { double dDamage; // st7 - //int iCarOffset; // eax + // int iCarOffset; // eax int iDamage; // [esp+0h] [ebp-10h] // //Calculate car array offset @@ -5166,18 +5464,19 @@ void do_blip(int iCarIdx) iDamage = (int)dDamage; if (fabs(Car[ViewType[iCarIdx]].fHealth) == 0) - //if ((*(_DWORD *)((_BYTE *)&Car[0].fDamage + iCarOffset) & 0x7FFFFFFF) == 0) + // if ((*(_DWORD *)((_BYTE *)&Car[0].fDamage + iCarOffset) & 0x7FFFFFFF) == + // 0) iDamage = 14; // Only proceed if car has valid max speed if (fabs(Car[ViewType[iCarIdx]].fFinalSpeed) > FLT_EPSILON) - //if ((LODWORD(Car[ViewType[iCarIdx]].fMaxSpeed) & 0x7FFFFFFF) != 0) + // if ((LODWORD(Car[ViewType[iCarIdx]].fMaxSpeed) & 0x7FFFFFFF) != 0) lastblip[iCarIdx] = iDamage; // Play sound effect if conditions are met if (iDamage < 14 && iDamage < lastblip[iCarIdx]) { if (Car[ViewType[iCarIdx]].byDebugDamage) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON lastblip[iCarIdx] = iDamage; } } diff --git a/PROJECTS/ROLLER/func2.h b/PROJECTS/ROLLER/func2.h index 29a1f407..008b7ae8 100644 --- a/PROJECTS/ROLLER/func2.h +++ b/PROJECTS/ROLLER/func2.h @@ -5,8 +5,7 @@ #include "func3.h" //------------------------------------------------------------------------------------------------- -typedef enum -{ +typedef enum { USERKEY_P1LEFT = 0, USERKEY_P1RIGHT = 1, USERKEY_P1UP = 2, @@ -23,11 +22,9 @@ typedef enum USERKEY_P2CHEAT = 13 } eUserKey; - //------------------------------------------------------------------------------------------------- -struct DPMI_MemInfo -{ +struct DPMI_MemInfo { uint32 largestFreeBlock; uint32 maxUnlockedPages; uint32 maxLockedPages; @@ -64,9 +61,12 @@ extern int lots_of_mem; void draw_smoke(uint8 *pScrBuf, int iPlayerCarIdx); void test_panel(uint8 *pScrBuf, int iPlayerCarIdx); -void ZoomString(const char *szStr, const char *mappingTable, tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets); -void ZoomSub(const char *szText, const char *mappingTable, tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets); -void zoom_letter(tBlockHeader *pBlockHeader, uint8 byCharCode, int *puiXPos, int *puiYPos, const char *mappingTable, float fZoomFactor); +void ZoomString(const char *szStr, const char *mappingTable, + tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets); +void ZoomSub(const char *szText, const char *mappingTable, + tBlockHeader *pBlockHeader, int iPlayerIdx, int *pCharVOffsets); +void zoom_letter(tBlockHeader *pBlockHeader, uint8 byCharCode, int *puiXPos, + int *puiYPos, const char *mappingTable, float fZoomFactor); void print_block(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx); void print_damage(uint8 *pDest, tBlockHeader *pBlockHeader, int iCarIdx); void print_pos(int iX, int iY, int iDriverIdx); @@ -83,25 +83,37 @@ void setdirectory(const char *szAppPath); void FindShades(); int nearest_colour(int iR, int iB, int iG); void select_view(int iPlayer); -void mini_prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY); -void mini_prt_string_rev(tBlockHeader *pBlockHeader, const char *szText, int iX, int iY); -void mini_prt_right(tBlockHeader *pBlockHeader, const char *szText, int iX, int iY); -void mini_prt_centre(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY); +void mini_prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY); +void mini_prt_string_rev(tBlockHeader *pBlockHeader, const char *szText, int iX, + int iY); +void mini_prt_right(tBlockHeader *pBlockHeader, const char *szText, int iX, + int iY); +void mini_prt_centre(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY); void prt_right(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY); void prt_string(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY); -void prt_letter(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPos, int iFontType); -void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPos, int iFontType); -void prt_stringcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, uint8 byColor); -void prt_rightcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, uint8 byColor); -void prt_centrecol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, uint8 byColor); -void prt_lettercol(tBlockHeader *pBlockHeader, char byChar, int *piXPos, int *piYPos, uint8 byColor); +void prt_letter(tBlockHeader *pBlockHeader, char byChar, int *piXPos, + int *piYPos, int iFontType); +void prt_letter_rev(tBlockHeader *pBlockHeader, char byChar, int *piXPos, + int *piYPos, int iFontType); +void prt_stringcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY, uint8 byColor); +void prt_rightcol(tBlockHeader *pBlockHeader, const char *szStr, int iX, int iY, + uint8 byColor); +void prt_centrecol(tBlockHeader *pBlockHeader, const char *szStr, int iX, + int iY, uint8 byColor); +void prt_lettercol(tBlockHeader *pBlockHeader, char byChar, int *piXPos, + int *piYPos, uint8 byColor); void display_paused(); void enable_keyboard(); void disable_keyboard(); void save_fatal_config(); void load_fatal_config(); -void getconfigvalue(const char *szConfigText, const char *szVarName, int *piOutVal, int iMin, int iMax); -void getconfigvalueuc(const char *szConfigText, const char *szVarName, uint8 *pbyOutVal, int iMin, int iMax); +void getconfigvalue(const char *szConfigText, const char *szVarName, + int *piOutVal, int iMin, int iMax); +void getconfigvalueuc(const char *szConfigText, const char *szVarName, + uint8 *pbyOutVal, int iMin, int iMax); void displaycalibrationbar(int iX, int iY, int iValue); void blankwindow(int iX1, int iY1, int iX2, int iY2); void volumebar(int iX, int iVolume); diff --git a/PROJECTS/ROLLER/func3.c b/PROJECTS/ROLLER/func3.c index fd6fc786..76f66060 100644 --- a/PROJECTS/ROLLER/func3.c +++ b/PROJECTS/ROLLER/func3.c @@ -32,119 +32,94 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -//symbols defined by ROLLER -char szMrEvil[10] = "MR EVIL"; //000A23F8 +// symbols defined by ROLLER +char szMrEvil[10] = "MR EVIL"; // 000A23F8 //------------------------------------------------------------------------------------------------- -char save_slots[4][13] = //000A6234 -{ - "champ1.sav", - "champ2.sav", - "champ3.sav", - "champ4.sav" -}; -int credit_order[25] = //000A6268 -{ 3, 1, 0, 2, 4, 5, 6, 7, -1, 0, 1, 2, 3, 4, -2 }; -char round_pals[8][13] = //000A62A4 -{ - "round1.pal", - "round2.pal", - "round3.pal", - "round4.pal", - "round5.pal", - "round6.pal", - "round7.pal", - "round8.pal" -}; -char round_pics[8][13] = //000A630C -{ - "round1.bm", - "round2.bm", - "round3.bm", - "round4.bm", - "round5.bm", - "round6.bm", - "round7.bm", - "round8.bm" -}; -char send_buffer[32] = "HELLO. WHAT A LOVELY DAY"; //000A6374 -int send_message_to = -1; //000A6394 -int rec_status = 0; //000A6398 -char rec_mes_buf[32]; //00188530 -char send_mes_buf[32]; //00188550 -tSaveStatus save_status[4]; //00188570 -int result_lap[16]; //001885D0 -int result_order[16]; //00188610 -float result_time[16]; //00188650 -int result_design[16]; //00188690 -float result_best[16]; //001886D0 -int result_competing[16]; //00188710 -int result_control[16]; //00188750 -int result_lives[16]; //00188790 -int result_kills[16]; //001887D0 -int send_status; //00188810 -char rec_mes_name[12]; //00188814 -int restart_net; //00188828 -float BestTime; //0018882C -int result_p1; //00188830 -int result_p2; //00188834 -int result_p2_pos; //00188838 -int result_p1_pos; //0018883C - -static void sync_scene_render_from_legacy_view(SceneRenderer *scene) -{ +char save_slots[4][13] = // 000A6234 + {"champ1.sav", "champ2.sav", "champ3.sav", "champ4.sav"}; +int credit_order[25] = // 000A6268 + {3, 1, 0, 2, 4, 5, 6, 7, -1, 0, 1, 2, 3, 4, -2}; +char round_pals[8][13] = // 000A62A4 + {"round1.pal", "round2.pal", "round3.pal", "round4.pal", + "round5.pal", "round6.pal", "round7.pal", "round8.pal"}; +char round_pics[8][13] = // 000A630C + {"round1.bm", "round2.bm", "round3.bm", "round4.bm", + "round5.bm", "round6.bm", "round7.bm", "round8.bm"}; +char send_buffer[32] = "HELLO. WHAT A LOVELY DAY"; // 000A6374 +int send_message_to = -1; // 000A6394 +int rec_status = 0; // 000A6398 +char rec_mes_buf[32]; // 00188530 +char send_mes_buf[32]; // 00188550 +tSaveStatus save_status[4]; // 00188570 +int result_lap[16]; // 001885D0 +int result_order[16]; // 00188610 +float result_time[16]; // 00188650 +int result_design[16]; // 00188690 +float result_best[16]; // 001886D0 +int result_competing[16]; // 00188710 +int result_control[16]; // 00188750 +int result_lives[16]; // 00188790 +int result_kills[16]; // 001887D0 +int send_status; // 00188810 +char rec_mes_name[12]; // 00188814 +int restart_net; // 00188828 +float BestTime; // 0018882C +int result_p1; // 00188830 +int result_p2; // 00188834 +int result_p2_pos; // 00188838 +int result_p1_pos; // 0018883C + +static void sync_scene_render_from_legacy_view(SceneRenderer *scene) { if (!scene) return; SceneRenderCamera cam = { - .viewX = viewx, - .viewY = viewy, - .viewZ = viewz, - .cosYaw = fcos, - .sinYaw = fsin, - .fovScale = (float)VIEWDIST, + .viewX = viewx, + .viewY = viewy, + .viewZ = viewz, + .cosYaw = fcos, + .sinYaw = fsin, + .fovScale = (float)VIEWDIST, }; SceneRenderProjection proj = { - .view = {{vk1, vk2, vk3}, - {vk4, vk5, vk6}, - {vk7, vk8, vk9}}, - .screenScale = scr_size, - .centerX = xbase, - .centerY = ybase, - .texHalfRes = gfx_size, + .view = {{vk1, vk2, vk3}, {vk4, vk5, vk6}, {vk7, vk8, vk9}}, + .screenScale = scr_size, + .centerX = xbase, + .centerY = ybase, + .texHalfRes = gfx_size, }; scene_render_set_camera(scene, &cam); scene_render_set_projection(scene, &proj); } //------------------------------------------------------------------------------------------------- -//00056070 -int winner_screen(int carDesign, char byFlags) -{ +// 00056070 +int winner_screen(int carDesign, char byFlags) { int iExit; // ebp - //int iCartexLoopItr; // eax - eCarType carType; // eax - eCarType carType_1; // esi - int iTexturesLoaded; // edx - int iExistingTexIdx; // ecx - uint8 *pScrBuf; // edi - tBlockHeader *pWinnerImage; // esi - unsigned int uiBufSize; // ecx - char byBufSizeLow; // al - unsigned int uiDWordCount; // ecx - int16 nNewYaw; // ax + // int iCartexLoopItr; // eax + eCarType carType; // eax + eCarType carType_1; // esi + int iTexturesLoaded; // edx + int iExistingTexIdx; // ecx + uint8 *pScrBuf; // edi + tBlockHeader *pWinnerImage; // esi + unsigned int uiBufSize; // ecx + char byBufSizeLow; // al + unsigned int uiDWordCount; // ecx + int16 nNewYaw; // ax tBlockHeader **ppFrontVgaItr; // edx - void **ppFrePtr; // eax - uint8 **ppCartexItr; // edx - void **ppFrePtr_1; // eax - int iRetVal; // [esp+0h] [ebp-28h] - int iOldGfxSize; // [esp+4h] [ebp-24h] - char byAnimFrame; // [esp+8h] [ebp-20h] - int iDisplayDuration; // [esp+Ch] [ebp-1Ch] + void **ppFrePtr; // eax + uint8 **ppCartexItr; // edx + void **ppFrePtr_1; // eax + int iRetVal; // [esp+0h] [ebp-28h] + int iOldGfxSize; // [esp+4h] [ebp-24h] + char byAnimFrame; // [esp+8h] [ebp-20h] + int iDisplayDuration; // [esp+Ch] [ebp-1Ch] SceneRenderer *scene; tick_on = -1; @@ -161,7 +136,7 @@ int winner_screen(int carDesign, char byFlags) winh = YMAX; // longer display with music - if ( MusicVolume && MusicCard ) + if (MusicVolume && MusicCard) iDisplayDuration = 720; else iDisplayDuration = 180; @@ -195,27 +170,25 @@ int winner_screen(int carDesign, char byFlags) iTexturesLoaded = 1; iExistingTexIdx = car_texs_loaded[carType]; - if ( iExistingTexIdx == -1 ) - { + if (iExistingTexIdx == -1) { // load new car tex if not already loaded LoadCarTexture(carType, 1u); iTexturesLoaded = 2; car_texmap[carDesign] = 1; car_texs_loaded[carType_1] = 1; - } - else - { + } else { // use existing texture car_texmap[carDesign] = iExistingTexIdx; } LoadCarTextures = iTexturesLoaded; - if (scene && car_texmap[carDesign] > 0 && cartex_vga[car_texmap[carDesign] - 1]) { - scene_render_load_texture(scene, cartex_vga[car_texmap[carDesign] - 1], - 256, 0, car_texmap[carDesign], gfx_size); + if (scene && car_texmap[carDesign] > 0 && + cartex_vga[car_texmap[carDesign] - 1]) { + scene_render_load_texture(scene, cartex_vga[car_texmap[carDesign] - 1], 256, + 0, car_texmap[carDesign], gfx_size); } NoOfTextures = 255; - if ( SVGA_ON ) + if (SVGA_ON) scr_size = 128; else scr_size = 64; @@ -225,11 +198,10 @@ int winner_screen(int carDesign, char byFlags) frames = 0; startmusic(winsong); byAnimFrame = byFlags & 1; - do - { + do { pScrBuf = scrbuf; pWinnerImage = front_vga[0]; - if ( SVGA_ON ) + if (SVGA_ON) uiBufSize = 256000; else uiBufSize = 64000; @@ -238,32 +210,32 @@ int winner_screen(int carDesign, char byFlags) byBufSizeLow = uiBufSize; uiDWordCount = uiBufSize >> 2; memcpy(scrbuf, front_vga[0], 4 * uiDWordCount); - memcpy(&pScrBuf[4 * uiDWordCount], &pWinnerImage->iWidth + uiDWordCount, byBufSizeLow & 3); + memcpy(&pScrBuf[4 * uiDWordCount], &pWinnerImage->iWidth + uiDWordCount, + byBufSizeLow & 3); scene_render_set_target(scene, scrbuf, winw, winw, winh); scene_render_set_viewport(scene, 0, 115, winw, winh - 115); DrawCar(scene, carDesign, 2200.0, 512, byAnimFrame); - front_text(front_vga[1], driver_names[result_order[0]], font3_ascii, font3_offsets, 320, 120, 0x8Fu, 1u); + front_text(front_vga[1], driver_names[result_order[0]], font3_ascii, + font3_offsets, 320, 120, 0x8Fu, 1u); copypic(scrbuf, screen); if (SnapshotShouldStop()) { iExit = -1; break; } - if ( !front_fade ) - { + if (!front_fade) { front_fade = -1; fade_palette(32); frames = 0; } - while ( fatkbhit() ) - { - if ( !(uint8)fatgetch() ) + while (fatkbhit()) { + if (!(uint8)fatgetch()) fatgetch(); iExit = -1; iRetVal = 0; UpdateSDL(); } - if ( ticks > iDisplayDuration ) + if (ticks > iDisplayDuration) iExit = -1; nNewYaw = Car[0].nYaw + 32 * frames; nNewYaw &= 0x3FFF; @@ -274,37 +246,30 @@ int winner_screen(int carDesign, char byFlags) iExit = -1; else SnapshotAdvanceTick(); - } - while ( !iExit ); + } while (!iExit); // cleanup ppFrontVgaItr = front_vga; - do - { + do { ppFrePtr = (void **)ppFrontVgaItr++; fre(ppFrePtr); - } - while ( ppFrontVgaItr != &front_vga[16] ); + } while (ppFrontVgaItr != &front_vga[16]); ppCartexItr = cartex_vga; - do - { + do { ppFrePtr_1 = (void **)ppCartexItr++; fre(ppFrePtr_1); - } - while ( ppCartexItr != &cartex_vga[16] ); + } while (ppCartexItr != &cartex_vga[16]); remove_mapsels(); scene_render_destroy(scene); gfx_size = iOldGfxSize; - if ( !iRetVal ) - { + if (!iRetVal) { fade_palette(0); front_fade = 0; } return iRetVal; } -void snapshot_render_winner_race(void) -{ +void snapshot_render_winner_race(void) { int iWinnerCar = 0; carorder[0] = iWinnerCar; @@ -317,21 +282,20 @@ void snapshot_render_winner_race(void) } //------------------------------------------------------------------------------------------------- -//000563E0 -void StoreResult() -{ - int iResultP2Pos; // edi - int iFastestLap; // ebp - int iMaxOffset_1; // esi +// 000563E0 +void StoreResult() { + int iResultP2Pos; // edi + int iFastestLap; // ebp + int iMaxOffset_1; // esi unsigned int iOffset; // ebx - int iCarIdx; // edx - double dResultTime; // st7 + int iCarIdx; // edx + double dResultTime; // st7 uint8 byCarDesignIdx; // al - int iResultP1Pos; // esi - int iCarOrderIdx; // edx - int iCarResult; // eax - int iCarOrderIdx_1; // eax - int iCarResult_1; // edx + int iResultP1Pos; // esi + int iCarOrderIdx; // edx + int iCarResult; // eax + int iCarOrderIdx_1; // eax + int iCarResult_1; // edx iResultP2Pos = result_p2_pos; @@ -340,17 +304,18 @@ void StoreResult() result_control[i] = human_control[i]; result_competing[i] = non_competitors[i]; } - //if (numcars > 0) { - // iMaxOffset = 4 * numcars; - // iResultOffset = 0; - // do { - // iResultOffset += 4; - // // offsets into adjacent data - // result_lap[iResultOffset / 4 + 15] = nearcall[iResultOffset / 4 + 15]; - // result_competing[iResultOffset / 4 + 15] = team_wins[iResultOffset / 4 + 15]; - // LODWORD(result_best[iResultOffset / 4 + 15]) = TrackArrow_variable_1[iResultOffset / 4]; - // } while ((int)iResultOffset < iMaxOffset); - //} + // if (numcars > 0) { + // iMaxOffset = 4 * numcars; + // iResultOffset = 0; + // do { + // iResultOffset += 4; + // // offsets into adjacent data + // result_lap[iResultOffset / 4 + 15] = nearcall[iResultOffset / 4 + 15]; + // result_competing[iResultOffset / 4 + 15] = team_wins[iResultOffset / 4 + // + 15]; LODWORD(result_best[iResultOffset / 4 + 15]) = + // TrackArrow_variable_1[iResultOffset / 4]; + // } while ((int)iResultOffset < iMaxOffset); + // } iFastestLap = -1; BestTime = 100000000.0; @@ -359,7 +324,8 @@ void StoreResult() iOffset = 0; do { iCarIdx = result_order[iOffset / 4]; - if (fabs(Car[iCarIdx].fBestLapTime) > FLT_EPSILON && Car[iCarIdx].fBestLapTime < (double)BestTime) { + if (fabs(Car[iCarIdx].fBestLapTime) > FLT_EPSILON && + Car[iCarIdx].fBestLapTime < (double)BestTime) { iFastestLap = result_order[iOffset / 4]; BestTime = Car[iCarIdx].fBestLapTime; } @@ -398,37 +364,36 @@ void StoreResult() } //------------------------------------------------------------------------------------------------- -//00056570 -void RaceResult() -{ - uint8 *pbyScreenBuffer; // edi +// 00056570 +void RaceResult() { + uint8 *pbyScreenBuffer; // edi tBlockHeader *pResultBitmap; // esi - unsigned int uiScreenSize; // ecx - char byRemainder; // al - unsigned int uiDwordCount; // ecx - int iBytesToCopy; // ebx - unsigned int uiLoopCounter; // eax - int iCarDesign; // ebp - int iKillIconX; // esi - int iKillIcon; // edi - int iTotalPoints; // eax - double dTimeDifference; // st7 - int iTotalRacePoints; // eax - int iFinishedCount; // [esp+0h] [ebp-4Ch] - int iSavedScreenSize; // [esp+4h] [ebp-48h] - float fWinnerTime; // [esp+8h] [ebp-44h] - char *pszPositionText; // [esp+Ch] [ebp-40h] - int iY; // [esp+10h] [ebp-3Ch] - int iTextY; // [esp+14h] [ebp-38h] - int iCarY; // [esp+1Ch] [ebp-30h] - int iCurrentRacer; // [esp+20h] [ebp-2Ch] - int iDriverIndex; // [esp+24h] [ebp-28h] - int iTextBaseY; // [esp+28h] [ebp-24h] - int iTimeCentiseconds; // [esp+2Ch] [ebp-20h] - int iTimeWork; // [esp+2Ch] [ebp-20h] + unsigned int uiScreenSize; // ecx + char byRemainder; // al + unsigned int uiDwordCount; // ecx + int iBytesToCopy; // ebx + unsigned int uiLoopCounter; // eax + int iCarDesign; // ebp + int iKillIconX; // esi + int iKillIcon; // edi + int iTotalPoints; // eax + double dTimeDifference; // st7 + int iTotalRacePoints; // eax + int iFinishedCount; // [esp+0h] [ebp-4Ch] + int iSavedScreenSize; // [esp+4h] [ebp-48h] + float fWinnerTime; // [esp+8h] [ebp-44h] + char *pszPositionText; // [esp+Ch] [ebp-40h] + int iY; // [esp+10h] [ebp-3Ch] + int iTextY; // [esp+14h] [ebp-38h] + int iCarY; // [esp+1Ch] [ebp-30h] + int iCurrentRacer; // [esp+20h] [ebp-2Ch] + int iDriverIndex; // [esp+24h] [ebp-28h] + int iTextBaseY; // [esp+28h] [ebp-24h] + int iTimeCentiseconds; // [esp+2Ch] [ebp-20h] + int iTimeWork; // [esp+2Ch] [ebp-20h] // init - fWinnerTime = 0; //added by ROLLER + fWinnerTime = 0; // added by ROLLER tick_on = 0; iSavedScreenSize = scr_size; SVGA_ON = -1; @@ -460,7 +425,8 @@ void RaceResult() byRemainder = uiScreenSize; uiDwordCount = uiScreenSize >> 2; memcpy(scrbuf, front_vga[2], 4 * uiDwordCount); - memcpy(&pbyScreenBuffer[4 * uiDwordCount], &pResultBitmap->iWidth + uiDwordCount, byRemainder & 3); + memcpy(&pbyScreenBuffer[4 * uiDwordCount], + &pResultBitmap->iWidth + uiDwordCount, byRemainder & 3); // Display "Result" header text iTextBaseY = 49; @@ -472,47 +438,62 @@ void RaceResult() do { non_competitors[uiLoopCounter / 4] = result_competing[uiLoopCounter / 4]; uiLoopCounter += 4; - //TrackArrow_variable_1[uiLoopCounter / 4] = LODWORD(result_best[uiLoopCounter / 4 + 15]);// non_competitors[uiLoopCounter / 4] = result_competing[uiLoopCounter / 4]; + // TrackArrow_variable_1[uiLoopCounter / 4] = + // LODWORD(result_best[uiLoopCounter / 4 + 15]);// + // non_competitors[uiLoopCounter / 4] = result_competing[uiLoopCounter / + // 4]; } while ((int)uiLoopCounter < iBytesToCopy); } iFinishedCount = 0; // display each racer's results if (racers > 0) { - iY = 44; // Initialize Y positions and text pointer for racer display + iY = 44; // Initialize Y positions and text pointer for racer display iTextY = 45; iCurrentRacer = 0; pszPositionText = race_posn[0]; iCarY = 46; do { iDriverIndex = result_order[iCurrentRacer]; - if (result_control[iDriverIndex]) // Show small human player icon if this racer is human controlled + if (result_control[iDriverIndex]) // Show small human player icon if this + // racer is human controlled display_block(scrbuf, front_vga[0], 0, 13, iY, 0); - sprintf(buffer, "%s", pszPositionText); // Display position text (1st, 2nd, etc.) - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 33, iTextBaseY, 0x8Fu, 0); - sprintf(buffer, "%s", driver_names[iDriverIndex]);// Display driver name - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 85, iTextBaseY, 0x8Fu, 0); - sprintf(buffer, "%s", CompanyNames[result_design[iDriverIndex]]);// Display car manufacturer name - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 218, iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%s", + pszPositionText); // Display position text (1st, 2nd, etc.) + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 33, + iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%s", driver_names[iDriverIndex]); // Display driver name + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 85, + iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%s", + CompanyNames[result_design[iDriverIndex]]); // Display car + // manufacturer name + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 218, + iTextBaseY, 0x8Fu, 0); iCarDesign = result_design[iDriverIndex]; // Display car sprite or CHEAT text if (iCarDesign >= 8) { - front_text(front_vga[3], "CHEAT", font2_ascii, font2_offsets, 165, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], "CHEAT", font2_ascii, font2_offsets, 165, + iTextBaseY, 0x8Fu, 0); } else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { - display_block(scrbuf, front_vga[0], smallcars[1][iCarDesign], 165, iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[1][iCarDesign], 165, + iCarY, 0); } else { - display_block(scrbuf, front_vga[0], smallcars[0][iCarDesign], 165, iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iCarDesign], 165, + iCarY, 0); } // Display kill count: either as number (>3) or individual icons (<=3) if (result_kills[iDriverIndex] > 3) { display_block(scrbuf, front_vga[0], 9, 356, iTextY, 0); sprintf(buffer, "%i", result_kills[iDriverIndex]); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 376, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 376, + iTextBaseY, 0x8Fu, 0); } else { iKillIconX = 356; - for (iKillIcon = 0; iKillIcon < result_kills[iDriverIndex]; iKillIconX += 18) { + for (iKillIcon = 0; iKillIcon < result_kills[iDriverIndex]; + iKillIconX += 18) { ++iKillIcon; display_block(scrbuf, front_vga[0], 9, iKillIconX, iTextY, 0); } @@ -541,40 +522,50 @@ void RaceResult() iTimeWork = iTimeCentiseconds / 10; buffer[0] = iTimeWork % 10 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 492, iTextBaseY, 0x8Fu, 0); - front_text(front_vga[3], ":", font2_ascii, font2_offsets, 467, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 492, + iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], ":", font2_ascii, font2_offsets, 467, + iTextBaseY, 0x8Fu, 0); iTimeWork /= 10; buffer[1] = iTimeWork % 10 + 48; iTimeWork /= 10; buffer[0] = iTimeWork % 6 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 471, iTextBaseY, 0x8Fu, 0); - front_text(front_vga[3], ":", font2_ascii, font2_offsets, 488, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 471, + iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], ":", font2_ascii, font2_offsets, 488, + iTextBaseY, 0x8Fu, 0); iTimeWork /= 6; buffer[1] = iTimeWork % 10 + 48; buffer[0] = iTimeWork / 10 % 10 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, + iTextBaseY, 0x8Fu, 0); } else { if (iTotalPoints == NoOfLaps) sprintf(buffer, "1 %s", &language_buffer[256]); else - sprintf(buffer, "%i %s", NoOfLaps - result_lap[iDriverIndex] + 1, &language_buffer[320]); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%i %s", NoOfLaps - result_lap[iDriverIndex] + 1, + &language_buffer[320]); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, + iTextBaseY, 0x8Fu, 0); } } else { - front_text(front_vga[3], &language_buffer[1920], font2_ascii, font2_offsets, 450, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], &language_buffer[1920], font2_ascii, + font2_offsets, 450, iTextBaseY, 0x8Fu, 0); } // Calculate total points (position + kills + fastest lap bonus) if (iDriverIndex == FastestLap) - iTotalRacePoints = result_kills[iDriverIndex] + points[iCurrentRacer] + 1; + iTotalRacePoints = + result_kills[iDriverIndex] + points[iCurrentRacer] + 1; else iTotalRacePoints = result_kills[iDriverIndex] + points[iCurrentRacer]; sprintf(buffer, "%2i", iTotalRacePoints); pszPositionText += 5; ++iCurrentRacer; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 560, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 560, + iTextBaseY, 0x8Fu, 0); // Move to next racer: increment Y positions and text pointer iTextBaseY += 22; @@ -603,42 +594,41 @@ void RaceResult() } //------------------------------------------------------------------------------------------------- -//00056D60 -void TimeTrials(int iDriverIdx) -{ - uint8 *pbyScreenBuffer; // edi +// 00056D60 +void TimeTrials(int iDriverIdx) { + uint8 *pbyScreenBuffer; // edi tBlockHeader *pResultBitmap; // esi - unsigned int uiScreenSize; // ecx - char byRemainder; // al - unsigned int uiDwordCount; // ecx - int iCarIdx; // edi - int iDesignIdx; // ebp - int iCarDesign; // ecx - double dBestTime; // st7 - int iLapTextY; // esi - int iLapNumber; // ebp - int iTimeOffset; // edi - double dLapTime; // st7 - int iRecordTextY; // esi - int iRecordCar; // edi - double dRecordTime; // st7 - int iFastestDriver; // edi - int iFastestTextY; // esi - int iFastestDriverCopy; // edi - int iFastestCarDesign; // ebp - double dFastestTime; // st7 - int iRecordHeaderY; // [esp-Ch] [ebp-40h] - int iSavedScreenSize; // [esp+0h] [ebp-34h] - int iRecordCentiseconds; // [esp+4h] [ebp-30h] - int iRecordTimeWork; // [esp+4h] [ebp-30h] - int iFastestCentiseconds; // [esp+8h] [ebp-2Ch] - int iFastestTimeWork; // [esp+8h] [ebp-2Ch] - int iBestCentiseconds; // [esp+Ch] [ebp-28h] - int iBestTimeWork; // [esp+Ch] [ebp-28h] - int iCarIndex; // [esp+10h] [ebp-24h] - int iY; // [esp+14h] [ebp-20h] - int iLapCentiseconds; // [esp+18h] [ebp-1Ch] - int iLapTimeWork; // [esp+18h] [ebp-1Ch] + unsigned int uiScreenSize; // ecx + char byRemainder; // al + unsigned int uiDwordCount; // ecx + int iCarIdx; // edi + int iDesignIdx; // ebp + int iCarDesign; // ecx + double dBestTime; // st7 + int iLapTextY; // esi + int iLapNumber; // ebp + int iTimeOffset; // edi + double dLapTime; // st7 + int iRecordTextY; // esi + int iRecordCar; // edi + double dRecordTime; // st7 + int iFastestDriver; // edi + int iFastestTextY; // esi + int iFastestDriverCopy; // edi + int iFastestCarDesign; // ebp + double dFastestTime; // st7 + int iRecordHeaderY; // [esp-Ch] [ebp-40h] + int iSavedScreenSize; // [esp+0h] [ebp-34h] + int iRecordCentiseconds; // [esp+4h] [ebp-30h] + int iRecordTimeWork; // [esp+4h] [ebp-30h] + int iFastestCentiseconds; // [esp+8h] [ebp-2Ch] + int iFastestTimeWork; // [esp+8h] [ebp-2Ch] + int iBestCentiseconds; // [esp+Ch] [ebp-28h] + int iBestTimeWork; // [esp+Ch] [ebp-28h] + int iCarIndex; // [esp+10h] [ebp-24h] + int iY; // [esp+14h] [ebp-20h] + int iLapCentiseconds; // [esp+18h] [ebp-1Ch] + int iLapTimeWork; // [esp+18h] [ebp-1Ch] // init tick_on = 0; @@ -671,7 +661,8 @@ void TimeTrials(int iDriverIdx) byRemainder = uiScreenSize; uiDwordCount = uiScreenSize >> 2; memcpy(scrbuf, front_vga[3], 4 * uiDwordCount); - memcpy(&pbyScreenBuffer[4 * uiDwordCount], &pResultBitmap->iWidth + uiDwordCount, byRemainder & 3); + memcpy(&pbyScreenBuffer[4 * uiDwordCount], + &pResultBitmap->iWidth + uiDwordCount, byRemainder & 3); // Display "Time Trials" header text display_block(scrbuf, front_vga[1], 4, 157, 5, -1); @@ -680,14 +671,17 @@ void TimeTrials(int iDriverIdx) sprintf(buffer, "%s", driver_names[iDriverIdx]); iCarIdx = iDriverIdx; iDesignIdx = iDriverIdx; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, 49, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, 49, 0x8Fu, + 0); sprintf(buffer, "%s", CompanyNames[result_design[iDesignIdx]]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, 49, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, 49, 0x8Fu, + 0); // Display car sprite or CHEAT text iCarDesign = result_design[iDesignIdx]; if (iCarDesign >= 8) { - front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, 49, 0x8Fu, 0); + front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, 49, + 0x8Fu, 0); } else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { display_block(scrbuf, front_vga[0], smallcars[1][iCarDesign], 165, 46, 0); } else { @@ -704,20 +698,23 @@ void TimeTrials(int iDriverIdx) iBestTimeWork = iBestCentiseconds / 10; buffer[0] = iBestTimeWork % 10 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, 49, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, 49, 0x8Fu, + 0); front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, 49, 0x8Fu, 0); iBestTimeWork /= 10; buffer[1] = iBestTimeWork % 10 + 48; iBestTimeWork /= 10; buffer[0] = iBestTimeWork % 6 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, 49, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, 49, 0x8Fu, + 0); front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, 49, 0x8Fu, 0); iBestTimeWork /= 6; buffer[1] = iBestTimeWork % 10 + 48; buffer[0] = iBestTimeWork / 10 % 10 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, 49, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, 49, 0x8Fu, + 0); // Initialize loop variables for displaying individual lap times iLapTextY = 93; @@ -728,18 +725,26 @@ void TimeTrials(int iDriverIdx) // Loop through each completed lap and display lap number and time while (iLapNumber < (char)Car[iCarIndex].byLap) { - sprintf(buffer, "%s %i", &language_buffer[256], iLapNumber);// Display lap number text - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 220, iLapTextY, 0x8Fu, 0); + sprintf(buffer, "%s %i", &language_buffer[256], + iLapNumber); // Display lap number text + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 220, iLapTextY, + 0x8Fu, 0); // Calculate the array index instead of byte offset - int iTrialIndex = (iTimeOffset - 4) / 4; // Convert byte offset back to array index - if (trial_times[iTrialIndex] == Car[iCarIndex].fBestLapTime) // Show fastest lap icon if this lap matches best time + int iTrialIndex = + (iTimeOffset - 4) / 4; // Convert byte offset back to array index + if (trial_times[iTrialIndex] == + Car[iCarIndex].fBestLapTime) // Show fastest lap icon if this lap + // matches best time display_block(scrbuf, front_vga[0], 10, 428, iY, 0); - dLapTime = trial_times[iTrialIndex] * 100.0; // Format and display lap time in MM:SS:CS format - //if (*(float *)((char *)trial_times + iTimeOffset) == Car[iCarIndex].fResultBestTime)// Show fastest lap icon if this lap matches best time - // display_block(scrbuf, front_vga[0], 10, 428, iY, 0); - //dLapTime = *(float *)((char *)trial_times + iTimeOffset) * 100.0;// Format and display lap time in MM:SS:CS format - //_CHP(); + dLapTime = trial_times[iTrialIndex] * + 100.0; // Format and display lap time in MM:SS:CS format + // if (*(float *)((char *)trial_times + iTimeOffset) == + // Car[iCarIndex].fResultBestTime)// Show fastest lap icon if this lap + // matches best time + // display_block(scrbuf, front_vga[0], 10, 428, iY, 0); + // dLapTime = *(float *)((char *)trial_times + iTimeOffset) * 100.0;// + // Format and display lap time in MM:SS:CS format _CHP(); iLapCentiseconds = (int)dLapTime; if ((int)dLapTime > 100000) @@ -748,21 +753,26 @@ void TimeTrials(int iDriverIdx) iLapTimeWork = iLapCentiseconds / 10; buffer[0] = iLapTimeWork % 10 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, iLapTextY, 0x8Fu, 0); - front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, iLapTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, iLapTextY, + 0x8Fu, 0); + front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, iLapTextY, + 0x8Fu, 0); iLapTimeWork /= 10; buffer[1] = iLapTimeWork % 10 + 48; iLapTimeWork /= 10; buffer[0] = iLapTimeWork % 6 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, iLapTextY, 0x8Fu, 0); - front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, iLapTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, iLapTextY, + 0x8Fu, 0); + front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, iLapTextY, + 0x8Fu, 0); iLapTimeWork /= 6; buffer[1] = iLapTimeWork % 10 + 48; buffer[0] = iLapTimeWork / 10 % 10 + 48; buffer[2] = 0; iTimeOffset += 4; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, iLapTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, iLapTextY, + 0x8Fu, 0); ++iLapNumber; iLapTextY += 22; iY += 22; @@ -771,25 +781,32 @@ void TimeTrials(int iDriverIdx) // Display track record section header iRecordHeaderY = iLapTextY + 44; iRecordTextY = iLapTextY + 66; - front_text(front_vga[2], &language_buffer[2752], font2_ascii, font2_offsets, 218, iRecordHeaderY, 0x8Fu, 0); + front_text(front_vga[2], &language_buffer[2752], font2_ascii, font2_offsets, + 218, iRecordHeaderY, 0x8Fu, 0); // Check if track record exists and display record holder info iRecordCar = RecordCars[TrackLoad]; if (iRecordCar < 0) { // Handle case where no track record exists sprintf(buffer, "%s", RecordNames[TrackLoad]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 165, iRecordTextY, 0x8Fu, 0); - front_text(front_vga[2], "00:00:00", font2_ascii, font2_offsets, 450, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 165, + iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], "00:00:00", font2_ascii, font2_offsets, 450, + iRecordTextY, 0x8Fu, 0); } else { // Display track record holder: name, company, car, and time sprintf(buffer, "%s", RecordNames[TrackLoad]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, + iRecordTextY, 0x8Fu, 0); sprintf(buffer, "%s", CompanyNames[iRecordCar & 0xF]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, + iRecordTextY, 0x8Fu, 0); if ((iRecordCar & 0xFu) >= 8) - front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, + iRecordTextY, 0x8Fu, 0); else - display_block(scrbuf, front_vga[0], smallcars[0][iRecordCar], 165, iRecordTextY - 3, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iRecordCar], 165, + iRecordTextY - 3, 0); dRecordTime = RecordLaps[TrackLoad] * 100.0; //_CHP(); iRecordCentiseconds = (int)dRecordTime; @@ -799,22 +816,29 @@ void TimeTrials(int iDriverIdx) iRecordTimeWork = iRecordCentiseconds / 10; buffer[0] = iRecordTimeWork % 10 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, iRecordTextY, 0x8Fu, 0); - front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, + iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, iRecordTextY, + 0x8Fu, 0); iRecordTimeWork /= 10; buffer[1] = iRecordTimeWork % 10 + 48; iRecordTimeWork /= 10; buffer[0] = iRecordTimeWork % 6 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, iRecordTextY, 0x8Fu, 0); - front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, + iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, iRecordTextY, + 0x8Fu, 0); iRecordTimeWork /= 6; buffer[1] = iRecordTimeWork % 10 + 48; buffer[2] = 0; buffer[0] = iRecordTimeWork / 10 % 10 + 48; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, iRecordTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, + iRecordTextY, 0x8Fu, 0); } - front_text(front_vga[2], &language_buffer[2880], font2_ascii, font2_offsets, 218, iRecordTextY + 44, 0x8Fu, 0);// Display session fastest lap section header + front_text(front_vga[2], &language_buffer[2880], font2_ascii, font2_offsets, + 218, iRecordTextY + 44, 0x8Fu, + 0); // Display session fastest lap section header iFastestDriver = FastestLap; iFastestTextY = iRecordTextY + 66; @@ -823,16 +847,21 @@ void TimeTrials(int iDriverIdx) // Display fastest lap holder: name, company, car, and time sprintf(buffer, "%s", driver_names[FastestLap]); iFastestDriverCopy = iFastestDriver; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, + iFastestTextY, 0x8Fu, 0); sprintf(buffer, "%s", CompanyNames[result_design[iFastestDriverCopy]]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, + iFastestTextY, 0x8Fu, 0); iFastestCarDesign = result_design[iFastestDriverCopy]; if (iFastestCarDesign >= 8) { - front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, + iFastestTextY, 0x8Fu, 0); } else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { - display_block(scrbuf, front_vga[0], smallcars[1][iFastestCarDesign], 165, iFastestTextY - 3, 0); + display_block(scrbuf, front_vga[0], smallcars[1][iFastestCarDesign], 165, + iFastestTextY - 3, 0); } else { - display_block(scrbuf, front_vga[0], smallcars[0][iFastestCarDesign], 165, iFastestTextY - 3, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iFastestCarDesign], 165, + iFastestTextY - 3, 0); } dFastestTime = BestTime * 100.0; //_CHP(); @@ -843,20 +872,25 @@ void TimeTrials(int iDriverIdx) iFastestTimeWork = iFastestCentiseconds / 10; buffer[2] = 0; buffer[0] = iFastestTimeWork % 10 + 48; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, iFastestTextY, 0x8Fu, 0); - front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 492, + iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], ":", font2_ascii, font2_offsets, 467, + iFastestTextY, 0x8Fu, 0); iFastestTimeWork /= 10; buffer[1] = iFastestTimeWork % 10 + 48; iFastestTimeWork /= 10; buffer[0] = iFastestTimeWork % 6 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, iFastestTextY, 0x8Fu, 0); - front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 471, + iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], ":", font2_ascii, font2_offsets, 488, + iFastestTextY, 0x8Fu, 0); iFastestTimeWork /= 6; buffer[1] = iFastestTimeWork % 10 + 48; buffer[0] = iFastestTimeWork / 10 % 10 + 48; buffer[2] = 0; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, iFastestTextY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 450, + iFastestTextY, 0x8Fu, 0); } // Display completed screen, start music, and wait for input @@ -877,39 +911,38 @@ void TimeTrials(int iDriverIdx) } //------------------------------------------------------------------------------------------------- -//00057AD0 -void ChampionshipStandings() -{ - int iSavedScreenSize; // ebp - uint8 *pbyScreenBuffer; // edi +// 00057AD0 +void ChampionshipStandings() { + int iSavedScreenSize; // ebp + uint8 *pbyScreenBuffer; // edi tBlockHeader *pResultBitmap; // esi - unsigned int uiScreenSize; // ecx - char byRemainder; // al - unsigned int uiDwordCount; // ecx - int iPosition; // ebx - int iOrderIndex; // edx - int iDriverIndex; // esi - int iDriverCopy; // eax - int iKills; // ecx - int iTotalKills; // edi - int iFastestLap; // ecx - int iTotalFasts; // ecx - int iSortOuter; // esi - int iSortIndex; // edi - int iMaxIndex; // ecx - int iSortInner; // eax - int iInnerIndex; // edx - int iSwapTemp; // edx - int iRacerCount; // eax - int iTextBaseY; // esi - int iCarY; // edi - int iCarDesign; // ebx - char *pszPositionText; // [esp+4h] [ebp-34h] - int iDisplayIndex; // [esp+8h] [ebp-30h] - int iY; // [esp+Ch] [ebp-2Ch] - int iIconY; // [esp+10h] [ebp-28h] - int iDisplayCount; // [esp+14h] [ebp-24h] - int iCurrentDriver; // [esp+1Ch] [ebp-1Ch] + unsigned int uiScreenSize; // ecx + char byRemainder; // al + unsigned int uiDwordCount; // ecx + int iPosition; // ebx + int iOrderIndex; // edx + int iDriverIndex; // esi + int iDriverCopy; // eax + int iKills; // ecx + int iTotalKills; // edi + int iFastestLap; // ecx + int iTotalFasts; // ecx + int iSortOuter; // esi + int iSortIndex; // edi + int iMaxIndex; // ecx + int iSortInner; // eax + int iInnerIndex; // edx + int iSwapTemp; // edx + int iRacerCount; // eax + int iTextBaseY; // esi + int iCarY; // edi + int iCarDesign; // ebx + char *pszPositionText; // [esp+4h] [ebp-34h] + int iDisplayIndex; // [esp+8h] [ebp-30h] + int iY; // [esp+Ch] [ebp-2Ch] + int iIconY; // [esp+10h] [ebp-28h] + int iDisplayCount; // [esp+14h] [ebp-24h] + int iCurrentDriver; // [esp+1Ch] [ebp-1Ch] // init tick_on = 0; @@ -942,7 +975,8 @@ void ChampionshipStandings() byRemainder = uiScreenSize; uiDwordCount = uiScreenSize >> 2; memcpy(scrbuf, front_vga[3], 4 * uiDwordCount); - memcpy(&pbyScreenBuffer[4 * uiDwordCount], &pResultBitmap->iWidth + uiDwordCount, byRemainder & 3); + memcpy(&pbyScreenBuffer[4 * uiDwordCount], + &pResultBitmap->iWidth + uiDwordCount, byRemainder & 3); // Calculate championship points for each racer based on race results iPosition = 0; @@ -953,18 +987,23 @@ void ChampionshipStandings() // Skip points calculation for single race mode (game_type == 3) if (game_type != 3) { iDriverCopy = iDriverIndex; - iKills = result_kills[iDriverIndex]; // Add race kills + position points to championship total - championship_points[iDriverCopy] = iKills + points[iOrderIndex] + championship_points[iDriverIndex]; - iTotalKills = iKills + total_kills[iDriverIndex];// Update total kills counter + iKills = result_kills[iDriverIndex]; // Add race kills + position points + // to championship total + championship_points[iDriverCopy] = + iKills + points[iOrderIndex] + championship_points[iDriverIndex]; + iTotalKills = + iKills + total_kills[iDriverIndex]; // Update total kills counter iFastestLap = FastestLap; total_kills[iDriverCopy] = iTotalKills; - if (iDriverIndex == iFastestLap) // Award bonus point and increment fastest lap count if this driver had fastest lap + if (iDriverIndex == + iFastestLap) // Award bonus point and increment fastest lap count if + // this driver had fastest lap { iTotalFasts = total_fasts[iDriverIndex] + 1; ++championship_points[iDriverIndex]; total_fasts[iDriverIndex] = iTotalFasts; } - if (!iPosition) // Increment win count for race winner (position 0) + if (!iPosition) // Increment win count for race winner (position 0) ++total_wins[iDriverIndex]; } ++iPosition; @@ -977,12 +1016,13 @@ void ChampionshipStandings() if (racers > 0) { iSortIndex = 0; do { - iMaxIndex = iSortOuter; // Find racer with highest points in remaining unsorted elements + iMaxIndex = iSortOuter; // Find racer with highest points in remaining + // unsorted elements iSortInner = iSortOuter + 1; iSavedScreenSize = championship_points[champorder[iSortIndex]]; if (iSortOuter + 1 < racers) { iInnerIndex = iSortInner; - do { // Update max if current racer has more points + do { // Update max if current racer has more points if (championship_points[champorder[iInnerIndex]] > iSavedScreenSize) { iMaxIndex = iSortInner; iSavedScreenSize = championship_points[champorder[iInnerIndex]]; @@ -992,7 +1032,7 @@ void ChampionshipStandings() } while (iSortInner < racers); } ++iSortIndex; - ++iSortOuter; // Swap highest scoring racer to correct position + ++iSortOuter; // Swap highest scoring racer to correct position iSwapTemp = champorder[iSortIndex - 1]; champorder[iSortIndex - 1] = champorder[iMaxIndex]; iRacerCount = racers; @@ -1014,38 +1054,58 @@ void ChampionshipStandings() iY = 44; do { iCurrentDriver = champorder[iDisplayIndex]; - if (result_control[iCurrentDriver]) // Show human player icon if this driver is human controlled + if (result_control[iCurrentDriver]) // Show human player icon if this + // driver is human controlled display_block(scrbuf, front_vga[0], 0, 13, iY, 0); - sprintf(buffer, "%s", pszPositionText); // Display position text (1st, 2nd, etc.) - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 33, iTextBaseY, 0x8Fu, 0); - sprintf(buffer, "%s", driver_names[iCurrentDriver]);// Display driver name - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, iTextBaseY, 0x8Fu, 0); - sprintf(buffer, "%s", CompanyNames[result_design[iCurrentDriver]]);// Display car manufacturer name - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%s", + pszPositionText); // Display position text (1st, 2nd, etc.) + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 33, + iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%s", + driver_names[iCurrentDriver]); // Display driver name + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 85, + iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%s", + CompanyNames[result_design[iCurrentDriver]]); // Display car + // manufacturer name + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 218, + iTextBaseY, 0x8Fu, 0); iCarDesign = result_design[iCurrentDriver]; // Display car sprite or CHEAT text if (iCarDesign >= 8) { - front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[2], "CHEAT", font2_ascii, font2_offsets, 165, + iTextBaseY, 0x8Fu, 0); } else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { - display_block(scrbuf, front_vga[0], smallcars[1][iCarDesign], 165, iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[1][iCarDesign], 165, + iCarY, 0); } else { - display_block(scrbuf, front_vga[0], smallcars[0][iCarDesign], 165, iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iCarDesign], 165, + iCarY, 0); } - display_block(scrbuf, front_vga[0], 9, 356, iIconY, 0);// Display total kills icon and count + display_block(scrbuf, front_vga[0], 9, 356, iIconY, + 0); // Display total kills icon and count sprintf(buffer, "%i", total_kills[iCurrentDriver]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 376, iTextBaseY, 0x8Fu, 0); - display_block(scrbuf, front_vga[0], 11, 475, iCarY, 0);// Display total wins icon and count + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 376, + iTextBaseY, 0x8Fu, 0); + display_block(scrbuf, front_vga[0], 11, 475, iCarY, + 0); // Display total wins icon and count sprintf(buffer, "%i", total_wins[iCurrentDriver]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 500, iTextBaseY, 0x8Fu, 0); - display_block(scrbuf, front_vga[0], 10, 428, iCarY, 0);// Display total fastest laps icon and count + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 500, + iTextBaseY, 0x8Fu, 0); + display_block(scrbuf, front_vga[0], 10, 428, iCarY, + 0); // Display total fastest laps icon and count sprintf(buffer, "%i", total_fasts[iCurrentDriver]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 448, iTextBaseY, 0x8Fu, 0); - sprintf(buffer, "%3i", championship_points[iCurrentDriver]);// Display total championship points + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 448, + iTextBaseY, 0x8Fu, 0); + sprintf(buffer, "%3i", + championship_points[iCurrentDriver]); // Display total + // championship points // Move to next driver: increment Y positions and text pointer iCarY += 22; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 560, iTextBaseY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 560, + iTextBaseY, 0x8Fu, 0); iTextBaseY += 22; iY += 22; iIconY += 22; @@ -1061,7 +1121,8 @@ void ChampionshipStandings() fade_palette(32); ticks = 0; - // Different wait behavior: single race mode waits indefinitely, championship mode waits 2160 ticks + // Different wait behavior: single race mode waits indefinitely, championship + // mode waits 2160 ticks if (game_type == 3) { while (!fatkbhit()) UpdateSDL(); @@ -1081,37 +1142,36 @@ void ChampionshipStandings() } //------------------------------------------------------------------------------------------------- -//00058100 -void TeamStandings() -{ - uint8 *pScrBuf; // edi +// 00058100 +void TeamStandings() { + uint8 *pScrBuf; // edi tBlockHeader *pResultImage; // esi - unsigned int uiBufSize; // ecx - char uiBufSizeLow; // al - unsigned int uiDWordCount; // ecx - int iRacerIdx; // edx - int iResultIdx; // ebx - int iDriverIdx; // ebp - int iCarDesignIdx; // esi - int iTeamIdx; // eax - int iFastestLapDrvr; // ecx - int iTeamFastLaps; // ebp - int iTeamOrderIdx; // eax - int iInitIdx; // edx - int iCurrTeamIdx; // edi - int iSortIdx; // ebp - int iCompareIdx; // ecx - int iNextIdx; // eax - int iBestPoints; // esi - int iCompareTeamIdx; // edx - int iBestTeamIdx; // edx - int iDisplayY; // edi - int iTeamDisplayIdx; // ebp - int iDisplayTeamIdx; // edi - int iBestTeamIdx_1; // ebp - char *szPosition; // [esp+8h] [ebp-28h] - int iTeamIter; // [esp+Ch] [ebp-24h] - int iCarY; // [esp+10h] [ebp-20h] + unsigned int uiBufSize; // ecx + char uiBufSizeLow; // al + unsigned int uiDWordCount; // ecx + int iRacerIdx; // edx + int iResultIdx; // ebx + int iDriverIdx; // ebp + int iCarDesignIdx; // esi + int iTeamIdx; // eax + int iFastestLapDrvr; // ecx + int iTeamFastLaps; // ebp + int iTeamOrderIdx; // eax + int iInitIdx; // edx + int iCurrTeamIdx; // edi + int iSortIdx; // ebp + int iCompareIdx; // ecx + int iNextIdx; // eax + int iBestPoints; // esi + int iCompareTeamIdx; // edx + int iBestTeamIdx; // edx + int iDisplayY; // edi + int iTeamDisplayIdx; // ebp + int iDisplayTeamIdx; // edi + int iBestTeamIdx_1; // ebp + char *szPosition; // [esp+8h] [ebp-28h] + int iTeamIter; // [esp+Ch] [ebp-24h] + int iCarY; // [esp+10h] [ebp-20h] // init screen tick_on = 0; @@ -1134,45 +1194,42 @@ void TeamStandings() tick_on = -1; pScrBuf = scrbuf; pResultImage = front_vga[3]; - if ( SVGA_ON ) + if (SVGA_ON) uiBufSize = 256000; else uiBufSize = 64000; uiBufSizeLow = uiBufSize; uiDWordCount = uiBufSize >> 2; memcpy(scrbuf, front_vga[3], 4 * uiDWordCount); - memcpy(&pScrBuf[4 * uiDWordCount], &pResultImage->iWidth + uiDWordCount, uiBufSizeLow & 3); + memcpy(&pScrBuf[4 * uiDWordCount], &pResultImage->iWidth + uiDWordCount, + uiBufSizeLow & 3); // calculate team stats - if ( game_type != 3 ) - { + if (game_type != 3) { iRacerIdx = 0; - if ( racers > 0 ) - { + if (racers > 0) { iResultIdx = 0; - do - { + do { iDriverIdx = result_order[iResultIdx]; iCarDesignIdx = result_design[iDriverIdx]; - if ( iCarDesignIdx < 8 ) - { + if (iCarDesignIdx < 8) { iTeamIdx = iCarDesignIdx; - team_points[iTeamIdx] += result_kills[iDriverIdx] + points[iResultIdx]; + team_points[iTeamIdx] += + result_kills[iDriverIdx] + points[iResultIdx]; iFastestLapDrvr = FastestLap; - team_kills[iTeamIdx] = result_kills[iDriverIdx] + team_kills[iCarDesignIdx]; - if ( iDriverIdx == iFastestLapDrvr ) - { + team_kills[iTeamIdx] = + result_kills[iDriverIdx] + team_kills[iCarDesignIdx]; + if (iDriverIdx == iFastestLapDrvr) { iTeamFastLaps = team_fasts[iCarDesignIdx] + 1; ++team_points[iCarDesignIdx]; team_fasts[iCarDesignIdx] = iTeamFastLaps; } - if ( !iRacerIdx ) + if (!iRacerIdx) ++team_wins[iCarDesignIdx]; } ++iRacerIdx; ++iResultIdx; - } - while ( iRacerIdx < racers ); + } while (iRacerIdx < racers); } } @@ -1181,90 +1238,90 @@ void TeamStandings() iInitIdx = 0; do teamorder[iInitIdx++] = iTeamOrderIdx++; - while ( iTeamOrderIdx < 8 ); + while (iTeamOrderIdx < 8); // Sort teams by points iCurrTeamIdx = 0; iSortIdx = 0; - do - { + do { iCompareIdx = iCurrTeamIdx; iNextIdx = iCurrTeamIdx + 1; iBestPoints = team_points[teamorder[iSortIdx]]; - if ( iCurrTeamIdx + 1 < 8 ) - { + if (iCurrTeamIdx + 1 < 8) { iCompareTeamIdx = iNextIdx; - do - { - if ( team_points[teamorder[iCompareTeamIdx]] > iBestPoints ) - { + do { + if (team_points[teamorder[iCompareTeamIdx]] > iBestPoints) { iCompareIdx = iNextIdx; iBestPoints = team_points[teamorder[iCompareTeamIdx]]; } ++iNextIdx; ++iCompareTeamIdx; - } - while ( iNextIdx < 8 ); + } while (iNextIdx < 8); } iBestTeamIdx = teamorder[iSortIdx]; teamorder[iSortIdx] = teamorder[iCompareIdx]; ++iSortIdx; - //iBestTeamIdx = DeathView_variable_1[++iSortIdx];// offset into teamorder - //DeathView_variable_1[iSortIdx] = teamorder[iCompareIdx]; + // iBestTeamIdx = DeathView_variable_1[++iSortIdx];// offset into teamorder + // DeathView_variable_1[iSortIdx] = teamorder[iCompareIdx]; ++iCurrTeamIdx; teamorder[iCompareIdx] = iBestTeamIdx; - } - while ( iCurrTeamIdx < 8 ); + } while (iCurrTeamIdx < 8); // Display team standings table iDisplayY = 49; - display_block(scrbuf, front_vga[1], 2, 157, 3, -1);// header + display_block(scrbuf, front_vga[1], 2, 157, 3, -1); // header iTeamIter = 0; szPosition = race_posn[0]; - do - { + do { iTeamDisplayIdx = teamorder[iTeamIter]; // display human player indicator if this team has huma players - if ( result_control[2 * iTeamDisplayIdx + 1] || result_control[2 * iTeamDisplayIdx] ) + if (result_control[2 * iTeamDisplayIdx + 1] || + result_control[2 * iTeamDisplayIdx]) display_block(scrbuf, front_vga[0], 0, 13, iDisplayY - 5, 0); // Display team position sprintf(buffer, (uint8 *)"%s", szPosition); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 33, iDisplayY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 33, iDisplayY, + 0x8Fu, 0); // Display team name sprintf(buffer, (uint8 *)"%s", CompanyNames[iTeamDisplayIdx]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 190, iDisplayY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 190, iDisplayY, + 0x8Fu, 0); // display car sprites iCarY = iDisplayY - 3; - if ( (textures_off & TEX_OFF_ADVANCED_CARS) != 0 ) - { - display_block(scrbuf, front_vga[0], smallcars[1][iTeamDisplayIdx], 340, iCarY, 0); - display_block(scrbuf, front_vga[0], smallcars[1][iTeamDisplayIdx], 100, iCarY, 0); - } - else - { - display_block(scrbuf, front_vga[0], smallcars[0][iTeamDisplayIdx], 340, iCarY, 0); - display_block(scrbuf, front_vga[0], smallcars[0][iTeamDisplayIdx], 100, iCarY, 0); + if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { + display_block(scrbuf, front_vga[0], smallcars[1][iTeamDisplayIdx], 340, + iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[1][iTeamDisplayIdx], 100, + iCarY, 0); + } else { + display_block(scrbuf, front_vga[0], smallcars[0][iTeamDisplayIdx], 340, + iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iTeamDisplayIdx], 100, + iCarY, 0); } // display wins icon and count display_block(scrbuf, front_vga[0], 11, 475, iDisplayY - 3, 0); sprintf(buffer, (uint8 *)"%i", team_wins[iTeamDisplayIdx]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 500, iDisplayY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 500, iDisplayY, + 0x8Fu, 0); // display fast laps icon and count display_block(scrbuf, front_vga[0], 10, 428, iDisplayY - 3, 0); sprintf(buffer, (uint8 *)"%i", team_fasts[iTeamDisplayIdx]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 448, iDisplayY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 448, iDisplayY, + 0x8Fu, 0); // display total points sprintf(buffer, (uint8 *)"%3i", team_points[iTeamDisplayIdx]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 560, iDisplayY, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 560, iDisplayY, + 0x8Fu, 0); // display kills icon and count (line 2) display_block(scrbuf, front_vga[0], 9, 428, iDisplayY + 18, 0); @@ -1272,24 +1329,26 @@ void TeamStandings() iDisplayTeamIdx = iDisplayY + 22; // Display both team driver names - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 448, iDisplayTeamIdx, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 448, + iDisplayTeamIdx, 0x8Fu, 0); sprintf(buffer, (uint8 *)"%s", driver_names[2 * iTeamDisplayIdx]); - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 110, iDisplayTeamIdx, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 110, + iDisplayTeamIdx, 0x8Fu, 0); sprintf(buffer, (uint8 *)"%s", driver_names[2 * iTeamDisplayIdx + 1]); iBestTeamIdx_1 = 2 * iTeamDisplayIdx; - front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 310, iDisplayTeamIdx, 0x8Fu, 0); + front_text(front_vga[2], buffer, font2_ascii, font2_offsets, 310, + iDisplayTeamIdx, 0x8Fu, 0); // display human player indicator for driver names if applicable - if ( result_control[iBestTeamIdx_1 + 1] || result_control[iBestTeamIdx_1] ) + if (result_control[iBestTeamIdx_1 + 1] || result_control[iBestTeamIdx_1]) display_block(scrbuf, front_vga[0], 0, 13, iDisplayTeamIdx - 5, 0); // move to next team display pos iDisplayY = iDisplayTeamIdx + 22; ++iTeamIter; szPosition += 5; - } - while ( iTeamIter != 8 ); + } while (iTeamIter != 8); // display completed standings screen copypic(scrbuf, screen); @@ -1298,14 +1357,11 @@ void TeamStandings() ticks = 0; // wait for user input or timeout - if ( game_type == 3 ) - { - while ( !fatkbhit() ) + if (game_type == 3) { + while (!fatkbhit()) UpdateSDL(); - } - else - { - while ( !fatkbhit() && ticks < 2160 ) + } else { + while (!fatkbhit() && ticks < 2160) UpdateSDL(); } @@ -1320,40 +1376,39 @@ void TeamStandings() } //------------------------------------------------------------------------------------------------- -//00058780 -void ShowLapRecords() -{ - uint8 *pScrBuf; // edi - tBlockHeader *pBlockHeader; // esi - unsigned int uiMemSize; // ecx - char byMemSize; // al - unsigned int uiDwordCount; // ecx - int iTextY; // esi - int iRecordIdx; // ebp - int iArrayIdx; // edi - double dLapTime; // st7 - uint8 *pScrBuf_1; // edi +// 00058780 +void ShowLapRecords() { + uint8 *pScrBuf; // edi + tBlockHeader *pBlockHeader; // esi + unsigned int uiMemSize; // ecx + char byMemSize; // al + unsigned int uiDwordCount; // ecx + int iTextY; // esi + int iRecordIdx; // ebp + int iArrayIdx; // edi + double dLapTime; // st7 + uint8 *pScrBuf_1; // edi tBlockHeader *pBlockHeader_1; // esi - unsigned int uiMemSize_1; // ecx - char byMemSize_1; // al - unsigned int uiDwordCount_1; // ecx - int iTextY_1; // esi - int iRecordIdx_1; // ebp - int iArrayIdx_1; // edi - double dLapTime_1; // st7 - int iCarY; // [esp+4h] [ebp-44h] - int iOldScrSize; // [esp+8h] [ebp-40h] - int iKillIconY_1; // [esp+Ch] [ebp-3Ch] - int iKillIconY; // [esp+10h] [ebp-38h] - int iCarY2; // [esp+14h] [ebp-34h] - int iCarType; // [esp+18h] [ebp-30h] - int iCarType_1; // [esp+1Ch] [ebp-2Ch] - const char *szRecordName; // [esp+20h] [ebp-28h] - const char *szRecordName_1; // [esp+24h] [ebp-24h] - int iTimeValue_1; // [esp+28h] [ebp-20h] - int iTimeTemp_1; // [esp+28h] [ebp-20h] - int iTimeValue; // [esp+2Ch] [ebp-1Ch] - int iTimeTemp; // [esp+2Ch] [ebp-1Ch] + unsigned int uiMemSize_1; // ecx + char byMemSize_1; // al + unsigned int uiDwordCount_1; // ecx + int iTextY_1; // esi + int iRecordIdx_1; // ebp + int iArrayIdx_1; // edi + double dLapTime_1; // st7 + int iCarY; // [esp+4h] [ebp-44h] + int iOldScrSize; // [esp+8h] [ebp-40h] + int iKillIconY_1; // [esp+Ch] [ebp-3Ch] + int iKillIconY; // [esp+10h] [ebp-38h] + int iCarY2; // [esp+14h] [ebp-34h] + int iCarType; // [esp+18h] [ebp-30h] + int iCarType_1; // [esp+1Ch] [ebp-2Ch] + const char *szRecordName; // [esp+20h] [ebp-28h] + const char *szRecordName_1; // [esp+24h] [ebp-24h] + int iTimeValue_1; // [esp+28h] [ebp-20h] + int iTimeTemp_1; // [esp+28h] [ebp-20h] + int iTimeValue; // [esp+2Ch] [ebp-1Ch] + int iTimeTemp; // [esp+2Ch] [ebp-1Ch] // init display settings holdmusic = -1; @@ -1382,14 +1437,15 @@ void ShowLapRecords() // copy background to screen buffer pScrBuf = scrbuf; pBlockHeader = front_vga[2]; - if ( SVGA_ON ) + if (SVGA_ON) uiMemSize = 256000; else uiMemSize = 64000; byMemSize = uiMemSize; uiDwordCount = uiMemSize >> 2; memcpy(scrbuf, front_vga[2], 4 * uiDwordCount); - memcpy(&pScrBuf[4 * uiDwordCount], &pBlockHeader->iWidth + uiDwordCount, byMemSize & 3); + memcpy(&pScrBuf[4 * uiDwordCount], &pBlockHeader->iWidth + uiDwordCount, + byMemSize & 3); // Display records iTextY = 49; @@ -1400,46 +1456,50 @@ void ShowLapRecords() iCarY = 46; iKillIconY = 45; - do - { + do { // display record number sprintf(buffer, (uint8 *)"%02i", iRecordIdx); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 33, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 33, iTextY, + 0x8Fu, 0); iCarType = RecordCars[iArrayIdx]; - if ( iCarType < 0 ) - { + if (iCarType < 0) { // no record set - display default name and time sprintf(buffer, (uint8 *)"%s", szRecordName); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 165, iTextY, 0x8Fu, 0); - front_text(front_vga[3], "00:00:00", font2_ascii, font2_offsets, 450, iTextY, 0x8Fu, 0); - } - else - { + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 165, iTextY, + 0x8Fu, 0); + front_text(front_vga[3], "00:00:00", font2_ascii, font2_offsets, 450, + iTextY, 0x8Fu, 0); + } else { // display record holder name sprintf(buffer, (uint8 *)"%s", szRecordName); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 85, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 85, iTextY, + 0x8Fu, 0); // display car company name sprintf(buffer, (uint8 *)"%s", CompanyNames[iCarType & 0xF]); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 218, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 218, iTextY, + 0x8Fu, 0); // display car - if ( (iCarType & 0xFu) >= 8 ) - front_text(front_vga[3], "CHEAT", font2_ascii, font2_offsets, 165, iTextY, 0x8Fu, 0); + if ((iCarType & 0xFu) >= 8) + front_text(front_vga[3], "CHEAT", font2_ascii, font2_offsets, 165, + iTextY, 0x8Fu, 0); else - display_block(scrbuf, front_vga[0], smallcars[0][iCarType], 165, iCarY, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iCarType], 165, iCarY, + 0); // display kill count icon and number display_block(scrbuf, front_vga[0], 9, 540, iKillIconY, 0); sprintf(buffer, (uint8 *)"%i", RecordKills[iArrayIdx]); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 560, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 560, iTextY, + 0x8Fu, 0); // display lap time dLapTime = RecordLaps[iArrayIdx] * 100.0; //_CHP(); iTimeValue = (int)dLapTime; - if ( (int)dLapTime > 599999 ) + if ((int)dLapTime > 599999) iTimeValue = 599999; // display centiseconds @@ -1447,8 +1507,10 @@ void ShowLapRecords() iTimeTemp = iTimeValue / 10; buffer[0] = iTimeTemp % 10 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 492, iTextY, 0x8Fu, 0); - front_text(front_vga[3], ":", font2_ascii, font2_offsets, 467, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 492, iTextY, + 0x8Fu, 0); + front_text(front_vga[3], ":", font2_ascii, font2_offsets, 467, iTextY, + 0x8Fu, 0); // display seconds iTimeTemp /= 10; @@ -1456,15 +1518,18 @@ void ShowLapRecords() iTimeTemp /= 10; buffer[0] = iTimeTemp % 6 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 471, iTextY, 0x8Fu, 0); - front_text(front_vga[3], ":", font2_ascii, font2_offsets, 488, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 471, iTextY, + 0x8Fu, 0); + front_text(front_vga[3], ":", font2_ascii, font2_offsets, 488, iTextY, + 0x8Fu, 0); // display minutes iTimeTemp /= 6; buffer[1] = iTimeTemp % 10 + 48; buffer[0] = iTimeTemp / 10 % 10 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, iTextY, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, iTextY, + 0x8Fu, 0); } // move to next record pos @@ -1474,43 +1539,39 @@ void ShowLapRecords() iCarY += 22; iKillIconY += 22; szRecordName += 9; - } - while ( iRecordIdx < 17 ); + } while (iRecordIdx < 17); // display first page and wait for input copypic(scrbuf, screen); holdmusic = -1; fade_palette(32); ticks = 0; - if ( game_type == 4 ) - { - while ( !fatkbhit() ) + if (game_type == 4) { + while (!fatkbhit()) UpdateSDL(); - } - else - { - while ( !fatkbhit() && ticks < 720 ) + } else { + while (!fatkbhit() && ticks < 720) UpdateSDL(); } scr_size = iOldScrSize; // display second page - if ( (textures_off & TEX_OFF_BONUS_CUP_AVAILABLE) != 0 ) - { + if ((textures_off & TEX_OFF_BONUS_CUP_AVAILABLE) != 0) { holdmusic = -1; fade_palette(0); // copy background to screen buffer pScrBuf_1 = scrbuf; pBlockHeader_1 = front_vga[2]; - if ( SVGA_ON ) + if (SVGA_ON) uiMemSize_1 = 256000; else uiMemSize_1 = 64000; byMemSize_1 = uiMemSize_1; uiDwordCount_1 = uiMemSize_1 >> 2; memcpy(scrbuf, front_vga[2], 4 * uiDwordCount_1); - memcpy(&pScrBuf_1[4 * uiDwordCount_1], &pBlockHeader_1->iWidth + uiDwordCount_1, byMemSize_1 & 3); + memcpy(&pScrBuf_1[4 * uiDwordCount_1], + &pBlockHeader_1->iWidth + uiDwordCount_1, byMemSize_1 & 3); // display records 17-24 iTextY_1 = 49; @@ -1521,46 +1582,50 @@ void ShowLapRecords() iCarY2 = 46; iKillIconY_1 = 45; - do - { + do { // display record number sprintf(buffer, (uint8 *)"%02i", iRecordIdx_1); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 33, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 33, iTextY_1, + 0x8Fu, 0); iCarType_1 = RecordCars[iArrayIdx_1]; - if ( iCarType_1 < 0 ) - { + if (iCarType_1 < 0) { // no record set sprintf(buffer, (uint8 *)"%s", szRecordName_1); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 165, iTextY_1, 0x8Fu, 0); - front_text(front_vga[3], "00:00:00", font2_ascii, font2_offsets, 450, iTextY_1, 0x8Fu, 0); - } - else - { + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 165, + iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], "00:00:00", font2_ascii, font2_offsets, 450, + iTextY_1, 0x8Fu, 0); + } else { // display record holder name sprintf(buffer, (uint8 *)"%s", szRecordName_1); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 85, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 85, + iTextY_1, 0x8Fu, 0); // display car company name sprintf(buffer, (uint8 *)"%s", CompanyNames[iCarType_1 & 0xF]); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 218, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 218, + iTextY_1, 0x8Fu, 0); // display car or cheat indicator - if ( (iCarType_1 & 0xFu) >= 8 ) - front_text(front_vga[3], "CHEAT", font2_ascii, font2_offsets, 165, iTextY_1, 0x8Fu, 0); + if ((iCarType_1 & 0xFu) >= 8) + front_text(front_vga[3], "CHEAT", font2_ascii, font2_offsets, 165, + iTextY_1, 0x8Fu, 0); else - display_block(scrbuf, front_vga[0], smallcars[0][iCarType_1], 165, iCarY2, 0); + display_block(scrbuf, front_vga[0], smallcars[0][iCarType_1], 165, + iCarY2, 0); // display kill count icon and number display_block(scrbuf, front_vga[0], 9, 540, iKillIconY_1, 0); sprintf(buffer, (uint8 *)"%i", RecordKills[iArrayIdx_1]); - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 560, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 560, + iTextY_1, 0x8Fu, 0); // display lap time dLapTime_1 = RecordLaps[iArrayIdx_1] * 100.0; //_CHP(); iTimeValue_1 = (int)dLapTime_1; - if ( (int)dLapTime_1 > 599999 ) + if ((int)dLapTime_1 > 599999) iTimeValue_1 = 599999; // display centiseconds @@ -1568,8 +1633,10 @@ void ShowLapRecords() iTimeTemp_1 = iTimeValue_1 / 10; buffer[0] = iTimeTemp_1 % 10 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 492, iTextY_1, 0x8Fu, 0); - front_text(front_vga[3], ":", font2_ascii, font2_offsets, 467, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 492, + iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], ":", font2_ascii, font2_offsets, 467, iTextY_1, + 0x8Fu, 0); // display seconds iTimeTemp_1 /= 10; @@ -1577,15 +1644,18 @@ void ShowLapRecords() iTimeTemp_1 /= 10; buffer[0] = iTimeTemp_1 % 6 + 48; buffer[2] = 0; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 471, iTextY_1, 0x8Fu, 0); - front_text(front_vga[3], ":", font2_ascii, font2_offsets, 488, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 471, + iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], ":", font2_ascii, font2_offsets, 488, iTextY_1, + 0x8Fu, 0); // display minutes iTimeTemp_1 /= 6; buffer[1] = iTimeTemp_1 % 10 + 48; buffer[2] = 0; buffer[0] = iTimeTemp_1 / 10 % 10 + 48; - front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, iTextY_1, 0x8Fu, 0); + front_text(front_vga[3], buffer, font2_ascii, font2_offsets, 450, + iTextY_1, 0x8Fu, 0); } // move to next record pos @@ -1595,22 +1665,18 @@ void ShowLapRecords() iCarY2 += 22; iKillIconY_1 += 22; szRecordName_1 += 9; - } - while ( iRecordIdx_1 < 25 ); + } while (iRecordIdx_1 < 25); // display second page and wait for input copypic(scrbuf, screen); holdmusic = -1; fade_palette(32); ticks = 0; - if ( game_type == 4 ) - { - while ( !fatkbhit() ) + if (game_type == 4) { + while (!fatkbhit()) UpdateSDL(); - } - else - { - while ( !fatkbhit() && ticks < 720 ) + } else { + while (!fatkbhit() && ticks < 720) UpdateSDL(); } scr_size = iOldScrSize; @@ -1623,189 +1689,188 @@ void ShowLapRecords() fre((void **)&front_vga[3]); holdmusic = (game_type != 4) - 1; fade_palette(0); - if ( game_type != 4 ) + if (game_type != 4) holdmusic = 0; } //------------------------------------------------------------------------------------------------- -//00059220 -void show_3dmap(float fZ, int iElevation, int iYaw) -{ - int iChunkIdx; // edx - double dBoundingBoxExpansionX; // st7 - double dBoundingBoxExpansionY; // st7 - double dZRange; // st7 - double dCenterDivisor; // st7 - double dTempTransform; // st7 - double dTempTransform2; // st7 - double dCorner1Y; // st5 - double dCorner1Z; // st4 - double dCorner1X; // st2 - double dTransformedX1; // st6 - double dTransformedY1; // rt2 - double dTransformedZ1; // st5 - double dDepth1; // st7 - double dViewDistance; // st7 - double dDepthInverse1; // st6 - double dScreenX1; // st5 - double dScreenY1; // st7 - double dCorner2Y; // st6 - double dCorner2Z; // st5 - double dCorner2X; // st3 - double dTransformedX2; // st7 - double dTransformedY2; // rtt - double dTransformedZ2; // st5 - double dProjX2; // st4 - int iScreenSize; // edi - double dProjZ2; // st3 - float fProjX1Int; // eax - double dProjY2Full; // st4 - float fProjY2; // eax - double dDepth2Full; // st7 - double dViewDistance2Full; // st7 - double dDepthInverse2; // st6 - double dScreenX2; // st5 - double dScreenY2; // st7 - double dCorner3Y; // st6 - double dCorner3Z; // st5 - double dCorner3X; // st3 - double dTransformedX3; // st7 - double fTransformedY3; // rt1 - double dTransformedZ3; // st5 - double dProjX3; // st4 - int iScreenSize2; // edi - double dProjZ3Full; // st3 - float fProjX2Temp; // eax - double dProjY3; // st4 - float fProjY2Temp; // eax - double dDepth3; // st7 - double dViewDistance3; // st7 - double dDepthInverse3; // st6 - double dScreenX3; // st5 - double dScreenY3Full; // st7 - double dCorner4Y; // st6 - double dCorner4Z; // st5 - double dCorner4X; // st3 - double dTransformedX4; // st7 - double dTransformedY4; // rtt - double dTransformedZ4; // st5 - double dProjX4; // st4 - int iScreenSize3; // edi - double dProjZ4; // st3 - float fProjX3; // eax - double dProjY4; // st4 - float fProjY3Full; // eax - double dDepth4Full; // st7 - double dViewDistance4; // st7 - double dDepthInverse4; // st6 - double dScreenX4; // st5 - double dScreenY4; // st7 - int iScreenSize4; // edi - int iProjX4Int; // eax - int iScreenXFinal; // eax - int iLoopIndex; // ecx - tTrackScreenXYZ *pTrackScreenXYZ; // ebx - tVec3 *pTrackPt; // edi - tGroundPt *pCurrentGroundPt; // eax - double dTrackPointY; // st6 - double dTrackPointZ; // st5 - double dTrackPointX; // st3 - double dTransformedTrackX; // st7 - double dTransformedTrackY; // rt1 - double dTransformedTrackZ; // st5 - double dViewDistanceTrackFull; // st7 - double dViewDistanceTrack; // st7 - double dDepthInverseTrack; // st6 - double dScreenXTrack; // st5 - double dScreenYTrack; // st7 - int iScreenXTrackInt; // eax - double dTrackPoint2Y; // st6 - double dTrackPoint2Z; // st5 - double dTrackPoint2X; // st3 - double dTransformedTrack2X; // st7 - double dTransformedTrack2Y; // rtt - double dTransformedTrack2Z; // st5 - double dDepthTrack2Full; // st7 - double dViewDistanceTrack2; // st7 - double dDepthInverseTrack2; // st6 - double dScreenXTrack2; // st5 - double dScreenYTrack2; // st7 - int iScreenSize5; // ebp - int iScreenXCalc; // esi - int iTrackSegmentLoop; // ecx - tTrackScreenXYZ *pTrackScreenXYZ_1; // edi - int iZOrderIndex; // esi - int iNextSegmentIdx; // edx - tTrackScreenXYZ *pNextTrackScreenXYZ; // edx - float fMaxDepthCurrent; // eax - float fDepthForZOrderFinal; // eax - float fDepthForZOrder; // eax - signed int iRenderLoopIndex; // ebp - int iColorGradient; // ecx - int iCurrentSegmentIdx; // ebx +// 00059220 +void show_3dmap(float fZ, int iElevation, int iYaw) { + int iChunkIdx; // edx + double dBoundingBoxExpansionX; // st7 + double dBoundingBoxExpansionY; // st7 + double dZRange; // st7 + double dCenterDivisor; // st7 + double dTempTransform; // st7 + double dTempTransform2; // st7 + double dCorner1Y; // st5 + double dCorner1Z; // st4 + double dCorner1X; // st2 + double dTransformedX1; // st6 + double dTransformedY1; // rt2 + double dTransformedZ1; // st5 + double dDepth1; // st7 + double dViewDistance; // st7 + double dDepthInverse1; // st6 + double dScreenX1; // st5 + double dScreenY1; // st7 + double dCorner2Y; // st6 + double dCorner2Z; // st5 + double dCorner2X; // st3 + double dTransformedX2; // st7 + double dTransformedY2; // rtt + double dTransformedZ2; // st5 + double dProjX2; // st4 + int iScreenSize; // edi + double dProjZ2; // st3 + float fProjX1Int; // eax + double dProjY2Full; // st4 + float fProjY2; // eax + double dDepth2Full; // st7 + double dViewDistance2Full; // st7 + double dDepthInverse2; // st6 + double dScreenX2; // st5 + double dScreenY2; // st7 + double dCorner3Y; // st6 + double dCorner3Z; // st5 + double dCorner3X; // st3 + double dTransformedX3; // st7 + double fTransformedY3; // rt1 + double dTransformedZ3; // st5 + double dProjX3; // st4 + int iScreenSize2; // edi + double dProjZ3Full; // st3 + float fProjX2Temp; // eax + double dProjY3; // st4 + float fProjY2Temp; // eax + double dDepth3; // st7 + double dViewDistance3; // st7 + double dDepthInverse3; // st6 + double dScreenX3; // st5 + double dScreenY3Full; // st7 + double dCorner4Y; // st6 + double dCorner4Z; // st5 + double dCorner4X; // st3 + double dTransformedX4; // st7 + double dTransformedY4; // rtt + double dTransformedZ4; // st5 + double dProjX4; // st4 + int iScreenSize3; // edi + double dProjZ4; // st3 + float fProjX3; // eax + double dProjY4; // st4 + float fProjY3Full; // eax + double dDepth4Full; // st7 + double dViewDistance4; // st7 + double dDepthInverse4; // st6 + double dScreenX4; // st5 + double dScreenY4; // st7 + int iScreenSize4; // edi + int iProjX4Int; // eax + int iScreenXFinal; // eax + int iLoopIndex; // ecx + tTrackScreenXYZ *pTrackScreenXYZ; // ebx + tVec3 *pTrackPt; // edi + tGroundPt *pCurrentGroundPt; // eax + double dTrackPointY; // st6 + double dTrackPointZ; // st5 + double dTrackPointX; // st3 + double dTransformedTrackX; // st7 + double dTransformedTrackY; // rt1 + double dTransformedTrackZ; // st5 + double dViewDistanceTrackFull; // st7 + double dViewDistanceTrack; // st7 + double dDepthInverseTrack; // st6 + double dScreenXTrack; // st5 + double dScreenYTrack; // st7 + int iScreenXTrackInt; // eax + double dTrackPoint2Y; // st6 + double dTrackPoint2Z; // st5 + double dTrackPoint2X; // st3 + double dTransformedTrack2X; // st7 + double dTransformedTrack2Y; // rtt + double dTransformedTrack2Z; // st5 + double dDepthTrack2Full; // st7 + double dViewDistanceTrack2; // st7 + double dDepthInverseTrack2; // st6 + double dScreenXTrack2; // st5 + double dScreenYTrack2; // st7 + int iScreenSize5; // ebp + int iScreenXCalc; // esi + int iTrackSegmentLoop; // ecx + tTrackScreenXYZ *pTrackScreenXYZ_1; // edi + int iZOrderIndex; // esi + int iNextSegmentIdx; // edx + tTrackScreenXYZ *pNextTrackScreenXYZ; // edx + float fMaxDepthCurrent; // eax + float fDepthForZOrderFinal; // eax + float fDepthForZOrder; // eax + signed int iRenderLoopIndex; // ebp + int iColorGradient; // ecx + int iCurrentSegmentIdx; // ebx tTrackScreenXYZ *pCurrentSegmentScreenXYZ; // esi - double dHeightColorCalc; // st7 - tTrackScreenXYZ *pNextTrackScreenXYZ_1; // edi - //int iSurfaceColor_1; // eax - tPoint pointTemp; // kr00_8 - float fBaseY; // [esp+34h] [ebp-B0h] - float fBaseX; // [esp+38h] [ebp-ACh] - float fTransformTemp; // [esp+3Ch] [ebp-A8h] - float fDepthTemp1; // [esp+40h] [ebp-A4h] - float fDepthTemp2; // [esp+40h] [ebp-A4h] - float fDepth1; // [esp+40h] [ebp-A4h] - float fDepth2; // [esp+40h] [ebp-A4h] - float fProjectedX1; // [esp+44h] [ebp-A0h] - float fProjectedX2; // [esp+44h] [ebp-A0h] - float fProjectedX3; // [esp+44h] [ebp-A0h] - float fProjectedX4; // [esp+44h] [ebp-A0h] - float fProjectedY1; // [esp+48h] [ebp-9Ch] - float fProjectedY2; // [esp+48h] [ebp-9Ch] - float fProjectedY3; // [esp+48h] [ebp-9Ch] - float fProjectedY4; // [esp+48h] [ebp-9Ch] - float fProjectedZ1; // [esp+4Ch] [ebp-98h] - float fProjectedZ2; // [esp+4Ch] [ebp-98h] - float fProjectedZ3; // [esp+4Ch] [ebp-98h] - float fProjectedZ4; // [esp+4Ch] [ebp-98h] - float fZRangeForColor; // [esp+50h] [ebp-94h] - float fTransform33; // [esp+58h] [ebp-8Ch] - float fTransform21; // [esp+5Ch] [ebp-88h] - float fTransform31; // [esp+60h] [ebp-84h] - float fTransform32; // [esp+64h] [ebp-80h] - float fTransform23; // [esp+68h] [ebp-7Ch] - float fTransform22; // [esp+6Ch] [ebp-78h] - float fTransform12; // [esp+70h] [ebp-74h] - float fTransform11; // [esp+74h] [ebp-70h] - float fTransform13; // [esp+78h] [ebp-6Ch] - float fMaxDepthForZOrder; // [esp+8Ch] [ebp-58h] + double dHeightColorCalc; // st7 + tTrackScreenXYZ *pNextTrackScreenXYZ_1; // edi + // int iSurfaceColor_1; // eax + tPoint pointTemp; // kr00_8 + float fBaseY; // [esp+34h] [ebp-B0h] + float fBaseX; // [esp+38h] [ebp-ACh] + float fTransformTemp; // [esp+3Ch] [ebp-A8h] + float fDepthTemp1; // [esp+40h] [ebp-A4h] + float fDepthTemp2; // [esp+40h] [ebp-A4h] + float fDepth1; // [esp+40h] [ebp-A4h] + float fDepth2; // [esp+40h] [ebp-A4h] + float fProjectedX1; // [esp+44h] [ebp-A0h] + float fProjectedX2; // [esp+44h] [ebp-A0h] + float fProjectedX3; // [esp+44h] [ebp-A0h] + float fProjectedX4; // [esp+44h] [ebp-A0h] + float fProjectedY1; // [esp+48h] [ebp-9Ch] + float fProjectedY2; // [esp+48h] [ebp-9Ch] + float fProjectedY3; // [esp+48h] [ebp-9Ch] + float fProjectedY4; // [esp+48h] [ebp-9Ch] + float fProjectedZ1; // [esp+4Ch] [ebp-98h] + float fProjectedZ2; // [esp+4Ch] [ebp-98h] + float fProjectedZ3; // [esp+4Ch] [ebp-98h] + float fProjectedZ4; // [esp+4Ch] [ebp-98h] + float fZRangeForColor; // [esp+50h] [ebp-94h] + float fTransform33; // [esp+58h] [ebp-8Ch] + float fTransform21; // [esp+5Ch] [ebp-88h] + float fTransform31; // [esp+60h] [ebp-84h] + float fTransform32; // [esp+64h] [ebp-80h] + float fTransform23; // [esp+68h] [ebp-7Ch] + float fTransform22; // [esp+6Ch] [ebp-78h] + float fTransform12; // [esp+70h] [ebp-74h] + float fTransform11; // [esp+74h] [ebp-70h] + float fTransform13; // [esp+78h] [ebp-6Ch] + float fMaxDepthForZOrder; // [esp+8Ch] [ebp-58h] signed int iTrackSegmentCount; // [esp+90h] [ebp-54h] - float fTrackDepth1; // [esp+94h] [ebp-50h] - float fTrackDepth2; // [esp+94h] [ebp-50h] - float fMinY; // [esp+98h] [ebp-4Ch] - float fBoundingMinY; // [esp+98h] [ebp-4Ch] - float fMinX; // [esp+9Ch] [ebp-48h] - float fBoundingMinX; // [esp+9Ch] [ebp-48h] - float fY; // [esp+A0h] [ebp-44h] - float fBoundingMaxY; // [esp+A0h] [ebp-44h] - float fX; // [esp+A4h] [ebp-40h] - float fBoundingMaxX; // [esp+A4h] [ebp-40h] - float fAccumulatedX; // [esp+A8h] [ebp-3Ch] - float fTrackCenterX; // [esp+A8h] [ebp-3Ch] - float fAccumulatedY; // [esp+ACh] [ebp-38h] - float fTrackCenterY; // [esp+ACh] [ebp-38h] - float fAccumulatedZ; // [esp+B0h] [ebp-34h] - float fTrackCenterZ; // [esp+B0h] [ebp-34h] - float fMinZ; // [esp+B4h] [ebp-30h] - float fBoundingMinZ; // [esp+B4h] [ebp-30h] - float fBoundingMaxZ; // [esp+B8h] [ebp-2Ch] - float fTrackProjY1; // [esp+BCh] [ebp-28h] - float fTrackProjY2; // [esp+BCh] [ebp-28h] - float fTrackProjX1; // [esp+C0h] [ebp-24h] - float fTrackProjX2; // [esp+C0h] [ebp-24h] - float fTrackProjZ1; // [esp+C4h] [ebp-20h] - float fTrackProjZ2; // [esp+C4h] [ebp-20h] - int iNextSegmentIdx_1; // [esp+C8h] [ebp-1Ch] - int iSurfaceColor; // [esp+C8h] [ebp-1Ch] + float fTrackDepth1; // [esp+94h] [ebp-50h] + float fTrackDepth2; // [esp+94h] [ebp-50h] + float fMinY; // [esp+98h] [ebp-4Ch] + float fBoundingMinY; // [esp+98h] [ebp-4Ch] + float fMinX; // [esp+9Ch] [ebp-48h] + float fBoundingMinX; // [esp+9Ch] [ebp-48h] + float fY; // [esp+A0h] [ebp-44h] + float fBoundingMaxY; // [esp+A0h] [ebp-44h] + float fX; // [esp+A4h] [ebp-40h] + float fBoundingMaxX; // [esp+A4h] [ebp-40h] + float fAccumulatedX; // [esp+A8h] [ebp-3Ch] + float fTrackCenterX; // [esp+A8h] [ebp-3Ch] + float fAccumulatedY; // [esp+ACh] [ebp-38h] + float fTrackCenterY; // [esp+ACh] [ebp-38h] + float fAccumulatedZ; // [esp+B0h] [ebp-34h] + float fTrackCenterZ; // [esp+B0h] [ebp-34h] + float fMinZ; // [esp+B4h] [ebp-30h] + float fBoundingMinZ; // [esp+B4h] [ebp-30h] + float fBoundingMaxZ; // [esp+B8h] [ebp-2Ch] + float fTrackProjY1; // [esp+BCh] [ebp-28h] + float fTrackProjY2; // [esp+BCh] [ebp-28h] + float fTrackProjX1; // [esp+C0h] [ebp-24h] + float fTrackProjX2; // [esp+C0h] [ebp-24h] + float fTrackProjZ1; // [esp+C4h] [ebp-20h] + float fTrackProjZ2; // [esp+C4h] [ebp-20h] + int iNextSegmentIdx_1; // [esp+C8h] [ebp-1Ch] + int iSurfaceColor; // [esp+C8h] [ebp-1Ch] // Initialize base screen coordinates fBaseX = (float)xbase; @@ -1828,7 +1893,8 @@ void show_3dmap(float fZ, int iElevation, int iYaw) velevation = -iElevation & 0x3FFF; fAccumulatedX = 0.0; xbase += 40; - calculatetransform(-1, 0, -iElevation & 0x3FFF, 0, worldx, 0.0, worldz, 0.0, 0.0, 0.0); + calculatetransform(-1, 0, -iElevation & 0x3FFF, 0, worldx, 0.0, worldz, 0.0, + 0.0, 0.0); fAccumulatedY = 0.0; worlddirn = vdirection; fAccumulatedZ = 0.0; @@ -1839,9 +1905,12 @@ void show_3dmap(float fZ, int iElevation, int iYaw) iChunkIdx = 0; do { // Accumulate track point coordinates for center calculation - fAccumulatedX = TrakPt[iChunkIdx].pointAy[0].fX + TrakPt[iChunkIdx].pointAy[4].fX + fAccumulatedX; - fAccumulatedY = TrakPt[iChunkIdx].pointAy[0].fY + TrakPt[iChunkIdx].pointAy[4].fY + fAccumulatedY; - fAccumulatedZ = TrakPt[iChunkIdx].pointAy[0].fZ + TrakPt[iChunkIdx].pointAy[4].fZ + fAccumulatedZ; + fAccumulatedX = TrakPt[iChunkIdx].pointAy[0].fX + + TrakPt[iChunkIdx].pointAy[4].fX + fAccumulatedX; + fAccumulatedY = TrakPt[iChunkIdx].pointAy[0].fY + + TrakPt[iChunkIdx].pointAy[4].fY + fAccumulatedY; + fAccumulatedZ = TrakPt[iChunkIdx].pointAy[0].fZ + + TrakPt[iChunkIdx].pointAy[4].fZ + fAccumulatedZ; // Update minimum bounding box coordinates if (TrakPt[iChunkIdx].pointAy[0].fX < (double)fMinX) fMinX = TrakPt[iChunkIdx].pointAy[0].fX; @@ -1907,12 +1976,18 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dCorner1Y = fBoundingMinY + fTrackCenterY; dCorner1Z = fBoundingMinZ + fTrackCenterZ; dCorner1X = fBoundingMinX + fTrackCenterX; - dTransformedX1 = dCorner1X * fTransform11 + dCorner1Y * fTransform21 + dCorner1Z * fTransform32 - viewx; - dTransformedY1 = dCorner1X * fTransform12 + dCorner1Y * fTransform22 + dCorner1Z * fTransform23 - viewy; - dTransformedZ1 = tsin[0] * dCorner1X + dCorner1Y * fTransform31 + dCorner1Z * fTransform33 - viewz; - fProjectedX1 = (float)dTransformedX1 * vk1 + (float)dTransformedY1 * vk4 + (float)dTransformedZ1 * vk7; - fProjectedY1 = (float)dTransformedX1 * vk2 + (float)dTransformedY1 * vk5 + (float)dTransformedZ1 * vk8; - dDepth1 = (float)dTransformedX1 * vk3 + (float)dTransformedY1 * vk6 + (float)dTransformedZ1 * vk9; + dTransformedX1 = dCorner1X * fTransform11 + dCorner1Y * fTransform21 + + dCorner1Z * fTransform32 - viewx; + dTransformedY1 = dCorner1X * fTransform12 + dCorner1Y * fTransform22 + + dCorner1Z * fTransform23 - viewy; + dTransformedZ1 = tsin[0] * dCorner1X + dCorner1Y * fTransform31 + + dCorner1Z * fTransform33 - viewz; + fProjectedX1 = (float)dTransformedX1 * vk1 + (float)dTransformedY1 * vk4 + + (float)dTransformedZ1 * vk7; + fProjectedY1 = (float)dTransformedX1 * vk2 + (float)dTransformedY1 * vk5 + + (float)dTransformedZ1 * vk8; + dDepth1 = (float)dTransformedX1 * vk3 + (float)dTransformedY1 * vk6 + + (float)dTransformedZ1 * vk9; fProjectedZ1 = (float)dDepth1; fDepthTemp1 = fProjectedZ1; if (dDepth1 < 80.0) { @@ -1932,9 +2007,12 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dCorner2Y = fBoundingMinY + fTrackCenterY; dCorner2Z = fBoundingMinZ + fTrackCenterZ; dCorner2X = fBoundingMaxX + fTrackCenterX; - dTransformedX2 = dCorner2X * fTransform11 + dCorner2Y * fTransform21 + dCorner2Z * fTransform32 - viewx; - dTransformedY2 = dCorner2X * fTransform12 + dCorner2Y * fTransform22 + dCorner2Z * fTransform23 - viewy; - dTransformedZ2 = dCorner2X * fTransform13 + dCorner2Y * fTransform31 + dCorner2Z * fTransform33 - viewz; + dTransformedX2 = dCorner2X * fTransform11 + dCorner2Y * fTransform21 + + dCorner2Z * fTransform32 - viewx; + dTransformedY2 = dCorner2X * fTransform12 + dCorner2Y * fTransform22 + + dCorner2Z * fTransform23 - viewy; + dTransformedZ2 = dCorner2X * fTransform13 + dCorner2Y * fTransform31 + + dCorner2Z * fTransform33 - viewz; dProjX2 = dTransformedX2 * vk1 + dTransformedY2 * vk4; iScreenSize = scr_size; dProjZ2 = dTransformedZ2 * vk7; @@ -1942,11 +2020,13 @@ void show_3dmap(float fZ, int iElevation, int iYaw) TrackScreenXYZ[0].screenPtAy[0].screen.y = (iScreenSize * (199 - yp)) >> 6; fProjX1Int = fProjectedX1; fProjectedX2 = (float)(dProjX2 + dProjZ2); - dProjY2Full = dTransformedX2 * vk2 + dTransformedY2 * vk5 + dTransformedZ2 * vk8; + dProjY2Full = + dTransformedX2 * vk2 + dTransformedY2 * vk5 + dTransformedZ2 * vk8; TrackScreenXYZ[0].screenPtAy[0].projected.fX = fProjX1Int; fProjY2 = fProjectedY1; fProjectedY2 = (float)dProjY2Full; - dDepth2Full = dTransformedX2 * vk3 + dTransformedY2 * vk6 + dTransformedZ2 * vk9; + dDepth2Full = + dTransformedX2 * vk3 + dTransformedY2 * vk6 + dTransformedZ2 * vk9; fProjectedZ2 = (float)dDepth2Full; TrackScreenXYZ[0].screenPtAy[0].projected.fY = fProjY2; TrackScreenXYZ[0].screenPtAy[0].projected.fZ = fDepthTemp1; @@ -1957,10 +2037,12 @@ void show_3dmap(float fZ, int iElevation, int iYaw) } dViewDistance2Full = (double)VIEWDIST; dDepthInverse2 = 1.0 / fProjectedZ2; - dScreenX2 = dViewDistance2Full * fProjectedX2 * dDepthInverse2 + (double)xbase; + dScreenX2 = + dViewDistance2Full * fProjectedX2 * dDepthInverse2 + (double)xbase; //_CHP(); xp = (int)dScreenX2; - dScreenY2 = dDepthInverse2 * (dViewDistance2Full * fProjectedY2) + (double)ybase; + dScreenY2 = + dDepthInverse2 * (dViewDistance2Full * fProjectedY2) + (double)ybase; //_CHP(); yp = (int)dScreenY2; @@ -1968,9 +2050,12 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dCorner3Y = fBoundingMaxY + fTrackCenterY; dCorner3Z = fBoundingMinZ + fTrackCenterZ; dCorner3X = fBoundingMaxX + fTrackCenterX; - dTransformedX3 = dCorner3X * fTransform11 + dCorner3Y * fTransform21 + dCorner3Z * fTransform32 - viewx; - fTransformedY3 = dCorner3X * fTransform12 + dCorner3Y * fTransform22 + dCorner3Z * fTransform23 - viewy; - dTransformedZ3 = dCorner3X * fTransform13 + dCorner3Y * fTransform31 + dCorner3Z * fTransform33 - viewz; + dTransformedX3 = dCorner3X * fTransform11 + dCorner3Y * fTransform21 + + dCorner3Z * fTransform32 - viewx; + fTransformedY3 = dCorner3X * fTransform12 + dCorner3Y * fTransform22 + + dCorner3Z * fTransform23 - viewy; + dTransformedZ3 = dCorner3X * fTransform13 + dCorner3Y * fTransform31 + + dCorner3Z * fTransform33 - viewz; dProjX3 = dTransformedX3 * vk1 + fTransformedY3 * vk4; iScreenSize2 = scr_size; dProjZ3Full = dTransformedZ3 * vk7; @@ -1996,7 +2081,8 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dScreenX3 = dViewDistance3 * fProjectedX3 * dDepthInverse3 + (double)xbase; //_CHP(); xp = (int)dScreenX3; - dScreenY3Full = dDepthInverse3 * (dViewDistance3 * fProjectedY3) + (double)ybase; + dScreenY3Full = + dDepthInverse3 * (dViewDistance3 * fProjectedY3) + (double)ybase; //_CHP(); yp = (int)dScreenY3Full; @@ -2004,9 +2090,12 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dCorner4Y = fBoundingMaxY + fTrackCenterY; dCorner4Z = fBoundingMinZ + fTrackCenterZ; dCorner4X = fBoundingMinX + fTrackCenterX; - dTransformedX4 = dCorner4X * fTransform11 + dCorner4Y * fTransform21 + dCorner4Z * fTransform32 - viewx; - dTransformedY4 = dCorner4X * fTransform12 + dCorner4Y * fTransform22 + dCorner4Z * fTransform23 - viewy; - dTransformedZ4 = dCorner4X * fTransform13 + dCorner4Y * fTransform31 + dCorner4Z * fTransform33 - viewz; + dTransformedX4 = dCorner4X * fTransform11 + dCorner4Y * fTransform21 + + dCorner4Z * fTransform32 - viewx; + dTransformedY4 = dCorner4X * fTransform12 + dCorner4Y * fTransform22 + + dCorner4Z * fTransform23 - viewy; + dTransformedZ4 = dCorner4X * fTransform13 + dCorner4Y * fTransform31 + + dCorner4Z * fTransform33 - viewz; dProjX4 = dTransformedX4 * vk1 + dTransformedY4 * vk4; iScreenSize3 = scr_size; dProjZ4 = dTransformedZ4 * vk7; @@ -2018,7 +2107,8 @@ void show_3dmap(float fZ, int iElevation, int iYaw) TrackScreenXYZ[0].screenPtAy[2].projected.fX = fProjX3; fProjY3Full = fProjectedY3; fProjectedY4 = (float)dProjY4; - dDepth4Full = dTransformedX4 * vk3 + dTransformedY4 * vk6 + dTransformedZ4 * vk9; + dDepth4Full = + dTransformedX4 * vk3 + dTransformedY4 * vk6 + dTransformedZ4 * vk9; fProjectedZ4 = (float)dDepth4Full; TrackScreenXYZ[0].screenPtAy[2].projected.fY = fProjY3Full; TrackScreenXYZ[0].screenPtAy[2].projected.fZ = fDepth1; @@ -2031,7 +2121,7 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dDepthInverse4 = 1.0 / fProjectedZ4; dScreenX4 = dViewDistance4 * fProjectedX4 * dDepthInverse4 + (double)xbase; //_CHP(); - iProjX4Int = scr_size * (int)dScreenX4; //lost line, decompiler artifact + iProjX4Int = scr_size * (int)dScreenX4; // lost line, decompiler artifact xp = (int)dScreenX4; dScreenY4 = dDepthInverse4 * (dViewDistance4 * fProjectedY4) + (double)ybase; iScreenSize4 = scr_size; @@ -2049,7 +2139,8 @@ void show_3dmap(float fZ, int iElevation, int iYaw) RoadPoly.uiNumVerts = 4; RoadPoly.vertices[3].x = iScreenXFinal; RoadPoly.vertices[3].y = TrackScreenXYZ[0].screenPtAy[3].screen.y; - RoadPoly.iSurfaceType = SURFACE_FLAG_TRANSPARENT | SURFACE_FLAG_FLIP_BACKFACE | 0x2; + RoadPoly.iSurfaceType = + SURFACE_FLAG_TRANSPARENT | SURFACE_FLAG_FLIP_BACKFACE | 0x2; // Render background polygon for track area POLYFLAT(scrbuf, &RoadPoly); @@ -2067,12 +2158,24 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dTrackPointZ = pCurrentGroundPt->pointAy[0].fZ + fTrackCenterZ; dTrackPointX = pCurrentGroundPt->pointAy[0].fX + fTrackCenterX; // Apply 3D transformation matrix to track point - dTransformedTrackX = dTrackPointX * fTransform11 + dTrackPointY * fTransform21 + dTrackPointZ * fTransform32 - viewx; - dTransformedTrackY = dTrackPointX * fTransform12 + dTrackPointY * fTransform22 + dTrackPointZ * fTransform23 - viewy; - dTransformedTrackZ = dTrackPointX * fTransform13 + dTrackPointY * fTransform31 + dTrackPointZ * fTransform33 - viewz; - fTrackProjX1 = (float)dTransformedTrackX * vk1 + (float)dTransformedTrackY * vk4 + (float)dTransformedTrackZ * vk7; - fTrackProjY1 = (float)dTransformedTrackX * vk2 + (float)dTransformedTrackY * vk5 + (float)dTransformedTrackZ * vk8; - dViewDistanceTrackFull = (float)dTransformedTrackX * vk3 + (float)dTransformedTrackY * vk6 + (float)dTransformedTrackZ * vk9; + dTransformedTrackX = dTrackPointX * fTransform11 + + dTrackPointY * fTransform21 + + dTrackPointZ * fTransform32 - viewx; + dTransformedTrackY = dTrackPointX * fTransform12 + + dTrackPointY * fTransform22 + + dTrackPointZ * fTransform23 - viewy; + dTransformedTrackZ = dTrackPointX * fTransform13 + + dTrackPointY * fTransform31 + + dTrackPointZ * fTransform33 - viewz; + fTrackProjX1 = (float)dTransformedTrackX * vk1 + + (float)dTransformedTrackY * vk4 + + (float)dTransformedTrackZ * vk7; + fTrackProjY1 = (float)dTransformedTrackX * vk2 + + (float)dTransformedTrackY * vk5 + + (float)dTransformedTrackZ * vk8; + dViewDistanceTrackFull = (float)dTransformedTrackX * vk3 + + (float)dTransformedTrackY * vk6 + + (float)dTransformedTrackZ * vk9; fTrackProjZ1 = (float)dViewDistanceTrackFull; fTrackDepth1 = fTrackProjZ1; if (dViewDistanceTrackFull < 80.0) { @@ -2082,11 +2185,14 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dViewDistanceTrack = (double)VIEWDIST; // Project 3D coordinates to 2D screen coordinates dDepthInverseTrack = 1.0 / fTrackProjZ1; - dScreenXTrack = dViewDistanceTrack * fTrackProjX1 * dDepthInverseTrack + (double)xbase; + dScreenXTrack = dViewDistanceTrack * fTrackProjX1 * dDepthInverseTrack + + (double)xbase; //_CHP(); - iScreenXTrackInt = scr_size * (int)dScreenXTrack; //lost line, decompiler artifact + iScreenXTrackInt = + scr_size * (int)dScreenXTrack; // lost line, decompiler artifact xp = (int)dScreenXTrack; - dScreenYTrack = dDepthInverseTrack * (dViewDistanceTrack * fTrackProjY1) + (double)ybase; + dScreenYTrack = dDepthInverseTrack * (dViewDistanceTrack * fTrackProjY1) + + (double)ybase; //_CHP(); yp = (int)dScreenYTrack; pTrackScreenXYZ->screenPtAy[1].screen.x = iScreenXTrackInt >> 6; @@ -2099,12 +2205,24 @@ void show_3dmap(float fZ, int iElevation, int iYaw) dTrackPoint2Y = pTrackPt->fY + fTrackCenterY; dTrackPoint2Z = pTrackPt->fZ + fTrackCenterZ; dTrackPoint2X = pTrackPt->fX + fTrackCenterX; - dTransformedTrack2X = dTrackPoint2X * fTransform11 + dTrackPoint2Y * fTransform21 + dTrackPoint2Z * fTransform32 - viewx; - dTransformedTrack2Y = dTrackPoint2X * fTransform12 + dTrackPoint2Y * fTransform22 + dTrackPoint2Z * fTransform23 - viewy; - dTransformedTrack2Z = dTrackPoint2X * fTransform13 + dTrackPoint2Y * fTransform31 + dTrackPoint2Z * fTransform33 - viewz; - fTrackProjX2 = (float)dTransformedTrack2X * vk1 + (float)dTransformedTrack2Y * vk4 + (float)dTransformedTrack2Z * vk7; - fTrackProjY2 = (float)dTransformedTrack2X * vk2 + (float)dTransformedTrack2Y * vk5 + (float)dTransformedTrack2Z * vk8; - dDepthTrack2Full = (float)dTransformedTrack2X * vk3 + (float)dTransformedTrack2Y * vk6 + (float)dTransformedTrack2Z * vk9; + dTransformedTrack2X = dTrackPoint2X * fTransform11 + + dTrackPoint2Y * fTransform21 + + dTrackPoint2Z * fTransform32 - viewx; + dTransformedTrack2Y = dTrackPoint2X * fTransform12 + + dTrackPoint2Y * fTransform22 + + dTrackPoint2Z * fTransform23 - viewy; + dTransformedTrack2Z = dTrackPoint2X * fTransform13 + + dTrackPoint2Y * fTransform31 + + dTrackPoint2Z * fTransform33 - viewz; + fTrackProjX2 = (float)dTransformedTrack2X * vk1 + + (float)dTransformedTrack2Y * vk4 + + (float)dTransformedTrack2Z * vk7; + fTrackProjY2 = (float)dTransformedTrack2X * vk2 + + (float)dTransformedTrack2Y * vk5 + + (float)dTransformedTrack2Z * vk8; + dDepthTrack2Full = (float)dTransformedTrack2X * vk3 + + (float)dTransformedTrack2Y * vk6 + + (float)dTransformedTrack2Z * vk9; fTrackProjZ2 = (float)dDepthTrack2Full; fTrackDepth2 = fTrackProjZ2; if (dDepthTrack2Full < 80.0) { @@ -2113,16 +2231,21 @@ void show_3dmap(float fZ, int iElevation, int iYaw) } dViewDistanceTrack2 = (double)VIEWDIST; dDepthInverseTrack2 = 1.0 / fTrackProjZ2; - dScreenXTrack2 = dViewDistanceTrack2 * fTrackProjX2 * dDepthInverseTrack2 + (double)xbase; + dScreenXTrack2 = + dViewDistanceTrack2 * fTrackProjX2 * dDepthInverseTrack2 + + (double)xbase; //_CHP(); xp = (int)dScreenXTrack2; - dScreenYTrack2 = dDepthInverseTrack2 * (dViewDistanceTrack2 * fTrackProjY2) + (double)ybase; + dScreenYTrack2 = + dDepthInverseTrack2 * (dViewDistanceTrack2 * fTrackProjY2) + + (double)ybase; iScreenSize5 = scr_size; iScreenXCalc = scr_size * (int)dScreenXTrack2; //_CHP(); yp = (int)dScreenYTrack2; pTrackScreenXYZ->screenPtAy[0].screen.x = iScreenXCalc >> 6; - pTrackScreenXYZ->screenPtAy[0].screen.y = (iScreenSize5 * (199 - yp)) >> 6; + pTrackScreenXYZ->screenPtAy[0].screen.y = + (iScreenSize5 * (199 - yp)) >> 6; pTrackScreenXYZ->screenPtAy[0].projected.fX = fTrackProjX2; pTrackPt += 12; pTrackScreenXYZ->screenPtAy[0].projected.fY = fTrackProjY2; @@ -2145,21 +2268,25 @@ void show_3dmap(float fZ, int iElevation, int iYaw) iNextSegmentIdx = 0; CarZOrder[iZOrderIndex].iPolygonIndex = iTrackSegmentLoop; pNextTrackScreenXYZ = &TrackScreenXYZ[iNextSegmentIdx]; - if (pTrackScreenXYZ_1->screenPtAy[1].projected.fZ <= (double)pTrackScreenXYZ_1->screenPtAy[0].projected.fZ) + if (pTrackScreenXYZ_1->screenPtAy[1].projected.fZ <= + (double)pTrackScreenXYZ_1->screenPtAy[0].projected.fZ) fMaxDepthCurrent = pTrackScreenXYZ_1->screenPtAy[0].projected.fZ; else fMaxDepthCurrent = pTrackScreenXYZ_1->screenPtAy[1].projected.fZ; fMaxDepthForZOrder = fMaxDepthCurrent; - if (pNextTrackScreenXYZ->screenPtAy[1].projected.fZ <= (double)pNextTrackScreenXYZ->screenPtAy[0].projected.fZ) + if (pNextTrackScreenXYZ->screenPtAy[1].projected.fZ <= + (double)pNextTrackScreenXYZ->screenPtAy[0].projected.fZ) fDepthForZOrderFinal = pNextTrackScreenXYZ->screenPtAy[0].projected.fZ; else fDepthForZOrderFinal = pNextTrackScreenXYZ->screenPtAy[1].projected.fZ; if (fMaxDepthForZOrder <= (double)fDepthForZOrderFinal) { - if (pNextTrackScreenXYZ->screenPtAy[1].projected.fZ <= (double)pNextTrackScreenXYZ->screenPtAy[0].projected.fZ) + if (pNextTrackScreenXYZ->screenPtAy[1].projected.fZ <= + (double)pNextTrackScreenXYZ->screenPtAy[0].projected.fZ) fDepthForZOrder = pNextTrackScreenXYZ->screenPtAy[0].projected.fZ; else fDepthForZOrder = pNextTrackScreenXYZ->screenPtAy[1].projected.fZ; - } else if (pTrackScreenXYZ_1->screenPtAy[1].projected.fZ <= (double)pTrackScreenXYZ_1->screenPtAy[0].projected.fZ) { + } else if (pTrackScreenXYZ_1->screenPtAy[1].projected.fZ <= + (double)pTrackScreenXYZ_1->screenPtAy[0].projected.fZ) { fDepthForZOrder = pTrackScreenXYZ_1->screenPtAy[0].projected.fZ; } else { fDepthForZOrder = pTrackScreenXYZ_1->screenPtAy[1].projected.fZ; @@ -2170,7 +2297,8 @@ void show_3dmap(float fZ, int iElevation, int iYaw) ++iZOrderIndex; pTrackScreenXYZ_1 += 2; iTrackSegmentLoop += 2; - //*(float *)((char *)&CarPt[127].view.fZ + iZOrderIndex * 12) = fDepthForZOrder;// offset into CarZOrder if placed above loop inc + //*(float *)((char *)&CarPt[127].view.fZ + iZOrderIndex * 12) = + // fDepthForZOrder;// offset into CarZOrder if placed above loop inc ++iTrackSegmentCount; } while (iTrackSegmentLoop < TRAK_LEN); } @@ -2184,17 +2312,23 @@ void show_3dmap(float fZ, int iElevation, int iYaw) iColorGradient = 15 * iTrackSegmentCount; do { iCurrentSegmentIdx = CarZOrder[iRenderLoopIndex].iPolygonIndex; - if (iCurrentSegmentIdx >= 0 - && ((TrakColour[iCurrentSegmentIdx][TRAK_COLOUR_LEFT_LANE] & SURFACE_FLAG_SKIP_RENDER) == 0 - || (TrakColour[iCurrentSegmentIdx][TRAK_COLOUR_CENTER] & SURFACE_FLAG_SKIP_RENDER) == 0 - || (TrakColour[iCurrentSegmentIdx][TRAK_COLOUR_RIGHT_LANE] & SURFACE_FLAG_SKIP_RENDER) == 0)) { + if (iCurrentSegmentIdx >= 0 && + ((TrakColour[iCurrentSegmentIdx][TRAK_COLOUR_LEFT_LANE] & + SURFACE_FLAG_SKIP_RENDER) == 0 || + (TrakColour[iCurrentSegmentIdx][TRAK_COLOUR_CENTER] & + SURFACE_FLAG_SKIP_RENDER) == 0 || + (TrakColour[iCurrentSegmentIdx][TRAK_COLOUR_RIGHT_LANE] & + SURFACE_FLAG_SKIP_RENDER) == 0)) { iNextSegmentIdx_1 = iCurrentSegmentIdx + 2; pCurrentSegmentScreenXYZ = &TrackScreenXYZ[iCurrentSegmentIdx]; if (iCurrentSegmentIdx + 2 >= TRAK_LEN) iNextSegmentIdx_1 = 0; RoadPoly.uiNumVerts = 4; // Calculate color based on height (elevation mapping) - dHeightColorCalc = (fBoundingMaxZ - TrakPt[iCurrentSegmentIdx].pointAy[2].fZ) * 15.0 / fZRangeForColor + (double)(iColorGradient / iTrackSegmentCount); + dHeightColorCalc = + (fBoundingMaxZ - TrakPt[iCurrentSegmentIdx].pointAy[2].fZ) * 15.0 / + fZRangeForColor + + (double)(iColorGradient / iTrackSegmentCount); //_CHP(); pNextTrackScreenXYZ_1 = &TrackScreenXYZ[iNextSegmentIdx_1]; iSurfaceColor = 143 - (int)dHeightColorCalc; @@ -2202,11 +2336,12 @@ void show_3dmap(float fZ, int iElevation, int iYaw) iSurfaceColor = 139; if (!iCurrentSegmentIdx) iSurfaceColor = 143; - //iSurfaceColor = iSurfaceColor; - //BYTE1(uiSurfaceColor) = BYTE1(iSurfaceColor) | 0x60; + // iSurfaceColor = iSurfaceColor; + // BYTE1(uiSurfaceColor) = BYTE1(iSurfaceColor) | 0x60; // Render road segment with vert orders for both front and back faces - RoadPoly.iSurfaceType = iSurfaceColor | SURFACE_FLAG_CONCAVE | SURFACE_FLAG_FLIP_BACKFACE; + RoadPoly.iSurfaceType = + iSurfaceColor | SURFACE_FLAG_CONCAVE | SURFACE_FLAG_FLIP_BACKFACE; RoadPoly.vertices[0] = pNextTrackScreenXYZ_1->screenPtAy[0].screen; RoadPoly.vertices[1] = pNextTrackScreenXYZ_1->screenPtAy[1].screen; RoadPoly.vertices[2] = pCurrentSegmentScreenXYZ->screenPtAy[1].screen; @@ -2232,150 +2367,150 @@ void show_3dmap(float fZ, int iElevation, int iYaw) } //------------------------------------------------------------------------------------------------- -//0005A400 -void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAngle, char byAnimFrame) -{ - int iNumCoords; // ecx - int iYaw; // eax - double dCosYaw; // st7 - double dCosPitch; // st7 - double dCosRoll; // st7 - tVec3 *pCarBoxAy; // ebx - uint32 uiColorTo; // eax - unsigned int uiVertIdx; // edx - int iScrSize; // edi - double dDeltaX; // st7 - double dDeltaY; // st6 - double dDeltaZ; // st5 - double dViewZ; // st7 - double dViewDist; // st7 - double dInvZ; // st6 - double dScreenX; // st5 - double dScreenY; // st7 - double dCarCenterX; // st7 - double dCarCenterY; // st6 - double dCarCenterZ; // st5 - signed int iVisiblePols; // esi - tPolygon *pPols; // ebp - int i; // eax - double dEdge1X; // st7 - double dEdge2X; // st5 - double dEdge2Y; // st4 - double dEdge2Z; // st3 - tPolygon *pPol; // ecx - int j; // edx - int byVertIdx; // ebx - tVec3 *pVertData; // eax - double dVertX; // st7 - double dVertY; // st5 - int iVertIdx_1; // eax - double dVertZ; // st6 - double dDeltaX_1; // st7 - double dDeltaY_1; // st6 - double dDeltaZ_1; // st5 - double dViewX; // st7 - double dViewDist_1; // st7 - double dInvZ_1; // st6 - double dProjX; // st5 - double dProjY; // st7 - int iScreenX; // edi - int iVertIdx_2; // eax +// 0005A400 +void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, + int iAngle, char byAnimFrame) { + int iNumCoords; // ecx + int iYaw; // eax + double dCosYaw; // st7 + double dCosPitch; // st7 + double dCosRoll; // st7 + tVec3 *pCarBoxAy; // ebx + uint32 uiColorTo; // eax + unsigned int uiVertIdx; // edx + int iScrSize; // edi + double dDeltaX; // st7 + double dDeltaY; // st6 + double dDeltaZ; // st5 + double dViewZ; // st7 + double dViewDist; // st7 + double dInvZ; // st6 + double dScreenX; // st5 + double dScreenY; // st7 + double dCarCenterX; // st7 + double dCarCenterY; // st6 + double dCarCenterZ; // st5 + signed int iVisiblePols; // esi + tPolygon *pPols; // ebp + int i; // eax + double dEdge1X; // st7 + double dEdge2X; // st5 + double dEdge2Y; // st4 + double dEdge2Z; // st3 + tPolygon *pPol; // ecx + int j; // edx + int byVertIdx; // ebx + tVec3 *pVertData; // eax + double dVertX; // st7 + double dVertY; // st5 + int iVertIdx_1; // eax + double dVertZ; // st6 + double dDeltaX_1; // st7 + double dDeltaY_1; // st6 + double dDeltaZ_1; // st5 + double dViewX; // st7 + double dViewDist_1; // st7 + double dInvZ_1; // st6 + double dProjX; // st5 + double dProjY; // st7 + int iScreenX; // edi + int iVertIdx_2; // eax unsigned int uiZOrderOffset_3; // edx - int iPolIdx_1; // eax - float fMinZ34_1; // eax - float fMinZ12_1; // eax - float fMaxZ; // eax + int iPolIdx_1; // eax + float fMinZ34_1; // eax + float fMinZ12_1; // eax + float fMaxZ; // eax unsigned int uiZOrderOffset_2; // edx - float fMinZ34; // eax - float fMinZ12; // eax - tPolygon *pFirstPol; // eax - int32 iLinkedPolIdx; // edi - int iNextPolIdx; // ecx - int iCurPolIdx; // edi - int iSearchIdx; // ebx - signed int k; // eax - int32 iCheckPolIdx; // edx - int iDrawIdx; // edi - int32 iPolToDraw; // esi - tPolygon *pDrawPol; // edx - uint32 uiTex; // ecx - int m; // eax - double dViewZ_1; // st7 - tCarPt *pMinZVert34; // eax - tCarPt *pMinZVert12; // eax - tCarPt *pMinZVert12_1; // eax - float fMinViewZ; // eax - tCarPt *pMinZVert34_1; // eax - int iCartexOffset; // ecx - int iGfxSize; // [esp+0h] [ebp-19Ch] - tVec3 *vertDataAy[4]; // [esp+4h] [ebp-198h] - tCarPt *screenVertAy[4]; // [esp+14h] [ebp-188h] - double dLocalZ; // [esp+24h] [ebp-178h] - double dLocalY; // [esp+2Ch] [ebp-170h] - double dDotProduct; // [esp+34h] [ebp-168h] - double dLocalX; // [esp+44h] [ebp-158h] - double dBoxZ; // [esp+4Ch] [ebp-150h] - double dBoxY; // [esp+54h] [ebp-148h] - double dBoxX; // [esp+5Ch] [ebp-140h] - uint32 uiColorFrom; // [esp+64h] [ebp-138h] - int iNumPols; // [esp+68h] [ebp-134h] - float fRotMat01; // [esp+70h] [ebp-12Ch] - float fClippedZ; // [esp+74h] [ebp-128h] - float fNearClip; // [esp+78h] [ebp-124h] - float fViewY; // [esp+7Ch] [ebp-120h] - float fViewX; // [esp+80h] [ebp-11Ch] - float fCarPosZ; // [esp+90h] [ebp-10Ch] - float fCarPosX; // [esp+94h] [ebp-108h] - float fRotMat22; // [esp+98h] [ebp-104h] - float fRotMat21; // [esp+9Ch] [ebp-100h] - float fRotMat11; // [esp+A0h] [ebp-FCh] - float fMinZ34Temp; // [esp+B0h] [ebp-ECh] - float fMinZ12Temp; // [esp+B4h] [ebp-E8h] - float fMaxZTemp_1; // [esp+B8h] [ebp-E4h] - float fMaxZTemp; // [esp+BCh] [ebp-E0h] - float fMinZTemp; // [esp+C0h] [ebp-DCh] - float fMaxZ34; // [esp+C4h] [ebp-D8h] - float fMaxZ12; // [esp+C8h] [ebp-D4h] - float fFinalMaxZ; // [esp+CCh] [ebp-D0h] - float fFinalMaxZ_1; // [esp+D0h] [ebp-CCh] - float fFinalMinZ; // [esp+D4h] [ebp-C8h] - tPolygon *pPolAy; // [esp+D8h] [ebp-C4h] - uint32 uiDesignOffset; // [esp+DCh] [ebp-C0h] - tPolygon *pLinkedPol; // [esp+E0h] [ebp-BCh] - float fMinZ; // [esp+E4h] [ebp-B8h] - float fMinZ_1; // [esp+E8h] [ebp-B4h] - float fMinZTemp_1; // [esp+ECh] [ebp-B0h] - float fMinZ12_2; // [esp+F0h] [ebp-ACh] - float fMinZ34_2; // [esp+F4h] [ebp-A8h] - int iSubPolType; // [esp+F8h] [ebp-A4h] - uint32 uiCarDesignIdxTimes4; // [esp+FCh] [ebp-A0h] - unsigned int uiZOrderOffset; // [esp+104h] [ebp-98h] + float fMinZ34; // eax + float fMinZ12; // eax + tPolygon *pFirstPol; // eax + int32 iLinkedPolIdx; // edi + int iNextPolIdx; // ecx + int iCurPolIdx; // edi + int iSearchIdx; // ebx + signed int k; // eax + int32 iCheckPolIdx; // edx + int iDrawIdx; // edi + int32 iPolToDraw; // esi + tPolygon *pDrawPol; // edx + uint32 uiTex; // ecx + int m; // eax + double dViewZ_1; // st7 + tCarPt *pMinZVert34; // eax + tCarPt *pMinZVert12; // eax + tCarPt *pMinZVert12_1; // eax + float fMinViewZ; // eax + tCarPt *pMinZVert34_1; // eax + int iCartexOffset; // ecx + int iGfxSize; // [esp+0h] [ebp-19Ch] + tVec3 *vertDataAy[4]; // [esp+4h] [ebp-198h] + tCarPt *screenVertAy[4]; // [esp+14h] [ebp-188h] + double dLocalZ; // [esp+24h] [ebp-178h] + double dLocalY; // [esp+2Ch] [ebp-170h] + double dDotProduct; // [esp+34h] [ebp-168h] + double dLocalX; // [esp+44h] [ebp-158h] + double dBoxZ; // [esp+4Ch] [ebp-150h] + double dBoxY; // [esp+54h] [ebp-148h] + double dBoxX; // [esp+5Ch] [ebp-140h] + uint32 uiColorFrom; // [esp+64h] [ebp-138h] + int iNumPols; // [esp+68h] [ebp-134h] + float fRotMat01; // [esp+70h] [ebp-12Ch] + float fClippedZ; // [esp+74h] [ebp-128h] + float fNearClip; // [esp+78h] [ebp-124h] + float fViewY; // [esp+7Ch] [ebp-120h] + float fViewX; // [esp+80h] [ebp-11Ch] + float fCarPosZ; // [esp+90h] [ebp-10Ch] + float fCarPosX; // [esp+94h] [ebp-108h] + float fRotMat22; // [esp+98h] [ebp-104h] + float fRotMat21; // [esp+9Ch] [ebp-100h] + float fRotMat11; // [esp+A0h] [ebp-FCh] + float fMinZ34Temp; // [esp+B0h] [ebp-ECh] + float fMinZ12Temp; // [esp+B4h] [ebp-E8h] + float fMaxZTemp_1; // [esp+B8h] [ebp-E4h] + float fMaxZTemp; // [esp+BCh] [ebp-E0h] + float fMinZTemp; // [esp+C0h] [ebp-DCh] + float fMaxZ34; // [esp+C4h] [ebp-D8h] + float fMaxZ12; // [esp+C8h] [ebp-D4h] + float fFinalMaxZ; // [esp+CCh] [ebp-D0h] + float fFinalMaxZ_1; // [esp+D0h] [ebp-CCh] + float fFinalMinZ; // [esp+D4h] [ebp-C8h] + tPolygon *pPolAy; // [esp+D8h] [ebp-C4h] + uint32 uiDesignOffset; // [esp+DCh] [ebp-C0h] + tPolygon *pLinkedPol; // [esp+E0h] [ebp-BCh] + float fMinZ; // [esp+E4h] [ebp-B8h] + float fMinZ_1; // [esp+E8h] [ebp-B4h] + float fMinZTemp_1; // [esp+ECh] [ebp-B0h] + float fMinZ12_2; // [esp+F0h] [ebp-ACh] + float fMinZ34_2; // [esp+F4h] [ebp-A8h] + int iSubPolType; // [esp+F8h] [ebp-A4h] + uint32 uiCarDesignIdxTimes4; // [esp+FCh] [ebp-A0h] + unsigned int uiZOrderOffset; // [esp+104h] [ebp-98h] unsigned int uiZOrderOffset_1; // [esp+108h] [ebp-94h] - int iTotalZOrderBytes; // [esp+10Ch] [ebp-90h] - float fOriginalZ; // [esp+110h] [ebp-8Ch] - float fClampedZ; // [esp+114h] [ebp-88h] - float fTransformedY; // [esp+118h] [ebp-84h] - float fTransformedX; // [esp+11Ch] [ebp-80h] - tVec3 *pCoords; // [esp+120h] [ebp-7Ch] - signed int iProcessedPols; // [esp+124h] [ebp-78h] - int iPolIdx; // [esp+128h] [ebp-74h] - int carDesign; // [esp+12Ch] [ebp-70h] - uint32 uiColorTo_1; // [esp+130h] [ebp-6Ch] - int iIsBack; // [esp+134h] [ebp-68h] - uint32 uiCarDesignOffset; // [esp+138h] [ebp-64h] - int iAnimFrame; // [esp+13Ch] [ebp-60h] - float fCarPosY; // [esp+140h] [ebp-5Ch] - float fRotMat20; // [esp+144h] [ebp-58h] - float fRotMat10; // [esp+148h] [ebp-54h] - float fRotMat12; // [esp+14Ch] [ebp-50h] - float fRotMat02; // [esp+150h] [ebp-4Ch] - float fRotMat00; // [esp+154h] [ebp-48h] - float fCarCenterViewZ; // [esp+15Ch] [ebp-40h] - float fCarCenterViewY; // [esp+160h] [ebp-3Ch] - float fCarCenterViewX; // [esp+164h] [ebp-38h] - float fEdge1YTemp; // [esp+178h] [ebp-24h] - int iTexturesEnabled; // [esp+180h] [ebp-1Ch] - tAnimation *pAnms; // [esp+184h] [ebp-18h] + int iTotalZOrderBytes; // [esp+10Ch] [ebp-90h] + float fOriginalZ; // [esp+110h] [ebp-8Ch] + float fClampedZ; // [esp+114h] [ebp-88h] + float fTransformedY; // [esp+118h] [ebp-84h] + float fTransformedX; // [esp+11Ch] [ebp-80h] + tVec3 *pCoords; // [esp+120h] [ebp-7Ch] + signed int iProcessedPols; // [esp+124h] [ebp-78h] + int iPolIdx; // [esp+128h] [ebp-74h] + int carDesign; // [esp+12Ch] [ebp-70h] + uint32 uiColorTo_1; // [esp+130h] [ebp-6Ch] + int iIsBack; // [esp+134h] [ebp-68h] + uint32 uiCarDesignOffset; // [esp+138h] [ebp-64h] + int iAnimFrame; // [esp+13Ch] [ebp-60h] + float fCarPosY; // [esp+140h] [ebp-5Ch] + float fRotMat20; // [esp+144h] [ebp-58h] + float fRotMat10; // [esp+148h] [ebp-54h] + float fRotMat12; // [esp+14Ch] [ebp-50h] + float fRotMat02; // [esp+150h] [ebp-4Ch] + float fRotMat00; // [esp+154h] [ebp-48h] + float fCarCenterViewZ; // [esp+15Ch] [ebp-40h] + float fCarCenterViewY; // [esp+160h] [ebp-3Ch] + float fCarCenterViewX; // [esp+164h] [ebp-38h] + float fEdge1YTemp; // [esp+178h] [ebp-24h] + int iTexturesEnabled; // [esp+180h] [ebp-1Ch] + tAnimation *pAnms; // [esp+184h] [ebp-18h] if (!scene) return; @@ -2391,7 +2526,8 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn vtilt = 0; // Set up view transformation - calculatetransform(-1, 0, -iAngle & 0x3FFF, 0, worldx, 0.0, worldz, 0.0, 0.0, 0.0); + calculatetransform(-1, 0, -iAngle & 0x3FFF, 0, worldx, 0.0, worldz, 0.0, 0.0, + 0.0); sync_scene_render_from_legacy_view(scene); worlddirn = vdirection; worldelev = velevation; @@ -2408,11 +2544,15 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn fRotMat01 = tsin[iYaw] * tcos[Car[0].nPitch]; dCosYaw = tcos[iYaw]; fRotMat02 = tsin[Car[0].nPitch]; - fRotMat11 = (float)dCosYaw * fRotMat02 * tsin[Car[0].nRoll] - tsin[iYaw] * tcos[Car[0].nRoll]; - fRotMat12 = tsin[iYaw] * fRotMat02 * tsin[Car[0].nRoll] + tcos[iYaw] * tcos[Car[0].nRoll]; + fRotMat11 = (float)dCosYaw * fRotMat02 * tsin[Car[0].nRoll] - + tsin[iYaw] * tcos[Car[0].nRoll]; + fRotMat12 = tsin[iYaw] * fRotMat02 * tsin[Car[0].nRoll] + + tcos[iYaw] * tcos[Car[0].nRoll]; fRotMat21 = -tsin[Car[0].nRoll] * tcos[Car[0].nPitch]; - fRotMat10 = -tcos[iYaw] * fRotMat02 * tcos[Car[0].nRoll] - tsin[iYaw] * tsin[Car[0].nRoll]; - fRotMat22 = -tsin[iYaw] * fRotMat02 * tcos[Car[0].nRoll] + tcos[iYaw] * tsin[Car[0].nRoll]; + fRotMat10 = -tcos[iYaw] * fRotMat02 * tcos[Car[0].nRoll] - + tsin[iYaw] * tsin[Car[0].nRoll]; + fRotMat22 = -tsin[iYaw] * fRotMat02 * tcos[Car[0].nRoll] + + tcos[iYaw] * tsin[Car[0].nRoll]; dCosPitch = tcos[Car[0].nPitch]; fCarPosX = Car[0].pos.fX; fCarPosY = Car[0].pos.fY; @@ -2436,9 +2576,15 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn dBoxZ = pCarBoxAy->fZ; // Transform to world space - CarPt[uiVertIdx / 8].world.fX = (float)(fRotMat00 * dBoxX + fRotMat11 * dBoxY + fRotMat10 * dBoxZ + fCarPosX); - CarPt[uiVertIdx / 8].world.fY = (float)(fRotMat01 * dBoxX + fRotMat12 * dBoxY + fRotMat22 * dBoxZ + fCarPosY); - CarPt[uiVertIdx / 8].world.fZ = (float)(fRotMat02 * dBoxX + fRotMat21 * dBoxY + fRotMat20 * dBoxZ + fCarPosZ); + CarPt[uiVertIdx / 8].world.fX = + (float)(fRotMat00 * dBoxX + fRotMat11 * dBoxY + fRotMat10 * dBoxZ + + fCarPosX); + CarPt[uiVertIdx / 8].world.fY = + (float)(fRotMat01 * dBoxX + fRotMat12 * dBoxY + fRotMat22 * dBoxZ + + fCarPosY); + CarPt[uiVertIdx / 8].world.fZ = + (float)(fRotMat02 * dBoxX + fRotMat21 * dBoxY + fRotMat20 * dBoxZ + + fCarPosZ); // Transform to view space dDeltaX = CarPt[uiVertIdx / 8].world.fX - viewx; @@ -2488,24 +2634,28 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn shadowVerts[vi].v = 0.0f; } SceneRenderLegacyQuadOptions shadowOptions = { - .subdivideType = carDesign + 3, - .subThreshold = 1.0f, + .subdivideType = carDesign + 3, + .subThreshold = 1.0f, }; - scene_render_quad_world_legacy(scene, shadowVerts, SCENE_TEXTURE_HANDLE_INVALID, - SURFACE_FLAG_FLIP_BACKFACE | SURFACE_FLAG_TRANSPARENT | 2, - shadowOptions); + scene_render_quad_world_legacy( + scene, shadowVerts, SCENE_TEXTURE_HANDLE_INVALID, + SURFACE_FLAG_FLIP_BACKFACE | SURFACE_FLAG_TRANSPARENT | 2, + shadowOptions); } // Calculate car center position in view space dCarCenterX = fCarPosX - viewx; dCarCenterY = fCarPosY - viewy; dCarCenterZ = fCarPosZ - viewz; - fCarCenterViewX = (float)(fRotMat00 * dCarCenterX + fRotMat01 * dCarCenterY + fRotMat02 * dCarCenterZ); - fCarCenterViewY = (float)(fRotMat11 * dCarCenterX + fRotMat12 * dCarCenterY + fRotMat21 * dCarCenterZ); + fCarCenterViewX = (float)(fRotMat00 * dCarCenterX + fRotMat01 * dCarCenterY + + fRotMat02 * dCarCenterZ); + fCarCenterViewY = (float)(fRotMat11 * dCarCenterX + fRotMat12 * dCarCenterY + + fRotMat21 * dCarCenterZ); iVisiblePols = 0; pCoords = CarDesigns[carDesign].pCoords; pPols = CarDesigns[carDesign].pPols; - fCarCenterViewZ = (float)(dCarCenterX * fRotMat10 + dCarCenterY * fRotMat22 + dCarCenterZ * fRotMat20); + fCarCenterViewZ = (float)(dCarCenterX * fRotMat10 + dCarCenterY * fRotMat22 + + dCarCenterZ * fRotMat20); // Clear vertex processing flags memset(car_persps, 0, 4 * iNumCoords); @@ -2516,11 +2666,10 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn uiZOrderOffset = 0; do { // Get pointers to the 3D vertices for all 4 corners of this polygon - for ( i = 0; i < 4; i++ ) - { + for (i = 0; i < 4; i++) { // Get vertex index from polygon definition uint8 vertexIndex = pPols->verts[i]; - + // Store pointer to the 3D vertex coordinates vertDataAy[i] = &pCoords[vertexIndex]; } @@ -2531,34 +2680,40 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn dEdge2X = vertDataAy[1]->fX - vertDataAy[3]->fX; dEdge2Y = vertDataAy[1]->fY - vertDataAy[3]->fY; dEdge2Z = vertDataAy[1]->fZ - vertDataAy[3]->fZ; - dDotProduct = ((vertDataAy[0]->fX + vertDataAy[1]->fX + vertDataAy[2]->fX + vertDataAy[3]->fX) * 0.25 - + fCarCenterViewX) - * (fEdge1YTemp * dEdge2Z - (vertDataAy[0]->fZ - vertDataAy[2]->fZ) * dEdge2Y) - + ((vertDataAy[0]->fY + vertDataAy[1]->fY + vertDataAy[2]->fY + vertDataAy[3]->fY) * 0.25 - + fCarCenterViewY) - * ((vertDataAy[0]->fZ - vertDataAy[2]->fZ) * dEdge2X - dEdge2Z * dEdge1X) - + (0.25 * (vertDataAy[0]->fZ + vertDataAy[1]->fZ + vertDataAy[2]->fZ + vertDataAy[3]->fZ) - + fCarCenterViewZ) - * (dEdge2Y * dEdge1X - dEdge2X * fEdge1YTemp); + dDotProduct = ((vertDataAy[0]->fX + vertDataAy[1]->fX + + vertDataAy[2]->fX + vertDataAy[3]->fX) * + 0.25 + + fCarCenterViewX) * + (fEdge1YTemp * dEdge2Z - + (vertDataAy[0]->fZ - vertDataAy[2]->fZ) * dEdge2Y) + + ((vertDataAy[0]->fY + vertDataAy[1]->fY + + vertDataAy[2]->fY + vertDataAy[3]->fY) * + 0.25 + + fCarCenterViewY) * + ((vertDataAy[0]->fZ - vertDataAy[2]->fZ) * dEdge2X - + dEdge2Z * dEdge1X) + + (0.25 * (vertDataAy[0]->fZ + vertDataAy[1]->fZ + + vertDataAy[2]->fZ + vertDataAy[3]->fZ) + + fCarCenterViewZ) * + (dEdge2Y * dEdge1X - dEdge2X * fEdge1YTemp); // Process visible pols - if ((pPols->uiTex & SURFACE_FLAG_FLIP_BACKFACE) != 0 || dDotProduct <= 0.0) - { + if ((pPols->uiTex & SURFACE_FLAG_FLIP_BACKFACE) != 0 || + dDotProduct <= 0.0) { // Transform verts if not already done pPol = pPols; for (j = 0; j != 4; ++j) { byVertIdx = pPol->verts[j]; - if (!car_persps[byVertIdx]) // vert not yet transformed + if (!car_persps[byVertIdx]) // vert not yet transformed { - car_persps[byVertIdx] = -1; // Mark as processed + car_persps[byVertIdx] = -1; // Mark as processed pVertData = vertDataAy[j]; dLocalX = pVertData->fX; dLocalY = pVertData->fY; dLocalZ = pVertData->fZ; // scale for tinycars - if ((cheat_mode & CHEAT_MODE_TINY_CARS) != 0) - { + if ((cheat_mode & CHEAT_MODE_TINY_CARS) != 0) { dLocalX = dLocalX * 0.25; dLocalY = 0.25 * dLocalY; } @@ -2568,16 +2723,24 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn dVertY = dLocalY; iVertIdx_1 = byVertIdx; dVertZ = dLocalZ; - CarPt[iVertIdx_1].world.fX = (float)(fRotMat00 * dLocalX + fRotMat11 * dLocalY + fRotMat10 * dLocalZ + fCarPosX); - CarPt[iVertIdx_1].world.fY = (float)(fRotMat01 * dVertX + fRotMat12 * dVertY + fRotMat22 * dVertZ + fCarPosY); - CarPt[iVertIdx_1].world.fZ = (float)(dVertX * fRotMat02 + dVertY * fRotMat21 + dVertZ * fRotMat20 + fCarPosZ); + CarPt[iVertIdx_1].world.fX = + (float)(fRotMat00 * dLocalX + fRotMat11 * dLocalY + + fRotMat10 * dLocalZ + fCarPosX); + CarPt[iVertIdx_1].world.fY = + (float)(fRotMat01 * dVertX + fRotMat12 * dVertY + + fRotMat22 * dVertZ + fCarPosY); + CarPt[iVertIdx_1].world.fZ = + (float)(dVertX * fRotMat02 + dVertY * fRotMat21 + + dVertZ * fRotMat20 + fCarPosZ); // Transform to view space dDeltaX_1 = CarPt[byVertIdx].world.fX - viewx; dDeltaY_1 = CarPt[byVertIdx].world.fY - viewy; dDeltaZ_1 = CarPt[byVertIdx].world.fZ - viewz; - fTransformedX = (float)(dDeltaX_1 * vk1 + dDeltaY_1 * vk4 + dDeltaZ_1 * vk7); - fTransformedY = (float)(dDeltaX_1 * vk2 + dDeltaY_1 * vk5 + dDeltaZ_1 * vk8); + fTransformedX = + (float)(dDeltaX_1 * vk1 + dDeltaY_1 * vk4 + dDeltaZ_1 * vk7); + fTransformedY = + (float)(dDeltaX_1 * vk2 + dDeltaY_1 * vk5 + dDeltaZ_1 * vk8); dViewX = dDeltaX_1 * vk3 + dDeltaY_1 * vk6 + dDeltaZ_1 * vk9; fClampedZ = (float)dViewX; fOriginalZ = fClampedZ; @@ -2608,41 +2771,45 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn } // Determine pol index and facing dir - if (dDotProduct > 0.0 && (pPols->uiTex & SURFACE_FLAG_BACK) != 0) - { + if (dDotProduct > 0.0 && (pPols->uiTex & SURFACE_FLAG_BACK) != 0) { uiZOrderOffset_3 = uiZOrderOffset; - iPolIdx_1 = -iPolIdx - 1; // negative index + iPolIdx_1 = -iPolIdx - 1; // negative index } else { uiZOrderOffset_3 = uiZOrderOffset; iPolIdx_1 = iPolIdx; } // Store pol data for depth sorting - CarZOrder[uiZOrderOffset_3 / sizeof(tCarZOrderEntry)].iPolygonIndex = iPolIdx_1; - CarZOrder[uiZOrderOffset / sizeof(tCarZOrderEntry)].iPolygonLink = pPols->nNextPolIdx; + CarZOrder[uiZOrderOffset_3 / sizeof(tCarZOrderEntry)].iPolygonIndex = + iPolIdx_1; + CarZOrder[uiZOrderOffset / sizeof(tCarZOrderEntry)].iPolygonLink = + pPols->nNextPolIdx; // Calculate max z val for depth sorting - if ((pPols->uiTex & CAR_FLAG_ANMS_LIVERY) == 0) - { + if ((pPols->uiTex & CAR_FLAG_ANMS_LIVERY) == 0) { // Find max Z among verts (furthest from camera) - if (CarPt[pPols->verts[2]].view.fZ <= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ <= + (double)CarPt[pPols->verts[3]].view.fZ) fMinZ34 = CarPt[pPols->verts[3]].view.fZ; else fMinZ34 = CarPt[pPols->verts[2]].view.fZ; fMaxZ34 = fMinZ34; - if (CarPt[pPols->verts[0]].view.fZ <= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ <= + (double)CarPt[pPols->verts[1]].view.fZ) fMinZ12 = CarPt[pPols->verts[1]].view.fZ; else fMinZ12 = CarPt[pPols->verts[0]].view.fZ; fMaxZ12 = fMinZ12; if (fMinZ12 <= (double)fMaxZ34) { - if (CarPt[pPols->verts[2]].view.fZ <= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ <= + (double)CarPt[pPols->verts[3]].view.fZ) fMaxZ = CarPt[pPols->verts[3]].view.fZ; else fMaxZ = CarPt[pPols->verts[2]].view.fZ; fFinalMinZ = fMaxZ; } else { - if (CarPt[pPols->verts[0]].view.fZ <= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ <= + (double)CarPt[pPols->verts[1]].view.fZ) fMaxZ = CarPt[pPols->verts[1]].view.fZ; else fMaxZ = CarPt[pPols->verts[0]].view.fZ; @@ -2652,24 +2819,28 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn uiZOrderOffset_2 = uiZOrderOffset; } else { // Find minimum Z among vertices (closest to camera) - if (CarPt[pPols->verts[2]].view.fZ >= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ >= + (double)CarPt[pPols->verts[3]].view.fZ) fMinZ34_1 = CarPt[pPols->verts[3]].view.fZ; else fMinZ34_1 = CarPt[pPols->verts[2]].view.fZ; fMinZ34Temp = fMinZ34_1; - if (CarPt[pPols->verts[0]].view.fZ >= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ >= + (double)CarPt[pPols->verts[1]].view.fZ) fMinZ12_1 = CarPt[pPols->verts[1]].view.fZ; else fMinZ12_1 = CarPt[pPols->verts[0]].view.fZ; fMinZ12Temp = fMinZ12_1; if (fMinZ12_1 >= (double)fMinZ34Temp) { - if (CarPt[pPols->verts[2]].view.fZ >= (double)CarPt[pPols->verts[3]].view.fZ) + if (CarPt[pPols->verts[2]].view.fZ >= + (double)CarPt[pPols->verts[3]].view.fZ) fMaxZ = CarPt[pPols->verts[3]].view.fZ; else fMaxZ = CarPt[pPols->verts[2]].view.fZ; fMinZTemp = fMaxZ; } else { - if (CarPt[pPols->verts[0]].view.fZ >= (double)CarPt[pPols->verts[1]].view.fZ) + if (CarPt[pPols->verts[0]].view.fZ >= + (double)CarPt[pPols->verts[1]].view.fZ) fMaxZ = CarPt[pPols->verts[1]].view.fZ; else fMaxZ = CarPt[pPols->verts[0]].view.fZ; @@ -2701,7 +2872,7 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn do { iLinkedPolIdx = CarZOrder[uiZOrderOffset_1 / 0xC].iPolygonIndex; if (iLinkedPolIdx < 0) - iLinkedPolIdx = -1 - iLinkedPolIdx; // Convert to negative index + iLinkedPolIdx = -1 - iLinkedPolIdx; // Convert to negative index // Follow polygon dependency chain iNextPolIdx = pPolAy[iLinkedPolIdx].nNextPolIdx; @@ -2718,13 +2889,14 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn iCheckPolIdx = -1 - iCheckPolIdx; if (iNextPolIdx == iCheckPolIdx) { iSearchIdx = k; - k = iVisiblePols; // exit loop + k = iVisiblePols; // exit loop } } // Adjust Z value to ensure proper ordering if (iSearchIdx >= 0) - CarZOrder[iSearchIdx].fZDepth = CarZOrder[iCurPolIdx].fZDepth + -1.0f; + CarZOrder[iSearchIdx].fZDepth = + CarZOrder[iCurPolIdx].fZDepth + -1.0f; iNextPolIdx = pLinkedPol[iNextPolIdx].nNextPolIdx; iCurPolIdx = iSearchIdx; @@ -2760,8 +2932,7 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn uiTex = pDrawPol->uiTex; // Get screen verts for pol - for ( m = 0; m < 4; m++ ) - { + for (m = 0; m < 4; m++) { // Get screen coordinates for this vertex screenVertAy[m] = &CarPt[pDrawPol->verts[m]]; } @@ -2807,9 +2978,8 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn // Handle backs if (iIsBack) { uiTex = CarDesigns[uiCarDesignOffset / 0x1C].pBacks[iPolToDraw]; - uiTex |= SURFACE_FLAG_FLIP_BACKFACE; - } else if ((uiTex & CAR_FLAG_ANMS_LOOKUP) != 0) - { + uiTex |= SURFACE_FLAG_FLIP_BACKFACE; + } else if ((uiTex & CAR_FLAG_ANMS_LOOKUP) != 0) { if ((uint8)uiTex >= 4u) uiTex = pAnms[(uint8)uiTex].framesAy[iAnimFrame]; else @@ -2817,7 +2987,9 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn } // Apply color remapping if textures are disabled - if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && (uiTex & SURFACE_FLAG_APPLY_TEXTURE) == 0 && (uint8)uiTex == uiColorFrom) + if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && + (uiTex & SURFACE_FLAG_APPLY_TEXTURE) == 0 && + (uint8)uiTex == uiColorFrom) uiTex = uiColorTo_1; CarPol.iSurfaceType = uiTex; @@ -2839,56 +3011,63 @@ void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAn carPolyTexture = scene_render_get_texture_handle(scene, iCartexOffset); } SceneRenderLegacyQuadOptions options = { - .subdivideType = iSubPolType, - .subThreshold = fMinViewZ >= 1.0 ? 1.0f : 0.0f, + .subdivideType = iSubPolType, + .subThreshold = fMinViewZ >= 1.0 ? 1.0f : 0.0f, }; - scene_render_quad_world_legacy(scene, verts, carPolyTexture, uiTex, options); + scene_render_quad_world_legacy(scene, verts, carPolyTexture, uiTex, + options); iDrawIdx += 12; } while (iDrawIdx < iTotalZOrderBytes); } } //------------------------------------------------------------------------------------------------- -//0005B490 -void championship_winner() -{ - uint8 *pbyScreenBuffer; // edi +// 0005B490 +void championship_winner() { + uint8 *pbyScreenBuffer; // edi tBlockHeader *pChampImageData; // esi - int iCurrentFrame; // ebp - unsigned int uiBufferSize; // ecx - char byBufferSizeRemainder; // al + int iCurrentFrame; // ebp + unsigned int uiBufferSize; // ecx + char byBufferSizeRemainder; // al unsigned int uiDwordCopyCount; // ecx - int iFrameTimer; // ebx - uint8 *pbyAnimScreenBuf; // edi - char *pszCurrentFrameData; // esi + int iFrameTimer; // ebx + uint8 *pbyAnimScreenBuf; // edi + char *pszCurrentFrameData; // esi unsigned int uiAnimBufferSize; // ecx - char byAnimRemainder; // al + char byAnimRemainder; // al unsigned int uiAnimDwordCount; // ecx - int iNumAnimFrames; // [esp+0h] [ebp-20h] - int iDuration; // [esp+4h] [ebp-1Ch] + int iNumAnimFrames; // [esp+0h] [ebp-20h] + int iDuration; // [esp+4h] [ebp-1Ch] - SVGA_ON = -1; // Initialize SVGA mode and full screen window for championship victory + SVGA_ON = -1; // Initialize SVGA mode and full screen window for championship + // victory init_screen(); winx = 0; winw = XMAX; winy = 0; winh = YMAX; mirror = 0; - setpal("champ.pal"); // Set championship palette and load victory image - front_vga[0] = (tBlockHeader *)try_load_picture("champ.bm");// Try to load animated championship image, fallback to static + setpal("champ.pal"); // Set championship palette and load victory image + front_vga[0] = (tBlockHeader *)try_load_picture( + "champ.bm"); // Try to load animated championship image, fallback to + // static if (front_vga[0]) { - iNumAnimFrames = 12; // Animated version has 12 frames + iNumAnimFrames = 12; // Animated version has 12 frames } else { - front_vga[0] = (tBlockHeader *)load_picture("chump.bm");// Static fallback version has 1 frame + front_vga[0] = (tBlockHeader *)load_picture( + "chump.bm"); // Static fallback version has 1 frame iNumAnimFrames = 1; } - if (iNumAnimFrames != 1 && MusicVolume && MusicCard)// Set display duration: longer for animated with music, shorter otherwise + if (iNumAnimFrames != 1 && MusicVolume && + MusicCard) // Set display duration: longer for animated with music, + // shorter otherwise iDuration = 720; else iDuration = 180; pbyScreenBuffer = scrbuf; pChampImageData = front_vga[0]; - iCurrentFrame = 0; // Copy first frame to screen buffer (optimized memory copy) + iCurrentFrame = + 0; // Copy first frame to screen buffer (optimized memory copy) if (SVGA_ON) uiBufferSize = 256000; else @@ -2896,8 +3075,10 @@ void championship_winner() byBufferSizeRemainder = uiBufferSize; uiDwordCopyCount = uiBufferSize >> 2; memcpy(scrbuf, front_vga[0], 4 * uiDwordCopyCount); - memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], &pChampImageData->iWidth + uiDwordCopyCount, byBufferSizeRemainder & 3); - copypic(scrbuf, screen); // Display initial frame and start championship music + memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], + &pChampImageData->iWidth + uiDwordCopyCount, + byBufferSizeRemainder & 3); + copypic(scrbuf, screen); // Display initial frame and start championship music if (SnapshotShouldStop()) { fre((void **)front_vga); return; @@ -2905,34 +3086,42 @@ void championship_winner() iFrameTimer = 0; startmusic(winchampsong); enable_keyboard(); - fade_palette(32); // Enable input, fade in display, and initialize animation timing + fade_palette( + 32); // Enable input, fade in display, and initialize animation timing front_fade = -1; ticks = 0; frames = 1; - do { // Main animation loop - exit on keyboard input + do { // Main animation loop - exit on keyboard input if (fatkbhit()) break; - iFrameTimer -= frames; // Update frame timer based on game frame rate + iFrameTimer -= frames; // Update frame timer based on game frame rate frames = 0; - if (iFrameTimer < 0) // Time to advance to next animation frame + if (iFrameTimer < 0) // Time to advance to next animation frame { pbyAnimScreenBuf = scrbuf; - pszCurrentFrameData = (char *)front_vga[0] + 256000 * iCurrentFrame;// Calculate pointer to current animation frame data + pszCurrentFrameData = + (char *)front_vga[0] + + 256000 * iCurrentFrame; // Calculate pointer to current animation + // frame data if (SVGA_ON) uiAnimBufferSize = 256000; else uiAnimBufferSize = 64000; byAnimRemainder = uiAnimBufferSize; uiAnimDwordCount = uiAnimBufferSize >> 2; - memcpy(scrbuf, pszCurrentFrameData, 4 * uiAnimDwordCount);// Copy current frame to screen buffer and display - memcpy(&pbyAnimScreenBuf[4 * uiAnimDwordCount], &pszCurrentFrameData[4 * uiAnimDwordCount], byAnimRemainder & 3); + memcpy(scrbuf, pszCurrentFrameData, + 4 * uiAnimDwordCount); // Copy current frame to screen buffer and + // display + memcpy(&pbyAnimScreenBuf[4 * uiAnimDwordCount], + &pszCurrentFrameData[4 * uiAnimDwordCount], byAnimRemainder & 3); copypic(scrbuf, screen); if (SnapshotShouldStop()) break; - do { // Advance to next frame, wrap around at end of animation + do { // Advance to next frame, wrap around at end of animation if (++iCurrentFrame == iNumAnimFrames) - iCurrentFrame ^= iNumAnimFrames; // Reset to frame 0 when reaching end of animation cycle - iFrameTimer += 2; // Add 2 ticks to frame timer for next frame timing + iCurrentFrame ^= iNumAnimFrames; // Reset to frame 0 when reaching end + // of animation cycle + iFrameTimer += 2; // Add 2 ticks to frame timer for next frame timing UpdateSDL(); if (!SnapshotShouldStop()) SnapshotAdvanceTick(); @@ -2942,35 +3131,31 @@ void championship_winner() if (SnapshotShouldStop()) break; SnapshotAdvanceTick(); - } while (ticks < iDuration); // Continue animation until timeout or user input - fre((void **)front_vga); // Clean up championship image resources + } while (ticks < iDuration); // Continue animation until timeout or user input + fre((void **)front_vga); // Clean up championship image resources } -void snapshot_render_winner_championship(void) -{ - championship_winner(); -} +void snapshot_render_winner_championship(void) { championship_winner(); } //------------------------------------------------------------------------------------------------- -//0005B660 -void print_mem_used(const char *szMsg) -{ +// 0005B660 +void print_mem_used(const char *szMsg) { printf("%s\n", szMsg); printf("hi mem used: %i\n", mem_used); printf("lo mem used: %i\n\n", mem_used_low); } //------------------------------------------------------------------------------------------------- -//0005B6A0 -uint8 *try_load_picture(const char *szFile) -{ - uint8 *pBuf2; // ebx - int iFile; // eax +// 0005B6A0 +uint8 *try_load_picture(const char *szFile) { + uint8 *pBuf2; // ebx + int iFile; // eax uint32 iLength; // eax - uint8 *pBuf; // ecx + uint8 *pBuf; // ecx pBuf2 = 0; - iFile = ROLLERopen(szFile, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFile = ROLLERopen( + szFile, O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFile != -1) { close(iFile); iLength = getcompactedfilelength(szFile); @@ -2983,67 +3168,68 @@ uint8 *try_load_picture(const char *szFile) } //------------------------------------------------------------------------------------------------- -//0005B6F0 -void save_champ(int iSlot) -{ - char *pbySaveBuffer; // eax - char *pBufPlus1; // eax - uint8 byCompetitorsFlags; // dl - char *pbyCurrentPos; // eax - uint8 *pbyPlayerData; // eax - int iPlayerIndex; // edx - int iCarWithInvul; // ebx - uint8 *pbyPlayerControlData; // eax - int iControlType; // ebx - int iBitMask; // ebx - int iNonCompetitorsMask; // esi - int iCarIndex; // edx +// 0005B6F0 +void save_champ(int iSlot) { + char *pbySaveBuffer; // eax + char *pBufPlus1; // eax + uint8 byCompetitorsFlags; // dl + char *pbyCurrentPos; // eax + uint8 *pbyPlayerData; // eax + int iPlayerIndex; // edx + int iCarWithInvul; // ebx + uint8 *pbyPlayerControlData; // eax + int iControlType; // ebx + int iBitMask; // ebx + int iNonCompetitorsMask; // esi + int iCarIndex; // edx uint8 *pbyAfterNonCompetitors; // eax - uint8 *pbyAfterNetworkChamp; // eax - uint8 *pbyAfterNetworkSlot; // eax - uint8 *pbyAfterHeader; // eax - int iCarStatsIndex; // esi - int iCarArrayIndex; // ebx - uint8 *pbyAfterPoints; // eax - uint8 *pbyAfterKills; // eax - uint8 *pbyAfterFasts; // eax - int i; // ebx - uint8 *pbyAfterTeamPoints; // eax - uint8 *pbyAfterTeamKills; // eax - uint8 *pbyAfterTeamFasts; // eax - int iTeamWins; // edx - int iNameEndIndex; // edi - int iTeamIndex; // esi - int iNameStartIndex; // edx - uint8 *pbyNameChar; // eax - char byPlayerNameChar; // cl - uint8 *pbyAfterSerial; // eax - uint8 *pbyAfterModemPort; // eax - uint8 *pbyAfterModemCall; // eax - uint8 *pbyPhoneData; // eax - int j; // edx - uint8 *pbyPhoneChar; // eax - char byPhoneDigit; // bl - uint8 *pbyEndOfData; // esi - char byChecksum; // cl - char *pbyChecksumPos; // eax - //int iPlayersCarsOffset; // esi + uint8 *pbyAfterNetworkChamp; // eax + uint8 *pbyAfterNetworkSlot; // eax + uint8 *pbyAfterHeader; // eax + int iCarStatsIndex; // esi + int iCarArrayIndex; // ebx + uint8 *pbyAfterPoints; // eax + uint8 *pbyAfterKills; // eax + uint8 *pbyAfterFasts; // eax + int i; // ebx + uint8 *pbyAfterTeamPoints; // eax + uint8 *pbyAfterTeamKills; // eax + uint8 *pbyAfterTeamFasts; // eax + int iTeamWins; // edx + int iNameEndIndex; // edi + int iTeamIndex; // esi + int iNameStartIndex; // edx + uint8 *pbyNameChar; // eax + char byPlayerNameChar; // cl + uint8 *pbyAfterSerial; // eax + uint8 *pbyAfterModemPort; // eax + uint8 *pbyAfterModemCall; // eax + uint8 *pbyPhoneData; // eax + int j; // edx + uint8 *pbyPhoneChar; // eax + char byPhoneDigit; // bl + uint8 *pbyEndOfData; // esi + char byChecksum; // cl + char *pbyChecksumPos; // eax + // int iPlayersCarsOffset; // esi int64 llPlayersCarsOffset; - int iNameIndex; // edx - char byDataByte; // ch - FILE *pSaveFile; // edi + int iNameIndex; // edx + char byDataByte; // ch + FILE *pSaveFile; // edi char *pbyBufferStart; // [esp+0h] [ebp-1Ch] BYREF - pbySaveBuffer = (char *)getbuffer(0x800u); // Allocate 2KB buffer for save data + pbySaveBuffer = + (char *)getbuffer(0x800u); // Allocate 2KB buffer for save data pbyBufferStart = pbySaveBuffer; *pbySaveBuffer = TrackLoad; pBufPlus1 = pbySaveBuffer + 1; byCompetitorsFlags = competitors; if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) byCompetitorsFlags = competitors | 0x20; - if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0) // CHEAT_MODE_DEATH_MODE + if ((cheat_mode & CHEAT_MODE_DEATH_MODE) != 0) // CHEAT_MODE_DEATH_MODE byCompetitorsFlags |= 0x40u; - if ((cheat_mode & CHEAT_MODE_KILLER_OPPONENTS) != 0) // CHEAT_MODE_KILLER_OPPONENTS + if ((cheat_mode & CHEAT_MODE_KILLER_OPPONENTS) != + 0) // CHEAT_MODE_KILLER_OPPONENTS byCompetitorsFlags |= 0x80u; pbyCurrentPos = pBufPlus1 + 1; *(pbyCurrentPos++ - 1) = byCompetitorsFlags; @@ -3056,8 +3242,9 @@ void save_champ(int iSlot) for (iPlayerIndex = 0; iPlayerIndex != 16; ++iPlayerIndex) { iCarWithInvul = Players_Cars[iPlayerIndex]; if (player_invul[iPlayerIndex]) { - //LOBYTE(iCarWithInvul) = iCarWithInvul | 0x40; - iCarWithInvul = (iCarWithInvul & 0xFFFFFF00) | ((iCarWithInvul & 0xFF) | 0x40); + // LOBYTE(iCarWithInvul) = iCarWithInvul | 0x40; + iCarWithInvul = + (iCarWithInvul & 0xFFFFFF00) | ((iCarWithInvul & 0xFF) | 0x40); } pbyPlayerControlData = pbyPlayerData + 1; *(pbyPlayerControlData - 1) = iCarWithInvul; @@ -3077,18 +3264,22 @@ void save_champ(int iSlot) } while (iCarIndex < numcars); } pbyAfterNonCompetitors = sav_champ_int(pbyPlayerData, iNonCompetitorsMask); - pbyAfterNetworkChamp = sav_champ_int(pbyAfterNonCompetitors, network_champ_on); + pbyAfterNetworkChamp = + sav_champ_int(pbyAfterNonCompetitors, network_champ_on); pbyAfterNetworkSlot = sav_champ_int(pbyAfterNetworkChamp, network_slot); pbyAfterHeader = sav_champ_int(pbyAfterNetworkSlot, net_type); iCarStatsIndex = 0; if (numcars > 0) { iCarArrayIndex = 0; do { - pbyAfterPoints = sav_champ_int(pbyAfterHeader, championship_points[iCarArrayIndex]); - pbyAfterKills = sav_champ_int(pbyAfterPoints, total_kills[iCarArrayIndex]); + pbyAfterPoints = + sav_champ_int(pbyAfterHeader, championship_points[iCarArrayIndex]); + pbyAfterKills = + sav_champ_int(pbyAfterPoints, total_kills[iCarArrayIndex]); pbyAfterFasts = sav_champ_int(pbyAfterKills, total_fasts[iCarArrayIndex]); ++iCarStatsIndex; - pbyAfterHeader = sav_champ_int(pbyAfterFasts, total_wins[iCarArrayIndex++]); + pbyAfterHeader = + sav_champ_int(pbyAfterFasts, total_wins[iCarArrayIndex++]); } while (iCarStatsIndex < numcars); } for (i = 0; i != 8; ++i) { @@ -3130,152 +3321,161 @@ void save_champ(int iSlot) pbyEndOfData = pbyPhoneData; byChecksum = 0; pbyChecksumPos = pbyBufferStart; - + llPlayersCarsOffset = pbyEndOfData - (uint8 *)pbyBufferStart; - for (iNameIndex = 0; iNameIndex < llPlayersCarsOffset; byChecksum += byDataByte) { + for (iNameIndex = 0; iNameIndex < llPlayersCarsOffset; + byChecksum += byDataByte) { ++iNameIndex; byDataByte = *pbyChecksumPos++; } - + *pbyChecksumPos = byChecksum; pSaveFile = ROLLERfopen(save_slots[iSlot - 1], "wb"); - if (pSaveFile)//check added by ROLLER + if (pSaveFile) // check added by ROLLER fwrite(pbyBufferStart, 1, llPlayersCarsOffset + 1, pSaveFile); fclose(pSaveFile); fre((void **)&pbyBufferStart); } //------------------------------------------------------------------------------------------------- -//0005B9A0 -int load_champ(int iSlot) -{ - int iFileHandle; // edx - int iFileLength; // esi +// 0005B9A0 +int load_champ(int iSlot) { + int iFileHandle; // edx + int iFileLength; // esi char *pbyCurrentPos; // eax - char byChecksum; // cl - int iChecksumLoop; // edx - char byCurrentByte; // ch - int iSavedRacers; // edi + char byChecksum; // cl + int iChecksumLoop; // edx + char byCurrentByte; // ch + int iSavedRacers; // edi char byGameSettings; // al - //uint32 uiTempCheatMode; // edx - //uint32 uiTempCheatMode2; // ecx + // uint32 uiTempCheatMode; // edx + // uint32 uiTempCheatMode2; // ecx uint8 *pbyPlayerData; // ebx - //int i; // eax + // int i; // eax uint8 byPlayerByte; // dl - //uint8 *pbyNextPlayerByte; // ebx - int *piDataPointer; // ecx - int iPlayerSecondByte; // edx - int iBitFlag; // ebx - int *piNextData; // edx + // uint8 *pbyNextPlayerByte; // ebx + int *piDataPointer; // ecx + int iPlayerSecondByte; // edx + int iBitFlag; // ebx + int *piNextData; // edx int iNonCompetitorFlags; // eax - //int iArraySize; // esi - //int iByteOffset; // eax - int iFlags = 0; // ebp - int iFlagCheck; // ecx - int *piStatsPointer; // edx - int iNetType; // eax - int *piTeamStatsPointer; // edx - int iStatsLoop; // eax - int *piTotalWinsPtr; // ecx - int *piTotalFastsPtr; // esi - int *piTotalKillsPtr; // ebx + // int iArraySize; // esi + // int iByteOffset; // eax + int iFlags = 0; // ebp + int iFlagCheck; // ecx + int *piStatsPointer; // edx + int iNetType; // eax + int *piTeamStatsPointer; // edx + int iStatsLoop; // eax + int *piTotalWinsPtr; // ecx + int *piTotalFastsPtr; // esi + int *piTotalKillsPtr; // ebx int *piChampionshipPointsPtr; // edi - int iTeamStatsValue; // ebp - int *piNextTeamData; // edx - int iSecondTeamValue; // ebp - int *piTeamWinsPtr; // ebx - int *piTeamPointsPtr; // eax - int *piTeamFastsPtr; // esi - int *piTeamKillsPtr; // ecx - int iCurrentTeamValue; // edi - int *piTeamDataPtr; // edx - int iTeamKillsValue; // edi - int iNameEndIndex; // edi - int iTeamIndex; // ecx - int iNameIndex; // eax - char byNameChar; // bl - uint8 *pbyNamePtr; // edx - char *pszTempPointer; // ebx - int iSerialPortValue; // eax - int *piModemDataPtr; // edx - int iModemPortValue; // eax - int iModemCallValue; // eax - int iModemBaudValue; // eax - char *pszPhonePtr; // edx - //int j; // eax - //char byPhoneChar1; // bl - //char *pszPhoneCharPtr; // edx - //char byPhoneChar2; // bl - //char byPhoneChar3; // bl - //char byPhoneChar4; // bl - int iDriverLoop; // esi - char *pszDriverNamePtr; // ebp - int iDriverIndex; // edi - char *pszSourceNamePtr; // edx - char *pszDefaultNamePtr; // eax - char byDriverNameChar; // cl - int iHumanPlayerLoop; // edi - int iPlayerCarIndex; // esi - char *pszPlayerNamePtr; // ebp - int iPlayerCarValue; // eax - int iCarSlotIndex; // edx - int iHumanControlLoop; // eax - int iControlCheck; // ebx - char *pszTargetNamePtr; // edx + int iTeamStatsValue; // ebp + int *piNextTeamData; // edx + int iSecondTeamValue; // ebp + int *piTeamWinsPtr; // ebx + int *piTeamPointsPtr; // eax + int *piTeamFastsPtr; // esi + int *piTeamKillsPtr; // ecx + int iCurrentTeamValue; // edi + int *piTeamDataPtr; // edx + int iTeamKillsValue; // edi + int iNameEndIndex; // edi + int iTeamIndex; // ecx + int iNameIndex; // eax + char byNameChar; // bl + uint8 *pbyNamePtr; // edx + char *pszTempPointer; // ebx + int iSerialPortValue; // eax + int *piModemDataPtr; // edx + int iModemPortValue; // eax + int iModemCallValue; // eax + int iModemBaudValue; // eax + char *pszPhonePtr; // edx + // int j; // eax + // char byPhoneChar1; // bl + // char *pszPhoneCharPtr; // edx + // char byPhoneChar2; // bl + // char byPhoneChar3; // bl + // char byPhoneChar4; // bl + int iDriverLoop; // esi + char *pszDriverNamePtr; // ebp + int iDriverIndex; // edi + char *pszSourceNamePtr; // edx + char *pszDefaultNamePtr; // eax + char byDriverNameChar; // cl + int iHumanPlayerLoop; // edi + int iPlayerCarIndex; // esi + char *pszPlayerNamePtr; // ebp + int iPlayerCarValue; // eax + int iCarSlotIndex; // edx + int iHumanControlLoop; // eax + int iControlCheck; // ebx + char *pszTargetNamePtr; // edx char *pszSourcePlayerPtr; // eax - char byPlayerNameChar; // cl - //int iControlArraySize; // edx - //unsigned int uiControlLoop; // edi - int iCompetitorCount; // edi + char byPlayerNameChar; // cl + // int iControlArraySize; // edx + // unsigned int uiControlLoop; // edi + int iCompetitorCount; // edi signed int iCompetitorCheck; // esi - //int iOrderSearchStart; // edx - //unsigned int uiOrderByteOffset; // ecx - //int k; // eax + // int iOrderSearchStart; // edx + // unsigned int uiOrderByteOffset; // ecx + // int k; // eax int iHighestPoints; // ecx - //int iSortCurrentIndex; // ebp - //int iSortTotalRacers; // edi - //int iSortSearchIndex; // eax - //int iSortCompareIndex; // edx - //int iSwapTempValue; // edx - //int iNextSortIndex; // eax - uint8 *pFileBuf; // [esp+0h] [ebp-30h] BYREF - int iChecksumOk; // [esp+4h] [ebp-2Ch] - int *piTeamPointsEnd; // [esp+8h] [ebp-28h] - int iFlags2; // [esp+Ch] [ebp-24h] + // int iSortCurrentIndex; // ebp + // int iSortTotalRacers; // edi + // int iSortSearchIndex; // eax + // int iSortCompareIndex; // edx + // int iSwapTempValue; // edx + // int iNextSortIndex; // eax + uint8 *pFileBuf; // [esp+0h] [ebp-30h] BYREF + int iChecksumOk; // [esp+4h] [ebp-2Ch] + int *piTeamPointsEnd; // [esp+8h] [ebp-28h] + int iFlags2; // [esp+Ch] [ebp-24h] char *pszDefaultNameEnd; // [esp+10h] [ebp-20h] - signed int iSortIndex; // [esp+14h] [ebp-1Ch] + signed int iSortIndex; // [esp+14h] [ebp-1Ch] iFileLength = ROLLERfilelength(save_slots[iSlot - 1]); - iFileHandle = ROLLERopen(save_slots[iSlot - 1], O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = + ROLLERopen(save_slots[iSlot - 1], + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h iChecksumOk = 0; if (iFileHandle != -1) { - pFileBuf = (uint8 *)getbuffer(0x800u); // Allocate buffer and read save file (expected size: 795 bytes) - - //iFileLength = _filelength(iFileHandle); + pFileBuf = (uint8 *)getbuffer(0x800u); // Allocate buffer and read save file + // (expected size: 795 bytes) + + // iFileLength = _filelength(iFileHandle); if (iFileLength == 795) read(iFileHandle, pFileBuf, 795); close(iFileHandle); if (iFileLength == 795) { - pbyCurrentPos = (char *)pFileBuf; // CHECKSUM VALIDATION: Calculate checksum of first 794 bytes + pbyCurrentPos = (char *)pFileBuf; // CHECKSUM VALIDATION: Calculate + // checksum of first 794 bytes byChecksum = 0; for (iChecksumLoop = 0; iChecksumLoop < 794; ++iChecksumLoop) { byCurrentByte = *pbyCurrentPos++; byChecksum += byCurrentByte; } - if (*pbyCurrentPos == byChecksum) // Verify checksum matches byte 795 - if valid, proceed with load + if (*pbyCurrentPos == byChecksum) // Verify checksum matches byte 795 - if + // valid, proceed with load iChecksumOk = -1; } if (iChecksumOk) { - iSavedRacers = racers; // NETWORK CLEANUP: Disconnect from network before loading saved state + iSavedRacers = racers; // NETWORK CLEANUP: Disconnect from network before + // loading saved state broadcast_mode = -666; while (broadcast_mode) UpdateSDL(); tick_on = 0; - TrackLoad = *pFileBuf; // BASIC GAME SETTINGS: Load track, competitors, texture/cheat flags + TrackLoad = *pFileBuf; // BASIC GAME SETTINGS: Load track, competitors, + // texture/cheat flags byGameSettings = pFileBuf[1]; - competitors = byGameSettings & 0x1F; // Parse game settings byte: bits 0-4=competitors, bit 5=textures, bit 6=cheat, bit 7=network cheat + competitors = byGameSettings & + 0x1F; // Parse game settings byte: bits 0-4=competitors, bit + // 5=textures, bit 6=cheat, bit 7=network cheat if ((byGameSettings & 0x20) != 0) textures_off |= TEX_OFF_ADVANCED_CARS; else @@ -3286,13 +3486,14 @@ int load_champ(int iSlot) cheat_mode &= ~CHEAT_MODE_DEATH_MODE; } if (byGameSettings >= 0) { - //uiTempCheatMode2 = cheat_mode; - //BYTE1(uiTempCheatMode2) = BYTE1(cheat_mode) & 0xFD; - cheat_mode &= ~CHEAT_MODE_KILLER_OPPONENTS;// uiTempCheatMode2; + // uiTempCheatMode2 = cheat_mode; + // BYTE1(uiTempCheatMode2) = BYTE1(cheat_mode) & 0xFD; + cheat_mode &= ~CHEAT_MODE_KILLER_OPPONENTS; // uiTempCheatMode2; } else { cheat_mode |= CHEAT_MODE_KILLER_OPPONENTS; } - players = pFileBuf[2]; // Load player count, difficulty level, damage level, and player type + players = pFileBuf[2]; // Load player count, difficulty level, damage + // level, and player type level = pFileBuf[3]; damage_level = pFileBuf[4]; player_type = pFileBuf[5]; @@ -3306,60 +3507,69 @@ int load_champ(int iSlot) // Store player car selection (bits 0-4 of first byte) Players_Cars[i] = byPlayerByte & 0x1F; - // Store player invulnerability status (bit 6: 0=vulnerable, 1=invulnerable) + // Store player invulnerability status (bit 6: 0=vulnerable, + // 1=invulnerable) player_invul[i] = ((byPlayerByte & 0x40) == 0) - 1; // Store manual control flags for this player manual_control[i] = iPlayerSecondByte; - // Update data pointer to current position (as int pointer for next section) + // Update data pointer to current position (as int pointer for next + // section) piDataPointer = (int *)pbyPlayerData; } - //for (i = 0; i != 16; *(int *)((char *)&competitors + i * 4) = iPlayerSecondByte)// Load 16 players' car choices and starting status + // for (i = 0; i != 16; *(int *)((char *)&competitors + i * 4) = + // iPlayerSecondByte)// Load 16 players' car choices and starting status //{ - // byPlayerByte = *pbyPlayerData; - // pbyNextPlayerByte = pbyPlayerData + 1; - // *(int *)((char *)&infinite_laps + ++i * 4) = byPlayerByte & 0x1F; - // player_started[i + 15] = ((byPlayerByte & 0x40) == 0) - 1; - // piDataPointer = (int *)(pbyNextPlayerByte + 1); - // iPlayerSecondByte = *pbyNextPlayerByte; - // pbyPlayerData = pbyNextPlayerByte + 1; - //} + // byPlayerByte = *pbyPlayerData; + // pbyNextPlayerByte = pbyPlayerData + 1; + // *(int *)((char *)&infinite_laps + ++i * 4) = byPlayerByte & 0x1F; + // player_started[i + 15] = ((byPlayerByte & 0x40) == 0) - 1; + // piDataPointer = (int *)(pbyNextPlayerByte + 1); + // iPlayerSecondByte = *pbyNextPlayerByte; + // pbyPlayerData = pbyNextPlayerByte + 1; + // } iBitFlag = 1; piNextData = piDataPointer + 1; iNonCompetitorFlags = *piDataPointer; racers = iSavedRacers; iFlags2 = iNonCompetitorFlags; - if (numcars > 0) // NON-COMPETITOR FLAGS: Parse bit flags to determine which cars are competitors + if (numcars > 0) // NON-COMPETITOR FLAGS: Parse bit flags to determine + // which cars are competitors { if (numcars > 0) { for (int i = 0; i < numcars; i++) { - // Check if bit i is set in the flags - if clear, car is a non-competitor + // Check if bit i is set in the flags - if clear, car is a + // non-competitor iFlagCheck = ((iFlags & iBitFlag) == 0) - 1; non_competitors[i] = iFlagCheck; - iBitFlag *= 2; // Move to next bit position + iBitFlag *= 2; // Move to next bit position } } - //iArraySize = 4 * numcars; - //iByteOffset = 0; - //iFlags = iFlags2; - //do { - // iByteOffset += 4; - // iFlagCheck = ((iFlags & iBitFlag) == 0) - 1; - // iBitFlag *= 2; - // TrackArrow_variable_1[iByteOffset / 4u] = iFlagCheck;// offset into non_competitors - //} while (iByteOffset < iArraySize); + // iArraySize = 4 * numcars; + // iByteOffset = 0; + // iFlags = iFlags2; + // do { + // iByteOffset += 4; + // iFlagCheck = ((iFlags & iBitFlag) == 0) - 1; + // iBitFlag *= 2; + // TrackArrow_variable_1[iByteOffset / 4u] = iFlagCheck;// offset into + // non_competitors + // } while (iByteOffset < iArraySize); } piStatsPointer = piNextData + 1; - network_champ_on = *(piStatsPointer++ - 1);// NETWORK SETTINGS: Load network championship flag, slot, and type + network_champ_on = + *(piStatsPointer++ - 1); // NETWORK SETTINGS: Load network + // championship flag, slot, and type network_slot = *(piStatsPointer - 1); iNetType = *piStatsPointer; piTeamStatsPointer = piStatsPointer + 1; net_type = iNetType; ROLLERCommsSetType(iNetType); iStatsLoop = 0; - if (numcars > 0) // INDIVIDUAL STATISTICS: Load championship points, kills, fastest laps, wins for each car + if (numcars > 0) // INDIVIDUAL STATISTICS: Load championship points, + // kills, fastest laps, wins for each car { piTotalWinsPtr = total_wins; piTotalFastsPtr = total_fasts; @@ -3382,7 +3592,8 @@ int load_champ(int iSlot) piTeamStatsPointer = piNextTeamData + 2; } while (iStatsLoop < numcars); } - piTeamWinsPtr = team_wins; // TEAM STATISTICS: Load team points, kills, fastest laps, wins for 8 teams + piTeamWinsPtr = team_wins; // TEAM STATISTICS: Load team points, kills, + // fastest laps, wins for 8 teams piTeamPointsPtr = team_points; piTeamFastsPtr = team_fasts; piTeamKillsPtr = team_kills; @@ -3403,14 +3614,19 @@ int load_champ(int iSlot) } while (piTeamPointsPtr != piTeamPointsEnd); iNameEndIndex = 9; - for (iTeamIndex = 0; iTeamIndex < 16; ++iTeamIndex)// PLAYER NAMES: Load 16 players * 9 * 2 character names (288 bytes total) + for (iTeamIndex = 0; iTeamIndex < 16; + ++iTeamIndex) // PLAYER NAMES: Load 16 players * 9 * 2 character + // names (288 bytes total) { iNameIndex = 9 * iTeamIndex; do { - byNameChar = *(uint8 *)piTeamStatsPointer;// Copy name bytes to both default_names and player_names arrays + byNameChar = + *(uint8 *) + piTeamStatsPointer; // Copy name bytes to both default_names + // and player_names arrays pbyNamePtr = (uint8 *)piTeamStatsPointer + 1; default_names[0][iNameIndex] = byNameChar; - //pszTempPointer = (char *)pbyNamePtr; + // pszTempPointer = (char *)pbyNamePtr; ++iNameIndex; uint8 byte = *pbyNamePtr; piTeamStatsPointer = (int *)(pbyNamePtr + 1); @@ -3418,7 +3634,9 @@ int load_champ(int iSlot) } while (iNameIndex != iNameEndIndex); iNameEndIndex += 9; } - iSerialPortValue = *piTeamStatsPointer; // COMMUNICATION SETTINGS: Load serial port, modem settings, and phone/init strings + iSerialPortValue = + *piTeamStatsPointer; // COMMUNICATION SETTINGS: Load serial port, + // modem settings, and phone/init strings piModemDataPtr = piTeamStatsPointer + 1; serial_port = iSerialPortValue; iModemPortValue = *piModemDataPtr++; @@ -3430,36 +3648,42 @@ int load_champ(int iSlot) iModemBaudValue = *(uint8 *)piModemDataPtr; pszPhonePtr = (char *)piModemDataPtr + 1; - // Load modem phone number and init string (51 chars each, 102 bytes total) + // Load modem phone number and init string (51 chars each, 102 bytes + // total) memcpy(modem_phone, pszPhonePtr, 51); pszPhonePtr += 51; memcpy(modem_initstring, pszPhonePtr, 51); pszPhonePtr += 51; - //modem_phone[0] = (uint8)iModemBaudValue; - //for (j = 1; j <= 50; modem_initstring[j + 50] = (char)pszTempPointer)// Load modem phone number and init string (51 chars each, 102 bytes total) + // modem_phone[0] = (uint8)iModemBaudValue; + // for (j = 1; j <= 50; modem_initstring[j + 50] = (char)pszTempPointer)// + // Load modem phone number and init string (51 chars each, 102 bytes + // total) //{ - // byPhoneChar1 = *pszPhonePtr; - // pszPhoneCharPtr = pszPhonePtr + 1; - // modem_phone[j] = byPhoneChar1; - // byPhoneChar2 = *pszPhoneCharPtr++; - // modem_phone[j + 1] = byPhoneChar2; - // byPhoneChar3 = *pszPhoneCharPtr++; - // modem_phone[j + 2] = byPhoneChar3; - // byPhoneChar4 = *pszPhoneCharPtr++; - // modem_phone[j + 3] = byPhoneChar4; - // j += 5; - // LOBYTE(pszTempPointer) = *pszPhoneCharPtr; - // pszPhonePtr = pszPhoneCharPtr + 1; - //} + // byPhoneChar1 = *pszPhonePtr; + // pszPhoneCharPtr = pszPhonePtr + 1; + // modem_phone[j] = byPhoneChar1; + // byPhoneChar2 = *pszPhoneCharPtr++; + // modem_phone[j + 1] = byPhoneChar2; + // byPhoneChar3 = *pszPhoneCharPtr++; + // modem_phone[j + 2] = byPhoneChar3; + // byPhoneChar4 = *pszPhoneCharPtr++; + // modem_phone[j + 3] = byPhoneChar4; + // j += 5; + // LOBYTE(pszTempPointer) = *pszPhoneCharPtr; + // pszPhonePtr = pszPhoneCharPtr + 1; + // } iDriverLoop = 0; - if (numcars > 0) // DRIVER SETUP: Configure AI driver names and human control flags + if (numcars > + 0) // DRIVER SETUP: Configure AI driver names and human control flags { pszDriverNamePtr = driver_names[0]; iDriverIndex = 0; pszDefaultNameEnd = default_names[1]; do { pszTempPointer = pszDefaultNameEnd; - human_control[iDriverIndex] = 0; // Initialize AI drivers: clear human control, set car design, copy names + human_control[iDriverIndex] = + 0; // Initialize AI drivers: clear human control, set car design, + // copy names result_design[iDriverIndex] = iDriverLoop / 2; pszSourceNamePtr = pszDriverNamePtr; pszDefaultNamePtr = default_names[iDriverLoop]; @@ -3478,13 +3702,15 @@ int load_champ(int iSlot) result_control[i] = 0; } iHumanPlayerLoop = 0; - if (players > 0) // HUMAN PLAYER SETUP: Configure human players and assign them to cars + if (players > 0) // HUMAN PLAYER SETUP: Configure human players and assign + // them to cars { iPlayerCarIndex = 0; pszPlayerNamePtr = player_names[1]; do { iPlayerCarValue = Players_Cars[iPlayerCarIndex]; - if (iPlayerCarValue < 8) // Find available car slot for human player or assign to first available AI slot + if (iPlayerCarValue < 8) // Find available car slot for human player + // or assign to first available AI slot { iCarSlotIndex = 2 * iPlayerCarValue; if (result_control[2 * iPlayerCarValue]) @@ -3513,19 +3739,22 @@ int load_champ(int iSlot) ++iHumanPlayerLoop; } while (iHumanPlayerLoop < players); } - if (numcars > 0) // CONTROL SETUP + if (numcars > 0) // CONTROL SETUP { for (int i = 0; i < numcars; i++) { result_control[i] = human_control[i]; } - //iControlArraySize = 4 * numcars; - //uiControlLoop = 0; - //do { - // uiControlLoop += 4; - // result_competing_variable_1[uiControlLoop / 4] = team_wins[uiControlLoop / 4 + 15];// offset into result_control and human_control - //} while ((int)uiControlLoop < iControlArraySize); + // iControlArraySize = 4 * numcars; + // uiControlLoop = 0; + // do { + // uiControlLoop += 4; + // result_competing_variable_1[uiControlLoop / 4] = + // team_wins[uiControlLoop / 4 + 15];// offset into result_control and + // human_control + // } while ((int)uiControlLoop < iControlArraySize); } - iCompetitorCount = competitors; // RACE ORDER SETUP: Build competitor lists and championship standings + iCompetitorCount = competitors; // RACE ORDER SETUP: Build competitor + // lists and championship standings iCompetitorCheck = competitors; if (competitors == 2) { iCompetitorCount = players; @@ -3544,37 +3773,43 @@ int load_champ(int iSlot) } iCarIndex++; } - //iOrderSearchStart = 0; - //if (iCompetitorCount > 0) { - // iCompetitorCheck = 4 * iCompetitorCount; - // uiOrderByteOffset = 0; // Find next available competitor slot (skip non-competitors) - // do { - // for (k = iOrderSearchStart; ; ++k) { - // pszTempPointer = (char *)(iOrderSearchStart + 1); - // if (!non_competitors[k]) - // break; - // ++iOrderSearchStart; - // } - // result_order[uiOrderByteOffset / 4] = iOrderSearchStart; - // champorder[uiOrderByteOffset / 4] = iOrderSearchStart; - // uiOrderByteOffset += 4; - // ++iOrderSearchStart; - // } while ((int)uiOrderByteOffset < iCompetitorCheck); - //} + // iOrderSearchStart = 0; + // if (iCompetitorCount > 0) { + // iCompetitorCheck = 4 * iCompetitorCount; + // uiOrderByteOffset = 0; // Find next available + // competitor slot (skip non-competitors) do { + // for (k = iOrderSearchStart; ; ++k) { + // pszTempPointer = (char *)(iOrderSearchStart + 1); + // if (!non_competitors[k]) + // break; + // ++iOrderSearchStart; + // } + // result_order[uiOrderByteOffset / 4] = iOrderSearchStart; + // champorder[uiOrderByteOffset / 4] = iOrderSearchStart; + // uiOrderByteOffset += 4; + // ++iOrderSearchStart; + // } while ((int)uiOrderByteOffset < iCompetitorCheck); + // } iHighestPoints = 0; racers = iCompetitorCount; iSortIndex = 0; - if (iCompetitorCount > 0) // CHAMPIONSHIP STANDINGS: Sort players by championship points (bubble sort) + if (iCompetitorCount > 0) // CHAMPIONSHIP STANDINGS: Sort players by + // championship points (bubble sort) { - // Selection sort: Sort racers by championship points (highest to lowest) - for (int iCurrentIndex = 0; iCurrentIndex < racers - 1; iCurrentIndex++) { - // Find the racer with the highest points in the remaining unsorted portion + // Selection sort: Sort racers by championship points (highest to + // lowest) + for (int iCurrentIndex = 0; iCurrentIndex < racers - 1; + iCurrentIndex++) { + // Find the racer with the highest points in the remaining unsorted + // portion int iBestIndex = iCurrentIndex; int iHighestPoints = championship_points[champorder[iCurrentIndex]]; - for (int iSearchIndex = iCurrentIndex + 1; iSearchIndex < racers; iSearchIndex++) { - if (championship_points[champorder[iSearchIndex]] > iHighestPoints) { + for (int iSearchIndex = iCurrentIndex + 1; iSearchIndex < racers; + iSearchIndex++) { + if (championship_points[champorder[iSearchIndex]] > + iHighestPoints) { iBestIndex = iSearchIndex; iHighestPoints = championship_points[champorder[iSearchIndex]]; } @@ -3588,35 +3823,40 @@ int load_champ(int iSlot) } } - //iSortCurrentIndex = 0; - //do { - // iCompetitorCheck = iSortIndex; - // iSortTotalRacers = racers; - // iSortSearchIndex = iSortIndex + 1; - // iHighestPoints = championship_points[champorder[iSortCurrentIndex]]; - // if (iSortIndex + 1 < racers) { - // iSortCompareIndex = iSortSearchIndex; - // do { - // pszTempPointer = (char *)championship_points[champorder[iSortCompareIndex]]; - // if ((int)pszTempPointer > iHighestPoints) { - // iCompetitorCheck = iSortSearchIndex; - // iHighestPoints = championship_points[champorder[iSortCompareIndex]]; - // } - // ++iSortSearchIndex; - // ++iSortCompareIndex; - // } while (iSortSearchIndex < racers); - // } - // iSwapTempValue = teamorder[++iSortCurrentIndex + 7]; - // teamorder[iSortCurrentIndex + 7] = champorder[iCompetitorCheck]; - // racers = iSortTotalRacers; - // iNextSortIndex = iSortIndex + 1; - // champorder[iCompetitorCheck] = iSwapTempValue; - // iSortIndex = iNextSortIndex; - //} while (iSortTotalRacers > iNextSortIndex); + // iSortCurrentIndex = 0; + // do { + // iCompetitorCheck = iSortIndex; + // iSortTotalRacers = racers; + // iSortSearchIndex = iSortIndex + 1; + // iHighestPoints = + // championship_points[champorder[iSortCurrentIndex]]; if (iSortIndex + // + 1 < racers) { + // iSortCompareIndex = iSortSearchIndex; + // do { + // pszTempPointer = (char + // *)championship_points[champorder[iSortCompareIndex]]; if + // ((int)pszTempPointer > iHighestPoints) { + // iCompetitorCheck = iSortSearchIndex; + // iHighestPoints = + // championship_points[champorder[iSortCompareIndex]]; + // } + // ++iSortSearchIndex; + // ++iSortCompareIndex; + // } while (iSortSearchIndex < racers); + // } + // iSwapTempValue = teamorder[++iSortCurrentIndex + 7]; + // teamorder[iSortCurrentIndex + 7] = champorder[iCompetitorCheck]; + // racers = iSortTotalRacers; + // iNextSortIndex = iSortIndex + 1; + // champorder[iCompetitorCheck] = iSwapTempValue; + // iSortIndex = iNextSortIndex; + // } while (iSortTotalRacers > iNextSortIndex); } - Race = ((uint8)TrackLoad - 1) & 7; // FINALIZATION: Set race number, enable game timer, configure network + Race = ((uint8)TrackLoad - 1) & 7; // FINALIZATION: Set race number, + // enable game timer, configure network tick_on = -1; - if (ROLLERCommsGetType()) // NETWORK RESTORATION: Reinitialize network connections if saved game used networking + if (ROLLERCommsGetType()) // NETWORK RESTORATION: Reinitialize network + // connections if saved game used networking { iHighestPoints = 0; ROLLERCommsUnInitSystem(); @@ -3638,16 +3878,16 @@ int load_champ(int iSlot) Initialise_Network(0); } } - fre((void **)&pFileBuf); // Cleanup: Free file buffer and return success/failure status + fre((void **)&pFileBuf); // Cleanup: Free file buffer and return + // success/failure status } return iChecksumOk; } //------------------------------------------------------------------------------------------------- -//0005C000 -uint8 *lod_champ_char(uint8 *pSrc, int *piValue) -{ - int iValue; // ebx +// 0005C000 +uint8 *lod_champ_char(uint8 *pSrc, int *piValue) { + int iValue; // ebx uint8 *pNextPos; // eax iValue = *pSrc; @@ -3657,117 +3897,130 @@ uint8 *lod_champ_char(uint8 *pSrc, int *piValue) } //------------------------------------------------------------------------------------------------- -//0005C020 -// MISLEADING NAME: Actually LOADS a 4-byte integer from buffer (should be named load_champ_int) -uint8 *sav_champ_char(uint8 *pSrc, int *piValue) -{ - int iValue; // ebx +// 0005C020 +// MISLEADING NAME: Actually LOADS a 4-byte integer from buffer (should be named +// load_champ_int) +uint8 *sav_champ_char(uint8 *pSrc, int *piValue) { + int iValue; // ebx uint8 *pNextPos; // eax - iValue = *(int *)pSrc; // Read 4-byte integer from buffer at current position - pNextPos = pSrc + 4; // Advance buffer pointer by 4 bytes to next data position - *piValue = iValue; // Store loaded value in output parameter - return pNextPos; // Return advanced buffer pointer for chaining reads + iValue = *(int *)pSrc; // Read 4-byte integer from buffer at current position + pNextPos = + pSrc + 4; // Advance buffer pointer by 4 bytes to next data position + *piValue = iValue; // Store loaded value in output parameter + return pNextPos; // Return advanced buffer pointer for chaining reads } //------------------------------------------------------------------------------------------------- -//0005C030 -uint8 *sav_champ_int(uint8 *pDest, int iValue) -{ - pDest[0] = (uint8)(iValue); // Byte 0: bits 0-7 - pDest[1] = (uint8)(iValue >> 8); // Byte 1: bits 8-15 - pDest[2] = (uint8)(iValue >> 16); // Byte 2: bits 16-23 - pDest[3] = (uint8)(iValue >> 24); // Byte 3: bits 24-31 +// 0005C030 +uint8 *sav_champ_int(uint8 *pDest, int iValue) { + pDest[0] = (uint8)(iValue); // Byte 0: bits 0-7 + pDest[1] = (uint8)(iValue >> 8); // Byte 1: bits 8-15 + pDest[2] = (uint8)(iValue >> 16); // Byte 2: bits 16-23 + pDest[3] = (uint8)(iValue >> 24); // Byte 3: bits 24-31 return pDest + 4; } //------------------------------------------------------------------------------------------------- -//0005C070 -void check_saves() -{ +// 0005C070 +void check_saves() { char *pszSaveSlotName; // esi - int iSlotIndex; // ecx - int iFileHandle; // edx - int iFileSize; // edi - uint8 *pbyFileData; // eax - uint8 byNetType; // al - uint8 *pbyReadBuffer; // [esp+0h] [ebp-1Ch] BYREF - - pszSaveSlotName = save_slots[0]; // Get pointer to first save slot filename - for (iSlotIndex = 0; iSlotIndex != 4; ++iSlotIndex)// Check each of the 4 save slots + int iSlotIndex; // ecx + int iFileHandle; // edx + int iFileSize; // edi + uint8 *pbyFileData; // eax + uint8 byNetType; // al + uint8 *pbyReadBuffer; // [esp+0h] [ebp-1Ch] BYREF + + pszSaveSlotName = save_slots[0]; // Get pointer to first save slot filename + for (iSlotIndex = 0; iSlotIndex != 4; + ++iSlotIndex) // Check each of the 4 save slots { iFileSize = ROLLERfilelength(pszSaveSlotName); - iFileHandle = ROLLERopen(pszSaveSlotName, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h - if (iFileHandle == -1) // Check if file open failed + iFileHandle = ROLLERopen( + pszSaveSlotName, + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h + if (iFileHandle == -1) // Check if file open failed { - save_status[iSlotIndex].iSlotUsed = 0; // Mark slot as empty if file doesn't exist + save_status[iSlotIndex].iSlotUsed = + 0; // Mark slot as empty if file doesn't exist } else { - pbyReadBuffer = (uint8 *)getbuffer(0x800u);// Allocate 2KB buffer for reading save file - //iFileSize = filelength(iFileHandle); // Get size of save file - if (iFileSize == 795) // Check if file is exactly 795 bytes (valid save file size) - read(iFileHandle, pbyReadBuffer, 795); // Read entire save file into buffer - close(iFileHandle); // Close the save file - if (iFileSize == 795) // Verify file size again before parsing + pbyReadBuffer = (uint8 *)getbuffer( + 0x800u); // Allocate 2KB buffer for reading save file + // iFileSize = filelength(iFileHandle); // Get size of save file + if (iFileSize == + 795) // Check if file is exactly 795 bytes (valid save file size) + read(iFileHandle, pbyReadBuffer, + 795); // Read entire save file into buffer + close(iFileHandle); // Close the save file + if (iFileSize == 795) // Verify file size again before parsing { pbyFileData = pbyReadBuffer; save_status[iSlotIndex].iSlotUsed = -1; // Mark slot as occupied - save_status[iSlotIndex].iPackedTrack = *pbyFileData;// Extract packed track info from offset 0 - save_status[iSlotIndex].iDifficulty = pbyReadBuffer[3];// Extract difficulty level from offset 3 - save_status[iSlotIndex].iPlayerType = pbyReadBuffer[5];// Extract player type from offset 5 - byNetType = pbyReadBuffer[51]; // Get network type from offset 51 - if (save_status[iSlotIndex].iPlayerType == 1 && byNetType)// Convert network player type based on net_type value + save_status[iSlotIndex].iPackedTrack = + *pbyFileData; // Extract packed track info from offset 0 + save_status[iSlotIndex].iDifficulty = + pbyReadBuffer[3]; // Extract difficulty level from offset 3 + save_status[iSlotIndex].iPlayerType = + pbyReadBuffer[5]; // Extract player type from offset 5 + byNetType = pbyReadBuffer[51]; // Get network type from offset 51 + if (save_status[iSlotIndex].iPlayerType == 1 && + byNetType) // Convert network player type based on net_type value { if (byNetType <= 1u) { - save_status[iSlotIndex].iPlayerType = 3;// net_type 0 or 1 = Network player (type 3) + save_status[iSlotIndex].iPlayerType = + 3; // net_type 0 or 1 = Network player (type 3) } else if (byNetType == 2) { - save_status[iSlotIndex].iPlayerType = 4;// net_type 2 = Modem player (type 4) + save_status[iSlotIndex].iPlayerType = + 4; // net_type 2 = Modem player (type 4) } } } else { - save_status[iSlotIndex].iSlotUsed = 0; // Mark slot as empty if file size is invalid + save_status[iSlotIndex].iSlotUsed = + 0; // Mark slot as empty if file size is invalid } - fre((void **)&pbyReadBuffer); // Free the read buffer + fre((void **)&pbyReadBuffer); // Free the read buffer } - pszSaveSlotName += 13; // Move to next save slot filename (13 bytes per filename) + pszSaveSlotName += + 13; // Move to next save slot filename (13 bytes per filename) } } //------------------------------------------------------------------------------------------------- -//0005C180 -void ResultRoundUp() -{ - uint8 *pbyScreenBuffer; // edi +// 0005C180 +void ResultRoundUp() { + uint8 *pbyScreenBuffer; // edi tBlockHeader *pBackgroundImage; // esi - unsigned int uiBufferSize; // ecx - char byBufferRemainder; // al - unsigned int uiDwordCopyCount; // ecx - int iCurrentYPos; // edi - double dBestTimeFloat; // st7 - int iMostKillsDriver; // esi - int iMaxKillCount; // eax - int iDriverIndex; // edx - int iCurrentDriver; // ebx - int iKillsYPos; // edi - int iP1HeaderYPos; // edi - int iPlayer1Id; // ebp - int iP1DriverId; // esi - int iP1StatsYPos; // edi - double dP1BestTime; // st7 - int iP2HeaderYPos; // edi - int iPlayer2Id; // ebp - int iP2DriverId; // esi - int iP2NameYPos; // edi - int iP2StatsYPos; // edi - double dP2BestTime; // st7 - int iOriginalScrSize; // [esp+0h] [ebp-28h] - int iP2Time1; // [esp+4h] [ebp-24h] - int iP2Time2; // [esp+4h] [ebp-24h] - int iP1Time1; // [esp+8h] [ebp-20h] - int iP1Time2; // [esp+8h] [ebp-20h] - int iLapTime1; // [esp+Ch] [ebp-1Ch] - int iLapTime2; // [esp+Ch] [ebp-1Ch] - - tick_on = 0; // Initialize race results screen display + unsigned int uiBufferSize; // ecx + char byBufferRemainder; // al + unsigned int uiDwordCopyCount; // ecx + int iCurrentYPos; // edi + double dBestTimeFloat; // st7 + int iMostKillsDriver; // esi + int iMaxKillCount; // eax + int iDriverIndex; // edx + int iCurrentDriver; // ebx + int iKillsYPos; // edi + int iP1HeaderYPos; // edi + int iPlayer1Id; // ebp + int iP1DriverId; // esi + int iP1StatsYPos; // edi + double dP1BestTime; // st7 + int iP2HeaderYPos; // edi + int iPlayer2Id; // ebp + int iP2DriverId; // esi + int iP2NameYPos; // edi + int iP2StatsYPos; // edi + double dP2BestTime; // st7 + int iOriginalScrSize; // [esp+0h] [ebp-28h] + int iP2Time1; // [esp+4h] [ebp-24h] + int iP2Time2; // [esp+4h] [ebp-24h] + int iP1Time1; // [esp+8h] [ebp-20h] + int iP1Time2; // [esp+8h] [ebp-20h] + int iLapTime1; // [esp+Ch] [ebp-1Ch] + int iLapTime2; // [esp+Ch] [ebp-1Ch] + + tick_on = 0; // Initialize race results screen display iOriginalScrSize = scr_size; SVGA_ON = -1; init_screen(); @@ -3777,29 +4030,38 @@ void ResultRoundUp() winy = 0; winh = YMAX; mirror = 0; - front_vga[2] = (tBlockHeader *)load_picture("resround.bm");// Load race results screen resources (background, fonts) + front_vga[2] = (tBlockHeader *)load_picture( + "resround.bm"); // Load race results screen resources (background, fonts) front_vga[1] = (tBlockHeader *)load_picture("font4.bm"); front_vga[0] = (tBlockHeader *)load_picture("font5.bm"); frontend_on = -1; tick_on = -1; pbyScreenBuffer = scrbuf; pBackgroundImage = front_vga[2]; - if (SVGA_ON) // Copy background image to screen buffer (optimized copy) + if (SVGA_ON) // Copy background image to screen buffer (optimized copy) uiBufferSize = 256000; else uiBufferSize = 64000; byBufferRemainder = uiBufferSize; uiDwordCopyCount = uiBufferSize >> 2; memcpy(scrbuf, front_vga[2], 4 * uiDwordCopyCount); - memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], &pBackgroundImage->iWidth + uiDwordCopyCount, byBufferRemainder & 3); - front_text(front_vga[1], &language_buffer[2560], font4_ascii, font4_offsets, 320, 8, 0x8Fu, 1u);// Display race winner information - sprintf(buffer, "%s %s", driver_names[result_order[0]], CompanyNames[result_design[result_order[0]]]); - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, 41, 0x8Fu, 1u); + memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], + &pBackgroundImage->iWidth + uiDwordCopyCount, byBufferRemainder & 3); + front_text(front_vga[1], &language_buffer[2560], font4_ascii, font4_offsets, + 320, 8, 0x8Fu, 1u); // Display race winner information + sprintf(buffer, "%s %s", driver_names[result_order[0]], + CompanyNames[result_design[result_order[0]]]); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, 41, 0x8Fu, + 1u); iCurrentYPos = 74; - if (FastestLap >= 0 && BestTime < 5000.0)// Display fastest lap information if valid + if (FastestLap >= 0 && + BestTime < 5000.0) // Display fastest lap information if valid { - front_text(front_vga[1], &language_buffer[2880], font4_ascii, font4_offsets, 320, 74, 0x8Fu, 1u); - dBestTimeFloat = BestTime * 100.0; // Convert fastest lap time to display format (MM:SS:HH) + front_text(front_vga[1], &language_buffer[2880], font4_ascii, font4_offsets, + 320, 74, 0x8Fu, 1u); + dBestTimeFloat = + BestTime * + 100.0; // Convert fastest lap time to display format (MM:SS:HH) //_CHP(); iLapTime1 = (int)dBestTimeFloat; if ((int)dBestTimeFloat > 599999) @@ -3817,12 +4079,14 @@ void ResultRoundUp() fp_buf[1] = iLapTime2 % 10 + 48; fp_buf[0] = iLapTime2 / 10 % 10 + 48; fp_buf[2] = 58; - sprintf(buffer, "%s %s %s", driver_names[FastestLap], CompanyNames[result_design[FastestLap]], (const char *)fp_buf); - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, 107, 0x8Fu, 1u); + sprintf(buffer, "%s %s %s", driver_names[FastestLap], + CompanyNames[result_design[FastestLap]], (const char *)fp_buf); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, 107, + 0x8Fu, 1u); iCurrentYPos = 140; } iMostKillsDriver = -1; - iMaxKillCount = 0; // Find driver with most kills in the race + iMaxKillCount = 0; // Find driver with most kills in the race if (racers > 0) { iDriverIndex = 0; do { @@ -3834,25 +4098,35 @@ void ResultRoundUp() ++iDriverIndex; } while (iDriverIndex < racers); } - if (iMostKillsDriver >= 0) // Display most kills information if any kills occurred + if (iMostKillsDriver >= + 0) // Display most kills information if any kills occurred { - front_text(front_vga[1], &language_buffer[4032], font4_ascii, font4_offsets, 320, iCurrentYPos, 0x8Fu, 1u); - sprintf(buffer, "%s %s %s %i", driver_names[iMostKillsDriver], CompanyNames[result_design[iMostKillsDriver]], &language_buffer[3968], result_kills[iMostKillsDriver]); + front_text(front_vga[1], &language_buffer[4032], font4_ascii, font4_offsets, + 320, iCurrentYPos, 0x8Fu, 1u); + sprintf(buffer, "%s %s %s %i", driver_names[iMostKillsDriver], + CompanyNames[result_design[iMostKillsDriver]], + &language_buffer[3968], result_kills[iMostKillsDriver]); iKillsYPos = iCurrentYPos + 33; - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, iKillsYPos, 0x8Fu, 1u); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, + iKillsYPos, 0x8Fu, 1u); iCurrentYPos = iKillsYPos + 33; } iP1HeaderYPos = iCurrentYPos + 4; - front_text(front_vga[1], &language_buffer[4672], font4_ascii, font4_offsets, 320, iP1HeaderYPos, 0x8Fu, 1u);// Display Player 1 results section + front_text(front_vga[1], &language_buffer[4672], font4_ascii, font4_offsets, + 320, iP1HeaderYPos, 0x8Fu, 1u); // Display Player 1 results section iPlayer1Id = result_p1; iP1DriverId = result_p1; - sprintf(buffer, "%s %s", driver_names[result_p1], CompanyNames[result_design[result_p1]]); + sprintf(buffer, "%s %s", driver_names[result_p1], + CompanyNames[result_design[result_p1]]); iP1HeaderYPos += 33; - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, iP1HeaderYPos, 0x8Fu, 1u); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, + iP1HeaderYPos, 0x8Fu, 1u); iP1StatsYPos = iP1HeaderYPos + 29; - if (result_lap[iP1DriverId] >= 2) // Format Player 1's best lap time or show dashes if no valid laps + if (result_lap[iP1DriverId] >= + 2) // Format Player 1's best lap time or show dashes if no valid laps { - dP1BestTime = result_best[iP1DriverId] * 100.0;// Convert P1's best time to display format (MM:SS:HH) + dP1BestTime = result_best[iP1DriverId] * + 100.0; // Convert P1's best time to display format (MM:SS:HH) //_CHP(); iP1Time1 = (int)dP1BestTime; if ((int)dP1BestTime > 599999) @@ -3874,23 +4148,34 @@ void ResultRoundUp() memcpy(fp_buf, "--:--:--", 8); } if (racers - 1 > result_p1_pos || racers == 1) - sprintf(buffer, "%s: %s", &language_buffer[1408], &language_buffer[64 * result_p1_pos + 384]); + sprintf(buffer, "%s: %s", &language_buffer[1408], + &language_buffer[64 * result_p1_pos + 384]); else sprintf(buffer, "%s: %s", &language_buffer[1408], &language_buffer[1344]); - sprintf(buffer, "%s %s %s %s %i", buffer, &language_buffer[64], (const char *)fp_buf, &language_buffer[3968], result_kills[iPlayer1Id]); - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, iP1StatsYPos, 0x8Fu, 1u); + sprintf(buffer, "%s %s %s %s %i", buffer, &language_buffer[64], + (const char *)fp_buf, &language_buffer[3968], + result_kills[iPlayer1Id]); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, + iP1StatsYPos, 0x8Fu, 1u); iP2HeaderYPos = iP1StatsYPos + 37; if (player_type == 2) { - front_text(front_vga[1], &language_buffer[4736], font4_ascii, font4_offsets, 320, iP2HeaderYPos, 0x8Fu, 1u);// Display Player 2 results section (if two-player mode) + front_text(front_vga[1], &language_buffer[4736], font4_ascii, font4_offsets, + 320, iP2HeaderYPos, 0x8Fu, + 1u); // Display Player 2 results section (if two-player mode) iPlayer2Id = result_p2; iP2DriverId = result_p2; - sprintf(buffer, "%s %s", driver_names[result_p2], CompanyNames[result_design[result_p2]]); + sprintf(buffer, "%s %s", driver_names[result_p2], + CompanyNames[result_design[result_p2]]); iP2NameYPos = iP2HeaderYPos + 33; - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, iP2NameYPos, 0x8Fu, 1u); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, + iP2NameYPos, 0x8Fu, 1u); iP2StatsYPos = iP2NameYPos + 29; - if (result_lap[iP2DriverId] >= 2) // Format Player 2's best lap time or show dashes if no valid laps + if (result_lap[iP2DriverId] >= + 2) // Format Player 2's best lap time or show dashes if no valid laps { - dP2BestTime = result_best[iP2DriverId] * 100.0;// Convert P2's best time to display format (MM:SS:HH) + dP2BestTime = + result_best[iP2DriverId] * + 100.0; // Convert P2's best time to display format (MM:SS:HH) //_CHP(); iP2Time1 = (int)dP2BestTime; if ((int)dP2BestTime > 599999) @@ -3920,19 +4205,23 @@ void ResultRoundUp() fp_buf[0] = 45; } if (racers - 1 > result_p2_pos || racers == 1) - sprintf(buffer, "%s: %s", &language_buffer[1408], &language_buffer[64 * result_p2_pos + 384]); + sprintf(buffer, "%s: %s", &language_buffer[1408], + &language_buffer[64 * result_p2_pos + 384]); else sprintf(buffer, "%s: %s", &language_buffer[1408], &language_buffer[1344]); - sprintf(buffer, "%s %s %s %s %i", buffer, &language_buffer[64], (const char *)fp_buf, &language_buffer[3968], result_kills[iPlayer2Id]); - front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, iP2StatsYPos, 0x8Fu, 1u); + sprintf(buffer, "%s %s %s %s %i", buffer, &language_buffer[64], + (const char *)fp_buf, &language_buffer[3968], + result_kills[iPlayer2Id]); + front_text(front_vga[0], buffer, font4_ascii, font5_offsets, 320, + iP2StatsYPos, 0x8Fu, 1u); } - copypic(scrbuf, screen); // Display results screen and wait for user input + copypic(scrbuf, screen); // Display results screen and wait for user input startmusic(leaderboardsong); fade_palette(32); ticks = 0; while (!fatkbhit() && ticks < 2160) UpdateSDL(); - fre((void **)&front_vga[2]); // Clean up resources and restore screen settings + fre((void **)&front_vga[2]); // Clean up resources and restore screen settings fre((void **)&front_vga[1]); fre((void **)front_vga); scr_size = iOriginalScrSize; @@ -3941,15 +4230,14 @@ void ResultRoundUp() } //------------------------------------------------------------------------------------------------- -//0005CB20 -void RollCredits() -{ - int iCurrImageIdx; // edi - int iCreditOrderIdx; // esi - int iBlockIdx; // ecx +// 0005CB20 +void RollCredits() { + int iCurrImageIdx; // edi + int iCreditOrderIdx; // esi + int iBlockIdx; // ecx tBlockHeader *pCurrImage; // ebp - int64 llBlockHeight; // rax - int i; // eax + int64 llBlockHeight; // rax + int i; // eax title_screens(); ticks = 0; @@ -3957,18 +4245,16 @@ void RollCredits() tick_on = -1; front_vga[0] = (tBlockHeader *)load_picture("credit1.bm"); front_vga[1] = (tBlockHeader *)load_picture("credit2.bm"); - while ( ticks < 108 ) + while (ticks < 108) UpdateSDL(); fade_palette(0); iCurrImageIdx = 0; iCreditOrderIdx = 0; setpal("credit1.pal"); - do - { + do { iBlockIdx = credit_order[iCreditOrderIdx]; - if ( iBlockIdx < 0 ) - { - if ( iBlockIdx == -3 ) + if (iBlockIdx < 0) { + if (iBlockIdx == -3) --iCurrImageIdx; else ++iCurrImageIdx; @@ -3977,58 +4263,57 @@ void RollCredits() memset(scrbuf, 0, 0x3E800u); pCurrImage = front_vga[iCurrImageIdx]; llBlockHeight = pCurrImage[iBlockIdx].iHeight; - display_block(scrbuf, pCurrImage, iBlockIdx, XMAX / 2 - pCurrImage[iBlockIdx].iWidth / 2, YMAX / 2 - (int)llBlockHeight / 2, -1); + display_block(scrbuf, pCurrImage, iBlockIdx, + XMAX / 2 - pCurrImage[iBlockIdx].iWidth / 2, + YMAX / 2 - (int)llBlockHeight / 2, -1); copypic(scrbuf, screen); fade_palette(32); ticks = 0; - do - { - while ( fatkbhit() ) - { + do { + while (fatkbhit()) { ticks = 74; - if ( !fatgetch() ) + if (!fatgetch()) fatgetch(); - for ( i = iCreditOrderIdx; credit_order[i] != -2; ++i ) + for (i = iCreditOrderIdx; credit_order[i] != -2; ++i) ++iCreditOrderIdx; UpdateSDL(); } UpdateSDL(); - } - while ( ticks < 72 ); - if ( credit_order[iCreditOrderIdx] != -2 ) + } while (ticks < 72); + if (credit_order[iCreditOrderIdx] != -2) ++iCreditOrderIdx; - if ( credit_order[iCreditOrderIdx] == -2 ) + if (credit_order[iCreditOrderIdx] == -2) holdmusic = 0; fade_palette(0); - } - while ( credit_order[iCreditOrderIdx] != -2 ); + } while (credit_order[iCreditOrderIdx] != -2); fre((void **)&front_vga[0]); fre((void **)&front_vga[1]); front_fade = 0; } //------------------------------------------------------------------------------------------------- -//0005CCE0 -void ChampionshipOver() -{ - signed int iPlayer1Position; // edx - int iP1SearchIndex; // eax - int iCurrentChampEntry; // ebx - signed int iPlayer2Position; // edx - int iP2SearchIndex; // eax - int iCurrentP2Entry; // ebx - uint8 *pbyScreenBuffer; // edi - char *pszTitleImageData; // esi - unsigned int uiBufferSize; // ecx - char byBufferSizeRemainder; // al +// 0005CCE0 +void ChampionshipOver() { + signed int iPlayer1Position; // edx + int iP1SearchIndex; // eax + int iCurrentChampEntry; // ebx + signed int iPlayer2Position; // edx + int iP2SearchIndex; // eax + int iCurrentP2Entry; // ebx + uint8 *pbyScreenBuffer; // edi + char *pszTitleImageData; // esi + unsigned int uiBufferSize; // ecx + char byBufferSizeRemainder; // al unsigned int uiDwordCopyCount; // ecx - int id; // [esp+0h] [ebp-20h] - signed int iBestPos; // [esp+4h] [ebp-1Ch] + int id; // [esp+0h] [ebp-20h] + signed int iBestPos; // [esp+4h] [ebp-1Ch] - iPlayer1Position = 0; // Initialize championship analysis and disable network championship mode + iPlayer1Position = 0; // Initialize championship analysis and disable network + // championship mode network_champ_on = 0; iP1SearchIndex = 0; - if (champorder[0] != result_p1) // Find Player 1's position in championship order + if (champorder[0] != + result_p1) // Find Player 1's position in championship order { do { iCurrentChampEntry = champorder[++iP1SearchIndex]; @@ -4036,7 +4321,8 @@ void ChampionshipOver() } while (iCurrentChampEntry != result_p1); } iBestPos = iPlayer1Position; - if (player_type == 2) // If two-player mode, find Player 2's position and use the better one + if (player_type == + 2) // If two-player mode, find Player 2's position and use the better one { iPlayer2Position = 0; iP2SearchIndex = 0; @@ -4046,56 +4332,68 @@ void ChampionshipOver() ++iPlayer2Position; } while (iCurrentP2Entry != result_p2); } - if (iPlayer2Position < iBestPos) // Use the better position between both players + if (iPlayer2Position < + iBestPos) // Use the better position between both players iBestPos = iPlayer2Position; } - if (!iBestPos) // If player won championship (position 0), show victory sequence + if (!iBestPos) // If player won championship (position 0), show victory + // sequence { championship_winner(); champion_race(); } - tick_on = 0; // Initialize screen for championship results display + tick_on = 0; // Initialize screen for championship results display id = scr_size; SVGA_ON = -1; init_screen(); setpal("resround.pal"); - winx = 0; // Set window to full screen and start victory music + winx = 0; // Set window to full screen and start victory music winw = XMAX; winy = 0; winh = YMAX; mirror = 0; startmusic(winsong); holdmusic = -1; - title_vga = load_picture("resround.bm"); // Load championship results screen resources + title_vga = + load_picture("resround.bm"); // Load championship results screen resources font_vga = load_picture("font4.bm"); front_vga[0] = (tBlockHeader *)load_picture("font5.bm"); frontend_on = -1; tick_on = -1; pbyScreenBuffer = scrbuf; pszTitleImageData = (char *)title_vga; - if (SVGA_ON) // Copy title background to screen buffer (optimized copy) + if (SVGA_ON) // Copy title background to screen buffer (optimized copy) uiBufferSize = 256000; else uiBufferSize = 64000; byBufferSizeRemainder = uiBufferSize; uiDwordCopyCount = uiBufferSize >> 2; memcpy(scrbuf, title_vga, 4 * uiDwordCopyCount); - memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], &pszTitleImageData[4 * uiDwordCopyCount], byBufferSizeRemainder & 3); - if (iBestPos) // Display different messages based on championship position - { // Second place - show runner-up messages + memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], + &pszTitleImageData[4 * uiDwordCopyCount], byBufferSizeRemainder & 3); + if (iBestPos) // Display different messages based on championship position + { // Second place - show runner-up messages if (iBestPos == 1) { - front_text((tBlockHeader *)font_vga, &language_buffer[4160], font4_ascii, font4_offsets, 320, 64, 0x8Fu, 1u); - front_text(front_vga[0], &language_buffer[4288], font4_ascii, font5_offsets, 320, 100, 0x8Fu, 1u); - front_text((tBlockHeader *)font_vga, &language_buffer[4352], font4_ascii, font4_offsets, 320, 140, 0x8Fu, 1u); - front_text((tBlockHeader *)font_vga, driver_names[champorder[0]], font4_ascii, font5_offsets, 320, 180, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, &language_buffer[4160], font4_ascii, + font4_offsets, 320, 64, 0x8Fu, 1u); + front_text(front_vga[0], &language_buffer[4288], font4_ascii, + font5_offsets, 320, 100, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, &language_buffer[4352], font4_ascii, + font4_offsets, 320, 140, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, driver_names[champorder[0]], + font4_ascii, font5_offsets, 320, 180, 0x8Fu, 1u); if (Race == 8) { TrackLoad = (((uint8)TrackLoad - 1) & 7) + 1; Race = 0; } } else { - front_text((tBlockHeader *)font_vga, &language_buffer[4224], font4_ascii, font4_offsets, 320, 64, 0x8Fu, 1u);// Third place or lower - show completion message - front_text((tBlockHeader *)font_vga, &language_buffer[4352], font4_ascii, font4_offsets, 320, 140, 0x8Fu, 1u); - front_text((tBlockHeader *)font_vga, driver_names[champorder[0]], font4_ascii, font4_offsets, 320, 180, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, &language_buffer[4224], font4_ascii, + font4_offsets, 320, 64, 0x8Fu, + 1u); // Third place or lower - show completion message + front_text((tBlockHeader *)font_vga, &language_buffer[4352], font4_ascii, + font4_offsets, 320, 140, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, driver_names[champorder[0]], + font4_ascii, font4_offsets, 320, 180, 0x8Fu, 1u); if (Race == 8) { TrackLoad = (((uint8)TrackLoad - 1) & 7) + 1; Race = 0; @@ -4103,164 +4401,198 @@ void ChampionshipOver() } goto LABEL_36; } - front_text((tBlockHeader *)font_vga, &language_buffer[4096], font4_ascii, font4_offsets, 320, 64, 0x8Fu, 1u);// Championship winner - display congratulations - if (Race == 8) // Handle completion rewards and progression - { // Unlock texture quality improvements for winning championship + front_text((tBlockHeader *)font_vga, &language_buffer[4096], font4_ascii, + font4_offsets, 320, 64, 0x8Fu, + 1u); // Championship winner - display congratulations + if (Race == 8) // Handle completion rewards and progression + { // Unlock texture quality improvements for winning championship if (level < 4) textures_off |= TEX_OFF_PREMIER_CUP_AVAILABLE; if (level < 2) { textures_off |= TEX_OFF_CAR_SET_AVAILABLE; - //uiTextureSettings = textures_off; - //BYTE1(uiTextureSettings) = BYTE1(textures_off) | 0x80; - //textures_off = uiTextureSettings; + // uiTextureSettings = textures_off; + // BYTE1(uiTextureSettings) = BYTE1(textures_off) | 0x80; + // textures_off = uiTextureSettings; } } - if (TrackLoad < 17 && level < 4) // Determine next level progression or reset - { // Continue in same track group at higher difficulties + if (TrackLoad < 17 && level < 4) // Determine next level progression or reset + { // Continue in same track group at higher difficulties if (level > 0) { - front_text((tBlockHeader *)font_vga, &language_buffer[4480], font4_ascii, font4_offsets, 320, 100, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, &language_buffer[4480], font4_ascii, + font4_offsets, 320, 100, 0x8Fu, 1u); goto LABEL_30; } } else { - TrackLoad = 17; // Reset to first track group and decrease difficulty if at higher levels + TrackLoad = 17; // Reset to first track group and decrease difficulty if at + // higher levels if (level > 0) { if (Race == 8) --level; - front_text((tBlockHeader *)font_vga, &language_buffer[4416], font4_ascii, font4_offsets, 320, 100, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, &language_buffer[4416], font4_ascii, + font4_offsets, 320, 100, 0x8Fu, 1u); goto LABEL_30; } } - front_text((tBlockHeader *)font_vga, &language_buffer[4544], font4_ascii, font4_offsets, 320, 100, 0x8Fu, 1u);// Ultimate completion - show mastery message + front_text((tBlockHeader *)font_vga, &language_buffer[4544], font4_ascii, + font4_offsets, 320, 100, 0x8Fu, + 1u); // Ultimate completion - show mastery message LABEL_30: - if (Race == 8) // Reset race counter after completing championship + if (Race == 8) // Reset race counter after completing championship Race = 0; LABEL_36: - copypic(scrbuf, screen); // Display results screen and wait for user input + copypic(scrbuf, screen); // Display results screen and wait for user input fade_palette(32); ticks = 0; while (!fatkbhit() && ticks < 2160) UpdateSDL(); - fre(&title_vga); // Clean up resources and show end sequence + fre(&title_vga); // Clean up resources and show end sequence fre(&font_vga); fre((void **)front_vga); scr_size = id; fade_palette(0); - EndChampSequence(); // Run championship end sequence and credits + EndChampSequence(); // Run championship end sequence and credits RollCredits(); - if (TrackLoad >= 17) // Reset track selection if at maximum + if (TrackLoad >= 17) // Reset track selection if at maximum TrackLoad = 1; } //------------------------------------------------------------------------------------------------- -//0005D180 -void EndChampSequence() -{ - int iImageIndex; // esi - int iRandomValue; // eax +// 0005D180 +void EndChampSequence() { + int iImageIndex; // esi + int iRandomValue; // eax int iRandomYPosition; // eax - ticks = 0; // Initialize championship end sequence timing and modes + ticks = 0; // Initialize championship end sequence timing and modes frontend_on = -1; tick_on = -1; - iImageIndex = 0; // Start with first championship image (index 0) - front_vga[0] = (tBlockHeader *)load_picture(round_pics[0]);// Load the first championship sequence image + iImageIndex = 0; // Start with first championship image (index 0) + front_vga[0] = (tBlockHeader *)load_picture( + round_pics[0]); // Load the first championship sequence image do { - setpal(round_pals[iImageIndex]); // Set palette for current championship image - memset(scrbuf, 0, 0x3E800u); // Clear screen buffer (320x200 = 0x3E800 bytes) - iRandomValue = ROLLERrandRaw(); // Generate random position for image display + setpal( + round_pals[iImageIndex]); // Set palette for current championship image + memset(scrbuf, 0, + 0x3E800u); // Clear screen buffer (320x200 = 0x3E800 bytes) + iRandomValue = + ROLLERrandRaw(); // Generate random position for image display iRandomYPosition = 300 * GetHighOrderRand(5, iRandomValue); - //iRandomYPosition = 300 * ((5 * iRandomValue - (__CFSHL__((5 * iRandomValue) >> 31, 15) + ((5 * iRandomValue) >> 31 << 15))) >> 15);// Calculate random Y position using complex modulo arithmetic + // iRandomYPosition = 300 * ((5 * iRandomValue - (__CFSHL__((5 * + // iRandomValue) >> 31, 15) + ((5 * iRandomValue) >> 31 << 15))) >> 15);// + // Calculate random Y position using complex modulo arithmetic display_block(scrbuf, front_vga[0], 0, iRandomYPosition / 4, 0, -1); - //display_block(scrbuf, front_vga[0], 0, (iRandomYPosition - (__CFSHL__(iRandomYPosition >> 31, 2) + 4 * (iRandomYPosition >> 31))) >> 2, 0, -1);// Display championship image at random Y position, centered horizontally - copypic(scrbuf, screen); // Copy buffer to screen and fade in + // display_block(scrbuf, front_vga[0], 0, (iRandomYPosition - + // (__CFSHL__(iRandomYPosition >> 31, 2) + 4 * (iRandomYPosition >> 31))) >> + // 2, 0, -1);// Display championship image at random Y position, centered + // horizontally + copypic(scrbuf, screen); // Copy buffer to screen and fade in fade_palette(32); - ticks = 0; // Reset timing for image display duration - if (++iImageIndex < 8) // Advance to next image if not at end of sequence + ticks = 0; // Reset timing for image display duration + if (++iImageIndex < 8) // Advance to next image if not at end of sequence { - fre((void **)front_vga); // Free current image and load next championship image + fre((void **) + front_vga); // Free current image and load next championship image front_vga[0] = (tBlockHeader *)load_picture(round_pics[iImageIndex]); } - do { // Check for user input to skip sequence + do { // Check for user input to skip sequence if (fatkbhit()) { - iImageIndex = 8; // Skip to end of sequence and set timeout on key press + iImageIndex = 8; // Skip to end of sequence and set timeout on key press if (!fatgetch()) fatgetch(); - ticks = 144; // Set timeout to 144 ticks for image display + ticks = 144; // Set timeout to 144 ticks for image display } UpdateSDL(); - } while (ticks < 144); // Wait for display timeout (144 ticks) or user input - fade_palette(0); // Fade out current image before next iteration - } while (iImageIndex < 8); // Continue sequence until all 8 championship images shown - fre((void **)front_vga); // Clean up resources and reset fade state + } while (ticks < 144); // Wait for display timeout (144 ticks) or user input + fade_palette(0); // Fade out current image before next iteration + } while (iImageIndex < + 8); // Continue sequence until all 8 championship images shown + fre((void **)front_vga); // Clean up resources and reset fade state front_fade = 0; } //------------------------------------------------------------------------------------------------- -//0005D2B0 -void network_fucked() -{ // Check if network is in error state and close if needed - int iOriginalScreenSize; // ebp - uint8 *pbyScreenBuffer; // edi - char *pszTitleImageData; // esi - unsigned int uiBufferSize; // ecx +// 0005D2B0 +void network_fucked() { // Check if network is in error state and close if + // needed + int iOriginalScreenSize; // ebp + uint8 *pbyScreenBuffer; // edi + char *pszTitleImageData; // esi + unsigned int uiBufferSize; // ecx char byBufferSizeRemainder; // al unsigned int uiDwordCopyCount; // ecx - int iInputReceived; // ebx - int iKeyCode; // eax + int iInputReceived; // ebx + int iKeyCode; // eax if (network_buggered != 666) close_network(); - tick_on = 0; // Disable game ticking - iOriginalScreenSize = scr_size; // Save original screen size for restoration later - SVGA_ON = -1; // Enable SVGA mode for error display - init_screen(); // Initialize screen for error display + tick_on = 0; // Disable game ticking + iOriginalScreenSize = + scr_size; // Save original screen size for restoration later + SVGA_ON = -1; // Enable SVGA mode for error display + init_screen(); // Initialize screen for error display setpal("resround.pal"); - winx = 0; // Set window to full screen dimensions + winx = 0; // Set window to full screen dimensions winw = XMAX; winy = 0; winh = YMAX; mirror = 0; - title_vga = load_picture("resround.bm"); // Load background image and fonts for error screen + title_vga = load_picture( + "resround.bm"); // Load background image and fonts for error screen font_vga = load_picture("font4.bm"); front_vga[0] = (tBlockHeader *)load_picture("font5.bm"); - frontend_on = -1; // Enable frontend mode and re-enable ticking + frontend_on = -1; // Enable frontend mode and re-enable ticking tick_on = -1; pbyScreenBuffer = scrbuf; pszTitleImageData = (char *)title_vga; - if (SVGA_ON) // Determine buffer size based on video mode (SVGA=256K, VGA=64K) + if (SVGA_ON) // Determine buffer size based on video mode (SVGA=256K, VGA=64K) uiBufferSize = 256000; else uiBufferSize = 64000; byBufferSizeRemainder = uiBufferSize; uiDwordCopyCount = uiBufferSize >> 2; - memcpy(scrbuf, title_vga, 4 * uiDwordCopyCount);// Copy title image to screen buffer (optimized 32-bit copy + remainder) - memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], &pszTitleImageData[4 * uiDwordCopyCount], byBufferSizeRemainder & 3); - if (network_buggered == 666) // Check if this is a data loss error (network_buggered == 666) + memcpy(scrbuf, title_vga, + 4 * uiDwordCopyCount); // Copy title image to screen buffer (optimized + // 32-bit copy + remainder) + memcpy(&pbyScreenBuffer[4 * uiDwordCopyCount], + &pszTitleImageData[4 * uiDwordCopyCount], byBufferSizeRemainder & 3); + if (network_buggered == + 666) // Check if this is a data loss error (network_buggered == 666) { - front_text((tBlockHeader *)font_vga, "ERROR", font4_ascii, font4_offsets, 320, 100, 0x8Fu, 1u);// Display data loss error messages and prompt for restart - front_text((tBlockHeader *)font_vga, "DATA LOSS", font4_ascii, font4_offsets, 320, 140, 0x8Fu, 1u); - front_text((tBlockHeader *)font_vga, "PLAY AGAIN?", font4_ascii, font4_offsets, 320, 200, 0x8Fu, 1u); - front_text((tBlockHeader *)font_vga, "YES OR NO", font4_ascii, font4_offsets, 320, 260, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, "ERROR", font4_ascii, font4_offsets, + 320, 100, 0x8Fu, + 1u); // Display data loss error messages and prompt for restart + front_text((tBlockHeader *)font_vga, "DATA LOSS", font4_ascii, + font4_offsets, 320, 140, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, "PLAY AGAIN?", font4_ascii, + font4_offsets, 320, 200, 0x8Fu, 1u); + front_text((tBlockHeader *)font_vga, "YES OR NO", font4_ascii, + font4_offsets, 320, 260, 0x8Fu, 1u); } else { - front_text((tBlockHeader *)font_vga, &language_buffer[6208], font4_ascii, font4_offsets, 320, 192, 0x8Fu, 1u);// Display general network error message from language buffer + front_text( + (tBlockHeader *)font_vga, &language_buffer[6208], font4_ascii, + font4_offsets, 320, 192, 0x8Fu, + 1u); // Display general network error message from language buffer } - copypic(scrbuf, screen); // Display the error screen and start background music + copypic(scrbuf, + screen); // Display the error screen and start background music startmusic(leaderboardsong); - fade_palette(32); // Fade in the error screen + fade_palette(32); // Fade in the error screen ticks = 0; - if (network_buggered == 666) // Handle user input based on error type + if (network_buggered == 666) // Handle user input based on error type { - iInputReceived = 0; // Data loss error: wait for Y/N input to restart network + iInputReceived = + 0; // Data loss error: wait for Y/N input to restart network do { while (fatkbhit()) { UpdateSDL(); iKeyCode = fatgetch(); - if (iKeyCode) { // Handle Y/y key: restart network + if (iKeyCode) { // Handle Y/y key: restart network if (iKeyCode == 0x79 || iKeyCode == 0x59) { iInputReceived = -1; restart_net = -1; } - if (iKeyCode == 0x6E || iKeyCode == 0x4E)// Handle N/n key: don't restart network + if (iKeyCode == 0x6E || + iKeyCode == 0x4E) // Handle N/n key: don't restart network { iInputReceived = -1; restart_net = 0; @@ -4271,17 +4603,20 @@ void network_fucked() } UpdateSDL(); } while (!iInputReceived); - } else { // General network error: wait for any key or timeout (2160 ticks) + } else { // General network error: wait for any key or timeout (2160 ticks) while (!fatkbhit() && ticks < 2160) UpdateSDL(); } - fre(&title_vga); // Clean up loaded images and restore original screen settings + fre(&title_vga); // Clean up loaded images and restore original screen + // settings fre(&font_vga); fre((void **)front_vga); scr_size = iOriginalScreenSize; - holdmusic = -1; // Hold music and fade out screen + holdmusic = -1; // Hold music and fade out screen fade_palette(0); - if (network_buggered == 666 && !restart_net)// If data loss occurred and user chose not to restart, close network + if (network_buggered == 666 && + !restart_net) // If data loss occurred and user chose not to restart, + // close network { broadcast_mode = -666; while (broadcast_mode) @@ -4291,15 +4626,14 @@ void network_fucked() } //------------------------------------------------------------------------------------------------- -//0005D560 -void no_cd() -{ - int iScrSize; // ebp - uint8 *pScrBuf; // edi - char *pTitleVga; // esi +// 0005D560 +void no_cd() { + int iScrSize; // ebp + uint8 *pScrBuf; // edi + char *pTitleVga; // esi unsigned int uiScreenTotalBytes; // ecx - char uiRemainderBytes; // al - unsigned int uiAlignedCopySize; // ecx + char uiRemainderBytes; // al + unsigned int uiAlignedCopySize; // ecx // disable timing to prepare for error screen display tick_on = 0; @@ -4339,10 +4673,12 @@ void no_cd() // Copy 4-bytes at a time then remainder memcpy(scrbuf, title_vga, 4 * uiAlignedCopySize); - memcpy(&pScrBuf[4 * uiAlignedCopySize], &pTitleVga[4 * uiAlignedCopySize], uiRemainderBytes & 3); + memcpy(&pScrBuf[4 * uiAlignedCopySize], &pTitleVga[4 * uiAlignedCopySize], + uiRemainderBytes & 3); // Display error text - front_text(font_vga, &language_buffer[6336], font4_ascii, font4_offsets, 320, 192, 0x8Fu, 1u); + front_text(font_vga, &language_buffer[6336], font4_ascii, font4_offsets, 320, + 192, 0x8Fu, 1u); // Copy to scrbuf and fade in copypic(scrbuf, screen); @@ -4351,12 +4687,12 @@ void no_cd() // Wait for user input ticks = 0; while (!fatkbhit() && ticks < 2160) - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER // Cleanup - fre((void**)&title_vga); - fre((void**)&font_vga); - fre((void**)&front_vga[0]); + fre((void **)&title_vga); + fre((void **)&font_vga); + fre((void **)&front_vga[0]); // Fade out and exit scr_size = iScrSize; @@ -4367,12 +4703,11 @@ void no_cd() } //------------------------------------------------------------------------------------------------- -//0005D6D0 -int name_cmp(char *szName1, char *szName2) -{ - int iResult; // edx +// 0005D6D0 +int name_cmp(char *szName1, char *szName2) { + int iResult; // edx int iCharIdx; // eax - char byChar; // cl + char byChar; // cl iResult = -1; iCharIdx = 0; @@ -4392,12 +4727,11 @@ int name_cmp(char *szName1, char *szName2) } //------------------------------------------------------------------------------------------------- -//0005D710 -void name_copy(char *szDest, char *szSrc) -{ - char *pSrcPos; // eax +// 0005D710 +void name_copy(char *szDest, char *szSrc) { + char *pSrcPos; // eax char *pSrcEndPos; // ebx - char byChar; // cl + char byChar; // cl pSrcPos = szSrc; pSrcEndPos = szSrc + 9; @@ -4409,18 +4743,18 @@ void name_copy(char *szDest, char *szSrc) } //------------------------------------------------------------------------------------------------- -//0005D730 -void loadtracksample(int track_number) -{ - if (track_number <= 0) track_number = 1; +// 0005D730 +void loadtracksample(int track_number) { + if (track_number <= 0) + track_number = 1; snprintf(buffer, sizeof(buffer), "TRACK%02d.RAW", track_number); loadfrontendsample(buffer); } //------------------------------------------------------------------------------------------------- -//0005D790 -void front_letter(tBlockHeader *pFont, uint8 byCharIdx, int *iX, int *iY, const char *szStr, uint8 byColorReplace) -{ +// 0005D790 +void front_letter(tBlockHeader *pFont, uint8 byCharIdx, int *iX, int *iY, + const char *szStr, uint8 byColorReplace) { // Get character from string uint8 c = szStr[byCharIdx]; @@ -4442,8 +4776,8 @@ void front_letter(tBlockHeader *pFont, uint8 byCharIdx, int *iX, int *iY, const for (int x = 0; x < pBlock->iWidth; x++) { uint8 byPixel = *pPixelData++; - if (byPixel != 0) { // Skip transparent pixels - if (byPixel == 0x8F) { // Special color replacement + if (byPixel != 0) { // Skip transparent pixels + if (byPixel == 0x8F) { // Special color replacement *pDest = byColorReplace; } else { *pDest = byPixel; @@ -4460,71 +4794,78 @@ void front_letter(tBlockHeader *pFont, uint8 byCharIdx, int *iX, int *iY, const } //------------------------------------------------------------------------------------------------- -//0005D840 -void scale_letter(tBlockHeader *pFont, uint8 byChar, int *iCursorX, int *iCursorY, char *mappingTable, char byColorReplace, int iScaleSize) -{ - int byCharIndex; // edx - int iCharWidth; // ebp - uint8 *pFontData; // edx - uint8 *pScreenPos; // edi - int iScaleFactor; // eax - int iPixelX; // ebx - uint8 byPixelColor; // cl - uint8 *pRowStart; // [esp+0h] [ebp-24h] - int iCharHeight; // [esp+Ch] [ebp-18h] +// 0005D840 +void scale_letter(tBlockHeader *pFont, uint8 byChar, int *iCursorX, + int *iCursorY, char *mappingTable, char byColorReplace, + int iScaleSize) { + int byCharIndex; // edx + int iCharWidth; // ebp + uint8 *pFontData; // edx + uint8 *pScreenPos; // edi + int iScaleFactor; // eax + int iPixelX; // ebx + uint8 byPixelColor; // cl + uint8 *pRowStart; // [esp+0h] [ebp-24h] + int iCharHeight; // [esp+Ch] [ebp-18h] uint8 *pFontRowStart; // [esp+10h] [ebp-14h] - int iPixelY; // [esp+14h] [ebp-10h] + int iPixelY; // [esp+14h] [ebp-10h] - byCharIndex = (uint8)mappingTable[byChar];// Get character index from ASCII lookup table - if (byCharIndex == 255) // Character not found (255) - advance cursor by scaled space width + byCharIndex = (uint8) + mappingTable[byChar]; // Get character index from ASCII lookup table + if (byCharIndex == + 255) // Character not found (255) - advance cursor by scaled space width { *iCursorX += (8 * iScaleSize) >> 6; } else { - iCharWidth = pFont[byCharIndex].iWidth; // Load character dimensions and font data pointer from font header + iCharWidth = + pFont[byCharIndex].iWidth; // Load character dimensions and font data + // pointer from font header iCharHeight = pFont[byCharIndex].iHeight; pFontData = (uint8 *)pFont + pFont[byCharIndex].iDataOffset; iPixelY = 0; - for (pScreenPos = &scrbuf[640 * *iCursorY + *iCursorX]; iPixelY < iCharHeight; ++iPixelY)// MAIN RENDER LOOP: Process each row of the character + for (pScreenPos = &scrbuf[640 * *iCursorY + *iCursorX]; + iPixelY < iCharHeight; + ++iPixelY) // MAIN RENDER LOOP: Process each row of the character { pRowStart = pScreenPos; pFontRowStart = pFontData; iScaleFactor = iScaleSize; iPixelX = 0; - while (iPixelX < iCharWidth) // PIXEL LOOP: Scale and render each pixel in the current row + while (iPixelX < iCharWidth) // PIXEL LOOP: Scale and render each pixel in + // the current row { byPixelColor = *pFontData; - if (*pFontData) { // Special color handling: 0x8F (-113) becomes the specified color parameter + if (*pFontData) { // Special color handling: 0x8F (-113) becomes the + // specified color parameter if (byPixelColor == 0x8F) byPixelColor = byColorReplace; *pScreenPos = byPixelColor; } iScaleFactor -= 64; ++pScreenPos; - for (; iScaleFactor <= 0; ++iPixelX) // Scaling logic: advance source pixel when scale factor reaches threshold + for (; iScaleFactor <= 0; + ++iPixelX) // Scaling logic: advance source pixel when scale factor + // reaches threshold { ++pFontData; iScaleFactor += iScaleSize; } } - pScreenPos = pRowStart + 640; // Move to next screen row (640 pixels per row) and next font data row + pScreenPos = pRowStart + 640; // Move to next screen row (640 pixels per + // row) and next font data row pFontData = &pFontRowStart[iCharWidth]; } - *iCursorX += (iScaleSize * (iCharWidth + 1)) >> 6;// Advance cursor position by scaled character width plus 1 pixel spacing + *iCursorX += (iScaleSize * (iCharWidth + 1)) >> + 6; // Advance cursor position by scaled character width plus 1 + // pixel spacing } } //------------------------------------------------------------------------------------------------- -//0005D930 -void front_text( - tBlockHeader *pFont, - const char *szText, - const uint8 *mappingTable, - int *pCharVOffsets, - int iX, - int iY, - uint8 byColorReplace, - int iAlignment) -{ +// 0005D930 +void front_text(tBlockHeader *pFont, const char *szText, + const uint8 *mappingTable, int *pCharVOffsets, int iX, int iY, + uint8 byColorReplace, int iAlignment) { int iCurrX = iX; int iCurrY = iY; const char *p = szText; @@ -4539,16 +4880,16 @@ void front_text( uint8 byMapped = mappingTable[c]; if (byMapped == 0xFF) { - iTotalWidth += 8; // Tab-like character + iTotalWidth += 8; // Tab-like character } else { // Get character width from font data tBlockHeader *pBlock = &pFont[byMapped]; - iTotalWidth += pBlock->iWidth + 1; // Width + 1px spacing + iTotalWidth += pBlock->iWidth + 1; // Width + 1px spacing } } // Apply alignment adjustment - if (iAlignment == 2) { // Right alignment + if (iAlignment == 2) { // Right alignment iCurrX -= iTotalWidth; } else if (iAlignment == 1) { // Center alignment iCurrX -= iTotalWidth / 2; @@ -4560,14 +4901,14 @@ void front_text( while (iContinue) { uint8 c = *p; - if (c == '\0') { // End of string - iContinue = -1; // Set exit flag - } else if (c == '\n') { // Newline character - // Skip to next character (no rendering) + if (c == '\0') { // End of string + iContinue = -1; // Set exit flag + } else if (c == '\n') { // Newline character + // Skip to next character (no rendering) } else { uint8 byMapped = mappingTable[c]; - if (byMapped == 0xFF) { // Special character (tab-like) + if (byMapped == 0xFF) { // Special character (tab-like) iCurrX += 8; } else { // Get vertical offset for this character @@ -4577,18 +4918,17 @@ void front_text( int iCharY = iCurrY + iVOffset; // Draw the character - front_letter( - pFont, // Font data - c, // Character to draw - &iCurrX, // Current X position (updated) - &iCharY, // Character-specific Y position - mappingTable, // Character mapping - byColorReplace // Color replacement + front_letter(pFont, // Font data + c, // Character to draw + &iCurrX, // Current X position (updated) + &iCharY, // Character-specific Y position + mappingTable, // Character mapping + byColorReplace // Color replacement ); } } - p++; // Move to next character + p++; // Move to next character // Exit loop if end flag is set if (iContinue == -1) { @@ -4598,44 +4938,36 @@ void front_text( } //------------------------------------------------------------------------------------------------- -//0005DA40 -void scale_text(tBlockHeader *pFont, - char *szText, - const char *mappingTable, - int *pCharVOffsets, - int iX, - int iY, - char byColorReplace, - unsigned int uiAlignment, - int iClipLeft, - int iClipRight) -{ - int iTextWidth; // esi - int byCurrentChar; // eax - int byCharIndex; // eax - int iTextEndX; // eax - int iAvailableWidth; // edx - char *pbyTextPtr; // eax - int iScaledWidth; // edx - int iCharIndexTemp; // esi - uint8 *pRenderPtr; // esi - int iRightBound; // [esp+0h] [ebp-34h] - char *szTextStart; // [esp+4h] [ebp-30h] - int iSavedY; // [esp+8h] [ebp-2Ch] - int iCursorY; // [esp+Ch] [ebp-28h] BYREF - int iCursorX; // [esp+10h] [ebp-24h] BYREF - int iLeftBound; // [esp+14h] [ebp-20h] - int *pCharVOffsets_1; // [esp+18h] [ebp-1Ch] +// 0005DA40 +void scale_text(tBlockHeader *pFont, char *szText, const char *mappingTable, + int *pCharVOffsets, int iX, int iY, char byColorReplace, + unsigned int uiAlignment, int iClipLeft, int iClipRight) { + int iTextWidth; // esi + int byCurrentChar; // eax + int byCharIndex; // eax + int iTextEndX; // eax + int iAvailableWidth; // edx + char *pbyTextPtr; // eax + int iScaledWidth; // edx + int iCharIndexTemp; // esi + uint8 *pRenderPtr; // esi + int iRightBound; // [esp+0h] [ebp-34h] + char *szTextStart; // [esp+4h] [ebp-30h] + int iSavedY; // [esp+8h] [ebp-2Ch] + int iCursorY; // [esp+Ch] [ebp-28h] BYREF + int iCursorX; // [esp+10h] [ebp-24h] BYREF + int iLeftBound; // [esp+14h] [ebp-20h] + int *pCharVOffsets_1; // [esp+18h] [ebp-1Ch] int iScaledSpaceWidth; // [esp+1Ch] [ebp-18h] - int iFinishedFlag; // [esp+20h] [ebp-14h] - int iScaleSize; // [esp+24h] [ebp-10h] + int iFinishedFlag; // [esp+20h] [ebp-14h] + int iScaleSize; // [esp+24h] [ebp-10h] - szTextStart = szText; // Store parameters and initialize position tracking + szTextStart = szText; // Store parameters and initialize position tracking pCharVOffsets_1 = pCharVOffsets; iCursorX = iX; iTextWidth = 0; iCursorY = iY; - while (*szText) // PASS 1: Calculate total text width in pixels for alignment + while (*szText) // PASS 1: Calculate total text width in pixels for alignment { byCurrentChar = (uint8)*szText++; byCharIndex = (uint8)mappingTable[byCurrentChar]; @@ -4644,7 +4976,7 @@ void scale_text(tBlockHeader *pFont, else iTextWidth += pFont[byCharIndex].iWidth + 1; } - if (!uiAlignment) // Apply horizontal alignment: 0=left, 1=center, 2=right + if (!uiAlignment) // Apply horizontal alignment: 0=left, 1=center, 2=right { iLeftBound = iCursorX; iTextEndX = iTextWidth + iCursorX; @@ -4662,7 +4994,9 @@ void scale_text(tBlockHeader *pFont, iLeftBound = iCursorX - iTextWidth / 2; iRightBound = iTextWidth / 2 + iCursorX; LABEL_14: - if (iClipLeft > iLeftBound || iRightBound > iClipRight)// Check if text extends beyond clipping bounds and calculate scaling factor + if (iClipLeft > iLeftBound || + iRightBound > iClipRight) // Check if text extends beyond clipping bounds + // and calculate scaling factor { if (iClipLeft <= iLeftBound) { iAvailableWidth = iClipRight - iLeftBound; @@ -4675,7 +5009,8 @@ void scale_text(tBlockHeader *pFont, } else { iScaleSize = 64; } - pbyTextPtr = szTextStart; // PASS 2: Calculate scaled text width for final positioning + pbyTextPtr = + szTextStart; // PASS 2: Calculate scaled text width for final positioning iScaledWidth = 0; while (*pbyTextPtr) { iCharIndexTemp = (uint8)mappingTable[(uint8)*pbyTextPtr++]; @@ -4684,7 +5019,8 @@ void scale_text(tBlockHeader *pFont, else iScaledWidth += (iScaleSize * (pFont[iCharIndexTemp].iWidth + 1)) >> 6; } - if (uiAlignment) // Adjust starting X position based on alignment and scaled width + if (uiAlignment) // Adjust starting X position based on alignment and scaled + // width { if (uiAlignment <= 1) { iCursorX -= iScaledWidth / 2; @@ -4692,39 +5028,39 @@ void scale_text(tBlockHeader *pFont, iCursorX -= iScaledWidth; } } - iFinishedFlag = 0; // PASS 3: Render each character with scaling and positioning + iFinishedFlag = + 0; // PASS 3: Render each character with scaling and positioning pRenderPtr = (uint8 *)szTextStart; iScaledSpaceWidth = (8 * iScaleSize) >> 6; do { - if (*pRenderPtr) { // Handle newline character (ASCII 10) - not implemented - if (*pRenderPtr != 10) { // Character not in font (index 255) - advance by scaled space width + if (*pRenderPtr) { // Handle newline character (ASCII 10) - not implemented + if (*pRenderPtr != 10) { // Character not in font (index 255) - advance by + // scaled space width if (mappingTable[*pRenderPtr] == -1) { iCursorX += iScaledSpaceWidth; } else { - iSavedY = iCursorY; // Render valid character: adjust Y position, call scale_letter, restore Y position + iSavedY = iCursorY; // Render valid character: adjust Y position, call + // scale_letter, restore Y position iCursorY += pCharVOffsets_1[(uint8)mappingTable[*pRenderPtr]]; - scale_letter(pFont, *pRenderPtr, &iCursorX, &iCursorY, (char *)mappingTable, byColorReplace, iScaleSize); + scale_letter(pFont, *pRenderPtr, &iCursorX, &iCursorY, + (char *)mappingTable, byColorReplace, iScaleSize); iCursorY = iSavedY; } } } else { - iFinishedFlag = -1; // End of string (null terminator) - set finished flag + iFinishedFlag = -1; // End of string (null terminator) - set finished flag } ++pRenderPtr; } while (!iFinishedFlag); } //------------------------------------------------------------------------------------------------- -//0005DC50 -void clear_screen(void *pDest, int iVal) -{ - memset(pDest, iVal, 256000u); -} +// 0005DC50 +void clear_screen(void *pDest, int iVal) { memset(pDest, iVal, 256000u); } //------------------------------------------------------------------------------------------------- -//0005DC60 -void display_picture(void *pDest, const void *pSrc) -{ +// 0005DC60 +void display_picture(void *pDest, const void *pSrc) { unsigned int uiSize; // ecx if (SVGA_ON) @@ -4735,19 +5071,19 @@ void display_picture(void *pDest, const void *pSrc) } //------------------------------------------------------------------------------------------------- -//0005DC90 -void display_block(uint8 *pDest, tBlockHeader *pSrc, int iBlockIdx, int iX, int iY, int iTransparentColor) -{ - int iBlockWidth; // ebp +// 0005DC90 +void display_block(uint8 *pDest, tBlockHeader *pSrc, int iBlockIdx, int iX, + int iY, int iTransparentColor) { + int iBlockWidth; // ebp int iPixelDataOffset; // edx - int iBlockHeight; // ebx - uint8 *pDestItr; // eax - uint8 *pPixelData; // esi - int iX2; // edx - int j; // ebx - uint8 byColor; // cl - int iBlockHeight2; // [esp+8h] [ebp-18h] - int i; // [esp+Ch] [ebp-14h] + int iBlockHeight; // ebx + uint8 *pDestItr; // eax + uint8 *pPixelData; // esi + int iX2; // edx + int j; // ebx + uint8 byColor; // cl + int iBlockHeight2; // [esp+8h] [ebp-18h] + int i; // [esp+Ch] [ebp-14h] iBlockWidth = pSrc[iBlockIdx].iWidth; iPixelDataOffset = iBlockIdx; @@ -4763,8 +5099,10 @@ void display_block(uint8 *pDest, tBlockHeader *pSrc, int iBlockIdx, int iX, int for (j = 0; j < iBlockWidth; ++pDestItr) { byColor = *pPixelData++; - // Skip transparent color if specified and draw pixel if within horizontal screen bounds - if ((unsigned int)iX2 < 0x280 && (iTransparentColor < 0 || byColor != iTransparentColor)) + // Skip transparent color if specified and draw pixel if within horizontal + // screen bounds + if ((unsigned int)iX2 < 0x280 && + (iTransparentColor < 0 || byColor != iTransparentColor)) *pDestItr = byColor; ++iX2; ++j; @@ -4774,18 +5112,18 @@ void display_block(uint8 *pDest, tBlockHeader *pSrc, int iBlockIdx, int iX, int } //------------------------------------------------------------------------------------------------- -//0005DD40 -uint8 *load_picture(const char *szFile) -{ - int iFileHandle; // ebx +// 0005DD40 +uint8 *load_picture(const char *szFile) { + int iFileHandle; // ebx uint32 uiFileLength; // eax - uint8 *pBuf; // ebx + uint8 *pBuf; // ebx - iFileHandle = ROLLERopen(szFile, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = ROLLERopen( + szFile, O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open texture map data file %s", szFile); - //printf("Unable to open texture map data file %s\n\n", szFile); - //doexit(); + // printf("Unable to open texture map data file %s\n\n", szFile); + // doexit(); return NULL; } close(iFileHandle); @@ -4796,71 +5134,71 @@ uint8 *load_picture(const char *szFile) } //------------------------------------------------------------------------------------------------- -//0005DDA0 -void AllocateCars() -{ - int iCarIdx; // esi +// 0005DDA0 +void AllocateCars() { + int iCarIdx; // esi char *pszNextDefaultNamePtr; // ebp - int iDriverIdx; // edi - int iAssignedCarType; // eax - char *pszDestName; // edx - char *pszSrcName; // eax - char byNameChar; // cl - int iTotalCars; // ecx - int iPlayerIdx; // edi - int iPlayersCarIdx; // ebp - int iSelectedCarType; // ebx - int iAvailableSlot; // eax - int iSlotSearchIdx; // edx - int iHumanCtrlCheck; // ecx - int iFallbackSearchIdx; // edx - int iFallbackCtrlCheck; // esi - char *szDest; // ebx - char *szPlayerNameItr; // edx - char c; // cl - int iConsolePlayerId; // edx - int iPlayerInvulFlag; // ebx - int iCarLoopBytes; // edx - int iLoopCounter; // eax - int iCompetitorMode; // eax - int iCarsBytesTotal; // edx + int iDriverIdx; // edi + int iAssignedCarType; // eax + char *pszDestName; // edx + char *pszSrcName; // eax + char byNameChar; // cl + int iTotalCars; // ecx + int iPlayerIdx; // edi + int iPlayersCarIdx; // ebp + int iSelectedCarType; // ebx + int iAvailableSlot; // eax + int iSlotSearchIdx; // edx + int iHumanCtrlCheck; // ecx + int iFallbackSearchIdx; // edx + int iFallbackCtrlCheck; // esi + char *szDest; // ebx + char *szPlayerNameItr; // edx + char c; // cl + int iConsolePlayerId; // edx + int iPlayerInvulFlag; // ebx + int iCarLoopBytes; // edx + int iLoopCounter; // eax + int iCompetitorMode; // eax + int iCarsBytesTotal; // edx unsigned int uiRandomCarIdx; // eax - int iRandResult; // eax - int iNormalizedCarSlot; // eax - //int iActiveCompetitors; // edi - //int v29; // eax - //int v30; // eax - int iEvilCarCounter; // edi - char *pszEvilNameDest; // ebp - int iEvilCarIdx; // esi - char *pszEvilNameSrc; // eax + int iRandResult; // eax + int iNormalizedCarSlot; // eax + // int iActiveCompetitors; // edi + // int v29; // eax + // int v30; // eax + int iEvilCarCounter; // edi + char *pszEvilNameDest; // ebp + int iEvilCarIdx; // esi + char *pszEvilNameSrc; // eax char *pszEvilNameCharDest; // edx - char byEvilNameChar; // cl - int iFinalCaridx; // edx - int iTotalCarsFinal; // esi - int iCarSlotIdx; // eax - char *pszNextPlayerName; // [esp+0h] [ebp-20h] - char *pszDriverName; // [esp+4h] [ebp-1Ch] - - my_number = -1; // Initialize my_number to indicate no player assigned yet - numcars = 16; // Set total cars to maximum (16) - ViewType[1] = -1; // Reset second player view - check_cars(); // Validate and initialize car data + char byEvilNameChar; // cl + int iFinalCaridx; // edx + int iTotalCarsFinal; // esi + int iCarSlotIdx; // eax + char *pszNextPlayerName; // [esp+0h] [ebp-20h] + char *pszDriverName; // [esp+4h] [ebp-1Ch] + + my_number = -1; // Initialize my_number to indicate no player assigned yet + numcars = 16; // Set total cars to maximum (16) + ViewType[1] = -1; // Reset second player view + check_cars(); // Validate and initialize car data iCarIdx = 0; if (numcars > 0) { pszNextDefaultNamePtr = default_names[1]; pszDriverName = driver_names[0]; iDriverIdx = 0; - do { // Clone mode: all cars use player 1's car type - if ((cheat_mode & 0x4000) != 0) // cheat_mode & CHEAT_MODE_CLONES + do { // Clone mode: all cars use player 1's car type + if ((cheat_mode & 0x4000) != 0) // cheat_mode & CHEAT_MODE_CLONES iAssignedCarType = Players_Cars[0]; else - iAssignedCarType = iCarIdx / 2; // Normal mode: car type based on position (pairs) + iAssignedCarType = + iCarIdx / 2; // Normal mode: car type based on position (pairs) Drivers_Car[iDriverIdx] = iAssignedCarType; pszDestName = pszDriverName; pszSrcName = default_names[iCarIdx]; do { - ++pszDestName; // Copy default driver name + ++pszDestName; // Copy default driver name byNameChar = *pszSrcName++; *(pszDestName - 1) = byNameChar; } while (pszSrcName != pszNextDefaultNamePtr); @@ -4870,8 +5208,8 @@ void AllocateCars() invulnerable[iDriverIdx] = 0; ++iDriverIdx; ++iCarIdx; - //team_wins[iDriverIdx + 15] = 0; - //RecordNames_variable_1[iDriverIdx] = 0; // offset into invulnerable + // team_wins[iDriverIdx + 15] = 0; + // RecordNames_variable_1[iDriverIdx] = 0; // offset into invulnerable pszDriverName += 9; } while (iCarIdx < iTotalCars); } @@ -4880,9 +5218,14 @@ void AllocateCars() iPlayersCarIdx = 0; pszNextPlayerName = player_names[1]; do { - iSelectedCarType = Players_Cars[iPlayersCarIdx];// Get player's selected car type - if (iPlayerIdx || (iAvailableSlot = my_number, my_number < 0)) { // For cars >= 8 or clone mode, find any available slot - if (iSelectedCarType >= 8 || (cheat_mode & 0x4000) != 0)// CHEAT_MODE_CLONES + iSelectedCarType = + Players_Cars[iPlayersCarIdx]; // Get player's selected car type + if (iPlayerIdx || + (iAvailableSlot = my_number, + my_number < + 0)) { // For cars >= 8 or clone mode, find any available slot + if (iSelectedCarType >= 8 || + (cheat_mode & 0x4000) != 0) // CHEAT_MODE_CLONES { iAvailableSlot = 0; iSlotSearchIdx = 0; @@ -4893,7 +5236,9 @@ void AllocateCars() } while (iHumanCtrlCheck); } } else { - iAvailableSlot = 2 * iSelectedCarType;// For standard cars (0-7), try preferred slot based on car type + iAvailableSlot = + 2 * iSelectedCarType; // For standard cars (0-7), try preferred + // slot based on car type if (human_control[2 * iSelectedCarType]) ++iAvailableSlot; } @@ -4912,21 +5257,26 @@ void AllocateCars() szDest = driver_names[iAvailableSlot]; szPlayerNameItr = player_names[iPlayerIdx]; do { - ++szDest; // Copy player name to driver slot + ++szDest; // Copy player name to driver slot c = *szPlayerNameItr++; *(szDest - 1) = c; } while (szPlayerNameItr != pszNextPlayerName); iConsolePlayerId = wConsoleNode; - human_control[iAvailableSlot] = manual_control[iPlayersCarIdx];// Set up control type and player mappings + human_control[iAvailableSlot] = + manual_control[iPlayersCarIdx]; // Set up control type and player + // mappings iPlayerInvulFlag = player_invul[iPlayersCarIdx]; car_to_player[iAvailableSlot] = iPlayerIdx; invulnerable[iAvailableSlot] = iPlayerInvulFlag; - if (iPlayerIdx == iConsolePlayerId) // Configure player 1 camera if this is the console player + if (iPlayerIdx == iConsolePlayerId) // Configure player 1 camera if this + // is the console player { player1_car = iAvailableSlot; ViewType[0] = iAvailableSlot; } - if (player_type == 2 && iPlayerIdx == player2_car)// Configure player 2 camera in split-screen mode + if (player_type == 2 && + iPlayerIdx == + player2_car) // Configure player 2 camera in split-screen mode { player2_car = iAvailableSlot; ViewType[1] = iAvailableSlot; @@ -4936,20 +5286,22 @@ void AllocateCars() pszNextPlayerName += 9; } while (iPlayerIdx < players); } - if (game_type != 1 || !Race) // Skip competitor setup for racing mode + if (game_type != 1 || !Race) // Skip competitor setup for racing mode { if (numcars > 0) { iCarLoopBytes = 4 * numcars; iLoopCounter = 0; do { non_competitors[iLoopCounter / 4u] = 0; - iLoopCounter += 4; // Initialize all cars as competitors by default - //TrackArrow_variable_1[iLoopCounter / 4u] = 0;// offset into non_competitors + iLoopCounter += 4; // Initialize all cars as competitors by default + // TrackArrow_variable_1[iLoopCounter / 4u] = 0;// offset into + // non_competitors } while (iLoopCounter < iCarLoopBytes); } iCompetitorMode = competitors; iCarsBytesTotal = 4 * numcars; - if ((unsigned int)competitors < 2) { // Competitor mode 1: Mark AI cars as non-competitors + if ((unsigned int)competitors < + 2) { // Competitor mode 1: Mark AI cars as non-competitors if (competitors == 1 && numcars > 0) { uiRandomCarIdx = 0; do { @@ -4958,59 +5310,65 @@ void AllocateCars() uiRandomCarIdx += 4; } while ((int)uiRandomCarIdx < iCarsBytesTotal); } - } else if ((unsigned int)competitors <= 2) { // Competitor mode 2: Mark AI cars as non-competitors + } else if ((unsigned int)competitors <= + 2) { // Competitor mode 2: Mark AI cars as non-competitors if (numcars > 0) { for (int i = 0; i < numcars; ++i) { if (!human_control[i]) non_competitors[i] = -1; } - //iCompetitorMode = 0; - //do { - // if (!*(int *)((char *)human_control + iCompetitorMode)) - // *(int *)((char *)non_competitors + iCompetitorMode) = -1; - // iCompetitorMode += 4; - //} while (iCompetitorMode < iCarsBytesTotal); + // iCompetitorMode = 0; + // do { + // if (!*(int *)((char *)human_control + iCompetitorMode)) + // *(int *)((char *)non_competitors + iCompetitorMode) = -1; + // iCompetitorMode += 4; + // } while (iCompetitorMode < iCarsBytesTotal); } - if (players == 1) // Single player mode: randomly select one AI as competitor + if (players == + 1) // Single player mode: randomly select one AI as competitor { do { - iRandResult = ROLLERrandRaw();// iCompetitorMode); - iNormalizedCarSlot = GetHighOrderRand(8, iRandResult); // Normalize to range [0, 8) + iRandResult = ROLLERrandRaw(); // iCompetitorMode); + iNormalizedCarSlot = + GetHighOrderRand(8, iRandResult); // Normalize to range [0, 8) if (iNormalizedCarSlot == 8) iNormalizedCarSlot = 7; } while (human_control[iNormalizedCarSlot]); non_competitors[iNormalizedCarSlot] = 0; - //do { - // iRandResult = rand(iCompetitorMode); // Generate random car slot until we find an AI-controlled one - // // iNormalizedCarSlot = (8 * iRandResult) / 32768; - // iNormalizedCarSlot = (8 * iRandResult - // - (__CFSHL__((8 * iRandResult) >> 31, 15) - // + ((8 * iRandResult) >> 31 << 15))) >> 15; - // if (iNormalizedCarSlot == 8) - // iNormalizedCarSlot = 7; - // iCompetitorMode = 8 * iNormalizedCarSlot; - //} while (*(int *)((char *)human_control + iCompetitorMode)); + // do { + // iRandResult = rand(iCompetitorMode); // Generate random car slot + // until we find an AI-controlled one + // // iNormalizedCarSlot = (8 * iRandResult) / 32768; + // iNormalizedCarSlot = (8 * iRandResult + // - (__CFSHL__((8 * iRandResult) >> 31, 15) + // + ((8 * iRandResult) >> 31 << 15))) >> 15; + // if (iNormalizedCarSlot == 8) + // iNormalizedCarSlot = 7; + // iCompetitorMode = 8 * iNormalizedCarSlot; + // } while (*(int *)((char *)human_control + iCompetitorMode)); //*(int *)((char *)&non_competitors[1] + iCompetitorMode) = 0; } - } else if (competitors == 8) { // Competitor mode 8: All AI cars marked as non-competitors initially + } else if (competitors == 8) { // Competitor mode 8: All AI cars marked as + // non-competitors initially if (numcars > 0) { for (int i = 0; i < numcars; ++i) { - if (!human_control[i]) - non_competitors[i] = -1; + if (!human_control[i]) + non_competitors[i] = -1; } - //iCompetitorMode = 0; - //do { - // if (!*(int *)((char *)human_control + iCompetitorMode)) - // *(int *)((char *)non_competitors + iCompetitorMode) = -1; - // iCompetitorMode += 4; - //} while (iCompetitorMode < iCarsBytesTotal); + // iCompetitorMode = 0; + // do { + // if (!*(int *)((char *)human_control + iCompetitorMode)) + // *(int *)((char *)non_competitors + iCompetitorMode) = -1; + // iCompetitorMode += 4; + // } while (iCompetitorMode < iCarsBytesTotal); } - if (players < 8) // Add random AI cars as competitors until we have 8 total + if (players < + 8) // Add random AI cars as competitors until we have 8 total { int iActiveCompetitors = players; while (1) { - int randVal = ROLLERrandRaw();// iCompetitorMode); + int randVal = ROLLERrandRaw(); // iCompetitorMode); int slot = GetHighOrderRand(8, randVal); if (slot == 8) slot = 7; @@ -5027,26 +5385,27 @@ void AllocateCars() } } } - //iActiveCompetitors = players; - //while (1) { - // v29 = rand(iCompetitorMode); - // v30 = (8 * v29 - (__CFSHL__((8 * v29) >> 31, 15) + ((8 * v29) >> 31 << 15))) >> 15; - // if (v30 == 8) - // v30 = 7; - // iCompetitorMode = 8 * v30; - // if (!*(int *)((char *)human_control + iCompetitorMode)) { - // if (*(int *)((char *)&non_competitors[1] + iCompetitorMode)) { - // ++iActiveCompetitors; - // *(int *)((char *)&non_competitors[1] + iCompetitorMode) = 0; - // if (iActiveCompetitors >= 8) - // break; - // } - // } - //} + // iActiveCompetitors = players; + // while (1) { + // v29 = rand(iCompetitorMode); + // v30 = (8 * v29 - (__CFSHL__((8 * v29) >> 31, 15) + ((8 * v29) >> 31 + // << 15))) >> 15; if (v30 == 8) + // v30 = 7; + // iCompetitorMode = 8 * v30; + // if (!*(int *)((char *)human_control + iCompetitorMode)) { + // if (*(int *)((char *)&non_competitors[1] + iCompetitorMode)) { + // ++iActiveCompetitors; + // *(int *)((char *)&non_competitors[1] + iCompetitorMode) = 0; + // if (iActiveCompetitors >= 8) + // break; + // } + // } + // } } } } - if ((cheat_mode & 0x200) != 0) // Mr. Evil cheat mode - replace AI drivers with Mr. Evil + if ((cheat_mode & 0x200) != + 0) // Mr. Evil cheat mode - replace AI drivers with Mr. Evil { iEvilCarCounter = 0; if (numcars > 0) { @@ -5056,7 +5415,8 @@ void AllocateCars() if (!human_control[iEvilCarIdx]) { pszEvilNameSrc = szMrEvil; pszEvilNameCharDest = pszEvilNameDest; - Drivers_Car[iEvilCarIdx] = 13; // Set AI car to Mr. Evil's car type (13) and copy name + Drivers_Car[iEvilCarIdx] = + 13; // Set AI car to Mr. Evil's car type (13) and copy name do { ++pszEvilNameCharDest; byEvilNameChar = *pszEvilNameSrc++; @@ -5069,11 +5429,12 @@ void AllocateCars() } while (iEvilCarCounter < numcars); } } - iFinalCaridx = 0; // Final step: Set up player-to-car mappings for human-controlled cars + iFinalCaridx = + 0; // Final step: Set up player-to-car mappings for human-controlled cars if (numcars > 0) { iTotalCarsFinal = numcars; iCarSlotIdx = 0; - do { // Map car slot back to player index for human-controlled cars + do { // Map car slot back to player index for human-controlled cars if (human_control[iCarSlotIdx]) player_to_car[car_to_player[iCarSlotIdx]] = iFinalCaridx; ++iFinalCaridx; @@ -5083,15 +5444,14 @@ void AllocateCars() } //------------------------------------------------------------------------------------------------- -//0005E1C0 -void check_cars() -{ - //int v0; // ebx +// 0005E1C0 +void check_cars() { + // int v0; // ebx int iPlayerCount; // eax - int i; // edx - int j; // eax - int iCarId; // edi - int iCarId2; // ebx + int i; // edx + int j; // eax + int iCarId; // edi + int iCarId2; // ebx memset(allocated_cars, 0, sizeof(allocated_cars)); //_STOSD(allocated_cars, 0, v0, 14u); @@ -5107,8 +5467,8 @@ void check_cars() goto LABEL_7; } if (player_type == 2) - LABEL_7: - players = iPlayerCount; + LABEL_7: + players = iPlayerCount; LABEL_8: i = 0; if (players > 0) { @@ -5122,7 +5482,8 @@ void check_cars() // Assign player index to car_to_player iCarId2 = Players_Cars[j]; - if (iCarId2 <= 7) { //added by ROLLER, ignore cheat cars, bug in original game + if (iCarId2 <= + 7) { // added by ROLLER, ignore cheat cars, bug in original game if (allocated_cars[iCarId2] == 1) car_to_player[2 * iCarId2] = i; else @@ -5136,33 +5497,32 @@ void check_cars() } //------------------------------------------------------------------------------------------------- -//0005E300 -void select_messages() -{ - uint8 *pScreenBuffer; // edi - tBlockHeader *pBlockHeader; // esi - unsigned int uiBufferSize; // ecx - char byBufferSizeByte; // al - unsigned int uiQwordCopySize; // ecx +// 0005E300 +void select_messages() { + uint8 *pScreenBuffer; // edi + tBlockHeader *pBlockHeader; // esi + unsigned int uiBufferSize; // ecx + char byBufferSizeByte; // al + unsigned int uiQwordCopySize; // ecx unsigned int uiCurrentSelection; // edi - char byTextColor; // al - int iPlayerIndex; // esi - char *pPlayerName; // edi - char byPlayerTextColor; // al - int iCursorX; // eax - unsigned int uiKeyCode; // eax - int iCharCode; // ebx - unsigned int uiExtendedKey; // eax - int j; // eax - int i; // eax - int iSendConfirmation; // [esp+4h] [ebp-1Ch] - int iMessageLength; // [esp+8h] [ebp-18h] - unsigned int uiCurrentMenu; // [esp+Ch] [ebp-14h] - unsigned int uiPreviousMenu; // [esp+Ch] [ebp-14h] - int iSelectedPlayer; // [esp+10h] [ebp-10h] - int iMenuSelection; // [esp+14h] [ebp-Ch] - int iExitFlag; // [esp+18h] [ebp-8h] - int iY; // [esp+1Ch] [ebp-4h] + char byTextColor; // al + int iPlayerIndex; // esi + char *pPlayerName; // edi + char byPlayerTextColor; // al + int iCursorX; // eax + unsigned int uiKeyCode; // eax + int iCharCode; // ebx + unsigned int uiExtendedKey; // eax + int j; // eax + int i; // eax + int iSendConfirmation; // [esp+4h] [ebp-1Ch] + int iMessageLength; // [esp+8h] [ebp-18h] + unsigned int uiCurrentMenu; // [esp+Ch] [ebp-14h] + unsigned int uiPreviousMenu; // [esp+Ch] [ebp-14h] + int iSelectedPlayer; // [esp+10h] [ebp-10h] + int iMenuSelection; // [esp+14h] [ebp-Ch] + int iExitFlag; // [esp+18h] [ebp-8h] + int iY; // [esp+1Ch] [ebp-4h] // Initialize UI state variables iExitFlag = 0; @@ -5180,7 +5540,7 @@ void select_messages() ; } MAIN_UI_LOOP: - if (!iExitFlag) // MAIN_UI_LOOP: Main display and input processing loop + if (!iExitFlag) // MAIN_UI_LOOP: Main display and input processing loop { if (iSelectedPlayer < 0 || iSelectedPlayer >= network_on) iSelectedPlayer = 0; @@ -5195,7 +5555,8 @@ void select_messages() byBufferSizeByte = uiBufferSize; uiQwordCopySize = uiBufferSize >> 2; memcpy(scrbuf, front_vga[0], 4 * uiQwordCopySize); - memcpy(&pScreenBuffer[4 * uiQwordCopySize], &pBlockHeader->iWidth + uiQwordCopySize, byBufferSizeByte & 3); + memcpy(&pScreenBuffer[4 * uiQwordCopySize], + &pBlockHeader->iWidth + uiQwordCopySize, byBufferSizeByte & 3); // Display UI elements: header, message panel, game type indicator display_block(scrbuf, front_vga[1], 3, head_x, head_y, 0); @@ -5210,326 +5571,373 @@ void select_messages() display_block(scrbuf, front_vga[6], 4, 62, 336, -1); } else { display_block(scrbuf, front_vga[6], 2, 62, 336, -1); - front_text(front_vga[2], "~", font2_ascii, font2_offsets, sel_posns[2 * uiPreviousMenu].x, sel_posns[2 * uiPreviousMenu].y, 0x8Fu, 0); + front_text(front_vga[2], "~", font2_ascii, font2_offsets, + sel_posns[2 * uiPreviousMenu].x, + sel_posns[2 * uiPreviousMenu].y, 0x8Fu, 0); } uiCurrentMenu = uiPreviousMenu + 1; } else if (iMenuSelection >= 3) { display_block(scrbuf, front_vga[6], 4, 62, 336, -1); } else { display_block(scrbuf, front_vga[6], 2, 62, 336, -1); - front_text(front_vga[2], "~", font2_ascii, font2_offsets, sel_posns[2 * iMenuSelection].x, sel_posns[2 * iMenuSelection].y, 0x8Fu, 0); + front_text(front_vga[2], "~", font2_ascii, font2_offsets, + sel_posns[2 * iMenuSelection].x, + sel_posns[2 * iMenuSelection].y, 0x8Fu, 0); } - front_text(front_vga[2], &language_buffer[7168], font2_ascii, font2_offsets, sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u); - front_text(front_vga[2], &language_buffer[7232], font2_ascii, font2_offsets, sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u); - front_text(front_vga[2], &language_buffer[7296], font2_ascii, font2_offsets, sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u); + front_text(front_vga[2], &language_buffer[7168], font2_ascii, font2_offsets, + sel_posns[0].x + 132, sel_posns[0].y + 7, 0x8Fu, 2u); + front_text(front_vga[2], &language_buffer[7232], font2_ascii, font2_offsets, + sel_posns[2].x + 132, sel_posns[2].y + 7, 0x8Fu, 2u); + front_text(front_vga[2], &language_buffer[7296], font2_ascii, font2_offsets, + sel_posns[4].x + 132, sel_posns[4].y + 7, 0x8Fu, 2u); switch (uiCurrentMenu) { - case 0u: - // Menu 0: Send to player selection screen - if (iSelectedPlayer) - sprintf(buffer, "%s", player_names[iSelectedPlayer]); - else - sprintf(buffer, "%s", &language_buffer[7360]); - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 190, 66, 143, 0, 180, 640); - scale_text(front_vga[15], send_buffer, font1_ascii, font1_offsets, 190, 110, 143, 0, 180, 640); - if (send_status > 0) - goto SHOW_SENDING_STATUS; - if (send_status) - goto SHOW_SEND_FAILED; - if (iSendConfirmation) { - uiCurrentMenu = send_status; - iSendConfirmation = send_status; - iMenuSelection = 2; - } - goto UPDATE_DISPLAY; - case 1u: - // Menu 1: Player list selection screen - scale_text(front_vga[15], &language_buffer[7424], font2_ascii, font2_offsets, 400, 60, 143, 1u, 200, 640); - if (iMenuSelection) - byTextColor = -113; - else - byTextColor = -85; - iPlayerIndex = 1; - scale_text(front_vga[15], &language_buffer[7360], font2_ascii, font2_offsets, 400, 98, byTextColor, 1u, 200, 640); - if (network_on > 1) { - pPlayerName = player_names[1]; - iY = 116; - do { - if (iPlayerIndex == iMenuSelection) - byPlayerTextColor = -85; - else - byPlayerTextColor = -113; - scale_text(front_vga[15], pPlayerName, font2_ascii, font2_offsets, 400, iY, byPlayerTextColor, 1u, 200, 640); - ++iPlayerIndex; - pPlayerName += 9; - iY += 18; - } while (iPlayerIndex < network_on); - } - goto UPDATE_DISPLAY; - case 2u: - // Menu 2: Message composition screen with cursor - scale_text(front_vga[15], &language_buffer[7488], font2_ascii, font2_offsets, 400, 60, 143, 1u, 200, 640); - if ((frames & 0xFu) < 8) { - iCursorX = stringwidth(send_buffer) + 190; - if (iCursorX <= 620) - scale_text(front_vga[15], "_", font1_ascii, font1_offsets, iCursorX, 110, 171, 0, 180, 640); + case 0u: + // Menu 0: Send to player selection screen + if (iSelectedPlayer) + sprintf(buffer, "%s", player_names[iSelectedPlayer]); + else + sprintf(buffer, "%s", &language_buffer[7360]); + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 190, 66, + 143, 0, 180, 640); + scale_text(front_vga[15], send_buffer, font1_ascii, font1_offsets, 190, + 110, 143, 0, 180, 640); + if (send_status > 0) + goto SHOW_SENDING_STATUS; + if (send_status) + goto SHOW_SEND_FAILED; + if (iSendConfirmation) { + uiCurrentMenu = send_status; + iSendConfirmation = send_status; + iMenuSelection = 2; + } + goto UPDATE_DISPLAY; + case 1u: + // Menu 1: Player list selection screen + scale_text(front_vga[15], &language_buffer[7424], font2_ascii, + font2_offsets, 400, 60, 143, 1u, 200, 640); + if (iMenuSelection) + byTextColor = -113; + else + byTextColor = -85; + iPlayerIndex = 1; + scale_text(front_vga[15], &language_buffer[7360], font2_ascii, + font2_offsets, 400, 98, byTextColor, 1u, 200, 640); + if (network_on > 1) { + pPlayerName = player_names[1]; + iY = 116; + do { + if (iPlayerIndex == iMenuSelection) + byPlayerTextColor = -85; else - scale_text(front_vga[15], "_", font1_ascii, font1_offsets, 621, 110, 171, 0, 180, 640); - } - scale_text(front_vga[15], send_buffer, font1_ascii, font1_offsets, 190, 110, 143, 0, 180, 630); - goto UPDATE_DISPLAY; - case 3u: - // Menu 3: Send confirmation screen - if (iSelectedPlayer) - sprintf(buffer, "%s", player_names[iSelectedPlayer]); + byPlayerTextColor = -113; + scale_text(front_vga[15], pPlayerName, font2_ascii, font2_offsets, + 400, iY, byPlayerTextColor, 1u, 200, 640); + ++iPlayerIndex; + pPlayerName += 9; + iY += 18; + } while (iPlayerIndex < network_on); + } + goto UPDATE_DISPLAY; + case 2u: + // Menu 2: Message composition screen with cursor + scale_text(front_vga[15], &language_buffer[7488], font2_ascii, + font2_offsets, 400, 60, 143, 1u, 200, 640); + if ((frames & 0xFu) < 8) { + iCursorX = stringwidth(send_buffer) + 190; + if (iCursorX <= 620) + scale_text(front_vga[15], "_", font1_ascii, font1_offsets, iCursorX, + 110, 171, 0, 180, 640); else - sprintf(buffer, "%s", &language_buffer[7360]); - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 190, 66, 143, 0, 180, 640); - scale_text(front_vga[15], send_buffer, font1_ascii, font1_offsets, 190, 110, 143, 0, 180, 640); - scale_text(front_vga[15], &language_buffer[7552], font2_ascii, font2_offsets, 400, 150, 143, 1u, 200, 640); - if (send_status > 0) { - SHOW_SENDING_STATUS: - scale_text(front_vga[15], &language_buffer[7616], font2_ascii, font2_offsets, 400, 180, 231, 1u, 200, 640);// SHOW_SENDING_STATUS: Display "Sending..." message - } else { - if (!send_status) { - if (iSendConfirmation) { - uiCurrentMenu = send_status; - iSendConfirmation = send_status; - iMenuSelection = 2; - } - goto UPDATE_DISPLAY; + scale_text(front_vga[15], "_", font1_ascii, font1_offsets, 621, 110, + 171, 0, 180, 640); + } + scale_text(front_vga[15], send_buffer, font1_ascii, font1_offsets, 190, + 110, 143, 0, 180, 630); + goto UPDATE_DISPLAY; + case 3u: + // Menu 3: Send confirmation screen + if (iSelectedPlayer) + sprintf(buffer, "%s", player_names[iSelectedPlayer]); + else + sprintf(buffer, "%s", &language_buffer[7360]); + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 190, 66, + 143, 0, 180, 640); + scale_text(front_vga[15], send_buffer, font1_ascii, font1_offsets, 190, + 110, 143, 0, 180, 640); + scale_text(front_vga[15], &language_buffer[7552], font2_ascii, + font2_offsets, 400, 150, 143, 1u, 200, 640); + if (send_status > 0) { + SHOW_SENDING_STATUS: + scale_text(front_vga[15], &language_buffer[7616], font2_ascii, + font2_offsets, 400, 180, 231, 1u, 200, + 640); // SHOW_SENDING_STATUS: Display "Sending..." message + } else { + if (!send_status) { + if (iSendConfirmation) { + uiCurrentMenu = send_status; + iSendConfirmation = send_status; + iMenuSelection = 2; } - SHOW_SEND_FAILED: - scale_text(front_vga[15], &language_buffer[7680], font2_ascii, font2_offsets, 400, 180, 231, 1u, 200, 640);// SHOW_SEND_FAILED: Display "Send failed" message + goto UPDATE_DISPLAY; } - --send_status; - UPDATE_DISPLAY: - show_received_mesage(); // UPDATE_DISPLAY: Show received messages and copy screen buffer - copypic(scrbuf, screen); - while (1) { - UpdateSDL(); - // Main input processing loop - if (!fatkbhit()) - goto MAIN_UI_LOOP; - uiKeyCode = fatgetch(); - iCharCode = uiKeyCode; - if (uiKeyCode < 8) { - if (uiKeyCode) - goto PROCESS_CHARACTER_INPUT; - // Handle extended keys (arrows, function keys) - uiExtendedKey = fatgetch(); - if (uiExtendedKey >= 0x48) { - if (uiExtendedKey <= 0x48) { // Up arrow key - move selection up - if (uiCurrentMenu <= 1 && iMenuSelection > 0) - --iMenuSelection; - } else if (uiExtendedKey == 80) { // Down arrow key - move selection down - if (uiCurrentMenu) { - if (uiCurrentMenu == 1 && network_on - 1 > iMenuSelection) - ++iMenuSelection; - } else if (iMenuSelection < 3) { + SHOW_SEND_FAILED: + scale_text(front_vga[15], &language_buffer[7680], font2_ascii, + font2_offsets, 400, 180, 231, 1u, 200, + 640); // SHOW_SEND_FAILED: Display "Send failed" message + } + --send_status; + UPDATE_DISPLAY: + show_received_mesage(); // UPDATE_DISPLAY: Show received messages and copy + // screen buffer + copypic(scrbuf, screen); + while (1) { + UpdateSDL(); + // Main input processing loop + if (!fatkbhit()) + goto MAIN_UI_LOOP; + uiKeyCode = fatgetch(); + iCharCode = uiKeyCode; + if (uiKeyCode < 8) { + if (uiKeyCode) + goto PROCESS_CHARACTER_INPUT; + // Handle extended keys (arrows, function keys) + uiExtendedKey = fatgetch(); + if (uiExtendedKey >= 0x48) { + if (uiExtendedKey <= 0x48) { // Up arrow key - move selection up + if (uiCurrentMenu <= 1 && iMenuSelection > 0) + --iMenuSelection; + } else if (uiExtendedKey == + 80) { // Down arrow key - move selection down + if (uiCurrentMenu) { + if (uiCurrentMenu == 1 && network_on - 1 > iMenuSelection) ++iMenuSelection; - } + } else if (iMenuSelection < 3) { + ++iMenuSelection; } } - } else if (uiKeyCode <= 8) { // Backspace key - remove character from message - if (uiCurrentMenu == 2 && iMessageLength > 0) { - send_buffer[iMessageLength--] = 0; - send_buffer[iMessageLength] = 0; - } - if (uiCurrentMenu == 3 && !iSendConfirmation) { + } + } else if (uiKeyCode <= + 8) { // Backspace key - remove character from message + if (uiCurrentMenu == 2 && iMessageLength > 0) { + send_buffer[iMessageLength--] = 0; + send_buffer[iMessageLength] = 0; + } + if (uiCurrentMenu == 3 && !iSendConfirmation) { + uiCurrentMenu = 0; + iMenuSelection = 2; + } + } else if (uiKeyCode < 0xD) { // PROCESS_CHARACTER_INPUT: Handle regular + // character input + PROCESS_CHARACTER_INPUT: + if (uiCurrentMenu == 3 && !iSendConfirmation) { + if (uiKeyCode == 121 || uiKeyCode == 89) { + iSendConfirmation = -1; + send_message_to = iSelectedPlayer; + + for (i = 0; i < 32; ++i) { + send_mes_buf[i] = send_buffer[i]; + } + // for (i = 0; i < 32; rec_mes_buf[i + 31] = round_pics[7][i + + // 12])// Fixed loop: Copy send_buffer to send_mes_buf (32 bytes) + //{ + // i += 8; + // rec_mes_buf[i + 24] = round_pics[7][i + 5];// offset into + // send_mes_buf and send_buffer rec_mes_buf[i + 25] = + // round_pics[7][i + 6]; rec_mes_buf[i + 26] = round_pics[7][i + + // 7]; rec_mes_buf[i + 27] = round_pics[7][i + 8]; rec_mes_buf[i + // + 28] = round_pics[7][i + 9]; rec_mes_buf[i + 29] = + // round_pics[7][i + 10]; rec_mes_buf[i + 30] = round_pics[7][i + // + 11]; + // } + } else { uiCurrentMenu = 0; iMenuSelection = 2; } - } else if (uiKeyCode < 0xD) { // PROCESS_CHARACTER_INPUT: Handle regular character input - PROCESS_CHARACTER_INPUT: - if (uiCurrentMenu == 3 && !iSendConfirmation) { - if (uiKeyCode == 121 || uiKeyCode == 89) { + } + if (uiCurrentMenu == 2 && + iMessageLength < + 30) { // Handle shift key combinations for special characters + if (keys[WHIP_SCANCODE_LSHIFT] || keys[WHIP_SCANCODE_RSHIFT]) { + switch (iCharCode) { + case '#': + iCharCode = 126; + break; + case '\'': + iCharCode = 64; + break; + case ',': + iCharCode = 60; + break; + case '-': + iCharCode = 95; + break; + case '.': + iCharCode = 62; + break; + case '/': + iCharCode = 63; + break; + case '0': + iCharCode = 41; + break; + case '1': + iCharCode = 33; + break; + case '2': + iCharCode = 34; + break; + case '3': + iCharCode = 156; + break; + case '4': + iCharCode = 36; + break; + case '5': + iCharCode = 37; + break; + case '6': + iCharCode = 94; + break; + case '7': + iCharCode = 38; + break; + case '8': + iCharCode = 42; + break; + case '9': + iCharCode = 40; + break; + case ';': + iCharCode = 58; + break; + case '=': + iCharCode = 43; + break; + default: + break; + } + } + if (iCharCode >= 97 && + iCharCode <= + 122) // Convert lowercase to uppercase for message input + iCharCode -= 32; + if (iCharCode != 127) { + send_buffer[iMessageLength++] = iCharCode; + send_buffer[iMessageLength] = 0; + } + } + } else if (uiKeyCode <= 0xD) { // Enter key - handle menu navigation and + // confirmations + if (uiCurrentMenu <= 3) { + switch (uiCurrentMenu) { + case 0u: + uiCurrentMenu = iMenuSelection + 1; + switch (iMenuSelection) { + case 0: + iMenuSelection = iSelectedPlayer; + break; + case 1: + iMessageLength = 0; + if (send_buffer[0]) { + while (send_buffer[++iMessageLength]) + ; + } + break; + case 2: iSendConfirmation = -1; send_message_to = iSelectedPlayer; - for (i = 0; i < 32; ++i) { - send_mes_buf[i] = send_buffer[i]; + for (j = 0; j < 32; ++j) { + send_mes_buf[j] = send_buffer[j]; } - //for (i = 0; i < 32; rec_mes_buf[i + 31] = round_pics[7][i + 12])// Fixed loop: Copy send_buffer to send_mes_buf (32 bytes) + // for (j = 0; j < 32; rec_mes_buf[j + 31] = round_pics[7][j + + // 12])// Fixed loop: Copy send_buffer to send_mes_buf (32 + // bytes) //{ - // i += 8; - // rec_mes_buf[i + 24] = round_pics[7][i + 5];// offset into send_mes_buf and send_buffer - // rec_mes_buf[i + 25] = round_pics[7][i + 6]; - // rec_mes_buf[i + 26] = round_pics[7][i + 7]; - // rec_mes_buf[i + 27] = round_pics[7][i + 8]; - // rec_mes_buf[i + 28] = round_pics[7][i + 9]; - // rec_mes_buf[i + 29] = round_pics[7][i + 10]; - // rec_mes_buf[i + 30] = round_pics[7][i + 11]; - //} - } else { + // j += 8; + // rec_mes_buf[j + 24] = round_pics[7][j + 5]; + // rec_mes_buf[j + 25] = round_pics[7][j + 6]; + // rec_mes_buf[j + 26] = round_pics[7][j + 7]; + // rec_mes_buf[j + 27] = round_pics[7][j + 8]; + // rec_mes_buf[j + 28] = round_pics[7][j + 9]; + // rec_mes_buf[j + 29] = round_pics[7][j + 10]; + // rec_mes_buf[j + 30] = round_pics[7][j + 11]; + // } uiCurrentMenu = 0; - iMenuSelection = 2; - } - } - if (uiCurrentMenu == 2 && iMessageLength < 30) { // Handle shift key combinations for special characters - if (keys[WHIP_SCANCODE_LSHIFT] || keys[WHIP_SCANCODE_RSHIFT]) { - switch (iCharCode) { - case '#': - iCharCode = 126; - break; - case '\'': - iCharCode = 64; - break; - case ',': - iCharCode = 60; - break; - case '-': - iCharCode = 95; - break; - case '.': - iCharCode = 62; - break; - case '/': - iCharCode = 63; - break; - case '0': - iCharCode = 41; - break; - case '1': - iCharCode = 33; - break; - case '2': - iCharCode = 34; - break; - case '3': - iCharCode = 156; - break; - case '4': - iCharCode = 36; - break; - case '5': - iCharCode = 37; - break; - case '6': - iCharCode = 94; - break; - case '7': - iCharCode = 38; - break; - case '8': - iCharCode = 42; - break; - case '9': - iCharCode = 40; - break; - case ';': - iCharCode = 58; - break; - case '=': - iCharCode = 43; - break; - default: - break; - } - } - if (iCharCode >= 97 && iCharCode <= 122)// Convert lowercase to uppercase for message input - iCharCode -= 32; - if (iCharCode != 127) { - send_buffer[iMessageLength++] = iCharCode; - send_buffer[iMessageLength] = 0; - } - } - } else if (uiKeyCode <= 0xD) { // Enter key - handle menu navigation and confirmations - if (uiCurrentMenu <= 3) { - switch (uiCurrentMenu) { - case 0u: - uiCurrentMenu = iMenuSelection + 1; - switch (iMenuSelection) { - case 0: - iMenuSelection = iSelectedPlayer; - break; - case 1: - iMessageLength = 0; - if (send_buffer[0]) { - while (send_buffer[++iMessageLength]) - ; - } - break; - case 2: - iSendConfirmation = -1; - send_message_to = iSelectedPlayer; - - - for (j = 0; j < 32; ++j) { - send_mes_buf[j] = send_buffer[j]; - } - //for (j = 0; j < 32; rec_mes_buf[j + 31] = round_pics[7][j + 12])// Fixed loop: Copy send_buffer to send_mes_buf (32 bytes) - //{ - // j += 8; - // rec_mes_buf[j + 24] = round_pics[7][j + 5]; - // rec_mes_buf[j + 25] = round_pics[7][j + 6]; - // rec_mes_buf[j + 26] = round_pics[7][j + 7]; - // rec_mes_buf[j + 27] = round_pics[7][j + 8]; - // rec_mes_buf[j + 28] = round_pics[7][j + 9]; - // rec_mes_buf[j + 29] = round_pics[7][j + 10]; - // rec_mes_buf[j + 30] = round_pics[7][j + 11]; - //} - uiCurrentMenu = 0; - break; - case 3: - goto EXIT_FUNCTION; - default: - continue; - } - break; - case 1u: - uiCurrentMenu = 0; - iSelectedPlayer = iMenuSelection; - iMenuSelection = 0; - break; - default: - continue; + break; + case 3: + goto EXIT_FUNCTION; + default: + continue; } - } - } else { - if (uiKeyCode != 27) - goto PROCESS_CHARACTER_INPUT; - if (uiCurrentMenu) // Escape key - go back or exit + break; + case 1u: uiCurrentMenu = 0; - else - EXIT_FUNCTION: - iExitFlag = -1; // EXIT_FUNCTION: Set exit flag and return from function + iSelectedPlayer = iMenuSelection; + iMenuSelection = 0; + break; + default: + continue; + } } + } else { + if (uiKeyCode != 27) + goto PROCESS_CHARACTER_INPUT; + if (uiCurrentMenu) // Escape key - go back or exit + uiCurrentMenu = 0; + else + EXIT_FUNCTION: + iExitFlag = + -1; // EXIT_FUNCTION: Set exit flag and return from function } - default: - goto UPDATE_DISPLAY; // Main menu state machine - handle different UI screens + } + default: + goto UPDATE_DISPLAY; // Main menu state machine - handle different UI + // screens } } } //------------------------------------------------------------------------------------------------- -//0005EDE0 -void show_received_mesage() -{ // Check if there's a message to display and screen is not fading - int iRecMesWidth; // ebx - int iBufStrWidth; // eax - int iWindowLeft; // ecx - int iWindowRight; // edx - int iAdjustedLeft; // ecx +// 0005EDE0 +void show_received_mesage() { // Check if there's a message to display and + // screen is not fading + int iRecMesWidth; // ebx + int iBufStrWidth; // eax + int iWindowLeft; // ecx + int iWindowRight; // edx + int iAdjustedLeft; // ecx if (rec_status > 0 && front_fade) { - sprintf(buffer, "%s %s", &language_buffer[7744], rec_mes_name);// Format message header with sender name - iRecMesWidth = stringwidth(rec_mes_buf); // Calculate width of the actual message text - iBufStrWidth = stringwidth(buffer); // Calculate width of the header (sender info) - if (iBufStrWidth > iRecMesWidth) // Use the wider of the two strings for window width + sprintf(buffer, "%s %s", &language_buffer[7744], + rec_mes_name); // Format message header with sender name + iRecMesWidth = + stringwidth(rec_mes_buf); // Calculate width of the actual message text + iBufStrWidth = + stringwidth(buffer); // Calculate width of the header (sender info) + if (iBufStrWidth > + iRecMesWidth) // Use the wider of the two strings for window width iRecMesWidth = iBufStrWidth; - iWindowLeft = 400 - iRecMesWidth / 2; // Calculate left edge of window (center at x=400) - if (iWindowLeft < 180) // Ensure window doesn't go too far left (min x=180) + iWindowLeft = + 400 - + iRecMesWidth / 2; // Calculate left edge of window (center at x=400) + if (iWindowLeft < 180) // Ensure window doesn't go too far left (min x=180) iWindowLeft = 180; - iWindowRight = iRecMesWidth / 2 + 408; // Calculate right edge of window + iWindowRight = iRecMesWidth / 2 + 408; // Calculate right edge of window iAdjustedLeft = iWindowLeft - 8; - if (iWindowRight > 639) // Ensure window doesn't go past screen edge (max x=639) + if (iWindowRight > + 639) // Ensure window doesn't go past screen edge (max x=639) iWindowRight = 639; - blankwindow(iAdjustedLeft / 2, 86, iWindowRight / 2, 118);// Draw message window background (coordinates are halved for some reason) - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 400, 180, 143, 1u, 180, 640);// Draw sender info text at y=180 - scale_text(front_vga[15], rec_mes_buf, font1_ascii, font1_offsets, 400, 210, 143, 1u, 180, 640);// Draw message text at y=210 - copypic(scrbuf, screen); // Copy rendered screen buffer to display - rec_status = 0; // Clear message received flag - frames = 0; // Reset frame counter for message display duration + blankwindow(iAdjustedLeft / 2, 86, iWindowRight / 2, + 118); // Draw message window background (coordinates are halved + // for some reason) + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 400, 180, 143, + 1u, 180, 640); // Draw sender info text at y=180 + scale_text(front_vga[15], rec_mes_buf, font1_ascii, font1_offsets, 400, 210, + 143, 1u, 180, 640); // Draw message text at y=210 + copypic(scrbuf, screen); // Copy rendered screen buffer to display + rec_status = 0; // Clear message received flag + frames = 0; // Reset frame counter for message display duration do { if (time_to_start) break; @@ -5537,8 +5945,9 @@ void show_received_mesage() if (!fatgetch()) fatgetch(); } - } while (frames < 72); // Show message for at least 72 frames - if (frames >= 72 && !time_to_start) // After 72 frames, wait for any key press to dismiss + } while (frames < 72); // Show message for at least 72 frames + if (frames >= 72 && + !time_to_start) // After 72 frames, wait for any key press to dismiss { while (!fatkbhit() && !time_to_start) ; @@ -5547,83 +5956,86 @@ void show_received_mesage() fatgetch(); } } - frames = 0; // Reset frame counter when done + frames = 0; // Reset frame counter when done } } //------------------------------------------------------------------------------------------------- -//0005EFB0 -int select_netslot() -{ +// 0005EFB0 +int select_netslot() { int iSlot1PlayerCount; // ebx - int iStringIndex; // esi - int iCurrentSlot; // ebp - int iDigitIndex; // edx - int i; // eax - //char byDigitChar; // bl - int iSlotCounter; // edx - int iSlotIndex; // eax - uint8 *pScreenBuffer; // edi - tBlockHeader *pBlockHeader; // esi - unsigned int uiBufferSize; // ecx - char byBufferSizeByte; // al + int iStringIndex; // esi + int iCurrentSlot; // ebp + int iDigitIndex; // edx + int i; // eax + // char byDigitChar; // bl + int iSlotCounter; // edx + int iSlotIndex; // eax + uint8 *pScreenBuffer; // edi + tBlockHeader *pBlockHeader; // esi + unsigned int uiBufferSize; // ecx + char byBufferSizeByte; // al unsigned int uiQwordCopySize; // ecx - char *pSlot1Names; // esi - int iSlot1YPos; // edi - int iSlot2PlayerIndex; // edi - char *pSlot2Names; // esi - char *pSlot3Names; // esi - int iSlot3YPos; // edi - int iSlot4PlayerIndex; // edi - char *pSlot4Names; // esi - unsigned int uiKeyCode; // eax - int iNextSlot; // ebx - unsigned int uiExtendedKey; // eax - int iPrevSlot; // edx - int iLeftSearchSlot; // eax - int iRightSearchSlot; // edx - int iRightSearchIndex; // eax - int textColor[4]; // [esp+0h] [ebp-4Ch] - char szSlotNumberBuffer[12]; // [esp+10h] [ebp-3Ch] - int iY; // [esp+1Ch] [ebp-30h] - int iReturnValue; // [esp+20h] [ebp-2Ch] - int iExitFlag; // [esp+24h] [ebp-28h] - int iSlot4YPos; // [esp+28h] [ebp-24h] - int iSlot3PlayerIndex; // [esp+2Ch] [ebp-20h] - int iSlot1PlayerIndex; // [esp+30h] [ebp-1Ch] - - iExitFlag = 0; // Initialize network slot selection variables + char *pSlot1Names; // esi + int iSlot1YPos; // edi + int iSlot2PlayerIndex; // edi + char *pSlot2Names; // esi + char *pSlot3Names; // esi + int iSlot3YPos; // edi + int iSlot4PlayerIndex; // edi + char *pSlot4Names; // esi + unsigned int uiKeyCode; // eax + int iNextSlot; // ebx + unsigned int uiExtendedKey; // eax + int iPrevSlot; // edx + int iLeftSearchSlot; // eax + int iRightSearchSlot; // edx + int iRightSearchIndex; // eax + int textColor[4]; // [esp+0h] [ebp-4Ch] + char szSlotNumberBuffer[12]; // [esp+10h] [ebp-3Ch] + int iY; // [esp+1Ch] [ebp-30h] + int iReturnValue; // [esp+20h] [ebp-2Ch] + int iExitFlag; // [esp+24h] [ebp-28h] + int iSlot4YPos; // [esp+28h] [ebp-24h] + int iSlot3PlayerIndex; // [esp+2Ch] [ebp-20h] + int iSlot1PlayerIndex; // [esp+30h] [ebp-1Ch] + + iExitFlag = 0; // Initialize network slot selection variables network_slot = -1; iReturnValue = -1; - Initialise_Network(-1); // Initialize network with slot -1 (discovery mode) + Initialise_Network(-1); // Initialize network with slot -1 (discovery mode) if (network_on) { iReturnValue = 0; iSlot1PlayerCount = 0; iStringIndex = 7; iCurrentSlot = 0; - szSlotNumberBuffer[8] = 0; // Setup slot number string conversion and text colors + szSlotNumberBuffer[8] = + 0; // Setup slot number string conversion and text colors textColor[1] = 0x83; textColor[2] = 0x83; textColor[3] = 0x83; textColor[0] = 0xAB; do { - szSlotNumberBuffer[iStringIndex--] = iSlot1PlayerCount % 10 + '0';// Convert slot number to ASCII digits (reverse order) + szSlotNumberBuffer[iStringIndex--] = + iSlot1PlayerCount % 10 + + '0'; // Convert slot number to ASCII digits (reverse order) iSlot1PlayerCount /= 10; } while (iSlot1PlayerCount > 0); // Copy digits from conversion area to display area of buffer iDigitIndex = 0; for (i = iStringIndex + 1; i < 8; ++i) { - szSlotNumberBuffer[iDigitIndex + 3] = szSlotNumberBuffer[i]; - ++iDigitIndex; + szSlotNumberBuffer[iDigitIndex + 3] = szSlotNumberBuffer[i]; + ++iDigitIndex; } - //for (i = iStringIndex + 1; i < 8; *((_BYTE *)&textColor[3] + iDigitIndex + 3) = byDigitChar)// Copy converted digits to buffer in correct order + // for (i = iStringIndex + 1; i < 8; *((_BYTE *)&textColor[3] + iDigitIndex + // + 3) = byDigitChar)// Copy converted digits to buffer in correct order //{ - // ++iDigitIndex; - // byDigitChar = szSlotNumberBuffer[i++]; - //} // - // - while (1) // MAIN_DISPLAY_LOOP: Main UI display and input loop + // ++iDigitIndex; + // byDigitChar = szSlotNumberBuffer[i++]; + // } // + // + while (1) // MAIN_DISPLAY_LOOP: Main UI display and input loop { UpdateSDL(); if (iExitFlag) @@ -5653,7 +6065,8 @@ int select_netslot() byBufferSizeByte = uiBufferSize; uiQwordCopySize = uiBufferSize >> 2; memcpy(scrbuf, front_vga[0], 4 * uiQwordCopySize); - memcpy(&pScreenBuffer[4 * uiQwordCopySize], &pBlockHeader->iWidth + uiQwordCopySize, byBufferSizeByte & 3); + memcpy(&pScreenBuffer[4 * uiQwordCopySize], + &pBlockHeader->iWidth + uiQwordCopySize, byBufferSizeByte & 3); // Display UI elements: header, panels, game type display_block(scrbuf, front_vga[1], 3, head_x, head_y, 0); @@ -5662,22 +6075,30 @@ int select_netslot() display_block(scrbuf, front_vga[5], game_type + 5, 135, 247, 0); display_block(scrbuf, front_vga[4], 4, 76, 257, -1); display_block(scrbuf, front_vga[6], 4, 62, 336, -1); - scale_text(front_vga[15], &language_buffer[6528], font1_ascii, font1_offsets, 400, 55, 143, 1u, 200, 640);// Display slot selection instructions - scale_text(front_vga[15], &language_buffer[6592], font1_ascii, font1_offsets, 400, 73, 143, 1u, 200, 640); - sprintf(buffer, "%s1", &language_buffer[7808]);// Display Slot 1 header and status - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 260, 92, textColor[0], 1u, 200, 320); + scale_text(front_vga[15], &language_buffer[6528], font1_ascii, + font1_offsets, 400, 55, 143, 1u, 200, + 640); // Display slot selection instructions + scale_text(front_vga[15], &language_buffer[6592], font1_ascii, + font1_offsets, 400, 73, 143, 1u, 200, 640); + sprintf(buffer, "%s1", + &language_buffer[7808]); // Display Slot 1 header and status + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 260, 92, + textColor[0], 1u, 200, 320); if (gamers_playing[0] < 0) { if (gamers_playing[0] == -2) { - scale_text(front_vga[15], &language_buffer[8000], font1_ascii, font1_offsets, 260, 200, textColor[0], 1u, 200, 319); + scale_text(front_vga[15], &language_buffer[8000], font1_ascii, + font1_offsets, 260, 200, textColor[0], 1u, 200, 319); goto SLOT2_DISPLAY; } } else { if (gamers_playing[0] <= 0) { - scale_text(front_vga[15], &language_buffer[7872], font1_ascii, font1_offsets, 260, 200, textColor[0], 1u, 200, 319); + scale_text(front_vga[15], &language_buffer[7872], font1_ascii, + font1_offsets, 260, 200, textColor[0], 1u, 200, 319); goto SLOT2_DISPLAY; } if (gamers_playing[0] == 16) { - scale_text(front_vga[15], &language_buffer[7936], font1_ascii, font1_offsets, 260, 200, textColor[0], 1u, 200, 319); + scale_text(front_vga[15], &language_buffer[7936], font1_ascii, + font1_offsets, 260, 200, textColor[0], 1u, 200, 319); goto SLOT2_DISPLAY; } } @@ -5688,28 +6109,33 @@ int select_netslot() pSlot1Names = gamers_names[0]; iSlot1YPos = 110; do { - scale_text(front_vga[15], pSlot1Names, font1_ascii, font1_offsets, 260, iSlot1YPos, textColor[0], 1u, 200, 319); + scale_text(front_vga[15], pSlot1Names, font1_ascii, font1_offsets, + 260, iSlot1YPos, textColor[0], 1u, 200, 319); pSlot1Names += 9; iSlot1YPos += 18; ++iSlot1PlayerIndex; } while (iSlot1PlayerIndex < gamers_playing[0]); } SLOT2_DISPLAY: - // SLOT2_DISPLAY: Display Slot 2 header and status + // SLOT2_DISPLAY: Display Slot 2 header and status sprintf(buffer, "%s2", &language_buffer[7808]); - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 370, 92, textColor[1], 1u, 200, 640); + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 370, 92, + textColor[1], 1u, 200, 640); if (gamers_playing[1] < 0) { if (gamers_playing[1] == -2) { - scale_text(front_vga[15], &language_buffer[8000], font1_ascii, font1_offsets, 370, 200, textColor[1], 1u, 321, 419); + scale_text(front_vga[15], &language_buffer[8000], font1_ascii, + font1_offsets, 370, 200, textColor[1], 1u, 321, 419); goto SLOT3_DISPLAY; } } else { if (gamers_playing[1] <= 0) { - scale_text(front_vga[15], &language_buffer[7872], font1_ascii, font1_offsets, 370, 200, textColor[1], 1u, 321, 419); + scale_text(front_vga[15], &language_buffer[7872], font1_ascii, + font1_offsets, 370, 200, textColor[1], 1u, 321, 419); goto SLOT3_DISPLAY; } if (gamers_playing[1] == 16) { - scale_text(front_vga[15], &language_buffer[7936], font1_ascii, font1_offsets, 370, 200, textColor[1], 1u, 321, 419); + scale_text(front_vga[15], &language_buffer[7936], font1_ascii, + font1_offsets, 370, 200, textColor[1], 1u, 321, 419); goto SLOT3_DISPLAY; } } @@ -5720,28 +6146,33 @@ int select_netslot() pSlot2Names = gamers_names[1]; iY = 110; do { - scale_text(front_vga[15], pSlot2Names, font1_ascii, font1_offsets, 370, iY, textColor[1], 1u, 321, 419); + scale_text(front_vga[15], pSlot2Names, font1_ascii, font1_offsets, + 370, iY, textColor[1], 1u, 321, 419); ++iSlot2PlayerIndex; pSlot2Names += 9; iY += 18; } while (iSlot2PlayerIndex < gamers_playing[1]); } SLOT3_DISPLAY: - // SLOT3_DISPLAY: Display Slot 3 header and status + // SLOT3_DISPLAY: Display Slot 3 header and status sprintf(buffer, "%s3", &language_buffer[7808]); - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 474, 92, textColor[2], 1u, 200, 640); + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 474, 92, + textColor[2], 1u, 200, 640); if (gamers_playing[2] < 0) { if (gamers_playing[2] == -2) { - scale_text(front_vga[15], &language_buffer[8000], font1_ascii, font1_offsets, 474, 200, textColor[2], 1u, 421, 519); + scale_text(front_vga[15], &language_buffer[8000], font1_ascii, + font1_offsets, 474, 200, textColor[2], 1u, 421, 519); goto SLOT4_DISPLAY; } } else { if (gamers_playing[2] <= 0) { - scale_text(front_vga[15], &language_buffer[7872], font1_ascii, font1_offsets, 474, 200, textColor[2], 1u, 421, 519); + scale_text(front_vga[15], &language_buffer[7872], font1_ascii, + font1_offsets, 474, 200, textColor[2], 1u, 421, 519); goto SLOT4_DISPLAY; } if (gamers_playing[2] == 16) { - scale_text(front_vga[15], &language_buffer[7936], font1_ascii, font1_offsets, 474, 200, textColor[2], 1u, 421, 519); + scale_text(front_vga[15], &language_buffer[7936], font1_ascii, + font1_offsets, 474, 200, textColor[2], 1u, 421, 519); goto SLOT4_DISPLAY; } } @@ -5752,28 +6183,33 @@ int select_netslot() pSlot3Names = gamers_names[2]; iSlot3YPos = 110; do { - scale_text(front_vga[15], pSlot3Names, font1_ascii, font1_offsets, 474, iSlot3YPos, textColor[2], 1u, 421, 519); + scale_text(front_vga[15], pSlot3Names, font1_ascii, font1_offsets, + 474, iSlot3YPos, textColor[2], 1u, 421, 519); pSlot3Names += 9; iSlot3YPos += 18; ++iSlot3PlayerIndex; } while (iSlot3PlayerIndex < gamers_playing[2]); } SLOT4_DISPLAY: - // SLOT4_DISPLAY: Display Slot 4 header and status + // SLOT4_DISPLAY: Display Slot 4 header and status sprintf(buffer, "%s4", &language_buffer[7808]); - scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 580, 92, textColor[3], 1u, 520, 640); + scale_text(front_vga[15], buffer, font1_ascii, font1_offsets, 580, 92, + textColor[3], 1u, 520, 640); if (gamers_playing[3] < 0) { if (gamers_playing[3] == -2) { - scale_text(front_vga[15], &language_buffer[8000], font1_ascii, font1_offsets, 580, 200, textColor[3], 1u, 521, 639); + scale_text(front_vga[15], &language_buffer[8000], font1_ascii, + font1_offsets, 580, 200, textColor[3], 1u, 521, 639); goto UPDATE_DISPLAY; } } else { if (gamers_playing[3] <= 0) { - scale_text(front_vga[15], &language_buffer[7872], font1_ascii, font1_offsets, 580, 200, textColor[3], 1u, 521, 639); + scale_text(front_vga[15], &language_buffer[7872], font1_ascii, + font1_offsets, 580, 200, textColor[3], 1u, 521, 639); goto UPDATE_DISPLAY; } if (gamers_playing[3] == 16) { - scale_text(front_vga[15], &language_buffer[7936], font1_ascii, font1_offsets, 580, 200, textColor[3], 1u, 521, 639); + scale_text(front_vga[15], &language_buffer[7936], font1_ascii, + font1_offsets, 580, 200, textColor[3], 1u, 521, 639); goto UPDATE_DISPLAY; } } @@ -5784,14 +6220,15 @@ int select_netslot() pSlot4Names = gamers_names[3]; iSlot4YPos = 110; do { - scale_text(front_vga[15], pSlot4Names, font1_ascii, font1_offsets, 580, iSlot4YPos, textColor[3], 1u, 521, 639); + scale_text(front_vga[15], pSlot4Names, font1_ascii, font1_offsets, + 580, iSlot4YPos, textColor[3], 1u, 521, 639); ++iSlot4PlayerIndex; pSlot4Names += 9; iSlot4YPos += 18; } while (iSlot4PlayerIndex < gamers_playing[3]); } UPDATE_DISPLAY: - // UPDATE_DISPLAY: Show received messages and update screen + // UPDATE_DISPLAY: Show received messages and update screen show_received_mesage(); copypic(scrbuf, screen); @@ -5799,11 +6236,13 @@ int select_netslot() while (fatkbhit()) { uiKeyCode = fatgetch(); iNextSlot = iCurrentSlot + 1; - if (uiKeyCode < 0xD) { // Handle extended keys (arrows) + if (uiKeyCode < 0xD) { // Handle extended keys (arrows) if (!uiKeyCode) { uiExtendedKey = fatgetch(); if (uiExtendedKey >= WHIP_SCANCODE_LEFT) { - if (uiExtendedKey <= WHIP_SCANCODE_LEFT) { // Left arrow - move to previous available slot + if (uiExtendedKey <= + WHIP_SCANCODE_LEFT) { // Left arrow - move to previous + // available slot if (iCurrentSlot > 0) { textColor[iCurrentSlot] = 131; iPrevSlot = iCurrentSlot - 1; @@ -5811,7 +6250,8 @@ int select_netslot() iLeftSearchSlot = iPrevSlot; do { if (gamers_playing[iLeftSearchSlot] != 16) - break; // Skip slots with status 16 (unavailable) when going left + break; // Skip slots with status 16 (unavailable) when + // going left --iLeftSearchSlot; --iPrevSlot; } while (iLeftSearchSlot > 0); @@ -5820,7 +6260,9 @@ int select_netslot() iCurrentSlot = iPrevSlot; textColor[iCurrentSlot] = 171; } - } else if (uiExtendedKey == WHIP_SCANCODE_RIGHT && iCurrentSlot < 3)// Right arrow - move to next available slot + } else if (uiExtendedKey == WHIP_SCANCODE_RIGHT && + iCurrentSlot < + 3) // Right arrow - move to next available slot { textColor[iCurrentSlot] = 131; iRightSearchSlot = iCurrentSlot + 1; @@ -5828,7 +6270,8 @@ int select_netslot() iRightSearchIndex = iNextSlot; do { if (gamers_playing[iRightSearchIndex] != 16) - break; // Skip slots with status 16 (unavailable) when going right + break; // Skip slots with status 16 (unavailable) when + // going right ++iRightSearchIndex; ++iRightSearchSlot; } while (iRightSearchIndex < 3); @@ -5839,13 +6282,14 @@ int select_netslot() } } } - } else if (uiKeyCode <= 0xD) { // Enter key - select current slot if available + } else if (uiKeyCode <= + 0xD) { // Enter key - select current slot if available if ((unsigned int)gamers_playing[iCurrentSlot] < 16) { iExitFlag = -1; iReturnValue = iCurrentSlot + 1; } } else if (uiKeyCode == 27) { - iExitFlag = -1; // Escape key - cancel slot selection + iExitFlag = -1; // Escape key - cancel slot selection iReturnValue = -2; } } diff --git a/PROJECTS/ROLLER/func3.h b/PROJECTS/ROLLER/func3.h index 174ce23e..fe91bf49 100644 --- a/PROJECTS/ROLLER/func3.h +++ b/PROJECTS/ROLLER/func3.h @@ -5,8 +5,7 @@ typedef struct SceneRenderer SceneRenderer; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iSlotUsed; int iPackedTrack; int iDifficulty; @@ -47,8 +46,7 @@ extern int result_p1_pos; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iWidth; int iHeight; int iDataOffset; @@ -64,14 +62,15 @@ void ChampionshipStandings(); void TeamStandings(); void ShowLapRecords(); void show_3dmap(float fZ, int iElevation, int iYaw); -void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, int iAngle, char byAnimFrame); +void DrawCar(SceneRenderer *scene, int iCarDesignIndex, float fDistance, + int iAngle, char byAnimFrame); void championship_winner(); void print_mem_used(const char *szMsg); uint8 *try_load_picture(const char *szFile); void save_champ(int iSlot); int load_champ(int iSlot); uint8 *lod_champ_char(uint8 *pSrc, int *piValue); -uint8 *sav_champ_char(uint8 *pSrc, int *piValue); //actually loads an int +uint8 *sav_champ_char(uint8 *pSrc, int *piValue); // actually loads an int uint8 *sav_champ_int(uint8 *pDest, int iValue); void check_saves(); void ResultRoundUp(); @@ -83,29 +82,21 @@ void no_cd(); int name_cmp(char *szName1, char *szName2); void name_copy(char *szDest, char *szSrc); void loadtracksample(int track_number); -void front_letter(tBlockHeader *pFont, uint8 byCharIdx, int *iX, int *iY, const char *szStr, uint8 byColorReplace); -void scale_letter(tBlockHeader *pFont, uint8 byChar, int *iCursorX, int *iCursorY, char *mappingTable, char byColorReplace, int iScaleSize); -void front_text(tBlockHeader *pFont, - const char *szText, - const uint8 *mappingTable, - int *pCharVOffsets, - int iX, - int iY, - uint8 byColorReplace, - int iAlignment); -void scale_text(tBlockHeader *pFont, - char *szText, - const char *mappingTable, - int *pCharVOffsets, - int iX, - int iY, - char byColorReplace, - unsigned int uiAlignment, - int iClipLeft, - int iClipRight); +void front_letter(tBlockHeader *pFont, uint8 byCharIdx, int *iX, int *iY, + const char *szStr, uint8 byColorReplace); +void scale_letter(tBlockHeader *pFont, uint8 byChar, int *iCursorX, + int *iCursorY, char *mappingTable, char byColorReplace, + int iScaleSize); +void front_text(tBlockHeader *pFont, const char *szText, + const uint8 *mappingTable, int *pCharVOffsets, int iX, int iY, + uint8 byColorReplace, int iAlignment); +void scale_text(tBlockHeader *pFont, char *szText, const char *mappingTable, + int *pCharVOffsets, int iX, int iY, char byColorReplace, + unsigned int uiAlignment, int iClipLeft, int iClipRight); void clear_screen(void *pDest, int iVal); void display_picture(void *pDest, const void *pSrc); -void display_block(uint8 *pDest, tBlockHeader *pSrc, int iBlockIdx, int iX, int iY, int iTransparentColor); +void display_block(uint8 *pDest, tBlockHeader *pSrc, int iBlockIdx, int iX, + int iY, int iTransparentColor); uint8 *load_picture(const char *szFile); void AllocateCars(); void check_cars(); diff --git a/PROJECTS/ROLLER/function.c b/PROJECTS/ROLLER/function.c index 3872960f..7569fadb 100644 --- a/PROJECTS/ROLLER/function.c +++ b/PROJECTS/ROLLER/function.c @@ -12,107 +12,95 @@ #include //------------------------------------------------------------------------------------------------- -int firework_colours[16] = //000A4580 -{ - 231, 207, 171, 255, 243, 219, 195, 183, - 255, 159, 183, 143, 231, 231, 231, 231 -}; -float mapsize[25] = //000A45C0 -{ - 6000.0, 6000.0, 3500.0, 4500.0, 6000.0, - 3000.0, 4000.0, 3000.0, 4000.0, 6000.0, - 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, - 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, - 6000.0, 6000.0, 6000.0, 6000.0, 6000.0 -}; -int mapsect[25] = //000A4624 -{ - 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10 -}; -int invulnerable[16]; //00149EB0 +int firework_colours[16] = // 000A4580 + {231, 207, 171, 255, 243, 219, 195, 183, + 255, 159, 183, 143, 231, 231, 231, 231}; +float mapsize[25] = // 000A45C0 + {6000.0, 6000.0, 3500.0, 4500.0, 6000.0, 3000.0, 4000.0, 3000.0, 4000.0, + 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, + 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, 6000.0, 6000.0}; +int mapsect[25] = // 000A4624 + {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}; +int invulnerable[16]; // 00149EB0 //------------------------------------------------------------------------------------------------- -//00036C00 -void finish_race() -{ - int iAiCarCount; // edi - int iLap; // esi - int iCarOrderIdx; // edx - int iCurrentCarId; // eax - int iFinishedCarIndex; // edx - int ii; // eax - int iNearCarId; // ecx - int iFinishingCarId; // eax - int iCarId; // ebx - int iTotalLaps; // ebp - int iChunk2; // ecx - int iLap_1; // eax - int iChunk2_1; // ebx - int iRandomOffset; // eax - int iTrackLength; // ebp - int iChunkDistance; // ebx - int iDistanceCounter; // edx - int iLapThreshold; // eax - int iChampAiIndex; // edx - int j; // ecx - int k; // eax - int iChampionshipCarId; // eax - int iChampPlayerIndex; // edx - int iPlayerPlaceIndex; // ebx - int m; // eax - int iAiPlacementIndex; // ebx - int iRandomValue; // eax - int iRandomCarIndex; // eax - int iRandomPlayerIndex; // edx +// 00036C00 +void finish_race() { + int iAiCarCount; // edi + int iLap; // esi + int iCarOrderIdx; // edx + int iCurrentCarId; // eax + int iFinishedCarIndex; // edx + int ii; // eax + int iNearCarId; // ecx + int iFinishingCarId; // eax + int iCarId; // ebx + int iTotalLaps; // ebp + int iChunk2; // ecx + int iLap_1; // eax + int iChunk2_1; // ebx + int iRandomOffset; // eax + int iTrackLength; // ebp + int iChunkDistance; // ebx + int iDistanceCounter; // edx + int iLapThreshold; // eax + int iChampAiIndex; // edx + int j; // ecx + int k; // eax + int iChampionshipCarId; // eax + int iChampPlayerIndex; // edx + int iPlayerPlaceIndex; // ebx + int m; // eax + int iAiPlacementIndex; // ebx + int iRandomValue; // eax + int iRandomCarIndex; // eax + int iRandomPlayerIndex; // edx int iPlayerPlacementIndex; // ebx - int n; // eax - int iCarIndex; // ebp - int iCarArrayIndex; // esi - int iTargetPosition; // eax - int i; // ebx - int iTargetCarId; // edx - int iCurrentPosition; // ebx - int iPositionIndex; // edx - int iCar; // ecx - int iCarBytesTotal; // ebx - int iCarByteOffset; // edx - int iCarInitIndex; // eax - int iLapTimeIndex; // ebx - int iLapTimeCarIndex; // ecx - int iLapTimeCarId; // edx - double dRunningLapTime; // st7 - int iRaceTimeCarId; // edx - int iAiCarBytes; // edi - int iByteOffset; // ebx - char byFinishingLap; // cl - int iLapAssignCarId; // edx - double dTimeDiff; // st7 - double dRemainingTime; // st7 - double dLapThreshold; // st6 - int iRacePosition; // [esp+8h] [ebp-3Ch] - float fTotalRaceTime; // [esp+10h] [ebp-34h] - float fWinnerTotalTime; // [esp+14h] [ebp-30h] - int iMaxRacerIndex; // [esp+18h] [ebp-2Ch] - int iCarCounter; // [esp+1Ch] [ebp-28h] - int iFinishingCarId_1; // [esp+1Ch] [ebp-28h] - int iAiOrderIndex; // [esp+1Ch] [ebp-28h] - int iPlayerOrderIndex; // [esp+1Ch] [ebp-28h] - int iRandomOrderCounter; // [esp+1Ch] [ebp-28h] - int iRandomPlayerCounter; // [esp+1Ch] [ebp-28h] - int iFinishCarIdx; // [esp+1Ch] [ebp-28h] - int iCarInitCounter; // [esp+1Ch] [ebp-28h] - int iCarCountera; // [esp+1Ch] [ebp-28h] - float fReferenceLapTime; // [esp+20h] [ebp-24h] + int n; // eax + int iCarIndex; // ebp + int iCarArrayIndex; // esi + int iTargetPosition; // eax + int i; // ebx + int iTargetCarId; // edx + int iCurrentPosition; // ebx + int iPositionIndex; // edx + int iCar; // ecx + int iCarBytesTotal; // ebx + int iCarByteOffset; // edx + int iCarInitIndex; // eax + int iLapTimeIndex; // ebx + int iLapTimeCarIndex; // ecx + int iLapTimeCarId; // edx + double dRunningLapTime; // st7 + int iRaceTimeCarId; // edx + int iAiCarBytes; // edi + int iByteOffset; // ebx + char byFinishingLap; // cl + int iLapAssignCarId; // edx + double dTimeDiff; // st7 + double dRemainingTime; // st7 + double dLapThreshold; // st6 + int iRacePosition; // [esp+8h] [ebp-3Ch] + float fTotalRaceTime; // [esp+10h] [ebp-34h] + float fWinnerTotalTime; // [esp+14h] [ebp-30h] + int iMaxRacerIndex; // [esp+18h] [ebp-2Ch] + int iCarCounter; // [esp+1Ch] [ebp-28h] + int iFinishingCarId_1; // [esp+1Ch] [ebp-28h] + int iAiOrderIndex; // [esp+1Ch] [ebp-28h] + int iPlayerOrderIndex; // [esp+1Ch] [ebp-28h] + int iRandomOrderCounter; // [esp+1Ch] [ebp-28h] + int iRandomPlayerCounter; // [esp+1Ch] [ebp-28h] + int iFinishCarIdx; // [esp+1Ch] [ebp-28h] + int iCarInitCounter; // [esp+1Ch] [ebp-28h] + int iCarCountera; // [esp+1Ch] [ebp-28h] + float fReferenceLapTime; // [esp+20h] [ebp-24h] float fRandomLapVariation; // [esp+24h] [ebp-20h] - float fTimeDifference; // [esp+28h] [ebp-1Ch] + float fTimeDifference; // [esp+28h] [ebp-1Ch] if (player_type == 1) ROLLERsrand(random_seed); - iAiCarCount = 0; // Count AI cars (non-human controlled) that are still alive + iAiCarCount = 0; // Count AI cars (non-human controlled) that are still alive iCarCounter = 0; iLap = Car[carorder[0]].byLap; if (racers > 0) { @@ -125,22 +113,23 @@ void finish_race() ++iCarCounter; } while (iCarOrderIdx < racers); } - if (iLap <= NoOfLaps) // Check if race is still in progress (current lap <= total laps) + if (iLap <= NoOfLaps) // Check if race is still in progress (current lap <= + // total laps) { - iLapThreshold = NoOfLaps - 2; // Handle near-end-of-race logic (last 2 laps) + iLapThreshold = NoOfLaps - 2; // Handle near-end-of-race logic (last 2 laps) if (NoOfLaps - 2 < 1) iLapThreshold = 1; if (iLap >= iLapThreshold) { - iFinishCarIdx = 0; // Handle human players finishing race in final laps + iFinishCarIdx = 0; // Handle human players finishing race in final laps if (racers > 0) { iCarIndex = 0; iCarArrayIndex = 0; iMaxRacerIndex = racers - 1; - do { // Find human player and update finishing order + do { // Find human player and update finishing order if (human_control[iCarIndex] && !finished_car[iCarIndex]) { iRacePosition = Car[iCarArrayIndex].byRacePosition; iTargetPosition = iMaxRacerIndex; - for (i = iMaxRacerIndex; ; --i) { + for (i = iMaxRacerIndex;; --i) { iTargetCarId = carorder[i]; if (!finished_car[iTargetCarId]) break; @@ -149,7 +138,8 @@ void finish_race() finished_car[iTargetCarId] = -1; iCurrentPosition = iRacePosition; if (iTargetPosition > iRacePosition) { - iPositionIndex = iRacePosition; // Shift car positions in finishing order array + iPositionIndex = + iRacePosition; // Shift car positions in finishing order array do { iCar = carorder[iPositionIndex + 1]; carorder[iPositionIndex] = iCar; @@ -166,13 +156,14 @@ void finish_race() ++iFinishCarIdx; } while (iFinishCarIdx < racers); } - } else if (game_type == 1 && Race > 0) // Championship mode: Order AI cars by championship standings + } else if (game_type == 1 && Race > 0) // Championship mode: Order AI cars + // by championship standings { iChampAiIndex = 0; iAiOrderIndex = 0; if (iAiCarCount > 0) { for (j = 0; j < iAiCarCount; ++j) { - for (k = iChampAiIndex; ; ++k) { + for (k = iChampAiIndex;; ++k) { ++iChampAiIndex; if (!human_control[champorder[k]]) break; @@ -201,16 +192,20 @@ void finish_race() } while (iPlayerOrderIndex < players); } } else { - iRandomOrderCounter = 0; // Random placement mode: Randomly order AI cars for finish + iRandomOrderCounter = + 0; // Random placement mode: Randomly order AI cars for finish if (iAiCarCount > 0) { iAiPlacementIndex = 0; while (1) { iRandomValue = ROLLERrandRaw(); iRandomCarIndex = GetHighOrderRand(numcars, iRandomValue); - //iRandomCarIndex = (iRandomValue * numcars - (__CFSHL__((iRandomValue * numcars) >> 31, 15) + ((iRandomValue * numcars) >> 31 << 15))) >> 15; + // iRandomCarIndex = (iRandomValue * numcars - + // (__CFSHL__((iRandomValue * numcars) >> 31, 15) + ((iRandomValue * + // numcars) >> 31 << 15))) >> 15; if (iRandomCarIndex == numcars) iRandomCarIndex = numcars - 1; - if (!human_control[iRandomCarIndex] && !finished_car[iRandomCarIndex]) { + if (!human_control[iRandomCarIndex] && + !finished_car[iRandomCarIndex]) { carorder[iAiPlacementIndex++] = iRandomCarIndex; finished_car[iRandomCarIndex] = -1; ++iRandomOrderCounter; @@ -237,7 +232,7 @@ void finish_race() } while (iRandomPlayerCounter < players); } } - iCarInitCounter = 0; // Initialize AI car race times and best lap times + iCarInitCounter = 0; // Initialize AI car race times and best lap times if (numcars > 0) { iCarBytesTotal = 4 * numcars; iCarByteOffset = 0; @@ -252,30 +247,43 @@ void finish_race() ++iCarInitCounter; } while (iCarByteOffset < iCarBytesTotal); } - for (iCarCountera = 0; iCarCountera < NoOfLaps; ++iCarCountera)// Generate lap times for each AI car for all laps + for (iCarCountera = 0; iCarCountera < NoOfLaps; + ++iCarCountera) // Generate lap times for each AI car for all laps { iLapTimeIndex = 0; if (iAiCarCount > 0) { iLapTimeCarIndex = 0; do { iLapTimeCarId = carorder[iLapTimeCarIndex]; - fRandomLapVariation = (float)((double)ROLLERrand() * 0.000030517578125 + 0.02);// Add random variation (0.02-0.05s) to base lap time + fRandomLapVariation = + (float)((double)ROLLERrand() * 0.000030517578125 + + 0.02); // Add random variation (0.02-0.05s) to base lap + // time if (iLapTimeIndex) - dRunningLapTime = Car[carorder[iLapTimeCarIndex - 1]].fRunningLapTime; - //dRunningLapTime = Car[nearcall[3][iLapTimeCarIndex + 3]].fRunningLapTime; + dRunningLapTime = + Car[carorder[iLapTimeCarIndex - 1]].fRunningLapTime; + // dRunningLapTime = Car[nearcall[3][iLapTimeCarIndex + + // 3]].fRunningLapTime; else dRunningLapTime = RecordLaps[game_track]; - Car[iLapTimeCarId].fRunningLapTime = (float)dRunningLapTime + fRandomLapVariation; + Car[iLapTimeCarId].fRunningLapTime = + (float)dRunningLapTime + fRandomLapVariation; iRaceTimeCarId = iLapTimeCarId; - Car[iRaceTimeCarId].fTotalRaceTime = Car[iRaceTimeCarId].fRunningLapTime + Car[iRaceTimeCarId].fTotalRaceTime; - if (Car[iRaceTimeCarId].fBestLapTime > (double)Car[iRaceTimeCarId].fRunningLapTime) - Car[iRaceTimeCarId].fBestLapTime = Car[iRaceTimeCarId].fRunningLapTime; + Car[iRaceTimeCarId].fTotalRaceTime = + Car[iRaceTimeCarId].fRunningLapTime + + Car[iRaceTimeCarId].fTotalRaceTime; + if (Car[iRaceTimeCarId].fBestLapTime > + (double)Car[iRaceTimeCarId].fRunningLapTime) + Car[iRaceTimeCarId].fBestLapTime = + Car[iRaceTimeCarId].fRunningLapTime; ++iLapTimeIndex; ++iLapTimeCarIndex; } while (iLapTimeIndex < iAiCarCount); } } - fTotalRaceTime = Car[carorder[0]].fTotalRaceTime;// Calculate final race positions based on total race times + fTotalRaceTime = + Car[carorder[0]].fTotalRaceTime; // Calculate final race positions based + // on total race times fReferenceLapTime = RecordLaps[game_track]; if (fReferenceLapTime < 10.0) fReferenceLapTime = 10.0; @@ -287,7 +295,8 @@ void finish_race() iLapAssignCarId = carorder[iByteOffset / 4u]; dTimeDiff = Car[iLapAssignCarId].fTotalRaceTime - fTotalRaceTime; Car[iLapAssignCarId].byLap = byFinishingLap; - if (dTimeDiff > fReferenceLapTime) // Calculate how many laps behind based on time difference + if (dTimeDiff > fReferenceLapTime) // Calculate how many laps behind + // based on time difference { fTimeDifference = (float)dTimeDiff; dRemainingTime = fTimeDifference; @@ -300,13 +309,13 @@ void finish_race() iByteOffset += 4; } while (iByteOffset < iAiCarBytes); } - } else { // Race in progress: Process cars finishing current lap + } else { // Race in progress: Process cars finishing current lap while (finishers < racers) { iFinishedCarIndex = 0; for (ii = 0; finished_car[carorder[ii]]; ++ii) ++iFinishedCarIndex; iNearCarId = carorder[iFinishedCarIndex]; - //iNearCarId = nearcall[3][iFinishedCarIndex + 3]; + // iNearCarId = nearcall[3][iFinishedCarIndex + 3]; fWinnerTotalTime = Car[iNearCarId].fTotalRaceTime; iFinishingCarId = carorder[iFinishedCarIndex]; iCarId = iFinishingCarId; @@ -316,7 +325,7 @@ void finish_race() iFinishingCarId_1 = iFinishingCarId; iLap_1 = Car[iFinishingCarId].byLap; ++finishers; - if (iLap_1 == iTotalLaps) // Check if car completed all laps + if (iLap_1 == iTotalLaps) // Check if car completed all laps { Car[iCarId].byLap = NoOfLaps + 1; iChunk2_1 = Car[iCarId].nReferenceChunk; @@ -330,8 +339,12 @@ void finish_race() iChunkDistance = iChunk2 - iChunk2_1 + iRandomOffset; iDistanceCounter = 0; for (Car[iFinishingCarId_1].fTotalRaceTime = fWinnerTotalTime + 0.02f; - iDistanceCounter < iChunkDistance; - Car[iFinishingCarId_1].fTotalRaceTime = (float)((double)ROLLERrand() * 0.1 * 0.000030517578125 + 0.1 + Car[iFinishingCarId_1].fTotalRaceTime))// Adjust finishing time based on track position + iDistanceCounter < iChunkDistance; + Car[iFinishingCarId_1].fTotalRaceTime = + (float)((double)ROLLERrand() * 0.1 * 0.000030517578125 + 0.1 + + Car[iFinishingCarId_1] + .fTotalRaceTime)) // Adjust finishing time based on + // track position { ++iDistanceCounter; } @@ -343,18 +356,17 @@ void finish_race() } //------------------------------------------------------------------------------------------------- -//00037250 -double getbankz(float fInput, int iChunkIdx, tData *pData) -{ - tData *pUseData; // edx - tGroundPt *pGroundPt; // ebx - double dCalcVal; // st7 +// 00037250 +double getbankz(float fInput, int iChunkIdx, tData *pData) { + tData *pUseData; // edx + tGroundPt *pGroundPt; // ebx + double dCalcVal; // st7 int iSelectedPointIdx; // esi - int iCurrPointIdx; // ecx - tVec3 *pPoint1; // ebx + int iCurrPointIdx; // ecx + tVec3 *pPoint1; // ebx tGroundPt *pGroundPt2; // ecx - float fPrevCalcVal; // [esp+0h] [ebp-20h] - float fCurrCalcVal; // [esp+4h] [ebp-1Ch] + float fPrevCalcVal; // [esp+0h] [ebp-20h] + float fCurrCalcVal; // [esp+4h] [ebp-1Ch] // Default to localdata if pData is NULL pUseData = pData; @@ -365,22 +377,26 @@ double getbankz(float fInput, int iChunkIdx, tData *pData) pGroundPt = &GroundPt[iChunkIdx]; // Calculate first dot product - dCalcVal = (pGroundPt->pointAy[0].fY + pUseData->pointAy[3].fY) * pUseData->pointAy[1].fY - + (pGroundPt->pointAy[0].fX + pUseData->pointAy[3].fX) * pUseData->pointAy[0].fY - + (pGroundPt->pointAy[0].fZ + pUseData->pointAy[3].fZ) * pUseData->pointAy[2].fY; + dCalcVal = (pGroundPt->pointAy[0].fY + pUseData->pointAy[3].fY) * + pUseData->pointAy[1].fY + + (pGroundPt->pointAy[0].fX + pUseData->pointAy[3].fX) * + pUseData->pointAy[0].fY + + (pGroundPt->pointAy[0].fZ + pUseData->pointAy[3].fZ) * + pUseData->pointAy[2].fY; - iSelectedPointIdx = 4; // default to point 4 if no point found - iCurrPointIdx = 1; // start checking from point 1 - pPoint1 = &pGroundPt->pointAy[1]; // point to second ground point + iSelectedPointIdx = 4; // default to point 4 if no point found + iCurrPointIdx = 1; // start checking from point 1 + pPoint1 = &pGroundPt->pointAy[1]; // point to second ground point fPrevCalcVal = (float)dCalcVal; // Loop through ground points to find appropriate interpolation segment while (1) { - fCurrCalcVal = (pPoint1->fY + pUseData->pointAy[3].fY) * pUseData->pointAy[1].fY - + (pPoint1->fX + pUseData->pointAy[3].fX) * pUseData->pointAy[0].fY - + (pPoint1->fZ + pUseData->pointAy[3].fZ) * pUseData->pointAy[2].fY; + fCurrCalcVal = + (pPoint1->fY + pUseData->pointAy[3].fY) * pUseData->pointAy[1].fY + + (pPoint1->fX + pUseData->pointAy[3].fX) * pUseData->pointAy[0].fY + + (pPoint1->fZ + pUseData->pointAy[3].fZ) * pUseData->pointAy[2].fY; -// If input is greater than current dot product, found segment + // If input is greater than current dot product, found segment if (fInput > (double)fCurrCalcVal) break; @@ -399,71 +415,100 @@ double getbankz(float fInput, int iChunkIdx, tData *pData) // First term: contribution from point at selectedPointIndex // Second term: contribution from point at selectedPointIndex + 1 pGroundPt2 = &GroundPt[iChunkIdx]; - return ((pGroundPt2->pointAy[iSelectedPointIdx].fY + pUseData->pointAy[3].fY) * pUseData->pointAy[1].fZ - + (pGroundPt2->pointAy[iSelectedPointIdx].fX + pUseData->pointAy[3].fX) * pUseData->pointAy[0].fZ - + (pGroundPt2->pointAy[iSelectedPointIdx].fZ + pUseData->pointAy[3].fZ) * pUseData->pointAy[2].fZ) - * (fInput - fCurrCalcVal) // weight for first point - / (fPrevCalcVal - fCurrCalcVal) // total range - + ((pGroundPt2->pointAy[iSelectedPointIdx + 1].fY + pUseData->pointAy[3].fY) * pUseData->pointAy[1].fZ - + (pGroundPt2->pointAy[iSelectedPointIdx + 1].fX + pUseData->pointAy[3].fX) * pUseData->pointAy[0].fZ - + (pGroundPt2->pointAy[iSelectedPointIdx + 1].fZ + pUseData->pointAy[3].fZ) * pUseData->pointAy[2].fZ) - * (fInput - fPrevCalcVal) // weight for second point - / (fCurrCalcVal - fPrevCalcVal); // total range + return ((pGroundPt2->pointAy[iSelectedPointIdx].fY + + pUseData->pointAy[3].fY) * + pUseData->pointAy[1].fZ + + (pGroundPt2->pointAy[iSelectedPointIdx].fX + + pUseData->pointAy[3].fX) * + pUseData->pointAy[0].fZ + + (pGroundPt2->pointAy[iSelectedPointIdx].fZ + + pUseData->pointAy[3].fZ) * + pUseData->pointAy[2].fZ) * + (fInput - fCurrCalcVal) // weight for first point + / (fPrevCalcVal - fCurrCalcVal) // total range + + ((pGroundPt2->pointAy[iSelectedPointIdx + 1].fY + + pUseData->pointAy[3].fY) * + pUseData->pointAy[1].fZ + + (pGroundPt2->pointAy[iSelectedPointIdx + 1].fX + + pUseData->pointAy[3].fX) * + pUseData->pointAy[0].fZ + + (pGroundPt2->pointAy[iSelectedPointIdx + 1].fZ + + pUseData->pointAy[3].fZ) * + pUseData->pointAy[2].fZ) * + (fInput - fPrevCalcVal) // weight for second point + / (fCurrCalcVal - fPrevCalcVal); // total range } //------------------------------------------------------------------------------------------------- -//000373A0 -void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, float *pfBehindTime) -{ - int iCurrentCarId; // eax - int iCurrChunk; // esi - int iAheadCarId; // edi - int nCurrChunk; // esi - int iAheadCarRef; // edi - float fFinalSpeed; // eax - double dTimeCalc; // st7 - int iRacePosition; // eax - int iBehindCarId; // esi - int iLastValidChunk; // eax - int iCurrentCarRef; // ecx - int iBehindCarRef; // esi - float fBehindSpeed; // eax - double dBehindTimeCalc; // st7 - float fAheadTimeResult; // [esp+0h] [ebp-44h] - float fBehindTimeResult; // [esp+0h] [ebp-44h] - float fTrackDistance; // [esp+4h] [ebp-40h] +// 000373A0 +void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, + float *pfBehindTime) { + int iCurrentCarId; // eax + int iCurrChunk; // esi + int iAheadCarId; // edi + int nCurrChunk; // esi + int iAheadCarRef; // edi + float fFinalSpeed; // eax + double dTimeCalc; // st7 + int iRacePosition; // eax + int iBehindCarId; // esi + int iLastValidChunk; // eax + int iCurrentCarRef; // ecx + int iBehindCarRef; // esi + float fBehindSpeed; // eax + double dBehindTimeCalc; // st7 + float fAheadTimeResult; // [esp+0h] [ebp-44h] + float fBehindTimeResult; // [esp+0h] [ebp-44h] + float fTrackDistance; // [esp+4h] [ebp-40h] float fBehindTrackDistance; // [esp+8h] [ebp-3Ch] - float fAheadSpeed; // [esp+Ch] [ebp-38h] - float fBehindSpeedFinal; // [esp+10h] [ebp-34h] - float fAheadDistance; // [esp+1Ch] [ebp-28h] - float fAheadCarPosition; // [esp+20h] [ebp-24h] - float fBehindDistance; // [esp+24h] [ebp-20h] - float fBehindCarPosition; // [esp+28h] [ebp-1Ch] - float fCurrentCarPosition; // [esp+2Ch] [ebp-18h] + float fAheadSpeed; // [esp+Ch] [ebp-38h] + float fBehindSpeedFinal; // [esp+10h] [ebp-34h] + float fAheadDistance; // [esp+1Ch] [ebp-28h] + float fAheadCarPosition; // [esp+20h] [ebp-24h] + float fBehindDistance; // [esp+24h] [ebp-20h] + float fBehindCarPosition; // [esp+28h] [ebp-1Ch] + float fCurrentCarPosition; // [esp+2Ch] [ebp-18h] iCurrentCarId = iCarIdx; - if ((char)Car[iCurrentCarId].byLives > 0) // Check if current car is alive, otherwise return -1 for both times + if ((char)Car[iCurrentCarId].byLives > + 0) // Check if current car is alive, otherwise return -1 for both times { - iCurrChunk = Car[iCurrentCarId].nCurrChunk; // Calculate current car's absolute position on track (chunk + lap distance) + iCurrChunk = Car[iCurrentCarId] + .nCurrChunk; // Calculate current car's absolute position + // on track (chunk + lap distance) if (iCurrChunk == -1) iCurrChunk = Car[iCurrentCarId].iLastValidChunk; - fCurrentCarPosition = (float)(averagesectionlen * iCurrChunk + totaltrackdistance * (char)Car[iCarIdx].byLapNumber); + fCurrentCarPosition = + (float)(averagesectionlen * iCurrChunk + + totaltrackdistance * (char)Car[iCarIdx].byLapNumber); if (Car[iCarIdx].nCurrChunk != -1) fCurrentCarPosition = fCurrentCarPosition + Car[iCarIdx].pos.fX; - if (Car[iCarIdx].byRacePosition) // Calculate time to car ahead (if not in first position) + if (Car[iCarIdx].byRacePosition) // Calculate time to car ahead (if not in + // first position) { - //TODO recheck this offset to ensure it is correct - iAheadCarId = carorder[Car[iCarIdx].byRacePosition - 1];// Get car ahead from race position order + // TODO recheck this offset to ensure it is correct + iAheadCarId = carorder[Car[iCarIdx].byRacePosition - + 1]; // Get car ahead from race position order if ((char)Car[iAheadCarId].byLives > 0) { nCurrChunk = Car[iAheadCarId].nCurrChunk; if (nCurrChunk == -1) nCurrChunk = Car[iAheadCarId].iLastValidChunk; - fAheadCarPosition = (float)(averagesectionlen * nCurrChunk + totaltrackdistance * (char)Car[iAheadCarId].byLapNumber);// Calculate ahead car's absolute position on track + fAheadCarPosition = + (float)(averagesectionlen * nCurrChunk + + totaltrackdistance * + (char)Car[iAheadCarId] + .byLapNumber); // Calculate ahead car's absolute + // position on track if (Car[iAheadCarId].nCurrChunk != -1) fAheadCarPosition = fAheadCarPosition + Car[iAheadCarId].pos.fX; iAheadCarRef = iAheadCarId; - fAheadDistance = (float)fabs(fCurrentCarPosition - fAheadCarPosition);// Calculate absolute distance between cars - if (Car[iCarIdx].fFinalSpeed <= (double)Car[iAheadCarRef].fFinalSpeed)// Use higher speed of the two cars for time calculation + fAheadDistance = (float)fabs( + fCurrentCarPosition - + fAheadCarPosition); // Calculate absolute distance between cars + if (Car[iCarIdx].fFinalSpeed <= + (double)Car[iAheadCarRef] + .fFinalSpeed) // Use higher speed of the two cars for time + // calculation fFinalSpeed = Car[iAheadCarRef].fFinalSpeed; else fFinalSpeed = Car[iCarIdx].fFinalSpeed; @@ -471,7 +516,9 @@ void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, float *pfBehindT if (fFinalSpeed < 100.0) fAheadSpeed = 100.0; fTrackDistance = (float)totaltrackdistance; - if (fAheadDistance >= (double)fTrackDistance)// Convert distance to time: if >1 lap apart use large penalty, else distance/speed + if (fAheadDistance >= + (double)fTrackDistance) // Convert distance to time: if >1 lap apart + // use large penalty, else distance/speed dTimeCalc = fAheadDistance * 10000000.0 / fTrackDistance; else dTimeCalc = fAheadDistance / fAheadSpeed * 0.027777778; @@ -483,22 +530,30 @@ void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, float *pfBehindT } else { *pfAheadTime = -1.0; } - iRacePosition = Car[iCarIdx].byRacePosition;// Calculate time to car behind (if not in last position) + iRacePosition = Car[iCarIdx].byRacePosition; // Calculate time to car behind + // (if not in last position) if (iRacePosition == numcars - 1) { *pfBehindTime = -1.0; } else { - iBehindCarId = carorder[iRacePosition + 1];// Get car behind from race position order + iBehindCarId = carorder[iRacePosition + + 1]; // Get car behind from race position order if ((char)Car[iBehindCarId].byLives > 0) { iLastValidChunk = Car[iBehindCarId].nCurrChunk; if (iLastValidChunk == -1) iLastValidChunk = Car[iBehindCarId].iLastValidChunk; - fBehindCarPosition = (float)(averagesectionlen * iLastValidChunk + totaltrackdistance * (char)Car[iBehindCarId].byLapNumber);// Calculate behind car's absolute position and distance/time gap + fBehindCarPosition = + (float)(averagesectionlen * iLastValidChunk + + totaltrackdistance * + (char)Car[iBehindCarId] + .byLapNumber); // Calculate behind car's absolute + // position and distance/time gap if (Car[iBehindCarId].nCurrChunk != -1) fBehindCarPosition = fBehindCarPosition + Car[iBehindCarId].pos.fX; iCurrentCarRef = iCarIdx; iBehindCarRef = iBehindCarId; fBehindDistance = (float)fabs(fCurrentCarPosition - fBehindCarPosition); - if (Car[iCurrentCarRef].fFinalSpeed <= (double)Car[iBehindCarRef].fFinalSpeed) + if (Car[iCurrentCarRef].fFinalSpeed <= + (double)Car[iBehindCarRef].fFinalSpeed) fBehindSpeed = Car[iBehindCarRef].fFinalSpeed; else fBehindSpeed = Car[iCurrentCarRef].fFinalSpeed; @@ -523,24 +578,25 @@ void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, float *pfBehindT } //------------------------------------------------------------------------------------------------- -//000376B0 -void initnearcars() -{ +// 000376B0 +void initnearcars() { int iAICarsRemaining; // edi - int iCarIndex; // ebx - int iCurrentCarIdx; // ebx - int iCarsPerGroup; // esi - //int iGroupCarCount; // ecx - //int iNearCallOffset; // edx - //int iTempCarIdx; // eax + int iCarIndex; // ebx + int iCurrentCarIdx; // ebx + int iCarsPerGroup; // esi + // int iGroupCarCount; // ecx + // int iNearCallOffset; // edx + // int iTempCarIdx; // eax int iGroupSize; // [esp+0h] [ebp-20h] - //int iGroupOffset; // [esp+4h] [ebp-1Ch] + // int iGroupOffset; // [esp+4h] [ebp-1Ch] - memset(nearcall, 255, sizeof(nearcall)); // Initialize nearcall array with -1 (no car assigned) - iAICarsRemaining = 0; // Count total number of AI-controlled cars + memset( + nearcall, 255, + sizeof(nearcall)); // Initialize nearcall array with -1 (no car assigned) + iAICarsRemaining = 0; // Count total number of AI-controlled cars if (numcars > 0) { iCarIndex = 0; - do { // Skip non-competitors and human-controlled cars + do { // Skip non-competitors and human-controlled cars if (!non_competitors[iCarIndex] && !human_control[iCarIndex]) ++iAICarsRemaining; ++iCarIndex; @@ -548,56 +604,62 @@ void initnearcars() } iCurrentCarIdx = 0; - iGroupSize = 4; // Start with group size 4, distribute AI cars across 4 groups - for (int iGroup = 0; iGroup < 4; iGroup++) // Loop through 4 nearcall groups: [0],[1],[2],[3] + iGroupSize = 4; // Start with group size 4, distribute AI cars across 4 groups + for (int iGroup = 0; iGroup < 4; + iGroup++) // Loop through 4 nearcall groups: [0],[1],[2],[3] { - iCarsPerGroup = iAICarsRemaining / iGroupSize; // Calculate how many cars to assign to current group - for (int iSlot = 0; iSlot < iCarsPerGroup; iSlot++) - { + iCarsPerGroup = + iAICarsRemaining / + iGroupSize; // Calculate how many cars to assign to current group + for (int iSlot = 0; iSlot < iCarsPerGroup; iSlot++) { // Find next AI car (skip non-competitors and human players) - while (non_competitors[iCurrentCarIdx] || human_control[iCurrentCarIdx]) - { + while (non_competitors[iCurrentCarIdx] || human_control[iCurrentCarIdx]) { iCurrentCarIdx++; } // Assign AI car index to current nearcall group slot nearcall[iGroup][iSlot] = iCurrentCarIdx; iCurrentCarIdx++; } - iAICarsRemaining -= iCarsPerGroup; // Subtract assigned cars from remaining count - iGroupSize--; // Decrease group size for uneven distribution + iAICarsRemaining -= + iCarsPerGroup; // Subtract assigned cars from remaining count + iGroupSize--; // Decrease group size for uneven distribution } - //iCurrentCarIdx = 0; - //iGroupSize = 4; // Start with group size 4, distribute AI cars across 4 groups - //for (iGroupOffset = 0; iGroupOffset != 64; iGroupOffset += 16)// Loop through 4 nearcall groups: [0],[1],[2],[3] + // iCurrentCarIdx = 0; + // iGroupSize = 4; // Start with group size 4, + // distribute AI cars across 4 groups for (iGroupOffset = 0; iGroupOffset != + // 64; iGroupOffset += 16)// Loop through 4 nearcall groups: [0],[1],[2],[3] //{ - // iCarsPerGroup = iAICarsRemaining / iGroupSize;// Calculate how many cars to assign to current group - // iGroupCarCount = 0; - // if (iAICarsRemaining / iGroupSize > 0) { - // iNearCallOffset = iGroupOffset; - // do { // Find next AI car (skip non-competitors and human players) - // for (iTempCarIdx = iCurrentCarIdx; non_competitors[iTempCarIdx] || human_control[iTempCarIdx]; ++iTempCarIdx) - // ++iCurrentCarIdx; - // ++iGroupCarCount; - // *(int *)((char *)nearcall[0] + iNearCallOffset) = iCurrentCarIdx;// Assign AI car index to current nearcall group slot - // iNearCallOffset += 4; - // ++iCurrentCarIdx; - // } while (iGroupCarCount < iCarsPerGroup); - // } - // iAICarsRemaining -= iCarsPerGroup; // Subtract assigned cars from remaining count - // --iGroupSize; // Decrease group size for uneven distribution - //} - nearcarcheck = 0; // Reset near car check counter + // iCarsPerGroup = iAICarsRemaining / iGroupSize;// Calculate how many cars + // to assign to current group iGroupCarCount = 0; if (iAICarsRemaining / + // iGroupSize > 0) { + // iNearCallOffset = iGroupOffset; + // do { // Find next AI car (skip + // non-competitors and human players) + // for (iTempCarIdx = iCurrentCarIdx; non_competitors[iTempCarIdx] || + // human_control[iTempCarIdx]; ++iTempCarIdx) + // ++iCurrentCarIdx; + // ++iGroupCarCount; + // *(int *)((char *)nearcall[0] + iNearCallOffset) = iCurrentCarIdx;// + // Assign AI car index to current nearcall group slot iNearCallOffset += + // 4; + // ++iCurrentCarIdx; + // } while (iGroupCarCount < iCarsPerGroup); + // } + // iAICarsRemaining -= iCarsPerGroup; // Subtract assigned cars + // from remaining count + // --iGroupSize; // Decrease group size for + // uneven distribution + // } + nearcarcheck = 0; // Reset near car check counter } //------------------------------------------------------------------------------------------------- -//00037780 -void initpits() -{ - int iChunkIdx_1; // eax +// 00037780 +void initpits() { + int iChunkIdx_1; // eax int iPitStopCount; // ecx - int iStopsIdx; // ebx - int iChunkIdx; // edx - + int iStopsIdx; // ebx + int iChunkIdx; // edx // Start from last track chunk and work backwards iChunkIdx_1 = TRAK_LEN - 1; @@ -608,8 +670,8 @@ void initpits() iStopsIdx = 0; iChunkIdx = iChunkIdx_1; do { - if ((TrakColour[iChunkIdx][TRAK_COLOUR_CENTER] & SURFACE_FLAG_PIT_BOX) != 0) - { + if ((TrakColour[iChunkIdx][TRAK_COLOUR_CENTER] & SURFACE_FLAG_PIT_BOX) != + 0) { // store pit stop position stops[iStopsIdx] = iChunkIdx_1; // reference into stops @@ -624,46 +686,48 @@ void initpits() } //------------------------------------------------------------------------------------------------- -//000377D0 -void dodamage(tCar *pCar, float fDamage) -{ - tCarEngine *pCarEngine; // edi - int iDriverIdx; // eax - tCarSpray *pCarSpray; // ebx - int iSprayIdx; // ecx - int iRandValue1; // eax +// 000377D0 +void dodamage(tCar *pCar, float fDamage) { + tCarEngine *pCarEngine; // edi + int iDriverIdx; // eax + tCarSpray *pCarSpray; // ebx + int iSprayIdx; // ecx + int iRandValue1; // eax tCarSpray *pPlayerSpray; // ebx - int i; // ecx - int iRandValue2; // eax - uint8 byStatusFlags; // dh - int iPlayerType; // ebx - int iDeadDriverIdx; // edi - int iGameTrack; // eax - int iCurrentDriverIdx; // ecx - int iRacePosition; // ebx - int j; // edx - int iCurrentPos; // edx - int iPosIdx; // eax - int iCarOrderValue; // ebx - int iFinishers; // edi - int iHumanControl; // ebp - int iCheckDriverIdx; // edx - int iPlayer2DriverIdx; // ebp - int iPlayerTypeCheck; // eax - uint8 byCarDesignIdx; // bl - int iFinalDriverIdx; // edi - float fHealth; // [esp+0h] [ebp-20h] - int iDamageIntensity; // [esp+4h] [ebp-1Ch] - int iRacePosCount; // [esp+4h] [ebp-1Ch] + int i; // ecx + int iRandValue2; // eax + uint8 byStatusFlags; // dh + int iPlayerType; // ebx + int iDeadDriverIdx; // edi + int iGameTrack; // eax + int iCurrentDriverIdx; // ecx + int iRacePosition; // ebx + int j; // edx + int iCurrentPos; // edx + int iPosIdx; // eax + int iCarOrderValue; // ebx + int iFinishers; // edi + int iHumanControl; // ebp + int iCheckDriverIdx; // edx + int iPlayer2DriverIdx; // ebp + int iPlayerTypeCheck; // eax + uint8 byCarDesignIdx; // bl + int iFinalDriverIdx; // edi + float fHealth; // [esp+0h] [ebp-20h] + int iDamageIntensity; // [esp+4h] [ebp-1Ch] + int iRacePosCount; // [esp+4h] [ebp-1Ch] - pCarEngine = &CarEngines.engines[pCar->byCarDesignIdx];// Get car engine data based on car design + pCarEngine = &CarEngines.engines[pCar->byCarDesignIdx]; // Get car engine data + // based on car design fHealth = pCar->fHealth; iDriverIdx = pCar->iDriverIdx; - if (!invulnerable[iDriverIdx] && !finished_car[iDriverIdx])// Check if car is vulnerable and not finished - { // Check if car is not already destroyed (status flag 4) + if (!invulnerable[iDriverIdx] && + !finished_car[iDriverIdx]) // Check if car is vulnerable and not finished + { // Check if car is not already destroyed (status flag 4) if ((pCar->byStatusFlags & 4) == 0) { pCarSpray = CarSpray[pCar->iDriverIdx]; - if (fDamage > 0.55) // Handle visual spray effects for significant damage (> 0.55) + if (fDamage > + 0.55) // Handle visual spray effects for significant damage (> 0.55) { //_CHP(); iDamageIntensity = (int)(fDamage * 16.0); @@ -680,7 +744,8 @@ void dodamage(tCar *pCar, float fDamage) } ++iSprayIdx; ++pCarSpray; - } while (iSprayIdx < 32); // Loop through all 32 spray effects for this car + } while (iSprayIdx < + 32); // Loop through all 32 spray effects for this car if (player_type == 2) { pPlayerSpray = 0; if (player1_car == pCar->iDriverIdx) @@ -700,8 +765,12 @@ void dodamage(tCar *pCar, float fDamage) } } } - pCar->fHealth = pCar->fHealth - fDamage * pCarEngine->fDurability;// Apply damage to car health (modified by engine durability) - if (pCar->fHealth < 1.0) // Handle car destruction when health drops below 1.0 + pCar->fHealth = + pCar->fHealth - + fDamage * pCarEngine->fDurability; // Apply damage to car health + // (modified by engine durability) + if (pCar->fHealth < + 1.0) // Handle car destruction when health drops below 1.0 { byStatusFlags = pCar->byStatusFlags; pCar->fHealth = 0.0; @@ -712,9 +781,12 @@ void dodamage(tCar *pCar, float fDamage) // CHEAT_MODE_CLONES if (iPlayerType != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0) { iDeadDriverIdx = pCar->iDriverIdx; - if (player1_car != iDeadDriverIdx && pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx && !human_control[iDeadDriverIdx] && pCar->byCarDesignIdx <= 7u) { + if (player1_car != iDeadDriverIdx && + pCar->byCarDesignIdx == Car[player1_car].byCarDesignIdx && + !human_control[iDeadDriverIdx] && pCar->byCarDesignIdx <= 7u) { // SOUND_SAMPLE_ARIEL - speechsample(pCar->byCarDesignIdx + SOUND_SAMPLE_ARIEL, 20000, 18, player1_car + 17152); + speechsample(pCar->byCarDesignIdx + SOUND_SAMPLE_ARIEL, 20000, 18, + player1_car + 17152); // SOUND_SAMPLE_TGONE speechsample(SOUND_SAMPLE_TGONE, 20000, 0, player1_car); } @@ -742,7 +814,8 @@ void dodamage(tCar *pCar, float fDamage) } } if (!pCar->byLives && !finished_car[iCurrentDriverIdx]) { - iRacePosition = pCar->byRacePosition; // Update race positions when car is eliminated + iRacePosition = pCar->byRacePosition; // Update race positions when + // car is eliminated ++Destroyed; iRacePosCount = racers - 1; for (j = racers - 1; finished_car[carorder[j]]; --j) @@ -765,14 +838,18 @@ void dodamage(tCar *pCar, float fDamage) finishers = iFinishers + 1; if (iHumanControl) ++human_finishers; - if ((iCurrentDriverIdx == player1_car || iCurrentDriverIdx == player2_car) && (char)pCar->byLives > 0) + if ((iCurrentDriverIdx == player1_car || + iCurrentDriverIdx == player2_car) && + (char)pCar->byLives > 0) // SOUND_SAMPLE_RUBBISH speechsample(SOUND_SAMPLE_RUBBISH, 0x8000, 18, iCurrentDriverIdx); } iCheckDriverIdx = pCar->iDriverIdx; if (player1_car == iCheckDriverIdx || player2_car == iCheckDriverIdx) { // SOUND_SAMPLE_FATALITY - speechsample(SOUND_SAMPLE_FATALITY, 0x8000, 18, pCar->iDriverIdx);// Play death sound effects for human players + speechsample( + SOUND_SAMPLE_FATALITY, 0x8000, 18, + pCar->iDriverIdx); // Play death sound effects for human players if (!pCar->byLives) { // SOUND_SAMPLE_0LEFT speechsample(SOUND_SAMPLE_0LEFT, 0x8000, 18, pCar->iDriverIdx); @@ -781,18 +858,21 @@ void dodamage(tCar *pCar, float fDamage) } } if (pCar->byDamageSourceTimer) - ++Car[pCar->byAttacker].byKills; // Track kills for the attacking car + ++Car[pCar->byAttacker].byKills; // Track kills for the attacking car if (pCar->byDamageSourceTimer && pCar->byAttacker == player1_car) { speechsample(SOUND_SAMPLE_GOTONE, 0x8000, 18, player1_car); Victim = pCar->iDriverIdx; } else if (player1_car != pCar->iDriverIdx) { if ((char)pCar->byLives <= 0) - sprintf(buffer, "%s %s", &language_buffer[1984], driver_names[pCar->iDriverIdx]); + sprintf(buffer, "%s %s", &language_buffer[1984], + driver_names[pCar->iDriverIdx]); else - sprintf(buffer, "%s %s", &language_buffer[1920], driver_names[pCar->iDriverIdx]); + sprintf(buffer, "%s %s", &language_buffer[1920], + driver_names[pCar->iDriverIdx]); small_zoom(buffer); if (pCar->byDamageSourceTimer) { - sprintf(buffer, "%s %s", &language_buffer[2176], driver_names[pCar->byAttacker]); + sprintf(buffer, "%s %s", &language_buffer[2176], + driver_names[pCar->byAttacker]); subzoom(buffer); } } @@ -805,12 +885,15 @@ void dodamage(tCar *pCar, float fDamage) iPlayer2DriverIdx = pCar->iDriverIdx; if (player2_car != iPlayer2DriverIdx) { if ((char)pCar->byLives <= 0) - sprintf(buffer, "%s %s", &language_buffer[1984], driver_names[iPlayer2DriverIdx]); + sprintf(buffer, "%s %s", &language_buffer[1984], + driver_names[iPlayer2DriverIdx]); else - sprintf(buffer, "%s %s", &language_buffer[1920], driver_names[iPlayer2DriverIdx]); + sprintf(buffer, "%s %s", &language_buffer[1920], + driver_names[iPlayer2DriverIdx]); small_zoom(buffer); if (pCar->byDamageSourceTimer) { - sprintf(buffer, "%s %s", &language_buffer[2176], driver_names[pCar->byAttacker]); + sprintf(buffer, "%s %s", &language_buffer[2176], + driver_names[pCar->byAttacker]); subzoom(buffer); } } @@ -819,16 +902,21 @@ void dodamage(tCar *pCar, float fDamage) } pCar->byStatusFlags |= 4u; } - if (pCar->fHealth < 30.0 && fHealth >= 30.0)// Handle transition from healthy to critical health (30.0 threshold) + if (pCar->fHealth < 30.0 && + fHealth >= 30.0) // Handle transition from healthy to critical health + // (30.0 threshold) { iPlayerTypeCheck = player_type; pCar->nChangeMateCooldown = 1080; // CHEAT_MODE_CLONES - if (iPlayerTypeCheck != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0 && player1_car != pCar->iDriverIdx) { + if (iPlayerTypeCheck != 2 && (cheat_mode & CHEAT_MODE_CLONES) == 0 && + player1_car != pCar->iDriverIdx) { byCarDesignIdx = pCar->byCarDesignIdx; - if (byCarDesignIdx == Car[player1_car].byCarDesignIdx && !human_control[pCar->iDriverIdx] && byCarDesignIdx <= 7u) { + if (byCarDesignIdx == Car[player1_car].byCarDesignIdx && + !human_control[pCar->iDriverIdx] && byCarDesignIdx <= 7u) { // SOUND_SAMPLE_ARIEL - speechsample(byCarDesignIdx + SOUND_SAMPLE_ARIEL, 20000, 18, player1_car + 17408); + speechsample(byCarDesignIdx + SOUND_SAMPLE_ARIEL, 20000, 18, + player1_car + 17408); // SOUND_SAMPLE_TDAMAGE speechsample(SOUND_SAMPLE_TDAMAGE, 20000, 0, player1_car); } @@ -836,63 +924,72 @@ void dodamage(tCar *pCar, float fDamage) } } iFinalDriverIdx = pCar->iDriverIdx; - if ((player1_car == iFinalDriverIdx || player2_car == iFinalDriverIdx) && pCar->fHealth < 30.0 && fHealth >= 30.0 && pCar->byCarDesignIdx <= 7u) + if ((player1_car == iFinalDriverIdx || player2_car == iFinalDriverIdx) && + pCar->fHealth < 30.0 && fHealth >= 30.0 && pCar->byCarDesignIdx <= 7u) // SOUND_SAMPLE_BLOWTIME - speechsample(SOUND_SAMPLE_BLOWTIME, 20000, 18, pCar->iDriverIdx);// Play critical health warning sound for human players + speechsample(SOUND_SAMPLE_BLOWTIME, 20000, 18, + pCar->iDriverIdx); // Play critical health warning sound for + // human players } //------------------------------------------------------------------------------------------------- -//00037F00 -void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) -{ - int iSelectedView; // edx - unsigned int iControlType; // eax - double dChasePullCrash; // st7 - double dTempPullCrash; // st7 - int iViewIndex; // ebx - double dTempPullCrash2; // st7 - double dChasePullNormal; // st7 - double dTempPullNormal; // st7 - int iViewIndex2; // ebx - double dTempPullNormal2; // st7 - double dChasePullDefault; // st7 - double dTempPullDefault; // st7 - int iViewIndex3; // ebx - double dTempPullDefault2; // st7 - double dHighSpeedCrashPull; // st7 - double dTempHighSpeedCrash; // st7 - int iViewIndex4; // ebx - double dTempHighSpeedCrash2; // st7 - double dHighSpeedNormalPull; // st7 - double dTempHighSpeedNormal; // st7 - int iViewIndex5; // ebx - double dTempHighSpeedNormal2; // st7 - int iHighSpeedPullIncrement; // [esp+4h] [ebp-50h] - int iTargetPullNormal; // [esp+8h] [ebp-4Ch] - int iTargetPullHighSpeed; // [esp+Ch] [ebp-48h] - int iTargetPullCrash; // [esp+10h] [ebp-44h] - int iTargetPullDefault; // [esp+14h] [ebp-40h] - int iTargetPullHighSpeedCrash; // [esp+18h] [ebp-3Ch] - float fTargetPullHighSpeed; // [esp+1Ch] [ebp-38h] - float fTargetPullNormal; // [esp+20h] [ebp-34h] - float fTargetPullHighSpeedCrash; // [esp+24h] [ebp-30h] - float fTargetPullDefault; // [esp+28h] [ebp-2Ch] - int iPullSpeed; // [esp+2Ch] [ebp-28h] - float fTargetPullDefaultFloat; // [esp+30h] [ebp-24h] - float fTargetPullCrashFloat; // [esp+34h] [ebp-20h] - float fTargetPullNormalFloat; // [esp+38h] [ebp-1Ch] - float fTargetPullCrashLimit; // [esp+3Ch] [ebp-18h] - float fTargetPullHighSpeedLimit; // [esp+40h] [ebp-14h] +// 00037F00 +void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) { + int iSelectedView; // edx + unsigned int iControlType; // eax + double dChasePullCrash; // st7 + double dTempPullCrash; // st7 + int iViewIndex; // ebx + double dTempPullCrash2; // st7 + double dChasePullNormal; // st7 + double dTempPullNormal; // st7 + int iViewIndex2; // ebx + double dTempPullNormal2; // st7 + double dChasePullDefault; // st7 + double dTempPullDefault; // st7 + int iViewIndex3; // ebx + double dTempPullDefault2; // st7 + double dHighSpeedCrashPull; // st7 + double dTempHighSpeedCrash; // st7 + int iViewIndex4; // ebx + double dTempHighSpeedCrash2; // st7 + double dHighSpeedNormalPull; // st7 + double dTempHighSpeedNormal; // st7 + int iViewIndex5; // ebx + double dTempHighSpeedNormal2; // st7 + int iHighSpeedPullIncrement; // [esp+4h] [ebp-50h] + int iTargetPullNormal; // [esp+8h] [ebp-4Ch] + int iTargetPullHighSpeed; // [esp+Ch] [ebp-48h] + int iTargetPullCrash; // [esp+10h] [ebp-44h] + int iTargetPullDefault; // [esp+14h] [ebp-40h] + int iTargetPullHighSpeedCrash; // [esp+18h] [ebp-3Ch] + float fTargetPullHighSpeed; // [esp+1Ch] [ebp-38h] + float fTargetPullNormal; // [esp+20h] [ebp-34h] + float fTargetPullHighSpeedCrash; // [esp+24h] [ebp-30h] + float fTargetPullDefault; // [esp+28h] [ebp-2Ch] + int iPullSpeed; // [esp+2Ch] [ebp-28h] + float fTargetPullDefaultFloat; // [esp+30h] [ebp-24h] + float fTargetPullCrashFloat; // [esp+34h] [ebp-20h] + float fTargetPullNormalFloat; // [esp+38h] [ebp-1Ch] + float fTargetPullCrashLimit; // [esp+3Ch] [ebp-18h] + float fTargetPullHighSpeedLimit; // [esp+40h] [ebp-14h] float fTargetPullHighSpeedCrashLimit; // [esp+44h] [ebp-10h] - iSelectedView = SelectedView[iViewIdx]; // Get the selected view type for this view index (a3: 0=player1 view, 1=player2 view) - if (iSelectedView == 1 || iSelectedView == 3)// Only process chase views (view types 1 and 3) + iSelectedView = + SelectedView[iViewIdx]; // Get the selected view type for this view index + // (a3: 0=player1 view, 1=player2 view) + if (iSelectedView == 1 || + iSelectedView == 3) // Only process chase views (view types 1 and 3) { - iControlType = pCar->iControlType; // Get car control type to determine pull behavior - iPullSpeed = 40 * iFrameDelta; // Calculate pull speed increment (40 units per frame) * frame delta - if (iControlType < 2) { // Control type 0: Autopilot/Default car behavior + iControlType = + pCar->iControlType; // Get car control type to determine pull behavior + iPullSpeed = 40 * iFrameDelta; // Calculate pull speed increment (40 units + // per frame) * frame delta + if (iControlType < 2) { // Control type 0: Autopilot/Default car behavior if (!iControlType) { - dChasePullDefault = viewdata[chaseview[iViewIdx]].fChasePullDefault;// Get default chase pull distance from view data + dChasePullDefault = viewdata[chaseview[iViewIdx]] + .fChasePullDefault; // Get default chase pull + // distance from view data //_CHP(); iTargetPullDefault = (int)dChasePullDefault; fTargetPullDefault = (float)dChasePullDefault; @@ -911,9 +1008,12 @@ void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) PULLZ[iViewIndex3] = fTargetPullDefaultFloat; } } - } else if (iControlType <= 3) { // Check if car is stunned/crashed to use crash pull values + } else if (iControlType <= + 3) { // Check if car is stunned/crashed to use crash pull values if (pCar->iStunned) { - dChasePullCrash = viewdata[chaseview[iViewIdx]].fChasePullCrash;// Use crash pull distance for stunned cars + dChasePullCrash = + viewdata[chaseview[iViewIdx]] + .fChasePullCrash; // Use crash pull distance for stunned cars //_CHP(); iTargetPullCrash = (int)dChasePullCrash; fTargetPullCrashFloat = (float)dChasePullCrash; @@ -932,7 +1032,9 @@ void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) PULLZ[iViewIndex] = fTargetPullCrashLimit; } } else { - dChasePullNormal = viewdata[chaseview[iViewIdx]].fChasePullNormal;// Use normal pull distance for active cars + dChasePullNormal = + viewdata[chaseview[iViewIdx]] + .fChasePullNormal; // Use normal pull distance for active cars //_CHP(); iTargetPullNormal = (int)dChasePullNormal; fTargetPullNormal = (float)dChasePullNormal; @@ -951,16 +1053,22 @@ void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) PULLZ[iViewIndex2] = fTargetPullNormalFloat; } } - } else if (iControlType == 1002) // Control type 1002: High-speed mode with modified pull distances + } else if (iControlType == 1002) // Control type 1002: High-speed mode with + // modified pull distances { - iHighSpeedPullIncrement = 160 * iFrameDelta;// Use faster pull speed for high-speed mode (160 units per frame) + iHighSpeedPullIncrement = + 160 * iFrameDelta; // Use faster pull speed for high-speed mode (160 + // units per frame) if (pCar->iStunned) { - dHighSpeedCrashPull = viewdata[chaseview[iViewIdx]].fChasePullCrash + -400.0;// High-speed crash: use crash pull distance minus 400 units + dHighSpeedCrashPull = + viewdata[chaseview[iViewIdx]].fChasePullCrash + + -400.0; // High-speed crash: use crash pull distance minus 400 units //_CHP(); iTargetPullHighSpeedCrash = (int)dHighSpeedCrashPull; fTargetPullHighSpeedCrash = (float)dHighSpeedCrashPull; if (PULLZ[iViewIdx] > (double)fTargetPullHighSpeedCrash) { - dTempHighSpeedCrash = PULLZ[iViewIdx] - (double)iHighSpeedPullIncrement; + dTempHighSpeedCrash = + PULLZ[iViewIdx] - (double)iHighSpeedPullIncrement; PULLZ[iViewIdx] = (float)dTempHighSpeedCrash; if (dTempHighSpeedCrash < fTargetPullHighSpeedCrash) PULLZ[iViewIdx] = fTargetPullHighSpeedCrash; @@ -968,18 +1076,22 @@ void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) fTargetPullHighSpeedCrashLimit = (float)iTargetPullHighSpeedCrash; iViewIndex4 = iViewIdx; if (PULLZ[iViewIndex4] < (double)fTargetPullHighSpeedCrashLimit) { - dTempHighSpeedCrash2 = (double)(40 * iFrameDelta) + PULLZ[iViewIndex4]; + dTempHighSpeedCrash2 = + (double)(40 * iFrameDelta) + PULLZ[iViewIndex4]; PULLZ[iViewIndex4] = (float)dTempHighSpeedCrash2; if (dTempHighSpeedCrash2 > fTargetPullHighSpeedCrashLimit) PULLZ[iViewIndex4] = fTargetPullHighSpeedCrashLimit; } } else { - dHighSpeedNormalPull = viewdata[chaseview[iViewIdx]].fChasePullNormal + 400.0;// High-speed normal: use normal pull distance plus 400 units + dHighSpeedNormalPull = + viewdata[chaseview[iViewIdx]].fChasePullNormal + + 400.0; // High-speed normal: use normal pull distance plus 400 units //_CHP(); iTargetPullHighSpeed = (int)dHighSpeedNormalPull; fTargetPullHighSpeed = (float)dHighSpeedNormalPull; if (PULLZ[iViewIdx] > (double)fTargetPullHighSpeed) { - dTempHighSpeedNormal = PULLZ[iViewIdx] - (double)iHighSpeedPullIncrement; + dTempHighSpeedNormal = + PULLZ[iViewIdx] - (double)iHighSpeedPullIncrement; PULLZ[iViewIdx] = (float)dTempHighSpeedNormal; if (dTempHighSpeedNormal < fTargetPullHighSpeed) PULLZ[iViewIdx] = fTargetPullHighSpeed; @@ -987,7 +1099,8 @@ void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) fTargetPullHighSpeedLimit = (float)iTargetPullHighSpeed; iViewIndex5 = iViewIdx; if (PULLZ[iViewIndex5] < (double)fTargetPullHighSpeedLimit) { - dTempHighSpeedNormal2 = (double)(40 * iFrameDelta) + PULLZ[iViewIndex5]; + dTempHighSpeedNormal2 = + (double)(40 * iFrameDelta) + PULLZ[iViewIndex5]; PULLZ[iViewIndex5] = (float)dTempHighSpeedNormal2; if (dTempHighSpeedNormal2 > fTargetPullHighSpeedLimit) PULLZ[iViewIndex5] = fTargetPullHighSpeedLimit; @@ -998,44 +1111,60 @@ void doviewtend(tCar *pCar, int iFrameDelta, int iViewIdx) } //------------------------------------------------------------------------------------------------- -//00038330 -void changemateto(int iCarIndex, int iNewStrategy) -{ - int iMateCarIndex; // esi - int iRandomValue; // eax - int iSpeechParam; // ecx - int iRandomSpeech; // eax +// 00038330 +void changemateto(int iCarIndex, int iNewStrategy) { + int iMateCarIndex; // esi + int iRandomValue; // eax + int iSpeechParam; // ecx + int iRandomSpeech; // eax int iCooldownCarIndex; // esi if ((iCarIndex & 1) != 0) iMateCarIndex = iCarIndex - 1; else iMateCarIndex = iCarIndex + 1; - if ((char)Car[iMateCarIndex].byLives > 0 && !human_control[iMateCarIndex])// Check if mate car is alive and AI-controlled - { // Check if mate already has the requested strategy - if (iNewStrategy == Car[iMateCarIndex].iSelectedStrategy) { // Play acknowledgment speech when mate already has requested strategy + if ((char)Car[iMateCarIndex].byLives > 0 && + !human_control[iMateCarIndex]) // Check if mate car is alive and + // AI-controlled + { // Check if mate already has the requested strategy + if (iNewStrategy == + Car[iMateCarIndex] + .iSelectedStrategy) { // Play acknowledgment speech when mate + // already has requested strategy // CHEAT_MODE_CLONES - if (player_type != 2 && iCarIndex == player1_car && (cheat_mode & CHEAT_MODE_CLONES) == 0) + if (player_type != 2 && iCarIndex == player1_car && + (cheat_mode & CHEAT_MODE_CLONES) == 0) speechsample(iNewStrategy + 57, 20000, 18, iCarIndex); } else { - iRandomValue = ROLLERrandRaw(); // Random chance (1/4) or cooldown check - mate may refuse strategy change - if (GetHighOrderRand(4, iRandomValue) == 3 || Car[iMateCarIndex].nChangeMateCooldown) { + iRandomValue = ROLLERrandRaw(); // Random chance (1/4) or cooldown check - + // mate may refuse strategy change + if (GetHighOrderRand(4, iRandomValue) == 3 || + Car[iMateCarIndex].nChangeMateCooldown) { // CHEAT_MODE_CLONES - if (player_type == 2 || iCarIndex != player1_car || (cheat_mode & CHEAT_MODE_CLONES) != 0) { + if (player_type == 2 || iCarIndex != player1_car || + (cheat_mode & CHEAT_MODE_CLONES) != 0) { ROLLERrandRaw(); } else { - iSpeechParam = player1_car + ((Car[iMateCarIndex].iSelectedStrategy + 61) << 8);// Play refusal speech sequence when mate rejects strategy change + iSpeechParam = + player1_car + ((Car[iMateCarIndex].iSelectedStrategy + 61) + << 8); // Play refusal speech sequence when mate + // rejects strategy change iRandomSpeech = ROLLERrandRaw(); - speechsample(GetHighOrderRand(2, iRandomSpeech) + 65, 20000, 18, iSpeechParam); - speechsample(Car[iMateCarIndex].iSelectedStrategy + 61, 20000, 0, player1_car); + speechsample(GetHighOrderRand(2, iRandomSpeech) + 65, 20000, 18, + iSpeechParam); + speechsample(Car[iMateCarIndex].iSelectedStrategy + 61, 20000, 0, + player1_car); } iCooldownCarIndex = iMateCarIndex; if (!Car[iCooldownCarIndex].nChangeMateCooldown) - Car[iCooldownCarIndex].nChangeMateCooldown = 1080;// Set strategy change cooldown (1080 ticks) + Car[iCooldownCarIndex].nChangeMateCooldown = + 1080; // Set strategy change cooldown (1080 ticks) } else { - Car[iMateCarIndex].iSelectedStrategy = iNewStrategy;// Accept strategy change and play confirmation speech + Car[iMateCarIndex].iSelectedStrategy = + iNewStrategy; // Accept strategy change and play confirmation speech // CHEAT_MODE_CLONES - if (player_type != 2 && iCarIndex == player1_car && (cheat_mode & CHEAT_MODE_CLONES) == 0) + if (player_type != 2 && iCarIndex == player1_car && + (cheat_mode & CHEAT_MODE_CLONES) == 0) speechsample(iNewStrategy + 57, 20000, 18, iCarIndex); Car[iMateCarIndex].nChangeMateCooldown = 1080; } @@ -1044,9 +1173,9 @@ void changemateto(int iCarIndex, int iNewStrategy) } //------------------------------------------------------------------------------------------------- -//000384C0 -// valid when car movement is not blocked by i.e. fence separating track from run-off area -// top-down view, driving up (= start is down, end is up): +// 000384C0 +// valid when car movement is not blocked by i.e. fence separating track from +// run-off area top-down view, driving up (= start is down, end is up): /****************************************************************** * region=2 f region=1 f region=0 * * e e * @@ -1054,18 +1183,17 @@ void changemateto(int iCarIndex, int iNewStrategy) * c c * * e e * *************** -halfWidth 0 halfWidth ****************/ -bool linevalid(int iChunkIdx, float fStartCoord, float fEndCoord) -{ - tData *pData; // ecx - tTrackInfo *pTrackInfo; // edx +bool linevalid(int iChunkIdx, float fStartCoord, float fEndCoord) { + tData *pData; // ecx + tTrackInfo *pTrackInfo; // edx unsigned int uiStartRegion; // esi - unsigned int uiEndRegion; // ebx - bool iValidResult; // ecx - int iRightSurfaceType; // edi - bool iRightBarierPresent; // ebp - int iLeftSurfaceType; // edi - bool iLeftBarierPresent; // edi - unsigned int iNotRendered; // eax + unsigned int uiEndRegion; // ebx + bool iValidResult; // ecx + int iRightSurfaceType; // edi + bool iRightBarierPresent; // ebp + int iLeftSurfaceType; // edi + bool iLeftBarierPresent; // edi + unsigned int iNotRendered; // eax pData = &localdata[iChunkIdx]; pTrackInfo = &TrackInfo[iChunkIdx]; @@ -1073,19 +1201,19 @@ bool linevalid(int iChunkIdx, float fStartCoord, float fEndCoord) // Classify start coordinate relative to track boundaries if (fStartCoord <= (double)pData->fTrackHalfWidth) { if (-pData->fTrackHalfWidth <= fStartCoord) - uiStartRegion = 1; // inside track boundaries + uiStartRegion = 1; // inside track boundaries else - uiStartRegion = 2; // outside track (negative side) + uiStartRegion = 2; // outside track (negative side) } else { - uiStartRegion = 0; // outside track (positive side) + uiStartRegion = 0; // outside track (positive side) } if (fEndCoord <= (double)pData->fTrackHalfWidth) { if (-pData->fTrackHalfWidth <= fEndCoord) - uiEndRegion = 1; // inside track boundaries + uiEndRegion = 1; // inside track boundaries else - uiEndRegion = 2; // outside track (negative side) + uiEndRegion = 2; // outside track (negative side) } else { - uiEndRegion = 0; // outside track (positive side) + uiEndRegion = 0; // outside track (positive side) } // If both points are in the same region, line doesn't cross track boundaries @@ -1095,116 +1223,120 @@ bool linevalid(int iChunkIdx, float fStartCoord, float fEndCoord) // Check surface types that block visibility iRightSurfaceType = pTrackInfo->iLeftSurfaceType; - if (iRightSurfaceType == 5 || iRightSurfaceType == 6 || iRightSurfaceType == 9) - iRightBarierPresent = true; // surface blocks visibility + if (iRightSurfaceType == 5 || iRightSurfaceType == 6 || + iRightSurfaceType == 9) + iRightBarierPresent = true; // surface blocks visibility else iRightBarierPresent = false; iLeftSurfaceType = pTrackInfo->iRightSurfaceType; if (iLeftSurfaceType == 5 || iLeftSurfaceType == 6 || iLeftSurfaceType == 9) - iLeftBarierPresent = true; // surface blocks visibility + iLeftBarierPresent = true; // surface blocks visibility else iLeftBarierPresent = false; // Check if invisible - iNotRendered = abs(TrakColour[iChunkIdx][TRAK_COLOUR_CENTER]) & SURFACE_FLAG_SKIP_RENDER; + iNotRendered = + abs(TrakColour[iChunkIdx][TRAK_COLOUR_CENTER]) & SURFACE_FLAG_SKIP_RENDER; // Determine line validity based on region crossing and surface blocking - if (!uiStartRegion) // start outside positive side + if (!uiStartRegion) // start outside positive side { - if (!uiEndRegion) // both outside positive (shouldn't happen) + if (!uiEndRegion) // both outside positive (shouldn't happen) return iValidResult; - if (uiEndRegion > 1) // end outside negative side + if (uiEndRegion > 1) // end outside negative side { - // Line crosses entire track, blocked if any barriers present and track rendered + // Line crosses entire track, blocked if any barriers present and track + // rendered if (!iRightBarierPresent && !iLeftBarierPresent && !iNotRendered) - return iValidResult; // valid if no barriers and rendered + return iValidResult; // valid if no barriers and rendered return 0; } - goto CHECK_LEFT_SURFACE; // Start outside positive, end inside track + goto CHECK_LEFT_SURFACE; // Start outside positive, end inside track } - if (uiStartRegion <= 1) // start inside track + if (uiStartRegion <= 1) // start inside track { if (uiEndRegion) { if (uiEndRegion != 2 || !iLeftBarierPresent) - return iValidResult; // valid if crossing to unblocked left surface + return iValidResult; // valid if crossing to unblocked left surface return false; } CHECK_LEFT_SURFACE: - // start on track, end outside positive - check right surface + // start on track, end outside positive - check right surface if (iRightBarierPresent) - return false; // valid if right surface missing + return false; // valid if right surface missing return iValidResult; } // Start=2 = outside negative side - if (!uiEndRegion) // end outside positive + if (!uiEndRegion) // end outside positive { // Line crosses entire track, blocked if no barriers and not rendered if (!iRightBarierPresent && !iLeftBarierPresent && !iNotRendered) - return iValidResult; // valid if no barriers and rendered + return iValidResult; // valid if no barriers and rendered return false; } - if (uiEndRegion != 1) // end not inside track + if (uiEndRegion != 1) // end not inside track return iValidResult; // Start outside negative, end inside - check left surface if (iLeftBarierPresent) - return false; // valid if left surface missing + return false; // valid if left surface missing return iValidResult; } //------------------------------------------------------------------------------------------------- -//00038640 -void analysefalloff(tCar *pCar) -{ - int iCurrChunk; // ecx - double dCarY; // st7 - tData *pData; // esi - tTrackInfo *pInfo; // edi +// 00038640 +void analysefalloff(tCar *pCar) { + int iCurrChunk; // ecx + double dCarY; // st7 + tData *pData; // esi + tTrackInfo *pInfo; // edi unsigned int iLaneType; // ecx - //int64 v7; // rax - //int64 v8; // rax + // int64 v7; // rax + // int64 v8; // rax double dWallPosition; // st7 - int iWallFlag; // edx - int nActualYaw; // ebp - double dSinVelocity; // st7 + int iWallFlag; // edx + int nActualYaw; // ebp + double dSinVelocity; // st7 double dRollMomentum; // st7 - //int64 v14; // rax - //int64 v15; // rax + // int64 v14; // rax + // int64 v15; // rax double dWallPosition2; // st7 - int iWallFlag2; // edx - int iYawTemp; // edx - double dSinVelocity2; // st7 + int iWallFlag2; // edx + int iYawTemp; // edx + double dSinVelocity2; // st7 double dRollMomentum2; // st7 - int iPrevChunk; // eax - //int64 v22; // rax - int iYawTemp2; // edx - double dCosVelocity; // st7 + int iPrevChunk; // eax + // int64 v22; // rax + int iYawTemp2; // edx + double dCosVelocity; // st7 double dRollMomentum3; // st7 - //int64 v26; // rax - int iYawTemp3; // edx - double dCosVelocity2; // st7 - double dRollMomentum4; // st7 - float fCosVelocity; // [esp+0h] [ebp-34h] - float fSinVelocity; // [esp+0h] [ebp-34h] - float fSinVelocity2; // [esp+0h] [ebp-34h] - float fSinVelocityTemp; // [esp+4h] [ebp-30h] - float fCosVelocityTemp; // [esp+8h] [ebp-2Ch] + // int64 v26; // rax + int iYawTemp3; // edx + double dCosVelocity2; // st7 + double dRollMomentum4; // st7 + float fCosVelocity; // [esp+0h] [ebp-34h] + float fSinVelocity; // [esp+0h] [ebp-34h] + float fSinVelocity2; // [esp+0h] [ebp-34h] + float fSinVelocityTemp; // [esp+4h] [ebp-30h] + float fCosVelocityTemp; // [esp+8h] [ebp-2Ch] float fCosVelocityTemp2; // [esp+Ch] [ebp-28h] float fSinVelocityTemp2; // [esp+10h] [ebp-24h] float fCosVelocityTemp3; // [esp+14h] [ebp-20h] - float fTrackHalfWidth; // [esp+18h] [ebp-1Ch] - float fWallPosition; // [esp+18h] [ebp-1Ch] + float fTrackHalfWidth; // [esp+18h] [ebp-1Ch] + float fWallPosition; // [esp+18h] [ebp-1Ch] iCurrChunk = pCar->nCurrChunk; dCarY = pCar->pos.fY; pData = &localdata[iCurrChunk]; pCar->iRollMomentum = 0; pInfo = &TrackInfo[iCurrChunk]; - if (dCarY <= pData->fTrackHalfWidth) // Determine which lane/area the car is in: 0=left shoulder, 1=on track, 2=right shoulder + if (dCarY <= + pData->fTrackHalfWidth) // Determine which lane/area the car is in: 0=left + // shoulder, 1=on track, 2=right shoulder { if (-pData->fTrackHalfWidth <= pCar->pos.fY) iLaneType = 1; @@ -1213,56 +1345,81 @@ void analysefalloff(tCar *pCar) } else { iLaneType = 0; } - if (!iLaneType) // Handle left shoulder collision - set wall position and check for wall collision + if (!iLaneType) // Handle left shoulder collision - set wall position and + // check for wall collision { dWallPosition = pData->fTrackHalfWidth + pInfo->fLShoulderWidth; iWallFlag = -1; goto LABEL_11; } if (iLaneType > 1) { - //v8 = TrakColour[pCar->nCurrChunk][1]; + // v8 = TrakColour[pCar->nCurrChunk][1]; dWallPosition = -pData->fTrackHalfWidth; - iWallFlag = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_CENTER] & SURFACE_FLAG_SKIP_RENDER;// ((HIDWORD(v8) ^ v8) - HIDWORD(v8)) & 0x20000; + iWallFlag = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_CENTER] & + SURFACE_FLAG_SKIP_RENDER; // ((HIDWORD(v8) ^ v8) - HIDWORD(v8)) + // & 0x20000; LABEL_11: fTrackHalfWidth = (float)dWallPosition; goto LABEL_12; } - //v7 = TrakColour[pCar->nCurrChunk][0]; - iWallFlag = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_LEFT_LANE] & SURFACE_FLAG_SKIP_RENDER; //((HIDWORD(v7) ^ v7) - HIDWORD(v7)) & 0x20000; + // v7 = TrakColour[pCar->nCurrChunk][0]; + iWallFlag = + TrakColour[pCar->nCurrChunk][TRAK_COLOUR_LEFT_LANE] & + SURFACE_FLAG_SKIP_RENDER; //((HIDWORD(v7) ^ v7) - HIDWORD(v7)) & 0x20000; fTrackHalfWidth = pData->fTrackHalfWidth; LABEL_12: - if (iWallFlag && fTrackHalfWidth < pCar->fCarHalfWidth * 0.5 + pCar->pos.fY)// Check if car is hitting the wall - if wall exists and car position exceeds wall boundary + if (iWallFlag && + fTrackHalfWidth < + pCar->fCarHalfWidth * 0.5 + + pCar->pos.fY) // Check if car is hitting the wall - if wall exists + // and car position exceeds wall boundary { nActualYaw = pCar->nActualYaw; - dSinVelocity = pCar->fFinalSpeed * tsin[nActualYaw];// Calculate lateral velocity component (sin component) for wall collision handling + dSinVelocity = + pCar->fFinalSpeed * + tsin[nActualYaw]; // Calculate lateral velocity component (sin + // component) for wall collision handling if (dSinVelocity < 30.0) { fSinVelocityTemp2 = (float)dSinVelocity; if (fSinVelocityTemp2 >= 0.0) { fCosVelocityTemp3 = pCar->fFinalSpeed * tcos[nActualYaw]; - pCar->nActualYaw = getangle(fCosVelocityTemp3, 40.0);// Adjust car yaw and speed when bouncing off left wall - redirect momentum - pCar->fFinalSpeed = (float)sqrt(fCosVelocityTemp3 * fCosVelocityTemp3 + 1600.0); + pCar->nActualYaw = getangle( + fCosVelocityTemp3, 40.0); // Adjust car yaw and speed when bouncing + // off left wall - redirect momentum + pCar->fFinalSpeed = + (float)sqrt(fCosVelocityTemp3 * fCosVelocityTemp3 + 1600.0); } } - dRollMomentum = tcos[pCar->nYaw] * 200.0 + (double)pCar->iRollMomentum;// Apply roll momentum based on car orientation - banking effect on slopes + dRollMomentum = + tcos[pCar->nYaw] * 200.0 + + (double)pCar->iRollMomentum; // Apply roll momentum based on car + // orientation - banking effect on slopes //_CHP(); pCar->iRollMomentum = (int)dRollMomentum; } if (iLaneType) { if (iLaneType <= 1) { - //v15 = TrakColour[pCar->nCurrChunk][2]; + // v15 = TrakColour[pCar->nCurrChunk][2]; dWallPosition2 = -pData->fTrackHalfWidth; - iWallFlag2 = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_RIGHT_LANE] & SURFACE_FLAG_SKIP_RENDER;//((HIDWORD(v15) ^ v15) - HIDWORD(v15)) & 0x20000; + iWallFlag2 = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_RIGHT_LANE] & + SURFACE_FLAG_SKIP_RENDER; //((HIDWORD(v15) ^ v15) - + // HIDWORD(v15)) & 0x20000; } else { dWallPosition2 = -pData->fTrackHalfWidth - pInfo->fRShoulderWidth; iWallFlag2 = -1; } fWallPosition = (float)dWallPosition2; } else { - //v14 = TrakColour[pCar->nCurrChunk][1]; - iWallFlag2 = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_CENTER] & SURFACE_FLAG_SKIP_RENDER; //((HIDWORD(v14) ^ v14) - HIDWORD(v14)) & 0x20000; + // v14 = TrakColour[pCar->nCurrChunk][1]; + iWallFlag2 = TrakColour[pCar->nCurrChunk][TRAK_COLOUR_CENTER] & + SURFACE_FLAG_SKIP_RENDER; //((HIDWORD(v14) ^ v14) - + // HIDWORD(v14)) & 0x20000; fWallPosition = pData->fTrackHalfWidth; } - if (iWallFlag2 && fWallPosition > pCar->pos.fY - pCar->fCarHalfWidth * 0.5)// Check for right wall collision - mirror of left wall logic + if (iWallFlag2 && + fWallPosition > pCar->pos.fY - pCar->fCarHalfWidth * + 0.5) // Check for right wall collision + // - mirror of left wall logic { iYawTemp = pCar->nActualYaw; dSinVelocity2 = pCar->fFinalSpeed * tsin[iYawTemp]; @@ -1270,7 +1427,9 @@ void analysefalloff(tCar *pCar) fSinVelocityTemp = (float)dSinVelocity2; if (fSinVelocityTemp <= 0.0) { fCosVelocity = pCar->fFinalSpeed * tcos[iYawTemp]; - pCar->nActualYaw = getangle(fCosVelocity, -40.0);// Adjust car yaw and speed when bouncing off right wall + pCar->nActualYaw = getangle( + fCosVelocity, + -40.0); // Adjust car yaw and speed when bouncing off right wall pCar->fFinalSpeed = (float)sqrt(fCosVelocity * fCosVelocity + 1600.0); } } @@ -1278,19 +1437,26 @@ void analysefalloff(tCar *pCar) //_CHP(); pCar->iRollMomentum = (int)dRollMomentum2; } - iPrevChunk = pCar->nCurrChunk - 1; // Check previous track chunk for front wall collision + iPrevChunk = pCar->nCurrChunk - + 1; // Check previous track chunk for front wall collision if (iPrevChunk < 0) iPrevChunk = TRAK_LEN - 1; - //v22 = TrakColour[iPrevChunk][iLaneType]; - //if ((((HIDWORD(v22) ^ (unsigned int)v22) - HIDWORD(v22)) & 0x20000) != 0 && -pData->fTrackHalfLength > pCar->pos.fX - pCar->fCarWidthBankingProjection * 0.5) { - if ((TrakColour[iPrevChunk][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0 && -pData->fTrackHalfLength > pCar->pos.fX - pCar->fCarWidthBankingProjection * 0.5) { + // v22 = TrakColour[iPrevChunk][iLaneType]; + // if ((((HIDWORD(v22) ^ (unsigned int)v22) - HIDWORD(v22)) & 0x20000) != 0 && + // -pData->fTrackHalfLength > pCar->pos.fX - pCar->fCarWidthBankingProjection + // * 0.5) { + if ((TrakColour[iPrevChunk][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0 && + -pData->fTrackHalfLength > + pCar->pos.fX - pCar->fCarWidthBankingProjection * 0.5) { iYawTemp2 = pCar->nActualYaw; dCosVelocity = pCar->fFinalSpeed * tcos[iYawTemp2]; if (dCosVelocity > -30.0) { fCosVelocityTemp2 = (float)dCosVelocity; if (fCosVelocityTemp2 <= 0.0) { fSinVelocity = pCar->fFinalSpeed * tsin[iYawTemp2]; - pCar->nActualYaw = getangle(-40.0, fSinVelocity);// Handle front wall collision - adjust yaw by redirecting forward momentum + pCar->nActualYaw = getangle( + -40.0, fSinVelocity); // Handle front wall collision - adjust yaw by + // redirecting forward momentum pCar->fFinalSpeed = (float)sqrt(fSinVelocity * fSinVelocity + 1600.0); } } @@ -1298,16 +1464,23 @@ void analysefalloff(tCar *pCar) //_CHP(); pCar->iRollMomentum = (int)dRollMomentum3; } - //v26 = TrakColour[pCar->nCurrChunk + 1][iLaneType];// Check next track chunk for rear wall collision - //if ((((HIDWORD(v26) ^ (unsigned int)v26) - HIDWORD(v26)) & 0x20000) != 0 && pData->fTrackHalfLength < pCar->fCarWidthBankingProjection * 0.5 + pCar->pos.fX) { - if ((TrakColour[pCar->nCurrChunk + 1][iLaneType] & SURFACE_FLAG_SKIP_RENDER) != 0 && pData->fTrackHalfLength < pCar->fCarWidthBankingProjection * 0.5 + pCar->pos.fX) { + // v26 = TrakColour[pCar->nCurrChunk + 1][iLaneType];// Check next track chunk + // for rear wall collision if ((((HIDWORD(v26) ^ (unsigned int)v26) - + // HIDWORD(v26)) & 0x20000) != 0 && pData->fTrackHalfLength < + // pCar->fCarWidthBankingProjection * 0.5 + pCar->pos.fX) { + if ((TrakColour[pCar->nCurrChunk + 1][iLaneType] & + SURFACE_FLAG_SKIP_RENDER) != 0 && + pData->fTrackHalfLength < + pCar->fCarWidthBankingProjection * 0.5 + pCar->pos.fX) { iYawTemp3 = pCar->nActualYaw; dCosVelocity2 = pCar->fFinalSpeed * tcos[iYawTemp3]; if (dCosVelocity2 < 30.0) { fCosVelocityTemp = (float)dCosVelocity2; if (fCosVelocityTemp >= 0.0) { fSinVelocity2 = pCar->fFinalSpeed * tsin[iYawTemp3]; - pCar->nActualYaw = getangle(40.0, fSinVelocity2);// Handle rear wall collision - adjust yaw by redirecting backward momentum + pCar->nActualYaw = getangle( + 40.0, fSinVelocity2); // Handle rear wall collision - adjust yaw by + // redirecting backward momentum pCar->fFinalSpeed = (float)sqrt(fSinVelocity2 * fSinVelocity2 + 1600.0); } } @@ -1318,86 +1491,87 @@ void analysefalloff(tCar *pCar) } //------------------------------------------------------------------------------------------------- -//00038A80 -void showmap(uint8 *pScrPtr, int iCarIdx) -{ - int iChunk2; // edx - int iNextChunk; // eax - tData *pCurrChunkData; // edx - tData *pNextChunkData; // ebx - tData *pCarChunkData; // eax - double dInvScale; // st5 - double dRelX; // st7 - double dRelY; // st6 - double dRotatedY_1; // st7 - int iCalcResult; // eax - int iScreenX2; // eax - int iScreenY; // ebx - int iMapSect; // edi - tData *pSectionData; // eax +// 00038A80 +void showmap(uint8 *pScrPtr, int iCarIdx) { + int iChunk2; // edx + int iNextChunk; // eax + tData *pCurrChunkData; // edx + tData *pNextChunkData; // ebx + tData *pCarChunkData; // eax + double dInvScale; // st5 + double dRelX; // st7 + double dRelY; // st6 + double dRotatedY_1; // st7 + int iCalcResult; // eax + int iScreenX2; // eax + int iScreenY; // ebx + int iMapSect; // edi + tData *pSectionData; // eax double dSectionInvScale; // st5 - double dSectionRelX; // st7 - double dSectionRelY; // st6 - //int iAngleIndex; // eax + double dSectionRelX; // st7 + double dSectionRelY; // st6 + // int iAngleIndex; // eax double dSectionRotatedY; // st7 - int iSectionCalc; // eax - int iNextScreenX; // edx - int iCurrentScreenX; // edx - int iMapSectLoop; // edi - int iCurrentScreenY; // ebx + int iSectionCalc; // eax + int iNextScreenX; // edx + int iCurrentScreenX; // edx + int iMapSectLoop; // edi + int iCurrentScreenY; // ebx tData *pLoopSectionData; // eax - double dLoopRelX; // st7 - double dLoopRelY; // st6 - //int iLoopAngleIndex; // eax - double dLoopRotatedY; // st7 - int iLoopCalc; // eax - int iLastSection; // eax - int iWinWidth; // esi - int iMarkerY; // edx - int iCurrentX; // eax - int i; // ebx - tCar *pCarArray; // eax - tCar *pCurrentCar; // edi - int iCurrChunk; // edx - float *pChunkTransform; // edx - double dCarInvScale; // st5 - double dTransformedX; // st7 - double dTransformedY; // st6 - double dRotatedX; // st5 - double dRotatedY; // st7 - int iScreenSize; // ecx - int iCarScreenCalc; // edx - int iDriverIdx; // edx - int iColorIndex; // edx - uint8 *pCarPixel; // ebx - int iCarColor; // edx - uint8 *pPlayerPixel; // eax - float fDeltaX; // [esp+0h] [ebp-9Ch] - float fDeltaY; // [esp+4h] [ebp-98h] - int iViewAngle; // [esp+1Ch] [ebp-80h] - int iX1; // [esp+20h] [ebp-7Ch] - int iOrigScreenY; // [esp+24h] [ebp-78h] - int iPlayerScreenY; // [esp+34h] [ebp-68h] - int iPlayerScreenX; // [esp+3Ch] [ebp-60h] - int iPlayerColor; // [esp+44h] [ebp-58h] - float fInvScale; // [esp+48h] [ebp-54h] - float fMapScale; // [esp+4Ch] [ebp-50h] - float fX; // [esp+50h] [ebp-4Ch] - float fY; // [esp+54h] [ebp-48h] - int iPixelLoop; // [esp+58h] [ebp-44h] - int iCarLoop; // [esp+5Ch] [ebp-40h] + double dLoopRelX; // st7 + double dLoopRelY; // st6 + // int iLoopAngleIndex; // eax + double dLoopRotatedY; // st7 + int iLoopCalc; // eax + int iLastSection; // eax + int iWinWidth; // esi + int iMarkerY; // edx + int iCurrentX; // eax + int i; // ebx + tCar *pCarArray; // eax + tCar *pCurrentCar; // edi + int iCurrChunk; // edx + float *pChunkTransform; // edx + double dCarInvScale; // st5 + double dTransformedX; // st7 + double dTransformedY; // st6 + double dRotatedX; // st5 + double dRotatedY; // st7 + int iScreenSize; // ecx + int iCarScreenCalc; // edx + int iDriverIdx; // edx + int iColorIndex; // edx + uint8 *pCarPixel; // ebx + int iCarColor; // edx + uint8 *pPlayerPixel; // eax + float fDeltaX; // [esp+0h] [ebp-9Ch] + float fDeltaY; // [esp+4h] [ebp-98h] + int iViewAngle; // [esp+1Ch] [ebp-80h] + int iX1; // [esp+20h] [ebp-7Ch] + int iOrigScreenY; // [esp+24h] [ebp-78h] + int iPlayerScreenY; // [esp+34h] [ebp-68h] + int iPlayerScreenX; // [esp+3Ch] [ebp-60h] + int iPlayerColor; // [esp+44h] [ebp-58h] + float fInvScale; // [esp+48h] [ebp-54h] + float fMapScale; // [esp+4Ch] [ebp-50h] + float fX; // [esp+50h] [ebp-4Ch] + float fY; // [esp+54h] [ebp-48h] + int iPixelLoop; // [esp+58h] [ebp-44h] + int iCarLoop; // [esp+5Ch] [ebp-40h] int iSectionScreenXTemp; // [esp+6Ch] [ebp-30h] - int iSectionScreenY; // [esp+70h] [ebp-2Ch] - int iSectionScreenX; // [esp+74h] [ebp-28h] - int iY1; // [esp+78h] [ebp-24h] - tData *pData; // [esp+7Ch] [ebp-20h] - int iCarScreenY; // [esp+80h] [ebp-1Ch] - int iCarScreenX; // [esp+84h] [ebp-18h] + int iSectionScreenY; // [esp+70h] [ebp-2Ch] + int iSectionScreenX; // [esp+74h] [ebp-28h] + int iY1; // [esp+78h] [ebp-24h] + tData *pData; // [esp+7Ch] [ebp-20h] + int iCarScreenY; // [esp+80h] [ebp-1Ch] + int iCarScreenX; // [esp+84h] [ebp-18h] - fMapScale = cur_mapsize; // Set base map scale - if ((cheat_mode & CHEAT_MODE_DOUBLE_TRACK) != 0) // Double scale if cheat mode bit 0x1000 is set + fMapScale = cur_mapsize; // Set base map scale + if ((cheat_mode & CHEAT_MODE_DOUBLE_TRACK) != + 0) // Double scale if cheat mode bit 0x1000 is set fMapScale = cur_mapsize * 2.0f; - iChunk2 = Car[iCarIdx].nReferenceChunk; // Calculate view angle based on car direction + iChunk2 = Car[iCarIdx] + .nReferenceChunk; // Calculate view angle based on car direction iNextChunk = iChunk2 + 1; if (iChunk2 + 1 == TRAK_LEN) iNextChunk ^= TRAK_LEN; @@ -1407,15 +1581,20 @@ void showmap(uint8 *pScrPtr, int iCarIdx) fDeltaX = pCurrChunkData->pointAy[3].fX - pNextChunkData->pointAy[3].fX; iViewAngle = (4096 - (uint16)getangle(fDeltaX, fDeltaY)) & 0x3FFF; pCarChunkData = &localdata[Car[iCarIdx].nReferenceChunk]; - dInvScale = 1.0 / fMapScale; // Setup coordinate transformation for map display - dRelX = (pCarChunkData->pointAy[3].fX - localdata[0].pointAy[3].fX) * dInvScale; - dRelY = (pCarChunkData->pointAy[3].fY - localdata[0].pointAy[3].fY) * dInvScale; + dInvScale = + 1.0 / fMapScale; // Setup coordinate transformation for map display + dRelX = + (pCarChunkData->pointAy[3].fX - localdata[0].pointAy[3].fX) * dInvScale; + dRelY = + (pCarChunkData->pointAy[3].fY - localdata[0].pointAy[3].fY) * dInvScale; pData = pCarChunkData; - dRotatedX = dRelX * tcos[iViewAngle] - dRelY * tsin[iViewAngle]; //line skipped decompiler artifact + dRotatedX = dRelX * tcos[iViewAngle] - + dRelY * tsin[iViewAngle]; // line skipped decompiler artifact //_CHP(); dRotatedY_1 = dRelX * tsin[iViewAngle] + dRelY * tcos[iViewAngle]; //_CHP(); - iCalcResult = scr_size * ((int)dRotatedX + 38); //line skipped decompiler artifact + iCalcResult = + scr_size * ((int)dRotatedX + 38); // line skipped decompiler artifact iScreenX2 = iCalcResult >> 6; iX1 = iScreenX2; iScreenY = (scr_size * (160 - (int)dRotatedY_1)) >> 6; @@ -1423,21 +1602,28 @@ void showmap(uint8 *pScrPtr, int iCarIdx) iOrigScreenY = iScreenY; while (1) { - iNextScreenX = iScreenX2 + 1; // Draw track centerline segments + iNextScreenX = iScreenX2 + 1; // Draw track centerline segments if (iMapSect >= TRAK_LEN) break; pSectionData = &localdata[iMapSect]; dSectionInvScale = 1.0 / fMapScale; - dSectionRelX = (pData->pointAy[3].fX - pSectionData->pointAy[3].fX) * dSectionInvScale; - dSectionRelY = (pData->pointAy[3].fY - pSectionData->pointAy[3].fY) * dSectionInvScale; - dRotatedX = dSectionRelX * tcos[iViewAngle] - dSectionRelY * tsin[iViewAngle]; //line skipped decompiler artifact + dSectionRelX = + (pData->pointAy[3].fX - pSectionData->pointAy[3].fX) * dSectionInvScale; + dSectionRelY = + (pData->pointAy[3].fY - pSectionData->pointAy[3].fY) * dSectionInvScale; + dRotatedX = + dSectionRelX * tcos[iViewAngle] - + dSectionRelY * tsin[iViewAngle]; // line skipped decompiler artifact //_CHP(); - dSectionRotatedY = dSectionRelX * tsin[iViewAngle] + dSectionRelY * tcos[iViewAngle]; + dSectionRotatedY = + dSectionRelX * tsin[iViewAngle] + dSectionRelY * tcos[iViewAngle]; //_CHP(); - iSectionCalc = scr_size * ((int)dRotatedX + 38); //line skipped decompiler artifact + iSectionCalc = + scr_size * ((int)dRotatedX + 38); // line skipped decompiler artifact iSectionScreenXTemp = iSectionCalc >> 6; iSectionScreenY = (scr_size * (160 - (int)dSectionRotatedY)) >> 6; - compout(pScrPtr, iNextScreenX, iScreenY, (iSectionCalc >> 6) + 1, iSectionScreenY, 0x70u); + compout(pScrPtr, iNextScreenX, iScreenY, (iSectionCalc >> 6) + 1, + iSectionScreenY, 0x70u); iScreenX2 = iSectionScreenXTemp; iScreenY = iSectionScreenY; iMapSect += cur_mapsect; @@ -1446,41 +1632,56 @@ void showmap(uint8 *pScrPtr, int iCarIdx) iCurrentScreenX = iX1; iMapSectLoop = cur_mapsect; iCurrentScreenY = iOrigScreenY; - if (cur_mapsect < TRAK_LEN) // Draw track edges with different colors + if (cur_mapsect < TRAK_LEN) // Draw track edges with different colors { fInvScale = 1.0f / fMapScale; do { pLoopSectionData = &localdata[iMapSectLoop]; - dLoopRelX = (pData->pointAy[3].fX - pLoopSectionData->pointAy[3].fX) * fInvScale; - dLoopRelY = (pData->pointAy[3].fY - pLoopSectionData->pointAy[3].fY) * fInvScale; - dRotatedX = dLoopRelX * tcos[iViewAngle] - dLoopRelY * tsin[iViewAngle]; //line skipped decompiler artifact + dLoopRelX = + (pData->pointAy[3].fX - pLoopSectionData->pointAy[3].fX) * fInvScale; + dLoopRelY = + (pData->pointAy[3].fY - pLoopSectionData->pointAy[3].fY) * fInvScale; + dRotatedX = + dLoopRelX * tcos[iViewAngle] - + dLoopRelY * tsin[iViewAngle]; // line skipped decompiler artifact //_CHP(); - dLoopRotatedY = dLoopRelX * tsin[iViewAngle] + dLoopRelY * tcos[iViewAngle]; + dLoopRotatedY = + dLoopRelX * tsin[iViewAngle] + dLoopRelY * tcos[iViewAngle]; //_CHP(); - iLoopCalc = scr_size * ((int)dRotatedX + 38); //line skipped decompiler artifact + iLoopCalc = + scr_size * ((int)dRotatedX + 38); // line skipped decompiler artifact iSectionScreenX = iLoopCalc >> 6; iY1 = (scr_size * (160 - (int)dLoopRotatedY)) >> 6; - if ((TrakColour[iMapSectLoop][0] & SURFACE_FLAG_PIT_ZONE) != 0 || (TrakColour[iMapSectLoop][1] & SURFACE_FLAG_PIT_ZONE) != 0 || (TrakColour[iMapSectLoop][2] & SURFACE_FLAG_PIT_ZONE) != 0) - compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iSectionScreenX, iY1, 0xCDu); + if ((TrakColour[iMapSectLoop][0] & SURFACE_FLAG_PIT_ZONE) != 0 || + (TrakColour[iMapSectLoop][1] & SURFACE_FLAG_PIT_ZONE) != 0 || + (TrakColour[iMapSectLoop][2] & SURFACE_FLAG_PIT_ZONE) != 0) + compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iSectionScreenX, iY1, + 0xCDu); else - compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iSectionScreenX, iY1, 0x83u); + compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iSectionScreenX, iY1, + 0x83u); iCurrentScreenX = iSectionScreenX; iMapSectLoop += cur_mapsect; iCurrentScreenY = iY1; } while (iMapSectLoop < TRAK_LEN); } iLastSection = TRAK_LEN - 1; - if ((TrakColour[iLastSection][0] & SURFACE_FLAG_PIT_ZONE) != 0 || (TrakColour[iLastSection][1] & SURFACE_FLAG_PIT_ZONE) != 0 || (TrakColour[iLastSection][2] & SURFACE_FLAG_PIT_ZONE) != 0) - compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iX1, iOrigScreenY, 0xCDu); + if ((TrakColour[iLastSection][0] & SURFACE_FLAG_PIT_ZONE) != 0 || + (TrakColour[iLastSection][1] & SURFACE_FLAG_PIT_ZONE) != 0 || + (TrakColour[iLastSection][2] & SURFACE_FLAG_PIT_ZONE) != 0) + compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iX1, iOrigScreenY, + 0xCDu); else - compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iX1, iOrigScreenY, 0x83u); - iPixelLoop = 0; // Draw 3x3 pixel marker at player position + compout(pScrPtr, iCurrentScreenX, iCurrentScreenY, iX1, iOrigScreenY, + 0x83u); + iPixelLoop = 0; // Draw 3x3 pixel marker at player position iWinWidth = winw; iMarkerY = iOrigScreenY - 1; do { iCurrentX = iX1 - 1; for (i = 0; i < 3; ++i) { - if (iCurrentX >= 0 && iCurrentX < iWinWidth && iMarkerY >= 0 && iMarkerY < winh) + if (iCurrentX >= 0 && iCurrentX < iWinWidth && iMarkerY >= 0 && + iMarkerY < winh) pScrPtr[iCurrentX + iWinWidth * iMarkerY] = -117; ++iCurrentX; } @@ -1488,13 +1689,13 @@ void showmap(uint8 *pScrPtr, int iCarIdx) ++iPixelLoop; } while (iPixelLoop < 3); iCarLoop = 0; - if (numcars > 0) // Draw all cars on the minimap + if (numcars > 0) // Draw all cars on the minimap { pCarArray = Car; do { pCurrentCar = pCarArray; if ((char)pCarArray->byLives > 0) { - iCurrChunk = pCarArray->nCurrChunk; // Calculate car position on track + iCurrChunk = pCarArray->nCurrChunk; // Calculate car position on track if (iCurrChunk == -1) { fX = pCarArray->pos.fX; fY = pCarArray->pos.fY; @@ -1503,27 +1704,33 @@ void showmap(uint8 *pScrPtr, int iCarIdx) fX = *pChunkTransform * pCarArray->pos.fX - pChunkTransform[9]; fY = pChunkTransform[3] * pCarArray->pos.fX - pChunkTransform[10]; } - dCarInvScale = 1.0 / fMapScale; // Transform car position to screen coordinates + dCarInvScale = + 1.0 / fMapScale; // Transform car position to screen coordinates dTransformedX = (fX + pData->pointAy[3].fX) * dCarInvScale; dTransformedY = (fY + pData->pointAy[3].fY) * dCarInvScale; - dRotatedX = dTransformedX * tcos[iViewAngle] - dTransformedY * tsin[iViewAngle]; + dRotatedX = + dTransformedX * tcos[iViewAngle] - dTransformedY * tsin[iViewAngle]; //_CHP(); - dRotatedY = dTransformedX * tsin[iViewAngle] + dTransformedY * tcos[iViewAngle]; + dRotatedY = + dTransformedX * tsin[iViewAngle] + dTransformedY * tcos[iViewAngle]; iScreenSize = scr_size; iCarScreenCalc = scr_size * ((int)dRotatedX + 38); //_CHP(); iCarScreenX = iCarScreenCalc >> 6; iCarScreenY = (iScreenSize * (160 - (int)dRotatedY)) >> 6; iDriverIdx = pCurrentCar->iDriverIdx; - if (iDriverIdx == iCarIdx) // Special handling for player car (larger marker) + if (iDriverIdx == + iCarIdx) // Special handling for player car (larger marker) { - //iColorIndex = iCarIdx ^ iDriverIdx; - //LOBYTE(iColorIndex) = pCurrentCar->byCarDesignIdx; + // iColorIndex = iCarIdx ^ iDriverIdx; + // LOBYTE(iColorIndex) = pCurrentCar->byCarDesignIdx; iColorIndex = pCurrentCar->byCarDesignIdx; iPlayerColor = team_col[iColorIndex]; iPlayerScreenX = iCarScreenX; iPlayerScreenY = (iScreenSize * (160 - (int)dRotatedY)) >> 6; - } else if (iCarScreenX > 0 && iWinWidth - 1 > iCarScreenX && iCarScreenY > 0 && winh - 1 > iCarScreenY)// Draw car marker (cross pattern) + } else if (iCarScreenX > 0 && iWinWidth - 1 > iCarScreenX && + iCarScreenY > 0 && + winh - 1 > iCarScreenY) // Draw car marker (cross pattern) { pCarPixel = &pScrPtr[iCarScreenX + iWinWidth * iCarScreenY]; iCarColor = team_col[pCurrentCar->byCarDesignIdx]; @@ -1540,7 +1747,8 @@ void showmap(uint8 *pScrPtr, int iCarIdx) ++iCarLoop; } while (iCarLoop < numcars); } - if ((char)Car[iCarIdx].byLives > 0 && (Car[iCarIdx].byRacePosition || (frames & 8) != 0)) { + if ((char)Car[iCarIdx].byLives > 0 && + (Car[iCarIdx].byRacePosition || (frames & 8) != 0)) { pPlayerPixel = &pScrPtr[iPlayerScreenX + iWinWidth * iPlayerScreenY]; *(pPlayerPixel - 1) = iPlayerColor; *(pPlayerPixel - 2) = iPlayerColor; @@ -1556,48 +1764,49 @@ void showmap(uint8 *pScrPtr, int iCarIdx) } //------------------------------------------------------------------------------------------------- -//000390D0 -void firework_display() -{ - int i; // ebp - tCarSpray *pSprayData; // ebx - uint8 byType; // al - int iRandTimer; // eax - int iTimerCount; // esi - int iWidthDiv3; // edx - int iRandX; // eax - int iRandVelX; // eax - int iRandLifetime; // eax - int iLifetimeCount; // eax - int iRandColor; // eax - int iParticleCount; // ecx - int iFireworkColor; // esi - int iRandAngle; // eax - int iAngleIndex; // edx - double dRandVelocity; // st7 - int iRandParticleLife; // eax - double dVelocityY; // st6 - double dVelocityX; // st7 - int iActiveParticles; // edx - int j; // eax - int iLifeTime; // ecx - double dParticleVelY; // st6 - double dParticleVelX; // st7 +// 000390D0 +void firework_display() { + int i; // ebp + tCarSpray *pSprayData; // ebx + uint8 byType; // al + int iRandTimer; // eax + int iTimerCount; // esi + int iWidthDiv3; // edx + int iRandX; // eax + int iRandVelX; // eax + int iRandLifetime; // eax + int iLifetimeCount; // eax + int iRandColor; // eax + int iParticleCount; // ecx + int iFireworkColor; // esi + int iRandAngle; // eax + int iAngleIndex; // edx + double dRandVelocity; // st7 + int iRandParticleLife; // eax + double dVelocityY; // st6 + double dVelocityX; // st7 + int iActiveParticles; // edx + int j; // eax + int iLifeTime; // ecx + double dParticleVelY; // st6 + double dParticleVelX; // st7 tCarSpray *pCleanupSpray; // eax - float fOrigVelY; // [esp+10h] [ebp-28h] - float fY; // [esp+14h] [ebp-24h] - float fX; // [esp+18h] [ebp-20h] - float fOrigVelX; // [esp+1Ch] [ebp-1Ch] + float fOrigVelY; // [esp+10h] [ebp-28h] + float fY; // [esp+14h] [ebp-24h] + float fX; // [esp+18h] [ebp-20h] + float fOrigVelX; // [esp+1Ch] [ebp-1Ch] - for (updates = 0; readptr != writeptr; readptr = ((uint16)readptr + 1) & 0x1FF) { // Only advance animation if not paused + for (updates = 0; readptr != writeptr; + readptr = ((uint16)readptr + 1) & + 0x1FF) { // Only advance animation if not paused if (!paused) ++updates; dozoomstuff(0); - if (readptr >= 0) { // Process all 18 firework spray slots + if (readptr >= 0) { // Process all 18 firework spray slots for (i = 0; i != 18; ++i) { pSprayData = CarSpray[i]; byType = CarSpray[i][0].iType; - if (byType) { // Handle ascending rocket (type 1) + if (byType) { // Handle ascending rocket (type 1) if (byType <= 1u) { iLifetimeCount = pSprayData->iLifeTime - 1; pSprayData->iLifeTime = iLifetimeCount; @@ -1606,24 +1815,29 @@ void firework_display() memcpy(&CarSpray[i][3], &CarSpray[i][2], sizeof(CarSpray[i][3])); memcpy(&CarSpray[i][2], &CarSpray[i][1], sizeof(CarSpray[i][2])); memcpy(&CarSpray[i][1], CarSpray[i], sizeof(CarSpray[i][1])); - dVelocityY = pSprayData->velocity.fY + 0.1;// Apply gravity and update rocket position + dVelocityY = pSprayData->velocity.fY + + 0.1; // Apply gravity and update rocket position pSprayData->velocity.fY = (float)dVelocityY; - pSprayData->position.fY = (float)dVelocityY + pSprayData->position.fY; + pSprayData->position.fY = + (float)dVelocityY + pSprayData->position.fY; dVelocityX = pSprayData->velocity.fX + pSprayData->position.fX; pSprayData->iColor = 0x8F; pSprayData->position.fX = (float)dVelocityX; } else { - sfxsample(SOUND_SAMPLE_EXPLO, 0x8000); // Rocket reached peak - create explosion particles + sfxsample( + SOUND_SAMPLE_EXPLO, + 0x8000); // Rocket reached peak - create explosion particles fX = pSprayData->position.fX; fY = pSprayData->position.fY; fOrigVelX = pSprayData->velocity.fX; fOrigVelY = pSprayData->velocity.fY; iRandColor = ROLLERrandRaw(); iParticleCount = 0; - iFireworkColor = firework_colours[GetHighOrderRand(12, iRandColor)]; + iFireworkColor = + firework_colours[GetHighOrderRand(12, iRandColor)]; do { pSprayData->iType = 2; - //LOBYTE(pSprayData->iType) = 2; + // LOBYTE(pSprayData->iType) = 2; pSprayData->iColor = iFireworkColor; pSprayData->position.fX = fX; @@ -1631,27 +1845,36 @@ void firework_display() iRandAngle = ROLLERrandRaw(); iAngleIndex = GetHighOrderRand(32768, iRandAngle); - //iAngleIndex = ((iRandAngle << 14) - (__CFSHL__(iRandAngle << 14 >> 31, 15) + (iRandAngle << 14 >> 31 << 15))) >> 15; - - dRandVelocity = (double)ROLLERrandRaw() * 2.0 * 0.000030517578125; - pSprayData->velocity.fX = (float)dRandVelocity * tcos[iAngleIndex] + fOrigVelX; - pSprayData->velocity.fY = (float)dRandVelocity * tsin[iAngleIndex] + fOrigVelY; + // iAngleIndex = ((iRandAngle << 14) - (__CFSHL__(iRandAngle << + // 14 >> 31, 15) + (iRandAngle << 14 >> 31 << 15))) >> 15; + + dRandVelocity = + (double)ROLLERrandRaw() * 2.0 * 0.000030517578125; + pSprayData->velocity.fX = + (float)dRandVelocity * tcos[iAngleIndex] + fOrigVelX; + pSprayData->velocity.fY = + (float)dRandVelocity * tsin[iAngleIndex] + fOrigVelY; iRandParticleLife = ROLLERrandRaw(); ++pSprayData; ++iParticleCount; - pSprayData[-1].iLifeTime = GetHighOrderRand(36, iRandParticleLife) + 36; + pSprayData[-1].iLifeTime = + GetHighOrderRand(36, iRandParticleLife) + 36; } while (iParticleCount < 32); } - } else if (byType == 2) // Handle explosion particles (type 2) + } else if (byType == 2) // Handle explosion particles (type 2) { iActiveParticles = 0; for (j = 0; j < 32; ++j) { iLifeTime = pSprayData->iLifeTime; if (iLifeTime > 0) { - dParticleVelY = pSprayData->velocity.fY + 0.1;// Apply gravity to particle and update position + dParticleVelY = + pSprayData->velocity.fY + + 0.1; // Apply gravity to particle and update position pSprayData->velocity.fY = (float)dParticleVelY; - pSprayData->position.fY = (float)dParticleVelY + pSprayData->position.fY; - dParticleVelX = pSprayData->velocity.fX + pSprayData->position.fX; + pSprayData->position.fY = + (float)dParticleVelY + pSprayData->position.fY; + dParticleVelX = + pSprayData->velocity.fX + pSprayData->position.fX; pSprayData->iLifeTime = iLifeTime - 1; ++iActiveParticles; pSprayData->position.fX = (float)dParticleVelX; @@ -1659,33 +1882,34 @@ void firework_display() ++pSprayData; } if (!iActiveParticles) { - pCleanupSpray = CarSpray[i]; // All particles expired - reset spray slot + pCleanupSpray = + CarSpray[i]; // All particles expired - reset spray slot do { pCleanupSpray += 4; pCleanupSpray[-4].iType = 0; - //LOBYTE(pCleanupSpray[-4].iType) = 0; + // LOBYTE(pCleanupSpray[-4].iType) = 0; pCleanupSpray[-4].iTimer = 0; pCleanupSpray[-4].position.fZ = 0.0; pCleanupSpray[-4].iColor = 0x8F; pCleanupSpray[-3].iType = 0; - //LOBYTE(pCleanupSpray[-3].iType) = 0; + // LOBYTE(pCleanupSpray[-3].iType) = 0; pCleanupSpray[-3].iTimer = 0; pCleanupSpray[-3].position.fZ = 0.0; pCleanupSpray[-3].iColor = 0x8F; pCleanupSpray[-2].iType = 0; - //LOBYTE(pCleanupSpray[-2].iType) = 0; + // LOBYTE(pCleanupSpray[-2].iType) = 0; pCleanupSpray[-2].iTimer = 0; pCleanupSpray[-2].position.fZ = 0.0; pCleanupSpray[-2].iColor = 0x8F; pCleanupSpray[-1].iType = 0; - //LOBYTE(pCleanupSpray[-1].iType) = 0; + // LOBYTE(pCleanupSpray[-1].iType) = 0; pCleanupSpray[-1].iTimer = 0; pCleanupSpray[-1].position.fZ = 0.0; @@ -1694,28 +1918,34 @@ void firework_display() } while (iActiveParticles < 32); } } - //} else if ((LODWORD(pSprayData->position.fZ) & 0x7FFFFFFF) != 0) { + //} else if ((LODWORD(pSprayData->position.fZ) & 0x7FFFFFFF) != 0) { } else if (fabs(pSprayData->position.fZ) != 0) { iTimerCount = pSprayData->iTimer - 1; pSprayData->iTimer = iTimerCount; if (iTimerCount < 0) { - iWidthDiv3 = winw / 3; // Launch new rocket with random position and velocity + iWidthDiv3 = + winw / 3; // Launch new rocket with random position and velocity iRandX = ROLLERrandRaw(); - pSprayData->position.fX = (float)(2 * winw / 3 - GetHighOrderRand(iWidthDiv3, iRandX)); + pSprayData->position.fX = + (float)(2 * winw / 3 - GetHighOrderRand(iWidthDiv3, iRandX)); pSprayData->position.fY = (float)winh; iRandVelX = ROLLERrandRaw(); - pSprayData->velocity.fX = (float)(2 - GetHighOrderRand(4, iRandVelX)); - pSprayData->velocity.fY = (float)(-4.8 - (double)ROLLERrandRaw() * 1.2 * 0.000030517578125); + pSprayData->velocity.fX = + (float)(2 - GetHighOrderRand(4, iRandVelX)); + pSprayData->velocity.fY = + (float)(-4.8 - + (double)ROLLERrandRaw() * 1.2 * 0.000030517578125); iRandLifetime = ROLLERrandRaw(); pSprayData->iColor = 0x8F; pSprayData->iType = 1; - //LOBYTE(pSprayData->iType) = 1; + // LOBYTE(pSprayData->iType) = 1; pSprayData->iLifeTime = GetHighOrderRand(48, iRandLifetime) + 18; } } else { - pSprayData->position.fZ = -1.0; // Initialize new firework with random launch delay + pSprayData->position.fZ = + -1.0; // Initialize new firework with random launch delay iRandTimer = ROLLERrandRaw(); pSprayData->iTimer = GetHighOrderRand(36, iRandTimer); } diff --git a/PROJECTS/ROLLER/function.h b/PROJECTS/ROLLER/function.h index a181252f..1b98379b 100644 --- a/PROJECTS/ROLLER/function.h +++ b/PROJECTS/ROLLER/function.h @@ -15,7 +15,8 @@ extern int invulnerable[16]; void finish_race(); double getbankz(float fInput, int iChunkIdx, tData *pData); -void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, float *pfBehindTime); +void calculate_aheadbehindtime(int iCarIdx, float *pfAheadTime, + float *pfBehindTime); void initnearcars(); void initpits(); void dodamage(tCar *pCar, float fDamage); diff --git a/PROJECTS/ROLLER/game_render.c b/PROJECTS/ROLLER/game_render.c index 93ada1ef..be2bfb73 100644 --- a/PROJECTS/ROLLER/game_render.c +++ b/PROJECTS/ROLLER/game_render.c @@ -7,232 +7,229 @@ #include struct GameRenderer { - GameRenderMode mode; - GameRendererSoftware *sw; - SceneRenderer *scene; - SDL_GPUDevice *device; - SDL_Window *window; + GameRenderMode mode; + GameRendererSoftware *sw; + SceneRenderer *scene; + SDL_GPUDevice *device; + SDL_Window *window; }; GameRenderer *game_render_create(SDL_GPUDevice *device, SDL_Window *window) { - GameRenderer *r = calloc(1, sizeof(GameRenderer)); - if (!r) - return NULL; - r->device = device; - r->window = window; - r->sw = game_render_sw_create(device, window); - r->scene = scene_render_create(device, window); - r->mode = GAME_RENDER_SOFTWARE; - return r; + GameRenderer *r = calloc(1, sizeof(GameRenderer)); + if (!r) + return NULL; + r->device = device; + r->window = window; + r->sw = game_render_sw_create(device, window); + r->scene = scene_render_create(device, window); + r->mode = GAME_RENDER_SOFTWARE; + return r; } void game_render_destroy(GameRenderer *renderer) { - if (!renderer) - return; - scene_render_destroy(renderer->scene); - game_render_sw_destroy(renderer->sw); - free(renderer); + if (!renderer) + return; + scene_render_destroy(renderer->scene); + game_render_sw_destroy(renderer->sw); + free(renderer); } void game_render_set_mode(GameRenderer *renderer, GameRenderMode mode) { - (void)renderer; - (void)mode; - // Only software mode available currently + (void)renderer; + (void)mode; + // Only software mode available currently } GameRenderMode game_render_get_mode(GameRenderer *renderer) { - return renderer->mode; + return renderer->mode; } // Frame lifecycle void game_render_begin_frame(GameRenderer *renderer) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_begin_frame(renderer->sw); + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_begin_frame(renderer->sw); } void game_render_end_frame(GameRenderer *renderer) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_end_frame(renderer->sw); + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_end_frame(renderer->sw); } // Viewport -void game_render_set_viewport(GameRenderer *renderer, - int x, int y, int w, int h) { - if (!renderer) - return; - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_set_viewport(renderer->sw, x, y, w, h); - scene_render_set_viewport(renderer->scene, x, y, w, h); +void game_render_set_viewport(GameRenderer *renderer, int x, int y, int w, + int h) { + if (!renderer) + return; + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_set_viewport(renderer->sw, x, y, w, h); + scene_render_set_viewport(renderer->scene, x, y, w, h); } -void game_render_set_target(GameRenderer *renderer, uint8 *buffer, - int stride, int width, int height) { - if (!renderer) - return; - scene_render_set_target(renderer->scene, buffer, stride, width, height); +void game_render_set_target(GameRenderer *renderer, uint8 *buffer, int stride, + int width, int height) { + if (!renderer) + return; + scene_render_set_target(renderer->scene, buffer, stride, width, height); } // Camera void game_render_set_camera(GameRenderer *renderer, const GameRenderCamera *camera) { - if (!renderer || !camera) - return; - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_set_camera(renderer->sw, camera); - scene_render_set_camera(renderer->scene, camera); + if (!renderer || !camera) + return; + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_set_camera(renderer->sw, camera); + scene_render_set_camera(renderer->scene, camera); } // Projection void game_render_set_projection(GameRenderer *renderer, const GameRenderProjection *proj) { - if (!renderer || !proj) - return; - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_set_projection(renderer->sw, proj); - scene_render_set_projection(renderer->scene, proj); + if (!renderer || !proj) + return; + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_set_projection(renderer->sw, proj); + scene_render_set_projection(renderer->scene, proj); } // Asset loading -TextureHandle game_render_load_texture(GameRenderer *renderer, - uint8 *pixelData, - int width, int height, - int tex_idx, int gfx_size) { - if (!renderer) - return TEXTURE_HANDLE_INVALID; - TextureHandle swHandle = game_render_sw_load_texture(renderer->sw, pixelData, - width, height, tex_idx, gfx_size); - TextureHandle sceneHandle = scene_render_load_texture(renderer->scene, pixelData, - width, height, tex_idx, gfx_size); - return sceneHandle != TEXTURE_HANDLE_INVALID ? sceneHandle : swHandle; +TextureHandle game_render_load_texture(GameRenderer *renderer, uint8 *pixelData, + int width, int height, int tex_idx, + int gfx_size) { + if (!renderer) + return TEXTURE_HANDLE_INVALID; + TextureHandle swHandle = game_render_sw_load_texture( + renderer->sw, pixelData, width, height, tex_idx, gfx_size); + TextureHandle sceneHandle = scene_render_load_texture( + renderer->scene, pixelData, width, height, tex_idx, gfx_size); + return sceneHandle != TEXTURE_HANDLE_INVALID ? sceneHandle : swHandle; } -void game_render_free_texture(GameRenderer *renderer, - TextureHandle handle) { - if (!renderer) - return; - scene_render_free_texture(renderer->scene, handle); - game_render_sw_free_texture(renderer->sw, handle); +void game_render_free_texture(GameRenderer *renderer, TextureHandle handle) { + if (!renderer) + return; + scene_render_free_texture(renderer->scene, handle); + game_render_sw_free_texture(renderer->sw, handle); } TextureHandle game_render_get_texture_handle(GameRenderer *renderer, int tex_idx) { - if (!renderer) - return TEXTURE_HANDLE_INVALID; - TextureHandle handle = scene_render_get_texture_handle(renderer->scene, tex_idx); - return handle != TEXTURE_HANDLE_INVALID ? handle : game_render_sw_get_texture_handle(renderer->sw, tex_idx); + if (!renderer) + return TEXTURE_HANDLE_INVALID; + TextureHandle handle = + scene_render_get_texture_handle(renderer->scene, tex_idx); + return handle != TEXTURE_HANDLE_INVALID + ? handle + : game_render_sw_get_texture_handle(renderer->sw, tex_idx); } TextureHandle game_render_load_blocks(GameRenderer *renderer, int slot, tBlockHeader *blocks, const tColor *palette) { - if (!renderer) - return TEXTURE_HANDLE_INVALID; - return game_render_sw_load_blocks(renderer->sw, slot, blocks, palette); + if (!renderer) + return TEXTURE_HANDLE_INVALID; + return game_render_sw_load_blocks(renderer->sw, slot, blocks, palette); } void game_render_free_blocks(GameRenderer *renderer, int slot) { - if (!renderer) - return; - game_render_sw_free_blocks(renderer->sw, slot); + if (!renderer) + return; + game_render_sw_free_blocks(renderer->sw, slot); } // Draw calls void game_render_quad_screen(GameRenderer *renderer, tPolyParams *poly, - TextureHandle handle, - const uint8 *palette_remap) { - if (!renderer) - return; - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_quad_screen(renderer->sw, poly, handle, palette_remap); + TextureHandle handle, const uint8 *palette_remap) { + if (!renderer) + return; + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_quad_screen(renderer->sw, poly, handle, palette_remap); } void game_render_quad_world(GameRenderer *renderer, - const GameRenderVertex *verts, - TextureHandle handle, - int surfaceFlags, - float subThreshold) { - game_render_quad_world_subdivide_type(renderer, verts, handle, surfaceFlags, - GAME_RENDER_SUBDIVIDE_TYPE_AUTO, - subThreshold); + const GameRenderVertex *verts, TextureHandle handle, + int surfaceFlags, float subThreshold) { + game_render_quad_world_subdivide_type(renderer, verts, handle, surfaceFlags, + GAME_RENDER_SUBDIVIDE_TYPE_AUTO, + subThreshold); } void game_render_quad_world_subdivide_type(GameRenderer *renderer, const GameRenderVertex *verts, TextureHandle handle, - int surfaceFlags, - int subdivideType, + int surfaceFlags, int subdivideType, float subThreshold) { - if (!renderer) - return; - SceneRenderLegacyQuadOptions options = { - .subdivideType = subdivideType, - .subThreshold = subThreshold, - }; - scene_render_quad_world_legacy(renderer->scene, verts, handle, - surfaceFlags, options); + if (!renderer) + return; + SceneRenderLegacyQuadOptions options = { + .subdivideType = subdivideType, + .subThreshold = subThreshold, + }; + scene_render_quad_world_legacy(renderer->scene, verts, handle, surfaceFlags, + options); } void game_render_draw_car(GameRenderer *renderer, int carIdx, const GameRenderCarPose *pose, const GameRenderCarOptions *options) { - if (!renderer || !pose) - return; - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_draw_car(renderer->sw, carIdx, pose, options); + if (!renderer || !pose) + return; + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_draw_car(renderer->sw, carIdx, pose, options); } void game_render_draw_sky(GameRenderer *renderer, const GameRenderCamera *camera, const GameRenderProjection *projection) { - if (!renderer || !camera || !projection) - return; - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_draw_sky(renderer->sw, camera, projection); + if (!renderer || !camera || !projection) + return; + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_draw_sky(renderer->sw, camera, projection); } -void game_render_sprite(GameRenderer *renderer, int slot, int blockIdx, - int x, int y, int transparentColorIndex, +void game_render_sprite(GameRenderer *renderer, int slot, int blockIdx, int x, + int y, int transparentColorIndex, const tColor *palette) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_sprite(renderer->sw, slot, blockIdx, x, y, - transparentColorIndex, palette); + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_sprite(renderer->sw, slot, blockIdx, x, y, + transparentColorIndex, palette); } void game_render_print_block(GameRenderer *renderer, int slot, int blockIdx, uint8 *pDest) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_print_block(renderer->sw, slot, blockIdx, pDest); + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_print_block(renderer->sw, slot, blockIdx, pDest); } // Palette void game_render_set_palette(GameRenderer *renderer, const tColor *palette) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_set_palette(renderer->sw, palette); + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_set_palette(renderer->sw, palette); } // Fade void game_render_begin_fade(GameRenderer *renderer, int direction, int durationFrames) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_begin_fade(renderer->sw, direction, durationFrames); + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_begin_fade(renderer->sw, direction, durationFrames); } int game_render_fade_active(GameRenderer *renderer) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - return game_render_sw_fade_active(renderer->sw); - return 0; + if (renderer->mode == GAME_RENDER_SOFTWARE) + return game_render_sw_fade_active(renderer->sw); + return 0; } -void game_render_fade_wait(GameRenderer *renderer, - void (*redraw_fn)(void *ctx), void *ctx) { - if (renderer->mode == GAME_RENDER_SOFTWARE) - game_render_sw_fade_wait(renderer->sw, redraw_fn, ctx); +void game_render_fade_wait(GameRenderer *renderer, void (*redraw_fn)(void *ctx), + void *ctx) { + if (renderer->mode == GAME_RENDER_SOFTWARE) + game_render_sw_fade_wait(renderer->sw, redraw_fn, ctx); } diff --git a/PROJECTS/ROLLER/game_render.h b/PROJECTS/ROLLER/game_render.h index 37163895..ad7fa2f1 100644 --- a/PROJECTS/ROLLER/game_render.h +++ b/PROJECTS/ROLLER/game_render.h @@ -7,10 +7,7 @@ #include "polyf.h" #include "scene_render.h" -typedef enum { - GAME_RENDER_GPU, - GAME_RENDER_SOFTWARE -} GameRenderMode; +typedef enum { GAME_RENDER_GPU, GAME_RENDER_SOFTWARE } GameRenderMode; typedef SceneTextureHandle TextureHandle; #define TEXTURE_HANDLE_INVALID SCENE_TEXTURE_HANDLE_INVALID @@ -20,15 +17,15 @@ typedef SceneRenderCamera GameRenderCamera; typedef SceneRenderProjection GameRenderProjection; typedef struct GameRenderCarPose { - tVec3 position; - int yaw; - int pitch; - int roll; + tVec3 position; + int yaw; + int pitch; + int roll; } GameRenderCarPose; typedef struct GameRenderCarOptions { - int anim_frame; - const uint8 *color_remap; + int anim_frame; + const uint8 *color_remap; } GameRenderCarOptions; #define GAME_RENDER_SUBDIVIDE_TYPE_AUTO SCENE_RENDER_SUBDIVIDE_TYPE_AUTO @@ -48,10 +45,10 @@ void game_render_begin_frame(GameRenderer *renderer); void game_render_end_frame(GameRenderer *renderer); // Viewport -void game_render_set_viewport(GameRenderer *renderer, - int x, int y, int w, int h); -void game_render_set_target(GameRenderer *renderer, uint8 *buffer, - int stride, int width, int height); +void game_render_set_viewport(GameRenderer *renderer, int x, int y, int w, + int h); +void game_render_set_target(GameRenderer *renderer, uint8 *buffer, int stride, + int width, int height); // Camera void game_render_set_camera(GameRenderer *renderer, @@ -64,12 +61,10 @@ void game_render_set_projection(GameRenderer *renderer, // Unified texture loading // tex_idx: use TEXTURE_BANK_* constants. // gfx_size determines layout: 0=64x64, 1=32x32. -TextureHandle game_render_load_texture(GameRenderer *renderer, - uint8 *pixelData, - int width, int height, - int tex_idx, int gfx_size); -void game_render_free_texture(GameRenderer *renderer, - TextureHandle handle); +TextureHandle game_render_load_texture(GameRenderer *renderer, uint8 *pixelData, + int width, int height, int tex_idx, + int gfx_size); +void game_render_free_texture(GameRenderer *renderer, TextureHandle handle); // Look up the handle registered for a given texture bank index TextureHandle game_render_get_texture_handle(GameRenderer *renderer, @@ -83,10 +78,8 @@ void game_render_free_blocks(GameRenderer *renderer, int slot); // Draw — polygon (track, buildings, particles, clouds) // Pass TEXTURE_HANDLE_INVALID for flat (untextured) polygons. -void game_render_quad_screen(GameRenderer *renderer, - tPolyParams *poly, - TextureHandle handle, - const uint8 *palette_remap); +void game_render_quad_screen(GameRenderer *renderer, tPolyParams *poly, + TextureHandle handle, const uint8 *palette_remap); // Draw — world-space quad (GPU-ready interface) // verts must point to exactly 4 GameRenderVertex entries. @@ -97,15 +90,12 @@ void game_render_quad_screen(GameRenderer *renderer, // (matches the legacy subdivide-vs-game_render_quad_screen branch). Pass 0.0f // to always subdivide. void game_render_quad_world(GameRenderer *renderer, - const GameRenderVertex *verts, - TextureHandle handle, - int surfaceFlags, - float subThreshold); + const GameRenderVertex *verts, TextureHandle handle, + int surfaceFlags, float subThreshold); void game_render_quad_world_subdivide_type(GameRenderer *renderer, const GameRenderVertex *verts, TextureHandle handle, - int surfaceFlags, - int subdivideType, + int surfaceFlags, int subdivideType, float subThreshold); // Draw — car mesh @@ -119,8 +109,8 @@ void game_render_draw_sky(GameRenderer *renderer, const GameRenderProjection *projection); // Draw — HUD sprites -void game_render_sprite(GameRenderer *renderer, int slot, int blockIdx, - int x, int y, int transparentColorIndex, +void game_render_sprite(GameRenderer *renderer, int slot, int blockIdx, int x, + int y, int transparentColorIndex, const tColor *palette); // Draw — HUD print_block (scaled sprite blit to dest pointer) @@ -134,7 +124,7 @@ void game_render_set_palette(GameRenderer *renderer, const tColor *palette); void game_render_begin_fade(GameRenderer *renderer, int direction, int durationFrames); int game_render_fade_active(GameRenderer *renderer); -void game_render_fade_wait(GameRenderer *renderer, - void (*redraw_fn)(void *ctx), void *ctx); +void game_render_fade_wait(GameRenderer *renderer, void (*redraw_fn)(void *ctx), + void *ctx); #endif diff --git a/PROJECTS/ROLLER/game_render_software.c b/PROJECTS/ROLLER/game_render_software.c index dfd0681b..a34a3e9d 100644 --- a/PROJECTS/ROLLER/game_render_software.c +++ b/PROJECTS/ROLLER/game_render_software.c @@ -20,27 +20,27 @@ // Slot table entry for pixel textures typedef struct { - uint8 *pixels; - int width; - int height; - int tex_idx; - int gfx_size; - int in_use; + uint8 *pixels; + int width; + int height; + int tex_idx; + int gfx_size; + int in_use; } TextureSlot; struct GameRendererSoftware { - GameRenderCamera camera; - GameRenderProjection proj; - int screenWidth; - int screenHeight; - int fadeInPending; - tBlockHeader *blocks[GAME_RENDER_MAX_BLOCK_SLOTS]; - TextureHandle blockHandles[GAME_RENDER_MAX_BLOCK_SLOTS]; - - // Texture slot table - TextureSlot texSlots[GAME_RENDER_MAX_TEXTURE_SLOTS]; - // Map tex_idx → TextureHandle (for game_render_get_texture_handle) - TextureHandle texIdxToHandle[32]; + GameRenderCamera camera; + GameRenderProjection proj; + int screenWidth; + int screenHeight; + int fadeInPending; + tBlockHeader *blocks[GAME_RENDER_MAX_BLOCK_SLOTS]; + TextureHandle blockHandles[GAME_RENDER_MAX_BLOCK_SLOTS]; + + // Texture slot table + TextureSlot texSlots[GAME_RENDER_MAX_TEXTURE_SLOTS]; + // Map tex_idx → TextureHandle (for game_render_get_texture_handle) + TextureHandle texIdxToHandle[32]; }; // --------------------------------------------------------------------------- @@ -49,50 +49,46 @@ struct GameRendererSoftware { GameRendererSoftware *game_render_sw_create(SDL_GPUDevice *device, SDL_Window *window) { - (void)device; - (void)window; - GameRendererSoftware *sw = calloc(1, sizeof(GameRendererSoftware)); - return sw; + (void)device; + (void)window; + GameRendererSoftware *sw = calloc(1, sizeof(GameRendererSoftware)); + return sw; } -void game_render_sw_destroy(GameRendererSoftware *sw) { - free(sw); -} +void game_render_sw_destroy(GameRendererSoftware *sw) { free(sw); } // --------------------------------------------------------------------------- // Frame lifecycle // --------------------------------------------------------------------------- -void game_render_sw_begin_frame(GameRendererSoftware *sw) { - (void)sw; -} +void game_render_sw_begin_frame(GameRendererSoftware *sw) { (void)sw; } void game_render_sw_end_frame(GameRendererSoftware *sw) { - if (sw->fadeInPending) { - sw->fadeInPending = 0; - palette_brightness = 0; - for (int i = 0; i < 256; i++) { - pal_addr[i].byR = 0; - pal_addr[i].byB = 0; - pal_addr[i].byG = 0; - } - fade_palette(32); - return; + if (sw->fadeInPending) { + sw->fadeInPending = 0; + palette_brightness = 0; + for (int i = 0; i < 256; i++) { + pal_addr[i].byR = 0; + pal_addr[i].byB = 0; + pal_addr[i].byG = 0; } - UpdateSDLWindow(); + fade_palette(32); + return; + } + UpdateSDLWindow(); } // --------------------------------------------------------------------------- // Viewport // --------------------------------------------------------------------------- -void game_render_sw_set_viewport(GameRendererSoftware *sw, - int x, int y, int w, int h) { - sw->screenWidth = w; - sw->screenHeight = h; - // Set screen_pointer to the viewport origin within scrbuf. - // Existing rendering code writes relative to screen_pointer. - screen_pointer = scrbuf + (y * sw->screenWidth) + x; +void game_render_sw_set_viewport(GameRendererSoftware *sw, int x, int y, int w, + int h) { + sw->screenWidth = w; + sw->screenHeight = h; + // Set screen_pointer to the viewport origin within scrbuf. + // Existing rendering code writes relative to screen_pointer. + screen_pointer = scrbuf + (y * sw->screenWidth) + x; } // --------------------------------------------------------------------------- @@ -101,31 +97,37 @@ void game_render_sw_set_viewport(GameRendererSoftware *sw, void game_render_sw_set_camera(GameRendererSoftware *sw, const GameRenderCamera *camera) { - extern float viewx, viewy, viewz; - extern float fcos, fsin; - extern int VIEWDIST; - sw->camera = *camera; - viewx = camera->viewX; - viewy = camera->viewY; - viewz = camera->viewZ; - fcos = camera->cosYaw; - fsin = camera->sinYaw; - VIEWDIST = (int)camera->fovScale; + extern float viewx, viewy, viewz; + extern float fcos, fsin; + extern int VIEWDIST; + sw->camera = *camera; + viewx = camera->viewX; + viewy = camera->viewY; + viewz = camera->viewZ; + fcos = camera->cosYaw; + fsin = camera->sinYaw; + VIEWDIST = (int)camera->fovScale; } void game_render_sw_set_projection(GameRendererSoftware *sw, const GameRenderProjection *proj) { - extern float vk1, vk2, vk3, vk4, vk5, vk6, vk7, vk8, vk9; - extern int scr_size, xbase, ybase, gfx_size; - sw->proj = *proj; - // Write through to globals for legacy code (subdivide, POLYTEX, etc.) - vk1 = proj->view[0][0]; vk2 = proj->view[0][1]; vk3 = proj->view[0][2]; - vk4 = proj->view[1][0]; vk5 = proj->view[1][1]; vk6 = proj->view[1][2]; - vk7 = proj->view[2][0]; vk8 = proj->view[2][1]; vk9 = proj->view[2][2]; - scr_size = proj->screenScale; - xbase = proj->centerX; - ybase = proj->centerY; - gfx_size = proj->texHalfRes; + extern float vk1, vk2, vk3, vk4, vk5, vk6, vk7, vk8, vk9; + extern int scr_size, xbase, ybase, gfx_size; + sw->proj = *proj; + // Write through to globals for legacy code (subdivide, POLYTEX, etc.) + vk1 = proj->view[0][0]; + vk2 = proj->view[0][1]; + vk3 = proj->view[0][2]; + vk4 = proj->view[1][0]; + vk5 = proj->view[1][1]; + vk6 = proj->view[1][2]; + vk7 = proj->view[2][0]; + vk8 = proj->view[2][1]; + vk9 = proj->view[2][2]; + scr_size = proj->screenScale; + xbase = proj->centerX; + ybase = proj->centerY; + gfx_size = proj->texHalfRes; } // --------------------------------------------------------------------------- @@ -133,71 +135,70 @@ void game_render_sw_set_projection(GameRendererSoftware *sw, // --------------------------------------------------------------------------- TextureHandle game_render_sw_load_texture(GameRendererSoftware *sw, - uint8 *pixelData, - int width, int height, - int tex_idx, int gfx_size) { - // Free any existing handle for this tex_idx first - if (tex_idx >= 0 && tex_idx < 32) { - TextureHandle old = sw->texIdxToHandle[tex_idx]; - if (old != TEXTURE_HANDLE_INVALID) - game_render_sw_free_texture(sw, old); - } - - // Find a free slot (skip 0 — reserved for TEXTURE_HANDLE_INVALID) - for (int i = 1; i < GAME_RENDER_MAX_TEXTURE_SLOTS; i++) { - if (!sw->texSlots[i].in_use) { - sw->texSlots[i].pixels = pixelData; - sw->texSlots[i].width = width; - sw->texSlots[i].height = height; - sw->texSlots[i].tex_idx = tex_idx; - sw->texSlots[i].gfx_size = gfx_size; - sw->texSlots[i].in_use = 1; - - // Register the handle for this tex_idx - if (tex_idx >= 0 && tex_idx < 32) - sw->texIdxToHandle[tex_idx] = i; - - return (TextureHandle)i; - } + uint8 *pixelData, int width, + int height, int tex_idx, + int gfx_size) { + // Free any existing handle for this tex_idx first + if (tex_idx >= 0 && tex_idx < 32) { + TextureHandle old = sw->texIdxToHandle[tex_idx]; + if (old != TEXTURE_HANDLE_INVALID) + game_render_sw_free_texture(sw, old); + } + + // Find a free slot (skip 0 — reserved for TEXTURE_HANDLE_INVALID) + for (int i = 1; i < GAME_RENDER_MAX_TEXTURE_SLOTS; i++) { + if (!sw->texSlots[i].in_use) { + sw->texSlots[i].pixels = pixelData; + sw->texSlots[i].width = width; + sw->texSlots[i].height = height; + sw->texSlots[i].tex_idx = tex_idx; + sw->texSlots[i].gfx_size = gfx_size; + sw->texSlots[i].in_use = 1; + + // Register the handle for this tex_idx + if (tex_idx >= 0 && tex_idx < 32) + sw->texIdxToHandle[tex_idx] = i; + + return (TextureHandle)i; } - return TEXTURE_HANDLE_INVALID; + } + return TEXTURE_HANDLE_INVALID; } void game_render_sw_free_texture(GameRendererSoftware *sw, TextureHandle handle) { - if (handle <= 0 || handle >= GAME_RENDER_MAX_TEXTURE_SLOTS) - return; - int tex_idx = sw->texSlots[handle].tex_idx; - if (tex_idx >= 0 && tex_idx < 32 - && sw->texIdxToHandle[tex_idx] == handle) - sw->texIdxToHandle[tex_idx] = TEXTURE_HANDLE_INVALID; - memset(&sw->texSlots[handle], 0, sizeof(TextureSlot)); + if (handle <= 0 || handle >= GAME_RENDER_MAX_TEXTURE_SLOTS) + return; + int tex_idx = sw->texSlots[handle].tex_idx; + if (tex_idx >= 0 && tex_idx < 32 && sw->texIdxToHandle[tex_idx] == handle) + sw->texIdxToHandle[tex_idx] = TEXTURE_HANDLE_INVALID; + memset(&sw->texSlots[handle], 0, sizeof(TextureSlot)); } TextureHandle game_render_sw_get_texture_handle(GameRendererSoftware *sw, - int tex_idx) { - if (tex_idx >= 0 && tex_idx < 32) - return sw->texIdxToHandle[tex_idx]; - return TEXTURE_HANDLE_INVALID; + int tex_idx) { + if (tex_idx >= 0 && tex_idx < 32) + return sw->texIdxToHandle[tex_idx]; + return TEXTURE_HANDLE_INVALID; } TextureHandle game_render_sw_load_blocks(GameRendererSoftware *sw, int slot, tBlockHeader *blocks, const tColor *palette) { - (void)palette; - if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS) { - sw->blocks[slot] = blocks; - sw->blockHandles[slot] = (TextureHandle)(slot + 1); - return sw->blockHandles[slot]; - } - return TEXTURE_HANDLE_INVALID; + (void)palette; + if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS) { + sw->blocks[slot] = blocks; + sw->blockHandles[slot] = (TextureHandle)(slot + 1); + return sw->blockHandles[slot]; + } + return TEXTURE_HANDLE_INVALID; } void game_render_sw_free_blocks(GameRendererSoftware *sw, int slot) { - if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS) { - sw->blocks[slot] = NULL; - sw->blockHandles[slot] = TEXTURE_HANDLE_INVALID; - } + if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS) { + sw->blocks[slot] = NULL; + sw->blockHandles[slot] = TEXTURE_HANDLE_INVALID; + } } // --------------------------------------------------------------------------- @@ -205,66 +206,65 @@ void game_render_sw_free_blocks(GameRendererSoftware *sw, int slot) { // --------------------------------------------------------------------------- void game_render_sw_quad_screen(GameRendererSoftware *sw, tPolyParams *poly, - TextureHandle handle, - const uint8 *palette_remap) { - (void)palette_remap; - if (handle > 0 && handle < GAME_RENDER_MAX_TEXTURE_SLOTS - && sw->texSlots[handle].in_use) { - TextureSlot *slot = &sw->texSlots[handle]; - POLYTEX(slot->pixels, screen_pointer, poly, - slot->tex_idx, slot->gfx_size); - } else { - POLYFLAT(screen_pointer, poly); - } + TextureHandle handle, + const uint8 *palette_remap) { + (void)palette_remap; + if (handle > 0 && handle < GAME_RENDER_MAX_TEXTURE_SLOTS && + sw->texSlots[handle].in_use) { + TextureSlot *slot = &sw->texSlots[handle]; + POLYTEX(slot->pixels, screen_pointer, poly, slot->tex_idx, slot->gfx_size); + } else { + POLYFLAT(screen_pointer, poly); + } } void game_render_sw_draw_car(GameRendererSoftware *sw, int carIdx, const GameRenderCarPose *pose, const GameRenderCarOptions *options) { - if (!sw || !pose) - return; - // Compute distance from camera to car for LOD using the explicit pose. - const GameRenderCamera *cam = &sw->camera; - float dx = pose->position.fX - cam->viewX; - float dy = pose->position.fY - cam->viewY; - float dz = pose->position.fZ - cam->viewZ; - float dist = sqrtf(dx * dx + dy * dy + dz * dz); - CarRenderPose car_pose = { - .position = pose->position, - .yaw = pose->yaw, - .pitch = pose->pitch, - .roll = pose->roll, - }; - CarRenderOptions car_options = { - .anim_frame = options ? options->anim_frame : 0, - .color_remap = options ? options->color_remap : NULL, - }; - DisplayCarWithPose(carIdx, screen_pointer, dist, &car_pose, &car_options); + if (!sw || !pose) + return; + // Compute distance from camera to car for LOD using the explicit pose. + const GameRenderCamera *cam = &sw->camera; + float dx = pose->position.fX - cam->viewX; + float dy = pose->position.fY - cam->viewY; + float dz = pose->position.fZ - cam->viewZ; + float dist = sqrtf(dx * dx + dy * dy + dz * dz); + CarRenderPose car_pose = { + .position = pose->position, + .yaw = pose->yaw, + .pitch = pose->pitch, + .roll = pose->roll, + }; + CarRenderOptions car_options = { + .anim_frame = options ? options->anim_frame : 0, + .color_remap = options ? options->color_remap : NULL, + }; + DisplayCarWithPose(carIdx, screen_pointer, dist, &car_pose, &car_options); } void game_render_sw_draw_sky(GameRendererSoftware *sw, const GameRenderCamera *camera, const GameRenderProjection *projection) { - if (!sw || !camera || !projection) - return; - game_render_sw_set_camera(sw, camera); - game_render_sw_set_projection(sw, projection); - DrawHorizon(screen_pointer); + if (!sw || !camera || !projection) + return; + game_render_sw_set_camera(sw, camera); + game_render_sw_set_projection(sw, projection); + DrawHorizon(screen_pointer); } void game_render_sw_sprite(GameRendererSoftware *sw, int slot, int blockIdx, int x, int y, int transparentColorIndex, const tColor *palette) { - (void)palette; - if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS && sw->blocks[slot]) - display_block(scrbuf, sw->blocks[slot], blockIdx, x, y, - transparentColorIndex); + (void)palette; + if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS && sw->blocks[slot]) + display_block(scrbuf, sw->blocks[slot], blockIdx, x, y, + transparentColorIndex); } void game_render_sw_print_block(GameRendererSoftware *sw, int slot, int blockIdx, uint8 *pDest) { - if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS && sw->blocks[slot]) - print_block(pDest, sw->blocks[slot], blockIdx); + if (slot >= 0 && slot < GAME_RENDER_MAX_BLOCK_SLOTS && sw->blocks[slot]) + print_block(pDest, sw->blocks[slot], blockIdx); } // --------------------------------------------------------------------------- @@ -273,9 +273,9 @@ void game_render_sw_print_block(GameRendererSoftware *sw, int slot, void game_render_sw_set_palette(GameRendererSoftware *sw, const tColor *palette) { - (void)sw; - for (int i = 0; i < 256; i++) - pal_addr[i] = palette[i]; + (void)sw; + for (int i = 0; i < 256; i++) + pal_addr[i] = palette[i]; } // --------------------------------------------------------------------------- @@ -284,22 +284,22 @@ void game_render_sw_set_palette(GameRendererSoftware *sw, void game_render_sw_begin_fade(GameRendererSoftware *sw, int direction, int durationFrames) { - (void)durationFrames; - if (direction) { - sw->fadeInPending = 1; - } else { - fade_palette(0); - } + (void)durationFrames; + if (direction) { + sw->fadeInPending = 1; + } else { + fade_palette(0); + } } int game_render_sw_fade_active(GameRendererSoftware *sw) { - (void)sw; - return 0; // blocking fade completes immediately + (void)sw; + return 0; // blocking fade completes immediately } void game_render_sw_fade_wait(GameRendererSoftware *sw, void (*redraw_fn)(void *ctx), void *ctx) { - (void)sw; - (void)redraw_fn; - (void)ctx; + (void)sw; + (void)redraw_fn; + (void)ctx; } diff --git a/PROJECTS/ROLLER/game_render_software.h b/PROJECTS/ROLLER/game_render_software.h index 9df0b710..a7a217c3 100644 --- a/PROJECTS/ROLLER/game_render_software.h +++ b/PROJECTS/ROLLER/game_render_software.h @@ -19,8 +19,8 @@ void game_render_sw_begin_frame(GameRendererSoftware *sw); void game_render_sw_end_frame(GameRendererSoftware *sw); // Viewport -void game_render_sw_set_viewport(GameRendererSoftware *sw, - int x, int y, int w, int h); +void game_render_sw_set_viewport(GameRendererSoftware *sw, int x, int y, int w, + int h); // Camera void game_render_sw_set_camera(GameRendererSoftware *sw, @@ -32,13 +32,13 @@ void game_render_sw_set_projection(GameRendererSoftware *sw, // Asset loading TextureHandle game_render_sw_load_texture(GameRendererSoftware *sw, - uint8 *pixelData, - int width, int height, - int tex_idx, int gfx_size); + uint8 *pixelData, int width, + int height, int tex_idx, + int gfx_size); void game_render_sw_free_texture(GameRendererSoftware *sw, TextureHandle handle); TextureHandle game_render_sw_get_texture_handle(GameRendererSoftware *sw, - int tex_idx); + int tex_idx); TextureHandle game_render_sw_load_blocks(GameRendererSoftware *sw, int slot, tBlockHeader *blocks, const tColor *palette); @@ -46,14 +46,14 @@ void game_render_sw_free_blocks(GameRendererSoftware *sw, int slot); // Draw calls void game_render_sw_quad_screen(GameRendererSoftware *sw, tPolyParams *poly, - TextureHandle handle, - const uint8 *palette_remap); + TextureHandle handle, + const uint8 *palette_remap); void game_render_sw_draw_car(GameRendererSoftware *sw, int carIdx, const GameRenderCarPose *pose, const GameRenderCarOptions *options); void game_render_sw_draw_sky(GameRendererSoftware *sw, - const GameRenderCamera *camera, - const GameRenderProjection *projection); + const GameRenderCamera *camera, + const GameRenderProjection *projection); void game_render_sw_sprite(GameRendererSoftware *sw, int slot, int blockIdx, int x, int y, int transparentColorIndex, const tColor *palette); diff --git a/PROJECTS/ROLLER/graphics.c b/PROJECTS/ROLLER/graphics.c index cd1d2c58..21c55cde 100644 --- a/PROJECTS/ROLLER/graphics.c +++ b/PROJECTS/ROLLER/graphics.c @@ -16,53 +16,38 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -char revs_files1[6][13] = //000A41C0 -{ - "minitext.bm", - "font6.bm", - "panel2.bm", - "font3.bm", - "pancar1.bm", - "" -}; -char revs_files2[6][13] = //000A420E -{ - "minitext.bm", - "font6.bm", - "panel2.bm", - "font3.bm", - "pancar2.bm", - "" -}; -char texture_file[13] = "texture.drh"; //000A425C -char bldtex_file[13] = "building.drh"; //000A4269 -char gencartex_name[11] = "gentex.drh"; //000A4276 -int car_remap[4096]; //001446C0 -int cargen_remap[256]; //001486C0 -int bld_remap[256]; //00148AC0 -int num_textures[32]; //00148EC0 -int remap_tex[256]; //00148F40 -int mode_c[256]; //00149340 -int gfx_size; //00149740 -int BldTextures; //00149744 -int NoOfTextures; //00149748 +char revs_files1[6][13] = // 000A41C0 + {"minitext.bm", "font6.bm", "panel2.bm", "font3.bm", "pancar1.bm", ""}; +char revs_files2[6][13] = // 000A420E + {"minitext.bm", "font6.bm", "panel2.bm", "font3.bm", "pancar2.bm", ""}; +char texture_file[13] = "texture.drh"; // 000A425C +char bldtex_file[13] = "building.drh"; // 000A4269 +char gencartex_name[11] = "gentex.drh"; // 000A4276 +int car_remap[4096]; // 001446C0 +int cargen_remap[256]; // 001486C0 +int bld_remap[256]; // 00148AC0 +int num_textures[32]; // 00148EC0 +int remap_tex[256]; // 00148F40 +int mode_c[256]; // 00149340 +int gfx_size; // 00149740 +int BldTextures; // 00149744 +int NoOfTextures; // 00149748 //------------------------------------------------------------------------------------------------- -//00027BA0 -void plotxyz(float fWorldX, float fWorldY, float fWorldZ, char byColor) -{ +// 00027BA0 +void plotxyz(float fWorldX, float fWorldY, float fWorldZ, char byColor) { double dPerspectiveScale; // st6 - double dScreenX; // st5 - double dScreenY; // st7 - float fTransformedX; // [esp+4h] [ebp-24h] - float fTransformedY; // [esp+8h] [ebp-20h] - float fTransformedZ; // [esp+Ch] [ebp-1Ch] - int iScreenXInt; // [esp+10h] [ebp-18h] - float fViewDistance; // [esp+14h] [ebp-14h] + double dScreenX; // st5 + double dScreenY; // st7 + float fTransformedX; // [esp+4h] [ebp-24h] + float fTransformedY; // [esp+8h] [ebp-20h] + float fTransformedZ; // [esp+Ch] [ebp-1Ch] + int iScreenXInt; // [esp+10h] [ebp-18h] + float fViewDistance; // [esp+14h] [ebp-14h] // Transform world coords to camera-relative coords k1 = fWorldX - viewx; @@ -72,8 +57,8 @@ void plotxyz(float fWorldX, float fWorldY, float fWorldZ, char byColor) // Frustum culling - only process points within max render distance (5600) if (fabs(k1) <= 5600.0 && fabs(k2) <= 5600.0 && fabs(k3) <= 5600.0) { // Apply camera transformation mat - fTransformedY = k1 * vk2 + k2 * vk5 + k3 * vk8;// right vector proj - fTransformedZ = k1 * vk3 + k2 * vk6 + k3 * vk9;// up vector proj + fTransformedY = k1 * vk2 + k2 * vk5 + k3 * vk8; // right vector proj + fTransformedZ = k1 * vk3 + k2 * vk6 + k3 * vk9; // up vector proj fViewDistance = (float)VIEWDIST; @@ -83,14 +68,17 @@ void plotxyz(float fWorldX, float fWorldY, float fWorldZ, char byColor) // Transform X to camera space using forward vec fTransformedX = k1 * vk1 + k2 * vk4 + k3 * vk7; - dScreenX = fViewDistance * fTransformedX * dPerspectiveScale + (double)xbase; + dScreenX = + fViewDistance * fTransformedX * dPerspectiveScale + (double)xbase; //_CHP iScreenXInt = (int)dScreenX; - dScreenY = dPerspectiveScale * (fViewDistance * fTransformedY) + (double)ybase; + dScreenY = + dPerspectiveScale * (fViewDistance * fTransformedY) + (double)ybase; //_CHP // Clip to screen bounds and plot pixel to 320x200 screen - if ((int)dScreenX >= 0 && iScreenXInt <= 319 && (unsigned int)(int)dScreenY < 200) + if ((int)dScreenX >= 0 && iScreenXInt <= 319 && + (unsigned int)(int)dScreenY < 200) // plot pixel with y coord flipped (199-y for top-down screen layout) // screen buffer offset: (x + width*flippedY) scrbuf[iScreenXInt + winw * (199 - (int)dScreenY)] = byColor; @@ -99,32 +87,32 @@ void plotxyz(float fWorldX, float fWorldY, float fWorldZ, char byColor) } //------------------------------------------------------------------------------------------------- -//00027D40 -void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, float fY2, float fZ2, uint8 byColor) -{ - double dViewDist; // st7 +// 00027D40 +void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, + float fY2, float fZ2, uint8 byColor) { + double dViewDist; // st7 double dClipInterpolationFactor; // st6 - double dScreenCenterX; // st5 - double dScrScale; // st4 - double dScrScale_1; // rt2 - double dScreenCenterY; // st4 - int iScreenX1; // edi - int iScreenY1; // eax - int iScreenX2; // eax - float fClippedRightProj; // [esp+4h] [ebp-3Ch] - float fRightProj_1; // [esp+8h] [ebp-38h] - float fForwardProj; // [esp+Ch] [ebp-34h] - float fClippedForwardProj; // [esp+10h] [ebp-30h] - float fRightProj; // [esp+14h] [ebp-2Ch] - float fViewDist; // [esp+18h] [ebp-28h] - float fUpProj2; // [esp+1Ch] [ebp-24h] - float fDepthOffset2; // [esp+1Ch] [ebp-24h] - float fFinalDepth2; // [esp+1Ch] [ebp-24h] - float fUpProj; // [esp+20h] [ebp-20h] - float fDepthOffset1; // [esp+20h] [ebp-20h] - float fFinalDepth1; // [esp+20h] [ebp-20h] - int iScaledScreenX1; // [esp+24h] [ebp-1Ch] - int iScaledScreenY2; // [esp+24h] [ebp-1Ch] + double dScreenCenterX; // st5 + double dScrScale; // st4 + double dScrScale_1; // rt2 + double dScreenCenterY; // st4 + int iScreenX1; // edi + int iScreenY1; // eax + int iScreenX2; // eax + float fClippedRightProj; // [esp+4h] [ebp-3Ch] + float fRightProj_1; // [esp+8h] [ebp-38h] + float fForwardProj; // [esp+Ch] [ebp-34h] + float fClippedForwardProj; // [esp+10h] [ebp-30h] + float fRightProj; // [esp+14h] [ebp-2Ch] + float fViewDist; // [esp+18h] [ebp-28h] + float fUpProj2; // [esp+1Ch] [ebp-24h] + float fDepthOffset2; // [esp+1Ch] [ebp-24h] + float fFinalDepth2; // [esp+1Ch] [ebp-24h] + float fUpProj; // [esp+20h] [ebp-20h] + float fDepthOffset1; // [esp+20h] [ebp-20h] + float fFinalDepth1; // [esp+20h] [ebp-20h] + int iScaledScreenX1; // [esp+24h] [ebp-1Ch] + int iScaledScreenY2; // [esp+24h] [ebp-1Ch] // Transform both points from world space to camera-relative space k1 = fX1 - viewx; // Point 1 relative to camera @@ -137,13 +125,16 @@ void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, float f // Apply camera transformation matrix to both points // Transform point 1 to camera space fForwardProj = k1 * vk1 + k2 * vk4 + k3 * vk7; // Forward (Z) projection - fRightProj_1 = k1 * vk2 + k2 * vk5 + k3 * vk8; // Right (X) projection for point 1 - fUpProj = k1 * vk3 + k2 * vk6 + k3 * vk9; // Up (Y) projection + fRightProj_1 = + k1 * vk2 + k2 * vk5 + k3 * vk8; // Right (X) projection for point 1 + fUpProj = k1 * vk3 + k2 * vk6 + k3 * vk9; // Up (Y) projection // Transform point 2 to camera space - fClippedForwardProj = k4 * vk1 + k5 * vk4 + k6 * vk7; // Forward projection for point 2 - fRightProj = k4 * vk2 + k5 * vk5 + k6 * vk8; // Right (X) projection for point 2 - fUpProj2 = k4 * vk3 + k5 * vk6 + k6 * vk9; // Up (Y) projection for point 2 + fClippedForwardProj = + k4 * vk1 + k5 * vk4 + k6 * vk7; // Forward projection for point 2 + fRightProj = + k4 * vk2 + k5 * vk5 + k6 * vk8; // Right (X) projection for point 2 + fUpProj2 = k4 * vk3 + k5 * vk6 + k6 * vk9; // Up (Y) projection for point 2 dViewDist = (double)VIEWDIST; @@ -152,21 +143,28 @@ void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, float f fDepthOffset2 = fUpProj2 - (float)dViewDist; // Check if line crosses the near clipping plane and perform clipping - if (fDepthOffset1 < 0.0 && fDepthOffset2 > 0.0 || fDepthOffset1 > 0.0 && fDepthOffset2 < 0.0) { + if (fDepthOffset1 < 0.0 && fDepthOffset2 > 0.0 || + fDepthOffset1 > 0.0 && fDepthOffset2 < 0.0) { // Line crosses near plane - interpolate to find clipping point dClipInterpolationFactor = 1.0 / (fDepthOffset1 - fDepthOffset2); - fClippedRightProj = (float)(dClipInterpolationFactor * (fRightProj * fDepthOffset1 - fDepthOffset2 * fRightProj_1)); + fClippedRightProj = + (float)(dClipInterpolationFactor * + (fRightProj * fDepthOffset1 - fDepthOffset2 * fRightProj_1)); if (fDepthOffset1 >= 0.0) { // Point 1 is behind near plane, clip it fDepthOffset2 = 0.0; fRightProj = fClippedRightProj; - fForwardProj = (float)((fClippedForwardProj * fDepthOffset1 - fForwardProj * fDepthOffset2) * dClipInterpolationFactor); + fForwardProj = (float)((fClippedForwardProj * fDepthOffset1 - + fForwardProj * fDepthOffset2) * + dClipInterpolationFactor); } else { // Point 2 is behind near plane, clip it fDepthOffset1 = 0.0; fRightProj_1 = fClippedRightProj; - fClippedForwardProj = (float)((fClippedForwardProj * fDepthOffset1 - fForwardProj * fDepthOffset2) * dClipInterpolationFactor); + fClippedForwardProj = (float)((fClippedForwardProj * fDepthOffset1 - + fForwardProj * fDepthOffset2) * + dClipInterpolationFactor); } } @@ -184,57 +182,68 @@ void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, float f // Project point 1 to screen coordinates with perspective division // X coordinate for point 1 - iScaledScreenX1 = (int)((fViewDist * fForwardProj * (1.0 / fFinalDepth1) + dScreenCenterX) * dScrScale); + iScaledScreenX1 = (int)((fViewDist * fForwardProj * (1.0 / fFinalDepth1) + + dScreenCenterX) * + dScrScale); dScrScale_1 = dScrScale; dScreenCenterY = (double)ybase; //_CHP(); - // Convert scaled X coordinate to pixel coordinate (divide by 64 for fixed-point) + // Convert scaled X coordinate to pixel coordinate (divide by 64 for + // fixed-point) iScreenX1 = iScaledScreenX1 >> 6; // Y coordinate for point 1 - int iScaledScreenY1 = (int)((199.0 - 1.0 / fFinalDepth1 * (fViewDist * fRightProj_1) - dScreenCenterY) * dScrScale_1); + int iScaledScreenY1 = + (int)((199.0 - 1.0 / fFinalDepth1 * (fViewDist * fRightProj_1) - + dScreenCenterY) * + dScrScale_1); iScreenY1 = iScaledScreenY1 >> 6; //_CHP(); // X coordinate for point 2 - int iScaledScreenX2 = (int)((fViewDist * fClippedForwardProj * (1.0 / fFinalDepth2) + dScreenCenterX) * dScrScale_1); + int iScaledScreenX2 = + (int)((fViewDist * fClippedForwardProj * (1.0 / fFinalDepth2) + + dScreenCenterX) * + dScrScale_1); iScreenX2 = iScaledScreenX2 >> 6; //_CHP(); - // Y coordinate for point 2 - iScaledScreenY2 = (int)((199.0 - 1.0 / fFinalDepth2 * (fViewDist * fRightProj) - dScreenCenterY) * dScrScale_1); + // Y coordinate for point 2 + iScaledScreenY2 = + (int)((199.0 - 1.0 / fFinalDepth2 * (fViewDist * fRightProj) - + dScreenCenterY) * + dScrScale_1); // Draw line between the two projected points - compout( - pScrBuf, - iScreenX1, // X coordinate of point 1 - iScreenY1, // Y coordinate of point 1 - iScreenX2, // X coordinate of point 2 - iScaledScreenY2 >> 6, // Y coordinate of point 2 - byColor); + compout(pScrBuf, + iScreenX1, // X coordinate of point 1 + iScreenY1, // Y coordinate of point 1 + iScreenX2, // X coordinate of point 2 + iScaledScreenY2 >> 6, // Y coordinate of point 2 + byColor); } } //------------------------------------------------------------------------------------------------- -//000280E0 -void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) -{ - int iNewX; // edi - int iNewY; // esi - int iX0_1; // ebp - char byOutcode0; // cl - char byOutcode1; // dl - int iDy; // ecx - int iYOffset; // eax +// 000280E0 +void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, + uint8 byColor) { + int iNewX; // edi + int iNewY; // esi + int iX0_1; // ebp + char byOutcode0; // cl + char byOutcode1; // dl + int iDy; // ecx + int iYOffset; // eax char *p_byOutcode; // ecx - char byOutcode; // dl - int iDx; // [esp+8h] [ebp-28h] + char byOutcode; // dl + int iDx; // [esp+8h] [ebp-28h] char byUseOutcode; // [esp+10h] [ebp-20h] char byOutcode1_1; // [esp+14h] [ebp-1Ch] BYREF char byOutcode0_1; // [esp+18h] [ebp-18h] BYREF - char byDone; // [esp+1Ch] [ebp-14h] - char byDraw; // [esp+20h] [ebp-10h] + char byDone; // [esp+1Ch] [ebp-14h] + char byDraw; // [esp+20h] [ebp-10h] iX0_1 = iX0; byOutcode0 = 0; @@ -244,15 +253,15 @@ void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) // Get region code for point 0 if (iY0 < winh) { if (iY0 < 0) - byOutcode0 = 4; // bottom + byOutcode0 = 4; // bottom } else { - byOutcode0 = 8; // top + byOutcode0 = 8; // top } if (iX0 < winw) { if (iX0 < 0) - ++byOutcode0; // left + ++byOutcode0; // left } else { - byOutcode0 += 2; // right + byOutcode0 += 2; // right } byOutcode0_1 = byOutcode0; byOutcode1 = 0; @@ -260,15 +269,15 @@ void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) // Get region code for point 1 if (iY1 < winh) { if (iY1 < 0) - byOutcode1 = 4; // bottom + byOutcode1 = 4; // bottom } else { - byOutcode1 = 8; // top + byOutcode1 = 8; // top } if (iX1 < winw) { if (iX1 < 0) - ++byOutcode1; // left + ++byOutcode1; // left } else { - byOutcode1 += 2; // right + byOutcode1 += 2; // right } byOutcode1_1 = byOutcode1; @@ -295,19 +304,19 @@ void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) // Calculate intersection with window boundary iDx = iX1 - iX0_1; iDy = iY1 - iY0; - if ((byUseOutcode & 8) != 0) // top + if ((byUseOutcode & 8) != 0) // top { iNewY = winh - 1; iNewX = iDx * (winh - 1 - iY0) / iDy + iX0_1; } else { - if ((byUseOutcode & 4) == 0) // bottom + if ((byUseOutcode & 4) == 0) // bottom { - if ((byUseOutcode & 2) != 0) // right + if ((byUseOutcode & 2) != 0) // right { iNewX = winw - 1; iYOffset = iDy * (winw - 1 - iX0_1) / iDx; } else { - if ((byUseOutcode & 1) == 0) // left + if ((byUseOutcode & 1) == 0) // left goto LABEL_35; iYOffset = iDy * -iX0_1 / iDx; iNewX = 0; @@ -319,7 +328,7 @@ void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) iNewX = iDx * -iY0 / iDy + iX0_1; } LABEL_35: - // Update clipped point and recompute outcode + // Update clipped point and recompute outcode if (byUseOutcode == byOutcode0_1) { p_byOutcode = &byOutcode0_1; iX0_1 = iNewX; @@ -362,29 +371,28 @@ void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) } //------------------------------------------------------------------------------------------------- -//000282F0 -void line(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) -{ - int iOldWinw; // ebp - int iTempX; // esi - int iTempY; // esi - int iDx; // edi - uint8 *pDest; // eax - int iDy; // esi - int iDy_1; // esi - int iError_2; // ebx - int iError_3; // edx +// 000282F0 +void line(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) { + int iOldWinw; // ebp + int iTempX; // esi + int iTempY; // esi + int iDx; // edi + uint8 *pDest; // eax + int iDy; // esi + int iDy_1; // esi + int iError_2; // ebx + int iError_3; // edx bool bAboveTarget; // cc - int iError_1; // ebx - int iError; // edx - int iTempX2; // [esp+4h] [ebp-10h] + int iError_1; // ebx + int iError; // edx + int iTempX2; // [esp+4h] [ebp-10h] iOldWinw = winw; iTempX2 = iX1; // single point check if (iX0 == iX1 && iY0 == iY1) { - pScrBuf[iX1 + winw * iY0] = byColor; // draw pixel + pScrBuf[iX1 + winw * iY0] = byColor; // draw pixel } else { // Swap points if needed to ensure left to right drawing if (iX0 > iX1) { @@ -407,54 +415,55 @@ void line(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) while (iY0 <= iY1) { ++iY0; iError -= iDx; - *pDest = byColor; // draw pixel - pDest += iOldWinw; // move down + *pDest = byColor; // draw pixel + pDest += iOldWinw; // move down if (iError < 0) { - ++pDest; // move right + ++pDest; // move right iError += iDy; } } - } else // gentle slope (|m| <= 1) + } else // gentle slope (|m| <= 1) { iError_1 = (iTempX2 - iX0) >> 1; while (iX0 <= iTempX2) { - ++pDest; // move right + ++pDest; // move right ++iX0; iError_1 -= iDy; - *(pDest - 1) = byColor; // draw pixel + *(pDest - 1) = byColor; // draw pixel if (iError_1 < 0) { iError_1 += iDx; - pDest += iOldWinw; // move down + pDest += iOldWinw; // move down } } } - } else // negative slope + } else // negative slope { iDy_1 = iY0 - iY1; // steep slope (|m| > 1) if (iDx <= iY0 - iY1) { iError_3 = iDy_1 >> 1; - for (bAboveTarget = iY0 < iY1; !bAboveTarget; bAboveTarget = iY0 < iY1) { + for (bAboveTarget = iY0 < iY1; !bAboveTarget; + bAboveTarget = iY0 < iY1) { --iY0; iError_3 -= iDx; - *pDest = byColor; // draw pixel - pDest -= iOldWinw; // move up + *pDest = byColor; // draw pixel + pDest -= iOldWinw; // move up if (iError_3 < 0) { - ++pDest; // move right + ++pDest; // move right iError_3 += iDy_1; } } - } else // gentle slope (|m| <= 1) + } else // gentle slope (|m| <= 1) { iError_2 = (iTempX2 - iX0) >> 1; while (iX0 <= iTempX2) { - ++pDest; // move right + ++pDest; // move right ++iX0; iError_2 -= iDy_1; - *(pDest - 1) = byColor; // draw pixel + *(pDest - 1) = byColor; // draw pixel if (iError_2 < 0) { iError_2 += iDx; - pDest -= iOldWinw; // move up + pDest -= iOldWinw; // move up } } } @@ -464,9 +473,8 @@ void line(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor) } //------------------------------------------------------------------------------------------------- -//00028400 -void LoadPanel() -{ +// 00028400 +void LoadPanel() { int iRevIdx; char *szRevPtr; const char *szRevFile; @@ -482,22 +490,24 @@ void LoadPanel() szRevFile = revs_files2[iRevIdx]; // Check if file exists - iFileHandle = ROLLERopen(szRevFile, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = ROLLERopen( + szRevFile, + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open %s", szRevFile); - //printf("Unable to open %s\n\n", szRevFile); - //doexit(); + // printf("Unable to open %s\n\n", szRevFile); + // doexit(); } close(iFileHandle); // Load the compressed file uiFileLength = getcompactedfilelength(szRevPtr); pBuf = getbuffer(uiFileLength); - rev_vga[iRevIdx] = (tBlockHeader*)pBuf; // Store buffer pointer in array + rev_vga[iRevIdx] = (tBlockHeader *)pBuf; // Store buffer pointer in array loadcompactedfile(szRevPtr, (uint8 *)pBuf); ++iRevIdx; - szRevPtr += 13; // Move to next filename + szRevPtr += 13; // Move to next filename } } else { szRevPtr = revs_files1[0]; @@ -505,32 +515,33 @@ void LoadPanel() szRevFile = revs_files1[iRevIdx]; // Check if file exists - iFileHandle = ROLLERopen(revs_files1[iRevIdx], O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = ROLLERopen( + revs_files1[iRevIdx], + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open %s", szRevFile); - //printf("Unable to open %s\n\n", szRevFile); - //doexit(); + // printf("Unable to open %s\n\n", szRevFile); + // doexit(); } close(iFileHandle); // Load the compressed file uiFileLength = getcompactedfilelength(szRevPtr); pBuf = getbuffer(uiFileLength); - rev_vga[iRevIdx] = (tBlockHeader *)pBuf; // Store buffer pointer in array + rev_vga[iRevIdx] = (tBlockHeader *)pBuf; // Store buffer pointer in array loadcompactedfile(szRevPtr, (uint8 *)pBuf); ++iRevIdx; - szRevPtr += 13; // Move to next filename + szRevPtr += 13; // Move to next filename } } } //------------------------------------------------------------------------------------------------- -//00028500 -void InitRemaps() -{ - int iCarIdx; // edi - int iCartexIdx; // esi +// 00028500 +void InitRemaps() { + int iCarIdx; // edi + int iCartexIdx; // esi int iCarTexsLoaded; // ecx init_remap(cargen_vga, 18, num_textures[18], gfx_size); @@ -541,11 +552,9 @@ void InitRemaps() do { iCarTexsLoaded = car_texs_loaded[iCartexIdx]; if (iCarTexsLoaded != -1) - init_remap( - cartex_vga[iCarTexsLoaded + 1], - car_texs_loaded[iCartexIdx] - 1, - num_textures[iCarTexsLoaded + 1], - gfx_size); + init_remap(cartex_vga[iCarTexsLoaded + 1], + car_texs_loaded[iCartexIdx] - 1, + num_textures[iCarTexsLoaded + 1], gfx_size); ++iCarIdx; ++iCartexIdx; } while (iCarIdx < numcars); @@ -554,23 +563,24 @@ void InitRemaps() } //------------------------------------------------------------------------------------------------- -//000285B0 -void LoadGenericCarTextures() -{ - int iFileHandle; // edx +// 000285B0 +void LoadGenericCarTextures() { + int iFileHandle; // edx signed int iFileLength; // ecx - int iNumTextures; // eax - int iNumTextures_1; // esi - int iFinalTexCount; // ecx - int iMapSelMode; // ebx - uint8 *pFileBuf; // [esp+0h] [ebp-14h] BYREF + int iNumTextures; // eax + int iNumTextures_1; // esi + int iFinalTexCount; // ecx + int iMapSelMode; // ebx + uint8 *pFileBuf; // [esp+0h] [ebp-14h] BYREF // Check if generic car texture file exists - iFileHandle = ROLLERopen(gencartex_name, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = + ROLLERopen(gencartex_name, + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open texture map data file <%s>", gencartex_name); - //printf("Unable to open texture map data file <%s>\n\n", gencartex_name); - //doexit(); + // printf("Unable to open texture map data file <%s>\n\n", gencartex_name); + // doexit(); } close(iFileHandle); @@ -622,51 +632,49 @@ void LoadGenericCarTextures() // Setup tex mapping selector setmapsel(cargen_vga, 18, iMapSelMode, iFinalTexCount); if (g_pGameRenderer) - game_render_load_texture(g_pGameRenderer, cargen_vga, 256, 0, - 18, gfx_size); + game_render_load_texture(g_pGameRenderer, cargen_vga, 256, 0, 18, gfx_size); // Update count num_textures[18] = iNumTextures_1; } //------------------------------------------------------------------------------------------------- -//000286C0 -void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) -{ - int iFileHandle; // edx +// 000286C0 +void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) { + int iFileHandle; // edx int iCompressedFileLength; // ecx - int iNumTexBlocks; // eax - uint8 *pTexBuf; // ebx - int iNumTexsToProcess; // ebp - int iChunkDataSize; // edx - uint8 *pChunkData; // eax - int iTexBlockIdx; // edi - uint8 *pSourcePixel; // eax - int iPxRowIdx; // esi - int iPixelGroupIdx; // edx - uint8 *pDestPixel; // ebx - uint8 byPx1; // cl - uint8 *pNextSourcePixel; // eax - uint8 byPx2; // cl - uint8 byPx3; // cl - uint8 byPx4; // cl - int iChunkDataSize_1; // edx - uint8 *pChunkData_1; // eax - int iTexBlockIdx_1; // edi - uint8 *pSourcePixel_1; // eax - int iPxRowIdx_1; // esi - int iPixelGroupIdx_1; // edx - uint8 *pDestPixel_1; // ebx - uint8 byPx1_1; // cl + int iNumTexBlocks; // eax + uint8 *pTexBuf; // ebx + int iNumTexsToProcess; // ebp + int iChunkDataSize; // edx + uint8 *pChunkData; // eax + int iTexBlockIdx; // edi + uint8 *pSourcePixel; // eax + int iPxRowIdx; // esi + int iPixelGroupIdx; // edx + uint8 *pDestPixel; // ebx + uint8 byPx1; // cl + uint8 *pNextSourcePixel; // eax + uint8 byPx2; // cl + uint8 byPx3; // cl + uint8 byPx4; // cl + int iChunkDataSize_1; // edx + uint8 *pChunkData_1; // eax + int iTexBlockIdx_1; // edi + uint8 *pSourcePixel_1; // eax + int iPxRowIdx_1; // esi + int iPixelGroupIdx_1; // edx + uint8 *pDestPixel_1; // ebx + uint8 byPx1_1; // cl uint8 *pNextSourcePixel_1; // eax - uint8 byPx2_1; // cl - uint8 byPx3_1; // cl - uint8 byPx4_1; // cl - uint8 *pTexBuf_1; // eax - int iTexSlotIdx; // [esp+0h] [ebp-28h] - int iTotalFileLength; // [esp+8h] [ebp-20h] - char *szTexFile; // [esp+Ch] [ebp-1Ch] - int iRemainingFileLength; // [esp+10h] [ebp-18h] + uint8 byPx2_1; // cl + uint8 byPx3_1; // cl + uint8 byPx4_1; // cl + uint8 *pTexBuf_1; // eax + int iTexSlotIdx; // [esp+0h] [ebp-28h] + int iTotalFileLength; // [esp+8h] [ebp-20h] + char *szTexFile; // [esp+Ch] [ebp-1Ch] + int iRemainingFileLength; // [esp+10h] [ebp-18h] iTexSlotIdx = byTexSlotIdx; szTexFile = car_texture_names[iCartexIdx]; @@ -676,15 +684,17 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) } // Advanced cars - if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && iCartexIdx >= 1 && iCartexIdx <= 8) - *szTexFile = 'y'; // load Y tex files + if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && iCartexIdx >= 1 && + iCartexIdx <= 8) + *szTexFile = 'y'; // load Y tex files // Check if file exists - iFileHandle = ROLLERopen(szTexFile, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = ROLLERopen( + szTexFile, O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open texture map data file <%s>", szTexFile); - //printf("Unable to open texture map data file <%s>\n\n", szTexFile); - //doexit(); + // printf("Unable to open texture map data file <%s>\n\n", szTexFile); + // doexit(); } close(iFileHandle); @@ -706,16 +716,17 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) iRemainingFileLength = iCompressedFileLength; // Allocate buffer for processed texture (aligned to 8-tex boundaries) - pTexBuf = (uint8 *)getbuffer((((int16)iTotalFileLength + 7) & 0xFFF8) << 10); + pTexBuf = + (uint8 *)getbuffer((((int16)iTotalFileLength + 7) & 0xFFF8) << 10); cartex_vga[iTexSlotIdx - 1] = pTexBuf; // Process file in chunks due to memory constraints while (iRemainingFileLength > 0) { iNumTexsToProcess = iRemainingFileLength / 4096; - // Low memory mode + // Low memory mode if (no_mem) { - if (iRemainingFileLength <= 20480) // 5 blocks max (5 * 4096) + if (iRemainingFileLength <= 20480) // 5 blocks max (5 * 4096) { iChunkDataSize = iRemainingFileLength; pChunkData = scrbuf; @@ -728,7 +739,8 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) // Process each tex block in chunk iTexBlockIdx = 0; - for (pSourcePixel = scrbuf + 40000; iTexBlockIdx < iNumTexsToProcess; ++iTexBlockIdx) { + for (pSourcePixel = scrbuf + 40000; iTexBlockIdx < iNumTexsToProcess; + ++iTexBlockIdx) { // Process each row of 32x32 tex for (iPxRowIdx = 0; iPxRowIdx < 32; ++iPxRowIdx) { iPixelGroupIdx = 0; @@ -754,18 +766,18 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) pSourcePixel = pNextSourcePixel + 2; *(pTexBuf - 1) = byPx4; } while (iPixelGroupIdx < 32); - pSourcePixel += 64; // skip to next row + pSourcePixel += 64; // skip to next row } } iRemainingFileLength -= 20480; - } else // normal memory mode + } else // normal memory mode { - if (iRemainingFileLength <= 196608) // 48 blocks max (48 * 4096) + if (iRemainingFileLength <= 196608) // 48 blocks max (48 * 4096) { pChunkData_1 = scrbuf; iChunkDataSize_1 = iRemainingFileLength; } else { - iChunkDataSize_1 = 196608; // process 48 blocks at a time + iChunkDataSize_1 = 196608; // process 48 blocks at a time pChunkData_1 = scrbuf; iNumTexsToProcess = 48; } @@ -773,7 +785,8 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) // Process each texture block in chunk iTexBlockIdx_1 = 0; - for (pSourcePixel_1 = scrbuf + 40000; iTexBlockIdx_1 < iNumTexsToProcess; ++iTexBlockIdx_1) { + for (pSourcePixel_1 = scrbuf + 40000; + iTexBlockIdx_1 < iNumTexsToProcess; ++iTexBlockIdx_1) { // Process each row of 32x32 texture for (iPxRowIdx_1 = 0; iPxRowIdx_1 < 32; ++iPxRowIdx_1) { iPixelGroupIdx_1 = 0; @@ -798,7 +811,7 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) pSourcePixel_1 = pNextSourcePixel_1 + 2; *(pTexBuf - 1) = byPx4_1; } while (iPixelGroupIdx_1 < 32); - pSourcePixel_1 += 64; // skip to next row + pSourcePixel_1 += 64; // skip to next row } } iRemainingFileLength -= 196608; @@ -815,7 +828,7 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) setmapsel(cartex_vga[iTexSlotIdx - 1], iTexSlotIdx, -1, iTotalFileLength); if (g_pGameRenderer) game_render_load_texture(g_pGameRenderer, cartex_vga[iTexSlotIdx - 1], - 256, 0, iTexSlotIdx, 1); + 256, 0, iTexSlotIdx, 1); // Store num textures num_textures[iTexSlotIdx - 1] = iTotalFileLength; @@ -834,38 +847,40 @@ void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx) setmapsel(cartex_vga[iTexSlotIdx - 1], iTexSlotIdx, 0, iTotalFileLength); if (g_pGameRenderer) game_render_load_texture(g_pGameRenderer, cartex_vga[iTexSlotIdx - 1], - 256, 0, iTexSlotIdx, 0); + 256, 0, iTexSlotIdx, 0); // Store num textures num_textures[iTexSlotIdx - 1] = iTotalFileLength; } // Restore original filename if modified - if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && iCartexIdx >= 1 && iCartexIdx <= 8) + if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0 && iCartexIdx >= 1 && + iCartexIdx <= 8) *szTexFile = 'x'; } //------------------------------------------------------------------------------------------------- -//000289E0 -void LoadBldTextures() -{ - int iFileHandle; // edx +// 000289E0 +void LoadBldTextures() { + int iFileHandle; // edx signed int iCompressedFileLength; // ecx - int iNumTextureBlocks; // eax - int iTexCount; // esi - int iFinalTexCount; // ecx - int iMapSelMode; // ebx - char *pTempBuf; // [esp+0h] [ebp-14h] BYREF + int iNumTextureBlocks; // eax + int iTexCount; // esi + int iFinalTexCount; // ecx + int iMapSelMode; // ebx + char *pTempBuf; // [esp+0h] [ebp-14h] BYREF // free existing bld fre((void **)&building_vga); // Check if bld file exists - iFileHandle = ROLLERopen(bldtex_file, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = + ROLLERopen(bldtex_file, + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open bld texture map data file"); - //printf("Unable to open bld texture map data file\n\n"); - //doexit(); + // printf("Unable to open bld texture map data file\n\n"); + // doexit(); } close(iFileHandle); @@ -877,17 +892,19 @@ void LoadBldTextures() // 32x32 mode if (gfx_size == 1) { // Load and process 32x32 textures - building_vga = (uint8 *)getbuffer((((int16)iNumTextureBlocks + 7) & 0xFFF8) << 10); + building_vga = + (uint8 *)getbuffer((((int16)iNumTextureBlocks + 7) & 0xFFF8) << 10); pTempBuf = (char *)getbuffer(iCompressedFileLength); loadcompactedfile(bldtex_file, (uint8 *)pTempBuf); iFinalTexCount = iCompressedFileLength / 4096; sort_small_texture(building_vga, (uint8 *)pTempBuf, iTexCount); iMapSelMode = -1; fre((void **)&pTempBuf); - } else // 64x64 mode + } else // 64x64 mode { // Load and process 64x64 textures - building_vga = (uint8 *)getbuffer((((int16)iNumTextureBlocks + 3) & 0xFFFC) << 12); + building_vga = + (uint8 *)getbuffer((((int16)iNumTextureBlocks + 3) & 0xFFFC) << 12); iFinalTexCount = iCompressedFileLength / 4096; loadcompactedfile(bldtex_file, building_vga); iMapSelMode = 0; @@ -898,56 +915,57 @@ void LoadBldTextures() BldTextures = iTexCount; setmapsel(building_vga, 17, iMapSelMode, iFinalTexCount); if (g_pGameRenderer) - game_render_load_texture(g_pGameRenderer, building_vga, 256, 0, - 17, gfx_size); + game_render_load_texture(g_pGameRenderer, building_vga, 256, 0, 17, + gfx_size); num_textures[17] = iTexCount; } //------------------------------------------------------------------------------------------------- -//00028B00 -void LoadTextures() -{ +// 00028B00 +void LoadTextures() { int iCompressedFileLength; // ecx - int iNumTextureBlocks; // eax - uint8 *pTexBuf; // ebx - int iNumTexsToProcess; // ebp - int iChunkDataSize; // edx - uint8 *pChunkData; // eax - int iTexBlockIdx; // edi - uint8 *pSourcePixel; // eax - int j; // esi - int iPxGroupIdx; // edx - uint8 *pDestPixel; // ebx - uint8 byPx1; // cl - uint8 *pNextSourcePixel; // eax - uint8 byPx2; // cl - uint8 byPx3; // cl - uint8 byPx4; // cl - int iChunkDataSize_1; // edx - uint8 *pChunkData_1; // eax - int iTexBlockIdx_1; // edi - uint8 *pSourcePixel_1; // eax - int iPxRowIdx; // esi - int iPxGroupIdx_1; // edx - uint8 *pDestPixel_1; // ebx - uint8 byPx1_1; // cl + int iNumTextureBlocks; // eax + uint8 *pTexBuf; // ebx + int iNumTexsToProcess; // ebp + int iChunkDataSize; // edx + uint8 *pChunkData; // eax + int iTexBlockIdx; // edi + uint8 *pSourcePixel; // eax + int j; // esi + int iPxGroupIdx; // edx + uint8 *pDestPixel; // ebx + uint8 byPx1; // cl + uint8 *pNextSourcePixel; // eax + uint8 byPx2; // cl + uint8 byPx3; // cl + uint8 byPx4; // cl + int iChunkDataSize_1; // edx + uint8 *pChunkData_1; // eax + int iTexBlockIdx_1; // edi + uint8 *pSourcePixel_1; // eax + int iPxRowIdx; // esi + int iPxGroupIdx_1; // edx + uint8 *pDestPixel_1; // ebx + uint8 byPx1_1; // cl uint8 *pNextSourcePixel_1; // eax - uint8 byPx2_1; // cl - uint8 byPx3_1; // cl - uint8 byPx4_1; // cl - int iFileHandle; // [esp+0h] [ebp-24h] - int iTotalTextureBlocks; // [esp+4h] [ebp-20h] - int iRemainingFileLength; // [esp+8h] [ebp-1Ch] + uint8 byPx2_1; // cl + uint8 byPx3_1; // cl + uint8 byPx4_1; // cl + int iFileHandle; // [esp+0h] [ebp-24h] + int iTotalTextureBlocks; // [esp+4h] [ebp-20h] + int iRemainingFileLength; // [esp+8h] [ebp-1Ch] // Free existing texture fre((void **)&texture_vga); // Check if tex file exists - iFileHandle = ROLLERopen(texture_file, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFileHandle = + ROLLERopen(texture_file, + O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) { ErrorBoxExit("Unable to open texture map data file"); - //printf("Unable to open texture map data file\n\n"); - //doexit(); + // printf("Unable to open texture map data file\n\n"); + // doexit(); } close(iFileHandle); @@ -963,20 +981,21 @@ void LoadTextures() iRemainingFileLength = iCompressedFileLength; // Allocate buf for processed textures (aligned to 8-tex boundaries) - pTexBuf = (uint8 *)getbuffer((((int16)iTotalTextureBlocks + 7) & 0xFFF8) << 10); + pTexBuf = + (uint8 *)getbuffer((((int16)iTotalTextureBlocks + 7) & 0xFFF8) << 10); texture_vga = pTexBuf; // Process file in chunks due to memory constraints while (iRemainingFileLength > 0) { iNumTexsToProcess = iRemainingFileLength / 4096; - if (no_mem) // low memory mode + if (no_mem) // low memory mode { - if (iRemainingFileLength <= 20480) // 5 blocks max (5 * 4096) + if (iRemainingFileLength <= 20480) // 5 blocks max (5 * 4096) { iChunkDataSize = iRemainingFileLength; pChunkData = scrbuf; } else { - iChunkDataSize = 20480; // process 5 blocks at a time + iChunkDataSize = 20480; // process 5 blocks at a time pChunkData = scrbuf; iNumTexsToProcess = 5; } @@ -986,7 +1005,8 @@ void LoadTextures() // Process each tex block in chunk iTexBlockIdx = 0; - for (pSourcePixel = scrbuf + 40000; iTexBlockIdx < iNumTexsToProcess; ++iTexBlockIdx) { + for (pSourcePixel = scrbuf + 40000; iTexBlockIdx < iNumTexsToProcess; + ++iTexBlockIdx) { for (j = 0; j < 32; ++j) { iPxGroupIdx = 0; @@ -1012,18 +1032,18 @@ void LoadTextures() pSourcePixel = pNextSourcePixel + 2; *(pTexBuf - 1) = byPx4; } while (iPxGroupIdx < 32); - pSourcePixel += 64; // skip to next row + pSourcePixel += 64; // skip to next row } } iRemainingFileLength -= 20480; - } else // normal memory mode + } else // normal memory mode { - if (iRemainingFileLength <= 196608) // 48 blocks max (48 * 4096) + if (iRemainingFileLength <= 196608) // 48 blocks max (48 * 4096) { pChunkData_1 = scrbuf; iChunkDataSize_1 = iRemainingFileLength; } else { - iChunkDataSize_1 = 196608; // process 48 blocks at a time + iChunkDataSize_1 = 196608; // process 48 blocks at a time pChunkData_1 = scrbuf; iNumTexsToProcess = 48; } @@ -1033,7 +1053,8 @@ void LoadTextures() // process each tex block in chunk iTexBlockIdx_1 = 0; - for (pSourcePixel_1 = scrbuf + 40000; iTexBlockIdx_1 < iNumTexsToProcess; ++iTexBlockIdx_1) { + for (pSourcePixel_1 = scrbuf + 40000; + iTexBlockIdx_1 < iNumTexsToProcess; ++iTexBlockIdx_1) { // Process each row of 32x32 tex for (iPxRowIdx = 0; iPxRowIdx < 32; ++iPxRowIdx) { iPxGroupIdx_1 = 0; @@ -1060,7 +1081,7 @@ void LoadTextures() pSourcePixel_1 = pNextSourcePixel_1 + 2; *(pTexBuf - 1) = byPx4_1; } while (iPxGroupIdx_1 < 32); - pSourcePixel_1 += 64; // skip to next row + pSourcePixel_1 += 64; // skip to next row } } iRemainingFileLength -= 196608; @@ -1072,53 +1093,52 @@ void LoadTextures() sort_mini_texture(texture_vga, iTotalTextureBlocks); setmapsel(texture_vga, 0, -1, iTotalTextureBlocks); if (g_pGameRenderer) - game_render_load_texture(g_pGameRenderer, texture_vga, 256, 0, - 0, 1); + game_render_load_texture(g_pGameRenderer, texture_vga, 256, 0, 0, 1); NoOfTextures = iTotalTextureBlocks; close(iFileHandle); num_textures[19] = iTotalTextureBlocks; - } else // 64x64 mode + } else // 64x64 mode { // Allocate buffer for processed textures (aligned to 4-tex boundaries) - texture_vga = (uint8 *)getbuffer((((int16)iNumTextureBlocks + 3) & 0xFFFC) << 12); + texture_vga = + (uint8 *)getbuffer((((int16)iNumTextureBlocks + 3) & 0xFFFC) << 12); loadcompactedfile(texture_file, texture_vga); sort_texture(texture_vga, iTotalTextureBlocks); setmapsel(texture_vga, 0, 0, iTotalTextureBlocks); if (g_pGameRenderer) - game_render_load_texture(g_pGameRenderer, texture_vga, 256, 0, - 0, 0); + game_render_load_texture(g_pGameRenderer, texture_vga, 256, 0, 0, 0); NoOfTextures = iCompressedFileLength / 4096; num_textures[19] = NoOfTextures; } } //------------------------------------------------------------------------------------------------- -//00028DA0 -void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, int iIsLowRes) -{ - int iBlockSize; // edi - uint8 *pBlockRow; // ebx - int iTexRowBytes_1; // eax - uint8 *pBlockData; // ebx - int iTotalB; // ebp - int i; // ecx - int j; // eax - int iMaxColorIdx; // edx - int iCurrColorIdx; // edx - int iSearchIdx; // eax - int iMaxColorCount; // ebx - int iColorCount; // ebx - int iColorCount_1; // esi - int iAvgB; // ebp - int iAvgG; // eax - int iDominantColorIdx; // edx - int iTotalPxCount; // [esp+0h] [ebp-40h] - int iTexRowBytes; // [esp+10h] [ebp-30h] - int iRemapAyOffset; // [esp+18h] [ebp-28h] - int iBlockIdx; // [esp+1Ch] [ebp-24h] - int iTotalG; // [esp+28h] [ebp-18h] - int iTotalR; // [esp+2Ch] [ebp-14h] - int iAvgR; // [esp+2Ch] [ebp-14h] +// 00028DA0 +void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, + int iIsLowRes) { + int iBlockSize; // edi + uint8 *pBlockRow; // ebx + int iTexRowBytes_1; // eax + uint8 *pBlockData; // ebx + int iTotalB; // ebp + int i; // ecx + int j; // eax + int iMaxColorIdx; // edx + int iCurrColorIdx; // edx + int iSearchIdx; // eax + int iMaxColorCount; // ebx + int iColorCount; // ebx + int iColorCount_1; // esi + int iAvgB; // ebp + int iAvgG; // eax + int iDominantColorIdx; // edx + int iTotalPxCount; // [esp+0h] [ebp-40h] + int iTexRowBytes; // [esp+10h] [ebp-30h] + int iRemapAyOffset; // [esp+18h] [ebp-28h] + int iBlockIdx; // [esp+1Ch] [ebp-24h] + int iTotalG; // [esp+28h] [ebp-18h] + int iTotalR; // [esp+2Ch] [ebp-14h] + int iAvgR; // [esp+2Ch] [ebp-14h] int iDominantColorSearch; // [esp+30h] [ebp-10h] // Determine block size based on resolution @@ -1132,18 +1152,20 @@ void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, int iIs if (iNumBlocks > 0) { iRemapAyOffset = 0; iTexRowBytes = 0; - if (iRemapType >= 0) //check added by ROLLER + if (iRemapType >= 0) // check added by ROLLER iTexRowBytes = iRemapType << 10; do { // Calculate tex memory addr for current block if (iIsLowRes) { // 8 blocks per row, each block 32px wide - pBlockRow = &pTextureBaseAddr[0x2000 * (iBlockIdx >> 3)];// row start addr - iTexRowBytes_1 = 32 * (iBlockIdx & 7); // column offset + pBlockRow = + &pTextureBaseAddr[0x2000 * (iBlockIdx >> 3)]; // row start addr + iTexRowBytes_1 = 32 * (iBlockIdx & 7); // column offset } else { // 4 blocks per row, 64px wide - pBlockRow = &pTextureBaseAddr[0x4000 * (iBlockIdx >> 2)];// row start addr - iTexRowBytes_1 = (iBlockIdx & 3) << 6; // column offset + pBlockRow = + &pTextureBaseAddr[0x4000 * (iBlockIdx >> 2)]; // row start addr + iTexRowBytes_1 = (iBlockIdx & 3) << 6; // column offset } pBlockData = &pBlockRow[iTexRowBytes_1]; @@ -1159,15 +1181,16 @@ void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, int iIs // Analyze all pixels in current block for (i = 0; i < iBlockSize; ++i) { for (j = 0; j < iBlockSize; ++j) { - iMaxColorIdx = *pBlockData++; // get pixel color index - ++mode_c[iMaxColorIdx]; // inc frequency counter for this color + iMaxColorIdx = *pBlockData++; // get pixel color index + ++mode_c[iMaxColorIdx]; // inc frequency counter for this color } - pBlockData += 256 - iBlockSize; // skip to next row + pBlockData += 256 - iBlockSize; // skip to next row } iTotalPxCount = 0; - for (iDominantColorSearch = 0; iDominantColorSearch < 4; ++iDominantColorSearch) { + for (iDominantColorSearch = 0; iDominantColorSearch < 4; + ++iDominantColorSearch) { iCurrColorIdx = 0; iSearchIdx = 0; iMaxColorCount = 0; @@ -1240,9 +1263,10 @@ void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, int iIs } // Default: store in car_remap - *(int *)((char *)car_remap + iTexRowBytes) = nearest_colour(iAvgR, iAvgB, iAvgG); + *(int *)((char *)car_remap + iTexRowBytes) = + nearest_colour(iAvgR, iAvgB, iAvgG); STORE_COMPLETE: - iTexRowBytes += 4; // move to next pos in remap array + iTexRowBytes += 4; // move to next pos in remap array ++iRemapAyOffset; ++iBlockIdx; } while (iBlockIdx < iNumBlocks); @@ -1250,28 +1274,27 @@ void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, int iIs } //------------------------------------------------------------------------------------------------- -//00029120 -void sort_small_texture(uint8 *pDest, uint8 *pSrc, int iNumBlocks) -{ - //ROLLER: we do not need interleaved texture data for this implementation +// 00029120 +void sort_small_texture(uint8 *pDest, uint8 *pSrc, int iNumBlocks) { + // ROLLER: we do not need interleaved texture data for this implementation return; - int iNumLayers; // eax - int iCurrLayerSize; // ebp + int iNumLayers; // eax + int iCurrLayerSize; // ebp int iLayerPixelHeight; // ebp - int iBlockRowOffset; // edi - int iPxRowInBlock; // esi - uint8 *pDestPixel; // eax - int iPixelColGroup; // edx - uint8 *pDestAddr; // eax - uint8 byPx1; // cl - uint8 *pSrcPixel; // ebx - uint8 byPx2; // cl - uint8 byPx3; // cl - uint8 byPx4; // cl - int iNumLayers_1; // [esp+0h] [ebp-20h] - int iLayerIdx; // [esp+4h] [ebp-1Ch] - int iRemainingBlocks; // [esp+8h] [ebp-18h] + int iBlockRowOffset; // edi + int iPxRowInBlock; // esi + uint8 *pDestPixel; // eax + int iPixelColGroup; // edx + uint8 *pDestAddr; // eax + uint8 byPx1; // cl + uint8 *pSrcPixel; // ebx + uint8 byPx2; // cl + uint8 byPx3; // cl + uint8 byPx4; // cl + int iNumLayers_1; // [esp+0h] [ebp-20h] + int iLayerIdx; // [esp+4h] [ebp-1Ch] + int iRemainingBlocks; // [esp+8h] [ebp-18h] // Calculate number of complete 8-block layers iNumLayers = iNumBlocks / 8; @@ -1286,7 +1309,7 @@ void sort_small_texture(uint8 *pDest, uint8 *pSrc, int iNumBlocks) else iCurrLayerSize = 8; if (iCurrLayerSize > 0) { - iLayerPixelHeight = 32 * iCurrLayerSize; // each block is 32px wide + iLayerPixelHeight = 32 * iCurrLayerSize; // each block is 32px wide iBlockRowOffset = 0; // Process each block column in layer @@ -1322,9 +1345,9 @@ void sort_small_texture(uint8 *pDest, uint8 *pSrc, int iNumBlocks) *(pDestPixel - 1) = byPx4; } while (iPixelColGroup < 32); - pDestPixel += 224; // skip to next row (256-32 = 224 px) + pDestPixel += 224; // skip to next row (256-32 = 224 px) ++iPxRowInBlock; - pSrc += 64; // advance src ptr (skip padding or next row data) + pSrc += 64; // advance src ptr (skip padding or next row data) } while (iPxRowInBlock < 32); // move to next block column @@ -1332,38 +1355,37 @@ void sort_small_texture(uint8 *pDest, uint8 *pSrc, int iNumBlocks) } while (iBlockRowOffset < iLayerPixelHeight); } - iRemainingBlocks -= 8; // process next layer - pDest += 8192; // move to next tex layer (8192 bytes) + iRemainingBlocks -= 8; // process next layer + pDest += 8192; // move to next tex layer (8192 bytes) } } //------------------------------------------------------------------------------------------------- -//00029200 -void sort_texture(uint8 *pTexData, int iNumTextures) -{ - int iTexturesInGroup; // ebp - int iSourceRowOffset; // esi - uint8 *pTempRow; // ecx - int iTexIdx; // edi - int iPixelGroupIdx; // edx - uint8 *pSourcePx; // eax - uint8 *pPx1; // ecx - uint8 byPx0; // bl - uint8 *pSourcePx_1; // eax - uint8 byPx2; // bl - uint8 byPx3; // bl - uint8 byPx4; // bl - uint8 *pTempBuf; // [esp+0h] [ebp-34h] BYREF - int iNumGroups; // [esp+4h] [ebp-30h] - int iGroupIdx; // [esp+8h] [ebp-2Ch] +// 00029200 +void sort_texture(uint8 *pTexData, int iNumTextures) { + int iTexturesInGroup; // ebp + int iSourceRowOffset; // esi + uint8 *pTempRow; // ecx + int iTexIdx; // edi + int iPixelGroupIdx; // edx + uint8 *pSourcePx; // eax + uint8 *pPx1; // ecx + uint8 byPx0; // bl + uint8 *pSourcePx_1; // eax + uint8 byPx2; // bl + uint8 byPx3; // bl + uint8 byPx4; // bl + uint8 *pTempBuf; // [esp+0h] [ebp-34h] BYREF + int iNumGroups; // [esp+4h] [ebp-30h] + int iGroupIdx; // [esp+8h] [ebp-2Ch] int iRemainingTextures; // [esp+Ch] [ebp-28h] - uint8 *pCurrTex; // [esp+10h] [ebp-24h] - int iTempRowOffset; // [esp+14h] [ebp-20h] - int iRowIdx; // [esp+18h] [ebp-1Ch] - uint8 *pGroupStart; // [esp+1Ch] [ebp-18h] SPLIT + uint8 *pCurrTex; // [esp+10h] [ebp-24h] + int iTempRowOffset; // [esp+14h] [ebp-20h] + int iRowIdx; // [esp+18h] [ebp-1Ch] + uint8 *pGroupStart; // [esp+1Ch] [ebp-18h] SPLIT iRemainingTextures = iNumTextures; - pTempBuf = (uint8 *)getbuffer(0x4000u); // 16KB temp buffer + pTempBuf = (uint8 *)getbuffer(0x4000u); // 16KB temp buffer pCurrTex = pTexData; iGroupIdx = 0; iNumGroups = iNumTextures / 4; @@ -1382,7 +1404,7 @@ void sort_texture(uint8 *pTexData, int iNumTextures) if (iTexturesInGroup > 0) { // Process each row of the 64x64 blocks for (iRowIdx = 0; iRowIdx < 64; ++iRowIdx) { - iSourceRowOffset = iRowIdx << 6; // iRowIndex * 64, 64 px per row + iSourceRowOffset = iRowIdx << 6; // iRowIndex * 64, 64 px per row pTempRow = &pTempBuf[iTempRowOffset]; // Process each texture in group @@ -1406,17 +1428,19 @@ void sort_texture(uint8 *pTexData, int iNumTextures) pSourcePx = pSourcePx_1 + 1; *(pTempRow - 1) = byPx4; } while (iPixelGroupIdx < 64); - iSourceRowOffset += 4096; // move to next texture (4096 bytes = 64x64 px) + iSourceRowOffset += + 4096; // move to next texture (4096 bytes = 64x64 px) } - iTempRowOffset += 256; // move to next row in temp buffer (4 tex * 64 px) + iTempRowOffset += + 256; // move to next row in temp buffer (4 tex * 64 px) } // Copy reorganized data back to original location memcpy(pCurrTex, pTempBuf, 0x4000u); } - pCurrTex += 0x4000; // move to next group of textures - iRemainingTextures -= 4; // process remaining textures + pCurrTex += 0x4000; // move to next group of textures + iRemainingTextures -= 4; // process remaining textures ++iGroupIdx; } while (iGroupIdx <= iNumGroups); } @@ -1426,32 +1450,31 @@ void sort_texture(uint8 *pTexData, int iNumTextures) } //------------------------------------------------------------------------------------------------- -//00029340 -void sort_mini_texture(uint8 *pTexData, int iNumTextures) -{ - int iTexturesInGroup; // ebp - int iTexIdx; // esi - int iSourceRowOffset; // edi - uint8 *pTempRow; // ecx - int iPixelGroupIdx; // edx - uint8 *pSourcePx; // eax - uint8 *pDestPixel; // ecx - uint8 byPx1; // bl +// 00029340 +void sort_mini_texture(uint8 *pTexData, int iNumTextures) { + int iTexturesInGroup; // ebp + int iTexIdx; // esi + int iSourceRowOffset; // edi + uint8 *pTempRow; // ecx + int iPixelGroupIdx; // edx + uint8 *pSourcePx; // eax + uint8 *pDestPixel; // ecx + uint8 byPx1; // bl uint8 *iPixelGroupIdx_1; // eax - char byPx2; // bl - char byPx3; // bl - char byPx4; // bl - uint8 *pTempBuf; // [esp+0h] [ebp-34h] BYREF - int iNumGroups; // [esp+4h] [ebp-30h] - int iGroupIdx; // [esp+8h] [ebp-2Ch] - uint8 *pCurrTex; // [esp+Ch] [ebp-28h] - int iRemainingTextures; // [esp+10h] [ebp-24h] - int iTempRowOffset; // [esp+14h] [ebp-20h] - int iRowIdx; // [esp+18h] [ebp-1Ch] - uint8 *pGroupStart; // [esp+1Ch] [ebp-18h] + char byPx2; // bl + char byPx3; // bl + char byPx4; // bl + uint8 *pTempBuf; // [esp+0h] [ebp-34h] BYREF + int iNumGroups; // [esp+4h] [ebp-30h] + int iGroupIdx; // [esp+8h] [ebp-2Ch] + uint8 *pCurrTex; // [esp+Ch] [ebp-28h] + int iRemainingTextures; // [esp+10h] [ebp-24h] + int iTempRowOffset; // [esp+14h] [ebp-20h] + int iRowIdx; // [esp+18h] [ebp-1Ch] + uint8 *pGroupStart; // [esp+1Ch] [ebp-18h] iRemainingTextures = iNumTextures; - pTempBuf = (uint8 *)getbuffer(0x2000u); // 8KB temp buffer + pTempBuf = (uint8 *)getbuffer(0x2000u); // 8KB temp buffer pCurrTex = pTexData; iGroupIdx = 0; iNumGroups = iNumTextures / 8; @@ -1501,7 +1524,8 @@ void sort_mini_texture(uint8 *pTexData, int iNumTextures) } while (iPixelGroupIdx < 32); ++iTexIdx; - iSourceRowOffset += 1024; // Move to next texture (1024 bytes = 32x32 px) + iSourceRowOffset += + 1024; // Move to next texture (1024 bytes = 32x32 px) } while (iTexIdx < iTexturesInGroup); // Move to next row in temp buffer (8 tex * 32px) @@ -1512,8 +1536,8 @@ void sort_mini_texture(uint8 *pTexData, int iNumTextures) memcpy(pCurrTex, pTempBuf, 0x2000u); } - pCurrTex += 0x2000; // move to next group of textures - iRemainingTextures -= 8; // update remaining textures + pCurrTex += 0x2000; // move to next group of textures + iRemainingTextures -= 8; // update remaining textures ++iGroupIdx; } while (iGroupIdx <= iNumGroups); } @@ -1523,13 +1547,12 @@ void sort_mini_texture(uint8 *pTexData, int iNumTextures) } //------------------------------------------------------------------------------------------------- -//000294A0 -void drbox(int iX, int iY, int iWidth, int iHeight, uint8 byColor) -{ +// 000294A0 +void drbox(int iX, int iY, int iWidth, int iHeight, uint8 byColor) { uint8 *pRowStart; // edi - int i; // esi - uint8 *pPixel; // eax - int iPixelCol; // edx + int i; // esi + uint8 *pPixel; // eax + int iPixelCol; // edx // Calculate starting position in screen buffer pRowStart = &scrbuf[iX + winw * (199 - iY)]; @@ -1548,18 +1571,17 @@ void drbox(int iX, int iY, int iWidth, int iHeight, uint8 byColor) } //------------------------------------------------------------------------------------------------- -//00029500 -void box(int iX, int iY, int iWidth, int iHeight, uint8 byBorderColor) -{ - int iWinW; // esi - int iTopRowY; // ebp +// 00029500 +void box(int iX, int iY, int iWidth, int iHeight, uint8 byBorderColor) { + int iWinW; // esi + int iTopRowY; // ebp int iHorizontalPixels; // edi - uint8 *pTopRow; // eax - uint8 *pBottomRow; // edx - int i; // ebx - uint8 *pLeftEdge; // eax - uint8 *pRightEdge; // edx - int j; // ebx + uint8 *pTopRow; // eax + uint8 *pBottomRow; // edx + int i; // ebx + uint8 *pLeftEdge; // eax + uint8 *pRightEdge; // edx + int j; // ebx iWinW = winw; iTopRowY = 199 - iY; @@ -1587,12 +1609,11 @@ void box(int iX, int iY, int iWidth, int iHeight, uint8 byBorderColor) } //------------------------------------------------------------------------------------------------- -//000295F0 -void SetVideoMode(uint8 byVideoMode) -{ - //union REGS regs; // [esp+0h] [ebp-24h] BYREF - //regs.w.ax = byVideoMode; - //int386(0x10, ®s, ®s); +// 000295F0 +void SetVideoMode(uint8 byVideoMode) { + // union REGS regs; // [esp+0h] [ebp-24h] BYREF + // regs.w.ax = byVideoMode; + // int386(0x10, ®s, ®s); } //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/graphics.h b/PROJECTS/ROLLER/graphics.h index 30c0fed0..34106ab3 100644 --- a/PROJECTS/ROLLER/graphics.h +++ b/PROJECTS/ROLLER/graphics.h @@ -22,7 +22,8 @@ extern int NoOfTextures; //------------------------------------------------------------------------------------------------- void plotxyz(float fWorldX, float fWorldY, float fWorldZ, char byColor); -void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, float fY2, float fZ2, uint8 byColor); +void linexyz(uint8 *pScrBuf, float fX1, float fY1, float fZ1, float fX2, + float fY2, float fZ2, uint8 byColor); void compout(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor); void line(uint8 *pScrBuf, int iX0, int iY0, int iX1, int iY1, uint8 byColor); void LoadPanel(); @@ -31,7 +32,8 @@ void LoadGenericCarTextures(); void LoadCarTexture(int iCartexIdx, uint8 byTexSlotIdx); void LoadBldTextures(); void LoadTextures(); -void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, int iIsLowRes); +void init_remap(uint8 *pTextureBaseAddr, int iRemapType, int iNumBlocks, + int iIsLowRes); void sort_small_texture(uint8 *pDest, uint8 *pSrc, int iNumBlocks); void sort_texture(uint8 *pTexData, int iNumTextures); void sort_mini_texture(uint8 *pTexData, int iNumTextures); diff --git a/PROJECTS/ROLLER/horizon.c b/PROJECTS/ROLLER/horizon.c index d8fc2050..6a4447a6 100644 --- a/PROJECTS/ROLLER/horizon.c +++ b/PROJECTS/ROLLER/horizon.c @@ -13,70 +13,74 @@ #include //------------------------------------------------------------------------------------------------- -tCloudData cloud[40]; //00199950 -int test_y1; //0019A3F4 -char upside_down; //0019A410 -char ground_left; //0019A411 +tCloudData cloud[40]; // 00199950 +int test_y1; // 0019A3F4 +char upside_down; // 0019A410 +char ground_left; // 0019A411 //------------------------------------------------------------------------------------------------- -//0006AB90 -void DrawHorizon(uint8 *pScrBuf) -{ - uint8 *pScrPtr; // ecx - uint8 byFillColor; // dl +// 0006AB90 +void DrawHorizon(uint8 *pScrBuf) { + uint8 *pScrPtr; // ecx + uint8 byFillColor; // dl int iWorldTiltMasked; // eax - double dViewDistTan; // st7 - double dHorizonX; // st6 - double dHorizonY; // st7 - int iGroundHeight1; // esi - int iGroundHeight2; // edi - int iSkyHeight1; // eax - int iSkyHeight2; // eax - int iGroundHeight3; // eax - //int iLoopEnd; // edi - //int iLoopCounter; // esi - //double dSlope; // st7 - //double dPrevScanValue; // st6 - int iRowCounter; // edi - int iScanIdx; // ebp - double dScanValue; // st7 - double dNegGroundWidth; // st7 - double dInvScale; // st6 + double dViewDistTan; // st7 + double dHorizonX; // st6 + double dHorizonY; // st7 + int iGroundHeight1; // esi + int iGroundHeight2; // edi + int iSkyHeight1; // eax + int iSkyHeight2; // eax + int iGroundHeight3; // eax + // int iLoopEnd; // edi + // int iLoopCounter; // esi + // double dSlope; // st7 + // double dPrevScanValue; // st6 + int iRowCounter; // edi + int iScanIdx; // ebp + double dScanValue; // st7 + double dNegGroundWidth; // st7 + double dInvScale; // st6 signed int iGroundWidthCopy; // esi - int iSkyWidth; // esi - uint8 *pScrPtrRight; // ecx - int iRowCounter2; // edi - int iScanIdx2; // esi - double dScanValue2; // st7 - int iGroundWidthTemp; // ebp - double dExcessWidth; // st7 - double dInvScale2; // st6 - double dModfResult1; // [esp+14h] [ebp-70h] BYREF - double dModfResult2; // [esp+1Ch] [ebp-68h] BYREF - double fSinElevation; // [esp+24h] [ebp-60h] - float fTempCalc; // [esp+2Ch] [ebp-58h] - int iYBase; // [esp+38h] [ebp-4Ch] - signed int iGroundWidth; // [esp+3Ch] [ebp-48h] - int iHorizonX; // [esp+40h] [ebp-44h] - uint8 *pScrBuf_1; // [esp+44h] [ebp-40h] - int iHorizonY; // [esp+48h] [ebp-3Ch] - float fSlope; // [esp+4Ch] [ebp-38h] - float fScale; // [esp+50h] [ebp-34h] - float fCosTilt; // [esp+54h] [ebp-30h] - float fNegSinTilt; // [esp+58h] [ebp-2Ch] - float fScanValue; // [esp+5Ch] [ebp-28h] - signed int iGroundWidth2; // [esp+60h] [ebp-24h] - uint8 bySkyColor; // [esp+64h] [ebp-20h] - uint8 byGroundColor; // [esp+68h] [ebp-1Ch] + int iSkyWidth; // esi + uint8 *pScrPtrRight; // ecx + int iRowCounter2; // edi + int iScanIdx2; // esi + double dScanValue2; // st7 + int iGroundWidthTemp; // ebp + double dExcessWidth; // st7 + double dInvScale2; // st6 + double dModfResult1; // [esp+14h] [ebp-70h] BYREF + double dModfResult2; // [esp+1Ch] [ebp-68h] BYREF + double fSinElevation; // [esp+24h] [ebp-60h] + float fTempCalc; // [esp+2Ch] [ebp-58h] + int iYBase; // [esp+38h] [ebp-4Ch] + signed int iGroundWidth; // [esp+3Ch] [ebp-48h] + int iHorizonX; // [esp+40h] [ebp-44h] + uint8 *pScrBuf_1; // [esp+44h] [ebp-40h] + int iHorizonY; // [esp+48h] [ebp-3Ch] + float fSlope; // [esp+4Ch] [ebp-38h] + float fScale; // [esp+50h] [ebp-34h] + float fCosTilt; // [esp+54h] [ebp-30h] + float fNegSinTilt; // [esp+58h] [ebp-2Ch] + float fScanValue; // [esp+5Ch] [ebp-28h] + signed int iGroundWidth2; // [esp+60h] [ebp-24h] + uint8 bySkyColor; // [esp+64h] [ebp-20h] + uint8 byGroundColor; // [esp+68h] [ebp-1Ch] pScrBuf_1 = pScrBuf; - fSinElevation = tsin[worldelev & 0x3FFF]; // Calculate sine of world elevation (masked to 14 bits for lookup table) + fSinElevation = + tsin[worldelev & 0x3FFF]; // Calculate sine of world elevation (masked to + // 14 bits for lookup table) pScrPtr = pScrBuf; bySkyColor = 0x91; byGroundColor = HorizonColour[front_sec]; // 0x10 = TEX_OFF_HORIZON - if (fSinElevation > 0.7 || fSinElevation < -0.7 || (textures_off & TEX_OFF_HORIZON) != 0)// Check for simple fill cases: steep angle or horizon textures disabled + if (fSinElevation > 0.7 || fSinElevation < -0.7 || + (textures_off & TEX_OFF_HORIZON) != + 0) // Check for simple fill cases: steep angle or horizon textures + // disabled { if (tsin[worldelev & 0x3FFF] <= 0.7) byFillColor = byGroundColor; @@ -84,16 +88,25 @@ void DrawHorizon(uint8 *pScrBuf) byFillColor = bySkyColor; if ((textures_off & TEX_OFF_HORIZON) != 0) byFillColor = bySkyColor; - memset(pScrBuf, byFillColor, winh * winw); // Simple case: fill entire screen with single color + memset(pScrBuf, byFillColor, + winh * winw); // Simple case: fill entire screen with single color } else { - iWorldTiltMasked = worldtilt & 0x3FFF; // Complex horizon rendering: calculate tilt trigonometry + iWorldTiltMasked = + worldtilt & + 0x3FFF; // Complex horizon rendering: calculate tilt trigonometry fNegSinTilt = -tsin[iWorldTiltMasked]; fCosTilt = tcos[iWorldTiltMasked]; - upside_down = tcos[worldelev & 0x3FFF] < 0.0 != fCosTilt < 0.0;// Determine if world is upside-down (elevation vs tilt sign comparison) - ground_left = fNegSinTilt < 0.0; // Determine which side has ground based on tilt direction + upside_down = tcos[worldelev & 0x3FFF] < 0.0 != + fCosTilt < 0.0; // Determine if world is upside-down + // (elevation vs tilt sign comparison) + ground_left = + fNegSinTilt < + 0.0; // Determine which side has ground based on tilt direction if (tcos[worldelev & 0x3FFF] < 0.0) ground_left = fNegSinTilt >= 0.0; - dViewDistTan = (double)VIEWDIST * ptan[worldelev & 0x3FFF];// Calculate horizon line position using perspective projection + dViewDistTan = (double)VIEWDIST * + ptan[worldelev & 0x3FFF]; // Calculate horizon line position + // using perspective projection dHorizonX = dViewDistTan * fNegSinTilt + (double)xbase; //_CHP(); iHorizonX = (int)dHorizonX; @@ -101,65 +114,84 @@ void DrawHorizon(uint8 *pScrBuf) dHorizonY = (double)(199 - ybase) + dViewDistTan * fCosTilt; //_CHP(); iHorizonY = (int)dHorizonY; - //if ((LODWORD(fNegSinTilt) & 0x7FFFFFFF) != 0)// Calculate horizon slope (rise/run) with divide-by-zero protection - if (fabs(fNegSinTilt) > FLT_EPSILON)// Calculate horizon slope (rise/run) with divide-by-zero protection + // if ((LODWORD(fNegSinTilt) & 0x7FFFFFFF) != 0)// Calculate horizon slope + // (rise/run) with divide-by-zero protection + if (fabs(fNegSinTilt) > FLT_EPSILON) // Calculate horizon slope (rise/run) + // with divide-by-zero protection fSlope = fCosTilt / fNegSinTilt; else fSlope = 41.0; - if (fSlope <= 40.0 && fSlope >= -40.0) // Check if slope is reasonable for scanline rendering (not too steep) + if (fSlope <= 40.0 && fSlope >= -40.0) // Check if slope is reasonable for + // scanline rendering (not too steep) { - fScale = (float)((double)scr_size * 0.015625); // Scanline rendering case: calculate per-row horizon intersection - if (tcos[worldelev & 0x3FFF] < 0.0) // Handle upside-down case by flipping tilt values + fScale = (float)((double)scr_size * + 0.015625); // Scanline rendering case: calculate per-row + // horizon intersection + if (tcos[worldelev & 0x3FFF] < + 0.0) // Handle upside-down case by flipping tilt values { fCosTilt = -fCosTilt; fNegSinTilt = -fNegSinTilt; - //HIBYTE(fCosTilt) ^= 0x80u; - //HIBYTE(fNegSinTilt) ^= 0x80u; + // HIBYTE(fCosTilt) ^= 0x80u; + // HIBYTE(fNegSinTilt) ^= 0x80u; } - fScanValue = (float)(((double)iHorizonY * fSlope + (double)iHorizonX) * fScale);// Pre-calculate horizon intersection points for each scanline + fScanValue = (float)(((double)iHorizonY * fSlope + (double)iHorizonX) * + fScale); // Pre-calculate horizon intersection points + // for each scanline if (winh > 0) { // Pre-calculate horizon intersection points for each scanline - for (int iScanlineIdx = 0; iScanlineIdx < winh; iScanlineIdx++) - { + for (int iScanlineIdx = 0; iScanlineIdx < winh; iScanlineIdx++) { hor_scan[iScanlineIdx] = fScanValue; - fScanValue -= fSlope; // Move to next scanline position + fScanValue -= fSlope; // Move to next scanline position } - //iLoopEnd = 4 * winh; - //iLoopCounter = 0; - //dSlope = fSlope; - //do { - // dPrevScanValue = fScanValue - dSlope; - // iLoopCounter += 4; - // *(float *)((char *)&GroundPt[499].pointAy[5].fZ + iLoopCounter) = fScanValue;// reference to hor_scan - // fScanValue = (float)dPrevScanValue; - //} while (iLoopCounter < iLoopEnd); + // iLoopEnd = 4 * winh; + // iLoopCounter = 0; + // dSlope = fSlope; + // do { + // dPrevScanValue = fScanValue - dSlope; + // iLoopCounter += 4; + // *(float *)((char *)&GroundPt[499].pointAy[5].fZ + iLoopCounter) = + // fScanValue;// reference to hor_scan fScanValue = + // (float)dPrevScanValue; + // } while (iLoopCounter < iLoopEnd); } - if (ground_left) // Branch: ground on left side of screen + if (ground_left) // Branch: ground on left side of screen { iRowCounter = 0; if (winh > 0) { iScanIdx = 0; do { - dScanValue = hor_scan[iScanIdx]; // Get horizon intersection point for current scanline from pre-calculated array + dScanValue = hor_scan[iScanIdx]; // Get horizon intersection point + // for current scanline from + // pre-calculated array //_CHP(); iGroundWidth = (int)dScanValue; - if ((int)dScanValue <= winw) // Check if horizon intersection is within screen bounds - { // Horizon intersection is on-screen: render ground portion + if ((int)dScanValue <= + winw) // Check if horizon intersection is within screen bounds + { // Horizon intersection is on-screen: render ground portion if ((int)dScanValue >= 0) { iGroundWidthCopy = iGroundWidth; - memset(pScrPtr, byGroundColor, iGroundWidth);// Fill ground pixels from left edge to horizon intersection + memset(pScrPtr, byGroundColor, + iGroundWidth); // Fill ground pixels from left edge to + // horizon intersection pScrPtr += iGroundWidthCopy; } else { - dNegGroundWidth = (double)iGroundWidth;// Horizon intersection is off-screen left: calculate texture coordinates + dNegGroundWidth = + (double)iGroundWidth; // Horizon intersection is off-screen + // left: calculate texture coordinates dInvScale = 1.0 / fScale; fTempCalc = (float)(-fCosTilt * dNegGroundWidth * dInvScale); - modf(dNegGroundWidth * fNegSinTilt * dInvScale, &dModfResult1);// modf() splits floating point into integer and fractional parts + modf(dNegGroundWidth * fNegSinTilt * dInvScale, + &dModfResult1); // modf() splits floating point into + // integer and fractional parts modf(fTempCalc, &dModfResult2); iGroundWidth = 0; } iSkyWidth = winw - iGroundWidth; if (winw - iGroundWidth >= 0) { - memset(pScrPtr, bySkyColor, winw - iGroundWidth);// Fill sky pixels from horizon intersection to right edge + memset(pScrPtr, bySkyColor, + winw - iGroundWidth); // Fill sky pixels from horizon + // intersection to right edge pScrPtr += iSkyWidth; } } else { @@ -171,7 +203,8 @@ void DrawHorizon(uint8 *pScrBuf) } while (iRowCounter < winh); } } else { - pScrPtrRight = &pScrPtr[winw - 1]; // Branch: ground on right side of screen (render right-to-left) + pScrPtrRight = &pScrPtr[winw - 1]; // Branch: ground on right side of + // screen (render right-to-left) iRowCounter2 = 0; if (winh > 0) { iScanIdx2 = 0; @@ -180,13 +213,19 @@ void DrawHorizon(uint8 *pScrBuf) //_CHP(); iGroundWidth2 = (int)dScanValue2; iGroundWidthTemp = (int)dScanValue2; - if ((int)dScanValue2 >= 0) // Right-side rendering: check horizon intersection bounds + if ((int)dScanValue2 >= + 0) // Right-side rendering: check horizon intersection bounds { if (iGroundWidthTemp <= winw) { pScrPtrRight -= winw - iGroundWidthTemp; - memset(pScrPtrRight + 1, byGroundColor, winw - iGroundWidthTemp);// Fill ground pixels from intersection to right edge (right-to-left) + memset(pScrPtrRight + 1, byGroundColor, + winw - iGroundWidthTemp); // Fill ground pixels from + // intersection to right edge + // (right-to-left) } else { - iYBase = iGroundWidthTemp - (winw - 1);// Horizon extends beyond screen right: calculate excess width + iYBase = iGroundWidthTemp - + (winw - 1); // Horizon extends beyond screen right: + // calculate excess width dExcessWidth = (double)iYBase; dInvScale2 = 1.0 / fScale; fTempCalc = (float)(-fCosTilt * dExcessWidth * dInvScale2); @@ -196,7 +235,9 @@ void DrawHorizon(uint8 *pScrBuf) } if (iGroundWidth2 >= 0) { pScrPtrRight -= iGroundWidth2; - memset(pScrPtrRight + 1, bySkyColor, iGroundWidth2);// Fill sky pixels from left edge to intersection (right-to-left) + memset(pScrPtrRight + 1, bySkyColor, + iGroundWidth2); // Fill sky pixels from left edge to + // intersection (right-to-left) } pScrPtrRight += 2 * winw; } else { @@ -208,10 +249,13 @@ void DrawHorizon(uint8 *pScrBuf) } while (iRowCounter2 < winh); } } - } else { // Steep slope case: fill screen in large blocks rather than scanlines + } else { // Steep slope case: fill screen in large blocks rather than + // scanlines if (upside_down) { iGroundHeight1 = (iHorizonY * scr_size + 32) / 64; - //iGroundHeight1 = (iHorizonY * scr_size + 32 - (__CFSHL__((iHorizonY * scr_size + 32) >> 31, 6) + ((iHorizonY * scr_size + 32) >> 31 << 6))) >> 6; + // iGroundHeight1 = (iHorizonY * scr_size + 32 - (__CFSHL__((iHorizonY * + // scr_size + 32) >> 31, 6) + ((iHorizonY * scr_size + 32) >> 31 << 6))) + // >> 6; if (iGroundHeight1 > winh) iGroundHeight1 = winh; if (iGroundHeight1 > 0) { @@ -220,7 +264,8 @@ void DrawHorizon(uint8 *pScrBuf) } } else { iGroundHeight1 = (iHorizonY * scr_size) / 64; - //iGroundHeight1 = (iHorizonY * scr_size - (__CFSHL__((iHorizonY * scr_size) >> 31, 6) + ((iHorizonY * scr_size) >> 31 << 6))) >> 6; + // iGroundHeight1 = (iHorizonY * scr_size - (__CFSHL__((iHorizonY * + // scr_size) >> 31, 6) + ((iHorizonY * scr_size) >> 31 << 6))) >> 6; iGroundHeight2 = iGroundHeight1; if (iGroundHeight1 > winh) iGroundHeight1 = winh; @@ -233,7 +278,9 @@ void DrawHorizon(uint8 *pScrBuf) } if (upside_down) { iSkyHeight1 = (iHorizonY * scr_size + 32) / 64; - //iSkyHeight1 = (iHorizonY * scr_size + 32 - (__CFSHL__((iHorizonY * scr_size + 32) >> 31, 6) + ((iHorizonY * scr_size + 32) >> 31 << 6))) >> 6; + // iSkyHeight1 = (iHorizonY * scr_size + 32 - (__CFSHL__((iHorizonY * + // scr_size + 32) >> 31, 6) + ((iHorizonY * scr_size + 32) >> 31 << 6))) + // >> 6; if (iSkyHeight1 > winh) iSkyHeight1 = winh; iSkyHeight2 = winh - iSkyHeight1; @@ -251,90 +298,102 @@ void DrawHorizon(uint8 *pScrBuf) } } // 0x8 = TEX_OFF_CLOUDS - if ((textures_off & TEX_OFF_CLOUDS) == 0) // Render clouds on top of horizon if cloud textures enabled + if ((textures_off & TEX_OFF_CLOUDS) == + 0) // Render clouds on top of horizon if cloud textures enabled displayclouds(pScrBuf_1); } //------------------------------------------------------------------------------------------------- -//0006B1A0 -void initclouds() -{ // Loop through all 40 cloud slots - int iCloudIdx; // edi - //int iRandVal1; // eax - //uint32 uiAngle1Calc; // eax +// 0006B1A0 +void initclouds() { // Loop through all 40 cloud slots + int iCloudIdx; // edi + // int iRandVal1; // eax + // uint32 uiAngle1Calc; // eax int iAngle1; // ebp - //int iRandVal2; // eax - int iAngle2; // esi + // int iRandVal2; // eax + int iAngle2; // esi double dRadiusRotComp1; // st6 double dRadiusRotComp2; // st5 - double dBaseCalcX; // st4 - double dBaseCalcY; // st6 - int iValidPlacement; // ecx - double dMatrix12; // st6 - double dMatrix20Temp; // st3 - double dMatrix21Temp; // st2 - double dMatrix22Temp; // rt1 - int iRandColorBase; // eax - int iColorIndex; // eax - int iCheckIdx; // edx - double fDeltaX; // st7 - double fDeltaY; // st6 - double fXYDistSq; // st7 - double fDeltaZ; // st6 - float fCos1Cos2; // [esp+8h] [ebp-80h] - float fTransX2; // [esp+Ch] [ebp-7Ch] - float fSin1Cos2; // [esp+10h] [ebp-78h] - float fTransX1; // [esp+14h] [ebp-74h] - float fTransY2; // [esp+18h] [ebp-70h] - float fTransZ1; // [esp+1Ch] [ebp-6Ch] - float fTransY1; // [esp+20h] [ebp-68h] - float fMatrix11; // [esp+24h] [ebp-64h] - float fMatrix02; // [esp+28h] [ebp-60h] - float fMatrix10; // [esp+2Ch] [ebp-5Ch] - float fMatrix00; // [esp+30h] [ebp-58h] - float fMatrix01; // [esp+34h] [ebp-54h] - float fRadiusComp; // [esp+38h] [ebp-50h] - float fSin2; // [esp+3Ch] [ebp-4Ch] - float fBaseY; // [esp+40h] [ebp-48h] - float fBaseX; // [esp+44h] [ebp-44h] - float fRotComp2; // [esp+48h] [ebp-40h] - float fRotComp1; // [esp+4Ch] [ebp-3Ch] - float fBaseZ; // [esp+50h] [ebp-38h] - float fCos2; // [esp+54h] [ebp-34h] - float fNegSin1; // [esp+58h] [ebp-30h] - float fCos1; // [esp+5Ch] [ebp-2Ch] - float fNegRadius; // [esp+60h] [ebp-28h] - float fRadius; // [esp+64h] [ebp-24h] - float fMinDistance; // [esp+68h] [ebp-20h] - float fDistance; // [esp+6Ch] [ebp-1Ch] + double dBaseCalcX; // st4 + double dBaseCalcY; // st6 + int iValidPlacement; // ecx + double dMatrix12; // st6 + double dMatrix20Temp; // st3 + double dMatrix21Temp; // st2 + double dMatrix22Temp; // rt1 + int iRandColorBase; // eax + int iColorIndex; // eax + int iCheckIdx; // edx + double fDeltaX; // st7 + double fDeltaY; // st6 + double fXYDistSq; // st7 + double fDeltaZ; // st6 + float fCos1Cos2; // [esp+8h] [ebp-80h] + float fTransX2; // [esp+Ch] [ebp-7Ch] + float fSin1Cos2; // [esp+10h] [ebp-78h] + float fTransX1; // [esp+14h] [ebp-74h] + float fTransY2; // [esp+18h] [ebp-70h] + float fTransZ1; // [esp+1Ch] [ebp-6Ch] + float fTransY1; // [esp+20h] [ebp-68h] + float fMatrix11; // [esp+24h] [ebp-64h] + float fMatrix02; // [esp+28h] [ebp-60h] + float fMatrix10; // [esp+2Ch] [ebp-5Ch] + float fMatrix00; // [esp+30h] [ebp-58h] + float fMatrix01; // [esp+34h] [ebp-54h] + float fRadiusComp; // [esp+38h] [ebp-50h] + float fSin2; // [esp+3Ch] [ebp-4Ch] + float fBaseY; // [esp+40h] [ebp-48h] + float fBaseX; // [esp+44h] [ebp-44h] + float fRotComp2; // [esp+48h] [ebp-40h] + float fRotComp1; // [esp+4Ch] [ebp-3Ch] + float fBaseZ; // [esp+50h] [ebp-38h] + float fCos2; // [esp+54h] [ebp-34h] + float fNegSin1; // [esp+58h] [ebp-30h] + float fCos1; // [esp+5Ch] [ebp-2Ch] + float fNegRadius; // [esp+60h] [ebp-28h] + float fRadius; // [esp+64h] [ebp-24h] + float fMinDistance; // [esp+68h] [ebp-20h] + float fDistance; // [esp+6Ch] [ebp-1Ch] for (iCloudIdx = 0; iCloudIdx < 40; ++iCloudIdx) { - fRadius = 1800000.0; // Start with maximum radius for placement attempt + fRadius = 1800000.0; // Start with maximum radius for placement attempt do { - //iRandVal1 = ROLLERrandRaw(); // Generate random angle1 (theta) for spherical coordinates - //uiAngle1Calc = (uint32)3400 * (uint32)GetHighOrderRand(iRandVal1, iRandVal1); + // iRandVal1 = ROLLERrandRaw(); // Generate random + // angle1 (theta) for spherical coordinates uiAngle1Calc = (uint32)3400 * + // (uint32)GetHighOrderRand(iRandVal1, iRandVal1); ////iAngle1Calc = 3400 * (((iRandVal1 * iRandVal1) & 0x7FFF) >> 15); - ////iAngle1Calc = 3400 * ((iRandVal1 * iRandVal1 - (__CFSHL__((iRandVal1 * iRandVal1) >> 31, 15) + ((iRandVal1 * iRandVal1) >> 31 << 15))) >> 15); - //iAngle1 = ((uiAngle1Calc & 0x8000) >> 15) + 520; // Will be either 520 or 521 - ////iAngle1 = ((iAngle1Calc - (__CFSHL__(iAngle1Calc >> 31, 15) + (iAngle1Calc >> 31 << 15))) >> 15) + 520; - //iRandVal2 = ROLLERrandRaw(); // Generate random angle2 (phi) for spherical coordinates + ////iAngle1Calc = 3400 * ((iRandVal1 * iRandVal1 - (__CFSHL__((iRandVal1 * + /// iRandVal1) >> 31, 15) + ((iRandVal1 * iRandVal1) >> 31 << 15))) >> + /// 15); + // iAngle1 = ((uiAngle1Calc & 0x8000) >> 15) + 520; // Will be either 520 + // or 521 + ////iAngle1 = ((iAngle1Calc - (__CFSHL__(iAngle1Calc >> 31, 15) + + ///(iAngle1Calc >> 31 << 15))) >> 15) + 520; + // iRandVal2 = ROLLERrandRaw(); // Generate random + // angle2 (phi) for spherical coordinates // ////TODO look at this - //iAngle2 = GetHighOrderRand(2, iRandVal2); // Will be 0 or 1 - ////iAngle2 = ((iRandVal2 << 14) - (__CFSHL__(iRandVal2 << 14 >> 31, 15) + (iRandVal2 << 14 >> 31 << 15))) >> 15; - + // iAngle2 = GetHighOrderRand(2, iRandVal2); // Will be 0 or 1 + ////iAngle2 = ((iRandVal2 << 14) - (__CFSHL__(iRandVal2 << 14 >> 31, 15) + + ///(iRandVal2 << 14 >> 31 << 15))) >> 15; + iAngle1 = (ROLLERrandRaw() & 0x0FFF) + 0x200; iAngle2 = ROLLERrandRaw() & 0x3FFF; - - fCos1Cos2 = tcos[iAngle2] * tcos[iAngle1];// Calculate rotation matrix elements using trigonometric tables + + fCos1Cos2 = + tcos[iAngle2] * tcos[iAngle1]; // Calculate rotation matrix elements + // using trigonometric tables fSin1Cos2 = tsin[iAngle2] * tcos[iAngle1]; fNegSin1 = -tsin[iAngle2]; fSin2 = tsin[iAngle1]; fCos1 = tcos[iAngle2]; - fRotComp1 = -fCos1 * fSin2; // Calculate rotation matrix components: -cos(phi)*sin(theta) and -sin(phi)*sin(theta) + fRotComp1 = + -fCos1 * fSin2; // Calculate rotation matrix components: + // -cos(phi)*sin(theta) and -sin(phi)*sin(theta) fRotComp2 = fNegSin1 * fSin2; - fNegRadius = -fRadius; // Negative radius for translation calculations - fBaseX = 10000000.0f * fCos1Cos2; // Calculate 3x4 transformation matrix for cloud positioning + fNegRadius = -fRadius; // Negative radius for translation calculations + fBaseX = 10000000.0f * fCos1Cos2; // Calculate 3x4 transformation matrix + // for cloud positioning fTransX1 = fNegRadius * fNegSin1; fMatrix00 = fBaseX + fTransX1; dRadiusRotComp1 = fRadius * fRotComp1; @@ -370,138 +429,160 @@ void initclouds() cloud[iCloudIdx].matrix[3][0] = (float)dMatrix20Temp + fMatrix00; cloud[iCloudIdx].matrix[3][1] = (float)dMatrix21Temp + fMatrix01; cloud[iCloudIdx].matrix[3][2] = (float)dMatrix22Temp + fMatrix02; - cloud[iCloudIdx].world.fX = fRotComp1 * 0.0f + 0.0f * fNegSin1 + fBaseX;// World X coordinate: final cloud position after transformation - cloud[iCloudIdx].world.fY = 0.0f * fCos1 + fBaseY + 0.0f * fRotComp2;// World Y coordinate: final cloud position after transformation - cloud[iCloudIdx].world.fZ = fBaseZ + 0.0f * fCos2;// World Z coordinate: final cloud position after transformation - iRandColorBase = ROLLERrandRaw(); // Generate random cloud color/texture index + cloud[iCloudIdx].world.fX = fRotComp1 * 0.0f + 0.0f * fNegSin1 + + fBaseX; // World X coordinate: final cloud + // position after transformation + cloud[iCloudIdx].world.fY = + 0.0f * fCos1 + fBaseY + + 0.0f * fRotComp2; // World Y coordinate: final cloud position after + // transformation + cloud[iCloudIdx].world.fZ = + fBaseZ + 0.0f * fCos2; // World Z coordinate: final cloud position + // after transformation + iRandColorBase = + ROLLERrandRaw(); // Generate random cloud color/texture index iColorIndex = GetHighOrderRand(5, iRandColorBase); - //iColorIndex = (5 * iRandColorBase - (__CFSHL__((5 * iRandColorBase) >> 31, 15) + ((5 * iRandColorBase) >> 31 << 15))) >> 15; + // iColorIndex = (5 * iRandColorBase - (__CFSHL__((5 * iRandColorBase) >> + // 31, 15) + ((5 * iRandColorBase) >> 31 << 15))) >> 15; cloud[iCloudIdx].iSurfaceType = iColorIndex; cloud[iCloudIdx].iSurfaceType = iColorIndex + 0x508; - if (ROLLERrand() < 0x4000) // Randomly modify color properties (50% chance each) + if (ROLLERrand() < + 0x4000) // Randomly modify color properties (50% chance each) cloud[iCloudIdx].iSurfaceType += 0x1000; if (ROLLERrand() < 0x4000) - SET_HIWORD(cloud[iCloudIdx].iSurfaceType, 4 + GET_HIWORD(cloud[iCloudIdx].iSurfaceType)); - //HIWORD(cloud[iCloudIdx].iSurfaceType) += 4; - cloud[iCloudIdx].fRadius = fRadius; // Store cloud radius - if (iCloudIdx > 0) { // Check collision with previously placed clouds + SET_HIWORD(cloud[iCloudIdx].iSurfaceType, + 4 + GET_HIWORD(cloud[iCloudIdx].iSurfaceType)); + // HIWORD(cloud[iCloudIdx].iSurfaceType) += 4; + cloud[iCloudIdx].fRadius = fRadius; // Store cloud radius + if (iCloudIdx > 0) { // Check collision with previously placed clouds for (iCheckIdx = 0; iCheckIdx < iCloudIdx; ++iCheckIdx) { if (iValidPlacement) { fDeltaX = cloud[iCheckIdx].world.fX - cloud[iCloudIdx].world.fX; fDeltaY = cloud[iCheckIdx].world.fY - cloud[iCloudIdx].world.fY; fXYDistSq = fDeltaX * fDeltaX + fDeltaY * fDeltaY; fDeltaZ = cloud[iCheckIdx].world.fZ - cloud[iCloudIdx].world.fZ; - fDistance = (float)sqrt(fXYDistSq + fDeltaZ * fDeltaZ);// Calculate 3D distance between cloud centers + fDistance = (float)sqrt( + fXYDistSq + + fDeltaZ * + fDeltaZ); // Calculate 3D distance between cloud centers } fMinDistance = fRadius + cloud[iCloudIdx].fRadius; - //TODO - if (fDistance < fMinDistance * 1.3f) // Check if clouds overlap (distance < combined radii * 1.3) + // TODO + if (fDistance < + fMinDistance * 1.3f) // Check if clouds overlap (distance < + // combined radii * 1.3) iValidPlacement = 0; } } if (!iValidPlacement) - fRadius = fRadius + -2000.0f; // Reduce radius and retry if collision detected - if (fRadius < 1000000.0f) // Minimum radius constraint + fRadius = + fRadius + -2000.0f; // Reduce radius and retry if collision detected + if (fRadius < 1000000.0f) // Minimum radius constraint fRadius = 1000000.0f; } while (!iValidPlacement); } } //------------------------------------------------------------------------------------------------- -//0006B530 -void displayclouds(uint8 *pScrBuf) -{ - int iCloudIdx; // esi - double dCorner0X; // st7 - double dCorner0Y; // st6 - double dCorner0Z; // st5 +// 0006B530 +void displayclouds(uint8 *pScrBuf) { + int iCloudIdx; // esi + double dCorner0X; // st7 + double dCorner0Y; // st6 + double dCorner0Z; // st5 double dCorner0ViewZ; // st7 - int iBehindCamera; // edx - double dViewDist; // st7 - double dInvZ0; // st6 - double dProjX0; // st5 - double dProjY0; // st7 - int iScrSizeTemp; // ecx - //int iXpTemp; // eax - double dScreenX0; // st7 - double dScreenY0; // st7 - double dCorner1X; // st7 - double dCorner1Y; // st6 - double dCorner1Z; // st5 + int iBehindCamera; // edx + double dViewDist; // st7 + double dInvZ0; // st6 + double dProjX0; // st5 + double dProjY0; // st7 + int iScrSizeTemp; // ecx + // int iXpTemp; // eax + double dScreenX0; // st7 + double dScreenY0; // st7 + double dCorner1X; // st7 + double dCorner1Y; // st6 + double dCorner1Z; // st5 double dCorner1ViewZ; // st7 - double dViewDist1; // st7 - double dInvZ1; // st6 - double dProjX1; // st5 - double dProjY1; // st7 - int iScrSize1; // ebx - //int iXpTemp1; // eax - double dScreenX1; // st7 - double dScreenY1; // st7 - double dCorner2X; // st7 - double dCorner2Y; // st6 - double dCorner2Z; // st5 + double dViewDist1; // st7 + double dInvZ1; // st6 + double dProjX1; // st5 + double dProjY1; // st7 + int iScrSize1; // ebx + // int iXpTemp1; // eax + double dScreenX1; // st7 + double dScreenY1; // st7 + double dCorner2X; // st7 + double dCorner2Y; // st6 + double dCorner2Z; // st5 double dCorner2ViewZ; // st7 - double dViewDist2; // st7 - double dInvZ2; // st6 - double dProjX2; // st5 - double dProjY2; // st7 - int iScrSize2; // ebx - //int iXpTemp2; // eax - double dScreenX2; // st7 - double dScreenY2; // st7 - double dCorner3X; // st7 - double dCorner3Y; // st6 - double dCorner3Z; // st5 + double dViewDist2; // st7 + double dInvZ2; // st6 + double dProjX2; // st5 + double dProjY2; // st7 + int iScrSize2; // ebx + // int iXpTemp2; // eax + double dScreenX2; // st7 + double dScreenY2; // st7 + double dCorner3X; // st7 + double dCorner3Y; // st6 + double dCorner3Z; // st5 double dCorner3ViewZ; // st7 - double dViewDist3; // st7 - double dInvZ3; // st6 - double dProjX3; // st5 - double dProjY3; // st7 - int iScrSize3; // ebx - //int iXpTemp3; // eax + double dViewDist3; // st7 + double dInvZ3; // st6 + double dProjX3; // st5 + double dProjY3; // st7 + int iScrSize3; // ebx + // int iXpTemp3; // eax double dScreenX3; // st7 double dScreenY3; // st7 tPolyParams poly; // [esp+0h] [ebp-A8h] BYREF - int iYCalcTemp; // [esp+38h] [ebp-70h] - float fViewX0; // [esp+3Ch] [ebp-6Ch] - float fViewY0; // [esp+40h] [ebp-68h] - float fViewY1; // [esp+44h] [ebp-64h] - float fViewX3; // [esp+48h] [ebp-60h] - float fViewX2; // [esp+4Ch] [ebp-5Ch] - float fViewY3; // [esp+50h] [ebp-58h] - float fViewY2; // [esp+54h] [ebp-54h] - float fViewX1; // [esp+58h] [ebp-50h] - float fScreenX0; // [esp+5Ch] [ebp-4Ch] - float fViewZ0; // [esp+60h] [ebp-48h] - float fScreenY0; // [esp+64h] [ebp-44h] - float fScreenX2; // [esp+68h] [ebp-40h] - float fScreenX1; // [esp+6Ch] [ebp-3Ch] - float fViewZ3; // [esp+70h] [ebp-38h] - float fViewZ2; // [esp+74h] [ebp-34h] - float fViewZ1; // [esp+78h] [ebp-30h] - float fScreenX3; // [esp+7Ch] [ebp-2Ch] - float fScreenY1; // [esp+80h] [ebp-28h] - float fScreenY3; // [esp+84h] [ebp-24h] - float fScreenY2; // [esp+88h] [ebp-20h] - //int iScreenXTemp; // [esp+8Ch] [ebp-1Ch] + int iYCalcTemp; // [esp+38h] [ebp-70h] + float fViewX0; // [esp+3Ch] [ebp-6Ch] + float fViewY0; // [esp+40h] [ebp-68h] + float fViewY1; // [esp+44h] [ebp-64h] + float fViewX3; // [esp+48h] [ebp-60h] + float fViewX2; // [esp+4Ch] [ebp-5Ch] + float fViewY3; // [esp+50h] [ebp-58h] + float fViewY2; // [esp+54h] [ebp-54h] + float fViewX1; // [esp+58h] [ebp-50h] + float fScreenX0; // [esp+5Ch] [ebp-4Ch] + float fViewZ0; // [esp+60h] [ebp-48h] + float fScreenY0; // [esp+64h] [ebp-44h] + float fScreenX2; // [esp+68h] [ebp-40h] + float fScreenX1; // [esp+6Ch] [ebp-3Ch] + float fViewZ3; // [esp+70h] [ebp-38h] + float fViewZ2; // [esp+74h] [ebp-34h] + float fViewZ1; // [esp+78h] [ebp-30h] + float fScreenX3; // [esp+7Ch] [ebp-2Ch] + float fScreenY1; // [esp+80h] [ebp-28h] + float fScreenY3; // [esp+84h] [ebp-24h] + float fScreenY2; // [esp+88h] [ebp-20h] + // int iScreenXTemp; // [esp+8Ch] [ebp-1Ch] - set_starts(0); // Initialize polygon renderer - if ((textures_off & 8) == 0) // Skip cloud rendering if textures disabled (bit 3 of textures_off) - { // Loop through all 40 cloud objects + set_starts(0); // Initialize polygon renderer + if ((textures_off & 8) == + 0) // Skip cloud rendering if textures disabled (bit 3 of textures_off) + { // Loop through all 40 cloud objects for (iCloudIdx = 0; iCloudIdx != 40; ++iCloudIdx) { - dCorner0X = cloud[iCloudIdx].matrix[0][0] - viewx;// Transform cloud corner 0 from world space to camera space + dCorner0X = + cloud[iCloudIdx].matrix[0][0] - + viewx; // Transform cloud corner 0 from world space to camera space dCorner0Y = cloud[iCloudIdx].matrix[0][1] - viewy; dCorner0Z = cloud[iCloudIdx].matrix[0][2] * 0.5 - viewz; - fViewX0 = (float)(dCorner0X * vk1 + dCorner0Y * vk4 + dCorner0Z * vk7);// Apply view matrix transformation to get view coordinates + fViewX0 = (float)(dCorner0X * vk1 + dCorner0Y * vk4 + + dCorner0Z * vk7); // Apply view matrix transformation to + // get view coordinates fViewY0 = (float)(dCorner0X * vk2 + dCorner0Y * vk5 + dCorner0Z * vk8); dCorner0ViewZ = dCorner0X * vk3 + dCorner0Y * vk6 + dCorner0Z * vk9; fViewZ0 = (float)dCorner0ViewZ; - iBehindCamera = 0; // Check for near clipping (minimum Z distance = 80.0) + iBehindCamera = 0; // Check for near clipping (minimum Z distance = 80.0) if (dCorner0ViewZ < 80.0) { iBehindCamera = 1; fViewZ0 = 80.0; } - dViewDist = (double)VIEWDIST; // Project 3D coordinates to 2D screen coordinates using perspective division + dViewDist = (double)VIEWDIST; // Project 3D coordinates to 2D screen + // coordinates using perspective division dInvZ0 = 1.0 / fViewZ0; dProjX0 = dViewDist * fViewX0 * dInvZ0 + (double)xbase; //_CHP(); @@ -510,12 +591,16 @@ void displayclouds(uint8 *pScrBuf) iScrSizeTemp = scr_size; //_CHP(); yp = (int)dProjY0; - fScreenX0 = (float)((long long)iScrSizeTemp * xp >> 6); // Convert to screen space and check clipping bounds (-5000 to +5000) - //long long cast added by ROLLER to avoid integer overflow + fScreenX0 = (float)((long long)iScrSizeTemp * xp >> + 6); // Convert to screen space and check clipping + // bounds (-5000 to +5000) + // long long cast added by ROLLER to avoid integer overflow iYCalcTemp = (int)((long long)iScrSizeTemp * (199 - (int)dProjY0)) >> 6; fScreenY0 = (float)iYCalcTemp; - if (iBehindCamera || fScreenX0 >= -5000.0 && fScreenX0 <= 5000.0 && fScreenY0 >= -5000.0 && fScreenY0 <= 5000.0) { - dScreenX0 = fScreenX0; // Store vertex 0 coordinates in polygon structure + if (iBehindCamera || fScreenX0 >= -5000.0 && fScreenX0 <= 5000.0 && + fScreenY0 >= -5000.0 && fScreenY0 <= 5000.0) { + dScreenX0 = + fScreenX0; // Store vertex 0 coordinates in polygon structure //_CHP(); poly.vertices[0].x = (int)dScreenX0; dScreenY0 = fScreenY0; @@ -525,7 +610,9 @@ void displayclouds(uint8 *pScrBuf) iBehindCamera = 1; } if (!iBehindCamera) { - dCorner1X = cloud[iCloudIdx].matrix[1][0] - viewx;// Transform cloud corner 1 (repeat process for second vertex) + dCorner1X = cloud[iCloudIdx].matrix[1][0] - + viewx; // Transform cloud corner 1 (repeat process for + // second vertex) dCorner1Y = cloud[iCloudIdx].matrix[1][1] - viewy; dCorner1Z = cloud[iCloudIdx].matrix[1][2] * 0.5 - viewz; fViewX1 = (float)(dCorner1X * vk1 + dCorner1Y * vk4 + dCorner1Z * vk7); @@ -545,12 +632,14 @@ void displayclouds(uint8 *pScrBuf) iScrSize1 = scr_size; //_CHP(); yp = (int)dProjY1; - //iScreenXTemp = xp >> 6; + // iScreenXTemp = xp >> 6; fScreenX1 = (float)((long long)iScrSize1 * xp >> 6); iYCalcTemp = ((long long)iScrSize1 * (199 - (int)dProjY1)) >> 6; fScreenY1 = (float)iYCalcTemp; - if (iBehindCamera || fScreenX1 >= -5000.0 && fScreenX1 <= 5000.0 && fScreenY1 >= -5000.0 && fScreenY1 <= 5000.0) { - dScreenX1 = fScreenX1; // Store vertex 1 coordinates in polygon structure + if (iBehindCamera || fScreenX1 >= -5000.0 && fScreenX1 <= 5000.0 && + fScreenY1 >= -5000.0 && fScreenY1 <= 5000.0) { + dScreenX1 = + fScreenX1; // Store vertex 1 coordinates in polygon structure //_CHP(); poly.vertices[1].x = (int)dScreenX1; dScreenY1 = fScreenY1; @@ -560,11 +649,14 @@ void displayclouds(uint8 *pScrBuf) iBehindCamera = 1; } if (!iBehindCamera) { - dCorner2X = cloud[iCloudIdx].matrix[2][0] - viewx;// Transform cloud corner 2 (third vertex of quad) + dCorner2X = cloud[iCloudIdx].matrix[2][0] - + viewx; // Transform cloud corner 2 (third vertex of quad) dCorner2Y = cloud[iCloudIdx].matrix[2][1] - viewy; dCorner2Z = cloud[iCloudIdx].matrix[2][2] * 0.5 - viewz; - fViewX2 = (float)(dCorner2X * vk1 + dCorner2Y * vk4 + dCorner2Z * vk7); - fViewY2 = (float)(dCorner2X * vk2 + dCorner2Y * vk5 + dCorner2Z * vk8); + fViewX2 = + (float)(dCorner2X * vk1 + dCorner2Y * vk4 + dCorner2Z * vk7); + fViewY2 = + (float)(dCorner2X * vk2 + dCorner2Y * vk5 + dCorner2Z * vk8); dCorner2ViewZ = dCorner2X * vk3 + dCorner2Y * vk6 + dCorner2Z * vk9; fViewZ2 = (float)dCorner2ViewZ; if (dCorner2ViewZ < 80.0) { @@ -583,8 +675,11 @@ void displayclouds(uint8 *pScrBuf) fScreenX2 = (float)((long long)iScrSize2 * xp >> 6); iYCalcTemp = ((long long)iScrSize2 * (199 - (int)dProjY2)) >> 6; fScreenY2 = (float)iYCalcTemp; - if (iBehindCamera || fScreenX2 >= -5000.0 && fScreenX2 <= 5000.0 && fScreenY2 >= -5000.0 && fScreenY2 <= 5000.0) { - dScreenX2 = fScreenX2; // Store vertex 2 coordinates in polygon structure + if (iBehindCamera || fScreenX2 >= -5000.0 && fScreenX2 <= 5000.0 && + fScreenY2 >= -5000.0 && + fScreenY2 <= 5000.0) { + dScreenX2 = + fScreenX2; // Store vertex 2 coordinates in polygon structure //_CHP(); poly.vertices[2].x = (int)dScreenX2; dScreenY2 = fScreenY2; @@ -594,11 +689,15 @@ void displayclouds(uint8 *pScrBuf) iBehindCamera = 1; } if (!iBehindCamera) { - dCorner3X = cloud[iCloudIdx].matrix[3][0] - viewx;// Transform cloud corner 3 (final vertex of quad) + dCorner3X = + cloud[iCloudIdx].matrix[3][0] - + viewx; // Transform cloud corner 3 (final vertex of quad) dCorner3Y = cloud[iCloudIdx].matrix[3][1] - viewy; dCorner3Z = cloud[iCloudIdx].matrix[3][2] * 0.5 - viewz; - fViewX3 = (float)(dCorner3X * vk1 + dCorner3Y * vk4 + dCorner3Z * vk7); - fViewY3 = (float)(dCorner3X * vk2 + dCorner3Y * vk5 + dCorner3Z * vk8); + fViewX3 = + (float)(dCorner3X * vk1 + dCorner3Y * vk4 + dCorner3Z * vk7); + fViewY3 = + (float)(dCorner3X * vk2 + dCorner3Y * vk5 + dCorner3Z * vk8); dCorner3ViewZ = dCorner3X * vk3 + dCorner3Y * vk6 + dCorner3Z * vk9; fViewZ3 = (float)dCorner3ViewZ; if (dCorner3ViewZ < 80.0) { @@ -617,8 +716,11 @@ void displayclouds(uint8 *pScrBuf) fScreenX3 = (float)((long long)iScrSize3 * xp >> 6); iYCalcTemp = ((long long)iScrSize3 * (199 - (int)dProjY3)) >> 6; fScreenY3 = (float)iYCalcTemp; - if (iBehindCamera || fScreenX3 >= -5000.0 && fScreenX3 <= 5000.0 && fScreenY3 >= -5000.0 && fScreenY3 <= 5000.0) { - dScreenX3 = fScreenX3; // Store vertex 3 coordinates in polygon structure + if (iBehindCamera || fScreenX3 >= -5000.0 && fScreenX3 <= 5000.0 && + fScreenY3 >= -5000.0 && + fScreenY3 <= 5000.0) { + dScreenX3 = + fScreenX3; // Store vertex 3 coordinates in polygon structure //_CHP(); poly.vertices[3].x = (int)dScreenX3; dScreenY3 = fScreenY3; @@ -637,12 +739,11 @@ void displayclouds(uint8 *pScrBuf) verts[vi].v = 0.0f; } game_render_quad_world_subdivide_type( - g_pGameRenderer, - verts, - game_render_get_texture_handle(g_pGameRenderer, 18), - cloud[iCloudIdx].iSurfaceType, - GAME_RENDER_SUBDIVIDE_TYPE_CLOUD, - 1.0f);// Render textured polygon through world-space renderer + g_pGameRenderer, verts, + game_render_get_texture_handle(g_pGameRenderer, 18), + cloud[iCloudIdx].iSurfaceType, + GAME_RENDER_SUBDIVIDE_TYPE_CLOUD, + 1.0f); // Render textured polygon through world-space renderer } } } diff --git a/PROJECTS/ROLLER/horizon.h b/PROJECTS/ROLLER/horizon.h index 27af6e63..3aebfec4 100644 --- a/PROJECTS/ROLLER/horizon.h +++ b/PROJECTS/ROLLER/horizon.h @@ -4,8 +4,7 @@ #include "types.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float matrix[4][3]; tVec3 world; int iSurfaceType; diff --git a/PROJECTS/ROLLER/loadtrak.c b/PROJECTS/ROLLER/loadtrak.c index 339268b5..e6b19f98 100644 --- a/PROJECTS/ROLLER/loadtrak.c +++ b/PROJECTS/ROLLER/loadtrak.c @@ -17,221 +17,210 @@ #include //------------------------------------------------------------------------------------------------- -tSurface surface[14] = //000A5FA8 -{ - { 50.0, 100, 500.0, 75 }, - { 50.0, 95, 500.0, 65 }, - { 50.0, 90, 500.0, 55 }, - { 50.0, 85, 500.0, 50 }, - { 50.0, 80, 500.0, 45 }, - { 50.0, 75, 500.0, 40 }, - { 50.0, 70, 500.0, 35 }, - { 50.0, 65, 500.0, 30 }, - { 50.0, 60, 500.0, 25 }, - { 50.0, 55, 500.0, 20 }, - { 50.0, 50, 500.0, 15 }, - { 50.0, 40, 500.0, 10 }, - { 30.0, 30, 500.0, 5 }, - { 10.0, 20, 500.0, 0 } +tSurface surface[14] = // 000A5FA8 + {{50.0, 100, 500.0, 75}, {50.0, 95, 500.0, 65}, {50.0, 90, 500.0, 55}, + {50.0, 85, 500.0, 50}, {50.0, 80, 500.0, 45}, {50.0, 75, 500.0, 40}, + {50.0, 70, 500.0, 35}, {50.0, 65, 500.0, 30}, {50.0, 60, 500.0, 25}, + {50.0, 55, 500.0, 20}, {50.0, 50, 500.0, 15}, {50.0, 40, 500.0, 10}, + {30.0, 30, 500.0, 5}, {10.0, 20, 500.0, 0}}; +uint8 TrackSelect = 0; // 000A5F9C +char *delims = " ,\n\t\r"; // 000A6088 +char *names[25] = { + // 000A608C + "TRACK0.TRK", // 0 + "TRACK1.TRK", // 1 + "TRACK2.TRK", // 2 + "TRACK3.TRK", // 3 + "TRACK4.TRK", // 4 + "TRACK5.TRK", // 5 + "TRACK6.TRK", // 6 + "TRACK7.TRK", // 7 + "TRACK8.TRK", // 8 + "TRACK9.TRK", // 9 + "TRACK10.TRK", // 10 + "TRACK11.TRK", // 11 + "TRACK12.TRK", // 12 + "TRACK13.TRK", // 13 + "TRACK14.TRK", // 14 + "TRACK15.TRK", // 15 + "TRACK16.TRK", // 16 + "TRACK17.TRK", // 17 + "TRACK18.TRK", // 18 + "TRACK19.TRK", // 19 + "TRACK20.TRK", // 20 + "TRACK21.TRK", // 21 + "TRACK22.TRK", // 22 + "TRACK23.TRK", // 23 + "TRACK24.TRK" // 24 }; -uint8 TrackSelect = 0; //000A5F9C -char *delims = " ,\n\t\r"; //000A6088 -char *names[25] = { //000A608C - "TRACK0.TRK", // 0 - "TRACK1.TRK", // 1 - "TRACK2.TRK", // 2 - "TRACK3.TRK", // 3 - "TRACK4.TRK", // 4 - "TRACK5.TRK", // 5 - "TRACK6.TRK", // 6 - "TRACK7.TRK", // 7 - "TRACK8.TRK", // 8 - "TRACK9.TRK", // 9 - "TRACK10.TRK", // 10 - "TRACK11.TRK", // 11 - "TRACK12.TRK", // 12 - "TRACK13.TRK", // 13 - "TRACK14.TRK", // 14 - "TRACK15.TRK", // 15 - "TRACK16.TRK", // 16 - "TRACK17.TRK", // 17 - "TRACK18.TRK", // 18 - "TRACK19.TRK", // 19 - "TRACK20.TRK", // 20 - "TRACK21.TRK", // 21 - "TRACK22.TRK", // 22 - "TRACK23.TRK", // 23 - "TRACK24.TRK" // 24 -}; -tTrakView TrakView[MAX_TRACK_CHUNKS]; //0016FF20 -int16 samplespeed[MAX_SAMPLES]; //00170EC0 -int16 samplemax[MAX_SAMPLES]; //001712A8 -float GroundLevel[MAX_TRACK_CHUNKS]; //00171690 -tTrackInfo TrackInfo[MAX_TRACK_CHUNKS]; //00171E60 -int cur_mapsect; //00178044 -float cur_TrackZ; //00178048 -float cur_mapsize; //0017804C -int TRAK_LEN; //00178050 -int16 samplemin[MAX_SAMPLES]; //001764B0 -int cur_laps[6]; //00176898 -uint8 fp_buf[512]; //001768B0 -int actualtrack; //00176AB8 -uint8 *start_f; //00176ABC -int TrackFlags; //00176AC0 -int meof; //00176AC4 -tSubdivide Subdivide[MAX_TRACK_CHUNKS]; //00176AC8 +tTrakView TrakView[MAX_TRACK_CHUNKS]; // 0016FF20 +int16 samplespeed[MAX_SAMPLES]; // 00170EC0 +int16 samplemax[MAX_SAMPLES]; // 001712A8 +float GroundLevel[MAX_TRACK_CHUNKS]; // 00171690 +tTrackInfo TrackInfo[MAX_TRACK_CHUNKS]; // 00171E60 +int cur_mapsect; // 00178044 +float cur_TrackZ; // 00178048 +float cur_mapsize; // 0017804C +int TRAK_LEN; // 00178050 +int16 samplemin[MAX_SAMPLES]; // 001764B0 +int cur_laps[6]; // 00176898 +uint8 fp_buf[512]; // 001768B0 +int actualtrack; // 00176AB8 +uint8 *start_f; // 00176ABC +int TrackFlags; // 00176AC0 +int meof; // 00176AC4 +tSubdivide Subdivide[MAX_TRACK_CHUNKS]; // 00176AC8 //------------------------------------------------------------------------------------------------- -//0004AF80 -void loadtrack(int iTrackIdx, int iPreviewMode) -{ - int iCarIdx; // ecx - tCar *pCar; // edi - FILE *pFile; // edx +// 0004AF80 +void loadtrack(int iTrackIdx, int iPreviewMode) { + int iCarIdx; // ecx + tCar *pCar; // edi + FILE *pFile; // edx int iCompactedFileLength; // edx - //int iFileHandle_1; // edx - unsigned int iFileLength; // ebx - uint8 *pTrackBuffer_1; // eax - uint8 *pTrackBuffer; // eax - FILE *pFile_1; // eax - int iChunkIdx; // edi - int iTrackInfoIdx; // esi - int iTrakColourIdx; // ebp - uint32 *p_uiLUOWallType; // edx - int iSubdivideIdx; // ebx - int iTemp1; // edx - int iTemp2; // eax - double dTemp1; // st7 - int iSubdivLoopIdx; // edx - int iSubdivOffset; // ebx - int iSubdivArrayIdx; // eax - unsigned int v22; // edx - int uiTrakViewOffset1; // ecx - int iBackwardExtraStart; // ecx - unsigned int uiTrakViewOffset2; // edx - int *pTowerBase; // edx - int *v27; // edx - int *p_iData1; // ebx - int *pTowerBase2; // ecx - int *pTowerBase3; // edx - int *p_iBuildingData; // eax - int *p_iBuildingData2; // ebx - float *p_fBuildingAngles; // eax - int v34; // edx - double dAngleCalc1; // st7 - double dLeftAngle; // st6 - double dRightAngle; // st6 - double dAILine1_1; // st7 - unsigned int uiLocalDataOffset1; // eax - unsigned int uiLocalDataOffset2; // edx - double dAIMaxSpeed_1; // st7 + // int iFileHandle_1; // edx + unsigned int iFileLength; // ebx + uint8 *pTrackBuffer_1; // eax + uint8 *pTrackBuffer; // eax + FILE *pFile_1; // eax + int iChunkIdx; // edi + int iTrackInfoIdx; // esi + int iTrakColourIdx; // ebp + uint32 *p_uiLUOWallType; // edx + int iSubdivideIdx; // ebx + int iTemp1; // edx + int iTemp2; // eax + double dTemp1; // st7 + int iSubdivLoopIdx; // edx + int iSubdivOffset; // ebx + int iSubdivArrayIdx; // eax + unsigned int v22; // edx + int uiTrakViewOffset1; // ecx + int iBackwardExtraStart; // ecx + unsigned int uiTrakViewOffset2; // edx + int *pTowerBase; // edx + int *v27; // edx + int *p_iData1; // ebx + int *pTowerBase2; // ecx + int *pTowerBase3; // edx + int *p_iBuildingData; // eax + int *p_iBuildingData2; // ebx + float *p_fBuildingAngles; // eax + int v34; // edx + double dAngleCalc1; // st7 + double dLeftAngle; // st6 + double dRightAngle; // st6 + double dAILine1_1; // st7 + unsigned int uiLocalDataOffset1; // eax + unsigned int uiLocalDataOffset2; // edx + double dAIMaxSpeed_1; // st7 unsigned int uiGroundColourOffset1; // eax - int iOFloorType; // edx - int iLeftSurfaceType; // eax - int iRightSurfaceType; // ecx - int iLeftSurfCheck; // ebx - int iRightSurfCheck; // edx - double dCos; // rt1 - int iDifficulty; // eax - int iTrackLapOffset; // edx - int iLapValue; // ebx - double dTrackZ; // st7 - int16 *p_nAudioBelowTrigger; // [esp+30h] [ebp-25Ch] - double dZ; // [esp+34h] [ebp-258h] BYREF - double dY; // [esp+3Ch] [ebp-250h] BYREF - double dX; // [esp+44h] [ebp-248h] BYREF - double dRoofHeight; // [esp+4Ch] [ebp-240h] BYREF - double dRUOWallHeight; // [esp+54h] [ebp-238h] BYREF - double dRLOWallHeight; // [esp+5Ch] [ebp-230h] BYREF - double dROFloorHeight; // [esp+64h] [ebp-228h] BYREF - double dLOFloorHeight; // [esp+6Ch] [ebp-220h] BYREF - double dLLOWallHeight; // [esp+74h] [ebp-218h] BYREF - double dLUOWallHeight; // [esp+7Ch] [ebp-210h] BYREF - double dRUOWallHOffset; // [esp+84h] [ebp-208h] BYREF - double dRLOWallHOffset; // [esp+8Ch] [ebp-200h] BYREF - double dROFloorHOffset; // [esp+94h] [ebp-1F8h] BYREF - double dLOFloorHOffset; // [esp+9Ch] [ebp-1F0h] BYREF - double dLLOWallHOffset; // [esp+A4h] [ebp-1E8h] BYREF - double dLUOWallHOffset; // [esp+ACh] [ebp-1E0h] BYREF - double dAIMaxSpeed; // [esp+B4h] [ebp-1D8h] BYREF - double dAILine4; // [esp+BCh] [ebp-1D0h] BYREF - double dAILine3; // [esp+C4h] [ebp-1C8h] BYREF - double dAILine2; // [esp+CCh] [ebp-1C0h] BYREF - double dAILine1; // [esp+D4h] [ebp-1B8h] BYREF - double dRoll; // [esp+DCh] [ebp-1B0h] BYREF - double dPitch; // [esp+E4h] [ebp-1A8h] BYREF - double dYaw; // [esp+ECh] [ebp-1A0h] BYREF - double dLength; // [esp+F4h] [ebp-198h] BYREF - double dRightShoulderHeight; // [esp+FCh] [ebp-190h] BYREF - double dLeftShoulderHeight; // [esp+104h] [ebp-188h] BYREF - double dRightShoulderWidth; // [esp+10Ch] [ebp-180h] BYREF - double dRightLaneWidth; // [esp+114h] [ebp-178h] BYREF - double dLeftLaneWidth; // [esp+11Ch] [ebp-170h] BYREF - double dLeftShoulderWidth; // [esp+124h] [ebp-168h] BYREF - double dWallCalc1; // [esp+12Ch] [ebp-160h] BYREF - double dWallCalc2; // [esp+134h] [ebp-158h] BYREF - double dWallCalc3; // [esp+13Ch] [ebp-150h] BYREF - double dTempPitch_3; // [esp+144h] [ebp-148h] - double dTempYaw_1; // [esp+14Ch] [ebp-140h] - double dLeftWallTotalHeight; // [esp+154h] [ebp-138h] - double dTempPitch; // [esp+15Ch] [ebp-130h] - double dTempYaw; // [esp+164h] [ebp-128h] - double dTempPitch_2; // [esp+16Ch] [ebp-120h] - double dTempYaw_2; // [esp+174h] [ebp-118h] - double dTempYaw_3; // [esp+17Ch] [ebp-110h] - double dTempPitch_1; // [esp+184h] [ebp-108h] - double dClampedPitch; // [esp+18Ch] [ebp-100h] - double dClampedYaw; // [esp+194h] [ebp-F8h] - double dTempCalc1; // [esp+19Ch] [ebp-F0h] - double dRadiansPerDegree; // [esp+1A4h] [ebp-E8h] - double dTempCalc2; // [esp+1BCh] [ebp-D0h] - int *p_iOFloorType; // [esp+1C4h] [ebp-C8h] - int *p_iLLOWallType; // [esp+1C8h] [ebp-C4h] - int iLeftShoulderGrip; // [esp+1CCh] [ebp-C0h] BYREF - int iDrawOrderBackward; // [esp+1D0h] [ebp-BCh] BYREF - int iRightShoulderGrip; // [esp+1D4h] [ebp-B8h] BYREF - int *p_iRUOWallType; // [esp+1D8h] [ebp-B4h] - int iDrawOrder3; // [esp+1DCh] [ebp-B0h] BYREF - int *p_iCenterSurfType; // [esp+1E0h] [ebp-ACh] - int iBackwardExtraStart2; // [esp+1E4h] [ebp-A8h] BYREF - int iBackwardExtraChunks; // [esp+1E8h] [ebp-A4h] BYREF - uint8 *pData; // [esp+1ECh] [ebp-A0h] BYREF - int iSignYaw; // [esp+1F0h] [ebp-9Ch] BYREF - int iSignVOffset; // [esp+1F4h] [ebp-98h] BYREF - int iSignHOffset; // [esp+1F8h] [ebp-94h] BYREF - int iSignType; // [esp+1FCh] [ebp-90h] BYREF - int iForwardExtraStart; // [esp+200h] [ebp-8Ch] BYREF - int iTrackIdx_1; // [esp+204h] [ebp-88h] - uint8 *pCurrDataPtr = NULL; // [esp+208h] [ebp-84h] BYREF - int iSignRoll; // [esp+20Ch] [ebp-80h] BYREF - int iSignPitch; // [esp+210h] [ebp-7Ch] BYREF - int iDrawOrder1; // [esp+214h] [ebp-78h] BYREF - int *p_iRLOWallType; // [esp+218h] [ebp-74h] - int iCompactedFlag; // [esp+21Ch] [ebp-70h] - FILE *pFile_2; // [esp+220h] [ebp-6Ch] - int iTemp3; // [esp+224h] [ebp-68h] - int iTrackGrip; // [esp+228h] [ebp-64h] BYREF - int iSubdivArrayBaseOffset; // [esp+22Ch] [ebp-60h] - int *p_uiRoofType; // [esp+230h] [ebp-5Ch] - int16 *p_nAudioAboveTrigger; // [esp+234h] [ebp-58h] - int16 *p_nSampleMin; // [esp+238h] [ebp-54h] - float *p_fGroundLevel; // [esp+23Ch] [ebp-50h] - int16 *p_nAudioTriggerSpeed; // [esp+240h] [ebp-4Ch] - int *p_iHorizonType; // [esp+244h] [ebp-48h] - int *p_iRightWallType; // [esp+248h] [ebp-44h] - int *p_iRightSurfType; // [esp+24Ch] [ebp-40h] - int *p_iLeftWallType; // [esp+250h] [ebp-3Ch] - int bMinimalMode; // [esp+254h] [ebp-38h] - unsigned int uiGroundLevelOffset; // [esp+258h] [ebp-34h] - unsigned int uiTrakViewOffset; // [esp+25Ch] [ebp-30h] - float *p_fBuildingAnglesBase; // [esp+260h] [ebp-2Ch] - unsigned int uiLocalDataOffset; // [esp+264h] [ebp-28h] - int *p_iBuildingBase; // [esp+268h] [ebp-24h] - unsigned int uiGroundColourOffset; // [esp+26Ch] [ebp-20h] - int *pTowerBasePtr; // [esp+270h] [ebp-1Ch] - unsigned int uiGroundPtOffset; // [esp+274h] [ebp-18h] + int iOFloorType; // edx + int iLeftSurfaceType; // eax + int iRightSurfaceType; // ecx + int iLeftSurfCheck; // ebx + int iRightSurfCheck; // edx + double dCos; // rt1 + int iDifficulty; // eax + int iTrackLapOffset; // edx + int iLapValue; // ebx + double dTrackZ; // st7 + int16 *p_nAudioBelowTrigger; // [esp+30h] [ebp-25Ch] + double dZ; // [esp+34h] [ebp-258h] BYREF + double dY; // [esp+3Ch] [ebp-250h] BYREF + double dX; // [esp+44h] [ebp-248h] BYREF + double dRoofHeight; // [esp+4Ch] [ebp-240h] BYREF + double dRUOWallHeight; // [esp+54h] [ebp-238h] BYREF + double dRLOWallHeight; // [esp+5Ch] [ebp-230h] BYREF + double dROFloorHeight; // [esp+64h] [ebp-228h] BYREF + double dLOFloorHeight; // [esp+6Ch] [ebp-220h] BYREF + double dLLOWallHeight; // [esp+74h] [ebp-218h] BYREF + double dLUOWallHeight; // [esp+7Ch] [ebp-210h] BYREF + double dRUOWallHOffset; // [esp+84h] [ebp-208h] BYREF + double dRLOWallHOffset; // [esp+8Ch] [ebp-200h] BYREF + double dROFloorHOffset; // [esp+94h] [ebp-1F8h] BYREF + double dLOFloorHOffset; // [esp+9Ch] [ebp-1F0h] BYREF + double dLLOWallHOffset; // [esp+A4h] [ebp-1E8h] BYREF + double dLUOWallHOffset; // [esp+ACh] [ebp-1E0h] BYREF + double dAIMaxSpeed; // [esp+B4h] [ebp-1D8h] BYREF + double dAILine4; // [esp+BCh] [ebp-1D0h] BYREF + double dAILine3; // [esp+C4h] [ebp-1C8h] BYREF + double dAILine2; // [esp+CCh] [ebp-1C0h] BYREF + double dAILine1; // [esp+D4h] [ebp-1B8h] BYREF + double dRoll; // [esp+DCh] [ebp-1B0h] BYREF + double dPitch; // [esp+E4h] [ebp-1A8h] BYREF + double dYaw; // [esp+ECh] [ebp-1A0h] BYREF + double dLength; // [esp+F4h] [ebp-198h] BYREF + double dRightShoulderHeight; // [esp+FCh] [ebp-190h] BYREF + double dLeftShoulderHeight; // [esp+104h] [ebp-188h] BYREF + double dRightShoulderWidth; // [esp+10Ch] [ebp-180h] BYREF + double dRightLaneWidth; // [esp+114h] [ebp-178h] BYREF + double dLeftLaneWidth; // [esp+11Ch] [ebp-170h] BYREF + double dLeftShoulderWidth; // [esp+124h] [ebp-168h] BYREF + double dWallCalc1; // [esp+12Ch] [ebp-160h] BYREF + double dWallCalc2; // [esp+134h] [ebp-158h] BYREF + double dWallCalc3; // [esp+13Ch] [ebp-150h] BYREF + double dTempPitch_3; // [esp+144h] [ebp-148h] + double dTempYaw_1; // [esp+14Ch] [ebp-140h] + double dLeftWallTotalHeight; // [esp+154h] [ebp-138h] + double dTempPitch; // [esp+15Ch] [ebp-130h] + double dTempYaw; // [esp+164h] [ebp-128h] + double dTempPitch_2; // [esp+16Ch] [ebp-120h] + double dTempYaw_2; // [esp+174h] [ebp-118h] + double dTempYaw_3; // [esp+17Ch] [ebp-110h] + double dTempPitch_1; // [esp+184h] [ebp-108h] + double dClampedPitch; // [esp+18Ch] [ebp-100h] + double dClampedYaw; // [esp+194h] [ebp-F8h] + double dTempCalc1; // [esp+19Ch] [ebp-F0h] + double dRadiansPerDegree; // [esp+1A4h] [ebp-E8h] + double dTempCalc2; // [esp+1BCh] [ebp-D0h] + int *p_iOFloorType; // [esp+1C4h] [ebp-C8h] + int *p_iLLOWallType; // [esp+1C8h] [ebp-C4h] + int iLeftShoulderGrip; // [esp+1CCh] [ebp-C0h] BYREF + int iDrawOrderBackward; // [esp+1D0h] [ebp-BCh] BYREF + int iRightShoulderGrip; // [esp+1D4h] [ebp-B8h] BYREF + int *p_iRUOWallType; // [esp+1D8h] [ebp-B4h] + int iDrawOrder3; // [esp+1DCh] [ebp-B0h] BYREF + int *p_iCenterSurfType; // [esp+1E0h] [ebp-ACh] + int iBackwardExtraStart2; // [esp+1E4h] [ebp-A8h] BYREF + int iBackwardExtraChunks; // [esp+1E8h] [ebp-A4h] BYREF + uint8 *pData; // [esp+1ECh] [ebp-A0h] BYREF + int iSignYaw; // [esp+1F0h] [ebp-9Ch] BYREF + int iSignVOffset; // [esp+1F4h] [ebp-98h] BYREF + int iSignHOffset; // [esp+1F8h] [ebp-94h] BYREF + int iSignType; // [esp+1FCh] [ebp-90h] BYREF + int iForwardExtraStart; // [esp+200h] [ebp-8Ch] BYREF + int iTrackIdx_1; // [esp+204h] [ebp-88h] + uint8 *pCurrDataPtr = NULL; // [esp+208h] [ebp-84h] BYREF + int iSignRoll; // [esp+20Ch] [ebp-80h] BYREF + int iSignPitch; // [esp+210h] [ebp-7Ch] BYREF + int iDrawOrder1; // [esp+214h] [ebp-78h] BYREF + int *p_iRLOWallType; // [esp+218h] [ebp-74h] + int iCompactedFlag; // [esp+21Ch] [ebp-70h] + FILE *pFile_2; // [esp+220h] [ebp-6Ch] + int iTemp3; // [esp+224h] [ebp-68h] + int iTrackGrip; // [esp+228h] [ebp-64h] BYREF + int iSubdivArrayBaseOffset; // [esp+22Ch] [ebp-60h] + int *p_uiRoofType; // [esp+230h] [ebp-5Ch] + int16 *p_nAudioAboveTrigger; // [esp+234h] [ebp-58h] + int16 *p_nSampleMin; // [esp+238h] [ebp-54h] + float *p_fGroundLevel; // [esp+23Ch] [ebp-50h] + int16 *p_nAudioTriggerSpeed; // [esp+240h] [ebp-4Ch] + int *p_iHorizonType; // [esp+244h] [ebp-48h] + int *p_iRightWallType; // [esp+248h] [ebp-44h] + int *p_iRightSurfType; // [esp+24Ch] [ebp-40h] + int *p_iLeftWallType; // [esp+250h] [ebp-3Ch] + int bMinimalMode; // [esp+254h] [ebp-38h] + unsigned int uiGroundLevelOffset; // [esp+258h] [ebp-34h] + unsigned int uiTrakViewOffset; // [esp+25Ch] [ebp-30h] + float *p_fBuildingAnglesBase; // [esp+260h] [ebp-2Ch] + unsigned int uiLocalDataOffset; // [esp+264h] [ebp-28h] + int *p_iBuildingBase; // [esp+268h] [ebp-24h] + unsigned int uiGroundColourOffset; // [esp+26Ch] [ebp-20h] + int *pTowerBasePtr; // [esp+270h] [ebp-1Ch] + unsigned int uiGroundPtOffset; // [esp+274h] [ebp-18h] - iTrackIdx_1 = iTrackIdx; // Initialize variables and clear car structures + iTrackIdx_1 = iTrackIdx; // Initialize variables and clear car structures bMinimalMode = iPreviewMode; p_iBuildingBase = BuildingBase[0]; p_fBuildingAnglesBase = BuildingAngles; @@ -251,21 +240,23 @@ void loadtrack(int iTrackIdx, int iPreviewMode) } pFile_2 = 0; if ((unsigned int)iTrackIdx_1 <= 0x18) { - pFile = ROLLERfopen(names[iTrackIdx_1], "r"); // Open and validate track file + pFile = + ROLLERfopen(names[iTrackIdx_1], "r"); // Open and validate track file if (!pFile) { ErrorBoxExit("Track %d not found\n", iTrackIdx_1); //__asm { int 10h; -VIDEO - SET VIDEO MODE } - //printf("Track %d not found\n", iTrackIdx_1); - //doexit(); + // printf("Track %d not found\n", iTrackIdx_1); + // doexit(); } fclose(pFile); iCompactedFileLength = getcompactedfilelength(names[iTrackIdx_1]); - if ((int16)iCompactedFileLength == 8224)// Check if file is compacted (magic number 8224) + if ((int16)iCompactedFileLength == + 8224) // Check if file is compacted (magic number 8224) { iFileLength = ROLLERfilelength(names[iTrackIdx_1]); - //iFileHandle_1 = ROLLERopen(names[iTrackIdx_1], 0); - //iFileLength = filelength(iFileHandle_1); - //close(iFileHandle_1); + // iFileHandle_1 = ROLLERopen(names[iTrackIdx_1], 0); + // iFileLength = filelength(iFileHandle_1); + // close(iFileHandle_1); if (bMinimalMode) pTrackBuffer_1 = scrbuf; else @@ -292,11 +283,13 @@ void loadtrack(int iTrackIdx, int iPreviewMode) } meof = 0; if (iTrackIdx_1 >= 0) - readline2(&pCurrDataPtr, "iddd", &TRAK_LEN, &dWallCalc3, &dWallCalc2, &dWallCalc1);// Read track header: length and initial position + readline2(&pCurrDataPtr, "iddd", &TRAK_LEN, &dWallCalc3, &dWallCalc2, + &dWallCalc1); // Read track header: length and initial position iChunkIdx = 0; TrackFlags = 0; if (TRAK_LEN > 0) { - p_iCenterSurfType = &TrakColour[0][TRAK_COLOUR_CENTER];// Main track chunk processing loop + p_iCenterSurfType = + &TrakColour[0][TRAK_COLOUR_CENTER]; // Main track chunk processing loop p_iRightSurfType = &TrakColour[0][TRAK_COLOUR_RIGHT_LANE]; p_iLeftWallType = &TrakColour[0][TRAK_COLOUR_LEFT_WALL]; uiTrakViewOffset = 0; @@ -327,100 +320,58 @@ void loadtrack(int iTrackIdx, int iPreviewMode) samplemin[iChunkIdx] = 0; samplemax[iChunkIdx] = 0; samplespeed[iChunkIdx] = 0; - readline2( - &pCurrDataPtr, - "ddddddddddddddiiidfsss", - &dLeftShoulderWidth, - &dLeftLaneWidth, - &dRightLaneWidth, - &dRightShoulderWidth, - &dLeftShoulderHeight, - &dRightShoulderHeight, - &dLength, - &dYaw, - &dPitch, - &dRoll, - &dAILine1, - &dAILine2, - &dAILine3, - &dAILine4, - &iTrackGrip, - &iLeftShoulderGrip, - &iRightShoulderGrip, - &dAIMaxSpeed, - p_fGroundLevel, - p_nAudioAboveTrigger, - p_nAudioTriggerSpeed, - p_nAudioBelowTrigger); // Read track segment geometry data - readline2( - &pCurrDataPtr, - "iiiiiiiiiiiiiiiiii", - &TrakColour[iTrakColourIdx], // LeftSurfType - p_iCenterSurfType, - p_iRightSurfType, - p_iLeftWallType, - p_iRightWallType, - p_uiRoofType, - p_uiLUOWallType, - p_iLLOWallType, - p_iOFloorType, - p_iRLOWallType, - p_iRUOWallType, - p_iHorizonType, - &iSignType, - &iSignHOffset, - &iSignVOffset, - &iSignYaw, - &iSignPitch, - &iSignRoll); // Read track surface and wall color data + readline2(&pCurrDataPtr, "ddddddddddddddiiidfsss", &dLeftShoulderWidth, + &dLeftLaneWidth, &dRightLaneWidth, &dRightShoulderWidth, + &dLeftShoulderHeight, &dRightShoulderHeight, &dLength, &dYaw, + &dPitch, &dRoll, &dAILine1, &dAILine2, &dAILine3, &dAILine4, + &iTrackGrip, &iLeftShoulderGrip, &iRightShoulderGrip, + &dAIMaxSpeed, p_fGroundLevel, p_nAudioAboveTrigger, + p_nAudioTriggerSpeed, + p_nAudioBelowTrigger); // Read track segment geometry data + readline2(&pCurrDataPtr, "iiiiiiiiiiiiiiiiii", + &TrakColour[iTrakColourIdx], // LeftSurfType + p_iCenterSurfType, p_iRightSurfType, p_iLeftWallType, + p_iRightWallType, p_uiRoofType, p_uiLUOWallType, + p_iLLOWallType, p_iOFloorType, p_iRLOWallType, p_iRUOWallType, + p_iHorizonType, &iSignType, &iSignHOffset, &iSignVOffset, + &iSignYaw, &iSignPitch, + &iSignRoll); // Read track surface and wall color data iTemp1 = iSubdivArrayBaseOffset; iTemp2 = 11 * iChunkIdx; // Clear the subdivides array for the current chunk for (int i = 0; i < 11; i++) { Subdivide[iChunkIdx].subdivides[i] = 0; } - //do - // *((uint8 *)&meof + ++iTemp2 + 3) = 0; - //while (iTemp2 != iTemp1); + // do + // *((uint8 *)&meof + ++iTemp2 + 3) = 0; + // while (iTemp2 != iTemp1); iSubdivideIdx = iChunkIdx; - readline2( - &pCurrDataPtr, - "dddddddddddddiiiuuuuuuuuuuuiii", - &dLUOWallHOffset, - &dLLOWallHOffset, - &dLOFloorHOffset, - &dROFloorHOffset, - &dRLOWallHOffset, - &dRUOWallHOffset, - &dLUOWallHeight, - &dLLOWallHeight, - &dLOFloorHeight, - &dROFloorHeight, - &dRLOWallHeight, - &dRUOWallHeight, - &dRoofHeight, - &iDrawOrder1, - &iForwardExtraStart, - &iDrawOrder3, - &Subdivide[iSubdivideIdx], - &Subdivide[iSubdivideIdx].subdivides[1], - &Subdivide[iSubdivideIdx].subdivides[2], - &Subdivide[iSubdivideIdx].subdivides[3], - &Subdivide[iSubdivideIdx].subdivides[4], - &Subdivide[iSubdivideIdx].subdivides[5], - &Subdivide[iSubdivideIdx].subdivides[6], - &Subdivide[iSubdivideIdx].subdivides[7], - &Subdivide[iSubdivideIdx].subdivides[8], - &Subdivide[iSubdivideIdx].subdivides[9], - &Subdivide[iSubdivideIdx].subdivides[10], - &iDrawOrderBackward, - &iBackwardExtraStart2, - &iBackwardExtraChunks); // Read wall heights, offsets and view distance data + readline2(&pCurrDataPtr, "dddddddddddddiiiuuuuuuuuuuuiii", + &dLUOWallHOffset, &dLLOWallHOffset, &dLOFloorHOffset, + &dROFloorHOffset, &dRLOWallHOffset, &dRUOWallHOffset, + &dLUOWallHeight, &dLLOWallHeight, &dLOFloorHeight, + &dROFloorHeight, &dRLOWallHeight, &dRUOWallHeight, + &dRoofHeight, &iDrawOrder1, &iForwardExtraStart, &iDrawOrder3, + &Subdivide[iSubdivideIdx], + &Subdivide[iSubdivideIdx].subdivides[1], + &Subdivide[iSubdivideIdx].subdivides[2], + &Subdivide[iSubdivideIdx].subdivides[3], + &Subdivide[iSubdivideIdx].subdivides[4], + &Subdivide[iSubdivideIdx].subdivides[5], + &Subdivide[iSubdivideIdx].subdivides[6], + &Subdivide[iSubdivideIdx].subdivides[7], + &Subdivide[iSubdivideIdx].subdivides[8], + &Subdivide[iSubdivideIdx].subdivides[9], + &Subdivide[iSubdivideIdx].subdivides[10], &iDrawOrderBackward, + &iBackwardExtraStart2, + &iBackwardExtraChunks); // Read wall heights, offsets and view + // distance data if (bMinimalMode) { dLeftLaneWidth = dLeftLaneWidth * 2.0; dRightLaneWidth = dRightLaneWidth * 2.0; } - if ((cheat_mode & 0x1000) != 0 && !bMinimalMode)// Apply double track width cheat if enabled + if ((cheat_mode & 0x1000) != 0 && + !bMinimalMode) // Apply double track width cheat if enabled { dLeftShoulderWidth = dLeftShoulderWidth * 2.0; dLeftLaneWidth = dLeftLaneWidth * 2.0; @@ -451,36 +402,43 @@ void loadtrack(int iTrackIdx, int iPreviewMode) iSignHOffset *= 2; GroundLevel[uiGroundLevelOffset / 4] = (float)dTemp1; } - iSubdivLoopIdx = 0; // Initialize subdivision array for current chunk + iSubdivLoopIdx = 0; // Initialize subdivision array for current chunk iSubdivOffset = 0; iSubdivArrayIdx = 11 * iChunkIdx; do { - //int iChunkIdx = iSubdivArrayIdx / 11; // Which chunk we're in - int iElementIdx = iSubdivArrayIdx % 11; // Which element within the chunk's subdivides array - if (!Subdivide[iChunkIdx].subdivides[iElementIdx] && (unsigned int)iSubdivLoopIdx <= 10) { + // int iChunkIdx = iSubdivArrayIdx / 11; // Which chunk we're in + int iElementIdx = + iSubdivArrayIdx % + 11; // Which element within the chunk's subdivides array + if (!Subdivide[iChunkIdx].subdivides[iElementIdx] && + (unsigned int)iSubdivLoopIdx <= 10) { switch (iSubdivLoopIdx) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 7: - case 9: - Subdivide[iChunkIdx].subdivides[iElementIdx] = 20; // 0x14 - Default subdivision level - break; - case 6: - case 8: - case 10: - Subdivide[iChunkIdx].subdivides[iElementIdx] = 4; // Special subdivision level for specific geometry - break; - default: - // Should never reach here due to the <= 0xA check - break; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 7: + case 9: + Subdivide[iChunkIdx].subdivides[iElementIdx] = + 20; // 0x14 - Default subdivision level + break; + case 6: + case 8: + case 10: + Subdivide[iChunkIdx].subdivides[iElementIdx] = + 4; // Special subdivision level for specific geometry + break; + default: + // Should never reach here due to the <= 0xA check + break; } } - //if (!Subdivide[0].subdivides[iSubdivArrayIdx] && (unsigned int)iSubdivLoopIdx <= 10) - // __asm { jmp cs : off_4AF00[ebx]; jumptable 0004BC6D case 257 } + // if (!Subdivide[0].subdivides[iSubdivArrayIdx] && (unsigned + // int)iSubdivLoopIdx <= 10) + // __asm { jmp cs : off_4AF00[ebx]; jumptable 0004BC6D case 257 + // } iSubdivOffset += 4; ++iSubdivLoopIdx; ++iSubdivArrayIdx; @@ -490,7 +448,8 @@ void loadtrack(int iTrackIdx, int iPreviewMode) if (iDrawOrder1 > 128) iDrawOrder1 = 32; TrakView[uiTrakViewOffset / 8].byForwardMainChunks = iDrawOrder1; - if (iForwardExtraStart < 0 || iForwardExtraStart > TRAK_LEN || iDrawOrder3 < 8 || iDrawOrder3 > 128) { + if (iForwardExtraStart < 0 || iForwardExtraStart > TRAK_LEN || + iDrawOrder3 < 8 || iDrawOrder3 > 128) { iForwardExtraStart = -1; iDrawOrder3 = 0; } @@ -503,15 +462,20 @@ void loadtrack(int iTrackIdx, int iPreviewMode) if (iDrawOrderBackward > 128) iDrawOrderBackward = 32; iBackwardExtraStart = iBackwardExtraStart2; - TrakView[uiTrakViewOffset / 8].byBackwardMainChunks = iDrawOrderBackward; - if (iBackwardExtraStart < 0 || iBackwardExtraStart > TRAK_LEN || iBackwardExtraChunks < 8 || iBackwardExtraChunks > 128) { + TrakView[uiTrakViewOffset / 8].byBackwardMainChunks = + iDrawOrderBackward; + if (iBackwardExtraStart < 0 || iBackwardExtraStart > TRAK_LEN || + iBackwardExtraChunks < 8 || iBackwardExtraChunks > 128) { iBackwardExtraStart2 = -1; iBackwardExtraChunks = 0; } uiTrakViewOffset2 = uiTrakViewOffset; - TrakView[uiTrakViewOffset / 8].nBackwardExtraStart = iBackwardExtraStart2; - TrakView[uiTrakViewOffset2 / 8].byBackwardExtraChunks = iBackwardExtraChunks; - //*(&TrakView[0].byBackwardExtraChunks + uiTrakViewOffset2) = iBackwardExtraChunks; + TrakView[uiTrakViewOffset / 8].nBackwardExtraStart = + iBackwardExtraStart2; + TrakView[uiTrakViewOffset2 / 8].byBackwardExtraChunks = + iBackwardExtraChunks; + //*(&TrakView[0].byBackwardExtraChunks + uiTrakViewOffset2) = + // iBackwardExtraChunks; } if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] == -1) TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] = 0; @@ -545,7 +509,7 @@ void loadtrack(int iTrackIdx, int iPreviewMode) if (dTempPitch_1 < -180.0) dTempPitch_1 = dTempPitch_1 + 360.0; dClampedPitch = dTempPitch_1 * 0.5 + dTempPitch; - if (iSignType != -1) { // Process signs/objects: buildings vs towers + if (iSignType != -1) { // Process signs/objects: buildings vs towers if (iSignType < 256) { p_iBuildingData = p_iBuildingBase + 1; *p_iBuildingBase = iSignType; @@ -570,49 +534,59 @@ void loadtrack(int iTrackIdx, int iPreviewMode) p_iData1 = v27 + 1; pTowerBasePtr = v27 + 1; switch (iSignType & 0xFF0F) { - case 0x101: - pTowerBasePtr = v27 + 2; - *p_iData1 = -4; - break; - case 0x103: - pTowerBasePtr = v27 + 2; - *p_iData1 = -2; - break; - case 0x104: - pTowerBasePtr = v27 + 2; - *p_iData1 = -5; - break; - case 0x105: - pTowerBasePtr = v27 + 2; - *p_iData1 = -3; - break; - default: - pTowerBase2 = pTowerBasePtr + 1; - *pTowerBasePtr = -1; - pTowerBasePtr = pTowerBase2; - break; + case 0x101: + pTowerBasePtr = v27 + 2; + *p_iData1 = -4; + break; + case 0x103: + pTowerBasePtr = v27 + 2; + *p_iData1 = -2; + break; + case 0x104: + pTowerBasePtr = v27 + 2; + *p_iData1 = -5; + break; + case 0x105: + pTowerBasePtr = v27 + 2; + *p_iData1 = -3; + break; + default: + pTowerBase2 = pTowerBasePtr + 1; + *pTowerBasePtr = -1; + pTowerBasePtr = pTowerBase2; + break; } pTowerBase3 = pTowerBasePtr; *pTowerBasePtr = (iSignType - 256) / 16; - //*pTowerBasePtr = (iSignType - 256 - (__CFSHL__((iSignType - 256) >> 31, 4) + 16 * ((iSignType - 256) >> 31))) >> 4; + //*pTowerBasePtr = (iSignType - 256 - (__CFSHL__((iSignType - 256) >> + // 31, 4) + 16 * ((iSignType - 256) >> 31))) >> 4; pTowerBasePtr = pTowerBase3 + 1; ++NumTowers; } } - rotatepoint(0.0, dLeftShoulderWidth + dLeftLaneWidth, dLeftShoulderHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ);// Calculate and set track geometry points + rotatepoint(0.0, dLeftShoulderWidth + dLeftLaneWidth, dLeftShoulderHeight, + dClampedYaw, dClampedPitch, dRoll, &dX, &dY, + &dZ); // Calculate and set track geometry points setpoint(iChunkIdx, 0, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, dLeftShoulderWidth + dLeftLaneWidth, 0.0, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, dLeftShoulderWidth + dLeftLaneWidth, 0.0, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); setpoint(iChunkIdx, 1, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, dLeftLaneWidth, 0.0, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, dLeftLaneWidth, 0.0, dClampedYaw, dClampedPitch, dRoll, + &dX, &dY, &dZ); setpoint(iChunkIdx, 2, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, -dRightLaneWidth, 0.0, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, -dRightLaneWidth, 0.0, dClampedYaw, dClampedPitch, dRoll, + &dX, &dY, &dZ); setpoint(iChunkIdx, 3, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, -dRightLaneWidth - dRightShoulderWidth, dRightShoulderHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, -dRightLaneWidth - dRightShoulderWidth, + dRightShoulderHeight, dClampedYaw, dClampedPitch, dRoll, &dX, + &dY, &dZ); setpoint(iChunkIdx, 4, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, -dRightLaneWidth - dRightShoulderWidth, 0.0, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, -dRightLaneWidth - dRightShoulderWidth, 0.0, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); setpoint(iChunkIdx, 5, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - if (!bMinimalMode) { // Calculate ground points based on floor type - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (!bMinimalMode) { // Calculate ground points based on floor type + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { dLOFloorHeight = -dLeftShoulderHeight; dLOFloorHOffset = dLeftShoulderWidth; dROFloorHOffset = dRightShoulderWidth; @@ -631,74 +605,99 @@ void loadtrack(int iTrackIdx, int iPreviewMode) v34 = GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR]; dTempCalc1 = dTempCalc2 + dLOFloorHOffset + dLeftLaneWidth; if (v34 == -2) { - rotatepoint(0.0, dTempCalc1, dLeftWallTotalHeight - dLOFloorHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); - setgpoint(iChunkIdx, 0, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, dLLOWallHOffset + dLOFloorHOffset + dLeftLaneWidth, dLLOWallHeight - dLOFloorHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); - setgpoint(iChunkIdx, 1, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, dLOFloorHOffset + dLeftLaneWidth, -dLOFloorHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); - setgpoint(iChunkIdx, 2, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, -dROFloorHOffset - dRightLaneWidth, -dROFloorHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); - setgpoint(iChunkIdx, 3, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint(0.0, -dRLOWallHOffset - dROFloorHOffset - dRightLaneWidth, dRLOWallHeight - dROFloorHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); - setgpoint(iChunkIdx, 4, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - rotatepoint( - 0.0, - -dRUOWallHOffset - dRLOWallHOffset - dROFloorHOffset - dRightLaneWidth, - dRUOWallHeight + dRLOWallHeight - dROFloorHeight, - dClampedYaw, - dClampedPitch, - dRoll, - &dX, - &dY, - &dZ); - setgpoint(iChunkIdx, 5, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); + rotatepoint(0.0, dTempCalc1, dLeftWallTotalHeight - dLOFloorHeight, + dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + setgpoint(iChunkIdx, 0, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); + rotatepoint(0.0, dLLOWallHOffset + dLOFloorHOffset + dLeftLaneWidth, + dLLOWallHeight - dLOFloorHeight, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); + setgpoint(iChunkIdx, 1, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); + rotatepoint(0.0, dLOFloorHOffset + dLeftLaneWidth, -dLOFloorHeight, + dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + setgpoint(iChunkIdx, 2, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); + rotatepoint(0.0, -dROFloorHOffset - dRightLaneWidth, -dROFloorHeight, + dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + setgpoint(iChunkIdx, 3, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); + rotatepoint(0.0, -dRLOWallHOffset - dROFloorHOffset - dRightLaneWidth, + dRLOWallHeight - dROFloorHeight, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); + setgpoint(iChunkIdx, 4, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); + rotatepoint(0.0, + -dRUOWallHOffset - dRLOWallHOffset - dROFloorHOffset - + dRightLaneWidth, + dRUOWallHeight + dRLOWallHeight - dROFloorHeight, + dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + setgpoint(iChunkIdx, 5, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); } else { - rotatepoint(0.0, dTempCalc1, dLeftWallTotalHeight + dLOFloorHeight, dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); + rotatepoint(0.0, dTempCalc1, dLeftWallTotalHeight + dLOFloorHeight, + dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); setgpoint(iChunkIdx, 0, dWallCalc3 + dX, dWallCalc2 + dY, dZ); - rotatepoint(0.0, dLLOWallHOffset + dLOFloorHOffset + dLeftLaneWidth, dLLOWallHeight + dLOFloorHeight, dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); + rotatepoint(0.0, dLLOWallHOffset + dLOFloorHOffset + dLeftLaneWidth, + dLLOWallHeight + dLOFloorHeight, dClampedYaw, + dClampedPitch, 0.0, &dX, &dY, &dZ); setgpoint(iChunkIdx, 1, dWallCalc3 + dX, dWallCalc2 + dY, dZ); - rotatepoint(0.0, dLOFloorHOffset + dLeftLaneWidth, dLOFloorHeight, dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); + rotatepoint(0.0, dLOFloorHOffset + dLeftLaneWidth, dLOFloorHeight, + dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); setgpoint(iChunkIdx, 2, dWallCalc3 + dX, dWallCalc2 + dY, dZ); - rotatepoint(0.0, -dROFloorHOffset - dRightLaneWidth, dROFloorHeight, dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); + rotatepoint(0.0, -dROFloorHOffset - dRightLaneWidth, dROFloorHeight, + dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); setgpoint(iChunkIdx, 3, dWallCalc3 + dX, dWallCalc2 + dY, dZ); - rotatepoint(0.0, -dRLOWallHOffset - dROFloorHOffset - dRightLaneWidth, dRLOWallHeight + dROFloorHeight, dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); + rotatepoint(0.0, -dRLOWallHOffset - dROFloorHOffset - dRightLaneWidth, + dRLOWallHeight + dROFloorHeight, dClampedYaw, + dClampedPitch, 0.0, &dX, &dY, &dZ); setgpoint(iChunkIdx, 4, dWallCalc3 + dX, dWallCalc2 + dY, dZ); - rotatepoint( - 0.0, - -dRUOWallHOffset - dRLOWallHOffset - dROFloorHOffset - dRightLaneWidth, - dRUOWallHeight + dRLOWallHeight + dROFloorHeight, - dClampedYaw, - dClampedPitch, - 0.0, - &dX, - &dY, - &dZ); + rotatepoint(0.0, + -dRUOWallHOffset - dRLOWallHOffset - dROFloorHOffset - + dRightLaneWidth, + dRUOWallHeight + dRLOWallHeight + dROFloorHeight, + dClampedYaw, dClampedPitch, 0.0, &dX, &dY, &dZ); setgpoint(iChunkIdx, 5, dWallCalc3 + dX, dWallCalc2 + dY, dZ); } if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] >= 0) { - rotatepoint(0.0, dLeftLaneWidth + dLeftShoulderWidth, dRoofHeight + dLeftShoulderHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, dLeftLaneWidth + dLeftShoulderWidth, + dRoofHeight + dLeftShoulderHeight, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); } else { dLeftShoulderHeight = 0.0; - rotatepoint(0.0, dLeftLaneWidth, dRoofHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, dLeftLaneWidth, dRoofHeight, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); } - setpoint(iChunkIdx, 1, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); + setpoint(iChunkIdx, 1, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] >= 0) { - rotatepoint(0.0, -dRightLaneWidth - dRightShoulderWidth, dRoofHeight + dRightShoulderHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, -dRightLaneWidth - dRightShoulderWidth, + dRoofHeight + dRightShoulderHeight, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); } else { dRightShoulderHeight = 0.0; - rotatepoint(0.0, -dRightLaneWidth, dRoofHeight, dClampedYaw, dClampedPitch, dRoll, &dX, &dY, &dZ); + rotatepoint(0.0, -dRightLaneWidth, dRoofHeight, dClampedYaw, + dClampedPitch, dRoll, &dX, &dY, &dZ); } - setpoint(iChunkIdx, 5, dWallCalc3 + dX, dWallCalc2 + dY, dWallCalc1 + dZ); - TrackInfo[iTrackInfoIdx].fLShoulderWidth = (float)dLeftShoulderWidth;// Store track info data for current chunk + setpoint(iChunkIdx, 5, dWallCalc3 + dX, dWallCalc2 + dY, + dWallCalc1 + dZ); + TrackInfo[iTrackInfoIdx].fLShoulderWidth = (float) + dLeftShoulderWidth; // Store track info data for current chunk TrackInfo[iTrackInfoIdx].fLShoulderHeight = (float)dLeftShoulderHeight; TrackInfo[iTrackInfoIdx].fRShoulderWidth = (float)dRightShoulderWidth; TrackInfo[iTrackInfoIdx].fRShoulderHeight = (float)dRightShoulderHeight; TrackInfo[iTrackInfoIdx].fRoofHeight = (float)dRoofHeight; dAngleCalc1 = dRadiansPerDegree; - dLeftAngle = dLeftShoulderWidth != 0.0 ? atan2(dLeftShoulderHeight / dLeftShoulderWidth, 1.0) * 16384.0 * dRadiansPerDegree : 0.0; + dLeftAngle = + dLeftShoulderWidth != 0.0 + ? atan2(dLeftShoulderHeight / dLeftShoulderWidth, 1.0) * + 16384.0 * dRadiansPerDegree + : 0.0; //_CHP(); iTemp3 = (int)dLeftAngle; - dRightAngle = dRightShoulderWidth != 0.0 ? dRightShoulderHeight / dRightShoulderWidth : 0.0; + dRightAngle = dRightShoulderWidth != 0.0 + ? dRightShoulderHeight / dRightShoulderWidth + : 0.0; TrackInfo[iTrackInfoIdx].iLeftBankAngle = iTemp3; //_CHP(); iTemp3 = (int)(dAngleCalc1 * (atan2(dRightAngle, 1.0) * 16384.0)); @@ -709,156 +708,215 @@ void loadtrack(int iTrackIdx, int iPreviewMode) localdata[uiLocalDataOffset1 / 0x80].fAILine2 = (float)dAILine2; localdata[uiLocalDataOffset1 / 0x80].fAILine3 = (float)dAILine3; localdata[uiLocalDataOffset1 / 0x80].fAILine4 = (float)dAILine4; - //*(float *)((char *)&localdata[0].fAILine2 + uiLocalDataOffset1) = dAILine2; - //*(float *)((char *)&localdata[0].fAILine3 + uiLocalDataOffset1) = dAILine3; - //*(float *)((char *)&localdata[0].fAILine4 + uiLocalDataOffset1) = dAILine4; + //*(float *)((char *)&localdata[0].fAILine2 + uiLocalDataOffset1) = + // dAILine2; + //*(float *)((char *)&localdata[0].fAILine3 + uiLocalDataOffset1) = + // dAILine3; + //*(float *)((char *)&localdata[0].fAILine4 + uiLocalDataOffset1) = + // dAILine4; uiLocalDataOffset2 = uiLocalDataOffset; localdata[uiLocalDataOffset / 0x80].iCenterGrip = iTrackGrip; dAIMaxSpeed_1 = dAIMaxSpeed; - localdata[uiLocalDataOffset2 / 0x80].iLeftShoulderGrip = iLeftShoulderGrip; - localdata[uiLocalDataOffset2 / 0x80].iRightShoulderGrip = iRightShoulderGrip; - //*(int *)((char *)&localdata[0].iLeftShoulderGrip + uiLocalDataOffset2) = iLeftShoulderGrip; - //*(int *)((char *)&localdata[0].iRightShoulderGrip + uiLocalDataOffset2) = iRightShoulderGrip; + localdata[uiLocalDataOffset2 / 0x80].iLeftShoulderGrip = + iLeftShoulderGrip; + localdata[uiLocalDataOffset2 / 0x80].iRightShoulderGrip = + iRightShoulderGrip; + //*(int *)((char *)&localdata[0].iLeftShoulderGrip + uiLocalDataOffset2) + //= iLeftShoulderGrip; + //*(int *)((char *)&localdata[0].iRightShoulderGrip + + // uiLocalDataOffset2) = iRightShoulderGrip; uiGroundColourOffset1 = uiGroundColourOffset; TrackInfo[iTrackInfoIdx].iLeftSurfaceType = -100; localdata[uiLocalDataOffset2 / 0x80].fAIMaxSpeed = (float)dAIMaxSpeed_1; - //*(float *)((char *)&localdata[0].fAIMaxSpeed + uiLocalDataOffset2) = dAIMaxSpeed_1; - iOFloorType = GroundColour[uiGroundColourOffset1 / 0x14][GROUND_COLOUR_OFLOOR]; - //iOFloorType = *(int *)((char *)&GroundColour[0][GROUND_COLOUR_OFLOOR] + uiGroundColourOffset1); - TrackInfo[iTrackInfoIdx].iRightSurfaceType = -100;// Determine surface grip types for physics + //*(float *)((char *)&localdata[0].fAIMaxSpeed + uiLocalDataOffset2) = + // dAIMaxSpeed_1; + iOFloorType = + GroundColour[uiGroundColourOffset1 / 0x14][GROUND_COLOUR_OFLOOR]; + // iOFloorType = *(int *)((char *)&GroundColour[0][GROUND_COLOUR_OFLOOR] + // + uiGroundColourOffset1); + TrackInfo[iTrackInfoIdx].iRightSurfaceType = + -100; // Determine surface grip types for physics if (iOFloorType != -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 0; TrackInfo[iTrackInfoIdx].iRightSurfaceType = 0; } - if (GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ >= (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ - && !TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ >= + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ && + !TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 1; } - if (GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ >= (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ - && !TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ >= + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ && + !TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iRightSurfaceType = 1; } - if (GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ < (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ - && !TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ < + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ && + !TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 2; } - if (GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ < (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ - && !TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ < + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ && + !TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iRightSurfaceType = 2; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ >= (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ >= + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 3; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ >= (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ >= + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iRightSurfaceType = 3; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ < (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ < + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 4; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ < (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ < + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iRightSurfaceType = 4; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] < 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ >= (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] < 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ >= + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 5; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] < 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ >= (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] < 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ >= + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iRightSurfaceType = 5; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] < 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ < (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] < 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[1].fZ < + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[2].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 6; } - if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] < 0 - && GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ < (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ - && GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -2) { + if (TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] < 0 && + GroundPt[uiGroundPtOffset / 0x48].pointAy[4].fZ < + (double)GroundPt[uiGroundPtOffset / 0x48].pointAy[3].fZ && + GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -2) { TrackInfo[iTrackInfoIdx].iRightSurfaceType = 6; } - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -1 && TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0) + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -1 && + TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0) TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 7; - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -1 && TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0) + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -1 && + TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0) TrackInfo[iTrackInfoIdx].iRightSurfaceType = 7; - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] >= 0 && TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0) + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] >= + 0 && + TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] > 0) TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 8; - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] >= 0 && TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0) + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] >= + 0 && + TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] > 0) TrackInfo[iTrackInfoIdx].iRightSurfaceType = 8; - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -1 && TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] < 0) + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -1 && + TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL] < 0) TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 9; - if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == -1 && TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] < 0) + if (GroundColour[uiGroundColourOffset / 0x14][GROUND_COLOUR_OFLOOR] == + -1 && + TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL] < 0) TrackInfo[iTrackInfoIdx].iRightSurfaceType = 9; iLeftSurfaceType = TrackInfo[iTrackInfoIdx].iLeftSurfaceType; - if ((!iLeftSurfaceType || iLeftSurfaceType == 2) && (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_LANE]) & SURFACE_FLAG_BOUNCE_20) == 0) + if ((!iLeftSurfaceType || iLeftSurfaceType == 2) && + (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_LANE]) & + SURFACE_FLAG_BOUNCE_20) == 0) TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 1; iRightSurfaceType = TrackInfo[iTrackInfoIdx].iRightSurfaceType; - if ((!iRightSurfaceType || iRightSurfaceType == 2) && (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_LANE]) & SURFACE_FLAG_BOUNCE_20) == 0) + if ((!iRightSurfaceType || iRightSurfaceType == 2) && + (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_LANE]) & + SURFACE_FLAG_BOUNCE_20) == 0) TrackInfo[iTrackInfoIdx].iRightSurfaceType = 1; iLeftSurfCheck = TrackInfo[iTrackInfoIdx].iLeftSurfaceType; - if ((iLeftSurfCheck == 6 || iLeftSurfCheck == 9) && (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_LANE]) & SURFACE_FLAG_BOUNCE_20) == 0) + if ((iLeftSurfCheck == 6 || iLeftSurfCheck == 9) && + (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_LANE]) & + SURFACE_FLAG_BOUNCE_20) == 0) TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 5; iRightSurfCheck = TrackInfo[iTrackInfoIdx].iRightSurfaceType; - if ((iRightSurfCheck == 6 || iRightSurfCheck == 9) && (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_LANE]) & SURFACE_FLAG_BOUNCE_20) == 0) + if ((iRightSurfCheck == 6 || iRightSurfCheck == 9) && + (abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_LANE]) & + SURFACE_FLAG_BOUNCE_20) == 0) TrackInfo[iTrackInfoIdx].iRightSurfaceType = 5; - if ((abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL]) & SURFACE_FLAG_SKIP_RENDER) != 0) { + if ((abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_LEFT_WALL]) & + SURFACE_FLAG_SKIP_RENDER) != 0) { switch (TrackInfo[iTrackInfoIdx].iLeftSurfaceType) { - case 3: - case 5: - TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 1; - break; - case 4: - case 6: - TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 2; - break; - case 7: - case 8: - case 9: - TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 0; - break; - default: - break; + case 3: + case 5: + TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 1; + break; + case 4: + case 6: + TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 2; + break; + case 7: + case 8: + case 9: + TrackInfo[iTrackInfoIdx].iLeftSurfaceType = 0; + break; + default: + break; } } - if ((abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL]) & SURFACE_FLAG_SKIP_RENDER) != 0) { + if ((abs(TrakColour[iTrakColourIdx][TRAK_COLOUR_RIGHT_WALL]) & + SURFACE_FLAG_SKIP_RENDER) != 0) { switch (TrackInfo[iTrackInfoIdx].iRightSurfaceType) { - case 3: - case 5: - TrackInfo[iTrackInfoIdx].iRightSurfaceType = 1; - break; - case 4: - case 6: - TrackInfo[iTrackInfoIdx].iRightSurfaceType = 2; - break; - case 7: - case 8: - case 9: - TrackInfo[iTrackInfoIdx].iRightSurfaceType = 0; - break; - default: - break; + case 3: + case 5: + TrackInfo[iTrackInfoIdx].iRightSurfaceType = 1; + break; + case 4: + case 6: + TrackInfo[iTrackInfoIdx].iRightSurfaceType = 2; + break; + case 7: + case 8: + case 9: + TrackInfo[iTrackInfoIdx].iRightSurfaceType = 0; + break; + default: + break; } } } - dCos = cos(0.0174532925199 * dPitch); // Calculate cosine for length projection + dCos = cos(0.0174532925199 * + dPitch); // Calculate cosine for length projection ++iTrakColourIdx; ++iTrackInfoIdx; ++iChunkIdx; p_iCenterSurfType += 6; - dWallCalc3 = cos(0.0174532925199 * dYaw) * (dCos * dLength) + dWallCalc3;// Update position coordinates using trigonometry + dWallCalc3 = cos(0.0174532925199 * dYaw) * (dCos * dLength) + + dWallCalc3; // Update position coordinates using trigonometry p_iRightSurfType += 6; p_iLeftWallType += 6; p_uiRoofType += 6; @@ -867,7 +925,7 @@ void loadtrack(int iTrackIdx, int iPreviewMode) p_iRUOWallType += 5; ++p_fGroundLevel; ++p_nAudioAboveTrigger; - dTempYaw = dYaw; // Increment array offsets and pointers for next chunk + dTempYaw = dYaw; // Increment array offsets and pointers for next chunk ++p_nSampleMin; dWallCalc2 = dCos * dLength * sin(0.0174532925199 * dYaw) + dWallCalc2; ++p_iHorizonType; @@ -885,17 +943,19 @@ void loadtrack(int iTrackIdx, int iPreviewMode) } while (iChunkIdx < TRAK_LEN); } if (!bMinimalMode) - ReadAnimData(pFile_2, &pCurrDataPtr); // Load animation data if not in minimal mode + ReadAnimData(pFile_2, + &pCurrDataPtr); // Load animation data if not in minimal mode if (bMinimalMode) { if (iTrackIdx_1 >= 0) min_skip_stuff(&pCurrDataPtr); } else { - initlocaltrack(); // Initialize track objects and car placement + initlocaltrack(); // Initialize track objects and car placement InitTowers(); InitBuildings(); placecars(); if (iTrackIdx_1 >= 0) { - start_f = pCurrDataPtr; // Read additional track data: stunts, textures, buildings + start_f = pCurrDataPtr; // Read additional track data: stunts, textures, + // buildings readstuntdata(&pCurrDataPtr); read_texturemap(&pCurrDataPtr); read_bldmap(&pCurrDataPtr); @@ -910,27 +970,34 @@ void loadtrack(int iTrackIdx, int iPreviewMode) initpits(); } if (iTrackIdx_1 >= 0) { - readline2(&pCurrDataPtr, "i", &actualtrack);// Read actual track ID and validate against requested - if (iCompactedFlag && replaytype != 2 && iTrackIdx_1 != actualtrack && !bMinimalMode) { - ErrorBoxExit("Cheat!!!! Track %d is really track %d!!!\n", iTrackIdx_1, actualtrack); + readline2( + &pCurrDataPtr, "i", + &actualtrack); // Read actual track ID and validate against requested + if (iCompactedFlag && replaytype != 2 && iTrackIdx_1 != actualtrack && + !bMinimalMode) { + ErrorBoxExit("Cheat!!!! Track %d is really track %d!!!\n", iTrackIdx_1, + actualtrack); //__asm { int 10h; -VIDEO - SET VIDEO MODE } - //printf("Cheat!!!! Track %d is really track %d!!!\n", iTrackIdx_1, actualtrack); - //doexit(); + // printf("Cheat!!!! Track %d is really track %d!!!\n", iTrackIdx_1, + // actualtrack); doexit(); } - cur_laps[0] = 0; // Initialize lap counters + cur_laps[0] = 0; // Initialize lap counters if (!meof) { - readline2(&pCurrDataPtr, "iiiiii", cur_laps, &cur_laps[1], &cur_laps[2], &cur_laps[3], &cur_laps[4], &cur_laps[5]);// Read lap configuration and map settings + readline2(&pCurrDataPtr, "iiiiii", cur_laps, &cur_laps[1], &cur_laps[2], + &cur_laps[3], &cur_laps[4], + &cur_laps[5]); // Read lap configuration and map settings readline2(&pCurrDataPtr, "fif", &cur_mapsize, &cur_mapsect, &cur_TrackZ); } if (meof) { - iDifficulty = 0; // Use default values if EOF reached + iDifficulty = 0; // Use default values if EOF reached iTrackLapOffset = 6 * actualtrack; do { iLapValue = track_laps[0][iTrackLapOffset++]; cur_laps[iDifficulty] = iLapValue; ++iDifficulty; - //iLapValue = track_laps[0][iTrackLapOffset++]; - //*(_DWORD *)&samplemin[2 * iDifficulty + 498] = iLapValue;// offset into cur_laps + // iLapValue = track_laps[0][iTrackLapOffset++]; + //*(_DWORD *)&samplemin[2 * iDifficulty + 498] = iLapValue;// offset + // into cur_laps } while (iDifficulty < 6); cur_mapsize = mapsize[actualtrack]; dTrackZ = TrackZs[actualtrack]; @@ -939,7 +1006,7 @@ void loadtrack(int iTrackIdx, int iPreviewMode) } fclose(pFile_2); } - if (!bMinimalMode) { // Cleanup and load textures if not in minimal mode + if (!bMinimalMode) { // Cleanup and load textures if not in minimal mode if (pData) fre((void **)&pData); if (iTrackIdx_1 >= 0) { @@ -951,13 +1018,12 @@ void loadtrack(int iTrackIdx, int iPreviewMode) } //------------------------------------------------------------------------------------------------- -//0004D6C0 -void read_backs(uint8 **ppTrackData) -{ - int iBacksEnd; // ecx - int iFoundBacks; // esi - uint8 *pTrackData; // edi - int iTextureIndex; // [esp+0h] [ebp-1Ch] BYREF +// 0004D6C0 +void read_backs(uint8 **ppTrackData) { + int iBacksEnd; // ecx + int iFoundBacks; // esi + uint8 *pTrackData; // edi + int iTextureIndex; // [esp+0h] [ebp-1Ch] BYREF int iReplacementTexture; // [esp+4h] [ebp-18h] BYREF iBacksEnd = 0; @@ -974,107 +1040,120 @@ void read_backs(uint8 **ppTrackData) memgets(fp_buf, ppTrackData); if (pTrackData == *ppTrackData) return; - if (fp_buf[0] == 'B' && fp_buf[1] == 'A' && fp_buf[2] == 'C' && fp_buf[3] == 'K' && fp_buf[4] == 'S') + if (fp_buf[0] == 'B' && fp_buf[1] == 'A' && fp_buf[2] == 'C' && + fp_buf[3] == 'K' && fp_buf[4] == 'S') iFoundBacks = -1; } } while (!iBacksEnd); } //------------------------------------------------------------------------------------------------- -//0004D780 -void read_texturemap(uint8 **ppTrackData) -{ - char *pszBufPtr; // eax - char byCurrentChar; // dh +// 0004D780 +void read_texturemap(uint8 **ppTrackData) { + char *pszBufPtr; // eax + char byCurrentChar; // dh char *pszFilenamePtr; // eax - int iIndex; // edx - char byChar; // bl + int iIndex; // edx + char byChar; // bl do - memgets(fp_buf, ppTrackData); // Read lines from track data until we find a line starting with 'T' (texture map entry) + memgets(fp_buf, ppTrackData); // Read lines from track data until we find a + // line starting with 'T' (texture map entry) while (fp_buf[0] != 84); pszBufPtr = fp_buf; do - byCurrentChar = *++pszBufPtr; // Scan forward in the line to find the ':' separator + byCurrentChar = + *++pszBufPtr; // Scan forward in the line to find the ':' separator while (byCurrentChar != 58); - pszFilenamePtr = pszBufPtr + 1; // Start of filename is right after the ':' + pszFilenamePtr = pszBufPtr + 1; // Start of filename is right after the ':' iIndex = 0; do { - byChar = *pszFilenamePtr++; // Copy filename character by character + byChar = *pszFilenamePtr++; // Copy filename character by character texture_file[iIndex] = byChar; - if ((uint8)byChar >= 0x61u && (uint8)byChar <= 0x7Au)// Convert lowercase letters to uppercase (a-z -> A-Z) + if ((uint8)byChar >= 0x61u && + (uint8)byChar <= + 0x7Au) // Convert lowercase letters to uppercase (a-z -> A-Z) texture_file[iIndex] = byChar - 32; ++iIndex; } while (*pszFilenamePtr != 13 && *pszFilenamePtr != 10); - texture_file[iIndex] = 0; // Null-terminate the texture filename string + texture_file[iIndex] = 0; // Null-terminate the texture filename string } //------------------------------------------------------------------------------------------------- -//0004D7F0 -void read_bldmap(uint8 **ppTrackData) -{ +// 0004D7F0 +void read_bldmap(uint8 **ppTrackData) { uint8 *pbyOriginalTrackData; // ebp - int iFoundBLD; // ecx - uint8 *pbyPrevPos; // esi - uint8 *pbyBufPtr; // eax - char byCurrentChar; // dh - char *pszFilenamePtr; // eax - int iIndex; // edx - char byChar; // cl + int iFoundBLD; // ecx + uint8 *pbyPrevPos; // esi + uint8 *pbyBufPtr; // eax + char byCurrentChar; // dh + char *pszFilenamePtr; // eax + int iIndex; // edx + char byChar; // cl - pbyOriginalTrackData = *ppTrackData; // Save original track data pointer to restore later + pbyOriginalTrackData = + *ppTrackData; // Save original track data pointer to restore later iFoundBLD = 0; - *ppTrackData = start_f; // Reset track data pointer to start of file for searching + *ppTrackData = + start_f; // Reset track data pointer to start of file for searching do { pbyPrevPos = *ppTrackData; - memgets(fp_buf, ppTrackData); // Read next line from track data - if (pbyPrevPos == *ppTrackData) // Check if we reached end of file (pointer didn't advance) + memgets(fp_buf, ppTrackData); // Read next line from track data + if (pbyPrevPos == *ppTrackData) // Check if we reached end of file (pointer + // didn't advance) iFoundBLD = -1; - if (fp_buf[0] == 66 && fp_buf[1] == 76 && fp_buf[2] == 68)// Check if line starts with "BLD" (building map entry) + if (fp_buf[0] == 66 && fp_buf[1] == 76 && + fp_buf[2] == 68) // Check if line starts with "BLD" (building map entry) iFoundBLD = -1; } while (!iFoundBLD); - if (fp_buf[0] == 66 && fp_buf[1] == 76 && fp_buf[2] == 68)// Process the BLD line if found + if (fp_buf[0] == 66 && fp_buf[1] == 76 && + fp_buf[2] == 68) // Process the BLD line if found { pbyBufPtr = fp_buf; if (fp_buf[0] != 58) { do - byCurrentChar = *++pbyBufPtr; // Scan forward to find ':' separator + byCurrentChar = *++pbyBufPtr; // Scan forward to find ':' separator while (byCurrentChar != 58); } - pszFilenamePtr = (char *)(pbyBufPtr + 1); // Start of filename is right after the ':' + pszFilenamePtr = + (char *)(pbyBufPtr + 1); // Start of filename is right after the ':' iIndex = 0; do { - byChar = *pszFilenamePtr++; // Copy building texture filename character by character + byChar = *pszFilenamePtr++; // Copy building texture filename character by + // character bldtex_file[iIndex] = byChar; - if ((uint8)byChar >= 0x61u && (uint8)byChar <= 0x7Au)// Convert lowercase letters to uppercase (a-z -> A-Z) + if ((uint8)byChar >= 0x61u && + (uint8)byChar <= + 0x7Au) // Convert lowercase letters to uppercase (a-z -> A-Z) bldtex_file[iIndex] = byChar - 32; ++iIndex; } while (*pszFilenamePtr != 13 && *pszFilenamePtr != 10); - bldtex_file[iIndex] = 0; // Null-terminate the building texture filename + bldtex_file[iIndex] = 0; // Null-terminate the building texture filename } else { - strcpy((char *)fp_buf, "building.drh"); // Use default building texture if no BLD entry found + strcpy( + (char *)fp_buf, + "building.drh"); // Use default building texture if no BLD entry found } - *ppTrackData = pbyOriginalTrackData; // Restore original track data pointer + *ppTrackData = pbyOriginalTrackData; // Restore original track data pointer } //------------------------------------------------------------------------------------------------- -//0004D8D0 -void readstuntdata(uint8 **pTrackData) -{ - int *pStuntData; // edx - int *pDataItr; // edx - int iFlags; // [esp+0h] [ebp-3Ch] BYREF +// 0004D8D0 +void readstuntdata(uint8 **pTrackData) { + int *pStuntData; // edx + int *pDataItr; // edx + int iFlags; // [esp+0h] [ebp-3Ch] BYREF int iRampSideLength; // [esp+4h] [ebp-38h] BYREF - int iTimeFlat; // [esp+8h] [ebp-34h] BYREF - int iTimeBulging; // [esp+Ch] [ebp-30h] BYREF - int iTimingGroup; // [esp+10h] [ebp-2Ch] BYREF - int iHeight; // [esp+14h] [ebp-28h] BYREF - int iTickStartIdx; // [esp+18h] [ebp-24h] BYREF - int iNumTicks; // [esp+1Ch] [ebp-20h] BYREF - int iChunkCount; // [esp+20h] [ebp-1Ch] BYREF - int iGeometryIndex; // [esp+24h] [ebp-18h] BYREF + int iTimeFlat; // [esp+8h] [ebp-34h] BYREF + int iTimeBulging; // [esp+Ch] [ebp-30h] BYREF + int iTimingGroup; // [esp+10h] [ebp-2Ch] BYREF + int iHeight; // [esp+14h] [ebp-28h] BYREF + int iTickStartIdx; // [esp+18h] [ebp-24h] BYREF + int iNumTicks; // [esp+1Ch] [ebp-20h] BYREF + int iChunkCount; // [esp+20h] [ebp-1Ch] BYREF + int iGeometryIndex; // [esp+24h] [ebp-18h] BYREF - pStuntData = (int *)scrbuf; // tStuntData + pStuntData = (int *)scrbuf; // tStuntData totalramps = 0; // Free existing stunts at the beginning of scrbuf @@ -1084,18 +1163,9 @@ void readstuntdata(uint8 **pTrackData) do { readline2( - pTrackData, - "iiiiiiiiii", - &iGeometryIndex, - &iChunkCount, - &iNumTicks, - &iTickStartIdx, - &iTimingGroup, - &iHeight, - &iTimeBulging, - &iTimeFlat, - &iRampSideLength, - &iFlags); + pTrackData, "iiiiiiiiii", &iGeometryIndex, &iChunkCount, &iNumTicks, + &iTickStartIdx, &iTimingGroup, &iHeight, &iTimeBulging, &iTimeFlat, + &iRampSideLength, &iFlags); if (iGeometryIndex != -1) { pDataItr = pStuntData + 1; *(pDataItr++ - 1) = iGeometryIndex; @@ -1117,32 +1187,31 @@ void readstuntdata(uint8 **pTrackData) } //------------------------------------------------------------------------------------------------- -//0004D9B0 -void activatestunts() -{ - uint8 *pScrBuf; // esi - int iRampIdx; // ebp - int iGeometryIdx; // edi - int iChunkCount_1; // eax - int *pBufItr; // esi - int iNumTicks_1; // eax - int iTickStartIdx_1; // eax - int iTimingGroup_1; // eax - int iHeight_1; // eax - int iTimeBulging_1; // eax - int iTimeFlat_1; // eax +// 0004D9B0 +void activatestunts() { + uint8 *pScrBuf; // esi + int iRampIdx; // ebp + int iGeometryIdx; // edi + int iChunkCount_1; // eax + int *pBufItr; // esi + int iNumTicks_1; // eax + int iTickStartIdx_1; // eax + int iTimingGroup_1; // eax + int iHeight_1; // eax + int iTimeBulging_1; // eax + int iTimeFlat_1; // eax int iRampSideLength_1; // eax - int iFlags; // eax - tStuntData *pRampBuf; // eax - int iNewTotalRamps; // edx - int iTimeFlat; // [esp+0h] [ebp-3Ch] - int iTimeBulging; // [esp+4h] [ebp-38h] - int iRampSideLength; // [esp+Ch] [ebp-30h] - int iTickStartIdx; // [esp+10h] [ebp-2Ch] - int iNumTicks; // [esp+14h] [ebp-28h] - int iChunkCount; // [esp+18h] [ebp-24h] - int iTimingGroup; // [esp+1Ch] [ebp-20h] - int iHeight; // [esp+20h] [ebp-1Ch] + int iFlags; // eax + tStuntData *pRampBuf; // eax + int iNewTotalRamps; // edx + int iTimeFlat; // [esp+0h] [ebp-3Ch] + int iTimeBulging; // [esp+4h] [ebp-38h] + int iRampSideLength; // [esp+Ch] [ebp-30h] + int iTickStartIdx; // [esp+10h] [ebp-2Ch] + int iNumTicks; // [esp+14h] [ebp-28h] + int iChunkCount; // [esp+18h] [ebp-24h] + int iTimingGroup; // [esp+1Ch] [ebp-20h] + int iHeight; // [esp+20h] [ebp-1Ch] pScrBuf = scrbuf; iRampIdx = 0; @@ -1172,7 +1241,9 @@ void activatestunts() iRampSideLength = iRampSideLength_1; iFlags = *pBufItr; pScrBuf = (uint8 *)(pBufItr + 1); - pRampBuf = initramp(iGeometryIdx, iChunkCount, iNumTicks, iTickStartIdx, iTimingGroup, iHeight, iTimeBulging, iTimeFlat, iRampSideLength, iFlags); + pRampBuf = initramp(iGeometryIdx, iChunkCount, iNumTicks, iTickStartIdx, + iTimingGroup, iHeight, iTimeBulging, iTimeFlat, + iRampSideLength, iFlags); iNewTotalRamps = totalramps + 1; ramp[iRampIdx] = pRampBuf; totalramps = iNewTotalRamps; @@ -1182,11 +1253,10 @@ void activatestunts() } //------------------------------------------------------------------------------------------------- -//0004DA90 -void ReadAnimData(FILE *pFile, uint8 **ppFileData) -{ +// 0004DA90 +void ReadAnimData(FILE *pFile, uint8 **ppFileData) { int iSignType; // [esp+0h] [ebp-14h] BYREF - int iSignTex; // [esp+4h] [ebp-10h] BYREF + int iSignTex; // [esp+4h] [ebp-10h] BYREF iSignType = 0; iSignTex = 0; @@ -1197,16 +1267,16 @@ void ReadAnimData(FILE *pFile, uint8 **ppFileData) advert_list[(int16)iSignType] = iSignTex; } else if ((int16)iSignType < -1) { advert_list[-iSignType - 1] = 0; - //VisibleBuildings_variable_1[-(__int16)iSignType] = 0;// offset into advert_list + // VisibleBuildings_variable_1[-(__int16)iSignType] = 0;// offset into + // advert_list } } while ((iSignTex & 0x8000u) == 0); } } //------------------------------------------------------------------------------------------------- -//0004DB00 -void readline(FILE *pFile, const char *szFmt, ...) -{ +// 0004DB00 +void readline(FILE *pFile, const char *szFmt, ...) { char szBuffer[0x200]; char *szTok; va_list args; @@ -1224,7 +1294,8 @@ void readline(FILE *pFile, const char *szFmt, ...) } szTok = strtok(szBuffer, szDelims); - if (!szTok) continue; + if (!szTok) + continue; if (strncmp(szTok, "//", 2) == 0 || strchr(szTok, ';') == szTok) { continue; @@ -1239,70 +1310,60 @@ void readline(FILE *pFile, const char *szFmt, ...) void *pDst = va_arg(args, void *); switch (*szFmtPtr) { - case 'D': - { // double scaled - double val = strtod(szCurrTok, NULL) * dScale; - *(double *)pDst = val; - break; - } - case 'F': - { // float scaled - float val = (float)(strtod(szCurrTok, NULL) * dScale); - *(float *)pDst = val; - break; - } - case 'I': - { // int shifted - int val = strtol(szCurrTok, NULL, 10) << 8; - *(int *)pDst = val; - break; - } - case 'S': - { // short shifted - short val = (short)(strtol(szCurrTok, NULL, 10) << 8); - *(short *)pDst = val; - break; - } - case 'd': - { - *(double *)pDst = strtod(szCurrTok, NULL); - break; - } - case 'f': - { - *(float *)pDst = (float)strtod(szCurrTok, NULL); - break; - } - case 'i': - { - *(int *)pDst = strtol(szCurrTok, NULL, 10); - break; - } - case 's': - { - *(short *)pDst = (short)strtol(szCurrTok, NULL, 10); - break; - } - case 'u': - { - *(uint8*)pDst = (uint8)strtol(szCurrTok, NULL, 10); - break; - } - case 'C': - case 'c': - { - char *szDest = (char *)pDst; - const char *szSrc = szCurrTok; - // Custom wide copy: 2 bytes per char - while (*szSrc) { - *szDest++ = *szSrc++; - if (!*szSrc) - break; - *szDest++ = *szSrc++; - } - *szDest = '\0'; - break; + case 'D': { // double scaled + double val = strtod(szCurrTok, NULL) * dScale; + *(double *)pDst = val; + break; + } + case 'F': { // float scaled + float val = (float)(strtod(szCurrTok, NULL) * dScale); + *(float *)pDst = val; + break; + } + case 'I': { // int shifted + int val = strtol(szCurrTok, NULL, 10) << 8; + *(int *)pDst = val; + break; + } + case 'S': { // short shifted + short val = (short)(strtol(szCurrTok, NULL, 10) << 8); + *(short *)pDst = val; + break; + } + case 'd': { + *(double *)pDst = strtod(szCurrTok, NULL); + break; + } + case 'f': { + *(float *)pDst = (float)strtod(szCurrTok, NULL); + break; + } + case 'i': { + *(int *)pDst = strtol(szCurrTok, NULL, 10); + break; + } + case 's': { + *(short *)pDst = (short)strtol(szCurrTok, NULL, 10); + break; + } + case 'u': { + *(uint8 *)pDst = (uint8)strtol(szCurrTok, NULL, 10); + break; + } + case 'C': + case 'c': { + char *szDest = (char *)pDst; + const char *szSrc = szCurrTok; + // Custom wide copy: 2 bytes per char + while (*szSrc) { + *szDest++ = *szSrc++; + if (!*szSrc) + break; + *szDest++ = *szSrc++; } + *szDest = '\0'; + break; + } } szFmtPtr++; @@ -1314,12 +1375,11 @@ void readline(FILE *pFile, const char *szFmt, ...) } //------------------------------------------------------------------------------------------------- -//0004DDF0 -uint8 *memgets(uint8 *pDst, uint8 **ppSrc) -{ - int iEof; // esi - uint8 *pDst2; // eax - uint8 byte; // bl +// 0004DDF0 +uint8 *memgets(uint8 *pDst, uint8 **ppSrc) { + int iEof; // esi + uint8 *pDst2; // eax + uint8 byte; // bl uint8 *ppSrcNext; // ebx iEof = 0; @@ -1340,9 +1400,8 @@ uint8 *memgets(uint8 *pDst, uint8 **ppSrc) } //------------------------------------------------------------------------------------------------- -//0004DE30 -void readline2(uint8 **ppFileData, const char *pszFormat, ...) -{ +// 0004DE30 +void readline2(uint8 **ppFileData, const char *pszFormat, ...) { char szLineBuffer[512]; va_list va; va_list vaCopy; @@ -1353,111 +1412,112 @@ void readline2(uint8 **ppFileData, const char *pszFormat, ...) va_copy(vaCopy, va); while (1) { - // Read next line from file into buffer + // Read next line from file into buffer memgets((uint8 *)szLineBuffer, ppFileData); // Check for end of file if (meof) break; - // Tokenize line using delimiters (whitespace) + // Tokenize line using delimiters (whitespace) pszToken = strtok(szLineBuffer, delims); // Skip C++ style comments (//) if (pszToken && strstr(pszToken, "//") == pszToken) pszToken = NULL; - // Skip lines starting with semicolon + // Skip lines starting with semicolon if (pszToken && strstr(pszToken, ";") == pszToken) pszToken = NULL; - // Skip newlines and carriage returns + // Skip newlines and carriage returns if (szLineBuffer[0] == '\n' || szLineBuffer[0] == '\r') pszToken = NULL; if (pszToken) { - // Process each format specifier in the format string - for (uiFormatIndex = 0; uiFormatIndex < strlen(pszFormat); ++uiFormatIndex) { + // Process each format specifier in the format string + for (uiFormatIndex = 0; uiFormatIndex < strlen(pszFormat); + ++uiFormatIndex) { switch (pszFormat[uiFormatIndex]) { - case 'D': // double scaled by 256 - { - double *pdblDest = va_arg(vaCopy, double *); - double dblValue = strtod(pszToken, NULL); - *pdblDest = dblValue * 256.0; - break; - } + case 'D': // double scaled by 256 + { + double *pdblDest = va_arg(vaCopy, double *); + double dblValue = strtod(pszToken, NULL); + *pdblDest = dblValue * 256.0; + break; + } - case 'F': // float scaled by 256 - { - float *pfDest = va_arg(vaCopy, float *); - double dblFloatValue = strtod(pszToken, NULL); - *pfDest = (float)(dblFloatValue * 256.0); - break; - } + case 'F': // float scaled by 256 + { + float *pfDest = va_arg(vaCopy, float *); + double dblFloatValue = strtod(pszToken, NULL); + *pfDest = (float)(dblFloatValue * 256.0); + break; + } - case 'I': // 32-bit integer shifted left by 8 - { - uint32 *puiDest = va_arg(vaCopy, uint32 *); - int32 iIntValue = strtol(pszToken, NULL, 10); - *puiDest = iIntValue << 8; - break; - } + case 'I': // 32-bit integer shifted left by 8 + { + uint32 *puiDest = va_arg(vaCopy, uint32 *); + int32 iIntValue = strtol(pszToken, NULL, 10); + *puiDest = iIntValue << 8; + break; + } - case 'S': // 16-bit short shifted left by 8 - { - int16 *pnDest = va_arg(vaCopy, int16 *); - int16 nShortValue = (int16)strtol(pszToken, NULL, 10); - *pnDest = nShortValue << 8; - break; - } + case 'S': // 16-bit short shifted left by 8 + { + int16 *pnDest = va_arg(vaCopy, int16 *); + int16 nShortValue = (int16)strtol(pszToken, NULL, 10); + *pnDest = nShortValue << 8; + break; + } - case 'd': // double (no scaling) - { - double *pdblDest = va_arg(vaCopy, double *); - double dblPlainValue = strtod(pszToken, NULL); - *pdblDest = dblPlainValue; - break; - } + case 'd': // double (no scaling) + { + double *pdblDest = va_arg(vaCopy, double *); + double dblPlainValue = strtod(pszToken, NULL); + *pdblDest = dblPlainValue; + break; + } - case 'f': // float (no scaling) - { - float *pfDest = va_arg(vaCopy, float *); - double fltPlainValue = strtod(pszToken, NULL); - *pfDest = (float)fltPlainValue; - break; - } + case 'f': // float (no scaling) + { + float *pfDest = va_arg(vaCopy, float *); + double fltPlainValue = strtod(pszToken, NULL); + *pfDest = (float)fltPlainValue; + break; + } - case 'i': // 32-bit integer (no shifting) - { - int32 *piDest = va_arg(vaCopy, int32 *); - int32 iPlainValue = strtol(pszToken, NULL, 10); - *piDest = iPlainValue; - break; - } + case 'i': // 32-bit integer (no shifting) + { + int32 *piDest = va_arg(vaCopy, int32 *); + int32 iPlainValue = strtol(pszToken, NULL, 10); + *piDest = iPlainValue; + break; + } - case 's': // 16-bit short (no shifting) - { - int16 *pnDest = va_arg(vaCopy, int16 *); - int16 nPlainValue = (int16)strtol(pszToken, NULL, 10); - *pnDest = nPlainValue; - break; - } + case 's': // 16-bit short (no shifting) + { + int16 *pnDest = va_arg(vaCopy, int16 *); + int16 nPlainValue = (int16)strtol(pszToken, NULL, 10); + *pnDest = nPlainValue; + break; + } - case 'C': // copy string (uppercase) - case 'c': // copy string (lowercase) - { - char *pszDestStr = va_arg(vaCopy, char *); - strcpy(pszDestStr, pszToken); - break; - } + case 'C': // copy string (uppercase) + case 'c': // copy string (lowercase) + { + char *pszDestStr = va_arg(vaCopy, char *); + strcpy(pszDestStr, pszToken); + break; + } - case 'u': // unsigned byte - { - uint8 *pbyDest = va_arg(vaCopy, uint8 *); - uint8 byByteValue = (uint8)strtol(pszToken, NULL, 10); - *pbyDest = byByteValue; - break; - } + case 'u': // unsigned byte + { + uint8 *pbyDest = va_arg(vaCopy, uint8 *); + uint8 byByteValue = (uint8)strtol(pszToken, NULL, 10); + *pbyDest = byByteValue; + break; + } } // Get next token from the line @@ -1477,56 +1537,64 @@ void readline2(uint8 **ppFileData, const char *pszFormat, ...) } //------------------------------------------------------------------------------------------------- -//0004E190 -void rotatepoint(double dX, double dY, double dZ, double dYaw, double dPitch, double dRoll, double *pdOutX, double *pdOutY, double *pdOutZ) -{ - long double dblCosX; // st7 - long double dblSinY; // st6 - long double dblSinZ; // st5 - double dblSinX; // [esp+8h] [ebp-28h] - long double dblCosZ; // [esp+10h] [ebp-20h] - double dblCosY; // [esp+18h] [ebp-18h] - long double dYawRad; // [esp+4Ch] [ebp+1Ch] +// 0004E190 +void rotatepoint(double dX, double dY, double dZ, double dYaw, double dPitch, + double dRoll, double *pdOutX, double *pdOutY, double *pdOutZ) { + long double dblCosX; // st7 + long double dblSinY; // st6 + long double dblSinZ; // st5 + double dblSinX; // [esp+8h] [ebp-28h] + long double dblCosZ; // [esp+10h] [ebp-20h] + double dblCosY; // [esp+18h] [ebp-18h] + long double dYawRad; // [esp+4Ch] [ebp+1Ch] long double dPitchRad; // [esp+54h] [ebp+24h] - long double dRollRad; // [esp+5Ch] [ebp+2Ch] + long double dRollRad; // [esp+5Ch] [ebp+2Ch] - dYawRad = dYaw * 0.0174532925199; // Convert X angle from degrees to radians (PI/180 = 0.0174532925199) - dPitchRad = dPitch * 0.0174532925199; // Convert Y angle from degrees to radians - dRollRad = dRoll * 0.0174532925199; // Convert Z angle from degrees to radians - dblCosX = cos(dYawRad); // Calculate cos(X angle) - dblSinY = sin(dPitchRad); // Calculate sin(Y angle) - dblSinZ = sin(dRollRad); // Calculate sin(Z angle) - dblSinX = sin(dYawRad); // Calculate sin(X angle) - dblCosZ = cos(dRollRad); // Calculate cos(Z angle) - dblCosY = cos(dPitchRad); // Calculate cos(Y angle) - *pdOutX = (dblCosX * dblSinY * dblSinZ - dblSinX * dblCosZ) * dY + dX * dblCosX * dblCosY + (-dblCosX * dblSinY * dblCosZ - dblSinX * dblSinZ) * dZ;// Apply 3D rotation matrix to calculate new X coordinate - *pdOutY = (dblSinX * dblSinY * dblSinZ + dblCosX * dblCosZ) * dY + dX * dblSinX * dblCosY + (-dblSinX * dblSinY * dblCosZ + dblCosX * dblSinZ) * dZ;// Apply 3D rotation matrix to calculate new Y coordinate - *pdOutZ = dblSinY * dX + dblSinZ * (-dblCosY * dY) + dZ * dblCosY * dblCosZ;// Apply 3D rotation matrix to calculate new Z coordinate + dYawRad = dYaw * 0.0174532925199; // Convert X angle from degrees to radians + // (PI/180 = 0.0174532925199) + dPitchRad = + dPitch * 0.0174532925199; // Convert Y angle from degrees to radians + dRollRad = dRoll * 0.0174532925199; // Convert Z angle from degrees to radians + dblCosX = cos(dYawRad); // Calculate cos(X angle) + dblSinY = sin(dPitchRad); // Calculate sin(Y angle) + dblSinZ = sin(dRollRad); // Calculate sin(Z angle) + dblSinX = sin(dYawRad); // Calculate sin(X angle) + dblCosZ = cos(dRollRad); // Calculate cos(Z angle) + dblCosY = cos(dPitchRad); // Calculate cos(Y angle) + *pdOutX = (dblCosX * dblSinY * dblSinZ - dblSinX * dblCosZ) * dY + + dX * dblCosX * dblCosY + + (-dblCosX * dblSinY * dblCosZ - dblSinX * dblSinZ) * + dZ; // Apply 3D rotation matrix to calculate new X coordinate + *pdOutY = (dblSinX * dblSinY * dblSinZ + dblCosX * dblCosZ) * dY + + dX * dblSinX * dblCosY + + (-dblSinX * dblSinY * dblCosZ + dblCosX * dblSinZ) * + dZ; // Apply 3D rotation matrix to calculate new Y coordinate + *pdOutZ = + dblSinY * dX + dblSinZ * (-dblCosY * dY) + + dZ * dblCosY * + dblCosZ; // Apply 3D rotation matrix to calculate new Z coordinate } //------------------------------------------------------------------------------------------------- -//0004E2D0 -void setpoint(int iChunkIdx, int iPointIdx, double dX, double dY, double dZ) -{ +// 0004E2D0 +void setpoint(int iChunkIdx, int iPointIdx, double dX, double dY, double dZ) { TrakPt[iChunkIdx].pointAy[iPointIdx].fX = (float)dX; TrakPt[iChunkIdx].pointAy[iPointIdx].fY = (float)dY; TrakPt[iChunkIdx].pointAy[iPointIdx].fZ = (float)dZ; } //------------------------------------------------------------------------------------------------- -//0004E320 -void setgpoint(int iChunkIdx, int iPointIdx, double dX, double dY, double dZ) -{ +// 0004E320 +void setgpoint(int iChunkIdx, int iPointIdx, double dX, double dY, double dZ) { GroundPt[iChunkIdx].pointAy[iPointIdx].fX = (float)dX; GroundPt[iChunkIdx].pointAy[iPointIdx].fY = (float)dY; GroundPt[iChunkIdx].pointAy[iPointIdx].fZ = (float)dZ; } //------------------------------------------------------------------------------------------------- -//0004E370 -void resetcars() -{ - int iCarIdx; // esi +// 0004E370 +void resetcars() { + int iCarIdx; // esi tCar *pCurrCar; // ecx iCarIdx = 0; @@ -1541,27 +1609,27 @@ void resetcars() } //------------------------------------------------------------------------------------------------- -//0004E3B0 -void min_skip_stuff(uint8 **ppFileData) -{ +// 0004E3B0 +void min_skip_stuff(uint8 **ppFileData) { char szBuf[256]; // [esp-100h] [ebp-130h] BYREF - int iData9; // [esp+0h] [ebp-30h] BYREF - int iData8; // [esp+4h] [ebp-2Ch] BYREF - int iData7; // [esp+8h] [ebp-28h] BYREF - int iData6; // [esp+Ch] [ebp-24h] BYREF - int iData5; // [esp+10h] [ebp-20h] BYREF - int iData4; // [esp+14h] [ebp-1Ch] BYREF - int iData3; // [esp+18h] [ebp-18h] BYREF - int iData2; // [esp+1Ch] [ebp-14h] BYREF - int iData1; // [esp+20h] [ebp-10h] BYREF - int iData0; // [esp+24h] [ebp-Ch] BYREF + int iData9; // [esp+0h] [ebp-30h] BYREF + int iData8; // [esp+4h] [ebp-2Ch] BYREF + int iData7; // [esp+8h] [ebp-28h] BYREF + int iData6; // [esp+Ch] [ebp-24h] BYREF + int iData5; // [esp+10h] [ebp-20h] BYREF + int iData4; // [esp+14h] [ebp-1Ch] BYREF + int iData3; // [esp+18h] [ebp-18h] BYREF + int iData2; // [esp+1Ch] [ebp-14h] BYREF + int iData1; // [esp+20h] [ebp-10h] BYREF + int iData0; // [esp+24h] [ebp-Ch] BYREF do { do readline2(ppFileData, "ii", &iData0, &iData1); while (iData0 != -1); } while (iData1 != -1); do - readline2(ppFileData, "iiiiiiiiii", &iData0, &iData1, &iData2, &iData3, &iData4, &iData5, &iData6, &iData7, &iData8, &iData9); + readline2(ppFileData, "iiiiiiiiii", &iData0, &iData1, &iData2, &iData3, + &iData4, &iData5, &iData6, &iData7, &iData8, &iData9); while (iData0 != -1); do readline2(ppFileData, "c", szBuf); diff --git a/PROJECTS/ROLLER/loadtrak.h b/PROJECTS/ROLLER/loadtrak.h index 02745678..852e7418 100644 --- a/PROJECTS/ROLLER/loadtrak.h +++ b/PROJECTS/ROLLER/loadtrak.h @@ -5,8 +5,7 @@ #include //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int16 nForwardExtraStart; uint8 byForwardMainChunks; uint8 byForwardExtraChunks; @@ -17,8 +16,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fLShoulderWidth; float fLShoulderHeight; float fRShoulderWidth; @@ -32,15 +30,13 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { char subdivides[11]; } tSubdivide; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fBaseGrip; int iGripModifier; float fGripMultiplier; @@ -83,7 +79,8 @@ void ReadAnimData(FILE *pFile, uint8 **ppFileData); void readline(FILE *pFile, const char *szFmt, ...); uint8 *memgets(uint8 *pDst, uint8 **ppSrc); void readline2(uint8 **ppFileData, const char *pszFormat, ...); -void rotatepoint(double dX, double dY, double dZ, double dYaw, double dPitch, double dRoll, double *pdOutX, double *pdOutY, double *pdOutZ); +void rotatepoint(double dX, double dY, double dZ, double dYaw, double dPitch, + double dRoll, double *pdOutX, double *pdOutY, double *pdOutZ); void setpoint(int iChunkIdx, int iPointIdx, double dX, double dY, double dZ); void setgpoint(int iChunkIdx, int iPointIdx, double dX, double dY, double dZ); void resetcars(); diff --git a/PROJECTS/ROLLER/menu_render.c b/PROJECTS/ROLLER/menu_render.c index 0cfa4f9c..ec749453 100644 --- a/PROJECTS/ROLLER/menu_render.c +++ b/PROJECTS/ROLLER/menu_render.c @@ -7,165 +7,178 @@ #include struct MenuRenderer { - MenuRenderMode mode; - MenuRenderMode pendingMode; - MenuRendererGPU *gpu; - MenuRendererSoftware *sw; - SDL_GPUDevice *device; - SDL_Window *window; + MenuRenderMode mode; + MenuRenderMode pendingMode; + MenuRendererGPU *gpu; + MenuRendererSoftware *sw; + SDL_GPUDevice *device; + SDL_Window *window; }; MenuRenderer *menu_render_create(SDL_GPUDevice *device, SDL_Window *window) { - MenuRenderer *r = calloc(1, sizeof(MenuRenderer)); - r->device = device; - r->window = window; - r->sw = menu_render_sw_create(device, window); - if (device && window) { - r->gpu = menu_render_gpu_create(device, window); - } - r->mode = MENU_RENDER_SOFTWARE; - r->pendingMode = MENU_RENDER_SOFTWARE; - return r; + MenuRenderer *r = calloc(1, sizeof(MenuRenderer)); + r->device = device; + r->window = window; + r->sw = menu_render_sw_create(device, window); + if (device && window) { + r->gpu = menu_render_gpu_create(device, window); + } + r->mode = MENU_RENDER_SOFTWARE; + r->pendingMode = MENU_RENDER_SOFTWARE; + return r; } void menu_render_destroy(MenuRenderer *renderer) { - if (!renderer) return; - if (renderer->gpu) - menu_render_gpu_destroy(renderer->gpu); - menu_render_sw_destroy(renderer->sw); - free(renderer); + if (!renderer) + return; + if (renderer->gpu) + menu_render_gpu_destroy(renderer->gpu); + menu_render_sw_destroy(renderer->sw); + free(renderer); } void menu_render_set_mode(MenuRenderer *renderer, MenuRenderMode mode) { - if (!renderer) return; - if (mode == MENU_RENDER_GPU && !renderer->gpu) - mode = MENU_RENDER_SOFTWARE; - renderer->pendingMode = mode; + if (!renderer) + return; + if (mode == MENU_RENDER_GPU && !renderer->gpu) + mode = MENU_RENDER_SOFTWARE; + renderer->pendingMode = mode; } MenuRenderMode menu_render_get_mode(MenuRenderer *renderer) { - if (!renderer) return MENU_RENDER_SOFTWARE; - return renderer->mode; + if (!renderer) + return MENU_RENDER_SOFTWARE; + return renderer->mode; } int menu_render_load_blocks(MenuRenderer *renderer, int slot, tBlockHeader *blocks, const tColor *palette) { - if (!renderer) return 1; - menu_render_sw_load_blocks(renderer->sw, slot, blocks, palette); - if (renderer->gpu) - return menu_render_gpu_load_blocks(renderer->gpu, slot, blocks, palette); - return 0; + if (!renderer) + return 1; + menu_render_sw_load_blocks(renderer->sw, slot, blocks, palette); + if (renderer->gpu) + return menu_render_gpu_load_blocks(renderer->gpu, slot, blocks, palette); + return 0; } void menu_render_free_blocks(MenuRenderer *renderer, int slot) { - if (!renderer) return; - if (renderer->gpu) - menu_render_gpu_free_blocks(renderer->gpu, slot); - menu_render_sw_free_blocks(renderer->sw, slot); + if (!renderer) + return; + if (renderer->gpu) + menu_render_gpu_free_blocks(renderer->gpu, slot); + menu_render_sw_free_blocks(renderer->sw, slot); } void menu_render_begin_frame(MenuRenderer *renderer) { - if (!renderer) return; - if (renderer->pendingMode == MENU_RENDER_GPU && !renderer->gpu) - renderer->pendingMode = MENU_RENDER_SOFTWARE; - - if (renderer->pendingMode != renderer->mode) { - if (renderer->pendingMode == MENU_RENDER_SOFTWARE) { - // GPU fade doesn't update pal_addr; restore from base palette - for (int i = 0; i < 256; i++) - pal_addr[i] = palette[i]; - } - renderer->mode = renderer->pendingMode; + if (!renderer) + return; + if (renderer->pendingMode == MENU_RENDER_GPU && !renderer->gpu) + renderer->pendingMode = MENU_RENDER_SOFTWARE; + + if (renderer->pendingMode != renderer->mode) { + if (renderer->pendingMode == MENU_RENDER_SOFTWARE) { + // GPU fade doesn't update pal_addr; restore from base palette + for (int i = 0; i < 256; i++) + pal_addr[i] = palette[i]; } + renderer->mode = renderer->pendingMode; + } - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_begin_frame(renderer->gpu); - else - menu_render_sw_begin_frame(renderer->sw); + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_begin_frame(renderer->gpu); + else + menu_render_sw_begin_frame(renderer->sw); } void menu_render_end_frame(MenuRenderer *renderer) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_end_frame(renderer->gpu); - else - menu_render_sw_end_frame(renderer->sw); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_end_frame(renderer->gpu); + else + menu_render_sw_end_frame(renderer->sw); } void menu_render_set_layer(MenuRenderer *renderer, MenuDrawLayer layer) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_set_layer(renderer->gpu, layer); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_set_layer(renderer->gpu, layer); } void menu_render_clear(MenuRenderer *renderer, uint8 colorIndex, const tColor *palette) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_clear(renderer->gpu, colorIndex, palette); - else - menu_render_sw_clear(renderer->sw, colorIndex, palette); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_clear(renderer->gpu, colorIndex, palette); + else + menu_render_sw_clear(renderer->sw, colorIndex, palette); } void menu_render_background(MenuRenderer *renderer, int slot) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_background(renderer->gpu, slot); - else - menu_render_sw_background(renderer->sw, slot); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_background(renderer->gpu, slot); + else + menu_render_sw_background(renderer->sw, slot); } -void menu_render_sprite(MenuRenderer *renderer, int slot, int blockIdx, - int x, int y, int transparentColorIndex, +void menu_render_sprite(MenuRenderer *renderer, int slot, int blockIdx, int x, + int y, int transparentColorIndex, const tColor *palette) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_sprite(renderer->gpu, slot, blockIdx, x, y, - transparentColorIndex, palette); - else - menu_render_sw_sprite(renderer->sw, slot, blockIdx, x, y, - transparentColorIndex, palette); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_sprite(renderer->gpu, slot, blockIdx, x, y, + transparentColorIndex, palette); + else + menu_render_sw_sprite(renderer->sw, slot, blockIdx, x, y, + transparentColorIndex, palette); } void menu_render_begin_fade(MenuRenderer *renderer, int direction, int durationFrames) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_begin_fade(renderer->gpu, direction, durationFrames); - else - menu_render_sw_begin_fade(renderer->sw, direction, durationFrames); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_begin_fade(renderer->gpu, direction, durationFrames); + else + menu_render_sw_begin_fade(renderer->sw, direction, durationFrames); } int menu_render_fade_active(MenuRenderer *renderer) { - if (!renderer) return 0; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - return menu_render_gpu_fade_active(renderer->gpu); - else - return menu_render_sw_fade_active(renderer->sw); + if (!renderer) + return 0; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + return menu_render_gpu_fade_active(renderer->gpu); + else + return menu_render_sw_fade_active(renderer->sw); } -void menu_render_fade_wait(MenuRenderer *renderer, - void (*redraw_fn)(void *ctx), void *ctx) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_fade_wait(renderer->gpu, redraw_fn, ctx); - else - menu_render_sw_fade_wait(renderer->sw, redraw_fn, ctx); +void menu_render_fade_wait(MenuRenderer *renderer, void (*redraw_fn)(void *ctx), + void *ctx) { + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_fade_wait(renderer->gpu, redraw_fn, ctx); + else + menu_render_sw_fade_wait(renderer->sw, redraw_fn, ctx); } void menu_render_text(MenuRenderer *renderer, int fontSlot, const char *text, - const char *mappingTable, int *charVOffsets, - int x, int y, uint8 colorReplace, int alignment, + const char *mappingTable, int *charVOffsets, int x, int y, + uint8 colorReplace, int alignment, const tColor *palette) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_text(renderer->gpu, fontSlot, text, mappingTable, - charVOffsets, x, y, colorReplace, alignment, - palette); - else - menu_render_sw_text(renderer->sw, fontSlot, text, mappingTable, - charVOffsets, x, y, colorReplace, alignment, - palette); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_text(renderer->gpu, fontSlot, text, mappingTable, + charVOffsets, x, y, colorReplace, alignment, palette); + else + menu_render_sw_text(renderer->sw, fontSlot, text, mappingTable, + charVOffsets, x, y, colorReplace, alignment, palette); } void menu_render_scaled_text(MenuRenderer *renderer, int fontSlot, @@ -174,66 +187,74 @@ void menu_render_scaled_text(MenuRenderer *renderer, int fontSlot, uint8 colorReplace, unsigned int alignment, int clipLeft, int clipRight, const tColor *palette) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_scaled_text(renderer->gpu, fontSlot, text, mappingTable, - charVOffsets, x, y, colorReplace, alignment, - clipLeft, clipRight, palette); - else - menu_render_sw_scaled_text(renderer->sw, fontSlot, text, mappingTable, - charVOffsets, x, y, colorReplace, alignment, - clipLeft, clipRight, palette); + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_scaled_text(renderer->gpu, fontSlot, text, mappingTable, + charVOffsets, x, y, colorReplace, alignment, + clipLeft, clipRight, palette); + else + menu_render_sw_scaled_text(renderer->sw, fontSlot, text, mappingTable, + charVOffsets, x, y, colorReplace, alignment, + clipLeft, clipRight, palette); } void menu_render_load_car_mesh(MenuRenderer *renderer, int carIdx, const tColor *palette) { - if (!renderer) return; - if (renderer->gpu) - menu_render_gpu_load_car_mesh(renderer->gpu, carIdx, palette); - menu_render_sw_load_car_mesh(renderer->sw, carIdx, palette); + if (!renderer) + return; + if (renderer->gpu) + menu_render_gpu_load_car_mesh(renderer->gpu, carIdx, palette); + menu_render_sw_load_car_mesh(renderer->sw, carIdx, palette); } void menu_render_free_car_mesh(MenuRenderer *renderer) { - if (!renderer) return; - if (renderer->gpu) - menu_render_gpu_free_car_mesh(renderer->gpu); - menu_render_sw_free_car_mesh(renderer->sw); + if (!renderer) + return; + if (renderer->gpu) + menu_render_gpu_free_car_mesh(renderer->gpu); + menu_render_sw_free_car_mesh(renderer->sw); } void menu_render_draw_car_preview(MenuRenderer *renderer, float angle, - float distance, int carYaw, - int destX, int destY, int destW, int destH) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_draw_car_preview(renderer->gpu, angle, distance, carYaw, - destX, destY, destW, destH); - else - menu_render_sw_draw_car_preview(renderer->sw, angle, distance, carYaw, - destX, destY, destW, destH); + float distance, int carYaw, int destX, + int destY, int destW, int destH) { + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_draw_car_preview(renderer->gpu, angle, distance, carYaw, + destX, destY, destW, destH); + else + menu_render_sw_draw_car_preview(renderer->sw, angle, distance, carYaw, + destX, destY, destW, destH); } -void menu_render_load_track_mesh(MenuRenderer *renderer, const tColor *palette) { - if (!renderer) return; - if (renderer->gpu) - menu_render_gpu_load_track_mesh(renderer->gpu, palette); - menu_render_sw_load_track_mesh(renderer->sw, palette); +void menu_render_load_track_mesh(MenuRenderer *renderer, + const tColor *palette) { + if (!renderer) + return; + if (renderer->gpu) + menu_render_gpu_load_track_mesh(renderer->gpu, palette); + menu_render_sw_load_track_mesh(renderer->sw, palette); } void menu_render_free_track_mesh(MenuRenderer *renderer) { - if (!renderer) return; - if (renderer->gpu) - menu_render_gpu_free_track_mesh(renderer->gpu); - menu_render_sw_free_track_mesh(renderer->sw); + if (!renderer) + return; + if (renderer->gpu) + menu_render_gpu_free_track_mesh(renderer->gpu); + menu_render_sw_free_track_mesh(renderer->sw); } void menu_render_draw_track_preview(MenuRenderer *renderer, float cameraZ, - int elevation, int yaw, - int destX, int destY, int destW, int destH) { - if (!renderer) return; - if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) - menu_render_gpu_draw_track_preview(renderer->gpu, cameraZ, elevation, yaw, - destX, destY, destW, destH); - else - menu_render_sw_draw_track_preview(renderer->sw, cameraZ, elevation, yaw, - destX, destY, destW, destH); + int elevation, int yaw, int destX, + int destY, int destW, int destH) { + if (!renderer) + return; + if (renderer->mode == MENU_RENDER_GPU && renderer->gpu) + menu_render_gpu_draw_track_preview(renderer->gpu, cameraZ, elevation, yaw, + destX, destY, destW, destH); + else + menu_render_sw_draw_track_preview(renderer->sw, cameraZ, elevation, yaw, + destX, destY, destW, destH); } diff --git a/PROJECTS/ROLLER/menu_render.h b/PROJECTS/ROLLER/menu_render.h index 5ef2fada..c5c0df87 100644 --- a/PROJECTS/ROLLER/menu_render.h +++ b/PROJECTS/ROLLER/menu_render.h @@ -5,15 +5,12 @@ #include "types.h" #include "func3.h" -typedef enum { - MENU_RENDER_GPU, - MENU_RENDER_SOFTWARE -} MenuRenderMode; +typedef enum { MENU_RENDER_GPU, MENU_RENDER_SOFTWARE } MenuRenderMode; typedef enum { - MENU_LAYER_BACKGROUND, // behind 3D preview - MENU_LAYER_PREVIEW, // 3D preview (set automatically by draw_*_preview) - MENU_LAYER_FOREGROUND // on top of 3D preview + MENU_LAYER_BACKGROUND, // behind 3D preview + MENU_LAYER_PREVIEW, // 3D preview (set automatically by draw_*_preview) + MENU_LAYER_FOREGROUND // on top of 3D preview } MenuDrawLayer; typedef struct MenuRenderer MenuRenderer; @@ -42,21 +39,21 @@ void menu_render_set_layer(MenuRenderer *renderer, MenuDrawLayer layer); void menu_render_clear(MenuRenderer *renderer, uint8 colorIndex, const tColor *palette); void menu_render_background(MenuRenderer *renderer, int slot); -void menu_render_sprite(MenuRenderer *renderer, int slot, int blockIdx, - int x, int y, int transparentColorIndex, +void menu_render_sprite(MenuRenderer *renderer, int slot, int blockIdx, int x, + int y, int transparentColorIndex, const tColor *palette); // Fade system -void menu_render_begin_fade(MenuRenderer *renderer, int direction, int durationFrames); +void menu_render_begin_fade(MenuRenderer *renderer, int direction, + int durationFrames); int menu_render_fade_active(MenuRenderer *renderer); -void menu_render_fade_wait(MenuRenderer *renderer, - void (*redraw_fn)(void *ctx), void *ctx); +void menu_render_fade_wait(MenuRenderer *renderer, void (*redraw_fn)(void *ctx), + void *ctx); // Text rendering void menu_render_text(MenuRenderer *renderer, int fontSlot, const char *text, - const char *mappingTable, int *charVOffsets, - int x, int y, uint8 colorReplace, int alignment, - const tColor *palette); + const char *mappingTable, int *charVOffsets, int x, int y, + uint8 colorReplace, int alignment, const tColor *palette); void menu_render_scaled_text(MenuRenderer *renderer, int fontSlot, const char *text, const char *mappingTable, int *charVOffsets, int x, int y, @@ -65,16 +62,17 @@ void menu_render_scaled_text(MenuRenderer *renderer, int fontSlot, const tColor *palette); // 3D mesh previews -void menu_render_load_car_mesh(MenuRenderer *renderer, int carIdx, const tColor *palette); +void menu_render_load_car_mesh(MenuRenderer *renderer, int carIdx, + const tColor *palette); void menu_render_free_car_mesh(MenuRenderer *renderer); -void menu_render_draw_car_preview(MenuRenderer *renderer, float angle, float distance, - int carYaw, - int destX, int destY, int destW, int destH); +void menu_render_draw_car_preview(MenuRenderer *renderer, float angle, + float distance, int carYaw, int destX, + int destY, int destW, int destH); void menu_render_load_track_mesh(MenuRenderer *renderer, const tColor *palette); void menu_render_free_track_mesh(MenuRenderer *renderer); void menu_render_draw_track_preview(MenuRenderer *renderer, float cameraZ, - int elevation, int yaw, - int destX, int destY, int destW, int destH); + int elevation, int yaw, int destX, + int destY, int destW, int destH); #endif diff --git a/PROJECTS/ROLLER/menu_render_gpu.c b/PROJECTS/ROLLER/menu_render_gpu.c index 3dfa0865..82270944 100644 --- a/PROJECTS/ROLLER/menu_render_gpu.c +++ b/PROJECTS/ROLLER/menu_render_gpu.c @@ -17,822 +17,872 @@ #define MAX_QUADS_PER_FRAME 1024 typedef struct { - float position[2]; - float uv[2]; + float position[2]; + float uv[2]; } MenuVertex; // Pixel uniform block (must match HLSL cbuffer PixelUniforms layout) typedef struct { - float alphaMul; - float transparentR, transparentG, transparentB; - float replaceFromR, replaceFromG, replaceFromB; - float replaceToR, replaceToG, replaceToB; - float _pad0, _pad1; + float alphaMul; + float transparentR, transparentG, transparentB; + float replaceFromR, replaceFromG, replaceFromB; + float replaceToR, replaceToG, replaceToB; + float _pad0, _pad1; } PixelUniforms; // Recorded draw command (deferred — replayed in end_frame) typedef struct { - SDL_GPUTexture *texture; - int vertexOffset; // offset into vertex array (in vertices) - int vertexCount; - MenuDrawLayer layer; - PixelUniforms uniforms; + SDL_GPUTexture *texture; + int vertexOffset; // offset into vertex array (in vertices) + int vertexCount; + MenuDrawLayer layer; + PixelUniforms uniforms; } DrawCommand; #define MAX_DRAW_COMMANDS 512 // 3D mesh vertex (must match HLSL MeshVertexInput layout: 36 bytes) typedef struct { - float position[3]; - float uv[2]; - float color[4]; + float position[3]; + float uv[2]; + float color[4]; } MeshVertex; // Loaded mesh GPU buffers typedef struct { - SDL_GPUBuffer *vertexBuffer; - SDL_GPUBuffer *indexBuffer; - SDL_GPUTexture *texture; - int indexCount; - bool loaded; + SDL_GPUBuffer *vertexBuffer; + SDL_GPUBuffer *indexBuffer; + SDL_GPUTexture *texture; + int indexCount; + bool loaded; } MeshPreview; // Recorded mesh draw command (deferred -- replayed in end_frame) typedef struct { - SDL_GPUBuffer *vertexBuffer; - SDL_GPUBuffer *indexBuffer; - SDL_GPUTexture *texture; - int indexCount; - float mvp[16]; - float vpX, vpY, vpW, vpH; // viewport in virtual 640x400 coords - bool useDepth; + SDL_GPUBuffer *vertexBuffer; + SDL_GPUBuffer *indexBuffer; + SDL_GPUTexture *texture; + int indexCount; + float mvp[16]; + float vpX, vpY, vpW, vpH; // viewport in virtual 640x400 coords + bool useDepth; } MeshDrawCommand; #define MAX_MESH_DRAWS 4 struct MenuRendererGPU { - SDL_GPUDevice *device; - SDL_Window *window; - - SDL_GPUGraphicsPipeline *pipeline; - SDL_GPUSampler *sampler; - SDL_GPUBuffer *vertexBuffer; - SDL_GPUTransferBuffer *vertexTransferBuffer; - - // Per-slot textures (front_vga[0..15]) - MenuTexture *slotTextures[MAX_SLOTS]; - int slotTextureCount[MAX_SLOTS]; - - // Background textures (full 640x400 raw images) - SDL_GPUTexture *backgroundTextures[MAX_SLOTS]; - - // Frame state - SDL_GPUCommandBuffer *cmdBuf; - SDL_GPUTexture *swapchainTexture; - Uint32 swapchainWidth; - Uint32 swapchainHeight; - - // Deferred vertex + draw command accumulation - MenuVertex vertices[MAX_QUADS_PER_FRAME * 6]; - int vertexCount; - DrawCommand drawCommands[MAX_DRAW_COMMANDS]; - int drawCommandCount; - - // Fade - SDL_GPUTexture *blackTexture; - float fadeAlpha; - float fadeStep; - int fadeActive; - - // Mesh pipelines (3D previews) - SDL_GPUGraphicsPipeline *meshPipeline; - SDL_GPUGraphicsPipeline *meshPipelineNoDepth; - SDL_GPUTexture *depthTexture; - Uint32 depthWidth; - Uint32 depthHeight; - SDL_GPUTexture *whiteTexture; - - // 3D mesh state - MeshPreview carMesh; - int loadedCarIdx; // -1 = no car loaded (avoids per-frame reload) - bool trackMeshLoaded; - MeshPreview trackMesh; - - // Per-frame mesh draw commands - MeshDrawCommand meshDraws[MAX_MESH_DRAWS]; - int meshDrawCount; - MenuDrawLayer currentLayer; - + SDL_GPUDevice *device; + SDL_Window *window; + + SDL_GPUGraphicsPipeline *pipeline; + SDL_GPUSampler *sampler; + SDL_GPUBuffer *vertexBuffer; + SDL_GPUTransferBuffer *vertexTransferBuffer; + + // Per-slot textures (front_vga[0..15]) + MenuTexture *slotTextures[MAX_SLOTS]; + int slotTextureCount[MAX_SLOTS]; + + // Background textures (full 640x400 raw images) + SDL_GPUTexture *backgroundTextures[MAX_SLOTS]; + + // Frame state + SDL_GPUCommandBuffer *cmdBuf; + SDL_GPUTexture *swapchainTexture; + Uint32 swapchainWidth; + Uint32 swapchainHeight; + + // Deferred vertex + draw command accumulation + MenuVertex vertices[MAX_QUADS_PER_FRAME * 6]; + int vertexCount; + DrawCommand drawCommands[MAX_DRAW_COMMANDS]; + int drawCommandCount; + + // Fade + SDL_GPUTexture *blackTexture; + float fadeAlpha; + float fadeStep; + int fadeActive; + + // Mesh pipelines (3D previews) + SDL_GPUGraphicsPipeline *meshPipeline; + SDL_GPUGraphicsPipeline *meshPipelineNoDepth; + SDL_GPUTexture *depthTexture; + Uint32 depthWidth; + Uint32 depthHeight; + SDL_GPUTexture *whiteTexture; + + // 3D mesh state + MeshPreview carMesh; + int loadedCarIdx; // -1 = no car loaded (avoids per-frame reload) + bool trackMeshLoaded; + MeshPreview trackMesh; + + // Per-frame mesh draw commands + MeshDrawCommand meshDraws[MAX_MESH_DRAWS]; + int meshDrawCount; + MenuDrawLayer currentLayer; }; //--------------------------------------------------------------------------- // Shader loading helper //--------------------------------------------------------------------------- -static SDL_GPUShader *LoadShader(SDL_GPUDevice *device, SDL_GPUShaderStage stage, - const unsigned char *spirv, unsigned int spirvSize, - const unsigned char *msl, unsigned int mslSize, - int numSamplers, int numUniformBuffers) -{ - SDL_GPUShaderFormat fmts = SDL_GetGPUShaderFormats(device); - SDL_GPUShaderCreateInfo info = {0}; - info.stage = stage; - info.num_samplers = numSamplers; - info.num_uniform_buffers = numUniformBuffers; - - if (fmts & SDL_GPU_SHADERFORMAT_SPIRV) { - info.format = SDL_GPU_SHADERFORMAT_SPIRV; - info.code = spirv; - info.code_size = spirvSize; - info.entrypoint = "main"; - } else if (fmts & SDL_GPU_SHADERFORMAT_MSL) { - info.format = SDL_GPU_SHADERFORMAT_MSL; - info.code = msl; - info.code_size = mslSize; - info.entrypoint = "main0"; - } else { - return NULL; - } - - return SDL_CreateGPUShader(device, &info); +static SDL_GPUShader *LoadShader(SDL_GPUDevice *device, + SDL_GPUShaderStage stage, + const unsigned char *spirv, + unsigned int spirvSize, + const unsigned char *msl, unsigned int mslSize, + int numSamplers, int numUniformBuffers) { + SDL_GPUShaderFormat fmts = SDL_GetGPUShaderFormats(device); + SDL_GPUShaderCreateInfo info = {0}; + info.stage = stage; + info.num_samplers = numSamplers; + info.num_uniform_buffers = numUniformBuffers; + + if (fmts & SDL_GPU_SHADERFORMAT_SPIRV) { + info.format = SDL_GPU_SHADERFORMAT_SPIRV; + info.code = spirv; + info.code_size = spirvSize; + info.entrypoint = "main"; + } else if (fmts & SDL_GPU_SHADERFORMAT_MSL) { + info.format = SDL_GPU_SHADERFORMAT_MSL; + info.code = msl; + info.code_size = mslSize; + info.entrypoint = "main0"; + } else { + return NULL; + } + + return SDL_CreateGPUShader(device, &info); } //--------------------------------------------------------------------------- // Projection, quad emit, draw recording //--------------------------------------------------------------------------- -static void FreeMeshPreview(SDL_GPUDevice *dev, MeshPreview *mp, SDL_GPUTexture *whiteTexture); - -static void EnsureDepthTexture(MenuRendererGPU *r) -{ - if (r->depthTexture && r->depthWidth == r->swapchainWidth && - r->depthHeight == r->swapchainHeight) - return; - - if (r->depthTexture) - SDL_ReleaseGPUTexture(r->device, r->depthTexture); - - SDL_GPUTextureCreateInfo dti = {0}; - dti.type = SDL_GPU_TEXTURETYPE_2D; - dti.format = SDL_GPU_TEXTUREFORMAT_D32_FLOAT; - dti.width = r->swapchainWidth; - dti.height = r->swapchainHeight; - dti.layer_count_or_depth = 1; - dti.num_levels = 1; - dti.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET; - r->depthTexture = SDL_CreateGPUTexture(r->device, &dti); - r->depthWidth = r->swapchainWidth; - r->depthHeight = r->swapchainHeight; +static void FreeMeshPreview(SDL_GPUDevice *dev, MeshPreview *mp, + SDL_GPUTexture *whiteTexture); + +static void EnsureDepthTexture(MenuRendererGPU *r) { + if (r->depthTexture && r->depthWidth == r->swapchainWidth && + r->depthHeight == r->swapchainHeight) + return; + + if (r->depthTexture) + SDL_ReleaseGPUTexture(r->device, r->depthTexture); + + SDL_GPUTextureCreateInfo dti = {0}; + dti.type = SDL_GPU_TEXTURETYPE_2D; + dti.format = SDL_GPU_TEXTUREFORMAT_D32_FLOAT; + dti.width = r->swapchainWidth; + dti.height = r->swapchainHeight; + dti.layer_count_or_depth = 1; + dti.num_levels = 1; + dti.usage = SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET; + r->depthTexture = SDL_CreateGPUTexture(r->device, &dti); + r->depthWidth = r->swapchainWidth; + r->depthHeight = r->swapchainHeight; } -static void MakeOrthoProjection(float *m, float l, float r, float b, float t) -{ - memset(m, 0, 16 * sizeof(float)); - m[0] = 2.0f / (r - l); - m[5] = 2.0f / (t - b); - m[10] = -1.0f; - m[12] = -(r + l) / (r - l); - m[13] = -(t + b) / (t - b); - m[15] = 1.0f; +static void MakeOrthoProjection(float *m, float l, float r, float b, float t) { + memset(m, 0, 16 * sizeof(float)); + m[0] = 2.0f / (r - l); + m[5] = 2.0f / (t - b); + m[10] = -1.0f; + m[12] = -(r + l) / (r - l); + m[13] = -(t + b) / (t - b); + m[15] = 1.0f; } static void EmitQuad(MenuRendererGPU *r, float x, float y, float w, float h, - float u0, float v0, float u1, float v1) -{ - if (r->vertexCount + 6 > MAX_QUADS_PER_FRAME * 6) return; - MenuVertex *v = &r->vertices[r->vertexCount]; - v[0] = (MenuVertex){{x, y}, {u0, v0}}; - v[1] = (MenuVertex){{x + w, y}, {u1, v0}}; - v[2] = (MenuVertex){{x, y + h}, {u0, v1}}; - v[3] = (MenuVertex){{x + w, y}, {u1, v0}}; - v[4] = (MenuVertex){{x + w, y + h}, {u1, v1}}; - v[5] = (MenuVertex){{x, y + h}, {u0, v1}}; - r->vertexCount += 6; + float u0, float v0, float u1, float v1) { + if (r->vertexCount + 6 > MAX_QUADS_PER_FRAME * 6) + return; + MenuVertex *v = &r->vertices[r->vertexCount]; + v[0] = (MenuVertex){{x, y}, {u0, v0}}; + v[1] = (MenuVertex){{x + w, y}, {u1, v0}}; + v[2] = (MenuVertex){{x, y + h}, {u0, v1}}; + v[3] = (MenuVertex){{x + w, y}, {u1, v0}}; + v[4] = (MenuVertex){{x + w, y + h}, {u1, v1}}; + v[5] = (MenuVertex){{x, y + h}, {u0, v1}}; + r->vertexCount += 6; } // tColor has unusual field order: byR, byB, byG -static float ColorToFloat(uint8 component6bit) -{ - return (float)(component6bit * 255 / 63) / 255.0f; +static float ColorToFloat(uint8 component6bit) { + return (float)(component6bit * 255 / 63) / 255.0f; } static void RecordDraw(MenuRendererGPU *r, SDL_GPUTexture *texture, - float alphaMul, int transparentIdx, const tColor *pal) -{ - if (r->vertexCount == 0 || r->drawCommandCount >= MAX_DRAW_COMMANDS) return; - - DrawCommand *cmd = &r->drawCommands[r->drawCommandCount++]; - cmd->texture = texture; - cmd->vertexOffset = r->vertexCount - 6; // last EmitQuad wrote 6 verts - cmd->vertexCount = 6; - cmd->layer = r->currentLayer; - memset(&cmd->uniforms, 0, sizeof(cmd->uniforms)); - cmd->uniforms.alphaMul = alphaMul; - - if (transparentIdx >= 0 && pal) { - const tColor *c = &pal[transparentIdx]; - cmd->uniforms.transparentR = ColorToFloat(c->byR); - cmd->uniforms.transparentG = ColorToFloat(c->byG); // byG, not byB - cmd->uniforms.transparentB = ColorToFloat(c->byB); // byB, not byG - } else { - cmd->uniforms.transparentR = cmd->uniforms.transparentG = cmd->uniforms.transparentB = -1.0f; - } - // Color replacement disabled by default - cmd->uniforms.replaceFromR = -1.0f; + float alphaMul, int transparentIdx, const tColor *pal) { + if (r->vertexCount == 0 || r->drawCommandCount >= MAX_DRAW_COMMANDS) + return; + + DrawCommand *cmd = &r->drawCommands[r->drawCommandCount++]; + cmd->texture = texture; + cmd->vertexOffset = r->vertexCount - 6; // last EmitQuad wrote 6 verts + cmd->vertexCount = 6; + cmd->layer = r->currentLayer; + memset(&cmd->uniforms, 0, sizeof(cmd->uniforms)); + cmd->uniforms.alphaMul = alphaMul; + + if (transparentIdx >= 0 && pal) { + const tColor *c = &pal[transparentIdx]; + cmd->uniforms.transparentR = ColorToFloat(c->byR); + cmd->uniforms.transparentG = ColorToFloat(c->byG); // byG, not byB + cmd->uniforms.transparentB = ColorToFloat(c->byB); // byB, not byG + } else { + cmd->uniforms.transparentR = cmd->uniforms.transparentG = + cmd->uniforms.transparentB = -1.0f; + } + // Color replacement disabled by default + cmd->uniforms.replaceFromR = -1.0f; } -static void RecordDrawWithColorReplace(MenuRendererGPU *r, SDL_GPUTexture *texture, - float alphaMul, uint8 fromIdx, uint8 toIdx, - const tColor *pal) -{ - if (r->vertexCount == 0 || r->drawCommandCount >= MAX_DRAW_COMMANDS) return; - - DrawCommand *cmd = &r->drawCommands[r->drawCommandCount++]; - cmd->texture = texture; - cmd->vertexOffset = r->vertexCount - 6; - cmd->vertexCount = 6; - cmd->layer = r->currentLayer; - memset(&cmd->uniforms, 0, sizeof(cmd->uniforms)); - cmd->uniforms.alphaMul = alphaMul; - - // Enable alpha-based transparency discard (shader checks transparentR >= 0) - cmd->uniforms.transparentR = 0.0f; - cmd->uniforms.transparentG = 0.0f; - cmd->uniforms.transparentB = 0.0f; - - // Color replacement: fromIdx -> toIdx - if (pal) { - const tColor *fc = &pal[fromIdx]; - cmd->uniforms.replaceFromR = ColorToFloat(fc->byR); - cmd->uniforms.replaceFromG = ColorToFloat(fc->byG); - cmd->uniforms.replaceFromB = ColorToFloat(fc->byB); - const tColor *tc = &pal[toIdx]; - cmd->uniforms.replaceToR = ColorToFloat(tc->byR); - cmd->uniforms.replaceToG = ColorToFloat(tc->byG); - cmd->uniforms.replaceToB = ColorToFloat(tc->byB); - } else { - cmd->uniforms.replaceFromR = -1.0f; - } +static void RecordDrawWithColorReplace(MenuRendererGPU *r, + SDL_GPUTexture *texture, float alphaMul, + uint8 fromIdx, uint8 toIdx, + const tColor *pal) { + if (r->vertexCount == 0 || r->drawCommandCount >= MAX_DRAW_COMMANDS) + return; + + DrawCommand *cmd = &r->drawCommands[r->drawCommandCount++]; + cmd->texture = texture; + cmd->vertexOffset = r->vertexCount - 6; + cmd->vertexCount = 6; + cmd->layer = r->currentLayer; + memset(&cmd->uniforms, 0, sizeof(cmd->uniforms)); + cmd->uniforms.alphaMul = alphaMul; + + // Enable alpha-based transparency discard (shader checks transparentR >= 0) + cmd->uniforms.transparentR = 0.0f; + cmd->uniforms.transparentG = 0.0f; + cmd->uniforms.transparentB = 0.0f; + + // Color replacement: fromIdx -> toIdx + if (pal) { + const tColor *fc = &pal[fromIdx]; + cmd->uniforms.replaceFromR = ColorToFloat(fc->byR); + cmd->uniforms.replaceFromG = ColorToFloat(fc->byG); + cmd->uniforms.replaceFromB = ColorToFloat(fc->byB); + const tColor *tc = &pal[toIdx]; + cmd->uniforms.replaceToR = ColorToFloat(tc->byR); + cmd->uniforms.replaceToG = ColorToFloat(tc->byG); + cmd->uniforms.replaceToB = ColorToFloat(tc->byB); + } else { + cmd->uniforms.replaceFromR = -1.0f; + } } static void ReplayDrawsLayer(MenuRendererGPU *r, SDL_GPURenderPass *renderPass, - MenuDrawLayer minLayer, MenuDrawLayer maxLayer) -{ - float proj[16]; - MakeOrthoProjection(proj, 0, MENU_WIDTH, MENU_HEIGHT, 0); + MenuDrawLayer minLayer, MenuDrawLayer maxLayer) { + float proj[16]; + MakeOrthoProjection(proj, 0, MENU_WIDTH, MENU_HEIGHT, 0); - SDL_BindGPUGraphicsPipeline(renderPass, r->pipeline); - SDL_PushGPUVertexUniformData(r->cmdBuf, 0, proj, sizeof(proj)); + SDL_BindGPUGraphicsPipeline(renderPass, r->pipeline); + SDL_PushGPUVertexUniformData(r->cmdBuf, 0, proj, sizeof(proj)); - SDL_GPUBufferBinding vbb = { .buffer = r->vertexBuffer }; - SDL_BindGPUVertexBuffers(renderPass, 0, &vbb, 1); + SDL_GPUBufferBinding vbb = {.buffer = r->vertexBuffer}; + SDL_BindGPUVertexBuffers(renderPass, 0, &vbb, 1); - for (int i = 0; i < r->drawCommandCount; i++) { - DrawCommand *cmd = &r->drawCommands[i]; - if (cmd->layer < minLayer || cmd->layer > maxLayer) continue; + for (int i = 0; i < r->drawCommandCount; i++) { + DrawCommand *cmd = &r->drawCommands[i]; + if (cmd->layer < minLayer || cmd->layer > maxLayer) + continue; - SDL_PushGPUFragmentUniformData(r->cmdBuf, 0, &cmd->uniforms, sizeof(cmd->uniforms)); + SDL_PushGPUFragmentUniformData(r->cmdBuf, 0, &cmd->uniforms, + sizeof(cmd->uniforms)); - SDL_GPUTextureSamplerBinding tsb = { .texture = cmd->texture, .sampler = r->sampler }; - SDL_BindGPUFragmentSamplers(renderPass, 0, &tsb, 1); + SDL_GPUTextureSamplerBinding tsb = {.texture = cmd->texture, + .sampler = r->sampler}; + SDL_BindGPUFragmentSamplers(renderPass, 0, &tsb, 1); - SDL_DrawGPUPrimitives(renderPass, cmd->vertexCount, 1, cmd->vertexOffset, 0); - } + SDL_DrawGPUPrimitives(renderPass, cmd->vertexCount, 1, cmd->vertexOffset, + 0); + } } -static void ReplayMeshDraws(MenuRendererGPU *r, SDL_GPURenderPass *renderPass) -{ - if (!r->meshPipeline || r->meshDrawCount == 0) return; - - // Compute viewport mapping from virtual 640x400 to swapchain pixels - float wAsp = (float)r->swapchainWidth / (float)r->swapchainHeight; - float mAsp = (float)MENU_WIDTH / (float)MENU_HEIGHT; - float baseX, baseY, baseW, baseH; - if (wAsp > mAsp) { - baseH = (float)r->swapchainHeight; - baseW = mAsp * baseH; - baseX = (r->swapchainWidth - baseW) / 2.0f; - baseY = 0; - } else { - baseW = (float)r->swapchainWidth; - baseH = baseW / mAsp; - baseX = 0; - baseY = (r->swapchainHeight - baseH) / 2.0f; +static void ReplayMeshDraws(MenuRendererGPU *r, SDL_GPURenderPass *renderPass) { + if (!r->meshPipeline || r->meshDrawCount == 0) + return; + + // Compute viewport mapping from virtual 640x400 to swapchain pixels + float wAsp = (float)r->swapchainWidth / (float)r->swapchainHeight; + float mAsp = (float)MENU_WIDTH / (float)MENU_HEIGHT; + float baseX, baseY, baseW, baseH; + if (wAsp > mAsp) { + baseH = (float)r->swapchainHeight; + baseW = mAsp * baseH; + baseX = (r->swapchainWidth - baseW) / 2.0f; + baseY = 0; + } else { + baseW = (float)r->swapchainWidth; + baseH = baseW / mAsp; + baseX = 0; + baseY = (r->swapchainHeight - baseH) / 2.0f; + } + float scaleX = baseW / (float)MENU_WIDTH; + float scaleY = baseH / (float)MENU_HEIGHT; + + SDL_GPUGraphicsPipeline *curPipeline = NULL; + + for (int i = 0; i < r->meshDrawCount; i++) { + MeshDrawCommand *cmd = &r->meshDraws[i]; + SDL_GPUGraphicsPipeline *wanted = + cmd->useDepth ? r->meshPipeline : r->meshPipelineNoDepth; + if (wanted != curPipeline) { + SDL_BindGPUGraphicsPipeline(renderPass, wanted); + curPipeline = wanted; } - float scaleX = baseW / (float)MENU_WIDTH; - float scaleY = baseH / (float)MENU_HEIGHT; - - SDL_GPUGraphicsPipeline *curPipeline = NULL; - for (int i = 0; i < r->meshDrawCount; i++) { - MeshDrawCommand *cmd = &r->meshDraws[i]; - SDL_GPUGraphicsPipeline *wanted = cmd->useDepth ? r->meshPipeline : r->meshPipelineNoDepth; - if (wanted != curPipeline) { - SDL_BindGPUGraphicsPipeline(renderPass, wanted); - curPipeline = wanted; - } + // Set sub-viewport for this mesh preview + SDL_GPUViewport mvp = {0}; + mvp.x = baseX + cmd->vpX * scaleX; + mvp.y = baseY + cmd->vpY * scaleY; + mvp.w = cmd->vpW * scaleX; + mvp.h = cmd->vpH * scaleY; + mvp.min_depth = 0.0f; + mvp.max_depth = 1.0f; + SDL_SetGPUViewport(renderPass, &mvp); - // Set sub-viewport for this mesh preview - SDL_GPUViewport mvp = {0}; - mvp.x = baseX + cmd->vpX * scaleX; - mvp.y = baseY + cmd->vpY * scaleY; - mvp.w = cmd->vpW * scaleX; - mvp.h = cmd->vpH * scaleY; - mvp.min_depth = 0.0f; - mvp.max_depth = 1.0f; - SDL_SetGPUViewport(renderPass, &mvp); + SDL_PushGPUVertexUniformData(r->cmdBuf, 0, cmd->mvp, sizeof(cmd->mvp)); - SDL_PushGPUVertexUniformData(r->cmdBuf, 0, cmd->mvp, sizeof(cmd->mvp)); + SDL_GPUTextureSamplerBinding tsb = {.texture = cmd->texture, + .sampler = r->sampler}; + SDL_BindGPUFragmentSamplers(renderPass, 0, &tsb, 1); - SDL_GPUTextureSamplerBinding tsb = { .texture = cmd->texture, .sampler = r->sampler }; - SDL_BindGPUFragmentSamplers(renderPass, 0, &tsb, 1); - - SDL_GPUBufferBinding vbb = { .buffer = cmd->vertexBuffer }; - SDL_BindGPUVertexBuffers(renderPass, 0, &vbb, 1); + SDL_GPUBufferBinding vbb = {.buffer = cmd->vertexBuffer}; + SDL_BindGPUVertexBuffers(renderPass, 0, &vbb, 1); - SDL_GPUBufferBinding ibb = { .buffer = cmd->indexBuffer }; - SDL_BindGPUIndexBuffer(renderPass, &ibb, SDL_GPU_INDEXELEMENTSIZE_32BIT); + SDL_GPUBufferBinding ibb = {.buffer = cmd->indexBuffer}; + SDL_BindGPUIndexBuffer(renderPass, &ibb, SDL_GPU_INDEXELEMENTSIZE_32BIT); - SDL_DrawGPUIndexedPrimitives(renderPass, cmd->indexCount, 1, 0, 0, 0); - } + SDL_DrawGPUIndexedPrimitives(renderPass, cmd->indexCount, 1, 0, 0, 0); + } } //--------------------------------------------------------------------------- // Asset upload helper //--------------------------------------------------------------------------- -static SDL_GPUTexture *UploadRGBA(SDL_GPUDevice *dev, const uint8 *rgba, int w, int h) -{ - SDL_GPUTextureCreateInfo ti = {0}; - ti.type = SDL_GPU_TEXTURETYPE_2D; - ti.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; - ti.width = w; ti.height = h; - ti.layer_count_or_depth = 1; ti.num_levels = 1; - ti.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER; - SDL_GPUTexture *tex = SDL_CreateGPUTexture(dev, &ti); - if (!tex) return NULL; - - SDL_GPUTransferBufferCreateInfo tbi = {0}; - tbi.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; - tbi.size = w * h * 4; - SDL_GPUTransferBuffer *tb = SDL_CreateGPUTransferBuffer(dev, &tbi); - if (!tb) { SDL_ReleaseGPUTexture(dev, tex); return NULL; } - void *m = SDL_MapGPUTransferBuffer(dev, tb, false); - if (!m) { SDL_ReleaseGPUTransferBuffer(dev, tb); SDL_ReleaseGPUTexture(dev, tex); return NULL; } - memcpy(m, rgba, w * h * 4); - SDL_UnmapGPUTransferBuffer(dev, tb); - - SDL_GPUCommandBuffer *cmd = SDL_AcquireGPUCommandBuffer(dev); - SDL_GPUCopyPass *cp = SDL_BeginGPUCopyPass(cmd); - SDL_GPUTextureTransferInfo src = { .transfer_buffer = tb }; - SDL_GPUTextureRegion dst = { .texture = tex, .w = w, .h = h, .d = 1 }; - SDL_UploadToGPUTexture(cp, &src, &dst, false); - SDL_EndGPUCopyPass(cp); - SDL_SubmitGPUCommandBuffer(cmd); - +static SDL_GPUTexture *UploadRGBA(SDL_GPUDevice *dev, const uint8 *rgba, int w, + int h) { + SDL_GPUTextureCreateInfo ti = {0}; + ti.type = SDL_GPU_TEXTURETYPE_2D; + ti.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM; + ti.width = w; + ti.height = h; + ti.layer_count_or_depth = 1; + ti.num_levels = 1; + ti.usage = SDL_GPU_TEXTUREUSAGE_SAMPLER; + SDL_GPUTexture *tex = SDL_CreateGPUTexture(dev, &ti); + if (!tex) + return NULL; + + SDL_GPUTransferBufferCreateInfo tbi = {0}; + tbi.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; + tbi.size = w * h * 4; + SDL_GPUTransferBuffer *tb = SDL_CreateGPUTransferBuffer(dev, &tbi); + if (!tb) { + SDL_ReleaseGPUTexture(dev, tex); + return NULL; + } + void *m = SDL_MapGPUTransferBuffer(dev, tb, false); + if (!m) { SDL_ReleaseGPUTransferBuffer(dev, tb); - return tex; + SDL_ReleaseGPUTexture(dev, tex); + return NULL; + } + memcpy(m, rgba, w * h * 4); + SDL_UnmapGPUTransferBuffer(dev, tb); + + SDL_GPUCommandBuffer *cmd = SDL_AcquireGPUCommandBuffer(dev); + SDL_GPUCopyPass *cp = SDL_BeginGPUCopyPass(cmd); + SDL_GPUTextureTransferInfo src = {.transfer_buffer = tb}; + SDL_GPUTextureRegion dst = {.texture = tex, .w = w, .h = h, .d = 1}; + SDL_UploadToGPUTexture(cp, &src, &dst, false); + SDL_EndGPUCopyPass(cp); + SDL_SubmitGPUCommandBuffer(cmd); + + SDL_ReleaseGPUTransferBuffer(dev, tb); + return tex; } -static SDL_GPUBuffer *UploadGPUBuffer(SDL_GPUDevice *dev, SDL_GPUBufferUsageFlags usage, - const void *data, Uint32 size) -{ - SDL_GPUBufferCreateInfo bi = {0}; - bi.usage = usage; - bi.size = size; - SDL_GPUBuffer *buf = SDL_CreateGPUBuffer(dev, &bi); - if (!buf) return NULL; - - SDL_GPUTransferBufferCreateInfo tbi = {0}; - tbi.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; - tbi.size = size; - SDL_GPUTransferBuffer *tb = SDL_CreateGPUTransferBuffer(dev, &tbi); - if (!tb) { SDL_ReleaseGPUBuffer(dev, buf); return NULL; } - void *m = SDL_MapGPUTransferBuffer(dev, tb, false); - if (!m) { SDL_ReleaseGPUTransferBuffer(dev, tb); SDL_ReleaseGPUBuffer(dev, buf); return NULL; } - memcpy(m, data, size); - SDL_UnmapGPUTransferBuffer(dev, tb); - - SDL_GPUCommandBuffer *cmd = SDL_AcquireGPUCommandBuffer(dev); - SDL_GPUCopyPass *cp = SDL_BeginGPUCopyPass(cmd); - SDL_GPUTransferBufferLocation src = { .transfer_buffer = tb }; - SDL_GPUBufferRegion dst = { .buffer = buf, .size = size }; - SDL_UploadToGPUBuffer(cp, &src, &dst, false); - SDL_EndGPUCopyPass(cp); - SDL_SubmitGPUCommandBuffer(cmd); - +static SDL_GPUBuffer *UploadGPUBuffer(SDL_GPUDevice *dev, + SDL_GPUBufferUsageFlags usage, + const void *data, Uint32 size) { + SDL_GPUBufferCreateInfo bi = {0}; + bi.usage = usage; + bi.size = size; + SDL_GPUBuffer *buf = SDL_CreateGPUBuffer(dev, &bi); + if (!buf) + return NULL; + + SDL_GPUTransferBufferCreateInfo tbi = {0}; + tbi.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; + tbi.size = size; + SDL_GPUTransferBuffer *tb = SDL_CreateGPUTransferBuffer(dev, &tbi); + if (!tb) { + SDL_ReleaseGPUBuffer(dev, buf); + return NULL; + } + void *m = SDL_MapGPUTransferBuffer(dev, tb, false); + if (!m) { SDL_ReleaseGPUTransferBuffer(dev, tb); - return buf; + SDL_ReleaseGPUBuffer(dev, buf); + return NULL; + } + memcpy(m, data, size); + SDL_UnmapGPUTransferBuffer(dev, tb); + + SDL_GPUCommandBuffer *cmd = SDL_AcquireGPUCommandBuffer(dev); + SDL_GPUCopyPass *cp = SDL_BeginGPUCopyPass(cmd); + SDL_GPUTransferBufferLocation src = {.transfer_buffer = tb}; + SDL_GPUBufferRegion dst = {.buffer = buf, .size = size}; + SDL_UploadToGPUBuffer(cp, &src, &dst, false); + SDL_EndGPUCopyPass(cp); + SDL_SubmitGPUCommandBuffer(cmd); + + SDL_ReleaseGPUTransferBuffer(dev, tb); + return buf; } // tColor field order: byR, byB, byG — read byG for green, byB for blue -static void IndexedToRGBA(const uint8 *indexed, const tColor *pal, uint8 *rgba, int count) -{ - for (int i = 0; i < count; i++) { - const tColor *c = &pal[indexed[i]]; - rgba[i * 4 + 0] = (c->byR * 255) / 63; - rgba[i * 4 + 1] = (c->byG * 255) / 63; - rgba[i * 4 + 2] = (c->byB * 255) / 63; - // Bake transparency for palette index 0 into alpha channel. - // Software display_block compares palette indices, not RGB values; - // multiple palette entries can share the same RGB, so comparing - // colors in the shader would incorrectly discard non-transparent pixels. - rgba[i * 4 + 3] = (indexed[i] == 0) ? 0 : 255; - } +static void IndexedToRGBA(const uint8 *indexed, const tColor *pal, uint8 *rgba, + int count) { + for (int i = 0; i < count; i++) { + const tColor *c = &pal[indexed[i]]; + rgba[i * 4 + 0] = (c->byR * 255) / 63; + rgba[i * 4 + 1] = (c->byG * 255) / 63; + rgba[i * 4 + 2] = (c->byB * 255) / 63; + // Bake transparency for palette index 0 into alpha channel. + // Software display_block compares palette indices, not RGB values; + // multiple palette entries can share the same RGB, so comparing + // colors in the shader would incorrectly discard non-transparent pixels. + rgba[i * 4 + 3] = (indexed[i] == 0) ? 0 : 255; + } } //--------------------------------------------------------------------------- // Create / Destroy //--------------------------------------------------------------------------- -MenuRendererGPU *menu_render_gpu_create(SDL_GPUDevice *device, SDL_Window *window) -{ - MenuRendererGPU *r = calloc(1, sizeof(MenuRendererGPU)); - r->device = device; - r->window = window; - - // Load shaders - SDL_GPUShader *vert = LoadShader(device, SDL_GPU_SHADERSTAGE_VERTEX, - menu_vertex_spirv, menu_vertex_spirv_size, - menu_vertex_msl, menu_vertex_msl_size, - 0, 1); - - SDL_GPUShader *frag = LoadShader(device, SDL_GPU_SHADERSTAGE_FRAGMENT, - menu_pixel_spirv, menu_pixel_spirv_size, - menu_pixel_msl, menu_pixel_msl_size, - 1, 1); - - if (!vert || !frag) { - SDL_Log("Failed to create menu shaders"); - free(r); - return NULL; - } +MenuRendererGPU *menu_render_gpu_create(SDL_GPUDevice *device, + SDL_Window *window) { + MenuRendererGPU *r = calloc(1, sizeof(MenuRendererGPU)); + r->device = device; + r->window = window; - // Pipeline - SDL_GPUGraphicsPipelineCreateInfo pipeInfo = {0}; - pipeInfo.vertex_shader = vert; - pipeInfo.fragment_shader = frag; - pipeInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; - - SDL_GPUVertexBufferDescription vbDesc = {0}; - vbDesc.slot = 0; - vbDesc.pitch = sizeof(MenuVertex); - vbDesc.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX; - - SDL_GPUVertexAttribute attrs[2] = {0}; - attrs[0].location = 0; - attrs[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; - attrs[0].offset = offsetof(MenuVertex, position); - attrs[1].location = 1; - attrs[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; - attrs[1].offset = offsetof(MenuVertex, uv); - - pipeInfo.vertex_input_state.vertex_buffer_descriptions = &vbDesc; - pipeInfo.vertex_input_state.num_vertex_buffers = 1; - pipeInfo.vertex_input_state.vertex_attributes = attrs; - pipeInfo.vertex_input_state.num_vertex_attributes = 2; - - SDL_GPUColorTargetDescription colorTarget = {0}; - colorTarget.format = SDL_GetGPUSwapchainTextureFormat(device, window); - colorTarget.blend_state.enable_blend = true; - colorTarget.blend_state.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA; - colorTarget.blend_state.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; - colorTarget.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD; - colorTarget.blend_state.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE; - colorTarget.blend_state.dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; - colorTarget.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD; - - pipeInfo.target_info.color_target_descriptions = &colorTarget; - pipeInfo.target_info.num_color_targets = 1; - pipeInfo.target_info.has_depth_stencil_target = true; - pipeInfo.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D32_FLOAT; - // depth_stencil_state defaults: depth test/write disabled (2D quads don't need depth) - - r->pipeline = SDL_CreateGPUGraphicsPipeline(device, &pipeInfo); - SDL_ReleaseGPUShader(device, vert); - SDL_ReleaseGPUShader(device, frag); - - if (!r->pipeline) { - SDL_Log("Failed to create menu pipeline: %s", SDL_GetError()); - free(r); - return NULL; - } + // Load shaders + SDL_GPUShader *vert = LoadShader(device, SDL_GPU_SHADERSTAGE_VERTEX, + menu_vertex_spirv, menu_vertex_spirv_size, + menu_vertex_msl, menu_vertex_msl_size, 0, 1); - // --- Mesh pipeline (3D previews with depth testing) --- - SDL_GPUShader *meshVert = LoadShader(device, SDL_GPU_SHADERSTAGE_VERTEX, - menu_mesh_vertex_spirv, menu_mesh_vertex_spirv_size, - menu_mesh_vertex_msl, menu_mesh_vertex_msl_size, - 0, 1); // 0 samplers, 1 uniform buffer (MVP) + SDL_GPUShader *frag = LoadShader(device, SDL_GPU_SHADERSTAGE_FRAGMENT, + menu_pixel_spirv, menu_pixel_spirv_size, + menu_pixel_msl, menu_pixel_msl_size, 1, 1); - SDL_GPUShader *meshFrag = LoadShader(device, SDL_GPU_SHADERSTAGE_FRAGMENT, - menu_mesh_pixel_spirv, menu_mesh_pixel_spirv_size, - menu_mesh_pixel_msl, menu_mesh_pixel_msl_size, - 1, 0); // 1 sampler, 0 uniform buffers - - if (!meshVert || !meshFrag) { - SDL_Log("Failed to create mesh shaders"); - } else { - SDL_GPUGraphicsPipelineCreateInfo meshPipeInfo = {0}; - meshPipeInfo.vertex_shader = meshVert; - meshPipeInfo.fragment_shader = meshFrag; - meshPipeInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; - - SDL_GPUVertexBufferDescription meshVbDesc = {0}; - meshVbDesc.slot = 0; - meshVbDesc.pitch = sizeof(MeshVertex); - meshVbDesc.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX; - - SDL_GPUVertexAttribute meshAttrs[3] = {0}; - meshAttrs[0].location = 0; - meshAttrs[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3; - meshAttrs[0].offset = offsetof(MeshVertex, position); - meshAttrs[1].location = 1; - meshAttrs[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; - meshAttrs[1].offset = offsetof(MeshVertex, uv); - meshAttrs[2].location = 2; - meshAttrs[2].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4; - meshAttrs[2].offset = offsetof(MeshVertex, color); - - meshPipeInfo.vertex_input_state.vertex_buffer_descriptions = &meshVbDesc; - meshPipeInfo.vertex_input_state.num_vertex_buffers = 1; - meshPipeInfo.vertex_input_state.vertex_attributes = meshAttrs; - meshPipeInfo.vertex_input_state.num_vertex_attributes = 3; - - meshPipeInfo.target_info.color_target_descriptions = &colorTarget; - meshPipeInfo.target_info.num_color_targets = 1; - meshPipeInfo.target_info.has_depth_stencil_target = true; - meshPipeInfo.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D32_FLOAT; - - meshPipeInfo.depth_stencil_state.enable_depth_test = true; - meshPipeInfo.depth_stencil_state.enable_depth_write = true; - meshPipeInfo.depth_stencil_state.compare_op = SDL_GPU_COMPAREOP_LESS; - - meshPipeInfo.rasterizer_state.cull_mode = SDL_GPU_CULLMODE_BACK; - meshPipeInfo.rasterizer_state.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE; - meshPipeInfo.rasterizer_state.fill_mode = SDL_GPU_FILLMODE_FILL; - - r->meshPipeline = SDL_CreateGPUGraphicsPipeline(device, &meshPipeInfo); - if (!r->meshPipeline) - SDL_Log("Failed to create mesh pipeline: %s", SDL_GetError()); - - // No-depth variant for flat meshes (track map) - meshPipeInfo.depth_stencil_state.enable_depth_test = false; - meshPipeInfo.depth_stencil_state.enable_depth_write = false; - r->meshPipelineNoDepth = SDL_CreateGPUGraphicsPipeline(device, &meshPipeInfo); - if (!r->meshPipelineNoDepth) - SDL_Log("Failed to create no-depth mesh pipeline: %s", SDL_GetError()); - } - if (meshVert) SDL_ReleaseGPUShader(device, meshVert); - if (meshFrag) SDL_ReleaseGPUShader(device, meshFrag); - - // Sampler - SDL_GPUSamplerCreateInfo sampInfo = {0}; - sampInfo.min_filter = SDL_GPU_FILTER_NEAREST; - sampInfo.mag_filter = SDL_GPU_FILTER_NEAREST; - sampInfo.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - sampInfo.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; - r->sampler = SDL_CreateGPUSampler(device, &sampInfo); - - // Vertex buffer - SDL_GPUBufferCreateInfo bufInfo = {0}; - bufInfo.usage = SDL_GPU_BUFFERUSAGE_VERTEX; - bufInfo.size = sizeof(r->vertices); - r->vertexBuffer = SDL_CreateGPUBuffer(device, &bufInfo); - - SDL_GPUTransferBufferCreateInfo tbInfo = {0}; - tbInfo.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; - tbInfo.size = sizeof(r->vertices); - r->vertexTransferBuffer = SDL_CreateGPUTransferBuffer(device, &tbInfo); - - // 1x1 black texture for fade overlay - uint8 blackPixel[4] = {0, 0, 0, 255}; - r->blackTexture = UploadRGBA(device, blackPixel, 1, 1); - - // 1x1 white texture for flat-colored meshes (track map) - uint8 whitePixel[4] = {255, 255, 255, 255}; - r->whiteTexture = UploadRGBA(device, whitePixel, 1, 1); - - r->loadedCarIdx = -1; - - return r; + if (!vert || !frag) { + SDL_Log("Failed to create menu shaders"); + free(r); + return NULL; + } + + // Pipeline + SDL_GPUGraphicsPipelineCreateInfo pipeInfo = {0}; + pipeInfo.vertex_shader = vert; + pipeInfo.fragment_shader = frag; + pipeInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + + SDL_GPUVertexBufferDescription vbDesc = {0}; + vbDesc.slot = 0; + vbDesc.pitch = sizeof(MenuVertex); + vbDesc.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX; + + SDL_GPUVertexAttribute attrs[2] = {0}; + attrs[0].location = 0; + attrs[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; + attrs[0].offset = offsetof(MenuVertex, position); + attrs[1].location = 1; + attrs[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; + attrs[1].offset = offsetof(MenuVertex, uv); + + pipeInfo.vertex_input_state.vertex_buffer_descriptions = &vbDesc; + pipeInfo.vertex_input_state.num_vertex_buffers = 1; + pipeInfo.vertex_input_state.vertex_attributes = attrs; + pipeInfo.vertex_input_state.num_vertex_attributes = 2; + + SDL_GPUColorTargetDescription colorTarget = {0}; + colorTarget.format = SDL_GetGPUSwapchainTextureFormat(device, window); + colorTarget.blend_state.enable_blend = true; + colorTarget.blend_state.src_color_blendfactor = SDL_GPU_BLENDFACTOR_SRC_ALPHA; + colorTarget.blend_state.dst_color_blendfactor = + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + colorTarget.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD; + colorTarget.blend_state.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE; + colorTarget.blend_state.dst_alpha_blendfactor = + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA; + colorTarget.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD; + + pipeInfo.target_info.color_target_descriptions = &colorTarget; + pipeInfo.target_info.num_color_targets = 1; + pipeInfo.target_info.has_depth_stencil_target = true; + pipeInfo.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_D32_FLOAT; + // depth_stencil_state defaults: depth test/write disabled (2D quads don't + // need depth) + + r->pipeline = SDL_CreateGPUGraphicsPipeline(device, &pipeInfo); + SDL_ReleaseGPUShader(device, vert); + SDL_ReleaseGPUShader(device, frag); + + if (!r->pipeline) { + SDL_Log("Failed to create menu pipeline: %s", SDL_GetError()); + free(r); + return NULL; + } + + // --- Mesh pipeline (3D previews with depth testing) --- + SDL_GPUShader *meshVert = LoadShader( + device, SDL_GPU_SHADERSTAGE_VERTEX, menu_mesh_vertex_spirv, + menu_mesh_vertex_spirv_size, menu_mesh_vertex_msl, + menu_mesh_vertex_msl_size, 0, 1); // 0 samplers, 1 uniform buffer (MVP) + + SDL_GPUShader *meshFrag = LoadShader( + device, SDL_GPU_SHADERSTAGE_FRAGMENT, menu_mesh_pixel_spirv, + menu_mesh_pixel_spirv_size, menu_mesh_pixel_msl, menu_mesh_pixel_msl_size, + 1, 0); // 1 sampler, 0 uniform buffers + + if (!meshVert || !meshFrag) { + SDL_Log("Failed to create mesh shaders"); + } else { + SDL_GPUGraphicsPipelineCreateInfo meshPipeInfo = {0}; + meshPipeInfo.vertex_shader = meshVert; + meshPipeInfo.fragment_shader = meshFrag; + meshPipeInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST; + + SDL_GPUVertexBufferDescription meshVbDesc = {0}; + meshVbDesc.slot = 0; + meshVbDesc.pitch = sizeof(MeshVertex); + meshVbDesc.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX; + + SDL_GPUVertexAttribute meshAttrs[3] = {0}; + meshAttrs[0].location = 0; + meshAttrs[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3; + meshAttrs[0].offset = offsetof(MeshVertex, position); + meshAttrs[1].location = 1; + meshAttrs[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2; + meshAttrs[1].offset = offsetof(MeshVertex, uv); + meshAttrs[2].location = 2; + meshAttrs[2].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4; + meshAttrs[2].offset = offsetof(MeshVertex, color); + + meshPipeInfo.vertex_input_state.vertex_buffer_descriptions = &meshVbDesc; + meshPipeInfo.vertex_input_state.num_vertex_buffers = 1; + meshPipeInfo.vertex_input_state.vertex_attributes = meshAttrs; + meshPipeInfo.vertex_input_state.num_vertex_attributes = 3; + + meshPipeInfo.target_info.color_target_descriptions = &colorTarget; + meshPipeInfo.target_info.num_color_targets = 1; + meshPipeInfo.target_info.has_depth_stencil_target = true; + meshPipeInfo.target_info.depth_stencil_format = + SDL_GPU_TEXTUREFORMAT_D32_FLOAT; + + meshPipeInfo.depth_stencil_state.enable_depth_test = true; + meshPipeInfo.depth_stencil_state.enable_depth_write = true; + meshPipeInfo.depth_stencil_state.compare_op = SDL_GPU_COMPAREOP_LESS; + + meshPipeInfo.rasterizer_state.cull_mode = SDL_GPU_CULLMODE_BACK; + meshPipeInfo.rasterizer_state.front_face = + SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE; + meshPipeInfo.rasterizer_state.fill_mode = SDL_GPU_FILLMODE_FILL; + + r->meshPipeline = SDL_CreateGPUGraphicsPipeline(device, &meshPipeInfo); + if (!r->meshPipeline) + SDL_Log("Failed to create mesh pipeline: %s", SDL_GetError()); + + // No-depth variant for flat meshes (track map) + meshPipeInfo.depth_stencil_state.enable_depth_test = false; + meshPipeInfo.depth_stencil_state.enable_depth_write = false; + r->meshPipelineNoDepth = + SDL_CreateGPUGraphicsPipeline(device, &meshPipeInfo); + if (!r->meshPipelineNoDepth) + SDL_Log("Failed to create no-depth mesh pipeline: %s", SDL_GetError()); + } + if (meshVert) + SDL_ReleaseGPUShader(device, meshVert); + if (meshFrag) + SDL_ReleaseGPUShader(device, meshFrag); + + // Sampler + SDL_GPUSamplerCreateInfo sampInfo = {0}; + sampInfo.min_filter = SDL_GPU_FILTER_NEAREST; + sampInfo.mag_filter = SDL_GPU_FILTER_NEAREST; + sampInfo.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + sampInfo.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE; + r->sampler = SDL_CreateGPUSampler(device, &sampInfo); + + // Vertex buffer + SDL_GPUBufferCreateInfo bufInfo = {0}; + bufInfo.usage = SDL_GPU_BUFFERUSAGE_VERTEX; + bufInfo.size = sizeof(r->vertices); + r->vertexBuffer = SDL_CreateGPUBuffer(device, &bufInfo); + + SDL_GPUTransferBufferCreateInfo tbInfo = {0}; + tbInfo.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD; + tbInfo.size = sizeof(r->vertices); + r->vertexTransferBuffer = SDL_CreateGPUTransferBuffer(device, &tbInfo); + + // 1x1 black texture for fade overlay + uint8 blackPixel[4] = {0, 0, 0, 255}; + r->blackTexture = UploadRGBA(device, blackPixel, 1, 1); + + // 1x1 white texture for flat-colored meshes (track map) + uint8 whitePixel[4] = {255, 255, 255, 255}; + r->whiteTexture = UploadRGBA(device, whitePixel, 1, 1); + + r->loadedCarIdx = -1; + + return r; } -void menu_render_gpu_destroy(MenuRendererGPU *r) -{ - if (!r) return; - for (int i = 0; i < MAX_SLOTS; i++) - menu_render_gpu_free_blocks(r, i); - if (r->blackTexture) SDL_ReleaseGPUTexture(r->device, r->blackTexture); - FreeMeshPreview(r->device, &r->carMesh, r->whiteTexture); - FreeMeshPreview(r->device, &r->trackMesh, r->whiteTexture); - if (r->whiteTexture) SDL_ReleaseGPUTexture(r->device, r->whiteTexture); - if (r->depthTexture) SDL_ReleaseGPUTexture(r->device, r->depthTexture); - if (r->meshPipeline) SDL_ReleaseGPUGraphicsPipeline(r->device, r->meshPipeline); - if (r->meshPipelineNoDepth) SDL_ReleaseGPUGraphicsPipeline(r->device, r->meshPipelineNoDepth); - SDL_ReleaseGPUBuffer(r->device, r->vertexBuffer); - SDL_ReleaseGPUTransferBuffer(r->device, r->vertexTransferBuffer); - SDL_ReleaseGPUSampler(r->device, r->sampler); - SDL_ReleaseGPUGraphicsPipeline(r->device, r->pipeline); - free(r); +void menu_render_gpu_destroy(MenuRendererGPU *r) { + if (!r) + return; + for (int i = 0; i < MAX_SLOTS; i++) + menu_render_gpu_free_blocks(r, i); + if (r->blackTexture) + SDL_ReleaseGPUTexture(r->device, r->blackTexture); + FreeMeshPreview(r->device, &r->carMesh, r->whiteTexture); + FreeMeshPreview(r->device, &r->trackMesh, r->whiteTexture); + if (r->whiteTexture) + SDL_ReleaseGPUTexture(r->device, r->whiteTexture); + if (r->depthTexture) + SDL_ReleaseGPUTexture(r->device, r->depthTexture); + if (r->meshPipeline) + SDL_ReleaseGPUGraphicsPipeline(r->device, r->meshPipeline); + if (r->meshPipelineNoDepth) + SDL_ReleaseGPUGraphicsPipeline(r->device, r->meshPipelineNoDepth); + SDL_ReleaseGPUBuffer(r->device, r->vertexBuffer); + SDL_ReleaseGPUTransferBuffer(r->device, r->vertexTransferBuffer); + SDL_ReleaseGPUSampler(r->device, r->sampler); + SDL_ReleaseGPUGraphicsPipeline(r->device, r->pipeline); + free(r); } //--------------------------------------------------------------------------- // Frame lifecycle //--------------------------------------------------------------------------- -void menu_render_gpu_begin_frame(MenuRendererGPU *r) -{ - r->vertexCount = 0; - r->drawCommandCount = 0; - r->meshDrawCount = 0; - r->currentLayer = MENU_LAYER_BACKGROUND; - - r->cmdBuf = SDL_AcquireGPUCommandBuffer(r->device); - if (!r->cmdBuf) return; - - if (!SDL_WaitAndAcquireGPUSwapchainTexture(r->cmdBuf, r->window, - &r->swapchainTexture, &r->swapchainWidth, &r->swapchainHeight) - || !r->swapchainTexture) { - SDL_CancelGPUCommandBuffer(r->cmdBuf); - r->cmdBuf = NULL; - return; - } +void menu_render_gpu_begin_frame(MenuRendererGPU *r) { + r->vertexCount = 0; + r->drawCommandCount = 0; + r->meshDrawCount = 0; + r->currentLayer = MENU_LAYER_BACKGROUND; + + r->cmdBuf = SDL_AcquireGPUCommandBuffer(r->device); + if (!r->cmdBuf) + return; + + if (!SDL_WaitAndAcquireGPUSwapchainTexture( + r->cmdBuf, r->window, &r->swapchainTexture, &r->swapchainWidth, + &r->swapchainHeight) || + !r->swapchainTexture) { + SDL_CancelGPUCommandBuffer(r->cmdBuf); + r->cmdBuf = NULL; + return; + } } -void menu_render_gpu_set_layer(MenuRendererGPU *r, MenuDrawLayer layer) -{ - r->currentLayer = layer; +void menu_render_gpu_set_layer(MenuRendererGPU *r, MenuDrawLayer layer) { + r->currentLayer = layer; } -void menu_render_gpu_end_frame(MenuRendererGPU *r) -{ - if (!r->cmdBuf) return; +void menu_render_gpu_end_frame(MenuRendererGPU *r) { + if (!r->cmdBuf) + return; - // Step fade and emit overlay quad (before copy pass so vertices are included) - if (r->fadeActive) { - r->fadeAlpha += r->fadeStep; - if (r->fadeAlpha <= 0.0f) { r->fadeAlpha = 0.0f; r->fadeActive = 0; } - if (r->fadeAlpha >= 1.0f) { r->fadeAlpha = 1.0f; r->fadeActive = 0; } - } - if (r->fadeAlpha > 0.001f && r->blackTexture) { - EmitQuad(r, 0, 0, MENU_WIDTH, MENU_HEIGHT, 0, 0, 1, 1); - RecordDraw(r, r->blackTexture, r->fadeAlpha, -1, NULL); + // Step fade and emit overlay quad (before copy pass so vertices are included) + if (r->fadeActive) { + r->fadeAlpha += r->fadeStep; + if (r->fadeAlpha <= 0.0f) { + r->fadeAlpha = 0.0f; + r->fadeActive = 0; } - - // Phase 1: Copy pass — upload all accumulated vertex data - if (r->vertexCount > 0) { - void *mapped = SDL_MapGPUTransferBuffer(r->device, r->vertexTransferBuffer, true); - memcpy(mapped, r->vertices, r->vertexCount * sizeof(MenuVertex)); - SDL_UnmapGPUTransferBuffer(r->device, r->vertexTransferBuffer); - - SDL_GPUCopyPass *cp = SDL_BeginGPUCopyPass(r->cmdBuf); - SDL_GPUTransferBufferLocation tbLoc = { .transfer_buffer = r->vertexTransferBuffer }; - SDL_GPUBufferRegion bufReg = { .buffer = r->vertexBuffer, - .size = r->vertexCount * sizeof(MenuVertex) }; - SDL_UploadToGPUBuffer(cp, &tbLoc, &bufReg, false); - SDL_EndGPUCopyPass(cp); - } - - // Phase 2: Render pass — replay all recorded draw commands - EnsureDepthTexture(r); - - SDL_GPUColorTargetInfo ct = {0}; - ct.texture = r->swapchainTexture; - ct.load_op = SDL_GPU_LOADOP_CLEAR; - ct.store_op = SDL_GPU_STOREOP_STORE; - ct.clear_color = (SDL_FColor){0, 0, 0, 1}; - - SDL_GPUDepthStencilTargetInfo dsi = {0}; - dsi.texture = r->depthTexture; - dsi.load_op = SDL_GPU_LOADOP_CLEAR; - dsi.store_op = SDL_GPU_STOREOP_DONT_CARE; - dsi.clear_depth = 1.0f; - - SDL_GPURenderPass *renderPass = SDL_BeginGPURenderPass(r->cmdBuf, &ct, 1, - r->depthTexture ? &dsi : NULL); - - // Set viewport for aspect-ratio preservation - SDL_GPUViewport vp = {0}; - float wAsp = (float)r->swapchainWidth / (float)r->swapchainHeight; - float mAsp = (float)MENU_WIDTH / (float)MENU_HEIGHT; - if (wAsp > mAsp) { - vp.h = (float)r->swapchainHeight; - vp.w = mAsp * r->swapchainHeight; - vp.x = (r->swapchainWidth - vp.w) / 2.0f; - } else { - vp.w = (float)r->swapchainWidth; - vp.h = r->swapchainWidth / mAsp; - vp.y = (r->swapchainHeight - vp.h) / 2.0f; + if (r->fadeAlpha >= 1.0f) { + r->fadeAlpha = 1.0f; + r->fadeActive = 0; } - vp.max_depth = 1.0f; - SDL_SetGPUViewport(renderPass, &vp); - - // Background 2D draws (behind 3D preview) - ReplayDrawsLayer(r, renderPass, MENU_LAYER_BACKGROUND, MENU_LAYER_BACKGROUND); - - // 3D mesh draws (car/track previews) - ReplayMeshDraws(r, renderPass); - - // Restore full viewport for foreground 2D draws - SDL_SetGPUViewport(renderPass, &vp); - - // Foreground 2D draws (on top of 3D preview) - ReplayDrawsLayer(r, renderPass, MENU_LAYER_FOREGROUND, MENU_LAYER_FOREGROUND); - - SDL_EndGPURenderPass(renderPass); - debug_overlay_render(ROLLERGetDebugOverlay(), r->cmdBuf, - r->swapchainTexture, r->swapchainWidth, r->swapchainHeight); - SDL_SubmitGPUCommandBuffer(r->cmdBuf); - r->cmdBuf = NULL; + } + if (r->fadeAlpha > 0.001f && r->blackTexture) { + EmitQuad(r, 0, 0, MENU_WIDTH, MENU_HEIGHT, 0, 0, 1, 1); + RecordDraw(r, r->blackTexture, r->fadeAlpha, -1, NULL); + } + + // Phase 1: Copy pass — upload all accumulated vertex data + if (r->vertexCount > 0) { + void *mapped = + SDL_MapGPUTransferBuffer(r->device, r->vertexTransferBuffer, true); + memcpy(mapped, r->vertices, r->vertexCount * sizeof(MenuVertex)); + SDL_UnmapGPUTransferBuffer(r->device, r->vertexTransferBuffer); + + SDL_GPUCopyPass *cp = SDL_BeginGPUCopyPass(r->cmdBuf); + SDL_GPUTransferBufferLocation tbLoc = {.transfer_buffer = + r->vertexTransferBuffer}; + SDL_GPUBufferRegion bufReg = {.buffer = r->vertexBuffer, + .size = r->vertexCount * sizeof(MenuVertex)}; + SDL_UploadToGPUBuffer(cp, &tbLoc, &bufReg, false); + SDL_EndGPUCopyPass(cp); + } + + // Phase 2: Render pass — replay all recorded draw commands + EnsureDepthTexture(r); + + SDL_GPUColorTargetInfo ct = {0}; + ct.texture = r->swapchainTexture; + ct.load_op = SDL_GPU_LOADOP_CLEAR; + ct.store_op = SDL_GPU_STOREOP_STORE; + ct.clear_color = (SDL_FColor){0, 0, 0, 1}; + + SDL_GPUDepthStencilTargetInfo dsi = {0}; + dsi.texture = r->depthTexture; + dsi.load_op = SDL_GPU_LOADOP_CLEAR; + dsi.store_op = SDL_GPU_STOREOP_DONT_CARE; + dsi.clear_depth = 1.0f; + + SDL_GPURenderPass *renderPass = + SDL_BeginGPURenderPass(r->cmdBuf, &ct, 1, r->depthTexture ? &dsi : NULL); + + // Set viewport for aspect-ratio preservation + SDL_GPUViewport vp = {0}; + float wAsp = (float)r->swapchainWidth / (float)r->swapchainHeight; + float mAsp = (float)MENU_WIDTH / (float)MENU_HEIGHT; + if (wAsp > mAsp) { + vp.h = (float)r->swapchainHeight; + vp.w = mAsp * r->swapchainHeight; + vp.x = (r->swapchainWidth - vp.w) / 2.0f; + } else { + vp.w = (float)r->swapchainWidth; + vp.h = r->swapchainWidth / mAsp; + vp.y = (r->swapchainHeight - vp.h) / 2.0f; + } + vp.max_depth = 1.0f; + SDL_SetGPUViewport(renderPass, &vp); + + // Background 2D draws (behind 3D preview) + ReplayDrawsLayer(r, renderPass, MENU_LAYER_BACKGROUND, MENU_LAYER_BACKGROUND); + + // 3D mesh draws (car/track previews) + ReplayMeshDraws(r, renderPass); + + // Restore full viewport for foreground 2D draws + SDL_SetGPUViewport(renderPass, &vp); + + // Foreground 2D draws (on top of 3D preview) + ReplayDrawsLayer(r, renderPass, MENU_LAYER_FOREGROUND, MENU_LAYER_FOREGROUND); + + SDL_EndGPURenderPass(renderPass); + debug_overlay_render(ROLLERGetDebugOverlay(), r->cmdBuf, r->swapchainTexture, + r->swapchainWidth, r->swapchainHeight); + SDL_SubmitGPUCommandBuffer(r->cmdBuf); + r->cmdBuf = NULL; } //--------------------------------------------------------------------------- // Asset conversion //--------------------------------------------------------------------------- -int menu_render_gpu_load_blocks(MenuRendererGPU *r, int slot, tBlockHeader *blocks, const tColor *pal) -{ - if (slot < 0 || slot >= MAX_SLOTS || !blocks) return 0; - menu_render_gpu_free_blocks(r, slot); - - // Count valid sub-blocks - int count = 0; - for (int i = 0; i < MAX_BLOCKS_PER_SLOT; i++) { - if (blocks[i].iWidth <= 0 || blocks[i].iHeight <= 0 || blocks[i].iDataOffset <= 0) - break; - if (blocks[i].iWidth > MENU_WIDTH || blocks[i].iHeight > MENU_HEIGHT) - break; - count++; - } - - if (count == 0) { - // Full-screen background (raw pixels, no block headers) - uint8 *rgba = malloc(MENU_WIDTH * MENU_HEIGHT * 4); - IndexedToRGBA((uint8 *)blocks, pal, rgba, MENU_WIDTH * MENU_HEIGHT); - r->backgroundTextures[slot] = UploadRGBA(r->device, rgba, MENU_WIDTH, MENU_HEIGHT); - free(rgba); - return 1; - } - - r->slotTextures[slot] = calloc(count, sizeof(MenuTexture)); - r->slotTextureCount[slot] = count; - - for (int i = 0; i < count; i++) { - int w = blocks[i].iWidth, h = blocks[i].iHeight; - uint8 *src = (uint8 *)blocks + blocks[i].iDataOffset; - uint8 *rgba = malloc(w * h * 4); - IndexedToRGBA(src, pal, rgba, w * h); - r->slotTextures[slot][i].texture = UploadRGBA(r->device, rgba, w, h); - r->slotTextures[slot][i].width = w; - r->slotTextures[slot][i].height = h; - free(rgba); - } - return count; +int menu_render_gpu_load_blocks(MenuRendererGPU *r, int slot, + tBlockHeader *blocks, const tColor *pal) { + if (slot < 0 || slot >= MAX_SLOTS || !blocks) + return 0; + menu_render_gpu_free_blocks(r, slot); + + // Count valid sub-blocks + int count = 0; + for (int i = 0; i < MAX_BLOCKS_PER_SLOT; i++) { + if (blocks[i].iWidth <= 0 || blocks[i].iHeight <= 0 || + blocks[i].iDataOffset <= 0) + break; + if (blocks[i].iWidth > MENU_WIDTH || blocks[i].iHeight > MENU_HEIGHT) + break; + count++; + } + + if (count == 0) { + // Full-screen background (raw pixels, no block headers) + uint8 *rgba = malloc(MENU_WIDTH * MENU_HEIGHT * 4); + IndexedToRGBA((uint8 *)blocks, pal, rgba, MENU_WIDTH * MENU_HEIGHT); + r->backgroundTextures[slot] = + UploadRGBA(r->device, rgba, MENU_WIDTH, MENU_HEIGHT); + free(rgba); + return 1; + } + + r->slotTextures[slot] = calloc(count, sizeof(MenuTexture)); + r->slotTextureCount[slot] = count; + + for (int i = 0; i < count; i++) { + int w = blocks[i].iWidth, h = blocks[i].iHeight; + uint8 *src = (uint8 *)blocks + blocks[i].iDataOffset; + uint8 *rgba = malloc(w * h * 4); + IndexedToRGBA(src, pal, rgba, w * h); + r->slotTextures[slot][i].texture = UploadRGBA(r->device, rgba, w, h); + r->slotTextures[slot][i].width = w; + r->slotTextures[slot][i].height = h; + free(rgba); + } + return count; } -void menu_render_gpu_free_blocks(MenuRendererGPU *r, int slot) -{ - if (slot < 0 || slot >= MAX_SLOTS) return; - if (r->slotTextures[slot]) { - for (int i = 0; i < r->slotTextureCount[slot]; i++) - if (r->slotTextures[slot][i].texture) - SDL_ReleaseGPUTexture(r->device, r->slotTextures[slot][i].texture); - free(r->slotTextures[slot]); - r->slotTextures[slot] = NULL; - r->slotTextureCount[slot] = 0; - } - if (r->backgroundTextures[slot]) { - SDL_ReleaseGPUTexture(r->device, r->backgroundTextures[slot]); - r->backgroundTextures[slot] = NULL; - } +void menu_render_gpu_free_blocks(MenuRendererGPU *r, int slot) { + if (slot < 0 || slot >= MAX_SLOTS) + return; + if (r->slotTextures[slot]) { + for (int i = 0; i < r->slotTextureCount[slot]; i++) + if (r->slotTextures[slot][i].texture) + SDL_ReleaseGPUTexture(r->device, r->slotTextures[slot][i].texture); + free(r->slotTextures[slot]); + r->slotTextures[slot] = NULL; + r->slotTextureCount[slot] = 0; + } + if (r->backgroundTextures[slot]) { + SDL_ReleaseGPUTexture(r->device, r->backgroundTextures[slot]); + r->backgroundTextures[slot] = NULL; + } } //--------------------------------------------------------------------------- // Draw calls //--------------------------------------------------------------------------- -void menu_render_gpu_clear(MenuRendererGPU *r, uint8 colorIndex, const tColor *pal) -{ - (void)r; (void)colorIndex; (void)pal; - // Clear already done by render pass LOADOP_CLEAR (black). +void menu_render_gpu_clear(MenuRendererGPU *r, uint8 colorIndex, + const tColor *pal) { + (void)r; + (void)colorIndex; + (void)pal; + // Clear already done by render pass LOADOP_CLEAR (black). } -void menu_render_gpu_background(MenuRendererGPU *r, int slot) -{ - if (slot < 0 || slot >= MAX_SLOTS || !r->backgroundTextures[slot]) return; - EmitQuad(r, 0, 0, MENU_WIDTH, MENU_HEIGHT, 0, 0, 1, 1); - RecordDraw(r, r->backgroundTextures[slot], 1.0f, -1, NULL); +void menu_render_gpu_background(MenuRendererGPU *r, int slot) { + if (slot < 0 || slot >= MAX_SLOTS || !r->backgroundTextures[slot]) + return; + EmitQuad(r, 0, 0, MENU_WIDTH, MENU_HEIGHT, 0, 0, 1, 1); + RecordDraw(r, r->backgroundTextures[slot], 1.0f, -1, NULL); } -void menu_render_gpu_sprite(MenuRendererGPU *r, int slot, int blockIdx, int x, int y, - int transparentIdx, const tColor *pal) -{ - if (slot < 0 || slot >= MAX_SLOTS) return; - if (!r->slotTextures[slot] || blockIdx >= r->slotTextureCount[slot]) return; - MenuTexture *mt = &r->slotTextures[slot][blockIdx]; - if (!mt->texture) return; - EmitQuad(r, (float)x, (float)y, (float)mt->width, (float)mt->height, 0, 0, 1, 1); - RecordDraw(r, mt->texture, 1.0f, transparentIdx, pal); +void menu_render_gpu_sprite(MenuRendererGPU *r, int slot, int blockIdx, int x, + int y, int transparentIdx, const tColor *pal) { + if (slot < 0 || slot >= MAX_SLOTS) + return; + if (!r->slotTextures[slot] || blockIdx >= r->slotTextureCount[slot]) + return; + MenuTexture *mt = &r->slotTextures[slot][blockIdx]; + if (!mt->texture) + return; + EmitQuad(r, (float)x, (float)y, (float)mt->width, (float)mt->height, 0, 0, 1, + 1); + RecordDraw(r, mt->texture, 1.0f, transparentIdx, pal); } //--------------------------------------------------------------------------- @@ -840,132 +890,159 @@ void menu_render_gpu_sprite(MenuRendererGPU *r, int slot, int blockIdx, int x, i //--------------------------------------------------------------------------- void menu_render_gpu_text(MenuRendererGPU *r, int fontSlot, const char *text, - const char *mappingTable, int *charVOffsets, - int x, int y, uint8 colorReplace, int alignment, - const tColor *pal) -{ - if (!text || fontSlot < 0 || fontSlot >= MAX_SLOTS || !r->slotTextures[fontSlot]) - return; - - // Pass 1: measure width - int totalWidth = 0; - for (const char *p = text; *p; p++) { - if (*p == '\n') continue; - uint8 idx = mappingTable[(uint8)*p]; - if (idx == 0xFF) { totalWidth += 8; continue; } - if (idx < r->slotTextureCount[fontSlot]) - totalWidth += r->slotTextures[fontSlot][idx].width + 1; + const char *mappingTable, int *charVOffsets, int x, + int y, uint8 colorReplace, int alignment, + const tColor *pal) { + if (!text || fontSlot < 0 || fontSlot >= MAX_SLOTS || + !r->slotTextures[fontSlot]) + return; + + // Pass 1: measure width + int totalWidth = 0; + for (const char *p = text; *p; p++) { + if (*p == '\n') + continue; + uint8 idx = mappingTable[(uint8)*p]; + if (idx == 0xFF) { + totalWidth += 8; + continue; } - if (totalWidth > 0) totalWidth--; - - // Apply alignment - int curX = x; - if (alignment == 1) curX = x - totalWidth / 2; - else if (alignment == 2) curX = x - totalWidth; + if (idx < r->slotTextureCount[fontSlot]) + totalWidth += r->slotTextures[fontSlot][idx].width + 1; + } + if (totalWidth > 0) + totalWidth--; + + // Apply alignment + int curX = x; + if (alignment == 1) + curX = x - totalWidth / 2; + else if (alignment == 2) + curX = x - totalWidth; + + // Pass 2: render glyphs + for (const char *p = text; *p; p++) { + if (*p == '\n') + continue; + uint8 idx = mappingTable[(uint8)*p]; + if (idx == 0xFF) { + curX += 8; + continue; + } + if (idx >= r->slotTextureCount[fontSlot]) + continue; - // Pass 2: render glyphs - for (const char *p = text; *p; p++) { - if (*p == '\n') continue; - uint8 idx = mappingTable[(uint8)*p]; - if (idx == 0xFF) { curX += 8; continue; } - if (idx >= r->slotTextureCount[fontSlot]) continue; + MenuTexture *g = &r->slotTextures[fontSlot][idx]; + if (!g->texture) + continue; - MenuTexture *g = &r->slotTextures[fontSlot][idx]; - if (!g->texture) continue; + int cy = y + (charVOffsets ? charVOffsets[idx] : 0); - int cy = y + (charVOffsets ? charVOffsets[idx] : 0); + EmitQuad(r, (float)curX, (float)cy, (float)g->width, (float)g->height, 0, 0, + 1, 1); + RecordDrawWithColorReplace(r, g->texture, 1.0f, 0x8F, colorReplace, pal); - EmitQuad(r, (float)curX, (float)cy, (float)g->width, (float)g->height, - 0, 0, 1, 1); - RecordDrawWithColorReplace(r, g->texture, 1.0f, 0x8F, colorReplace, pal); + curX += g->width + 1; + } +} - curX += g->width + 1; +void menu_render_gpu_scaled_text(MenuRendererGPU *r, int fontSlot, + const char *text, const char *mappingTable, + int *charVOffsets, int x, int y, + uint8 colorReplace, unsigned int alignment, + int clipLeft, int clipRight, + const tColor *pal) { + if (!text || fontSlot < 0 || fontSlot >= MAX_SLOTS || + !r->slotTextures[fontSlot]) + return; + + // Measure unscaled width + int totalWidth = 0; + for (const char *p = text; *p; p++) { + uint8 idx = (uint8)mappingTable[(uint8)*p]; + if (idx < r->slotTextureCount[fontSlot]) + totalWidth += r->slotTextures[fontSlot][idx].width + 1; + } + if (totalWidth > 0) + totalWidth--; + + // Scale factor + int avail = clipRight - clipLeft; + float scale = 1.0f; + if (totalWidth > avail && avail > 0) + scale = (float)avail / (float)totalWidth; + + float scaledWidth = totalWidth * scale; + + // Alignment + float startX = (float)x; + if (alignment == 1) + startX = x - scaledWidth / 2.0f; + else if (alignment == 2) + startX = x - scaledWidth; + + // Render scaled glyphs + float curX = startX; + for (const char *p = text; *p; p++) { + if (*p == '\n') + continue; + uint8 idx = (uint8)mappingTable[(uint8)*p]; + if (idx == 0xFF) { + curX += 8 * scale; + continue; } -} + if (idx >= r->slotTextureCount[fontSlot]) + continue; -void menu_render_gpu_scaled_text(MenuRendererGPU *r, int fontSlot, const char *text, - const char *mappingTable, int *charVOffsets, - int x, int y, uint8 colorReplace, - unsigned int alignment, int clipLeft, int clipRight, - const tColor *pal) -{ - if (!text || fontSlot < 0 || fontSlot >= MAX_SLOTS || !r->slotTextures[fontSlot]) - return; - - // Measure unscaled width - int totalWidth = 0; - for (const char *p = text; *p; p++) { - uint8 idx = (uint8)mappingTable[(uint8)*p]; - if (idx < r->slotTextureCount[fontSlot]) - totalWidth += r->slotTextures[fontSlot][idx].width + 1; + MenuTexture *g = &r->slotTextures[fontSlot][idx]; + if (!g->texture) { + curX += scale; + continue; } - if (totalWidth > 0) totalWidth--; - - // Scale factor - int avail = clipRight - clipLeft; - float scale = 1.0f; - if (totalWidth > avail && avail > 0) - scale = (float)avail / (float)totalWidth; - - float scaledWidth = totalWidth * scale; - - // Alignment - float startX = (float)x; - if (alignment == 1) startX = x - scaledWidth / 2.0f; - else if (alignment == 2) startX = x - scaledWidth; - - // Render scaled glyphs - float curX = startX; - for (const char *p = text; *p; p++) { - if (*p == '\n') continue; - uint8 idx = (uint8)mappingTable[(uint8)*p]; - if (idx == 0xFF) { curX += 8 * scale; continue; } - if (idx >= r->slotTextureCount[fontSlot]) continue; - - MenuTexture *g = &r->slotTextures[fontSlot][idx]; - if (!g->texture) { curX += scale; continue; } - - float cw = g->width * scale; - float ch = g->height * scale; - int cy = y + (charVOffsets ? charVOffsets[idx] : 0); - - if (curX + cw >= clipLeft && curX <= clipRight) { - EmitQuad(r, curX, (float)cy, cw, ch, 0, 0, 1, 1); - RecordDrawWithColorReplace(r, g->texture, 1.0f, 0x8F, - (uint8)colorReplace, pal); - } - - curX += cw + scale; + + float cw = g->width * scale; + float ch = g->height * scale; + int cy = y + (charVOffsets ? charVOffsets[idx] : 0); + + if (curX + cw >= clipLeft && curX <= clipRight) { + EmitQuad(r, curX, (float)cy, cw, ch, 0, 0, 1, 1); + RecordDrawWithColorReplace(r, g->texture, 1.0f, 0x8F, (uint8)colorReplace, + pal); } + + curX += cw + scale; + } } //--------------------------------------------------------------------------- // Fade system //--------------------------------------------------------------------------- -void menu_render_gpu_begin_fade(MenuRendererGPU *r, int direction, int durationFrames) -{ - if (durationFrames <= 0) durationFrames = 32; - if (direction == 0) { - // Fade out: overlay goes from transparent to opaque - r->fadeStep = 1.0f / (float)durationFrames; - } else { - // Fade in: overlay goes from opaque to transparent - r->fadeAlpha = 1.0f; - r->fadeStep = -1.0f / (float)durationFrames; - } - r->fadeActive = 1; +void menu_render_gpu_begin_fade(MenuRendererGPU *r, int direction, + int durationFrames) { + if (durationFrames <= 0) + durationFrames = 32; + if (direction == 0) { + // Fade out: overlay goes from transparent to opaque + r->fadeStep = 1.0f / (float)durationFrames; + } else { + // Fade in: overlay goes from opaque to transparent + r->fadeAlpha = 1.0f; + r->fadeStep = -1.0f / (float)durationFrames; + } + r->fadeActive = 1; } int menu_render_gpu_fade_active(MenuRendererGPU *r) { return r->fadeActive; } -void menu_render_gpu_fade_wait(MenuRendererGPU *r, void (*redraw_fn)(void *ctx), void *ctx) -{ - while (menu_render_gpu_fade_active(r)) { - menu_render_gpu_begin_frame(r); - if (redraw_fn) redraw_fn(ctx); - menu_render_gpu_end_frame(r); - } +void menu_render_gpu_fade_wait(MenuRendererGPU *r, void (*redraw_fn)(void *ctx), + void *ctx) { + while (menu_render_gpu_fade_active(r)) { + menu_render_gpu_begin_frame(r); + if (redraw_fn) + redraw_fn(ctx); + menu_render_gpu_end_frame(r); + } } //--------------------------------------------------------------------------- @@ -973,70 +1050,90 @@ void menu_render_gpu_fade_wait(MenuRendererGPU *r, void (*redraw_fn)(void *ctx), // Column-major: m[col*4 + row], i.e. m[0..3]=col0, m[4..7]=col1, etc. //--------------------------------------------------------------------------- -static void Mat4Multiply(float *out, const float *a, const float *b) -{ - float tmp[16]; - for (int c = 0; c < 4; c++) { - for (int r = 0; r < 4; r++) { - tmp[c * 4 + r] = - a[0 * 4 + r] * b[c * 4 + 0] + - a[1 * 4 + r] * b[c * 4 + 1] + - a[2 * 4 + r] * b[c * 4 + 2] + - a[3 * 4 + r] * b[c * 4 + 3]; - } +static void Mat4Multiply(float *out, const float *a, const float *b) { + float tmp[16]; + for (int c = 0; c < 4; c++) { + for (int r = 0; r < 4; r++) { + tmp[c * 4 + r] = + a[0 * 4 + r] * b[c * 4 + 0] + a[1 * 4 + r] * b[c * 4 + 1] + + a[2 * 4 + r] * b[c * 4 + 2] + a[3 * 4 + r] * b[c * 4 + 3]; } - memcpy(out, tmp, sizeof(tmp)); + } + memcpy(out, tmp, sizeof(tmp)); } -static void MakePerspective(float *m, float fovY, float aspect, float zNear, float zFar) -{ - memset(m, 0, 16 * sizeof(float)); - float f = 1.0f / tanf(fovY * 0.5f); - m[0] = f / aspect; - m[5] = f; - m[10] = zFar / (zNear - zFar); - m[11] = -1.0f; - m[14] = (zNear * zFar) / (zNear - zFar); +static void MakePerspective(float *m, float fovY, float aspect, float zNear, + float zFar) { + memset(m, 0, 16 * sizeof(float)); + float f = 1.0f / tanf(fovY * 0.5f); + m[0] = f / aspect; + m[5] = f; + m[10] = zFar / (zNear - zFar); + m[11] = -1.0f; + m[14] = (zNear * zFar) / (zNear - zFar); } -static void MakeLookAt(float *m, float eyeX, float eyeY, float eyeZ, - float atX, float atY, float atZ) -{ - // Forward = normalize(at - eye) - float fx = atX - eyeX, fy = atY - eyeY, fz = atZ - eyeZ; - float flen = sqrtf(fx*fx + fy*fy + fz*fz); - if (flen < 1e-6f) flen = 1.0f; - fx /= flen; fy /= flen; fz /= flen; - - // Right = normalize(cross(forward, up)) where up = (0, 1, 0) - // cross(f, (0,1,0)) = (-fz, 0, fx) - float rx = -fz, ry = 0.0f, rz = fx; - float rlen = sqrtf(rx*rx + ry*ry + rz*rz); - if (rlen < 1e-6f) rlen = 1.0f; - rx /= rlen; ry /= rlen; rz /= rlen; - - // True up = cross(right, forward) - float ux = ry * fz - rz * fy; - float uy = rz * fx - rx * fz; - float uz = rx * fy - ry * fx; - - // Column-major view matrix - m[0] = rx; m[4] = ry; m[8] = rz; m[12] = -(rx*eyeX + ry*eyeY + rz*eyeZ); - m[1] = ux; m[5] = uy; m[9] = uz; m[13] = -(ux*eyeX + uy*eyeY + uz*eyeZ); - m[2] = -fx; m[6] = -fy; m[10] = -fz; m[14] = (fx*eyeX + fy*eyeY + fz*eyeZ); - m[3] = 0.0f; m[7] = 0.0f; m[11] = 0.0f; m[15] = 1.0f; +static void MakeLookAt(float *m, float eyeX, float eyeY, float eyeZ, float atX, + float atY, float atZ) { + // Forward = normalize(at - eye) + float fx = atX - eyeX, fy = atY - eyeY, fz = atZ - eyeZ; + float flen = sqrtf(fx * fx + fy * fy + fz * fz); + if (flen < 1e-6f) + flen = 1.0f; + fx /= flen; + fy /= flen; + fz /= flen; + + // Right = normalize(cross(forward, up)) where up = (0, 1, 0) + // cross(f, (0,1,0)) = (-fz, 0, fx) + float rx = -fz, ry = 0.0f, rz = fx; + float rlen = sqrtf(rx * rx + ry * ry + rz * rz); + if (rlen < 1e-6f) + rlen = 1.0f; + rx /= rlen; + ry /= rlen; + rz /= rlen; + + // True up = cross(right, forward) + float ux = ry * fz - rz * fy; + float uy = rz * fx - rx * fz; + float uz = rx * fy - ry * fx; + + // Column-major view matrix + m[0] = rx; + m[4] = ry; + m[8] = rz; + m[12] = -(rx * eyeX + ry * eyeY + rz * eyeZ); + m[1] = ux; + m[5] = uy; + m[9] = uz; + m[13] = -(ux * eyeX + uy * eyeY + uz * eyeZ); + m[2] = -fx; + m[6] = -fy; + m[10] = -fz; + m[14] = (fx * eyeX + fy * eyeY + fz * eyeZ); + m[3] = 0.0f; + m[7] = 0.0f; + m[11] = 0.0f; + m[15] = 1.0f; } -static void FreeMeshPreview(SDL_GPUDevice *dev, MeshPreview *mp, SDL_GPUTexture *whiteTexture) -{ - if (mp->vertexBuffer) { SDL_ReleaseGPUBuffer(dev, mp->vertexBuffer); mp->vertexBuffer = NULL; } - if (mp->indexBuffer) { SDL_ReleaseGPUBuffer(dev, mp->indexBuffer); mp->indexBuffer = NULL; } - // Don't release whiteTexture — it's shared - if (mp->texture && mp->texture != whiteTexture) - SDL_ReleaseGPUTexture(dev, mp->texture); - mp->texture = NULL; - mp->indexCount = 0; - mp->loaded = false; +static void FreeMeshPreview(SDL_GPUDevice *dev, MeshPreview *mp, + SDL_GPUTexture *whiteTexture) { + if (mp->vertexBuffer) { + SDL_ReleaseGPUBuffer(dev, mp->vertexBuffer); + mp->vertexBuffer = NULL; + } + if (mp->indexBuffer) { + SDL_ReleaseGPUBuffer(dev, mp->indexBuffer); + mp->indexBuffer = NULL; + } + // Don't release whiteTexture — it's shared + if (mp->texture && mp->texture != whiteTexture) + SDL_ReleaseGPUTexture(dev, mp->texture); + mp->texture = NULL; + mp->indexCount = 0; + mp->loaded = false; } //--------------------------------------------------------------------------- @@ -1046,511 +1143,552 @@ static void FreeMeshPreview(SDL_GPUDevice *dev, MeshPreview *mp, SDL_GPUTexture // Build RGBA texture atlas from car's indexed-color tile data. // Layout: 256px wide (4 tiles per row), with one extra white row at bottom. static SDL_GPUTexture *BuildCarTextureAtlas(MenuRendererGPU *r, int carIdx, - const tColor *pal, - int *outNumTiles, int *outAtlasH) -{ - int texSlot = car_texmap[carIdx]; - if (texSlot <= 0) return NULL; - - uint8 *texData = cartex_vga[texSlot - 1]; - if (!texData) return NULL; - - int nTiles = num_textures[texSlot - 1]; - if (nTiles <= 0) return NULL; - - int numRows = (nTiles + 3) / 4; - int atlasW = 256; - int atlasH = numRows * 64 + 1; // +1 row for white pixel - - uint8 *rgba = calloc((size_t)atlasW * atlasH * 4, 1); - if (!rgba) return NULL; - - // Convert sorted indexed-color tiles (4-per-row, 256px wide) to RGBA - for (int t = 0; t < nTiles; t++) { - int col = t % 4; - int row = t / 4; - for (int y = 0; y < 64; y++) { - for (int x = 0; x < 64; x++) { - int srcOff = (row * 64 + y) * 256 + col * 64 + x; - uint8 palIdx = texData[srcOff]; - int ax = col * 64 + x; - int ay = row * 64 + y; - int dstOff = (ay * atlasW + ax) * 4; - const tColor *c = &pal[palIdx]; - rgba[dstOff + 0] = (uint8)(c->byR * 255 / 63); - rgba[dstOff + 1] = (uint8)(c->byG * 255 / 63); - rgba[dstOff + 2] = (uint8)(c->byB * 255 / 63); - rgba[dstOff + 3] = palIdx ? 255 : 0; - } - } + const tColor *pal, int *outNumTiles, + int *outAtlasH) { + int texSlot = car_texmap[carIdx]; + if (texSlot <= 0) + return NULL; + + uint8 *texData = cartex_vga[texSlot - 1]; + if (!texData) + return NULL; + + int nTiles = num_textures[texSlot - 1]; + if (nTiles <= 0) + return NULL; + + int numRows = (nTiles + 3) / 4; + int atlasW = 256; + int atlasH = numRows * 64 + 1; // +1 row for white pixel + + uint8 *rgba = calloc((size_t)atlasW * atlasH * 4, 1); + if (!rgba) + return NULL; + + // Convert sorted indexed-color tiles (4-per-row, 256px wide) to RGBA + for (int t = 0; t < nTiles; t++) { + int col = t % 4; + int row = t / 4; + for (int y = 0; y < 64; y++) { + for (int x = 0; x < 64; x++) { + int srcOff = (row * 64 + y) * 256 + col * 64 + x; + uint8 palIdx = texData[srcOff]; + int ax = col * 64 + x; + int ay = row * 64 + y; + int dstOff = (ay * atlasW + ax) * 4; + const tColor *c = &pal[palIdx]; + rgba[dstOff + 0] = (uint8)(c->byR * 255 / 63); + rgba[dstOff + 1] = (uint8)(c->byG * 255 / 63); + rgba[dstOff + 2] = (uint8)(c->byB * 255 / 63); + rgba[dstOff + 3] = palIdx ? 255 : 0; + } } + } - // Fill bottom row with white (flat-colored polygon UVs sample here) - for (int x = 0; x < atlasW; x++) { - int off = ((atlasH - 1) * atlasW + x) * 4; - rgba[off] = rgba[off + 1] = rgba[off + 2] = rgba[off + 3] = 255; - } + // Fill bottom row with white (flat-colored polygon UVs sample here) + for (int x = 0; x < atlasW; x++) { + int off = ((atlasH - 1) * atlasW + x) * 4; + rgba[off] = rgba[off + 1] = rgba[off + 2] = rgba[off + 3] = 255; + } - SDL_GPUTexture *tex = UploadRGBA(r->device, rgba, atlasW, atlasH); - free(rgba); + SDL_GPUTexture *tex = UploadRGBA(r->device, rgba, atlasW, atlasH); + free(rgba); - *outNumTiles = nTiles; - *outAtlasH = atlasH; - return tex; + *outNumTiles = nTiles; + *outAtlasH = atlasH; + return tex; } -void menu_render_gpu_load_car_mesh(MenuRendererGPU *r, int carIdx, const tColor *pal) -{ - if (r->loadedCarIdx == carIdx && r->carMesh.loaded) return; - menu_render_gpu_free_car_mesh(r); - - if (carIdx < 0 || carIdx > CAR_DESIGN_DEATH) return; - - tCarDesign *design = &CarDesigns[carIdx]; - int numPols = design->byNumPols; - int numCoords = design->byNumCoords; - tVec3 *coords = design->pCoords; - tPolygon *pols = design->pPols; - tAnimation *pAnms = design->pAnms; - if (!coords || !pols || numPols == 0) return; - - // Build texture atlas from car texture data - int numTiles = 0, atlasH = 0; - SDL_GPUTexture *atlas = BuildCarTextureAtlas(r, carIdx, pal, - &numTiles, &atlasH); - bool hasAtlas = (atlas != NULL && numTiles > 0); - float fAtlasH = hasAtlas ? (float)atlasH : 1.0f; - - // White pixel UV (center of bottom row, for flat-colored polygons) - float whiteU = hasAtlas ? 0.5f / 256.0f : 0.0f; - float whiteV = hasAtlas ? (atlasH - 0.5f) / fAtlasH : 0.0f; - - // Each quad becomes 4 verts + 6 indices (2 triangles), plus 4+6 for shadow quad - MeshVertex *vertices = calloc(numPols * 4 + 4, sizeof(MeshVertex)); - uint32 *indices = calloc(numPols * 6 + 6, sizeof(uint32)); - int vertCount = 0, idxCount = 0; - - tCarColorRemap *remap = &car_flat_remap[carIdx]; - - for (int p = 0; p < numPols; p++) { - uint32 tex = pols[p].uiTex; - if (tex & SURFACE_FLAG_SKIP_RENDER) continue; - - // Resolve animation texture lookups (use frame 0 for menu preview) - if ((tex & CAR_FLAG_ANMS_LOOKUP) && pAnms) { - tex = pAnms[(uint8)tex].framesAy[0]; - } - - bool isTextured = hasAtlas && (tex & SURFACE_FLAG_APPLY_TEXTURE) && - (uint8)tex < numTiles; - - float u0, u1, v0, v1; - float cr, cg, cb, ca; - - if (isTextured) { - // Textured polygon — compute UV rect for tile in atlas - uint8 tileIdx = (uint8)tex; - int col = tileIdx % 4; - int row = tileIdx / 4; - u0 = (col * 64.0f) / 256.0f; - u1 = ((col + 1) * 64.0f) / 256.0f; - v0 = (row * 64.0f) / fAtlasH; - v1 = ((row + 1) * 64.0f) / fAtlasH; - - if (tex & SURFACE_FLAG_FLIP_HORIZ) { - float tmp = u0; u0 = u1; u1 = tmp; - } - if (tex & SURFACE_FLAG_FLIP_VERT) { - float tmp = v0; v0 = v1; v1 = tmp; - } - - // Vertex color = white (texture provides all color) - cr = cg = cb = ca = 1.0f; - } else { - // Flat-colored polygon — palette color via vertex color - uint8 colorIdx = (uint8)tex; - if (!(tex & SURFACE_FLAG_APPLY_TEXTURE) && - remap->uiColorFrom != 0xFFFFFFFF && - colorIdx == (uint8)remap->uiColorFrom) - colorIdx = (uint8)remap->uiColorTo; - - const tColor *c = &pal[colorIdx]; - cr = (c->byR * 255.0f / 63.0f) / 255.0f; - cg = (c->byG * 255.0f / 63.0f) / 255.0f; - cb = (c->byB * 255.0f / 63.0f) / 255.0f; - ca = 1.0f; - - // UV points to white pixel in atlas - u0 = u1 = whiteU; - v0 = v1 = whiteV; - } - - int baseVert = vertCount; - - // UV mapping matches game's startsx/startsy defaults: - // v0 → (right, top), v1 → (left, top), - // v2 → (left, bottom), v3 → (right, bottom) - float uvs[4][2] = { - { u1, v0 }, { u0, v0 }, { u0, v1 }, { u1, v1 } - }; - - for (int v = 0; v < 4; v++) { - uint8 vi = pols[p].verts[v]; - if (vi >= numCoords) vi = 0; - - MeshVertex *mv = &vertices[vertCount++]; - // Game uses Z-up (X=forward, Y=lateral, Z=up); - // GPU pipeline uses Y-up (X=right, Y=up, Z=depth) - mv->position[0] = coords[vi].fY; // GPU X = model lateral - mv->position[1] = coords[vi].fZ; // GPU Y = model up - mv->position[2] = coords[vi].fX; // GPU Z = model forward - mv->uv[0] = uvs[v][0]; - mv->uv[1] = uvs[v][1]; - mv->color[0] = cr; - mv->color[1] = cg; - mv->color[2] = cb; - mv->color[3] = ca; - } - - // Two triangles: (0,1,2) and (0,2,3) - indices[idxCount++] = baseVert + 0; - indices[idxCount++] = baseVert + 1; - indices[idxCount++] = baseVert + 2; - indices[idxCount++] = baseVert + 0; - indices[idxCount++] = baseVert + 2; - indices[idxCount++] = baseVert + 3; +void menu_render_gpu_load_car_mesh(MenuRendererGPU *r, int carIdx, + const tColor *pal) { + if (r->loadedCarIdx == carIdx && r->carMesh.loaded) + return; + menu_render_gpu_free_car_mesh(r); + + if (carIdx < 0 || carIdx > CAR_DESIGN_DEATH) + return; + + tCarDesign *design = &CarDesigns[carIdx]; + int numPols = design->byNumPols; + int numCoords = design->byNumCoords; + tVec3 *coords = design->pCoords; + tPolygon *pols = design->pPols; + tAnimation *pAnms = design->pAnms; + if (!coords || !pols || numPols == 0) + return; + + // Build texture atlas from car texture data + int numTiles = 0, atlasH = 0; + SDL_GPUTexture *atlas = + BuildCarTextureAtlas(r, carIdx, pal, &numTiles, &atlasH); + bool hasAtlas = (atlas != NULL && numTiles > 0); + float fAtlasH = hasAtlas ? (float)atlasH : 1.0f; + + // White pixel UV (center of bottom row, for flat-colored polygons) + float whiteU = hasAtlas ? 0.5f / 256.0f : 0.0f; + float whiteV = hasAtlas ? (atlasH - 0.5f) / fAtlasH : 0.0f; + + // Each quad becomes 4 verts + 6 indices (2 triangles), plus 4+6 for shadow + // quad + MeshVertex *vertices = calloc(numPols * 4 + 4, sizeof(MeshVertex)); + uint32 *indices = calloc(numPols * 6 + 6, sizeof(uint32)); + int vertCount = 0, idxCount = 0; + + tCarColorRemap *remap = &car_flat_remap[carIdx]; + + for (int p = 0; p < numPols; p++) { + uint32 tex = pols[p].uiTex; + if (tex & SURFACE_FLAG_SKIP_RENDER) + continue; + + // Resolve animation texture lookups (use frame 0 for menu preview) + if ((tex & CAR_FLAG_ANMS_LOOKUP) && pAnms) { + tex = pAnms[(uint8)tex].framesAy[0]; } - // Shadow quad: semi-transparent ground plane computed from mesh bounding box - { - float minX = 1e18f, maxX = -1e18f; - float minY = 1e18f; - float minZ = 1e18f, maxZ = -1e18f; - for (int c = 0; c < numCoords; c++) { - float gx = coords[c].fX, gy = coords[c].fY, gz = coords[c].fZ; - // GPU X = game Y, GPU Y = game Z, GPU Z = game X - if (gy < minX) minX = gy; - if (gy > maxX) maxX = gy; - if (gz < minY) minY = gz; - if (gx < minZ) minZ = gx; - if (gx > maxZ) maxZ = gx; - } - // Place shadow at the bottom of the car - float shadowY = minY; - float shadowCorners[4][3] = { - { minX, shadowY, minZ }, - { minX, shadowY, maxZ }, - { maxX, shadowY, maxZ }, - { maxX, shadowY, minZ }, - }; - int shadowBase = vertCount; - for (int v = 0; v < 4; v++) { - MeshVertex *mv = &vertices[vertCount++]; - mv->position[0] = shadowCorners[v][0]; - mv->position[1] = shadowCorners[v][1]; - mv->position[2] = shadowCorners[v][2]; - mv->uv[0] = whiteU; - mv->uv[1] = whiteV; - mv->color[0] = 0.0f; - mv->color[1] = 0.0f; - mv->color[2] = 0.0f; - mv->color[3] = 0.5f; - } - // CCW winding when viewed from above (+Y) - indices[idxCount++] = shadowBase + 0; - indices[idxCount++] = shadowBase + 1; - indices[idxCount++] = shadowBase + 2; - indices[idxCount++] = shadowBase + 0; - indices[idxCount++] = shadowBase + 2; - indices[idxCount++] = shadowBase + 3; + bool isTextured = + hasAtlas && (tex & SURFACE_FLAG_APPLY_TEXTURE) && (uint8)tex < numTiles; + + float u0, u1, v0, v1; + float cr, cg, cb, ca; + + if (isTextured) { + // Textured polygon — compute UV rect for tile in atlas + uint8 tileIdx = (uint8)tex; + int col = tileIdx % 4; + int row = tileIdx / 4; + u0 = (col * 64.0f) / 256.0f; + u1 = ((col + 1) * 64.0f) / 256.0f; + v0 = (row * 64.0f) / fAtlasH; + v1 = ((row + 1) * 64.0f) / fAtlasH; + + if (tex & SURFACE_FLAG_FLIP_HORIZ) { + float tmp = u0; + u0 = u1; + u1 = tmp; + } + if (tex & SURFACE_FLAG_FLIP_VERT) { + float tmp = v0; + v0 = v1; + v1 = tmp; + } + + // Vertex color = white (texture provides all color) + cr = cg = cb = ca = 1.0f; + } else { + // Flat-colored polygon — palette color via vertex color + uint8 colorIdx = (uint8)tex; + if (!(tex & SURFACE_FLAG_APPLY_TEXTURE) && + remap->uiColorFrom != 0xFFFFFFFF && + colorIdx == (uint8)remap->uiColorFrom) + colorIdx = (uint8)remap->uiColorTo; + + const tColor *c = &pal[colorIdx]; + cr = (c->byR * 255.0f / 63.0f) / 255.0f; + cg = (c->byG * 255.0f / 63.0f) / 255.0f; + cb = (c->byB * 255.0f / 63.0f) / 255.0f; + ca = 1.0f; + + // UV points to white pixel in atlas + u0 = u1 = whiteU; + v0 = v1 = whiteV; } - if (idxCount > 0) { - r->carMesh.vertexBuffer = UploadGPUBuffer(r->device, - SDL_GPU_BUFFERUSAGE_VERTEX, vertices, vertCount * sizeof(MeshVertex)); - r->carMesh.indexBuffer = UploadGPUBuffer(r->device, - SDL_GPU_BUFFERUSAGE_INDEX, indices, idxCount * sizeof(uint32)); - r->carMesh.texture = atlas ? atlas : r->whiteTexture; - r->carMesh.indexCount = idxCount; - r->carMesh.loaded = true; - r->loadedCarIdx = carIdx; - } else if (atlas) { - SDL_ReleaseGPUTexture(r->device, atlas); + int baseVert = vertCount; + + // UV mapping matches game's startsx/startsy defaults: + // v0 → (right, top), v1 → (left, top), + // v2 → (left, bottom), v3 → (right, bottom) + float uvs[4][2] = {{u1, v0}, {u0, v0}, {u0, v1}, {u1, v1}}; + + for (int v = 0; v < 4; v++) { + uint8 vi = pols[p].verts[v]; + if (vi >= numCoords) + vi = 0; + + MeshVertex *mv = &vertices[vertCount++]; + // Game uses Z-up (X=forward, Y=lateral, Z=up); + // GPU pipeline uses Y-up (X=right, Y=up, Z=depth) + mv->position[0] = coords[vi].fY; // GPU X = model lateral + mv->position[1] = coords[vi].fZ; // GPU Y = model up + mv->position[2] = coords[vi].fX; // GPU Z = model forward + mv->uv[0] = uvs[v][0]; + mv->uv[1] = uvs[v][1]; + mv->color[0] = cr; + mv->color[1] = cg; + mv->color[2] = cb; + mv->color[3] = ca; } - free(vertices); - free(indices); + // Two triangles: (0,1,2) and (0,2,3) + indices[idxCount++] = baseVert + 0; + indices[idxCount++] = baseVert + 1; + indices[idxCount++] = baseVert + 2; + indices[idxCount++] = baseVert + 0; + indices[idxCount++] = baseVert + 2; + indices[idxCount++] = baseVert + 3; + } + + // Shadow quad: semi-transparent ground plane computed from mesh bounding box + { + float minX = 1e18f, maxX = -1e18f; + float minY = 1e18f; + float minZ = 1e18f, maxZ = -1e18f; + for (int c = 0; c < numCoords; c++) { + float gx = coords[c].fX, gy = coords[c].fY, gz = coords[c].fZ; + // GPU X = game Y, GPU Y = game Z, GPU Z = game X + if (gy < minX) + minX = gy; + if (gy > maxX) + maxX = gy; + if (gz < minY) + minY = gz; + if (gx < minZ) + minZ = gx; + if (gx > maxZ) + maxZ = gx; + } + // Place shadow at the bottom of the car + float shadowY = minY; + float shadowCorners[4][3] = { + {minX, shadowY, minZ}, + {minX, shadowY, maxZ}, + {maxX, shadowY, maxZ}, + {maxX, shadowY, minZ}, + }; + int shadowBase = vertCount; + for (int v = 0; v < 4; v++) { + MeshVertex *mv = &vertices[vertCount++]; + mv->position[0] = shadowCorners[v][0]; + mv->position[1] = shadowCorners[v][1]; + mv->position[2] = shadowCorners[v][2]; + mv->uv[0] = whiteU; + mv->uv[1] = whiteV; + mv->color[0] = 0.0f; + mv->color[1] = 0.0f; + mv->color[2] = 0.0f; + mv->color[3] = 0.5f; + } + // CCW winding when viewed from above (+Y) + indices[idxCount++] = shadowBase + 0; + indices[idxCount++] = shadowBase + 1; + indices[idxCount++] = shadowBase + 2; + indices[idxCount++] = shadowBase + 0; + indices[idxCount++] = shadowBase + 2; + indices[idxCount++] = shadowBase + 3; + } + + if (idxCount > 0) { + r->carMesh.vertexBuffer = + UploadGPUBuffer(r->device, SDL_GPU_BUFFERUSAGE_VERTEX, vertices, + vertCount * sizeof(MeshVertex)); + r->carMesh.indexBuffer = + UploadGPUBuffer(r->device, SDL_GPU_BUFFERUSAGE_INDEX, indices, + idxCount * sizeof(uint32)); + r->carMesh.texture = atlas ? atlas : r->whiteTexture; + r->carMesh.indexCount = idxCount; + r->carMesh.loaded = true; + r->loadedCarIdx = carIdx; + } else if (atlas) { + SDL_ReleaseGPUTexture(r->device, atlas); + } + + free(vertices); + free(indices); } -void menu_render_gpu_free_car_mesh(MenuRendererGPU *r) -{ - FreeMeshPreview(r->device, &r->carMesh, r->whiteTexture); - r->loadedCarIdx = -1; +void menu_render_gpu_free_car_mesh(MenuRendererGPU *r) { + FreeMeshPreview(r->device, &r->carMesh, r->whiteTexture); + r->loadedCarIdx = -1; } -void menu_render_gpu_draw_car_preview(MenuRendererGPU *r, float angle, float distance, - int carYaw, - int destX, int destY, int destW, int destH) -{ - if (!r->carMesh.loaded || r->meshDrawCount >= MAX_MESH_DRAWS) return; - - // Convert TRIG angle (0-16383) to radians - float rad = angle * (2.0f * 3.14159265f / 16384.0f); - - // Game uses Z-up: camera at world(-dist*cos, 0, dist*sin) - // After Z-up to Y-up conversion: X=lateral, Y=up, Z=forward - float eyeX = 0.0f; // world Y (lateral) = 0 - float eyeY = distance * sinf(rad); // world Z (up) = dist*sin - float eyeZ = -distance * cosf(rad); // world X (forward) = -dist*cos - - // Build model rotation from car yaw (rotation around Y axis in GPU space) - // Negate to match game's rotation convention (original DrawCar rotates - // X' = cos*X - sin*Y; column-major layout inverts without negation) - float yawRad = -(float)carYaw * (2.0f * 3.14159265f / 16384.0f); - float cy = cosf(yawRad), sy = sinf(yawRad); - float model[16] = { - cy, 0.0f, sy, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - -sy, 0.0f, cy, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; - - float view[16], proj[16], mv[16], mvp[16]; - MakeLookAt(view, eyeX, eyeY, eyeZ, 0.0f, 0.0f, 0.0f); - float aspect = (float)destW / (float)destH; - float fov = 2.0f * atanf(81.0f / (float)VIEWDIST); - MakePerspective(proj, fov, aspect, 1.0f, distance * 4.0f); - Mat4Multiply(mv, view, model); // view * model - Mat4Multiply(mvp, proj, mv); // proj * view * model - - // Expand viewport to full width and bottom to avoid clipping, compensate in MVP - int padLeft = destX; - int padRight = MENU_WIDTH - (destX + destW); - int totalW = destW + padLeft + padRight; - float Sx = (float)destW / (float)totalW; - float Tx = (float)(padLeft - padRight) / (float)totalW; - for (int j = 0; j < 4; j++) - mvp[j * 4] = Sx * mvp[j * 4] + Tx * mvp[j * 4 + 3]; - - int padBottom = MENU_HEIGHT - (destY + destH); - int totalH = destH + padBottom; - float Sy = (float)destH / (float)totalH; - float Ty = (float)padBottom / (float)totalH; - for (int j = 0; j < 4; j++) - mvp[j * 4 + 1] = Sy * mvp[j * 4 + 1] + Ty * mvp[j * 4 + 3]; - - MeshDrawCommand *cmd = &r->meshDraws[r->meshDrawCount++]; - cmd->vertexBuffer = r->carMesh.vertexBuffer; - cmd->indexBuffer = r->carMesh.indexBuffer; - cmd->texture = r->carMesh.texture; - cmd->indexCount = r->carMesh.indexCount; - memcpy(cmd->mvp, mvp, sizeof(mvp)); - cmd->vpX = (float)(destX - padLeft); - cmd->vpY = (float)destY; - cmd->vpW = (float)totalW; - cmd->vpH = (float)totalH; - cmd->useDepth = true; +void menu_render_gpu_draw_car_preview(MenuRendererGPU *r, float angle, + float distance, int carYaw, int destX, + int destY, int destW, int destH) { + if (!r->carMesh.loaded || r->meshDrawCount >= MAX_MESH_DRAWS) + return; + + // Convert TRIG angle (0-16383) to radians + float rad = angle * (2.0f * 3.14159265f / 16384.0f); + + // Game uses Z-up: camera at world(-dist*cos, 0, dist*sin) + // After Z-up to Y-up conversion: X=lateral, Y=up, Z=forward + float eyeX = 0.0f; // world Y (lateral) = 0 + float eyeY = distance * sinf(rad); // world Z (up) = dist*sin + float eyeZ = -distance * cosf(rad); // world X (forward) = -dist*cos + + // Build model rotation from car yaw (rotation around Y axis in GPU space) + // Negate to match game's rotation convention (original DrawCar rotates + // X' = cos*X - sin*Y; column-major layout inverts without negation) + float yawRad = -(float)carYaw * (2.0f * 3.14159265f / 16384.0f); + float cy = cosf(yawRad), sy = sinf(yawRad); + float model[16] = {cy, 0.0f, sy, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, + -sy, 0.0f, cy, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + float view[16], proj[16], mv[16], mvp[16]; + MakeLookAt(view, eyeX, eyeY, eyeZ, 0.0f, 0.0f, 0.0f); + float aspect = (float)destW / (float)destH; + float fov = 2.0f * atanf(81.0f / (float)VIEWDIST); + MakePerspective(proj, fov, aspect, 1.0f, distance * 4.0f); + Mat4Multiply(mv, view, model); // view * model + Mat4Multiply(mvp, proj, mv); // proj * view * model + + // Expand viewport to full width and bottom to avoid clipping, compensate in + // MVP + int padLeft = destX; + int padRight = MENU_WIDTH - (destX + destW); + int totalW = destW + padLeft + padRight; + float Sx = (float)destW / (float)totalW; + float Tx = (float)(padLeft - padRight) / (float)totalW; + for (int j = 0; j < 4; j++) + mvp[j * 4] = Sx * mvp[j * 4] + Tx * mvp[j * 4 + 3]; + + int padBottom = MENU_HEIGHT - (destY + destH); + int totalH = destH + padBottom; + float Sy = (float)destH / (float)totalH; + float Ty = (float)padBottom / (float)totalH; + for (int j = 0; j < 4; j++) + mvp[j * 4 + 1] = Sy * mvp[j * 4 + 1] + Ty * mvp[j * 4 + 3]; + + MeshDrawCommand *cmd = &r->meshDraws[r->meshDrawCount++]; + cmd->vertexBuffer = r->carMesh.vertexBuffer; + cmd->indexBuffer = r->carMesh.indexBuffer; + cmd->texture = r->carMesh.texture; + cmd->indexCount = r->carMesh.indexCount; + memcpy(cmd->mvp, mvp, sizeof(mvp)); + cmd->vpX = (float)(destX - padLeft); + cmd->vpY = (float)destY; + cmd->vpW = (float)totalW; + cmd->vpH = (float)totalH; + cmd->useDepth = true; } //--------------------------------------------------------------------------- // 3D mesh previews — track map //--------------------------------------------------------------------------- -void menu_render_gpu_load_track_mesh(MenuRendererGPU *r, const tColor *pal) -{ - menu_render_gpu_free_track_mesh(r); - - extern int TRAK_LEN; - if (TRAK_LEN <= 0) return; - - // Compute track center, bounding box, and height range (matching original show_3dmap) - float accX = 0, accY = 0, accZ = 0; - float bbMinX = 1e18f, bbMinY = 1e18f, bbMinZ = 1e18f; - float bbMaxX = -1e18f, bbMaxY = -1e18f, bbMaxZ = -1e18f; - float minZ = 1e18f, maxZ = -1e18f; - for (int i = 0; i < TRAK_LEN; i++) { - accX += TrakPt[i].pointAy[0].fX + TrakPt[i].pointAy[4].fX; - accY += TrakPt[i].pointAy[0].fY + TrakPt[i].pointAy[4].fY; - accZ += TrakPt[i].pointAy[0].fZ + TrakPt[i].pointAy[4].fZ; - for (int p = 0; p <= 4; p += 4) { - float px = TrakPt[i].pointAy[p].fX; - float py = TrakPt[i].pointAy[p].fY; - float pz = TrakPt[i].pointAy[p].fZ; - if (px < bbMinX) bbMinX = px; if (px > bbMaxX) bbMaxX = px; - if (py < bbMinY) bbMinY = py; if (py > bbMaxY) bbMaxY = py; - if (pz < bbMinZ) bbMinZ = pz; if (pz > bbMaxZ) bbMaxZ = pz; - } - if (TrakPt[i].pointAy[2].fZ < minZ) minZ = TrakPt[i].pointAy[2].fZ; - if (TrakPt[i].pointAy[2].fZ > maxZ) maxZ = TrakPt[i].pointAy[2].fZ; - } - float div = 1.0f / (float)(2 * TRAK_LEN); - float cenX = -accX * div; - float cenY = -accY * div; - float cenZ = -accZ * div; - float zRange = maxZ - minZ; - if (zRange < 1.0f) zRange = 1.0f; - - // Expanded bounding box with 10% margin (matching original) - float expandX = (bbMaxX - bbMinX) * 0.1f; - float expandY = (bbMaxY - bbMinY) * 0.1f; - float floorMinX = bbMinX - expandX; - float floorMaxX = bbMaxX + expandX; - float floorMinY = bbMinY - expandY; - float floorMaxY = bbMaxY + expandY; - float bbZRange = bbMaxZ - bbMinZ; - if (bbZRange < 100.0f) bbZRange = 100.0f; - float floorZ = bbMinZ - bbZRange * 0.4f; - - // One quad per 2-chunk segment + 1 floor quad - int numSegments = TRAK_LEN / 2; - MeshVertex *vertices = calloc(numSegments * 4 + 4, sizeof(MeshVertex)); - uint32 *indices = calloc(numSegments * 6 + 6, sizeof(uint32)); - int vertCount = 0, idxCount = 0; - - // Floor quad: semi-transparent plane at bottom of bounding box (color index 2) - { - float fr = 0.0f, fg = 0.0f, fb = 0.0f; - float floorCorners[4][3] = { - { floorMinY + cenY, floorZ + cenZ, floorMinX + cenX }, - { floorMaxY + cenY, floorZ + cenZ, floorMinX + cenX }, - { floorMaxY + cenY, floorZ + cenZ, floorMaxX + cenX }, - { floorMinY + cenY, floorZ + cenZ, floorMaxX + cenX }, - }; - for (int v = 0; v < 4; v++) { - MeshVertex *mv = &vertices[vertCount++]; - mv->position[0] = floorCorners[v][0]; - mv->position[1] = floorCorners[v][1]; - mv->position[2] = floorCorners[v][2]; - mv->uv[0] = 0.0f; mv->uv[1] = 0.0f; - mv->color[0] = fr; mv->color[1] = fg; mv->color[2] = fb; - mv->color[3] = 0.5f; - } - indices[idxCount++] = 0; indices[idxCount++] = 2; indices[idxCount++] = 1; - indices[idxCount++] = 0; indices[idxCount++] = 3; indices[idxCount++] = 2; +void menu_render_gpu_load_track_mesh(MenuRendererGPU *r, const tColor *pal) { + menu_render_gpu_free_track_mesh(r); + + extern int TRAK_LEN; + if (TRAK_LEN <= 0) + return; + + // Compute track center, bounding box, and height range (matching original + // show_3dmap) + float accX = 0, accY = 0, accZ = 0; + float bbMinX = 1e18f, bbMinY = 1e18f, bbMinZ = 1e18f; + float bbMaxX = -1e18f, bbMaxY = -1e18f, bbMaxZ = -1e18f; + float minZ = 1e18f, maxZ = -1e18f; + for (int i = 0; i < TRAK_LEN; i++) { + accX += TrakPt[i].pointAy[0].fX + TrakPt[i].pointAy[4].fX; + accY += TrakPt[i].pointAy[0].fY + TrakPt[i].pointAy[4].fY; + accZ += TrakPt[i].pointAy[0].fZ + TrakPt[i].pointAy[4].fZ; + for (int p = 0; p <= 4; p += 4) { + float px = TrakPt[i].pointAy[p].fX; + float py = TrakPt[i].pointAy[p].fY; + float pz = TrakPt[i].pointAy[p].fZ; + if (px < bbMinX) + bbMinX = px; + if (px > bbMaxX) + bbMaxX = px; + if (py < bbMinY) + bbMinY = py; + if (py > bbMaxY) + bbMaxY = py; + if (pz < bbMinZ) + bbMinZ = pz; + if (pz > bbMaxZ) + bbMaxZ = pz; } - - for (int seg = 0; seg < numSegments - 1; seg++) { - int chunk = seg * 2; - int nextChunk = (seg + 1) * 2; - if (nextChunk >= TRAK_LEN) break; - - // Height-based color gradient (palette 128-139, matching original) - float heightCalc = (maxZ - TrakPt[chunk].pointAy[2].fZ) * 15.0f / zRange; - int colorIdx = 143 - (int)heightCalc; - if (colorIdx > 139) colorIdx = 139; - if (colorIdx < 128) colorIdx = 128; - - const tColor *c = &pal[colorIdx]; - float cr = c->byR / 63.0f; - float cg = c->byG / 63.0f; - float cb = c->byB / 63.0f; - - // Quad spanning full track width: pointAy[4] to pointAy[0] - // Vertex order matches original: next[4], next[0], cur[0], cur[4] - tVec3 *pts[4] = { - &TrakPt[nextChunk].pointAy[4], - &TrakPt[nextChunk].pointAy[0], - &TrakPt[chunk].pointAy[0], - &TrakPt[chunk].pointAy[4], - }; - - int baseVert = vertCount; - for (int v = 0; v < 4; v++) { - MeshVertex *mv = &vertices[vertCount++]; - // Apply centering + Z-up to Y-up swap - float gx = pts[v]->fX + cenX; - float gy = pts[v]->fY + cenY; - float gz = pts[v]->fZ + cenZ; - mv->position[0] = gy; // GPU X = game Y (lateral) - mv->position[1] = gz; // GPU Y = game Z (up) - mv->position[2] = gx; // GPU Z = game X (forward) - mv->uv[0] = 0.0f; - mv->uv[1] = 0.0f; - mv->color[0] = cr; - mv->color[1] = cg; - mv->color[2] = cb; - mv->color[3] = 1.0f; - } - - indices[idxCount++] = baseVert + 0; - indices[idxCount++] = baseVert + 1; - indices[idxCount++] = baseVert + 2; - indices[idxCount++] = baseVert + 0; - indices[idxCount++] = baseVert + 2; - indices[idxCount++] = baseVert + 3; + if (TrakPt[i].pointAy[2].fZ < minZ) + minZ = TrakPt[i].pointAy[2].fZ; + if (TrakPt[i].pointAy[2].fZ > maxZ) + maxZ = TrakPt[i].pointAy[2].fZ; + } + float div = 1.0f / (float)(2 * TRAK_LEN); + float cenX = -accX * div; + float cenY = -accY * div; + float cenZ = -accZ * div; + float zRange = maxZ - minZ; + if (zRange < 1.0f) + zRange = 1.0f; + + // Expanded bounding box with 10% margin (matching original) + float expandX = (bbMaxX - bbMinX) * 0.1f; + float expandY = (bbMaxY - bbMinY) * 0.1f; + float floorMinX = bbMinX - expandX; + float floorMaxX = bbMaxX + expandX; + float floorMinY = bbMinY - expandY; + float floorMaxY = bbMaxY + expandY; + float bbZRange = bbMaxZ - bbMinZ; + if (bbZRange < 100.0f) + bbZRange = 100.0f; + float floorZ = bbMinZ - bbZRange * 0.4f; + + // One quad per 2-chunk segment + 1 floor quad + int numSegments = TRAK_LEN / 2; + MeshVertex *vertices = calloc(numSegments * 4 + 4, sizeof(MeshVertex)); + uint32 *indices = calloc(numSegments * 6 + 6, sizeof(uint32)); + int vertCount = 0, idxCount = 0; + + // Floor quad: semi-transparent plane at bottom of bounding box (color index + // 2) + { + float fr = 0.0f, fg = 0.0f, fb = 0.0f; + float floorCorners[4][3] = { + {floorMinY + cenY, floorZ + cenZ, floorMinX + cenX}, + {floorMaxY + cenY, floorZ + cenZ, floorMinX + cenX}, + {floorMaxY + cenY, floorZ + cenZ, floorMaxX + cenX}, + {floorMinY + cenY, floorZ + cenZ, floorMaxX + cenX}, + }; + for (int v = 0; v < 4; v++) { + MeshVertex *mv = &vertices[vertCount++]; + mv->position[0] = floorCorners[v][0]; + mv->position[1] = floorCorners[v][1]; + mv->position[2] = floorCorners[v][2]; + mv->uv[0] = 0.0f; + mv->uv[1] = 0.0f; + mv->color[0] = fr; + mv->color[1] = fg; + mv->color[2] = fb; + mv->color[3] = 0.5f; } + indices[idxCount++] = 0; + indices[idxCount++] = 2; + indices[idxCount++] = 1; + indices[idxCount++] = 0; + indices[idxCount++] = 3; + indices[idxCount++] = 2; + } + + for (int seg = 0; seg < numSegments - 1; seg++) { + int chunk = seg * 2; + int nextChunk = (seg + 1) * 2; + if (nextChunk >= TRAK_LEN) + break; + + // Height-based color gradient (palette 128-139, matching original) + float heightCalc = (maxZ - TrakPt[chunk].pointAy[2].fZ) * 15.0f / zRange; + int colorIdx = 143 - (int)heightCalc; + if (colorIdx > 139) + colorIdx = 139; + if (colorIdx < 128) + colorIdx = 128; + + const tColor *c = &pal[colorIdx]; + float cr = c->byR / 63.0f; + float cg = c->byG / 63.0f; + float cb = c->byB / 63.0f; + + // Quad spanning full track width: pointAy[4] to pointAy[0] + // Vertex order matches original: next[4], next[0], cur[0], cur[4] + tVec3 *pts[4] = { + &TrakPt[nextChunk].pointAy[4], + &TrakPt[nextChunk].pointAy[0], + &TrakPt[chunk].pointAy[0], + &TrakPt[chunk].pointAy[4], + }; - if (idxCount > 0) { - r->trackMesh.vertexBuffer = UploadGPUBuffer(r->device, - SDL_GPU_BUFFERUSAGE_VERTEX, vertices, vertCount * sizeof(MeshVertex)); - r->trackMesh.indexBuffer = UploadGPUBuffer(r->device, - SDL_GPU_BUFFERUSAGE_INDEX, indices, idxCount * sizeof(uint32)); - r->trackMesh.texture = r->whiteTexture; - r->trackMesh.indexCount = idxCount; - r->trackMesh.loaded = true; + int baseVert = vertCount; + for (int v = 0; v < 4; v++) { + MeshVertex *mv = &vertices[vertCount++]; + // Apply centering + Z-up to Y-up swap + float gx = pts[v]->fX + cenX; + float gy = pts[v]->fY + cenY; + float gz = pts[v]->fZ + cenZ; + mv->position[0] = gy; // GPU X = game Y (lateral) + mv->position[1] = gz; // GPU Y = game Z (up) + mv->position[2] = gx; // GPU Z = game X (forward) + mv->uv[0] = 0.0f; + mv->uv[1] = 0.0f; + mv->color[0] = cr; + mv->color[1] = cg; + mv->color[2] = cb; + mv->color[3] = 1.0f; } - free(vertices); - free(indices); + indices[idxCount++] = baseVert + 0; + indices[idxCount++] = baseVert + 1; + indices[idxCount++] = baseVert + 2; + indices[idxCount++] = baseVert + 0; + indices[idxCount++] = baseVert + 2; + indices[idxCount++] = baseVert + 3; + } + + if (idxCount > 0) { + r->trackMesh.vertexBuffer = + UploadGPUBuffer(r->device, SDL_GPU_BUFFERUSAGE_VERTEX, vertices, + vertCount * sizeof(MeshVertex)); + r->trackMesh.indexBuffer = + UploadGPUBuffer(r->device, SDL_GPU_BUFFERUSAGE_INDEX, indices, + idxCount * sizeof(uint32)); + r->trackMesh.texture = r->whiteTexture; + r->trackMesh.indexCount = idxCount; + r->trackMesh.loaded = true; + } + + free(vertices); + free(indices); } -void menu_render_gpu_free_track_mesh(MenuRendererGPU *r) -{ - FreeMeshPreview(r->device, &r->trackMesh, r->whiteTexture); +void menu_render_gpu_free_track_mesh(MenuRendererGPU *r) { + FreeMeshPreview(r->device, &r->trackMesh, r->whiteTexture); } void menu_render_gpu_draw_track_preview(MenuRendererGPU *r, float cameraZ, - int elevation, int yaw, - int destX, int destY, int destW, int destH) -{ - if (!r->trackMesh.loaded || r->meshDrawCount >= MAX_MESH_DRAWS) return; - - // Convert TRIG angles to radians - float yawRad = (float)yaw * (2.0f * 3.14159265f / 16384.0f); - float elevRad = (float)elevation * (2.0f * 3.14159265f / 16384.0f); - - // Camera position: match original show_3dmap - // Original: worldx = -fZ*tcos[elev], worldy = 0, worldz = fZ*tsin[elev] - // Game→GPU: GPU_X = game_Y, GPU_Y = game_Z, GPU_Z = game_X - // Camera orbit by +yaw with -Z forward matches original's vertex rotation - float camDist = cameraZ; - float horizDist = camDist * cosf(elevRad); - float eyeX = horizDist * sinf(yawRad); - float eyeY = camDist * sinf(elevRad); - float eyeZ = -horizDist * cosf(yawRad); - - float view[16], proj[16], mvp[16]; - MakeLookAt(view, eyeX, eyeY, eyeZ, 0.0f, 0.0f, 0.0f); - float aspect = (float)destW / (float)destH; - float fov = 2.0f * atanf(81.0f / (float)VIEWDIST); - MakePerspective(proj, fov, aspect, 1.0f, camDist * 8.0f); - Mat4Multiply(mvp, proj, view); - - // Expand viewport to full width and bottom to avoid clipping, compensate in MVP - int padLeft = destX; - int padRight = MENU_WIDTH - (destX + destW); - int totalW = destW + padLeft + padRight; - float Sx = (float)destW / (float)totalW; - float Tx = (float)(padLeft - padRight) / (float)totalW; - for (int j = 0; j < 4; j++) - mvp[j * 4] = Sx * mvp[j * 4] + Tx * mvp[j * 4 + 3]; - - int padBottom = MENU_HEIGHT - (destY + destH); - int totalH = destH + padBottom; - float Sy = (float)destH / (float)totalH; - float Ty = (float)padBottom / (float)totalH; - for (int j = 0; j < 4; j++) - mvp[j * 4 + 1] = Sy * mvp[j * 4 + 1] + Ty * mvp[j * 4 + 3]; - - MeshDrawCommand *cmd = &r->meshDraws[r->meshDrawCount++]; - cmd->vertexBuffer = r->trackMesh.vertexBuffer; - cmd->indexBuffer = r->trackMesh.indexBuffer; - cmd->texture = r->trackMesh.texture; - cmd->indexCount = r->trackMesh.indexCount; - memcpy(cmd->mvp, mvp, sizeof(mvp)); - cmd->vpX = (float)(destX - padLeft); - cmd->vpY = (float)destY; - cmd->vpW = (float)totalW; - cmd->vpH = (float)totalH; - cmd->useDepth = false; + int elevation, int yaw, int destX, + int destY, int destW, int destH) { + if (!r->trackMesh.loaded || r->meshDrawCount >= MAX_MESH_DRAWS) + return; + + // Convert TRIG angles to radians + float yawRad = (float)yaw * (2.0f * 3.14159265f / 16384.0f); + float elevRad = (float)elevation * (2.0f * 3.14159265f / 16384.0f); + + // Camera position: match original show_3dmap + // Original: worldx = -fZ*tcos[elev], worldy = 0, worldz = fZ*tsin[elev] + // Game→GPU: GPU_X = game_Y, GPU_Y = game_Z, GPU_Z = game_X + // Camera orbit by +yaw with -Z forward matches original's vertex rotation + float camDist = cameraZ; + float horizDist = camDist * cosf(elevRad); + float eyeX = horizDist * sinf(yawRad); + float eyeY = camDist * sinf(elevRad); + float eyeZ = -horizDist * cosf(yawRad); + + float view[16], proj[16], mvp[16]; + MakeLookAt(view, eyeX, eyeY, eyeZ, 0.0f, 0.0f, 0.0f); + float aspect = (float)destW / (float)destH; + float fov = 2.0f * atanf(81.0f / (float)VIEWDIST); + MakePerspective(proj, fov, aspect, 1.0f, camDist * 8.0f); + Mat4Multiply(mvp, proj, view); + + // Expand viewport to full width and bottom to avoid clipping, compensate in + // MVP + int padLeft = destX; + int padRight = MENU_WIDTH - (destX + destW); + int totalW = destW + padLeft + padRight; + float Sx = (float)destW / (float)totalW; + float Tx = (float)(padLeft - padRight) / (float)totalW; + for (int j = 0; j < 4; j++) + mvp[j * 4] = Sx * mvp[j * 4] + Tx * mvp[j * 4 + 3]; + + int padBottom = MENU_HEIGHT - (destY + destH); + int totalH = destH + padBottom; + float Sy = (float)destH / (float)totalH; + float Ty = (float)padBottom / (float)totalH; + for (int j = 0; j < 4; j++) + mvp[j * 4 + 1] = Sy * mvp[j * 4 + 1] + Ty * mvp[j * 4 + 3]; + + MeshDrawCommand *cmd = &r->meshDraws[r->meshDrawCount++]; + cmd->vertexBuffer = r->trackMesh.vertexBuffer; + cmd->indexBuffer = r->trackMesh.indexBuffer; + cmd->texture = r->trackMesh.texture; + cmd->indexCount = r->trackMesh.indexCount; + memcpy(cmd->mvp, mvp, sizeof(mvp)); + cmd->vpX = (float)(destX - padLeft); + cmd->vpY = (float)destY; + cmd->vpW = (float)totalW; + cmd->vpH = (float)totalH; + cmd->useDepth = false; } diff --git a/PROJECTS/ROLLER/menu_render_gpu.h b/PROJECTS/ROLLER/menu_render_gpu.h index 13cc4ef2..dbc2140d 100644 --- a/PROJECTS/ROLLER/menu_render_gpu.h +++ b/PROJECTS/ROLLER/menu_render_gpu.h @@ -9,18 +9,19 @@ typedef struct MenuRendererGPU MenuRendererGPU; typedef struct { - SDL_GPUTexture *texture; - int width; - int height; + SDL_GPUTexture *texture; + int width; + int height; } MenuTexture; // Lifecycle -MenuRendererGPU *menu_render_gpu_create(SDL_GPUDevice *device, SDL_Window *window); +MenuRendererGPU *menu_render_gpu_create(SDL_GPUDevice *device, + SDL_Window *window); void menu_render_gpu_destroy(MenuRendererGPU *renderer); // Asset conversion int menu_render_gpu_load_blocks(MenuRendererGPU *renderer, int slot, - tBlockHeader *blocks, const tColor *palette); + tBlockHeader *blocks, const tColor *palette); void menu_render_gpu_free_blocks(MenuRendererGPU *renderer, int slot); // Frame lifecycle @@ -32,41 +33,45 @@ void menu_render_gpu_set_layer(MenuRendererGPU *renderer, MenuDrawLayer layer); // Draw calls (between begin_frame / end_frame) void menu_render_gpu_clear(MenuRendererGPU *renderer, uint8 colorIndex, - const tColor *palette); + const tColor *palette); void menu_render_gpu_background(MenuRendererGPU *renderer, int slot); void menu_render_gpu_sprite(MenuRendererGPU *renderer, int slot, int blockIdx, - int x, int y, int transparentColorIndex, - const tColor *palette); + int x, int y, int transparentColorIndex, + const tColor *palette); // Fade system -void menu_render_gpu_begin_fade(MenuRendererGPU *renderer, int direction, int durationFrames); +void menu_render_gpu_begin_fade(MenuRendererGPU *renderer, int direction, + int durationFrames); int menu_render_gpu_fade_active(MenuRendererGPU *renderer); void menu_render_gpu_fade_wait(MenuRendererGPU *renderer, - void (*redraw_fn)(void *ctx), void *ctx); + void (*redraw_fn)(void *ctx), void *ctx); // Text rendering -void menu_render_gpu_text(MenuRendererGPU *renderer, int fontSlot, const char *text, - const char *mappingTable, int *charVOffsets, - int x, int y, uint8 colorReplace, int alignment, - const tColor *palette); +void menu_render_gpu_text(MenuRendererGPU *renderer, int fontSlot, + const char *text, const char *mappingTable, + int *charVOffsets, int x, int y, uint8 colorReplace, + int alignment, const tColor *palette); void menu_render_gpu_scaled_text(MenuRendererGPU *renderer, int fontSlot, - const char *text, const char *mappingTable, - int *charVOffsets, int x, int y, - uint8 colorReplace, unsigned int alignment, - int clipLeft, int clipRight, - const tColor *palette); + const char *text, const char *mappingTable, + int *charVOffsets, int x, int y, + uint8 colorReplace, unsigned int alignment, + int clipLeft, int clipRight, + const tColor *palette); // 3D mesh previews -void menu_render_gpu_load_car_mesh(MenuRendererGPU *renderer, int carIdx, const tColor *palette); +void menu_render_gpu_load_car_mesh(MenuRendererGPU *renderer, int carIdx, + const tColor *palette); void menu_render_gpu_free_car_mesh(MenuRendererGPU *renderer); -void menu_render_gpu_draw_car_preview(MenuRendererGPU *renderer, float angle, float distance, - int carYaw, - int destX, int destY, int destW, int destH); +void menu_render_gpu_draw_car_preview(MenuRendererGPU *renderer, float angle, + float distance, int carYaw, int destX, + int destY, int destW, int destH); -void menu_render_gpu_load_track_mesh(MenuRendererGPU *renderer, const tColor *palette); +void menu_render_gpu_load_track_mesh(MenuRendererGPU *renderer, + const tColor *palette); void menu_render_gpu_free_track_mesh(MenuRendererGPU *renderer); -void menu_render_gpu_draw_track_preview(MenuRendererGPU *renderer, float cameraZ, - int elevation, int yaw, - int destX, int destY, int destW, int destH); +void menu_render_gpu_draw_track_preview(MenuRendererGPU *renderer, + float cameraZ, int elevation, int yaw, + int destX, int destY, int destW, + int destH); #endif diff --git a/PROJECTS/ROLLER/menu_render_software.c b/PROJECTS/ROLLER/menu_render_software.c index c869c66c..2c611b23 100644 --- a/PROJECTS/ROLLER/menu_render_software.c +++ b/PROJECTS/ROLLER/menu_render_software.c @@ -12,9 +12,9 @@ #include struct MenuRendererSoftware { - SceneRenderer *scene; - int loadedCarIdx; // stored by _sw_load_car_mesh for DrawCar() - int fadeInPending; // deferred fade-in (so content is drawn before the fade) + SceneRenderer *scene; + int loadedCarIdx; // stored by _sw_load_car_mesh for DrawCar() + int fadeInPending; // deferred fade-in (so content is drawn before the fade) }; // Legacy software preview origin: old code rendered at scrbuf + 34640, @@ -29,19 +29,19 @@ struct MenuRendererSoftware { MenuRendererSoftware *menu_render_sw_create(SDL_GPUDevice *device, SDL_Window *window) { - MenuRendererSoftware *sw = calloc(1, sizeof(MenuRendererSoftware)); - if (!sw) - return NULL; - sw->loadedCarIdx = -1; - sw->scene = scene_render_create(device, window); - return sw; + MenuRendererSoftware *sw = calloc(1, sizeof(MenuRendererSoftware)); + if (!sw) + return NULL; + sw->loadedCarIdx = -1; + sw->scene = scene_render_create(device, window); + return sw; } void menu_render_sw_destroy(MenuRendererSoftware *sw) { - if (!sw) - return; - scene_render_destroy(sw->scene); - free(sw); + if (!sw) + return; + scene_render_destroy(sw->scene); + free(sw); } // --------------------------------------------------------------------------- @@ -50,16 +50,16 @@ void menu_render_sw_destroy(MenuRendererSoftware *sw) { int menu_render_sw_load_blocks(MenuRendererSoftware *sw, int slot, tBlockHeader *blocks, const tColor *palette) { - (void)sw; - (void)slot; - (void)blocks; - (void)palette; - return 0; + (void)sw; + (void)slot; + (void)blocks; + (void)palette; + return 0; } void menu_render_sw_free_blocks(MenuRendererSoftware *sw, int slot) { - (void)sw; - (void)slot; + (void)sw; + (void)slot; } // --------------------------------------------------------------------------- @@ -67,36 +67,37 @@ void menu_render_sw_free_blocks(MenuRendererSoftware *sw, int slot) { // --------------------------------------------------------------------------- void menu_render_sw_begin_frame(MenuRendererSoftware *sw) { - (void)sw; - // No-op: scrbuf is always available + (void)sw; + // No-op: scrbuf is always available } void menu_render_sw_end_frame(MenuRendererSoftware *sw) { - if (sw->fadeInPending) { - sw->fadeInPending = 0; - if (g_bSnapshotMode && g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE) { - g_bPaletteSet = true; - UpdateSDLWindow(); - if (!SnapshotShouldStop()) - SnapshotAdvanceTick(); - return; - } - // Content has been drawn to scrbuf; fade from black to full brightness. - // palette_brightness may have been set to 32 by GPU init code, so - // reset to 0 to ensure the fade actually animates. - palette_brightness = 0; - for (int i = 0; i < 256; i++) { - pal_addr[i].byR = 0; - pal_addr[i].byB = 0; - pal_addr[i].byG = 0; - } - fade_palette(32); // blocking; calls UpdateSDLWindow each step - return; - } - g_bPaletteSet = true; - UpdateSDLWindow(); - if (g_bSnapshotMode && g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE && !SnapshotShouldStop()) + if (sw->fadeInPending) { + sw->fadeInPending = 0; + if (g_bSnapshotMode && g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE) { + g_bPaletteSet = true; + UpdateSDLWindow(); + if (!SnapshotShouldStop()) SnapshotAdvanceTick(); + return; + } + // Content has been drawn to scrbuf; fade from black to full brightness. + // palette_brightness may have been set to 32 by GPU init code, so + // reset to 0 to ensure the fade actually animates. + palette_brightness = 0; + for (int i = 0; i < 256; i++) { + pal_addr[i].byR = 0; + pal_addr[i].byB = 0; + pal_addr[i].byG = 0; + } + fade_palette(32); // blocking; calls UpdateSDLWindow each step + return; + } + g_bPaletteSet = true; + UpdateSDLWindow(); + if (g_bSnapshotMode && g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE && + !SnapshotShouldStop()) + SnapshotAdvanceTick(); } // --------------------------------------------------------------------------- @@ -105,23 +106,22 @@ void menu_render_sw_end_frame(MenuRendererSoftware *sw) { void menu_render_sw_clear(MenuRendererSoftware *sw, uint8 colorIndex, const tColor *palette) { - (void)sw; - (void)palette; - memset(scrbuf, colorIndex, winw * winh); + (void)sw; + (void)palette; + memset(scrbuf, colorIndex, winw * winh); } void menu_render_sw_background(MenuRendererSoftware *sw, int slot) { - (void)sw; - display_picture(scrbuf, front_vga[slot]); + (void)sw; + display_picture(scrbuf, front_vga[slot]); } void menu_render_sw_sprite(MenuRendererSoftware *sw, int slot, int blockIdx, int x, int y, int transparentColorIndex, const tColor *palette) { - (void)sw; - (void)palette; - display_block(scrbuf, front_vga[slot], blockIdx, x, y, - transparentColorIndex); + (void)sw; + (void)palette; + display_block(scrbuf, front_vga[slot], blockIdx, x, y, transparentColorIndex); } // --------------------------------------------------------------------------- @@ -130,26 +130,26 @@ void menu_render_sw_sprite(MenuRendererSoftware *sw, int slot, int blockIdx, void menu_render_sw_begin_fade(MenuRendererSoftware *sw, int direction, int durationFrames) { - (void)durationFrames; - if (direction) { - // Fade-in: defer to end_frame so scrbuf has the new content drawn first - sw->fadeInPending = 1; - } else { - fade_palette(0); - } + (void)durationFrames; + if (direction) { + // Fade-in: defer to end_frame so scrbuf has the new content drawn first + sw->fadeInPending = 1; + } else { + fade_palette(0); + } } int menu_render_sw_fade_active(MenuRendererSoftware *sw) { - (void)sw; - return 0; // blocking fade completes immediately + (void)sw; + return 0; // blocking fade completes immediately } void menu_render_sw_fade_wait(MenuRendererSoftware *sw, void (*redraw_fn)(void *ctx), void *ctx) { - (void)sw; - (void)redraw_fn; - (void)ctx; - // No-op: fade already done in begin_fade + (void)sw; + (void)redraw_fn; + (void)ctx; + // No-op: fade already done in begin_fade } // --------------------------------------------------------------------------- @@ -158,13 +158,12 @@ void menu_render_sw_fade_wait(MenuRendererSoftware *sw, void menu_render_sw_text(MenuRendererSoftware *sw, int fontSlot, const char *text, const char *mappingTable, - int *charVOffsets, int x, int y, - uint8 colorReplace, int alignment, - const tColor *palette) { - (void)sw; - (void)palette; - front_text(front_vga[fontSlot], text, (const uint8 *)mappingTable, - charVOffsets, x, y, colorReplace, alignment); + int *charVOffsets, int x, int y, uint8 colorReplace, + int alignment, const tColor *palette) { + (void)sw; + (void)palette; + front_text(front_vga[fontSlot], text, (const uint8 *)mappingTable, + charVOffsets, x, y, colorReplace, alignment); } void menu_render_sw_scaled_text(MenuRendererSoftware *sw, int fontSlot, @@ -173,10 +172,10 @@ void menu_render_sw_scaled_text(MenuRendererSoftware *sw, int fontSlot, uint8 colorReplace, unsigned int alignment, int clipLeft, int clipRight, const tColor *palette) { - (void)sw; - (void)palette; - scale_text(front_vga[fontSlot], (char *)text, mappingTable, charVOffsets, - x, y, (char)colorReplace, alignment, clipLeft, clipRight); + (void)sw; + (void)palette; + scale_text(front_vga[fontSlot], (char *)text, mappingTable, charVOffsets, x, + y, (char)colorReplace, alignment, clipLeft, clipRight); } // --------------------------------------------------------------------------- @@ -185,35 +184,36 @@ void menu_render_sw_scaled_text(MenuRendererSoftware *sw, int fontSlot, void menu_render_sw_load_car_mesh(MenuRendererSoftware *sw, int carIdx, const tColor *palette) { - (void)palette; - sw->loadedCarIdx = carIdx; - if (!sw->scene || carIdx < 0 || carIdx > CAR_DESIGN_DEATH) - return; - int texIdx = car_texmap[carIdx]; - if (texIdx > 0 && cartex_vga[texIdx - 1]) { - scene_render_load_texture(sw->scene, cartex_vga[texIdx - 1], - 256, 0, texIdx, gfx_size); - } + (void)palette; + sw->loadedCarIdx = carIdx; + if (!sw->scene || carIdx < 0 || carIdx > CAR_DESIGN_DEATH) + return; + int texIdx = car_texmap[carIdx]; + if (texIdx > 0 && cartex_vga[texIdx - 1]) { + scene_render_load_texture(sw->scene, cartex_vga[texIdx - 1], 256, 0, texIdx, + gfx_size); + } } void menu_render_sw_free_car_mesh(MenuRendererSoftware *sw) { - (void)sw; - // No-op + (void)sw; + // No-op } void menu_render_sw_draw_car_preview(MenuRendererSoftware *sw, float angle, - float distance, int carYaw, - int destX, int destY, - int destW, int destH) { - (void)carYaw; - (void)destX; - (void)destY; - if (sw->loadedCarIdx < 0 || sw->loadedCarIdx > CAR_DESIGN_DEATH) return; - if (!CarDesigns[sw->loadedCarIdx].pCoords) return; - scene_render_set_target(sw->scene, scrbuf, winw, winw, winh); - scene_render_set_viewport(sw->scene, MENU_SW_CAR_PREVIEW_X, - MENU_SW_CAR_PREVIEW_Y, destW, destH); - DrawCar(sw->scene, sw->loadedCarIdx, distance, (int)angle, 0); + float distance, int carYaw, int destX, + int destY, int destW, int destH) { + (void)carYaw; + (void)destX; + (void)destY; + if (sw->loadedCarIdx < 0 || sw->loadedCarIdx > CAR_DESIGN_DEATH) + return; + if (!CarDesigns[sw->loadedCarIdx].pCoords) + return; + scene_render_set_target(sw->scene, scrbuf, winw, winw, winh); + scene_render_set_viewport(sw->scene, MENU_SW_CAR_PREVIEW_X, + MENU_SW_CAR_PREVIEW_Y, destW, destH); + DrawCar(sw->scene, sw->loadedCarIdx, distance, (int)angle, 0); } // --------------------------------------------------------------------------- @@ -222,25 +222,25 @@ void menu_render_sw_draw_car_preview(MenuRendererSoftware *sw, float angle, void menu_render_sw_load_track_mesh(MenuRendererSoftware *sw, const tColor *palette) { - (void)sw; - (void)palette; - // No-op + (void)sw; + (void)palette; + // No-op } void menu_render_sw_free_track_mesh(MenuRendererSoftware *sw) { - (void)sw; - // No-op + (void)sw; + // No-op } void menu_render_sw_draw_track_preview(MenuRendererSoftware *sw, float cameraZ, - int elevation, int yaw, - int destX, int destY, - int destW, int destH) { - (void)sw; - (void)destX; - (void)destY; - (void)destW; - (void)destH; - // Original code: show_3dmap uses xbase/ybase globals internally (set by init_screen) - show_3dmap(cameraZ, elevation, yaw); + int elevation, int yaw, int destX, + int destY, int destW, int destH) { + (void)sw; + (void)destX; + (void)destY; + (void)destW; + (void)destH; + // Original code: show_3dmap uses xbase/ybase globals internally (set by + // init_screen) + show_3dmap(cameraZ, elevation, yaw); } diff --git a/PROJECTS/ROLLER/menu_render_software.h b/PROJECTS/ROLLER/menu_render_software.h index d01c679e..d705e43c 100644 --- a/PROJECTS/ROLLER/menu_render_software.h +++ b/PROJECTS/ROLLER/menu_render_software.h @@ -8,7 +8,8 @@ typedef struct MenuRendererSoftware MenuRendererSoftware; // Lifecycle -MenuRendererSoftware *menu_render_sw_create(SDL_GPUDevice *device, SDL_Window *window); +MenuRendererSoftware *menu_render_sw_create(SDL_GPUDevice *device, + SDL_Window *window); void menu_render_sw_destroy(MenuRendererSoftware *sw); // Asset conversion @@ -38,9 +39,8 @@ void menu_render_sw_fade_wait(MenuRendererSoftware *sw, // Text rendering void menu_render_sw_text(MenuRendererSoftware *sw, int fontSlot, const char *text, const char *mappingTable, - int *charVOffsets, int x, int y, - uint8 colorReplace, int alignment, - const tColor *palette); + int *charVOffsets, int x, int y, uint8 colorReplace, + int alignment, const tColor *palette); void menu_render_sw_scaled_text(MenuRendererSoftware *sw, int fontSlot, const char *text, const char *mappingTable, int *charVOffsets, int x, int y, @@ -53,16 +53,14 @@ void menu_render_sw_load_car_mesh(MenuRendererSoftware *sw, int carIdx, const tColor *palette); void menu_render_sw_free_car_mesh(MenuRendererSoftware *sw); void menu_render_sw_draw_car_preview(MenuRendererSoftware *sw, float angle, - float distance, int carYaw, - int destX, int destY, - int destW, int destH); + float distance, int carYaw, int destX, + int destY, int destW, int destH); void menu_render_sw_load_track_mesh(MenuRendererSoftware *sw, const tColor *palette); void menu_render_sw_free_track_mesh(MenuRendererSoftware *sw); void menu_render_sw_draw_track_preview(MenuRendererSoftware *sw, float cameraZ, - int elevation, int yaw, - int destX, int destY, - int destW, int destH); + int elevation, int yaw, int destX, + int destY, int destW, int destH); #endif diff --git a/PROJECTS/ROLLER/menu_shaders.h b/PROJECTS/ROLLER/menu_shaders.h index 422a6c52..8b41b772 100644 --- a/PROJECTS/ROLLER/menu_shaders.h +++ b/PROJECTS/ROLLER/menu_shaders.h @@ -1,28 +1,889 @@ #ifndef MENU_SHADERS_H #define MENU_SHADERS_H -static const unsigned char menu_vertex_spirv[] = {0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x06, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x15, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x17, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x16, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x90, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; +static const unsigned char menu_vertex_spirv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x74, 0x79, 0x70, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, + 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x06, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x72, 0x6f, 0x6a, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, + 0x6d, 0x73, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, + 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, + 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x03, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x07, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x90, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; static const unsigned int menu_vertex_spirv_size = 968; -static const unsigned char menu_vertex_msl[] = {0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x26, 0x20, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x20, 0x2a, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; +static const unsigned char menu_vertex_msl[] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, + 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, + 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, + 0x6d, 0x73, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, + 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x3b, 0x0a, + 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, + 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x75, + 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, + 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, + 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, + 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, + 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, + 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, + 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, + 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, + 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, + 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, + 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, + 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, + 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, + 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, + 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x56, + 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, + 0x73, 0x26, 0x20, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, + 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, + 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, + 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x56, 0x65, 0x72, + 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, + 0x74, 0x72, 0x69, 0x78, 0x20, 0x2a, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x34, 0x28, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, + 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x2c, 0x20, 0x30, + 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, + 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, + 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, + 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, + 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; static const unsigned int menu_vertex_msl_size = 654; -static const unsigned char menu_pixel_spirv[] = {0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x4d, 0x75, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x47, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x42, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x47, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x52, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x47, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x42, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x5f, 0x70, 0x61, 0x64, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x5f, 0x70, 0x61, 0x64, 0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x32, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x6e, 0x75, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x05, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x6e, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x6f, 0x12, 0x83, 0x3b, 0x14, 0x00, 0x02, 0x00, 0x17, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x02, 0x00, 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x23, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x27, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x57, 0x00, 0x06, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x31, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x36, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x35, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x32, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x08, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, 0x25, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x25, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x25, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x49, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x48, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x48, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x17, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x17, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x51, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x53, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, 0x25, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x09, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x52, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x52, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; +static const unsigned char menu_pixel_spirv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x50, 0x69, 0x78, + 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x6c, 0x70, 0x68, 0x61, 0x4d, 0x75, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, + 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0x47, 0x00, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, + 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x42, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, + 0x72, 0x6f, 0x6d, 0x47, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x72, 0x65, 0x70, 0x6c, + 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x52, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x47, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x42, 0x00, 0x00, + 0x06, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x5f, 0x70, 0x61, 0x64, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x5f, 0x70, 0x61, 0x64, + 0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, + 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x74, 0x79, 0x70, 0x65, 0x2e, 0x32, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, + 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x6d, 0x65, 0x6e, 0x75, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, + 0x05, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, + 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x6e, 0x75, + 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, + 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x6f, 0x12, 0x83, 0x3b, + 0x14, 0x00, 0x02, 0x00, 0x17, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x03, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x0e, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x02, 0x00, 0x09, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x03, 0x00, 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x27, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x57, 0x00, 0x06, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x2f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xf7, 0x00, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfa, 0x00, 0x04, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x36, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x35, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x32, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, + 0x30, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x30, 0x00, 0x00, 0x00, + 0xf5, 0x00, 0x07, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xf7, 0x00, 0x03, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfa, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x4f, 0x00, 0x08, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x43, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, + 0x47, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x49, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x4b, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0xf9, 0x00, 0x02, 0x00, 0x48, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x48, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x4b, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, + 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0xf9, 0x00, 0x02, 0x00, 0x4d, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x4d, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, + 0x52, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, + 0x51, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x53, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x09, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, + 0x52, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x52, 0x00, 0x00, 0x00, + 0xf5, 0x00, 0x07, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x53, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x07, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x5d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x5f, 0x00, 0x00, 0x00, 0x52, 0x00, 0x06, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x62, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x62, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; static const unsigned int menu_pixel_spirv_size = 2988; -static const unsigned char menu_pixel_msl[] = {0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x4d, 0x75, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x47, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x47, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x47, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x70, 0x61, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x70, 0x61, 0x64, 0x31, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x26, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x34, 0x34, 0x20, 0x3d, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x6d, 0x65, 0x6e, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x35, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x34, 0x34, 0x2e, 0x77, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x35, 0x36, 0x20, 0x3d, 0x20, 0x5f, 0x34, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x34, 0x34, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x35, 0x36, 0x20, 0x3d, 0x20, 0x5f, 0x34, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x39, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x5f, 0x36, 0x39, 0x20, 0x3d, 0x20, 0x61, 0x62, 0x73, 0x28, 0x5f, 0x35, 0x36, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x47, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x42, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x6f, 0x6c, 0x20, 0x5f, 0x37, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x36, 0x39, 0x2e, 0x78, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x38, 0x39, 0x39, 0x38, 0x39, 0x38, 0x30, 0x35, 0x32, 0x32, 0x31, 0x35, 0x35, 0x37, 0x36, 0x31, 0x37, 0x31, 0x38, 0x37, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x37, 0x36, 0x20, 0x3d, 0x20, 0x5f, 0x36, 0x39, 0x2e, 0x79, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x38, 0x39, 0x39, 0x38, 0x39, 0x38, 0x30, 0x35, 0x32, 0x32, 0x31, 0x35, 0x35, 0x37, 0x36, 0x31, 0x37, 0x31, 0x38, 0x37, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x37, 0x36, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x6f, 0x6c, 0x20, 0x5f, 0x38, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x37, 0x36, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x38, 0x31, 0x20, 0x3d, 0x20, 0x5f, 0x36, 0x39, 0x2e, 0x7a, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x38, 0x39, 0x39, 0x38, 0x39, 0x38, 0x30, 0x35, 0x32, 0x32, 0x31, 0x35, 0x35, 0x37, 0x36, 0x31, 0x37, 0x31, 0x38, 0x37, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x38, 0x31, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x39, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x38, 0x31, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x5f, 0x39, 0x30, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x52, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x47, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x42, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x32, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x5f, 0x39, 0x30, 0x2e, 0x78, 0x2c, 0x20, 0x5f, 0x39, 0x30, 0x2e, 0x79, 0x2c, 0x20, 0x5f, 0x39, 0x30, 0x2e, 0x7a, 0x2c, 0x20, 0x5f, 0x35, 0x36, 0x2e, 0x77, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x32, 0x20, 0x3d, 0x20, 0x5f, 0x35, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x33, 0x20, 0x3d, 0x20, 0x5f, 0x39, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x33, 0x20, 0x3d, 0x20, 0x5f, 0x35, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x39, 0x38, 0x20, 0x3d, 0x20, 0x5f, 0x39, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x38, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x5f, 0x39, 0x33, 0x2e, 0x77, 0x20, 0x2a, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x4d, 0x75, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x5f, 0x39, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; +static const unsigned char menu_pixel_msl[] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, + 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, + 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, + 0x73, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, + 0x74, 0x20, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x4d, 0x75, 0x6c, 0x3b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, + 0x6f, 0x72, 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, + 0x61, 0x74, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x47, 0x3b, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, + 0x52, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, + 0x47, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, + 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x52, 0x3b, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, + 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x47, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x65, 0x70, + 0x6c, 0x61, 0x63, 0x65, 0x54, 0x6f, 0x42, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x5f, 0x70, 0x61, 0x64, 0x30, + 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, + 0x5f, 0x70, 0x61, 0x64, 0x31, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, + 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, + 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, + 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, + 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x5b, + 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, + 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, + 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, + 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, + 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, + 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, + 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, + 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, + 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, + 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, + 0x74, 0x79, 0x70, 0x65, 0x5f, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, + 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x26, 0x20, 0x50, 0x69, 0x78, 0x65, + 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20, 0x5b, 0x5b, + 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, + 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x54, 0x65, + 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, + 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x53, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, + 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, + 0x34, 0x34, 0x20, 0x3d, 0x20, 0x6d, 0x65, 0x6e, 0x75, 0x54, 0x65, 0x78, + 0x74, 0x75, 0x72, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, + 0x6d, 0x65, 0x6e, 0x75, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, + 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x29, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x35, + 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x50, + 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, + 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x2e, + 0x30, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x34, 0x34, + 0x2e, 0x77, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, + 0x61, 0x72, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x35, + 0x36, 0x20, 0x3d, 0x20, 0x5f, 0x34, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x5f, 0x34, 0x34, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, + 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, + 0x35, 0x36, 0x20, 0x3d, 0x20, 0x5f, 0x34, 0x34, 0x3b, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, + 0x74, 0x34, 0x20, 0x5f, 0x39, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x69, 0x66, 0x20, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, + 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, + 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x20, 0x3e, 0x3d, 0x20, 0x30, 0x2e, + 0x30, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, + 0x5f, 0x36, 0x39, 0x20, 0x3d, 0x20, 0x61, 0x62, 0x73, 0x28, 0x5f, 0x35, + 0x36, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2d, 0x20, 0x66, 0x6c, 0x6f, 0x61, + 0x74, 0x33, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, + 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, + 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, + 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, + 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, 0x47, 0x2c, 0x20, 0x50, + 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, + 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x46, 0x72, 0x6f, 0x6d, + 0x42, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x62, 0x6f, 0x6f, 0x6c, 0x20, 0x5f, 0x37, 0x36, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, + 0x36, 0x39, 0x2e, 0x78, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x34, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x38, 0x39, 0x39, 0x38, 0x39, + 0x38, 0x30, 0x35, 0x32, 0x32, 0x31, 0x35, 0x35, 0x37, 0x36, 0x31, 0x37, + 0x31, 0x38, 0x37, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x5f, 0x37, 0x36, 0x20, 0x3d, 0x20, 0x5f, 0x36, + 0x39, 0x2e, 0x79, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x34, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x38, 0x39, 0x39, 0x38, 0x39, 0x38, + 0x30, 0x35, 0x32, 0x32, 0x31, 0x35, 0x35, 0x37, 0x36, 0x31, 0x37, 0x31, + 0x38, 0x37, 0x35, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, + 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x5f, 0x37, 0x36, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, + 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x6f, + 0x6c, 0x20, 0x5f, 0x38, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x37, 0x36, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x38, + 0x31, 0x20, 0x3d, 0x20, 0x5f, 0x36, 0x39, 0x2e, 0x7a, 0x20, 0x3c, 0x20, + 0x30, 0x2e, 0x30, 0x30, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0x38, 0x39, 0x39, 0x38, 0x39, 0x38, 0x30, 0x35, 0x32, 0x32, 0x31, 0x35, + 0x35, 0x37, 0x36, 0x31, 0x37, 0x31, 0x38, 0x37, 0x35, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x38, 0x31, 0x20, + 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x39, + 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, + 0x66, 0x20, 0x28, 0x5f, 0x38, 0x31, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, + 0x20, 0x5f, 0x39, 0x30, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x33, 0x28, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, + 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x54, + 0x6f, 0x52, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, 0x6e, 0x69, + 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, + 0x65, 0x54, 0x6f, 0x47, 0x2c, 0x20, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x55, + 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x72, 0x65, 0x70, 0x6c, + 0x61, 0x63, 0x65, 0x54, 0x6f, 0x42, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x32, + 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x5f, 0x39, + 0x30, 0x2e, 0x78, 0x2c, 0x20, 0x5f, 0x39, 0x30, 0x2e, 0x79, 0x2c, 0x20, + 0x5f, 0x39, 0x30, 0x2e, 0x7a, 0x2c, 0x20, 0x5f, 0x35, 0x36, 0x2e, 0x77, + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, + 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x5f, 0x39, 0x32, 0x20, 0x3d, 0x20, 0x5f, 0x35, 0x36, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x33, 0x20, 0x3d, 0x20, 0x5f, + 0x39, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x33, + 0x20, 0x3d, 0x20, 0x5f, 0x35, 0x36, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, + 0x20, 0x5f, 0x39, 0x38, 0x20, 0x3d, 0x20, 0x5f, 0x39, 0x33, 0x3b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x5f, 0x39, 0x38, 0x2e, 0x77, 0x20, 0x3d, 0x20, + 0x5f, 0x39, 0x33, 0x2e, 0x77, 0x20, 0x2a, 0x20, 0x50, 0x69, 0x78, 0x65, + 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x61, 0x6c, + 0x70, 0x68, 0x61, 0x4d, 0x75, 0x6c, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, + 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x3d, 0x20, + 0x5f, 0x39, 0x38, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; static const unsigned int menu_pixel_msl_size = 2076; -static const unsigned char menu_mesh_vertex_spirv[] = {0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x06, 0x00, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x76, 0x70, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x32, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x90, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; +static const unsigned char menu_mesh_vertex_spirv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, + 0x05, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, + 0x2e, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, + 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x06, 0x00, 0x06, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x76, 0x70, 0x4d, + 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, + 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, + 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, + 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, + 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x90, 0x00, 0x05, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; static const unsigned int menu_mesh_vertex_spirv_size = 1176; -static const unsigned char menu_mesh_vertex_msl[] = {0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x6d, 0x76, 0x70, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x32, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x26, 0x20, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x6d, 0x76, 0x70, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x20, 0x2a, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; +static const unsigned char menu_mesh_vertex_msl[] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, + 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x5f, + 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, + 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x6d, 0x76, + 0x70, 0x4d, 0x61, 0x74, 0x72, 0x69, 0x78, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, + 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, + 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, + 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, + 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, + 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, + 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, + 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, + 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x31, 0x29, + 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, + 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, + 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, + 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, + 0x33, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, + 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, + 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x69, 0x6e, + 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, + 0x44, 0x32, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, + 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, 0x6d, 0x61, 0x69, 0x6e, + 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, + 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, + 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, + 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x74, + 0x79, 0x70, 0x65, 0x5f, 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x26, 0x20, + 0x4d, 0x65, 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, + 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, + 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, + 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x67, 0x6c, 0x5f, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x4d, 0x65, + 0x73, 0x68, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x55, 0x6e, 0x69, 0x66, + 0x6f, 0x72, 0x6d, 0x73, 0x2e, 0x6d, 0x76, 0x70, 0x4d, 0x61, 0x74, 0x72, + 0x69, 0x78, 0x20, 0x2a, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, + 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, + 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, + 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, + 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x30, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, + 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, + 0x44, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, + 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, + 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x2e, 0x69, + 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, + 0x52, 0x44, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; static const unsigned int menu_mesh_vertex_msl_size = 792; -static const unsigned char menu_mesh_pixel_spirv[] = {0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x32, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x73, 0x68, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x73, 0x68, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x09, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0a, 0xd7, 0x23, 0x3c, 0x19, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x13, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x14, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x14, 0x00, 0x02, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x16, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x57, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x15, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x21, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; +static const unsigned char menu_mesh_pixel_spirv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, + 0x05, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, + 0x2e, 0x32, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x73, 0x68, + 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x73, 0x68, 0x53, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x72, 0x00, 0x05, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, 0x45, 0x58, 0x43, 0x4f, + 0x4f, 0x52, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x2e, 0x76, 0x61, 0x72, 0x2e, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x2e, + 0x76, 0x61, 0x72, 0x2e, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x73, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x64, 0x2e, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x0a, 0xd7, 0x23, 0x3c, 0x19, 0x00, 0x09, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x14, 0x00, 0x02, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x56, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x05, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xf7, 0x00, 0x03, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfa, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x21, 0x00, 0x00, 0x00, + 0xfc, 0x00, 0x01, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00}; static const unsigned int menu_mesh_pixel_spirv_size = 992; -static const unsigned char menu_mesh_pixel_msl[] = {0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x6d, 0x65, 0x73, 0x68, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x6d, 0x65, 0x73, 0x68, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x32, 0x38, 0x20, 0x3d, 0x20, 0x6d, 0x65, 0x73, 0x68, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, 0x6d, 0x65, 0x73, 0x68, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x32, 0x39, 0x20, 0x3d, 0x20, 0x5f, 0x32, 0x38, 0x20, 0x2a, 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x5f, 0x32, 0x39, 0x2e, 0x77, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x30, 0x30, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x37, 0x36, 0x34, 0x38, 0x32, 0x35, 0x38, 0x32, 0x30, 0x39, 0x32, 0x32, 0x38, 0x35, 0x31, 0x35, 0x36, 0x32, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x63, 0x61, 0x72, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x5f, 0x32, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a}; +static const unsigned char menu_mesh_pixel_msl[] = { + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x6d, 0x65, + 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x3e, 0x0a, + 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x3c, 0x73, 0x69, + 0x6d, 0x64, 0x2f, 0x73, 0x69, 0x6d, 0x64, 0x2e, 0x68, 0x3e, 0x0a, 0x0a, + 0x75, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x0a, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x6f, 0x75, 0x74, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x6f, 0x75, 0x74, 0x5f, 0x76, 0x61, + 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, + 0x5b, 0x5b, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, + 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x0a, 0x7b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, + 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, + 0x52, 0x44, 0x30, 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, + 0x6f, 0x63, 0x6e, 0x30, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x69, 0x6e, 0x5f, 0x76, + 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x31, + 0x20, 0x5b, 0x5b, 0x75, 0x73, 0x65, 0x72, 0x28, 0x6c, 0x6f, 0x63, 0x6e, + 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x0a, 0x66, 0x72, + 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, + 0x5f, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x28, 0x6d, + 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x69, 0x6e, 0x20, 0x69, 0x6e, 0x20, 0x5b, + 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, + 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, + 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x6d, 0x65, 0x73, 0x68, 0x54, 0x65, + 0x78, 0x74, 0x75, 0x72, 0x65, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, + 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x6d, 0x65, 0x73, 0x68, 0x53, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x30, 0x5f, 0x6f, 0x75, + 0x74, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x3b, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, + 0x32, 0x38, 0x20, 0x3d, 0x20, 0x6d, 0x65, 0x73, 0x68, 0x54, 0x65, 0x78, + 0x74, 0x75, 0x72, 0x65, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x28, + 0x6d, 0x65, 0x73, 0x68, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2c, + 0x20, 0x69, 0x6e, 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, + 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x30, 0x29, 0x3b, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x5f, 0x32, + 0x39, 0x20, 0x3d, 0x20, 0x5f, 0x32, 0x38, 0x20, 0x2a, 0x20, 0x69, 0x6e, + 0x2e, 0x69, 0x6e, 0x5f, 0x76, 0x61, 0x72, 0x5f, 0x54, 0x45, 0x58, 0x43, + 0x4f, 0x4f, 0x52, 0x44, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, + 0x66, 0x20, 0x28, 0x5f, 0x32, 0x39, 0x2e, 0x77, 0x20, 0x3c, 0x20, 0x30, + 0x2e, 0x30, 0x30, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x37, 0x37, + 0x36, 0x34, 0x38, 0x32, 0x35, 0x38, 0x32, 0x30, 0x39, 0x32, 0x32, 0x38, + 0x35, 0x31, 0x35, 0x36, 0x32, 0x35, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x64, 0x69, + 0x73, 0x63, 0x61, 0x72, 0x64, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x28, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x2e, 0x6f, 0x75, 0x74, 0x5f, + 0x76, 0x61, 0x72, 0x5f, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x20, 0x3d, 0x20, 0x5f, 0x32, 0x39, 0x3b, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6f, 0x75, 0x74, 0x3b, + 0x0a, 0x7d, 0x0a, 0x0a}; static const unsigned int menu_mesh_pixel_msl_size = 664; #endif diff --git a/PROJECTS/ROLLER/mouse.c b/PROJECTS/ROLLER/mouse.c index d393e5fe..2c47a01e 100644 --- a/PROJECTS/ROLLER/mouse.c +++ b/PROJECTS/ROLLER/mouse.c @@ -1,107 +1,104 @@ #include "mouse.h" #include "3d.h" //------------------------------------------------------------------------------------------------- -//00075AA0 -void initmouse() -{ - //REGS registers; // [esp+0h] [ebp-24h] BYREF - //registers.w.ax = 0; // function 0 = reset mouse and get status - //int386(0x33, ®isters, ®isters); // 0x33 = mouse services - //mouse = registers.h.al; // mouse installed flag +// 00075AA0 +void initmouse() { + // REGS registers; // [esp+0h] [ebp-24h] BYREF + // registers.w.ax = 0; // function 0 = reset mouse + // and get status int386(0x33, ®isters, ®isters); // 0x33 = + // mouse services mouse = registers.h.al; // mouse + // installed flag } //------------------------------------------------------------------------------------------------- -//00075AD0 -void mousexy() -{ - //int iMouseX; // ecx - //int iMouseY; // esi - //REGS registers; // [esp+0h] [ebp-2Ch] BYREF +// 00075AD0 +void mousexy() { + // int iMouseX; // ecx + // int iMouseY; // esi + // REGS registers; // [esp+0h] [ebp-2Ch] BYREF // - //registers.w.ax = 0xB; // 0xb = Get Mouse Motion Counters - //int386(0x33, ®isters, ®isters); // 0x33 = mouse services + // registers.w.ax = 0xB; // 0xb = Get Mouse Motion + // Counters int386(0x33, ®isters, ®isters); // 0x33 = mouse + // services // //// get mouse x and y deltas - //dxmouse = (int16)registers.w.cx; - //dymouse = (int16)registers.w.dx; + // dxmouse = (int16)registers.w.cx; + // dymouse = (int16)registers.w.dx; // //// calculate new mouse position - //iMouseX = (int16)registers.w.cx + mousex; - //iMouseY = mousey - (int16)registers.w.dx; + // iMouseX = (int16)registers.w.cx + mousex; + // iMouseY = mousey - (int16)registers.w.dx; // //// clamp to screen bounds - //if (iMouseX > XMAX - 1) - // iMouseX = XMAX - 1; - //if (iMouseY > YMAX - 1) - // iMouseY = YMAX - 1; - //if (iMouseX < 0) - // iMouseX = 0; - //if (iMouseY < 0) - // iMouseY = 0; + // if (iMouseX > XMAX - 1) + // iMouseX = XMAX - 1; + // if (iMouseY > YMAX - 1) + // iMouseY = YMAX - 1; + // if (iMouseX < 0) + // iMouseX = 0; + // if (iMouseY < 0) + // iMouseY = 0; // //// store updated position - //mousey = iMouseY; - //mousex = iMouseX; + // mousey = iMouseY; + // mousex = iMouseX; } //------------------------------------------------------------------------------------------------- -//00075B60 -int mousebut(uint16 unMask) -{ - //REGS regs; // [esp+0h] [ebp-28h] BYREF - //if (!mouse) - // return 0; - //regs.w.ax = 5; // Function 5: Get button status - //regs.w.bx = 0; - //int386(0x33, ®s, ®s); // 0x33 = mouse services - //return unMask & regs.w.ax; // Return masked button status +// 00075B60 +int mousebut(uint16 unMask) { + // REGS regs; // [esp+0h] [ebp-28h] BYREF + // if (!mouse) + // return 0; + // regs.w.ax = 5; // Function 5: Get button + // status regs.w.bx = 0; int386(0x33, ®s, ®s); // 0x33 + // = mouse services return unMask & regs.w.ax; // Return + // masked button status return 0; } //------------------------------------------------------------------------------------------------- -//00075BB0 -void checkmouse() -{ - //char byCurrPressed; // cl - //REGS regs; // [esp+0h] [ebp-2Ch] BYREF - //char byPrevPressed; // [esp+1Ch] [ebp-10h] +// 00075BB0 +void checkmouse() { + // char byCurrPressed; // cl + // REGS regs; // [esp+0h] [ebp-2Ch] BYREF + // char byPrevPressed; // [esp+1Ch] [ebp-10h] // - //byPrevPressed = mpressed; - //if (mouse) { - // regs.w.ax = 5; // Function 5: Get button status - // regs.w.bx = 0; - // int386(0x33, ®s, ®s); // 0x33 = Mouse driver interrupt - // byCurrPressed = regs.h.al & 3; // Mask to left+right button bits - //} else { - // byCurrPressed = 0; - //} - //mpressed = byCurrPressed; - //if (byCurrPressed) { - // if (byPrevPressed) - // jpressed = 0; // Held down, not new - // else - // jpressed = -1; // New press - //} else { - // jpressed = 0; // Not pressed - //} + // byPrevPressed = mpressed; + // if (mouse) { + // regs.w.ax = 5; // Function 5: Get button + // status regs.w.bx = 0; int386(0x33, ®s, ®s); // 0x33 + // = Mouse driver interrupt byCurrPressed = regs.h.al & 3; // + // Mask to left+right button bits + // } else { + // byCurrPressed = 0; + // } + // mpressed = byCurrPressed; + // if (byCurrPressed) { + // if (byPrevPressed) + // jpressed = 0; // Held down, not new + // else + // jpressed = -1; // New press + // } else { + // jpressed = 0; // Not pressed + // } } //------------------------------------------------------------------------------------------------- -//00075C30 -void drmouse(int iX0, int iY0, uint8 *pData, uint8 *pScreenBase) -{ - int iScreenWidth; // edi +// 00075C30 +void drmouse(int iX0, int iY0, uint8 *pData, uint8 *pScreenBase) { + int iScreenWidth; // edi uint8 *pDataPlus1; // ebx - int iHotX; // eax - uint8 *pDataItr2; // ebx - int iYItr; // ebp - int v10; // esi - uint8 *pRowPtr; // edx - int i; // eax - int iPixel; // ecx + int iHotX; // eax + uint8 *pDataItr2; // ebx + int iYItr; // ebp + int v10; // esi + uint8 *pRowPtr; // edx + int i; // eax + int iPixel; // ecx uint8 *pScreenBuf; // [esp+0h] [ebp-1Ch] - int iYEnd; // [esp+4h] [ebp-18h] - int iXStart; // [esp+8h] [ebp-14h] + int iYEnd; // [esp+4h] [ebp-18h] + int iXStart; // [esp+8h] [ebp-14h] iScreenWidth = XMAX; pDataPlus1 = pData + 1; @@ -130,7 +127,7 @@ void drmouse(int iX0, int iY0, uint8 *pData, uint8 *pScreenBase) // Draw non-transparent pixels within horizontal scren bounds if (iPixel && i > 0 && i < iScreenWidth) - *pRowPtr = iPixel; // draw pixel to screen + *pRowPtr = iPixel; // draw pixel to screen ++i; } ++iYItr; @@ -139,11 +136,10 @@ void drmouse(int iX0, int iY0, uint8 *pData, uint8 *pScreenBase) } //------------------------------------------------------------------------------------------------- -//00075CC0 -void plotmouse() -{ - int iScreenWidth; // ecx - int iMouseX; // esi +// 00075CC0 +void plotmouse() { + int iScreenWidth; // ecx + int iMouseX; // esi uint8 *pScreenBuf; // eax iScreenWidth = XMAX; diff --git a/PROJECTS/ROLLER/moving.c b/PROJECTS/ROLLER/moving.c index 3c1ad34b..aee38a72 100644 --- a/PROJECTS/ROLLER/moving.c +++ b/PROJECTS/ROLLER/moving.c @@ -5,26 +5,18 @@ #include //------------------------------------------------------------------------------------------------- -int totalramps = 0; //000A7508 -tStuntData *ramp[50]; //001A1A80 -int replaytype; //001A1B48 +int totalramps = 0; // 000A7508 +tStuntData *ramp[50]; // 001A1A80 +int replaytype; // 001A1B48 //------------------------------------------------------------------------------------------------- -//00073E90 -tStuntData *initramp( - int iGeometryIdx, - int iChunkCount, - int iNumTicks, - int iTickStartIdx, - int iTimingGroup, - int iHeight, - int iTimeBulging, - int iTimeFlat, - int iRampSideLength, - int iFlags) -{ +// 00073E90 +tStuntData *initramp(int iGeometryIdx, int iChunkCount, int iNumTicks, + int iTickStartIdx, int iTimingGroup, int iHeight, + int iTimeBulging, int iTimeFlat, int iRampSideLength, + int iFlags) { tStuntData *pBuffer; // eax - tStuntData *pStunt; // [esp+0h] [ebp-10h] BYREF + tStuntData *pStunt; // [esp+0h] [ebp-10h] BYREF pBuffer = (tStuntData *)getbuffer(sizeof(tStuntData)); pStunt = pBuffer; @@ -58,99 +50,131 @@ tStuntData *initramp( } //------------------------------------------------------------------------------------------------- -//00073F80 -void reinitramp(tStuntData *pStunt) -{ - int iGeometryIdx; // ebx - int iStartTrackIdx; // eax - int iFlags; // edi - int iAngle; // eax - tStuntGeometry *pChunkData; // ebp - int iPointOffset; // esi - tStuntLocalPoint *pDataPoint; // ebx - double dRelX; // st7 - double dRelY; // st6 - double dRelZ; // st5 - double dTempZ; // st4 - double dRelX2; // st7 - double dRelY2; // st6 - double dRelZ2; // st5 - double dTempZ2; // st4 - double dTrackHalfLength_1; // st7 - int iPointOffset2; // ebx +// 00073F80 +void reinitramp(tStuntData *pStunt) { + int iGeometryIdx; // ebx + int iStartTrackIdx; // eax + int iFlags; // edi + int iAngle; // eax + tStuntGeometry *pChunkData; // ebp + int iPointOffset; // esi + tStuntLocalPoint *pDataPoint; // ebx + double dRelX; // st7 + double dRelY; // st6 + double dRelZ; // st5 + double dTempZ; // st4 + double dRelX2; // st7 + double dRelY2; // st6 + double dRelZ2; // st5 + double dTempZ2; // st4 + double dTrackHalfLength_1; // st7 + int iPointOffset2; // ebx tStuntLocalPoint *pDataPoint2; // esi - double dRelX3; // st7 - double dRelY3; // st6 - double dRelZ3; // st5 - double dRelX4; // st7 - double dRelY4; // st6 - double dRelZ4; // st5 - double dTrackHalfLength; // st7 - float fDeltaX; // [esp+0h] [ebp-88h] - float fDeltaY; // [esp+4h] [ebp-84h] - int iStartIdx; // [esp+24h] [ebp-64h] - int iChunkCount; // [esp+28h] [ebp-60h] - int j; // [esp+30h] [ebp-58h] - int iPointOffsetBase; // [esp+34h] [ebp-54h] - int iPointOffsetCur; // [esp+38h] [ebp-50h] - tData *pCurrentData; // [esp+3Ch] [ebp-4Ch] - tData *pNextData; // [esp+3Ch] [ebp-4Ch] - float fCos; // [esp+54h] [ebp-34h] - float fNegSin; // [esp+58h] [ebp-30h] - float fSin; // [esp+60h] [ebp-28h] - int i; // [esp+64h] [ebp-24h] - int k; // [esp+68h] [ebp-20h] + double dRelX3; // st7 + double dRelY3; // st6 + double dRelZ3; // st5 + double dRelX4; // st7 + double dRelY4; // st6 + double dRelZ4; // st5 + double dTrackHalfLength; // st7 + float fDeltaX; // [esp+0h] [ebp-88h] + float fDeltaY; // [esp+4h] [ebp-84h] + int iStartIdx; // [esp+24h] [ebp-64h] + int iChunkCount; // [esp+28h] [ebp-60h] + int j; // [esp+30h] [ebp-58h] + int iPointOffsetBase; // [esp+34h] [ebp-54h] + int iPointOffsetCur; // [esp+38h] [ebp-50h] + tData *pCurrentData; // [esp+3Ch] [ebp-4Ch] + tData *pNextData; // [esp+3Ch] [ebp-4Ch] + float fCos; // [esp+54h] [ebp-34h] + float fNegSin; // [esp+58h] [ebp-30h] + float fSin; // [esp+60h] [ebp-28h] + int i; // [esp+64h] [ebp-24h] + int k; // [esp+68h] [ebp-20h] - pStunt->iTickStartIdx = pStunt->iTickStartIdx2;// Initialize stunt timing and geometry data + pStunt->iTickStartIdx = + pStunt->iTickStartIdx2; // Initialize stunt timing and geometry data pStunt->iTimingGroup2 = pStunt->iTimingGroup; iGeometryIdx = pStunt->iGeometryIdx; iChunkCount = pStunt->iChunkCount; iStartTrackIdx = pStunt->iGeometryIdx - iChunkCount; pStunt->iRunningTimer = 0; - pStunt->startPos.fX = (TrakPt[iStartTrackIdx].pointAy[2].fX + TrakPt[iStartTrackIdx].pointAy[3].fX) * 0.5f;// Calculate start position as midpoint between track edge points - pStunt->startPos.fY = (TrakPt[iStartTrackIdx].pointAy[2].fY + TrakPt[iStartTrackIdx].pointAy[3].fY) * 0.5f; - pStunt->startPos.fZ = (TrakPt[iStartTrackIdx].pointAy[2].fZ + TrakPt[iStartTrackIdx].pointAy[3].fZ) * 0.5f; - pStunt->endPos.fX = (TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[2].fX + TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[3].fX) * 0.5f;// Calculate end position as midpoint between track edge points - pStunt->endPos.fY = (TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[2].fY + TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[3].fY) * 0.5f; - pStunt->endPos.fZ = (TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[2].fZ + TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[3].fZ) * 0.5f; + pStunt->startPos.fX = + (TrakPt[iStartTrackIdx].pointAy[2].fX + + TrakPt[iStartTrackIdx].pointAy[3].fX) * + 0.5f; // Calculate start position as midpoint between track edge points + pStunt->startPos.fY = (TrakPt[iStartTrackIdx].pointAy[2].fY + + TrakPt[iStartTrackIdx].pointAy[3].fY) * + 0.5f; + pStunt->startPos.fZ = (TrakPt[iStartTrackIdx].pointAy[2].fZ + + TrakPt[iStartTrackIdx].pointAy[3].fZ) * + 0.5f; + pStunt->endPos.fX = + (TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[2].fX + + TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[3].fX) * + 0.5f; // Calculate end position as midpoint between track edge points + pStunt->endPos.fY = (TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[2].fY + + TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[3].fY) * + 0.5f; + pStunt->endPos.fZ = (TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[2].fZ + + TrakPt[iGeometryIdx + 1 + iChunkCount].pointAy[3].fZ) * + 0.5f; iFlags = pStunt->iFlags; - fDeltaY = (TrakPt[iGeometryIdx].pointAy[2].fY + TrakPt[iGeometryIdx].pointAy[3].fY) * 0.5f - pStunt->startPos.fY; - fDeltaX = (TrakPt[iGeometryIdx].pointAy[2].fX + TrakPt[iGeometryIdx].pointAy[3].fX) * 0.5f - pStunt->startPos.fX; - iAngle = getangle(fDeltaX, fDeltaY); // Calculate ramp angle from delta coordinates + fDeltaY = (TrakPt[iGeometryIdx].pointAy[2].fY + + TrakPt[iGeometryIdx].pointAy[3].fY) * + 0.5f - + pStunt->startPos.fY; + fDeltaX = (TrakPt[iGeometryIdx].pointAy[2].fX + + TrakPt[iGeometryIdx].pointAy[3].fX) * + 0.5f - + pStunt->startPos.fX; + iAngle = + getangle(fDeltaX, fDeltaY); // Calculate ramp angle from delta coordinates pStunt->iAngle = iAngle; iStartIdx = iGeometryIdx - iChunkCount + 1; - fSin = tsin[iAngle]; // Get sine and cosine values from lookup tables + fSin = tsin[iAngle]; // Get sine and cosine values from lookup tables fCos = tcos[iAngle]; pChunkData = pStunt->chunkDataAy; pCurrentData = &localdata[iStartIdx - 1]; fNegSin = -fSin; if (iChunkCount > 0) { - iPointOffsetCur = 72 * iStartIdx; // Process first chunk of track geometry data + iPointOffsetCur = + 72 * iStartIdx; // Process first chunk of track geometry data do { iPointOffset = iPointOffsetCur; pDataPoint = (tStuntLocalPoint *)pChunkData; for (i = 0; i < 6; ++i) { if (((1 << i) & iFlags) != 0) { - dRelX = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset) - pStunt->startPos.fX;// Transform track point coordinates relative to ramp start position - dRelY = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset) - pStunt->startPos.fY; - dRelZ = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset) - pStunt->startPos.fZ; + dRelX = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset) - + pStunt->startPos.fX; // Transform track point coordinates + // relative to ramp start position + dRelY = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset) - + pStunt->startPos.fY; + dRelZ = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset) - + pStunt->startPos.fZ; dTempZ = 0.0 * dRelZ; //_CHP(); //_CHP(); //_CHP(); - pDataPoint->iLocalX = (int)(fCos * dRelX + fSin * dRelY + dTempZ);// Apply rotation matrix to transform coordinates + pDataPoint->iLocalX = + (int)(fCos * dRelX + fSin * dRelY + + dTempZ); // Apply rotation matrix to transform coordinates pDataPoint->iLocalY = (int)(dTempZ + fNegSin * dRelX + fCos * dRelY); pDataPoint->iLocalZ = (int)(dRelX * 0.0 + dRelY * 0.0 + dRelZ); } ++pDataPoint; iPointOffset += sizeof(tStuntLocalPoint); } - dRelX2 = -pCurrentData->pointAy[3].fX - pStunt->startPos.fX;// Process special data point with negative coordinates + dRelX2 = -pCurrentData->pointAy[3].fX - + pStunt->startPos + .fX; // Process special data point with negative coordinates dRelY2 = -pCurrentData->pointAy[3].fY - pStunt->startPos.fY; dRelZ2 = -pCurrentData->pointAy[3].fZ - pStunt->startPos.fZ; dTempZ2 = 0.0 * dRelZ2; - pChunkData->refPoint.fX = (float)(fCos * dRelX2 + fSin * dRelY2 + dTempZ2); - pChunkData->refPoint.fY = (float)(dTempZ2 + fNegSin * dRelX2 + fCos * dRelY2); + pChunkData->refPoint.fX = + (float)(fCos * dRelX2 + fSin * dRelY2 + dTempZ2); + pChunkData->refPoint.fY = + (float)(dTempZ2 + fNegSin * dRelX2 + fCos * dRelY2); pChunkData->refPoint.fZ = (float)(dRelX2 * 0.0 + dRelY2 * 0.0 + dRelZ2); dTrackHalfLength_1 = pCurrentData->fTrackHalfLength; ++pChunkData; @@ -161,21 +185,31 @@ void reinitramp(tStuntData *pStunt) } pNextData = pCurrentData + 1; iPointOffsetBase = 72 * iStartIdx + 72 * iChunkCount; - for (j = 144 * iChunkCount + 72 * iStartIdx; iPointOffsetBase < j; pChunkData[-1].fTrackHalfLength = (float)dTrackHalfLength)// Process second chunk of track geometry data relative to ramp end + for (j = 144 * iChunkCount + 72 * iStartIdx; iPointOffsetBase < j; + pChunkData[-1].fTrackHalfLength = + (float)dTrackHalfLength) // Process second chunk of track geometry + // data relative to ramp end { iPointOffset2 = iPointOffsetBase; pDataPoint2 = (tStuntLocalPoint *)pChunkData; for (k = 0; k < 6; ++k) { if (((1 << k) & iFlags) != 0) { - dRelX3 = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset2) - pStunt->endPos.fX;// Transform track point coordinates relative to ramp end position - dRelY3 = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset2) - pStunt->endPos.fY; - dRelZ3 = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset2) - pStunt->endPos.fZ; + dRelX3 = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset2) - + pStunt->endPos.fX; // Transform track point coordinates + // relative to ramp end position + dRelY3 = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset2) - + pStunt->endPos.fY; + dRelZ3 = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset2) - + pStunt->endPos.fZ; //_CHP(); //_CHP(); //_CHP(); - pDataPoint2->iLocalX = (int)(fCos * dRelX3 + fSin * dRelY3 + 0.0 * dRelZ3); - pDataPoint2->iLocalY = (int)(fNegSin * dRelX3 + fCos * dRelY3 + 0.0 * dRelZ3); - pDataPoint2->iLocalZ = (int)(dRelX3 * 0.0 + dRelY3 * 0.0 + dRelZ3 * 1.0); + pDataPoint2->iLocalX = + (int)(fCos * dRelX3 + fSin * dRelY3 + 0.0 * dRelZ3); + pDataPoint2->iLocalY = + (int)(fNegSin * dRelX3 + fCos * dRelY3 + 0.0 * dRelZ3); + pDataPoint2->iLocalZ = + (int)(dRelX3 * 0.0 + dRelY3 * 0.0 + dRelZ3 * 1.0); } ++pDataPoint2; iPointOffset2 += sizeof(tStuntLocalPoint); @@ -183,92 +217,96 @@ void reinitramp(tStuntData *pStunt) dRelX4 = -pNextData->pointAy[3].fX - pStunt->endPos.fX; dRelY4 = -pNextData->pointAy[3].fY - pStunt->endPos.fY; dRelZ4 = -pNextData->pointAy[3].fZ - pStunt->endPos.fZ; - pChunkData->refPoint.fX = (float)(fCos * dRelX4 + fSin * dRelY4 + 0.0 * dRelZ4); - pChunkData->refPoint.fY = (float)(fNegSin * dRelX4 + fCos * dRelY4 + 0.0 * dRelZ4); - pChunkData->refPoint.fZ = (float)(dRelX4 * 0.0 + dRelY4 * 0.0 + dRelZ4 * 1.0); + pChunkData->refPoint.fX = + (float)(fCos * dRelX4 + fSin * dRelY4 + 0.0 * dRelZ4); + pChunkData->refPoint.fY = + (float)(fNegSin * dRelX4 + fCos * dRelY4 + 0.0 * dRelZ4); + pChunkData->refPoint.fZ = + (float)(dRelX4 * 0.0 + dRelY4 * 0.0 + dRelZ4 * 1.0); dTrackHalfLength = pNextData->fTrackHalfLength; ++pChunkData; ++pNextData; iPointOffsetBase += sizeof(tGroundPt); } - updateramp(pStunt); // Update ramp display data after geometry processing + updateramp(pStunt); // Update ramp display data after geometry processing } //------------------------------------------------------------------------------------------------- -//00074440 -void updateramp(tStuntData *pStunt) -{ - int iTickStartIdx; // edx - int iTimer; // ecx - int iHeightOffset; // ebx - int iAngle; // edx - double dNegSin; // st7 - int iFlags; // esi - int iStartIdx; // edx - tData *pData; // edi - int iFlagBit; // ecx - int iPointOffset; // ebx - tStuntLocalPoint *pLocalPoint; // edx - double dScaledX; // st7 - double iLocalY; // st6 - double iLocalZ; // st5 - double dInterpolation; // st6 - tData *pNextData; // edi - int iFlagBit2; // ecx - int iPointOffset2; // ebx - tStuntLocalPoint *pCoords; // edx - double dScaledX2; // st7 - double dLocalY2; // st6 - double dLocalZ2; // st5 - double dInterpolation2; // st6 - double dTrackHalfLength; // st6 - int iGeometryIdx; // ebx - double dMidX; // st7 - double dMidY; // st6 - double dMidZ; // st5 - int iNextGeomIdx; // eax - double dNextMidX; // st4 - double dNextMidY; // st3 - double dNextMidZ; // st2 - tData *pCurrentData; // edx - float fHeightCos; // [esp+14h] [ebp-A0h] - float fHeightSin; // [esp+18h] [ebp-9Ch] - float fAngleCos; // [esp+24h] [ebp-90h] - float fAngleSin; // [esp+28h] [ebp-8Ch] - float fZ; // [esp+2Ch] [ebp-88h] - float fRefZ2; // [esp+2Ch] [ebp-88h] - float fY; // [esp+30h] [ebp-84h] - float fRefY2; // [esp+30h] [ebp-84h] - int iHeightValue; // [esp+38h] [ebp-7Ch] - float fGravityX; // [esp+3Ch] [ebp-78h] - float fGravityX2; // [esp+40h] [ebp-74h] - float fGravityZ; // [esp+44h] [ebp-70h] - float fGravityZ2; // [esp+48h] [ebp-6Ch] - float fGravityY; // [esp+4Ch] [ebp-68h] - int *pEndLocalPoints; // [esp+50h] [ebp-64h] - int iCurrentIdx; // [esp+54h] [ebp-60h] - int iPointOffsetBase; // [esp+58h] [ebp-5Ch] +// 00074440 +void updateramp(tStuntData *pStunt) { + int iTickStartIdx; // edx + int iTimer; // ecx + int iHeightOffset; // ebx + int iAngle; // edx + double dNegSin; // st7 + int iFlags; // esi + int iStartIdx; // edx + tData *pData; // edi + int iFlagBit; // ecx + int iPointOffset; // ebx + tStuntLocalPoint *pLocalPoint; // edx + double dScaledX; // st7 + double iLocalY; // st6 + double iLocalZ; // st5 + double dInterpolation; // st6 + tData *pNextData; // edi + int iFlagBit2; // ecx + int iPointOffset2; // ebx + tStuntLocalPoint *pCoords; // edx + double dScaledX2; // st7 + double dLocalY2; // st6 + double dLocalZ2; // st5 + double dInterpolation2; // st6 + double dTrackHalfLength; // st6 + int iGeometryIdx; // ebx + double dMidX; // st7 + double dMidY; // st6 + double dMidZ; // st5 + int iNextGeomIdx; // eax + double dNextMidX; // st4 + double dNextMidY; // st3 + double dNextMidZ; // st2 + tData *pCurrentData; // edx + float fHeightCos; // [esp+14h] [ebp-A0h] + float fHeightSin; // [esp+18h] [ebp-9Ch] + float fAngleCos; // [esp+24h] [ebp-90h] + float fAngleSin; // [esp+28h] [ebp-8Ch] + float fZ; // [esp+2Ch] [ebp-88h] + float fRefZ2; // [esp+2Ch] [ebp-88h] + float fY; // [esp+30h] [ebp-84h] + float fRefY2; // [esp+30h] [ebp-84h] + int iHeightValue; // [esp+38h] [ebp-7Ch] + float fGravityX; // [esp+3Ch] [ebp-78h] + float fGravityX2; // [esp+40h] [ebp-74h] + float fGravityZ; // [esp+44h] [ebp-70h] + float fGravityZ2; // [esp+48h] [ebp-6Ch] + float fGravityY; // [esp+4Ch] [ebp-68h] + int *pEndLocalPoints; // [esp+50h] [ebp-64h] + int iCurrentIdx; // [esp+54h] [ebp-60h] + int iPointOffsetBase; // [esp+58h] [ebp-5Ch] tStuntLocalPoint *pEndLocalPoints_1; // [esp+5Ch] [ebp-58h] - int iPointOffsetCur; // [esp+60h] [ebp-54h] - int iGeomIdx; // [esp+64h] [ebp-50h] - tStuntGeometry *pStuntGeometry; // [esp+68h] [ebp-4Ch] - float fNegAngleSin; // [esp+78h] [ebp-3Ch] - float fRotYX; // [esp+7Ch] [ebp-38h] - float fRotXX; // [esp+80h] [ebp-34h] - float fRotXZ; // [esp+8Ch] [ebp-28h] - float fRotYZ; // [esp+90h] [ebp-24h] - float fRampScale; // [esp+94h] [ebp-20h] - float fInterpolation; // [esp+94h] [ebp-20h] - float fRotZX; // [esp+98h] [ebp-1Ch] + int iPointOffsetCur; // [esp+60h] [ebp-54h] + int iGeomIdx; // [esp+64h] [ebp-50h] + tStuntGeometry *pStuntGeometry; // [esp+68h] [ebp-4Ch] + float fNegAngleSin; // [esp+78h] [ebp-3Ch] + float fRotYX; // [esp+7Ch] [ebp-38h] + float fRotXX; // [esp+80h] [ebp-34h] + float fRotXZ; // [esp+8Ch] [ebp-28h] + float fRotYZ; // [esp+90h] [ebp-24h] + float fRampScale; // [esp+94h] [ebp-20h] + float fInterpolation; // [esp+94h] [ebp-20h] + float fRotZX; // [esp+98h] [ebp-1Ch] - iTickStartIdx = pStunt->iTickStartIdx; // Get current tick position for ramp animation timing - if (replaytype != 2) // Skip timing updates during replay mode + iTickStartIdx = pStunt->iTickStartIdx; // Get current tick position for ramp + // animation timing + if (replaytype != 2) // Skip timing updates during replay mode { iTimer = pStunt->iRunningTimer; - if (iTimer) // Handle ramp animation state machine for timing control + if (iTimer) // Handle ramp animation state machine for timing control { pStunt->iRunningTimer = iTimer - 1; - } else if (pStunt->iTimingGroup2 == 1) { // Check if reached end of ramp animation sequence + } else if (pStunt->iTimingGroup2 == + 1) { // Check if reached end of ramp animation sequence if (iTickStartIdx == pStunt->iNumTicks - 1) { pStunt->iTimingGroup2 = -1; pStunt->iRunningTimer = pStunt->iTimeBulging; @@ -282,35 +320,49 @@ void updateramp(tStuntData *pStunt) pStunt->iRunningTimer = pStunt->iTimeFlat; } } - if (iTickStartIdx != pStunt->iTickStartIdx || replaytype == 2)// Update geometry only when timing changed or in replay mode + if (iTickStartIdx != pStunt->iTickStartIdx || + replaytype == + 2) // Update geometry only when timing changed or in replay mode { - iHeightOffset = iTickStartIdx * pStunt->iHeight;// Calculate height offset based on current tick position + iHeightOffset = + iTickStartIdx * + pStunt + ->iHeight; // Calculate height offset based on current tick position pStunt->iTickStartIdx = iTickStartIdx; iAngle = pStunt->iAngle; iHeightValue = iHeightOffset; - fAngleSin = tsin[iAngle]; // Get trigonometric values from lookup tables for rotation matrix + fAngleSin = tsin[iAngle]; // Get trigonometric values from lookup tables for + // rotation matrix fAngleCos = tcos[iAngle]; fHeightCos = tcos[iHeightOffset]; - fRotXX = fHeightCos * fAngleCos; // Build 3D rotation matrix components for coordinate transformation + fRotXX = fHeightCos * fAngleCos; // Build 3D rotation matrix components for + // coordinate transformation fRotYX = fHeightCos * fAngleSin; fNegAngleSin = -fAngleSin; fHeightSin = tsin[iHeightOffset]; dNegSin = -fHeightSin; fRotXZ = (float)dNegSin * fAngleCos; fRotYZ = (float)dNegSin * fAngleSin; - fRampScale = (float)((double)pStunt->iRampSideLength * 0.0009765625);// Calculate ramp scaling factor and interpolation value + fRampScale = (float)((double)pStunt->iRampSideLength * + 0.0009765625); // Calculate ramp scaling factor and + // interpolation value iFlags = pStunt->iFlags; fRotZX = fHeightSin; pStuntGeometry = pStunt->chunkDataAy; - if (!pStuntGeometry) //added by ROLLER + if (!pStuntGeometry) // added by ROLLER return; iStartIdx = pStunt->iGeometryIdx - pStunt->iChunkCount + 1; iCurrentIdx = iStartIdx; pData = &localdata[iStartIdx - 1]; - fInterpolation = (float)((double)pStunt->iTickStartIdx * (fRampScale + -1.0) / (double)pStunt->iNumTicks + 1.0);// Calculate animation interpolation factor based on timing state - if (iStartIdx <= pStunt->iGeometryIdx) // Process first half of ramp geometry (start to middle) + fInterpolation = + (float)((double)pStunt->iTickStartIdx * (fRampScale + -1.0) / + (double)pStunt->iNumTicks + + 1.0); // Calculate animation interpolation factor based on + // timing state + if (iStartIdx <= pStunt->iGeometryIdx) // Process first half of ramp + // geometry (start to middle) { pEndLocalPoints = (int *)&pStuntGeometry->refPoint; iPointOffsetCur = 72 * iStartIdx; @@ -318,29 +370,48 @@ void updateramp(tStuntData *pStunt) iFlagBit = 1; iPointOffset = iPointOffsetCur; pLocalPoint = (tStuntLocalPoint *)pStuntGeometry; - do { // Transform local ramp coordinates to world coordinates for each track point + do { // Transform local ramp coordinates to world coordinates for each + // track point if ((iFlagBit & iFlags) != 0) { dScaledX = (double)pLocalPoint->iLocalX * fInterpolation; iLocalY = (double)pLocalPoint->iLocalY; iLocalZ = (double)pLocalPoint->iLocalZ; - *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset) = (float)(fRotXX * dScaledX + fNegAngleSin * iLocalY + fRotXZ * iLocalZ + pStunt->startPos.fX);// Apply 3D rotation matrix and translation to transform coordinates - *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset) = (float)(fRotYX * dScaledX + fAngleCos * iLocalY + fRotYZ * iLocalZ + pStunt->startPos.fY); - *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset) = (float)(dScaledX * fHeightSin + iLocalY * 0.0 + iLocalZ * fHeightCos + pStunt->startPos.fZ); + *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset) = + (float)(fRotXX * dScaledX + fNegAngleSin * iLocalY + + fRotXZ * iLocalZ + + pStunt->startPos + .fX); // Apply 3D rotation matrix and translation to + // transform coordinates + *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset) = + (float)(fRotYX * dScaledX + fAngleCos * iLocalY + + fRotYZ * iLocalZ + pStunt->startPos.fY); + *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset) = + (float)(dScaledX * fHeightSin + iLocalY * 0.0 + + iLocalZ * fHeightCos + pStunt->startPos.fZ); } iPointOffset += 12; ++pLocalPoint; iFlagBit *= 2; } while (pLocalPoint != (tStuntLocalPoint *)pEndLocalPoints); - dInterpolation = pStuntGeometry->refPoint.fX * fInterpolation;// Transform reference point with negative coordinates + dInterpolation = pStuntGeometry->refPoint.fX * + fInterpolation; // Transform reference point with + // negative coordinates fY = pStuntGeometry->refPoint.fY; fZ = pStuntGeometry->refPoint.fZ; - pData->pointAy[3].fX = (float)(-fRotXX * dInterpolation - fNegAngleSin * fY - fRotXZ * fZ - pStunt->startPos.fX); - pData->pointAy[3].fY = (float)(-fRotYX * dInterpolation - fAngleCos * fY - fRotYZ * fZ - pStunt->startPos.fY); - pData->pointAy[3].fZ = (float)(dInterpolation * -fHeightSin - 0.0 * fY - fHeightCos * fZ - pStunt->startPos.fZ); - pData->fTrackHalfLength = fInterpolation * pStuntGeometry->fTrackHalfLength; + pData->pointAy[3].fX = + (float)(-fRotXX * dInterpolation - fNegAngleSin * fY - fRotXZ * fZ - + pStunt->startPos.fX); + pData->pointAy[3].fY = + (float)(-fRotYX * dInterpolation - fAngleCos * fY - fRotYZ * fZ - + pStunt->startPos.fY); + pData->pointAy[3].fZ = (float)(dInterpolation * -fHeightSin - 0.0 * fY - + fHeightCos * fZ - pStunt->startPos.fZ); + pData->fTrackHalfLength = + fInterpolation * pStuntGeometry->fTrackHalfLength; ++pData; pData[-1].pointAy[2].fY = 0.0; - pData[-1].pointAy[0].fX = fRotXX; // Set up rotation matrix components for track geometry + pData[-1].pointAy[0].fX = + fRotXX; // Set up rotation matrix components for track geometry pData[-1].pointAy[0].fY = fNegAngleSin; pData[-1].pointAy[0].fZ = fRotXZ; pData[-1].pointAy[1].fX = fRotYX; @@ -351,7 +422,8 @@ void updateramp(tStuntData *pStunt) pData[-1].pointAy[2].fZ = fHeightCos; ++iCurrentIdx; fGravityX = fHeightSin * -3.0f; - pData[-1].gravity.fX = fGravityX; // Set gravity vector components for physics simulation + pData[-1].gravity.fX = + fGravityX; // Set gravity vector components for physics simulation ++pStuntGeometry; fGravityZ = fHeightCos * -3.0f; pData[-1].gravity.fZ = fGravityZ; @@ -360,27 +432,36 @@ void updateramp(tStuntData *pStunt) } while (iCurrentIdx <= pStunt->iGeometryIdx); } fRotZX = -fHeightSin; - //HIBYTE(fRotZX) = HIBYTE(fHeightSin) ^ 0x80; + // HIBYTE(fRotZX) = HIBYTE(fHeightSin) ^ 0x80; fRotXZ = -fRotXZ; - //HIBYTE(fRotXZ) ^= 0x80u; + // HIBYTE(fRotXZ) ^= 0x80u; iGeomIdx = pStunt->iGeometryIdx + 1; fRotYZ = -fRotYZ; - //HIBYTE(fRotYZ) ^= 0x80u; + // HIBYTE(fRotYZ) ^= 0x80u; pEndLocalPoints_1 = (tStuntLocalPoint *)&pStuntGeometry->refPoint; pNextData = pData + 1; - iPointOffsetBase = 72 * iGeomIdx; // Process second half of ramp geometry (middle to end) + iPointOffsetBase = + 72 * iGeomIdx; // Process second half of ramp geometry (middle to end) while (pStunt->iChunkCount + pStunt->iGeometryIdx >= iGeomIdx) { iFlagBit2 = 1; iPointOffset2 = iPointOffsetBase; pCoords = (tStuntLocalPoint *)pStuntGeometry; - do { // Transform coordinates relative to ramp end position + do { // Transform coordinates relative to ramp end position if ((iFlagBit2 & iFlags) != 0) { dScaledX2 = (double)pCoords->iLocalX * fInterpolation; dLocalY2 = (double)pCoords->iLocalY; dLocalZ2 = (double)pCoords->iLocalZ; - *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset2) = (float)(fRotXX * dScaledX2 + fNegAngleSin * dLocalY2 + fRotXZ * dLocalZ2 + pStunt->endPos.fX);// Apply transformation matrix relative to end position - *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset2) = (float)(fRotYX * dScaledX2 + fAngleCos * dLocalY2 + fRotYZ * dLocalZ2 + pStunt->endPos.fY); - *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset2) = (float)(dScaledX2 * fRotZX + dLocalY2 * 0.0 + dLocalZ2 * fHeightCos + pStunt->endPos.fZ); + *(float *)((char *)&TrakPt[0].pointAy[0].fX + iPointOffset2) = + (float)(fRotXX * dScaledX2 + fNegAngleSin * dLocalY2 + + fRotXZ * dLocalZ2 + + pStunt->endPos.fX); // Apply transformation matrix + // relative to end position + *(float *)((char *)&TrakPt[0].pointAy[0].fY + iPointOffset2) = + (float)(fRotYX * dScaledX2 + fAngleCos * dLocalY2 + + fRotYZ * dLocalZ2 + pStunt->endPos.fY); + *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iPointOffset2) = + (float)(dScaledX2 * fRotZX + dLocalY2 * 0.0 + + dLocalZ2 * fHeightCos + pStunt->endPos.fZ); } iPointOffset2 += 12; ++pCoords; @@ -389,9 +470,15 @@ void updateramp(tStuntData *pStunt) dInterpolation2 = pStuntGeometry->refPoint.fX * fInterpolation; fRefY2 = pStuntGeometry->refPoint.fY; fRefZ2 = pStuntGeometry->refPoint.fZ; - pNextData->pointAy[3].fX = (float)(-fRotXX * dInterpolation2 - fNegAngleSin * fRefY2 - fRotXZ * fRefZ2 - pStunt->endPos.fX); - pNextData->pointAy[3].fY = (float)(-fRotYX * dInterpolation2 - fAngleCos * fRefY2 - fRotYZ * fRefZ2 - pStunt->endPos.fY); - pNextData->pointAy[3].fZ = (float)(dInterpolation2 * -fRotZX - 0.0 * fRefY2 - fHeightCos * fRefZ2 - pStunt->endPos.fZ); + pNextData->pointAy[3].fX = + (float)(-fRotXX * dInterpolation2 - fNegAngleSin * fRefY2 - + fRotXZ * fRefZ2 - pStunt->endPos.fX); + pNextData->pointAy[3].fY = + (float)(-fRotYX * dInterpolation2 - fAngleCos * fRefY2 - + fRotYZ * fRefZ2 - pStunt->endPos.fY); + pNextData->pointAy[3].fZ = + (float)(dInterpolation2 * -fRotZX - 0.0 * fRefY2 - + fHeightCos * fRefZ2 - pStunt->endPos.fZ); ++pNextData; dTrackHalfLength = pStuntGeometry->fTrackHalfLength; pNextData[-1].pointAy[0].fX = fRotXX; @@ -415,34 +502,50 @@ void updateramp(tStuntData *pStunt) pNextData[-1].fTrackHalfLength = fInterpolation * (float)dTrackHalfLength; pEndLocalPoints_1 = (tStuntLocalPoint *)((char *)pEndLocalPoints_1 + 88); } - //TODO is this correct? + // TODO is this correct? localdata[pStunt->iGeometryIdx - pStunt->iChunkCount].iPitch = iHeightValue; localdata[pStunt->iGeometryIdx].iPitch = -iHeightValue; - //HorizonColour[32 * (pStunt->iGeometryIdx - pStunt->iChunkCount) + 482] = iHeightValue; - //HorizonColour[32 * pStunt->iGeometryIdx + 482] = -iHeightValue; - localdata[pStunt->iGeometryIdx].iPitch = -iHeightValue;// Set pitch values for track geometry + // HorizonColour[32 * (pStunt->iGeometryIdx - pStunt->iChunkCount) + 482] = + // iHeightValue; HorizonColour[32 * pStunt->iGeometryIdx + 482] = + // -iHeightValue; + localdata[pStunt->iGeometryIdx].iPitch = + -iHeightValue; // Set pitch values for track geometry localdata[pStunt->iChunkCount + pStunt->iGeometryIdx].iPitch = iHeightValue; iGeometryIdx = pStunt->iGeometryIdx; - dMidX = (TrakPt[pStunt->iGeometryIdx].pointAy[2].fX + TrakPt[pStunt->iGeometryIdx].pointAy[3].fX) * 0.5;// Calculate ramp center point for final geometry setup - dMidY = (TrakPt[pStunt->iGeometryIdx].pointAy[2].fY + TrakPt[pStunt->iGeometryIdx].pointAy[3].fY) * 0.5; - dMidZ = (TrakPt[pStunt->iGeometryIdx].pointAy[2].fZ + TrakPt[pStunt->iGeometryIdx].pointAy[3].fZ) * 0.5; + dMidX = (TrakPt[pStunt->iGeometryIdx].pointAy[2].fX + + TrakPt[pStunt->iGeometryIdx].pointAy[3].fX) * + 0.5; // Calculate ramp center point for final geometry setup + dMidY = (TrakPt[pStunt->iGeometryIdx].pointAy[2].fY + + TrakPt[pStunt->iGeometryIdx].pointAy[3].fY) * + 0.5; + dMidZ = (TrakPt[pStunt->iGeometryIdx].pointAy[2].fZ + + TrakPt[pStunt->iGeometryIdx].pointAy[3].fZ) * + 0.5; iNextGeomIdx = pStunt->iGeometryIdx + 1; - dNextMidX = (TrakPt[iNextGeomIdx].pointAy[2].fX + TrakPt[iNextGeomIdx].pointAy[3].fX) * 0.5; - dNextMidY = (TrakPt[iNextGeomIdx].pointAy[2].fY + TrakPt[iNextGeomIdx].pointAy[3].fY) * 0.5; - dNextMidZ = (TrakPt[iNextGeomIdx].pointAy[2].fZ + TrakPt[iNextGeomIdx].pointAy[3].fZ) * 0.5; + dNextMidX = (TrakPt[iNextGeomIdx].pointAy[2].fX + + TrakPt[iNextGeomIdx].pointAy[3].fX) * + 0.5; + dNextMidY = (TrakPt[iNextGeomIdx].pointAy[2].fY + + TrakPt[iNextGeomIdx].pointAy[3].fY) * + 0.5; + dNextMidZ = (TrakPt[iNextGeomIdx].pointAy[2].fZ + + TrakPt[iNextGeomIdx].pointAy[3].fZ) * + 0.5; pCurrentData = &localdata[iGeometryIdx]; pCurrentData->pointAy[3].fX = (float)(-(dMidX + dNextMidX) * 0.5); pCurrentData->pointAy[3].fY = (float)(-(dMidY + dNextMidY) * 0.5); pCurrentData->pointAy[3].fZ = (float)(-(dMidZ + dNextMidZ) * 0.5); - pCurrentData->fTrackHalfLength = (float)sqrt((dNextMidX - dMidX) * (dNextMidX - dMidX) + (dNextMidY - dMidY) * (dNextMidY - dMidY) + (dNextMidZ - dMidZ) * (dNextMidZ - dMidZ)) - * 0.5f; // Calculate distance between ramp endpoints for track half-length + pCurrentData->fTrackHalfLength = + (float)sqrt((dNextMidX - dMidX) * (dNextMidX - dMidX) + + (dNextMidY - dMidY) * (dNextMidY - dMidY) + + (dNextMidZ - dMidZ) * (dNextMidZ - dMidZ)) * + 0.5f; // Calculate distance between ramp endpoints for track half-length } } //------------------------------------------------------------------------------------------------- -//00074BA0 -void updatestunts() -{ +// 00074BA0 +void updatestunts() { tStuntData **pStuntItr; // edx tStuntData *pCurrStunt; // ecx @@ -457,9 +560,8 @@ void updatestunts() } //------------------------------------------------------------------------------------------------- -//00074BD0 -void reinitstunts() -{ +// 00074BD0 +void reinitstunts() { tStuntData **pStuntItr; // edx tStuntData *pCurrStunt; // ecx @@ -474,9 +576,8 @@ void reinitstunts() } //------------------------------------------------------------------------------------------------- -//00074C00 -void freeramp(void **pRampData) -{ +// 00074C00 +void freeramp(void **pRampData) { void *pRampToFree; // [esp+0h] [ebp-4h] BYREF pRampToFree = pRampData; @@ -488,30 +589,31 @@ void freeramp(void **pRampData) } //------------------------------------------------------------------------------------------------- -//00074C30 -void freestunts(uint8 **pTrackData, int *pBuf) -{ +// 00074C30 +void freestunts(uint8 **pTrackData, int *pBuf) { tStuntData **ppRampArray; // edx - tStuntData *pRampData; // eax - tStuntData *pNextRamp; // ecx - void *pRampToFree; // [esp+0h] [ebp-10h] BYREF - int *pBufSaved; // [esp+4h] [ebp-Ch] + tStuntData *pRampData; // eax + tStuntData *pNextRamp; // ecx + void *pRampToFree; // [esp+0h] [ebp-10h] BYREF + int *pBufSaved; // [esp+4h] [ebp-Ch] pBufSaved = pBuf; - ppRampArray = ramp; // Start at the beginning of the global ramp pointer array - if (ramp[0]) // Check if there are any ramps to free + ppRampArray = ramp; // Start at the beginning of the global ramp pointer array + if (ramp[0]) // Check if there are any ramps to free { do { - pRampData = *ppRampArray; // Get pointer to current ramp structure + pRampData = *ppRampArray; // Get pointer to current ramp structure pRampToFree = pRampData; - if (pRampData) { // Check if ramp has allocated data at offset 0x50 (80 bytes) + if (pRampData) { // Check if ramp has allocated data at offset 0x50 (80 + // bytes) if (pRampData->chunkDataAy) - fre((void **)&pRampData->chunkDataAy);// Free the allocated data at offset 0x50 - fre(&pRampToFree); // Free the ramp structure itself + fre((void **)&pRampData + ->chunkDataAy); // Free the allocated data at offset 0x50 + fre(&pRampToFree); // Free the ramp structure itself } - pNextRamp = ppRampArray[1]; // Get next ramp pointer for loop condition - ++ppRampArray; // Move to next ramp pointer in array - } while (pNextRamp); // Continue until we find a NULL pointer + pNextRamp = ppRampArray[1]; // Get next ramp pointer for loop condition + ++ppRampArray; // Move to next ramp pointer in array + } while (pNextRamp); // Continue until we find a NULL pointer } } diff --git a/PROJECTS/ROLLER/moving.h b/PROJECTS/ROLLER/moving.h index 5d7e3ce8..141b41fb 100644 --- a/PROJECTS/ROLLER/moving.h +++ b/PROJECTS/ROLLER/moving.h @@ -4,8 +4,7 @@ #include "types.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iLocalX; int iLocalY; int iLocalZ; @@ -13,8 +12,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tStuntLocalPoint localPtAy[6]; tVec3 refPoint; float fTrackHalfLength; @@ -22,8 +20,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iGeometryIdx; int iChunkCount; int iNumTicks; @@ -51,17 +48,10 @@ extern int replaytype; //------------------------------------------------------------------------------------------------- -tStuntData *initramp( - int iGeometryIdx, - int iChunkCount, - int iNumTicks, - int iTickStartIdx, - int iTimingGroup, - int iHeight, - int iTimeBulging, - int iTimeFlat, - int iRampSideLength, - int iFlags); +tStuntData *initramp(int iGeometryIdx, int iChunkCount, int iNumTicks, + int iTickStartIdx, int iTimingGroup, int iHeight, + int iTimeBulging, int iTimeFlat, int iRampSideLength, + int iFlags); void reinitramp(tStuntData *pStunt); void updateramp(tStuntData *pStunt); void updatestunts(); diff --git a/PROJECTS/ROLLER/network.c b/PROJECTS/ROLLER/network.c index 8c4913e2..3a9a8654 100644 --- a/PROJECTS/ROLLER/network.c +++ b/PROJECTS/ROLLER/network.c @@ -11,57 +11,57 @@ #include "rollercomms.h" //------------------------------------------------------------------------------------------------- -int sync_errors = 0; //000A6100 -int net_type = 1; //000A6104 -int slave_pause = 0; //000A6108 -int net_started = 0; //000A610C -int next_resync = 0; //000A6110 -_NETNOW_NODE_ADDR gamers_address[4][16]; //00178070 -int gamers_playing[4]; //00178470 -char gamers_names[4][144]; //00178480 -uint32 test_mini[2]; //001786C0 -int test_multiple[16]; //001786C8 -tRecordPacket p_record; //00178708 -int net_players[16]; //00178718 -int16 player_checks[512][16]; //00178758 -int address[64]; //0017C758 -int player_ready[16]; //0017C858 -int16 player_syncs[16]; //0017C898 -int syncptr; //0017C928 -int syncleft; //0017C92C -int syncnode; //0017C930 -int syncframe; //0017C934 -int received_seed; //0017C938 -int received_records; //0017C93C -int frame_number; //0017C940 -int start_multiple; //0017C944 -tSyncHeader p_header; //0017C948 -int test_seed; //0017C958 -int resync; //0017C95C -int message_received; //0017C960 -int my_age; //0017C964 -int message_number; //0017C968 -int message_node; //0017C96C -int read_check; //0017C970 -int write_check; //0017C974 -int test; //0017C978 -int network_mistake; //0017C97C -int pauser; //0017C980 -uint32 broadcast_mode; //0017C984 -int message_sent; //0017C988 -int random_seed; //0017C98C -int dostopsamps; //0017C990 -int lost_message; //0017C994 -int duff_message; //0017C998 -int check_set; //0017C99C -int master; //0017C9A0 -tSyncHeader in_header; //0017C9A4 -int active_nodes; //0017C9B0 -int net_quit; //0017C9B4 -tDataPacket slave_data; //0017C9B8 -char p_data[14]; //0017C9BE -char received_message[14]; //0017C9CC -int16 wConsoleNode; //0017C9DA +int sync_errors = 0; // 000A6100 +int net_type = 1; // 000A6104 +int slave_pause = 0; // 000A6108 +int net_started = 0; // 000A610C +int next_resync = 0; // 000A6110 +_NETNOW_NODE_ADDR gamers_address[4][16]; // 00178070 +int gamers_playing[4]; // 00178470 +char gamers_names[4][144]; // 00178480 +uint32 test_mini[2]; // 001786C0 +int test_multiple[16]; // 001786C8 +tRecordPacket p_record; // 00178708 +int net_players[16]; // 00178718 +int16 player_checks[512][16]; // 00178758 +int address[64]; // 0017C758 +int player_ready[16]; // 0017C858 +int16 player_syncs[16]; // 0017C898 +int syncptr; // 0017C928 +int syncleft; // 0017C92C +int syncnode; // 0017C930 +int syncframe; // 0017C934 +int received_seed; // 0017C938 +int received_records; // 0017C93C +int frame_number; // 0017C940 +int start_multiple; // 0017C944 +tSyncHeader p_header; // 0017C948 +int test_seed; // 0017C958 +int resync; // 0017C95C +int message_received; // 0017C960 +int my_age; // 0017C964 +int message_number; // 0017C968 +int message_node; // 0017C96C +int read_check; // 0017C970 +int write_check; // 0017C974 +int test; // 0017C978 +int network_mistake; // 0017C97C +int pauser; // 0017C980 +uint32 broadcast_mode; // 0017C984 +int message_sent; // 0017C988 +int random_seed; // 0017C98C +int dostopsamps; // 0017C990 +int lost_message; // 0017C994 +int duff_message; // 0017C998 +int check_set; // 0017C99C +int master; // 0017C9A0 +tSyncHeader in_header; // 0017C9A4 +int active_nodes; // 0017C9B0 +int net_quit; // 0017C9B4 +tDataPacket slave_data; // 0017C9B8 +char p_data[14]; // 0017C9BE +char received_message[14]; // 0017C9CC +int16 wConsoleNode; // 0017C9DA //------------------------------------------------------------------------------------------------- @@ -69,8 +69,7 @@ static int s_iLastDiscoveryBroadcastFrame = -1000; //------------------------------------------------------------------------------------------------- -static void NormalizePacketAddress(int32 pAddress[4]) -{ +static void NormalizePacketAddress(int32 pAddress[4]) { tROLLERNetAddr netAddr; memset(&netAddr, 0, sizeof(netAddr)); memcpy(&netAddr, pAddress, sizeof(netAddr)); @@ -81,16 +80,14 @@ static void NormalizePacketAddress(int32 pAddress[4]) //------------------------------------------------------------------------------------------------- -static int IsInvalidPacketAddress(const int32 pAddress[4]) -{ +static int IsInvalidPacketAddress(const int32 pAddress[4]) { const tROLLERNetAddr *pNetAddr = (const tROLLERNetAddr *)pAddress; return pNetAddr->uiIPAddress == 0 || pNetAddr->unPort == 0; } //------------------------------------------------------------------------------------------------- -static int IsLocalPacketAddress(const int32 pAddress[4]) -{ +static int IsLocalPacketAddress(const int32 pAddress[4]) { int localAddress[4]; ROLLERCommsGetNetworkAddr(localAddress); NormalizePacketAddress(localAddress); @@ -99,17 +96,17 @@ static int IsLocalPacketAddress(const int32 pAddress[4]) //------------------------------------------------------------------------------------------------- -static void LogDiscoveryAddress(const char *szMessage, const int32 pAddress[4]) -{ +static void LogDiscoveryAddress(const char *szMessage, + const int32 pAddress[4]) { char szAddr[32]; - ROLLERCommsFormatAddr((const tROLLERNetAddr *)pAddress, szAddr, sizeof(szAddr)); + ROLLERCommsFormatAddr((const tROLLERNetAddr *)pAddress, szAddr, + sizeof(szAddr)); SDL_Log("[NET-DISCOVERY] %s %s", szMessage, szAddr); } //------------------------------------------------------------------------------------------------- -static void PulseLobbyDiscovery(void) -{ +static void PulseLobbyDiscovery(void) { if (!frontend_on || !network_on || time_to_start || !master) return; if (frames - s_iLastDiscoveryBroadcastFrame < 36) @@ -120,9 +117,8 @@ static void PulseLobbyDiscovery(void) } //------------------------------------------------------------------------------------------------- -//0004EB30 -void Initialise_Network(int iSelectNetSlot) -{ +// 0004EB30 +void Initialise_Network(int iSelectNetSlot) { int iResetNetwork; // [esp+0h] [ebp-1Ch] iResetNetwork = 0; @@ -174,12 +170,12 @@ void Initialise_Network(int iSelectNetSlot) ROLLERCommsGetConsoleNode(); network_on = 1; if (iSelectNetSlot || network_slot < 0) - broadcast_mode = 0xFFFFFE38; // force slave broadcast? + broadcast_mode = 0xFFFFFE38; // force slave broadcast? else broadcast_mode = -1; tick_on = -1; while (broadcast_mode) - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER ROLLERCommsSortNodes(); received_records = 1; switch_sets = 0; @@ -189,11 +185,10 @@ void Initialise_Network(int iSelectNetSlot) } //------------------------------------------------------------------------------------------------- -//0004ED70 -void close_network() -{ +// 0004ED70 +void close_network() { int iNode; // edx - int i; // edx + int i; // edx network_slot = -1; if (network_on) { @@ -222,8 +217,7 @@ void close_network() if (exiting) goto LABEL_18; } else if ((net_started || net_type) && exiting) { - LABEL_18: - ; + LABEL_18:; ROLLERCommsSetType(1); ROLLERCommsUnInitSystem(); ROLLERCommsSetType(0); @@ -231,7 +225,7 @@ void close_network() } for (int i = 0; i < 16; ++i) - net_players[i] = -667; + net_players[i] = -667; if (network_on && !frontend_on) { Players_Cars[0] = my_car; @@ -257,9 +251,8 @@ void close_network() } //------------------------------------------------------------------------------------------------- -//0004EF60 -void send_net_error() -{ +// 0004EF60 +void send_net_error() { int i; // esi if (network_on) { @@ -276,11 +269,10 @@ void send_net_error() } //------------------------------------------------------------------------------------------------- -//0004EFD0 -void send_game_error() -{ +// 0004EFD0 +void send_game_error() { int iDataSent = 0; // eax - int i; // esi + int i; // esi if (network_on) { p_header.byConsoleNode = (uint8)wConsoleNode; @@ -289,7 +281,8 @@ void send_game_error() if (wConsoleNode == master) { for (i = 0; i < network_on; ++i) { if (i != wConsoleNode) { - iDataSent = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, i); + iDataSent = + ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, i); if (!iDataSent) i = network_on; } @@ -301,9 +294,8 @@ void send_game_error() } //------------------------------------------------------------------------------------------------- -//0004F070 -void send_network_sync_error() -{ +// 0004F070 +void send_network_sync_error() { int i; // esi if (network_on) { @@ -322,21 +314,20 @@ void send_network_sync_error() } //------------------------------------------------------------------------------------------------- -//0004F100 -void send_resync(int iFrameNumber) -{ +// 0004F100 +void send_resync(int iFrameNumber) { if (network_on) { resync = iFrameNumber; p_header.byConsoleNode = (uint8)wConsoleNode; p_header.uiId = PACKET_ID_RESYNC; - ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &resync, sizeof(int32), master); + ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &resync, sizeof(int32), + master); } } //------------------------------------------------------------------------------------------------- -//0004F150 -void send_nocd_error() -{ +// 0004F150 +void send_nocd_error() { int i; // esi if (network_on) { @@ -355,9 +346,8 @@ void send_nocd_error() } //------------------------------------------------------------------------------------------------- -//0004F1E0 -void send_quit() -{ +// 0004F1E0 +void send_quit() { int i; // esi if (network_on) { @@ -366,22 +356,23 @@ void send_quit() if (wConsoleNode == master) { for (i = 0; i < network_on; ++i) { if (i != wConsoleNode) { - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, i)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, + i)) + UpdateSDL(); // added by ROLLER } } net_quit = -1; } else { - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, master)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, + master)) + UpdateSDL(); // added by ROLLER } } } //------------------------------------------------------------------------------------------------- -//0004F290 -void send_ready() -{ +// 0004F290 +void send_ready() { int iDataSent; // eax if (network_on) { @@ -393,9 +384,10 @@ void send_ready() if (wConsoleNode != master || player_ready[master]) { do { //_disable(); - iDataSent = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, 0, master); + iDataSent = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, + 0, master); //_enable(); - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER } while (!iDataSent); } else { player_ready[master] = -1; @@ -405,39 +397,41 @@ void send_ready() } //------------------------------------------------------------------------------------------------- -//0004F350 -void send_record_to_master(int iRecordIdx) -{ +// 0004F350 +void send_record_to_master(int iRecordIdx) { if (network_on) { p_header.byConsoleNode = (uint8)wConsoleNode; p_header.uiId = PACKET_ID_RECORD; p_record.fRecordLap = RecordLaps[iRecordIdx]; - strncpy(p_record.szRecordName, RecordNames[iRecordIdx], sizeof(p_record.szRecordName)); + strncpy(p_record.szRecordName, RecordNames[iRecordIdx], + sizeof(p_record.szRecordName)); p_record.unRecordCar = RecordCars[iRecordIdx]; SDL_Log("[NET-START] send record to master=%d from node=%d track=%d", master, (int)wConsoleNode, iRecordIdx); - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &p_record, sizeof(tRecordPacket), master)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &p_record, + sizeof(tRecordPacket), master)) + UpdateSDL(); // added by ROLLER } } //------------------------------------------------------------------------------------------------- -//0004F400 -void send_record_to_slaves(int iRecordIdx) -{ +// 0004F400 +void send_record_to_slaves(int iRecordIdx) { if (network_on) { p_header.byConsoleNode = (uint8)wConsoleNode; p_header.uiId = PACKET_ID_RECORD; p_record.fRecordLap = RecordLaps[iRecordIdx]; - strncpy(p_record.szRecordName, RecordNames[iRecordIdx], sizeof(p_record.szRecordName)); + strncpy(p_record.szRecordName, RecordNames[iRecordIdx], + sizeof(p_record.szRecordName)); p_record.unRecordCar = RecordCars[iRecordIdx]; for (int i = 0; i < network_on; ++i) { iRecordIdx = wConsoleNode; if (wConsoleNode != i) { - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &p_record, sizeof(tRecordPacket), i)) { - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &p_record, + sizeof(tRecordPacket), i)) { + UpdateSDL(); // added by ROLLER } } } @@ -445,12 +439,11 @@ void send_record_to_slaves(int iRecordIdx) } //------------------------------------------------------------------------------------------------- -//0004F4E0 -void send_mes(int iNetworkMessageIdx, int iNode) -{ +// 0004F4E0 +void send_mes(int iNetworkMessageIdx, int iNode) { char *szNetworkMessage; // eax - int iNodeIdx; // esi - int iNetPlayers; // edi + int iNodeIdx; // esi + int iNetPlayers; // edi if (network_on) { szNetworkMessage = network_messages[iNetworkMessageIdx]; @@ -468,16 +461,18 @@ void send_mes(int iNetworkMessageIdx, int iNode) iNetPlayers = 0; do { if (iNodeIdx != wConsoleNode && net_players[iNetPlayers]) { - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, sizeof(p_data), iNodeIdx)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), + p_data, sizeof(p_data), iNodeIdx)) + UpdateSDL(); // added by ROLLER } ++iNetPlayers; ++iNodeIdx; } while (iNodeIdx < network_on); } } else { - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, sizeof(p_data), iNode)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), p_data, + sizeof(p_data), iNode)) + UpdateSDL(); // added by ROLLER } } else { message_sent = 4; @@ -486,19 +481,18 @@ void send_mes(int iNetworkMessageIdx, int iNode) } //------------------------------------------------------------------------------------------------- -//0004F5E0 -void send_seed(int iRandomSeed) -{ +// 0004F5E0 +void send_seed(int iRandomSeed) { if (network_on) { test_seed = iRandomSeed; p_header.uiId = PACKET_ID_SEED; p_header.byConsoleNode = (uint8)wConsoleNode; - SDL_Log("[NET-START] send seed=%d from node=%d to %d nodes", - iRandomSeed, (int)wConsoleNode, network_on); - for (int i = 0; i < network_on; ++i) { + SDL_Log("[NET-START] send seed=%d from node=%d to %d nodes", iRandomSeed, + (int)wConsoleNode, network_on); + for (int i = 0; i < network_on; ++i) { if (i != wConsoleNode) { while (!ROLLERCommsSendData(&p_header, 12, &test_seed, 4, i)) - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER } } @@ -508,10 +502,10 @@ void send_seed(int iRandomSeed) } //------------------------------------------------------------------------------------------------- -//0004F660 -void send_single(uint32 uiData) -{ - if (!network_on) return; +// 0004F660 +void send_single(uint32 uiData) { + if (!network_on) + return; // Initialize header and data packet p_header.uiId = PACKET_ID_SINGLE; @@ -532,63 +526,63 @@ void send_single(uint32 uiData) // - Bit 8 from read_check // - Lower 8 bits from read_check unsigned int uiComposite = (nChecksum & 0x7F) << 9; - uiComposite |= (read_check & 0x100); // Bit 8 - uiComposite |= (read_check & 0xFF); // Bits 0-7 + uiComposite |= (read_check & 0x100); // Bit 8 + uiComposite |= (read_check & 0xFF); // Bits 0-7 slave_data.nChecksum = (short)uiComposite; } - //TODO network - ROLLERCommsSendData(&p_header, sizeof(p_header), &slave_data, sizeof(tDataPacket), master); + // TODO network + ROLLERCommsSendData(&p_header, sizeof(p_header), &slave_data, + sizeof(tDataPacket), master); // Mark check as processed - player_checks[read_check][player1_car] = -1; // 0xFFFF + player_checks[read_check][player1_car] = -1; // 0xFFFF // Advance read position if valid and not caught up if (read_check != write_check && read_check >= 0) { - read_check = (read_check + 1) & 0x1FF; // Wrap around at 512 + read_check = (read_check + 1) & 0x1FF; // Wrap around at 512 } } //------------------------------------------------------------------------------------------------- -//0004F750 -void send_pause() -{ +// 0004F750 +void send_pause() { tSyncHeader syncHeader; // [esp+0h] [ebp-1Ch] BYREF - bool bPaused; // [esp+Ch] [ebp-10h] BYREF + bool bPaused; // [esp+Ch] [ebp-10h] BYREF if (network_on) { syncHeader.byConsoleNode = (uint8)wConsoleNode; syncHeader.uiId = PACKET_ID_PAUSE; bPaused = paused == 0; - while (!ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &bPaused, sizeof(bool), master)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &bPaused, + sizeof(bool), master)) + UpdateSDL(); // added by ROLLER } } //------------------------------------------------------------------------------------------------- -//0004F7B0 -void send_slot() -{ +// 0004F7B0 +void send_slot() { tSyncHeader syncHeader; - int iSlot;// = network_slot? + int iSlot; // = network_slot? if (network_on) { syncHeader.byConsoleNode = (uint8)network_slot; syncHeader.uiId = PACKET_ID_SLOT; - while (!ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &iSlot, sizeof(int), 21)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &iSlot, + sizeof(int), 21)) + UpdateSDL(); // added by ROLLER } } //------------------------------------------------------------------------------------------------- -//0004F800 -void transmitpausetoslaves() -{ - int iNode; // esi - int iNetPlayerIdx; // edi +// 0004F800 +void transmitpausetoslaves() { + int iNode; // esi + int iNetPlayerIdx; // edi tSyncHeader syncHeader; // [esp+0h] [ebp-28h] BYREF - bool bPaused; // [esp+Ch] [ebp-1Ch] BYREF + bool bPaused; // [esp+Ch] [ebp-1Ch] BYREF if (network_on) { syncHeader.byConsoleNode = pauser; @@ -599,8 +593,9 @@ void transmitpausetoslaves() iNetPlayerIdx = 0; do { if (iNode != master && net_players[iNetPlayerIdx]) { - while (!ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &bPaused, sizeof(bool), iNode)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), + &bPaused, sizeof(bool), iNode)) + UpdateSDL(); // added by ROLLER } ++iNetPlayerIdx; ++iNode; @@ -610,38 +605,40 @@ void transmitpausetoslaves() } //------------------------------------------------------------------------------------------------- -//0004F880 -void send_multiple() -{ - int iCarIdx; // eax - int *pTestMultiple; // esi +// 0004F880 +void send_multiple() { + int iCarIdx; // eax + int *pTestMultiple; // esi tCopyData iCopyMultipleVal2; // edi - int iNode; // esi - int iNodeIsValid; // eax - int iNode2; // edi - int iSendCopyMultiple; // edx - tCopyData *pCopyMultiple; // ebx - int *pTestMini; // esi - int i; // eax - tCopyData iCopyMultipleVal; // edx - int iNode3; // edi - int iNode4; // edi + int iNode; // esi + int iNodeIsValid; // eax + int iNode2; // edi + int iSendCopyMultiple; // edx + tCopyData *pCopyMultiple; // ebx + int *pTestMini; // esi + int i; // eax + tCopyData iCopyMultipleVal; // edx + int iNode3; // edi + int iNode4; // edi if (network_on) { p_header.byConsoleNode = (uint8)wConsoleNode; - p_header.uiId = PACKET_ID_PLAYER_CARS; // PACKET_ID_PLAYER_CARS + p_header.uiId = PACKET_ID_PLAYER_CARS; // PACKET_ID_PLAYER_CARS p_header.unFrameId = frame_number; if (net_type) { iSendCopyMultiple = -1; - if (memcmp((const char *)©_multiple[((int16)writeptr - 1) & 0x1FF][player_to_car[0]], (const char *)©_multiple[writeptr][player_to_car[0]], 4)) + if (memcmp((const char *)©_multiple[((int16)writeptr - 1) & 0x1FF] + [player_to_car[0]], + (const char *)©_multiple[writeptr][player_to_car[0]], 4)) iSendCopyMultiple = 0; pCopyMultiple = copy_multiple[((int16)writeptr - 1) & 0x1FF]; - if (memcmp((const char *)&pCopyMultiple[player_to_car[1]], (const char *)©_multiple[writeptr][player_to_car[1]], 4)) + if (memcmp((const char *)&pCopyMultiple[player_to_car[1]], + (const char *)©_multiple[writeptr][player_to_car[1]], 4)) iSendCopyMultiple = 0; if (!frame_number) iSendCopyMultiple = 0; if (iSendCopyMultiple) { - p_header.uiId = PACKET_ID_MULTIPLE; // PACKET_ID_MULTIPLE + p_header.uiId = PACKET_ID_MULTIPLE; // PACKET_ID_MULTIPLE iNode = abs(start_multiple); iNodeIsValid = -1; if (iNode >= 0) { @@ -652,7 +649,8 @@ void send_multiple() if (iNode == master || !net_players[iNode4]) iNodeIsValid = -1; else { - iNodeIsValid = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), pCopyMultiple, 1, iNode); + iNodeIsValid = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), + pCopyMultiple, 1, iNode); } if (iNodeIsValid) { --iNode4; @@ -677,7 +675,8 @@ void send_multiple() if (iNode == master || !net_players[iNode3]) iNodeIsValid = -1; else { - iNodeIsValid = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), test_mini, 8, iNode); + iNodeIsValid = ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), + test_mini, 8, iNode); } if (iNodeIsValid) { --iNode3; @@ -702,7 +701,11 @@ void send_multiple() do { if (!iNodeIsValid) break; - iNodeIsValid = iNode == master || !net_players[iNode2] ? -1 : ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), test_multiple, 64, iNode); + iNodeIsValid = + iNode == master || !net_players[iNode2] + ? -1 + : ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), + test_multiple, 64, iNode); if (iNodeIsValid) { --iNode2; --iNode; @@ -720,328 +723,332 @@ void send_multiple() } //------------------------------------------------------------------------------------------------- -//0004FBA0 -void receive_multiple() -{ +// 0004FBA0 +void receive_multiple() { tPlayerInfoPacket playerInfoPacket; // [esp+0h] [ebp-60h] BYREF - char szMesPacket[14]; // [esp+28h] [ebp-38h] BYREF - void *pPacket; // [esp+38h] [ebp-28h] BYREF - int iPaused; // [esp+40h] [ebp-20h] BYREF - int *pSeed; // [esp+44h] [ebp-1Ch] + char szMesPacket[14]; // [esp+28h] [ebp-38h] BYREF + void *pPacket; // [esp+38h] [ebp-28h] BYREF + int iPaused; // [esp+40h] [ebp-20h] BYREF + int *pSeed; // [esp+44h] [ebp-1Ch] if (network_on && !net_quit) { pSeed = &test_seed; while (ROLLERCommsGetHeader(&in_header, 12, &pPacket)) { switch (in_header.uiId) { - case PACKET_ID_SEND_MES: - ROLLERCommsGetBlock(pPacket, szMesPacket, 14); - message_received = in_header.byConsoleNode; - strncpy(received_message, szMesPacket, sizeof(received_message)); - goto LABEL_54; - case PACKET_ID_QUIT: - net_quit = -1; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_PLAYER_CARS: - if (net_type) { - if (network_on > 0) { - for (int i = 0; i < network_on; ++i) { - player_ready[i] = -1; - } - } - active_nodes = network_on; - net_loading = 0; - ROLLERCommsGetBlock(pPacket, test_mini, 8); - for (int i = 0; i < 2; ++i) { - copy_multiple[writeptr][player_to_car[i]].uiFullData = test_mini[i]; - } - } else { - if (network_on > 0) { - - for (int i = 0; i < network_on; ++i) { - player_ready[i] = -1; - } + case PACKET_ID_SEND_MES: + ROLLERCommsGetBlock(pPacket, szMesPacket, 14); + message_received = in_header.byConsoleNode; + strncpy(received_message, szMesPacket, sizeof(received_message)); + goto LABEL_54; + case PACKET_ID_QUIT: + net_quit = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_PLAYER_CARS: + if (net_type) { + if (network_on > 0) { + for (int i = 0; i < network_on; ++i) { + player_ready[i] = -1; } - active_nodes = network_on; - net_loading = 0; - ROLLERCommsGetBlock(pPacket, ©_multiple[writeptr], 64); } - network_timeout = frames; - ++ticks_received; - if (in_header.unFrameId == frame_number) { - ++frame_number; - writeptr = (writeptr + 1) & 0x1FF; - next_resync = -1; - ROLLERCommsPostListen(); - continue; + active_nodes = network_on; + net_loading = 0; + ROLLERCommsGetBlock(pPacket, test_mini, 8); + for (int i = 0; i < 2; ++i) { + copy_multiple[writeptr][player_to_car[i]].uiFullData = test_mini[i]; } - if (in_header.unFrameId <= frame_number) - goto LABEL_54; - ++lost_message; - ROLLERCommsPostListen(); - if (in_header.unFrameId - frame_number > 500) { - send_network_sync_error(); - network_sync_error = -1; - ROLLERCommsPostListen(); - continue; + } else { + if (network_on > 0) { + + for (int i = 0; i < network_on; ++i) { + player_ready[i] = -1; + } } - if (frames <= next_resync) - goto LABEL_54; - if (ROLLERCommsGetType()) - ROLLERclrrx(); - goto LABEL_17; - case PACKET_ID_SEED: - ROLLERCommsGetBlock(pPacket, &test_seed, 4); - ROLLERsrand(*pSeed); - random_seed = *pSeed; - received_seed = -1; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_PAUSE: - ROLLERCommsGetBlock(pPacket, &iPaused, 4); - if (paused != iPaused && iPaused) - dostopsamps = -1; - paused = iPaused; - if (!iPaused) - goto LABEL_54; - pauser = in_header.byConsoleNode; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_PLAYER_INFO: - ROLLERCommsGetBlock(pPacket, &playerInfoPacket, sizeof(tPlayerInfoPacket)); - Players_Cars[in_header.byConsoleNode] = playerInfoPacket.iPlayerCar; - check_cars(); - name_copy(player_names[in_header.byConsoleNode], playerInfoPacket.szPlayerName); - TrackLoad = playerInfoPacket.iTrackLoad; - game_type = playerInfoPacket.iGameType; - competitors = playerInfoPacket.iCompetitors; - level = playerInfoPacket.iLevel; - damage_level = playerInfoPacket.iDamageLevel & 0xF; - if ((playerInfoPacket.iDamageLevel & 0x40) != 0) - player_invul[in_header.byConsoleNode] = -1; - else - player_invul[in_header.byConsoleNode] = 0; - manual_control[in_header.byConsoleNode] = playerInfoPacket.iManualControl; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_NET_ERROR: - network_error = 999; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SYNC_ERROR: - goto LABEL_13; - case PACKET_ID_GAME_ERROR: - network_error = 666; + active_nodes = network_on; + net_loading = 0; + ROLLERCommsGetBlock(pPacket, ©_multiple[writeptr], 64); + } + network_timeout = frames; + ++ticks_received; + if (in_header.unFrameId == frame_number) { + ++frame_number; + writeptr = (writeptr + 1) & 0x1FF; + next_resync = -1; ROLLERCommsPostListen(); continue; - case PACKET_ID_NOCD: - //cd_error = -1; + } + if (in_header.unFrameId <= frame_number) + goto LABEL_54; + ++lost_message; + ROLLERCommsPostListen(); + if (in_header.unFrameId - frame_number > 500) { + send_network_sync_error(); + network_sync_error = -1; ROLLERCommsPostListen(); continue; - case PACKET_ID_SEND_HERE: - load_times[in_header.byConsoleNode] = in_header.unFrameId; + } + if (frames <= next_resync) + goto LABEL_54; + if (ROLLERCommsGetType()) + ROLLERclrrx(); + goto LABEL_17; + case PACKET_ID_SEED: + ROLLERCommsGetBlock(pPacket, &test_seed, 4); + ROLLERsrand(*pSeed); + random_seed = *pSeed; + received_seed = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_PAUSE: + ROLLERCommsGetBlock(pPacket, &iPaused, 4); + if (paused != iPaused && iPaused) + dostopsamps = -1; + paused = iPaused; + if (!iPaused) + goto LABEL_54; + pauser = in_header.byConsoleNode; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_PLAYER_INFO: + ROLLERCommsGetBlock(pPacket, &playerInfoPacket, + sizeof(tPlayerInfoPacket)); + Players_Cars[in_header.byConsoleNode] = playerInfoPacket.iPlayerCar; + check_cars(); + name_copy(player_names[in_header.byConsoleNode], + playerInfoPacket.szPlayerName); + TrackLoad = playerInfoPacket.iTrackLoad; + game_type = playerInfoPacket.iGameType; + competitors = playerInfoPacket.iCompetitors; + level = playerInfoPacket.iLevel; + damage_level = playerInfoPacket.iDamageLevel & 0xF; + if ((playerInfoPacket.iDamageLevel & 0x40) != 0) + player_invul[in_header.byConsoleNode] = -1; + else + player_invul[in_header.byConsoleNode] = 0; + manual_control[in_header.byConsoleNode] = + playerInfoPacket.iManualControl; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_NET_ERROR: + network_error = 999; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SYNC_ERROR: + goto LABEL_13; + case PACKET_ID_GAME_ERROR: + network_error = 666; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_NOCD: + // cd_error = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SEND_HERE: + load_times[in_header.byConsoleNode] = in_header.unFrameId; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_MULTIPLE: + if (in_header.unFrameId == frame_number) { + + int iPrevIdx = (writeptr - 1) & 0x1FF; + int iCar0 = player_to_car[0]; + int iCar1 = player_to_car[1]; + copy_multiple[writeptr][iCar0] = copy_multiple[iPrevIdx][iCar0]; + copy_multiple[writeptr][iCar1] = copy_multiple[iPrevIdx][iCar1]; + + network_timeout = frames; + ++ticks_received; + ++frame_number; + writeptr = (writeptr + 1) & 0x1FF; + next_resync = -1; ROLLERCommsPostListen(); continue; - case PACKET_ID_MULTIPLE: - if (in_header.unFrameId == frame_number) { - - int iPrevIdx = (writeptr - 1) & 0x1FF; - int iCar0 = player_to_car[0]; - int iCar1 = player_to_car[1]; - copy_multiple[writeptr][iCar0] = copy_multiple[iPrevIdx][iCar0]; - copy_multiple[writeptr][iCar1] = copy_multiple[iPrevIdx][iCar1]; - - network_timeout = frames; - ++ticks_received; - ++frame_number; - writeptr = (writeptr + 1) & 0x1FF; - next_resync = -1; + } + if (in_header.unFrameId <= frame_number) + goto LABEL_54; + ++lost_message; + ROLLERCommsPostListen(); + if (in_header.unFrameId - frame_number <= 500) { + if (frames <= next_resync) { + LABEL_54:; ROLLERCommsPostListen(); - continue; - } - if (in_header.unFrameId <= frame_number) - goto LABEL_54; - ++lost_message; - ROLLERCommsPostListen(); - if (in_header.unFrameId - frame_number <= 500) { - if (frames <= next_resync) { - LABEL_54: - ; - ROLLERCommsPostListen(); - } else { - if (ROLLERCommsGetType()) { - ROLLERclrrx(); - } - LABEL_17: - ++sync_errors; - send_resync(frame_number); - next_resync = frames + 16; - ROLLERCommsPostListen(); - } } else { - send_network_sync_error(); - LABEL_13: - network_sync_error = -1; + if (ROLLERCommsGetType()) { + ROLLERclrrx(); + } + LABEL_17: + ++sync_errors; + send_resync(frame_number); + next_resync = frames + 16; ROLLERCommsPostListen(); } - break; - default: - ++duff_message; - goto LABEL_54; + } else { + send_network_sync_error(); + LABEL_13: + network_sync_error = -1; + ROLLERCommsPostListen(); + } + break; + default: + ++duff_message; + goto LABEL_54; } } } } //------------------------------------------------------------------------------------------------- -//000501B0 -void receive_all_singles() -{ - int byConsoleNode; // eax +// 000501B0 +void receive_all_singles() { + int byConsoleNode; // eax tTransmitInitPacket transmitInitPacket; // [esp+0h] [ebp-140h] BYREF - tPlayerInfoPacket playerInfoPacket; // [esp+E8h] [ebp-58h] BYREF - char szMesPacket[14]; // [esp+110h] [ebp-30h] BYREF - void *pData; // [esp+120h] [ebp-20h] BYREF + tPlayerInfoPacket playerInfoPacket; // [esp+E8h] [ebp-58h] BYREF + char szMesPacket[14]; // [esp+110h] [ebp-30h] BYREF + void *pData; // [esp+120h] [ebp-20h] BYREF int iFrame = 0; if (network_on) { while (ROLLERCommsGetHeader(&in_header, sizeof(tSyncHeader), &pData)) { byConsoleNode = in_header.byConsoleNode; switch (in_header.uiId) { - case PACKET_ID_TRANSMIT_INIT: - ROLLERCommsGetBlock(pData, &transmitInitPacket, sizeof(tTransmitInitPacket)); - if (transmitInitPacket.iTimeToStart != 0xFFFFFE38) - goto LABEL_31; - send_slot(); - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SEND_MES: - ROLLERCommsGetBlock(pData, szMesPacket, 14); - message_received = in_header.byConsoleNode; + case PACKET_ID_TRANSMIT_INIT: + ROLLERCommsGetBlock(pData, &transmitInitPacket, + sizeof(tTransmitInitPacket)); + if (transmitInitPacket.iTimeToStart != 0xFFFFFE38) + goto LABEL_31; + send_slot(); + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SEND_MES: + ROLLERCommsGetBlock(pData, szMesPacket, 14); + message_received = in_header.byConsoleNode; - strncpy(received_message, szMesPacket, sizeof(received_message)); + strncpy(received_message, szMesPacket, sizeof(received_message)); - goto LABEL_31; - case PACKET_ID_QUIT: - ROLLERCommsPostListen(); - send_quit(); - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SINGLE: - if (byConsoleNode < 0 || byConsoleNode >= MAX_CARS) - goto LABEL_31; - if (car_to_player[byConsoleNode] < 0 || car_to_player[byConsoleNode] >= network_on) - goto LABEL_31; - if (!net_players[car_to_player[byConsoleNode]]) - goto LABEL_31; - ROLLERCommsGetBlock(pData, &slave_data, 6); - copy_multiple[writeptr][in_header.byConsoleNode].uiFullData = slave_data.uiData; - net_time[car_to_player[in_header.byConsoleNode]] = frames; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_READY: - if (byConsoleNode < 0 || byConsoleNode >= network_on) - goto LABEL_31; - if (!net_players[byConsoleNode]) - goto LABEL_31; - if (player_ready[in_header.byConsoleNode]) - goto LABEL_31; - ++active_nodes; - player_ready[byConsoleNode] = -1; - netCD = -1; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_PAUSE: - slave_pause = -1; - pauser = in_header.byConsoleNode; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_PLAYER_INFO: - ROLLERCommsGetBlock(pData, &playerInfoPacket, sizeof(tPlayerInfoPacket)); - Players_Cars[in_header.byConsoleNode] = playerInfoPacket.iPlayerCar; - check_cars(); - name_copy(player_names[in_header.byConsoleNode], playerInfoPacket.szPlayerName); - TrackLoad = playerInfoPacket.iTrackLoad; - game_type = playerInfoPacket.iGameType; - competitors = playerInfoPacket.iCompetitors; - level = playerInfoPacket.iLevel; - damage_level = playerInfoPacket.iDamageLevel & 0xF; - if ((playerInfoPacket.iDamageLevel & 0x40) != 0) - player_invul[in_header.byConsoleNode] = -1; - else - player_invul[in_header.byConsoleNode] = 0; - manual_control[in_header.byConsoleNode] = playerInfoPacket.iManualControl; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SYNC_ERROR: - goto LABEL_23; - case PACKET_ID_NOCD: - if (byConsoleNode < 0 || byConsoleNode >= network_on) - goto LABEL_31; - if (!net_players[byConsoleNode]) - goto LABEL_31; - if (player_ready[in_header.byConsoleNode]) - goto LABEL_31; - ++active_nodes; - player_ready[byConsoleNode] = -1; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_RESYNC: - ++lost_message; - ROLLERCommsPostListen(); - syncnode = in_header.byConsoleNode; - ROLLERCommsGetBlock(pData, &iFrame, 4); - syncframe = iFrame; - if (frame_number - iFrame <= 500) { - if (ROLLERCommsGetType()) - ROLLERclrtx(); - syncleft = frame_number - syncframe; - syncptr = syncframe & 0x1FF; - if (check_set && syncleft > 7) { - memset(player_checks, -1, sizeof(player_checks)); - check_set = 0; - } - do_sync_stuff(); - ROLLERCommsPostListen(); - } else { - LABEL_23: - ROLLERCommsPostListen(); - send_network_sync_error(); - network_sync_error = -1; - ROLLERCommsPostListen(); - } - break; - case PACKET_ID_SEND_HERE: - load_times[in_header.byConsoleNode] = in_header.unFrameId; - ROLLERCommsPostListen(); - break; - default: - ++duff_message; - goto LABEL_31; + goto LABEL_31; + case PACKET_ID_QUIT: + ROLLERCommsPostListen(); + send_quit(); + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SINGLE: + if (byConsoleNode < 0 || byConsoleNode >= MAX_CARS) + goto LABEL_31; + if (car_to_player[byConsoleNode] < 0 || + car_to_player[byConsoleNode] >= network_on) + goto LABEL_31; + if (!net_players[car_to_player[byConsoleNode]]) + goto LABEL_31; + ROLLERCommsGetBlock(pData, &slave_data, 6); + copy_multiple[writeptr][in_header.byConsoleNode].uiFullData = + slave_data.uiData; + net_time[car_to_player[in_header.byConsoleNode]] = frames; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_READY: + if (byConsoleNode < 0 || byConsoleNode >= network_on) + goto LABEL_31; + if (!net_players[byConsoleNode]) + goto LABEL_31; + if (player_ready[in_header.byConsoleNode]) + goto LABEL_31; + ++active_nodes; + player_ready[byConsoleNode] = -1; + netCD = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_PAUSE: + slave_pause = -1; + pauser = in_header.byConsoleNode; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_PLAYER_INFO: + ROLLERCommsGetBlock(pData, &playerInfoPacket, + sizeof(tPlayerInfoPacket)); + Players_Cars[in_header.byConsoleNode] = playerInfoPacket.iPlayerCar; + check_cars(); + name_copy(player_names[in_header.byConsoleNode], + playerInfoPacket.szPlayerName); + TrackLoad = playerInfoPacket.iTrackLoad; + game_type = playerInfoPacket.iGameType; + competitors = playerInfoPacket.iCompetitors; + level = playerInfoPacket.iLevel; + damage_level = playerInfoPacket.iDamageLevel & 0xF; + if ((playerInfoPacket.iDamageLevel & 0x40) != 0) + player_invul[in_header.byConsoleNode] = -1; + else + player_invul[in_header.byConsoleNode] = 0; + manual_control[in_header.byConsoleNode] = + playerInfoPacket.iManualControl; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SYNC_ERROR: + goto LABEL_23; + case PACKET_ID_NOCD: + if (byConsoleNode < 0 || byConsoleNode >= network_on) + goto LABEL_31; + if (!net_players[byConsoleNode]) + goto LABEL_31; + if (player_ready[in_header.byConsoleNode]) + goto LABEL_31; + ++active_nodes; + player_ready[byConsoleNode] = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_RESYNC: + ++lost_message; + ROLLERCommsPostListen(); + syncnode = in_header.byConsoleNode; + ROLLERCommsGetBlock(pData, &iFrame, 4); + syncframe = iFrame; + if (frame_number - iFrame <= 500) { + if (ROLLERCommsGetType()) + ROLLERclrtx(); + syncleft = frame_number - syncframe; + syncptr = syncframe & 0x1FF; + if (check_set && syncleft > 7) { + memset(player_checks, -1, sizeof(player_checks)); + check_set = 0; + } + do_sync_stuff(); + ROLLERCommsPostListen(); + } else { + LABEL_23: + ROLLERCommsPostListen(); + send_network_sync_error(); + network_sync_error = -1; + ROLLERCommsPostListen(); } - LABEL_31: - ; + break; + case PACKET_ID_SEND_HERE: + load_times[in_header.byConsoleNode] = in_header.unFrameId; ROLLERCommsPostListen(); + break; + default: + ++duff_message; + goto LABEL_31; + } + LABEL_31:; + ROLLERCommsPostListen(); } } } //------------------------------------------------------------------------------------------------- -//00050600 -void do_sync_stuff() -{ - int iSyncPtr; // esi - uint8 byConsoleNode2; // al - int iNumCars; // edx - int iCarIdx; // eax - int *pTestMultiple; // edx - uint32 uiSyncData2; // ebx +// 00050600 +void do_sync_stuff() { + int iSyncPtr; // esi + uint8 byConsoleNode2; // al + int iNumCars; // edx + int iCarIdx; // eax + int *pTestMultiple; // edx + uint32 uiSyncData2; // ebx int iSendDataSuccess2; // eax - uint8 byConsoleNode; // al - int *pTestMini; // edx - int i; // eax - uint32 uiSyncData; // ebx - int iSendDataSuccess; // eax + uint8 byConsoleNode; // al + int *pTestMini; // edx + int i; // eax + uint32 uiSyncData; // ebx + int iSendDataSuccess; // eax iSyncPtr = syncptr; if (net_type) { @@ -1051,7 +1058,7 @@ void do_sync_stuff() // Prepare sync header byConsoleNode = (uint8)wConsoleNode; - in_header.uiId = 0x686C6366; // fclh + in_header.uiId = 0x686C6366; // fclh in_header.byConsoleNode = byConsoleNode; pTestMini = test_mini; in_header.unFrameId = syncframe; @@ -1065,10 +1072,12 @@ void do_sync_stuff() syncptr = iSyncPtr; // Send data - iSendDataSuccess = ROLLERCommsSendData(&in_header, 12, test_mini, 8, syncnode); + iSendDataSuccess = + ROLLERCommsSendData(&in_header, 12, test_mini, 8, syncnode); // Advance state - iSyncPtr = ((uint16)syncptr + 1) & 0x1FF; // ensure this index doesn't go beyond 511 + iSyncPtr = ((uint16)syncptr + 1) & + 0x1FF; // ensure this index doesn't go beyond 511 --syncleft; ++syncframe; } while (iSendDataSuccess); @@ -1076,7 +1085,7 @@ void do_sync_stuff() while (syncleft) { // Prepare sync header byConsoleNode2 = (uint8)wConsoleNode; - in_header.uiId = 0x686C6366; // fclh + in_header.uiId = 0x686C6366; // fclh in_header.byConsoleNode = byConsoleNode2; iNumCars = numcars; in_header.unFrameId = syncframe; @@ -1093,14 +1102,16 @@ void do_sync_stuff() syncptr = iSyncPtr; // Send data - iSendDataSuccess2 = ROLLERCommsSendData(&in_header, 12, test_multiple, 64, syncnode); + iSendDataSuccess2 = + ROLLERCommsSendData(&in_header, 12, test_multiple, 64, syncnode); // Advance state iSyncPtr = ((uint16)syncptr + 1) & 0x1FF; --syncleft; ++syncframe; if (!iSendDataSuccess2) { - syncptr = ((uint16)syncptr + 1) & 0x1FF; // ensure this index doesn't go beyond 511 + syncptr = ((uint16)syncptr + 1) & + 0x1FF; // ensure this index doesn't go beyond 511 return; } } @@ -1109,15 +1120,14 @@ void do_sync_stuff() } //------------------------------------------------------------------------------------------------- -//00050790 -int TransmitInit() -{ - int iSuccess; // eax - int32 iCarIdx; // eax - int32 iGameType; // eax - int32 iLevelFlags; // eax - char *szDefaultNamesDst; // ecx - char *szDefaultNameItr; // ebx +// 00050790 +int TransmitInit() { + int iSuccess; // eax + int32 iCarIdx; // eax + int32 iGameType; // eax + int32 iLevelFlags; // eax + char *szDefaultNamesDst; // ecx + char *szDefaultNameItr; // ebx tTransmitInitPacket initPacket; // [esp+0h] [ebp-108h] BYREF tSyncHeader header; @@ -1184,27 +1194,20 @@ int TransmitInit() szDefaultNamesDst += 9; } while (szDefaultNameItr != default_names[16]); - int iKnownPeerSuccess = ROLLERCommsSendData( - &header, - sizeof(tSyncHeader), - &initPacket, - sizeof(tTransmitInitPacket), - 21); + int iKnownPeerSuccess = + ROLLERCommsSendData(&header, sizeof(tSyncHeader), &initPacket, + sizeof(tTransmitInitPacket), 21); int iBroadcastSuccess = ROLLERCommsBroadcastData( - &header, - sizeof(tSyncHeader), - &initPacket, - sizeof(tTransmitInitPacket), - ROLLER_DEFAULT_PORT); + &header, sizeof(tSyncHeader), &initPacket, sizeof(tTransmitInitPacket), + ROLLER_DEFAULT_PORT); return iKnownPeerSuccess || iBroadcastSuccess; } return iSuccess; } //------------------------------------------------------------------------------------------------- -//000509B0 -void StartNode(int iNode) -{ +// 000509B0 +void StartNode(int iNode) { my_age = 0; ROLLERCommsGetNetworkAddr(address); ROLLERCommsGetConsoleNode(); @@ -1217,557 +1220,611 @@ void StartNode(int iNode) } //------------------------------------------------------------------------------------------------- -//00050A60 -void CheckNewNodes() -{ +// 00050A60 +void CheckNewNodes() { int iNode; // edx - //int iMsgCopyIndex; // eax + // int iMsgCopyIndex; // eax int iNumGamersInSlot; // ebp - int iGamerIndex; // edi - //char *pTxInitPacketByteCmp; // edx + int iGamerIndex; // edi + // char *pTxInitPacketByteCmp; // edx int iAddressMatchFlag; // ebx - //char *szAddressPtr; // eax - //char *szAddressEndPtr; // esi - int iSlotIndex; // edi - char *szGamerNamesPtr; // eax + // char *szAddressPtr; // eax + // char *szAddressEndPtr; // esi + int iSlotIndex; // edi + char *szGamerNamesPtr; // eax _NETNOW_NODE_ADDR *pNetNowNodeAddr4; // edi - int iSlotIndex2; // eax - int iFoundNodeOffset; // ebp - int iNetworkNodeIndex; // edi - //char *pTxInitPacketByteCmp_1; // edx + int iSlotIndex2; // eax + int iFoundNodeOffset; // ebp + int iNetworkNodeIndex; // edi + // char *pTxInitPacketByteCmp_1; // edx int iAddressMatchFlag2; // ebx - //char *pNodeAddrByteCmp; // eax - //char *pByteCmpEnd; // esi + // char *pNodeAddrByteCmp; // eax + // char *pByteCmpEnd; // esi //_NETNOW_NODE_ADDR *pNetNowNodeAddr3; // edi - int iTimeToStart; // eax + int iTimeToStart; // eax int iCheckNamesResult; // ebp - //char *szTxInitPacketNamesItr2; // ebx - //char *szDefaultNamesItr2; // esi - //uint32 iTempCheatMode4; // ecx - //uint32 iTempCheatMode5; // eax - //uint32 iTempCheatMode6; // ebx - //uint32 iTempCheatMode7; // ebx + // char *szTxInitPacketNamesItr2; // ebx + // char *szDefaultNamesItr2; // esi + // uint32 iTempCheatMode4; // ecx + // uint32 iTempCheatMode5; // eax + // uint32 iTempCheatMode6; // ebx + // uint32 iTempCheatMode7; // ebx unsigned int uiTimerHz; // eax - //uint32 iTempCheatMode8; // eax - //uint32 iTempCheatMode9; // eax - int i; // eax - int iNodeIndex; // ebp + // uint32 iTempCheatMode8; // eax + // uint32 iTempCheatMode9; // eax + int i; // eax + int iNodeIndex; // ebp int iCheckNamesResult2; // ecx - //uint32 uiTempCheatMode; // edx - //uint32 uiTempCheatMode2; // edx - //uint32 iTempCheatMode3; // ebx + // uint32 uiTempCheatMode; // edx + // uint32 uiTempCheatMode2; // edx + // uint32 iTempCheatMode3; // ebx unsigned int uiTimerHz2; // eax - //uint32 iTempCheatMode; // eax - //uint32 iTempCheatMode2; // edx - //char *szPacketNamesIt; // ebx - //char *szDefaultNamesItr; // esi + // uint32 iTempCheatMode; // eax + // uint32 iTempCheatMode2; // edx + // char *szPacketNamesIt; // ebx + // char *szDefaultNamesItr; // esi int iPlayerIndex; // eax - //int j; // eax - int byConsoleNode; // edx + // int j; // eax + int byConsoleNode; // edx tTransmitInitPacket transmitInitPacket; // [esp+0h] [ebp-18Ch] BYREF - tMessagePacket messagePacket; // [esp+E8h] [ebp-A4h] BYREF - tPlayerInfoPacket playerInfoPacket; // [esp+118h] [ebp-74h] BYREF - tRecordPacket recordPacket; // [esp+140h] [ebp-4Ch] BYREF - tSyncHeader syncHeader; // [esp+150h] [ebp-3Ch] BYREF - void *pPacket2; // [esp+15Ch] [ebp-30h] BYREF - int iMaxGamerIndex; // [esp+160h] [ebp-2Ch] - int *pTestSeed; // [esp+164h] [ebp-28h] - int iTxInitPacketNetworkSlotMinus1; // [esp+168h] [ebp-24h] + tMessagePacket messagePacket; // [esp+E8h] [ebp-A4h] BYREF + tPlayerInfoPacket playerInfoPacket; // [esp+118h] [ebp-74h] BYREF + tRecordPacket recordPacket; // [esp+140h] [ebp-4Ch] BYREF + tSyncHeader syncHeader; // [esp+150h] [ebp-3Ch] BYREF + void *pPacket2; // [esp+15Ch] [ebp-30h] BYREF + int iMaxGamerIndex; // [esp+160h] [ebp-2Ch] + int *pTestSeed; // [esp+164h] [ebp-28h] + int iTxInitPacketNetworkSlotMinus1; // [esp+168h] [ebp-24h] //_NETNOW_NODE_ADDR *szGamerAddressPtr; // [esp+16Ch] [ebp-20h] int iFoundGamerIndex; // [esp+170h] [ebp-1Ch] - pTestSeed = &test_seed; // Initialize pointer to test seed for random number generation + pTestSeed = &test_seed; // Initialize pointer to test seed for random number + // generation - while (ROLLERCommsGetHeader(&syncHeader, sizeof(tSyncHeader), &pPacket2))// Main packet processing loop - handle incoming network packets from other nodes - { // Handle PACKET_ID_TRANSMIT_INIT (0x686C6361) - player initialization packets + while (ROLLERCommsGetHeader( + &syncHeader, sizeof(tSyncHeader), + &pPacket2)) // Main packet processing loop - handle incoming network + // packets from other nodes + { // Handle PACKET_ID_TRANSMIT_INIT (0x686C6361) - player initialization + // packets switch (syncHeader.uiId) { - case PACKET_ID_TRANSMIT_INIT: // PACKET_ID_TRANSMIT_INIT - transmitInitPacket.iNetworkChampOn = 0; - transmitInitPacket.iNetworkSlot = 0; - ROLLERCommsGetBlock(pPacket2, &transmitInitPacket, sizeof(tTransmitInitPacket)); - NormalizePacketAddress(transmitInitPacket.address); - if (IsInvalidPacketAddress(transmitInitPacket.address)) { - LogDiscoveryAddress("ignored invalid", transmitInitPacket.address); - goto LABEL_40; - } - if (IsLocalPacketAddress(transmitInitPacket.address)) { - LogDiscoveryAddress("ignored self", transmitInitPacket.address); - goto LABEL_40; + case PACKET_ID_TRANSMIT_INIT: // PACKET_ID_TRANSMIT_INIT + transmitInitPacket.iNetworkChampOn = 0; + transmitInitPacket.iNetworkSlot = 0; + ROLLERCommsGetBlock(pPacket2, &transmitInitPacket, + sizeof(tTransmitInitPacket)); + NormalizePacketAddress(transmitInitPacket.address); + if (IsInvalidPacketAddress(transmitInitPacket.address)) { + LogDiscoveryAddress("ignored invalid", transmitInitPacket.address); + goto LABEL_40; + } + if (IsLocalPacketAddress(transmitInitPacket.address)) { + LogDiscoveryAddress("ignored self", transmitInitPacket.address); + goto LABEL_40; + } + if (network_slot >= 0) // Process init packet when we are already + // connected (network_slot >= 0) + { + if (transmitInitPacket.iNetworkSlot < 0 && !I_Quit) { + send_broadcast(0xFFFFFE37); + test = 3; + ROLLERCommsPostListen(); + continue; } - if (network_slot >= 0) // Process init packet when we are already connected (network_slot >= 0) + test = 4; + iFoundNodeOffset = 0; + for (iNetworkNodeIndex = 0; iNetworkNodeIndex < network_on; + ++iNetworkNodeIndex) // Search through existing network nodes to + // find matching address { - if (transmitInitPacket.iNetworkSlot < 0 && !I_Quit) { - send_broadcast(0xFFFFFE37); - test = 3; - ROLLERCommsPostListen(); - continue; - } - test = 4; - iFoundNodeOffset = 0; - for (iNetworkNodeIndex = 0; iNetworkNodeIndex < network_on; ++iNetworkNodeIndex)// Search through existing network nodes to find matching address - { - //This byte-by-byte comparison could be simplified to: - iAddressMatchFlag2 = memcmp(&address[iNetworkNodeIndex * 4], &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); - //pTxInitPacketByteCmp_1 = (char *)&transmitInitPacket; - //iAddressMatchFlag2 = 0; - //pNodeAddrByteCmp = (char *)&address[iNetworkNodeIndex]; - //pByteCmpEnd = pNodeAddrByteCmp + 16; - //do { // Compare network addresses byte by byte to detect duplicate nodes - // if (*pNodeAddrByteCmp != *pTxInitPacketByteCmp_1) - // iAddressMatchFlag2 = -1; - // ++pNodeAddrByteCmp; - // ++pTxInitPacketByteCmp_1; - //} while (pNodeAddrByteCmp != pByteCmpEnd); - - if (!iAddressMatchFlag2) { - iFoundNodeOffset = iNetworkNodeIndex + 10; - iNetworkNodeIndex = network_on + 6; - } + // This byte-by-byte comparison could be simplified to: + iAddressMatchFlag2 = + memcmp(&address[iNetworkNodeIndex * 4], + &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); + // pTxInitPacketByteCmp_1 = (char *)&transmitInitPacket; + // iAddressMatchFlag2 = 0; + // pNodeAddrByteCmp = (char *)&address[iNetworkNodeIndex]; + // pByteCmpEnd = pNodeAddrByteCmp + 16; + // do { // Compare network addresses + // byte by byte to detect duplicate nodes + // if (*pNodeAddrByteCmp != *pTxInitPacketByteCmp_1) + // iAddressMatchFlag2 = -1; + // ++pNodeAddrByteCmp; + // ++pTxInitPacketByteCmp_1; + // } while (pNodeAddrByteCmp != pByteCmpEnd); + + if (!iAddressMatchFlag2) { + iFoundNodeOffset = iNetworkNodeIndex + 10; + iNetworkNodeIndex = network_on + 6; } - if (!iFoundNodeOffset) { - test = 5; - if (time_to_start == -1) - goto LABEL_40; - if (transmitInitPacket.iNetworkChampOn != network_champ_on) - goto LABEL_40; - if (transmitInitPacket.iNetworkSlot != network_slot) - goto LABEL_40; - if (network_on >= 16) - goto LABEL_40; - if (I_Quit) - goto LABEL_40; - test = 20; // Add new network node if all validation checks pass - if ((unsigned int)ROLLERCommsAddNode(&transmitInitPacket.address) > 1) - goto LABEL_40; - LogDiscoveryAddress("discovered", transmitInitPacket.address); - test = 6; - ROLLERCommsSortNodes(); - - memcpy(&address[network_on * 4], &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); - //pNetNowNodeAddr3 = &address[network_on * 4];// Manual address copying - could be simplified to: memcpy(&address[network_on * 4], &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); - //*(_DWORD *)pNetNowNodeAddr3->sIPX.sInternetAddr.bNetwork = *(_DWORD *)transmitInitPacket.address.sIPX.sInternetAddr.bNetwork; - //pNetNowNodeAddr3 = (_NETNOW_NODE_ADDR *)((char *)pNetNowNodeAddr3 + 4); - //*(_DWORD *)pNetNowNodeAddr3->sIPX.sInternetAddr.bNetwork = *(_DWORD *)&transmitInitPacket.address.sNETBIOS.bNode[4]; - //*(_QWORD *)&pNetNowNodeAddr3->sNETBIOS.bNode[4] = *(_QWORD *)&transmitInitPacket.address.sNETBIOS.bNode[8]; - - iTimeToStart = transmitInitPacket.iTimeToStart; - switch_types = 0; - if (transmitInitPacket.iTimeToStart == -667) - iTimeToStart = 0; - if (iTimeToStart) { - if (time_to_start != -666) - goto LABEL_40; - LABEL_64: - reset_network(-1); - ROLLERCommsPostListen(); - continue; - } - test = 7; - name_copy(player_names[network_on], transmitInitPacket.szPlayerName); - Players_Cars[network_on] = transmitInitPacket.iCarIdx; - manual_control[network_on] = transmitInitPacket.iManualControl; - player_started[network_on] = transmitInitPacket.iStartPressed; - iCheckNamesResult = CheckNames(player_names[network_on], network_on); - check_cars(); - if (my_age < transmitInitPacket.iMyAge) { - - for (int i = 0; i < 16; i++) { - name_copy(default_names[i], transmitInitPacket.default_names[i]); - } - //szTxInitPacketNamesItr2 = transmitInitPacket.default_names[0]; - //szDefaultNamesItr2 = default_names[0]; - //do { - // name_copy(szDefaultNamesItr2, szTxInitPacketNamesItr2); - // szTxInitPacketNamesItr2 += 9; - // szDefaultNamesItr2 += 9; - //} while (szTxInitPacketNamesItr2 != (char *)&messagePacket);// messagePacket is immediately after transmitInitPacket - - my_age = transmitInitPacket.iMyAge; - TrackLoad = transmitInitPacket.iTrackLoad; - game_type = transmitInitPacket.iGameType; - if (transmitInitPacket.iGameType == 1) - Race = ((uint8)TrackLoad - 1) & 7; - else - network_champ_on = 0; - competitors = transmitInitPacket.iCompetitors; - level = transmitInitPacket.iLevelFlags; - if ((transmitInitPacket.iLevelFlags & 0x100) != 0)// Process level flags and update cheat mode settings accordingly - { - cheat_mode |= CHEAT_MODE_DEATH_MODE; - //iTempCheatMode4 = cheat_mode; - //LOBYTE(iTempCheatMode4) = cheat_mode | 2; - //cheat_mode = iTempCheatMode4; - } - player_invul[network_on] = ((level & 0x200) == 0) - 1; - if ((level & 0x400) != 0) { - cheat_mode |= CHEAT_MODE_KILLER_OPPONENTS; - //iTempCheatMode5 = cheat_mode; - //BYTE1(iTempCheatMode5) = BYTE1(cheat_mode) | 2; - //cheat_mode = iTempCheatMode5; - } - if ((level & 0x800) != 0) { - cheat_mode |= CHEAT_MODE_ICY_ROAD; - //iTempCheatMode6 = cheat_mode; - //BYTE1(iTempCheatMode6) = BYTE1(cheat_mode) | 4; - //cheat_mode = iTempCheatMode6; - } - if ((level & 0x1000) != 0) { - if ((level & 0x4000) != 0) { - if ((cheat_mode & 0x2000) == 0) { - cheat_mode |= (CHEAT_MODE_50HZ_TIMER | CHEAT_MODE_100HZ_TIMER); - //iTempCheatMode7 = cheat_mode; - //BYTE1(iTempCheatMode7) = BYTE1(cheat_mode) | 0x28; - //cheat_mode = iTempCheatMode7; - release_ticktimer(); - uiTimerHz = 100; - goto LABEL_83; - } - } else if ((cheat_mode & 0x800) == 0) { - cheat_mode |= CHEAT_MODE_50HZ_TIMER; - //iTempCheatMode8 = cheat_mode; - //BYTE1(iTempCheatMode8) = BYTE1(cheat_mode) | 8; - //cheat_mode = iTempCheatMode8; - release_ticktimer(); - uiTimerHz = 50; - LABEL_83: - claim_ticktimer(uiTimerHz); - } - } - if ((level & 0x2000) != 0) - cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; - if ((level & 0x10000) != 0) { - cheat_mode |= CHEAT_MODE_TINY_CARS; - //iTempCheatMode9 = cheat_mode; - //BYTE1(iTempCheatMode9) = BYTE1(cheat_mode) | 0x80; - //cheat_mode = iTempCheatMode9; - } - if ((level & 0x8000) != 0 && switch_same >= 0) - switch_same = transmitInitPacket.iCarIdx + 666; - level &= 0xFu; - damage_level = transmitInitPacket.iDamageLevel; - false_starts = transmitInitPacket.iFalseStart; - if (transmitInitPacket.iTextureMode) { - // TEX_OFF_ADVANCED_CARS - if ((textures_off & TEX_OFF_ADVANCED_CARS) == 0) { - textures_off |= TEX_OFF_ADVANCED_CARS; - goto LABEL_96; - } - } - // TEX_OFF_ADVANCED_CARS - else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { - textures_off &= ~TEX_OFF_ADVANCED_CARS; - LABEL_96: - switch_sets = -1; - } - } - players_waiting = 0; - for (i = 0; i <= network_on; ++i) // Count how many players have pressed start and are waiting - { - if (player_started[i]) - ++players_waiting; - } - ++my_age; - ++network_on; - if (!I_Quit) - send_broadcast(0xFFFFFFFF); - if (!iCheckNamesResult) + } + if (!iFoundNodeOffset) { + test = 5; + if (time_to_start == -1) + goto LABEL_40; + if (transmitInitPacket.iNetworkChampOn != network_champ_on) + goto LABEL_40; + if (transmitInitPacket.iNetworkSlot != network_slot) + goto LABEL_40; + if (network_on >= 16) + goto LABEL_40; + if (I_Quit) + goto LABEL_40; + test = 20; // Add new network node if all validation checks pass + if ((unsigned int)ROLLERCommsAddNode(&transmitInitPacket.address) > 1) + goto LABEL_40; + LogDiscoveryAddress("discovered", transmitInitPacket.address); + test = 6; + ROLLERCommsSortNodes(); + + memcpy(&address[network_on * 4], &transmitInitPacket.address, + sizeof(_NETNOW_NODE_ADDR)); + // pNetNowNodeAddr3 = &address[network_on * 4];// Manual address + // copying - could be simplified to: memcpy(&address[network_on * 4], + // &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); + //*(_DWORD *)pNetNowNodeAddr3->sIPX.sInternetAddr.bNetwork = *(_DWORD + //*)transmitInitPacket.address.sIPX.sInternetAddr.bNetwork; + // pNetNowNodeAddr3 = (_NETNOW_NODE_ADDR *)((char *)pNetNowNodeAddr3 + + // 4); + //*(_DWORD *)pNetNowNodeAddr3->sIPX.sInternetAddr.bNetwork = *(_DWORD + //*)&transmitInitPacket.address.sNETBIOS.bNode[4]; + //*(_QWORD *)&pNetNowNodeAddr3->sNETBIOS.bNode[4] = *(_QWORD + //*)&transmitInitPacket.address.sNETBIOS.bNode[8]; + + iTimeToStart = transmitInitPacket.iTimeToStart; + switch_types = 0; + if (transmitInitPacket.iTimeToStart == -667) + iTimeToStart = 0; + if (iTimeToStart) { + if (time_to_start != -666) goto LABEL_40; - LABEL_104: - cheat_mode = 0; + LABEL_64: + reset_network(-1); ROLLERCommsPostListen(); continue; } - test = 8; - iNodeIndex = iFoundNodeOffset - 10; - ++my_age; - if (iNodeIndex <= 0) - goto LABEL_40; - test = 9; - if (!transmitInitPacket.iTimeToStart) { - test = 10; - name_copy(player_names[iNodeIndex], transmitInitPacket.szPlayerName); - Players_Cars[iNodeIndex] = transmitInitPacket.iCarIdx; - iCheckNamesResult2 = CheckNames(player_names[iNodeIndex], iNodeIndex); - check_cars(); - TrackLoad = transmitInitPacket.iTrackLoad; - if (transmitInitPacket.iGameType < 3) { - if (transmitInitPacket.iGameType == game_type) - game_type = transmitInitPacket.iGameType; - else - switch_types = transmitInitPacket.iGameType + 1; + test = 7; + name_copy(player_names[network_on], transmitInitPacket.szPlayerName); + Players_Cars[network_on] = transmitInitPacket.iCarIdx; + manual_control[network_on] = transmitInitPacket.iManualControl; + player_started[network_on] = transmitInitPacket.iStartPressed; + iCheckNamesResult = CheckNames(player_names[network_on], network_on); + check_cars(); + if (my_age < transmitInitPacket.iMyAge) { + + for (int i = 0; i < 16; i++) { + name_copy(default_names[i], transmitInitPacket.default_names[i]); } + // szTxInitPacketNamesItr2 = transmitInitPacket.default_names[0]; + // szDefaultNamesItr2 = default_names[0]; + // do { + // name_copy(szDefaultNamesItr2, szTxInitPacketNamesItr2); + // szTxInitPacketNamesItr2 += 9; + // szDefaultNamesItr2 += 9; + // } while (szTxInitPacketNamesItr2 != (char *)&messagePacket);// + // messagePacket is immediately after transmitInitPacket + + my_age = transmitInitPacket.iMyAge; + TrackLoad = transmitInitPacket.iTrackLoad; + game_type = transmitInitPacket.iGameType; + if (transmitInitPacket.iGameType == 1) + Race = ((uint8)TrackLoad - 1) & 7; + else + network_champ_on = 0; competitors = transmitInitPacket.iCompetitors; level = transmitInitPacket.iLevelFlags; - if ((transmitInitPacket.iLevelFlags & 0x100) != 0) { + if ((transmitInitPacket.iLevelFlags & 0x100) != + 0) // Process level flags and update cheat mode settings + // accordingly + { cheat_mode |= CHEAT_MODE_DEATH_MODE; - //uiTempCheatMode = cheat_mode; - //LOBYTE(uiTempCheatMode) = cheat_mode | 2; - //cheat_mode = uiTempCheatMode; + // iTempCheatMode4 = cheat_mode; + // LOBYTE(iTempCheatMode4) = cheat_mode | 2; + // cheat_mode = iTempCheatMode4; } - player_invul[iNodeIndex] = ((level & 0x200) == 0) - 1; - if ((level & 0x400) != 0) + player_invul[network_on] = ((level & 0x200) == 0) - 1; + if ((level & 0x400) != 0) { cheat_mode |= CHEAT_MODE_KILLER_OPPONENTS; + // iTempCheatMode5 = cheat_mode; + // BYTE1(iTempCheatMode5) = BYTE1(cheat_mode) | 2; + // cheat_mode = iTempCheatMode5; + } if ((level & 0x800) != 0) { cheat_mode |= CHEAT_MODE_ICY_ROAD; - //uiTempCheatMode2 = cheat_mode; - //BYTE1(uiTempCheatMode2) = BYTE1(cheat_mode) | 4; - //cheat_mode = uiTempCheatMode2; + // iTempCheatMode6 = cheat_mode; + // BYTE1(iTempCheatMode6) = BYTE1(cheat_mode) | 4; + // cheat_mode = iTempCheatMode6; } if ((level & 0x1000) != 0) { if ((level & 0x4000) != 0) { if ((cheat_mode & 0x2000) == 0) { - cheat_mode |= (CHEAT_MODE_50HZ_TIMER | CHEAT_MODE_100HZ_TIMER); - //iTempCheatMode3 = cheat_mode; - //BYTE1(iTempCheatMode3) = BYTE1(cheat_mode) | 0x28; - //cheat_mode = iTempCheatMode3; + cheat_mode |= + (CHEAT_MODE_50HZ_TIMER | CHEAT_MODE_100HZ_TIMER); + // iTempCheatMode7 = cheat_mode; + // BYTE1(iTempCheatMode7) = BYTE1(cheat_mode) | 0x28; + // cheat_mode = iTempCheatMode7; release_ticktimer(); - uiTimerHz2 = 100; - goto LABEL_130; + uiTimerHz = 100; + goto LABEL_83; } } else if ((cheat_mode & 0x800) == 0) { cheat_mode |= CHEAT_MODE_50HZ_TIMER; - //iTempCheatMode = cheat_mode; - //BYTE1(iTempCheatMode) = BYTE1(cheat_mode) | 8; - //cheat_mode = iTempCheatMode; + // iTempCheatMode8 = cheat_mode; + // BYTE1(iTempCheatMode8) = BYTE1(cheat_mode) | 8; + // cheat_mode = iTempCheatMode8; release_ticktimer(); - uiTimerHz2 = 50; - LABEL_130: - claim_ticktimer(uiTimerHz2); + uiTimerHz = 50; + LABEL_83: + claim_ticktimer(uiTimerHz); } } if ((level & 0x2000) != 0) cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; if ((level & 0x10000) != 0) { cheat_mode |= CHEAT_MODE_TINY_CARS; - //iTempCheatMode2 = cheat_mode; - //BYTE1(iTempCheatMode2) = BYTE1(cheat_mode) | 0x80; - //cheat_mode = iTempCheatMode2; + // iTempCheatMode9 = cheat_mode; + // BYTE1(iTempCheatMode9) = BYTE1(cheat_mode) | 0x80; + // cheat_mode = iTempCheatMode9; } if ((level & 0x8000) != 0 && switch_same >= 0) switch_same = transmitInitPacket.iCarIdx + 666; level &= 0xFu; damage_level = transmitInitPacket.iDamageLevel; - - for (int i = 0; i < 16; i++) { - name_copy(default_names[i], transmitInitPacket.default_names[i]); - } - //szPacketNamesIt = transmitInitPacket.default_names[0]; - //szDefaultNamesItr = default_names[0]; - //do { - // name_copy(szDefaultNamesItr, szPacketNamesIt); - // szPacketNamesIt += 9; - // szDefaultNamesItr += 9; - //} while (szPacketNamesIt != (char *)&messagePacket); - false_starts = transmitInitPacket.iFalseStart; if (transmitInitPacket.iTextureMode) { // TEX_OFF_ADVANCED_CARS if ((textures_off & TEX_OFF_ADVANCED_CARS) == 0) { textures_off |= TEX_OFF_ADVANCED_CARS; - goto LABEL_145; + goto LABEL_96; } } // TEX_OFF_ADVANCED_CARS else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { textures_off &= ~TEX_OFF_ADVANCED_CARS; - LABEL_145: + LABEL_96: switch_sets = -1; } - manual_control[iNodeIndex] = transmitInitPacket.iManualControl; - player_started[iNodeIndex] = transmitInitPacket.iStartPressed; - players_waiting = 0; - for (iPlayerIndex = 0; iPlayerIndex < network_on; ++iPlayerIndex) { - if (player_started[iPlayerIndex]) - ++players_waiting; + } + players_waiting = 0; + for (i = 0; i <= network_on; + ++i) // Count how many players have pressed start and are waiting + { + if (player_started[i]) + ++players_waiting; + } + ++my_age; + ++network_on; + if (!I_Quit) + send_broadcast(0xFFFFFFFF); + if (!iCheckNamesResult) + goto LABEL_40; + LABEL_104: + cheat_mode = 0; + ROLLERCommsPostListen(); + continue; + } + test = 8; + iNodeIndex = iFoundNodeOffset - 10; + ++my_age; + if (iNodeIndex <= 0) + goto LABEL_40; + test = 9; + if (!transmitInitPacket.iTimeToStart) { + test = 10; + name_copy(player_names[iNodeIndex], transmitInitPacket.szPlayerName); + Players_Cars[iNodeIndex] = transmitInitPacket.iCarIdx; + iCheckNamesResult2 = CheckNames(player_names[iNodeIndex], iNodeIndex); + check_cars(); + TrackLoad = transmitInitPacket.iTrackLoad; + if (transmitInitPacket.iGameType < 3) { + if (transmitInitPacket.iGameType == game_type) + game_type = transmitInitPacket.iGameType; + else + switch_types = transmitInitPacket.iGameType + 1; + } + competitors = transmitInitPacket.iCompetitors; + level = transmitInitPacket.iLevelFlags; + if ((transmitInitPacket.iLevelFlags & 0x100) != 0) { + cheat_mode |= CHEAT_MODE_DEATH_MODE; + // uiTempCheatMode = cheat_mode; + // LOBYTE(uiTempCheatMode) = cheat_mode | 2; + // cheat_mode = uiTempCheatMode; + } + player_invul[iNodeIndex] = ((level & 0x200) == 0) - 1; + if ((level & 0x400) != 0) + cheat_mode |= CHEAT_MODE_KILLER_OPPONENTS; + if ((level & 0x800) != 0) { + cheat_mode |= CHEAT_MODE_ICY_ROAD; + // uiTempCheatMode2 = cheat_mode; + // BYTE1(uiTempCheatMode2) = BYTE1(cheat_mode) | 4; + // cheat_mode = uiTempCheatMode2; + } + if ((level & 0x1000) != 0) { + if ((level & 0x4000) != 0) { + if ((cheat_mode & 0x2000) == 0) { + cheat_mode |= (CHEAT_MODE_50HZ_TIMER | CHEAT_MODE_100HZ_TIMER); + // iTempCheatMode3 = cheat_mode; + // BYTE1(iTempCheatMode3) = BYTE1(cheat_mode) | 0x28; + // cheat_mode = iTempCheatMode3; + release_ticktimer(); + uiTimerHz2 = 100; + goto LABEL_130; + } + } else if ((cheat_mode & 0x800) == 0) { + cheat_mode |= CHEAT_MODE_50HZ_TIMER; + // iTempCheatMode = cheat_mode; + // BYTE1(iTempCheatMode) = BYTE1(cheat_mode) | 8; + // cheat_mode = iTempCheatMode; + release_ticktimer(); + uiTimerHz2 = 50; + LABEL_130: + claim_ticktimer(uiTimerHz2); } - if (!iCheckNamesResult2) - goto LABEL_40; - goto LABEL_104; } - if (transmitInitPacket.iTimeToStart < ~665u) { - if (transmitInitPacket.iTimeToStart == -667) { - send_broadcast(0xFFFFFFFF); - ROLLERCommsPostListen(); - continue; + if ((level & 0x2000) != 0) + cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; + if ((level & 0x10000) != 0) { + cheat_mode |= CHEAT_MODE_TINY_CARS; + // iTempCheatMode2 = cheat_mode; + // BYTE1(iTempCheatMode2) = BYTE1(cheat_mode) | 0x80; + // cheat_mode = iTempCheatMode2; + } + if ((level & 0x8000) != 0 && switch_same >= 0) + switch_same = transmitInitPacket.iCarIdx + 666; + level &= 0xFu; + damage_level = transmitInitPacket.iDamageLevel; + + for (int i = 0; i < 16; i++) { + name_copy(default_names[i], transmitInitPacket.default_names[i]); + } + // szPacketNamesIt = transmitInitPacket.default_names[0]; + // szDefaultNamesItr = default_names[0]; + // do { + // name_copy(szDefaultNamesItr, szPacketNamesIt); + // szPacketNamesIt += 9; + // szDefaultNamesItr += 9; + // } while (szPacketNamesIt != (char *)&messagePacket); + + false_starts = transmitInitPacket.iFalseStart; + if (transmitInitPacket.iTextureMode) { + // TEX_OFF_ADVANCED_CARS + if ((textures_off & TEX_OFF_ADVANCED_CARS) == 0) { + textures_off |= TEX_OFF_ADVANCED_CARS; + goto LABEL_145; } - } else { - if (transmitInitPacket.iTimeToStart <= ~665u) - goto LABEL_64; - if (transmitInitPacket.iTimeToStart == -457) - goto LABEL_40; } - time_to_start = -1; - FoundNodes(); - ROLLERCommsPostListen(); - } else { - test = 1; - if (transmitInitPacket.iNetworkSlot < 0) - goto LABEL_40; - test = 2; - iTxInitPacketNetworkSlotMinus1 = transmitInitPacket.iNetworkSlot - 1; - if ((unsigned int)(transmitInitPacket.iNetworkSlot - 1) > 4) + // TEX_OFF_ADVANCED_CARS + else if ((textures_off & TEX_OFF_ADVANCED_CARS) != 0) { + textures_off &= ~TEX_OFF_ADVANCED_CARS; + LABEL_145: + switch_sets = -1; + } + manual_control[iNodeIndex] = transmitInitPacket.iManualControl; + player_started[iNodeIndex] = transmitInitPacket.iStartPressed; + players_waiting = 0; + for (iPlayerIndex = 0; iPlayerIndex < network_on; ++iPlayerIndex) { + if (player_started[iPlayerIndex]) + ++players_waiting; + } + if (!iCheckNamesResult2) goto LABEL_40; - if (transmitInitPacket.iTimeToStart < -666) - goto LABEL_24; - if (transmitInitPacket.iTimeToStart <= -666) { - send_broadcast(0xFFFFFE38); - gamers_playing[iTxInitPacketNetworkSlotMinus1] = 0; + goto LABEL_104; + } + if (transmitInitPacket.iTimeToStart < ~665u) { + if (transmitInitPacket.iTimeToStart == -667) { + send_broadcast(0xFFFFFFFF); ROLLERCommsPostListen(); continue; } - if (transmitInitPacket.iTimeToStart != -1) { - LABEL_24: - if (!transmitInitPacket.iNetworkChampOn) { - iFoundGamerIndex = 0; - iNumGamersInSlot = gamers_playing[iTxInitPacketNetworkSlotMinus1]; - if (iNumGamersInSlot < 0) { - iNumGamersInSlot = 0; - gamers_playing[iTxInitPacketNetworkSlotMinus1] = 0; - } - iGamerIndex = 0; - if (iNumGamersInSlot > 0) { - //szGamerAddressPtr = gamers_address[iTxInitPacketNetworkSlotMinus1]; - iMaxGamerIndex = iNumGamersInSlot + 678; - do { - - iAddressMatchFlag = memcmp(&gamers_address[iTxInitPacketNetworkSlotMinus1][iGamerIndex], &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); - //pTxInitPacketByteCmp = (char *)&transmitInitPacket; - //iAddressMatchFlag = 0; - //szAddressPtr = (char *)&szGamerAddressPtr[iGamerIndex]; - //szAddressEndPtr = szAddressPtr + 16; - //do { - // if (*szAddressPtr != *pTxInitPacketByteCmp) - // iAddressMatchFlag = -1; - // ++szAddressPtr; - // ++pTxInitPacketByteCmp; - //} while (szAddressPtr != szAddressEndPtr); - - if (!iAddressMatchFlag) { - iFoundGamerIndex = iGamerIndex + 678; - iGamerIndex = iMaxGamerIndex; - } - ++iGamerIndex; - } while (iGamerIndex < iNumGamersInSlot); - } - if (!transmitInitPacket.iNetworkChampOn) { - iSlotIndex = iTxInitPacketNetworkSlotMinus1; - szGamerNamesPtr = gamers_names[iTxInitPacketNetworkSlotMinus1]; - if (iFoundGamerIndex) { - name_copy(&szGamerNamesPtr[9 * iFoundGamerIndex - 6102], transmitInitPacket.szPlayerName); - } else { - name_copy(&szGamerNamesPtr[9 * iNumGamersInSlot], transmitInitPacket.szPlayerName); - pNetNowNodeAddr4 = &gamers_address[iSlotIndex][iNumGamersInSlot]; - iSlotIndex2 = iTxInitPacketNetworkSlotMinus1; - - memcpy(&gamers_address[iSlotIndex][iNumGamersInSlot], &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); - //*(_DWORD *)pNetNowNodeAddr4->sIPX.sInternetAddr.bNetwork = *(_DWORD *)transmitInitPacket.address.sIPX.sInternetAddr.bNetwork; - //pNetNowNodeAddr4 = (_NETNOW_NODE_ADDR *)((char *)pNetNowNodeAddr4 + 4); - //*(_DWORD *)pNetNowNodeAddr4->sIPX.sInternetAddr.bNetwork = *(_DWORD *)&transmitInitPacket.address.sNETBIOS.bNode[4]; - //*(_QWORD *)&pNetNowNodeAddr4->sNETBIOS.bNode[4] = *(_QWORD *)&transmitInitPacket.address.sNETBIOS.bNode[8]; - - ++gamers_playing[iSlotIndex2]; + } else { + if (transmitInitPacket.iTimeToStart <= ~665u) + goto LABEL_64; + if (transmitInitPacket.iTimeToStart == -457) + goto LABEL_40; + } + time_to_start = -1; + FoundNodes(); + ROLLERCommsPostListen(); + } else { + test = 1; + if (transmitInitPacket.iNetworkSlot < 0) + goto LABEL_40; + test = 2; + iTxInitPacketNetworkSlotMinus1 = transmitInitPacket.iNetworkSlot - 1; + if ((unsigned int)(transmitInitPacket.iNetworkSlot - 1) > 4) + goto LABEL_40; + if (transmitInitPacket.iTimeToStart < -666) + goto LABEL_24; + if (transmitInitPacket.iTimeToStart <= -666) { + send_broadcast(0xFFFFFE38); + gamers_playing[iTxInitPacketNetworkSlotMinus1] = 0; + ROLLERCommsPostListen(); + continue; + } + if (transmitInitPacket.iTimeToStart != -1) { + LABEL_24: + if (!transmitInitPacket.iNetworkChampOn) { + iFoundGamerIndex = 0; + iNumGamersInSlot = gamers_playing[iTxInitPacketNetworkSlotMinus1]; + if (iNumGamersInSlot < 0) { + iNumGamersInSlot = 0; + gamers_playing[iTxInitPacketNetworkSlotMinus1] = 0; + } + iGamerIndex = 0; + if (iNumGamersInSlot > 0) { + // szGamerAddressPtr = + // gamers_address[iTxInitPacketNetworkSlotMinus1]; + iMaxGamerIndex = iNumGamersInSlot + 678; + do { + + iAddressMatchFlag = memcmp( + &gamers_address[iTxInitPacketNetworkSlotMinus1] + [iGamerIndex], + &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); + // pTxInitPacketByteCmp = (char *)&transmitInitPacket; + // iAddressMatchFlag = 0; + // szAddressPtr = (char *)&szGamerAddressPtr[iGamerIndex]; + // szAddressEndPtr = szAddressPtr + 16; + // do { + // if (*szAddressPtr != *pTxInitPacketByteCmp) + // iAddressMatchFlag = -1; + // ++szAddressPtr; + // ++pTxInitPacketByteCmp; + // } while (szAddressPtr != szAddressEndPtr); + + if (!iAddressMatchFlag) { + iFoundGamerIndex = iGamerIndex + 678; + iGamerIndex = iMaxGamerIndex; } + ++iGamerIndex; + } while (iGamerIndex < iNumGamersInSlot); + } + if (!transmitInitPacket.iNetworkChampOn) { + iSlotIndex = iTxInitPacketNetworkSlotMinus1; + szGamerNamesPtr = gamers_names[iTxInitPacketNetworkSlotMinus1]; + if (iFoundGamerIndex) { + name_copy(&szGamerNamesPtr[9 * iFoundGamerIndex - 6102], + transmitInitPacket.szPlayerName); + } else { + name_copy(&szGamerNamesPtr[9 * iNumGamersInSlot], + transmitInitPacket.szPlayerName); + pNetNowNodeAddr4 = + &gamers_address[iSlotIndex][iNumGamersInSlot]; + iSlotIndex2 = iTxInitPacketNetworkSlotMinus1; + + memcpy(&gamers_address[iSlotIndex][iNumGamersInSlot], + &transmitInitPacket.address, sizeof(_NETNOW_NODE_ADDR)); + //*(_DWORD *)pNetNowNodeAddr4->sIPX.sInternetAddr.bNetwork = + //*(_DWORD + //*)transmitInitPacket.address.sIPX.sInternetAddr.bNetwork; + // pNetNowNodeAddr4 = (_NETNOW_NODE_ADDR *)((char + // *)pNetNowNodeAddr4 + 4); + //*(_DWORD *)pNetNowNodeAddr4->sIPX.sInternetAddr.bNetwork = + //*(_DWORD *)&transmitInitPacket.address.sNETBIOS.bNode[4]; + //*(_QWORD *)&pNetNowNodeAddr4->sNETBIOS.bNode[4] = *(_QWORD + //*)&transmitInitPacket.address.sNETBIOS.bNode[8]; + + ++gamers_playing[iSlotIndex2]; } - goto LABEL_40; } + goto LABEL_40; } - gamers_playing[iTxInitPacketNetworkSlotMinus1] = -2; - ROLLERCommsPostListen(); } - break; - case PACKET_ID_QUIT: // PACKET_ID_QUIT - net_quit = -1; // Handle PACKET_ID_QUIT (0x686C6364) - player disconnection notification + gamers_playing[iTxInitPacketNetworkSlotMinus1] = -2; ROLLERCommsPostListen(); - continue; - case PACKET_ID_READY: // PACKET_ID_READY - if (player_ready[syncHeader.byConsoleNode])// Handle PACKET_ID_READY (0x686C6367) - player ready status - goto LABEL_40; - ++active_nodes; - player_ready[syncHeader.byConsoleNode] = -1; - netCD = -1; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SEED: // PACKET_ID_SEED - ROLLERCommsGetBlock(pPacket2, &test_seed, 4);// Handle PACKET_ID_SEED (0x686C6368) - synchronize random seed across network - ROLLERsrand(*pTestSeed); - random_seed = *pTestSeed; - received_seed = -1; - SDL_Log("[NET-START] received seed=%d on node=%d", random_seed, (int)wConsoleNode); - ROLLERCommsPostListen(); - continue; - case PACKET_ID_PLAYER_INFO: // PACKET_ID_PLAYER_INFO - ROLLERCommsGetBlock(pPacket2, &playerInfoPacket, 40);// Handle PACKET_ID_PLAYER_INFO (0x686C636A) - update player information - byConsoleNode = syncHeader.byConsoleNode; - Players_Cars[syncHeader.byConsoleNode] = playerInfoPacket.iPlayerCar; - name_copy(player_names[byConsoleNode], playerInfoPacket.szPlayerName); - TrackLoad = playerInfoPacket.iTrackLoad; - game_type = playerInfoPacket.iGameType; - competitors = playerInfoPacket.iCompetitors; - level = playerInfoPacket.iLevel; - damage_level = playerInfoPacket.iDamageLevel & 0xF; - if ((playerInfoPacket.iDamageLevel & 0x40) != 0) - player_invul[syncHeader.byConsoleNode] = -1; - else - player_invul[syncHeader.byConsoleNode] = 0; - manual_control[syncHeader.byConsoleNode] = playerInfoPacket.iManualControl; - goto LABEL_40; - case PACKET_ID_RECORD: // PACKET_ID_RECORD - ++received_records; // Handle PACKET_ID_RECORD (0x686C636B) - update lap record if faster than current - ROLLERCommsGetBlock(pPacket2, &recordPacket, 16); - SDL_Log("[NET-START] received record from node=%d count=%d/%d", - syncHeader.byConsoleNode, received_records, network_on); - if (recordPacket.fRecordLap < (double)RecordLaps[TrackLoad]) { - RecordLaps[TrackLoad] = recordPacket.fRecordLap; - RecordCars[TrackLoad] = (int16)recordPacket.unRecordCar; - - strncpy(RecordNames[TrackLoad], recordPacket.szRecordName, 9); - //for (j = 0; j < 9; *((_BYTE *)&fudge_wait + 9 * TrackLoad + j + 3) = recordPacket.szRecordName[j - 1])// fudge_wait is offset into RecordNames - // ++j; - } + } + break; + case PACKET_ID_QUIT: // PACKET_ID_QUIT + net_quit = -1; // Handle PACKET_ID_QUIT (0x686C6364) - player + // disconnection notification + ROLLERCommsPostListen(); + continue; + case PACKET_ID_READY: // PACKET_ID_READY + if (player_ready[syncHeader.byConsoleNode]) // Handle PACKET_ID_READY + // (0x686C6367) - player ready + // status goto LABEL_40; - case PACKET_ID_NOCD: // PACKET_ID_NOCD - if (player_ready[syncHeader.byConsoleNode]) - goto LABEL_40; - ++active_nodes; - player_ready[syncHeader.byConsoleNode] = -1; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SLOT: // PACKET_ID_SLOT - //TODO: ensure this is accurate - gamers_playing[syncHeader.byConsoleNode - 1] = -2; - //*(_DWORD *)&gamers_address[3][15].sNETBIOS.bNode[4 * syncHeader.byConsoleNode + 12] = -2; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_SEND_HERE: // PACKET_ID_SEND_HERE - load_times[syncHeader.byConsoleNode] = syncHeader.unFrameId; - ROLLERCommsPostListen(); - continue; - case PACKET_ID_MESSAGE: // PACKET_ID_MESSAGE - ROLLERCommsGetBlock(pPacket2, &messagePacket, 48);// Handle PACKET_ID_MESSAGE (0x686C6373) - receive and process chat messages - iNode = syncHeader.byConsoleNode; - if (iNode != ROLLERCommsNetAddrToNode(address) && messagePacket.iNetworkSlot == network_slot) { - rec_status = 36; - name_copy(rec_mes_name, messagePacket.szPlayerName); - - strncpy(rec_mes_buf, messagePacket.szMessage, sizeof(rec_mes_buf)); - //for (iMsgCopyIndex = 0; iMsgCopyIndex < 32; LoadCarTextures_variable_1[iMsgCopyIndex] = transmitInitPacket.default_names[15][iMsgCopyIndex + 8]) - // ++iMsgCopyIndex; - } + ++active_nodes; + player_ready[syncHeader.byConsoleNode] = -1; + netCD = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SEED: // PACKET_ID_SEED + ROLLERCommsGetBlock(pPacket2, &test_seed, + 4); // Handle PACKET_ID_SEED (0x686C6368) - + // synchronize random seed across network + ROLLERsrand(*pTestSeed); + random_seed = *pTestSeed; + received_seed = -1; + SDL_Log("[NET-START] received seed=%d on node=%d", random_seed, + (int)wConsoleNode); + ROLLERCommsPostListen(); + continue; + case PACKET_ID_PLAYER_INFO: // PACKET_ID_PLAYER_INFO + ROLLERCommsGetBlock(pPacket2, &playerInfoPacket, + 40); // Handle PACKET_ID_PLAYER_INFO (0x686C636A) - + // update player information + byConsoleNode = syncHeader.byConsoleNode; + Players_Cars[syncHeader.byConsoleNode] = playerInfoPacket.iPlayerCar; + name_copy(player_names[byConsoleNode], playerInfoPacket.szPlayerName); + TrackLoad = playerInfoPacket.iTrackLoad; + game_type = playerInfoPacket.iGameType; + competitors = playerInfoPacket.iCompetitors; + level = playerInfoPacket.iLevel; + damage_level = playerInfoPacket.iDamageLevel & 0xF; + if ((playerInfoPacket.iDamageLevel & 0x40) != 0) + player_invul[syncHeader.byConsoleNode] = -1; + else + player_invul[syncHeader.byConsoleNode] = 0; + manual_control[syncHeader.byConsoleNode] = + playerInfoPacket.iManualControl; + goto LABEL_40; + case PACKET_ID_RECORD: // PACKET_ID_RECORD + ++received_records; // Handle PACKET_ID_RECORD (0x686C636B) - update lap + // record if faster than current + ROLLERCommsGetBlock(pPacket2, &recordPacket, 16); + SDL_Log("[NET-START] received record from node=%d count=%d/%d", + syncHeader.byConsoleNode, received_records, network_on); + if (recordPacket.fRecordLap < (double)RecordLaps[TrackLoad]) { + RecordLaps[TrackLoad] = recordPacket.fRecordLap; + RecordCars[TrackLoad] = (int16)recordPacket.unRecordCar; + + strncpy(RecordNames[TrackLoad], recordPacket.szRecordName, 9); + // for (j = 0; j < 9; *((_BYTE *)&fudge_wait + 9 * TrackLoad + j + 3) = + // recordPacket.szRecordName[j - 1])// fudge_wait is offset into + // RecordNames + // ++j; + } + goto LABEL_40; + case PACKET_ID_NOCD: // PACKET_ID_NOCD + if (player_ready[syncHeader.byConsoleNode]) goto LABEL_40; - default: - LABEL_40: - ROLLERCommsPostListen(); - continue; + ++active_nodes; + player_ready[syncHeader.byConsoleNode] = -1; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SLOT: // PACKET_ID_SLOT + // TODO: ensure this is accurate + gamers_playing[syncHeader.byConsoleNode - 1] = -2; + //*(_DWORD *)&gamers_address[3][15].sNETBIOS.bNode[4 * + // syncHeader.byConsoleNode + 12] = -2; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_SEND_HERE: // PACKET_ID_SEND_HERE + load_times[syncHeader.byConsoleNode] = syncHeader.unFrameId; + ROLLERCommsPostListen(); + continue; + case PACKET_ID_MESSAGE: // PACKET_ID_MESSAGE + ROLLERCommsGetBlock(pPacket2, &messagePacket, + 48); // Handle PACKET_ID_MESSAGE (0x686C6373) - + // receive and process chat messages + iNode = syncHeader.byConsoleNode; + if (iNode != ROLLERCommsNetAddrToNode(address) && + messagePacket.iNetworkSlot == network_slot) { + rec_status = 36; + name_copy(rec_mes_name, messagePacket.szPlayerName); + + strncpy(rec_mes_buf, messagePacket.szMessage, sizeof(rec_mes_buf)); + // for (iMsgCopyIndex = 0; iMsgCopyIndex < 32; + // LoadCarTextures_variable_1[iMsgCopyIndex] = + // transmitInitPacket.default_names[15][iMsgCopyIndex + 8]) + // ++iMsgCopyIndex; + } + goto LABEL_40; + default: + LABEL_40: + ROLLERCommsPostListen(); + continue; } } } //------------------------------------------------------------------------------------------------- -//000516F0 -void FoundNodes() -{ - if (!master) return; // Only process if we're the master +// 000516F0 +void FoundNodes() { + if (!master) + return; // Only process if we're the master int oldNetworkOn = network_on; int oldPlayersCars[16]; @@ -1791,9 +1848,10 @@ void FoundNodes() master = 0; start_multiple = network_on - 1; - // The lobby address table is discovery-ordered with our own address in slot 0, - // while the comms node table is sorted. Remap player configuration by address - // so player indices match sorted node indices before the race car mapping runs. + // The lobby address table is discovery-ordered with our own address in slot + // 0, while the comms node table is sorted. Remap player configuration by + // address so player indices match sorted node indices before the race car + // mapping runs. for (int i = 0; i < network_on; i++) { Players_Cars[i] = -1; manual_control[i] = 0; @@ -1817,29 +1875,28 @@ void FoundNodes() player1_car = wConsoleNode; SDL_Log("[NET] FoundNodes: wConsoleNode=%d player1_car=%d network_on=%d\n", - (int)wConsoleNode, player1_car, network_on); + (int)wConsoleNode, player1_car, network_on); for (int i = 0; i < network_on; i++) { - SDL_Log("[NET] player[%d]: car=%d manual=%d started=%d%s\n", - i, Players_Cars[i], manual_control[i], player_started[i], - i == wConsoleNode ? " <-- self" : ""); + SDL_Log("[NET] player[%d]: car=%d manual=%d started=%d%s\n", i, + Players_Cars[i], manual_control[i], player_started[i], + i == wConsoleNode ? " <-- self" : ""); } // Initialize net_players array if (network_on > 0) { for (int i = 0; i < network_on; i++) { - net_players[i] = -1; // 0xFFFFFFFF + net_players[i] = -1; // 0xFFFFFFFF } } } //------------------------------------------------------------------------------------------------- -//000517D0 -void SendPlayerInfo() -{ +// 000517D0 +void SendPlayerInfo() { tPlayerInfoPacket playerInfo; // [esp+0h] [ebp-44h] BYREF if (network_on) { - //setup playerInfo packet + // setup playerInfo packet name_copy(playerInfo.szPlayerName, player_names[player1_car]); playerInfo.iPlayerCar = Players_Cars[player1_car]; playerInfo.iTrackLoad = TrackLoad; @@ -1850,43 +1907,43 @@ void SendPlayerInfo() if (player_invul[player1_car]) playerInfo.iDamageLevel |= 0x00000040; playerInfo.iManualControl = manual_control[player1_car]; - - //setup header + + // setup header p_header.byConsoleNode = (uint8)wConsoleNode; p_header.uiId = PACKET_ID_PLAYER_INFO; - //send to all nodes + // send to all nodes for (int i = 0; i < network_on; ++i) { if (wConsoleNode != i) { - while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &playerInfo, sizeof(tPlayerInfoPacket), i)) - UpdateSDL(); //added by ROLLER + while (!ROLLERCommsSendData(&p_header, sizeof(tSyncHeader), &playerInfo, + sizeof(tPlayerInfoPacket), i)) + UpdateSDL(); // added by ROLLER } } } } //------------------------------------------------------------------------------------------------- -//000518F0 -void prepare_net_message(int iMessageMode, int iMessageNumber) -{ +// 000518F0 +void prepare_net_message(int iMessageMode, int iMessageNumber) { message_node = iMessageMode; message_number = iMessageNumber; } //------------------------------------------------------------------------------------------------- -//00051900 -void SendAMessage() -{ - int iNode; // [esp+4h] [ebp-4Ch] +// 00051900 +void SendAMessage() { + int iNode; // [esp+4h] [ebp-4Ch] tMessagePacket messagePacket; // [esp+8h] [ebp-48h] BYREF - tSyncHeader syncHeader; // [esp+38h] [ebp-18h] BYREF + tSyncHeader syncHeader; // [esp+38h] [ebp-18h] BYREF if (!broadcast_mode && send_message_to >= 0) { syncHeader.byConsoleNode = ROLLERCommsNetAddrToNode(address); syncHeader.uiId = PACKET_ID_MESSAGE; name_copy(messagePacket.szPlayerName, player_names[player1_car]); - strncpy(messagePacket.szMessage, rec_mes_buf, sizeof(messagePacket.szMessage)); + strncpy(messagePacket.szMessage, rec_mes_buf, + sizeof(messagePacket.szMessage)); messagePacket.iNetworkSlot = network_slot; @@ -1895,7 +1952,8 @@ void SendAMessage() else iNode = 21; - if (ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &messagePacket, sizeof(tMessagePacket), iNode)) + if (ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &messagePacket, + sizeof(tMessagePacket), iNode)) send_status = 18; else send_status = -18; @@ -1904,25 +1962,23 @@ void SendAMessage() } //------------------------------------------------------------------------------------------------- -//00051A30 -void BroadcastNews() -{ - int iInitSuccess8; // eax - int iInitSuccess7; // eax - int iInitSuccess6; // eax - int j; // eax - int iInitSuccess5; // eax - int iInitSuccess4; // eax - int i; // eax - int iInitSuccess3; // eax - int iInitSuccess2; // eax - int iInitSuccess10; // eax +// 00051A30 +void BroadcastNews() { + int iInitSuccess8; // eax + int iInitSuccess7; // eax + int iInitSuccess6; // eax + int j; // eax + int iInitSuccess5; // eax + int iInitSuccess4; // eax + int i; // eax + int iInitSuccess3; // eax + int iInitSuccess2; // eax + int iInitSuccess10; // eax int iOldTimeToStart; // edx - int iInitSuccess9; // eax - int iInitSuccess; // eax + int iInitSuccess9; // eax + int iInitSuccess; // eax - if (!broadcast_mode) - { + if (!broadcast_mode) { PulseLobbyDiscovery(); return; } @@ -2075,32 +2131,32 @@ void BroadcastNews() } //------------------------------------------------------------------------------------------------- -//00051E20 -void remove_messages(int iClear) -{ - //uint8 buffer[4]; // [esp-Ch] [ebp-10h] BYREF +// 00051E20 +void remove_messages(int iClear) { + // uint8 buffer[4]; // [esp-Ch] [ebp-10h] BYREF void *pPacketData; - + // first message processing loop do { - ROLLERCommsPostListen(); // check for incoming messages - UpdateSDL(); //added by ROLLER - } while (ROLLERCommsGetHeader(&in_header, sizeof(tSyncHeader), &pPacketData));// continue until there are no more messages - + ROLLERCommsPostListen(); // check for incoming messages + UpdateSDL(); // added by ROLLER + } while (ROLLERCommsGetHeader( + &in_header, sizeof(tSyncHeader), + &pPacketData)); // continue until there are no more messages + // additional clearing if condition is true if (iClear) { while (ROLLERCommsPostListen()) - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER } clear_network_game(); } //------------------------------------------------------------------------------------------------- -//00051E60 -void reset_network(int iResetBroadcastMode) -{ +// 00051E60 +void reset_network(int iResetBroadcastMode) { int iNode; // edx - int i; // edx + int i; // edx iNode = 0; gamers_playing[0] = 0; @@ -2167,13 +2223,11 @@ void reset_network(int iResetBroadcastMode) } //------------------------------------------------------------------------------------------------- -//00052060 -void clear_network_game() -{ +// 00052060 +void clear_network_game() { for (int iPlayer = 0; iPlayer < 16; ++iPlayer) { player_ready[iPlayer] = 0; - for (int iRow = 0; iRow < 512; iRow++) - { + for (int iRow = 0; iRow < 512; iRow++) { player_checks[iRow][iPlayer] = -1; } } @@ -2181,9 +2235,8 @@ void clear_network_game() } //------------------------------------------------------------------------------------------------- -//000520D0 -void reset_net_wait() -{ +// 000520D0 +void reset_net_wait() { for (int i = 0; i < 16; ++i) { player_started[i] = 0; } @@ -2193,9 +2246,8 @@ void reset_net_wait() } //------------------------------------------------------------------------------------------------- -//00052130 -unsigned int send_broadcast(unsigned int uiBroadcastMode) -{ +// 00052130 +unsigned int send_broadcast(unsigned int uiBroadcastMode) { uint32 uiOldTimeToStart; if (uiBroadcastMode < 0xFFFFFE38) { @@ -2229,12 +2281,11 @@ unsigned int send_broadcast(unsigned int uiBroadcastMode) } //------------------------------------------------------------------------------------------------- -//000521D0 -void send_here(int iNode, int iFrame) -{ - int i; // esi +// 000521D0 +void send_here(int iNode, int iFrame) { + int i; // esi tSyncHeader syncHeader; // [esp+0h] [ebp-1Ch] BYREF - int iData; // [esp+Ch] [ebp-10h] BYREF + int iData; // [esp+Ch] [ebp-10h] BYREF if (network_on) { syncHeader.byConsoleNode = iNode; @@ -2243,11 +2294,13 @@ void send_here(int iNode, int iFrame) if (iNode == master) { for (i = 0; i < network_on; ++i) { if (i != master) { - ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &iData, sizeof(int), i); + ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &iData, + sizeof(int), i); } } } else { - ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &iData, sizeof(int), master); + ROLLERCommsSendData(&syncHeader, sizeof(tSyncHeader), &iData, sizeof(int), + master); } } } diff --git a/PROJECTS/ROLLER/network.h b/PROJECTS/ROLLER/network.h index 49f774fe..88aefe50 100644 --- a/PROJECTS/ROLLER/network.h +++ b/PROJECTS/ROLLER/network.h @@ -5,29 +5,28 @@ //------------------------------------------------------------------------------------------------- #define PACKET_ID_TRANSMIT_INIT 0x686C6361 -#define PACKET_ID_SEND_MES 0x686C6363 -#define PACKET_ID_QUIT 0x686C6364 -#define PACKET_ID_SINGLE 0x686C6365 -#define PACKET_ID_PLAYER_CARS 0x686C6366 -#define PACKET_ID_READY 0x686C6367 -#define PACKET_ID_SEED 0x686C6368 -#define PACKET_ID_PAUSE 0x686C6369 -#define PACKET_ID_PLAYER_INFO 0x686C636A -#define PACKET_ID_RECORD 0x686C636B -#define PACKET_ID_NET_ERROR 0x686C636C -#define PACKET_ID_SYNC_ERROR 0x686C636D -#define PACKET_ID_GAME_ERROR 0x686C636E -#define PACKET_ID_NOCD 0x686C636F -#define PACKET_ID_RESYNC 0x686C6370 -#define PACKET_ID_SLOT 0x686C6371 -#define PACKET_ID_SEND_HERE 0x686C6372 -#define PACKET_ID_MESSAGE 0x686C6373 -#define PACKET_ID_MULTIPLE 0x686C6374 +#define PACKET_ID_SEND_MES 0x686C6363 +#define PACKET_ID_QUIT 0x686C6364 +#define PACKET_ID_SINGLE 0x686C6365 +#define PACKET_ID_PLAYER_CARS 0x686C6366 +#define PACKET_ID_READY 0x686C6367 +#define PACKET_ID_SEED 0x686C6368 +#define PACKET_ID_PAUSE 0x686C6369 +#define PACKET_ID_PLAYER_INFO 0x686C636A +#define PACKET_ID_RECORD 0x686C636B +#define PACKET_ID_NET_ERROR 0x686C636C +#define PACKET_ID_SYNC_ERROR 0x686C636D +#define PACKET_ID_GAME_ERROR 0x686C636E +#define PACKET_ID_NOCD 0x686C636F +#define PACKET_ID_RESYNC 0x686C6370 +#define PACKET_ID_SLOT 0x686C6371 +#define PACKET_ID_SEND_HERE 0x686C6372 +#define PACKET_ID_MESSAGE 0x686C6373 +#define PACKET_ID_MULTIPLE 0x686C6374 //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint32 uiUnk1; uint32 uiId; uint8 byConsoleNode; @@ -39,9 +38,9 @@ typedef struct typedef struct { int32 address[4]; char szPlayerName[9]; - //padding byte - //padding byte - //padding byte + // padding byte + // padding byte + // padding byte int32 iNetworkOn; int32 iMyAge; int32 iCarIdx; @@ -62,22 +61,20 @@ typedef struct { //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fRecordLap; char szRecordName[9]; - //padding byte + // padding byte uint16 unRecordCar; } tRecordPacket; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { char szPlayerName[9]; - //padding byte - //padding byte - //padding byte + // padding byte + // padding byte + // padding byte int iPlayerCar; int iTrackLoad; int iGameType; @@ -89,21 +86,19 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { char szMessage[32]; char szPlayerName[9]; - //padding byte - //padding byte - //padding byte + // padding byte + // padding byte + // padding byte int iNetworkSlot; } tMessagePacket; //------------------------------------------------------------------------------------------------- #pragma pack(push, 1) -typedef struct -{ +typedef struct { uint32 uiData; int16 nChecksum; } tDataPacket; @@ -111,25 +106,21 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint8 bNode[16]; } _NETBIOS_LOCAL_TARGET; -typedef struct -{ +typedef struct { uint8 bNetwork[4]; uint8 bNode[6]; } _IPX_INTERNET_ADDR; -typedef struct -{ +typedef struct { _IPX_INTERNET_ADDR sInternetAddr; uint8 bImmediate[6]; } _IPX_LOCAL_TARGET; -typedef union -{ +typedef union { _IPX_LOCAL_TARGET sIPX; _NETBIOS_LOCAL_TARGET sNETBIOS; } _NETNOW_NODE_ADDR; diff --git a/PROJECTS/ROLLER/plans.c b/PROJECTS/ROLLER/plans.c index 7a6be166..b86e422e 100644 --- a/PROJECTS/ROLLER/plans.c +++ b/PROJECTS/ROLLER/plans.c @@ -1,677 +1,517 @@ #include "plans.h" //------------------------------------------------------------------------------------------------- -//000ADAFC -tVec3 tower_coords[8] = -{ - { -1030.8831f, -997.65601f, -432.27701f }, - { 1030.8831f, -997.65601f, -432.27701f }, - { 1030.8831f, -997.65601f, 8214.1992f }, - { -1030.8831f, -997.65601f, 8214.1992f }, - { -1030.8831f, 997.65601f, -432.27701f }, - { 1030.8831f, 997.65601f, -432.27701f }, - { 1030.8831f, 997.65601f, 8214.1992f }, - { -1030.8831f, 997.65601f, 8214.1992f } -}; +// 000ADAFC +tVec3 tower_coords[8] = {{-1030.8831f, -997.65601f, -432.27701f}, + {1030.8831f, -997.65601f, -432.27701f}, + {1030.8831f, -997.65601f, 8214.1992f}, + {-1030.8831f, -997.65601f, 8214.1992f}, + {-1030.8831f, 997.65601f, -432.27701f}, + {1030.8831f, 997.65601f, -432.27701f}, + {1030.8831f, 997.65601f, 8214.1992f}, + {-1030.8831f, 997.65601f, 8214.1992f}}; //------------------------------------------------------------------------------------------------- -//000ADB5C -tPolygon tower_pols[5] = -{ - { { 2u, 3u, 0u, 1u }, 512u, 0, 0u }, - { { 6u, 2u, 1u, 5u }, 512u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 47u, 0, 0u }, - { { 3u, 7u, 4u, 0u }, 512u, 0, 0u }, - { { 7u, 6u, 5u, 4u }, 512u, 0, 0u } -}; +// 000ADB5C +tPolygon tower_pols[5] = {{{2u, 3u, 0u, 1u}, 512u, 0, 0u}, + {{6u, 2u, 1u, 5u}, 512u, 0, 0u}, + {{2u, 6u, 7u, 3u}, 47u, 0, 0u}, + {{3u, 7u, 4u, 0u}, 512u, 0, 0u}, + {{7u, 6u, 5u, 4u}, 512u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000ADB98 -unsigned int tower_backs[5] = { 0, 0, 0, 0, 0 }; +// 000ADB98 +unsigned int tower_backs[5] = {0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000ADBAC -tAnimation tower_anms[4] = -{ - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000ADBAC +tAnimation tower_anms[4] = { + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000ADCBC -tVec3 tower2_coords[8] = -{ - { -1030.8831f, -997.65601f, 0.046999998f }, - { 1030.8831f, -997.65601f, 0.046999998f }, - { 1030.8831f, -997.65601f, 8646.5234f }, - { -1030.8831f, -997.65601f, 8646.5234f }, - { -1030.8831f, 997.65601f, 0.046999998f }, - { 1030.8831f, 997.65601f, 0.046999998f }, - { 1030.8831f, 997.65601f, 8646.5234f }, - { -1030.8831f, 997.65601f, 8646.5234f } -}; +// 000ADCBC +tVec3 tower2_coords[8] = {{-1030.8831f, -997.65601f, 0.046999998f}, + {1030.8831f, -997.65601f, 0.046999998f}, + {1030.8831f, -997.65601f, 8646.5234f}, + {-1030.8831f, -997.65601f, 8646.5234f}, + {-1030.8831f, 997.65601f, 0.046999998f}, + {1030.8831f, 997.65601f, 0.046999998f}, + {1030.8831f, 997.65601f, 8646.5234f}, + {-1030.8831f, 997.65601f, 8646.5234f}}; //------------------------------------------------------------------------------------------------- -//000ADD1C -tPolygon tower2_pols[5] = -{ - { { 0u, 1u, 2u, 3u }, 278u, 0, 0u }, - { { 1u, 5u, 6u, 2u }, 278u, 0, 0u }, - { { 7u, 3u, 2u, 6u }, 278u, 0, 0u }, - { { 4u, 0u, 3u, 7u }, 278u, 0, 0u }, - { { 5u, 4u, 7u, 6u }, 278u, 0, 0u } -}; +// 000ADD1C +tPolygon tower2_pols[5] = {{{0u, 1u, 2u, 3u}, 278u, 0, 0u}, + {{1u, 5u, 6u, 2u}, 278u, 0, 0u}, + {{7u, 3u, 2u, 6u}, 278u, 0, 0u}, + {{4u, 0u, 3u, 7u}, 278u, 0, 0u}, + {{5u, 4u, 7u, 6u}, 278u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000ADD58 -unsigned int tower2_backs[5] = { 0, 0, 0, 0, 0 }; +// 000ADD58 +unsigned int tower2_backs[5] = {0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000ADD6C -tVec3 sign01_coords[8] = -{ - { 0.0f, -246.666f, 362.43301f }, - { 0.0f, 243.047f, 362.43301f }, - { 0.0f, 243.047f, 581.84497f }, - { 0.0f, -246.666f, 581.84497f }, - { 0.0f, -33.169998f, -8.3240004f }, - { 0.0f, 36.789001f, -8.3240004f }, - { 0.0f, 36.789001f, 362.41699f }, - { 0.0f, -33.169998f, 362.41699f } -}; +// 000ADD6C +tVec3 sign01_coords[8] = { + {0.0f, -246.666f, 362.43301f}, {0.0f, 243.047f, 362.43301f}, + {0.0f, 243.047f, 581.84497f}, {0.0f, -246.666f, 581.84497f}, + {0.0f, -33.169998f, -8.3240004f}, {0.0f, 36.789001f, -8.3240004f}, + {0.0f, 36.789001f, 362.41699f}, {0.0f, -33.169998f, 362.41699f}}; //------------------------------------------------------------------------------------------------- -//000ADDCC -tPolygon sign01_pols[2] = -{ - { { 3u, 2u, 1u, 0u }, 8704u, 0, 0u }, - { { 4u, 7u, 6u, 5u }, 8468u, 0, 0u } -}; +// 000ADDCC +tPolygon sign01_pols[2] = {{{3u, 2u, 1u, 0u}, 8704u, 0, 0u}, + {{4u, 7u, 6u, 5u}, 8468u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000ADDE4 -unsigned int sign01_backs[2] = { 0, 0 }; +// 000ADDE4 +unsigned int sign01_backs[2] = {0, 0}; //------------------------------------------------------------------------------------------------- -//000ADDEC -tAnimation sign01_anms[1] = -{ 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }; +// 000ADDEC +tAnimation sign01_anms[1] = { + 0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}; //------------------------------------------------------------------------------------------------- -//000ADE30 -tVec3 sign02_coords[12] = -{ - { 0.0f, -280.96201f, -3.171f }, - { 0.0f, -167.121f, -3.171f }, - { 0.0f, -167.121f, 315.582f }, - { 0.0f, -280.96201f, 315.582f }, - { 0.0f, -335.98001f, 315.22198f }, - { 0.0f, 328.54599f, 315.22198f }, - { 0.0f, 328.54599f, 804.479f }, - { 0.0f, -335.98001f, 804.479f }, - { 0.0f, 170.838f, -3.171f }, - { 0.0f, 284.67899f, -3.171f }, - { 0.0f, 284.67899f, 315.582f }, - { 0.0f, 170.838f, 315.582f } -}; +// 000ADE30 +tVec3 sign02_coords[12] = { + {0.0f, -280.96201f, -3.171f}, {0.0f, -167.121f, -3.171f}, + {0.0f, -167.121f, 315.582f}, {0.0f, -280.96201f, 315.582f}, + {0.0f, -335.98001f, 315.22198f}, {0.0f, 328.54599f, 315.22198f}, + {0.0f, 328.54599f, 804.479f}, {0.0f, -335.98001f, 804.479f}, + {0.0f, 170.838f, -3.171f}, {0.0f, 284.67899f, -3.171f}, + {0.0f, 284.67899f, 315.582f}, {0.0f, 170.838f, 315.582f}}; //------------------------------------------------------------------------------------------------- -//000ADEC0 -tPolygon sign02_pols[3] = -{ - { { 0u, 3u, 2u, 1u }, 270613u, 0, 0u }, - { { 7u, 6u, 5u, 4u }, 8704u, 0, 0u }, - { { 8u, 11u, 10u, 9u }, 8469u, 0, 0u } -}; +// 000ADEC0 +tPolygon sign02_pols[3] = {{{0u, 3u, 2u, 1u}, 270613u, 0, 0u}, + {{7u, 6u, 5u, 4u}, 8704u, 0, 0u}, + {{8u, 11u, 10u, 9u}, 8469u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000ADEE4 -unsigned int sign02_backs[3] = { 0, 0, 0 }; +// 000ADEE4 +unsigned int sign02_backs[3] = {0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000ADEF0 -tAnimation sign02_anms[1] = -{ 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }; +// 000ADEF0 +tAnimation sign02_anms[1] = { + 0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}; //------------------------------------------------------------------------------------------------- -//000ADF34 -tVec3 build_coords[14] = -{ - { 2683.0959f, -2933.0029f, -10.578f }, - { 399.05399f, -2933.0029f, -10.578f }, - { 399.05899f, -2933.0029f, 8558.9893f }, - { 2683.0959f, -2933.0029f, 8558.9873f }, - { -4422.585f, 10093.194f, -10.576f }, - { -4422.5801f, 10093.207f, 8558.9893f }, - { 2680.8601f, 2938.864f, 1348.897f }, - { 2680.8601f, -2935.7109f, 1348.897f }, - { -4422.585f, -10090.117f, -10.576f }, - { -4422.5801f, -10090.13f, 8558.9893f }, - { 2683.0959f, 2930.678f, -10.578f }, - { 399.05399f, 2930.6741f, -10.578f }, - { 399.05899f, 2930.6741f, 8558.9893f }, - { 2683.0959f, 2930.678f, 8558.9873f } -}; +// 000ADF34 +tVec3 build_coords[14] = {{2683.0959f, -2933.0029f, -10.578f}, + {399.05399f, -2933.0029f, -10.578f}, + {399.05899f, -2933.0029f, 8558.9893f}, + {2683.0959f, -2933.0029f, 8558.9873f}, + {-4422.585f, 10093.194f, -10.576f}, + {-4422.5801f, 10093.207f, 8558.9893f}, + {2680.8601f, 2938.864f, 1348.897f}, + {2680.8601f, -2935.7109f, 1348.897f}, + {-4422.585f, -10090.117f, -10.576f}, + {-4422.5801f, -10090.13f, 8558.9893f}, + {2683.0959f, 2930.678f, -10.578f}, + {399.05399f, 2930.6741f, -10.578f}, + {399.05899f, 2930.6741f, 8558.9893f}, + {2683.0959f, 2930.678f, 8558.9873f}}; //------------------------------------------------------------------------------------------------- -//000ADFDC -tPolygon build_pols[5] = -{ - { { 2u, 3u, 0u, 1u }, 277u, 0, 0u }, - { { 12u, 5u, 4u, 11u }, 276u, 0, 0u }, - { { 3u, 13u, 6u, 7u }, 276u, 0, 0u }, - { { 9u, 2u, 1u, 8u }, 276u, 0, 0u }, - { { 13u, 12u, 11u, 10u }, 277u, 0, 0u } -}; +// 000ADFDC +tPolygon build_pols[5] = {{{2u, 3u, 0u, 1u}, 277u, 0, 0u}, + {{12u, 5u, 4u, 11u}, 276u, 0, 0u}, + {{3u, 13u, 6u, 7u}, 276u, 0, 0u}, + {{9u, 2u, 1u, 8u}, 276u, 0, 0u}, + {{13u, 12u, 11u, 10u}, 277u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE018 -unsigned int build_backs[5] = { 0, 0, 0, 0, 0 }; +// 000AE018 +unsigned int build_backs[5] = {0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AE02C -tVec3 build1_coords[12] = -{ - { -3990.8159f, 6487.0308f, 10431.105f }, - { 1186.108f, 371.841f, 10431.105f }, - { 2269.0f, 1288.573f, 10431.105f }, - { -2907.8979f, 7403.791f, 10431.105f }, - { -3990.8159f, 6487.0308f, 0.0f }, - { 1186.108f, 371.841f, 0.0f }, - { 2269.0f, 1288.573f, 0.0f }, - { -2907.8979f, 7403.791f, 0.0f }, - { 1186.776f, -7775.6318f, 10431.105f }, - { 2256.8279f, -7775.6318f, 10431.105f }, - { 1186.776f, -7775.6318f, 0.0f }, - { 2256.8279f, -7775.6318f, 0.0f } -}; +// 000AE02C +tVec3 build1_coords[12] = {{-3990.8159f, 6487.0308f, 10431.105f}, + {1186.108f, 371.841f, 10431.105f}, + {2269.0f, 1288.573f, 10431.105f}, + {-2907.8979f, 7403.791f, 10431.105f}, + {-3990.8159f, 6487.0308f, 0.0f}, + {1186.108f, 371.841f, 0.0f}, + {2269.0f, 1288.573f, 0.0f}, + {-2907.8979f, 7403.791f, 0.0f}, + {1186.776f, -7775.6318f, 10431.105f}, + {2256.8279f, -7775.6318f, 10431.105f}, + {1186.776f, -7775.6318f, 0.0f}, + {2256.8279f, -7775.6318f, 0.0f}}; //------------------------------------------------------------------------------------------------- -//000AE0BC -tPolygon build1_pols[10] = -{ - { { 0u, 4u, 5u, 1u }, 256u, 0, 0u }, - { { 2u, 1u, 5u, 6u }, 256u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 256u, 0, 0u }, - { { 3u, 7u, 4u, 0u }, 256u, 0, 0u }, - { { 4u, 7u, 6u, 5u }, 20u, 0, 0u }, - { { 1u, 5u, 10u, 8u }, 256u, 0, 0u }, - { { 8u, 10u, 11u, 9u }, 256u, 0, 0u }, - { { 9u, 11u, 6u, 2u }, 256u, 0, 0u }, - { { 2u, 6u, 5u, 1u }, 256u, 0, 0u }, - { { 5u, 6u, 11u, 10u }, 256u, 0, 0u } -}; +// 000AE0BC +tPolygon build1_pols[10] = { + {{0u, 4u, 5u, 1u}, 256u, 0, 0u}, {{2u, 1u, 5u, 6u}, 256u, 0, 0u}, + {{2u, 6u, 7u, 3u}, 256u, 0, 0u}, {{3u, 7u, 4u, 0u}, 256u, 0, 0u}, + {{4u, 7u, 6u, 5u}, 20u, 0, 0u}, {{1u, 5u, 10u, 8u}, 256u, 0, 0u}, + {{8u, 10u, 11u, 9u}, 256u, 0, 0u}, {{9u, 11u, 6u, 2u}, 256u, 0, 0u}, + {{2u, 6u, 5u, 1u}, 256u, 0, 0u}, {{5u, 6u, 11u, 10u}, 256u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE134 -unsigned int build1_backs[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000AE134 +unsigned int build1_backs[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AE15C -tVec3 build2_coords[12] = -{ - { -6825.6519f, 11095.023f, 17840.732f }, - { 2028.651f, 635.974f, 17840.732f }, - { 3880.7581f, 2203.897f, 17840.732f }, - { -4973.4922f, 12662.997f, 17840.732f }, - { -6825.6519f, 11095.023f, 0.0f }, - { 2028.651f, 635.974f, 0.0f }, - { 3880.7581f, 2203.897f, 0.0f }, - { -4973.4922f, 12662.997f, 0.0f }, - { 2029.787f, -13298.971f, 17840.732f }, - { 3859.9441f, -13298.971f, 17840.732f }, - { 2029.787f, -13298.971f, 0.0f }, - { 3859.9441f, -13298.971f, 0.0f } -}; +// 000AE15C +tVec3 build2_coords[12] = {{-6825.6519f, 11095.023f, 17840.732f}, + {2028.651f, 635.974f, 17840.732f}, + {3880.7581f, 2203.897f, 17840.732f}, + {-4973.4922f, 12662.997f, 17840.732f}, + {-6825.6519f, 11095.023f, 0.0f}, + {2028.651f, 635.974f, 0.0f}, + {3880.7581f, 2203.897f, 0.0f}, + {-4973.4922f, 12662.997f, 0.0f}, + {2029.787f, -13298.971f, 17840.732f}, + {3859.9441f, -13298.971f, 17840.732f}, + {2029.787f, -13298.971f, 0.0f}, + {3859.9441f, -13298.971f, 0.0f}}; //------------------------------------------------------------------------------------------------- -//000AE1EC -tPolygon build2_pols[10] = -{ - { { 0u, 4u, 5u, 1u }, 276u, 0, 0u }, - { { 2u, 1u, 5u, 6u }, 276u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 276u, 0, 0u }, - { { 3u, 7u, 4u, 0u }, 276u, 0, 0u }, - { { 4u, 7u, 6u, 5u }, 20u, 0, 0u }, - { { 1u, 5u, 10u, 8u }, 276u, 0, 0u }, - { { 8u, 10u, 11u, 9u }, 276u, 0, 0u }, - { { 9u, 11u, 6u, 2u }, 276u, 0, 0u }, - { { 2u, 6u, 5u, 1u }, 276u, 0, 0u }, - { { 5u, 6u, 11u, 10u }, 276u, 0, 0u } -}; +// 000AE1EC +tPolygon build2_pols[10] = { + {{0u, 4u, 5u, 1u}, 276u, 0, 0u}, {{2u, 1u, 5u, 6u}, 276u, 0, 0u}, + {{2u, 6u, 7u, 3u}, 276u, 0, 0u}, {{3u, 7u, 4u, 0u}, 276u, 0, 0u}, + {{4u, 7u, 6u, 5u}, 20u, 0, 0u}, {{1u, 5u, 10u, 8u}, 276u, 0, 0u}, + {{8u, 10u, 11u, 9u}, 276u, 0, 0u}, {{9u, 11u, 6u, 2u}, 276u, 0, 0u}, + {{2u, 6u, 5u, 1u}, 276u, 0, 0u}, {{5u, 6u, 11u, 10u}, 276u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE264 -unsigned int build2_backs[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +// 000AE264 +unsigned int build2_backs[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AE28C -tVec3 build3_coords[8] = -{ - { -817.40002f, 7712.064f, 497.573f }, - { -817.40002f, -7712.064f, 497.573f }, - { 817.40002f, -7712.064f, 497.573f }, - { 817.40002f, 7712.064f, 497.573f }, - { -817.40002f, 7712.064f, 0.0f }, - { -817.40002f, -7712.064f, 0.0f }, - { 817.40002f, -7712.064f, 0.0f }, - { 817.40002f, 7712.064f, 0.0f } -}; +// 000AE28C +tVec3 build3_coords[8] = { + {-817.40002f, 7712.064f, 497.573f}, {-817.40002f, -7712.064f, 497.573f}, + {817.40002f, -7712.064f, 497.573f}, {817.40002f, 7712.064f, 497.573f}, + {-817.40002f, 7712.064f, 0.0f}, {-817.40002f, -7712.064f, 0.0f}, + {817.40002f, -7712.064f, 0.0f}, {817.40002f, 7712.064f, 0.0f}}; //------------------------------------------------------------------------------------------------- -//000AE2EC -tPolygon build3_pols[3] = -{ - { { 0u, 4u, 5u, 1u }, 512u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 512u, 0, 0u }, - { { 4u, 7u, 6u, 5u }, 512u, 0, 0u } -}; +// 000AE2EC +tPolygon build3_pols[3] = {{{0u, 4u, 5u, 1u}, 512u, 0, 0u}, + {{2u, 6u, 7u, 3u}, 512u, 0, 0u}, + {{4u, 7u, 6u, 5u}, 512u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE310 -unsigned int build3_backs[3] = { 0, 0, 0 }; +// 000AE310 +unsigned int build3_backs[3] = {0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AE31C -tAnimation build3_anms[3] = -{ - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000AE31C +tAnimation build3_anms[3] = { + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000AE3E8 -tVec3 heelbar_coords[8] = -{ - { -630.48798f, -794.495f, -194.396f }, - { 630.48798f, -794.495f, -194.396f }, - { 630.48798f, -794.495f, 1101.626f }, - { -630.48798f, -794.495f, 1101.626f }, - { -630.48798f, 794.495f, -194.396f }, - { 630.48798f, 794.495f, -194.396f }, - { 630.48798f, 794.495f, 1101.626f }, - { -630.48798f, 794.495f, 1101.626f } -}; +// 000AE3E8 +tVec3 heelbar_coords[8] = { + {-630.48798f, -794.495f, -194.396f}, {630.48798f, -794.495f, -194.396f}, + {630.48798f, -794.495f, 1101.626f}, {-630.48798f, -794.495f, 1101.626f}, + {-630.48798f, 794.495f, -194.396f}, {630.48798f, 794.495f, -194.396f}, + {630.48798f, 794.495f, 1101.626f}, {-630.48798f, 794.495f, 1101.626f}}; //------------------------------------------------------------------------------------------------- -//000AE448 -tPolygon heelbar_pols[5] = -{ - { { 2u, 3u, 0u, 1u }, 264u, 0, 0u }, - { { 6u, 2u, 1u, 5u }, 264u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 47u, 0, 0u }, - { { 3u, 7u, 4u, 0u }, 264u, 0, 0u }, - { { 7u, 6u, 5u, 4u }, 264u, 0, 0u } -}; +// 000AE448 +tPolygon heelbar_pols[5] = {{{2u, 3u, 0u, 1u}, 264u, 0, 0u}, + {{6u, 2u, 1u, 5u}, 264u, 0, 0u}, + {{2u, 6u, 7u, 3u}, 47u, 0, 0u}, + {{3u, 7u, 4u, 0u}, 264u, 0, 0u}, + {{7u, 6u, 5u, 4u}, 264u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE484 -unsigned int heelbar_backs[5] = { 0, 0, 0, 0, 0 }; +// 000AE484 +unsigned int heelbar_backs[5] = {0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AE498 -tVec3 balloon_coords[4] = -{ - { 0.0f, 846.76703f, -84.984001f }, - { 0.0f, -846.76703f, -84.984001f }, - { 0.0f, -846.76703f, 1614.759f }, - { 0.0f, 846.76703f, 1614.759f } -}; +// 000AE498 +tVec3 balloon_coords[4] = {{0.0f, 846.76703f, -84.984001f}, + {0.0f, -846.76703f, -84.984001f}, + {0.0f, -846.76703f, 1614.759f}, + {0.0f, 846.76703f, 1614.759f}}; //------------------------------------------------------------------------------------------------- -//000AE4C8 -tPolygon balloon_pols[1] = -{ - { { 2u, 3u, 0u, 1u }, 8704u, 0, 0u } -}; +// 000AE4C8 +tPolygon balloon_pols[1] = {{{2u, 3u, 0u, 1u}, 8704u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE4D4 -tVec3 balloon2_coords[4] = -{ - { 0.0f, 1520.672f, -152.619f }, - { 0.0f, -1520.672f, -152.619f }, - { 0.0f, -1520.672f, 2899.875f }, - { 0.0f, 1520.672f, 2899.875f } -}; +// 000AE4D4 +tVec3 balloon2_coords[4] = {{0.0f, 1520.672f, -152.619f}, + {0.0f, -1520.672f, -152.619f}, + {0.0f, -1520.672f, 2899.875f}, + {0.0f, 1520.672f, 2899.875f}}; //------------------------------------------------------------------------------------------------- -//000AE504 -tPolygon balloon2_pols[1] = -{ - { { 2u, 3u, 0u, 1u }, 8704u, 0, 0u } -}; +// 000AE504 +tPolygon balloon2_pols[1] = {{{2u, 3u, 0u, 1u}, 8704u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE510 -unsigned int balloon2_backs[1] = { 0 }; +// 000AE510 +unsigned int balloon2_backs[1] = {0}; //------------------------------------------------------------------------------------------------- -//000AE514 -tAnimation balloon2_anms[1] = -{ 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }; +// 000AE514 +tAnimation balloon2_anms[1] = { + 0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE558 -tVec3 tree_coords[4] = -{ - { 0.0f, 372.30099f, 0.003f }, - { 0.0f, -372.30099f, 0.003f }, - { 0.0f, -372.30099f, 1712.558f }, - { 0.0f, 372.30099f, 1712.558f } -}; +// 000AE558 +tVec3 tree_coords[4] = {{0.0f, 372.30099f, 0.003f}, + {0.0f, -372.30099f, 0.003f}, + {0.0f, -372.30099f, 1712.558f}, + {0.0f, 372.30099f, 1712.558f}}; //------------------------------------------------------------------------------------------------- -//000AE588 -tPolygon tree_pols[1] = -{ - { { 2u, 3u, 0u, 1u }, 9473u, 0, 0u } -}; +// 000AE588 +tPolygon tree_pols[1] = {{{2u, 3u, 0u, 1u}, 9473u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE594 -unsigned int tree_backs[1] = { 0 }; +// 000AE594 +unsigned int tree_backs[1] = {0}; //------------------------------------------------------------------------------------------------- -//000AE598 -tVec3 advert_coords[8] = -{ - { 24.461f, -378.76199f, 0.0080000004f }, - { 24.461f, 378.76199f, 0.0080000004f }, - { 24.461f, 378.76199f, 525.48901f }, - { 24.461f, -378.76199f, 525.48901f }, - { -24.461f, -378.76199f, 0.0080000004f }, - { -24.461f, 378.76199f, 0.0080000004f }, - { -24.461f, 378.76199f, 525.48901f }, - { -24.461f, -378.76199f, 525.48901f } -}; +// 000AE598 +tVec3 advert_coords[8] = {{24.461f, -378.76199f, 0.0080000004f}, + {24.461f, 378.76199f, 0.0080000004f}, + {24.461f, 378.76199f, 525.48901f}, + {24.461f, -378.76199f, 525.48901f}, + {-24.461f, -378.76199f, 0.0080000004f}, + {-24.461f, 378.76199f, 0.0080000004f}, + {-24.461f, 378.76199f, 525.48901f}, + {-24.461f, -378.76199f, 525.48901f}}; //------------------------------------------------------------------------------------------------- -//000AE5F8 -tPolygon advert_pols[6] = -{ - { { 2u, 3u, 0u, 1u }, 512u, 0, 0u }, - { { 0u, 4u, 5u, 1u }, 122u, 0, 0u }, - { { 1u, 5u, 6u, 2u }, 124u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 122u, 0, 0u }, - { { 3u, 7u, 4u, 0u }, 124u, 0, 0u }, - { { 7u, 6u, 5u, 4u }, 512u, 0, 0u } -}; +// 000AE5F8 +tPolygon advert_pols[6] = { + {{2u, 3u, 0u, 1u}, 512u, 0, 0u}, {{0u, 4u, 5u, 1u}, 122u, 0, 0u}, + {{1u, 5u, 6u, 2u}, 124u, 0, 0u}, {{2u, 6u, 7u, 3u}, 122u, 0, 0u}, + {{3u, 7u, 4u, 0u}, 124u, 0, 0u}, {{7u, 6u, 5u, 4u}, 512u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE640 -unsigned int advert_backs[6] = { 0, 0, 0, 0, 0, 0 }; +// 000AE640 +unsigned int advert_backs[6] = {0, 0, 0, 0, 0, 0}; //------------------------------------------------------------------------------------------------- -//000AE658 -tAnimation advert_anms[2] = -{ - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }, - { 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } } -}; +// 000AE658 +tAnimation advert_anms[2] = { + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}, + {0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}}; //------------------------------------------------------------------------------------------------- -//000AE6E0 -tVec3 advert2_coords[4] = -{ - { 0.0f, 1520.672f, -152.619f }, - { 0.0f, -1520.672f, -152.619f }, - { 0.0f, -1520.672f, 2899.875f }, - { 0.0f, 1520.672f, 2899.875f } -}; +// 000AE6E0 +tVec3 advert2_coords[4] = {{0.0f, 1520.672f, -152.619f}, + {0.0f, -1520.672f, -152.619f}, + {0.0f, -1520.672f, 2899.875f}, + {0.0f, 1520.672f, 2899.875f}}; //------------------------------------------------------------------------------------------------- -//000AE710 -tPolygon advert2_pols[1] = -{ - { { 2u, 3u, 0u, 1u }, 8704u, 0, 0u } -}; +// 000AE710 +tPolygon advert2_pols[1] = {{{2u, 3u, 0u, 1u}, 8704u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE71C -unsigned int advert2_backs[1] = { 0 }; +// 000AE71C +unsigned int advert2_backs[1] = {0}; //------------------------------------------------------------------------------------------------- -//000AE720 -tAnimation advert2_anms[1] = -{ 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }; +// 000AE720 +tAnimation advert2_anms[1] = { + 0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE764 -tVec3 advert3_coords[4] = -{ - { 0.0f, 1520.672f, -100.242f }, - { 0.0f, -1520.672f, -100.242f }, - { 0.0f, -1520.672f, 1904.67f }, - { 0.0f, 1520.672f, 1904.67f } -}; +// 000AE764 +tVec3 advert3_coords[4] = {{0.0f, 1520.672f, -100.242f}, + {0.0f, -1520.672f, -100.242f}, + {0.0f, -1520.672f, 1904.67f}, + {0.0f, 1520.672f, 1904.67f}}; //------------------------------------------------------------------------------------------------- -//000AE794 -tPolygon advert3_pols[1] = -{ - { { 2u, 3u, 0u, 1u }, 8704u, 0, 0u } -}; +// 000AE794 +tPolygon advert3_pols[1] = {{{2u, 3u, 0u, 1u}, 8704u, 0, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE7A0 -unsigned int advert3_backs[1] = { 0 }; +// 000AE7A0 +unsigned int advert3_backs[1] = {0}; //------------------------------------------------------------------------------------------------- -//000AE7A4 -tAnimation advert3_anms[1] = -{ 0u, { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u } }; - -//------------------------------------------------------------------------------------------------- - -//000AE7E8 -tVec3 quadbld_coords[32] = -{ - { -564.95203f, 691.53802f, 14.749f }, - { -564.95203f, 2328.5281f, 14.749f }, - { -564.95203f, 2328.5281f, 6206.293f }, - { -564.95203f, 691.53802f, 6206.293f }, - { -2303.3689f, 691.53802f, 14.749f }, - { -2303.3689f, 2328.5281f, 14.749f }, - { -2303.3689f, 2328.5281f, 6206.293f }, - { -2303.3689f, 691.53802f, 6206.293f }, - { -513.54602f, -2328.5281f, -0.071000002f }, - { -513.54602f, -691.53802f, -0.071000002f }, - { -513.54602f, -691.53802f, 6191.7041f }, - { -513.54602f, -2328.5281f, 6191.7041f }, - { -2251.5681f, -2328.5281f, -0.071000002f }, - { -2251.5681f, -691.53802f, -0.071000002f }, - { -2251.5681f, -691.53802f, 6191.7041f }, - { -2251.5681f, -2328.5281f, 6191.7041f }, - { 2251.5681f, 691.53802f, 14.749f }, - { 2251.5681f, 2328.5281f, 14.749f }, - { 2251.5681f, 2328.5281f, 6206.293f }, - { 2251.5681f, 691.53802f, 6206.293f }, - { 513.54602f, 691.53802f, 14.749f }, - { 513.54602f, 2328.5281f, 14.749f }, - { 513.54602f, 2328.5281f, 6206.293f }, - { 513.54602f, 691.53802f, 6206.293f }, - { 2303.3689f, -2328.5281f, -0.071000002f }, - { 2303.3689f, -691.53802f, -0.071000002f }, - { 2303.3689f, -691.53802f, 6191.7041f }, - { 2303.3689f, -2328.5281f, 6191.7041f }, - { 564.95203f, -2328.5281f, -0.071000002f }, - { 564.95203f, -691.53802f, -0.071000002f }, - { 564.95203f, -691.53802f, 6191.7041f }, - { 564.95203f, -2328.5281f, 6191.7041f } -}; +// 000AE7A4 +tAnimation advert3_anms[1] = { + 0u, {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}}; //------------------------------------------------------------------------------------------------- -//000AE968 -tPolygon quadbld_pols[20] = -{ - { { 2u, 3u, 0u, 1u }, 282u, 0, 0u }, - { { 6u, 2u, 1u, 5u }, 282u, 0, 0u }, - { { 2u, 6u, 7u, 3u }, 68u, 0, 0u }, - { { 3u, 7u, 4u, 0u }, 282u, 0, 0u }, - { { 7u, 6u, 5u, 4u }, 282u, 0, 0u }, - { { 10u, 11u, 8u, 9u }, 279u, 0, 0u }, - { { 14u, 10u, 9u, 13u }, 279u, 0, 0u }, - { { 10u, 14u, 15u, 11u }, 68u, 0, 0u }, - { { 11u, 15u, 12u, 8u }, 279u, 0, 0u }, - { { 15u, 14u, 13u, 12u }, 279u, 0, 0u }, - { { 18u, 19u, 16u, 17u }, 280u, 0, 0u }, - { { 22u, 18u, 17u, 21u }, 280u, 0, 0u }, - { { 18u, 22u, 23u, 19u }, 68u, 0, 0u }, - { { 19u, 23u, 20u, 16u }, 280u, 0, 0u }, - { { 23u, 22u, 21u, 20u }, 280u, 0, 0u }, - { { 26u, 27u, 24u, 25u }, 281u, 0, 0u }, - { { 30u, 26u, 25u, 29u }, 281u, 0, 0u }, - { { 26u, 30u, 31u, 27u }, 68u, 0, 0u }, - { { 27u, 31u, 28u, 24u }, 281u, 0, 0u }, - { { 31u, 30u, 29u, 28u }, 281u, 0, 0u } -}; - -//------------------------------------------------------------------------------------------------- - -//000AEA58 -unsigned int quadbld_backs[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -//------------------------------------------------------------------------------------------------- - -//000AEAA8 -tVec3 bld0_coords[12] = -{ - { -676.14502f, -698.68799f, 5.928f }, - { 676.14502f, -698.68799f, 0.032000002f }, - { 676.14502f, -698.68799f, 5029.5732f }, - { -676.14502f, -698.68799f, 5029.5732f }, - { -676.14502f, 698.68799f, 5.928f }, - { 676.14502f, 698.68799f, 5.928f }, - { 676.14502f, 698.68799f, 5029.5732f }, - { -676.14502f, 698.68799f, 5029.5732f }, - { 216.739f, -270.72101f, 6319.0972f }, - { -217.91701f, -270.72101f, 6319.0972f }, - { 216.739f, 279.23499f, 6319.0972f }, - { -217.91701f, 279.23499f, 6319.0972f } -}; - -//------------------------------------------------------------------------------------------------- - -//000AEB38 -tPolygon bld0_pols[9] = -{ - { { 0u, 1u, 2u, 3u }, 276u, 0, 0u }, - { { 1u, 5u, 6u, 2u }, 276u, 0, 0u }, - { { 4u, 0u, 3u, 7u }, 276u, 0, 0u }, - { { 5u, 4u, 7u, 6u }, 276u, 0, 0u }, - { { 3u, 2u, 8u, 9u }, 277u, 0, 0u }, - { { 2u, 6u, 10u, 8u }, 4373u, 0, 0u }, - { { 11u, 9u, 8u, 10u }, 277u, 0, 0u }, - { { 7u, 3u, 9u, 11u }, 4373u, 0, 0u }, - { { 6u, 7u, 11u, 10u }, 277u, 0, 0u } -}; - -//------------------------------------------------------------------------------------------------- - -//000AEBA4 -unsigned int bld0_backs[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -//------------------------------------------------------------------------------------------------- - -//000AEBC8 +// 000AE7E8 +tVec3 quadbld_coords[32] = {{-564.95203f, 691.53802f, 14.749f}, + {-564.95203f, 2328.5281f, 14.749f}, + {-564.95203f, 2328.5281f, 6206.293f}, + {-564.95203f, 691.53802f, 6206.293f}, + {-2303.3689f, 691.53802f, 14.749f}, + {-2303.3689f, 2328.5281f, 14.749f}, + {-2303.3689f, 2328.5281f, 6206.293f}, + {-2303.3689f, 691.53802f, 6206.293f}, + {-513.54602f, -2328.5281f, -0.071000002f}, + {-513.54602f, -691.53802f, -0.071000002f}, + {-513.54602f, -691.53802f, 6191.7041f}, + {-513.54602f, -2328.5281f, 6191.7041f}, + {-2251.5681f, -2328.5281f, -0.071000002f}, + {-2251.5681f, -691.53802f, -0.071000002f}, + {-2251.5681f, -691.53802f, 6191.7041f}, + {-2251.5681f, -2328.5281f, 6191.7041f}, + {2251.5681f, 691.53802f, 14.749f}, + {2251.5681f, 2328.5281f, 14.749f}, + {2251.5681f, 2328.5281f, 6206.293f}, + {2251.5681f, 691.53802f, 6206.293f}, + {513.54602f, 691.53802f, 14.749f}, + {513.54602f, 2328.5281f, 14.749f}, + {513.54602f, 2328.5281f, 6206.293f}, + {513.54602f, 691.53802f, 6206.293f}, + {2303.3689f, -2328.5281f, -0.071000002f}, + {2303.3689f, -691.53802f, -0.071000002f}, + {2303.3689f, -691.53802f, 6191.7041f}, + {2303.3689f, -2328.5281f, 6191.7041f}, + {564.95203f, -2328.5281f, -0.071000002f}, + {564.95203f, -691.53802f, -0.071000002f}, + {564.95203f, -691.53802f, 6191.7041f}, + {564.95203f, -2328.5281f, 6191.7041f}}; + +//------------------------------------------------------------------------------------------------- + +// 000AE968 +tPolygon quadbld_pols[20] = { + {{2u, 3u, 0u, 1u}, 282u, 0, 0u}, {{6u, 2u, 1u, 5u}, 282u, 0, 0u}, + {{2u, 6u, 7u, 3u}, 68u, 0, 0u}, {{3u, 7u, 4u, 0u}, 282u, 0, 0u}, + {{7u, 6u, 5u, 4u}, 282u, 0, 0u}, {{10u, 11u, 8u, 9u}, 279u, 0, 0u}, + {{14u, 10u, 9u, 13u}, 279u, 0, 0u}, {{10u, 14u, 15u, 11u}, 68u, 0, 0u}, + {{11u, 15u, 12u, 8u}, 279u, 0, 0u}, {{15u, 14u, 13u, 12u}, 279u, 0, 0u}, + {{18u, 19u, 16u, 17u}, 280u, 0, 0u}, {{22u, 18u, 17u, 21u}, 280u, 0, 0u}, + {{18u, 22u, 23u, 19u}, 68u, 0, 0u}, {{19u, 23u, 20u, 16u}, 280u, 0, 0u}, + {{23u, 22u, 21u, 20u}, 280u, 0, 0u}, {{26u, 27u, 24u, 25u}, 281u, 0, 0u}, + {{30u, 26u, 25u, 29u}, 281u, 0, 0u}, {{26u, 30u, 31u, 27u}, 68u, 0, 0u}, + {{27u, 31u, 28u, 24u}, 281u, 0, 0u}, {{31u, 30u, 29u, 28u}, 281u, 0, 0u}}; + +//------------------------------------------------------------------------------------------------- + +// 000AEA58 +unsigned int quadbld_backs[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +//------------------------------------------------------------------------------------------------- + +// 000AEAA8 +tVec3 bld0_coords[12] = {{-676.14502f, -698.68799f, 5.928f}, + {676.14502f, -698.68799f, 0.032000002f}, + {676.14502f, -698.68799f, 5029.5732f}, + {-676.14502f, -698.68799f, 5029.5732f}, + {-676.14502f, 698.68799f, 5.928f}, + {676.14502f, 698.68799f, 5.928f}, + {676.14502f, 698.68799f, 5029.5732f}, + {-676.14502f, 698.68799f, 5029.5732f}, + {216.739f, -270.72101f, 6319.0972f}, + {-217.91701f, -270.72101f, 6319.0972f}, + {216.739f, 279.23499f, 6319.0972f}, + {-217.91701f, 279.23499f, 6319.0972f}}; + +//------------------------------------------------------------------------------------------------- + +// 000AEB38 +tPolygon bld0_pols[9] = { + {{0u, 1u, 2u, 3u}, 276u, 0, 0u}, {{1u, 5u, 6u, 2u}, 276u, 0, 0u}, + {{4u, 0u, 3u, 7u}, 276u, 0, 0u}, {{5u, 4u, 7u, 6u}, 276u, 0, 0u}, + {{3u, 2u, 8u, 9u}, 277u, 0, 0u}, {{2u, 6u, 10u, 8u}, 4373u, 0, 0u}, + {{11u, 9u, 8u, 10u}, 277u, 0, 0u}, {{7u, 3u, 9u, 11u}, 4373u, 0, 0u}, + {{6u, 7u, 11u, 10u}, 277u, 0, 0u}}; + +//------------------------------------------------------------------------------------------------- + +// 000AEBA4 +unsigned int bld0_backs[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; + +//------------------------------------------------------------------------------------------------- + +// 000AEBC8 char building_names[17][256] = { - "TOWER", - "TOWER 2", - "SIGN 1", - "SIGN 2", - "BUILD", - "BUILD 1", - "BUILD 2", - "BUILD 3", - "HEELBAR", - "BALLOON", - "TREE", - "ADVERT", - "ADVERT 2", - "QUAD BLD", - "BIG BALL", - "BIG AD", - "B" -}; - -//------------------------------------------------------------------------------------------------- - -//000AFCC8 -tBuildingPlan BuildingPlans[17] = -{ - { 5u, 8u, 0u, 0u, tower_pols, tower_coords }, - { 5u, 8u, 0u, 0u, tower2_pols, tower2_coords }, - { 2u, 8u, 0u, 0u, sign01_pols, sign01_coords }, - { 3u, 12u, 0u, 0u, sign02_pols, sign02_coords }, - { 5u, 14u, 0u, 0u, build_pols, build_coords }, - { 10u, 12u, 0u, 0u, build1_pols, build1_coords }, - { 10u, 12u, 0u, 0u, build2_pols, build2_coords }, - { 3u, 8u, 0u, 0u, build3_pols, build3_coords }, - { 5u, 8u, 0u, 0u, heelbar_pols, heelbar_coords }, - { 1u, 4u, 0u, 0u, balloon_pols, balloon_coords }, - { 1u, 4u, 0u, 0u, tree_pols, tree_coords }, - { 6u, 8u, 0u, 0u, advert_pols, advert_coords }, - { 1u, 4u, 0u, 0u, advert2_pols, advert2_coords }, - { 20u, 32u, 0u, 0u, quadbld_pols, quadbld_coords }, - { 9u, 12u, 0u, 0u, bld0_pols, bld0_coords }, - { 1u, 4u, 0u, 0u, balloon2_pols, balloon2_coords }, - { 1u, 4u, 0u, 0u, advert3_pols, advert3_coords } -}; + "TOWER", "TOWER 2", "SIGN 1", "SIGN 2", "BUILD", "BUILD 1", + "BUILD 2", "BUILD 3", "HEELBAR", "BALLOON", "TREE", "ADVERT", + "ADVERT 2", "QUAD BLD", "BIG BALL", "BIG AD", "B"}; + +//------------------------------------------------------------------------------------------------- + +// 000AFCC8 +tBuildingPlan BuildingPlans[17] = { + {5u, 8u, 0u, 0u, tower_pols, tower_coords}, + {5u, 8u, 0u, 0u, tower2_pols, tower2_coords}, + {2u, 8u, 0u, 0u, sign01_pols, sign01_coords}, + {3u, 12u, 0u, 0u, sign02_pols, sign02_coords}, + {5u, 14u, 0u, 0u, build_pols, build_coords}, + {10u, 12u, 0u, 0u, build1_pols, build1_coords}, + {10u, 12u, 0u, 0u, build2_pols, build2_coords}, + {3u, 8u, 0u, 0u, build3_pols, build3_coords}, + {5u, 8u, 0u, 0u, heelbar_pols, heelbar_coords}, + {1u, 4u, 0u, 0u, balloon_pols, balloon_coords}, + {1u, 4u, 0u, 0u, tree_pols, tree_coords}, + {6u, 8u, 0u, 0u, advert_pols, advert_coords}, + {1u, 4u, 0u, 0u, advert2_pols, advert2_coords}, + {20u, 32u, 0u, 0u, quadbld_pols, quadbld_coords}, + {9u, 12u, 0u, 0u, bld0_pols, bld0_coords}, + {1u, 4u, 0u, 0u, balloon2_pols, balloon2_coords}, + {1u, 4u, 0u, 0u, advert3_pols, advert3_coords}}; //------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/PROJECTS/ROLLER/plans.h b/PROJECTS/ROLLER/plans.h index f8f19814..6a601a3c 100644 --- a/PROJECTS/ROLLER/plans.h +++ b/PROJECTS/ROLLER/plans.h @@ -4,8 +4,7 @@ #include "carplans.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint8 byNumPols; uint8 byNumCoords; uint8 byPadding1; diff --git a/PROJECTS/ROLLER/png_writer.c b/PROJECTS/ROLLER/png_writer.c index ecad91a3..9a2f7456 100644 --- a/PROJECTS/ROLLER/png_writer.c +++ b/PROJECTS/ROLLER/png_writer.c @@ -4,16 +4,13 @@ //------------------------------------------------------------------------------------------------- -int RollerWriteIndexedPng(const char *szPath, - const uint8 *pIndexedBuf, - const tColor *pPalette, - int iWidth, - int iHeight) -{ +int RollerWriteIndexedPng(const char *szPath, const uint8 *pIndexedBuf, + const tColor *pPalette, int iWidth, int iHeight) { if (!szPath || !pIndexedBuf || !pPalette || iWidth <= 0 || iHeight <= 0) return 1; - SDL_Surface *surface = SDL_CreateSurface(iWidth, iHeight, SDL_PIXELFORMAT_INDEX8); + SDL_Surface *surface = + SDL_CreateSurface(iWidth, iHeight, SDL_PIXELFORMAT_INDEX8); if (!surface) return 1; diff --git a/PROJECTS/ROLLER/png_writer.h b/PROJECTS/ROLLER/png_writer.h index 86131fb0..91b729cf 100644 --- a/PROJECTS/ROLLER/png_writer.h +++ b/PROJECTS/ROLLER/png_writer.h @@ -7,11 +7,8 @@ // Writes an 8-bit indexed PNG with the supplied 256-entry palette in the PLTE // chunk. The palette uses the game's 6-bit colour values (0..63), which are // scaled to 8-bit. Returns 0 on success, non-zero on error. -int RollerWriteIndexedPng(const char *szPath, - const uint8 *pIndexedBuf, - const tColor *pPalette, - int iWidth, - int iHeight); +int RollerWriteIndexedPng(const char *szPath, const uint8 *pIndexedBuf, + const tColor *pPalette, int iWidth, int iHeight); //------------------------------------------------------------------------------------------------- #endif diff --git a/PROJECTS/ROLLER/polyf.c b/PROJECTS/ROLLER/polyf.c index 7bf641ad..c75b1052 100644 --- a/PROJECTS/ROLLER/polyf.c +++ b/PROJECTS/ROLLER/polyf.c @@ -9,9 +9,8 @@ #include #include //------------------------------------------------------------------------------------------------- -//000706B0 -void twpoly(tPoint *vertices, int16 nColor) -{ +// 000706B0 +void twpoly(tPoint *vertices, int16 nColor) { int16 nEdge1Dx; int16 nEdge2Dx; int16 nEdge2Dy; @@ -69,59 +68,65 @@ void twpoly(tPoint *vertices, int16 nColor) pTempPoint = *vertices; if (iCrossProductResult1 <= 0) { // Case 1: Split into triangles P2-P3-P* and P0-P*-P3 - *vertices = vertices[2]; // move P2 to P0 position + *vertices = vertices[2]; // move P2 to P0 position // Calculate intersection point P* - dIntersectionX = (double)nEdge3Dx * dIntersectionParam + (double)vertices[2].x; - //CHP + dIntersectionX = + (double)nEdge3Dx * dIntersectionParam + (double)vertices[2].x; + // CHP vertices[2].x = (int)dIntersectionX; - dIntersectionY = dIntersectionParam * (double)nEdge3Dy + (double)vertices[2].y; - //CHP + dIntersectionY = + dIntersectionParam * (double)nEdge3Dy + (double)vertices[2].y; + // CHP vertices[2].y = (int)dIntersectionY; // Render first triangle (P2, P3, P*) poly(vertices, 3, nColor); // Prepare second triangle (P0, P*, P3) - *vertices = vertices[3]; // Original P3 - vertices[1] = pTempPoint; // Original P0 + *vertices = vertices[3]; // Original P3 + vertices[1] = pTempPoint; // Original P0 poly(vertices, 3, nColor); return; } // Case 2: Split into triangles P1-P2-P* and P0-P*-P3 - *vertices = vertices[1]; // Move P1 to P0 position - vertices[1] = vertices[2]; // Move P2 to P1 position + *vertices = vertices[1]; // Move P1 to P0 position + vertices[1] = vertices[2]; // Move P2 to P1 position // Calculate intersection point P* - dIntersectionX2 = (double)nEdge3Dx * dIntersectionParam + (double)vertices[2].x; - //CHP + dIntersectionX2 = + (double)nEdge3Dx * dIntersectionParam + (double)vertices[2].x; + // CHP vertices[2].x = (int)dIntersectionX2; - dIntersectionY2 = dIntersectionParam * (double)nEdge3Dy + (double)vertices[2].y; - //CHP + dIntersectionY2 = + dIntersectionParam * (double)nEdge3Dy + (double)vertices[2].y; + // CHP vertices[2].y = (int)dIntersectionY2; // Render first triangle (P1, P2, P*) poly(vertices, 3, nColor); // Prepare second triangle (P0, P*, P3) - *vertices = vertices[3]; // Original P3 + *vertices = vertices[3]; // Original P3 iNumVerts = 3; vertices2 = vertices; nColor2 = nColor; - vertices[1] = pTempPoint; // Original P0 + vertices[1] = pTempPoint; // Original P0 goto LABEL_18; } } // Secondary concave test using different edge combination - fCrossProduct2 = (float)(SumEdge23Dy2 * nSumEdge23Dx - nSumEdge23Dy * nSumEdge23Dx2); + fCrossProduct2 = + (float)(SumEdge23Dy2 * nSumEdge23Dx - nSumEdge23Dy * nSumEdge23Dx2); - if (fabsf(fCrossProduct2) <= FLT_EPSILON - || (iCrossProductResult2 = nEdge2Dx * nSumEdge23Dy - nEdge2Dy * nSumEdge23Dx, - iCrossProductResult2_2 = iCrossProductResult2, - fIntersectionParam2 = (float)((double)iCrossProductResult2 / (double)fCrossProduct2), - fIntersectionParam2 <= 0.0) // Valid intersection point found (0 < t < 1) - || fIntersectionParam2 >= 1.0) { + if (fabsf(fCrossProduct2) <= FLT_EPSILON || + (iCrossProductResult2 = nEdge2Dx * nSumEdge23Dy - nEdge2Dy * nSumEdge23Dx, + iCrossProductResult2_2 = iCrossProductResult2, + fIntersectionParam2 = + (float)((double)iCrossProductResult2 / (double)fCrossProduct2), + fIntersectionParam2 <= 0.0) // Valid intersection point found (0 < t < 1) + || fIntersectionParam2 >= 1.0) { // Convex quadrilateral handling if (iCrossProductResult1 < 0 || iCrossProductResult2_2 > 0) { @@ -142,14 +147,16 @@ void twpoly(tPoint *vertices, int16 nColor) if (iCrossProductResult2 <= 0) { // Case 3: Swap vertices and split pTempPoint3 = *vertices; - *vertices = vertices[1]; // Swap P0 and P1 + *vertices = vertices[1]; // Swap P0 and P1 vertices[1] = pTempPoint3; pTempPoint4 = vertices[2]; // Calculate intersection point P* - vertices[2].x = (int)((double)nSumEdge23Dx2 * fIntersectionParam2 + (double)pTempPoint4.x); - dIntersectionY4 = fIntersectionParam2 * (double)SumEdge23Dy2 + (double)pTempPoint4.y; - //CHP + vertices[2].x = (int)((double)nSumEdge23Dx2 * fIntersectionParam2 + + (double)pTempPoint4.x); + dIntersectionY4 = + fIntersectionParam2 * (double)SumEdge23Dy2 + (double)pTempPoint4.y; + // CHP vertices[2].y = (int)dIntersectionY4; nColor3 = nColor; @@ -164,9 +171,11 @@ void twpoly(tPoint *vertices, int16 nColor) pTempPoint5 = vertices[2]; // Calculate intersection point P* - vertices[2].x = (int)((double)nSumEdge23Dx2 * fIntersectionParam2 + (double)pTempPoint5.x); - dIntersectionY3 = fIntersectionParam2 * (double)SumEdge23Dy2 + (double)vertices[2].y; - //CHP + vertices[2].x = (int)((double)nSumEdge23Dx2 * fIntersectionParam2 + + (double)pTempPoint5.x); + dIntersectionY3 = + fIntersectionParam2 * (double)SumEdge23Dy2 + (double)vertices[2].y; + // CHP vertices[2].y = (int)dIntersectionY3; nColor3 = nColor; @@ -174,27 +183,26 @@ void twpoly(tPoint *vertices, int16 nColor) poly(vertices, 3, nColor); // Prepare second triangle - *vertices = vertices[3]; // Original P3 - vertices[1] = pTempPoint5; // Original P2 + *vertices = vertices[3]; // Original P3 + vertices[1] = pTempPoint5; // Original P2 } poly(vertices, 3, nColor3); } //------------------------------------------------------------------------------------------------- -//00070A40 -void POLYFLAT(uint8 *pScrBuf, tPolyParams *polyParams) -{ +// 00070A40 +void POLYFLAT(uint8 *pScrBuf, tPolyParams *polyParams) { uint32 uiSurfaceType; // ebx - int iX0; // edx - int iY0; // ecx - int iY1; // ebp - int iDx; // edx - int iDy; // ecx - int iX0_1; // edx - int iY0_1; // ecx - int iX1_1; // edx - int iY1_1; // ecx - int iX1; // [esp+0h] [ebp-18h] + int iX0; // edx + int iY0; // ecx + int iY1; // ebp + int iDx; // edx + int iDy; // ecx + int iX0_1; // edx + int iY0_1; // ecx + int iX1_1; // edx + int iY1_1; // ecx + int iX1; // [esp+0h] [ebp-18h] uiSurfaceType = polyParams->iSurfaceType; if ((polyParams->iSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0) { @@ -205,8 +213,8 @@ void POLYFLAT(uint8 *pScrBuf, tPolyParams *polyParams) iY1 = iY0 - polyParams->vertices[1].y; // Determine comparison points (p2 or p3) - if (polyParams->vertices[1].x == polyParams->vertices[2].x - && polyParams->vertices[1].y == polyParams->vertices[2].y) { + if (polyParams->vertices[1].x == polyParams->vertices[2].x && + polyParams->vertices[1].y == polyParams->vertices[2].y) { iDx = iX0 - polyParams->vertices[3].x; iDy = iY0 - polyParams->vertices[3].y; } else { @@ -235,12 +243,14 @@ void POLYFLAT(uint8 *pScrBuf, tPolyParams *polyParams) } scrptr = pScrBuf; ++num_pols; - if ((uiSurfaceType & SURFACE_FLAG_TRANSPARENT) != 0) // shadow polygon + if ((uiSurfaceType & SURFACE_FLAG_TRANSPARENT) != 0) // shadow polygon { - shadow_poly(polyParams->vertices, polyParams->uiNumVerts, (uint8)uiSurfaceType); + shadow_poly(polyParams->vertices, polyParams->uiNumVerts, + (uint8)uiSurfaceType); } else if ((uiSurfaceType & SURFACE_FLAG_CONCAVE) != 0) { - twpoly(polyParams->vertices, (uint8)uiSurfaceType);// potentially concave quad - } else // solid polygon + twpoly(polyParams->vertices, + (uint8)uiSurfaceType); // potentially concave quad + } else // solid polygon { poly(polyParams->vertices, polyParams->uiNumVerts, (uint8)uiSurfaceType); } @@ -248,9 +258,8 @@ void POLYFLAT(uint8 *pScrBuf, tPolyParams *polyParams) } //------------------------------------------------------------------------------------------------- -//00070B40 -void poly(tPoint *vertices, int iNumVerts, int16 nColor) -{ +// 00070B40 +void poly(tPoint *vertices, int iNumVerts, int16 nColor) { // Find polygon bounds and top vertex int iMinX = vertices[0].x; int iMaxX = vertices[0].x; @@ -262,14 +271,17 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) int x = vertices[i].x; int y = vertices[i].y; - if (x < iMinX) iMinX = x; - if (x > iMaxX) iMaxX = x; + if (x < iMinX) + iMinX = x; + if (x > iMaxX) + iMaxX = x; if (y < iMinY) { iMinY = y; iMinYIdx = i; } - if (y > iMaxY) iMaxY = y; + if (y > iMaxY) + iMaxY = y; } // Early exit if polygon is completely outside screen @@ -281,7 +293,8 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) int iSignedArea = 0; for (int i = 0; i < iNumVerts; i++) { int j = (i + 1) % iNumVerts; - iSignedArea += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); + iSignedArea += + (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); } // Determine edge walking directions based on winding order @@ -297,10 +310,10 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) } // Edge walking variables (floating-point) - float fLeftEdgeX = 0.0f; // Left edge X position - float fRightEdgeX = 0.0f; // Right edge X position - float fLeftEdgeStep = 0.0f; // Left edge X step per scanline - float fRightEdgeStep = 0.0f; // Right edge X step per scanline + float fLeftEdgeX = 0.0f; // Left edge X position + float fRightEdgeX = 0.0f; // Right edge X position + float fLeftEdgeStep = 0.0f; // Left edge X step per scanline + float fRightEdgeStep = 0.0f; // Right edge X step per scanline // Vertex indices for edge walking int iLeftVertexIdx = iMinYIdx; @@ -386,11 +399,13 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) if (iLeftRemain > 0) { int iTotalHeight = iEndY - iStartY; - float fDeltaX = (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftIdx].x); + float fDeltaX = + (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftIdx].x); fLeftEdgeStep = fDeltaX / (float)iTotalHeight; // Adjust for clipping - fLeftEdgeX = (float)vertices[iPrevLeftIdx].x + fLeftEdgeStep * (float)(0 - iStartY); + fLeftEdgeX = (float)vertices[iPrevLeftIdx].x + + fLeftEdgeStep * (float)(0 - iStartY); if (fLeftEdgeStep < 0.0f) { fLeftEdgeX += fLeftEdgeStep; @@ -411,11 +426,13 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) if (iRightRemain > 0) { int iTotalHeight = iEndY - iStartY; - float fDeltaX = (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightIdx].x); + float fDeltaX = + (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightIdx].x); fRightEdgeStep = fDeltaX / (float)iTotalHeight; // Adjust for clipping - fRightEdgeX = (float)vertices[iPrevRightIdx].x + fRightEdgeStep * (float)(0 - iStartY); + fRightEdgeX = (float)vertices[iPrevRightIdx].x + + fRightEdgeStep * (float)(0 - iStartY); if (fRightEdgeStep > 0.0f) { fRightEdgeX += fRightEdgeStep; @@ -466,7 +483,8 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) // Setup new left edge fLeftEdgeX = (float)vertices[iPrevLeftVertexIdx].x; - float fDeltaX = (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftVertexIdx].x); + float fDeltaX = (float)(vertices[iLeftVertexIdx].x - + vertices[iPrevLeftVertexIdx].x); fLeftEdgeStep = fDeltaX / (float)iLeftRemain; if (fLeftEdgeStep < 0.0f) { @@ -496,7 +514,8 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) // Setup new right edge fRightEdgeX = (float)vertices[iPrevRightVertexIdx].x; - float fDeltaX = (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightVertexIdx].x); + float fDeltaX = (float)(vertices[iRightVertexIdx].x - + vertices[iPrevRightVertexIdx].x); fRightEdgeStep = fDeltaX / (float)iRightRemain; if (fRightEdgeStep > 0.0f) { @@ -513,9 +532,8 @@ void poly(tPoint *vertices, int iNumVerts, int16 nColor) } //------------------------------------------------------------------------------------------------- -//00071D70 -void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) -{ +// 00071D70 +void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) { // Find polygon bounds and top vertex int iMinX = vertices[0].x; int iMaxX = vertices[0].x; @@ -527,14 +545,17 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) int x = vertices[i].x; int y = vertices[i].y; - if (x < iMinX) iMinX = x; - if (x > iMaxX) iMaxX = x; + if (x < iMinX) + iMinX = x; + if (x > iMaxX) + iMaxX = x; if (y < iMinY) { iMinY = y; iMinYIdx = i; } - if (y > iMaxY) iMaxY = y; + if (y > iMaxY) + iMaxY = y; } // Early exit if polygon is completely outside screen @@ -546,7 +567,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) int iSignedArea = 0; for (int i = 0; i < iNumVerts; i++) { int j = (i + 1) % iNumVerts; - iSignedArea += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); + iSignedArea += + (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); } // Determine edge walking directions based on winding order @@ -565,10 +587,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) uint8 *pShadePalette = &shade_palette[256 * iPaletteIndex]; // Edge walking variables (floating-point) - float fLeftEdgeX = 0.0f; // Left edge X position - float fRightEdgeX = 0.0f; // Right edge X position - float fLeftEdgeStep = 0.0f; // Left edge X step per scanline - float fRightEdgeStep = 0.0f; // Right edge X step per scanline + float fLeftEdgeX = 0.0f; // Left edge X position + float fRightEdgeX = 0.0f; // Right edge X position + float fLeftEdgeStep = 0.0f; // Left edge X step per scanline + float fRightEdgeStep = 0.0f; // Right edge X step per scanline // Vertex indices for edge walking int iLeftVertexIdx = iMinYIdx; @@ -654,11 +676,13 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) if (iLeftRemain > 0) { int iTotalHeight = iEndY - iStartY; - float fDeltaX = (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftIdx].x); + float fDeltaX = + (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftIdx].x); fLeftEdgeStep = fDeltaX / (float)iTotalHeight; // Adjust for clipping - fLeftEdgeX = (float)vertices[iPrevLeftIdx].x + fLeftEdgeStep * (float)(0 - iStartY); + fLeftEdgeX = (float)vertices[iPrevLeftIdx].x + + fLeftEdgeStep * (float)(0 - iStartY); if (fLeftEdgeStep < 0.0f) { fLeftEdgeX += fLeftEdgeStep; @@ -679,11 +703,13 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) if (iRightRemain > 0) { int iTotalHeight = iEndY - iStartY; - float fDeltaX = (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightIdx].x); + float fDeltaX = + (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightIdx].x); fRightEdgeStep = fDeltaX / (float)iTotalHeight; // Adjust for clipping - fRightEdgeX = (float)vertices[iPrevRightIdx].x + fRightEdgeStep * (float)(0 - iStartY); + fRightEdgeX = (float)vertices[iPrevRightIdx].x + + fRightEdgeStep * (float)(0 - iStartY); if (fRightEdgeStep > 0.0f) { fRightEdgeX += fRightEdgeStep; @@ -737,7 +763,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) // Setup new left edge fLeftEdgeX = (float)vertices[iPrevLeftVertexIdx].x; - float fDeltaX = (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftVertexIdx].x); + float fDeltaX = (float)(vertices[iLeftVertexIdx].x - + vertices[iPrevLeftVertexIdx].x); fLeftEdgeStep = fDeltaX / (float)iLeftRemain; if (fLeftEdgeStep < 0.0f) { @@ -767,7 +794,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) // Setup new right edge fRightEdgeX = (float)vertices[iPrevRightVertexIdx].x; - float fDeltaX = (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightVertexIdx].x); + float fDeltaX = (float)(vertices[iRightVertexIdx].x - + vertices[iPrevRightVertexIdx].x); fRightEdgeStep = fDeltaX / (float)iRightRemain; if (fRightEdgeStep > 0.0f) { @@ -784,7 +812,7 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) } //------------------------------------------------------------------------------------------------- -//00070B40 +// 00070B40 /*void poly(tPoint *vertices, int iVertexCount, int16 nColor) { int iOldWinW; // ebp @@ -949,10 +977,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) // Initialize left edge with top vertex X (16.16 fixed point format) SET_HIWORD(iLeftXFixed, pTopVertex->x); SET_HIWORD(v114, pTopVertex->x); - SET_LOWORD(iLeftXFixed, -1); // Initialize fraction to -1 for correct rounding - SET_LOWORD(v114, 0); // Initialize fraction to 0 - SET_LOWORD(v105, 0); // Clear loword - SET_LOWORD(v97, 0); // Clear loword + SET_LOWORD(iLeftXFixed, -1); // Initialize fraction to -1 +for correct rounding SET_LOWORD(v114, 0); // +Initialize fraction to 0 SET_LOWORD(v105, 0); // Clear +loword SET_LOWORD(v97, 0); // Clear loword // Initialize left edge while (1) { @@ -988,10 +1016,9 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) // Initialize right edge while (1) { - v22 = --iMinYIdx2; // Move to previous vertex clockwise - if ((int16)iMinYIdx2 == -1) // Wrap vertex idx - iMinYIdx2 = iVertexCount - 1; - pVertex = &vertices[(int16)iMinYIdx2]; + v22 = --iMinYIdx2; // Move to previous vertex +clockwise if ((int16)iMinYIdx2 == -1) // Wrap vertex idx iMinYIdx2 = +iVertexCount - 1; pVertex = &vertices[(int16)iMinYIdx2]; // Calculate scanlines until next vertex SET_LOWORD(v22, GET_LOWORD(pVertex->y) - iScanlineY); iLeftRemaining_1 = v22; @@ -1026,7 +1053,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) SET_LOWORD(v103, 0); // Clear loword SET_LOWORD(v95, 0); // Clear loword SET_LOWORD(v113, 0); // Clear loword - SET_LOWORD(iLeftX, -1); // Initialize fraction for right edge + SET_LOWORD(iLeftX, -1); // Initialize fraction for +right edge // Find first vertex at or below screen top do { @@ -1091,10 +1119,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) goto CLEANUP_AND_RETURN; // All vertices above screen } // Calculate right edge slope (dx/dy) - SET_HIWORD(v103, GET_LOWORD(vertices[(int16)iMinYIdx2].x) - GET_HIWORD(iLeftX)); - iLeftRemaining_1 = iY; - if (v103 <= 0) { - DEC_HIWORD(v103); + SET_HIWORD(v103, GET_LOWORD(vertices[(int16)iMinYIdx2].x) - +GET_HIWORD(iLeftX)); iLeftRemaining_1 = iY; if (v103 <= 0) { DEC_HIWORD(v103); v104 = v103 / ((int16)iY - v16 + 1); // dx/dy INC_HIWORD(iLeftX); // Adjust for rounding } else { @@ -1177,17 +1203,14 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) iLeftRemaining_1 = v26; if ((int16)v26 > 0) // Valid edge segment { - SET_HIWORD(v106, GET_LOWORD(pVertex_2->x) - GET_HIWORD(iLeftXFixed));// dx - SET_LOWORD(v106, 0); // clear fraction - SET_LOWORD(iLeftXFixed, -1); // reset fraction - if (v106 <= 0) { - DEC_HIWORD(v106); // Adjust for negative slope - v104 = v106 / ((int16)v26 + 1); // dx/dy - INC_HIWORD(iLeftXFixed); // Adjust for rounding - } else { - INC_HIWORD(v106); // Adjust for positive slope - v104 = v106 / ((int16)v26 + 1); // dx/dy - iLeftXFixed += v104; // Udpate X + SET_HIWORD(v106, GET_LOWORD(pVertex_2->x) - +GET_HIWORD(iLeftXFixed));// dx SET_LOWORD(v106, 0); // clear +fraction SET_LOWORD(iLeftXFixed, -1); // reset fraction if (v106 <= +0) { DEC_HIWORD(v106); // Adjust for negative slope v104 = +v106 / ((int16)v26 + 1); // dx/dy INC_HIWORD(iLeftXFixed); // +Adjust for rounding } else { INC_HIWORD(v106); // Adjust for +positive slope v104 = v106 / ((int16)v26 + 1); // dx/dy iLeftXFixed += v104; +// Udpate X } break; } @@ -1197,8 +1220,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) } if (iScanlineY >= winh) // Past bottom of screen goto CLEANUP_AND_RETURN; - } // - // + } // + // while (1) { // Main drawing loop @@ -1225,9 +1248,9 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) { winw = iOldWinW; // Fill entire scanline segment - memset(&scrptr[iOldWinW * iScanlineY], nColor, GET_SHIWORD(iLeftXFixed)); - iOldWinW = winw; - } else if (iLeftXFixed < 0) // Right edge off left + memset(&scrptr[iOldWinW * iScanlineY], nColor, +GET_SHIWORD(iLeftXFixed)); iOldWinW = winw; } else if (iLeftXFixed < 0) // Right +edge off left { goto CLEANUP_AND_RETURN; } @@ -1272,9 +1295,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) goto CLEANUP_AND_RETURN; // nothing to draw } LABEL_253: - if (GET_SHIWORD(iLeftXFixed) <= 0) // Right edge beyond screen right - goto CLEANUP_AND_RETURN; - goto FILL_FULL_WIDTH; + if (GET_SHIWORD(iLeftXFixed) <= 0) // Right edge beyond screen +right goto CLEANUP_AND_RETURN; goto FILL_FULL_WIDTH; } // Continue processing left edge after completion while (1) { @@ -1349,8 +1371,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) goto CLEANUP_AND_RETURN; } // Calcualte new right edge slope - SET_HIWORD(v108, GET_LOWORD(pVertex_4->x) - GET_HIWORD(iLeftXFixed));// dx - SET_LOWORD(v108, 0); // clear fraction + SET_HIWORD(v108, GET_LOWORD(pVertex_4->x) - GET_HIWORD(iLeftXFixed));// +dx SET_LOWORD(v108, 0); // clear fraction SET_LOWORD(iLeftXFixed, -1); // reset fraction if (v108 <= 0) { DEC_HIWORD(v108); // adjust for negative slope @@ -1528,17 +1550,16 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) break; // check if right edge beyond right if (GET_SHIWORD(iLeftXFixed) > winw) - goto FILL_RIGHT_CLIPPED; // fill from left to screen right - DRAW_SCANLINE: // draw between left and right edges - if (GET_SHIWORD(iLeftXFixed) <= 0) // right edge not visible - goto CLEANUP_AND_RETURN; - DRAW_SCANLINE_SEGMENT: + goto FILL_RIGHT_CLIPPED; // fill from left to screen +right DRAW_SCANLINE: // draw between left and +right edges if (GET_SHIWORD(iLeftXFixed) <= 0) // right edge not +visible goto CLEANUP_AND_RETURN; DRAW_SCANLINE_SEGMENT: // calculate span between edges if ((int16)(GET_HIWORD(iLeftXFixed) - GET_HIWORD(v114)) > 0) { winw = iOldWinW; // fill between edges - memset(&scrptr[GET_SHIWORD(v114) + iOldWinW * iScanlineY], nColor, (int16)(GET_HIWORD(iLeftXFixed) - GET_HIWORD(v114))); - iOldWinW = winw; + memset(&scrptr[GET_SHIWORD(v114) + iOldWinW * iScanlineY], nColor, +(int16)(GET_HIWORD(iLeftXFixed) - GET_HIWORD(v114))); iOldWinW = winw; } // Handle inverted edges (shouldn't happen) else if ((int16)(GET_HIWORD(iLeftXFixed) - GET_HIWORD(v114)) < 0) { @@ -1784,8 +1805,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) goto CLEANUP_AND_RETURN; } // calculate new right edge slope - SET_HIWORD(v110, GET_LOWORD(pVertex_10->x) - GET_HIWORD(iLeftXFixed));// dx - SET_LOWORD(v110, 0); // clear fraction + SET_HIWORD(v110, GET_LOWORD(pVertex_10->x) - GET_HIWORD(iLeftXFixed));// +dx SET_LOWORD(v110, 0); // clear fraction SET_LOWORD(iLeftXFixed, -1); // reset fraction if (v110 <= 0) { DEC_HIWORD(v110); // adjust negative slope @@ -1847,7 +1868,7 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) }*/ //------------------------------------------------------------------------------------------------- -//00071D70 +// 00071D70 /*void shadow_poly(tPoint *vertices, int iNumVertices, int iPaletteIndex) { int iOldWinW; // ebp @@ -2037,13 +2058,11 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) } // Calculate left edge step - SET_HIWORD(iLeftEdgeDxTemp2, GET_LOWORD(pVertex->x) - GET_HIWORD(iLeftEdgeX)); - iStep = iLeftEdgeDxTemp2 / (int16)iStep_3; - iRemainder_1 = iLeftEdgeDxTemp2 % (int16)iLeftRemain; - iLeftEdgeDx_1 = iStep; - if (iStep < 0) + SET_HIWORD(iLeftEdgeDxTemp2, GET_LOWORD(pVertex->x) - +GET_HIWORD(iLeftEdgeX)); iStep = iLeftEdgeDxTemp2 / (int16)iStep_3; iRemainder_1 += iLeftEdgeDxTemp2 % (int16)iLeftRemain; iLeftEdgeDx_1 = iStep; if (iStep < 0) iLeftEdgeX += iStep; // adjust for negative slope - // + // while (1) { // Process right edge if ((int16)--iBackwardIdx == -1) @@ -2100,14 +2119,12 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) } // Calculate left edge parameters for clipped start - SET_HIWORD(iLeftEdgeDxTemp, GET_LOWORD(vertices[(int16)iMinYIdx].x) - GET_HIWORD(iLeftEdgeXTemp)); - iLeftRemain = iTempY2; - iCalculatedStep = iLeftEdgeDxTemp / ((int16)iTempY2 - iTempY_2); - iStepOffset = (int)((long long)iLeftEdgeXTemp - (long long)iCalculatedStep * iTempY_2); - iLeftEdgeDx_1 = iCalculatedStep; - iLeftEdgeX = iStepOffset; - if (iCalculatedStep < 0) - iLeftEdgeX = iCalculatedStep + iStepOffset; + SET_HIWORD(iLeftEdgeDxTemp, GET_LOWORD(vertices[(int16)iMinYIdx].x) - +GET_HIWORD(iLeftEdgeXTemp)); iLeftRemain = iTempY2; iCalculatedStep = +iLeftEdgeDxTemp / ((int16)iTempY2 - iTempY_2); iStepOffset = (int)((long +long)iLeftEdgeXTemp - (long long)iCalculatedStep * iTempY_2); iLeftEdgeDx_1 = +iCalculatedStep; iLeftEdgeX = iStepOffset; if (iCalculatedStep < 0) iLeftEdgeX = +iCalculatedStep + iStepOffset; // Find first visible right vertex do { @@ -2136,19 +2153,18 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) } // Calculate right edge parameters for clipped start - SET_HIWORD(iRemainder, GET_LOWORD(vertices[(int16)iBackwardIdx].x) - GET_HIWORD(iRightEdgeXTemp)); - iRightRemain = iTempY; - iRightCalculatedStep = iRemainder / ((int16)iTempY - iTempY_4); - iRightStepOffset = (int)((long long)iRightEdgeXTemp - (long long)iRightCalculatedStep * iTempY_4); - iRightEdgeDx = iRightCalculatedStep; - iRightEdgeX = iRightStepOffset; - if (iRightCalculatedStep > 0) - iRightEdgeX = iRightCalculatedStep + iRightStepOffset; - iCurrScanline = 0; // Start rendering at top of screen + SET_HIWORD(iRemainder, GET_LOWORD(vertices[(int16)iBackwardIdx].x) - +GET_HIWORD(iRightEdgeXTemp)); iRightRemain = iTempY; iRightCalculatedStep = +iRemainder / ((int16)iTempY - iTempY_4); iRightStepOffset = (int)((long +long)iRightEdgeXTemp - (long long)iRightCalculatedStep * iTempY_4); iRightEdgeDx += iRightCalculatedStep; iRightEdgeX = iRightStepOffset; if (iRightCalculatedStep +> 0) iRightEdgeX = iRightCalculatedStep + iRightStepOffset; iCurrScanline = 0; +// Start rendering at top of screen } // Edge processing and clipping - while (((iLeftEdgeX >> 16) & 0xFFFF) >= winw || iRightEdgeX < 0 || iLeftEdgeX > iRightEdgeX) { + while (((iLeftEdgeX >> 16) & 0xFFFF) >= winw || iRightEdgeX < 0 || iLeftEdgeX +> iRightEdgeX) { // Advance edges iLeftEdgeX += iLeftEdgeDx_1; ++iCurrScanline; @@ -2171,15 +2187,11 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) SET_LOWORD(iVertexX, pVertex_10->y); iLeftRemain = iVertexX - iCurrScanline; if ((int16)(iVertexX - iCurrScanline) > 0) { - SET_HIWORD(iLeftEdgeDxTemp3, GET_LOWORD(pVertex_10->x) - GET_HIWORD(iLeftEdgeX)); - SET_LOWORD(iLeftEdgeX, 0); - SET_LOWORD(iLeftEdgeDxTemp3, 0); - iNewStep = iLeftEdgeDxTemp3 / (int16)iLeftRemain; - iRightEdgeUpdate = iLeftEdgeDxTemp3 % (int16)iLeftRemain; - iLeftEdgeDx_1 = iNewStep; - if (iNewStep < 0) - iLeftEdgeX += iNewStep; - goto EDGE_ADVANCE_1; + SET_HIWORD(iLeftEdgeDxTemp3, GET_LOWORD(pVertex_10->x) - +GET_HIWORD(iLeftEdgeX)); SET_LOWORD(iLeftEdgeX, 0); SET_LOWORD(iLeftEdgeDxTemp3, +0); iNewStep = iLeftEdgeDxTemp3 / (int16)iLeftRemain; iRightEdgeUpdate = +iLeftEdgeDxTemp3 % (int16)iLeftRemain; iLeftEdgeDx_1 = iNewStep; if (iNewStep < +0) iLeftEdgeX += iNewStep; goto EDGE_ADVANCE_1; } } goto RESTORE_AND_RETURN; @@ -2202,14 +2214,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) iRightEdgeUpdate -= iCurrScanline; iRightRemain = iRightEdgeUpdate; if ((int16)iRightEdgeUpdate > 0) { - SET_HIWORD(iTempEdgeDx, GET_LOWORD(pVertex_2->x) - GET_HIWORD(iRightEdgeX)); - SET_LOWORD(iRightEdgeX, 0); - SET_LOWORD(iTempEdgeDx, 0); - iStep_4 = iTempEdgeDx / (int16)iRightEdgeUpdate; - iRightEdgeDx = iStep_4; - if (iStep_4 > 0) - iRightEdgeX += iStep_4; - goto EDGE_ADVANCE_2; + SET_HIWORD(iTempEdgeDx, GET_LOWORD(pVertex_2->x) - +GET_HIWORD(iRightEdgeX)); SET_LOWORD(iRightEdgeX, 0); SET_LOWORD(iTempEdgeDx, +0); iStep_4 = iTempEdgeDx / (int16)iRightEdgeUpdate; iRightEdgeDx = iStep_4; if +(iStep_4 > 0) iRightEdgeX += iStep_4; goto EDGE_ADVANCE_2; } } goto RESTORE_AND_RETURN; @@ -2260,15 +2268,11 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) SET_LOWORD(iVertexIdx_1, pVertex_11->y); iLeftRemain = iVertexIdx_1 - iCurrScanline; if ((int16)(iVertexIdx_1 - iCurrScanline) > 0) { - SET_HIWORD(iLeftEdgeDxTemp7, GET_LOWORD(pVertex_11->x) - GET_HIWORD(iLeftEdgeX)); - SET_LOWORD(iLeftEdgeX, 0); - SET_LOWORD(iLeftEdgeDxTemp7, 0); - iNewStep_1 = iLeftEdgeDxTemp7 / (int16)iLeftRemain; - iRightEdgeTemp = iLeftEdgeDxTemp7 % (int16)iLeftRemain; - iLeftEdgeDx_1 = iNewStep_1; - if (iNewStep_1 < 0) - iLeftEdgeX += iNewStep_1; - goto LEFT_EDGE_COMPLETE; + SET_HIWORD(iLeftEdgeDxTemp7, GET_LOWORD(pVertex_11->x) - +GET_HIWORD(iLeftEdgeX)); SET_LOWORD(iLeftEdgeX, 0); SET_LOWORD(iLeftEdgeDxTemp7, +0); iNewStep_1 = iLeftEdgeDxTemp7 / (int16)iLeftRemain; iRightEdgeTemp = +iLeftEdgeDxTemp7 % (int16)iLeftRemain; iLeftEdgeDx_1 = iNewStep_1; if +(iNewStep_1 < 0) iLeftEdgeX += iNewStep_1; goto LEFT_EDGE_COMPLETE; } } goto RESTORE_AND_RETURN; @@ -2291,14 +2295,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) iRightEdgeTemp -= iCurrScanline; iRightRemain = iRightEdgeTemp; if ((int16)iRightEdgeTemp > 0) { - SET_HIWORD(iTempEdgeDx5, GET_LOWORD(pVertex_3->x) - GET_HIWORD(iRightEdgeX)); - SET_LOWORD(iRightEdgeX, 0); - SET_LOWORD(iTempEdgeDx5, 0); - iStep_5 = iTempEdgeDx5 / (int16)iRightEdgeTemp; - iRightEdgeDx = iStep_5; - if (iStep_5 > 0) - iRightEdgeX += iStep_5; - goto SCANLINE_CHECK; + SET_HIWORD(iTempEdgeDx5, GET_LOWORD(pVertex_3->x) - +GET_HIWORD(iRightEdgeX)); SET_LOWORD(iRightEdgeX, 0); SET_LOWORD(iTempEdgeDx5, +0); iStep_5 = iTempEdgeDx5 / (int16)iRightEdgeTemp; iRightEdgeDx = iStep_5; if +(iStep_5 > 0) iRightEdgeX += iStep_5; goto SCANLINE_CHECK; } } goto RESTORE_AND_RETURN; @@ -2333,8 +2333,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) // Right clipped scanline processing RIGHT_CLIPPED_RENDER: pDest3 = &scrptr[GET_SHIWORD(iLeftEdgeX) + iOldWinW * iCurrScanline]; - for (iPixelIdx_1 = 0; iOldWinW - GET_SHIWORD(iLeftEdgeX) > iPixelIdx_1; ++iPixelIdx_1) { - *pDest3 = pShadePalette[*pDest3]; + for (iPixelIdx_1 = 0; iOldWinW - GET_SHIWORD(iLeftEdgeX) > +iPixelIdx_1; ++iPixelIdx_1) { *pDest3 = pShadePalette[*pDest3]; ++pDest3; } // Advance to next scanline @@ -2359,15 +2359,11 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) SET_LOWORD(iTempY_5, pVertex_4->y); iLeftRemain = iTempY_5 - iCurrScanline; if ((int16)(iTempY_5 - iCurrScanline) > 0) { - SET_HIWORD(iLeftEdgeDxTemp6, GET_LOWORD(pVertex_4->x) - GET_HIWORD(iLeftEdgeX)); - SET_LOWORD(iLeftEdgeX, 0); - SET_LOWORD(iLeftEdgeDxTemp6, 0); - iNewStep_2 = iLeftEdgeDxTemp6 / (int16)iLeftRemain; - iRightEdgeTemp_1 = iLeftEdgeDxTemp6 % (int16)iLeftRemain; - iLeftEdgeDx_1 = iNewStep_2; - if (iNewStep_2 < 0) - iLeftEdgeX += iNewStep_2; - goto LEFT_EDGE_COMPLETE_2; + SET_HIWORD(iLeftEdgeDxTemp6, GET_LOWORD(pVertex_4->x) - +GET_HIWORD(iLeftEdgeX)); SET_LOWORD(iLeftEdgeX, 0); SET_LOWORD(iLeftEdgeDxTemp6, +0); iNewStep_2 = iLeftEdgeDxTemp6 / (int16)iLeftRemain; iRightEdgeTemp_1 = +iLeftEdgeDxTemp6 % (int16)iLeftRemain; iLeftEdgeDx_1 = iNewStep_2; if +(iNewStep_2 < 0) iLeftEdgeX += iNewStep_2; goto LEFT_EDGE_COMPLETE_2; } } goto RESTORE_AND_RETURN; @@ -2390,14 +2386,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) iRightEdgeTemp_1 -= iCurrScanline; iRightRemain = iRightEdgeTemp_1; if ((int16)iRightEdgeTemp_1 > 0) { - SET_HIWORD(iTempEdgeDx4, GET_LOWORD(pVertex_5->x) - GET_HIWORD(iRightEdgeX)); - SET_LOWORD(iRightEdgeX, 0); - SET_LOWORD(iTempEdgeDx4, 0); - iStep_6 = iTempEdgeDx4 / (int16)iRightEdgeTemp_1; - iRightEdgeDx = iStep_6; - if (iStep_6 > 0) - iRightEdgeX += iStep_6; - goto SCANLINE_CHECK_2; + SET_HIWORD(iTempEdgeDx4, GET_LOWORD(pVertex_5->x) - +GET_HIWORD(iRightEdgeX)); SET_LOWORD(iRightEdgeX, 0); SET_LOWORD(iTempEdgeDx4, +0); iStep_6 = iTempEdgeDx4 / (int16)iRightEdgeTemp_1; iRightEdgeDx = iStep_6; if +(iStep_6 > 0) iRightEdgeX += iStep_6; goto SCANLINE_CHECK_2; } } goto RESTORE_AND_RETURN; @@ -2428,8 +2420,8 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) // Left-visible scanline processing RENDER_LEFT_VISIBLE_SEGMENT: pDest2 = &scrptr[iOldWinW * iCurrScanline]; - for (iPixelIdx_2 = 0; GET_SHIWORD(iRightEdgeX) + 1 > iPixelIdx_2; ++iPixelIdx_2) { - *pDest2 = pShadePalette[*pDest2]; + for (iPixelIdx_2 = 0; GET_SHIWORD(iRightEdgeX) + 1 > iPixelIdx_2; +++iPixelIdx_2) { *pDest2 = pShadePalette[*pDest2]; ++pDest2; } @@ -2454,15 +2446,11 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) SET_LOWORD(nTempX_10, pVertex_6->y); iLeftRemain = nTempX_10 - iCurrScanline; if ((int16)(nTempX_10 - iCurrScanline) > 0) { - SET_HIWORD(iLeftEdgeDxTemp5, GET_LOWORD(pVertex_6->x) - GET_HIWORD(iLeftEdgeX)); - SET_LOWORD(iLeftEdgeX, 0); - SET_LOWORD(iLeftEdgeDxTemp5, 0); - iNewStep_3 = iLeftEdgeDxTemp5 / (int16)iLeftRemain; - iStep_2 = iLeftEdgeDxTemp5 % (int16)iLeftRemain; - iLeftEdgeDx_1 = iNewStep_3; - if (iNewStep_3 < 0) - iLeftEdgeX += iNewStep_3; - goto LEFT_EDGE_COMPLETE_3; + SET_HIWORD(iLeftEdgeDxTemp5, GET_LOWORD(pVertex_6->x) - +GET_HIWORD(iLeftEdgeX)); SET_LOWORD(iLeftEdgeX, 0); SET_LOWORD(iLeftEdgeDxTemp5, +0); iNewStep_3 = iLeftEdgeDxTemp5 / (int16)iLeftRemain; iStep_2 = +iLeftEdgeDxTemp5 % (int16)iLeftRemain; iLeftEdgeDx_1 = iNewStep_3; if +(iNewStep_3 < 0) iLeftEdgeX += iNewStep_3; goto LEFT_EDGE_COMPLETE_3; } } goto RESTORE_AND_RETURN; @@ -2485,14 +2473,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) iStep_2 -= iCurrScanline; iRightRemain = iStep_2; if ((int16)iStep_2 > 0) { - SET_HIWORD(iTempEdgeDx3, GET_LOWORD(pVertex_7->x) - GET_HIWORD(iRightEdgeX)); - SET_LOWORD(iRightEdgeX, 0); - SET_LOWORD(iTempEdgeDx3, 0); - iStep_8 = iTempEdgeDx3 / (int16)iStep_2; - iRightEdgeDx = iStep_8; - if (iStep_8 > 0) - iRightEdgeX += iStep_8; - goto SCANLINE_CHECK_3; + SET_HIWORD(iTempEdgeDx3, GET_LOWORD(pVertex_7->x) - +GET_HIWORD(iRightEdgeX)); SET_LOWORD(iRightEdgeX, 0); SET_LOWORD(iTempEdgeDx3, +0); iStep_8 = iTempEdgeDx3 / (int16)iStep_2; iRightEdgeDx = iStep_8; if (iStep_8 +> 0) iRightEdgeX += iStep_8; goto SCANLINE_CHECK_3; } } goto RESTORE_AND_RETURN; @@ -2517,9 +2501,9 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) } // Calculate visible segment width - nSegmentWidth = (int16)(GET_HIWORD(iRightEdgeX) - GET_HIWORD(iLeftEdgeX) + 1); - if (nSegmentWidth < 0) // Negative width check - goto RESTORE_AND_RETURN; + nSegmentWidth = (int16)(GET_HIWORD(iRightEdgeX) - GET_HIWORD(iLeftEdgeX) + +1); if (nSegmentWidth < 0) // Negative width check goto +RESTORE_AND_RETURN; // Process visible scanline segment pDest4 = &scrptr[GET_SHIWORD(iLeftEdgeX) + iOldWinW * iCurrScanline]; @@ -2559,14 +2543,10 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) iStepOffset_1 -= iCurrScanline; iRightRemain = iStepOffset_1; if ((int16)iStepOffset_1 > 0) { - SET_HIWORD(iTempEdgeDx2, GET_LOWORD(pVertex_8->x) - GET_HIWORD(iRightEdgeX)); - SET_LOWORD(iRightEdgeX, 0); - SET_LOWORD(iTempEdgeDx2, 0); - iStep_7 = iTempEdgeDx2 / (int16)iStepOffset_1; - iRightEdgeDx = iStep_7; - if (iStep_7 > 0) - iRightEdgeX += iStep_7; - goto NEXT_SCANLINE; + SET_HIWORD(iTempEdgeDx2, GET_LOWORD(pVertex_8->x) - +GET_HIWORD(iRightEdgeX)); SET_LOWORD(iRightEdgeX, 0); SET_LOWORD(iTempEdgeDx2, +0); iStep_7 = iTempEdgeDx2 / (int16)iStepOffset_1; iRightEdgeDx = iStep_7; if +(iStep_7 > 0) iRightEdgeX += iStep_7; goto NEXT_SCANLINE; } } goto RESTORE_AND_RETURN; @@ -2590,15 +2570,11 @@ void shadow_poly(tPoint *vertices, int iNumVerts, int iPaletteIndex) SET_LOWORD(iVertexIdx_2, pVertex_9->y); iLeftRemain = iVertexIdx_2 - iCurrScanline; if ((int16)(iVertexIdx_2 - iCurrScanline) > 0) { - SET_HIWORD(iLeftEdgeDxTemp4, GET_LOWORD(pVertex_9->x) - GET_HIWORD(iLeftEdgeX)); - SET_LOWORD(iLeftEdgeX, 0); - SET_LOWORD(iLeftEdgeDxTemp4, 0); - iNewStep_4 = iLeftEdgeDxTemp4 / (int16)iLeftRemain; - iStepOffset_1 = iLeftEdgeDxTemp4 % (int16)iLeftRemain; - iLeftEdgeDx_1 = iNewStep_4; - if (iNewStep_4 < 0) - iLeftEdgeX += iNewStep_4; - goto PROCESS_RIGHT_EDGE; + SET_HIWORD(iLeftEdgeDxTemp4, GET_LOWORD(pVertex_9->x) - +GET_HIWORD(iLeftEdgeX)); SET_LOWORD(iLeftEdgeX, 0); SET_LOWORD(iLeftEdgeDxTemp4, +0); iNewStep_4 = iLeftEdgeDxTemp4 / (int16)iLeftRemain; iStepOffset_1 = +iLeftEdgeDxTemp4 % (int16)iLeftRemain; iLeftEdgeDx_1 = iNewStep_4; if +(iNewStep_4 < 0) iLeftEdgeX += iNewStep_4; goto PROCESS_RIGHT_EDGE; } } RESTORE_AND_RETURN: diff --git a/PROJECTS/ROLLER/polyf.h b/PROJECTS/ROLLER/polyf.h index a756d4ba..70c45c6a 100644 --- a/PROJECTS/ROLLER/polyf.h +++ b/PROJECTS/ROLLER/polyf.h @@ -5,8 +5,7 @@ #include "frontend.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iSurfaceType; uint32 uiNumVerts; tPoint vertices[4]; diff --git a/PROJECTS/ROLLER/polytex.c b/PROJECTS/ROLLER/polytex.c index 216cdb7d..e306d695 100644 --- a/PROJECTS/ROLLER/polytex.c +++ b/PROJECTS/ROLLER/polytex.c @@ -14,152 +14,157 @@ typedef uint32 _DWORD; //------------------------------------------------------------------------------------------------- -fixed16_16 startsx[4] = { 0x3FF000, 0x0, 0x0, 0x3FF000 }; //000A7474 0x3FF000 = 64.0 in 16.16 fixed point -fixed16_16 startsy[4] = { 0x0, 0x0, 0x3FF000, 0x3FF000 }; //000A7484 0x3FF000 = 64.0 in 16.16 fixed point -//fixed16_16 nTexU = 0; //000A7498 -//fixed16_16 nTexV = 0; //000A749C -//fixed16_16 nTexDuDx = 0; //000A74A0 -//fixed16_16 nTexDvDx = 0; //000A74A4 -int texture_back[4608]; //0019A420 -uint8 *scrptr; //0019EC20 -uint8 *scrptr1; //0019EC24 -uint8 *mapsel[4884]; //0019EC28 changed to uint8* by ROLLER, original code these are 16-bit DOS selectors, [19][257] +fixed16_16 startsx[4] = { + 0x3FF000, 0x0, 0x0, + 0x3FF000}; // 000A7474 0x3FF000 = 64.0 in 16.16 fixed point +fixed16_16 startsy[4] = { + 0x0, 0x0, 0x3FF000, + 0x3FF000}; // 000A7484 0x3FF000 = 64.0 in 16.16 fixed point +// fixed16_16 nTexU = 0; //000A7498 +// fixed16_16 nTexV = 0; //000A749C +// fixed16_16 nTexDuDx = 0; //000A74A0 +// fixed16_16 nTexDvDx = 0; //000A74A4 +int texture_back[4608]; // 0019A420 +uint8 *scrptr; // 0019EC20 +uint8 *scrptr1; // 0019EC24 +uint8 *mapsel[4884]; // 0019EC28 changed to uint8* by ROLLER, original code + // these are 16-bit DOS selectors, [19][257] //------------------------------------------------------------------------------------------------- -//0006BBF0 -void remove_mapsels() -{ +// 0006BBF0 +void remove_mapsels() { // Clear all mapsel arrays memset(mapsel, 0, sizeof(mapsel)); // Clear texture counts memset(num_textures, 0, sizeof(num_textures)); - //int iCarIdx; // ebp - //int iMapselOffset; // ecx - //int iCarDataOffset; // edi - //int iTextureIdx; // esi - //int iNextCarDataOffset; // esi - //int iNextMapselOffset; // eax - //int iTrackTexIdx; // esi - //int iMapselOffset_1; // ecx - //int iBldTexIdx; // esi - //int iBuildingMapselIdx; // ecx - //int iCarGenTexIdx; // esi - //int iCarGenMapselIdx; // ecx - //union REGS regs; // [esp+0h] [ebp-3Ch] BYREF - //int iCarIdxCounter; // [esp+1Ch] [ebp-20h] - //int iCarMapselOffset; // [esp+20h] [ebp-1Ch] + // int iCarIdx; // ebp + // int iMapselOffset; // ecx + // int iCarDataOffset; // edi + // int iTextureIdx; // esi + // int iNextCarDataOffset; // esi + // int iNextMapselOffset; // eax + // int iTrackTexIdx; // esi + // int iMapselOffset_1; // ecx + // int iBldTexIdx; // esi + // int iBuildingMapselIdx; // ecx + // int iCarGenTexIdx; // esi + // int iCarGenMapselIdx; // ecx + // union REGS regs; // [esp+0h] [ebp-3Ch] BYREF + // int iCarIdxCounter; // [esp+1Ch] [ebp-20h] + // int iCarMapselOffset; // [esp+20h] [ebp-1Ch] // - //iCarIdxCounter = 1; + // iCarIdxCounter = 1; // //// Process car textures - //if (LoadCarTextures > 1) { - // iCarIdx = 1; - // iCarMapselOffset = 514; // starting offset: 514 = 257*2 (skip types 0 and 1) - // do { - // iMapselOffset = iCarMapselOffset; - // iCarDataOffset = iCarIdx * 4; // 4 bytes per car entry + // if (LoadCarTextures > 1) { + // iCarIdx = 1; + // iCarMapselOffset = 514; // starting offset: 514 = + // 257*2 (skip types 0 and 1) do { + // iMapselOffset = iCarMapselOffset; + // iCarDataOffset = iCarIdx * 4; // 4 bytes per car entry // - // // Process all textures for this car - // for (iTextureIdx = 0; iTextureIdx < bld_remap[iCarIdx + 255]; iMapselOffset += 2)// reference into num_textures - // { - // // Check if selector is allocated - // if (*(int16 *)((char *)mapsel[0] + iMapselOffset)) { - // // Free the selector - // regs.w.bx = *(int16 *)((char *)mapsel[0] + iMapselOffset); - // regs.w.ax = 1; // DPMI function: free LDT descriptor - // int386(0x31, ®s, ®s); // DPMI services - // // Clear the selector entry - // *(int16 *)((char *)mapsel[0] + iMapselOffset) = 0; - // } - // ++iTextureIdx; - // } + // // Process all textures for this car + // for (iTextureIdx = 0; iTextureIdx < bld_remap[iCarIdx + 255]; + // iMapselOffset += 2)// reference into num_textures + // { + // // Check if selector is allocated + // if (*(int16 *)((char *)mapsel[0] + iMapselOffset)) { + // // Free the selector + // regs.w.bx = *(int16 *)((char *)mapsel[0] + iMapselOffset); + // regs.w.ax = 1; // DPMI function: free LDT + // descriptor int386(0x31, ®s, ®s); // DPMI services + // // Clear the selector entry + // *(int16 *)((char *)mapsel[0] + iMapselOffset) = 0; + // } + // ++iTextureIdx; + // } // - // iNextCarDataOffset = iCarMapselOffset; - // iNextMapselOffset = LoadCarTextures; - // ++iCarIdx; + // iNextCarDataOffset = iCarMapselOffset; + // iNextMapselOffset = LoadCarTextures; + // ++iCarIdx; // - // // Clear tex count for this car - // *(int *)((char *)&bld_remap[255] + iCarDataOffset) = 0;// reference into num_textures + // // Clear tex count for this car + // *(int *)((char *)&bld_remap[255] + iCarDataOffset) = 0;// reference + // into num_textures // - // // Move to next car's mapsel area - // iCarMapselOffset = iNextCarDataOffset + 514; - // ++iCarIdxCounter; - // } while (iCarIdxCounter < iNextMapselOffset); - //} + // // Move to next car's mapsel area + // iCarMapselOffset = iNextCarDataOffset + 514; + // ++iCarIdxCounter; + // } while (iCarIdxCounter < iNextMapselOffset); + // } // //// Process track textures - //iTrackTexIdx = 0; - //if (num_textures[19] > 0) { - // iMapselOffset_1 = 0; - // do { - // // Check if selector is allocated - // if (mapsel[0][iMapselOffset_1]) { - // // Free the selector - // regs.w.bx = mapsel[0][iMapselOffset_1]; - // regs.w.ax = 1; - // int386(0x31, ®s, ®s); + // iTrackTexIdx = 0; + // if (num_textures[19] > 0) { + // iMapselOffset_1 = 0; + // do { + // // Check if selector is allocated + // if (mapsel[0][iMapselOffset_1]) { + // // Free the selector + // regs.w.bx = mapsel[0][iMapselOffset_1]; + // regs.w.ax = 1; + // int386(0x31, ®s, ®s); // - // // Clear the selector entry - // mapsel[0][iMapselOffset_1] = 0; - // } - // ++iTrackTexIdx; - // ++iMapselOffset_1; - // } while (iTrackTexIdx < num_textures[19]); - //} - //iBldTexIdx = 0; - //num_textures[19] = 0; // clear track tex count + // // Clear the selector entry + // mapsel[0][iMapselOffset_1] = 0; + // } + // ++iTrackTexIdx; + // ++iMapselOffset_1; + // } while (iTrackTexIdx < num_textures[19]); + // } + // iBldTexIdx = 0; + // num_textures[19] = 0; // clear track tex count // //// Process bld textures - //if (num_textures[17] > 0) { - // iBuildingMapselIdx = 0; - // do { - // // Check if selector is allocated - // if (mapsel[17][iBuildingMapselIdx]) { - // // free the selector - // regs.w.bx = mapsel[17][iBuildingMapselIdx]; - // regs.w.ax = 1; - // int386(0x31, ®s, ®s); + // if (num_textures[17] > 0) { + // iBuildingMapselIdx = 0; + // do { + // // Check if selector is allocated + // if (mapsel[17][iBuildingMapselIdx]) { + // // free the selector + // regs.w.bx = mapsel[17][iBuildingMapselIdx]; + // regs.w.ax = 1; + // int386(0x31, ®s, ®s); // - // // Clear the selector entry - // mapsel[17][iBuildingMapselIdx] = 0; - // } - // ++iBldTexIdx; - // ++iBuildingMapselIdx; - // } while (iBldTexIdx < num_textures[17]); - //} - //iCarGenTexIdx = 0; - //num_textures[17] = 0; // clear building tex count + // // Clear the selector entry + // mapsel[17][iBuildingMapselIdx] = 0; + // } + // ++iBldTexIdx; + // ++iBuildingMapselIdx; + // } while (iBldTexIdx < num_textures[17]); + // } + // iCarGenTexIdx = 0; + // num_textures[17] = 0; // clear building tex count // //// process car gen textures - //if (num_textures[18] > 0) { - // iCarGenMapselIdx = 0; - // do { - // if (mapsel[18][iCarGenMapselIdx]) { - // // Free the selector - // regs.w.bx = mapsel[18][iCarGenMapselIdx]; - // regs.w.ax = 1; - // int386(0x31, ®s, ®s); + // if (num_textures[18] > 0) { + // iCarGenMapselIdx = 0; + // do { + // if (mapsel[18][iCarGenMapselIdx]) { + // // Free the selector + // regs.w.bx = mapsel[18][iCarGenMapselIdx]; + // regs.w.ax = 1; + // int386(0x31, ®s, ®s); // - // // Clear the selector entry - // mapsel[18][iCarGenMapselIdx] = 0; - // } - // ++iCarGenTexIdx; - // ++iCarGenMapselIdx; - // } while (iCarGenTexIdx < num_textures[18]); - //} + // // Clear the selector entry + // mapsel[18][iCarGenMapselIdx] = 0; + // } + // ++iCarGenTexIdx; + // ++iCarGenMapselIdx; + // } while (iCarGenTexIdx < num_textures[18]); + // } // //// Clear car gen tex count - //num_textures[18] = 0; + // num_textures[18] = 0; } //------------------------------------------------------------------------------------------------- -//0006BDB0 -void setmapsel(uint8_t *pBase, int iIndex, int iMode, int iCount) -{ -// Calculate base offset in mapsel array for this texture index -// Original used 257 * iIndex, but since we changed from int16 to uint8*, -// and POLYTEX uses 514 * iTexIdx, we need to adjust +// 0006BDB0 +void setmapsel(uint8_t *pBase, int iIndex, int iMode, int iCount) { + // Calculate base offset in mapsel array for this texture index + // Original used 257 * iIndex, but since we changed from int16 to uint8*, + // and POLYTEX uses 514 * iTexIdx, we need to adjust int iBaseMapselIndex = 257 * iIndex; // Set up pointers for each texture @@ -167,77 +172,76 @@ void setmapsel(uint8_t *pBase, int iIndex, int iMode, int iCount) uint8_t *pTexturePointer; if (iMode == 1) { - // Mode 1: 8-segment grouping (32x32 textures) - // Original: iCoarseOffset = (i >> 3 << 13) + iBaseAdjusted; - // iFineOffset = 32 * (i & 7); - int iCoarseOffset = (i >> 3) << 13; // (i / 8) * 8192 - int iFineOffset = 32 * (i & 7); // 32 * (i % 8) + // Mode 1: 8-segment grouping (32x32 textures) + // Original: iCoarseOffset = (i >> 3 << 13) + iBaseAdjusted; + // iFineOffset = 32 * (i & 7); + int iCoarseOffset = (i >> 3) << 13; // (i / 8) * 8192 + int iFineOffset = 32 * (i & 7); // 32 * (i % 8) pTexturePointer = pBase + iCoarseOffset + iFineOffset; } else { - // Mode 0: 4-segment grouping (64x64 textures) - interleaved layout - // Original: iCoarseOffset = (i & 3) << 6; - // iFineOffset = iBaseAdjusted + (i >> 2 << 14); - int iCoarseOffset = (i & 3) << 6; // (i % 4) * 64 - int iFineOffset = (i >> 2) << 14; // (i / 4) * 16384 + // Mode 0: 4-segment grouping (64x64 textures) - interleaved layout + // Original: iCoarseOffset = (i & 3) << 6; + // iFineOffset = iBaseAdjusted + (i >> 2 << 14); + int iCoarseOffset = (i & 3) << 6; // (i % 4) * 64 + int iFineOffset = (i >> 2) << 14; // (i / 4) * 16384 pTexturePointer = pBase + iFineOffset + iCoarseOffset; } -// Store pointer in mapsel array + // Store pointer in mapsel array mapsel[iBaseMapselIndex + i] = pTexturePointer; } } //------------------------------------------------------------------------------------------------- -//0006BF50 -void twpolym(tPoint *vertices, uint8 *pTex) -{ - int16 nEdge01X; // bx - int16 nEdge01Y; // si - int16 nEdge02Y; // di - int iOgStartsY2_1; // ebx - double dIntersectionX1_1; // st6 - double dIntersectionY1_1; // st6 - tPoint *pCurrVert; // edi - double dIntersectionX1; // st6 - double dIntersectionY1; // st6 - int iCrossProduct2_1; // ebp - double dIntersectionY1_3; // st6 - tPoint *pNextVert; // edi - double dIntersectionY1_2; // st6 - int iSwappedStartsX; // eax - int iSwappedStartsY; // ebp - int iSwappedStartsX_1; // esi - tPoint pSavedVert; // [esp+0h] [ebp-9Ch] - tPoint pVert1Copy; // [esp+8h] [ebp-94h] +// 0006BF50 +void twpolym(tPoint *vertices, uint8 *pTex) { + int16 nEdge01X; // bx + int16 nEdge01Y; // si + int16 nEdge02Y; // di + int iOgStartsY2_1; // ebx + double dIntersectionX1_1; // st6 + double dIntersectionY1_1; // st6 + tPoint *pCurrVert; // edi + double dIntersectionX1; // st6 + double dIntersectionY1; // st6 + int iCrossProduct2_1; // ebp + double dIntersectionY1_3; // st6 + tPoint *pNextVert; // edi + double dIntersectionY1_2; // st6 + int iSwappedStartsX; // eax + int iSwappedStartsY; // ebp + int iSwappedStartsX_1; // esi + tPoint pSavedVert; // [esp+0h] [ebp-9Ch] + tPoint pVert1Copy; // [esp+8h] [ebp-94h] tPoint pIntersectionVert_1; // [esp+10h] [ebp-8Ch] - tPoint pIntersectionVert; // [esp+10h] [ebp-8Ch] - int iDeltaTexY23; // [esp+1Ch] [ebp-80h] - int iDeltaTexX23; // [esp+20h] [ebp-7Ch] - float fCrossProduct2; // [esp+24h] [ebp-78h] - float fCrossProduct1; // [esp+28h] [ebp-74h] - int iOgStartsX1_1; // [esp+2Ch] [ebp-70h] - int iOgStartsY1_1; // [esp+30h] [ebp-6Ch] - int iOgStartsX0_1; // [esp+34h] [ebp-68h] - int iOgStartsX1; // [esp+38h] [ebp-64h] - int iOgStartsY0_1; // [esp+3Ch] [ebp-60h] - int iOgStartsY1; // [esp+40h] [ebp-5Ch] - int iOgStartsY0; // [esp+44h] [ebp-58h] - int iOgStartsX0; // [esp+48h] [ebp-54h] - int iCrossProduct2; // [esp+4Ch] [ebp-50h] - int iCrossProduct1; // [esp+50h] [ebp-4Ch] - int iOgStartsY2; // [esp+54h] [ebp-48h] - int iOgStartsX2; // [esp+58h] [ebp-44h] - int iOgStartsY2_2; // [esp+5Ch] [ebp-40h] - int iOgStartsX2_1; // [esp+60h] [ebp-3Ch] - float fIntersection; // [esp+64h] [ebp-38h] - float fIntersection_1; // [esp+68h] [ebp-34h] - int16 nEdge23X; // [esp+6Ch] [ebp-30h] - int16 nEdge23Y; // [esp+70h] [ebp-2Ch] - int16 nEdge02X; // [esp+74h] [ebp-28h] - int16 nDiagonal13X; // [esp+78h] [ebp-24h] - int16 nDiagonal03Y; // [esp+7Ch] [ebp-20h] - int16 nDiagonal13Y; // [esp+80h] [ebp-1Ch] - int16 nDiagonal03X; // [esp+84h] [ebp-18h] + tPoint pIntersectionVert; // [esp+10h] [ebp-8Ch] + int iDeltaTexY23; // [esp+1Ch] [ebp-80h] + int iDeltaTexX23; // [esp+20h] [ebp-7Ch] + float fCrossProduct2; // [esp+24h] [ebp-78h] + float fCrossProduct1; // [esp+28h] [ebp-74h] + int iOgStartsX1_1; // [esp+2Ch] [ebp-70h] + int iOgStartsY1_1; // [esp+30h] [ebp-6Ch] + int iOgStartsX0_1; // [esp+34h] [ebp-68h] + int iOgStartsX1; // [esp+38h] [ebp-64h] + int iOgStartsY0_1; // [esp+3Ch] [ebp-60h] + int iOgStartsY1; // [esp+40h] [ebp-5Ch] + int iOgStartsY0; // [esp+44h] [ebp-58h] + int iOgStartsX0; // [esp+48h] [ebp-54h] + int iCrossProduct2; // [esp+4Ch] [ebp-50h] + int iCrossProduct1; // [esp+50h] [ebp-4Ch] + int iOgStartsY2; // [esp+54h] [ebp-48h] + int iOgStartsX2; // [esp+58h] [ebp-44h] + int iOgStartsY2_2; // [esp+5Ch] [ebp-40h] + int iOgStartsX2_1; // [esp+60h] [ebp-3Ch] + float fIntersection; // [esp+64h] [ebp-38h] + float fIntersection_1; // [esp+68h] [ebp-34h] + int16 nEdge23X; // [esp+6Ch] [ebp-30h] + int16 nEdge23Y; // [esp+70h] [ebp-2Ch] + int16 nEdge02X; // [esp+74h] [ebp-28h] + int16 nDiagonal13X; // [esp+78h] [ebp-24h] + int16 nDiagonal03Y; // [esp+7Ch] [ebp-20h] + int16 nDiagonal13Y; // [esp+80h] [ebp-1Ch] + int16 nDiagonal03X; // [esp+84h] [ebp-18h] // Calcualte edge vectors for intersection testing nEdge01X = GET_LOWORD(vertices[1].x) - GET_LOWORD(vertices->x); @@ -257,11 +261,12 @@ void twpolym(tPoint *vertices, uint8 *pTex) // Test for intersection between edgse 0-1 and 2-3 fCrossProduct1 = (float)(nEdge23Y * nEdge01X - nEdge01Y * nEdge23X); - if (fabs(fCrossProduct1) != 0.0// non-parallel edges - && (iCrossProduct1 = nEdge02X * nEdge01Y - nEdge02Y * nEdge01X, - fIntersection = (float)((double)iCrossProduct1 / (double)fCrossProduct1), - fIntersection > 0.0) - && fIntersection < 1.0) // valid intersection exists + if (fabs(fCrossProduct1) != 0.0 // non-parallel edges + && + (iCrossProduct1 = nEdge02X * nEdge01Y - nEdge02Y * nEdge01X, + fIntersection = (float)((double)iCrossProduct1 / (double)fCrossProduct1), + fIntersection > 0.0) && + fIntersection < 1.0) // valid intersection exists { // Save original texcoords iOgStartsX0 = startsx[0]; @@ -282,22 +287,26 @@ void twpolym(tPoint *vertices, uint8 *pTex) *vertices = vertices[2]; // Calcualte intersection point on edge 2-3 - dIntersectionX1 = (double)nEdge23X * fIntersection + (double)vertices[2].x; + dIntersectionX1 = + (double)nEdge23X * fIntersection + (double)vertices[2].x; //_CHP(); vertices[2].x = (int)dIntersectionX1; - dIntersectionY1 = (double)nEdge23Y * fIntersection + (double)vertices[2].y; + dIntersectionY1 = + (double)nEdge23Y * fIntersection + (double)vertices[2].y; //_CHP(); vertices[2].y = (int)dIntersectionY1; // Interpolate tex coords at intersection //_CHP(); - startsx[2] = (int)((double)iDeltaTexX23 * fIntersection + (double)iOgStartsX2); + startsx[2] = + (int)((double)iDeltaTexX23 * fIntersection + (double)iOgStartsX2); startsy[0] = iOgStartsY2_1; startsx[1] = iOgStartsX1; //_CHP(); startsx[0] = iOgStartsX2; startsy[1] = iOgStartsY1; - startsy[2] = (int)(fIntersection * (double)iDeltaTexY23 + (double)iOgStartsY2); + startsy[2] = + (int)(fIntersection * (double)iDeltaTexY23 + (double)iOgStartsY2); // Render first tri polym(vertices, 3, pTex); @@ -308,29 +317,33 @@ void twpolym(tPoint *vertices, uint8 *pTex) startsy[1] = startsy[3]; pCurrVert = vertices + 1; startsy[0] = iOgStartsY0; - } else // intersection from other side + } else // intersection from other side { // Reorder verts: start from vert 1 *vertices = vertices[1]; vertices[1] = vertices[2]; // Calculate intersection point - dIntersectionX1_1 = (double)nEdge23X * fIntersection + (double)vertices[2].x; + dIntersectionX1_1 = + (double)nEdge23X * fIntersection + (double)vertices[2].x; //_CHP(); vertices[2].x = (int)dIntersectionX1_1; - dIntersectionY1_1 = (double)nEdge23Y * fIntersection + (double)vertices[2].y; + dIntersectionY1_1 = + (double)nEdge23Y * fIntersection + (double)vertices[2].y; // Interpolate tex coords //_CHP(); vertices[2].y = (int)dIntersectionY1_1; //_CHP(); - startsx[2] = (int)((double)iDeltaTexX23 * fIntersection + (double)iOgStartsX2); + startsx[2] = + (int)((double)iDeltaTexX23 * fIntersection + (double)iOgStartsX2); startsy[1] = iOgStartsY2_1; startsx[0] = iOgStartsX1; //_CHP(); startsx[1] = iOgStartsX2; startsy[0] = iOgStartsY1; - startsy[2] = (int)(fIntersection * (double)iDeltaTexY23 + (double)iOgStartsY2); + startsy[2] = + (int)(fIntersection * (double)iDeltaTexY23 + (double)iOgStartsY2); // Render first tri polym(vertices, 3, pTex); @@ -356,13 +369,16 @@ void twpolym(tPoint *vertices, uint8 *pTex) startsy[2] = iOgStartsY2; } else { // Test for intersection between edges 1-3 and 0-2 - fCrossProduct2 = (float)(nDiagonal13Y * nDiagonal03X - nDiagonal03Y * nDiagonal13X); - if (fabs(fCrossProduct2) != 0.0// non-parallel - && (iCrossProduct2_1 = nEdge02X * nDiagonal03Y - nDiagonal03X * nEdge02Y, - iCrossProduct2 = iCrossProduct2_1, - fIntersection_1 = (float)((double)iCrossProduct2_1 / (double)fCrossProduct2), - fIntersection_1 > 0.0) - && fIntersection_1 < 1.0) // valid intersection + fCrossProduct2 = + (float)(nDiagonal13Y * nDiagonal03X - nDiagonal03Y * nDiagonal13X); + if (fabs(fCrossProduct2) != 0.0 // non-parallel + && + (iCrossProduct2_1 = nEdge02X * nDiagonal03Y - nDiagonal03X * nEdge02Y, + iCrossProduct2 = iCrossProduct2_1, + fIntersection_1 = + (float)((double)iCrossProduct2_1 / (double)fCrossProduct2), + fIntersection_1 > 0.0) && + fIntersection_1 < 1.0) // valid intersection { // Save original tex coords iOgStartsX0_1 = startsx[0]; @@ -382,8 +398,10 @@ void twpolym(tPoint *vertices, uint8 *pTex) // Calculate intersection point pIntersectionVert_1 = vertices[2]; //_CHP(); - vertices[2].x = (int)((double)nDiagonal13X * fIntersection_1 + (double)pIntersectionVert_1.x); - dIntersectionY1_2 = (double)nDiagonal13Y * fIntersection_1 + (double)vertices[2].y; + vertices[2].x = (int)((double)nDiagonal13X * fIntersection_1 + + (double)pIntersectionVert_1.x); + dIntersectionY1_2 = + (double)nDiagonal13Y * fIntersection_1 + (double)vertices[2].y; //_CHP(); // Setup tex coords @@ -395,9 +413,13 @@ void twpolym(tPoint *vertices, uint8 *pTex) // Interpolate tex coords at intersection //_CHP(); - startsx[2] = (int)((double)(iOgStartsX0_1 - iOgStartsX2_1) * fIntersection_1 + (double)iOgStartsX2_1); + startsx[2] = + (int)((double)(iOgStartsX0_1 - iOgStartsX2_1) * fIntersection_1 + + (double)iOgStartsX2_1); //_CHP(); - startsy[2] = (int)(fIntersection_1 * (double)(iOgStartsY0_1 - iOgStartsY2_2) + (double)iOgStartsY2_2); + startsy[2] = + (int)(fIntersection_1 * (double)(iOgStartsY0_1 - iOgStartsY2_2) + + (double)iOgStartsY2_2); // Render first tri polym(vertices, 3, pTex); @@ -408,20 +430,26 @@ void twpolym(tPoint *vertices, uint8 *pTex) startsy[1] = startsy[3]; pNextVert = vertices; startsy[0] = iOgStartsY2_2; - } else // intersection from other side + } else // intersection from other side { pIntersectionVert_1 = vertices[2]; //_CHP(); - vertices[2].x = (int)((double)nDiagonal13X * fIntersection_1 + (double)pIntersectionVert_1.x); - dIntersectionY1_3 = (double)nDiagonal13Y * fIntersection_1 + (double)vertices[2].y; + vertices[2].x = (int)((double)nDiagonal13X * fIntersection_1 + + (double)pIntersectionVert_1.x); + dIntersectionY1_3 = + (double)nDiagonal13Y * fIntersection_1 + (double)vertices[2].y; //_CHP(); vertices[2].y = (int)dIntersectionY1_3; // Interpolate tex coords //_CHP(); - startsx[2] = (int)((double)(iOgStartsX1_1 - iOgStartsX2_1) * fIntersection_1 + (double)iOgStartsX2_1); + startsx[2] = + (int)((double)(iOgStartsX1_1 - iOgStartsX2_1) * fIntersection_1 + + (double)iOgStartsX2_1); //_CHP(); - startsy[2] = (int)(fIntersection_1 * (double)(iOgStartsY1_1 - iOgStartsY2_2) + (double)iOgStartsY2_2); + startsy[2] = + (int)(fIntersection_1 * (double)(iOgStartsY1_1 - iOgStartsY2_2) + + (double)iOgStartsY2_2); // Render first tri polym(vertices, 3, pTex); @@ -441,11 +469,11 @@ void twpolym(tPoint *vertices, uint8 *pTex) startsy[1] = iOgStartsY1_1; startsx[2] = iOgStartsX2_1; startsy[2] = iOgStartsY2_2; - } else if (iCrossProduct1 >= 0 && iCrossProduct2 <= 0)// convex quad + } else if (iCrossProduct1 >= 0 && iCrossProduct2 <= 0) // convex quad { // Render as single quad polym(vertices, 4, pTex); - } else // concave - need to swap diagonal + } else // concave - need to swap diagonal { // Sawp verts 1 and 3 to change triangulation pSavedVert = vertices[1]; @@ -472,42 +500,43 @@ void twpolym(tPoint *vertices, uint8 *pTex) } //------------------------------------------------------------------------------------------------- -//0006C620 -void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTexIdx, int iGfxSize) -{ +// 0006C620 +void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, + int iTexIdx, int iGfxSize) { uint32 uiSurfaceType; // eax - int iVert0X; // edx - int iVert0Y; // ecx - int iDeltaX02; // edx - int iDeltaY02; // ecx - int iTempX; // edx - int iTempY; // ecx - int iTempX_1; // edx - int iTempY_1; // ecx - int iTempStartsX0; // edx - int iTempStartsX1; // edx - int iTempStartsY0; // edx - int iTempStartsY1; // edx - int iTexRowOffset; // ecx - int iTexColOffset; // eax - tPoint *vertices; // edx - //int iMapselOffset; // ebx - int iTempStartsX2; // eax - int iTempStartsX3; // eax - int iTempStartsY2; // eax - int iTempStartsY3; // eax - int iDeltaY01; // [esp+4h] [ebp-18h] - char iShouldFlipVert; // [esp+8h] [ebp-14h] + int iVert0X; // edx + int iVert0Y; // ecx + int iDeltaX02; // edx + int iDeltaY02; // ecx + int iTempX; // edx + int iTempY; // ecx + int iTempX_1; // edx + int iTempY_1; // ecx + int iTempStartsX0; // edx + int iTempStartsX1; // edx + int iTempStartsY0; // edx + int iTempStartsY1; // edx + int iTexRowOffset; // ecx + int iTexColOffset; // eax + tPoint *vertices; // edx + // int iMapselOffset; // ebx + int iTempStartsX2; // eax + int iTempStartsX3; // eax + int iTempStartsY2; // eax + int iTempStartsY3; // eax + int iDeltaY01; // [esp+4h] [ebp-18h] + char iShouldFlipVert; // [esp+8h] [ebp-14h] char iShouldFlipHoriz; // [esp+Ch] [ebp-10h] if (!pTexture) - return; //added by ROLLER + return; // added by ROLLER // Check if tex idx is valid for given tex type uiSurfaceType = pPolyParams->iSurfaceType; - if ((uint8)pPolyParams->iSurfaceType >= NoOfTextures && (uiSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0 && !iTexIdx - || (uint8)uiSurfaceType >= BldTextures && (uiSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0 && iTexIdx == 17) - { + if ((uint8)pPolyParams->iSurfaceType >= NoOfTextures && + (uiSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0 && !iTexIdx || + (uint8)uiSurfaceType >= BldTextures && + (uiSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0 && iTexIdx == 17) { // Invalid texture, render as flat colored pol instead pPolyParams->iSurfaceType = (uint8)pPolyParams->iSurfaceType; POLYFLAT(pScrBuf, pPolyParams); @@ -515,8 +544,7 @@ void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTex } // Textured rendering - if ((uiSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0) - { + if ((uiSurfaceType & SURFACE_FLAG_SKIP_RENDER) == 0) { scrptr = pScrBuf; scrptr1 = &pScrBuf[winw]; if ((uiSurfaceType & SURFACE_FLAG_FLIP_HORIZ) != 0) @@ -529,18 +557,18 @@ void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTex iShouldFlipVert = 0; // Handle backface culling and vertex reordering - //SURFACE_FLAG_BACK added by ROLLER, TODO: why didn't the IDA decomp check for this - //and how does it work? - if ((uiSurfaceType & (SURFACE_FLAG_FLIP_BACKFACE | SURFACE_FLAG_BACK)) != 0) - { + // SURFACE_FLAG_BACK added by ROLLER, TODO: why didn't the IDA decomp check + // for this and how does it work? + if ((uiSurfaceType & (SURFACE_FLAG_FLIP_BACKFACE | SURFACE_FLAG_BACK)) != + 0) { // Get first vertex coords for cross product calculation iVert0X = pPolyParams->vertices[0].x; iVert0Y = pPolyParams->vertices[0].y; iDeltaY01 = iVert0Y - pPolyParams->vertices[1].y; // Find a non-degenerate edge for cross product - if (pPolyParams->vertices[1].x == pPolyParams->vertices[2].x - && pPolyParams->vertices[1].y == pPolyParams->vertices[2].y) { + if (pPolyParams->vertices[1].x == pPolyParams->vertices[2].x && + pPolyParams->vertices[1].y == pPolyParams->vertices[2].y) { // Vertex 1 and 2 are the same, use vertex 3 iDeltaX02 = iVert0X - pPolyParams->vertices[3].x; iDeltaY02 = iVert0Y - pPolyParams->vertices[3].y; @@ -551,7 +579,9 @@ void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTex } // Cross product test for backface detection - if ((pPolyParams->vertices[0].x - pPolyParams->vertices[1].x) * iDeltaY02 > iDeltaY01 * iDeltaX02) { + if ((pPolyParams->vertices[0].x - pPolyParams->vertices[1].x) * + iDeltaY02 > + iDeltaY01 * iDeltaX02) { // Backface detected, swap vertex pairs to flip winding order // Swap verts 0 and 1 iTempX = pPolyParams->vertices[0].x; @@ -573,8 +603,7 @@ void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTex iShouldFlipHoriz = iShouldFlipHoriz == 0; // Handle back texture substitution - if ((uiSurfaceType & SURFACE_FLAG_BACK) != 0) - { + if ((uiSurfaceType & SURFACE_FLAG_BACK) != 0) { uiSurfaceType = texture_back[256 * iTexIdx + (uint8)uiSurfaceType]; uiSurfaceType |= SURFACE_FLAG_FLIP_BACKFACE; } @@ -605,23 +634,23 @@ void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTex ++num_pols; // Choose rendering method - if ((uiSurfaceType & SURFACE_FLAG_PARTIAL_TRANS) != 0) - { + if ((uiSurfaceType & SURFACE_FLAG_PARTIAL_TRANS) != 0) { if (iGfxSize) { // 32x32 textures, 8 per row - iTexRowOffset = (int)(int8)uiSurfaceType >> 3 << 13;// row * 8192 - iTexColOffset = 32 * (uiSurfaceType & 7);// col * 32 + iTexRowOffset = (int)(int8)uiSurfaceType >> 3 << 13; // row * 8192 + iTexColOffset = 32 * (uiSurfaceType & 7); // col * 32 } else { // 64x64 textures, 4 per row - iTexRowOffset = (int)(uint8)uiSurfaceType >> 2 << 14;// row * 16384 - iTexColOffset = (uiSurfaceType & 3) << 6;// col * 64 + iTexRowOffset = (int)(uint8)uiSurfaceType >> 2 << 14; // row * 16384 + iTexColOffset = (uiSurfaceType & 3) << 6; // col * 64 } // Render transparent textured polygon polyt(pPolyParams->vertices, 4, &pTexture[iTexRowOffset + iTexColOffset]); } else { // Opaque rendering vertices = pPolyParams->vertices; - // iMapselOffset = 514 * iTexIdx + 2 * (uint8)uiSurfaceType; //offset assumes array of int16s + // iMapselOffset = 514 * iTexIdx + 2 * (uint8)uiSurfaceType; //offset + // assumes array of int16s if ((uiSurfaceType & SURFACE_FLAG_CONCAVE) != 0) // Render concave pol (tri) twpolym(vertices, mapsel[257 * iTexIdx + (uint8)uiSurfaceType]); @@ -653,22 +682,20 @@ void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTex //------------------------------------------------------------------------------------------------- static int iTestPol = 0; -//if (iTestPol == 16) { -// memcpy(testbuf, pTex, sizeof(testbuf)); -//} +// if (iTestPol == 16) { +// memcpy(testbuf, pTex, sizeof(testbuf)); +// } //++iTestPol; //------------------------------------------------------------------------------------------------- -//0006C8D0 -void polym(tPoint *vertices, int iNumVerts, uint8 *pTex) -{ +// 0006C8D0 +void polym(tPoint *vertices, int iNumVerts, uint8 *pTex) { polyt(vertices, iNumVerts, pTex); } //------------------------------------------------------------------------------------------------- -//0006F240 -void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) -{ +// 0006F240 +void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) { // Find polygon bounds and top vertex int iMinX = vertices[0].x; int iMaxX = vertices[0].x; @@ -680,14 +707,17 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) int x = vertices[i].x; int y = vertices[i].y; - if (x < iMinX) iMinX = x; - if (x > iMaxX) iMaxX = x; + if (x < iMinX) + iMinX = x; + if (x > iMaxX) + iMaxX = x; if (y < iMinY) { iMinY = y; iTopVertexIdx = i; } - if (y > iMaxY) iMaxY = y; + if (y > iMaxY) + iMaxY = y; } // Early exit if polygon is completely outside screen @@ -699,7 +729,8 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) int iSignedArea = 0; for (int i = 0; i < iNumVerts; i++) { int j = (i + 1) % iNumVerts; - iSignedArea += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); + iSignedArea += + (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); } // Determine edge walking directions based on winding order @@ -715,16 +746,20 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) } // Edge walking variables (floating-point) - float fLeftEdgeX = 0.0f; // Left edge X position - float fRightEdgeX = 0.0f; // Right edge X position - float fLeftEdgeStep = 0.0f; // Left edge X step per scanline - float fRightEdgeStep = 0.0f; // Right edge X step per scanline + float fLeftEdgeX = 0.0f; // Left edge X position + float fRightEdgeX = 0.0f; // Right edge X position + float fLeftEdgeStep = 0.0f; // Left edge X step per scanline + float fRightEdgeStep = 0.0f; // Right edge X step per scanline // Texture coordinate interpolation variables - float fLeftTexX = 0.0f, fLeftTexY = 0.0f; // Current texture coords on left edge - float fRightTexX = 0.0f, fRightTexY = 0.0f; // Current texture coords on right edge - float fLeftTexXStep = 0.0f, fLeftTexYStep = 0.0f; // Texture coord steps for left edge - float fRightTexXStep = 0.0f, fRightTexYStep = 0.0f; // Texture coord steps for right edge + float fLeftTexX = 0.0f, + fLeftTexY = 0.0f; // Current texture coords on left edge + float fRightTexX = 0.0f, + fRightTexY = 0.0f; // Current texture coords on right edge + float fLeftTexXStep = 0.0f, + fLeftTexYStep = 0.0f; // Texture coord steps for left edge + float fRightTexXStep = 0.0f, + fRightTexYStep = 0.0f; // Texture coord steps for right edge // Vertex indices for edge walking int iLeftVertexIdx = iTopVertexIdx; @@ -762,8 +797,10 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) fLeftEdgeStep = fDeltaX / (float)iLeftEdgeHeight; // Calculate texture coordinate steps - fLeftTexXStep = (FROM_FIXED(startsx[iLeftVertexIdx]) - fLeftTexX) / (float)iLeftEdgeHeight; - fLeftTexYStep = (FROM_FIXED(startsy[iLeftVertexIdx]) - fLeftTexY) / (float)iLeftEdgeHeight; + fLeftTexXStep = (FROM_FIXED(startsx[iLeftVertexIdx]) - fLeftTexX) / + (float)iLeftEdgeHeight; + fLeftTexYStep = (FROM_FIXED(startsy[iLeftVertexIdx]) - fLeftTexY) / + (float)iLeftEdgeHeight; // Adjust for negative slopes (prestep) if (fLeftEdgeStep < 0.0f) { @@ -796,8 +833,10 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) fRightEdgeStep = fDeltaX / (float)iRightEdgeHeight; // Calculate texture coordinate steps - fRightTexXStep = (FROM_FIXED(startsx[iRightVertexIdx]) - fRightTexX) / (float)iRightEdgeHeight; - fRightTexYStep = (FROM_FIXED(startsy[iRightVertexIdx]) - fRightTexY) / (float)iRightEdgeHeight; + fRightTexXStep = (FROM_FIXED(startsx[iRightVertexIdx]) - fRightTexX) / + (float)iRightEdgeHeight; + fRightTexYStep = (FROM_FIXED(startsy[iRightVertexIdx]) - fRightTexY) / + (float)iRightEdgeHeight; // Adjust for positive slopes (prestep) if (fRightEdgeStep > 0.0f) { @@ -835,17 +874,21 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) if (iLeftEdgeHeight > 0) { int iTotalHeight = iEndY - iStartY; - float fDeltaX = (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftIdx].x); + float fDeltaX = + (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftIdx].x); fLeftEdgeStep = fDeltaX / (float)iTotalHeight; // Adjust for clipping - fLeftEdgeX = (float)vertices[iPrevLeftIdx].x + fLeftEdgeStep * (float)(0 - iStartY); + fLeftEdgeX = (float)vertices[iPrevLeftIdx].x + + fLeftEdgeStep * (float)(0 - iStartY); // Calculate texture steps and adjust for clipping float fTexXStart = FROM_FIXED(startsx[iPrevLeftIdx]); float fTexYStart = FROM_FIXED(startsy[iPrevLeftIdx]); - fLeftTexXStep = (FROM_FIXED(startsx[iLeftVertexIdx]) - fTexXStart) / (float)iTotalHeight; - fLeftTexYStep = (FROM_FIXED(startsy[iLeftVertexIdx]) - fTexYStart) / (float)iTotalHeight; + fLeftTexXStep = (FROM_FIXED(startsx[iLeftVertexIdx]) - fTexXStart) / + (float)iTotalHeight; + fLeftTexYStep = (FROM_FIXED(startsy[iLeftVertexIdx]) - fTexYStart) / + (float)iTotalHeight; fLeftTexX = fTexXStart + fLeftTexXStep * (float)(0 - iStartY); fLeftTexY = fTexYStart + fLeftTexYStep * (float)(0 - iStartY); @@ -874,17 +917,21 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) if (iRightEdgeHeight > 0) { int iTotalHeight = iEndY - iStartY; - float fDeltaX = (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightIdx].x); + float fDeltaX = + (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightIdx].x); fRightEdgeStep = fDeltaX / (float)iTotalHeight; // Adjust for clipping - fRightEdgeX = (float)vertices[iPrevRightIdx].x + fRightEdgeStep * (float)(0 - iStartY); + fRightEdgeX = (float)vertices[iPrevRightIdx].x + + fRightEdgeStep * (float)(0 - iStartY); // Calculate texture steps and adjust for clipping float fTexXStart = FROM_FIXED(startsx[iPrevRightIdx]); float fTexYStart = FROM_FIXED(startsy[iPrevRightIdx]); - fRightTexXStep = (FROM_FIXED(startsx[iRightVertexIdx]) - fTexXStart) / (float)iTotalHeight; - fRightTexYStep = (FROM_FIXED(startsy[iRightVertexIdx]) - fTexYStart) / (float)iTotalHeight; + fRightTexXStep = (FROM_FIXED(startsx[iRightVertexIdx]) - fTexXStart) / + (float)iTotalHeight; + fRightTexYStep = (FROM_FIXED(startsy[iRightVertexIdx]) - fTexYStart) / + (float)iTotalHeight; fRightTexX = fTexXStart + fRightTexXStep * (float)(0 - iStartY); fRightTexY = fTexYStart + fRightTexYStep * (float)(0 - iStartY); @@ -922,7 +969,8 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) // Render the span uint8_t *pDest = &scrptr[iScanlineY * winw + iStartX]; for (int x = iStartX; x < iEndX; x++) { - // Extract texture coordinates (convert float to int for 64x64 texture) + // Extract texture coordinates (convert float to int for 64x64 + // texture) int iU = (int)fTexX; int iV = (int)fTexY; @@ -967,14 +1015,17 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) // Setup new left edge fLeftEdgeX = (float)vertices[iPrevLeftVertexIdx].x; - float fDeltaX = (float)(vertices[iLeftVertexIdx].x - vertices[iPrevLeftVertexIdx].x); + float fDeltaX = (float)(vertices[iLeftVertexIdx].x - + vertices[iPrevLeftVertexIdx].x); fLeftEdgeStep = fDeltaX / (float)iLeftEdgeHeight; // Setup texture interpolation fLeftTexX = FROM_FIXED(startsx[iPrevLeftVertexIdx]); fLeftTexY = FROM_FIXED(startsy[iPrevLeftVertexIdx]); - fLeftTexXStep = (FROM_FIXED(startsx[iLeftVertexIdx]) - fLeftTexX) / (float)iLeftEdgeHeight; - fLeftTexYStep = (FROM_FIXED(startsy[iLeftVertexIdx]) - fLeftTexY) / (float)iLeftEdgeHeight; + fLeftTexXStep = (FROM_FIXED(startsx[iLeftVertexIdx]) - fLeftTexX) / + (float)iLeftEdgeHeight; + fLeftTexYStep = (FROM_FIXED(startsy[iLeftVertexIdx]) - fLeftTexY) / + (float)iLeftEdgeHeight; if (fLeftEdgeStep < 0.0f) { fLeftEdgeX += fLeftEdgeStep; @@ -1002,14 +1053,17 @@ void polyt(tPoint *vertices, int iNumVerts, uint8_t *pTex) // Setup new right edge fRightEdgeX = (float)vertices[iPrevRightVertexIdx].x; - float fDeltaX = (float)(vertices[iRightVertexIdx].x - vertices[iPrevRightVertexIdx].x); + float fDeltaX = (float)(vertices[iRightVertexIdx].x - + vertices[iPrevRightVertexIdx].x); fRightEdgeStep = fDeltaX / (float)iRightEdgeHeight; // Setup texture interpolation fRightTexX = FROM_FIXED(startsx[iPrevRightVertexIdx]); fRightTexY = FROM_FIXED(startsy[iPrevRightVertexIdx]); - fRightTexXStep = (FROM_FIXED(startsx[iRightVertexIdx]) - fRightTexX) / (float)iRightEdgeHeight; - fRightTexYStep = (FROM_FIXED(startsy[iRightVertexIdx]) - fRightTexY) / (float)iRightEdgeHeight; + fRightTexXStep = (FROM_FIXED(startsx[iRightVertexIdx]) - fRightTexX) / + (float)iRightEdgeHeight; + fRightTexYStep = (FROM_FIXED(startsy[iRightVertexIdx]) - fRightTexY) / + (float)iRightEdgeHeight; if (fRightEdgeStep > 0.0f) { fRightEdgeX += fRightEdgeStep; diff --git a/PROJECTS/ROLLER/polytex.h b/PROJECTS/ROLLER/polytex.h index 8f1cdf55..914e4bd5 100644 --- a/PROJECTS/ROLLER/polytex.h +++ b/PROJECTS/ROLLER/polytex.h @@ -18,7 +18,8 @@ extern uint8 *mapsel[4884]; void remove_mapsels(); void setmapsel(uint8 *pBase, int iIndex, int iMode, int iCount); void twpolym(tPoint *vertices, uint8 *pTex); -void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, int iTexIdx, int iGfxSize); +void POLYTEX(uint8 *pTexture, uint8 *pScrBuf, tPolyParams *pPolyParams, + int iTexIdx, int iGfxSize); void polym(tPoint *vertices, int iNumVerts, uint8 *pTex); void polyt(tPoint *vertices, int iNumVerts, uint8 *pTex); diff --git a/PROJECTS/ROLLER/render_queue_3d.c b/PROJECTS/ROLLER/render_queue_3d.c index 13e3fde0..195fc9da 100644 --- a/PROJECTS/ROLLER/render_queue_3d.c +++ b/PROJECTS/ROLLER/render_queue_3d.c @@ -4,8 +4,7 @@ static RenderQueue3D g_RenderQueue3D; -typedef struct -{ +typedef struct { tTrackZOrderEntry entry; RenderCommand3D command; int has_typed_command; @@ -13,29 +12,22 @@ typedef struct //------------------------------------------------------------------------------------------------- -RenderQueue3D *render_queue_3d_global(void) -{ - return &g_RenderQueue3D; -} +RenderQueue3D *render_queue_3d_global(void) { return &g_RenderQueue3D; } //------------------------------------------------------------------------------------------------- -void render_queue_3d_clear(RenderQueue3D *pQueue) -{ - pQueue->count = 0; -} +void render_queue_3d_clear(RenderQueue3D *pQueue) { pQueue->count = 0; } //------------------------------------------------------------------------------------------------- -tTrackZOrderEntry *render_queue_3d_entries(RenderQueue3D *pQueue) -{ +tTrackZOrderEntry *render_queue_3d_entries(RenderQueue3D *pQueue) { return pQueue->entries; } //------------------------------------------------------------------------------------------------- -const RenderCommand3D *render_queue_3d_command_at(const RenderQueue3D *pQueue, int iIndex) -{ +const RenderCommand3D *render_queue_3d_command_at(const RenderQueue3D *pQueue, + int iIndex) { if (iIndex < 0 || iIndex >= pQueue->count) return NULL; if (!pQueue->has_typed_command[iIndex]) @@ -45,15 +37,11 @@ const RenderCommand3D *render_queue_3d_command_at(const RenderQueue3D *pQueue, i //------------------------------------------------------------------------------------------------- -int render_queue_3d_count(const RenderQueue3D *pQueue) -{ - return pQueue->count; -} +int render_queue_3d_count(const RenderQueue3D *pQueue) { return pQueue->count; } //------------------------------------------------------------------------------------------------- -void render_queue_3d_set_legacy_count(RenderQueue3D *pQueue, int iCount) -{ +void render_queue_3d_set_legacy_count(RenderQueue3D *pQueue, int iCount) { int iCommandIndex; if (iCount < 0) @@ -71,9 +59,7 @@ void render_queue_3d_set_legacy_count(RenderQueue3D *pQueue, int iCount) static tTrackZOrderEntry *render_queue_3d_add(RenderQueue3D *pQueue, int iLegacyPriority, - int iChunkIdx, - float fZDepth) -{ + int iChunkIdx, float fZDepth) { tTrackZOrderEntry *pEntry; if (pQueue->count >= RENDER_QUEUE_3D_CAPACITY) @@ -94,8 +80,7 @@ static tTrackZOrderEntry *render_queue_3d_add(RenderQueue3D *pQueue, tTrackZOrderEntry *render_queue_3d_add_legacy_priority(RenderQueue3D *pQueue, int iLegacyPriority, int iChunkIdx, - float fZDepth) -{ + float fZDepth) { switch (iLegacyPriority) { case RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY: case RENDER_QUEUE_3D_BUILDING_LEGACY_PRIORITY: @@ -110,9 +95,9 @@ tTrackZOrderEntry *render_queue_3d_add_legacy_priority(RenderQueue3D *pQueue, tTrackZOrderEntry *render_queue_3d_add_building(RenderQueue3D *pQueue, int iBuildingIdx, - float fZDepth) -{ - tTrackZOrderEntry *pEntry = render_queue_3d_add(pQueue, RENDER_QUEUE_3D_BUILDING_LEGACY_PRIORITY, iBuildingIdx, fZDepth); + float fZDepth) { + tTrackZOrderEntry *pEntry = render_queue_3d_add( + pQueue, RENDER_QUEUE_3D_BUILDING_LEGACY_PRIORITY, iBuildingIdx, fZDepth); if (pEntry != NULL) { RenderCommand3D *pCommand = &pQueue->commands[pQueue->count - 1]; pCommand->kind = RENDER_COMMAND_3D_KIND_BUILDING; @@ -123,13 +108,12 @@ tTrackZOrderEntry *render_queue_3d_add_building(RenderQueue3D *pQueue, return pEntry; } -tTrackZOrderEntry *render_queue_3d_add_car(RenderQueue3D *pQueue, - int iCarIdx, - float fZDepth, - const GameRenderCarPose *pPose, - const GameRenderCarOptions *pOptions) -{ - tTrackZOrderEntry *pEntry = render_queue_3d_add(pQueue, RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY, iCarIdx, fZDepth); +tTrackZOrderEntry * +render_queue_3d_add_car(RenderQueue3D *pQueue, int iCarIdx, float fZDepth, + const GameRenderCarPose *pPose, + const GameRenderCarOptions *pOptions) { + tTrackZOrderEntry *pEntry = render_queue_3d_add( + pQueue, RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY, iCarIdx, fZDepth); if (pEntry != NULL) { RenderCommand3D *pCommand = &pQueue->commands[pQueue->count - 1]; pCommand->kind = RENDER_COMMAND_3D_KIND_CAR; @@ -158,14 +142,13 @@ tTrackZOrderEntry *render_queue_3d_add_car(RenderQueue3D *pQueue, //------------------------------------------------------------------------------------------------- - //------------------------------------------------------------------------------------------------- tTrackZOrderEntry *render_queue_3d_add_start_light(RenderQueue3D *pQueue, int iLightIdx, - float fZDepth) -{ - tTrackZOrderEntry *pEntry = render_queue_3d_add(pQueue, RENDER_QUEUE_3D_START_LIGHT_LEGACY_PRIORITY, iLightIdx, fZDepth); + float fZDepth) { + tTrackZOrderEntry *pEntry = render_queue_3d_add( + pQueue, RENDER_QUEUE_3D_START_LIGHT_LEGACY_PRIORITY, iLightIdx, fZDepth); if (pEntry != NULL) { RenderCommand3D *pCommand = &pQueue->commands[pQueue->count - 1]; pCommand->kind = RENDER_COMMAND_3D_KIND_START_LIGHT; @@ -178,8 +161,8 @@ tTrackZOrderEntry *render_queue_3d_add_start_light(RenderQueue3D *pQueue, //------------------------------------------------------------------------------------------------- -int render_queue_3d_compare_legacy_z_order(const void *pCommand1, const void *pCommand2) -{ +int render_queue_3d_compare_legacy_z_order(const void *pCommand1, + const void *pCommand2) { const tTrackZOrderEntry *pTrackZ1 = (const tTrackZOrderEntry *)pCommand1; const tTrackZOrderEntry *pTrackZ2 = (const tTrackZOrderEntry *)pCommand2; const float fZCmp1 = pTrackZ1->fZDepth; @@ -200,26 +183,30 @@ int render_queue_3d_compare_legacy_z_order(const void *pCommand1, const void *pC //------------------------------------------------------------------------------------------------- -static int render_queue_3d_compare_sort_entries(const void *pCommand1, const void *pCommand2) -{ - const RenderQueue3DSortEntry *pSortEntry1 = (const RenderQueue3DSortEntry *)pCommand1; - const RenderQueue3DSortEntry *pSortEntry2 = (const RenderQueue3DSortEntry *)pCommand2; - return render_queue_3d_compare_legacy_z_order(&pSortEntry1->entry, &pSortEntry2->entry); +static int render_queue_3d_compare_sort_entries(const void *pCommand1, + const void *pCommand2) { + const RenderQueue3DSortEntry *pSortEntry1 = + (const RenderQueue3DSortEntry *)pCommand1; + const RenderQueue3DSortEntry *pSortEntry2 = + (const RenderQueue3DSortEntry *)pCommand2; + return render_queue_3d_compare_legacy_z_order(&pSortEntry1->entry, + &pSortEntry2->entry); } //------------------------------------------------------------------------------------------------- -void render_queue_3d_sort(RenderQueue3D *pQueue) -{ +void render_queue_3d_sort(RenderQueue3D *pQueue) { int iCommandIndex; RenderQueue3DSortEntry *pSortEntries; if (pQueue->count <= 1) return; - pSortEntries = (RenderQueue3DSortEntry *)malloc(sizeof(*pSortEntries) * pQueue->count); + pSortEntries = + (RenderQueue3DSortEntry *)malloc(sizeof(*pSortEntries) * pQueue->count); if (pSortEntries == NULL) { - qsort(pQueue->entries, pQueue->count, sizeof(pQueue->entries[0]), render_queue_3d_compare_legacy_z_order); + qsort(pQueue->entries, pQueue->count, sizeof(pQueue->entries[0]), + render_queue_3d_compare_legacy_z_order); for (iCommandIndex = 0; iCommandIndex < pQueue->count; ++iCommandIndex) pQueue->has_typed_command[iCommandIndex] = 0; return; @@ -228,15 +215,18 @@ void render_queue_3d_sort(RenderQueue3D *pQueue) for (iCommandIndex = 0; iCommandIndex < pQueue->count; ++iCommandIndex) { pSortEntries[iCommandIndex].entry = pQueue->entries[iCommandIndex]; pSortEntries[iCommandIndex].command = pQueue->commands[iCommandIndex]; - pSortEntries[iCommandIndex].has_typed_command = pQueue->has_typed_command[iCommandIndex]; + pSortEntries[iCommandIndex].has_typed_command = + pQueue->has_typed_command[iCommandIndex]; } - qsort(pSortEntries, pQueue->count, sizeof(pSortEntries[0]), render_queue_3d_compare_sort_entries); + qsort(pSortEntries, pQueue->count, sizeof(pSortEntries[0]), + render_queue_3d_compare_sort_entries); for (iCommandIndex = 0; iCommandIndex < pQueue->count; ++iCommandIndex) { pQueue->entries[iCommandIndex] = pSortEntries[iCommandIndex].entry; pQueue->commands[iCommandIndex] = pSortEntries[iCommandIndex].command; - pQueue->has_typed_command[iCommandIndex] = pSortEntries[iCommandIndex].has_typed_command; + pQueue->has_typed_command[iCommandIndex] = + pSortEntries[iCommandIndex].has_typed_command; } free(pSortEntries); diff --git a/PROJECTS/ROLLER/render_queue_3d.h b/PROJECTS/ROLLER/render_queue_3d.h index ef16f527..c1fec75c 100644 --- a/PROJECTS/ROLLER/render_queue_3d.h +++ b/PROJECTS/ROLLER/render_queue_3d.h @@ -9,49 +9,42 @@ #define RENDER_QUEUE_3D_BUILDING_LEGACY_PRIORITY 13 #define RENDER_QUEUE_3D_START_LIGHT_LEGACY_PRIORITY 14 -// Only implemented gameplay-3D command kinds are named here. Legacy priorities stay on the -// temporary compatibility path until their renderers migrate to typed queue submission APIs. -typedef enum -{ +// Only implemented gameplay-3D command kinds are named here. Legacy priorities +// stay on the temporary compatibility path until their renderers migrate to +// typed queue submission APIs. +typedef enum { RENDER_COMMAND_3D_KIND_BUILDING = 0, RENDER_COMMAND_3D_KIND_CAR, RENDER_COMMAND_3D_KIND_START_LIGHT } RenderCommand3DKind; -typedef struct -{ +typedef struct { int building_idx; float depth; } RenderCommand3DBuilding; -typedef struct -{ +typedef struct { int car_idx; float depth; GameRenderCarPose pose; GameRenderCarOptions options; } RenderCommand3DCar; -typedef struct -{ +typedef struct { int light_idx; float depth; } RenderCommand3DStartLight; -typedef struct -{ +typedef struct { RenderCommand3DKind kind; - union - { + union { RenderCommand3DBuilding building; RenderCommand3DCar car; RenderCommand3DStartLight start_light; } payload; } RenderCommand3D; - -typedef struct -{ +typedef struct { tTrackZOrderEntry entries[RENDER_QUEUE_3D_CAPACITY]; RenderCommand3D commands[RENDER_QUEUE_3D_CAPACITY]; int has_typed_command[RENDER_QUEUE_3D_CAPACITY]; @@ -63,33 +56,33 @@ typedef struct RenderQueue3D *render_queue_3d_global(void); void render_queue_3d_clear(RenderQueue3D *pQueue); tTrackZOrderEntry *render_queue_3d_entries(RenderQueue3D *pQueue); -const RenderCommand3D *render_queue_3d_command_at(const RenderQueue3D *pQueue, int iIndex); +const RenderCommand3D *render_queue_3d_command_at(const RenderQueue3D *pQueue, + int iIndex); int render_queue_3d_count(const RenderQueue3D *pQueue); void render_queue_3d_set_legacy_count(RenderQueue3D *pQueue, int iCount); -// Temporary compatibility API for unmigrated legacy render priorities. Priorities with named -// command APIs must use those APIs instead. +// Temporary compatibility API for unmigrated legacy render priorities. +// Priorities with named command APIs must use those APIs instead. tTrackZOrderEntry *render_queue_3d_add_legacy_priority(RenderQueue3D *pQueue, int iLegacyPriority, int iChunkIdx, float fZDepth); -tTrackZOrderEntry *render_queue_3d_add_car(RenderQueue3D *pQueue, - int iCarIdx, - float fZDepth, - const GameRenderCarPose *pPose, - const GameRenderCarOptions *pOptions); +tTrackZOrderEntry * +render_queue_3d_add_car(RenderQueue3D *pQueue, int iCarIdx, float fZDepth, + const GameRenderCarPose *pPose, + const GameRenderCarOptions *pOptions); tTrackZOrderEntry *render_queue_3d_add_building(RenderQueue3D *pQueue, int iBuildingIdx, float fZDepth); - tTrackZOrderEntry *render_queue_3d_add_start_light(RenderQueue3D *pQueue, int iLightIdx, float fZDepth); -int render_queue_3d_compare_legacy_z_order(const void *pCommand1, const void *pCommand2); +int render_queue_3d_compare_legacy_z_order(const void *pCommand1, + const void *pCommand2); void render_queue_3d_sort(RenderQueue3D *pQueue); //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/replay.c b/PROJECTS/ROLLER/replay.c index d3a55b6c..fe409730 100644 --- a/PROJECTS/ROLLER/replay.c +++ b/PROJECTS/ROLLER/replay.c @@ -21,154 +21,125 @@ #include #endif //------------------------------------------------------------------------------------------------- -//symbol names added by ROLLER -char g_szGss[5] = ".GSS"; //000A253C -char g_szNewEdit[10] = "NEW EDIT:"; //000A274C -char g_szEdit[6] = "EDIT:"; //000A2758 +// symbol names added by ROLLER +char g_szGss[5] = ".GSS"; // 000A253C +char g_szNewEdit[10] = "NEW EDIT:"; // 000A274C +char g_szEdit[6] = "EDIT:"; // 000A2758 //------------------------------------------------------------------------------------------------- -int disciconpressed = 0; //000A63AC -int rotpoint = 0; //000A63B0 -int replaypanel = -1; //000A63B4 -int controlicon = 9; //000A63B8 -int replayspeeds[9] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 }; //000A63BC -char *replayname[9] = { //000A63E0 - "1/16", - "1/8", - "1/4", - "1/2", - "1", - "2", - "4", - "8", - "16" -}; -int lastintro = -1; //000A6404 -int filingmenu = 0; //000A6408 -int filefile = 0; //000A640C -int filefiles = 0; //000A6410 -int replaysetspeed = 0; //000A6414 -int replaydirection = 0; //000A6418 -int lastfile = -1; //000A641C -int lastautocut = -1; //000A6420 -int pend_view_init = -1; //000A6424 -int replayedit = 0; //000A6428 -char replayfilename[32] = "INTRO1.GSS"; //000A642C -char *views[8] = { //000A644C - "IN CAR", - "CHASE", - "MIRROR", - "BEHIND", - "CAMERA", - "ABOVE", - "BACK", - "TEAM" -}; -int loading_replay = 0; //000A6470 -tRIcon ricon[26] = //000A6474 -{ - { 0, 0, NULL }, - { 7, 5, &Rframeminus }, - { 29, 5, &Rframeplus }, - { 51, 5, &Rreverseplay }, - { 73, 5, &Rplay }, - { 95, 5, &Rspeedminus }, - { 117, 5, &Rspeedplus }, - { 7, 21, &Rstart }, - { 29, 21, NULL }, - { 51, 21, &DoRstop }, - { 95, 21, NULL }, - { 117, 21, &Rend }, - { 7, 37, &carminus }, - { 29, 37, &carplus }, - { 51, 37, &viewminus }, - { 73, 37, &viewplus }, - { 95, 37, &discmenu }, - { 117, 37, &rtoggleedit }, - { 140, 37, &rstartblock }, - { 162, 37, &rselectblock }, - { 184, 37, &rdeleteblock }, - { 206, 37, &rstoreview }, - { 228, 37, &rremoveview }, - { 250, 37, &rpreviouscut }, - { 272, 37, &rnextcut }, - { 294, 37, &rstartassemble } -}; -char *replayhelp[26] = { //000A6544 - "", - "FRAME|REVERSE", - "FRAME|FORWARD", - "REVERSE PLAY", - "PLAY", - "DECREASE|PLAY SPEED", - "INCREASE|PLAY SPEED", - "GO TO START", - "REWIND", - "STOP", - "FAST FORWARD", - "GO TO END", - "SELECT|PREVIOUS CAR", - "SELECT|NEXT CAR", - "SELECT|PREVIOUS VIEW", - "SELECT|NEXT VIEW", - "FILE|OPERATIONS", - "SELECT|EDIT MODE", - "START|BLOCK", - "SELECT|BLOCK", - "DESELECT|BLOCK", - "STORE|NEW CUT", - "REMOVE|CUT", - "GO TO|PREVIOUS CUT", - "GO TO|NEXT CUT", - "ASSEMBLE|REPLAY" -}; -int lsdsel = 0; //000A646C -tPoint rrotate[8] = //000A65AC -{ - { 194, 11 }, - { 199, 11 }, - { 203, 15 }, - { 203, 20 }, - { 199, 24 }, - { 194, 24 }, - { 190, 20 }, - { 190, 15 } -}; -tReplayCamera camera[100];//00189980 -int disabled[4096]; //00189BD8 -char temp_names[16][9]; //0018DBD8 -char newrepsample[16]; //0018DC68 -char repsample[16]; //0018DC78 -char repvolume[16]; //0018DC88 -int topfile; //0018DC98 -char filename[500][9]; //0018DC9C -int oldtrack; //0018EE30 -int oldtextures; //0018EE34 -int replayheader; //0018EE38 -FILE *replayfile; //0018EE3C -int replayspeed; //0018EE40 -int oldcars; //0018EE44 -int replayframes; //0018EE48 -int discfull; //0018EE4C -int replayblock; //0018EE50 -int currentreplayframe; //0018EE54 -int lastreplayframe; //0018EE58 -int introfiles; //0018EE70 -int newreplayframe; //0018EE5C -int replayselect; //0018EE60 -int slowing; //0018EE64 -int rewinding; //0018EE68 -int forwarding; //0018EE6C -int replaystart; //0018EE74 -int cuts; //0018EE78 -char selectfilename[30]; //0018EE80 -char rememberfilename[34];//0018EE9E +int disciconpressed = 0; // 000A63AC +int rotpoint = 0; // 000A63B0 +int replaypanel = -1; // 000A63B4 +int controlicon = 9; // 000A63B8 +int replayspeeds[9] = {16, 32, 64, 128, 256, 512, 1024, 2048, 4096}; // 000A63BC +char *replayname[9] = { // 000A63E0 + "1/16", "1/8", "1/4", "1/2", "1", "2", "4", "8", "16"}; +int lastintro = -1; // 000A6404 +int filingmenu = 0; // 000A6408 +int filefile = 0; // 000A640C +int filefiles = 0; // 000A6410 +int replaysetspeed = 0; // 000A6414 +int replaydirection = 0; // 000A6418 +int lastfile = -1; // 000A641C +int lastautocut = -1; // 000A6420 +int pend_view_init = -1; // 000A6424 +int replayedit = 0; // 000A6428 +char replayfilename[32] = "INTRO1.GSS"; // 000A642C +char *views[8] = { // 000A644C + "IN CAR", "CHASE", "MIRROR", "BEHIND", "CAMERA", "ABOVE", "BACK", "TEAM"}; +int loading_replay = 0; // 000A6470 +tRIcon ricon[26] = // 000A6474 + {{0, 0, NULL}, + {7, 5, &Rframeminus}, + {29, 5, &Rframeplus}, + {51, 5, &Rreverseplay}, + {73, 5, &Rplay}, + {95, 5, &Rspeedminus}, + {117, 5, &Rspeedplus}, + {7, 21, &Rstart}, + {29, 21, NULL}, + {51, 21, &DoRstop}, + {95, 21, NULL}, + {117, 21, &Rend}, + {7, 37, &carminus}, + {29, 37, &carplus}, + {51, 37, &viewminus}, + {73, 37, &viewplus}, + {95, 37, &discmenu}, + {117, 37, &rtoggleedit}, + {140, 37, &rstartblock}, + {162, 37, &rselectblock}, + {184, 37, &rdeleteblock}, + {206, 37, &rstoreview}, + {228, 37, &rremoveview}, + {250, 37, &rpreviouscut}, + {272, 37, &rnextcut}, + {294, 37, &rstartassemble}}; +char *replayhelp[26] = { // 000A6544 + "", + "FRAME|REVERSE", + "FRAME|FORWARD", + "REVERSE PLAY", + "PLAY", + "DECREASE|PLAY SPEED", + "INCREASE|PLAY SPEED", + "GO TO START", + "REWIND", + "STOP", + "FAST FORWARD", + "GO TO END", + "SELECT|PREVIOUS CAR", + "SELECT|NEXT CAR", + "SELECT|PREVIOUS VIEW", + "SELECT|NEXT VIEW", + "FILE|OPERATIONS", + "SELECT|EDIT MODE", + "START|BLOCK", + "SELECT|BLOCK", + "DESELECT|BLOCK", + "STORE|NEW CUT", + "REMOVE|CUT", + "GO TO|PREVIOUS CUT", + "GO TO|NEXT CUT", + "ASSEMBLE|REPLAY"}; +int lsdsel = 0; // 000A646C +tPoint rrotate[8] = // 000A65AC + {{194, 11}, {199, 11}, {203, 15}, {203, 20}, + {199, 24}, {194, 24}, {190, 20}, {190, 15}}; +tReplayCamera camera[100]; // 00189980 +int disabled[4096]; // 00189BD8 +char temp_names[16][9]; // 0018DBD8 +char newrepsample[16]; // 0018DC68 +char repsample[16]; // 0018DC78 +char repvolume[16]; // 0018DC88 +int topfile; // 0018DC98 +char filename[500][9]; // 0018DC9C +int oldtrack; // 0018EE30 +int oldtextures; // 0018EE34 +int replayheader; // 0018EE38 +FILE *replayfile; // 0018EE3C +int replayspeed; // 0018EE40 +int oldcars; // 0018EE44 +int replayframes; // 0018EE48 +int discfull; // 0018EE4C +int replayblock; // 0018EE50 +int currentreplayframe; // 0018EE54 +int lastreplayframe; // 0018EE58 +int introfiles; // 0018EE70 +int newreplayframe; // 0018EE5C +int replayselect; // 0018EE60 +int slowing; // 0018EE64 +int rewinding; // 0018EE68 +int forwarding; // 0018EE6C +int replaystart; // 0018EE74 +int cuts; // 0018EE78 +char selectfilename[30]; // 0018EE80 +char rememberfilename[34]; // 0018EE9E //------------------------------------------------------------------------------------------------- -static int SelectIntroFile(int iAvoidIntro) -{ +static int SelectIntroFile(int iAvoidIntro) { int iAttempt; int iRandValue; int iIntroFile; @@ -191,29 +162,28 @@ static int SelectIntroFile(int iAvoidIntro) } //------------------------------------------------------------------------------------------------- -//00063DB0 -void setreplaytrack() -{ +// 00063DB0 +void setreplaytrack() { char *pszRememberFilename; // edi - char *pszReplayFilename; // esi - char c1; // al - char c2; // al - int iIntroFileNum1; // eax - FILE *pFile; // edi - int iIntroFileNum2; // eax - //uint32 iCheatFlags1; // ecx - //uint32 iCheatFlags2; // ebx - int *iNonCompetitor; // esi + char *pszReplayFilename; // esi + char c1; // al + char c2; // al + int iIntroFileNum1; // eax + FILE *pFile; // edi + int iIntroFileNum2; // eax + // uint32 iCheatFlags1; // ecx + // uint32 iCheatFlags2; // ebx + int *iNonCompetitor; // esi int *pReplayNonCompetitor; // eax - int iByteOffset; // ebp - int iCarIndex; // esi - uint8 iCarDesign; // al - int iNumCarsTemp; // ecx - int iCarCounter; // [esp+0h] [ebp-20h] - uint8 buffer[28]; // [esp+4h] [ebp-1Ch] BYREF + int iByteOffset; // ebp + int iCarIndex; // esi + uint8 iCarDesign; // al + int iNumCarsTemp; // ecx + int iCarCounter; // [esp+0h] [ebp-20h] + uint8 buffer[28]; // [esp+4h] [ebp-1Ch] BYREF if (replaytype == 2) { - oldtrack = TrackLoad; // Save current game state before loading replay + oldtrack = TrackLoad; // Save current game state before loading replay oldcars = numcars; oldtextures = textures_off; if (g_bSnapshotMode) { @@ -221,10 +191,12 @@ void setreplaytrack() // command line, bypassing the random intro picker. strncpy(rememberfilename, replayfilename, sizeof(rememberfilename) - 1); rememberfilename[sizeof(rememberfilename) - 1] = '\0'; - strncpy(replayfilename, g_SnapshotConfig.szReplayName, sizeof(replayfilename) - 1); + strncpy(replayfilename, g_SnapshotConfig.szReplayName, + sizeof(replayfilename) - 1); replayfilename[sizeof(replayfilename) - 1] = '\0'; } else if (intro || replayfilename[0] == 73) { - pszRememberFilename = rememberfilename; // Copy current filename to remember buffer + pszRememberFilename = + rememberfilename; // Copy current filename to remember buffer pszReplayFilename = replayfilename; do { c1 = *pszReplayFilename; @@ -236,40 +208,44 @@ void setreplaytrack() pszRememberFilename[1] = c2; pszRememberFilename += 2; } while (c2); - iIntroFileNum1 = SelectIntroFile(lastintro); // Generate random intro file number (1 to introfiles) + iIntroFileNum1 = SelectIntroFile( + lastintro); // Generate random intro file number (1 to introfiles) lastintro = iIntroFileNum1; sprintf(replayfilename, "INTRO%d.GSS", iIntroFileNum1); } - pFile = fopen(replayfilename, "rb"); // Open the selected intro GSS file + pFile = fopen(replayfilename, "rb"); // Open the selected intro GSS file if (!pFile && introfiles > 1) { - iIntroFileNum2 = SelectIntroFile(lastintro); // Fallback: try different intro file if first failed to open + iIntroFileNum2 = + SelectIntroFile(lastintro); // Fallback: try different intro file if + // first failed to open lastintro = iIntroFileNum2; sprintf(replayfilename, "INTRO%d.GSS", iIntroFileNum2); pFile = fopen(replayfilename, "rb"); } if (pFile) { - fread(buffer, 1u, 1u, pFile); // Read track number from GSS file + fread(buffer, 1u, 1u, pFile); // Read track number from GSS file TrackLoad = buffer[0]; game_track = buffer[0]; - fread(buffer, 1u, 1u, pFile); // Read game flags byte from GSS file + fread(buffer, 1u, 1u, pFile); // Read game flags byte from GSS file - if ((buffer[0] & 0x20) != 0) // Process texture flag (bit 5 = 0x20) + if ((buffer[0] & 0x20) != 0) // Process texture flag (bit 5 = 0x20) textures_off |= TEX_OFF_ADVANCED_CARS; else textures_off &= ~TEX_OFF_ADVANCED_CARS; cheat_mode = 0; - if ((buffer[0] & 0x40) != 0) // Process cheat mode flags (bit 6 = 0x40, bit 7 = 0x80) + if ((buffer[0] & 0x40) != + 0) // Process cheat mode flags (bit 6 = 0x40, bit 7 = 0x80) { cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; - //iCheatFlags1 = cheat_mode; - //BYTE1(iCheatFlags1) = BYTE1(cheat_mode) | 0x10; - //cheat_mode = iCheatFlags1; + // iCheatFlags1 = cheat_mode; + // BYTE1(iCheatFlags1) = BYTE1(cheat_mode) | 0x10; + // cheat_mode = iCheatFlags1; } else { cheat_mode &= ~CHEAT_MODE_DOUBLE_TRACK; - //iCheatFlags2 = cheat_mode; - //BYTE1(iCheatFlags2) = BYTE1(cheat_mode) & 0xEF; - //cheat_mode = iCheatFlags2; + // iCheatFlags2 = cheat_mode; + // BYTE1(iCheatFlags2) = BYTE1(cheat_mode) & 0xEF; + // cheat_mode = iCheatFlags2; } if ((buffer[0] & 0x80u) == 0) @@ -278,82 +254,84 @@ void setreplaytrack() cheat_mode |= CHEAT_MODE_TINY_CARS; iNonCompetitor = non_competitors; - numcars = buffer[0] & 0x1F; // Extract number of cars from lower 5 bits (0x1F mask) - fseek(pFile, 605, 0); // Seek to non-competitors data at offset 605 + numcars = buffer[0] & + 0x1F; // Extract number of cars from lower 5 bits (0x1F mask) + fseek(pFile, 605, 0); // Seek to non-competitors data at offset 605 do { - pReplayNonCompetitor = iNonCompetitor++;// Read 16 non-competitor entries (4 bytes each) + pReplayNonCompetitor = + iNonCompetitor++; // Read 16 non-competitor entries (4 bytes each) fread(pReplayNonCompetitor, 4u, 1u, pFile); } while (iNonCompetitor != &non_competitors[16]); - fread(&racers, 4u, 1u, pFile); // Read racers data (4 bytes) + fread(&racers, 4u, 1u, pFile); // Read racers data (4 bytes) iCarCounter = 0; if (numcars > 0) { iByteOffset = 0; iCarIndex = 0; do { - fread(buffer, 1u, 1u, pFile); // Read car design index for each car + fread(buffer, 1u, 1u, pFile); // Read car design index for each car iCarDesign = buffer[0]; Car[iCarIndex].byCarDesignIdx = buffer[0]; iNumCarsTemp = numcars; iByteOffset += 4; Drivers_Car[iCarIndex] = iCarDesign; ++iCarIndex; - //*(_DWORD *)&car_texture_names[10][iByteOffset + 252] = iCarDesign;// offset into Drivers_Car + //*(_DWORD *)&car_texture_names[10][iByteOffset + 252] = iCarDesign;// + // offset into Drivers_Car ++iCarCounter; } while (iCarCounter < iNumCarsTemp); } } if (pFile) - fclose(pFile); // Close the GSS file + fclose(pFile); // Close the GSS file } } //------------------------------------------------------------------------------------------------- -//00064040 -void startreplay() -{ - char *pDestStr; // edi - const char *pSrcStr; // esi - char cChar1; // al - char cChar2; // al - FILE *pWriteFile; // ecx - int *pNonCompetitorsWrite; // esi +// 00064040 +void startreplay() { + char *pDestStr; // edi + const char *pSrcStr; // esi + char cChar1; // al + char cChar2; // al + FILE *pWriteFile; // ecx + int *pNonCompetitorsWrite; // esi int *pCurrentNonCompetitor; // eax - int iCarWriteCounter; // edi - int iCarWriteIndex; // esi - int iDriverNameCounter; // edi - char *pDriverNamesWrite; // esi - char *pDriverNamesSrc; // edx - char *pTempNamesDest; // ebx - char *pTempPtr1; // edi - char *pTempPtr2; // esi - char cTempChar1; // al - char cTempChar2; // al - //int iFileHandle; // eax - //int iFileHandleCopy; // edx + int iCarWriteCounter; // edi + int iCarWriteIndex; // esi + int iDriverNameCounter; // edi + char *pDriverNamesWrite; // esi + char *pDriverNamesSrc; // edx + char *pTempNamesDest; // ebx + char *pTempPtr1; // edi + char *pTempPtr2; // esi + char cTempChar1; // al + char cTempChar2; // al + // int iFileHandle; // eax + // int iFileHandleCopy; // edx FILE *pReadFile; // ecx - //uint32 iCheatFlags1; // edx - //uint32 iCheatFlags2; // eax - //uint32 iCheatFlags3; // ecx - //uint32 iCheatFlags4; // ebx - int *pNonCompetitorsRead; // esi + // uint32 iCheatFlags1; // edx + // uint32 iCheatFlags2; // eax + // uint32 iCheatFlags3; // ecx + // uint32 iCheatFlags4; // ebx + int *pNonCompetitorsRead; // esi int *pCurrentNonCompetitorRead; // eax - int iDriverIndex; // ebp - int iNonCompetitorIndex; // edi - int iCarArrayIndex; // esi - uint8 byCarDesignIdx; // al - int iNonCompetitorValue; // ebx - double dZCoordinate; // st7 - int iDriverNameIndex; // edi - char *pDriverNamesRead; // esi - int iReplayDataIndex; // esi - char cReplayDataByte; // al - int iNumCarsLocal; // ebp - //signed int iCarByteOffset; // eax - //signed int iTotalCarBytes; // edx + int iDriverIndex; // ebp + int iNonCompetitorIndex; // edi + int iCarArrayIndex; // esi + uint8 byCarDesignIdx; // al + int iNonCompetitorValue; // ebx + double dZCoordinate; // st7 + int iDriverNameIndex; // edi + char *pDriverNamesRead; // esi + int iReplayDataIndex; // esi + char cReplayDataByte; // al + int iNumCarsLocal; // ebp + // signed int iCarByteOffset; // eax + // signed int iTotalCarBytes; // edx tReplayData replayData; // [esp+0h] [ebp-3Ch] BYREF - uint8 buffer[28]; // [esp+20h] [ebp-1Ch] BYREF + uint8 buffer[28]; // [esp+20h] [ebp-1Ch] BYREF - oldcars = numcars; // Initialize replay state variables + oldcars = numcars; // Initialize replay state variables lastreplayframe = -1; currentreplayframe = 0; lastautocut = -1; @@ -368,10 +346,10 @@ void startreplay() memset(disabled, 255, sizeof(disabled)); memset(camera, 0, sizeof(camera)); cuts = 0; - if (replaytype) { // RECORDING MODE: Set up replay file for writing + if (replaytype) { // RECORDING MODE: Set up replay file for writing if ((unsigned int)replaytype <= 1) { pDestStr = replayfilename; - pSrcStr = "../REPLAYS/REPLAY.TMP"; // Copy replay temp filename + pSrcStr = "../REPLAYS/REPLAY.TMP"; // Copy replay temp filename discfull = 0; do { cChar1 = *pSrcStr; @@ -383,12 +361,13 @@ void startreplay() pDestStr[1] = cChar2; pDestStr += 2; } while (cChar2); - pWriteFile = ROLLERfopen(replayfilename, "wb");// Open replay file for writing + pWriteFile = + ROLLERfopen(replayfilename, "wb"); // Open replay file for writing replayfile = pWriteFile; if (pWriteFile) { - buffer[0] = TrackLoad; // Write track number to replay file + buffer[0] = TrackLoad; // Write track number to replay file fwrite(buffer, 1, 1, pWriteFile); - buffer[0] = numcars; // Write game flags (numcars + texture/cheat flags) + buffer[0] = numcars; // Write game flags (numcars + texture/cheat flags) // TEX_OFF_ADVANCED_CARS if ((textures_off & 0x10000) != 0) buffer[0] = numcars | 0x20; @@ -399,16 +378,19 @@ void startreplay() if ((cheat_mode & 0x8000) != 0) buffer[0] |= 0x80u; fwrite(buffer, 1, 1, replayfile); - buffer[0] = (uint8)ViewType[0]; // Write view type and selected view to replay file + buffer[0] = (uint8) + ViewType[0]; // Write view type and selected view to replay file fwrite(buffer, 1, 1, replayfile); buffer[0] = SelectedView[0]; fwrite(buffer, 1, 1, replayfile); pNonCompetitorsWrite = non_competitors; - fwrite(camera, 6, 100, replayfile); // Write camera data and cuts to replay file + fwrite(camera, 6, 100, + replayfile); // Write camera data and cuts to replay file buffer[0] = cuts; fwrite(buffer, 1, 1, replayfile); do { - pCurrentNonCompetitor = pNonCompetitorsWrite++;// Write non-competitors and racers data + pCurrentNonCompetitor = + pNonCompetitorsWrite++; // Write non-competitors and racers data fwrite(pCurrentNonCompetitor, 4, 1, replayfile); } while (pNonCompetitorsWrite != &non_competitors[16]); fwrite(&racers, 4, 1, replayfile); @@ -416,7 +398,9 @@ void startreplay() if (numcars > 0) { iCarWriteIndex = 0; do { - buffer[0] = Car[iCarWriteIndex].byCarDesignIdx;// Write car design indices for each car + buffer[0] = + Car[iCarWriteIndex] + .byCarDesignIdx; // Write car design indices for each car ++iCarWriteCounter; fwrite(buffer, 1, 1, replayfile); ++iCarWriteIndex; @@ -432,12 +416,15 @@ void startreplay() } while (iDriverNameCounter < numcars); } } - } else if (replaytype == 2) { // PLAYBACK MODE: Load replay data from GSS file + } else if (replaytype == + 2) { // PLAYBACK MODE: Load replay data from GSS file if (!intro) - rev_vga[15] = (tBlockHeader *)load_picture("replaysc.bm");// Load replay screen image if not in intro mode + rev_vga[15] = (tBlockHeader *)load_picture( + "replaysc.bm"); // Load replay screen image if not in intro mode - int iCounter = 0; //added by ROLLER - pDriverNamesSrc = driver_names[0]; // Backup current driver names to temp storage + int iCounter = 0; // added by ROLLER + pDriverNamesSrc = + driver_names[0]; // Backup current driver names to temp storage pTempNamesDest = temp_names[0]; do { pTempPtr1 = pTempNamesDest; @@ -459,17 +446,19 @@ void startreplay() } while (iCounter < 16); replayframes = ROLLERfilelength(replayfilename); - //iFileHandle = open(replayfilename, 0x200);// Get replay file size to calculate frame count - //iFileHandleCopy = iFileHandle; - //if (iFileHandle != -1) { - // replayframes = filelength(iFileHandle); - // close(iFileHandleCopy); - //} - - pReadFile = ROLLERfopen(replayfilename, "rb"); // Open replay file for reading + // iFileHandle = open(replayfilename, 0x200);// Get replay file size to + // calculate frame count iFileHandleCopy = iFileHandle; if (iFileHandle != + // -1) { + // replayframes = filelength(iFileHandle); + // close(iFileHandleCopy); + // } + + pReadFile = + ROLLERfopen(replayfilename, "rb"); // Open replay file for reading replayfile = pReadFile; if (pReadFile) { - fread(buffer, 1u, 1u, pReadFile); // Read track number and game flags from replay file + fread(buffer, 1u, 1u, + pReadFile); // Read track number and game flags from replay file TrackLoad = buffer[0]; game_track = buffer[0]; fread(buffer, 1u, 1u, replayfile); @@ -485,27 +474,27 @@ void startreplay() // CHEAT_MODE_DOUBLE_TRACK if ((buffer[0] & 0x40) != 0) { cheat_mode |= CHEAT_MODE_DOUBLE_TRACK; - //iCheatFlags1 = cheat_mode; - //BYTE1(iCheatFlags1) = BYTE1(cheat_mode) | 0x10; - //cheat_mode = iCheatFlags1; + // iCheatFlags1 = cheat_mode; + // BYTE1(iCheatFlags1) = BYTE1(cheat_mode) | 0x10; + // cheat_mode = iCheatFlags1; } else { cheat_mode &= ~CHEAT_MODE_DOUBLE_TRACK; - //iCheatFlags2 = cheat_mode; - //BYTE1(iCheatFlags2) = BYTE1(cheat_mode) & 0xEF; - //cheat_mode = iCheatFlags2; + // iCheatFlags2 = cheat_mode; + // BYTE1(iCheatFlags2) = BYTE1(cheat_mode) & 0xEF; + // cheat_mode = iCheatFlags2; } // CHEAT_MODE_TINY_CARS if ((buffer[0] & 0x80u) == 0) { cheat_mode &= ~CHEAT_MODE_TINY_CARS; - //iCheatFlags4 = cheat_mode; - //BYTE1(iCheatFlags4) = BYTE1(cheat_mode) & 0x7F; - //cheat_mode = iCheatFlags4; + // iCheatFlags4 = cheat_mode; + // BYTE1(iCheatFlags4) = BYTE1(cheat_mode) & 0x7F; + // cheat_mode = iCheatFlags4; } else { cheat_mode |= CHEAT_MODE_TINY_CARS; - //iCheatFlags3 = cheat_mode; - //BYTE1(iCheatFlags3) = BYTE1(cheat_mode) | 0x80; - //cheat_mode = iCheatFlags3; + // iCheatFlags3 = cheat_mode; + // BYTE1(iCheatFlags3) = BYTE1(cheat_mode) | 0x80; + // cheat_mode = iCheatFlags3; } numcars = buffer[0] & 0x1F; @@ -527,14 +516,15 @@ void startreplay() iNonCompetitorIndex = 0; iCarArrayIndex = 0; do { - fread(buffer, 1u, 1u, replayfile); // Initialize each car from replay data + fread(buffer, 1u, 1u, + replayfile); // Initialize each car from replay data byCarDesignIdx = buffer[0]; Car[iCarArrayIndex].iDriverIdx = iDriverIndex; Car[iCarArrayIndex].byCarDesignIdx = byCarDesignIdx; Car[iCarArrayIndex].byDamageToggle = 0; iNonCompetitorValue = non_competitors[iNonCompetitorIndex]; Car[iCarArrayIndex].byLastDamageToggle = 20; - if (iNonCompetitorValue) // Position non-competitor cars off-track + if (iNonCompetitorValue) // Position non-competitor cars off-track { Car[iCarArrayIndex].pos.fX = -localdata[0].pointAy[3].fX; Car[iCarArrayIndex].pos.fY = -localdata[0].pointAy[3].fY; @@ -544,7 +534,8 @@ void startreplay() Car[iCarArrayIndex].fFinalSpeed = 0.0; Car[iCarArrayIndex].fSpeedOverflow = 0.0; finished_car[iNonCompetitorIndex] = -1; - Car[iCarArrayIndex].nReferenceChunk = Car[iCarArrayIndex].nCurrChunk; + Car[iCarArrayIndex].nReferenceChunk = + Car[iCarArrayIndex].nCurrChunk; Car[iCarArrayIndex].nCurrChunk = -1; Car[iCarArrayIndex].pos.fZ = (float)dZCoordinate + 1000.0f; } @@ -555,30 +546,36 @@ void startreplay() } iDriverNameIndex = 0; if (numcars > 0) { - pDriverNamesRead = driver_names[0]; // Read driver names from replay file + pDriverNamesRead = + driver_names[0]; // Read driver names from replay file do { - fread(pDriverNamesRead, 9u, 1u, replayfile);// Write driver names (9 bytes each) + fread(pDriverNamesRead, 9u, 1u, + replayfile); // Write driver names (9 bytes each) ++iDriverNameIndex; pDriverNamesRead += 9; } while (iDriverNameIndex < numcars); } - fseek(replayfile, replayheader, 0); // Seek to replay frame data header + fseek(replayfile, replayheader, 0); // Seek to replay frame data header iReplayDataIndex = 0; if (numcars > 0) { do { - fread(&replayData, 0x1Eu, 1u, replayfile);// Read initial replay frame data (30 bytes per car) + fread(&replayData, 0x1Eu, 1u, + replayfile); // Read initial replay frame data (30 bytes per + // car) ++iReplayDataIndex; cReplayDataByte = GET_HIBYTE(replayData.iPackedPosX); iNumCarsLocal = numcars; -//TODO: ensure this is correct - newrepsample[iReplayDataIndex - 1] = GET_HIBYTE(replayData.iPackedPosX); + // TODO: ensure this is correct + newrepsample[iReplayDataIndex - 1] = + GET_HIBYTE(replayData.iPackedPosX); repsample[iReplayDataIndex - 1] = cReplayDataByte; - //temp_names[15][iReplayDataIndex + 8] = replayData[3]; - //newrepsample[iReplayDataIndex + 15] = cReplayDataByte; + // temp_names[15][iReplayDataIndex + 8] = replayData[3]; + // newrepsample[iReplayDataIndex + 15] = cReplayDataByte; } while (iReplayDataIndex < iNumCarsLocal); } - replayheader = 10 * numcars + 673; // Calculate replay header size and frame block size + replayheader = 10 * numcars + + 673; // Calculate replay header size and frame block size replayblock = 30 * racers + 16; replayframes = (int)(replayframes - replayheader) / (30 * racers + 16); } @@ -590,20 +587,26 @@ void startreplay() Car[iCarIndex].iRollCameraOffset = 0; Car[iCarIndex].iEngineState = 8; } - //if (numcars > 0) { - // iCarByteOffset = 0; - // iTotalCarBytes = sizeof(tCar) * numcars; - // do { - // iCarByteOffset += sizeof(tCar); // Initialize car physics data for replay - // *(_DWORD *)((char *)&CarBox.hitboxAy[15][6].fY + iCarByteOffset) = 8;// offset into Car - // *(float *)((char *)&CarBox.hitboxAy[14][2].fZ + iCarByteOffset) = 0.0; - // *(float *)((char *)&CarBox.hitboxAy[14][3].fY + iCarByteOffset) = 0.0; - // *(float *)((char *)&CarBox.hitboxAy[14][1].fY + iCarByteOffset) = 0.0; - // *(float *)((char *)&CarBox.hitboxAy[14][1].fZ + iCarByteOffset) = 0.0; - // } while (iCarByteOffset < iTotalCarBytes); - //} - - replayspeed = 256; // Set default replay speed and check for intro mode + // if (numcars > 0) { + // iCarByteOffset = 0; + // iTotalCarBytes = sizeof(tCar) * numcars; + // do { + // iCarByteOffset += sizeof(tCar); // Initialize car physics + // data for replay + // *(_DWORD *)((char *)&CarBox.hitboxAy[15][6].fY + iCarByteOffset) = + // 8;// offset into Car + // *(float *)((char *)&CarBox.hitboxAy[14][2].fZ + iCarByteOffset) = + // 0.0; + // *(float *)((char *)&CarBox.hitboxAy[14][3].fY + iCarByteOffset) = + // 0.0; + // *(float *)((char *)&CarBox.hitboxAy[14][1].fY + iCarByteOffset) = + // 0.0; + // *(float *)((char *)&CarBox.hitboxAy[14][1].fZ + iCarByteOffset) = + // 0.0; + // } while (iCarByteOffset < iTotalCarBytes); + // } + + replayspeed = 256; // Set default replay speed and check for intro mode if (replayfilename[0] == 73 && !intro) filingmenu = 1; } @@ -611,33 +614,34 @@ void startreplay() } //------------------------------------------------------------------------------------------------- -//00064730 -void stopreplay() -{ - char *szTempNamePtr; // edx +// 00064730 +void stopreplay() { + char *szTempNamePtr; // edx char *szDriverNamePtr; // ebx - char *szDstPtr; // edi - char *szSrcPtr; // esi - char byChar1; // al - char byChar2; // al - //int uiAvailBytes; // edx - //int iFileHandle; // eax - //int iFileHandleCopy; // ebx - //int iNewFileSize; // edx - char *szReplayDstPtr; // edi + char *szDstPtr; // edi + char *szSrcPtr; // esi + char byChar1; // al + char byChar2; // al + // int uiAvailBytes; // edx + // int iFileHandle; // eax + // int iFileHandleCopy; // ebx + // int iNewFileSize; // edx + char *szReplayDstPtr; // edi char *szRememberSrcPtr; // esi - char byReplayChar1; // al - char byReplayChar2; // al + char byReplayChar1; // al + char byReplayChar2; // al //_diskfree_t diskfree; // [esp-2h] [ebp-1Ch] BYREF - if (replaytype) { // Close replay file if replay is active - if (replayfile) //check added by ROLLER + if (replaytype) { // Close replay file if replay is active + if (replayfile) // check added by ROLLER fclose(replayfile); } - if (replaytype == 2) // If replay type is 2 (recording/playback mode), restore driver names + if (replaytype == + 2) // If replay type is 2 (recording/playback mode), restore driver names { int iCounter = 0; - szTempNamePtr = temp_names[0]; // Copy temp driver names back to original driver names array + szTempNamePtr = temp_names[0]; // Copy temp driver names back to original + // driver names array szDriverNamePtr = driver_names[0]; do { szDstPtr = szDriverNamePtr; @@ -657,35 +661,41 @@ void stopreplay() ++iCounter; } while (iCounter < 16); - TrackLoad = oldtrack; // Restore original track, car count and texture settings + TrackLoad = + oldtrack; // Restore original track, car count and texture settings numcars = oldcars; textures_off = oldtextures; } - if (replaytype == 1) // If replay type is 1 (recording mode), manage disk space + if (replaytype == + 1) // If replay type is 1 (recording mode), manage disk space { - //dos_getdiskfree(0, &diskfree); // Get disk free space information - //uiAvailBytes = HIWORD(diskfree.total_clusters) * LOWORD(diskfree.avail_clusters) * HIWORD(diskfree.avail_clusters);// Calculate available disk space in bytes - //if (uiAvailBytes < 0x100000) // Check if available space is less than required threshold + // dos_getdiskfree(0, &diskfree); // Get disk free space + // information uiAvailBytes = HIWORD(diskfree.total_clusters) * + // LOWORD(diskfree.avail_clusters) * HIWORD(diskfree.avail_clusters);// + // Calculate available disk space in bytes if (uiAvailBytes < 0x100000) // + // Check if available space is less than required threshold //{ - // iFileHandle = open(replayfilename, 0x202);// Open replay file for trimming - // iFileHandleCopy = iFileHandle; - // if (iFileHandle != -1) { - // iNewFileSize = filelength(iFileHandle) - (0x100000 - uiAvailBytes);// Calculate new file size to free up disk space - // if (iNewFileSize >= 20480) // If new size >= 20KB, truncate file; otherwise delete it - // { - // chsize(iFileHandleCopy, iNewFileSize); - // close(iFileHandleCopy); - // } else { - // close(iFileHandleCopy); - // remove(replayfilename); - // } - // } - //} + // iFileHandle = open(replayfilename, 0x202);// Open replay file for + // trimming iFileHandleCopy = iFileHandle; if (iFileHandle != -1) { + // iNewFileSize = filelength(iFileHandle) - (0x100000 - uiAvailBytes);// + // Calculate new file size to free up disk space if (iNewFileSize >= + // 20480) // If new size >= 20KB, truncate file; otherwise + // delete it + // { + // chsize(iFileHandleCopy, iNewFileSize); + // close(iFileHandleCopy); + // } else { + // close(iFileHandleCopy); + // remove(replayfilename); + // } + // } + // } } - replaytype = 0; // Reset replay type to inactive (0) - if (intro) // If in intro mode, restore original filename + replaytype = 0; // Reset replay type to inactive (0) + if (intro) // If in intro mode, restore original filename { - szReplayDstPtr = replayfilename; // Copy remembered filename back to replay filename + szReplayDstPtr = + replayfilename; // Copy remembered filename back to replay filename szRememberSrcPtr = rememberfilename; do { byReplayChar1 = *szRememberSrcPtr; @@ -701,147 +711,147 @@ void stopreplay() } //------------------------------------------------------------------------------------------------- -//00064880 -void DoReplayData() -{ // Check replay type: 0=disabled, 1=recording, 2=playback - int iCarIndex; // esi - tCar *pCar; // edi - int iCarArrayIndex; // ebp +// 00064880 +void DoReplayData() { // Check replay type: 0=disabled, 1=recording, 2=playback + int iCarIndex; // esi + tCar *pCar; // edi + int iCarArrayIndex; // ebp char byNewRepSample; // ah - char byAdjustedSample; // al + char byAdjustedSample; // al int16 nPitchWithOffsets; // ax - int16 nRollWithOffsets; // ax - tStuntData **ppRamp; // esi - int i; // edi - //tStuntData *pRampData; // eax - tCar *pReplayCar; // ebp - int iCarIndexForReplay; // edx - int16 nChunkFromReplay; // dx - int16 nNegativeChunk; // ax - int iStatusAndSpeed; // edx - int iLivesFromReplay; // edx - int iStunnedDirection; // ecx - int iWheelAnimFrame; // eax - int iDamageState_1; // edi - int iTrackSegmentIdx; // ebx - int iGroundColorIdx; // ecx - float fNearestDistance; // eax - int iCarSpray; // eax - int iSprayIdx; // ecx - tCarSpray *pCarSpray; // ebx - int iDamageIntensity; // edi - int iRandomValue; // eax - tStuntData **ppRampReplay; // esi - int j; // ebp - int iFrameDifference; // ebx - int iDelayWriteNew; // esi - int iInterpolationSteps; // ecx - int iNextDelaySlot; // edx - unsigned int uiSoundOffset; // edi - int iEngineVol; // eax - int iEngineStepCounter; // ebp - int iEngineVolDelta; // edi - int iEnginePitchOld; // eax - int iEnginePitchNew; // edi - int iEnginePitchDelta; // ebp - int iEngine2DelaySlot; // edx + int16 nRollWithOffsets; // ax + tStuntData **ppRamp; // esi + int i; // edi + // tStuntData *pRampData; // eax + tCar *pReplayCar; // ebp + int iCarIndexForReplay; // edx + int16 nChunkFromReplay; // dx + int16 nNegativeChunk; // ax + int iStatusAndSpeed; // edx + int iLivesFromReplay; // edx + int iStunnedDirection; // ecx + int iWheelAnimFrame; // eax + int iDamageState_1; // edi + int iTrackSegmentIdx; // ebx + int iGroundColorIdx; // ecx + float fNearestDistance; // eax + int iCarSpray; // eax + int iSprayIdx; // ecx + tCarSpray *pCarSpray; // ebx + int iDamageIntensity; // edi + int iRandomValue; // eax + tStuntData **ppRampReplay; // esi + int j; // ebp + int iFrameDifference; // ebx + int iDelayWriteNew; // esi + int iInterpolationSteps; // ecx + int iNextDelaySlot; // edx + unsigned int uiSoundOffset; // edi + int iEngineVol; // eax + int iEngineStepCounter; // ebp + int iEngineVolDelta; // edi + int iEnginePitchOld; // eax + int iEnginePitchNew; // edi + int iEnginePitchDelta; // ebp + int iEngine2DelaySlot; // edx unsigned int uiEngine2SoundOffset; // edi - int iEngine2StepIdx; // edi - int iEngine2Vol; // eax - int iEngine2VolCurrent; // ebp - int iEngine2PitchOld; // eax - int iEngine2PitchNew; // ebp - int iEngine2PitchStep; // edi - int iEngine2PitchDelta; // ebp - int iSkidDelaySlot; // edx - unsigned int uiSkidSoundOffset; // edi - int iSkid1Vol; // eax - int iSkidVolCurrent; // ebp - int iSkidVolDelta; // edi - int iSkidPitchOld; // eax - int iSkidPitchNew; // edi - int iSkidPitchStep; // ebp - int iSkidPitchDelta; // edi - int iPanStepIdx; // edi - int iPan; // eax - int iPanDelta; // ebp - int iPanOld; // eax - int iPanNew; // edi - int iPanStepCounter; // ebp - int iCurrentCut; // ecx - int iCutIndex; // eax - int iCutArrayIndex; // edx - int iUpdateSteps; // ecx - int iSmokeCarIndex; // esi - tCar *pSmokeCar; // edi - int iStepCounter; // edx - int iTexCleanupIdx; // ebx - int iTexOffsetStep; // ecx - int iCarTexIdx; // esi - unsigned int uiTexArrayOffset; // eax + int iEngine2StepIdx; // edi + int iEngine2Vol; // eax + int iEngine2VolCurrent; // ebp + int iEngine2PitchOld; // eax + int iEngine2PitchNew; // ebp + int iEngine2PitchStep; // edi + int iEngine2PitchDelta; // ebp + int iSkidDelaySlot; // edx + unsigned int uiSkidSoundOffset; // edi + int iSkid1Vol; // eax + int iSkidVolCurrent; // ebp + int iSkidVolDelta; // edi + int iSkidPitchOld; // eax + int iSkidPitchNew; // edi + int iSkidPitchStep; // ebp + int iSkidPitchDelta; // edi + int iPanStepIdx; // edi + int iPan; // eax + int iPanDelta; // ebp + int iPanOld; // eax + int iPanNew; // edi + int iPanStepCounter; // ebp + int iCurrentCut; // ecx + int iCutIndex; // eax + int iCutArrayIndex; // edx + int iUpdateSteps; // ecx + int iSmokeCarIndex; // esi + tCar *pSmokeCar; // edi + int iStepCounter; // edx + int iTexCleanupIdx; // ebx + int iTexOffsetStep; // ecx + int iCarTexIdx; // esi + unsigned int uiTexArrayOffset; // eax tReplayData replayData; - int iPanNewCopy; // [esp+20h] [ebp-114h] - int iPanDeltaStep; // [esp+24h] [ebp-110h] - int iPanOldCopy; // [esp+28h] [ebp-10Ch] - unsigned int uiDelayOldOffset; // [esp+2Ch] [ebp-108h] - int iPanStepCount; // [esp+30h] [ebp-104h] - int iSkidStepCount; // [esp+34h] [ebp-100h] - int iEnginePitchStepCount; // [esp+38h] [ebp-FCh] - float fDistanceBuffer; // [esp+40h] [ebp-F4h] - int iDelayIdxForEngine; // [esp+50h] [ebp-E4h] - int iDelayWriteOld; // [esp+54h] [ebp-E0h] - int bReadDisabled; // [esp+58h] [ebp-DCh] - int iDamageState; // [esp+5Ch] [ebp-D8h] - int iReplayCarIndex; // [esp+60h] [ebp-D4h] - int iNearestChunk; // [esp+64h] [ebp-D0h] BYREF - unsigned int uiEnginePitchOffset; // [esp+68h] [ebp-CCh] + int iPanNewCopy; // [esp+20h] [ebp-114h] + int iPanDeltaStep; // [esp+24h] [ebp-110h] + int iPanOldCopy; // [esp+28h] [ebp-10Ch] + unsigned int uiDelayOldOffset; // [esp+2Ch] [ebp-108h] + int iPanStepCount; // [esp+30h] [ebp-104h] + int iSkidStepCount; // [esp+34h] [ebp-100h] + int iEnginePitchStepCount; // [esp+38h] [ebp-FCh] + float fDistanceBuffer; // [esp+40h] [ebp-F4h] + int iDelayIdxForEngine; // [esp+50h] [ebp-E4h] + int iDelayWriteOld; // [esp+54h] [ebp-E0h] + int bReadDisabled; // [esp+58h] [ebp-DCh] + int iDamageState; // [esp+5Ch] [ebp-D8h] + int iReplayCarIndex; // [esp+60h] [ebp-D4h] + int iNearestChunk; // [esp+64h] [ebp-D0h] BYREF + unsigned int uiEnginePitchOffset; // [esp+68h] [ebp-CCh] unsigned int uiEngine2PitchOffset; // [esp+6Ch] [ebp-C8h] - unsigned int uiSkidPitchOffset; // [esp+70h] [ebp-C4h] + unsigned int uiSkidPitchOffset; // [esp+70h] [ebp-C4h] unsigned int uiDelayOldByteOffset; // [esp+74h] [ebp-C0h] unsigned int uiDelayNewByteOffset; // [esp+78h] [ebp-BCh] - unsigned int uiPanSoundOffset; // [esp+7Ch] [ebp-B8h] - int iNextDelayIndex; // [esp+80h] [ebp-B4h] - unsigned int uiEngineCalcOffset; // [esp+84h] [ebp-B0h] - unsigned int uiEngine2CalcOffset; // [esp+88h] [ebp-ACh] - unsigned int uiSkidCalcOffset; // [esp+8Ch] [ebp-A8h] - unsigned int uiPanCalcOffset; // [esp+90h] [ebp-A4h] - unsigned int uiCarOffset; // [esp+94h] [ebp-A0h] - int iEngineVolStep; // [esp+98h] [ebp-9Ch] - int iEngineVolIncrement; // [esp+9Ch] [ebp-98h] - int iEngineVolBase; // [esp+A0h] [ebp-94h] - int iEnginePitchStep; // [esp+A4h] [ebp-90h] - int iEnginePitchBase; // [esp+A8h] [ebp-8Ch] - int iEngine2VolIncrement; // [esp+ACh] [ebp-88h] - int iEngine2VolDelta; // [esp+B0h] [ebp-84h] - int iEngine2VolBase; // [esp+B4h] [ebp-80h] - int iEngine2PitchWorking; // [esp+B8h] [ebp-7Ch] - int iEngine2PitchIncrement; // [esp+BCh] [ebp-78h] - int iEngine2PitchBase; // [esp+C0h] [ebp-74h] - int iSkidVolIncrement; // [esp+C4h] [ebp-70h] - int iSkidVolBase; // [esp+C8h] [ebp-6Ch] - int iSkidPitchWorking; // [esp+CCh] [ebp-68h] - int iSkidPitchIncrement; // [esp+D0h] [ebp-64h] - int iSkidPitchBase; // [esp+D4h] [ebp-60h] - int iPanStep; // [esp+D8h] [ebp-5Ch] - int iPanIncrement; // [esp+DCh] [ebp-58h] - int iPanBase; // [esp+E0h] [ebp-54h] - int iCarLoopIndex; // [esp+E4h] [ebp-50h] - unsigned int uiSoundOffsetCopy; // [esp+E8h] [ebp-4Ch] - unsigned int uiSoundDataOffset; // [esp+ECh] [ebp-48h] - int iTotalCarDataSize; // [esp+F0h] [ebp-44h] - float fBestDistance; // [esp+F4h] [ebp-40h] - int iPanLoopStep; // [esp+F8h] [ebp-3Ch] - int iEngine2LoopStep; // [esp+FCh] [ebp-38h] - int iSkidPitchDelayIdx; // [esp+100h] [ebp-34h] - int iSkidVolDelayIdx; // [esp+104h] [ebp-30h] - int iEngine2PitchDelayIdx; // [esp+108h] [ebp-2Ch] - int iEnginePitchDelayIdx; // [esp+10Ch] [ebp-28h] - int iConversionBuffer; // [esp+110h] [ebp-24h] - tStuntData *pRampData_1; // [esp+114h] [ebp-20h] BYREF - int iTempCalcBuffer; // [esp+118h] [ebp-1Ch] + unsigned int uiPanSoundOffset; // [esp+7Ch] [ebp-B8h] + int iNextDelayIndex; // [esp+80h] [ebp-B4h] + unsigned int uiEngineCalcOffset; // [esp+84h] [ebp-B0h] + unsigned int uiEngine2CalcOffset; // [esp+88h] [ebp-ACh] + unsigned int uiSkidCalcOffset; // [esp+8Ch] [ebp-A8h] + unsigned int uiPanCalcOffset; // [esp+90h] [ebp-A4h] + unsigned int uiCarOffset; // [esp+94h] [ebp-A0h] + int iEngineVolStep; // [esp+98h] [ebp-9Ch] + int iEngineVolIncrement; // [esp+9Ch] [ebp-98h] + int iEngineVolBase; // [esp+A0h] [ebp-94h] + int iEnginePitchStep; // [esp+A4h] [ebp-90h] + int iEnginePitchBase; // [esp+A8h] [ebp-8Ch] + int iEngine2VolIncrement; // [esp+ACh] [ebp-88h] + int iEngine2VolDelta; // [esp+B0h] [ebp-84h] + int iEngine2VolBase; // [esp+B4h] [ebp-80h] + int iEngine2PitchWorking; // [esp+B8h] [ebp-7Ch] + int iEngine2PitchIncrement; // [esp+BCh] [ebp-78h] + int iEngine2PitchBase; // [esp+C0h] [ebp-74h] + int iSkidVolIncrement; // [esp+C4h] [ebp-70h] + int iSkidVolBase; // [esp+C8h] [ebp-6Ch] + int iSkidPitchWorking; // [esp+CCh] [ebp-68h] + int iSkidPitchIncrement; // [esp+D0h] [ebp-64h] + int iSkidPitchBase; // [esp+D4h] [ebp-60h] + int iPanStep; // [esp+D8h] [ebp-5Ch] + int iPanIncrement; // [esp+DCh] [ebp-58h] + int iPanBase; // [esp+E0h] [ebp-54h] + int iCarLoopIndex; // [esp+E4h] [ebp-50h] + unsigned int uiSoundOffsetCopy; // [esp+E8h] [ebp-4Ch] + unsigned int uiSoundDataOffset; // [esp+ECh] [ebp-48h] + int iTotalCarDataSize; // [esp+F0h] [ebp-44h] + float fBestDistance; // [esp+F4h] [ebp-40h] + int iPanLoopStep; // [esp+F8h] [ebp-3Ch] + int iEngine2LoopStep; // [esp+FCh] [ebp-38h] + int iSkidPitchDelayIdx; // [esp+100h] [ebp-34h] + int iSkidVolDelayIdx; // [esp+104h] [ebp-30h] + int iEngine2PitchDelayIdx; // [esp+108h] [ebp-2Ch] + int iEnginePitchDelayIdx; // [esp+10Ch] [ebp-28h] + int iConversionBuffer; // [esp+110h] [ebp-24h] + tStuntData *pRampData_1; // [esp+114h] [ebp-20h] BYREF + int iTempCalcBuffer; // [esp+118h] [ebp-1Ch] if (replaytype) { - if ((unsigned int)replaytype <= 1) { // Recording mode: write replay data to file + if ((unsigned int)replaytype <= + 1) { // Recording mode: write replay data to file if (replayfile && !discfull) { iCarIndex = 0; @@ -861,21 +871,28 @@ void DoReplayData() repsample[iCarIndex] = byAdjustedSample; } - replayData.iPackedPosX = PACK_24_WITH_TAG((int32)pCar->pos.fX, repsample[iCarIndex]); - replayData.iPackedPosY = PACK_24_WITH_TAG((int32)pCar->pos.fY, repvolume[iCarIndex]); - replayData.iPackedPosZ = PACK_24_WITH_TAG((int32)pCar->pos.fZ, (uint8)pCar->iSteeringInput); + replayData.iPackedPosX = + PACK_24_WITH_TAG((int32)pCar->pos.fX, repsample[iCarIndex]); + replayData.iPackedPosY = + PACK_24_WITH_TAG((int32)pCar->pos.fY, repvolume[iCarIndex]); + replayData.iPackedPosZ = PACK_24_WITH_TAG( + (int32)pCar->pos.fZ, (uint8)pCar->iSteeringInput); //__asm { fld dword ptr[edx]; Load Real } //_CHP(); //__asm { fistp[esp + 134h + var_24]; Store Integer and Pop } - //iPackedPosX = (repsample[iCarIndex] << 24) | iConversionBuffer & 0xFFFFFF;// Pack X position with sample data in high byte + // iPackedPosX = (repsample[iCarIndex] << 24) | iConversionBuffer + // & 0xFFFFFF;// Pack X position with sample data in high byte //__asm { fld dword ptr[edx + 4]; Load Real } //_CHP(); //__asm { fistp[esp + 134h + var_24]; Store Integer and Pop } - //iPackedPosY = ((unsigned __int8)repvolume[iCarIndex] << 24) | iConversionBuffer & 0xFFFFFF;// Pack Y position with volume data in high byte + // iPackedPosY = ((unsigned __int8)repvolume[iCarIndex] << 24) | + // iConversionBuffer & 0xFFFFFF;// Pack Y position with volume + // data in high byte //__asm { fld dword ptr[edx + 8]; Load Real } //_CHP(); //__asm { fistp[esp + 134h + var_24]; Store Integer and Pop } - //iPackedPosZ = (pCar->iSteeringInput << 24) | iConversionBuffer & 0xFFFFFF;// Pack Z position with steering input in high byte + // iPackedPosZ = (pCar->iSteeringInput << 24) | iConversionBuffer + // & 0xFFFFFF;// Pack Z position with steering input in high byte if (pCar->nCurrChunk == -1) replayData.nCurrChunk = -pCar->nReferenceChunk; @@ -883,26 +900,32 @@ void DoReplayData() replayData.nCurrChunk = pCar->nCurrChunk; replayData.nDesiredYaw = pCar->nYaw; replayData.nActualYaw = pCar->nActualYaw; - nPitchWithOffsets = (int16)(pCar->iPitchCameraOffset) + (int16)(pCar->iPitchDynamicOffset) + pCar->nPitch; + nPitchWithOffsets = (int16)(pCar->iPitchCameraOffset) + + (int16)(pCar->iPitchDynamicOffset) + + pCar->nPitch; nPitchWithOffsets &= 0x3FFF; - //HIBYTE(nPitchWithOffsets) &= 0x3Fu; + // HIBYTE(nPitchWithOffsets) &= 0x3Fu; replayData.nPitchPacked = nPitchWithOffsets; - nRollWithOffsets = (int16)(pCar->iRollCameraOffset) + (int16)(pCar->iRollDynamicOffset) + pCar->nRoll; + nRollWithOffsets = (int16)(pCar->iRollCameraOffset) + + (int16)(pCar->iRollDynamicOffset) + + pCar->nRoll; nRollWithOffsets &= 0x3FFF; - //HIBYTE(nRollWithOffsets) &= 0x3Fu; + // HIBYTE(nRollWithOffsets) &= 0x3Fu; replayData.nRollPacked = nRollWithOffsets; - // Convert car speed (take absolute value) and pack with lives/status data + // Convert car speed (take absolute value) and pack with + // lives/status data //_CHP(); iConversionBuffer = (int)fabs(pCar->fFinalSpeed); - replayData.nSpeedAndStatus = iConversionBuffer | (((char)pCar->byLives + 2) << 10); + replayData.nSpeedAndStatus = + iConversionBuffer | (((char)pCar->byLives + 2) << 10); // Pack status flags into high byte - if ( (pCar->byStatusFlags & 2) != 0 ) + if ((pCar->byStatusFlags & 2) != 0) replayData.nSpeedAndStatus |= 0x2000u; - //HIBYTE(nSpeedAndStatus) |= 0x20u; - if ( (pCar->byStatusFlags & 4) != 0 ) + // HIBYTE(nSpeedAndStatus) |= 0x20u; + if ((pCar->byStatusFlags & 4) != 0) replayData.nSpeedAndStatus |= 0x4000u; - //HIBYTE(nSpeedAndStatus) |= 0x40u; + // HIBYTE(nSpeedAndStatus) |= 0x40u; // Convert RPM ratio with scaling factor //_CHP(); iConversionBuffer = (int)(pCar->fRPMRatio * 255.0); @@ -910,7 +933,9 @@ void DoReplayData() // Convert health value and pack with stunned flag //_CHP(); iConversionBuffer = (int)pCar->fHealth; - replayData.byHealthAndStunned = iConversionBuffer | ((uint8)(pCar->iStunned) << 7); //TODO: check on this + replayData.byHealthAndStunned = + iConversionBuffer | + ((uint8)(pCar->iStunned) << 7); // TODO: check on this //__asm //{ // fld dword ptr[edx + 18h]; Load Real @@ -918,10 +943,11 @@ void DoReplayData() //} //_CHP(); //__asm { fistp[esp + 134h + var_24]; Store Integer and Pop } - //nSpeedAndStatus = iConversionBuffer | (((char)pCar->byLives + 2) << 10);// Pack speed and lives data into replay format - //if ((pCar->byStatusFlags & 2) != 0) + // nSpeedAndStatus = iConversionBuffer | (((char)pCar->byLives + + // 2) << 10);// Pack speed and lives data into replay format if + // ((pCar->byStatusFlags & 2) != 0) // HIBYTE(nSpeedAndStatus) |= 0x20u; - //if ((pCar->byStatusFlags & 4) != 0) + // if ((pCar->byStatusFlags & 4) != 0) // HIBYTE(nSpeedAndStatus) |= 0x40u; //__asm //{ @@ -930,13 +956,17 @@ void DoReplayData() //} //_CHP(); //__asm { fistp[esp + 134h + var_24]; Store Integer and Pop } - //byRPMPacked = iConversionBuffer; + // byRPMPacked = iConversionBuffer; //__asm { fld dword ptr[edx + 1Ch]; Load Real } //_CHP(); //__asm { fistp[esp + 134h + var_24]; Store Integer and Pop } - //byHealthAndStunned = iConversionBuffer | (LOBYTE(pCar->iStunned) << 7); + // byHealthAndStunned = iConversionBuffer | + // (LOBYTE(pCar->iStunned) << 7); - replayData.byMiscCarData = (pCar->byDamageToggle << 7) + 8 * (uint8)(pCar->iDamageState) + pCar->byGearAyMax + 2 + 16 * pCar->byWheelAnimationFrame; + replayData.byMiscCarData = (pCar->byDamageToggle << 7) + + 8 * (uint8)(pCar->iDamageState) + + pCar->byGearAyMax + 2 + + 16 * pCar->byWheelAnimationFrame; replayData.byLap = pCar->byLap; if (pCar->nDeathTimer >= 0) replayData.byDeathTimer = (char)pCar->nDeathTimer; @@ -957,32 +987,32 @@ void DoReplayData() for (i = 0; i < 8; ++i) { int16 nRampTiming; if (*ppRamp) { - // Ramp exists - get its activation timing + // Ramp exists - get its activation timing nRampTiming = (*ppRamp)->iTickStartIdx; } else { - // No ramp in this slot - write 0 + // No ramp in this slot - write 0 nRampTiming = 0; } // Write 2 bytes (16-bit timing value) to replay file if (!fwrite(&nRampTiming, 2, 1, replayfile)) discfull = -1; - ++ppRamp; // Move to next ramp slot + ++ppRamp; // Move to next ramp slot } - //ppRamp = ramp; - //for (i = 0; i < 8; ++i) { - // pRampData = *ppRamp; - // if (*ppRamp) { - // LOWORD(pRampData) = pRampData->iTickStartIdx; - // ++ppRamp; - // } else { - // pRampData = 0; - // } - // pRampData_1 = pRampData; - // if (!fwrite(&pRampData_1, 2, 1, replayfile)) - // discfull = -1; - //} + // ppRamp = ramp; + // for (i = 0; i < 8; ++i) { + // pRampData = *ppRamp; + // if (*ppRamp) { + // LOWORD(pRampData) = pRampData->iTickStartIdx; + // ++ppRamp; + // } else { + // pRampData = 0; + // } + // pRampData_1 = pRampData; + // if (!fwrite(&pRampData_1, 2, 1, replayfile)) + // discfull = -1; + // } } - } else if (replaytype == 2) { // Playback mode: read and apply replay data + } else if (replaytype == 2) { // Playback mode: read and apply replay data if (replayspeed != 256) stopallsamples(); newreplayframe = 0; @@ -1002,7 +1032,8 @@ void DoReplayData() } bReadDisabled = -1; } - if (replayframes - 1 == currentreplayframe && replayspeed > 0 && replaytype == 2) { + if (replayframes - 1 == currentreplayframe && replayspeed > 0 && + replaytype == 2) { //_disable(); replayspeed = 0; fraction = 0; @@ -1022,7 +1053,8 @@ void DoReplayData() newreplayframe = 0; } else { newreplayframe = -1; - fseek(replayfile, replayblock * currentreplayframe + replayheader, 0);// Seek to current replay frame in file + fseek(replayfile, replayblock * currentreplayframe + replayheader, + 0); // Seek to current replay frame in file iReplayCarIndex = 0; // Read car state data from replay file @@ -1034,34 +1066,39 @@ void DoReplayData() fread(&replayData, 0x1Eu, 1u, replayfile); // Unpack X position: extract lower 24 bits and convert to float - pReplayCar->pos.fX = (float)SIGN_EXTEND_24(replayData.iPackedPosX); - pReplayCar->pos.fY = (float)SIGN_EXTEND_24(replayData.iPackedPosY); - pReplayCar->pos.fZ = (float)SIGN_EXTEND_24(replayData.iPackedPosZ); - //iConversionBuffer = iPackedPosX << 8 >> 8; + pReplayCar->pos.fX = + (float)SIGN_EXTEND_24(replayData.iPackedPosX); + pReplayCar->pos.fY = + (float)SIGN_EXTEND_24(replayData.iPackedPosY); + pReplayCar->pos.fZ = + (float)SIGN_EXTEND_24(replayData.iPackedPosZ); + // iConversionBuffer = iPackedPosX << 8 >> 8; //__asm //{ - // fild[esp + 134h + var_24]; Load Integer - // fstp dword ptr[ebp + 0]; Store Real and Pop - //} - //pReplayCar->pos.fX = _ET1; - //iConversionBuffer = iPackedPosY << 8 >> 8; + // fild[esp + 134h + var_24]; Load Integer + // fstp dword ptr[ebp + 0]; Store Real and Pop + // } + // pReplayCar->pos.fX = _ET1; + // iConversionBuffer = iPackedPosY << 8 >> 8; //__asm //{ - // fild[esp + 134h + var_24]; Load Integer - // fstp dword ptr[ebp + 4]; Store Real and Pop - //} - //pReplayCar->pos.fY = _ET1; - //iConversionBuffer = iPackedPosZ << 8 >> 8; + // fild[esp + 134h + var_24]; Load Integer + // fstp dword ptr[ebp + 4]; Store Real and Pop + // } + // pReplayCar->pos.fY = _ET1; + // iConversionBuffer = iPackedPosZ << 8 >> 8; //__asm //{ - // fild[esp + 134h + var_24]; Load Integer - // fstp dword ptr[ebp + 8]; Store Real and Pop - //} - //pReplayCar->pos.fZ = _ET1; + // fild[esp + 134h + var_24]; Load Integer + // fstp dword ptr[ebp + 8]; Store Real and Pop + // } + // pReplayCar->pos.fZ = _ET1; iCarIndexForReplay = iReplayCarIndex; - newrepsample[iReplayCarIndex] = GET_HIBYTE(replayData.iPackedPosX); - repvolume[iCarIndexForReplay] = GET_HIBYTE(replayData.iPackedPosY); + newrepsample[iReplayCarIndex] = + GET_HIBYTE(replayData.iPackedPosX); + repvolume[iCarIndexForReplay] = + GET_HIBYTE(replayData.iPackedPosY); pReplayCar->iSteeringInput = replayData.iPackedPosZ >> 24; nChunkFromReplay = replayData.nCurrChunk; //_ESI = pReplayCar; @@ -1081,17 +1118,16 @@ void DoReplayData() if (pReplayCar->iControlType == 3) { tData *pData = &localdata[pReplayCar->nCurrChunk]; // Compare car's Y position with track lane boundary - if ( pReplayCar->pos.fY < pData->fTrackHalfWidth || isnan(pReplayCar->pos.fY) ) - { - // Check if car is in the opposite lane boundary - if ( pReplayCar->pos.fY > -pData->fTrackHalfWidth || isnan(pReplayCar->pos.fY) ) - pReplayCar->iLaneType = 1; // Left lane or boundary area - else - pReplayCar->iLaneType = 2; // Far left outside track - } - else - { - pReplayCar->iLaneType = 0; // Right lane or center + if (pReplayCar->pos.fY < pData->fTrackHalfWidth || + isnan(pReplayCar->pos.fY)) { + // Check if car is in the opposite lane boundary + if (pReplayCar->pos.fY > -pData->fTrackHalfWidth || + isnan(pReplayCar->pos.fY)) + pReplayCar->iLaneType = 1; // Left lane or boundary area + else + pReplayCar->iLaneType = 2; // Far left outside track + } else { + pReplayCar->iLaneType = 0; // Right lane or center } //__asm { fld dword ptr[esi + 4]; Load Real } //_EDX = &localdata[pReplayCar->nCurrChunk]; @@ -1100,7 +1136,7 @@ void DoReplayData() // fcomp dword ptr[edx + 34h]; Compare Real and Pop // fnstsw ax; Store Status Word(no wait) //} - //if ((_AX & 0x100) != 0 || (_AX & 0x4000) != 0) { + // if ((_AX & 0x100) != 0 || (_AX & 0x4000) != 0) { // __asm // { // fld dword ptr[edx + 34h]; Load Real @@ -1119,20 +1155,23 @@ void DoReplayData() pReplayCar->nYaw = replayData.nDesiredYaw; pReplayCar->nActualYaw = replayData.nActualYaw; pReplayCar->nPitch = replayData.nPitchPacked; - //HIWORD(iStatusAndSpeed) = 0; + // HIWORD(iStatusAndSpeed) = 0; pReplayCar->nRoll = replayData.nRollPacked; - //LOWORD(iStatusAndSpeed) = nSpeedAndStatus; + // LOWORD(iStatusAndSpeed) = nSpeedAndStatus; iStatusAndSpeed = replayData.nSpeedAndStatus; - // Extract speed data from packed format (lower 10 bits) and convert to float - iConversionBuffer = replayData.nSpeedAndStatus & 0x2FF; // Extract lower 10 bits containing speed + // Extract speed data from packed format (lower 10 bits) and + // convert to float + iConversionBuffer = + replayData.nSpeedAndStatus & + 0x2FF; // Extract lower 10 bits containing speed pReplayCar->byStatusFlags = 0; pReplayCar->fFinalSpeed = (float)iConversionBuffer; - //iConversionBuffer = nSpeedAndStatus & 0x2FF; + // iConversionBuffer = nSpeedAndStatus & 0x2FF; //__asm { fild[esp + 134h + var_24]; Load Integer } - //pReplayCar->byStatusFlags = 0; + // pReplayCar->byStatusFlags = 0; //__asm { fstp dword ptr[esi + 18h]; Store Real and Pop } - //pReplayCar->fFinalSpeed = _ET1; + // pReplayCar->fFinalSpeed = _ET1; if ((iStatusAndSpeed & 0x2000) != 0) pReplayCar->byStatusFlags = 2; @@ -1147,27 +1186,32 @@ void DoReplayData() } pReplayCar->nDeathTimer = replayData.byDeathTimer; - // Unpack RPM data: convert packed byte back to floating point ratio - pReplayCar->fRPMRatio = (float)replayData.byRPMPacked * 0.00392156862745098f; - //LOWORD(iTempCalcBuffer) = byRPMPacked; + // Unpack RPM data: convert packed byte back to floating point + // ratio + pReplayCar->fRPMRatio = + (float)replayData.byRPMPacked * 0.00392156862745098f; + // LOWORD(iTempCalcBuffer) = byRPMPacked; //__asm //{ - // fild word ptr[esp + 134h + var_1C]; Load Integer - // fmul replay_c_variable_16; Multiply Real - // fstp dword ptr[esi + 78h]; Store Real and Pop - //} - //pReplayCar->fRPMRatio = _ET1; - - // Extract health data from packed format (lower 7 bits) and convert to float - iTempCalcBuffer = replayData.byHealthAndStunned & 0x7F; // Extract lower 7 bits containing health + // fild word ptr[esp + 134h + var_1C]; Load Integer + // fmul replay_c_variable_16; Multiply Real + // fstp dword ptr[esi + 78h]; Store Real and Pop + // } + // pReplayCar->fRPMRatio = _ET1; + + // Extract health data from packed format (lower 7 bits) and + // convert to float + iTempCalcBuffer = + replayData.byHealthAndStunned & + 0x7F; // Extract lower 7 bits containing health pReplayCar->fHealth = (float)iTempCalcBuffer; - //iTempCalcBuffer = byHealthAndStunned & 0x7F; + // iTempCalcBuffer = byHealthAndStunned & 0x7F; //__asm //{ - // fild word ptr[esp + 134h + var_1C]; Load Integer - // fstp dword ptr[esi + 1Ch]; Store Real and Pop - //} - //pReplayCar->fHealth = _ET1; + // fild word ptr[esp + 134h + var_1C]; Load Integer + // fstp dword ptr[esi + 1Ch]; Store Real and Pop + // } + // pReplayCar->fHealth = _ET1; iStunnedDirection = (int)replayData.byHealthAndStunned >> 7; pReplayCar->iStunned = iStunnedDirection; @@ -1178,56 +1222,62 @@ void DoReplayData() pReplayCar->byWheelAnimationFrame = iWheelAnimFrame; if ((uint8)iWheelAnimFrame > 4u) pReplayCar->byWheelAnimationFrame = 4; - pReplayCar->byDamageToggle = (replayData.byMiscCarData & 0x80) >> 7; + pReplayCar->byDamageToggle = + (replayData.byMiscCarData & 0x80) >> 7; iDamageState_1 = pReplayCar->iDamageState; pReplayCar->byDamageIntensity = replayData.byDamageIntensity; - if (iDamageState_1 != iDamageState && ViewType[0] == pReplayCar->iDriverIdx) { + if (iDamageState_1 != iDamageState && + ViewType[0] == pReplayCar->iDriverIdx) { if (replayData.nCurrChunk < 0) { tData *pData = &localdata[0]; - fBestDistance = 1.0e10f; // Very large initial value (appears to be a float constant) + fBestDistance = 1.0e10f; // Very large initial value + // (appears to be a float constant) iTrackSegmentIdx = 0; - if ( TRAK_LEN > 0 ) - { + if (TRAK_LEN > 0) { iGroundColorIdx = 0; - do - { - // Calculate relative position (car position + track segment offset) - float fRelativeX = pReplayCar->pos.fX + pData->pointAy[3].fX; // [edx+24h] - float fRelativeY = pReplayCar->pos.fY + pData->pointAy[3].fY; // [edx+28h] - float fRelativeZ = pReplayCar->pos.fZ + pData->pointAy[3].fZ; // [edx+2Ch] + do { + // Calculate relative position (car position + track + // segment offset) + float fRelativeX = pReplayCar->pos.fX + + pData->pointAy[3].fX; // [edx+24h] + float fRelativeY = pReplayCar->pos.fY + + pData->pointAy[3].fY; // [edx+28h] + float fRelativeZ = pReplayCar->pos.fZ + + pData->pointAy[3].fZ; // [edx+2Ch] // Calculate dot product with track normal vector - float fDotProduct = (pData->pointAy[0].fZ * fRelativeX) + // [edx+8] - (pData->pointAy[1].fZ * fRelativeY) + // [edx+14h] - (pData->pointAy[2].fZ * fRelativeZ); // [edx+20h] - + float fDotProduct = + (pData->pointAy[0].fZ * fRelativeX) + // [edx+8] + (pData->pointAy[1].fZ * fRelativeY) + // [edx+14h] + (pData->pointAy[2].fZ * fRelativeZ); // [edx+20h] + // Calculate distance from car to track segment - float fDistanceSquared = (fRelativeX * fRelativeX) + - (fRelativeY * fRelativeY) + - (fRelativeZ * fRelativeZ) - - (fDotProduct * fDotProduct); - float fDistance = (float)sqrt(fDistanceSquared) - pData->fTrackHalfLength; // [edx+30h] + float fDistanceSquared = (fRelativeX * fRelativeX) + + (fRelativeY * fRelativeY) + + (fRelativeZ * fRelativeZ) - + (fDotProduct * fDotProduct); + float fDistance = (float)sqrt(fDistanceSquared) - + pData->fTrackHalfLength; // [edx+30h] fDistanceBuffer = fDistance; - // Check if this is a valid segment and closer than previous best - if ( fDistance >= -400.0 || GroundColour[iGroundColorIdx][2] >= 0 ) - { - if ( fDistance < fBestDistance ) - { + // Check if this is a valid segment and closer than + // previous best + if (fDistance >= -400.0 || + GroundColour[iGroundColorIdx][2] >= 0) { + if (fDistance < fBestDistance) { fNearestDistance = fDistanceBuffer; pReplayCar->iLastValidChunk = iTrackSegmentIdx; fBestDistance = fNearestDistance; } } ++pData; - ++iTrackSegmentIdx; + ++iTrackSegmentIdx; ++iGroundColorIdx; - } - while ( iTrackSegmentIdx < TRAK_LEN ); + } while (iTrackSegmentIdx < TRAK_LEN); } //_EDX = localdata; - //fBestDistance = 1.0e10; - //iTrackSegmentIdx = 0; - //if (TRAK_LEN > 0) { + // fBestDistance = 1.0e10; + // iTrackSegmentIdx = 0; + // if (TRAK_LEN > 0) { // iGroundColorIdx = 0; // do { // __asm @@ -1261,7 +1311,8 @@ void DoReplayData() // fcomp replay_c_variable_17; Compare Real and Pop // fnstsw ax; Store Status Word(no wait) // } - // if ((_AX & 0x100) == 0 || GroundColour[iGroundColorIdx][2] >= 0) { + // if ((_AX & 0x100) == 0 || + // GroundColour[iGroundColorIdx][2] >= 0) { // __asm // { // fld[esp + 134h + var_F4]; Load Real @@ -1286,13 +1337,15 @@ void DoReplayData() if (iDamageState != pReplayCar->iDamageState) { for (iCarSpray = 0; iCarSpray < 32; iCarSpray++) CarSpray[pReplayCar->iDriverIdx][iCarSpray].iTimer = 0; - //for (iTexIndex = 0; iTexIndex != 352; car_texs_loaded[352 * pReplayCar->iDriverIdx + 12 + iTexIndex] = 0) - // iTexIndex += 11; + // for (iTexIndex = 0; iTexIndex != 352; car_texs_loaded[352 * + // pReplayCar->iDriverIdx + 12 + iTexIndex] = 0) + // iTexIndex += 11; pReplayCar->byLastDamageToggle = pReplayCar->byDamageToggle; } // Initialize damage spray effects when damage state changes - if (pReplayCar->byDamageToggle != pReplayCar->byLastDamageToggle) { + if (pReplayCar->byDamageToggle != + pReplayCar->byLastDamageToggle) { iSprayIdx = 0; pCarSpray = CarSpray[pReplayCar->iDriverIdx]; iDamageIntensity = pReplayCar->byDamageIntensity; @@ -1345,36 +1398,64 @@ void DoReplayData() do { if (!non_competitors[iCarLoopIndex / 4u]) { // Check if engine sound data needs interpolation or reset - if (enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iEngineVol == -1 - || enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C + uiSoundDataOffset / 0x1C].iEngineVol == -1) { + if (enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iEngineVol == -1 || + enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C + + uiSoundDataOffset / 0x1C] + .iEngineVol == -1) { iNextDelaySlot = iNextDelayIndex; if (iDelayWriteNew != iNextDelayIndex) { uiSoundOffset = uiSoundDataOffset; do { - *(int *)((char *)&enginedelay[0].engineSoundData[iNextDelaySlot].iEngineVol + uiSoundOffset) = -1; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iNextDelaySlot] + .iEngineVol + + uiSoundOffset) = -1; iNextDelaySlot = ((uint8)iNextDelaySlot + 1) & 0x1F; } while (iNextDelaySlot != iDelayWriteNew); } } else { iDelayIdxForEngine = iDelayWriteOld; - iEngineVol = enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C + uiSoundDataOffset / 0x1C].iEngineVol; - iEngineVolIncrement = enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iEngineVol; + iEngineVol = + enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C + + uiSoundDataOffset / 0x1C] + .iEngineVol; + iEngineVolIncrement = + enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iEngineVol; iEngineVolStep = iEngineVolIncrement; iEngineStepCounter = 1; iEngineVolBase = iEngineVol; uiEngineCalcOffset = uiSoundDataOffset; iEngineVolDelta = iEngineVol * -iFrameDifference; do { - iDelayIdxForEngine = ((uint8)iDelayIdxForEngine + 1) & 0x1F; + iDelayIdxForEngine = + ((uint8)iDelayIdxForEngine + 1) & 0x1F; iConversionBuffer = 28 * iDelayIdxForEngine; - *(int *)((char *)&enginedelay[0].engineSoundData[iDelayIdxForEngine].iEngineVol + uiEngineCalcOffset) = (iEngineVolStep - iEngineVolDelta) - / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iDelayIdxForEngine] + .iEngineVol + + uiEngineCalcOffset) = + (iEngineVolStep - iEngineVolDelta) / + iInterpolationSteps; ++iEngineStepCounter; iEngineVolStep += iEngineVolIncrement; iEngineVolDelta += iEngineVolBase; } while (iEngineStepCounter <= iFrameDifference); - iEnginePitchOld = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C].iEnginePitch + uiEngineCalcOffset); - iEnginePitchNew = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayNewByteOffset / 0x1C].iEnginePitch + uiEngineCalcOffset); + iEnginePitchOld = *( + int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C] + .iEnginePitch + + uiEngineCalcOffset); + iEnginePitchNew = *( + int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayNewByteOffset / 0x1C] + .iEnginePitch + + uiEngineCalcOffset); iEnginePitchDelayIdx = iDelayWriteOld; iEnginePitchStepCount = 1; uiEnginePitchOffset = uiSoundDataOffset; @@ -1382,32 +1463,54 @@ void DoReplayData() iEnginePitchStep = iEnginePitchNew; iEnginePitchDelta = iEnginePitchOld * -iFrameDifference; do { - iEnginePitchDelayIdx = ((uint8)iEnginePitchDelayIdx + 1) & 0x1F; + iEnginePitchDelayIdx = + ((uint8)iEnginePitchDelayIdx + 1) & 0x1F; iConversionBuffer = 28 * iEnginePitchDelayIdx; - *(int *)((char *)&enginedelay[0].engineSoundData[iEnginePitchDelayIdx].iEnginePitch + uiEnginePitchOffset) = (iEnginePitchNew - iEnginePitchDelta) - / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iEnginePitchDelayIdx] + .iEnginePitch + + uiEnginePitchOffset) = + (iEnginePitchNew - iEnginePitchDelta) / + iInterpolationSteps; iEnginePitchNew += iEnginePitchStep; iEnginePitchDelta += iEnginePitchBase; ++iEnginePitchStepCount; } while (iFrameDifference >= iEnginePitchStepCount); } - // Begin engine2 sound interpolation (secondary engine channel) - if (enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iEngine2Vol == -1 - || enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C + uiSoundDataOffset / 0x1C].iEngine2Vol == -1) { + // Begin engine2 sound interpolation (secondary engine + // channel) + if (enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iEngine2Vol == -1 || + enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C + + uiSoundDataOffset / 0x1C] + .iEngine2Vol == -1) { iEngine2DelaySlot = iNextDelayIndex; if (iDelayWriteNew != iNextDelayIndex) { uiEngine2SoundOffset = uiSoundDataOffset; do { - *(int *)((char *)&enginedelay[0].engineSoundData[iEngine2DelaySlot].iEngine2Vol + uiEngine2SoundOffset) = -1; - iEngine2DelaySlot = ((uint8)iEngine2DelaySlot + 1) & 0x1F; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iEngine2DelaySlot] + .iEngine2Vol + + uiEngine2SoundOffset) = -1; + iEngine2DelaySlot = + ((uint8)iEngine2DelaySlot + 1) & 0x1F; } while (iEngine2DelaySlot != iDelayWriteNew); } } else { iEngine2StepIdx = iDelayWriteOld; - //LOBYTE(iEngine2StepIdx) = iDelayWriteOld; - iEngine2Vol = enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C + uiSoundDataOffset / 0x1C].iEngine2Vol; - iEngine2VolCurrent = enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iEngine2Vol; + // LOBYTE(iEngine2StepIdx) = iDelayWriteOld; + iEngine2Vol = + enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C + + uiSoundDataOffset / 0x1C] + .iEngine2Vol; + iEngine2VolCurrent = + enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iEngine2Vol; iEngine2LoopStep = 1; uiEngine2CalcOffset = uiSoundDataOffset; iEngine2VolBase = iEngine2Vol; @@ -1416,14 +1519,26 @@ void DoReplayData() do { iEngine2StepIdx = ((uint8)iEngine2StepIdx + 1) & 0x1F; iConversionBuffer = 28 * iEngine2StepIdx; - *(int *)((char *)&enginedelay[0].engineSoundData[iEngine2StepIdx].iEngine2Vol + uiEngine2CalcOffset) = (iEngine2VolCurrent - iEngine2VolDelta) - / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iEngine2StepIdx] + .iEngine2Vol + + uiEngine2CalcOffset) = + (iEngine2VolCurrent - iEngine2VolDelta) / + iInterpolationSteps; iEngine2VolCurrent += iEngine2VolIncrement; iEngine2VolDelta += iEngine2VolBase; ++iEngine2LoopStep; } while (iFrameDifference >= iEngine2LoopStep); - iEngine2PitchOld = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C].iEngine2Pitch + uiEngine2CalcOffset); - iEngine2PitchNew = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayNewByteOffset / 0x1C].iEngine2Pitch + uiEngine2CalcOffset); + iEngine2PitchOld = *( + int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C] + .iEngine2Pitch + + uiEngine2CalcOffset); + iEngine2PitchNew = *( + int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayNewByteOffset / 0x1C] + .iEngine2Pitch + + uiEngine2CalcOffset); iEngine2PitchStep = 1; iEngine2PitchDelayIdx = iDelayWriteOld; uiEngine2PitchOffset = uiSoundDataOffset; @@ -1432,10 +1547,15 @@ void DoReplayData() iEngine2PitchWorking = iEngine2PitchNew; iEngine2PitchDelta = iEngine2PitchOld * -iFrameDifference; do { - iEngine2PitchDelayIdx = ((uint8)iEngine2PitchDelayIdx + 1) & 0x1F; + iEngine2PitchDelayIdx = + ((uint8)iEngine2PitchDelayIdx + 1) & 0x1F; iConversionBuffer = 28 * iEngine2PitchDelayIdx; - *(int *)((char *)&enginedelay[0].engineSoundData[iEngine2PitchDelayIdx].iEngine2Pitch + uiEngine2PitchOffset) = (iEngine2PitchWorking - iEngine2PitchDelta) - / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iEngine2PitchDelayIdx] + .iEngine2Pitch + + uiEngine2PitchOffset) = + (iEngine2PitchWorking - iEngine2PitchDelta) / + iInterpolationSteps; ++iEngine2PitchStep; iEngine2PitchWorking += iEngine2PitchIncrement; iEngine2PitchDelta += iEngine2PitchBase; @@ -1443,20 +1563,35 @@ void DoReplayData() } // Begin skid sound interpolation (tire screech effects) - if (enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iSkid1Vol == -1 - || enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C + uiSoundDataOffset / 0x1C].iSkid1Vol == -1) { + if (enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iSkid1Vol == -1 || + enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C + + uiSoundDataOffset / 0x1C] + .iSkid1Vol == -1) { iSkidDelaySlot = iNextDelayIndex; if (iDelayWriteNew != iNextDelayIndex) { uiSkidSoundOffset = uiSoundDataOffset; do { - *(int *)((char *)&enginedelay[0].engineSoundData[iSkidDelaySlot].iSkid1Vol + uiSkidSoundOffset) = -1; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iSkidDelaySlot] + .iSkid1Vol + + uiSkidSoundOffset) = -1; iSkidDelaySlot = ((uint8)iSkidDelaySlot + 1) & 0x1F; } while (iSkidDelaySlot != iDelayWriteNew); } } else { iSkidVolDelayIdx = iDelayWriteOld; - iSkid1Vol = enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C + uiSoundDataOffset / 0x1C].iSkid1Vol; - iSkidVolCurrent = enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iSkid1Vol; + iSkid1Vol = + enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C + + uiSoundDataOffset / 0x1C] + .iSkid1Vol; + iSkidVolCurrent = + enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iSkid1Vol; iSkidStepCount = 1; uiSkidCalcOffset = uiSoundDataOffset; iSkidVolBase = iSkid1Vol; @@ -1465,14 +1600,26 @@ void DoReplayData() do { iSkidVolDelayIdx = ((uint8)iSkidVolDelayIdx + 1) & 0x1F; iConversionBuffer = 28 * iSkidVolDelayIdx; - *(int *)((char *)&enginedelay[0].engineSoundData[iSkidVolDelayIdx].iSkid1Vol + uiSkidCalcOffset) = (iSkidVolCurrent - iSkidVolDelta) - / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iSkidVolDelayIdx] + .iSkid1Vol + + uiSkidCalcOffset) = + (iSkidVolCurrent - iSkidVolDelta) / + iInterpolationSteps; iSkidVolCurrent += iSkidVolIncrement; iSkidVolDelta += iSkidVolBase; ++iSkidStepCount; } while (iFrameDifference >= iSkidStepCount); - iSkidPitchOld = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C].iSkid1Pitch + uiSkidCalcOffset); - iSkidPitchNew = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayNewByteOffset / 0x1C].iSkid1Pitch + uiSkidCalcOffset); + iSkidPitchOld = *( + int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C] + .iSkid1Pitch + + uiSkidCalcOffset); + iSkidPitchNew = *( + int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayNewByteOffset / 0x1C] + .iSkid1Pitch + + uiSkidCalcOffset); iSkidPitchStep = 1; iSkidPitchDelayIdx = iDelayWriteOld; uiSkidPitchOffset = uiSoundDataOffset; @@ -1481,19 +1628,28 @@ void DoReplayData() iSkidPitchWorking = iSkidPitchNew; iSkidPitchDelta = iSkidPitchOld * -iFrameDifference; do { - iSkidPitchDelayIdx = ((uint8)iSkidPitchDelayIdx + 1) & 0x1F; + iSkidPitchDelayIdx = + ((uint8)iSkidPitchDelayIdx + 1) & 0x1F; iConversionBuffer = 28 * iSkidPitchDelayIdx; - *(int *)((char *)&enginedelay[0].engineSoundData[iSkidPitchDelayIdx].iSkid1Pitch + uiSkidPitchOffset) = (iSkidPitchWorking - iSkidPitchDelta) - / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iSkidPitchDelayIdx] + .iSkid1Pitch + + uiSkidPitchOffset) = + (iSkidPitchWorking - iSkidPitchDelta) / + iInterpolationSteps; ++iSkidPitchStep; iSkidPitchWorking += iSkidPitchIncrement; iSkidPitchDelta += iSkidPitchBase; } while (iSkidPitchStep <= iFrameDifference); } iPanStepIdx = iDelayWriteOld; - //LOBYTE(iPanStepIdx) = iDelayWriteOld; - iPan = enginedelay[0].engineSoundData[uiDelayOldOffset / 0x1C].iPan; - iPanIncrement = enginedelay[0].engineSoundData[uiSoundOffsetCopy / 0x1C].iPan; + // LOBYTE(iPanStepIdx) = iDelayWriteOld; + iPan = enginedelay[0] + .engineSoundData[uiDelayOldOffset / 0x1C] + .iPan; + iPanIncrement = enginedelay[0] + .engineSoundData[uiSoundOffsetCopy / 0x1C] + .iPan; iPanStep = iPanIncrement; iPanBase = iPan; iPanStepCount = 1; @@ -1502,15 +1658,27 @@ void DoReplayData() do { iPanStepIdx = ((uint8)iPanStepIdx + 1) & 0x1F; iConversionBuffer = 28 * iPanStepIdx; - *(int *)((char *)&enginedelay[0].engineSoundData[iPanStepIdx].iPan + uiPanCalcOffset) = (iPanStep - iPanDelta) / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iPanStepIdx] + .iPan + + uiPanCalcOffset) = + (iPanStep - iPanDelta) / iInterpolationSteps; iPanStep += iPanIncrement; iPanDelta += iPanBase; ++iPanStepCount; } while (iFrameDifference >= iPanStepCount); - iPanOld = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayOldByteOffset / 0x1C].iPan + uiPanCalcOffset); - iPanNew = *(int *)((char *)&enginedelay[0].engineSoundData[uiDelayNewByteOffset / 0x1C].iPan + uiPanCalcOffset); + iPanOld = + *(int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayOldByteOffset / 0x1C] + .iPan + + uiPanCalcOffset); + iPanNew = + *(int *)((char *)&enginedelay[0] + .engineSoundData[uiDelayNewByteOffset / 0x1C] + .iPan + + uiPanCalcOffset); iPanStepCounter = iDelayWriteOld; - //LOBYTE(iPanStepCounter) = iDelayWriteOld; + // LOBYTE(iPanStepCounter) = iDelayWriteOld; iPanLoopStep = 1; uiPanSoundOffset = uiSoundDataOffset; iPanOldCopy = iPanOld; @@ -1519,7 +1687,11 @@ void DoReplayData() do { iPanStepCounter = ((uint8)iPanStepCounter + 1) & 0x1F; iConversionBuffer = 28 * iPanStepCounter; - *(int *)((char *)&enginedelay[0].engineSoundData[iPanStepCounter].iPan + uiPanSoundOffset) = (iPanNew - iPanDeltaStep) / iInterpolationSteps; + *(int *)((char *)&enginedelay[0] + .engineSoundData[iPanStepCounter] + .iPan + + uiPanSoundOffset) = + (iPanNew - iPanDeltaStep) / iInterpolationSteps; iPanNew += iPanNewCopy; iPanDeltaStep += iPanOldCopy; ++iPanLoopStep; @@ -1548,10 +1720,10 @@ void DoReplayData() } while (iCutIndex < cuts); } } - if (iCurrentCut != -1 - && iCurrentCut != lastautocut - && (camera[iCurrentCut].byView != SelectedView[0] || camera[iCurrentCut].byCarIdx != ViewType[0]) - && autoswitch) { + if (iCurrentCut != -1 && iCurrentCut != lastautocut && + (camera[iCurrentCut].byView != SelectedView[0] || + camera[iCurrentCut].byCarIdx != ViewType[0]) && + autoswitch) { SelectedView[0] = camera[iCurrentCut].byView; ViewType[0] = camera[iCurrentCut].byCarIdx; select_view(0); @@ -1570,7 +1742,8 @@ void DoReplayData() pend_view_init = -1; } if (lastreplayframe != -1) - doviewtend(&Car[ViewType[0]], abs(lastreplayframe - currentreplayframe), 0); + doviewtend(&Car[ViewType[0]], + abs(lastreplayframe - currentreplayframe), 0); iUpdateSteps = abs(currentreplayframe - lastreplayframe); if (iUpdateSteps > 16) iUpdateSteps = 16; @@ -1580,7 +1753,8 @@ void DoReplayData() if (numcars > 0) { pSmokeCar = Car; do { - for (iStepCounter = 0; iStepCounter < iUpdateSteps; ++iStepCounter) + for (iStepCounter = 0; iStepCounter < iUpdateSteps; + ++iStepCounter) updatesmokeandflames(pSmokeCar); ++iSmokeCarIndex; ++pSmokeCar; @@ -1617,9 +1791,8 @@ void DoReplayData() } //------------------------------------------------------------------------------------------------- -//00065BF0 -void Rplay() -{ +// 00065BF0 +void Rplay() { if (replaytype == 2) { // Play sound effect sample 83 at 50% volume (0x8000) // Volume 0x8000 = 32768, which is 50 % of full 16-bit volume @@ -1635,20 +1808,20 @@ void Rplay() // copy newrepsample into repsample memcpy(repsample, newrepsample, sizeof(repsample)); - // Initialize sound timing if playing at normal speed (0x100 is 1.0 in 8.8 fixed float) + // Initialize sound timing if playing at normal speed (0x100 is 1.0 in 8.8 + // fixed float) if (replayspeed == 0x100) initsoundlag(currentreplayframe); } } //------------------------------------------------------------------------------------------------- -//00065C70 -void Rreverseplay() -{ +// 00065C70 +void Rreverseplay() { int iCurrSpeed; // eax if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON iCurrSpeed = replayspeeds[replaysetspeed]; replaydirection = -1; lastautocut = -1; @@ -1657,11 +1830,10 @@ void Rreverseplay() } //------------------------------------------------------------------------------------------------- -//00065CC0 -void Rframeplus() -{ +// 00065CC0 +void Rframeplus() { if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON //_disable(); replayspeed = 0; fraction = 0; @@ -1673,11 +1845,10 @@ void Rframeplus() } //------------------------------------------------------------------------------------------------- -//00065D20 -void Rframeminus() -{ +// 00065D20 +void Rframeminus() { if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON //_disable(); replayspeed = 0; fraction = 0; @@ -1689,13 +1860,12 @@ void Rframeminus() } //------------------------------------------------------------------------------------------------- -//00065D70 -void Rspeedplus() -{ +// 00065D70 +void Rspeedplus() { int iNewSpeed; // eax if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON if (++replaysetspeed == 9) replaysetspeed = 8; if (replayspeed) { @@ -1713,13 +1883,12 @@ void Rspeedplus() } //------------------------------------------------------------------------------------------------- -//00065E00 -void Rspeedminus() -{ +// 00065E00 +void Rspeedminus() { int iNewSpeed; // eax if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON if (--replaysetspeed < 0) replaysetspeed = 0; if (replayspeed) { @@ -1737,9 +1906,8 @@ void Rspeedminus() } //------------------------------------------------------------------------------------------------- -//00065E90 -void DoRstop() -{ +// 00065E90 +void DoRstop() { if (replaytype == 2) { //_disable(); replayspeed = 0; @@ -1748,13 +1916,12 @@ void DoRstop() ticks = currentreplayframe; //_enable(); } - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } //------------------------------------------------------------------------------------------------- -//00065ED0 -void Rstop() -{ +// 00065ED0 +void Rstop() { if (replaytype == 2) { //_disable(); replayspeed = 0; @@ -1766,11 +1933,10 @@ void Rstop() } //------------------------------------------------------------------------------------------------- -//00065F00 -void Rrewindstart() -{ +// 00065F00 +void Rrewindstart() { if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON if (replayspeed >= 0) replayspeed = -64; rewinding = -1; @@ -1778,11 +1944,10 @@ void Rrewindstart() } //------------------------------------------------------------------------------------------------- -//00065F40 -void Rforwardstart() -{ +// 00065F40 +void Rforwardstart() { if (replaytype == 2) { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON if (replayspeed <= 0) replayspeed = 64; forwarding = -1; @@ -1790,14 +1955,13 @@ void Rforwardstart() } //------------------------------------------------------------------------------------------------- -//00065F80 -void ROldStatus() -{ +// 00065F80 +void ROldStatus() { if (replaytype == 2) { // Calculate effective replay speed (direction * base speed) replayspeed = replaydirection * replayspeeds[replaysetspeed]; - //cli(); //disable interrupts + // cli(); //disable interrupts rewinding = 0; forwarding = 0; @@ -1805,17 +1969,16 @@ void ROldStatus() ticks = currentreplayframe; fraction = 0; - //if playing at normal speed (0x100 is 1.0 in 8.8 fixed float) + // if playing at normal speed (0x100 is 1.0 in 8.8 fixed float) if (replayspeed == 0x100) - Rplay(); //Initialize replay playback - //sti() //enable interrupts + Rplay(); // Initialize replay playback + // sti() //enable interrupts } } //------------------------------------------------------------------------------------------------- -//00065FE0 -void Rstart() -{ +// 00065FE0 +void Rstart() { if (ticks) { if (replaytype == 2) { //_disable(); @@ -1832,9 +1995,8 @@ void Rstart() } //------------------------------------------------------------------------------------------------- -//00066040 -void Rend() -{ +// 00066040 +void Rend() { if (replayframes - 1 != ticks && replaytype == 2) { //_disable(); replayspeed = 0; @@ -1843,150 +2005,178 @@ void Rend() ticks = replayframes - 1; //_enable(); pend_view_init = ViewType[0]; - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON resetsmoke(); } } //------------------------------------------------------------------------------------------------- -//000660A0 -unsigned int readdisable(int iFrame) -{ +// 000660A0 +unsigned int readdisable(int iFrame) { char byBitPosition; // bl - int iArrayIndex; // eax + int iArrayIndex; // eax byBitPosition = iFrame; if (!replayedit || iFrame > 0x1FFFF) return 0; - iArrayIndex = iFrame / 32; // Calculate array index: divide by 32 to get DWORD index - //iArrayIndex = (iFrame - (__CFSHL__(iFrame >> 31, 5) + 32 * (iFrame >> 31))) >> 5; - return ((unsigned int)disabled[iArrayIndex] >> (byBitPosition - 32 * iArrayIndex)) & 1; + iArrayIndex = + iFrame / 32; // Calculate array index: divide by 32 to get DWORD index + // iArrayIndex = (iFrame - (__CFSHL__(iFrame >> 31, 5) + 32 * (iFrame >> 31))) + // >> 5; + return ((unsigned int)disabled[iArrayIndex] >> + (byBitPosition - 32 * iArrayIndex)) & + 1; } //------------------------------------------------------------------------------------------------- -//000660F0 -void cleardisable(int iFrame) -{ +// 000660F0 +void cleardisable(int iFrame) { char byBitPosition; // bl - int iArrayIndex; // eax + int iArrayIndex; // eax - byBitPosition = iFrame; // Store lower 8 bits of replay index for bit position calculation - if (iFrame < 0x20000) // Check if replay index is within valid range (0-131071) + byBitPosition = + iFrame; // Store lower 8 bits of replay index for bit position calculation + if (iFrame < + 0x20000) // Check if replay index is within valid range (0-131071) { - iArrayIndex = iFrame / 32; // Calculate array index: divide by 32 to get DWORD index - //iArrayIndex = (iFrame - (__CFSHL__(iFrame >> 31, 5) + 32 * (iFrame >> 31))) >> 5;// Calculate array index: divide by 32 to get DWORD index - disabled[iArrayIndex] &= ~(1 << (byBitPosition - 32 * iArrayIndex));// Clear the specific bit using AND with inverted bit mask + iArrayIndex = + iFrame / 32; // Calculate array index: divide by 32 to get DWORD index + // iArrayIndex = (iFrame - (__CFSHL__(iFrame >> 31, 5) + 32 * (iFrame >> + // 31))) >> 5;// Calculate array index: divide by 32 to get DWORD index + disabled[iArrayIndex] &= + ~(1 << (byBitPosition - + 32 * iArrayIndex)); // Clear the specific bit using AND with + // inverted bit mask } } //------------------------------------------------------------------------------------------------- -//00066130 -void setdisable(int iFrame) -{ +// 00066130 +void setdisable(int iFrame) { char byBitPosition; // bl - int iArrayIndex; // eax + int iArrayIndex; // eax byBitPosition = iFrame; if (iFrame < 0x20000) { - iArrayIndex = iFrame / 32; // Calculate array index: divide by 32 to get DWORD index - //iArrayIndex = (iFrame - (__CFSHL__(iFrame >> 31, 5) + 32 * (iFrame >> 31))) >> 5; + iArrayIndex = + iFrame / 32; // Calculate array index: divide by 32 to get DWORD index + // iArrayIndex = (iFrame - (__CFSHL__(iFrame >> 31, 5) + 32 * (iFrame >> + // 31))) >> 5; disabled[iArrayIndex] |= 1 << (byBitPosition - 32 * iArrayIndex); } } //------------------------------------------------------------------------------------------------- -//00066170 -void deleteframes(int iStartFrame, int iEndFrame) -{ +// 00066170 +void deleteframes(int iStartFrame, int iEndFrame) { int iEndFrameFixed; // esi - int iTemp; // ebx - int iCurrentFrame; // ebx - int iArrayIndex; // eax + int iTemp; // ebx + int iCurrentFrame; // ebx + int iArrayIndex; // eax iEndFrameFixed = iEndFrame; - if (replaytype == 2) // Check if we're in replay mode (type 2) - { // Ensure start frame <= end frame by swapping if necessary + if (replaytype == 2) // Check if we're in replay mode (type 2) + { // Ensure start frame <= end frame by swapping if necessary if (iEndFrame < iStartFrame) { iTemp = iStartFrame; iStartFrame = iEndFrame; iEndFrameFixed = iTemp; } - for (iCurrentFrame = iStartFrame; iCurrentFrame <= iEndFrameFixed; ++iCurrentFrame)// Loop through all frames in the range to mark as disabled - { // Check frame is within valid range (< 128K frames max) + for (iCurrentFrame = iStartFrame; iCurrentFrame <= iEndFrameFixed; + ++iCurrentFrame) // Loop through all frames in the range to mark as + // disabled + { // Check frame is within valid range (< 128K frames max) if (iCurrentFrame < 0x20000) { - iArrayIndex = iCurrentFrame / 32; // Calculate array index: divide by 32 to get DWORD index - //iArrayIndex = (iCurrentFrame - (__CFSHL__(iCurrentFrame >> 31, 5) + 32 * (iCurrentFrame >> 31))) >> 5;// Calculate array index: iCurrentFrame / 32 - disabled[iArrayIndex] |= 1 << (iCurrentFrame - 32 * iArrayIndex);// Set bit in disabled[] bitfield to mark frame as disabled + iArrayIndex = + iCurrentFrame / + 32; // Calculate array index: divide by 32 to get DWORD index + // iArrayIndex = (iCurrentFrame - (__CFSHL__(iCurrentFrame >> 31, 5) + + // 32 * (iCurrentFrame >> 31))) >> 5;// Calculate array index: + // iCurrentFrame / 32 + disabled[iArrayIndex] |= + 1 << (iCurrentFrame - + 32 * iArrayIndex); // Set bit in disabled[] bitfield to mark + // frame as disabled } } } } //------------------------------------------------------------------------------------------------- -//000661E0 -void undeleteframes(int iStartFrame, int iEndFrame) -{ - int iEndFrameFixed; // ebx - int iTemp; // edx - int iCurrentFrame; // edx +// 000661E0 +void undeleteframes(int iStartFrame, int iEndFrame) { + int iEndFrameFixed; // ebx + int iTemp; // edx + int iCurrentFrame; // edx int iFrameToUndelete; // eax iEndFrameFixed = iEndFrame; - if (replaytype == 2) // Check if we're in replay mode (type 2) - { // Ensure start frame <= end frame by swapping if necessary + if (replaytype == 2) // Check if we're in replay mode (type 2) + { // Ensure start frame <= end frame by swapping if necessary if (iEndFrame < iStartFrame) { iTemp = iStartFrame; iStartFrame = iEndFrameFixed; iEndFrameFixed = iTemp; } - for (iCurrentFrame = iStartFrame; iCurrentFrame <= iEndFrameFixed; ++iCurrentFrame)// Loop through all frames in the range to undelete them + for (iCurrentFrame = iStartFrame; iCurrentFrame <= iEndFrameFixed; + ++iCurrentFrame) // Loop through all frames in the range to undelete + // them { iFrameToUndelete = iCurrentFrame; - cleardisable(iFrameToUndelete); // Clear the disabled bit for this frame + cleardisable(iFrameToUndelete); // Clear the disabled bit for this frame } } } //------------------------------------------------------------------------------------------------- -//00066210 -void findnextvalid() -{ - int iOriginalFrame; // ebx - int iTestFrame; // edx - unsigned int uiDisabledStatus; // eax - int iBackwardFrame; // edx +// 00066210 +void findnextvalid() { + int iOriginalFrame; // ebx + int iTestFrame; // edx + unsigned int uiDisabledStatus; // eax + int iBackwardFrame; // edx unsigned int uiBackwardDisabled; // eax - iOriginalFrame = currentreplayframe; // Store original frame position for potential fallback - for (iTestFrame = currentreplayframe + 1; currentreplayframe + 1 < replayframes; iTestFrame = currentreplayframe + 1)// Search forward for next valid (non-disabled) frame + iOriginalFrame = currentreplayframe; // Store original frame position for + // potential fallback + for (iTestFrame = currentreplayframe + 1; + currentreplayframe + 1 < replayframes; + iTestFrame = currentreplayframe + + 1) // Search forward for next valid (non-disabled) frame { currentreplayframe = iTestFrame; - uiDisabledStatus = readdisable(iTestFrame); // Check if current frame is disabled + uiDisabledStatus = + readdisable(iTestFrame); // Check if current frame is disabled iTestFrame = currentreplayframe; if (!uiDisabledStatus) - break; // If frame is enabled (not disabled), we found our target + break; // If frame is enabled (not disabled), we found our target } - if (iTestFrame == replayframes) // If reached end without finding valid frame, search backward + if (iTestFrame == replayframes) // If reached end without finding valid frame, + // search backward { iBackwardFrame = iOriginalFrame - 1; - if (iOriginalFrame - 1 >= 0) // Search backward from original position for valid frame + if (iOriginalFrame - 1 >= + 0) // Search backward from original position for valid frame { do { currentreplayframe = iBackwardFrame; - uiBackwardDisabled = readdisable(iBackwardFrame);// Check if backward frame is disabled + uiBackwardDisabled = + readdisable(iBackwardFrame); // Check if backward frame is disabled iBackwardFrame = currentreplayframe; if (!uiBackwardDisabled) break; iBackwardFrame = currentreplayframe - 1; } while (currentreplayframe - 1 >= 0); } - if (iBackwardFrame < 0) // If no valid frame found, fallback to original position + if (iBackwardFrame < + 0) // If no valid frame found, fallback to original position iBackwardFrame = iOriginalFrame; - if (replaytype == 2) // If in replay mode, stop playback and reset state + if (replaytype == 2) // If in replay mode, stop playback and reset state { - currentreplayframe = iBackwardFrame; // Disable interrupts for atomic update + currentreplayframe = + iBackwardFrame; // Disable interrupts for atomic update //_disable(); - replayspeed = 0; // Stop replay playback + replayspeed = 0; // Stop replay playback fraction = 0; replaydirection = 0; ticks = currentreplayframe; @@ -1995,66 +2185,80 @@ void findnextvalid() } } else { currentreplayframe = iTestFrame; - //_disable(); // Found valid frame forward - update timing atomically + //_disable(); // Found valid frame forward - + // update timing atomically ticks = currentreplayframe; fraction = 0; //_enable(); iBackwardFrame = currentreplayframe; - if (iOriginalFrame != currentreplayframe) // If frame changed, trigger view refresh + if (iOriginalFrame != + currentreplayframe) // If frame changed, trigger view refresh pend_view_init = ViewType[0]; } currentreplayframe = iBackwardFrame; } //------------------------------------------------------------------------------------------------- -//00066300 -void findlastvalid() -{ - int iOriginalFrame; // ebx - int iTestFrame; // edx - unsigned int uiDisabledStatus; // eax - int iForwardFrame; // edx +// 00066300 +void findlastvalid() { + int iOriginalFrame; // ebx + int iTestFrame; // edx + unsigned int uiDisabledStatus; // eax + int iForwardFrame; // edx unsigned int uiForwardDisabled; // eax - iOriginalFrame = currentreplayframe; // Store original frame position for potential fallback - for (iTestFrame = currentreplayframe - 1; currentreplayframe - 1 >= 0; iTestFrame = currentreplayframe - 1)// Search backward for previous valid (non-disabled) frame + iOriginalFrame = currentreplayframe; // Store original frame position for + // potential fallback + for (iTestFrame = currentreplayframe - 1; currentreplayframe - 1 >= 0; + iTestFrame = + currentreplayframe - + 1) // Search backward for previous valid (non-disabled) frame { currentreplayframe = iTestFrame; - uiDisabledStatus = readdisable(iTestFrame); // Check if current frame is disabled + uiDisabledStatus = + readdisable(iTestFrame); // Check if current frame is disabled iTestFrame = currentreplayframe; if (!uiDisabledStatus) - break; // If frame is enabled (not disabled), we found our target + break; // If frame is enabled (not disabled), we found our target } - if (iTestFrame >= 0) // If found valid frame backward, use it + if (iTestFrame >= 0) // If found valid frame backward, use it { currentreplayframe = iTestFrame; - //_disable(); // Found valid frame backward - update timing atomically + //_disable(); // Found valid frame backward + //- update timing atomically ticks = currentreplayframe; fraction = 0; //_enable(); iForwardFrame = currentreplayframe; - if (iOriginalFrame != currentreplayframe) // If frame changed, trigger view refresh + if (iOriginalFrame != + currentreplayframe) // If frame changed, trigger view refresh pend_view_init = ViewType[0]; } else { - iForwardFrame = iOriginalFrame + 1; // No valid frame backward, search forward from original position - if (iOriginalFrame + 1 < replayframes) // Search forward from original position for valid frame + iForwardFrame = + iOriginalFrame + + 1; // No valid frame backward, search forward from original position + if (iOriginalFrame + 1 < + replayframes) // Search forward from original position for valid frame { do { currentreplayframe = iForwardFrame; - uiForwardDisabled = readdisable(iForwardFrame);// Check if forward frame is disabled + uiForwardDisabled = + readdisable(iForwardFrame); // Check if forward frame is disabled iForwardFrame = currentreplayframe; if (!uiForwardDisabled) break; iForwardFrame = currentreplayframe + 1; } while (currentreplayframe + 1 < replayframes); } - if (iForwardFrame == replayframes) // If no valid frame found, fallback to original position + if (iForwardFrame == + replayframes) // If no valid frame found, fallback to original position iForwardFrame = iOriginalFrame; - if (replaytype == 2) // If in replay mode, stop playback and reset state + if (replaytype == 2) // If in replay mode, stop playback and reset state { currentreplayframe = iForwardFrame; - //_disable(); // Disable interrupts for atomic update - replayspeed = 0; // Stop replay playback + //_disable(); // Disable interrupts for + // atomic update + replayspeed = 0; // Stop replay playback fraction = 0; replaydirection = 0; ticks = currentreplayframe; @@ -2066,83 +2270,84 @@ void findlastvalid() } //------------------------------------------------------------------------------------------------- -//000663F0 -void Rassemble() -{ - int iCarIndex; // eax - int iNumCars; // ebp - int iCarCounter; // edx - char *szSourcePtr; // esi - char *szDestPtr; // edi - char byChar1; // al - char byChar2; // al - char *szExtSourcePtr; // esi - char *szExtDestPtr; // edi - char byExtChar1; // al - char byExtChar2; // al - FILE *pOutputFile; // esi - int iErrorCode1; // eax - int iFrame; // ebp - int iValidFrames; // esi - int iCutIndex; // edi - int i; // edx - int iSeekOffset; // edx - int iErrorCode2; // eax - tReplayCamera *pCamera; // eax - FILE *pWriteFile; // ecx - int iErrorCode3; // eax - int iCutsTotal; // edx - tReplayCamera *pNextCamera; // ebx - int iCutCounter; // ecx - int iPaddingCount; // ebp - int j; // edi - int iErrorCode4; // eax - int iErrorCode5; // eax - uint8 *szDataBuffer; // edi - unsigned int uiBytesRead; // eax - uint8 *szCarDataPtr; // ebx - int iCarLoop1; // edx - int iCarIndex1; // ecx - uint8 *szCarDataPtr2; // ebx - int iCarLoop2; // edx - int iCarIndex2; // ecx - char byCarData; // al - uint8 byDirection; // ah - uint8 byProcessedData; // al - int iCarCount; // esi - int iErrorCode6; // eax - int iHasData; // esi +// 000663F0 +void Rassemble() { + int iCarIndex; // eax + int iNumCars; // ebp + int iCarCounter; // edx + char *szSourcePtr; // esi + char *szDestPtr; // edi + char byChar1; // al + char byChar2; // al + char *szExtSourcePtr; // esi + char *szExtDestPtr; // edi + char byExtChar1; // al + char byExtChar2; // al + FILE *pOutputFile; // esi + int iErrorCode1; // eax + int iFrame; // ebp + int iValidFrames; // esi + int iCutIndex; // edi + int i; // edx + int iSeekOffset; // edx + int iErrorCode2; // eax + tReplayCamera *pCamera; // eax + FILE *pWriteFile; // ecx + int iErrorCode3; // eax + int iCutsTotal; // edx + tReplayCamera *pNextCamera; // ebx + int iCutCounter; // ecx + int iPaddingCount; // ebp + int j; // edi + int iErrorCode4; // eax + int iErrorCode5; // eax + uint8 *szDataBuffer; // edi + unsigned int uiBytesRead; // eax + uint8 *szCarDataPtr; // ebx + int iCarLoop1; // edx + int iCarIndex1; // ecx + uint8 *szCarDataPtr2; // ebx + int iCarLoop2; // edx + int iCarIndex2; // ecx + char byCarData; // al + uint8 byDirection; // ah + uint8 byProcessedData; // al + int iCarCount; // esi + int iErrorCode6; // eax + int iHasData; // esi int aiCarDirectionFlags[32]; // [esp+0h] [ebp-134h] - char szFilename[32]; // [esp+80h] [ebp-B4h] BYREF - uint8 carVelocityData[32]; // [esp+A0h] [ebp-94h] - uint8 emptyCameraData[16]; // [esp+C0h] [ebp-74h] BYREF - int iCutsWritten; // [esp+D0h] [ebp-64h] - int iLastError; // [esp+D4h] [ebp-60h] - int iErrorFlag; // [esp+D8h] [ebp-5Ch] - int iTempData; // [esp+DCh] [ebp-58h] - int iFrameBackup; // [esp+E0h] [ebp-54h] - unsigned int uiSize; // [esp+E4h] [ebp-50h] - void *pData; // [esp+E8h] [ebp-4Ch] - tReplayCamera *pCameraPtr; // [esp+ECh] [ebp-48h] - int iOffset; // [esp+F0h] [ebp-44h] - int iPrevValidFrame; // [esp+F4h] [ebp-40h] - int iCutProcessed; // [esp+F8h] [ebp-3Ch] - int iDataWritten; // [esp+FCh] [ebp-38h] - signed int k; // [esp+100h] [ebp-34h] - FILE *fp; // [esp+104h] [ebp-30h] - int iInitFlag; // [esp+108h] [ebp-2Ch] - int iFrameCounter; // [esp+10Ch] [ebp-28h] - signed int iBlockCounter; // [esp+110h] [ebp-24h] - uint8 tempBuffer[32]; // [esp+114h] [ebp-20h] BYREF + char szFilename[32]; // [esp+80h] [ebp-B4h] BYREF + uint8 carVelocityData[32]; // [esp+A0h] [ebp-94h] + uint8 emptyCameraData[16]; // [esp+C0h] [ebp-74h] BYREF + int iCutsWritten; // [esp+D0h] [ebp-64h] + int iLastError; // [esp+D4h] [ebp-60h] + int iErrorFlag; // [esp+D8h] [ebp-5Ch] + int iTempData; // [esp+DCh] [ebp-58h] + int iFrameBackup; // [esp+E0h] [ebp-54h] + unsigned int uiSize; // [esp+E4h] [ebp-50h] + void *pData; // [esp+E8h] [ebp-4Ch] + tReplayCamera *pCameraPtr; // [esp+ECh] [ebp-48h] + int iOffset; // [esp+F0h] [ebp-44h] + int iPrevValidFrame; // [esp+F4h] [ebp-40h] + int iCutProcessed; // [esp+F8h] [ebp-3Ch] + int iDataWritten; // [esp+FCh] [ebp-38h] + signed int k; // [esp+100h] [ebp-34h] + FILE *fp; // [esp+104h] [ebp-30h] + int iInitFlag; // [esp+108h] [ebp-2Ch] + int iFrameCounter; // [esp+10Ch] [ebp-28h] + signed int iBlockCounter; // [esp+110h] [ebp-24h] + uint8 tempBuffer[32]; // [esp+114h] [ebp-20h] BYREF iDataWritten = 0; iErrorFlag = 0; - if (replaytype == 2) // Only process if replay type is 2 (assembly mode) + if (replaytype == 2) // Only process if replay type is 2 (assembly mode) { - memset(emptyCameraData, 0, sizeof(emptyCameraData));// Initialize empty camera data buffer and setup car processing arrays + memset(emptyCameraData, 0, + sizeof(emptyCameraData)); // Initialize empty camera data buffer and + // setup car processing arrays pData = scrbuf; iCarIndex = 0; - if (numcars > 0) // Initialize car data arrays for all cars in replay + if (numcars > 0) // Initialize car data arrays for all cars in replay { iNumCars = numcars; iCarCounter = 0; @@ -2152,14 +2357,17 @@ void Rassemble() aiCarDirectionFlags[iCarCounter + 15] = 1; } while (iCarIndex < iNumCars); } - //_disable(); // Disable interrupts and reset replay state for assembly + //_disable(); // Disable interrupts and + // reset replay state for assembly iInitFlag = -1; replayspeed = 0; replaydirection = 0; fraction = 0; ticks = currentreplayframe; //_enable(); - strcpy(szFilename, "../REPLAYS/"); // Build output filename by concatenating path, selected name, and .GSS extension + strcpy(szFilename, + "../REPLAYS/"); // Build output filename by concatenating path, + // selected name, and .GSS extension szSourcePtr = selectfilename; szDestPtr = &szFilename[strlen(szFilename)]; do { @@ -2184,13 +2392,17 @@ void Rassemble() szExtDestPtr[1] = byExtChar2; szExtDestPtr += 2; } while (byExtChar2); - if (!strcmp(szFilename, replayfilename)) // Check if trying to overwrite current replay file + if (!strcmp( + szFilename, + replayfilename)) // Check if trying to overwrite current replay file { lastfile = 0; screenready = 0; filingmenu = 9; } else { - pOutputFile = ROLLERfopen(szFilename, "wb"); // Open output file and copy replay header from source file + pOutputFile = ROLLERfopen( + szFilename, + "wb"); // Open output file and copy replay header from source file fp = pOutputFile; if (pOutputFile) { fseek(replayfile, 0, 0); @@ -2200,26 +2412,30 @@ void Rassemble() iErrorFlag = -1; iLastError = iErrorCode1; } - iFrame = 0; // Initialize frame processing and camera cut handling + iFrame = 0; // Initialize frame processing and camera cut handling iPrevValidFrame = -1; iValidFrames = 0; uiSize = 64000 / replayblock; iCutsWritten = 0; fseek(fp, 4, 0); iCutProcessed = 0; - if (cuts > 0) // Process each camera cut, counting valid frames and writing camera data + if (cuts > 0) // Process each camera cut, counting valid frames and + // writing camera data { pCameraPtr = camera; iOffset = -4; iCutIndex = 0; - do { // Count valid frames up to current camera cut + do { // Count valid frames up to current camera cut for (i = iFrame; i < camera[iCutIndex].iFrame; ++i) { if (!readdisable(i)) ++iValidFrames; } iFrame = camera[iCutIndex].iFrame; iFrameBackup = iFrame; - if (iPrevValidFrame == -1 || iValidFrames != iPrevValidFrame)// Write camera cut data - either new entry or update existing duplicate frame + if (iPrevValidFrame == -1 || + iValidFrames != + iPrevValidFrame) // Write camera cut data - either new entry + // or update existing duplicate frame { pCamera = pCameraPtr; pWriteFile = fp; @@ -2246,14 +2462,16 @@ void Rassemble() ++iCutIndex; pNextCamera = pCameraPtr + 1; iCutCounter = iCutProcessed + 1; - //TODO ensure this is accurate + // TODO ensure this is accurate camera[iCutIndex - 1].iFrame = iFrameBackup; - //*(int *)((char *)&yp_variable_1 + iCutIndex * 6) = iFrameBackup;// reference into adjacent data camera + //*(int *)((char *)&yp_variable_1 + iCutIndex * 6) = iFrameBackup;// + // reference into adjacent data camera pCameraPtr = pNextCamera; iCutProcessed = iCutCounter; } while (iCutCounter < iCutsTotal); } - iPaddingCount = 100 - iCutsWritten; // Fill remaining camera slots with empty data (max 100 cuts) + iPaddingCount = 100 - iCutsWritten; // Fill remaining camera slots with + // empty data (max 100 cuts) for (j = 0; j < iPaddingCount; ++j) { if (fwrite(emptyCameraData, 1, 6, fp) != 6) { iErrorCode4 = errno; @@ -2261,31 +2479,37 @@ void Rassemble() iLastError = iErrorCode4; } } - tempBuffer[0] = iCutsWritten; // Write total number of camera cuts to file + tempBuffer[0] = + iCutsWritten; // Write total number of camera cuts to file if (fwrite(tempBuffer, 1, 1, fp) != 1) { iErrorCode5 = errno; iErrorFlag = -1; iLastError = iErrorCode5; } - fseek(fp, replayheader, 0); // Main replay data processing - read blocks and filter/process car data + fseek(fp, replayheader, 0); // Main replay data processing - read blocks + // and filter/process car data iFrameCounter = 0; do { szDataBuffer = (uint8 *)pData; uiBytesRead = (uint32)fread(pData, replayblock, uiSize, replayfile); iBlockCounter = 0; - for (k = uiBytesRead; iBlockCounter < k; ++iBlockCounter) { // Skip disabled frames, process valid frames with car data filtering + for (k = uiBytesRead; iBlockCounter < k; + ++iBlockCounter) { // Skip disabled frames, process valid frames + // with car data filtering if (readdisable(iFrameCounter)) { iInitFlag = -1; - } else { // First-time setup of car direction tracking arrays + } else { // First-time setup of car direction tracking arrays if (iInitFlag) { szCarDataPtr = szDataBuffer; iCarLoop1 = 0; if (numcars > 0) { iCarIndex1 = 0; do { - aiCarDirectionFlags[iCarIndex1] = (((int)szCarDataPtr[26] >> 3) & 1) == aiCarDirectionFlags[iCarIndex1 + 16]; + aiCarDirectionFlags[iCarIndex1] = + (((int)szCarDataPtr[26] >> 3) & 1) == + aiCarDirectionFlags[iCarIndex1 + 16]; iTempData = szCarDataPtr[3]; - //iTempData = (uint8)HIBYTE(*(_DWORD *)szCarDataPtr); + // iTempData = (uint8)HIBYTE(*(_DWORD *)szCarDataPtr); tempBuffer[4] = iTempData; if ((char)iTempData * (char)carVelocityData[iCarLoop1] >= 0) carVelocityData[iCarLoop1 + 16] = 1; @@ -2298,15 +2522,19 @@ void Rassemble() } iInitFlag = 0; } - szCarDataPtr2 = szDataBuffer; // Process car data - flip direction bits and apply velocity corrections + szCarDataPtr2 = + szDataBuffer; // Process car data - flip direction bits and + // apply velocity corrections iCarLoop2 = 0; if (numcars > 0) { iCarIndex2 = 0; do { - szCarDataPtr2[26] ^= 8 * (uint8)(aiCarDirectionFlags[iCarIndex2]); - aiCarDirectionFlags[iCarIndex2 + 16] = ((int)szCarDataPtr2[26] >> 3) & 1; + szCarDataPtr2[26] ^= + 8 * (uint8)(aiCarDirectionFlags[iCarIndex2]); + aiCarDirectionFlags[iCarIndex2 + 16] = + ((int)szCarDataPtr2[26] >> 3) & 1; iTempData = szCarDataPtr2[3]; - //iTempData = (uint8)HIBYTE(*(_DWORD *)szCarDataPtr2); + // iTempData = (uint8)HIBYTE(*(_DWORD *)szCarDataPtr2); byCarData = iTempData; byDirection = carVelocityData[iCarLoop2 + 16]; carVelocityData[iCarLoop2] = iTempData; @@ -2315,7 +2543,9 @@ void Rassemble() ++iCarIndex2; carVelocityData[iCarLoop2++] = byProcessedData; iCarCount = numcars; - *(int *)(szCarDataPtr2 - 30) = ((char)byProcessedData << 24) | *(int *)(szCarDataPtr2 - 30) & 0xFFFFFF; + *(int *)(szCarDataPtr2 - 30) = + ((char)byProcessedData << 24) | + *(int *)(szCarDataPtr2 - 30) & 0xFFFFFF; } while (iCarLoop2 < iCarCount); } iDataWritten = -1; @@ -2329,7 +2559,8 @@ void Rassemble() ++iFrameCounter; } } while (k == uiSize && !iErrorFlag); - iHasData = iDataWritten; // Close file and handle errors - delete incomplete file on failure + iHasData = iDataWritten; // Close file and handle errors - delete + // incomplete file on failure fclose(fp); if (!iHasData) { errno = -1000; @@ -2343,7 +2574,7 @@ void Rassemble() screenready = 0; } } - if (iErrorFlag) // Set appropriate error dialog based on failure type + if (iErrorFlag) // Set appropriate error dialog based on failure type { if (iLastError == 12) { filingmenu = 6; @@ -2356,136 +2587,152 @@ void Rassemble() } //------------------------------------------------------------------------------------------------- -//00066AF0 -void storecut() -{ - int iNumCuts; // esi +// 00066AF0 +void storecut() { + int iNumCuts; // esi int iTargetFrame; // edi int iInsertIndex; // ecx - int iCutCounter; // eax + int iCutCounter; // eax int iCameraIndex; // edx - int iStoreIndex; // eax + int iStoreIndex; // eax - iNumCuts = cuts; // Initialize working variables + iNumCuts = cuts; // Initialize working variables iTargetFrame = currentreplayframe; - if (replaytype == 2 && cuts < 100) // Only allow cut creation in edit mode and under limit (100 cuts max) + if (replaytype == 2 && cuts < 100) // Only allow cut creation in edit mode and + // under limit (100 cuts max) { - iInsertIndex = -1; // Initialize insertion index to -1 (no position found yet) - if (cuts) // Search for correct insertion position if cuts exist + iInsertIndex = + -1; // Initialize insertion index to -1 (no position found yet) + if (cuts) // Search for correct insertion position if cuts exist { iCutCounter = 0; if (cuts > 0) { - iCameraIndex = 0; // Find the last cut that occurs before or at current frame - do { // Check if this cut frame is <= current frame + iCameraIndex = + 0; // Find the last cut that occurs before or at current frame + do { // Check if this cut frame is <= current frame if (camera[iCameraIndex].iFrame <= currentreplayframe) iInsertIndex = iCutCounter; ++iCutCounter; ++iCameraIndex; } while (iCutCounter < cuts); } - if (camera[iInsertIndex].iFrame != currentreplayframe || iInsertIndex == -1)// Check if cut already exists at this frame - { // Calculate insertion position (after last matching cut) + if (camera[iInsertIndex].iFrame != currentreplayframe || + iInsertIndex == -1) // Check if cut already exists at this frame + { // Calculate insertion position (after last matching cut) if (++iInsertIndex != cuts) { - memmove(&camera[iInsertIndex + 1], &camera[iInsertIndex], 6 * (cuts - iInsertIndex));// Shift existing cuts up to make room for new cut + memmove(&camera[iInsertIndex + 1], &camera[iInsertIndex], + 6 * (cuts - iInsertIndex)); // Shift existing cuts up to make + // room for new cut iNumCuts = cuts; } - iTargetFrame = currentreplayframe; // Increment cut count for new cut + iTargetFrame = currentreplayframe; // Increment cut count for new cut ++iNumCuts; } } else { - iNumCuts = 1; // First cut - set count to 1 and insert at position 0 + iNumCuts = 1; // First cut - set count to 1 and insert at position 0 iInsertIndex = 0; } - iStoreIndex = iInsertIndex; // Store cut data at calculated index - camera[iStoreIndex].byView = SelectedView[0];// Store current view settings - camera[iStoreIndex].iFrame = iTargetFrame; // Store current frame number - camera[iStoreIndex].byCarIdx = (uint8)ViewType[0]; // Store current car index for view + iStoreIndex = iInsertIndex; // Store cut data at calculated index + camera[iStoreIndex].byView = SelectedView[0]; // Store current view settings + camera[iStoreIndex].iFrame = iTargetFrame; // Store current frame number + camera[iStoreIndex].byCarIdx = + (uint8)ViewType[0]; // Store current car index for view } - currentreplayframe = iTargetFrame; // Update global state + currentreplayframe = iTargetFrame; // Update global state cuts = iNumCuts; } //------------------------------------------------------------------------------------------------- -//00066BE0 -void removecut() -{ - int iNumCuts; // esi - int iCutIndex; // ecx +// 00066BE0 +void removecut() { + int iNumCuts; // esi + int iCutIndex; // ecx int iCameraIndex; // edi - iNumCuts = cuts; // Get current number of cuts - if (replaytype == 2) // Only allow cut removal in edit mode (replaytype == 2) + iNumCuts = cuts; // Get current number of cuts + if (replaytype == 2) // Only allow cut removal in edit mode (replaytype == 2) { iCutIndex = 0; - if (cuts > 0) // Search through existing cuts to find match + if (cuts > 0) // Search through existing cuts to find match { iCameraIndex = 0; - do { // Check if current replay frame matches this cut frame - if (currentreplayframe == camera[iCameraIndex].iFrame) { // If not the last cut, shift remaining cuts down to fill gap + do { // Check if current replay frame matches this cut frame + if (currentreplayframe == + camera[iCameraIndex].iFrame) { // If not the last cut, shift + // remaining cuts down to fill gap if (iCutIndex != iNumCuts - 1) { cuts = iNumCuts; - memmove(&camera[iCameraIndex], &camera[iCameraIndex + 1], 6 * (iNumCuts - iCutIndex - 1));// Move remaining cuts down by 6 bytes each (camera struct size) + memmove(&camera[iCameraIndex], &camera[iCameraIndex + 1], + 6 * (iNumCuts - iCutIndex - + 1)); // Move remaining cuts down by 6 bytes each + // (camera struct size) iNumCuts = cuts; } - --iNumCuts; // Decrement total cut count + --iNumCuts; // Decrement total cut count } ++iCutIndex; ++iCameraIndex; } while (iCutIndex < iNumCuts); } } - cuts = iNumCuts; // Update global cuts count + cuts = iNumCuts; // Update global cuts count } //------------------------------------------------------------------------------------------------- -//00066C50 -int readcut() -{ +// 00066C50 +int readcut() { int iLastValidCut; // ecx - int iCutIndex; // eax - int iArrayIndex; // edx + int iCutIndex; // eax + int iArrayIndex; // edx - iLastValidCut = -1; // Initialize to -1 (no valid cut found) - if (cuts) // Check if any camera cuts exist + iLastValidCut = -1; // Initialize to -1 (no valid cut found) + if (cuts) // Check if any camera cuts exist { iCutIndex = 0; - if (cuts > 0) // Iterate through all camera cuts to find the active one + if (cuts > 0) // Iterate through all camera cuts to find the active one { iArrayIndex = 0; - do { // Check if this cut's frame is at or before current replay frame + do { // Check if this cut's frame is at or before current replay frame if (camera[iArrayIndex].iFrame <= currentreplayframe) - iLastValidCut = iCutIndex; // Update to this cut index (keeps the latest valid cut) + iLastValidCut = iCutIndex; // Update to this cut index (keeps the + // latest valid cut) ++iCutIndex; ++iArrayIndex; } while (iCutIndex < cuts); } } - return iLastValidCut; // Return index of most recent valid cut, or -1 if none found + return iLastValidCut; // Return index of most recent valid cut, or -1 if none + // found } //------------------------------------------------------------------------------------------------- -//00066CC0 -void displayreplay() -{ // Apply scanline effect for disabled replay frames (type 2) +// 00066CC0 +void displayreplay() { // Apply scanline effect for disabled replay frames (type + // 2) uint8 *pScreenBuffer; // edi - int iWindowWidth; // esi - int iHeightLoop; // ecx - int iWidthLoop; // eax - uint8 *pPixelPtr; // edx - int iRowIndex; // ecx - uint8 *pRowPtr; // eax + int iWindowWidth; // esi + int iHeightLoop; // ecx + int iWidthLoop; // eax + uint8 *pPixelPtr; // edx + int iRowIndex; // ecx + uint8 *pRowPtr; // eax if (replaytype == 2 && readdisable(currentreplayframe)) { - pScreenBuffer = scrbuf; // Get screen buffer and window dimensions for scanline processing + pScreenBuffer = scrbuf; // Get screen buffer and window dimensions for + // scanline processing iWindowWidth = winw; - for (iHeightLoop = 0; iHeightLoop < winh; iHeightLoop += 2)// First pass: Set every other pixel to black on even rows (scanlines) + for (iHeightLoop = 0; iHeightLoop < winh; + iHeightLoop += 2) // First pass: Set every other pixel to black on even + // rows (scanlines) { - for (iWidthLoop = 0; iWidthLoop < iWindowWidth; pPixelPtr[iWindowWidth * iHeightLoop] = 0) { + for (iWidthLoop = 0; iWidthLoop < iWindowWidth; + pPixelPtr[iWindowWidth * iHeightLoop] = 0) { pPixelPtr = &pScreenBuffer[iWidthLoop]; iWidthLoop += 2; } } - iRowIndex = 1; // Second pass: Clear entire odd rows to create horizontal scanline effect + iRowIndex = 1; // Second pass: Clear entire odd rows to create horizontal + // scanline effect winw = iWindowWidth; scrbuf = pScreenBuffer; while (iRowIndex < winh) { @@ -2494,64 +2741,69 @@ void displayreplay() memset(pRowPtr, 0, winw); } } - if (filingmenu) // Handle file menu dialogs for replay management + if (filingmenu) // Handle file menu dialogs for replay management { switch (filingmenu) { - case 1: - fileselect(10, 10, 310, 125, 160, 20, &language_buffer[3136], "../REPLAYS/*.GSS", 1);// Load replay dialog - break; - case 2: - fileselect(10, 10, 310, 140, 160, 20, &language_buffer[3200], "../REPLAYS/*.GSS", 2);// Save replay dialog - break; - case 3: - fileselect(10, 10, 310, 125, 160, 20, &language_buffer[3264], "../REPLAYS/*.GSS", 3);// Delete replay dialog - break; - case 4: - fileselect(10, 10, 310, 140, 160, 20, &language_buffer[3392], "../REPLAYS/*.GSS", 4);// Assemble replay dialog - break; - case 5: - lsd(40, 37, 280, 107); // Show LSD (replay statistics) dialog - break; - case 6: - warning(122, 55, 198, 85, &language_buffer[3456]);// Show warning dialogs for various replay operations - break; - case 7: - warning(112, 55, 208, 85, &language_buffer[3520]); - break; - case 8: - warning(82, 55, 238, 85, &language_buffer[3584]); - break; - case 9: - warning(40, 55, 280, 85, &language_buffer[3648]); - break; - default: - break; + case 1: + fileselect(10, 10, 310, 125, 160, 20, &language_buffer[3136], + "../REPLAYS/*.GSS", 1); // Load replay dialog + break; + case 2: + fileselect(10, 10, 310, 140, 160, 20, &language_buffer[3200], + "../REPLAYS/*.GSS", 2); // Save replay dialog + break; + case 3: + fileselect(10, 10, 310, 125, 160, 20, &language_buffer[3264], + "../REPLAYS/*.GSS", 3); // Delete replay dialog + break; + case 4: + fileselect(10, 10, 310, 140, 160, 20, &language_buffer[3392], + "../REPLAYS/*.GSS", 4); // Assemble replay dialog + break; + case 5: + lsd(40, 37, 280, 107); // Show LSD (replay statistics) dialog + break; + case 6: + warning(122, 55, 198, 85, + &language_buffer[3456]); // Show warning dialogs for various + // replay operations + break; + case 7: + warning(112, 55, 208, 85, &language_buffer[3520]); + break; + case 8: + warning(82, 55, 238, 85, &language_buffer[3584]); + break; + case 9: + warning(40, 55, 280, 85, &language_buffer[3648]); + break; + default: + break; } } - if (replaypanel) // Validate replay panel display based on screen mode and size + if (replaypanel) // Validate replay panel display based on screen mode and + // size { if ((!SVGA_ON || scr_size != 128) && (SVGA_ON || scr_size != 64)) { replaypanel = 0; controlicon = 9; } } - if (replaypanel) // Display control panel if replay panel is active + if (replaypanel) // Display control panel if replay panel is active displaycontrolpanel(); } //------------------------------------------------------------------------------------------------- -//00066F60 -int compare(const void *szStr1, const void *szStr2) -{ +// 00066F60 +int compare(const void *szStr1, const void *szStr2) { return strcmp((const char *)szStr1, (const char *)szStr2); } //------------------------------------------------------------------------------------------------- -//00066F70 -void warning(int iX1, int iY1, int iX2, int iY2, char *szWarning) -{ - int iX1Scaled; // esi - int iY1_1; // edi +// 00066F70 +void warning(int iX1, int iY1, int iX2, int iY2, char *szWarning) { + int iX1Scaled; // esi + int iY1_1; // edi tPolyParams poly; // [esp+0h] [ebp-38h] BYREF iX1Scaled = iX1; @@ -2570,7 +2822,7 @@ void warning(int iX1, int iY1, int iX2, int iY2, char *szWarning) poly.vertices[2].y = iY2; poly.vertices[3].x = iX2; poly.vertices[3].y = iY2; - poly.iSurfaceType = SURFACE_FLAG_TRANSPARENT | 0x3;// 0x200003; + poly.iSurfaceType = SURFACE_FLAG_TRANSPARENT | 0x3; // 0x200003; poly.uiNumVerts = 4; game_render_quad_screen(g_pGameRenderer, &poly, TEXTURE_HANDLE_INVALID, NULL); prt_centrecol(rev_vga[1], szWarning, (iX1Scaled + iX2) / 2, iY1_1 + 10, 231); @@ -2583,30 +2835,29 @@ void warning(int iX1, int iY1, int iX2, int iY2, char *szWarning) } //------------------------------------------------------------------------------------------------- -//00067020 -void lsd(int iX1, int iY1, int iX2, int iY2) -{ - int iOriginalY1; // esi - uint8 byKey; // al +// 00067020 +void lsd(int iX1, int iY1, int iX2, int iY2) { + int iOriginalY1; // esi + uint8 byKey; // al uint8 byExtendedKey; // al - int iMenuOption; // ebp - char *pDestBuffer; // edi - char *pSourceText; // esi - char byChar1; // al - char byChar2; // al - char byTextColor; // [esp-4h] [ebp-40h] - tPolyParams poly; // [esp+0h] [ebp-3Ch] BYREF - int iTextY; // [esp+2Ch] [ebp-10h] - - iOriginalY1 = iY1; // Save original Y1 coordinate before SVGA scaling - if (SVGA_ON) // Scale coordinates by 2x for SVGA mode + int iMenuOption; // ebp + char *pDestBuffer; // edi + char *pSourceText; // esi + char byChar1; // al + char byChar2; // al + char byTextColor; // [esp-4h] [ebp-40h] + tPolyParams poly; // [esp+0h] [ebp-3Ch] BYREF + int iTextY; // [esp+2Ch] [ebp-10h] + + iOriginalY1 = iY1; // Save original Y1 coordinate before SVGA scaling + if (SVGA_ON) // Scale coordinates by 2x for SVGA mode { iX2 *= 2; iY1 *= 2; iX1 *= 2; iY2 *= 2; } - poly.vertices[0].x = iX2; // Set up polygon vertices for background rectangle + poly.vertices[0].x = iX2; // Set up polygon vertices for background rectangle poly.vertices[0].y = iY1; poly.vertices[1].x = iX1; poly.vertices[1].y = iY1; @@ -2614,43 +2865,46 @@ void lsd(int iX1, int iY1, int iX2, int iY2) poly.vertices[2].y = iY2; poly.vertices[3].x = iX2; poly.vertices[3].y = iY2; - poly.iSurfaceType = 0x200003; // = SURFACE_FLAG_TRANSPARENT | 0x3; + poly.iSurfaceType = 0x200003; // = SURFACE_FLAG_TRANSPARENT | 0x3; poly.uiNumVerts = 4; game_render_quad_screen(g_pGameRenderer, &poly, TEXTURE_HANDLE_INVALID, NULL); - prt_centrecol(rev_vga[1], &language_buffer[3072], 160, iOriginalY1 + 10, 231);// Display menu title text centered - while (fatkbhit()) // Main input loop - process keyboard input + prt_centrecol(rev_vga[1], &language_buffer[3072], 160, iOriginalY1 + 10, + 231); // Display menu title text centered + while (fatkbhit()) // Main input loop - process keyboard input { - byKey = fatgetch(); // Get key press - if (byKey) // Check if regular ASCII key or extended key (0 = extended) - { // Check for ENTER key (0x0D) + byKey = fatgetch(); // Get key press + if (byKey) // Check if regular ASCII key or extended key (0 = extended) + { // Check for ENTER key (0x0D) if (byKey >= 0xDu) { if (byKey <= 0xDu) { - sfxsample(83, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(83, 0x8000); // SOUND_SAMPLE_BUTTON filingmenu = lsdsel + 1; - } else if (byKey == 0x1B) // Check for ESCAPE key (0x1B) + } else if (byKey == 0x1B) // Check for ESCAPE key (0x1B) { - filingmenu = 0; // ESCAPE: cancel menu and reset state + filingmenu = 0; // ESCAPE: cancel menu and reset state disciconpressed = 0; rotpoint = currentreplayframe; } } } else { - byExtendedKey = fatgetch(); // Extended key: get second byte of scancode - if (byExtendedKey >= 0x48u) // Check for UP arrow key (0x48) + byExtendedKey = fatgetch(); // Extended key: get second byte of scancode + if (byExtendedKey >= 0x48u) // Check for UP arrow key (0x48) { - if (byExtendedKey <= 0x48u) { // UP arrow: move selection up if not at top + if (byExtendedKey <= + 0x48u) { // UP arrow: move selection up if not at top if (lsdsel) --lsdsel; - } else if (byExtendedKey == 0x50 && lsdsel < 2)// Check for DOWN arrow key (0x50) + } else if (byExtendedKey == 0x50 && + lsdsel < 2) // Check for DOWN arrow key (0x50) { - ++lsdsel; // DOWN arrow: move selection down if not at bottom + ++lsdsel; // DOWN arrow: move selection down if not at bottom } } } } - iMenuOption = 0; // Begin menu text rendering loop - iTextY = iOriginalY1 + 30; // Calculate starting Y position for menu text - do { // Select appropriate menu text based on option index + iMenuOption = 0; // Begin menu text rendering loop + iTextY = iOriginalY1 + 30; // Calculate starting Y position for menu text + do { // Select appropriate menu text based on option index if (iMenuOption) { if ((unsigned int)iMenuOption <= 1) { pDestBuffer = buffer; @@ -2666,7 +2920,8 @@ void lsd(int iX1, int iY1, int iX2, int iY2) pSourceText = &language_buffer[3136]; } do { - byChar1 = *pSourceText; // String copy loop: copy 2 bytes at a time until null terminator + byChar1 = *pSourceText; // String copy loop: copy 2 bytes at a time until + // null terminator *pDestBuffer = *pSourceText; if (!byChar1) break; @@ -2676,20 +2931,21 @@ void lsd(int iX1, int iY1, int iX2, int iY2) pDestBuffer += 2; } while (byChar2); RENDER_MENU_OPTION: - if (iMenuOption == lsdsel) // Set text color based on selection: highlighted vs normal - byTextColor = 0x8F; // Selected item color (0x8F = white) + if (iMenuOption == + lsdsel) // Set text color based on selection: highlighted vs normal + byTextColor = 0x8F; // Selected item color (0x8F = white) else - byTextColor = 0x83; // Normal item color (0x83 = grey) - prt_centrecol(rev_vga[1], buffer, 160, iTextY, byTextColor);// Draw menu option text centered - ++iMenuOption; // Advance to next menu option and Y position + byTextColor = 0x83; // Normal item color (0x83 = grey) + prt_centrecol(rev_vga[1], buffer, 160, iTextY, + byTextColor); // Draw menu option text centered + ++iMenuOption; // Advance to next menu option and Y position iTextY += 10; - } while (iMenuOption < 3); // Continue until all 3 menu options are drawn + } while (iMenuOption < 3); // Continue until all 3 menu options are drawn } //------------------------------------------------------------------------------------------------- -//000671D0 -void scandirectory(const char *szPattern) -{ +// 000671D0 +void scandirectory(const char *szPattern) { int iFileCount = 0; #ifdef IS_WINDOWS @@ -2718,14 +2974,16 @@ void scandirectory(const char *szPattern) _findclose(handle); #else - // For Unix-like systems, we need to extract directory and pattern from szPattern + // For Unix-like systems, we need to extract directory and pattern from + // szPattern char szDirectory[256]; char szFilePattern[256]; // Find the last directory separator const char *szLastSlash = strrchr(szPattern, '/'); const char *szLastBackslash = strrchr(szPattern, '\\'); - const char *szSeparator = (szLastSlash > szLastBackslash) ? szLastSlash : szLastBackslash; + const char *szSeparator = + (szLastSlash > szLastBackslash) ? szLastSlash : szLastBackslash; if (szSeparator) { // Extract directory path @@ -2775,68 +3033,72 @@ void scandirectory(const char *szPattern) } //------------------------------------------------------------------------------------------------- -//000672C0 -void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int iTextY, const char *szText, const char *szPattern, int iFileIdx) -{ - int iCurrentFile; // ebp - char *szDestPtr; // edi - char *szSourcePtr; // esi - char byChar1; // al - char byChar2; // al - char byKeyCode; // al - char byProcessedKey; // dl - int iLeftNavFile; // ebp - char *szLeftDestPtr; // edi - char *szLeftSourcePtr; // esi - char byLeftChar1; // al - char byLeftChar2; // al - int iRightNavFile; // ebp - char *szRightDestPtr; // edi - char *szRightSourcePtr; // esi - char byRightChar1; // al - char byRightChar2; // al - int iUpNavFile; // ebp - char *szUpDestPtr; // edi - char *szUpSourcePtr; // esi - char byUpChar1; // al - char byUpChar2; // al - int iDownNavFile; // ebp - char *szDownDestPtr; // edi - char *szDownSourcePtr; // esi - char byDownChar1; // al - char byDownChar2; // al - unsigned int uiDelStrLen; // kr08_4 +// 000672C0 +void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, + int iTextY, const char *szText, const char *szPattern, + int iFileIdx) { + int iCurrentFile; // ebp + char *szDestPtr; // edi + char *szSourcePtr; // esi + char byChar1; // al + char byChar2; // al + char byKeyCode; // al + char byProcessedKey; // dl + int iLeftNavFile; // ebp + char *szLeftDestPtr; // edi + char *szLeftSourcePtr; // esi + char byLeftChar1; // al + char byLeftChar2; // al + int iRightNavFile; // ebp + char *szRightDestPtr; // edi + char *szRightSourcePtr; // esi + char byRightChar1; // al + char byRightChar2; // al + int iUpNavFile; // ebp + char *szUpDestPtr; // edi + char *szUpSourcePtr; // esi + char byUpChar1; // al + char byUpChar2; // al + int iDownNavFile; // ebp + char *szDownDestPtr; // edi + char *szDownSourcePtr; // esi + char byDownChar1; // al + char byDownChar2; // al + unsigned int uiDelStrLen; // kr08_4 unsigned int uiBackspaceLen; // kr0C_4 - int iInputStrLen; // ecx - int iDisplayFile; // ebp - int iLoopCounter; // edi - int iDisplayX; // ebx - int iDisplayY; // ecx - const char *szDisplayName; // edx - unsigned int uiCursorLen; // kr14_4 - unsigned int uiCursorPos; // ebx - int iScreenWidth; // esi - int iUpArrowX; // ecx - int iDownArrowX; // ecx - tPolyParams params; // [esp+0h] [ebp-48h] BYREF - int iRightEdge; // [esp+2Ch] [ebp-1Ch] - int iEditMode; // [esp+30h] [ebp-18h] - int iLeftEdge; // [esp+34h] [ebp-14h] - int iBottomEdge; // [esp+38h] [ebp-10h] - - iLeftEdge = iBoxX0; // Store left edge coordinate in local variable - if (filingmenu == 2 || filingmenu == 4) // Check if in save mode (2) or assemble mode (4) to enable text editing + int iInputStrLen; // ecx + int iDisplayFile; // ebp + int iLoopCounter; // edi + int iDisplayX; // ebx + int iDisplayY; // ecx + const char *szDisplayName; // edx + unsigned int uiCursorLen; // kr14_4 + unsigned int uiCursorPos; // ebx + int iScreenWidth; // esi + int iUpArrowX; // ecx + int iDownArrowX; // ecx + tPolyParams params; // [esp+0h] [ebp-48h] BYREF + int iRightEdge; // [esp+2Ch] [ebp-1Ch] + int iEditMode; // [esp+30h] [ebp-18h] + int iLeftEdge; // [esp+34h] [ebp-14h] + int iBottomEdge; // [esp+38h] [ebp-10h] + + iLeftEdge = iBoxX0; // Store left edge coordinate in local variable + if (filingmenu == 2 || + filingmenu == 4) // Check if in save mode (2) or assemble mode (4) to + // enable text editing iEditMode = -1; else iEditMode = 0; - if (SVGA_ON) // Scale coordinates by 2 if SVGA mode is enabled + if (SVGA_ON) // Scale coordinates by 2 if SVGA mode is enabled { iBoxX1 *= 2; iBoxY0 *= 2; iBoxY1 *= 2; iLeftEdge *= 2; } - params.vertices[0].x = iBoxX1; // Set up polygon vertices for file selection background rectangle + params.vertices[0].x = + iBoxX1; // Set up polygon vertices for file selection background rectangle params.vertices[0].y = iBoxY0; params.vertices[1].y = iBoxY0; params.vertices[2].y = iBoxY1; @@ -2846,9 +3108,11 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int params.uiNumVerts = 4; params.vertices[1].x = iLeftEdge; params.vertices[2].x = iLeftEdge; - game_render_quad_screen(g_pGameRenderer, ¶ms, TEXTURE_HANDLE_INVALID, NULL); + game_render_quad_screen(g_pGameRenderer, ¶ms, TEXTURE_HANDLE_INVALID, + NULL); prt_centrecol(rev_vga[1], szText, iTextX, iTextY, 231); - if (iFileIdx != lastfile) // If different directory selected, rescan files and reset selection + if (iFileIdx != lastfile) // If different directory selected, rescan files and + // reset selection { topfile = 0; filefile = 0; @@ -2875,7 +3139,7 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int szDestPtr += 2; } while (byChar2); } - while (fatkbhit()) // Main keyboard input processing loop + while (fatkbhit()) // Main keyboard input processing loop { byKeyCode = fatgetch(); byProcessedKey = byKeyCode; @@ -2885,15 +3149,16 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int uiBackspaceLen = (uint32)strlen(selectfilename) + 1; if ((int)(uiBackspaceLen - 1) > 0) selectfilename[strlen(selectfilename) - 1] = 0; - //filesel_variable_1[uiBackspaceLen - 1] = 0; + // filesel_variable_1[uiBackspaceLen - 1] = 0; } else { LABEL_85: if ((uint8)byKeyCode > 0x39u) byProcessedKey = byKeyCode & 0xDF; iInputStrLen = (uint32)strlen(selectfilename); - if (iInputStrLen <= 7 - && ((uint8)byProcessedKey >= 0x41u && (uint8)byProcessedKey <= 0x5Au - || (uint8)byProcessedKey >= 0x30u && (uint8)byProcessedKey <= 0x39u)) { + if (iInputStrLen <= 7 && ((uint8)byProcessedKey >= 0x41u && + (uint8)byProcessedKey <= 0x5Au || + (uint8)byProcessedKey >= 0x30u && + (uint8)byProcessedKey <= 0x39u)) { selectfilename[iInputStrLen] = byProcessedKey; selectfilename[iInputStrLen + 1] = 0; } @@ -2901,32 +3166,33 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int } else if ((uint8)byKeyCode <= 0xDu) { sfxsample(83, 0x8000); switch (filingmenu) { - case 1: - loadreplay(); - replayedit = 0; - replayselect = 0; - disciconpressed = 0; - rotpoint = currentreplayframe; - break; - case 2: - if (selectfilename[0]) { - savereplay(); - disciconpressed = 0; - rotpoint = currentreplayframe; - } - break; - case 3: - deletereplay(); - disciconpressed = 0; - rotpoint = currentreplayframe; - break; - case 4: - Rassemble(); + case 1: + loadreplay(); + replayedit = 0; + replayselect = 0; + disciconpressed = 0; + rotpoint = currentreplayframe; + break; + case 2: + if (selectfilename[0]) { + savereplay(); disciconpressed = 0; rotpoint = currentreplayframe; - break; - default: - continue; // Execute action based on filing menu mode (1=Load, 2=Save, 3=Delete, 4=Assemble) + } + break; + case 3: + deletereplay(); + disciconpressed = 0; + rotpoint = currentreplayframe; + break; + case 4: + Rassemble(); + disciconpressed = 0; + rotpoint = currentreplayframe; + break; + default: + continue; // Execute action based on filing menu mode (1=Load, 2=Save, + // 3=Delete, 4=Assemble) } } else { if (byKeyCode != 27) @@ -2937,110 +3203,112 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int } } else { switch ((uint8)fatgetch()) { - case 'H': - iUpNavFile = filefile - 3; - if (filefile - 3 < 0) - iUpNavFile = 0; - if (!filefiles) - iUpNavFile = 0; - if (iUpNavFile < topfile) - topfile -= 3; - if (iUpNavFile >= topfile + 18) - topfile += 3; - szUpDestPtr = selectfilename; - szUpSourcePtr = filename[iUpNavFile]; - filefile = iUpNavFile; - do { - byUpChar1 = *szUpSourcePtr; - *szUpDestPtr = *szUpSourcePtr; - if (!byUpChar1) - break; - byUpChar2 = szUpSourcePtr[1]; - szUpSourcePtr += 2; - szUpDestPtr[1] = byUpChar2; - szUpDestPtr += 2; - } while (byUpChar2); - break; - case 'K': - iLeftNavFile = filefile - 1; - if (filefile - 1 < 0) - iLeftNavFile = 0; - if (!filefiles) - iLeftNavFile = 0; - if (iLeftNavFile < topfile) - topfile -= 3; - if (iLeftNavFile >= topfile + 18) - topfile += 3; - szLeftDestPtr = selectfilename; - szLeftSourcePtr = filename[iLeftNavFile]; - filefile = iLeftNavFile; - do { - byLeftChar1 = *szLeftSourcePtr; - *szLeftDestPtr = *szLeftSourcePtr; - if (!byLeftChar1) - break; - byLeftChar2 = szLeftSourcePtr[1]; - szLeftSourcePtr += 2; - szLeftDestPtr[1] = byLeftChar2; - szLeftDestPtr += 2; - } while (byLeftChar2); - break; - case 'M': - iRightNavFile = filefile + 1; - if (filefile + 1 >= filefiles) - iRightNavFile = filefiles - 1; - if (!filefiles) - iRightNavFile = 0; - if (iRightNavFile < topfile) - topfile -= 3; - if (iRightNavFile >= topfile + 18) - topfile += 3; - szRightDestPtr = selectfilename; - szRightSourcePtr = filename[iRightNavFile]; - filefile = iRightNavFile; - do { - byRightChar1 = *szRightSourcePtr; - *szRightDestPtr = *szRightSourcePtr; - if (!byRightChar1) - break; - byRightChar2 = szRightSourcePtr[1]; - szRightSourcePtr += 2; - szRightDestPtr[1] = byRightChar2; - szRightDestPtr += 2; - } while (byRightChar2); - break; - case 'P': - iDownNavFile = filefile + 3; - if (filefile + 3 >= filefiles) - iDownNavFile = filefiles - 1; - if (!filefiles) - iDownNavFile = 0; - if (iDownNavFile < topfile) - topfile -= 3; - if (iDownNavFile >= topfile + 18) - topfile += 3; - szDownDestPtr = selectfilename; - szDownSourcePtr = filename[iDownNavFile]; - filefile = iDownNavFile; - do { - byDownChar1 = *szDownSourcePtr; - *szDownDestPtr = *szDownSourcePtr; - if (!byDownChar1) - break; - byDownChar2 = szDownSourcePtr[1]; - szDownSourcePtr += 2; - szDownDestPtr[1] = byDownChar2; - szDownDestPtr += 2; - } while (byDownChar2); - break; - case 'S': - uiDelStrLen = (uint32)strlen(selectfilename) + 1; - if ((int)(uiDelStrLen - 1) > 0) - selectfilename[strlen(selectfilename) - 1] = 0; - //filesel_variable_1[uiDelStrLen - 1] = 0;// reference into selectfilename - break; - default: - continue; // Handle arrow key navigation (H=Up, K=Left, M=Right, P=Down, S=Delete) + case 'H': + iUpNavFile = filefile - 3; + if (filefile - 3 < 0) + iUpNavFile = 0; + if (!filefiles) + iUpNavFile = 0; + if (iUpNavFile < topfile) + topfile -= 3; + if (iUpNavFile >= topfile + 18) + topfile += 3; + szUpDestPtr = selectfilename; + szUpSourcePtr = filename[iUpNavFile]; + filefile = iUpNavFile; + do { + byUpChar1 = *szUpSourcePtr; + *szUpDestPtr = *szUpSourcePtr; + if (!byUpChar1) + break; + byUpChar2 = szUpSourcePtr[1]; + szUpSourcePtr += 2; + szUpDestPtr[1] = byUpChar2; + szUpDestPtr += 2; + } while (byUpChar2); + break; + case 'K': + iLeftNavFile = filefile - 1; + if (filefile - 1 < 0) + iLeftNavFile = 0; + if (!filefiles) + iLeftNavFile = 0; + if (iLeftNavFile < topfile) + topfile -= 3; + if (iLeftNavFile >= topfile + 18) + topfile += 3; + szLeftDestPtr = selectfilename; + szLeftSourcePtr = filename[iLeftNavFile]; + filefile = iLeftNavFile; + do { + byLeftChar1 = *szLeftSourcePtr; + *szLeftDestPtr = *szLeftSourcePtr; + if (!byLeftChar1) + break; + byLeftChar2 = szLeftSourcePtr[1]; + szLeftSourcePtr += 2; + szLeftDestPtr[1] = byLeftChar2; + szLeftDestPtr += 2; + } while (byLeftChar2); + break; + case 'M': + iRightNavFile = filefile + 1; + if (filefile + 1 >= filefiles) + iRightNavFile = filefiles - 1; + if (!filefiles) + iRightNavFile = 0; + if (iRightNavFile < topfile) + topfile -= 3; + if (iRightNavFile >= topfile + 18) + topfile += 3; + szRightDestPtr = selectfilename; + szRightSourcePtr = filename[iRightNavFile]; + filefile = iRightNavFile; + do { + byRightChar1 = *szRightSourcePtr; + *szRightDestPtr = *szRightSourcePtr; + if (!byRightChar1) + break; + byRightChar2 = szRightSourcePtr[1]; + szRightSourcePtr += 2; + szRightDestPtr[1] = byRightChar2; + szRightDestPtr += 2; + } while (byRightChar2); + break; + case 'P': + iDownNavFile = filefile + 3; + if (filefile + 3 >= filefiles) + iDownNavFile = filefiles - 1; + if (!filefiles) + iDownNavFile = 0; + if (iDownNavFile < topfile) + topfile -= 3; + if (iDownNavFile >= topfile + 18) + topfile += 3; + szDownDestPtr = selectfilename; + szDownSourcePtr = filename[iDownNavFile]; + filefile = iDownNavFile; + do { + byDownChar1 = *szDownSourcePtr; + *szDownDestPtr = *szDownSourcePtr; + if (!byDownChar1) + break; + byDownChar2 = szDownSourcePtr[1]; + szDownSourcePtr += 2; + szDownDestPtr[1] = byDownChar2; + szDownDestPtr += 2; + } while (byDownChar2); + break; + case 'S': + uiDelStrLen = (uint32)strlen(selectfilename) + 1; + if ((int)(uiDelStrLen - 1) > 0) + selectfilename[strlen(selectfilename) - 1] = 0; + // filesel_variable_1[uiDelStrLen - 1] = 0;// reference into + // selectfilename + break; + default: + continue; // Handle arrow key navigation (H=Up, K=Left, M=Right, P=Down, + // S=Delete) } } } @@ -3049,7 +3317,7 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int iLoopCounter = 0; iBottomEdge = iTextY + 20; do { - filefile = iDisplayFile; // Display up to 18 files in a 3x6 grid layout + filefile = iDisplayFile; // Display up to 18 files in a 3x6 grid layout if (iLoopCounter + topfile < filefiles) { iDisplayX = 100 * (iLoopCounter % 3) + iRightEdge; iDisplayY = iBottomEdge + 10 * (iLoopCounter / 3); @@ -3065,14 +3333,16 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int if (iEditMode) { uiCursorLen = (uint32)strlen(selectfilename) + 1; uiCursorPos = uiCursorLen - 1; - if (frames % 18 >= 9) // Animate blinking cursor for filename input (shows underscore every 9 frames) + if (frames % 18 >= 9) // Animate blinking cursor for filename input (shows + // underscore every 9 frames) { selectfilename[uiCursorPos] = 0; } else { selectfilename[uiCursorPos] = 95; selectfilename[uiCursorPos + 1] = 0; } - prt_stringcol(rev_vga[1], selectfilename, iLeftEdge + 20, iTextY + 100, 255); + prt_stringcol(rev_vga[1], selectfilename, iLeftEdge + 20, iTextY + 100, + 255); selectfilename[uiCursorLen - 1] = 0; } if (SVGA_ON) @@ -3080,46 +3350,52 @@ void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int else iScreenWidth = 320; iUpArrowX = iTextX + 128; - if (topfile) // Draw scroll up/down arrows based on current position in file list - replayicon(scrbuf, rev_vga[15], 79, iUpArrowX, iTextY - 3, iScreenWidth, 255); + if (topfile) // Draw scroll up/down arrows based on current position in file + // list + replayicon(scrbuf, rev_vga[15], 79, iUpArrowX, iTextY - 3, iScreenWidth, + 255); else - replayicon(scrbuf, rev_vga[15], 78, iUpArrowX, iTextY - 3, iScreenWidth, 255); + replayicon(scrbuf, rev_vga[15], 78, iUpArrowX, iTextY - 3, iScreenWidth, + 255); iDownArrowX = iTextX + 128; if (topfile + 18 >= filefiles) - replayicon(scrbuf, rev_vga[15], 80, iDownArrowX, iTextY + 82, iScreenWidth, 255); + replayicon(scrbuf, rev_vga[15], 80, iDownArrowX, iTextY + 82, iScreenWidth, + 255); else - replayicon(scrbuf, rev_vga[15], 81, iDownArrowX, iTextY + 82, iScreenWidth, 255); - if (!filefiles) // Show 'no files found' message if directory is empty + replayicon(scrbuf, rev_vga[15], 81, iDownArrowX, iTextY + 82, iScreenWidth, + 255); + if (!filefiles) // Show 'no files found' message if directory is empty prt_centrecol(rev_vga[1], &language_buffer[3328], iTextX, iTextY + 44, 143); } //------------------------------------------------------------------------------------------------- -//000679E0 -void previouscut() -{ - int iSearchFrame; // ebx - int iCutIndex; // esi - int iCutCounter; // edx - int iCameraIndex; // eax - int iFrame; // edi - int iTargetFrame; // ebx - unsigned int uiPrevDisabled; // edx - unsigned int uiTempDisabled; // eax - unsigned int uiCurrDisabled; // eax - unsigned int uiCurrentDisabled; // ecx +// 000679E0 +void previouscut() { + int iSearchFrame; // ebx + int iCutIndex; // esi + int iCutCounter; // edx + int iCameraIndex; // eax + int iFrame; // edi + int iTargetFrame; // ebx + unsigned int uiPrevDisabled; // edx + unsigned int uiTempDisabled; // eax + unsigned int uiCurrDisabled; // eax + unsigned int uiCurrentDisabled; // ecx unsigned int uiTempPrevDisabled; // eax - resetsmoke(); // Clear smoke effects for clean transition - iSearchFrame = currentreplayframe; // Start search from current frame or previous frame if possible + resetsmoke(); // Clear smoke effects for clean transition + iSearchFrame = currentreplayframe; // Start search from current frame or + // previous frame if possible if (currentreplayframe > 0) iSearchFrame = currentreplayframe - 1; - iCutIndex = -1; // Initialize cut index to -1 (no cut found) - if (cuts) // Search through camera cuts if any exist + iCutIndex = -1; // Initialize cut index to -1 (no cut found) + if (cuts) // Search through camera cuts if any exist { iCutCounter = 0; if (cuts > 0) { - iCameraIndex = 0; // Find the last cut that occurs before or at search frame - do { // Check if this cut frame is <= search frame + iCameraIndex = + 0; // Find the last cut that occurs before or at search frame + do { // Check if this cut frame is <= search frame if (camera[iCameraIndex].iFrame <= iSearchFrame) iCutIndex = iCutCounter; ++iCutCounter; @@ -3127,11 +3403,12 @@ void previouscut() } while (iCutCounter < cuts); } } - iFrame = iCutIndex; // Set target frame based on found cut - if (iCutIndex != -1) // If cut found, use the cut frame as target + iFrame = iCutIndex; // Set target frame based on found cut + if (iCutIndex != -1) // If cut found, use the cut frame as target iFrame = camera[iCutIndex].iFrame; - if (iSearchFrame >= iFrame) // Search backwards from current position to find previous cut boundary - { // Get disable status of previous and current frames + if (iSearchFrame >= iFrame) // Search backwards from current position to find + // previous cut boundary + { // Get disable status of previous and current frames if (iSearchFrame) { currentreplayframe = iSearchFrame; uiTempDisabled = readdisable(iSearchFrame - 1); @@ -3144,12 +3421,13 @@ void previouscut() uiCurrDisabled = readdisable(iSearchFrame); iTargetFrame = currentreplayframe; uiCurrentDisabled = uiCurrDisabled; - while (iTargetFrame > 0) // Search backwards until boundary found or target frame reached + while (iTargetFrame > + 0) // Search backwards until boundary found or target frame reached { if (!uiCurrentDisabled && uiPrevDisabled) - break; // Stop if found transition from disabled to enabled frame + break; // Stop if found transition from disabled to enabled frame if (iTargetFrame <= iFrame) - break; // Stop if reached target frame boundary + break; // Stop if reached target frame boundary --iTargetFrame; uiCurrentDisabled = uiPrevDisabled; if (iTargetFrame < 1) { @@ -3164,32 +3442,32 @@ void previouscut() } else { iTargetFrame = iFrame; } - ticks = iTargetFrame; // Set game timer to target frame - pend_view_init = ViewType[0]; // Initialize view system for frame transition + ticks = iTargetFrame; // Set game timer to target frame + pend_view_init = ViewType[0]; // Initialize view system for frame transition currentreplayframe = iTargetFrame; } //------------------------------------------------------------------------------------------------- -//00067AF0 -void nextcut() -{ - int iCutIndex; // esi - int iCutCounter; // eax - int iCameraIndex; // edx - int iSearchFrame; // ebx - int iNextCutFrame; // esi - int iTargetFrame; // ebx +// 00067AF0 +void nextcut() { + int iCutIndex; // esi + int iCutCounter; // eax + int iCameraIndex; // edx + int iSearchFrame; // ebx + int iNextCutFrame; // esi + int iTargetFrame; // ebx unsigned int uiPrevDisabled; // edx unsigned int uiCurrDisabled; // eax - resetsmoke(); // Clear smoke effects for clean transition - iCutIndex = -1; // Initialize cut index to -1 (no cut found) - if (cuts) // Search through camera cuts if any exist + resetsmoke(); // Clear smoke effects for clean transition + iCutIndex = -1; // Initialize cut index to -1 (no cut found) + if (cuts) // Search through camera cuts if any exist { iCutCounter = 0; if (cuts > 0) { - iCameraIndex = 0; // Find the last cut that occurs before or at current frame - do { // Check if this cut frame is <= current frame + iCameraIndex = + 0; // Find the last cut that occurs before or at current frame + do { // Check if this cut frame is <= current frame if (camera[iCameraIndex].iFrame <= currentreplayframe) iCutIndex = iCutCounter; ++iCameraIndex; @@ -3197,63 +3475,70 @@ void nextcut() } while (iCutCounter < cuts); } } - iSearchFrame = currentreplayframe; // Start search from current frame - if (iCutIndex >= cuts - 1) // Determine next cut boundary or end of replay - iNextCutFrame = replayframes + 1; // If at last cut, target is end of replay + iSearchFrame = currentreplayframe; // Start search from current frame + if (iCutIndex >= cuts - 1) // Determine next cut boundary or end of replay + iNextCutFrame = replayframes + 1; // If at last cut, target is end of replay else - iNextCutFrame = camera[iCutIndex + 1].iFrame;// Otherwise target is next cut frame - if (currentreplayframe < replayframes - 1) // Advance to next frame if not at end of replay + iNextCutFrame = + camera[iCutIndex + 1].iFrame; // Otherwise target is next cut frame + if (currentreplayframe < + replayframes - 1) // Advance to next frame if not at end of replay iSearchFrame = currentreplayframe + 1; - if (iSearchFrame <= iNextCutFrame) // Search forward from current position to find next cut boundary - { // Get disable status of previous frame for boundary detection + if (iSearchFrame <= iNextCutFrame) // Search forward from current position to + // find next cut boundary + { // Get disable status of previous frame for boundary detection if (iSearchFrame) { currentreplayframe = iSearchFrame; uiCurrDisabled = readdisable(iSearchFrame - 1); iSearchFrame = currentreplayframe; goto SEARCH_LOOP_ENTRY; } - for (uiPrevDisabled = 0; ; uiPrevDisabled = uiCurrDisabled)// Search forward until boundary found or target reached + for (uiPrevDisabled = 0;; + uiPrevDisabled = uiCurrDisabled) // Search forward until boundary found + // or target reached { currentreplayframe = iSearchFrame; uiCurrDisabled = readdisable(iSearchFrame); iTargetFrame = currentreplayframe; - if (currentreplayframe >= replayframes - 1 || !uiCurrDisabled && uiPrevDisabled) - break; // Stop at end of replay or transition from disabled to enabled + if (currentreplayframe >= replayframes - 1 || + !uiCurrDisabled && uiPrevDisabled) + break; // Stop at end of replay or transition from disabled to enabled if (currentreplayframe >= iNextCutFrame) - break; // Stop if reached next cut frame boundary + break; // Stop if reached next cut frame boundary iSearchFrame = currentreplayframe + 1; - SEARCH_LOOP_ENTRY: - ; + SEARCH_LOOP_ENTRY:; } } else { iTargetFrame = iNextCutFrame; } - ticks = iTargetFrame; // Set game timer to target frame - pend_view_init = ViewType[0]; // Initialize view system for frame transition + ticks = iTargetFrame; // Set game timer to target frame + pend_view_init = ViewType[0]; // Initialize view system for frame transition currentreplayframe = iTargetFrame; } //------------------------------------------------------------------------------------------------- -//00067BF0 -void loadreplay() -{ - char *szSrc; // esi - char *szDst; // edi - char byChar1; // al - char byChar2; // al - char *szExt; // esi - char *szExtDst; // edi +// 00067BF0 +void loadreplay() { + char *szSrc; // esi + char *szDst; // edi + char byChar1; // al + char byChar2; // al + char *szExt; // esi + char *szExtDst; // edi char byExtChar1; // al char byExtChar2; // al - holdmusic = -1; // Set initial flags for replay loading + holdmusic = -1; // Set initial flags for replay loading loading_replay = -1; filingmenu = 0; - if (filefiles) // If files are available for replay loading + if (filefiles) // If files are available for replay loading { play_game_uninit(); - strcpy(replayfilename, "../REPLAYS/"); // Start building replay file path with base directory - szSrc = selectfilename; // Manually copy selected filename to replay path (2 chars at a time) + strcpy( + replayfilename, + "../REPLAYS/"); // Start building replay file path with base directory + szSrc = selectfilename; // Manually copy selected filename to replay path (2 + // chars at a time) szDst = &replayfilename[strlen(replayfilename)]; do { byChar1 = *szSrc; @@ -3265,7 +3550,7 @@ void loadreplay() szDst[1] = byChar2; szDst += 2; } while (byChar2); - szExt = g_szGss; // Append file extension to complete replay filename + szExt = g_szGss; // Append file extension to complete replay filename szExtDst = &replayfilename[strlen(replayfilename)]; do { byExtChar1 = *szExt; @@ -3277,8 +3562,9 @@ void loadreplay() szExtDst[1] = byExtChar2; szExtDst += 2; } while (byExtChar2); - replaytype = 2; // Initialize replay playback parameters - //_disable(); // Disable interrupts while setting time-critical replay state + replaytype = 2; // Initialize replay playback parameters + //_disable(); // Disable interrupts while + // setting time-critical replay state replayspeed = 0; fraction = 0; replaydirection = 0; @@ -3287,50 +3573,54 @@ void loadreplay() play_game_init(); pend_view_init = ViewType[0]; } - screenready = 0; // Clear screen and loading flags to complete initialization + screenready = 0; // Clear screen and loading flags to complete initialization lagdone = 0; holdmusic = 0; loading_replay = 0; } //------------------------------------------------------------------------------------------------- -//00067CF0 -void savereplay() -{ - uint8 *pbyBuffer; // ebp - char *szSrc1; // esi - char *szDst1; // edi - char byChar1_1; // al - char byChar2_1; // al - char *szExtSrc1; // esi - char *szExtDst1; // edi - char byExtChar1_1; // al - char byExtChar2_1; // al - char *szSrc2; // esi - char *szDst2; // edi - char byChar1_2; // al - char byChar2_2; // al - char *szExtSrc2; // esi - char *szExtDst2; // edi - char byExtChar1_2; // al - char byExtChar2_2; // al +// 00067CF0 +void savereplay() { + uint8 *pbyBuffer; // ebp + char *szSrc1; // esi + char *szDst1; // edi + char byChar1_1; // al + char byChar2_1; // al + char *szExtSrc1; // esi + char *szExtDst1; // edi + char byExtChar1_1; // al + char byExtChar2_1; // al + char *szSrc2; // esi + char *szDst2; // edi + char byChar1_2; // al + char byChar2_2; // al + char *szExtSrc2; // esi + char *szExtDst2; // edi + char byExtChar1_2; // al + char byExtChar2_2; // al unsigned int uiBytesRead; // edi - int iError; // eax - int iErrorCopy; // edi - char szTempFilename[32]; // [esp+0h] [ebp-48h] BYREF - int iFilePos; // [esp+20h] [ebp-28h] - int iErrorNum; // [esp+24h] [ebp-24h] - FILE *pFile; // [esp+28h] [ebp-20h] - int iErrorFlag; // [esp+2Ch] [ebp-1Ch] - - iErrorFlag = 0; // Initialize error flag and buffer pointer + int iError; // eax + int iErrorCopy; // edi + char szTempFilename[32]; // [esp+0h] [ebp-48h] BYREF + int iFilePos; // [esp+20h] [ebp-28h] + int iErrorNum; // [esp+24h] [ebp-24h] + FILE *pFile; // [esp+28h] [ebp-20h] + int iErrorFlag; // [esp+2Ch] [ebp-1Ch] + + iErrorFlag = 0; // Initialize error flag and buffer pointer pbyBuffer = scrbuf; - if (!strcmp(replayfilename, "../REPLAYS/REPLAY.TMP"))// Check if currently working with temporary replay file + if (!strcmp(replayfilename, + "../REPLAYS/REPLAY.TMP")) // Check if currently working with + // temporary replay file { - ftell(replayfile); // Finalize temp replay: close file and rename to permanent location + ftell(replayfile); // Finalize temp replay: close file and rename to + // permanent location fclose(replayfile); - strcpy(replayfilename, "../REPLAYS/"); // Build final replay filename: path + selected name + extension - szSrc1 = selectfilename; // Copy selected filename to replay path (2 chars at a time) + strcpy(replayfilename, "../REPLAYS/"); // Build final replay filename: path + // + selected name + extension + szSrc1 = selectfilename; // Copy selected filename to replay path (2 chars + // at a time) szDst1 = &replayfilename[strlen(replayfilename)]; do { byChar1_1 = *szSrc1; @@ -3342,7 +3632,7 @@ void savereplay() szDst1[1] = byChar2_1; szDst1 += 2; } while (byChar2_1); - szExtSrc1 = g_szGss; // Append file extension to complete the filename + szExtSrc1 = g_szGss; // Append file extension to complete the filename szExtDst1 = &replayfilename[strlen(replayfilename)]; do { byExtChar1_1 = *szExtSrc1; @@ -3354,13 +3644,16 @@ void savereplay() szExtDst1[1] = byExtChar2_1; szExtDst1 += 2; } while (byExtChar2_1); - ROLLERremove(replayfilename); // Remove existing file and rename temp to final name + ROLLERremove( + replayfilename); // Remove existing file and rename temp to final name rename("../REPLAYS/REPLAY.TMP", replayfilename); replayfile = ROLLERfopen(replayfilename, "rb"); fseek(replayfile, 0, 0); } else { - strcpy(szTempFilename, "../REPLAYS/"); // Handle non-temp replay: copy current replay to new filename - szSrc2 = selectfilename; // Build target filename: path + selected name + extension + strcpy(szTempFilename, "../REPLAYS/"); // Handle non-temp replay: copy + // current replay to new filename + szSrc2 = selectfilename; // Build target filename: path + selected name + + // extension szDst2 = &szTempFilename[strlen(szTempFilename)]; do { byChar1_2 = *szSrc2; @@ -3384,23 +3677,28 @@ void savereplay() szExtDst2[1] = byExtChar2_2; szExtDst2 += 2; } while (byExtChar2_2); - if (strcmp(szTempFilename, replayfilename))// Only copy if target filename is different from current + if (strcmp(szTempFilename, replayfilename)) // Only copy if target filename + // is different from current { - pFile = ROLLERfopen(szTempFilename, "wb"); // Open target file for writing and prepare for copy operation + pFile = ROLLERfopen( + szTempFilename, + "wb"); // Open target file for writing and prepare for copy operation if (pFile) { iFilePos = ftell(replayfile); fseek(replayfile, 0, 0); - iErrorFlag = 0; // Copy file in chunks with error checking + iErrorFlag = 0; // Copy file in chunks with error checking do { uiBytesRead = (uint32)fread(pbyBuffer, 1u, 0xFA00u, replayfile); if (fwrite(pbyBuffer, 1, uiBytesRead, pFile) != uiBytesRead) { - iError = errno;// *(_DWORD *)_get_errno_ptr();// Handle write error - set error flag and save errno + iError = errno; // *(_DWORD *)_get_errno_ptr();// Handle write error + // - set error flag and save errno iErrorFlag = -1; iErrorNum = iError; } } while (uiBytesRead && !iErrorFlag); iErrorCopy = iErrorFlag; - fclose(pFile); // Cleanup: close file, remove on error, restore file position + fclose(pFile); // Cleanup: close file, remove on error, restore file + // position if (iErrorCopy) ROLLERremove(szTempFilename); fseek(replayfile, iFilePos, 0); @@ -3408,10 +3706,10 @@ void savereplay() } } } - filingmenu = 0; // Reset menu flags and screen state + filingmenu = 0; // Reset menu flags and screen state lastfile = 0; screenready = 0; - if (iErrorFlag) // Set appropriate error menu state based on error type + if (iErrorFlag) // Set appropriate error menu state based on error type { if (iErrorNum == 12) filingmenu = 6; @@ -3421,25 +3719,25 @@ void savereplay() } //------------------------------------------------------------------------------------------------- -//00067F50 -void deletereplay() -{ - char *szSrc; // esi - char *szDst; // edi - char byChar1; // al - char byChar2; // al - char *szExtSrc; // esi - char *szExtDst; // edi - char byExtChar1; // al - char byExtChar2; // al - char *szTmpDst; // edi - const char *szTmpSrc; // esi - char byTmpChar1; // al - char byTmpChar2; // al +// 00067F50 +void deletereplay() { + char *szSrc; // esi + char *szDst; // edi + char byChar1; // al + char byChar2; // al + char *szExtSrc; // esi + char *szExtDst; // edi + char byExtChar1; // al + char byExtChar2; // al + char *szTmpDst; // edi + const char *szTmpSrc; // esi + char byTmpChar1; // al + char byTmpChar2; // al char szTargetFilename[40]; // [esp-30h] [ebp-34h] BYREF - strcpy(szTargetFilename, "../REPLAYS/"); // Build target filename: path + selected filename + extension - szSrc = selectfilename; // Copy selected filename to path (2 chars at a time) + strcpy(szTargetFilename, "../REPLAYS/"); // Build target filename: path + + // selected filename + extension + szSrc = selectfilename; // Copy selected filename to path (2 chars at a time) szDst = &szTargetFilename[strlen(szTargetFilename)]; do { byChar1 = *szSrc; @@ -3451,7 +3749,7 @@ void deletereplay() szDst[1] = byChar2; szDst += 2; } while (byChar2); - szExtSrc = g_szGss; // Append file extension to complete target filename + szExtSrc = g_szGss; // Append file extension to complete target filename szExtDst = &szTargetFilename[strlen(szTargetFilename)]; do { byExtChar1 = *szExtSrc; @@ -3463,13 +3761,16 @@ void deletereplay() szExtDst[1] = byExtChar2; szExtDst += 2; } while (byExtChar2); - if (!strcmp(replayfilename, szTargetFilename))// Check if deleting the currently loaded replay file + if (!strcmp(replayfilename, szTargetFilename)) // Check if deleting the + // currently loaded replay file { - ROLLERremove("../REPLAYS/REPLAY.TMP"); // Deleting current replay: cleanup temp files and swap to temp - ftell(replayfile); // Close current replay file and rename target to temp + ROLLERremove("../REPLAYS/REPLAY.TMP"); // Deleting current replay: cleanup + // temp files and swap to temp + ftell(replayfile); // Close current replay file and rename target to temp szTmpDst = replayfilename; fclose(replayfile); - szTmpSrc = "../REPLAYS/REPLAY.TMP"; // Copy temp filename to current replayfilename (2 chars at a time) + szTmpSrc = "../REPLAYS/REPLAY.TMP"; // Copy temp filename to current + // replayfilename (2 chars at a time) ROLLERrename(szTargetFilename, "../REPLAYS/REPLAY.TMP"); do { byTmpChar1 = *szTmpSrc; @@ -3481,36 +3782,39 @@ void deletereplay() szTmpDst[1] = byTmpChar2; szTmpDst += 2; } while (byTmpChar2); - replayfile = ROLLERfopen(replayfilename, "rb"); // Reopen temp file as current replay + replayfile = + ROLLERfopen(replayfilename, "rb"); // Reopen temp file as current replay fseek(replayfile, 0, 0); } else { - ROLLERremove(szTargetFilename); // Not current replay: simple file deletion + ROLLERremove(szTargetFilename); // Not current replay: simple file deletion } - ticks = currentreplayframe; // Reset replay state and clear menu flags + ticks = currentreplayframe; // Reset replay state and clear menu flags filingmenu = 0; lastfile = 0; } //------------------------------------------------------------------------------------------------- -//00068070 -void updatedirectory() -{ +// 00068070 +void updatedirectory() { int iNewTopFile; // edx - char *szDst; // edi - char *szSrc; // esi - char byChar1; // al - char byChar2; // al + char *szDst; // edi + char *szSrc; // esi + char byChar1; // al + char byChar2; // al - iNewTopFile = topfile; // Initialize with current top file position - if (!filefiles) // If no files available, reset current file selection + iNewTopFile = topfile; // Initialize with current top file position + if (!filefiles) // If no files available, reset current file selection filefile = 0; - if (filefile < topfile) // If selected file is above view window, scroll up 3 positions + if (filefile < + topfile) // If selected file is above view window, scroll up 3 positions iNewTopFile = topfile - 3; - if (iNewTopFile + 18 <= filefile) // If selected file is below view window (18 files visible), scroll down 3 positions + if (iNewTopFile + 18 <= filefile) // If selected file is below view window (18 + // files visible), scroll down 3 positions iNewTopFile += 3; - szDst = selectfilename; // Copy currently selected filename to selectfilename buffer (2 chars at a time) + szDst = selectfilename; // Copy currently selected filename to selectfilename + // buffer (2 chars at a time) szSrc = filename[filefile]; - topfile = iNewTopFile; // Update top file position for scrolled view + topfile = iNewTopFile; // Update top file position for scrolled view do { byChar1 = *szSrc; *szDst = *szSrc; @@ -3524,9 +3828,8 @@ void updatedirectory() } //------------------------------------------------------------------------------------------------- -//000680F0 -void findintrofiles() -{ +// 000680F0 +void findintrofiles() { introfiles = 0; #ifdef IS_WINDOWS struct _finddata_t fileinfo; @@ -3562,25 +3865,24 @@ void findintrofiles() } //------------------------------------------------------------------------------------------------- -//00068130 -void displaycontrolpanel() -{ - int iScreenWidth; // ebp - int iIconOffset; // eax - int iCalculatedFrame; // edi - int iFrameLoop; // eax - int iFrameLoop2; // eax - int iRotateIndex; // eax - int iRotateLoop; // esi - int iRotateX; // ecx - int iCurrentCut; // ebx - int iCutLoop; // eax - int iCutIndex; // edx +// 00068130 +void displaycontrolpanel() { + int iScreenWidth; // ebp + int iIconOffset; // eax + int iCalculatedFrame; // edi + int iFrameLoop; // eax + int iFrameLoop2; // eax + int iRotateIndex; // eax + int iRotateLoop; // esi + int iRotateX; // ecx + int iCurrentCut; // ebx + int iCutLoop; // eax + int iCutIndex; // edx const char *pEditString; // eax - int iRotateY; // [esp-Ch] [ebp-48h] - int iEndFrame; // [esp+4h] [ebp-38h] - int iStartFrame; // [esp+8h] [ebp-34h] - int iRotateLimit; // [esp+18h] [ebp-24h] + int iRotateY; // [esp-Ch] [ebp-48h] + int iEndFrame; // [esp+4h] [ebp-38h] + int iStartFrame; // [esp+8h] [ebp-34h] + int iRotateLimit; // [esp+18h] [ebp-24h] if (SVGA_ON) { iScreenWidth = 640; @@ -3589,54 +3891,75 @@ void displaycontrolpanel() iScreenWidth = 320; replayicon(scrbuf, rev_vga[15], 0, 0, 150, 320, -1); } - if (!replayedit) // Draw control panel overlay if not in replay edit mode + if (!replayedit) // Draw control panel overlay if not in replay edit mode replayicon(scrbuf, rev_vga[15], 77, 117, 187, iScreenWidth, -1); - if (!keys[WHIP_SCANCODE_RETURN] || paused || (iIconOffset = -1, controlicon == 18) && !replayselect)// Calculate icon offset: -1 if ENTER pressed and conditions met, 0 otherwise + if (!keys[WHIP_SCANCODE_RETURN] || paused || + (iIconOffset = -1, controlicon == 18) && + !replayselect) // Calculate icon offset: -1 if ENTER pressed and + // conditions met, 0 otherwise iIconOffset = 0; - replayicon(scrbuf, rev_vga[15], controlicon, ricon[controlicon].nX, ricon[controlicon].nY + 150 + iIconOffset, iScreenWidth, -1);// Draw current control icon with calculated offset - if (replayspeed > 0 && !forwarding && !rewinding)// Draw fast forward indicators when replay speed is positive + replayicon(scrbuf, rev_vga[15], controlicon, ricon[controlicon].nX, + ricon[controlicon].nY + 150 + iIconOffset, iScreenWidth, + -1); // Draw current control icon with calculated offset + if (replayspeed > 0 && !forwarding && + !rewinding) // Draw fast forward indicators when replay speed is positive { if (controlicon == 4) - replayicon(scrbuf, rev_vga[15], 4, ricon[4].nX, ricon[4].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 4, ricon[4].nX, ricon[4].nY + 149, + iScreenWidth, -1); else - replayicon(scrbuf, rev_vga[15], 27, ricon[4].nX, ricon[4].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 27, ricon[4].nX, ricon[4].nY + 149, + iScreenWidth, -1); } - if (replayspeed < 0 && !forwarding && !rewinding)// Draw rewind indicators when replay speed is negative + if (replayspeed < 0 && !forwarding && + !rewinding) // Draw rewind indicators when replay speed is negative { if (controlicon == 3) - replayicon(scrbuf, rev_vga[15], 3, ricon[3].nX, ricon[3].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 3, ricon[3].nX, ricon[3].nY + 149, + iScreenWidth, -1); else - replayicon(scrbuf, rev_vga[15], 26, ricon[3].nX, ricon[3].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 26, ricon[3].nX, ricon[3].nY + 149, + iScreenWidth, -1); } - if (replayedit) // Draw edit mode indicator icon + if (replayedit) // Draw edit mode indicator icon { if (controlicon == 17) - replayicon(scrbuf, rev_vga[15], 17, ricon[17].nX, ricon[17].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 17, ricon[17].nX, ricon[17].nY + 149, + iScreenWidth, -1); else - replayicon(scrbuf, rev_vga[15], 28, ricon[17].nX, ricon[17].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 28, ricon[17].nX, ricon[17].nY + 149, + iScreenWidth, -1); } - if (replayselect) // Draw replay selection mode indicator icon + if (replayselect) // Draw replay selection mode indicator icon { if (controlicon == 18) - replayicon(scrbuf, rev_vga[15], 18, ricon[18].nX, ricon[18].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 18, ricon[18].nX, ricon[18].nY + 149, + iScreenWidth, -1); else - replayicon(scrbuf, rev_vga[15], 29, ricon[18].nX, ricon[18].nY + 149, iScreenWidth, -1); + replayicon(scrbuf, rev_vga[15], 29, ricon[18].nX, ricon[18].nY + 149, + iScreenWidth, -1); } - if (disciconpressed) // Draw disc icon when pressed - replayicon(scrbuf, rev_vga[15], 16, ricon[16].nX, ricon[17].nY + 149, iScreenWidth, -1); - replaypanelstring(replayhelp[controlicon], 255, 165, iScreenWidth);// Display help text for current control icon - if (replayedit) // EDIT MODE: Display edit mode information panel + if (disciconpressed) // Draw disc icon when pressed + replayicon(scrbuf, rev_vga[15], 16, ricon[16].nX, ricon[17].nY + 149, + iScreenWidth, -1); + replaypanelstring(replayhelp[controlicon], 255, 165, + iScreenWidth); // Display help text for current control icon + if (replayedit) // EDIT MODE: Display edit mode information panel { - replaypanelstring("CURRENT:", 164, 165, iScreenWidth);// Show current edit info text - sprintf(buffer, "CAR %d", ViewType[0] + 1); // Display current car number being viewed + replaypanelstring("CURRENT:", 164, 165, + iScreenWidth); // Show current edit info text + sprintf(buffer, "CAR %d", + ViewType[0] + 1); // Display current car number being viewed replaypanelstring(buffer, 199, 165, iScreenWidth); - replaypanelstring(views[SelectedView[0]], 225, 165, iScreenWidth);// Display current camera view type - if (cuts) // Process camera cuts if they exist + replaypanelstring(views[SelectedView[0]], 225, 165, + iScreenWidth); // Display current camera view type + if (cuts) // Process camera cuts if they exist { iCurrentCut = -1; iCutLoop = 0; if (cuts > 0) { - iCutIndex = 0; // Find the current active camera cut based on replay frame + iCutIndex = + 0; // Find the current active camera cut based on replay frame do { if (currentreplayframe >= camera[iCutIndex].iFrame) iCurrentCut = iCutLoop; @@ -3644,8 +3967,8 @@ void displaycontrolpanel() ++iCutIndex; } while (iCutLoop < cuts); } - if (iCurrentCut != -1) // Display camera cut information if one is active - { // Show different text for exact frame match vs approximate + if (iCurrentCut != -1) // Display camera cut information if one is active + { // Show different text for exact frame match vs approximate if (camera[iCurrentCut].iFrame == currentreplayframe) pEditString = g_szNewEdit; else @@ -3653,11 +3976,12 @@ void displaycontrolpanel() replaypanelstring(pEditString, 164, 171, iScreenWidth); sprintf(buffer, "CAR %d", camera[iCurrentCut].byCarIdx + 1); replaypanelstring(buffer, 199, 171, iScreenWidth); - replaypanelstring(views[camera[iCurrentCut].byView], 225, 171, iScreenWidth); + replaypanelstring(views[camera[iCurrentCut].byView], 225, 171, + iScreenWidth); } } - if (replayselect) // Display selection range if in replay select mode - { // Order start and end frames correctly for display + if (replayselect) // Display selection range if in replay select mode + { // Order start and end frames correctly for display if (replaystart >= currentreplayframe) { iStartFrame = currentreplayframe; iEndFrame = replaystart; @@ -3665,47 +3989,66 @@ void displaycontrolpanel() iStartFrame = replaystart; iEndFrame = currentreplayframe; } - replaypanelstring("BLOCK:", 164, 159, iScreenWidth);// Display selection block text and time range + replaypanelstring( + "BLOCK:", 164, 159, + iScreenWidth); // Display selection block text and time range displaypaneltime(iStartFrame, 189, 159, iScreenWidth); displaypaneltime(iEndFrame, 223, 159, iScreenWidth); replaypanelstring("-", 218, 159, iScreenWidth); } else { - displaypaneltime(currentreplayframe, 223, 159, iScreenWidth);// Just show current time when not selecting + displaypaneltime( + currentreplayframe, 223, 159, + iScreenWidth); // Just show current time when not selecting } } else { - sprintf(buffer, "X %s", replayname[replaysetspeed]);// NORMAL MODE: Display speed multiplier and status icons + sprintf(buffer, "X %s", + replayname[replaysetspeed]); // NORMAL MODE: Display speed + // multiplier and status icons replaypanelstring(buffer, 229, 165, iScreenWidth); - displaypaneltime(currentreplayframe, 223, 159, iScreenWidth);// Display current replay time - if (replayspeed > 0 && !forwarding && !rewinding)// Show fast forward icon when playing forward + displaypaneltime(currentreplayframe, 223, 159, + iScreenWidth); // Display current replay time + if (replayspeed > 0 && !forwarding && + !rewinding) // Show fast forward icon when playing forward replayicon(scrbuf, rev_vga[15], 73, 164, 161, iScreenWidth, 255); - if (replayspeed < 0 && !forwarding && !rewinding)// Show rewind icon when playing backward + if (replayspeed < 0 && !forwarding && + !rewinding) // Show rewind icon when playing backward replayicon(scrbuf, rev_vga[15], 72, 164, 161, iScreenWidth, 255); - if (forwarding && replayspeed > 0) // Show fast forward icon when actively fast forwarding + if (forwarding && + replayspeed > 0) // Show fast forward icon when actively fast forwarding replayicon(scrbuf, rev_vga[15], 71, 164, 161, iScreenWidth, 255); - if (rewinding && replayspeed < 0) // Show rewind icon when actively rewinding + if (rewinding && + replayspeed < 0) // Show rewind icon when actively rewinding replayicon(scrbuf, rev_vga[15], 70, 164, 161, iScreenWidth, 255); - if (!replayspeed) // Show pause icon when replay speed is zero + if (!replayspeed) // Show pause icon when replay speed is zero replayicon(scrbuf, rev_vga[15], 74, 164, 161, iScreenWidth, 255); - replayicon(scrbuf, rev_vga[15], 75, 190, 161, iScreenWidth, 255);// Draw progress bar background - if (currentreplayframe <= rotpoint) // Calculate position for progress bar indicators - { // Current frame is before rotation point + replayicon(scrbuf, rev_vga[15], 75, 190, 161, iScreenWidth, + 255); // Draw progress bar background + if (currentreplayframe <= + rotpoint) // Calculate position for progress bar indicators + { // Current frame is before rotation point if (rotpoint - currentreplayframe > 24) { iCalculatedFrame = rotpoint - 24; - for (iFrameLoop2 = rotpoint - 152; iFrameLoop2 >= currentreplayframe; iCalculatedFrame -= 64) + for (iFrameLoop2 = rotpoint - 152; iFrameLoop2 >= currentreplayframe; + iCalculatedFrame -= 64) iFrameLoop2 -= 64; } else { iCalculatedFrame = currentreplayframe; } - } else if (currentreplayframe - rotpoint > 24)// Current frame is after rotation point + } else if (currentreplayframe - rotpoint > + 24) // Current frame is after rotation point { iCalculatedFrame = rotpoint + 24; - for (iFrameLoop = rotpoint + 152; iFrameLoop <= currentreplayframe; iCalculatedFrame += 64) + for (iFrameLoop = rotpoint + 152; iFrameLoop <= currentreplayframe; + iCalculatedFrame += 64) iFrameLoop += 64; } else { iCalculatedFrame = currentreplayframe; } - iRotateIndex = iCalculatedFrame / 8; // Calculate rotation index for progress bar markers - //iRotateIndex = (iCalculatedFrame - (__CFSHL__(iCalculatedFrame >> 31, 3) + 8 * (iCalculatedFrame >> 31))) >> 3;// Calculate rotation index for progress bar markers + iRotateIndex = iCalculatedFrame / + 8; // Calculate rotation index for progress bar markers + // iRotateIndex = (iCalculatedFrame - (__CFSHL__(iCalculatedFrame >> 31, 3) + // + 8 * (iCalculatedFrame >> 31))) >> 3;// Calculate rotation index for + // progress bar markers rotpoint = iCalculatedFrame; iRotateLoop = iRotateIndex; iRotateLimit = iRotateIndex + 3; @@ -3714,15 +4057,15 @@ void displaycontrolpanel() iRotateY = rrotate[iRotateLoop % 8].y + 150; iRotateX = rrotate[iRotateLoop % 8].x; ++iRotateLoop; - replayicon(scrbuf, rev_vga[15], 76, iRotateX, iRotateY, iScreenWidth, 255); + replayicon(scrbuf, rev_vga[15], 76, iRotateX, iRotateY, iScreenWidth, + 255); } while (iRotateLoop < iRotateLimit); } } //------------------------------------------------------------------------------------------------- -//00068910 -void rtoggleedit() -{ +// 00068910 +void rtoggleedit() { replayedit = replayedit == 0; replayselect = 0; if (replaytype == 2) { @@ -3734,13 +4077,12 @@ void rtoggleedit() //_enable(); } rotpoint = currentreplayframe; - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } //------------------------------------------------------------------------------------------------- -//00068980 -void rstartblock() -{ +// 00068980 +void rstartblock() { bool bReplaySelected; // zf if (replayedit) { @@ -3763,98 +4105,104 @@ void rstartblock() //_enable(); } replaystart = currentreplayframe; - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068A20 -void rselectblock() -{ // Check if replay editing mode is active - int iStartFrame; // eax - int iEndFrame; // ebx - int iFrameIndex; // edx - int iCurrentFrame; // eax - - if (replayedit) { // Check if replay type is 2 (selection mode) +// 00068A20 +void rselectblock() { // Check if replay editing mode is active + int iStartFrame; // eax + int iEndFrame; // ebx + int iFrameIndex; // edx + int iCurrentFrame; // eax + + if (replayedit) { // Check if replay type is 2 (selection mode) if (replaytype == 2) { - //_disable(); // Pause replay playback - disable interrupts - replayspeed = 0; // Stop replay playback + //_disable(); // Pause replay playback - + // disable interrupts + replayspeed = 0; // Stop replay playback fraction = 0; replaydirection = 0; ticks = currentreplayframe; //_enable(); } - if (!replayselect) // If no selection active, start new selection at current frame + if (!replayselect) // If no selection active, start new selection at current + // frame replaystart = currentreplayframe; - iStartFrame = replaystart; // Get frame range for selection block operation + iStartFrame = replaystart; // Get frame range for selection block operation iEndFrame = currentreplayframe; - if (replaytype == 2) { // Ensure start frame <= end frame for proper range + if (replaytype == 2) { // Ensure start frame <= end frame for proper range if (currentreplayframe < replaystart) { iStartFrame = currentreplayframe; iEndFrame = replaystart; } - for (iFrameIndex = iStartFrame; iFrameIndex <= iEndFrame; ++iFrameIndex)// Clear disabled status for all frames in selected range + for (iFrameIndex = iStartFrame; iFrameIndex <= iEndFrame; + ++iFrameIndex) // Clear disabled status for all frames in selected + // range { iCurrentFrame = iFrameIndex; cleardisable(iCurrentFrame); } } - replayselect = 0; // Clear selection flag + replayselect = 0; // Clear selection flag if (replaytype == 2) { - //_disable(); // Reset replay state after selection operation + //_disable(); // Reset replay state after + // selection operation replayspeed = 0; fraction = 0; replaydirection = 0; ticks = currentreplayframe; //_enable(); } - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068AF0 -void rdeleteblock() -{ // Check if replay editing mode is active - int iStartFrame; // ecx - int iEndFrame; // ebx - int iFrameIndex; // edx - int iCurrentFrame; // eax - - if (replayedit) { // Check if replay type is 2 (deletion mode) +// 00068AF0 +void rdeleteblock() { // Check if replay editing mode is active + int iStartFrame; // ecx + int iEndFrame; // ebx + int iFrameIndex; // edx + int iCurrentFrame; // eax + + if (replayedit) { // Check if replay type is 2 (deletion mode) if (replaytype == 2) { - //_disable(); // Pause replay playback - disable interrupts - replayspeed = 0; // Stop replay playback + //_disable(); // Pause replay playback - + // disable interrupts + replayspeed = 0; // Stop replay playback fraction = 0; replaydirection = 0; ticks = currentreplayframe; //_enable(); } - if (!replayselect) // If no selection active, start new selection at current frame + if (!replayselect) // If no selection active, start new selection at current + // frame replaystart = currentreplayframe; - iStartFrame = replaystart; // Get frame range for deletion block operation + iStartFrame = replaystart; // Get frame range for deletion block operation iEndFrame = currentreplayframe; - if (replaytype == 2) { // Ensure start frame <= end frame for proper range + if (replaytype == 2) { // Ensure start frame <= end frame for proper range if (currentreplayframe < replaystart) { iStartFrame = currentreplayframe; iEndFrame = replaystart; } - for (iFrameIndex = iStartFrame; iFrameIndex <= iEndFrame; ++iFrameIndex)// Mark all frames in selected range as disabled/deleted + for (iFrameIndex = iStartFrame; iFrameIndex <= iEndFrame; + ++iFrameIndex) // Mark all frames in selected range as + // disabled/deleted { iCurrentFrame = iFrameIndex; setdisable(iCurrentFrame); } } - replayselect = 0; // Clear selection flag - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + replayselect = 0; // Clear selection flag + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068B90 -void rstoreview() -{ +// 00068B90 +void rstoreview() { if (replayedit) { if (replaytype == 2) { //_disable(); @@ -3865,14 +4213,13 @@ void rstoreview() //_enable(); } storecut(); - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068BE0 -void rremoveview() -{ +// 00068BE0 +void rremoveview() { if (replayedit) { if (replaytype == 2) { //_disable(); @@ -3883,14 +4230,13 @@ void rremoveview() //_enable(); } removecut(); - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068C30 -void rpreviouscut() -{ +// 00068C30 +void rpreviouscut() { if (replayedit) { if (replaytype == 2) { //_disable(); @@ -3901,14 +4247,13 @@ void rpreviouscut() //_enable(); } previouscut(); - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068C80 -void rnextcut() -{ +// 00068C80 +void rnextcut() { if (replayedit) { if (replaytype == 2) { //_disable(); @@ -3919,80 +4264,89 @@ void rnextcut() //_enable(); } nextcut(); - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON } } //------------------------------------------------------------------------------------------------- -//00068CD0 -void rstartassemble() -{ +// 00068CD0 +void rstartassemble() { int iEnabledFramesFound; // ebx - int iFrameIndex; // edx + int iFrameIndex; // edx - iEnabledFramesFound = 0; // Initialize flag - assume no enabled frames found - if (replaytype == 2 && replayedit) // Only allow assembly in edit mode with replay editing enabled + iEnabledFramesFound = 0; // Initialize flag - assume no enabled frames found + if (replaytype == 2 && replayedit) // Only allow assembly in edit mode with + // replay editing enabled { - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON - iFrameIndex = 0; // Start searching from first frame - if (replayframes > 0) // Search through all replay frames - { // Skip disabled frames - look for first enabled frame + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON + iFrameIndex = 0; // Start searching from first frame + if (replayframes > 0) // Search through all replay frames + { // Skip disabled frames - look for first enabled frame while (readdisable(iFrameIndex)) { if (++iFrameIndex >= replayframes) goto CHECK_RESULTS; } - iEnabledFramesFound = -1; // Found at least one enabled frame + iEnabledFramesFound = -1; // Found at least one enabled frame } CHECK_RESULTS: - if (iEnabledFramesFound) // Set appropriate menu state based on search results - filingmenu = 4; // No enabled frames - set menu to error/warning state + if (iEnabledFramesFound) // Set appropriate menu state based on search + // results + filingmenu = 4; // No enabled frames - set menu to error/warning state else - filingmenu = 8; // Enabled frames found - proceed with assembly menu + filingmenu = 8; // Enabled frames found - proceed with assembly menu } } //------------------------------------------------------------------------------------------------- -//00068D50 -void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, int iY, int iScreenWidth, int byTransparentColor) -{ - int iScaledDestY; // edx - uint8 *pDestPixel; // eax +// 00068D50 +void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, + int iY, int iScreenWidth, int byTransparentColor) { + int iScaledDestY; // edx + uint8 *pDestPixel; // eax tBlockHeader *pSpriteHeader; // edx - uint8 *pSpritePixels; // edx - int iCurrentX; // esi - int iPixelX; // ebp - uint8 byPixelColor; // cl - int iSvgaCurrentX; // esi - uint8 bySvgaPixelColor; // cl - uint8 *pNextLineStart; // ebp - uint8 *pTempPixel1; // eax - uint8 *pTempPixel2; // ebp - uint8 *pTempPixel3; // eax - uint8 *pTempPixel4; // ebp - int iHeight; // [esp+Ch] [ebp-2Ch] - int iScaledDestX; // [esp+10h] [ebp-28h] - int iCurrentRow; // [esp+14h] [ebp-24h] - int iRowLoop; // [esp+18h] [ebp-20h] - int iWidth; // [esp+1Ch] [ebp-1Ch] - uint8 *pSvgaNextLine; // [esp+20h] [ebp-18h] - int iSvgaPixelX; // [esp+24h] [ebp-14h] + uint8 *pSpritePixels; // edx + int iCurrentX; // esi + int iPixelX; // ebp + uint8 byPixelColor; // cl + int iSvgaCurrentX; // esi + uint8 bySvgaPixelColor; // cl + uint8 *pNextLineStart; // ebp + uint8 *pTempPixel1; // eax + uint8 *pTempPixel2; // ebp + uint8 *pTempPixel3; // eax + uint8 *pTempPixel4; // ebp + int iHeight; // [esp+Ch] [ebp-2Ch] + int iScaledDestX; // [esp+10h] [ebp-28h] + int iCurrentRow; // [esp+14h] [ebp-24h] + int iRowLoop; // [esp+18h] [ebp-20h] + int iWidth; // [esp+1Ch] [ebp-1Ch] + uint8 *pSvgaNextLine; // [esp+20h] [ebp-18h] + int iSvgaPixelX; // [esp+24h] [ebp-14h] iScaledDestX = iX; iScaledDestY = iY; - if (SVGA_ON) // If SVGA mode is enabled, scale coordinates by 2x + if (SVGA_ON) // If SVGA mode is enabled, scale coordinates by 2x { iScaledDestY = 2 * iY; iScaledDestX = 2 * iX; } - pDestPixel = &pDest[iScaledDestX + iScreenWidth * iScaledDestY];// Calculate destination pixel pointer: buffer + (y * width) + x - iWidth = pBlockHeader[iBlockIdx].iWidth; // Get sprite width from sprite data header (offset 0) + pDestPixel = + &pDest[iScaledDestX + + iScreenWidth * iScaledDestY]; // Calculate destination pixel + // pointer: buffer + (y * width) + x + iWidth = pBlockHeader[iBlockIdx] + .iWidth; // Get sprite width from sprite data header (offset 0) pSpriteHeader = &pBlockHeader[iBlockIdx]; - iHeight = pSpriteHeader->iHeight; // Get sprite height from sprite data header (offset 4) - pSpritePixels = (uint8 *)pBlockHeader + pSpriteHeader->iDataOffset;// Get pointer to sprite pixel data (offset 8) + iHeight = + pSpriteHeader + ->iHeight; // Get sprite height from sprite data header (offset 4) + pSpritePixels = + (uint8 *)pBlockHeader + + pSpriteHeader->iDataOffset; // Get pointer to sprite pixel data (offset 8) // Branch to SVGA rendering path (2x2 pixel scaling) if (SVGA_ON) { - iCurrentRow = 0; // SVGA mode: outer loop for sprite rows with 2x scaling + iCurrentRow = 0; // SVGA mode: outer loop for sprite rows with 2x scaling if (iHeight <= 0) return; while (1) { @@ -4001,16 +4355,18 @@ void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, if (iWidth > 0) break; SVGA_NEXT_ROW: - // SVGA: Move to next row, skip unused portion of screen line - pDestPixel += 2 * (iScreenWidth - iWidth);// SVGA_NEXT_ROW: Advance to next sprite row and check completion + // SVGA: Move to next row, skip unused portion of screen line + pDestPixel += + 2 * (iScreenWidth - iWidth); // SVGA_NEXT_ROW: Advance to next sprite + // row and check completion if (++iCurrentRow >= iHeight) return; } - while (1) // SVGA mode: inner loop for sprite pixels with 2x2 scaling + while (1) // SVGA mode: inner loop for sprite pixels with 2x2 scaling { bySvgaPixelColor = *pSpritePixels++; if (iSvgaCurrentX < 0 || iSvgaCurrentX >= iScreenWidth) - break; // SVGA bounds check + break; // SVGA bounds check pNextLineStart = &pDestPixel[iScreenWidth]; pSvgaNextLine = &pDestPixel[iScreenWidth]; @@ -4039,7 +4395,8 @@ void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, *pTempPixel2 = bySvgaPixelColor; } SVGA_NEXT_PIXEL: - iSvgaCurrentX += 2; // SVGA_NEXT_PIXEL: Advance to next pixel in current row (2x scaling) + iSvgaCurrentX += 2; // SVGA_NEXT_PIXEL: Advance to next pixel in current + // row (2x scaling) if (++iSvgaPixelX >= iWidth) goto SVGA_NEXT_ROW; } @@ -4054,8 +4411,10 @@ void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, for (iPixelX = 0; iPixelX < iWidth; ++pDestPixel) { byPixelColor = *pSpritePixels++; - // Check bounds and transparency: skip if out of bounds or matches transparent color - if (iCurrentX >= 0 && iCurrentX < iScreenWidth && (byTransparentColor < 0 || byTransparentColor != byPixelColor)) + // Check bounds and transparency: skip if out of bounds or matches + // transparent color + if (iCurrentX >= 0 && iCurrentX < iScreenWidth && + (byTransparentColor < 0 || byTransparentColor != byPixelColor)) *pDestPixel = byPixelColor; ++iCurrentX; ++iPixelX; @@ -4067,9 +4426,8 @@ void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, } //------------------------------------------------------------------------------------------------- -//00068EF0 -void replaypanelletter(char c, int *piX, int *piY, int iScreenWidth) -{ +// 00068EF0 +void replaypanelletter(char c, int *piX, int *piY, int iScreenWidth) { int iCharBlockIdx; // esi iCharBlockIdx = -1; @@ -4086,20 +4444,20 @@ void replaypanelletter(char c, int *piX, int *piY, int iScreenWidth) if (c == '?') iCharBlockIdx = 69; if (iCharBlockIdx != -1) { - replayicon(scrbuf, rev_vga[15], iCharBlockIdx, *piX, *piY, iScreenWidth, 255); + replayicon(scrbuf, rev_vga[15], iCharBlockIdx, *piX, *piY, iScreenWidth, + 255); *piX += rev_vga[15][iCharBlockIdx].iWidth + 1; } } //------------------------------------------------------------------------------------------------- -//00068F80 -void replaypanelstring(const char *szStr, int iX, int iY, int iScreenWidth) -{ - const char *szStrItr; // esi - unsigned int i; // ebp - int iXPos; // [esp+4h] [ebp-1Ch] BYREF - int iYPos; // [esp+8h] [ebp-18h] BYREF - int iScreenWidth_1; // [esp+Ch] [ebp-14h] +// 00068F80 +void replaypanelstring(const char *szStr, int iX, int iY, int iScreenWidth) { + const char *szStrItr; // esi + unsigned int i; // ebp + int iXPos; // [esp+4h] [ebp-1Ch] BYREF + int iYPos; // [esp+8h] [ebp-18h] BYREF + int iScreenWidth_1; // [esp+Ch] [ebp-14h] const char *szGetStrLen; // [esp+10h] [ebp-10h] szGetStrLen = szStr; @@ -4121,34 +4479,33 @@ void replaypanelstring(const char *szStr, int iX, int iY, int iScreenWidth) } //------------------------------------------------------------------------------------------------- -//00069000 -void displaypaneltime(int iTime, int iX, int iY, int iScreenWidth) -{ - sprintf(buffer, "%02d:%02d:%02d", iTime / 36 / 60, iTime / 36 % 60, iTime % 36); +// 00069000 +void displaypaneltime(int iTime, int iX, int iY, int iScreenWidth) { + sprintf(buffer, "%02d:%02d:%02d", iTime / 36 / 60, iTime / 36 % 60, + iTime % 36); replaypanelstring(buffer, iX, iY, iScreenWidth); } //------------------------------------------------------------------------------------------------- -//00069080 -void discmenu() -{ - sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON +// 00069080 +void discmenu() { + sfxsample(SOUND_SAMPLE_BUTTON, 0x8000); // SOUND_SAMPLE_BUTTON lsdsel = 0; disciconpressed = -1; filingmenu = 5; } //------------------------------------------------------------------------------------------------- -//000690C0 -void initsoundlag(uint32 uiTicks) -{ - //cli(); // Disable interrupts +// 000690C0 +void initsoundlag(uint32 uiTicks) { + // cli(); // Disable interrupts delayread = 0; delaywrite = 6; int iNumCars = numcars; - if (iNumCars > 16) iNumCars = 16; + if (iNumCars > 16) + iNumCars = 16; for (int iCarIdx = 0; iCarIdx < iNumCars; iCarIdx++) { // Initialize all 6 entries for this car @@ -4164,42 +4521,39 @@ void initsoundlag(uint32 uiTicks) fraction = 0; currentreplayframe = uiTicks; lastreplayframe = uiTicks; - replayspeed = 0x100; // 1.0x speed + replayspeed = 0x100; // 1.0x speed - //sti(); // Enable interrupts + // sti(); // Enable interrupts } //------------------------------------------------------------------------------------------------- -//00069160 -void resetsmoke() -{ - int iNumCars; // esi +// 00069160 +void resetsmoke() { + int iNumCars; // esi int iCarIndex; // ebx - //int iCarSprayEnd; // ecx - //unsigned int uiOffset; // eax + // int iCarSprayEnd; // ecx + // unsigned int uiOffset; // eax iNumCars = numcars; iCarIndex = 0; - for (iCarIndex = 0; iCarIndex < iNumCars; iCarIndex++) - { - for (int iSprayIndex = 0; iSprayIndex < 32; iSprayIndex++) - { + for (iCarIndex = 0; iCarIndex < iNumCars; iCarIndex++) { + for (int iSprayIndex = 0; iSprayIndex < 32; iSprayIndex++) { CarSpray[iCarIndex][iSprayIndex].iLifeTime = 0; } } - //if (numcars > 0) { - // iCarSprayEnd = 1408; - // do { - // uiOffset = 1408 * iCarIndex; - // do { - // uiOffset += sizeof(tCarSpray); - // car_texs_loaded[uiOffset / 4 + 12] = 0; // offset into CarSpray - // } while (uiOffset != iCarSprayEnd); - // ++iCarIndex; - // iCarSprayEnd += 1408; - // } while (iCarIndex < iNumCars); - //} + // if (numcars > 0) { + // iCarSprayEnd = 1408; + // do { + // uiOffset = 1408 * iCarIndex; + // do { + // uiOffset += sizeof(tCarSpray); + // car_texs_loaded[uiOffset / 4 + 12] = 0; // offset into CarSpray + // } while (uiOffset != iCarSprayEnd); + // ++iCarIndex; + // iCarSprayEnd += 1408; + // } while (iCarIndex < iNumCars); + // } numcars = iNumCars; } diff --git a/PROJECTS/ROLLER/replay.h b/PROJECTS/ROLLER/replay.h index 822d9acb..5f8ed292 100644 --- a/PROJECTS/ROLLER/replay.h +++ b/PROJECTS/ROLLER/replay.h @@ -8,15 +8,14 @@ #include //------------------------------------------------------------------------------------------------- -#define REPLAY_SPEED_MIN -8192 -#define REPLAY_SPEED_MAX 8192 -#define REPLAY_NORMAL_SPEED 256 +#define REPLAY_SPEED_MIN -8192 +#define REPLAY_SPEED_MAX 8192 +#define REPLAY_NORMAL_SPEED 256 //------------------------------------------------------------------------------------------------- #pragma pack(push, 1) -typedef struct -{ +typedef struct { uint8 byView; uint8 byCarIdx; int iFrame; @@ -25,8 +24,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int16 nX; int16 nY; void *pFunc; @@ -35,8 +33,7 @@ typedef struct //------------------------------------------------------------------------------------------------- #pragma pack(push, 1) -typedef struct -{ +typedef struct { int iPackedPosX; int iPackedPosY; int iPackedPosZ; @@ -145,7 +142,9 @@ int compare(const void *szStr1, const void *szStr2); void warning(int iX1, int iY1, int iX2, int iY2, char *szWarning); void lsd(int iX1, int iY1, int iX2, int iY2); void scandirectory(const char *szPattern); -void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, int iTextY, const char *szText, const char *szPattern, int iFileIdx); +void fileselect(int iBoxX0, int iBoxY0, int iBoxX1, int iBoxY1, int iTextX, + int iTextY, const char *szText, const char *szPattern, + int iFileIdx); void previouscut(); void nextcut(); void loadreplay(); @@ -163,7 +162,8 @@ void rremoveview(); void rpreviouscut(); void rnextcut(); void rstartassemble(); -void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, int iY, int iScreenWidth, int byTransparentColor); +void replayicon(uint8 *pDest, tBlockHeader *pBlockHeader, int iBlockIdx, int iX, + int iY, int iScreenWidth, int byTransparentColor); void replaypanelletter(char c, int *piX, int *piY, int iScreenWidth); void replaypanelstring(const char *szStr, int iX, int iY, int iScreenWidth); void displaypaneltime(int iTime, int iX, int iY, int iScreenWidth); diff --git a/PROJECTS/ROLLER/roller.c b/PROJECTS/ROLLER/roller.c index a07951fe..1b6843f9 100644 --- a/PROJECTS/ROLLER/roller.c +++ b/PROJECTS/ROLLER/roller.c @@ -39,7 +39,7 @@ #include #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif #ifdef IS_LINUX #include @@ -48,16 +48,14 @@ #endif //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint32 uiHandle; uint64 ullTargetSDLTicksNS; uint64 ullLastSDLTicksNS; uint64 ullCurrSDLTicksNS; } tTimerData; -typedef struct -{ +typedef struct { char szPath[ROLLER_MAX_PATH]; bool bFolder; bool bDone; @@ -76,8 +74,10 @@ tJoyPos g_rollerJoyPos; SDL_JoystickID g_joyId1 = 0; SDL_JoystickID g_joyId2 = 0; bool g_bPaletteSet = false; -bool g_bForceMaxDraw = false; //TODO: figure out why this causes some flickering, also load from INI file -bool g_bAINoCheatStart = false; // Set true to not give AI cars an advantage during race start +bool g_bForceMaxDraw = false; // TODO: figure out why this causes some + // flickering, also load from INI file +bool g_bAINoCheatStart = + false; // Set true to not give AI cars an advantage during race start int g_iCurrentSong = 0; uint8 testbuf[4096]; uint64 g_ullTimer150Ms = 0; @@ -88,8 +88,7 @@ SDL_Window *ROLLERGetWindow(void) { return s_pWindow; } static MenuRenderer *s_pMenuRenderer = NULL; MenuRenderer *GetMenuRenderer(void) { return s_pMenuRenderer; } -void SnapshotEnsureMenuRenderer(void) -{ +void SnapshotEnsureMenuRenderer(void) { if (!s_pMenuRenderer) s_pMenuRenderer = menu_render_create(NULL, NULL); } @@ -98,7 +97,7 @@ static DebugOverlay *s_pDebugOverlay = NULL; DebugOverlay *ROLLERGetDebugOverlay(void) { return s_pDebugOverlay; } SDL_Mutex *g_pTimerMutex = NULL; -tTimerData timerDataAy[MAX_TIMERS] = { 0 }; +tTimerData timerDataAy[MAX_TIMERS] = {0}; static SDL_Mutex *s_pDigiMutex = NULL; // Scancode translation table (SDL scancode -> PC set1 scancode) @@ -195,9 +194,9 @@ uint8 sdl_to_set1[] = { //------------------------------------------------------------------------------------------------- static void ConvertIndexedToRGBA(const uint8 *pIndexed, const tColor *pPalette, - uint8 *pRGBA, int width, int height) -{ - if (!pIndexed || !pPalette || !pRGBA) return; + uint8 *pRGBA, int width, int height) { + if (!pIndexed || !pPalette || !pRGBA) + return; for (int i = 0; i < width * height; ++i) { const tColor *c = &pPalette[pIndexed[i]]; @@ -210,21 +209,23 @@ static void ConvertIndexedToRGBA(const uint8 *pIndexed, const tColor *pPalette, //------------------------------------------------------------------------------------------------- -void UpdateSDLWindow() -{ +void UpdateSDLWindow() { if (g_bSnapshotMode) { SnapshotPresent(); return; } - if (!g_bPaletteSet) return; + if (!g_bPaletteSet) + return; // Acquire command buffer SDL_GPUCommandBuffer *cmdBuf = SDL_AcquireGPUCommandBuffer(s_pGPUDevice); - if (!cmdBuf) return; + if (!cmdBuf) + return; // Convert indexed framebuffer directly into mapped transfer buffer - void *mapped = SDL_MapGPUTransferBuffer(s_pGPUDevice, s_pTransferBuffer, false); + void *mapped = + SDL_MapGPUTransferBuffer(s_pGPUDevice, s_pTransferBuffer, false); ConvertIndexedToRGBA(scrbuf, pal_addr, (uint8 *)mapped, winw, winh); SDL_UnmapGPUTransferBuffer(s_pGPUDevice, s_pTransferBuffer); @@ -245,8 +246,9 @@ void UpdateSDLWindow() // Acquire swapchain and blit SDL_GPUTexture *swapchainTex; Uint32 swW, swH; - if (!SDL_WaitAndAcquireGPUSwapchainTexture(cmdBuf, s_pWindow, - &swapchainTex, &swW, &swH) || !swapchainTex) { + if (!SDL_WaitAndAcquireGPUSwapchainTexture(cmdBuf, s_pWindow, &swapchainTex, + &swW, &swH) || + !swapchainTex) { SDL_CancelGPUCommandBuffer(cmdBuf); return; } @@ -286,17 +288,16 @@ void UpdateSDLWindow() //------------------------------------------------------------------------------------------------- -void ToggleFullscreen() -{ +void ToggleFullscreen() { static bool s_bIsFullscreen = false; s_bIsFullscreen = !s_bIsFullscreen; - SDL_SetWindowFullscreen(s_pWindow, s_bIsFullscreen ? SDL_WINDOW_FULLSCREEN : 0); + SDL_SetWindowFullscreen(s_pWindow, + s_bIsFullscreen ? SDL_WINDOW_FULLSCREEN : 0); } //------------------------------------------------------------------------------------------------- -int InitSDL(char *whiplash_root, const char *midi_root) -{ +int InitSDL(char *whiplash_root, const char *midi_root) { SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); Uint32 uiSdlInitFlags = SDL_INIT_VIDEO; @@ -309,7 +310,8 @@ int InitSDL(char *whiplash_root, const char *midi_root) if (strlen(whiplash_root)) { if (chdir(whiplash_root) != 0) { - ErrorBoxExit("Could not changed working directory to '%s'", whiplash_root); + ErrorBoxExit("Could not changed working directory to '%s'", + whiplash_root); return 1; } } else { @@ -336,9 +338,10 @@ int InitSDL(char *whiplash_root, const char *midi_root) return 1; } - s_pGPUDevice = SDL_CreateGPUDevice( - SDL_GPU_SHADERFORMAT_SPIRV | SDL_GPU_SHADERFORMAT_MSL | SDL_GPU_SHADERFORMAT_DXIL, - false, NULL); + s_pGPUDevice = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_SPIRV | + SDL_GPU_SHADERFORMAT_MSL | + SDL_GPU_SHADERFORMAT_DXIL, + false, NULL); if (!s_pGPUDevice) { ErrorBoxExit("Couldn't create GPU device: %s", SDL_GetError()); return 1; @@ -383,7 +386,8 @@ int InitSDL(char *whiplash_root, const char *midi_root) // Move the window to the display where the mouse is currently located float mouseX, mouseY; SDL_GetGlobalMouseState(&mouseX, &mouseY); - int displayIndex = SDL_GetDisplayForPoint(&(SDL_Point) { (int)mouseX, (int)mouseY }); + int displayIndex = + SDL_GetDisplayForPoint(&(SDL_Point){(int)mouseX, (int)mouseY}); int sdl_window_centered = SDL_WINDOWPOS_CENTERED_DISPLAY(displayIndex); SDL_SetWindowPosition(s_pWindow, sdl_window_centered, sdl_window_centered); @@ -407,9 +411,10 @@ int InitSDL(char *whiplash_root, const char *midi_root) if (midi_root) { strcpy(localMidiPath, midi_root); size_t lenMidiPath = strlen(localMidiPath); - if (lenMidiPath > 0 && (localMidiPath[lenMidiPath - 1] != '/' || localMidiPath[lenMidiPath - 1] != '\\')) { + if (lenMidiPath > 0 && (localMidiPath[lenMidiPath - 1] != '/' || + localMidiPath[lenMidiPath - 1] != '\\')) { localMidiPath[lenMidiPath] = '/'; - localMidiPath[lenMidiPath+1] = '\0'; + localMidiPath[lenMidiPath + 1] = '\0'; } } else { midi_root = SDL_GetBasePath(); @@ -422,7 +427,9 @@ int InitSDL(char *whiplash_root, const char *midi_root) strcat(localMidiPath, "midi/wildmidi.cfg"); // Initialize MIDI with WildMidi if (!MIDI_Init(localMidiPath)) { - SDL_Log("Failed to initialize WildMidi. Please check your configuration file '%s'.", localMidiPath); + SDL_Log("Failed to initialize WildMidi. Please check your configuration " + "file '%s'.", + localMidiPath); } return 0; @@ -430,8 +437,8 @@ int InitSDL(char *whiplash_root, const char *midi_root) //------------------------------------------------------------------------------------------------- -void SDLCALL FileCallback(void *pUserData, const char *const *filelist, int iFilter) -{ +void SDLCALL FileCallback(void *pUserData, const char *const *filelist, + int iFilter) { tDialogResult *pResult = (tDialogResult *)pUserData; if (!filelist || !filelist[0]) { @@ -444,16 +451,15 @@ void SDLCALL FileCallback(void *pUserData, const char *const *filelist, int iFil //------------------------------------------------------------------------------------------------- -void InitFATDATA(const char *szDataRoot) -{ +void InitFATDATA(const char *szDataRoot) { if (!szDataRoot) return; // check if data folder exists (case-insensitive for linux) if (!ROLLERdirexists("./FATDATA") && !ROLLERdirexists("./fatdata")) { SDL_MessageBoxButtonData buttons[] = { - { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "Select Image" }, - { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 1, "Cancel" }, + {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "Select Image"}, + {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 1, "Cancel"}, }; SDL_MessageBoxData msgbox = { @@ -463,19 +469,20 @@ void InitFATDATA(const char *szDataRoot) "Choose a CD image (ISO, BIN/CUE) to extract the game data:", SDL_arraysize(buttons), buttons, - NULL - }; + NULL}; int iButtonID; - tDialogResult result = { 0 }; + tDialogResult result = {0}; if (SDL_ShowMessageBox(&msgbox, &iButtonID) && iButtonID == 0) { - #ifdef IS_WINDOWS - SDL_DialogFileFilter filters[] = { { "CD Images", "iso;bin;cue" } }; - #else - SDL_DialogFileFilter filters[] = { { "CD Images", "iso;bin;cue;ISO;BIN;CUE" } }; - #endif +#ifdef IS_WINDOWS + SDL_DialogFileFilter filters[] = {{"CD Images", "iso;bin;cue"}}; +#else + SDL_DialogFileFilter filters[] = { + {"CD Images", "iso;bin;cue;ISO;BIN;CUE"}}; +#endif - SDL_ShowOpenFileDialog(FileCallback, &result, s_pWindow, filters, 1, szDataRoot, false); + SDL_ShowOpenFileDialog(FileCallback, &result, s_pWindow, filters, 1, + szDataRoot, false); SDL_Event event; while (!result.bDone) { @@ -489,17 +496,20 @@ void InitFATDATA(const char *szDataRoot) } if (!result.bCancelled) { - ExtractFATDATA(result.szPath, szDataRoot); - SaveDefaultFatalIni(szDataRoot); //save default config after extraction so all users will have svga, sfx, and music on by default + ExtractFATDATA(result.szPath, szDataRoot); + SaveDefaultFatalIni( + szDataRoot); // save default config after extraction so all users + // will have svga, sfx, and music on by default } } } - //check if extraction was successful + // check if extraction was successful if (!ROLLERdirexists("./FATDATA") && !ROLLERdirexists("./fatdata")) { - ErrorBoxExit("The folder FATDATA does not exist.\nROLLER requires the FATDATA folder assets from a retail copy of the game."); + ErrorBoxExit("The folder FATDATA does not exist.\nROLLER requires the " + "FATDATA folder assets from a retail copy of the game."); } - + // if the extracted audio tracks are present, enable CD music. FILE *pTrack = ROLLERfopen("./audio/track02.wav", "rb"); if (pTrack) { @@ -511,24 +521,24 @@ void InitFATDATA(const char *szDataRoot) //------------------------------------------------------------------------------------------------- -void InitREPLAYS(const char *szDataRoot) -{ - #ifdef IS_WINDOWS +void InitREPLAYS(const char *szDataRoot) { +#ifdef IS_WINDOWS mkdir("./REPLAYS"); - #else +#else mkdir("./REPLAYS", 0755); - #endif +#endif } //------------------------------------------------------------------------------------------------- -void ShutdownSDL() -{ +void ShutdownSDL() { if (!g_bSnapshotMode) { MIDI_Shutdown(); - if (g_pController1) SDL_CloseGamepad(g_pController1); - if (g_pController2) SDL_CloseGamepad(g_pController2); + if (g_pController1) + SDL_CloseGamepad(g_pController1); + if (g_pController2) + SDL_CloseGamepad(g_pController2); SDL_QuitSubSystem(SDL_INIT_GAMEPAD); debug_overlay_destroy(s_pDebugOverlay); @@ -554,8 +564,7 @@ void ShutdownSDL() } uint8 songId = 4; -void playMusic() -{ +void playMusic() { MIDIDigi_ClearBuffer(); MIDISetMasterVolume(127); uint8 *songBuffer; @@ -570,8 +579,7 @@ void playMusic() //------------------------------------------------------------------------------------------------- #if _DEBUG bool debugEnable = false; -void UpdateDebugLoop() -{ +void UpdateDebugLoop() { if (debugEnable) { void *front_vga_font1 = load_picture("font1.bm"); @@ -583,15 +591,15 @@ void UpdateDebugLoop() void *font_ascii = &font1_ascii; void *font_offsets = &font1_offsets; - char buffer[256] = { 0 }; - char text[32] = { 0 }; + char buffer[256] = {0}; + char text[32] = {0}; int value = 0; int font = 0; int _scr_size = scr_size; // Backup scr_size - LoadPanel(); // Load rev_vga array - scr_size = 64; // scale text size + LoadPanel(); // Load rev_vga array + scr_size = 64; // scale text size screen_pointer = scrbuf; // Set screen pointer to scrbuf strcpy(text, "Debug font ascii"); @@ -600,9 +608,12 @@ void UpdateDebugLoop() uint8 size = 24; // Font size - if (value < 0) value = 0; - if (font < 0) font = 0; - if (font > 3) font = 3; + if (value < 0) + value = 0; + if (font < 0) + font = 0; + if (font > 3) + font = 3; // Set font if (font == 0) { @@ -636,31 +647,41 @@ void UpdateDebugLoop() mini_prt_centre(rev_vga[0], "0123456789", 320, 240 - 8); prt_centrecol(rev_vga[1], "0123456789", 320, 240, color_white); scr_size = 128; // scale text size - mini_prt_centre(rev_vga[0], "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 320 / 2, (240 + 8) / 2); - prt_centrecol(rev_vga[1], "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 320 / 2, (240 + 24) / 2, color_white); + mini_prt_centre(rev_vga[0], "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 320 / 2, + (240 + 8) / 2); + prt_centrecol(rev_vga[1], "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 320 / 2, + (240 + 24) / 2, color_white); // Mini text print with config_buffer - //mini_prt_centre(rev_vga[0], &config_buffer[value * 64], 320 / 2, (240 + 40) / 2); // This fail with `-` + // mini_prt_centre(rev_vga[0], &config_buffer[value * 64], 320 / 2, (240 + + // 40) / 2); // This fail with `-` - prt_centrecol(rev_vga[1], &config_buffer[value * 64], 320 / 2, (240 + 56) / 2, color_white); + prt_centrecol(rev_vga[1], &config_buffer[value * 64], 320 / 2, + (240 + 56) / 2, color_white); scr_size = 256; // scale text size - prt_centrecol(rev_vga[1], &config_buffer[value * 64], 320 / 4, (240 + 72) / 4, color_white); - + prt_centrecol(rev_vga[1], &config_buffer[value * 64], 320 / 4, + (240 + 72) / 4, color_white); sprintf(buffer, "%s", text); - front_text((tBlockHeader *)front_vga_font, buffer, font_ascii, font_offsets, 0, size / 2, color_white, 0); + front_text((tBlockHeader *)front_vga_font, buffer, font_ascii, + font_offsets, 0, size / 2, color_white, 0); sprintf(buffer, "%i-%i", value, font); - front_text((tBlockHeader *)front_vga_font, buffer, font_ascii, font_offsets, 640 - size / 2, size / 2, color_white, 2); + front_text((tBlockHeader *)front_vga_font, buffer, font_ascii, + font_offsets, 640 - size / 2, size / 2, color_white, 2); - front_text((tBlockHeader *)front_vga_font, &config_buffer[value * 64], font_ascii, font_offsets, 0, 0 + size + size / 2, color_white, 0); + front_text((tBlockHeader *)front_vga_font, &config_buffer[value * 64], + font_ascii, font_offsets, 0, 0 + size + size / 2, color_white, + 0); for (size_t j = 0; j < 8; j++) { for (size_t i = 0; i < 32; i++) { buffer[i] = (char)(i + 32 * j); } buffer[32] = '\0'; - front_text((tBlockHeader *)front_vga_font, buffer, font_ascii, font_offsets, 640 - size / 2, size / 2 + size * ((int)j + 1), color_white, 2); + front_text((tBlockHeader *)front_vga_font, buffer, font_ascii, + font_offsets, 640 - size / 2, size / 2 + size * ((int)j + 1), + color_white, 2); } SDL_Event e; @@ -708,8 +729,7 @@ void UpdateDebugLoop() #endif //------------------------------------------------------------------------------------------------- -void UpdateSDL() -{ +void UpdateSDL() { SDL_Event e; while (SDL_PollEvent(&e)) { UpdateSDLAudioEvents(e); @@ -728,7 +748,8 @@ void UpdateSDL() #if _DEBUG if (e.key.key == SDLK_D) { // Add by ROLLER if (SDL_GetModState() & (SDL_KMOD_LCTRL | SDL_KMOD_RCTRL)) { - if (front_vga[2] != NULL) { // Check if front_vga is loaded, loaded in main menu. + if (front_vga[2] != + NULL) { // Check if front_vga is loaded, loaded in main menu. debugEnable = !debugEnable; continue; } @@ -736,19 +757,20 @@ void UpdateSDL() } #endif // _DEBUG - //if (e.key.key == SDLK_ESCAPE) { - // quit_game = 1; - //} else if (e.key.key == SDLK_F11) { - // ToggleFullscreen(); - // continue; + // if (e.key.key == SDLK_ESCAPE) { + // quit_game = 1; + // } else if (e.key.key == SDLK_F11) { + // ToggleFullscreen(); + // continue; if (e.key.key == SDLK_F10) { if (frontend_on) { MenuRenderer *mr = GetMenuRenderer(); MenuRenderMode mode = menu_render_get_mode(mr); menu_render_set_mode(mr, mode == MENU_RENDER_GPU - ? MENU_RENDER_SOFTWARE : MENU_RENDER_GPU); + ? MENU_RENDER_SOFTWARE + : MENU_RENDER_GPU); SDL_Log("Menu render mode: %s", - mode == MENU_RENDER_GPU ? "software" : "GPU"); + mode == MENU_RENDER_GPU ? "software" : "GPU"); } continue; } else if (e.key.key == SDLK_RETURN) { @@ -781,7 +803,7 @@ void UpdateSDL() if (sc < SDL_arraysize(sdl_to_set1) && sdl_to_set1[sc]) { uint8 byRawCode = sdl_to_set1[sc]; if (e.type == SDL_EVENT_KEY_UP) { - byRawCode |= 0x80; // Set high bit for release + byRawCode |= 0x80; // Set high bit for release } key_handler(byRawCode); } @@ -825,10 +847,10 @@ void UpdateSDL() } } } - //UpdateSDLWindow(); + // UpdateSDLWindow(); #if _DEBUG UpdateDebugLoop(); // Add by ROLLER -#endif // _DEBUG +#endif // _DEBUG uint64 ullCurTicksMs = SDL_GetTicks(); if (ullCurTicksMs > g_ullTimer150Ms) { g_ullTimer150Ms = ullCurTicksMs + 150; @@ -844,12 +866,13 @@ SDL_AudioStream *midi_stream; float midi_volume; midi *midi_music; -void MIDI_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount) -{ - //int available = SDL_GetAudioStreamAvailable(stream); - //SDL_Log("MIDI_AudioStreamCallback[%i]: %i - %i", available, additional_amount, total_amount); +void MIDI_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, + int additional_amount, int total_amount) { + // int available = SDL_GetAudioStreamAvailable(stream); + // SDL_Log("MIDI_AudioStreamCallback[%i]: %i - %i", available, + // additional_amount, total_amount); - //if (available != 0) return; + // if (available != 0) return; if (midi_music) { void *output_buffer; @@ -868,13 +891,10 @@ void MIDI_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int addit } } -bool MIDI_Init(const char *config_file) -{ +bool MIDI_Init(const char *config_file) { long version = WildMidi_GetVersion(); SDL_Log("MIDI_Init: Initializing libWildMidi %ld.%ld.%ld", - (version >> 16) & 255, - (version >> 8) & 255, - (version) & 255); + (version >> 16) & 255, (version >> 8) & 255, (version) & 255); uint16_t rate = MIDI_RATE; uint16_t mixer_options = 0; @@ -890,15 +910,17 @@ bool MIDI_Init(const char *config_file) wav_spec.freq = MIDI_RATE; wav_spec.format = SDL_AUDIO_S16; - midi_stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wav_spec, MIDI_AudioStreamCallback, NULL); + midi_stream = + SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wav_spec, + MIDI_AudioStreamCallback, NULL); midi_volume = 1.0f; // Default volume return true; } -void MIDIDigi_PlayBuffer(uint8 *midi_buffer, uint32 midi_length) -{ - if (g_bSnapshotMode) return; +void MIDIDigi_PlayBuffer(uint8 *midi_buffer, uint32 midi_length) { + if (g_bSnapshotMode) + return; midi *midi_ptr = WildMidi_OpenBuffer(midi_buffer, midi_length); if (!midi_ptr) { SDL_Log("WildMidi_OpenBuffer failed: %s", WildMidi_GetError()); @@ -914,21 +936,28 @@ void MIDIDigi_PlayBuffer(uint8 *midi_buffer, uint32 midi_length) if (wm_info) { int apr_mins = wm_info->approx_total_samples / (MIDI_RATE * 60); - int apr_secs = (wm_info->approx_total_samples % (MIDI_RATE * 60)) / MIDI_RATE; + int apr_secs = + (wm_info->approx_total_samples % (MIDI_RATE * 60)) / MIDI_RATE; - SDL_Log("MIDIDigi_PlayBuffer: [Approx %2um %2us Total]", apr_mins, apr_secs); + SDL_Log("MIDIDigi_PlayBuffer: [Approx %2um %2us Total]", apr_mins, + apr_secs); - SDL_Log("MIDIDigi_PlayBuffer: Total Samples %i", wm_info->approx_total_samples); + SDL_Log("MIDIDigi_PlayBuffer: Total Samples %i", + wm_info->approx_total_samples); SDL_Log("MIDIDigi_PlayBuffer: Current Samples %i", wm_info->current_sample); - SDL_Log("MIDIDigi_PlayBuffer: Total Midi time %i", wm_info->total_midi_time); + SDL_Log("MIDIDigi_PlayBuffer: Total Midi time %i", + wm_info->total_midi_time); SDL_Log("MIDIDigi_PlayBuffer: Mix Options %i", wm_info->mixer_options); } SDL_AudioStream *stream = midi_stream; if (stream != NULL) { - float master_volume = (float)MIDIGetMasterVolume() / 127.0f; // Normalize to [0.0, 1.0] range - SDL_SetAudioStreamGain(stream, midi_volume * master_volume); // Set the gain for the audio stream + float master_volume = + (float)MIDIGetMasterVolume() / 127.0f; // Normalize to [0.0, 1.0] range + SDL_SetAudioStreamGain( + stream, + midi_volume * master_volume); // Set the gain for the audio stream SDL_Log("MIDIDigi_PlayBuffer: Volume: %f", midi_volume * master_volume); void *output_buffer; @@ -946,7 +975,8 @@ void MIDIDigi_PlayBuffer(uint8 *midi_buffer, uint32 midi_length) SDL_PutAudioStreamData(stream, output_buffer, res); total_pcm_bytes += res; if (total_pcm_bytes > 64e6) { - SDL_Log("MIDIDigi_PlayBuffer: Stopping put audio stream due to large buffer size."); + SDL_Log("MIDIDigi_PlayBuffer: Stopping put audio stream due to large " + "buffer size."); break; } } @@ -961,8 +991,7 @@ void MIDIDigi_PlayBuffer(uint8 *midi_buffer, uint32 midi_length) WildMidi_Close(midi_ptr); } -void MIDIDigi_ClearBuffer() -{ +void MIDIDigi_ClearBuffer() { if (midi_stream) { SDL_PauseAudioStreamDevice(midi_stream); SDL_ClearAudioStream(midi_stream); @@ -970,8 +999,7 @@ void MIDIDigi_ClearBuffer() MIDI_CloseMidiBuffer(); } -void MIDI_Shutdown() -{ +void MIDI_Shutdown() { if (midi_stream) { SDL_PauseAudioStreamDevice(midi_stream); SDL_DestroyAudioStream(midi_stream); @@ -984,8 +1012,7 @@ void MIDI_Shutdown() /// /// Close midi buffer /// -void MIDI_CloseMidiBuffer() -{ +void MIDI_CloseMidiBuffer() { if (midi_music) { WildMidi_Close(midi_music); midi_music = NULL; @@ -995,25 +1022,28 @@ void MIDI_CloseMidiBuffer() /// /// Initializes the MIDI audio stream if it hasn't been initialized yet. /// -void MIDIInitStream() -{ +void MIDIInitStream() { if (!midi_stream) { SDL_Log("MIDIInitStream: initialize 'midi_stream'."); SDL_AudioSpec wav_spec; wav_spec.channels = 2; wav_spec.freq = MIDI_RATE; wav_spec.format = SDL_AUDIO_S16; - midi_stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wav_spec, MIDI_AudioStreamCallback, NULL); + midi_stream = + SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wav_spec, + MIDI_AudioStreamCallback, NULL); } // Set Volume Stream - float master_volume = (float)MIDIGetMasterVolume() / 127.0f; // Normalize to [0.0, 1.0] range - SDL_SetAudioStreamGain(midi_stream, midi_volume * master_volume); // Set the gain for the audio stream + float master_volume = + (float)MIDIGetMasterVolume() / 127.0f; // Normalize to [0.0, 1.0] range + SDL_SetAudioStreamGain( + midi_stream, + midi_volume * master_volume); // Set the gain for the audio stream SDL_Log("MIDIInitSong: Volume: %f", midi_volume * master_volume); } -void MIDIClearStream() -{ +void MIDIClearStream() { if (midi_stream) { SDL_PauseAudioStreamDevice(midi_stream); SDL_ClearAudioStream(midi_stream); @@ -1023,13 +1053,15 @@ void MIDIClearStream() /// /// Initializes a MIDI song for playback using the provided song data. -/// This function closes any currently loaded MIDI song, opens the new song buffer, -/// enables looping, logs song information, and sets the audio stream volume. +/// This function closes any currently loaded MIDI song, opens the new song +/// buffer, enables looping, logs song information, and sets the audio stream +/// volume. /// -/// Pointer to a tInitSong structure containing the MIDI song data and its length. -void MIDIInitSong(tInitSong *data) -{ - if (g_bSnapshotMode) return; +/// Pointer to a tInitSong structure containing the MIDI song +/// data and its length. +void MIDIInitSong(tInitSong *data) { + if (g_bSnapshotMode) + return; MIDIStopSong(); SDL_Log("MIDIInitSong: Midi - Length: %i", data->iLength); @@ -1038,7 +1070,8 @@ void MIDIInitSong(tInitSong *data) midi_music = WildMidi_OpenBuffer(((uint8 *)data->pData), data->iLength); if (!midi_music) { - SDL_Log("MIDIInitSong: WildMidi_OpenBuffer failed: %s", WildMidi_GetError()); + SDL_Log("MIDIInitSong: WildMidi_OpenBuffer failed: %s", + WildMidi_GetError()); return; } // Enable WildMidi_GetOutput Loop @@ -1049,7 +1082,8 @@ void MIDIInitSong(tInitSong *data) if (wm_info) { int apr_mins = wm_info->approx_total_samples / (MIDI_RATE * 60); - int apr_secs = (wm_info->approx_total_samples % (MIDI_RATE * 60)) / MIDI_RATE; + int apr_secs = + (wm_info->approx_total_samples % (MIDI_RATE * 60)) / MIDI_RATE; SDL_Log("MIDIInitSong: Approx %2um %2us Total", apr_mins, apr_secs); @@ -1062,8 +1096,7 @@ void MIDIInitSong(tInitSong *data) MIDIInitStream(); } -void MIDIStartSong() -{ +void MIDIStartSong() { if (!midi_stream) { SDL_Log("MIDIStartSong: 'midi_stream' is not initialized."); return; @@ -1073,8 +1106,7 @@ void MIDIStartSong() SDL_ResumeAudioStreamDevice(midi_stream); } -void MIDIStopSong() -{ +void MIDIStopSong() { if (!midi_stream) { SDL_Log("MIDIStopSong: 'midi_stream' is not initialized."); return; @@ -1088,10 +1120,11 @@ int8 MIDIMasterVolume = 127; // Default master volume (0-127) /// /// Set the master volume for MIDI playback. (0-127) /// -void MIDISetMasterVolume(int8 volume) -{ - if (volume > 127) volume = 127; - if (volume < 0) volume = 0; +void MIDISetMasterVolume(int8 volume) { + if (volume > 127) + volume = 127; + if (volume < 0) + volume = 0; MIDIMasterVolume = volume; float master_volume = (float)volume / 127.0f; // Normalize to [0.0, 1.0] range @@ -1103,10 +1136,7 @@ void MIDISetMasterVolume(int8 volume) /// /// Get the current master volume level for MIDI playback. (0-127) /// -int MIDIGetMasterVolume() -{ - return MIDIMasterVolume; -} +int MIDIGetMasterVolume() { return MIDIMasterVolume; } #pragma endregion //------------------------------------------------------------------------------------------------- @@ -1114,40 +1144,45 @@ int MIDIGetMasterVolume() #define NUM_DIGI_STREAMS 32 SDL_AudioStream *digi_stream[NUM_DIGI_STREAMS]; float digi_volume[NUM_DIGI_STREAMS]; -float digi_pan[NUM_DIGI_STREAMS]; // -1.0 (full left) to 1.0 (full right), 0.0 = center +float digi_pan[NUM_DIGI_STREAMS]; // -1.0 (full left) to 1.0 (full right), 0.0 = + // center int digi_generation[NUM_DIGI_STREAMS]; tSampleData digi_sample_data[NUM_DIGI_STREAMS]; -static void DIGILock(void) -{ +static void DIGILock(void) { if (s_pDigiMutex) SDL_LockMutex(s_pDigiMutex); } -static void DIGIUnlock(void) -{ +static void DIGIUnlock(void) { if (s_pDigiMutex) SDL_UnlockMutex(s_pDigiMutex); } -// Convert mono U8 to stereo U8 with panning applied. out must be in_length * 2 bytes. -static void mono_to_stereo_pan_u8(const Uint8 *in, int in_length, Uint8 *out, float pan) -{ - float left_gain = (pan <= 0.0f) ? 1.0f : 1.0f - pan; +// Convert mono U8 to stereo U8 with panning applied. out must be in_length * 2 +// bytes. +static void mono_to_stereo_pan_u8(const Uint8 *in, int in_length, Uint8 *out, + float pan) { + float left_gain = (pan <= 0.0f) ? 1.0f : 1.0f - pan; float right_gain = (pan >= 0.0f) ? 1.0f : 1.0f + pan; for (int i = 0; i < in_length; i++) { int s = (int)in[i] - 128; int l = (int)(s * left_gain); int r = (int)(s * right_gain); - if (l > 127) l = 127; if (l < -128) l = -128; - if (r > 127) r = 127; if (r < -128) r = -128; - out[2 * i] = (Uint8)(l + 128); + if (l > 127) + l = 127; + if (l < -128) + l = -128; + if (r > 127) + r = 127; + if (r < -128) + r = -128; + out[2 * i] = (Uint8)(l + 128); out[2 * i + 1] = (Uint8)(r + 128); } } -static int DIGISampleAvailableUnlocked(int iHandle) -{ +static int DIGISampleAvailableUnlocked(int iHandle) { if (iHandle < 0 || iHandle >= NUM_DIGI_STREAMS) return 0; if (digi_stream[iHandle]) @@ -1155,8 +1190,7 @@ static int DIGISampleAvailableUnlocked(int iHandle) return 0; } -static bool DIGISampleDoneUnlocked(int iHandle) -{ +static bool DIGISampleDoneUnlocked(int iHandle) { if (iHandle < 0 || iHandle >= NUM_DIGI_STREAMS) return true; if (!digi_stream[iHandle]) @@ -1166,8 +1200,8 @@ static bool DIGISampleDoneUnlocked(int iHandle) return DIGISampleAvailableUnlocked(iHandle) == 0; } -void DIGI_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int additional_amount, int total_amount) -{ +void DIGI_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, + int additional_amount, int total_amount) { tSampleData *data = (tSampleData *)userdata; if (!data || !data->pSample || additional_amount <= 0) return; @@ -1175,15 +1209,17 @@ void DIGI_AudioStreamCallback(void *userdata, SDL_AudioStream *stream, int addit float pan = (index >= 0 && index < NUM_DIGI_STREAMS) ? digi_pan[index] : 0.0f; int stereo_len = data->iLength * 2; Uint8 *stereo_buf = (Uint8 *)SDL_malloc(stereo_len); - if (!stereo_buf) return; - mono_to_stereo_pan_u8((const Uint8 *)data->pSample, data->iLength, stereo_buf, pan); + if (!stereo_buf) + return; + mono_to_stereo_pan_u8((const Uint8 *)data->pSample, data->iLength, stereo_buf, + pan); SDL_PutAudioStreamData(stream, stereo_buf, stereo_len); SDL_free(stereo_buf); } -int DIGISampleStart(tSampleData *data) -{ - if (g_bSnapshotMode) return -1; +int DIGISampleStart(tSampleData *data) { + if (g_bSnapshotMode) + return -1; DIGILock(); int index = -1; @@ -1194,17 +1230,19 @@ int DIGISampleStart(tSampleData *data) } } if (index < 0) { - //SDL_Log("DIGISampleStart: No available audio stream slots for digital sample."); + // SDL_Log("DIGISampleStart: No available audio stream slots for digital + // sample."); DIGIUnlock(); return index; // No available stream slots } - float volume = (float)data->iVolume / 0x7FFF; // Convert volume to [0.0, 1.0] range + float volume = + (float)data->iVolume / 0x7FFF; // Convert volume to [0.0, 1.0] range int iFlags = data->iFlags; int iPan = data->iPan; if (digi_stream[index]) { - //audio stream is available but needs to be destroyed + // audio stream is available but needs to be destroyed SDL_PauseAudioStreamDevice(digi_stream[index]); SDL_DestroyAudioStream(digi_stream[index]); digi_stream[index] = NULL; @@ -1214,51 +1252,60 @@ int DIGISampleStart(tSampleData *data) // Compute initial pan: raw iPan [0, 0x10000], 0x8000 = center → [-1.0, 1.0] float fInitialPan = ((float)((int32)iPan) / (int32)0x8000) - 1.0f; - if (fInitialPan < -1.0f) fInitialPan = -1.0f; - if (fInitialPan > 1.0f) fInitialPan = 1.0f; + if (fInitialPan < -1.0f) + fInitialPan = -1.0f; + if (fInitialPan > 1.0f) + fInitialPan = 1.0f; digi_pan[index] = fInitialPan; if (!digi_stream[index]) { SDL_AudioSpec spec; - spec.channels = 2; // Stereo (panning applied manually per-sample) - spec.freq = 11025; // Sample rate + spec.channels = 2; // Stereo (panning applied manually per-sample) + spec.freq = 11025; // Sample rate spec.format = SDL_AUDIO_U8; // 8-bit unsigned audio - if (iFlags != 18176) //one of these means loop the audio - digi_stream[index] = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, NULL, NULL); + if (iFlags != 18176) // one of these means loop the audio + digi_stream[index] = SDL_OpenAudioDeviceStream( + SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, NULL, NULL); else { - //need to copy what's in SampleData first + // need to copy what's in SampleData first digi_sample_data[index].pSample = data->pSample; digi_sample_data[index].iLength = data->iLength; digi_sample_data[index].iSampleIndex = data->iSampleIndex; - digi_stream[index] = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, DIGI_AudioStreamCallback, &digi_sample_data[index]); + digi_stream[index] = SDL_OpenAudioDeviceStream( + SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, DIGI_AudioStreamCallback, + &digi_sample_data[index]); } } else { - assert(0); //should never happen + assert(0); // should never happen } if (!digi_stream[index]) { - //SDL_Log("DIGISampleStart: Couldn't create audio stream: %s", SDL_GetError()); + // SDL_Log("DIGISampleStart: Couldn't create audio stream: %s", + // SDL_GetError()); DIGIUnlock(); return -1; } // Set pitch in the stream SDL_SetAudioStreamFrequencyRatio(digi_stream[index], 1.0); // pitch - SDL_SetAudioStreamFrequencyRatio(digi_stream[index], (float)data->iPitch / 0x10000); + SDL_SetAudioStreamFrequencyRatio(digi_stream[index], + (float)data->iPitch / 0x10000); // Remember the volume for this stream digi_volume[index] = volume; // Set the gain for the audio stream - float master_volume = (float)DIGIGetMasterVolume() / 0x7FFF; // Normalize to [0.0, 1.0] range + float master_volume = + (float)DIGIGetMasterVolume() / 0x7FFF; // Normalize to [0.0, 1.0] range SDL_SetAudioStreamGain(digi_stream[index], volume * master_volume); // Convert mono to stereo with pan applied and push to stream int stereo_len = data->iLength * 2; Uint8 *stereo_buf = (Uint8 *)SDL_malloc(stereo_len); if (stereo_buf) { - mono_to_stereo_pan_u8((const Uint8 *)data->pSample, data->iLength, stereo_buf, fInitialPan); + mono_to_stereo_pan_u8((const Uint8 *)data->pSample, data->iLength, + stereo_buf, fInitialPan); SDL_PutAudioStreamData(digi_stream[index], stereo_buf, stereo_len); SDL_free(stereo_buf); } @@ -1272,24 +1319,21 @@ int DIGISampleStart(tSampleData *data) /// Check if a digital sample is done playing. /// /// -bool DIGISampleDone(int index) -{ +bool DIGISampleDone(int index) { DIGILock(); bool bDone = DIGISampleDoneUnlocked(index); DIGIUnlock(); return bDone; } -int DIGISampleAvailable(int index) -{ +int DIGISampleAvailable(int index) { DIGILock(); int iAvailable = DIGISampleAvailableUnlocked(index); DIGIUnlock(); return iAvailable; } -int DIGISampleGeneration(int index) -{ +int DIGISampleGeneration(int index) { if (index < 0 || index >= NUM_DIGI_STREAMS) return -1; @@ -1304,18 +1348,21 @@ int DIGIMasterVolume = 0x7FFF; // Default master volume (0-0x7FFF) /// Set the master volume for all digital audio streams. /// /// Volume level (0-0x7FFF). -void DIGISetMasterVolume(int volume) -{ - if (volume > 0x7FFF) volume = 0x7FFF; - if (volume < 0) volume = 0; +void DIGISetMasterVolume(int volume) { + if (volume > 0x7FFF) + volume = 0x7FFF; + if (volume < 0) + volume = 0; DIGIMasterVolume = volume; - - float normalized_volume = (float)volume / 0x7FFF; // Normalize to [0.0, 1.0] range + + float normalized_volume = + (float)volume / 0x7FFF; // Normalize to [0.0, 1.0] range DIGILock(); for (size_t i = 0; i < NUM_DIGI_STREAMS; i++) { if (digi_stream[i]) { - SDL_SetAudioStreamGain(digi_stream[i], digi_volume[i] * normalized_volume); + SDL_SetAudioStreamGain(digi_stream[i], + digi_volume[i] * normalized_volume); } } DIGIUnlock(); @@ -1325,13 +1372,9 @@ void DIGISetMasterVolume(int volume) /// Get the current master volume level. /// /// The master volume level (0-0x7FFF). -int DIGIGetMasterVolume() -{ - return DIGIMasterVolume; -} +int DIGIGetMasterVolume() { return DIGIMasterVolume; } -void DIGIStopSample(int index) -{ +void DIGIStopSample(int index) { if (index < 0 || index >= NUM_DIGI_STREAMS) { SDL_Log("DIGIStopSample: Invalid stream index: %d", index); return; @@ -1348,8 +1391,7 @@ void DIGIStopSample(int index) DIGIUnlock(); } -void DIGIClearAllStream() -{ +void DIGIClearAllStream() { DIGILock(); for (int i = 0; i < NUM_DIGI_STREAMS; i++) { if (digi_stream[i]) { @@ -1364,45 +1406,45 @@ void DIGIClearAllStream() DIGIUnlock(); } -void PlayAudioSampleWait(int iIndex) -{ - if (iIndex >= 120) return; +void PlayAudioSampleWait(int iIndex) { + if (iIndex >= 120) + return; SDL_Log("Play Sample[%i]: %s", iIndex, Sample[iIndex]); loadasample(iIndex); PlayAudioDataWait(SamplePtr[iIndex], SampleLen[iIndex]); } -void DIGISetSampleVolume(int iHandle, int iVolume) -{ +void DIGISetSampleVolume(int iHandle, int iVolume) { if (iHandle < 0 || iHandle >= NUM_DIGI_STREAMS) return; DIGILock(); if (!digi_stream[iHandle]) { DIGIUnlock(); - return; //DIGI stream not found + return; // DIGI stream not found } - float fStreamVolume = (float)iVolume / 0x7FFF; // Convert volume to [0.0, 1.0] range + float fStreamVolume = + (float)iVolume / 0x7FFF; // Convert volume to [0.0, 1.0] range // udpate saved volume digi_volume[iHandle] = fStreamVolume; // Set the gain for the audio stream - float fMasterVolume = (float)DIGIGetMasterVolume() / 0x7FFF; // Normalize to [0.0, 1.0] range + float fMasterVolume = + (float)DIGIGetMasterVolume() / 0x7FFF; // Normalize to [0.0, 1.0] range SDL_SetAudioStreamGain(digi_stream[iHandle], fStreamVolume * fMasterVolume); DIGIUnlock(); } -void DIGISetPitch(int iHandle, int iPitch) -{ +void DIGISetPitch(int iHandle, int iPitch) { if (iHandle < 0 || iHandle >= NUM_DIGI_STREAMS) return; DIGILock(); if (!digi_stream[iHandle]) { DIGIUnlock(); - return; //DIGI stream not found + return; // DIGI stream not found } float fStreamPitch = (float)iPitch / 0x10000; @@ -1410,8 +1452,7 @@ void DIGISetPitch(int iHandle, int iPitch) DIGIUnlock(); } -void DIGISetPanLocation(int iHandle, int iPan) -{ +void DIGISetPanLocation(int iHandle, int iPan) { if (iHandle < 0 || iHandle >= NUM_DIGI_STREAMS) return; DIGILock(); @@ -1420,8 +1461,10 @@ void DIGISetPanLocation(int iHandle, int iPan) return; } float fNewPan = ((float)((int32)iPan) / (int32)0x8000) - 1.0f; - if (fNewPan < -1.0f) fNewPan = -1.0f; - if (fNewPan > 1.0f) fNewPan = 1.0f; + if (fNewPan < -1.0f) + fNewPan = -1.0f; + if (fNewPan > 1.0f) + fNewPan = 1.0f; digi_pan[iHandle] = fNewPan; // For looping samples (callback-driven), flush queued audio so the new pan // takes effect immediately rather than after the current loop finishes. @@ -1431,7 +1474,8 @@ void DIGISetPanLocation(int iHandle, int iPan) int stereo_len = data->iLength * 2; Uint8 *stereo_buf = (Uint8 *)SDL_malloc(stereo_len); if (stereo_buf) { - mono_to_stereo_pan_u8((const Uint8 *)data->pSample, data->iLength, stereo_buf, fNewPan); + mono_to_stereo_pan_u8((const Uint8 *)data->pSample, data->iLength, + stereo_buf, fNewPan); SDL_PutAudioStreamData(digi_stream[iHandle], stereo_buf, stereo_len); SDL_free(stereo_buf); } @@ -1439,15 +1483,15 @@ void DIGISetPanLocation(int iHandle, int iPan) DIGIUnlock(); } -void PlayAudioDataWait(Uint8 *buffer, Uint32 length) -{ +void PlayAudioDataWait(Uint8 *buffer, Uint32 length) { // https://wiki.libsdl.org/SDL3/QuickReference SDL_AudioSpec wav_spec; - wav_spec.channels = 1; // Stereo - wav_spec.freq = 11025; // Sample rate + wav_spec.channels = 1; // Stereo + wav_spec.freq = 11025; // Sample rate wav_spec.format = SDL_AUDIO_U8; // 8-bit unsigned audio - SDL_AudioStream *stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wav_spec, NULL, NULL); + SDL_AudioStream *stream = SDL_OpenAudioDeviceStream( + SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &wav_spec, NULL, NULL); if (!stream) { SDL_Log("Couldn't create audio stream: %s", SDL_GetError()); return; @@ -1471,8 +1515,7 @@ void PlayAudioDataWait(Uint8 *buffer, Uint32 length) /// Handle SDL audio device events for MIDI and digital audio streams. /// /// -void UpdateSDLAudioEvents(SDL_Event e) -{ +void UpdateSDLAudioEvents(SDL_Event e) { if (e.type == SDL_EVENT_AUDIO_DEVICE_REMOVED) { SDL_AudioDeviceEvent *ade = (SDL_AudioDeviceEvent *)&e; SDL_Log("UpdateSDLAudioEvents: Audio device removed: %d", ade->which); @@ -1491,28 +1534,30 @@ void UpdateSDLAudioEvents(SDL_Event e) //------------------------------------------------------------------------------------------------- #ifndef IS_WINDOWS -static int s_findpath_append(char *szPath, int iCurLen, int iMaxLen, const char *szComp) -{ +static int s_findpath_append(char *szPath, int iCurLen, int iMaxLen, + const char *szComp) { int iCompLen = (int)strlen(szComp); if (iCurLen == 0) { - if (iCompLen >= iMaxLen) return -1; + if (iCompLen >= iMaxLen) + return -1; memcpy(szPath, szComp, iCompLen + 1); return iCompLen; } if (iCurLen == 1 && szPath[0] == '/') { - if (1 + iCompLen >= iMaxLen) return -1; + if (1 + iCompLen >= iMaxLen) + return -1; memcpy(szPath + 1, szComp, iCompLen + 1); return 1 + iCompLen; } - if (iCurLen + 1 + iCompLen >= iMaxLen) return -1; + if (iCurLen + 1 + iCompLen >= iMaxLen) + return -1; szPath[iCurLen] = '/'; memcpy(szPath + iCurLen + 1, szComp, iCompLen + 1); return iCurLen + 1 + iCompLen; } #endif -const char *ROLLERfindpath(const char *szFile) -{ +const char *ROLLERfindpath(const char *szFile) { #ifdef IS_WINDOWS return szFile; #else @@ -1532,7 +1577,8 @@ const char *ROLLERfindpath(const char *szFile) char *pSave = NULL; char *pToken = strtok_r(szInput, "/", &pSave); - if (!pToken) return NULL; + if (!pToken) + return NULL; while (pToken) { const char *szScanDir = (iResolvedLen == 0) ? "." : szResolved; @@ -1544,20 +1590,25 @@ const char *ROLLERfindpath(const char *szFile) else if (iResolvedLen == 1 && szResolved[0] == '/') iExactLen = snprintf(szExact, sizeof(szExact), "/%s", pToken); else - iExactLen = snprintf(szExact, sizeof(szExact), "%s/%s", szResolved, pToken); + iExactLen = + snprintf(szExact, sizeof(szExact), "%s/%s", szResolved, pToken); struct stat sb; - if (iExactLen > 0 && iExactLen < (int)sizeof(szExact) && stat(szExact, &sb) == 0) { - iResolvedLen = s_findpath_append(szResolved, iResolvedLen, sizeof(szResolved), pToken); - if (iResolvedLen < 0) return NULL; + if (iExactLen > 0 && iExactLen < (int)sizeof(szExact) && + stat(szExact, &sb) == 0) { + iResolvedLen = s_findpath_append(szResolved, iResolvedLen, + sizeof(szResolved), pToken); + if (iResolvedLen < 0) + return NULL; pToken = strtok_r(NULL, "/", &pSave); continue; } DIR *pDir = opendir(szScanDir); - if (!pDir) return NULL; + if (!pDir) + return NULL; - char szFound[256] = { 0 }; + char szFound[256] = {0}; struct dirent *pEntry; while ((pEntry = readdir(pDir)) != NULL) { if (strcasecmp(pEntry->d_name, pToken) == 0) { @@ -1567,10 +1618,13 @@ const char *ROLLERfindpath(const char *szFile) } closedir(pDir); - if (szFound[0] == '\0') return NULL; + if (szFound[0] == '\0') + return NULL; - iResolvedLen = s_findpath_append(szResolved, iResolvedLen, sizeof(szResolved), szFound); - if (iResolvedLen < 0) return NULL; + iResolvedLen = s_findpath_append(szResolved, iResolvedLen, + sizeof(szResolved), szFound); + if (iResolvedLen < 0) + return NULL; pToken = strtok_r(NULL, "/", &pSave); } @@ -1581,8 +1635,7 @@ const char *ROLLERfindpath(const char *szFile) //------------------------------------------------------------------------------------------------- -bool ROLLERfexists(const char *szFile) -{ +bool ROLLERfexists(const char *szFile) { FILE *pFile = fopen(szFile, "r"); if (pFile) { fclose(pFile); @@ -1590,8 +1643,8 @@ bool ROLLERfexists(const char *szFile) } #ifdef IS_WINDOWS - char szUpper[260] = { 0 }; - char szLower[260] = { 0 }; + char szUpper[260] = {0}; + char szLower[260] = {0}; int iLength = (int)strlen(szFile); for (int i = 0; i < iLength && i < (int)sizeof(szUpper); ++i) { @@ -1614,7 +1667,10 @@ bool ROLLERfexists(const char *szFile) const char *szResolved = ROLLERfindpath(szFile); if (szResolved) { pFile = fopen(szResolved, "r"); - if (pFile) { fclose(pFile); return true; } + if (pFile) { + fclose(pFile); + return true; + } } #endif @@ -1623,16 +1679,15 @@ bool ROLLERfexists(const char *szFile) //------------------------------------------------------------------------------------------------- -bool ROLLERdirexists(const char *szDir) -{ +bool ROLLERdirexists(const char *szDir) { struct stat sb; if (stat(szDir, &sb) == 0 && S_ISDIR(sb.st_mode)) { return true; } #ifdef IS_WINDOWS - char szUpper[260] = { 0 }; - char szLower[260] = { 0 }; + char szUpper[260] = {0}; + char szLower[260] = {0}; int iLength = (int)strlen(szDir); for (int i = 0; i < iLength && i < (int)sizeof(szUpper); ++i) { @@ -1659,14 +1714,14 @@ bool ROLLERdirexists(const char *szDir) //------------------------------------------------------------------------------------------------- -FILE *ROLLERfopen(const char *szFile, const char *szMode) -{ +FILE *ROLLERfopen(const char *szFile, const char *szMode) { FILE *pFile = fopen(szFile, szMode); - if (pFile) return pFile; + if (pFile) + return pFile; #ifdef IS_WINDOWS - char szUpper[260] = { 0 }; - char szLower[260] = { 0 }; + char szUpper[260] = {0}; + char szLower[260] = {0}; int iLength = (int)strlen(szFile); for (int i = 0; i < iLength && i < (int)sizeof(szUpper); ++i) { @@ -1675,27 +1730,29 @@ FILE *ROLLERfopen(const char *szFile, const char *szMode) } pFile = fopen(szUpper, szMode); - if (pFile) return pFile; + if (pFile) + return pFile; pFile = fopen(szLower, szMode); return pFile; #else const char *szResolved = ROLLERfindpath(szFile); - if (szResolved) return fopen(szResolved, szMode); + if (szResolved) + return fopen(szResolved, szMode); return NULL; #endif } //------------------------------------------------------------------------------------------------- -int ROLLERopen(const char *szFile, int iOpenFlags) -{ +int ROLLERopen(const char *szFile, int iOpenFlags) { int iHandle = open(szFile, iOpenFlags); - if (iHandle != -1) return iHandle; + if (iHandle != -1) + return iHandle; #ifdef IS_WINDOWS - char szUpper[260] = { 0 }; - char szLower[260] = { 0 }; + char szUpper[260] = {0}; + char szLower[260] = {0}; int iLength = (int)strlen(szFile); for (int i = 0; i < iLength && i < (int)sizeof(szUpper); ++i) { @@ -1704,27 +1761,29 @@ int ROLLERopen(const char *szFile, int iOpenFlags) } iHandle = open(szUpper, iOpenFlags); - if (iHandle != -1) return iHandle; + if (iHandle != -1) + return iHandle; iHandle = open(szLower, iOpenFlags); return iHandle; #else const char *szResolved = ROLLERfindpath(szFile); - if (szResolved) return open(szResolved, iOpenFlags); + if (szResolved) + return open(szResolved, iOpenFlags); return -1; #endif } //------------------------------------------------------------------------------------------------- -int ROLLERremove(const char *szFile) -{ +int ROLLERremove(const char *szFile) { int iSuccess = remove(szFile); - if (iSuccess == 0) return 0; + if (iSuccess == 0) + return 0; #ifdef IS_WINDOWS - char szUpper[260] = { 0 }; - char szLower[260] = { 0 }; + char szUpper[260] = {0}; + char szLower[260] = {0}; int iLength = (int)strlen(szFile); for (int i = 0; i < iLength && i < (int)sizeof(szUpper); ++i) { @@ -1733,27 +1792,29 @@ int ROLLERremove(const char *szFile) } iSuccess = remove(szUpper); - if (iSuccess == 0) return 0; + if (iSuccess == 0) + return 0; iSuccess = remove(szLower); return iSuccess; #else const char *szResolved = ROLLERfindpath(szFile); - if (szResolved) return remove(szResolved); + if (szResolved) + return remove(szResolved); return iSuccess; #endif } //------------------------------------------------------------------------------------------------- -int ROLLERrename(const char *szOldName, const char *szNewName) -{ +int ROLLERrename(const char *szOldName, const char *szNewName) { int iSuccess = rename(szOldName, szNewName); - if (iSuccess == 0) return 0; + if (iSuccess == 0) + return 0; #ifdef IS_WINDOWS - char szUpper[260] = { 0 }; - char szLower[260] = { 0 }; + char szUpper[260] = {0}; + char szLower[260] = {0}; int iLength = (int)strlen(szOldName); for (int i = 0; i < iLength && i < (int)sizeof(szUpper); ++i) { @@ -1762,25 +1823,27 @@ int ROLLERrename(const char *szOldName, const char *szNewName) } iSuccess = rename(szUpper, szNewName); - if (iSuccess == 0) return 0; + if (iSuccess == 0) + return 0; iSuccess = rename(szLower, szNewName); return iSuccess; #else const char *szResolved = ROLLERfindpath(szOldName); - if (szResolved) return rename(szResolved, szNewName); + if (szResolved) + return rename(szResolved, szNewName); return iSuccess; #endif } //------------------------------------------------------------------------------------------------- -uint32 ROLLERAddTimer(Uint32 uiFrequencyHz, SDL_NSTimerCallback callback, void *userdata) -{ +uint32 ROLLERAddTimer(Uint32 uiFrequencyHz, SDL_NSTimerCallback callback, + void *userdata) { SDL_LockMutex(g_pTimerMutex); uint32 uiHandle = SDL_AddTimerNS(HZ_TO_NS(uiFrequencyHz), callback, userdata); - //find empty timer slot + // find empty timer slot bool bFoundSlot = false; for (int i = 0; i < MAX_TIMERS; ++i) { if (timerDataAy[i].uiHandle == 0) { @@ -1794,7 +1857,7 @@ uint32 ROLLERAddTimer(Uint32 uiFrequencyHz, SDL_NSTimerCallback callback, void * SDL_UnlockMutex(g_pTimerMutex); if (!bFoundSlot) { - //too many timers! + // too many timers! assert(0); ErrorBoxExit("Too many timers!"); } @@ -1804,12 +1867,11 @@ uint32 ROLLERAddTimer(Uint32 uiFrequencyHz, SDL_NSTimerCallback callback, void * //------------------------------------------------------------------------------------------------- -void ROLLERRemoveTimer(uint32 uiHandle) -{ +void ROLLERRemoveTimer(uint32 uiHandle) { SDL_RemoveTimer(uiHandle); SDL_LockMutex(g_pTimerMutex); - //clear timer data + // clear timer data for (int i = 0; i < MAX_TIMERS; ++i) { if (timerDataAy[i].uiHandle == uiHandle) { memset(&timerDataAy[i], 0, sizeof(tTimerData)); @@ -1820,10 +1882,10 @@ void ROLLERRemoveTimer(uint32 uiHandle) //------------------------------------------------------------------------------------------------- -int ROLLERfilelength(const char *szFile) -{ +int ROLLERfilelength(const char *szFile) { #ifdef IS_WINDOWS - int iFileHandle = ROLLERopen(szFile, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + int iFileHandle = ROLLERopen( + szFile, O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFileHandle == -1) return -1; @@ -1849,30 +1911,22 @@ int ROLLERfilelength(const char *szFile) static uint32 g_uiRandState = 1; -void ROLLERsrand(unsigned int uiSeed) -{ - g_uiRandState = (uint32)uiSeed; -} +void ROLLERsrand(unsigned int uiSeed) { g_uiRandState = (uint32)uiSeed; } //------------------------------------------------------------------------------------------------- -int ROLLERrandRaw(void) -{ +int ROLLERrandRaw(void) { g_uiRandState = g_uiRandState * 1103515245u + 12345u; return (int)((g_uiRandState >> 16) & 0x7FFFu); } //------------------------------------------------------------------------------------------------- -int ROLLERrand() -{ - return GetHighOrderRand(0x7FFF, ROLLERrandRaw()); -} +int ROLLERrand() { return GetHighOrderRand(0x7FFF, ROLLERrandRaw()); } //------------------------------------------------------------------------------------------------- -//g_pTimerMutex MUST BE LOCKED before calling this function -tTimerData *GetTimerData(SDL_TimerID timerID) -{ +// g_pTimerMutex MUST BE LOCKED before calling this function +tTimerData *GetTimerData(SDL_TimerID timerID) { for (int i = 0; i < MAX_TIMERS; ++i) { if (timerDataAy[i].uiHandle == timerID) { return &timerDataAy[i]; @@ -1883,8 +1937,7 @@ tTimerData *GetTimerData(SDL_TimerID timerID) //------------------------------------------------------------------------------------------------- -static bool ROLLERGetTimerInterval(SDL_TimerID timerID, uint64 *pUllInterval) -{ +static bool ROLLERGetTimerInterval(SDL_TimerID timerID, uint64 *pUllInterval) { SDL_LockMutex(g_pTimerMutex); tTimerData *pTimerData = GetTimerData(timerID); if (!pTimerData) { @@ -1893,7 +1946,8 @@ static bool ROLLERGetTimerInterval(SDL_TimerID timerID, uint64 *pUllInterval) } pTimerData->ullCurrSDLTicksNS = SDL_GetTicksNS(); - int64 llNSSinceLast = (int64)pTimerData->ullCurrSDLTicksNS - (int64)pTimerData->ullLastSDLTicksNS; + int64 llNSSinceLast = (int64)pTimerData->ullCurrSDLTicksNS - + (int64)pTimerData->ullLastSDLTicksNS; int64 llDelta = llNSSinceLast - (int64)pTimerData->ullTargetSDLTicksNS; if (llDelta < 0) llDelta = 0; @@ -1906,8 +1960,8 @@ static bool ROLLERGetTimerInterval(SDL_TimerID timerID, uint64 *pUllInterval) //------------------------------------------------------------------------------------------------- -Uint64 SDLTickTimerCallback(void *userdata, SDL_TimerID timerID, Uint64 interval) -{ +Uint64 SDLTickTimerCallback(void *userdata, SDL_TimerID timerID, + Uint64 interval) { tickhandler(); uint64 ullRet = 0; @@ -1919,8 +1973,8 @@ Uint64 SDLTickTimerCallback(void *userdata, SDL_TimerID timerID, Uint64 interval //------------------------------------------------------------------------------------------------- -Uint64 SDLS7TimerCallback(void *userdata, SDL_TimerID timerID, Uint64 interval) -{ +Uint64 SDLS7TimerCallback(void *userdata, SDL_TimerID timerID, + Uint64 interval) { SOSTimerCallbackS7(); uint64 ullRet = 0; @@ -1932,8 +1986,7 @@ Uint64 SDLS7TimerCallback(void *userdata, SDL_TimerID timerID, Uint64 interval) //------------------------------------------------------------------------------------------------- -int IsCDROMDevice(const char *szPath) -{ +int IsCDROMDevice(const char *szPath) { #if CDROM_SUPPORT int fd = open(szPath, O_RDONLY | O_NONBLOCK); if (fd < 0) @@ -1949,8 +2002,7 @@ int IsCDROMDevice(const char *szPath) //------------------------------------------------------------------------------------------------- -void ReplaceExtension(char *szFilename, const char *szNewExt) -{ +void ReplaceExtension(char *szFilename, const char *szNewExt) { char *szDot = strrchr(szFilename, '.'); char *szSlash = strrchr(szFilename, '/'); char *szBackslash = strrchr(szFilename, '\\'); @@ -1966,26 +2018,28 @@ void ReplaceExtension(char *szFilename, const char *szNewExt) //------------------------------------------------------------------------------------------------- -void ErrorBoxExit(const char *szErrorMsgFormat, ...) -{ +void ErrorBoxExit(const char *szErrorMsgFormat, ...) { va_list args; va_start(args, szErrorMsgFormat); char szErrorMsg[2048]; - int iLen = vsnprintf(szErrorMsg, sizeof(szErrorMsg) - 1, szErrorMsgFormat, args); + int iLen = + vsnprintf(szErrorMsg, sizeof(szErrorMsg) - 1, szErrorMsgFormat, args); if (iLen >= 0) szErrorMsg[iLen] = '\0'; va_end(args); - SDL_ShowMessageBox(&(SDL_MessageBoxData) - { - .title = "ROLLER", - .message = szErrorMsg, - .flags = SDL_MESSAGEBOX_ERROR, - .numbuttons = 1, - .buttons = (SDL_MessageBoxButtonData[]){ - {.flags = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, .text = "OK" } - }, - }, NULL); + SDL_ShowMessageBox( + &(SDL_MessageBoxData){ + .title = "ROLLER", + .message = szErrorMsg, + .flags = SDL_MESSAGEBOX_ERROR, + .numbuttons = 1, + .buttons = + (SDL_MessageBoxButtonData[]){ + {.flags = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, + .text = "OK"}}, + }, + NULL); ShutdownSDL(); exit(0); @@ -1993,7 +2047,8 @@ void ErrorBoxExit(const char *szErrorMsgFormat, ...) //------------------------------------------------------------------------------------------------- -void autoselectsoundlanguage() // Add by ROLLER to auto-select languagename when config.ini is not found +void autoselectsoundlanguage() // Add by ROLLER to auto-select languagename when + // config.ini is not found { SDL_Log("autoselectsoundlanguage: config.ini not found"); @@ -2008,16 +2063,20 @@ void autoselectsoundlanguage() // Add by ROLLER to auto-select languagename when const char *szTextExt = (char *)TextExt + i * 4; const char *szLangExt = (const char *)SampleExt + i * 4; - snprintf(textFileName, sizeof(textFileName), "./CONFIG.%s", szTextExt); // e.g., CONFIG.ENG, CONFIG.FRA, CONFIG.GER, CONFIG.BPO, CONFIG.SAS. - snprintf(audioFileName, sizeof(audioFileName), "./GO.%s", szLangExt); // e.g., GO.RAW, GO.RFR, GO.RGE, GO.RBP, GO.RSS. + snprintf(textFileName, sizeof(textFileName), "./CONFIG.%s", + szTextExt); // e.g., CONFIG.ENG, CONFIG.FRA, CONFIG.GER, + // CONFIG.BPO, CONFIG.SAS. + snprintf(audioFileName, sizeof(audioFileName), "./GO.%s", + szLangExt); // e.g., GO.RAW, GO.RFR, GO.RGE, GO.RBP, GO.RSS. - //SDL_Log("lang[%i]: %s", i, lang[i]); - //SDL_Log("textFileName[%i]: %s", i, textFileName); - //SDL_Log("audioFileName[%i]: %s", i, audioFileName); + // SDL_Log("lang[%i]: %s", i, lang[i]); + // SDL_Log("textFileName[%i]: %s", i, textFileName); + // SDL_Log("audioFileName[%i]: %s", i, audioFileName); if (ROLLERfexists(textFileName) && ROLLERfexists(audioFileName)) { sscanf(lang[i], "%s", languagename); language = i; - SDL_Log("autoselectsoundlanguage: select language[%i]: %s - %s %s", language, languagename, szTextExt, szLangExt); + SDL_Log("autoselectsoundlanguage: select language[%i]: %s - %s %s", + language, languagename, szTextExt, szLangExt); break; } } @@ -2025,25 +2084,24 @@ void autoselectsoundlanguage() // Add by ROLLER to auto-select languagename when //------------------------------------------------------------------------------------------------- -int GetHighOrderRand(int iRange, int iRandValue) -{ +int GetHighOrderRand(int iRange, int iRandValue) { int64 llProduct = (int64)iRange * iRandValue; return (int)(llProduct >> ROLLER_RAND_BITS); } //------------------------------------------------------------------------------------------------- -int ReadUnalignedInt(const void *pData) -{ - const uint8 *pBytes = (const uint8*)pData; - return (uint32)pBytes[0] | ((uint32)pBytes[1] << 8) | ((uint32)pBytes[2] << 16) | ((uint32)pBytes[3] << 24); +int ReadUnalignedInt(const void *pData) { + const uint8 *pBytes = (const uint8 *)pData; + return (uint32)pBytes[0] | ((uint32)pBytes[1] << 8) | + ((uint32)pBytes[2] << 16) | ((uint32)pBytes[3] << 24); } //------------------------------------------------------------------------------------------------- -void LBAToMSF(uint32 uiLBA, uint8 *pbyMinute, uint8 *pbySecond, uint8 *pbyFrame) -{ - uint32 uiAdjustedLBA = uiLBA + 150; // Add CD lead-in offset +void LBAToMSF(uint32 uiLBA, uint8 *pbyMinute, uint8 *pbySecond, + uint8 *pbyFrame) { + uint32 uiAdjustedLBA = uiLBA + 150; // Add CD lead-in offset *pbyFrame = uiAdjustedLBA % 75; *pbySecond = (uiAdjustedLBA / 75) % 60; *pbyMinute = (uiAdjustedLBA / 75) / 60; @@ -2054,8 +2112,8 @@ void LBAToMSF(uint32 uiLBA, uint8 *pbyMinute, uint8 *pbySecond, uint8 *pbyFrame) // Globals for CD audio management int g_iNumTracks = 0; int g_iCurrentTrack = -1; -int g_iStartTrack = -1; // For PlayTrack4 -int g_iTrackCount = 0; // For PlayTrack4 +int g_iStartTrack = -1; // For PlayTrack4 +int g_iTrackCount = 0; // For PlayTrack4 int g_iCDVolume = 0; bool g_bRepeat = false; bool g_bUsingRealCD = false; @@ -2073,9 +2131,8 @@ static MCIDEVICEID g_wDeviceID = 0; static int g_iCDHandle = -1; #endif -void ROLLERGetAudioInfo() -{ - //only get info once +void ROLLERGetAudioInfo() { + // only get info once if (g_bGotAudioInfo) return; g_bGotAudioInfo = true; @@ -2084,7 +2141,7 @@ void ROLLERGetAudioInfo() g_bUsingRealCD = false; #ifdef IS_WINDOWS - // Windows: Use MCI (Media Control Interface) + // Windows: Use MCI (Media Control Interface) MCI_OPEN_PARMS mciOpenParms; MCI_SET_PARMS mciSetParms; MCI_STATUS_PARMS mciStatusParms; @@ -2098,7 +2155,7 @@ void ROLLERGetAudioInfo() // Set time format to tracks mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF; mciSendCommand(g_wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, - (DWORD_PTR)&mciSetParms); + (DWORD_PTR)&mciSetParms); // Get number of tracks mciStatusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS; @@ -2110,21 +2167,17 @@ void ROLLERGetAudioInfo() } #elif defined(IS_LINUX) - // Linux: Try to open CD device - const char *szCDDevices[] = { - "/dev/cdrom", - "/dev/sr0", - "/dev/sr1", - "/dev/dvd" - }; + // Linux: Try to open CD device + const char *szCDDevices[] = {"/dev/cdrom", "/dev/sr0", "/dev/sr1", + "/dev/dvd"}; for (int i = 0; i < sizeof(szCDDevices) / sizeof(szCDDevices[0]); i++) { g_iCDHandle = open(szCDDevices[i], O_RDONLY | O_NONBLOCK); if (g_iCDHandle >= 0) { struct cdrom_tochdr tochdr; if (ioctl(g_iCDHandle, CDROMREADTOCHDR, &tochdr) == 0) { - // First track is usually data (track 1), audio starts at track 2 - g_iNumTracks = tochdr.cdth_trk1; // Last track number + // First track is usually data (track 1), audio starts at track 2 + g_iNumTracks = tochdr.cdth_trk1; // Last track number g_bUsingRealCD = true; break; } @@ -2134,7 +2187,7 @@ void ROLLERGetAudioInfo() } #endif - // If no real CD found, check for ripped tracks + // If no real CD found, check for ripped tracks if (!g_bUsingRealCD) { char szTrackFile[256]; FILE *fp; @@ -2146,9 +2199,9 @@ void ROLLERGetAudioInfo() if (fp) { fclose(fp); - g_iNumTracks = iTrack; // Keep counting up + g_iNumTracks = iTrack; // Keep counting up } else if (iTrack > 2) { - break; // Stop at first missing track after track 2 + break; // Stop at first missing track after track 2 } } } @@ -2156,8 +2209,7 @@ void ROLLERGetAudioInfo() //------------------------------------------------------------------------------------------------- -void ROLLERStopTrack() -{ +void ROLLERStopTrack() { SDL_Log("ROLLERStopTrack %d", g_iCurrentTrack); if (g_bUsingRealCD) { @@ -2171,7 +2223,7 @@ void ROLLERStopTrack() } #endif } else { - // Stop file playback + // Stop file playback if (g_pCurrentStream) { SDL_DestroyAudioStream(g_pCurrentStream); g_pCurrentStream = NULL; @@ -2185,9 +2237,8 @@ void ROLLERStopTrack() //------------------------------------------------------------------------------------------------- -void ROLLERPlayTrack(int iTrack) -{ -// CD audio tracks start at 2 (track 1 is data) +void ROLLERPlayTrack(int iTrack) { + // CD audio tracks start at 2 (track 1 is data) if (iTrack < 2 || iTrack > g_iNumTracks) { return; } @@ -2202,7 +2253,7 @@ void ROLLERPlayTrack(int iTrack) mciPlayParms.dwFrom = MCI_MAKE_TMSF(iTrack, 0, 0, 0); mciPlayParms.dwTo = MCI_MAKE_TMSF(iTrack + 1, 0, 0, 0); mciSendCommand(g_wDeviceID, MCI_PLAY, MCI_FROM | MCI_TO, - (DWORD_PTR)&mciPlayParms); + (DWORD_PTR)&mciPlayParms); } #elif defined(IS_LINUX) if (g_iCDHandle >= 0) { @@ -2215,7 +2266,7 @@ void ROLLERPlayTrack(int iTrack) } #endif } else { - // Play from file + // Play from file char szTrackFile[256]; SDL_AudioSpec spec; @@ -2229,11 +2280,11 @@ void ROLLERPlayTrack(int iTrack) if (SDL_LoadWAV_IO(io, true, &spec, &g_pAudioData, &g_uiAudioLen)) { g_pCurrentStream = SDL_OpenAudioDeviceStream( - SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, - &spec, NULL, NULL); + SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, NULL, NULL); if (g_pCurrentStream) { - SDL_PutAudioStreamData(g_pCurrentStream, g_pAudioData, g_uiAudioLen); + SDL_PutAudioStreamData(g_pCurrentStream, g_pAudioData, + g_uiAudioLen); SDL_ResumeAudioStreamDevice(g_pCurrentStream); float fGain = g_iCDVolume / 255.0f; SDL_SetAudioStreamGain(g_pCurrentStream, fGain); @@ -2249,8 +2300,7 @@ void ROLLERPlayTrack(int iTrack) //------------------------------------------------------------------------------------------------- -void ROLLERPlayTrack4(int iStartTrack) -{ +void ROLLERPlayTrack4(int iStartTrack) { g_iStartTrack = iStartTrack; g_iTrackCount = 4; g_bRepeat = false; @@ -2260,21 +2310,21 @@ void ROLLERPlayTrack4(int iStartTrack) //------------------------------------------------------------------------------------------------- -void ROLLERSetAudioVolume(int iVolume) -{ +void ROLLERSetAudioVolume(int iVolume) { g_iCDVolume = iVolume; if (g_bUsingRealCD) { #ifdef IS_WINDOWS if (g_wDeviceID != 0) { - // Method 1: Using MCI + // Method 1: Using MCI MCI_DGV_SETAUDIO_PARMS mciSetAudioParms; mciSetAudioParms.dwItem = MCI_DGV_SETAUDIO_VOLUME; - mciSetAudioParms.dwValue = (iVolume * 1000) / 255; // MCI uses 0-1000 + mciSetAudioParms.dwValue = (iVolume * 1000) / 255; // MCI uses 0-1000 - DWORD dwResult = mciSendCommand(g_wDeviceID, MCI_SETAUDIO, - MCI_DGV_SETAUDIO_VALUE | MCI_DGV_SETAUDIO_ITEM, - (DWORD_PTR)&mciSetAudioParms); + DWORD dwResult = + mciSendCommand(g_wDeviceID, MCI_SETAUDIO, + MCI_DGV_SETAUDIO_VALUE | MCI_DGV_SETAUDIO_ITEM, + (DWORD_PTR)&mciSetAudioParms); if (dwResult != 0) { if (!g_bSentCDVolWarning) { SDL_Log("CD volume control not supported on this system"); @@ -2284,7 +2334,7 @@ void ROLLERSetAudioVolume(int iVolume) } #elif defined(IS_LINUX) if (g_iCDHandle >= 0) { - // Linux CD-ROM volume control + // Linux CD-ROM volume control struct cdrom_volctrl volume; // All channels set to same volume (0-255 range) @@ -2298,9 +2348,9 @@ void ROLLERSetAudioVolume(int iVolume) } #endif } else { - // Set volume for SDL audio stream + // Set volume for SDL audio stream if (g_pCurrentStream) { - // SDL3 gain: 1.0 = normal, 0.0 = silence + // SDL3 gain: 1.0 = normal, 0.0 = silence float fGain = iVolume / 255.0f; SDL_SetAudioStreamGain(g_pCurrentStream, fGain); } @@ -2309,8 +2359,7 @@ void ROLLERSetAudioVolume(int iVolume) //------------------------------------------------------------------------------------------------- // Call this periodically to handle track transitions and repeat -void UpdateAudioTracks(void) -{ +void UpdateAudioTracks(void) { bool bTrackFinished = false; if (g_iCurrentTrack < 0) { @@ -2329,11 +2378,11 @@ void UpdateAudioTracks(void) if (mciStatusParms.dwReturn == MCI_MODE_STOP) { bTrackFinished = true; } else if (mciStatusParms.dwReturn == MCI_MODE_PLAY) { - // Check if we're still on the same track + // Check if we're still on the same track mciStatusParms.dwItem = MCI_STATUS_CURRENT_TRACK; if (mciSendCommand(g_wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatusParms) == 0) { - // If we've moved past our track, it finished + // If we've moved past our track, it finished if (mciStatusParms.dwReturn != g_iCurrentTrack) { bTrackFinished = true; } @@ -2366,7 +2415,7 @@ void UpdateAudioTracks(void) } #endif } else if (g_pCurrentStream) { - // Check file playback + // Check file playback int iQueued = SDL_GetAudioStreamQueued(g_pCurrentStream); if (iQueued == 0) { bTrackFinished = true; @@ -2376,11 +2425,11 @@ void UpdateAudioTracks(void) if (bTrackFinished) { if (g_bRepeat) { SDL_Log("Repeat track %d", g_iCurrentTrack); - // Repeat current track + // Repeat current track ROLLERPlayTrack(g_iCurrentTrack); } else if (g_iTrackCount > 1) { SDL_Log("Advance track"); - // PlayTrack4 sequence + // PlayTrack4 sequence g_iTrackCount--; int iNextTrack = g_iCurrentTrack + 1; ROLLERPlayTrack(iNextTrack); @@ -2393,8 +2442,7 @@ void UpdateAudioTracks(void) //------------------------------------------------------------------------------------------------- -void CleanupAudioCD(void) -{ +void CleanupAudioCD(void) { ROLLERStopTrack(); #if defined(IS_LINUX) diff --git a/PROJECTS/ROLLER/roller.h b/PROJECTS/ROLLER/roller.h index a60d711e..ec9c0dae 100644 --- a/PROJECTS/ROLLER/roller.h +++ b/PROJECTS/ROLLER/roller.h @@ -71,19 +71,29 @@ void DIGISetPanLocation(int iHandle, int iPan); void PlayAudioSampleWait(int iIndex); void PlayAudioDataWait(Uint8 *buffer, Uint32 length); bool ROLLERfexists(const char *szFile); -const char *ROLLERfindpath(const char *szFile); // case-insensitive path resolution (no-op on Windows) +const char *ROLLERfindpath( + const char *szFile); // case-insensitive path resolution (no-op on Windows) bool ROLLERdirexists(const char *szDir); -FILE *ROLLERfopen(const char *szFile, const char *szMode); //tries to open file with both all caps and all lower case -int ROLLERopen(const char *szFile, int iOpenFlags); //tries to open file with both all caps and all lower case -int ROLLERremove(const char *szFile); //tries to remove file with both all caps and all lower case -int ROLLERrename(const char *szOldName, const char *szNewName); //tries to rename file with both all caps and all lower case -uint32 ROLLERAddTimer(Uint32 uiFrequencyHz, SDL_NSTimerCallback callback, void *userdata); +FILE *ROLLERfopen(const char *szFile, + const char *szMode); // tries to open file with both all caps + // and all lower case +int ROLLERopen( + const char *szFile, + int iOpenFlags); // tries to open file with both all caps and all lower case +int ROLLERremove(const char *szFile); // tries to remove file with both all caps + // and all lower case +int ROLLERrename(const char *szOldName, + const char *szNewName); // tries to rename file with both all + // caps and all lower case +uint32 ROLLERAddTimer(Uint32 uiFrequencyHz, SDL_NSTimerCallback callback, + void *userdata); void ROLLERRemoveTimer(uint32 uiHandle); int ROLLERfilelength(const char *szFile); void ROLLERsrand(unsigned int uiSeed); int ROLLERrandRaw(void); int ROLLERrand(); -Uint64 SDLTickTimerCallback(void *userdata, SDL_TimerID timerID, Uint64 interval); +Uint64 SDLTickTimerCallback(void *userdata, SDL_TimerID timerID, + Uint64 interval); Uint64 SDLS7TimerCallback(void *userdata, SDL_TimerID timerID, Uint64 interval); int IsCDROMDevice(const char *szPath); void ReplaceExtension(char *szFilename, const char *szNewExt); @@ -91,7 +101,8 @@ void ErrorBoxExit(const char *szErrorMsgFormat, ...); void autoselectsoundlanguage(); int GetHighOrderRand(int iRange, int iRandValue); int ReadUnalignedInt(const void *pData); -void LBAToMSF(uint32 uiLBA, uint8 *pbyMinute, uint8 *pbySecond, uint8 *pbyFrame); +void LBAToMSF(uint32 uiLBA, uint8 *pbyMinute, uint8 *pbySecond, + uint8 *pbyFrame); void ROLLERGetAudioInfo(); void ROLLERStopTrack(); void ROLLERPlayTrack(int iTrack); diff --git a/PROJECTS/ROLLER/rollercd.c b/PROJECTS/ROLLER/rollercd.c index 1db008a8..b72ecc6a 100644 --- a/PROJECTS/ROLLER/rollercd.c +++ b/PROJECTS/ROLLER/rollercd.c @@ -23,15 +23,13 @@ #endif //------------------------------------------------------------------------------------------------- -typedef enum -{ +typedef enum { CUE_TRACK_UNKNOWN, CUE_TRACK_AUDIO, CUE_TRACK_DATA } tCueTrackKind; -typedef struct -{ +typedef struct { char szFile[ROLLER_MAX_PATH]; char szMode[32]; track_t uiTrack; @@ -42,8 +40,7 @@ typedef struct int iIndex01Sector; } tCueTrackInfo; -typedef struct -{ +typedef struct { tCueTrackInfo tracks[ROLLER_MAX_CUE_TRACKS]; int iNumTracks; int iNumFiles; @@ -52,52 +49,45 @@ typedef struct //------------------------------------------------------------------------------------------------- -static void WriteU16LE(FILE *pOut, uint16 v) -{ - uint8 b[2] = { (uint8)(v & 0xff), (uint8)((v >> 8) & 0xff) }; +static void WriteU16LE(FILE *pOut, uint16 v) { + uint8 b[2] = {(uint8)(v & 0xff), (uint8)((v >> 8) & 0xff)}; fwrite(b, 1, 2, pOut); } //------------------------------------------------------------------------------------------------- -static void WriteU32LE(FILE *pOut, uint32 v) -{ - uint8 b[4] = { (uint8)(v & 0xff), (uint8)((v >> 8) & 0xff), - (uint8)((v >> 16) & 0xff), (uint8)((v >> 24) & 0xff) }; +static void WriteU32LE(FILE *pOut, uint32 v) { + uint8 b[4] = {(uint8)(v & 0xff), (uint8)((v >> 8) & 0xff), + (uint8)((v >> 16) & 0xff), (uint8)((v >> 24) & 0xff)}; fwrite(b, 1, 4, pOut); } //------------------------------------------------------------------------------------------------- // Write a 44-byte RIFF PCM WAV header for CD-DA (44100 Hz, stereo, 16-bit). -static void WriteWAVHeader(FILE *pOut, uint32 uiDataBytes) -{ +static void WriteWAVHeader(FILE *pOut, uint32 uiDataBytes) { fwrite("RIFF", 1, 4, pOut); WriteU32LE(pOut, 36 + uiDataBytes); // file size minus 8 fwrite("WAVE", 1, 4, pOut); fwrite("fmt ", 1, 4, pOut); - WriteU32LE(pOut, 16); // fmt chunk size - WriteU16LE(pOut, 1); // PCM - WriteU16LE(pOut, 2); // stereo - WriteU32LE(pOut, 44100); // sample rate - WriteU32LE(pOut, 176400); // byte rate: 44100 * 2 * 2 - WriteU16LE(pOut, 4); // block align: 2 channels * 2 bytes - WriteU16LE(pOut, 16); // bits per sample + WriteU32LE(pOut, 16); // fmt chunk size + WriteU16LE(pOut, 1); // PCM + WriteU16LE(pOut, 2); // stereo + WriteU32LE(pOut, 44100); // sample rate + WriteU32LE(pOut, 176400); // byte rate: 44100 * 2 * 2 + WriteU16LE(pOut, 4); // block align: 2 channels * 2 bytes + WriteU16LE(pOut, 16); // bits per sample fwrite("data", 1, 4, pOut); WriteU32LE(pOut, uiDataBytes); } //------------------------------------------------------------------------------------------------- -static int CueCharLower(int c) -{ - return tolower((unsigned char)c); -} +static int CueCharLower(int c) { return tolower((unsigned char)c); } //------------------------------------------------------------------------------------------------- -static bool CueStringEqualsIgnoreCase(const char *szA, const char *szB) -{ +static bool CueStringEqualsIgnoreCase(const char *szA, const char *szB) { while (*szA && *szB) { if (CueCharLower(*szA) != CueCharLower(*szB)) return false; @@ -109,8 +99,8 @@ static bool CueStringEqualsIgnoreCase(const char *szA, const char *szB) //------------------------------------------------------------------------------------------------- -static bool CueStringEndsWithIgnoreCase(const char *szText, const char *szSuffix) -{ +static bool CueStringEndsWithIgnoreCase(const char *szText, + const char *szSuffix) { size_t nTextLen = strlen(szText); size_t nSuffixLen = strlen(szSuffix); if (nSuffixLen > nTextLen) @@ -120,18 +110,18 @@ static bool CueStringEndsWithIgnoreCase(const char *szText, const char *szSuffix //------------------------------------------------------------------------------------------------- -static void NormalizePathForCdio(const char *szPath, char *szNormPath, int nBufSize) -{ +static void NormalizePathForCdio(const char *szPath, char *szNormPath, + int nBufSize) { SDL_strlcpy(szNormPath, szPath, nBufSize); for (char *p = szNormPath; *p; p++) { - if (*p == '\\') *p = '/'; + if (*p == '\\') + *p = '/'; } } //------------------------------------------------------------------------------------------------- -static void GetPathDirectory(const char *szPath, char *szDir, int nBufSize) -{ +static void GetPathDirectory(const char *szPath, char *szDir, int nBufSize) { SDL_strlcpy(szDir, szPath, nBufSize); char *szSlash = SDL_strrchr(szDir, '/'); @@ -148,8 +138,7 @@ static void GetPathDirectory(const char *szPath, char *szDir, int nBufSize) //------------------------------------------------------------------------------------------------- -static const char *GetPathFilename(const char *szPath) -{ +static const char *GetPathFilename(const char *szPath) { const char *szSlash = SDL_strrchr(szPath, '/'); const char *szBackslash = SDL_strrchr(szPath, '\\'); if (szBackslash && (!szSlash || szBackslash > szSlash)) @@ -159,8 +148,7 @@ static const char *GetPathFilename(const char *szPath) //------------------------------------------------------------------------------------------------- -static bool RawFileExists(const char *szPath) -{ +static bool RawFileExists(const char *szPath) { FILE *pFile = fopen(szPath, "rb"); if (!pFile) return false; @@ -170,10 +158,10 @@ static bool RawFileExists(const char *szPath) //------------------------------------------------------------------------------------------------- -static bool BuildTempCuePath(const char *szDir, char *szCuePath, int nBufSize) -{ +static bool BuildTempCuePath(const char *szDir, char *szCuePath, int nBufSize) { for (int i = 0; i < 100; i++) { - int iLen = SDL_snprintf(szCuePath, nBufSize, "%sroller_data_track_%02d.cue", szDir, i); + int iLen = SDL_snprintf(szCuePath, nBufSize, "%sroller_data_track_%02d.cue", + szDir, i); if (iLen < 0 || iLen >= nBufSize) return false; if (!RawFileExists(szCuePath)) @@ -186,8 +174,7 @@ static bool BuildTempCuePath(const char *szDir, char *szCuePath, int nBufSize) //------------------------------------------------------------------------------------------------- -static bool IsAbsolutePath(const char *szPath) -{ +static bool IsAbsolutePath(const char *szPath) { if (!szPath || !szPath[0]) return false; @@ -199,8 +186,7 @@ static bool IsAbsolutePath(const char *szPath) //------------------------------------------------------------------------------------------------- -static int ChangeWorkingDirectory(const char *szDir) -{ +static int ChangeWorkingDirectory(const char *szDir) { #ifdef IS_WINDOWS if (isalpha((unsigned char)szDir[0]) && szDir[1] == ':') { char cDriveLetter = szDir[0] & 0xDF; @@ -212,12 +198,13 @@ static int ChangeWorkingDirectory(const char *szDir) //------------------------------------------------------------------------------------------------- -void SaveDefaultFatalIni(const char *szWhipRoot) -{ +void SaveDefaultFatalIni(const char *szWhipRoot) { char szPreviousDir[ROLLER_MAX_PATH]; if (!getcwd(szPreviousDir, sizeof(szPreviousDir))) { - SDL_Log("ExtractFATDATA: failed to capture current directory before saving FATAL.INI: %s", strerror(errno)); + SDL_Log("ExtractFATDATA: failed to capture current directory before saving " + "FATAL.INI: %s", + strerror(errno)); return; } @@ -225,13 +212,14 @@ void SaveDefaultFatalIni(const char *szWhipRoot) save_fatal_config(); if (ChangeWorkingDirectory(szPreviousDir) != 0) - SDL_Log("ExtractFATDATA: failed to restore directory '%s': %s", szPreviousDir, strerror(errno)); + SDL_Log("ExtractFATDATA: failed to restore directory '%s': %s", + szPreviousDir, strerror(errno)); } //------------------------------------------------------------------------------------------------- -static void JoinCuePath(const char *szCueDir, const char *szFile, char *szOut, int nBufSize) -{ +static void JoinCuePath(const char *szCueDir, const char *szFile, char *szOut, + int nBufSize) { if (IsAbsolutePath(szFile)) { SDL_strlcpy(szOut, szFile, nBufSize); } else { @@ -241,12 +229,13 @@ static void JoinCuePath(const char *szCueDir, const char *szFile, char *szOut, i //------------------------------------------------------------------------------------------------- -static bool ParseCueFileLine(const char *szLine, char *szFile, int nFileSize, char *szType, int nTypeSize) -{ +static bool ParseCueFileLine(const char *szLine, char *szFile, int nFileSize, + char *szType, int nTypeSize) { char szParsedFile[ROLLER_MAX_PATH]; char szParsedType[32]; - if (sscanf(szLine, " FILE \"%259[^\"]\" %31s", szParsedFile, szParsedType) == 2) { + if (sscanf(szLine, " FILE \"%259[^\"]\" %31s", szParsedFile, szParsedType) == + 2) { SDL_strlcpy(szFile, szParsedFile, nFileSize); SDL_strlcpy(szType, szParsedType, nTypeSize); return true; @@ -263,8 +252,7 @@ static bool ParseCueFileLine(const char *szLine, char *szFile, int nFileSize, ch //------------------------------------------------------------------------------------------------- -static bool ParseCueTimeToSector(const char *szTime, int *piSector) -{ +static bool ParseCueTimeToSector(const char *szTime, int *piSector) { int iMinute; int iSecond; int iFrame; @@ -281,8 +269,7 @@ static bool ParseCueTimeToSector(const char *szTime, int *piSector) //------------------------------------------------------------------------------------------------- -static bool ParseCueFile(const char *szCuePath, tCueInfo *pCueInfo) -{ +static bool ParseCueFile(const char *szCuePath, tCueInfo *pCueInfo) { FILE *pCue = fopen(szCuePath, "r"); if (!pCue) return false; @@ -290,8 +277,8 @@ static bool ParseCueFile(const char *szCuePath, tCueInfo *pCueInfo) memset(pCueInfo, 0, sizeof(*pCueInfo)); char szCueDir[ROLLER_MAX_PATH]; - char szCurrentFile[ROLLER_MAX_PATH] = { 0 }; - char szFirstFile[ROLLER_MAX_PATH] = { 0 }; + char szCurrentFile[ROLLER_MAX_PATH] = {0}; + char szFirstFile[ROLLER_MAX_PATH] = {0}; bool bCurrentFileIsBinary = true; tCueTrackInfo *pCurrentTrack = NULL; @@ -302,7 +289,8 @@ static bool ParseCueFile(const char *szCuePath, tCueInfo *pCueInfo) char szFile[ROLLER_MAX_PATH]; char szType[32]; - if (ParseCueFileLine(szLine, szFile, sizeof(szFile), szType, sizeof(szType))) { + if (ParseCueFileLine(szLine, szFile, sizeof(szFile), szType, + sizeof(szType))) { char szResolvedFile[ROLLER_MAX_PATH]; JoinCuePath(szCueDir, szFile, szResolvedFile, sizeof(szResolvedFile)); SDL_strlcpy(szCurrentFile, szResolvedFile, sizeof(szCurrentFile)); @@ -333,19 +321,22 @@ static bool ParseCueFile(const char *szCuePath, tCueInfo *pCueInfo) pCurrentTrack->bBinaryFile = bCurrentFileIsBinary; pCurrentTrack->bHasFile = szCurrentFile[0] != '\0'; pCurrentTrack->iIndex01Sector = 0; - SDL_strlcpy(pCurrentTrack->szFile, szCurrentFile, sizeof(pCurrentTrack->szFile)); + SDL_strlcpy(pCurrentTrack->szFile, szCurrentFile, + sizeof(pCurrentTrack->szFile)); SDL_strlcpy(pCurrentTrack->szMode, szMode, sizeof(pCurrentTrack->szMode)); pCurrentTrack->eKind = CueStringEqualsIgnoreCase(szMode, "AUDIO") - ? CUE_TRACK_AUDIO - : CUE_TRACK_DATA; + ? CUE_TRACK_AUDIO + : CUE_TRACK_DATA; continue; } unsigned uiIndex; char szTime[32]; - if (pCurrentTrack && sscanf(szLine, " INDEX %u %31s", &uiIndex, szTime) == 2) { - if (uiIndex == 1 && ParseCueTimeToSector(szTime, &pCurrentTrack->iIndex01Sector)) + if (pCurrentTrack && + sscanf(szLine, " INDEX %u %31s", &uiIndex, szTime) == 2) { + if (uiIndex == 1 && + ParseCueTimeToSector(szTime, &pCurrentTrack->iIndex01Sector)) pCurrentTrack->bHasIndex01 = true; } } @@ -356,8 +347,7 @@ static bool ParseCueFile(const char *szCuePath, tCueInfo *pCueInfo) //------------------------------------------------------------------------------------------------- -static const tCueTrackInfo *FindCueDataTrack(const tCueInfo *pCueInfo) -{ +static const tCueTrackInfo *FindCueDataTrack(const tCueInfo *pCueInfo) { for (int i = 0; i < pCueInfo->iNumTracks; i++) { const tCueTrackInfo *pTrack = &pCueInfo->tracks[i]; if (pTrack->eKind == CUE_TRACK_DATA && pTrack->bHasFile) @@ -368,8 +358,7 @@ static const tCueTrackInfo *FindCueDataTrack(const tCueInfo *pCueInfo) //------------------------------------------------------------------------------------------------- -static bool GetOpenFileSize(FILE *pFile, uint64 *puiSize) -{ +static bool GetOpenFileSize(FILE *pFile, uint64 *puiSize) { #ifdef IS_WINDOWS if (_fseeki64(pFile, 0, SEEK_END) != 0) return false; @@ -394,8 +383,7 @@ static bool GetOpenFileSize(FILE *pFile, uint64 *puiSize) //------------------------------------------------------------------------------------------------- -static bool SeekOpenFile(FILE *pFile, uint64 uiOffset) -{ +static bool SeekOpenFile(FILE *pFile, uint64 uiOffset) { #ifdef IS_WINDOWS return _fseeki64(pFile, (__int64)uiOffset, SEEK_SET) == 0; #else @@ -406,71 +394,77 @@ static bool SeekOpenFile(FILE *pFile, uint64 uiOffset) //------------------------------------------------------------------------------------------------- // Extract CD-DA audio tracks 2..N from an already-opened CdIo image. // Writes track02.wav .. trackNN.wav into szOutDir/audio/. -void ExtractAudioTracks(CdIo_t *p_cdio, const char *szOutDir) -{ +void ExtractAudioTracks(CdIo_t *p_cdio, const char *szOutDir) { char szAudioDir[ROLLER_MAX_PATH]; SDL_snprintf(szAudioDir, ROLLER_MAX_PATH, "%s/audio", szOutDir); SDL_CreateDirectory(szAudioDir); track_t uiFirst = cdio_get_first_track_num(p_cdio); - track_t uiLast = cdio_get_last_track_num(p_cdio); - SDL_Log("ExtractAudioTracks: tracks %u-%u", (unsigned)uiFirst, (unsigned)uiLast); + track_t uiLast = cdio_get_last_track_num(p_cdio); + SDL_Log("ExtractAudioTracks: tracks %u-%u", (unsigned)uiFirst, + (unsigned)uiLast); // Track 1 is the data track; audio starts at track 2. for (track_t t = 2; t <= uiLast; t++) { if (cdio_get_track_format(p_cdio, t) != TRACK_FORMAT_AUDIO) { - SDL_Log("ExtractAudioTracks: track %u is not audio, skipping", (unsigned)t); + SDL_Log("ExtractAudioTracks: track %u is not audio, skipping", + (unsigned)t); continue; } lsn_t lsnStart = cdio_get_track_lsn(p_cdio, t); - lsn_t lsnLast = cdio_get_track_last_lsn(p_cdio, t); + lsn_t lsnLast = cdio_get_track_last_lsn(p_cdio, t); if (lsnStart == CDIO_INVALID_LSN || lsnLast == CDIO_INVALID_LSN) { - SDL_Log("ExtractAudioTracks: track %u has invalid LSN, skipping", (unsigned)t); + SDL_Log("ExtractAudioTracks: track %u has invalid LSN, skipping", + (unsigned)t); continue; } - uint32 uiSectors = (uint32)(lsnLast - lsnStart + 1); + uint32 uiSectors = (uint32)(lsnLast - lsnStart + 1); uint32 uiDataBytes = uiSectors * CDIO_CD_FRAMESIZE_RAW; char szWavPath[ROLLER_MAX_PATH]; - SDL_snprintf(szWavPath, ROLLER_MAX_PATH, "%s/track%02u.wav", szAudioDir, (unsigned)t); + SDL_snprintf(szWavPath, ROLLER_MAX_PATH, "%s/track%02u.wav", szAudioDir, + (unsigned)t); SDL_Log("ExtractAudioTracks: track %u, LSN %d-%d (%u sectors) -> '%s'", (unsigned)t, lsnStart, lsnLast, uiSectors, szWavPath); FILE *pOut = fopen(szWavPath, "wb"); if (!pOut) { - SDL_Log("ExtractAudioTracks: failed to open '%s': %s", szWavPath, strerror(errno)); + SDL_Log("ExtractAudioTracks: failed to open '%s': %s", szWavPath, + strerror(errno)); continue; } WriteWAVHeader(pOut, uiDataBytes); - // Read and write in chunks of 32 sectors for reasonable performance. - #define AUDIO_CHUNK_SECTORS 32 +// Read and write in chunks of 32 sectors for reasonable performance. +#define AUDIO_CHUNK_SECTORS 32 uint8 szBuf[CDIO_CD_FRAMESIZE_RAW * AUDIO_CHUNK_SECTORS]; lsn_t lsn = lsnStart; while (lsn <= lsnLast) { uint32 uiCount = (uint32)(lsnLast - lsn + 1); - if (uiCount > AUDIO_CHUNK_SECTORS) uiCount = AUDIO_CHUNK_SECTORS; - if (cdio_read_audio_sectors(p_cdio, szBuf, lsn, uiCount) != DRIVER_OP_SUCCESS) { + if (uiCount > AUDIO_CHUNK_SECTORS) + uiCount = AUDIO_CHUNK_SECTORS; + if (cdio_read_audio_sectors(p_cdio, szBuf, lsn, uiCount) != + DRIVER_OP_SUCCESS) { SDL_Log("ExtractAudioTracks: read error at LSN %d", lsn); memset(szBuf, 0, (size_t)uiCount * CDIO_CD_FRAMESIZE_RAW); } fwrite(szBuf, 1, (size_t)uiCount * CDIO_CD_FRAMESIZE_RAW, pOut); lsn += (lsn_t)uiCount; } - #undef AUDIO_CHUNK_SECTORS +#undef AUDIO_CHUNK_SECTORS fclose(pOut); - SDL_Log("ExtractAudioTracks: wrote '%s' (%u bytes)", szWavPath, 44 + uiDataBytes); + SDL_Log("ExtractAudioTracks: wrote '%s' (%u bytes)", szWavPath, + 44 + uiDataBytes); } } //------------------------------------------------------------------------------------------------- -static uint64 CueTrackStartByte(const tCueTrackInfo *pTrack) -{ +static uint64 CueTrackStartByte(const tCueTrackInfo *pTrack) { int iStartSector = pTrack->bHasIndex01 ? pTrack->iIndex01Sector : 0; if (iStartSector < 0) iStartSector = 0; @@ -479,8 +473,8 @@ static uint64 CueTrackStartByte(const tCueTrackInfo *pTrack) //------------------------------------------------------------------------------------------------- -static uint64 CueTrackEndByte(const tCueInfo *pCueInfo, int iTrackIndex, uint64 uiFileSize) -{ +static uint64 CueTrackEndByte(const tCueInfo *pCueInfo, int iTrackIndex, + uint64 uiFileSize) { const tCueTrackInfo *pTrack = &pCueInfo->tracks[iTrackIndex]; for (int i = iTrackIndex + 1; i < pCueInfo->iNumTracks; i++) { @@ -498,24 +492,28 @@ static uint64 CueTrackEndByte(const tCueInfo *pCueInfo, int iTrackIndex, uint64 //------------------------------------------------------------------------------------------------- -static void ExtractAudioTrackFromCue(const tCueInfo *pCueInfo, int iTrackIndex, const char *szAudioDir) -{ +static void ExtractAudioTrackFromCue(const tCueInfo *pCueInfo, int iTrackIndex, + const char *szAudioDir) { const tCueTrackInfo *pTrack = &pCueInfo->tracks[iTrackIndex]; if (!pTrack->bBinaryFile) { - SDL_Log("ExtractAudioTracksFromCue: track %u is not a binary file, skipping", (unsigned)pTrack->uiTrack); + SDL_Log( + "ExtractAudioTracksFromCue: track %u is not a binary file, skipping", + (unsigned)pTrack->uiTrack); return; } FILE *pIn = fopen(pTrack->szFile, "rb"); if (!pIn) { - SDL_Log("ExtractAudioTracksFromCue: failed to open '%s': %s", pTrack->szFile, strerror(errno)); + SDL_Log("ExtractAudioTracksFromCue: failed to open '%s': %s", + pTrack->szFile, strerror(errno)); return; } uint64 uiFileSize; if (!GetOpenFileSize(pIn, &uiFileSize)) { - SDL_Log("ExtractAudioTracksFromCue: failed to determine size of '%s'", pTrack->szFile); + SDL_Log("ExtractAudioTracksFromCue: failed to determine size of '%s'", + pTrack->szFile); fclose(pIn); return; } @@ -523,14 +521,18 @@ static void ExtractAudioTrackFromCue(const tCueInfo *pCueInfo, int iTrackIndex, uint64 uiStart = CueTrackStartByte(pTrack); uint64 uiEnd = CueTrackEndByte(pCueInfo, iTrackIndex, uiFileSize); if (uiStart >= uiFileSize || uiEnd <= uiStart) { - SDL_Log("ExtractAudioTracksFromCue: track %u has invalid byte range, skipping", (unsigned)pTrack->uiTrack); + SDL_Log( + "ExtractAudioTracksFromCue: track %u has invalid byte range, skipping", + (unsigned)pTrack->uiTrack); fclose(pIn); return; } uint64 uiDataBytes64 = uiEnd - uiStart; if (uiDataBytes64 > 0xffffffffu) { - SDL_Log("ExtractAudioTracksFromCue: track %u is too large for a WAV file, skipping", (unsigned)pTrack->uiTrack); + SDL_Log("ExtractAudioTracksFromCue: track %u is too large for a WAV file, " + "skipping", + (unsigned)pTrack->uiTrack); fclose(pIn); return; } @@ -542,25 +544,27 @@ static void ExtractAudioTrackFromCue(const tCueInfo *pCueInfo, int iTrackIndex, } char szWavPath[ROLLER_MAX_PATH]; - SDL_snprintf(szWavPath, ROLLER_MAX_PATH, "%s/track%02u.wav", szAudioDir, (unsigned)pTrack->uiTrack); + SDL_snprintf(szWavPath, ROLLER_MAX_PATH, "%s/track%02u.wav", szAudioDir, + (unsigned)pTrack->uiTrack); FILE *pOut = fopen(szWavPath, "wb"); if (!pOut) { - SDL_Log("ExtractAudioTracksFromCue: failed to open '%s': %s", szWavPath, strerror(errno)); + SDL_Log("ExtractAudioTracksFromCue: failed to open '%s': %s", szWavPath, + strerror(errno)); fclose(pIn); return; } WriteWAVHeader(pOut, (uint32)uiDataBytes64); - #define AUDIO_FILE_CHUNK_BYTES (CDIO_CD_FRAMESIZE_RAW * 32) +#define AUDIO_FILE_CHUNK_BYTES (CDIO_CD_FRAMESIZE_RAW * 32) uint8 szBuf[AUDIO_FILE_CHUNK_BYTES]; uint64 uiBytesLeft = uiDataBytes64; uint64 uiBytesWritten = 0; while (uiBytesLeft > 0) { size_t nToRead = uiBytesLeft > AUDIO_FILE_CHUNK_BYTES - ? AUDIO_FILE_CHUNK_BYTES - : (size_t)uiBytesLeft; + ? AUDIO_FILE_CHUNK_BYTES + : (size_t)uiBytesLeft; size_t nRead = fread(szBuf, 1, nToRead, pIn); if (nRead == 0) break; @@ -569,7 +573,7 @@ static void ExtractAudioTrackFromCue(const tCueInfo *pCueInfo, int iTrackIndex, uiBytesWritten += nRead; uiBytesLeft -= nRead; } - #undef AUDIO_FILE_CHUNK_BYTES +#undef AUDIO_FILE_CHUNK_BYTES if (uiBytesWritten != uiDataBytes64) { fseek(pOut, 0, SEEK_SET); @@ -579,14 +583,14 @@ static void ExtractAudioTrackFromCue(const tCueInfo *pCueInfo, int iTrackIndex, fclose(pOut); fclose(pIn); - SDL_Log("ExtractAudioTracksFromCue: wrote '%s' (%llu bytes)", - szWavPath, (unsigned long long)(44 + uiBytesWritten)); + SDL_Log("ExtractAudioTracksFromCue: wrote '%s' (%llu bytes)", szWavPath, + (unsigned long long)(44 + uiBytesWritten)); } //------------------------------------------------------------------------------------------------- -static void ExtractAudioTracksFromCue(const tCueInfo *pCueInfo, const char *szOutDir) -{ +static void ExtractAudioTracksFromCue(const tCueInfo *pCueInfo, + const char *szOutDir) { char szAudioDir[ROLLER_MAX_PATH]; SDL_snprintf(szAudioDir, ROLLER_MAX_PATH, "%s/audio", szOutDir); SDL_CreateDirectory(szAudioDir); @@ -600,8 +604,7 @@ static void ExtractAudioTracksFromCue(const tCueInfo *pCueInfo, const char *szOu //------------------------------------------------------------------------------------------------- -void ExtractDir(CdIo_t *p_cdio, const char *szIsoDir, const char *szOutDir) -{ +void ExtractDir(CdIo_t *p_cdio, const char *szIsoDir, const char *szOutDir) { UpdateSDL(); SDL_CreateDirectory(szOutDir); @@ -617,15 +620,15 @@ void ExtractDir(CdIo_t *p_cdio, const char *szIsoDir, const char *szOutDir) SDL_Log("ExtractDir: reading '%s' -> '%s'", szIsoDir, szOutDir); CdioListNode_t *pNode; - _CDIO_LIST_FOREACH(pNode, pList) - { + _CDIO_LIST_FOREACH(pNode, pList) { iso9660_stat_t *pStat = (iso9660_stat_t *)_cdio_list_node_data(pNode); // strip version number from filename (e.g. "FILE.DAT;1" -> "FILE.DAT") char szFilename[ROLLER_MAX_PATH]; SDL_strlcpy(szFilename, pStat->filename, ROLLER_MAX_PATH); char *szSemi = SDL_strchr(szFilename, ';'); - if (szSemi) *szSemi = '\0'; + if (szSemi) + *szSemi = '\0'; // skip . and .. if (SDL_strcmp(szFilename, ".") == 0 || SDL_strcmp(szFilename, "..") == 0) { @@ -657,9 +660,8 @@ void ExtractDir(CdIo_t *p_cdio, const char *szIsoDir, const char *szOutDir) memset(szBuf, 0, ISO_BLOCK_SIZE); cdio_read_data_sectors(p_cdio, szBuf, lsn, ISO_BLOCK_SIZE, 1); - uint32 uiToWrite = uiBytesLeft > ISO_BLOCK_SIZE - ? ISO_BLOCK_SIZE - : uiBytesLeft; + uint32 uiToWrite = + uiBytesLeft > ISO_BLOCK_SIZE ? ISO_BLOCK_SIZE : uiBytesLeft; fwrite(szBuf, 1, uiToWrite, pOut); uiBytesLeft -= uiToWrite; @@ -668,7 +670,8 @@ void ExtractDir(CdIo_t *p_cdio, const char *szIsoDir, const char *szOutDir) fclose(pOut); SDL_Log(" -> wrote '%s' (%u bytes)", szOutPath, pStat->size); } else { - SDL_Log(" -> FAILED to open '%s' for writing: %s", szOutPath, strerror(errno)); + SDL_Log(" -> FAILED to open '%s' for writing: %s", szOutPath, + strerror(errno)); } } iso9660_stat_free(pStat); @@ -678,10 +681,10 @@ void ExtractDir(CdIo_t *p_cdio, const char *szIsoDir, const char *szOutDir) //------------------------------------------------------------------------------------------------- -char *GetBinPathFromCue(const char *szCuePath, char *szBinPath, int nBufSize) -{ +char *GetBinPathFromCue(const char *szCuePath, char *szBinPath, int nBufSize) { FILE *pCue = fopen(szCuePath, "r"); - if (!pCue) return NULL; + if (!pCue) + return NULL; char szLine[256]; while (fgets(szLine, sizeof(szLine), pCue)) { @@ -690,7 +693,8 @@ char *GetBinPathFromCue(const char *szCuePath, char *szBinPath, int nBufSize) char szDir[ROLLER_MAX_PATH]; SDL_strlcpy(szDir, szCuePath, ROLLER_MAX_PATH); char *szSlash = SDL_strrchr(szDir, '/'); - if (!szSlash) szSlash = SDL_strrchr(szDir, '\\'); + if (!szSlash) + szSlash = SDL_strrchr(szDir, '\\'); if (szSlash) { *(szSlash + 1) = '\0'; SDL_snprintf(szBinPath, nBufSize, "%s%s", szDir, szFile); @@ -707,21 +711,24 @@ char *GetBinPathFromCue(const char *szCuePath, char *szBinPath, int nBufSize) //------------------------------------------------------------------------------------------------- -static bool WriteSingleTrackCue(const char *szSourceCuePath, const tCueTrackInfo *pTrack, char *szCuePath, int nBufSize) -{ +static bool WriteSingleTrackCue(const char *szSourceCuePath, + const tCueTrackInfo *pTrack, char *szCuePath, + int nBufSize) { char szTempCueDir[ROLLER_MAX_PATH]; GetPathDirectory(pTrack->szFile, szTempCueDir, ROLLER_MAX_PATH); if (szTempCueDir[0] == '\0') GetPathDirectory(szSourceCuePath, szTempCueDir, ROLLER_MAX_PATH); if (!BuildTempCuePath(szTempCueDir, szCuePath, nBufSize)) { - SDL_Log("WriteSingleTrackCue: generated cue path is too long or unavailable"); + SDL_Log( + "WriteSingleTrackCue: generated cue path is too long or unavailable"); return false; } FILE *pCue = fopen(szCuePath, "w"); if (!pCue) { - SDL_Log("WriteSingleTrackCue: failed to open '%s': %s", szCuePath, strerror(errno)); + SDL_Log("WriteSingleTrackCue: failed to open '%s': %s", szCuePath, + strerror(errno)); return false; } @@ -734,7 +741,8 @@ static bool WriteSingleTrackCue(const char *szSourceCuePath, const tCueTrackInfo fclose(pCue); if (pTrack->bHasIndex01 && pTrack->iIndex01Sector != 0) { - SDL_Log("WriteSingleTrackCue: data track INDEX 01 is not 00:00:00; reading from the file start"); + SDL_Log("WriteSingleTrackCue: data track INDEX 01 is not 00:00:00; reading " + "from the file start"); } return true; @@ -742,16 +750,19 @@ static bool WriteSingleTrackCue(const char *szSourceCuePath, const tCueTrackInfo //------------------------------------------------------------------------------------------------- -static bool ExtractFATDATAFromMultiFileCue(const char *szCuePath, const char *szOutDir, const tCueInfo *pCueInfo) -{ +static bool ExtractFATDATAFromMultiFileCue(const char *szCuePath, + const char *szOutDir, + const tCueInfo *pCueInfo) { const tCueTrackInfo *pDataTrack = FindCueDataTrack(pCueInfo); if (!pDataTrack) { - SDL_Log("ExtractFATDATAFromMultiFileCue: no data track found in '%s'", szCuePath); + SDL_Log("ExtractFATDATAFromMultiFileCue: no data track found in '%s'", + szCuePath); return false; } char szTempCuePath[ROLLER_MAX_PATH]; - if (!WriteSingleTrackCue(szCuePath, pDataTrack, szTempCuePath, ROLLER_MAX_PATH)) + if (!WriteSingleTrackCue(szCuePath, pDataTrack, szTempCuePath, + ROLLER_MAX_PATH)) return false; char szNormTempCuePath[ROLLER_MAX_PATH]; @@ -762,7 +773,8 @@ static bool ExtractFATDATAFromMultiFileCue(const char *szCuePath, const char *sz CdIo_t *p_cdio = cdio_open_am(szNormTempCuePath, DRIVER_UNKNOWN, NULL); if (!p_cdio) { - SDL_Log("ExtractFATDATAFromMultiFileCue: cdio_open_am failed for '%s'", szNormTempCuePath); + SDL_Log("ExtractFATDATAFromMultiFileCue: cdio_open_am failed for '%s'", + szNormTempCuePath); remove(szTempCuePath); return false; } @@ -780,17 +792,18 @@ static bool ExtractFATDATAFromMultiFileCue(const char *szCuePath, const char *sz //------------------------------------------------------------------------------------------------- -void ExtractFATDATA(const char *szImagePath, const char *szOutDir) -{ +void ExtractFATDATA(const char *szImagePath, const char *szOutDir) { // Use cdio_open_am with DRIVER_UNKNOWN: auto-detects BIN/CUE, ISO, NRG, etc. // Unlike iso9660_open_fuzzy (which reads raw bytes), the CdIo driver layer // handles Mode 2 XA sectors (2352-byte, 24-byte header) correctly. - SDL_Log("ExtractFATDATA: opening '%s', output dir '%s'", szImagePath, szOutDir); + SDL_Log("ExtractFATDATA: opening '%s', output dir '%s'", szImagePath, + szOutDir); if (CueStringEndsWithIgnoreCase(szImagePath, ".cue")) { tCueInfo cueInfo; if (ParseCueFile(szImagePath, &cueInfo) && cueInfo.bMultiFile) { - SDL_Log("ExtractFATDATA: detected multi-file CUE with %d tracks", cueInfo.iNumTracks); + SDL_Log("ExtractFATDATA: detected multi-file CUE with %d tracks", + cueInfo.iNumTracks); ExtractFATDATAFromMultiFileCue(szImagePath, szOutDir, &cueInfo); return; } diff --git a/PROJECTS/ROLLER/rollercomms.c b/PROJECTS/ROLLER/rollercomms.c index f5d5fa4a..c0e2ceb0 100644 --- a/PROJECTS/ROLLER/rollercomms.c +++ b/PROJECTS/ROLLER/rollercomms.c @@ -25,17 +25,15 @@ //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tROLLERNetAddr address; SOCKET socket; bool bActive; } tNodeInfo; -static struct -{ +static struct { bool bInitialized; - int iNetType; // 0 = IPX-style, 1 = Serial-style + int iNetType; // 0 = IPX-style, 1 = Serial-style int iConsoleNode; int iActiveNodes; SOCKET listenSocket; @@ -57,33 +55,44 @@ static uint32_t s_uiLocalIPOverride = 0; // 0 = auto-detect //------------------------------------------------------------------------------------------------- -int ROLLERCommsEnumLocalAddrs(tROLLERNetIface *pOut, int iMax) -{ - if (!pOut || iMax <= 0) return 0; +int ROLLERCommsEnumLocalAddrs(tROLLERNetIface *pOut, int iMax) { + if (!pOut || iMax <= 0) + return 0; int iCount = 0; #ifdef IS_WINDOWS ULONG uiBufLen = 15000; IP_ADAPTER_ADDRESSES *pBuf = (IP_ADAPTER_ADDRESSES *)malloc(uiBufLen); - if (!pBuf) return 0; + if (!pBuf) + return 0; if (GetAdaptersAddresses(AF_INET, - GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, - NULL, pBuf, &uiBufLen) == ERROR_BUFFER_OVERFLOW) { + GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | + GAA_FLAG_SKIP_DNS_SERVER, + NULL, pBuf, &uiBufLen) == ERROR_BUFFER_OVERFLOW) { free(pBuf); pBuf = (IP_ADAPTER_ADDRESSES *)malloc(uiBufLen); - if (!pBuf) return 0; + if (!pBuf) + return 0; GetAdaptersAddresses(AF_INET, - GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER, - NULL, pBuf, &uiBufLen); - } - for (IP_ADAPTER_ADDRESSES *pAA = pBuf; pAA && iCount < iMax; pAA = pAA->Next) { - if (pAA->OperStatus != IfOperStatusUp) continue; - if (pAA->IfType == IF_TYPE_SOFTWARE_LOOPBACK) continue; - for (IP_ADAPTER_UNICAST_ADDRESS *pUA = pAA->FirstUnicastAddress; pUA; pUA = pUA->Next) { - if (pUA->Address.lpSockaddr->sa_family != AF_INET) continue; + GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | + GAA_FLAG_SKIP_DNS_SERVER, + NULL, pBuf, &uiBufLen); + } + for (IP_ADAPTER_ADDRESSES *pAA = pBuf; pAA && iCount < iMax; + pAA = pAA->Next) { + if (pAA->OperStatus != IfOperStatusUp) + continue; + if (pAA->IfType == IF_TYPE_SOFTWARE_LOOPBACK) + continue; + for (IP_ADAPTER_UNICAST_ADDRESS *pUA = pAA->FirstUnicastAddress; pUA; + pUA = pUA->Next) { + if (pUA->Address.lpSockaddr->sa_family != AF_INET) + continue; struct sockaddr_in *pSin = (struct sockaddr_in *)pUA->Address.lpSockaddr; - inet_ntop(AF_INET, &pSin->sin_addr, pOut[iCount].szIP, sizeof(pOut[iCount].szIP)); + inet_ntop(AF_INET, &pSin->sin_addr, pOut[iCount].szIP, + sizeof(pOut[iCount].szIP)); WideCharToMultiByte(CP_UTF8, 0, pAA->FriendlyName, -1, - pOut[iCount].szName, sizeof(pOut[iCount].szName), NULL, NULL); + pOut[iCount].szName, sizeof(pOut[iCount].szName), + NULL, NULL); iCount++; break; // one entry per adapter } @@ -92,12 +101,17 @@ int ROLLERCommsEnumLocalAddrs(tROLLERNetIface *pOut, int iMax) #else struct ifaddrs *pList = NULL; if (getifaddrs(&pList) == 0) { - for (struct ifaddrs *pIfa = pList; pIfa && iCount < iMax; pIfa = pIfa->ifa_next) { - if (!pIfa->ifa_addr || pIfa->ifa_addr->sa_family != AF_INET) continue; + for (struct ifaddrs *pIfa = pList; pIfa && iCount < iMax; + pIfa = pIfa->ifa_next) { + if (!pIfa->ifa_addr || pIfa->ifa_addr->sa_family != AF_INET) + continue; struct sockaddr_in *pSin = (struct sockaddr_in *)pIfa->ifa_addr; - if (pSin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) continue; - inet_ntop(AF_INET, &pSin->sin_addr, pOut[iCount].szIP, sizeof(pOut[iCount].szIP)); - strncpy(pOut[iCount].szName, pIfa->ifa_name, sizeof(pOut[iCount].szName) - 1); + if (pSin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) + continue; + inet_ntop(AF_INET, &pSin->sin_addr, pOut[iCount].szIP, + sizeof(pOut[iCount].szIP)); + strncpy(pOut[iCount].szName, pIfa->ifa_name, + sizeof(pOut[iCount].szName) - 1); pOut[iCount].szName[sizeof(pOut[iCount].szName) - 1] = '\0'; iCount++; } @@ -107,8 +121,7 @@ int ROLLERCommsEnumLocalAddrs(tROLLERNetIface *pOut, int iMax) return iCount; } -static uint32_t DetectLocalIPv4(void) -{ +static uint32_t DetectLocalIPv4(void) { tROLLERNetIface iface; if (ROLLERCommsEnumLocalAddrs(&iface, 1) < 1) return htonl(INADDR_LOOPBACK); @@ -117,8 +130,7 @@ static uint32_t DetectLocalIPv4(void) return addr.s_addr; } -static int InitializeSockets(void) -{ +static int InitializeSockets(void) { #ifdef IS_WINDOWS WSADATA wsaData; int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); @@ -132,16 +144,13 @@ static int InitializeSockets(void) //------------------------------------------------------------------------------------------------- -static int BuildPacket(uint8_t *pPacketBuffer, - int *pTotalSizeOut, - const void *pHeader, - int iHeaderSize, - const void *pData, - int iDataSize) -{ +static int BuildPacket(uint8_t *pPacketBuffer, int *pTotalSizeOut, + const void *pHeader, int iHeaderSize, const void *pData, + int iDataSize) { int iTotalSize = iHeaderSize + iDataSize; - if (!pPacketBuffer || !pTotalSizeOut || !pHeader || iHeaderSize < 0 || iDataSize < 0) + if (!pPacketBuffer || !pTotalSizeOut || !pHeader || iHeaderSize < 0 || + iDataSize < 0) return 0; if (iTotalSize > ROLLER_MAX_PACKET_SIZE) return 0; @@ -156,31 +165,30 @@ static int BuildPacket(uint8_t *pPacketBuffer, //------------------------------------------------------------------------------------------------- -static int SendPacketToIPv4(uint32_t uiIPAddress, uint16_t unPort, const uint8_t *pPacket, int iPacketSize) -{ +static int SendPacketToIPv4(uint32_t uiIPAddress, uint16_t unPort, + const uint8_t *pPacket, int iPacketSize) { struct sockaddr_in destAddr; memset(&destAddr, 0, sizeof(destAddr)); destAddr.sin_family = AF_INET; destAddr.sin_addr.s_addr = uiIPAddress; destAddr.sin_port = htons(unPort); - int iBytesSent = sendto(g_commsState.listenSocket, (const char *)pPacket, iPacketSize, 0, - (struct sockaddr *)&destAddr, sizeof(destAddr)); + int iBytesSent = + sendto(g_commsState.listenSocket, (const char *)pPacket, iPacketSize, 0, + (struct sockaddr *)&destAddr, sizeof(destAddr)); return (iBytesSent == iPacketSize) ? 1 : 0; } //------------------------------------------------------------------------------------------------- -static int IsLoopbackIPv4(uint32_t uiIPAddress) -{ +static int IsLoopbackIPv4(uint32_t uiIPAddress) { return (ntohl(uiIPAddress) & 0xFF000000u) == 0x7F000000u; } //------------------------------------------------------------------------------------------------- -static void CleanupSockets(void) -{ +static void CleanupSockets(void) { #ifdef IS_WINDOWS WSACleanup(); #endif @@ -188,15 +196,11 @@ static void CleanupSockets(void) //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetLocalPort(uint16_t unPort) -{ - s_unLocalPort = unPort; -} +void ROLLERCommsSetLocalPort(uint16_t unPort) { s_unLocalPort = unPort; } //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetLocalIP(const char *szIP) -{ +void ROLLERCommsSetLocalIP(const char *szIP) { if (!szIP || szIP[0] == '\0') { s_uiLocalIPOverride = 0; return; @@ -208,8 +212,7 @@ void ROLLERCommsSetLocalIP(const char *szIP) //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetPeer(const char *szIP, uint16_t unPort) -{ +void ROLLERCommsSetPeer(const char *szIP, uint16_t unPort) { struct in_addr addr; if (inet_pton(AF_INET, szIP, &addr) != 1) { printf("ROLLERCommsSetPeer: invalid IP address '%s'\n", szIP); @@ -224,8 +227,7 @@ void ROLLERCommsSetPeer(const char *szIP, uint16_t unPort) //------------------------------------------------------------------------------------------------- -int ROLLERCommsInitSystem(unsigned int uiMaxPackets) -{ +int ROLLERCommsInitSystem(unsigned int uiMaxPackets) { if (g_commsState.bInitialized) { return 1; } @@ -253,8 +255,10 @@ int ROLLERCommsInitSystem(unsigned int uiMaxPackets) int iBroadcast = 1; if (setsockopt(g_commsState.listenSocket, SOL_SOCKET, SO_BROADCAST, - (const char *)&iBroadcast, sizeof(iBroadcast)) == SOCKET_ERROR) { - SDL_Log("[NET-DISCOVERY] SO_BROADCAST setup failed; manual peers may still work"); + (const char *)&iBroadcast, + sizeof(iBroadcast)) == SOCKET_ERROR) { + SDL_Log("[NET-DISCOVERY] SO_BROADCAST setup failed; manual peers may still " + "work"); } struct sockaddr_in bindAddr; @@ -263,8 +267,10 @@ int ROLLERCommsInitSystem(unsigned int uiMaxPackets) bindAddr.sin_addr.s_addr = INADDR_ANY; bindAddr.sin_port = htons(s_unLocalPort); - if (bind(g_commsState.listenSocket, (struct sockaddr *)&bindAddr, sizeof(bindAddr)) == SOCKET_ERROR) { - printf("ROLLERCommsInitSystem: bind to port %u failed\n", (unsigned)s_unLocalPort); + if (bind(g_commsState.listenSocket, (struct sockaddr *)&bindAddr, + sizeof(bindAddr)) == SOCKET_ERROR) { + printf("ROLLERCommsInitSystem: bind to port %u failed\n", + (unsigned)s_unLocalPort); closesocket(g_commsState.listenSocket); CleanupSockets(); return 0; @@ -300,8 +306,7 @@ int ROLLERCommsInitSystem(unsigned int uiMaxPackets) //------------------------------------------------------------------------------------------------- -void ROLLERCommsUnInitSystem() -{ +void ROLLERCommsUnInitSystem() { if (!g_commsState.bInitialized) { return; } @@ -317,20 +322,15 @@ void ROLLERCommsUnInitSystem() //------------------------------------------------------------------------------------------------- -int ROLLERCommsSendData( - const void *pHeader, - int iHeaderSize, - const void *pData, - int iDataSize, - int iDestNode) -{ +int ROLLERCommsSendData(const void *pHeader, int iHeaderSize, const void *pData, + int iDataSize, int iDestNode) { if (!g_commsState.bInitialized) { return 0; } // Special case: node 21 means broadcast if (iDestNode == 21) { - // Broadcast to all active nodes + // Broadcast to all active nodes int iSuccess = 1; for (int i = 0; i < g_commsState.iActiveNodes; i++) { if (i != g_commsState.iConsoleNode && g_commsState.nodes[i].bActive) { @@ -342,54 +342,56 @@ int ROLLERCommsSendData( return iSuccess; } - if (iDestNode < 0 || iDestNode >= ROLLER_MAX_NODES || !g_commsState.nodes[iDestNode].bActive) { + if (iDestNode < 0 || iDestNode >= ROLLER_MAX_NODES || + !g_commsState.nodes[iDestNode].bActive) { return 0; } if (iDestNode == g_commsState.iConsoleNode) { - return 1; // Don't send to ourselves + return 1; // Don't send to ourselves } // Combine header and data into single packet uint8_t packetBuffer[ROLLER_MAX_PACKET_SIZE]; int iTotalSize = 0; - if (!BuildPacket(packetBuffer, &iTotalSize, pHeader, iHeaderSize, pData, iDataSize)) { + if (!BuildPacket(packetBuffer, &iTotalSize, pHeader, iHeaderSize, pData, + iDataSize)) { return 0; } return SendPacketToIPv4(g_commsState.nodes[iDestNode].address.uiIPAddress, g_commsState.nodes[iDestNode].address.unPort, - packetBuffer, - iTotalSize); + packetBuffer, iTotalSize); } //------------------------------------------------------------------------------------------------- -int ROLLERCommsBroadcastData( - const void *pHeader, - int iHeaderSize, - const void *pData, - int iDataSize, - uint16_t unPort) -{ +int ROLLERCommsBroadcastData(const void *pHeader, int iHeaderSize, + const void *pData, int iDataSize, + uint16_t unPort) { if (!g_commsState.bInitialized) { return 0; } uint8_t packetBuffer[ROLLER_MAX_PACKET_SIZE]; int iTotalSize = 0; - if (!BuildPacket(packetBuffer, &iTotalSize, pHeader, iHeaderSize, pData, iDataSize)) { + if (!BuildPacket(packetBuffer, &iTotalSize, pHeader, iHeaderSize, pData, + iDataSize)) { return 0; } int iSuccess = 0; - if (SendPacketToIPv4(htonl(INADDR_BROADCAST), unPort, packetBuffer, iTotalSize)) { - SDL_Log("[NET-DISCOVERY] broadcast init to 255.255.255.255:%u", (unsigned)unPort); + if (SendPacketToIPv4(htonl(INADDR_BROADCAST), unPort, packetBuffer, + iTotalSize)) { + SDL_Log("[NET-DISCOVERY] broadcast init to 255.255.255.255:%u", + (unsigned)unPort); iSuccess = 1; } if (s_unLocalPort != unPort && - SendPacketToIPv4(htonl(INADDR_BROADCAST), s_unLocalPort, packetBuffer, iTotalSize)) { - SDL_Log("[NET-DISCOVERY] broadcast init to 255.255.255.255:%u", (unsigned)s_unLocalPort); + SendPacketToIPv4(htonl(INADDR_BROADCAST), s_unLocalPort, packetBuffer, + iTotalSize)) { + SDL_Log("[NET-DISCOVERY] broadcast init to 255.255.255.255:%u", + (unsigned)s_unLocalPort); iSuccess = 1; } @@ -398,8 +400,7 @@ int ROLLERCommsBroadcastData( //------------------------------------------------------------------------------------------------- -int ROLLERCommsGetHeader(void *pHeaderOut, int iHeaderSize, void **ppDataOut) -{ +int ROLLERCommsGetHeader(void *pHeaderOut, int iHeaderSize, void **ppDataOut) { if (!g_commsState.bInitialized) { return 0; } @@ -407,8 +408,9 @@ int ROLLERCommsGetHeader(void *pHeaderOut, int iHeaderSize, void **ppDataOut) struct sockaddr_in fromAddr; socklen_t fromLen = sizeof(fromAddr); - int iBytesReceived = recvfrom(g_commsState.listenSocket, (char *)g_commsState.receiveBuffer, - ROLLER_MAX_PACKET_SIZE, 0, (struct sockaddr *)&fromAddr, &fromLen); + int iBytesReceived = recvfrom( + g_commsState.listenSocket, (char *)g_commsState.receiveBuffer, + ROLLER_MAX_PACKET_SIZE, 0, (struct sockaddr *)&fromAddr, &fromLen); if (iBytesReceived <= 0) { return 0; // No data available @@ -431,8 +433,7 @@ int ROLLERCommsGetHeader(void *pHeaderOut, int iHeaderSize, void **ppDataOut) //------------------------------------------------------------------------------------------------- -void ROLLERCommsGetBlock(void *pDataIn, void *pDataOut, int iSize) -{ +void ROLLERCommsGetBlock(void *pDataIn, void *pDataOut, int iSize) { if (pDataIn && pDataOut && iSize > 0) { memcpy(pDataOut, pDataIn, iSize); } @@ -440,8 +441,7 @@ void ROLLERCommsGetBlock(void *pDataIn, void *pDataOut, int iSize) //------------------------------------------------------------------------------------------------- -int ROLLERCommsPostListen(void) -{ +int ROLLERCommsPostListen(void) { // In non-blocking mode, this is a no-op // Return 1 if there might be more data, 0 otherwise return 0; @@ -449,22 +449,15 @@ int ROLLERCommsPostListen(void) //------------------------------------------------------------------------------------------------- -int ROLLERCommsGetActiveNodes(void) -{ - return g_commsState.iActiveNodes; -} +int ROLLERCommsGetActiveNodes(void) { return g_commsState.iActiveNodes; } //------------------------------------------------------------------------------------------------- -int ROLLERCommsGetConsoleNode(void) -{ - return g_commsState.iConsoleNode; -} +int ROLLERCommsGetConsoleNode(void) { return g_commsState.iConsoleNode; } //------------------------------------------------------------------------------------------------- -int ROLLERCommsAddNode(const void *pAddress) -{ +int ROLLERCommsAddNode(const void *pAddress) { tROLLERNetAddr address; if (!pAddress) return 2; @@ -486,29 +479,30 @@ int ROLLERCommsAddNode(const void *pAddress) // Idempotent: if this address is already in the table, do nothing for (int i = 0; i < g_commsState.iActiveNodes; i++) { - if (memcmp(&g_commsState.nodes[i].address, &address, sizeof(tROLLERNetAddr)) == 0) { - return 1; // Already present (not an error — > 1 is the failure sentinel) + if (memcmp(&g_commsState.nodes[i].address, &address, + sizeof(tROLLERNetAddr)) == 0) { + return 1; // Already present (not an error — > 1 is the failure sentinel) } } if (g_commsState.iActiveNodes >= ROLLER_MAX_NODES) { - return 2; // Too many nodes + return 2; // Too many nodes } int iNodeIdx = g_commsState.iActiveNodes; - memcpy(&g_commsState.nodes[iNodeIdx].address, &address, sizeof(tROLLERNetAddr)); + memcpy(&g_commsState.nodes[iNodeIdx].address, &address, + sizeof(tROLLERNetAddr)); g_commsState.nodes[iNodeIdx].bActive = true; g_commsState.iActiveNodes++; - return 0; // Success + return 0; // Success } //------------------------------------------------------------------------------------------------- -int ROLLERCommsDeleteNode(int iNodeIdx) -{ +int ROLLERCommsDeleteNode(int iNodeIdx) { if (iNodeIdx < 0 || iNodeIdx >= g_commsState.iActiveNodes) { - return 1; // Invalid node + return 1; // Invalid node } g_commsState.nodes[iNodeIdx].bActive = false; @@ -517,8 +511,7 @@ int ROLLERCommsDeleteNode(int iNodeIdx) //------------------------------------------------------------------------------------------------- -void ROLLERCommsSortNodes(void) -{ +void ROLLERCommsSortNodes(void) { // Compact: remove inactive nodes int iWriteIdx = 0; for (int iReadIdx = 0; iReadIdx < g_commsState.iActiveNodes; iReadIdx++) { @@ -561,64 +554,55 @@ void ROLLERCommsSortNodes(void) } } - // Diagnostic: dump the sorted node table so we can verify iConsoleNode is correct on each machine. + // Diagnostic: dump the sorted node table so we can verify iConsoleNode is + // correct on each machine. SDL_Log("[NET] SortNodes: %d active nodes, iConsoleNode=%d\n", - g_commsState.iActiveNodes, g_commsState.iConsoleNode); + g_commsState.iActiveNodes, g_commsState.iConsoleNode); for (int i = 0; i < g_commsState.iActiveNodes; i++) { char szIP[INET_ADDRSTRLEN]; - inet_ntop(AF_INET, &g_commsState.nodes[i].address.uiIPAddress, szIP, sizeof(szIP)); + inet_ntop(AF_INET, &g_commsState.nodes[i].address.uiIPAddress, szIP, + sizeof(szIP)); SDL_Log("[NET] node[%d]: %s:%u%s\n", i, szIP, - (unsigned)g_commsState.nodes[i].address.unPort, - i == g_commsState.iConsoleNode ? " <-- self" : ""); + (unsigned)g_commsState.nodes[i].address.unPort, + i == g_commsState.iConsoleNode ? " <-- self" : ""); } } //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetType(int iType) -{ - g_commsState.iNetType = iType; -} +void ROLLERCommsSetType(int iType) { g_commsState.iNetType = iType; } //------------------------------------------------------------------------------------------------- -int ROLLERCommsGetType(void) -{ - return g_commsState.iNetType; -} +int ROLLERCommsGetType(void) { return g_commsState.iNetType; } //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetCommandBase(int iCommandBase) -{ -// No-op for modern networking +void ROLLERCommsSetCommandBase(int iCommandBase) { + // No-op for modern networking } //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetComPort(int iPort) -{ -// No-op for modern networking +void ROLLERCommsSetComPort(int iPort) { + // No-op for modern networking } //------------------------------------------------------------------------------------------------- -void ROLLERCommsSetComBaudRate(int iBaudRate) -{ -// No-op for modern networking +void ROLLERCommsSetComBaudRate(int iBaudRate) { + // No-op for modern networking } //------------------------------------------------------------------------------------------------- -int ROLLER16550(int iPort) -{ - return 1; // Always return success +int ROLLER16550(int iPort) { + return 1; // Always return success } //------------------------------------------------------------------------------------------------- -void ROLLERCommsGetNetworkAddr(int *pAddressOut) -{ +void ROLLERCommsGetNetworkAddr(int *pAddressOut) { if (pAddressOut) { memcpy(pAddressOut, &g_commsState.myAddress, sizeof(tROLLERNetAddr)); } @@ -626,11 +610,11 @@ void ROLLERCommsGetNetworkAddr(int *pAddressOut) //------------------------------------------------------------------------------------------------- -int ROLLERCommsNetAddrToNode(const int *pAddress) -{ +int ROLLERCommsNetAddrToNode(const int *pAddress) { // Find node with matching address for (int i = 0; i < g_commsState.iActiveNodes; i++) { - if (memcmp(&g_commsState.nodes[i].address, pAddress, sizeof(tROLLERNetAddr)) == 0) { + if (memcmp(&g_commsState.nodes[i].address, pAddress, + sizeof(tROLLERNetAddr)) == 0) { return i; } } @@ -639,19 +623,19 @@ int ROLLERCommsNetAddrToNode(const int *pAddress) //------------------------------------------------------------------------------------------------- -void ROLLERCommsGetLocalAddrStr(char *szBuf, int iBufLen) -{ - if (!szBuf || iBufLen <= 0) return; +void ROLLERCommsGetLocalAddrStr(char *szBuf, int iBufLen) { + if (!szBuf || iBufLen <= 0) + return; uint32_t uiIP; uint16_t unPort; if (g_commsState.bInitialized) { - uiIP = g_commsState.myAddress.uiIPAddress; + uiIP = g_commsState.myAddress.uiIPAddress; unPort = g_commsState.myAddress.unPort; } else if (s_uiLocalIPOverride) { - uiIP = s_uiLocalIPOverride; + uiIP = s_uiLocalIPOverride; unPort = s_unLocalPort; } else { - uiIP = DetectLocalIPv4(); + uiIP = DetectLocalIPv4(); unPort = s_unLocalPort; } char szIP[INET_ADDRSTRLEN]; @@ -663,10 +647,11 @@ void ROLLERCommsGetLocalAddrStr(char *szBuf, int iBufLen) //------------------------------------------------------------------------------------------------- -void ROLLERCommsGetNodeAddrStr(int iNode, char *szBuf, int iBufLen) -{ - if (!szBuf || iBufLen <= 0) return; - if (!g_commsState.bInitialized || iNode < 0 || iNode >= g_commsState.iActiveNodes) { +void ROLLERCommsGetNodeAddrStr(int iNode, char *szBuf, int iBufLen) { + if (!szBuf || iBufLen <= 0) + return; + if (!g_commsState.bInitialized || iNode < 0 || + iNode >= g_commsState.iActiveNodes) { snprintf(szBuf, iBufLen, "---"); return; } @@ -674,14 +659,16 @@ void ROLLERCommsGetNodeAddrStr(int iNode, char *szBuf, int iBufLen) struct in_addr addr; addr.s_addr = g_commsState.nodes[iNode].address.uiIPAddress; inet_ntop(AF_INET, &addr, szIP, sizeof(szIP)); - snprintf(szBuf, iBufLen, "%s:%u", szIP, (unsigned)g_commsState.nodes[iNode].address.unPort); + snprintf(szBuf, iBufLen, "%s:%u", szIP, + (unsigned)g_commsState.nodes[iNode].address.unPort); } //------------------------------------------------------------------------------------------------- -void ROLLERCommsFormatAddr(const tROLLERNetAddr *pAddress, char *szBuf, int iBufLen) -{ - if (!szBuf || iBufLen <= 0) return; +void ROLLERCommsFormatAddr(const tROLLERNetAddr *pAddress, char *szBuf, + int iBufLen) { + if (!szBuf || iBufLen <= 0) + return; if (!pAddress) { snprintf(szBuf, iBufLen, "---"); return; @@ -696,25 +683,27 @@ void ROLLERCommsFormatAddr(const tROLLERNetAddr *pAddress, char *szBuf, int iBuf //------------------------------------------------------------------------------------------------- -void ROLLERclrrx(void) -{ -// Clear receive buffer - could implement if needed +void ROLLERclrrx(void) { + // Clear receive buffer - could implement if needed } //------------------------------------------------------------------------------------------------- -void ROLLERclrtx(void) -{ -// Clear transmit buffer - could implement if needed +void ROLLERclrtx(void) { + // Clear transmit buffer - could implement if needed } //------------------------------------------------------------------------------------------------- // Modem stubs (always succeed immediately for local network) int ROLLERModemHangUp(void) { return 1; } -int ROLLERModemInit(const char *szInitString, int p1, int p2, int p3) { return 1; } +int ROLLERModemInit(const char *szInitString, int p1, int p2, int p3) { + return 1; +} int ROLLERModemDial(const char *szPhoneNumber, int iToneMode) { return 1; } int ROLLERModemAnswer(void) { return 1; } -int ROLLERModemCheckResponse(int p1, int p2, int p3, int p4) { return 0; /* Ready */ } +int ROLLERModemCheckResponse(int p1, int p2, int p3, int p4) { + return 0; /* Ready */ +} //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/rollercomms.h b/PROJECTS/ROLLER/rollercomms.h index c048075b..f9c36f02 100644 --- a/PROJECTS/ROLLER/rollercomms.h +++ b/PROJECTS/ROLLER/rollercomms.h @@ -10,19 +10,18 @@ #define ROLLER_MAX_PACKET_SIZE 1024 #define ROLLER_MAX_IFACES 8 -typedef struct -{ +typedef struct { char szIP[16]; // dotted-decimal IPv4 char szName[48]; // interface / adapter friendly name } tROLLERNetIface; //------------------------------------------------------------------------------------------------- -typedef struct -{ - uint32 uiIPAddress; // IPv4 address in network byte order - uint16 unPort; // Port number +typedef struct { + uint32 uiIPAddress; // IPv4 address in network byte order + uint16 unPort; // Port number uint16 unPadding; - uint64 ullReserved; // Must be zero — pads to 16 bytes to match _NETNOW_NODE_ADDR + uint64 + ullReserved; // Must be zero — pads to 16 bytes to match _NETNOW_NODE_ADDR } tROLLERNetAddr; //------------------------------------------------------------------------------------------------- @@ -49,22 +48,15 @@ int ROLLERCommsNetAddrToNode(const int *pAddress); void ROLLERCommsGetNetworkAddr(int *pAddressOut); void ROLLERCommsGetLocalAddrStr(char *szBuf, int iBufLen); void ROLLERCommsGetNodeAddrStr(int iNode, char *szBuf, int iBufLen); -void ROLLERCommsFormatAddr(const tROLLERNetAddr *pAddress, char *szBuf, int iBufLen); -int ROLLERCommsEnumLocalAddrs(tROLLERNetIface *pOut, int iMax); +void ROLLERCommsFormatAddr(const tROLLERNetAddr *pAddress, char *szBuf, + int iBufLen); +int ROLLERCommsEnumLocalAddrs(tROLLERNetIface *pOut, int iMax); // Data transmission -int ROLLERCommsSendData( - const void *pHeader, - int iHeaderSize, - const void *pData, - int iDataSize, - int iDestNode); -int ROLLERCommsBroadcastData( - const void *pHeader, - int iHeaderSize, - const void *pData, - int iDataSize, - uint16_t unPort); +int ROLLERCommsSendData(const void *pHeader, int iHeaderSize, const void *pData, + int iDataSize, int iDestNode); +int ROLLERCommsBroadcastData(const void *pHeader, int iHeaderSize, + const void *pData, int iDataSize, uint16_t unPort); // Data reception int ROLLERCommsGetHeader(void *pHeaderOut, int iHeaderSize, void **ppDataOut); @@ -84,10 +76,12 @@ void ROLLERclrtx(void); // Clear transmit buffer // Modem emulation (for compatibility) int ROLLERModemHangUp(void); -int ROLLERModemInit(const char *szInitString, int iParam1, int iParam2, int iParam3); +int ROLLERModemInit(const char *szInitString, int iParam1, int iParam2, + int iParam3); int ROLLERModemDial(const char *szPhoneNumber, int iToneMode); int ROLLERModemAnswer(void); -int ROLLERModemCheckResponse(int iParam1, int iParam2, int iParam3, int iParam4); +int ROLLERModemCheckResponse(int iParam1, int iParam2, int iParam3, + int iParam4); //------------------------------------------------------------------------------------------------- #endif // _ROLLER_ROLLERCOMMS_H diff --git a/PROJECTS/ROLLER/scene_render.c b/PROJECTS/ROLLER/scene_render.c index fac65416..379c360c 100644 --- a/PROJECTS/ROLLER/scene_render.c +++ b/PROJECTS/ROLLER/scene_render.c @@ -4,83 +4,82 @@ #include struct SceneRenderer { - SceneRendererSoftware *sw; - SDL_GPUDevice *device; - SDL_Window *window; + SceneRendererSoftware *sw; + SDL_GPUDevice *device; + SDL_Window *window; }; SceneRenderer *scene_render_create(SDL_GPUDevice *device, SDL_Window *window) { - SceneRenderer *r = calloc(1, sizeof(SceneRenderer)); - if (!r) - return NULL; - r->device = device; - r->window = window; - r->sw = scene_render_sw_create(device, window); - if (!r->sw) { - free(r); - return NULL; - } - return r; + SceneRenderer *r = calloc(1, sizeof(SceneRenderer)); + if (!r) + return NULL; + r->device = device; + r->window = window; + r->sw = scene_render_sw_create(device, window); + if (!r->sw) { + free(r); + return NULL; + } + return r; } void scene_render_destroy(SceneRenderer *renderer) { - if (!renderer) - return; - scene_render_sw_destroy(renderer->sw); - free(renderer); + if (!renderer) + return; + scene_render_sw_destroy(renderer->sw); + free(renderer); } -void scene_render_set_target(SceneRenderer *renderer, uint8 *buffer, - int stride, int width, int height) { - if (!renderer) - return; - scene_render_sw_set_target(renderer->sw, buffer, stride, width, height); +void scene_render_set_target(SceneRenderer *renderer, uint8 *buffer, int stride, + int width, int height) { + if (!renderer) + return; + scene_render_sw_set_target(renderer->sw, buffer, stride, width, height); } -void scene_render_set_viewport(SceneRenderer *renderer, - int x, int y, int w, int h) { - if (!renderer) - return; - scene_render_sw_set_viewport(renderer->sw, x, y, w, h); +void scene_render_set_viewport(SceneRenderer *renderer, int x, int y, int w, + int h) { + if (!renderer) + return; + scene_render_sw_set_viewport(renderer->sw, x, y, w, h); } void scene_render_set_camera(SceneRenderer *renderer, const SceneRenderCamera *camera) { - if (!renderer || !camera) - return; - scene_render_sw_set_camera(renderer->sw, camera); + if (!renderer || !camera) + return; + scene_render_sw_set_camera(renderer->sw, camera); } void scene_render_set_projection(SceneRenderer *renderer, const SceneRenderProjection *projection) { - if (!renderer || !projection) - return; - scene_render_sw_set_projection(renderer->sw, projection); + if (!renderer || !projection) + return; + scene_render_sw_set_projection(renderer->sw, projection); } SceneTextureHandle scene_render_load_texture(SceneRenderer *renderer, - uint8 *pixelData, - int width, int height, - int tex_idx, + uint8 *pixelData, int width, + int height, int tex_idx, int texHalfRes) { - if (!renderer) - return SCENE_TEXTURE_HANDLE_INVALID; - return scene_render_sw_load_texture(renderer->sw, pixelData, width, height, - tex_idx, texHalfRes); + if (!renderer) + return SCENE_TEXTURE_HANDLE_INVALID; + return scene_render_sw_load_texture(renderer->sw, pixelData, width, height, + tex_idx, texHalfRes); } void scene_render_free_texture(SceneRenderer *renderer, SceneTextureHandle handle) { - if (!renderer) - return; - scene_render_sw_free_texture(renderer->sw, handle); + if (!renderer) + return; + scene_render_sw_free_texture(renderer->sw, handle); } SceneTextureHandle scene_render_get_texture_handle(SceneRenderer *renderer, int tex_idx) { - if (!renderer) - return SCENE_TEXTURE_HANDLE_INVALID; - return scene_render_sw_get_texture_handle(renderer->sw, tex_idx); + if (!renderer) + return SCENE_TEXTURE_HANDLE_INVALID; + return scene_render_sw_get_texture_handle(renderer->sw, tex_idx); } void scene_render_quad_world_legacy(SceneRenderer *renderer, @@ -88,8 +87,8 @@ void scene_render_quad_world_legacy(SceneRenderer *renderer, SceneTextureHandle texture, int surfaceFlags, SceneRenderLegacyQuadOptions options) { - if (!renderer || !verts) - return; - scene_render_sw_quad_world_legacy(renderer->sw, verts, texture, - surfaceFlags, options); + if (!renderer || !verts) + return; + scene_render_sw_quad_world_legacy(renderer->sw, verts, texture, surfaceFlags, + options); } diff --git a/PROJECTS/ROLLER/scene_render.h b/PROJECTS/ROLLER/scene_render.h index 034237e1..bb59fcdf 100644 --- a/PROJECTS/ROLLER/scene_render.h +++ b/PROJECTS/ROLLER/scene_render.h @@ -4,62 +4,62 @@ #include #include "types.h" -/* Texture bank indices passed to scene_render_load_texture / get_texture_handle. - * These identify which legacy asset category a texture belongs to. */ -#define TEXTURE_BANK_TRACK 0 +/* Texture bank indices passed to scene_render_load_texture / + * get_texture_handle. These identify which legacy asset category a texture + * belongs to. */ +#define TEXTURE_BANK_TRACK 0 #define TEXTURE_BANK_BUILDING 17 -#define TEXTURE_BANK_CARGEN 18 +#define TEXTURE_BANK_CARGEN 18 typedef struct SceneRenderer SceneRenderer; typedef int SceneTextureHandle; #define SCENE_TEXTURE_HANDLE_INVALID 0 typedef struct { - float x, y, z; // world-space position - float u, v; // texture coordinates + float x, y, z; // world-space position + float u, v; // texture coordinates } SceneRenderVertex; -#define SCENE_RENDER_SUBDIVIDE_TYPE_AUTO (-2147483647 - 1) -#define SCENE_RENDER_SUBDIVIDE_TYPE_CLOUD (-2147483647) +#define SCENE_RENDER_SUBDIVIDE_TYPE_AUTO (-2147483647 - 1) +#define SCENE_RENDER_SUBDIVIDE_TYPE_CLOUD (-2147483647) #define SCENE_RENDER_SUBDIVIDE_TYPE_BUILDING 666 typedef struct { - float viewX, viewY, viewZ; - float cosYaw, sinYaw; - float fovScale; + float viewX, viewY, viewZ; + float cosYaw, sinYaw; + float fovScale; } SceneRenderCamera; // Column-major 3×3 view matrix + screen-space projection state. // view[col][row] maps to GLSL mat3 for direct GPU upload. typedef struct { - float view[3][3]; - int screenScale; // 6-bit fixed-point scale (was scr_size) - int centerX; // projection origin X (was xbase) - int centerY; // projection origin Y (was ybase) - int texHalfRes; // 0=64×64, 1=32×32 (was gfx_size) + float view[3][3]; + int screenScale; // 6-bit fixed-point scale (was scr_size) + int centerX; // projection origin X (was xbase) + int centerY; // projection origin Y (was ybase) + int texHalfRes; // 0=64×64, 1=32×32 (was gfx_size) } SceneRenderProjection; typedef struct { - int subdivideType; - float subThreshold; + int subdivideType; + float subThreshold; } SceneRenderLegacyQuadOptions; SceneRenderer *scene_render_create(SDL_GPUDevice *device, SDL_Window *window); void scene_render_destroy(SceneRenderer *renderer); -void scene_render_set_target(SceneRenderer *renderer, uint8 *buffer, - int stride, int width, int height); -void scene_render_set_viewport(SceneRenderer *renderer, - int x, int y, int w, int h); +void scene_render_set_target(SceneRenderer *renderer, uint8 *buffer, int stride, + int width, int height); +void scene_render_set_viewport(SceneRenderer *renderer, int x, int y, int w, + int h); void scene_render_set_camera(SceneRenderer *renderer, const SceneRenderCamera *camera); void scene_render_set_projection(SceneRenderer *renderer, const SceneRenderProjection *projection); SceneTextureHandle scene_render_load_texture(SceneRenderer *renderer, - uint8 *pixelData, - int width, int height, - int tex_idx, + uint8 *pixelData, int width, + int height, int tex_idx, int texHalfRes); void scene_render_free_texture(SceneRenderer *renderer, SceneTextureHandle handle); diff --git a/PROJECTS/ROLLER/scene_render_software.c b/PROJECTS/ROLLER/scene_render_software.c index 11b2054b..643d0499 100644 --- a/PROJECTS/ROLLER/scene_render_software.c +++ b/PROJECTS/ROLLER/scene_render_software.c @@ -18,143 +18,142 @@ /* SubpolyType values passed to dodivide for texture routing. * -1 = wide wall (2048x1024), 0 = standard track (1024x1024), * 666 = building (other_texture[] lookup). */ -#define SUBPOLY_WALL (-1) -#define SUBPOLY_STANDARD 0 +#define SUBPOLY_WALL (-1) +#define SUBPOLY_STANDARD 0 #define SUBPOLY_BUILDING SCENE_RENDER_SUBDIVIDE_TYPE_BUILDING //------------------------------------------------------------------------------------------------- -//000257E0 -static void dodivide(float fX0_3D, float fY0_3D, float fZ0_3D, - float fX1_3D, float fY1_3D, float fZ1_3D, - float fX2_3D, float fY2_3D, float fZ2_3D, - float fX3_3D, float fY3_3D, float fZ3_3D, - int iScreenX0, int iScreenY0, int iScreenX1, int iScreenY1, int iScreenX2, int iScreenY2, int iScreenX3, int iScreenY3, - int iTexU, int iTexV, int iTexWid, int iTexHgt) -{ - int iCullFlag; // edx - float fMaxZ; // eax - float fMaxZ_temp; // eax - float fMaxZ_final; // eax - float fMinZ; // eax - float fMinZ_temp; // eax - float fMinZ_final; // eax - int iMaxScreenX; // eax - int iMaxScreenX_temp; // eax - int iMinScreenX; // eax - int iMinScreenX_temp; // eax - int iMaxScreenY; // eax - int iMaxScreenY_temp; // eax - int iMinScreenY; // eax - int iMinScreenY_temp; // eax - tPolyParams *pPolyParams; // edx - int iPolyType; // eax - uint8 *pFrameBuf; // eax - double dViewDist; // st7 - double dInvZ; // st6 - double dScreenScale; // st5 - double dProjX; // st4 - double dProjY; // st7 - double dViewDist_1; // st7 - double dInvZ_1; // st6 - double dScreenScale_1; // st5 - double dProjX_1; // st4 - double dProjY_1; // st7 - double dViewDist_2; // st7 - double dInvZ_2; // st6 - double dScreenScale_2; // st5 - double dProjX_2; // st4 - double dProjY_2; // st7 - double dViewDist_3; // st7 - double dInvZ_3; // st6 - double dScreenScale_3; // st5 - double dProjX_3; // st4 - double dProjY_3; // st7 - double dViewDist_4; // st7 - double dInvZ_4; // st6 - double dScreenScale_4; // st5 - double dProjX_4; // st4 - double dProjY_4; // st7 - double dViewDist_5; // st7 - double dInvZ_5; // st6 - double dScreenScale_5; // st5 - double dProjX_5; // st4 - double dProjY_5; // st7 - double dViewDist_6; // st7 - double dInvZ_6; // st6 - double dScreenScale_6; // st5 - double dProjX_6; // st4 - double dProjY_6; // st7 - double dViewDist_7; // st7 - double dInvZ_7; // st6 - double dScreenScale_7; // st5 - double dProjX_7; // st4 - double dProjY_7; // st7 - double dViewDist_8; // st7 - double dInvZ_8; // st6 - double dScreenScale_8; // st5 - double dProjX_8; // st4 - double dProjY_8; // st7 - int iTexU_right; // edx - int iScreenCenterY; // [esp-28h] [ebp-180h] +// 000257E0 +static void dodivide(float fX0_3D, float fY0_3D, float fZ0_3D, float fX1_3D, + float fY1_3D, float fZ1_3D, float fX2_3D, float fY2_3D, + float fZ2_3D, float fX3_3D, float fY3_3D, float fZ3_3D, + int iScreenX0, int iScreenY0, int iScreenX1, int iScreenY1, + int iScreenX2, int iScreenY2, int iScreenX3, int iScreenY3, + int iTexU, int iTexV, int iTexWid, int iTexHgt) { + int iCullFlag; // edx + float fMaxZ; // eax + float fMaxZ_temp; // eax + float fMaxZ_final; // eax + float fMinZ; // eax + float fMinZ_temp; // eax + float fMinZ_final; // eax + int iMaxScreenX; // eax + int iMaxScreenX_temp; // eax + int iMinScreenX; // eax + int iMinScreenX_temp; // eax + int iMaxScreenY; // eax + int iMaxScreenY_temp; // eax + int iMinScreenY; // eax + int iMinScreenY_temp; // eax + tPolyParams *pPolyParams; // edx + int iPolyType; // eax + uint8 *pFrameBuf; // eax + double dViewDist; // st7 + double dInvZ; // st6 + double dScreenScale; // st5 + double dProjX; // st4 + double dProjY; // st7 + double dViewDist_1; // st7 + double dInvZ_1; // st6 + double dScreenScale_1; // st5 + double dProjX_1; // st4 + double dProjY_1; // st7 + double dViewDist_2; // st7 + double dInvZ_2; // st6 + double dScreenScale_2; // st5 + double dProjX_2; // st4 + double dProjY_2; // st7 + double dViewDist_3; // st7 + double dInvZ_3; // st6 + double dScreenScale_3; // st5 + double dProjX_3; // st4 + double dProjY_3; // st7 + double dViewDist_4; // st7 + double dInvZ_4; // st6 + double dScreenScale_4; // st5 + double dProjX_4; // st4 + double dProjY_4; // st7 + double dViewDist_5; // st7 + double dInvZ_5; // st6 + double dScreenScale_5; // st5 + double dProjX_5; // st4 + double dProjY_5; // st7 + double dViewDist_6; // st7 + double dInvZ_6; // st6 + double dScreenScale_6; // st5 + double dProjX_6; // st4 + double dProjY_6; // st7 + double dViewDist_7; // st7 + double dInvZ_7; // st6 + double dScreenScale_7; // st5 + double dProjX_7; // st4 + double dProjY_7; // st7 + double dViewDist_8; // st7 + double dInvZ_8; // st6 + double dScreenScale_8; // st5 + double dProjX_8; // st4 + double dProjY_8; // st7 + int iTexU_right; // edx + int iScreenCenterY; // [esp-28h] [ebp-180h] tPolyParams *pPolyParamsLocal; // [esp+Ch] [ebp-14Ch] - float fMidZ_Edge01; // [esp+10h] [ebp-148h] - float fMidZ_Edge23; // [esp+14h] [ebp-144h] - float fMidZ_Edge03; // [esp+18h] [ebp-140h] - int iRenderFlag; // [esp+1Ch] [ebp-13Ch] - int iMaxScreenCoord; // [esp+28h] [ebp-130h] - int iMinScreenCoord; // [esp+30h] [ebp-128h] - float fMinZ_edge; // [esp+3Ch] [ebp-11Ch] - float fMaxZ_quad; // [esp+54h] [ebp-104h] - int iMaxScreenX_quad; // [esp+5Ch] [ebp-FCh] - int iMinScreenY_quad; // [esp+64h] [ebp-F4h] - int iScreenCenterX_calc; // [esp+78h] [ebp-E0h] - float fMidZ_quad; // [esp+7Ch] [ebp-DCh] - int iScreenY_mid30; // [esp+8Ch] [ebp-CCh] - int iScreenX_mid30; // [esp+90h] [ebp-C8h] - int iScreenY_mid12; // [esp+94h] [ebp-C4h] - int iScreenX_mid23; // [esp+98h] [ebp-C0h] - float fX_mid01; // [esp+9Ch] [ebp-BCh] - float fY_mid01; // [esp+A0h] [ebp-B8h] - int iScreenX_mid12; // [esp+A4h] [ebp-B4h] - float fZ_mid30; // [esp+A8h] [ebp-B0h] - float fY_mid30; // [esp+ACh] [ebp-ACh] - float fX_mid30; // [esp+B0h] [ebp-A8h] - float fZ_mid12; // [esp+B4h] [ebp-A4h] - float fY_mid12; // [esp+B8h] [ebp-A0h] - float fX_mid12; // [esp+BCh] [ebp-9Ch] - float fZ_mid12_1; // [esp+C0h] [ebp-98h] - float fY_mid12_1; // [esp+C4h] [ebp-94h] - float fX_mid12_1; // [esp+C8h] [ebp-90h] - int iScreenY_mid12_1; // [esp+CCh] [ebp-8Ch] - int iScreenX_mid12_1; // [esp+D0h] [ebp-88h] - int iScreenX_subdiv1; // [esp+D4h] [ebp-84h] - int iTexV_bottom; // [esp+D8h] [ebp-80h] - int iScreenY_mid01; // [esp+E4h] [ebp-74h] - int iScreenY_mid23; // [esp+E8h] [ebp-70h] - int iScreenX_mid01; // [esp+ECh] [ebp-6Ch] - int iScreenY_mid30_1; // [esp+F0h] [ebp-68h] - int iScreenX_mid23_1; // [esp+F4h] [ebp-64h] - int iScreenY_mid30_2; // [esp+FCh] [ebp-5Ch] - int iScreenX_mid12_2; // [esp+100h] [ebp-58h] - int iScreenX_mid30_1; // [esp+104h] [ebp-54h] - float fY_mid12_2; // [esp+108h] [ebp-50h] - float fZ_mid12_2; // [esp+10Ch] [ebp-4Ch] - float fZ_mid30_1; // [esp+110h] [ebp-48h] - float fX_mid30_1; // [esp+114h] [ebp-44h] - float fX_mid12_2; // [esp+118h] [ebp-40h] - float fY_mid30_1; // [esp+11Ch] [ebp-3Ch] - float fY_mid23; // [esp+120h] [ebp-38h] - float fZ_mid23; // [esp+124h] [ebp-34h] - float fX_mid23; // [esp+128h] [ebp-30h] - int iScreenY_center; // [esp+12Ch] [ebp-2Ch] - float fX_center; // [esp+130h] [ebp-28h] - float fY_center; // [esp+134h] [ebp-24h] - float fZ_center; // [esp+138h] [ebp-20h] - int iScreenX_center; // [esp+13Ch] [ebp-1Ch] + float fMidZ_Edge01; // [esp+10h] [ebp-148h] + float fMidZ_Edge23; // [esp+14h] [ebp-144h] + float fMidZ_Edge03; // [esp+18h] [ebp-140h] + int iRenderFlag; // [esp+1Ch] [ebp-13Ch] + int iMaxScreenCoord; // [esp+28h] [ebp-130h] + int iMinScreenCoord; // [esp+30h] [ebp-128h] + float fMinZ_edge; // [esp+3Ch] [ebp-11Ch] + float fMaxZ_quad; // [esp+54h] [ebp-104h] + int iMaxScreenX_quad; // [esp+5Ch] [ebp-FCh] + int iMinScreenY_quad; // [esp+64h] [ebp-F4h] + int iScreenCenterX_calc; // [esp+78h] [ebp-E0h] + float fMidZ_quad; // [esp+7Ch] [ebp-DCh] + int iScreenY_mid30; // [esp+8Ch] [ebp-CCh] + int iScreenX_mid30; // [esp+90h] [ebp-C8h] + int iScreenY_mid12; // [esp+94h] [ebp-C4h] + int iScreenX_mid23; // [esp+98h] [ebp-C0h] + float fX_mid01; // [esp+9Ch] [ebp-BCh] + float fY_mid01; // [esp+A0h] [ebp-B8h] + int iScreenX_mid12; // [esp+A4h] [ebp-B4h] + float fZ_mid30; // [esp+A8h] [ebp-B0h] + float fY_mid30; // [esp+ACh] [ebp-ACh] + float fX_mid30; // [esp+B0h] [ebp-A8h] + float fZ_mid12; // [esp+B4h] [ebp-A4h] + float fY_mid12; // [esp+B8h] [ebp-A0h] + float fX_mid12; // [esp+BCh] [ebp-9Ch] + float fZ_mid12_1; // [esp+C0h] [ebp-98h] + float fY_mid12_1; // [esp+C4h] [ebp-94h] + float fX_mid12_1; // [esp+C8h] [ebp-90h] + int iScreenY_mid12_1; // [esp+CCh] [ebp-8Ch] + int iScreenX_mid12_1; // [esp+D0h] [ebp-88h] + int iScreenX_subdiv1; // [esp+D4h] [ebp-84h] + int iTexV_bottom; // [esp+D8h] [ebp-80h] + int iScreenY_mid01; // [esp+E4h] [ebp-74h] + int iScreenY_mid23; // [esp+E8h] [ebp-70h] + int iScreenX_mid01; // [esp+ECh] [ebp-6Ch] + int iScreenY_mid30_1; // [esp+F0h] [ebp-68h] + int iScreenX_mid23_1; // [esp+F4h] [ebp-64h] + int iScreenY_mid30_2; // [esp+FCh] [ebp-5Ch] + int iScreenX_mid12_2; // [esp+100h] [ebp-58h] + int iScreenX_mid30_1; // [esp+104h] [ebp-54h] + float fY_mid12_2; // [esp+108h] [ebp-50h] + float fZ_mid12_2; // [esp+10Ch] [ebp-4Ch] + float fZ_mid30_1; // [esp+110h] [ebp-48h] + float fX_mid30_1; // [esp+114h] [ebp-44h] + float fX_mid12_2; // [esp+118h] [ebp-40h] + float fY_mid30_1; // [esp+11Ch] [ebp-3Ch] + float fY_mid23; // [esp+120h] [ebp-38h] + float fZ_mid23; // [esp+124h] [ebp-34h] + float fX_mid23; // [esp+128h] [ebp-30h] + int iScreenY_center; // [esp+12Ch] [ebp-2Ch] + float fX_center; // [esp+130h] [ebp-28h] + float fY_center; // [esp+134h] [ebp-24h] + float fZ_center; // [esp+138h] [ebp-20h] + int iScreenX_center; // [esp+13Ch] [ebp-1Ch] while (2) { iCullFlag = 0; - divtype = 0; // Reset subdivision type + divtype = 0; // Reset subdivision type // Find maximum Z value among all 4 verts if (fZ0_3D <= (double)fZ1_3D) @@ -299,9 +298,9 @@ static void dodivide(float fX0_3D, float fY0_3D, float fZ0_3D, } else { // Polygon is too close, check if we should subdivide based on tex size if (iTexWid > min_sub_size) - ++divtype; // subdivide horizontally + ++divtype; // subdivide horizontally if (iTexHgt > min_sub_size) - divtype += 2; // subdivide vertically + divtype += 2; // subdivide vertically iRenderFlag = 0; } @@ -309,979 +308,729 @@ static void dodivide(float fX0_3D, float fY0_3D, float fZ0_3D, if (!iCullFlag) { // Additional subdivision checks based on polygon screen size if (!divtype && !flatpol) { - // Calculate perimeter in screen space to determine if polygon is large enough to subdivide - polyxsize = abs(iScreenY3 - iScreenY2) + abs(iScreenY0 - iScreenY1) + abs(iScreenX3 - iScreenX2) + abs(iScreenX0 - iScreenX1); - polyysize = abs(iScreenY1 - iScreenY2) + abs(iScreenY0 - iScreenY3) + abs(iScreenX1 - iScreenX2) + abs(iScreenX0 - iScreenX3); + // Calculate perimeter in screen space to determine if polygon is large + // enough to subdivide + polyxsize = abs(iScreenY3 - iScreenY2) + abs(iScreenY0 - iScreenY1) + + abs(iScreenX3 - iScreenX2) + abs(iScreenX0 - iScreenX1); + polyysize = abs(iScreenY1 - iScreenY2) + abs(iScreenY0 - iScreenY3) + + abs(iScreenX1 - iScreenX2) + abs(iScreenX0 - iScreenX3); if (polyxsize > small_poly && iTexWid > min_sub_size) - ++divtype; // Subdivide horizontally if pol is large enough + ++divtype; // Subdivide horizontally if pol is large enough if (polyysize > small_poly && iTexHgt > min_sub_size) - divtype += 2; // Subdivide vertically if pol is large enough + divtype += 2; // Subdivide vertically if pol is large enough } // Calculate midpoints for potential subdivision fMidZ_Edge23 = fZ0_3D + fZ1_3D; fMidZ_Edge01 = fY0_3D + fY1_3D; fMidZ_Edge03 = fX0_3D + fX1_3D; - fY_mid01 = fMidZ_Edge23 * 0.5f; // Midpoint between verts 0 and 1 + fY_mid01 = fMidZ_Edge23 * 0.5f; // Midpoint between verts 0 and 1 fMidZ_quad = fMidZ_Edge01 * 0.5f; - iScreenCenterX_calc = winw / 2; // screen center x + iScreenCenterX_calc = winw / 2; // screen center x fX_mid01 = fMidZ_Edge03 * 0.5f; switch (divtype) { - case 0: // No subdivision - render the polygon - if (!iRenderFlag) - return; // don't render if flag is not set - - // Set up pol params for rendering - pPolyParamsLocal = subpoly; - pPolyParams = subpoly; - subpoly->vertices[0].x = iScreenX0; - pPolyParams->vertices[2].x = iScreenX2; - pPolyParams->vertices[2].y = iScreenY2; - pPolyParams->vertices[3].x = iScreenX3; - pPolyParams->vertices[3].y = iScreenY3; - - // Set up texture coords in 16.16 fixed point - startsx[0] = (iTexWid + iTexU - 1) << 12; - startsx[1] = iTexU << 12; - startsx[2] = iTexU << 12; - startsx[3] = (iTexWid + iTexU - 1) << 12; - startsy[0] = iTexV << 12; - startsy[1] = iTexV << 12; - pPolyParams->vertices[0].y = iScreenY0; - pPolyParams->vertices[1].x = iScreenX1; - startsy[2] = (iTexHgt + iTexV - 1) << 12; - startsy[3] = (iTexHgt + iTexV - 1) << 12; - - iPolyType = subpolytype; - pPolyParams->vertices[1].y = iScreenY1; - - // Render based on pol type - if (iPolyType < 1) { - if (iPolyType < -2) { - // Check if tex should be applied - LABEL_111: - if ((subpoly->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) != 0)// SURFACE_FLAG_APPLY_TEXTURE - { - // Render textured pol with car texture - //TODO is this correct? - game_render_quad_screen( - g_pGameRenderer, - subpoly, - game_render_get_texture_handle(g_pGameRenderer, car_texmap[subpolytype - 3]), - NULL); - //POLYTEX( - // (&horizon_vga)[*(&car_draw_order[15].iChunkIdx + subpolytype)],// offset into car_texmap - // subptr, - // subpoly, - // *(&car_draw_order[15].iChunkIdx + subpolytype),// offset into car_texmap - // gfx_size); - goto LABEL_115; - } - pFrameBuf = subptr; - pPolyParams = subpoly; - LABEL_114: - game_render_quad_screen(g_pGameRenderer, pPolyParams, TEXTURE_HANDLE_INVALID, NULL); // render flat pol - LABEL_115: - // Debug: draw pol outline if showsub is enabled - if (showsub) { - compout(subptr, subpoly->vertices[0].x, subpoly->vertices[0].y, subpoly->vertices[1].x, subpoly->vertices[1].y, 0x9Fu);// 0x9F is light blue in PALETTE.PAL - compout(subptr, subpoly->vertices[1].x, subpoly->vertices[1].y, subpoly->vertices[2].x, subpoly->vertices[2].y, 0x9Fu); - compout(subptr, subpoly->vertices[2].x, subpoly->vertices[2].y, subpoly->vertices[3].x, subpoly->vertices[3].y, 0x9Fu); - compout(subptr, subpoly->vertices[0].x, subpoly->vertices[0].y, subpoly->vertices[1].x, subpoly->vertices[1].y, 0x9Fu); - } - return; - } - if ((pPolyParams->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) == 0)// SURFACE_FLAG_APPLY_TEXTURE - goto LABEL_106; - } else if (iPolyType > 1) { - if (iPolyType <= 2) { - LABEL_107: - pFrameBuf = subptr; - goto LABEL_114; - } - if (iPolyType != 666) - goto LABEL_111; - if ((pPolyParams->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) != 0)// SURFACE_FLAG_APPLY_TEXTURE + case 0: // No subdivision - render the polygon + if (!iRenderFlag) + return; // don't render if flag is not set + + // Set up pol params for rendering + pPolyParamsLocal = subpoly; + pPolyParams = subpoly; + subpoly->vertices[0].x = iScreenX0; + pPolyParams->vertices[2].x = iScreenX2; + pPolyParams->vertices[2].y = iScreenY2; + pPolyParams->vertices[3].x = iScreenX3; + pPolyParams->vertices[3].y = iScreenY3; + + // Set up texture coords in 16.16 fixed point + startsx[0] = (iTexWid + iTexU - 1) << 12; + startsx[1] = iTexU << 12; + startsx[2] = iTexU << 12; + startsx[3] = (iTexWid + iTexU - 1) << 12; + startsy[0] = iTexV << 12; + startsy[1] = iTexV << 12; + pPolyParams->vertices[0].y = iScreenY0; + pPolyParams->vertices[1].x = iScreenX1; + startsy[2] = (iTexHgt + iTexV - 1) << 12; + startsy[3] = (iTexHgt + iTexV - 1) << 12; + + iPolyType = subpolytype; + pPolyParams->vertices[1].y = iScreenY1; + + // Render based on pol type + if (iPolyType < 1) { + if (iPolyType < -2) { + // Check if tex should be applied + LABEL_111: + if ((subpoly->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) != + 0) // SURFACE_FLAG_APPLY_TEXTURE { - game_render_quad_screen(g_pGameRenderer, pPolyParamsLocal, game_render_get_texture_handle(g_pGameRenderer, 17), NULL); + // Render textured pol with car texture + // TODO is this correct? + game_render_quad_screen( + g_pGameRenderer, subpoly, + game_render_get_texture_handle(g_pGameRenderer, + car_texmap[subpolytype - 3]), + NULL); + // POLYTEX( + // (&horizon_vga)[*(&car_draw_order[15].iChunkIdx + + // subpolytype)],// offset into car_texmap subptr, subpoly, + // *(&car_draw_order[15].iChunkIdx + subpolytype),// offset into + // car_texmap gfx_size); goto LABEL_115; } - LABEL_106: - pPolyParams = pPolyParamsLocal; - goto LABEL_107; + pFrameBuf = subptr; + pPolyParams = subpoly; + LABEL_114: + game_render_quad_screen(g_pGameRenderer, pPolyParams, + TEXTURE_HANDLE_INVALID, + NULL); // render flat pol + LABEL_115: + // Debug: draw pol outline if showsub is enabled + if (showsub) { + compout(subptr, subpoly->vertices[0].x, subpoly->vertices[0].y, + subpoly->vertices[1].x, subpoly->vertices[1].y, + 0x9Fu); // 0x9F is light blue in PALETTE.PAL + compout(subptr, subpoly->vertices[1].x, subpoly->vertices[1].y, + subpoly->vertices[2].x, subpoly->vertices[2].y, 0x9Fu); + compout(subptr, subpoly->vertices[2].x, subpoly->vertices[2].y, + subpoly->vertices[3].x, subpoly->vertices[3].y, 0x9Fu); + compout(subptr, subpoly->vertices[0].x, subpoly->vertices[0].y, + subpoly->vertices[1].x, subpoly->vertices[1].y, 0x9Fu); + } + return; } - // Default texture rendering - game_render_quad_screen(g_pGameRenderer, pPolyParamsLocal, game_render_get_texture_handle(g_pGameRenderer, 0), NULL); - goto LABEL_115; - case 1: // Horiz subdivision only - // Calculate midpoint between verts 0 and 1, and 2 and 3 - if (fY_mid01 < 1.0 || isnan(fY_mid01)) { - if ((double)iScreenCenterX_calc <= fX_mid01) - iScreenX_mid12 = 20000; - else - iScreenX_mid12 = -20000; - if ((double)(winh / 2) <= fMidZ_quad) - iScreenX_subdiv1 = 20000; - else - iScreenX_subdiv1 = -20000; - } else { - // Project 3D coords into screen space - dViewDist = (double)VIEWDIST; - dInvZ = 1.0 / fY_mid01; - dScreenScale = (double)scr_size; - dProjX = (dViewDist * fX_mid01 * dInvZ + (double)xbase) * dScreenScale * 0.015625; - dProjX = round(dProjX);//_CHP(); - iScreenX_mid12 = (int)dProjX; - dProjY = dScreenScale * (199.0 - dInvZ * (dViewDist * fMidZ_quad) - (double)ybase) * 0.015625; - dProjY = round(dProjY);//_CHP(); - iScreenX_subdiv1 = (int)dProjY; + if ((pPolyParams->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) == + 0) // SURFACE_FLAG_APPLY_TEXTURE + goto LABEL_106; + } else if (iPolyType > 1) { + if (iPolyType <= 2) { + LABEL_107: + pFrameBuf = subptr; + goto LABEL_114; } - - // Calculate midpoint between verts 1 and 2 - fX_mid12 = (fX2_3D + fX3_3D) * 0.5f; - fY_mid12 = (fY2_3D + fY3_3D) * 0.5f; - fZ_mid12 = (fZ2_3D + fZ3_3D) * 0.5f; - - if (fZ_mid12 < 1.0 || isnan(fZ_mid12)) { - if ((double)(winw / 2) <= fX_mid12) - iScreenX_mid23 = 20000; - else - iScreenX_mid23 = -20000; - if ((double)(winh / 2) <= fY_mid12) - iScreenY_mid12 = 20000; - else - iScreenY_mid12 = -20000; - } else { - // Project to screen space - dViewDist_1 = (double)VIEWDIST; - dInvZ_1 = 1.0 / fZ_mid12; - dScreenScale_1 = (double)scr_size; - dProjX_1 = (dViewDist_1 * fX_mid12 * dInvZ_1 + (double)xbase) * dScreenScale_1 * 0.015625; - dProjX_1 = round(dProjX_1);//_CHP(); - iScreenX_mid23 = (int)dProjX_1; - dProjY_1 = dScreenScale_1 * (199.0 - dInvZ_1 * (dViewDist_1 * fY_mid12) - (double)ybase) * 0.015625; - dProjY_1 = round(dProjY_1);//_CHP(); - iScreenY_mid12 = (int)dProjY_1; + if (iPolyType != 666) + goto LABEL_111; + if ((pPolyParams->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) != + 0) // SURFACE_FLAG_APPLY_TEXTURE + { + game_render_quad_screen( + g_pGameRenderer, pPolyParamsLocal, + game_render_get_texture_handle(g_pGameRenderer, 17), NULL); + goto LABEL_115; } + LABEL_106: + pPolyParams = pPolyParamsLocal; + goto LABEL_107; + } + // Default texture rendering + game_render_quad_screen( + g_pGameRenderer, pPolyParamsLocal, + game_render_get_texture_handle(g_pGameRenderer, 0), NULL); + goto LABEL_115; + case 1: // Horiz subdivision only + // Calculate midpoint between verts 0 and 1, and 2 and 3 + if (fY_mid01 < 1.0 || isnan(fY_mid01)) { + if ((double)iScreenCenterX_calc <= fX_mid01) + iScreenX_mid12 = 20000; + else + iScreenX_mid12 = -20000; + if ((double)(winh / 2) <= fMidZ_quad) + iScreenX_subdiv1 = 20000; + else + iScreenX_subdiv1 = -20000; + } else { + // Project 3D coords into screen space + dViewDist = (double)VIEWDIST; + dInvZ = 1.0 / fY_mid01; + dScreenScale = (double)scr_size; + dProjX = (dViewDist * fX_mid01 * dInvZ + (double)xbase) * + dScreenScale * 0.015625; + dProjX = round(dProjX); //_CHP(); + iScreenX_mid12 = (int)dProjX; + dProjY = dScreenScale * + (199.0 - dInvZ * (dViewDist * fMidZ_quad) - (double)ybase) * + 0.015625; + dProjY = round(dProjY); //_CHP(); + iScreenX_subdiv1 = (int)dProjY; + } - // Half tex width for subdivision - iTexWid >>= 1; - - // Check flip type for tex coord handling - if ((fliptype & 1) != 0) { - // Flip horiz - swap coords - iScreenCenterY = iScreenX1; - iScreenX1 = iScreenX_mid12; - - // Recursively subdivide left half - dodivide( - fX_mid01, - fMidZ_quad, - fY_mid01, - fX1_3D, - fY1_3D, - fZ1_3D, - fX2_3D, - fY2_3D, - fZ2_3D, - fX_mid12, - fY_mid12, - fZ_mid12, - iScreenX_mid12, - iScreenX_subdiv1, - iScreenCenterY, - iScreenY1, - iScreenX2, - iScreenY2, - iScreenX_mid23, - iScreenY_mid12, - iTexWid + iTexU, - iTexV, - iTexWid, - iTexHgt); - - // Update coords for right half - fX1_3D = fMidZ_Edge03 * 0.5f; - fY1_3D = fMidZ_Edge01 * 0.5f; - fZ1_3D = fMidZ_Edge23 * 0.5f; - fX2_3D = (fX2_3D + fX3_3D) * 0.5f; - fY2_3D = (fY2_3D + fY3_3D) * 0.5f; - fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; - } else { - // No flip - normal subdivision - dodivide( - fX_mid01, - fMidZ_quad, - fY_mid01, - fX1_3D, - fY1_3D, - fZ1_3D, - fX2_3D, - fY2_3D, - fZ2_3D, - fX_mid12, - fY_mid12, - fZ_mid12, - iScreenX_mid12, - iScreenX_subdiv1, - iScreenX1, - iScreenY1, - iScreenX2, - iScreenY2, - iScreenX_mid23, - iScreenY_mid12, - iTexU, - iTexV, - iTexWid, - iTexHgt); - - // Update coords for right half - fX1_3D = fMidZ_Edge03 * 0.5f; - fY1_3D = fMidZ_Edge01 * 0.5f; - fZ1_3D = fMidZ_Edge23 * 0.5f; - fX2_3D = (fX2_3D + fX3_3D) * 0.5f; - fY2_3D = (fY2_3D + fY3_3D) * 0.5f; - iTexU += iTexWid; // Advance texture U coord - fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; - iScreenX1 = iScreenX_mid12; - } - iScreenX2 = iScreenX_mid23; - iScreenY1 = iScreenX_subdiv1; - iScreenY2 = iScreenY_mid12; - continue; - case 2: // Vertical flip - // Calculate midpoint between verts 1 and 2 - fX_mid12_1 = (fX1_3D + fX2_3D) * 0.5f; - fY_mid12_1 = (fY1_3D + fY2_3D) * 0.5f; - fZ_mid12_1 = (fZ1_3D + fZ2_3D) * 0.5f; - - // Too close to camera - if (fZ_mid12_1 < 1.0 || isnan(fZ_mid12_1)) { - if ((double)iScreenCenterX_calc <= fX_mid12_1) - iScreenX_mid12_1 = 20000; - else - iScreenX_mid12_1 = -20000; - if ((double)(winh / 2) <= fY_mid12_1) - iScreenY_mid12_1 = 20000; - else - iScreenY_mid12_1 = -20000; - } else { - dViewDist_2 = (double)VIEWDIST; - dInvZ_2 = 1.0 / fZ_mid12_1; - dScreenScale_2 = (double)scr_size; - dProjX_2 = (dViewDist_2 * fX_mid12_1 * dInvZ_2 + (double)xbase) * dScreenScale_2 * 0.015625; - dProjX_2 = round(dProjX_2);//_CHP(); - iScreenX_mid12_1 = (int)dProjX_2; - dProjY_2 = dScreenScale_2 * (199.0 - dInvZ_2 * (dViewDist_2 * fY_mid12_1) - (double)ybase) * 0.015625; - dProjY_2 = round(dProjY_2);//_CHP(); - iScreenY_mid12_1 = (int)dProjY_2; - } + // Calculate midpoint between verts 1 and 2 + fX_mid12 = (fX2_3D + fX3_3D) * 0.5f; + fY_mid12 = (fY2_3D + fY3_3D) * 0.5f; + fZ_mid12 = (fZ2_3D + fZ3_3D) * 0.5f; + + if (fZ_mid12 < 1.0 || isnan(fZ_mid12)) { + if ((double)(winw / 2) <= fX_mid12) + iScreenX_mid23 = 20000; + else + iScreenX_mid23 = -20000; + if ((double)(winh / 2) <= fY_mid12) + iScreenY_mid12 = 20000; + else + iScreenY_mid12 = -20000; + } else { + // Project to screen space + dViewDist_1 = (double)VIEWDIST; + dInvZ_1 = 1.0 / fZ_mid12; + dScreenScale_1 = (double)scr_size; + dProjX_1 = (dViewDist_1 * fX_mid12 * dInvZ_1 + (double)xbase) * + dScreenScale_1 * 0.015625; + dProjX_1 = round(dProjX_1); //_CHP(); + iScreenX_mid23 = (int)dProjX_1; + dProjY_1 = + dScreenScale_1 * + (199.0 - dInvZ_1 * (dViewDist_1 * fY_mid12) - (double)ybase) * + 0.015625; + dProjY_1 = round(dProjY_1); //_CHP(); + iScreenY_mid12 = (int)dProjY_1; + } - // Update for bottom-right quad - fX_mid30 = (fX3_3D + fX0_3D) * 0.5f; - fY_mid30 = (fY3_3D + fY0_3D) * 0.5f; - fZ_mid30 = (fZ3_3D + fZ0_3D) * 0.5f; - if (fZ_mid30 < 1.0 || isnan(fZ_mid30)) { - if ((double)(winw / 2) <= fX_mid30) - iScreenX_mid30 = 20000; - else - iScreenX_mid30 = -20000; - if ((double)(winh / 2) <= fY_mid30) - iScreenY_mid30 = 20000; - else - iScreenY_mid30 = -20000; - } else { - dViewDist_3 = (double)VIEWDIST; - dInvZ_3 = 1.0 / fZ_mid30; - dScreenScale_3 = (double)scr_size; - dProjX_3 = (dViewDist_3 * fX_mid30 * dInvZ_3 + (double)xbase) * dScreenScale_3 * 0.015625; - dProjX_3 = round(dProjX_3);//_CHP(); - iScreenX_mid30 = (int)dProjX_3; - dProjY_3 = dScreenScale_3 * (199.0 - dInvZ_3 * (dViewDist_3 * fY_mid30) - (double)ybase) * 0.015625; - dProjY_3 = round(dProjY_3);//_CHP(); - iScreenY_mid30 = (int)dProjY_3; - } + // Half tex width for subdivision + iTexWid >>= 1; + + // Check flip type for tex coord handling + if ((fliptype & 1) != 0) { + // Flip horiz - swap coords + iScreenCenterY = iScreenX1; + iScreenX1 = iScreenX_mid12; + + // Recursively subdivide left half + dodivide(fX_mid01, fMidZ_quad, fY_mid01, fX1_3D, fY1_3D, fZ1_3D, + fX2_3D, fY2_3D, fZ2_3D, fX_mid12, fY_mid12, fZ_mid12, + iScreenX_mid12, iScreenX_subdiv1, iScreenCenterY, iScreenY1, + iScreenX2, iScreenY2, iScreenX_mid23, iScreenY_mid12, + iTexWid + iTexU, iTexV, iTexWid, iTexHgt); + + // Update coords for right half + fX1_3D = fMidZ_Edge03 * 0.5f; + fY1_3D = fMidZ_Edge01 * 0.5f; + fZ1_3D = fMidZ_Edge23 * 0.5f; + fX2_3D = (fX2_3D + fX3_3D) * 0.5f; + fY2_3D = (fY2_3D + fY3_3D) * 0.5f; + fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; + } else { + // No flip - normal subdivision + dodivide(fX_mid01, fMidZ_quad, fY_mid01, fX1_3D, fY1_3D, fZ1_3D, + fX2_3D, fY2_3D, fZ2_3D, fX_mid12, fY_mid12, fZ_mid12, + iScreenX_mid12, iScreenX_subdiv1, iScreenX1, iScreenY1, + iScreenX2, iScreenY2, iScreenX_mid23, iScreenY_mid12, iTexU, + iTexV, iTexWid, iTexHgt); + + // Update coords for right half + fX1_3D = fMidZ_Edge03 * 0.5f; + fY1_3D = fMidZ_Edge01 * 0.5f; + fZ1_3D = fMidZ_Edge23 * 0.5f; + fX2_3D = (fX2_3D + fX3_3D) * 0.5f; + fY2_3D = (fY2_3D + fY3_3D) * 0.5f; + iTexU += iTexWid; // Advance texture U coord + fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; + iScreenX1 = iScreenX_mid12; + } + iScreenX2 = iScreenX_mid23; + iScreenY1 = iScreenX_subdiv1; + iScreenY2 = iScreenY_mid12; + continue; + case 2: // Vertical flip + // Calculate midpoint between verts 1 and 2 + fX_mid12_1 = (fX1_3D + fX2_3D) * 0.5f; + fY_mid12_1 = (fY1_3D + fY2_3D) * 0.5f; + fZ_mid12_1 = (fZ1_3D + fZ2_3D) * 0.5f; + + // Too close to camera + if (fZ_mid12_1 < 1.0 || isnan(fZ_mid12_1)) { + if ((double)iScreenCenterX_calc <= fX_mid12_1) + iScreenX_mid12_1 = 20000; + else + iScreenX_mid12_1 = -20000; + if ((double)(winh / 2) <= fY_mid12_1) + iScreenY_mid12_1 = 20000; + else + iScreenY_mid12_1 = -20000; + } else { + dViewDist_2 = (double)VIEWDIST; + dInvZ_2 = 1.0 / fZ_mid12_1; + dScreenScale_2 = (double)scr_size; + dProjX_2 = (dViewDist_2 * fX_mid12_1 * dInvZ_2 + (double)xbase) * + dScreenScale_2 * 0.015625; + dProjX_2 = round(dProjX_2); //_CHP(); + iScreenX_mid12_1 = (int)dProjX_2; + dProjY_2 = + dScreenScale_2 * + (199.0 - dInvZ_2 * (dViewDist_2 * fY_mid12_1) - (double)ybase) * + 0.015625; + dProjY_2 = round(dProjY_2); //_CHP(); + iScreenY_mid12_1 = (int)dProjY_2; + } - // Half texture height for subdivision - iTexHgt >>= 1; - - // Vertical flip - if ((fliptype & 2) != 0) { - // Recursively subdivide top half - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX1_3D, - fY1_3D, - fZ1_3D, - fX_mid12_1, - fY_mid12_1, - fZ_mid12_1, - fX_mid30, - fY_mid30, - fZ_mid30, - iScreenX0, - iScreenY0, - iScreenX1, - iScreenY1, - iScreenX_mid12_1, - iScreenY_mid12_1, - iScreenX_mid30, - iScreenY_mid30, - iTexU, - iTexHgt + iTexV, // bottom half of texture - iTexWid, - iTexHgt); - - // Update coords for bottom half - fX0_3D = (fX3_3D + fX0_3D) * 0.5f; - fY0_3D = (fY3_3D + fY0_3D) * 0.5f; - fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; - fX1_3D = (fX1_3D + fX2_3D) * 0.5f; - iScreenY1 = iScreenY_mid12_1; - fY1_3D = (fY1_3D + fY2_3D) * 0.5f; - iScreenX1 = iScreenX_mid12_1; - fZ1_3D = (fZ1_3D + fZ2_3D) * 0.5f; - iScreenY0 = iScreenY_mid30; - } else { - // No flip - normal subdivision - // Recursively subdivide top half - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX1_3D, - fY1_3D, - fZ1_3D, - fX_mid12_1, - fY_mid12_1, - fZ_mid12_1, - fX_mid30, - fY_mid30, - fZ_mid30, - iScreenX0, - iScreenY0, - iScreenX1, - iScreenY1, - iScreenX_mid12_1, - iScreenY_mid12_1, - iScreenX_mid30, - iScreenY_mid30, - iTexU, - iTexV, // top half of tex - iTexWid, - iTexHgt); - - // Update coords for bottom half - fX0_3D = (fX3_3D + fX0_3D) * 0.5f; - fY0_3D = (fY3_3D + fY0_3D) * 0.5f; - fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; - iTexV += iTexHgt; // Advance texture V coord to bottom half - fX1_3D = (fX1_3D + fX2_3D) * 0.5f; - iScreenY1 = iScreenY_mid12_1; - fY1_3D = (fY1_3D + fY2_3D) * 0.5f; - iScreenY0 = iScreenY_mid30; - fZ1_3D = (fZ1_3D + fZ2_3D) * 0.5f; - iScreenX1 = iScreenX_mid12_1; - } - iScreenX0 = iScreenX_mid30; - continue; // Process bottom half in next iteration - case 3: // Both horiz and vert subdivision - // Calculate all edge midpoints - - // midpoint of edge 0-1 (top edge) - if (fY_mid01 < 1.0 || isnan(fY_mid01)) { - if ((double)iScreenCenterX_calc <= fX_mid01) - iScreenX_mid01 = 20000; - else - iScreenX_mid01 = -20000; - if ((double)(winh / 2) <= fMidZ_quad) - iScreenY_mid01 = 20000; - else - iScreenY_mid01 = -20000; - } else { - dViewDist_4 = (double)VIEWDIST; - dInvZ_4 = 1.0 / fY_mid01; - dScreenScale_4 = (double)scr_size; - dProjX_4 = (dViewDist_4 * fX_mid01 * dInvZ_4 + (double)xbase) * dScreenScale_4 * 0.015625; - dProjX_4 = round(dProjX_4);//_CHP(); - iScreenX_mid01 = (int)dProjX_4; - dProjY_4 = dScreenScale_4 * (199.0 - dInvZ_4 * (dViewDist_4 * fMidZ_quad) - (double)ybase) * 0.015625; - dProjY_4 = round(dProjY_4);//_CHP(); - iScreenY_mid01 = (int)dProjY_4; - } + // Update for bottom-right quad + fX_mid30 = (fX3_3D + fX0_3D) * 0.5f; + fY_mid30 = (fY3_3D + fY0_3D) * 0.5f; + fZ_mid30 = (fZ3_3D + fZ0_3D) * 0.5f; + if (fZ_mid30 < 1.0 || isnan(fZ_mid30)) { + if ((double)(winw / 2) <= fX_mid30) + iScreenX_mid30 = 20000; + else + iScreenX_mid30 = -20000; + if ((double)(winh / 2) <= fY_mid30) + iScreenY_mid30 = 20000; + else + iScreenY_mid30 = -20000; + } else { + dViewDist_3 = (double)VIEWDIST; + dInvZ_3 = 1.0 / fZ_mid30; + dScreenScale_3 = (double)scr_size; + dProjX_3 = (dViewDist_3 * fX_mid30 * dInvZ_3 + (double)xbase) * + dScreenScale_3 * 0.015625; + dProjX_3 = round(dProjX_3); //_CHP(); + iScreenX_mid30 = (int)dProjX_3; + dProjY_3 = + dScreenScale_3 * + (199.0 - dInvZ_3 * (dViewDist_3 * fY_mid30) - (double)ybase) * + 0.015625; + dProjY_3 = round(dProjY_3); //_CHP(); + iScreenY_mid30 = (int)dProjY_3; + } - // Midpoint of edge 1-2 (right edge) - fX_mid12_2 = (fX1_3D + fX2_3D) * 0.5f; - fY_mid12_2 = (fY1_3D + fY2_3D) * 0.5f; - fZ_mid12_2 = (fZ1_3D + fZ2_3D) * 0.5f; - if (fZ_mid12_2 < 1.0 || isnan(fZ_mid12_2)) { - if ((double)(winw / 2) <= fX_mid12_2) - iScreenX_mid12_2 = 20000; - else - iScreenX_mid12_2 = -20000; - if ((double)(winh / 2) <= fY_mid12_2) - iScreenY_mid23 = 20000; - else - iScreenY_mid23 = -20000; - } else { - dViewDist_5 = (double)VIEWDIST; - dInvZ_5 = 1.0 / fZ_mid12_2; - dScreenScale_5 = (double)scr_size; - dProjX_5 = (dViewDist_5 * fX_mid12_2 * dInvZ_5 + (double)xbase) * dScreenScale_5 * 0.015625; - dProjX_5 = round(dProjX_5);//_CHP(); - iScreenX_mid12_2 = (int)dProjX_5; - dProjY_5 = dScreenScale_5 * (199.0 - dInvZ_5 * (dViewDist_5 * fY_mid12_2) - (double)ybase) * 0.015625; - dProjY_5 = round(dProjY_5);//_CHP(); - iScreenY_mid23 = (int)dProjY_5; - } + // Half texture height for subdivision + iTexHgt >>= 1; + + // Vertical flip + if ((fliptype & 2) != 0) { + // Recursively subdivide top half + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX1_3D, fY1_3D, fZ1_3D, fX_mid12_1, + fY_mid12_1, fZ_mid12_1, fX_mid30, fY_mid30, fZ_mid30, + iScreenX0, iScreenY0, iScreenX1, iScreenY1, iScreenX_mid12_1, + iScreenY_mid12_1, iScreenX_mid30, iScreenY_mid30, iTexU, + iTexHgt + iTexV, // bottom half of texture + iTexWid, iTexHgt); + + // Update coords for bottom half + fX0_3D = (fX3_3D + fX0_3D) * 0.5f; + fY0_3D = (fY3_3D + fY0_3D) * 0.5f; + fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; + fX1_3D = (fX1_3D + fX2_3D) * 0.5f; + iScreenY1 = iScreenY_mid12_1; + fY1_3D = (fY1_3D + fY2_3D) * 0.5f; + iScreenX1 = iScreenX_mid12_1; + fZ1_3D = (fZ1_3D + fZ2_3D) * 0.5f; + iScreenY0 = iScreenY_mid30; + } else { + // No flip - normal subdivision + // Recursively subdivide top half + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX1_3D, fY1_3D, fZ1_3D, fX_mid12_1, + fY_mid12_1, fZ_mid12_1, fX_mid30, fY_mid30, fZ_mid30, + iScreenX0, iScreenY0, iScreenX1, iScreenY1, iScreenX_mid12_1, + iScreenY_mid12_1, iScreenX_mid30, iScreenY_mid30, iTexU, + iTexV, // top half of tex + iTexWid, iTexHgt); + + // Update coords for bottom half + fX0_3D = (fX3_3D + fX0_3D) * 0.5f; + fY0_3D = (fY3_3D + fY0_3D) * 0.5f; + fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; + iTexV += iTexHgt; // Advance texture V coord to bottom half + fX1_3D = (fX1_3D + fX2_3D) * 0.5f; + iScreenY1 = iScreenY_mid12_1; + fY1_3D = (fY1_3D + fY2_3D) * 0.5f; + iScreenY0 = iScreenY_mid30; + fZ1_3D = (fZ1_3D + fZ2_3D) * 0.5f; + iScreenX1 = iScreenX_mid12_1; + } + iScreenX0 = iScreenX_mid30; + continue; // Process bottom half in next iteration + case 3: // Both horiz and vert subdivision + // Calculate all edge midpoints + + // midpoint of edge 0-1 (top edge) + if (fY_mid01 < 1.0 || isnan(fY_mid01)) { + if ((double)iScreenCenterX_calc <= fX_mid01) + iScreenX_mid01 = 20000; + else + iScreenX_mid01 = -20000; + if ((double)(winh / 2) <= fMidZ_quad) + iScreenY_mid01 = 20000; + else + iScreenY_mid01 = -20000; + } else { + dViewDist_4 = (double)VIEWDIST; + dInvZ_4 = 1.0 / fY_mid01; + dScreenScale_4 = (double)scr_size; + dProjX_4 = (dViewDist_4 * fX_mid01 * dInvZ_4 + (double)xbase) * + dScreenScale_4 * 0.015625; + dProjX_4 = round(dProjX_4); //_CHP(); + iScreenX_mid01 = (int)dProjX_4; + dProjY_4 = + dScreenScale_4 * + (199.0 - dInvZ_4 * (dViewDist_4 * fMidZ_quad) - (double)ybase) * + 0.015625; + dProjY_4 = round(dProjY_4); //_CHP(); + iScreenY_mid01 = (int)dProjY_4; + } - // Midpoint fo edge 2-3 (bottom edge) - fX_mid23 = (fX2_3D + fX3_3D) * 0.5f; - fY_mid23 = (fY2_3D + fY3_3D) * 0.5f; - fZ_mid23 = (fZ2_3D + fZ3_3D) * 0.5f; - if (fZ_mid23 < 1.0 || isnan(fZ_mid23)) { - if ((double)(winw / 2) <= fX_mid23) - iScreenX_mid23_1 = 20000; - else - iScreenX_mid23_1 = -20000; - if ((double)(winh / 2) <= fY_mid23) - iScreenY_mid30_1 = 20000; - else - iScreenY_mid30_1 = -20000; - } else { - dViewDist_6 = (double)VIEWDIST; - dInvZ_6 = 1.0 / fZ_mid23; - dScreenScale_6 = (double)scr_size; - dProjX_6 = (dViewDist_6 * fX_mid23 * dInvZ_6 + (double)xbase) * dScreenScale_6 * 0.015625; - dProjX_6 = round(dProjX_6);//_CHP(); - iScreenX_mid23_1 = (int)dProjX_6; - dProjY_6 = dScreenScale_6 * (199.0 - dInvZ_6 * (dViewDist_6 * fY_mid23) - (double)ybase) * 0.015625; - dProjY_6 = round(dProjY_6);//_CHP(); - iScreenY_mid30_1 = (int)dProjY_6; - } + // Midpoint of edge 1-2 (right edge) + fX_mid12_2 = (fX1_3D + fX2_3D) * 0.5f; + fY_mid12_2 = (fY1_3D + fY2_3D) * 0.5f; + fZ_mid12_2 = (fZ1_3D + fZ2_3D) * 0.5f; + if (fZ_mid12_2 < 1.0 || isnan(fZ_mid12_2)) { + if ((double)(winw / 2) <= fX_mid12_2) + iScreenX_mid12_2 = 20000; + else + iScreenX_mid12_2 = -20000; + if ((double)(winh / 2) <= fY_mid12_2) + iScreenY_mid23 = 20000; + else + iScreenY_mid23 = -20000; + } else { + dViewDist_5 = (double)VIEWDIST; + dInvZ_5 = 1.0 / fZ_mid12_2; + dScreenScale_5 = (double)scr_size; + dProjX_5 = (dViewDist_5 * fX_mid12_2 * dInvZ_5 + (double)xbase) * + dScreenScale_5 * 0.015625; + dProjX_5 = round(dProjX_5); //_CHP(); + iScreenX_mid12_2 = (int)dProjX_5; + dProjY_5 = + dScreenScale_5 * + (199.0 - dInvZ_5 * (dViewDist_5 * fY_mid12_2) - (double)ybase) * + 0.015625; + dProjY_5 = round(dProjY_5); //_CHP(); + iScreenY_mid23 = (int)dProjY_5; + } - // Midpoint of edge 3-0 (left edge) - fX_mid30_1 = (fX3_3D + fX0_3D) * 0.5f; - fY_mid30_1 = (fY3_3D + fY0_3D) * 0.5f; - fZ_mid30_1 = (fZ3_3D + fZ0_3D) * 0.5f; - if (fZ_mid30_1 < 1.0 || isnan(fZ_mid30_1)) { - if ((double)(winw / 2) <= fX_mid30_1) - iScreenX_mid30_1 = 20000; - else - iScreenX_mid30_1 = -20000; - if ((double)(winh / 2) <= fY_mid30_1) - iScreenY_mid30_2 = 20000; - else - iScreenY_mid30_2 = -20000; - } else { - dViewDist_7 = (double)VIEWDIST; - dInvZ_7 = 1.0 / fZ_mid30_1; - dScreenScale_7 = (double)scr_size; - dProjX_7 = (dViewDist_7 * fX_mid30_1 * dInvZ_7 + (double)xbase) * dScreenScale_7 * 0.015625; - dProjX_7= round(dProjX_7);//_CHP(); - iScreenX_mid30_1 = (int)dProjX_7; - dProjY_7 = dScreenScale_7 * (199.0 - dInvZ_7 * (dViewDist_7 * fY_mid30_1) - (double)ybase) * 0.015625; - dProjY_7 = round(dProjY_7);//_CHP(); - iScreenY_mid30_2 = (int)dProjY_7; - } + // Midpoint fo edge 2-3 (bottom edge) + fX_mid23 = (fX2_3D + fX3_3D) * 0.5f; + fY_mid23 = (fY2_3D + fY3_3D) * 0.5f; + fZ_mid23 = (fZ2_3D + fZ3_3D) * 0.5f; + if (fZ_mid23 < 1.0 || isnan(fZ_mid23)) { + if ((double)(winw / 2) <= fX_mid23) + iScreenX_mid23_1 = 20000; + else + iScreenX_mid23_1 = -20000; + if ((double)(winh / 2) <= fY_mid23) + iScreenY_mid30_1 = 20000; + else + iScreenY_mid30_1 = -20000; + } else { + dViewDist_6 = (double)VIEWDIST; + dInvZ_6 = 1.0 / fZ_mid23; + dScreenScale_6 = (double)scr_size; + dProjX_6 = (dViewDist_6 * fX_mid23 * dInvZ_6 + (double)xbase) * + dScreenScale_6 * 0.015625; + dProjX_6 = round(dProjX_6); //_CHP(); + iScreenX_mid23_1 = (int)dProjX_6; + dProjY_6 = + dScreenScale_6 * + (199.0 - dInvZ_6 * (dViewDist_6 * fY_mid23) - (double)ybase) * + 0.015625; + dProjY_6 = round(dProjY_6); //_CHP(); + iScreenY_mid30_1 = (int)dProjY_6; + } - // Calculate center point of quad - fX_center = (fX_mid01 + fX_mid23) * 0.5f; - fY_center = (fMidZ_quad + fY_mid23) * 0.5f; - fZ_center = (fY_mid01 + fZ_mid23) * 0.5f; - if (fZ_center < 1.0 || isnan(fZ_center)) { - if ((double)(winw / 2) <= fX_center) - iScreenX_center = 20000; - else - iScreenX_center = -20000; - if ((double)(winh / 2) <= fY_center) - iScreenY_center = 20000; - else - iScreenY_center = -20000; - } else { - dViewDist_8 = (double)VIEWDIST; - dInvZ_8 = 1.0 / fZ_center; - dScreenScale_8 = (double)scr_size; - dProjX_8 = (dViewDist_8 * fX_center * dInvZ_8 + (double)xbase) * dScreenScale_8 * 0.015625; - dProjX_8 = round(dProjX_8);//_CHP(); - iScreenX_center = (int)dProjX_8; - dProjY_8 = dScreenScale_8 * (199.0 - dInvZ_8 * (dViewDist_8 * fY_center) - (double)ybase) * 0.015625; - dProjY_8 = round(dProjY_8);//_CHP(); - iScreenY_center = (int)dProjY_8; - } + // Midpoint of edge 3-0 (left edge) + fX_mid30_1 = (fX3_3D + fX0_3D) * 0.5f; + fY_mid30_1 = (fY3_3D + fY0_3D) * 0.5f; + fZ_mid30_1 = (fZ3_3D + fZ0_3D) * 0.5f; + if (fZ_mid30_1 < 1.0 || isnan(fZ_mid30_1)) { + if ((double)(winw / 2) <= fX_mid30_1) + iScreenX_mid30_1 = 20000; + else + iScreenX_mid30_1 = -20000; + if ((double)(winh / 2) <= fY_mid30_1) + iScreenY_mid30_2 = 20000; + else + iScreenY_mid30_2 = -20000; + } else { + dViewDist_7 = (double)VIEWDIST; + dInvZ_7 = 1.0 / fZ_mid30_1; + dScreenScale_7 = (double)scr_size; + dProjX_7 = (dViewDist_7 * fX_mid30_1 * dInvZ_7 + (double)xbase) * + dScreenScale_7 * 0.015625; + dProjX_7 = round(dProjX_7); //_CHP(); + iScreenX_mid30_1 = (int)dProjX_7; + dProjY_7 = + dScreenScale_7 * + (199.0 - dInvZ_7 * (dViewDist_7 * fY_mid30_1) - (double)ybase) * + 0.015625; + dProjY_7 = round(dProjY_7); //_CHP(); + iScreenY_mid30_2 = (int)dProjY_7; + } - // Quarter tex dimensions - iTexWid >>= 1; - iTexHgt >>= 1; - iTexV_bottom = iTexHgt + iTexV; - iTexU_right = iTexWid + iTexU; - - // Handle all 4 flip combinations - switch (fliptype) { - case 0: // no flip - // Top-left quadrant - dodivide( - fX_mid01, - fMidZ_quad, - fY_mid01, - fX1_3D, - fY1_3D, - fZ1_3D, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX_center, - fY_center, - fZ_center, - iScreenX_mid01, - iScreenY_mid01, - iScreenX1, - iScreenY1, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX_center, - iScreenY_center, - iTexU, - iTexV, - iTexWid, - iTexHgt); - - // Top-right quadrant - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX_mid01, - fMidZ_quad, - fY_mid01, - fX_center, - fY_center, - fZ_center, - fX_mid30_1, - fY_mid30_1, - fZ_mid30_1, - iScreenX0, - iScreenY0, - iScreenX_mid01, - iScreenY_mid01, - iScreenX_center, - iScreenY_center, - iScreenX_mid30_1, - iScreenY_mid30_2, - iTexU_right, - iTexV, - iTexWid, - iTexHgt); - - iScreenY1 = iScreenY_center; - - // bottom-right quadrant - dodivide( - fX_center, - fY_center, - fZ_center, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX2_3D, - fY2_3D, - fZ2_3D, - fX_mid23, - fY_mid23, - fZ_mid23, - iScreenX_center, - iScreenY_center, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX2, - iScreenY2, - iScreenX_mid23_1, - iScreenY_mid30_1, - iTexU, - iTexV_bottom, - iTexWid, - iTexHgt); - - // Update for bottom-left quadrant (processed in next iteration) - fX0_3D = (fX3_3D + fX0_3D) * 0.5f; - fY0_3D = (fY3_3D + fY0_3D) * 0.5f; - fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; - fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; - fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; - fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; - fX2_3D = (fX2_3D + fX3_3D) * 0.5f; - fY2_3D = (fY2_3D + fY3_3D) * 0.5f; - fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; - iScreenX0 = iScreenX_mid30_1; - iTexU += iTexWid; - iScreenX2 = iScreenX_mid23_1; - iScreenX1 = iScreenX_center; - iScreenY2 = iScreenY_mid30_1; - iScreenY0 = iScreenY_mid30_2; - iTexV += iTexHgt; - continue; - case 1: // horiz flip - // top-right quadrant (flipped to top-left) - dodivide( - fX_mid01, - fMidZ_quad, - fY_mid01, - fX1_3D, - fY1_3D, - fZ1_3D, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX_center, - fY_center, - fZ_center, - iScreenX_mid01, - iScreenY_mid01, - iScreenX1, - iScreenY1, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX_center, - iScreenY_center, - iTexWid + iTexU, // right side tex - iTexV, - iTexWid, - iTexHgt); - - // Top-left quadrant (flipped to top-right) - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX_mid01, - fMidZ_quad, - fY_mid01, - fX_center, - fY_center, - fZ_center, - fX_mid30_1, - fY_mid30_1, - fZ_mid30_1, - iScreenX0, - iScreenY0, - iScreenX_mid01, - iScreenY_mid01, - iScreenX_center, - iScreenY_center, - iScreenX_mid30_1, - iScreenY_mid30_2, - iTexU, // left side tex - iTexV, - iTexWid, - iTexHgt); - iScreenX1 = iScreenX_center; - - // bottom-right quadrant (flipped to bottom-left) - dodivide( - fX_center, - fY_center, - fZ_center, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX2_3D, - fY2_3D, - fZ2_3D, - fX_mid23, - fY_mid23, - fZ_mid23, - iScreenX_center, - iScreenY_center, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX2, - iScreenY2, - iScreenX_mid23_1, - iScreenY_mid30_1, - iTexU_right, - iTexV_bottom, - iTexWid, - iTexHgt); - - // Update for bottom-left quadrant (flipped to bottom-right) - fX0_3D = (fX3_3D + fX0_3D) * 0.5f; - fY0_3D = (fY3_3D + fY0_3D) * 0.5f; - fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; - fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; - fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; - fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; - fX2_3D = (fX2_3D + fX3_3D) * 0.5f; - fY2_3D = (fY2_3D + fY3_3D) * 0.5f; - fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; - iScreenX0 = iScreenX_mid30_1; - iScreenX2 = iScreenX_mid23_1; - iScreenY1 = iScreenY_center; - iScreenY2 = iScreenY_mid30_1; - iScreenY0 = iScreenY_mid30_2; - iTexV += iTexHgt; - continue; - case 2: // vertical flip - // Top-left quadrant (flipped to bottom-left) - dodivide( - fX_mid01, - fMidZ_quad, - fY_mid01, - fX1_3D, - fY1_3D, - fZ1_3D, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX_center, - fY_center, - fZ_center, - iScreenX_mid01, - iScreenY_mid01, - iScreenX1, - iScreenY1, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX_center, - iScreenY_center, - iTexU, - iTexV_bottom, // bottom tex - iTexWid, - iTexHgt); - - // Top-right quadrant (flipped to bottom-right) - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX_mid01, - fMidZ_quad, - fY_mid01, - fX_center, - fY_center, - fZ_center, - fX_mid30_1, - fY_mid30_1, - fZ_mid30_1, - iScreenX0, - iScreenY0, - iScreenX_mid01, - iScreenY_mid01, - iScreenX_center, - iScreenY_center, - iScreenX_mid30_1, - iScreenY_mid30_2, - iTexU_right, - iTexV_bottom, // bottom-right tex - iTexWid, - iTexHgt); - - iScreenY1 = iScreenY_center; - - // bottom-right quadrant (flipped to top-right) - dodivide( - fX_center, - fY_center, - fZ_center, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX2_3D, - fY2_3D, - fZ2_3D, - fX_mid23, - fY_mid23, - fZ_mid23, - iScreenX_center, - iScreenY_center, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX2, - iScreenY2, - iScreenX_mid23_1, - iScreenY_mid30_1, - iTexU, - iTexV, // top tex - iTexWid, - iTexHgt); - - // Update for bottom-left quadrant (flipped to top-left) - fX0_3D = (fX3_3D + fX0_3D) * 0.5f; - fY0_3D = (fY3_3D + fY0_3D) * 0.5f; - fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; - fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; - fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; - fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; - fX2_3D = (fX2_3D + fX3_3D) * 0.5f; - fY2_3D = (fY2_3D + fY3_3D) * 0.5f; - fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; - iTexU += iTexWid; - iScreenX0 = iScreenX_mid30_1; - iScreenX1 = iScreenX_center; - iScreenX2 = iScreenX_mid23_1; - iScreenY0 = iScreenY_mid30_2; - iScreenY2 = iScreenY_mid30_1; - continue; - case 3: // both horiz and vert flip - // top-right quadrant (flipped to bottom-left) - dodivide( - fX_mid01, - fMidZ_quad, - fY_mid01, - fX1_3D, - fY1_3D, - fZ1_3D, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX_center, - fY_center, - fZ_center, - iScreenX_mid01, - iScreenY_mid01, - iScreenX1, - iScreenY1, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX_center, - iScreenY_center, - iTexWid + iTexU, // right tex - iTexV_bottom, // bottom tex - iTexWid, - iTexHgt); - - // top-left quadrant (flipped to bottom-right) - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX_mid01, - fMidZ_quad, - fY_mid01, - fX_center, - fY_center, - fZ_center, - fX_mid30_1, - fY_mid30_1, - fZ_mid30_1, - iScreenX0, - iScreenY0, - iScreenX_mid01, - iScreenY_mid01, - iScreenX_center, - iScreenY_center, - iScreenX_mid30_1, - iScreenY_mid30_2, - iTexU, // left tex - iTexV_bottom, // bottom tex - iTexWid, - iTexHgt); - - iScreenX1 = iScreenX_center; - - // bottom-right quadrant (flipped to top-left) - dodivide( - fX_center, - fY_center, - fZ_center, - fX_mid12_2, - fY_mid12_2, - fZ_mid12_2, - fX2_3D, - fY2_3D, - fZ2_3D, - fX_mid23, - fY_mid23, - fZ_mid23, - iScreenX_center, - iScreenY_center, - iScreenX_mid12_2, - iScreenY_mid23, - iScreenX2, - iScreenY2, - iScreenX_mid23_1, - iScreenY_mid30_1, - iTexU_right, - iTexV, // top tex - iTexWid, - iTexHgt); - - // update for bottom-left quadrant (flipped to top-right) - fX0_3D = (fX3_3D + fX0_3D) * 0.5f; - fY0_3D = (fY3_3D + fY0_3D) * 0.5f; - fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; - fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; - fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; - fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; - fX2_3D = (fX2_3D + fX3_3D) * 0.5f; - fY2_3D = (fY2_3D + fY3_3D) * 0.5f; - fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; - iScreenX0 = iScreenX_mid30_1; - iScreenY1 = iScreenY_center; - iScreenX2 = iScreenX_mid23_1; - iScreenY0 = iScreenY_mid30_2; - iScreenY2 = iScreenY_mid30_1; - continue; - default: - return; - } - return; + // Calculate center point of quad + fX_center = (fX_mid01 + fX_mid23) * 0.5f; + fY_center = (fMidZ_quad + fY_mid23) * 0.5f; + fZ_center = (fY_mid01 + fZ_mid23) * 0.5f; + if (fZ_center < 1.0 || isnan(fZ_center)) { + if ((double)(winw / 2) <= fX_center) + iScreenX_center = 20000; + else + iScreenX_center = -20000; + if ((double)(winh / 2) <= fY_center) + iScreenY_center = 20000; + else + iScreenY_center = -20000; + } else { + dViewDist_8 = (double)VIEWDIST; + dInvZ_8 = 1.0 / fZ_center; + dScreenScale_8 = (double)scr_size; + dProjX_8 = (dViewDist_8 * fX_center * dInvZ_8 + (double)xbase) * + dScreenScale_8 * 0.015625; + dProjX_8 = round(dProjX_8); //_CHP(); + iScreenX_center = (int)dProjX_8; + dProjY_8 = + dScreenScale_8 * + (199.0 - dInvZ_8 * (dViewDist_8 * fY_center) - (double)ybase) * + 0.015625; + dProjY_8 = round(dProjY_8); //_CHP(); + iScreenY_center = (int)dProjY_8; + } + + // Quarter tex dimensions + iTexWid >>= 1; + iTexHgt >>= 1; + iTexV_bottom = iTexHgt + iTexV; + iTexU_right = iTexWid + iTexU; + + // Handle all 4 flip combinations + switch (fliptype) { + case 0: // no flip + // Top-left quadrant + dodivide(fX_mid01, fMidZ_quad, fY_mid01, fX1_3D, fY1_3D, fZ1_3D, + fX_mid12_2, fY_mid12_2, fZ_mid12_2, fX_center, fY_center, + fZ_center, iScreenX_mid01, iScreenY_mid01, iScreenX1, + iScreenY1, iScreenX_mid12_2, iScreenY_mid23, iScreenX_center, + iScreenY_center, iTexU, iTexV, iTexWid, iTexHgt); + + // Top-right quadrant + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX_mid01, fMidZ_quad, fY_mid01, + fX_center, fY_center, fZ_center, fX_mid30_1, fY_mid30_1, + fZ_mid30_1, iScreenX0, iScreenY0, iScreenX_mid01, + iScreenY_mid01, iScreenX_center, iScreenY_center, + iScreenX_mid30_1, iScreenY_mid30_2, iTexU_right, iTexV, + iTexWid, iTexHgt); + + iScreenY1 = iScreenY_center; + + // bottom-right quadrant + dodivide(fX_center, fY_center, fZ_center, fX_mid12_2, fY_mid12_2, + fZ_mid12_2, fX2_3D, fY2_3D, fZ2_3D, fX_mid23, fY_mid23, + fZ_mid23, iScreenX_center, iScreenY_center, iScreenX_mid12_2, + iScreenY_mid23, iScreenX2, iScreenY2, iScreenX_mid23_1, + iScreenY_mid30_1, iTexU, iTexV_bottom, iTexWid, iTexHgt); + + // Update for bottom-left quadrant (processed in next iteration) + fX0_3D = (fX3_3D + fX0_3D) * 0.5f; + fY0_3D = (fY3_3D + fY0_3D) * 0.5f; + fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; + fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; + fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; + fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; + fX2_3D = (fX2_3D + fX3_3D) * 0.5f; + fY2_3D = (fY2_3D + fY3_3D) * 0.5f; + fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; + iScreenX0 = iScreenX_mid30_1; + iTexU += iTexWid; + iScreenX2 = iScreenX_mid23_1; + iScreenX1 = iScreenX_center; + iScreenY2 = iScreenY_mid30_1; + iScreenY0 = iScreenY_mid30_2; + iTexV += iTexHgt; + continue; + case 1: // horiz flip + // top-right quadrant (flipped to top-left) + dodivide(fX_mid01, fMidZ_quad, fY_mid01, fX1_3D, fY1_3D, fZ1_3D, + fX_mid12_2, fY_mid12_2, fZ_mid12_2, fX_center, fY_center, + fZ_center, iScreenX_mid01, iScreenY_mid01, iScreenX1, + iScreenY1, iScreenX_mid12_2, iScreenY_mid23, iScreenX_center, + iScreenY_center, + iTexWid + iTexU, // right side tex + iTexV, iTexWid, iTexHgt); + + // Top-left quadrant (flipped to top-right) + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX_mid01, fMidZ_quad, fY_mid01, + fX_center, fY_center, fZ_center, fX_mid30_1, fY_mid30_1, + fZ_mid30_1, iScreenX0, iScreenY0, iScreenX_mid01, + iScreenY_mid01, iScreenX_center, iScreenY_center, + iScreenX_mid30_1, iScreenY_mid30_2, + iTexU, // left side tex + iTexV, iTexWid, iTexHgt); + iScreenX1 = iScreenX_center; + + // bottom-right quadrant (flipped to bottom-left) + dodivide(fX_center, fY_center, fZ_center, fX_mid12_2, fY_mid12_2, + fZ_mid12_2, fX2_3D, fY2_3D, fZ2_3D, fX_mid23, fY_mid23, + fZ_mid23, iScreenX_center, iScreenY_center, iScreenX_mid12_2, + iScreenY_mid23, iScreenX2, iScreenY2, iScreenX_mid23_1, + iScreenY_mid30_1, iTexU_right, iTexV_bottom, iTexWid, + iTexHgt); + + // Update for bottom-left quadrant (flipped to bottom-right) + fX0_3D = (fX3_3D + fX0_3D) * 0.5f; + fY0_3D = (fY3_3D + fY0_3D) * 0.5f; + fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; + fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; + fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; + fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; + fX2_3D = (fX2_3D + fX3_3D) * 0.5f; + fY2_3D = (fY2_3D + fY3_3D) * 0.5f; + fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; + iScreenX0 = iScreenX_mid30_1; + iScreenX2 = iScreenX_mid23_1; + iScreenY1 = iScreenY_center; + iScreenY2 = iScreenY_mid30_1; + iScreenY0 = iScreenY_mid30_2; + iTexV += iTexHgt; + continue; + case 2: // vertical flip + // Top-left quadrant (flipped to bottom-left) + dodivide(fX_mid01, fMidZ_quad, fY_mid01, fX1_3D, fY1_3D, fZ1_3D, + fX_mid12_2, fY_mid12_2, fZ_mid12_2, fX_center, fY_center, + fZ_center, iScreenX_mid01, iScreenY_mid01, iScreenX1, + iScreenY1, iScreenX_mid12_2, iScreenY_mid23, iScreenX_center, + iScreenY_center, iTexU, + iTexV_bottom, // bottom tex + iTexWid, iTexHgt); + + // Top-right quadrant (flipped to bottom-right) + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX_mid01, fMidZ_quad, fY_mid01, + fX_center, fY_center, fZ_center, fX_mid30_1, fY_mid30_1, + fZ_mid30_1, iScreenX0, iScreenY0, iScreenX_mid01, + iScreenY_mid01, iScreenX_center, iScreenY_center, + iScreenX_mid30_1, iScreenY_mid30_2, iTexU_right, + iTexV_bottom, // bottom-right tex + iTexWid, iTexHgt); + + iScreenY1 = iScreenY_center; + + // bottom-right quadrant (flipped to top-right) + dodivide(fX_center, fY_center, fZ_center, fX_mid12_2, fY_mid12_2, + fZ_mid12_2, fX2_3D, fY2_3D, fZ2_3D, fX_mid23, fY_mid23, + fZ_mid23, iScreenX_center, iScreenY_center, iScreenX_mid12_2, + iScreenY_mid23, iScreenX2, iScreenY2, iScreenX_mid23_1, + iScreenY_mid30_1, iTexU, + iTexV, // top tex + iTexWid, iTexHgt); + + // Update for bottom-left quadrant (flipped to top-left) + fX0_3D = (fX3_3D + fX0_3D) * 0.5f; + fY0_3D = (fY3_3D + fY0_3D) * 0.5f; + fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; + fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; + fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; + fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; + fX2_3D = (fX2_3D + fX3_3D) * 0.5f; + fY2_3D = (fY2_3D + fY3_3D) * 0.5f; + fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; + iTexU += iTexWid; + iScreenX0 = iScreenX_mid30_1; + iScreenX1 = iScreenX_center; + iScreenX2 = iScreenX_mid23_1; + iScreenY0 = iScreenY_mid30_2; + iScreenY2 = iScreenY_mid30_1; + continue; + case 3: // both horiz and vert flip + // top-right quadrant (flipped to bottom-left) + dodivide(fX_mid01, fMidZ_quad, fY_mid01, fX1_3D, fY1_3D, fZ1_3D, + fX_mid12_2, fY_mid12_2, fZ_mid12_2, fX_center, fY_center, + fZ_center, iScreenX_mid01, iScreenY_mid01, iScreenX1, + iScreenY1, iScreenX_mid12_2, iScreenY_mid23, iScreenX_center, + iScreenY_center, + iTexWid + iTexU, // right tex + iTexV_bottom, // bottom tex + iTexWid, iTexHgt); + + // top-left quadrant (flipped to bottom-right) + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX_mid01, fMidZ_quad, fY_mid01, + fX_center, fY_center, fZ_center, fX_mid30_1, fY_mid30_1, + fZ_mid30_1, iScreenX0, iScreenY0, iScreenX_mid01, + iScreenY_mid01, iScreenX_center, iScreenY_center, + iScreenX_mid30_1, iScreenY_mid30_2, + iTexU, // left tex + iTexV_bottom, // bottom tex + iTexWid, iTexHgt); + + iScreenX1 = iScreenX_center; + + // bottom-right quadrant (flipped to top-left) + dodivide(fX_center, fY_center, fZ_center, fX_mid12_2, fY_mid12_2, + fZ_mid12_2, fX2_3D, fY2_3D, fZ2_3D, fX_mid23, fY_mid23, + fZ_mid23, iScreenX_center, iScreenY_center, iScreenX_mid12_2, + iScreenY_mid23, iScreenX2, iScreenY2, iScreenX_mid23_1, + iScreenY_mid30_1, iTexU_right, + iTexV, // top tex + iTexWid, iTexHgt); + + // update for bottom-left quadrant (flipped to top-right) + fX0_3D = (fX3_3D + fX0_3D) * 0.5f; + fY0_3D = (fY3_3D + fY0_3D) * 0.5f; + fZ0_3D = (fZ3_3D + fZ0_3D) * 0.5f; + fX1_3D = (fX_mid01 + fX_mid23) * 0.5f; + fY1_3D = (fMidZ_quad + fY_mid23) * 0.5f; + fZ1_3D = (fY_mid01 + fZ_mid23) * 0.5f; + fX2_3D = (fX2_3D + fX3_3D) * 0.5f; + fY2_3D = (fY2_3D + fY3_3D) * 0.5f; + fZ2_3D = (fZ2_3D + fZ3_3D) * 0.5f; + iScreenX0 = iScreenX_mid30_1; + iScreenY1 = iScreenY_center; + iScreenX2 = iScreenX_mid23_1; + iScreenY0 = iScreenY_mid30_2; + iScreenY2 = iScreenY_mid30_1; + continue; default: return; + } + return; + default: + return; } } break; } } - typedef struct { - uint8 *pixels; - int width; - int height; - int tex_idx; - int texHalfRes; - int in_use; + uint8 *pixels; + int width; + int height; + int tex_idx; + int texHalfRes; + int in_use; } SceneTextureSlot; struct SceneRendererSoftware { - SceneRenderCamera camera; - SceneRenderProjection proj; - - uint8 *targetBuffer; - int targetStride; - int targetWidth; - int targetHeight; - int viewportX; - int viewportY; - int viewportW; - int viewportH; - - SceneTextureSlot texSlots[SCENE_RENDER_MAX_TEXTURE_SLOTS]; - SceneTextureHandle texIdxToHandle[32]; + SceneRenderCamera camera; + SceneRenderProjection proj; + + uint8 *targetBuffer; + int targetStride; + int targetWidth; + int targetHeight; + int viewportX; + int viewportY; + int viewportW; + int viewportH; + + SceneTextureSlot texSlots[SCENE_RENDER_MAX_TEXTURE_SLOTS]; + SceneTextureHandle texIdxToHandle[32]; }; -static void subdivide(uint8 *pDest, tPolyParams *polyParams, - float fX0_3D, float fY0_3D, float fZ0_3D, - float fX1_3D, float fY1_3D, float fZ1_3D, - float fX2_3D, float fY2_3D, float fZ2_3D, +static void subdivide(uint8 *pDest, tPolyParams *polyParams, float fX0_3D, + float fY0_3D, float fZ0_3D, float fX1_3D, float fY1_3D, + float fZ1_3D, float fX2_3D, float fY2_3D, float fZ2_3D, float fX3_3D, float fY3_3D, float fZ3_3D, - int iSubpolyType, - int bHalfResTex) -{ - int iX0; // ebp - int iX1; // edi - int iX3; // esi + int iSubpolyType, int bHalfResTex) { + int iX0; // ebp + int iX1; // edi + int iX3; // esi int iTexHgt; // ebx - int iY3; // [esp+0h] [ebp-28h] - int iY0; // [esp+4h] [ebp-24h] - int iY1; // [esp+8h] [ebp-20h] - int iY2; // [esp+Ch] [ebp-1Ch] - int iX2; // [esp+10h] [ebp-18h] - - if ((polyParams->iSurfaceType & SURFACE_FLAG_SKIP_RENDER) != 0)// SURFACE_FLAG_SKIP_RENDER + int iY3; // [esp+0h] [ebp-28h] + int iY0; // [esp+4h] [ebp-24h] + int iY1; // [esp+8h] [ebp-20h] + int iY2; // [esp+Ch] [ebp-1Ch] + int iX2; // [esp+10h] [ebp-18h] + + if ((polyParams->iSurfaceType & SURFACE_FLAG_SKIP_RENDER) != + 0) // SURFACE_FLAG_SKIP_RENDER return; // setup globals for dodivide @@ -1300,13 +1049,16 @@ static void subdivide(uint8 *pDest, tPolyParams *polyParams, iX3 = polyParams->vertices[3].x; // determine tex flipping mode - fliptype = (polyParams->iSurfaceType & SURFACE_FLAG_FLIP_HORIZ) != 0;// SURFACE_FLAG_FLIP_HORIZ - if ((polyParams->iSurfaceType & SURFACE_FLAG_FLIP_VERT) != 0)// SURFACE_FLAG_FLIP_VERT - fliptype += 2; // 0=none, 1=horiz, 2=vert, 3=both + fliptype = (polyParams->iSurfaceType & SURFACE_FLAG_FLIP_HORIZ) != + 0; // SURFACE_FLAG_FLIP_HORIZ + if ((polyParams->iSurfaceType & SURFACE_FLAG_FLIP_VERT) != + 0) // SURFACE_FLAG_FLIP_VERT + fliptype += 2; // 0=none, 1=horiz, 2=vert, 3=both // set flat pol flag if SURFACE_FLAG_APPLY_TEXTURE is not set // This disables screen-size based subdivision for untextured pol - flatpol = ((subpoly->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) != 0) - 1;// SURFACE_FLAG_APPLY_TEXTURE + flatpol = ((subpoly->iSurfaceType & SURFACE_FLAG_APPLY_TEXTURE) != 0) - + 1; // SURFACE_FLAG_APPLY_TEXTURE // Determine tex dimensions based on pol type if (subpolytype >= 0) { @@ -1332,31 +1084,9 @@ static void subdivide(uint8 *pDest, tPolyParams *polyParams, tex_wid >>= 1; tex_hgt >>= 1; } - dodivide( - fX0_3D, - fY0_3D, - fZ0_3D, - fX1_3D, - fY1_3D, - fZ1_3D, - fX2_3D, - fY2_3D, - fZ2_3D, - fX3_3D, - fY3_3D, - fZ3_3D, - iX0, - iY0, - iX1, - iY1, - iX2, - iY2, - iX3, - iY3, - 0, - 0, - tex_wid, - tex_hgt); + dodivide(fX0_3D, fY0_3D, fZ0_3D, fX1_3D, fY1_3D, fZ1_3D, fX2_3D, fY2_3D, + fZ2_3D, fX3_3D, fY3_3D, fZ3_3D, iX0, iY0, iX1, iY1, iX2, iY2, iX3, + iY3, 0, 0, tex_wid, tex_hgt); // Reset tex coords to default values // Clean slate for next pol @@ -1366,7 +1096,7 @@ static void subdivide(uint8 *pDest, tPolyParams *polyParams, if (showsub) { // Edge 0-1 (top) if (fZ0_3D >= 1.0 && fZ1_3D >= 1.0) - compout(subptr, iX0, iY0, iX1, iY1, 0xF3u);// 0xF3 is blue in PALETTE.PAL + compout(subptr, iX0, iY0, iX1, iY1, 0xF3u); // 0xF3 is blue in PALETTE.PAL // Edge 1-2 (right) if (fZ1_3D >= 1.0 && fZ2_3D >= 1.0) compout(subptr, iX1, iY1, iX2, iY2, 0xF3u); @@ -1379,132 +1109,136 @@ static void subdivide(uint8 *pDest, tPolyParams *polyParams, } } - static void scene_render_sw_bind_target(SceneRendererSoftware *sw) { - if (!sw || !sw->targetBuffer) - return; - screen_pointer = sw->targetBuffer + sw->viewportY * sw->targetStride + sw->viewportX; + if (!sw || !sw->targetBuffer) + return; + screen_pointer = + sw->targetBuffer + sw->viewportY * sw->targetStride + sw->viewportX; } SceneRendererSoftware *scene_render_sw_create(SDL_GPUDevice *device, SDL_Window *window) { - (void)device; - (void)window; - SceneRendererSoftware *sw = calloc(1, sizeof(SceneRendererSoftware)); - return sw; + (void)device; + (void)window; + SceneRendererSoftware *sw = calloc(1, sizeof(SceneRendererSoftware)); + return sw; } -void scene_render_sw_destroy(SceneRendererSoftware *sw) { - free(sw); -} +void scene_render_sw_destroy(SceneRendererSoftware *sw) { free(sw); } void scene_render_sw_set_target(SceneRendererSoftware *sw, uint8 *buffer, int stride, int width, int height) { - if (!sw) - return; - sw->targetBuffer = buffer; - sw->targetStride = stride; - sw->targetWidth = width; - sw->targetHeight = height; - if (sw->viewportW == 0 && sw->viewportH == 0) { - sw->viewportX = 0; - sw->viewportY = 0; - sw->viewportW = width; - sw->viewportH = height; - } - scene_render_sw_bind_target(sw); + if (!sw) + return; + sw->targetBuffer = buffer; + sw->targetStride = stride; + sw->targetWidth = width; + sw->targetHeight = height; + if (sw->viewportW == 0 && sw->viewportH == 0) { + sw->viewportX = 0; + sw->viewportY = 0; + sw->viewportW = width; + sw->viewportH = height; + } + scene_render_sw_bind_target(sw); } -void scene_render_sw_set_viewport(SceneRendererSoftware *sw, - int x, int y, int w, int h) { - if (!sw) - return; - sw->viewportX = x; - sw->viewportY = y; - sw->viewportW = w; - sw->viewportH = h; - scene_render_sw_bind_target(sw); +void scene_render_sw_set_viewport(SceneRendererSoftware *sw, int x, int y, + int w, int h) { + if (!sw) + return; + sw->viewportX = x; + sw->viewportY = y; + sw->viewportW = w; + sw->viewportH = h; + scene_render_sw_bind_target(sw); } void scene_render_sw_set_camera(SceneRendererSoftware *sw, const SceneRenderCamera *camera) { - extern float viewx, viewy, viewz; - extern float fcos, fsin; - extern int VIEWDIST; - if (!sw || !camera) - return; - sw->camera = *camera; - viewx = camera->viewX; - viewy = camera->viewY; - viewz = camera->viewZ; - fcos = camera->cosYaw; - fsin = camera->sinYaw; - VIEWDIST = (int)camera->fovScale; + extern float viewx, viewy, viewz; + extern float fcos, fsin; + extern int VIEWDIST; + if (!sw || !camera) + return; + sw->camera = *camera; + viewx = camera->viewX; + viewy = camera->viewY; + viewz = camera->viewZ; + fcos = camera->cosYaw; + fsin = camera->sinYaw; + VIEWDIST = (int)camera->fovScale; } void scene_render_sw_set_projection(SceneRendererSoftware *sw, const SceneRenderProjection *proj) { - extern float vk1, vk2, vk3, vk4, vk5, vk6, vk7, vk8, vk9; - extern int scr_size, xbase, ybase, gfx_size; - if (!sw || !proj) - return; - sw->proj = *proj; - // Write through to globals for legacy code (subdivide, POLYTEX, etc.) - vk1 = proj->view[0][0]; vk2 = proj->view[0][1]; vk3 = proj->view[0][2]; - vk4 = proj->view[1][0]; vk5 = proj->view[1][1]; vk6 = proj->view[1][2]; - vk7 = proj->view[2][0]; vk8 = proj->view[2][1]; vk9 = proj->view[2][2]; - scr_size = proj->screenScale; - xbase = proj->centerX; - ybase = proj->centerY; - gfx_size = proj->texHalfRes; + extern float vk1, vk2, vk3, vk4, vk5, vk6, vk7, vk8, vk9; + extern int scr_size, xbase, ybase, gfx_size; + if (!sw || !proj) + return; + sw->proj = *proj; + // Write through to globals for legacy code (subdivide, POLYTEX, etc.) + vk1 = proj->view[0][0]; + vk2 = proj->view[0][1]; + vk3 = proj->view[0][2]; + vk4 = proj->view[1][0]; + vk5 = proj->view[1][1]; + vk6 = proj->view[1][2]; + vk7 = proj->view[2][0]; + vk8 = proj->view[2][1]; + vk9 = proj->view[2][2]; + scr_size = proj->screenScale; + xbase = proj->centerX; + ybase = proj->centerY; + gfx_size = proj->texHalfRes; } SceneTextureHandle scene_render_sw_load_texture(SceneRendererSoftware *sw, - uint8 *pixelData, - int width, int height, - int tex_idx, int texHalfRes) { - if (!sw) - return SCENE_TEXTURE_HANDLE_INVALID; - - if (tex_idx >= 0 && tex_idx < 32) { - SceneTextureHandle old = sw->texIdxToHandle[tex_idx]; - if (old != SCENE_TEXTURE_HANDLE_INVALID) - scene_render_sw_free_texture(sw, old); - } + uint8 *pixelData, int width, + int height, int tex_idx, + int texHalfRes) { + if (!sw) + return SCENE_TEXTURE_HANDLE_INVALID; - for (int i = 1; i < SCENE_RENDER_MAX_TEXTURE_SLOTS; i++) { - if (!sw->texSlots[i].in_use) { - sw->texSlots[i].pixels = pixelData; - sw->texSlots[i].width = width; - sw->texSlots[i].height = height; - sw->texSlots[i].tex_idx = tex_idx; - sw->texSlots[i].texHalfRes = texHalfRes; - sw->texSlots[i].in_use = 1; - if (tex_idx >= 0 && tex_idx < 32) - sw->texIdxToHandle[tex_idx] = i; - return (SceneTextureHandle)i; - } + if (tex_idx >= 0 && tex_idx < 32) { + SceneTextureHandle old = sw->texIdxToHandle[tex_idx]; + if (old != SCENE_TEXTURE_HANDLE_INVALID) + scene_render_sw_free_texture(sw, old); + } + + for (int i = 1; i < SCENE_RENDER_MAX_TEXTURE_SLOTS; i++) { + if (!sw->texSlots[i].in_use) { + sw->texSlots[i].pixels = pixelData; + sw->texSlots[i].width = width; + sw->texSlots[i].height = height; + sw->texSlots[i].tex_idx = tex_idx; + sw->texSlots[i].texHalfRes = texHalfRes; + sw->texSlots[i].in_use = 1; + if (tex_idx >= 0 && tex_idx < 32) + sw->texIdxToHandle[tex_idx] = i; + return (SceneTextureHandle)i; } - return SCENE_TEXTURE_HANDLE_INVALID; + } + return SCENE_TEXTURE_HANDLE_INVALID; } void scene_render_sw_free_texture(SceneRendererSoftware *sw, SceneTextureHandle handle) { - if (!sw || handle <= 0 || handle >= SCENE_RENDER_MAX_TEXTURE_SLOTS) - return; - int tex_idx = sw->texSlots[handle].tex_idx; - if (tex_idx >= 0 && tex_idx < 32 && sw->texIdxToHandle[tex_idx] == handle) - sw->texIdxToHandle[tex_idx] = SCENE_TEXTURE_HANDLE_INVALID; - memset(&sw->texSlots[handle], 0, sizeof(SceneTextureSlot)); + if (!sw || handle <= 0 || handle >= SCENE_RENDER_MAX_TEXTURE_SLOTS) + return; + int tex_idx = sw->texSlots[handle].tex_idx; + if (tex_idx >= 0 && tex_idx < 32 && sw->texIdxToHandle[tex_idx] == handle) + sw->texIdxToHandle[tex_idx] = SCENE_TEXTURE_HANDLE_INVALID; + memset(&sw->texSlots[handle], 0, sizeof(SceneTextureSlot)); } SceneTextureHandle scene_render_sw_get_texture_handle(SceneRendererSoftware *sw, int tex_idx) { - if (!sw) - return SCENE_TEXTURE_HANDLE_INVALID; - if (tex_idx >= 0 && tex_idx < 32) - return sw->texIdxToHandle[tex_idx]; + if (!sw) return SCENE_TEXTURE_HANDLE_INVALID; + if (tex_idx >= 0 && tex_idx < 32) + return sw->texIdxToHandle[tex_idx]; + return SCENE_TEXTURE_HANDLE_INVALID; } void scene_render_sw_quad_world_legacy(SceneRendererSoftware *sw, @@ -1512,123 +1246,136 @@ void scene_render_sw_quad_world_legacy(SceneRendererSoftware *sw, SceneTextureHandle handle, int surfaceFlags, SceneRenderLegacyQuadOptions options) { - if (!sw || !verts || !sw->targetBuffer) - return; + if (!sw || !verts || !sw->targetBuffer) + return; - scene_render_sw_bind_target(sw); - - const SceneRenderCamera *cam = &sw->camera; - const SceneRenderProjection *proj = &sw->proj; - - int useCloudProjection = options.subdivideType == SCENE_RENDER_SUBDIVIDE_TYPE_CLOUD; - int subpolyType; - if (useCloudProjection) { - subpolyType = SUBPOLY_STANDARD; - } else if (options.subdivideType != SCENE_RENDER_SUBDIVIDE_TYPE_AUTO) { - subpolyType = options.subdivideType; - } else if (handle > 0 && handle < SCENE_RENDER_MAX_TEXTURE_SLOTS - && sw->texSlots[handle].in_use - && sw->texSlots[handle].tex_idx == TEXTURE_BANK_BUILDING) { - subpolyType = SUBPOLY_BUILDING; - } else if ((surfaceFlags & SURFACE_FLAG_TEXTURE_PAIR) && wide_on) { - subpolyType = SUBPOLY_WALL; - } else { - subpolyType = SUBPOLY_STANDARD; - } + scene_render_sw_bind_target(sw); + + const SceneRenderCamera *cam = &sw->camera; + const SceneRenderProjection *proj = &sw->proj; + + int useCloudProjection = + options.subdivideType == SCENE_RENDER_SUBDIVIDE_TYPE_CLOUD; + int subpolyType; + if (useCloudProjection) { + subpolyType = SUBPOLY_STANDARD; + } else if (options.subdivideType != SCENE_RENDER_SUBDIVIDE_TYPE_AUTO) { + subpolyType = options.subdivideType; + } else if (handle > 0 && handle < SCENE_RENDER_MAX_TEXTURE_SLOTS && + sw->texSlots[handle].in_use && + sw->texSlots[handle].tex_idx == TEXTURE_BANK_BUILDING) { + subpolyType = SUBPOLY_BUILDING; + } else if ((surfaceFlags & SURFACE_FLAG_TEXTURE_PAIR) && wide_on) { + subpolyType = SUBPOLY_WALL; + } else { + subpolyType = SUBPOLY_STANDARD; + } - tPolyParams poly; - poly.iSurfaceType = surfaceFlags; - poly.uiNumVerts = 4; - - float subVx[4], subVy[4], subVz[4]; - float directVz[4]; - - if (subpolyType == SUBPOLY_BUILDING) { - int iVx[4], iVy[4], iVz[4]; - int clippedCount = 0; - for (int i = 0; i < 4; i++) { - double dx = floor((double)verts[i].x - cam->viewX); - double dy = floor((double)verts[i].y - cam->viewY); - double dz = floor((double)verts[i].z - cam->viewZ); - iVx[i] = (int)(dx * proj->view[0][0] + dy * proj->view[1][0] + dz * proj->view[2][0]); - iVy[i] = (int)(dx * proj->view[0][1] + dy * proj->view[1][1] + dz * proj->view[2][1]); - iVz[i] = (int)(dx * proj->view[0][2] + dy * proj->view[1][2] + dz * proj->view[2][2]); - directVz[i] = (float)iVz[i]; - } - int viewDist = (int)cam->fovScale; - for (int i = 0; i < 4; i++) { - if (iVz[i] < 80) { - iVz[i] = 80; - clippedCount++; - } - int xp = iVx[i] * viewDist / iVz[i] + proj->centerX; - int yp = iVy[i] * viewDist / iVz[i] + proj->centerY; - poly.vertices[i].x = (proj->screenScale * xp) >> 6; - poly.vertices[i].y = (proj->screenScale * (199 - yp)) >> 6; - subVx[i] = (float)iVx[i]; - subVy[i] = (float)iVy[i]; - subVz[i] = (float)iVz[i]; - } - if (clippedCount >= 4) - return; - } else { - int useCarProjection = subpolyType >= 3; - double viewDist = (double)cam->fovScale; - for (int i = 0; i < 4; i++) { - double dx = (double)(verts[i].x - cam->viewX); - double dy = (double)(verts[i].y - cam->viewY); - double dz = (double)(verts[i].z - cam->viewZ); - float fVx = (float)(dx * proj->view[0][0] + dy * proj->view[1][0] + dz * proj->view[2][0]); - float fVy = (float)(dx * proj->view[0][1] + dy * proj->view[1][1] + dz * proj->view[2][1]); - double dCameraZ = dx * proj->view[0][2] + dy * proj->view[1][2] + dz * proj->view[2][2]; - float fVz = (float)dCameraZ; - float fProjectedZ = fVz; - if (fProjectedZ < 80.0f) fProjectedZ = 80.0f; - double dInvZ = 1.0 / (double)fProjectedZ; - int xp; - int yp; - if (useCarProjection || useCloudProjection) { - xp = (int)(viewDist * (double)fVx * dInvZ + (double)proj->centerX); - yp = (int)(dInvZ * (viewDist * (double)fVy) + (double)proj->centerY); - } else { - xp = (int)round(viewDist * (double)fVx * dInvZ + (double)proj->centerX); - yp = (int)round(dInvZ * (viewDist * (double)fVy) + (double)proj->centerY); - } - poly.vertices[i].x = (xp * proj->screenScale) >> 6; - poly.vertices[i].y = (proj->screenScale * (199 - yp)) >> 6; - subVx[i] = fVx; - subVy[i] = fVy; - subVz[i] = (useCarProjection || useCloudProjection) ? fVz : (float)((int)round(dCameraZ)); - directVz[i] = subVz[i]; - } + tPolyParams poly; + poly.iSurfaceType = surfaceFlags; + poly.uiNumVerts = 4; + + float subVx[4], subVy[4], subVz[4]; + float directVz[4]; + + if (subpolyType == SUBPOLY_BUILDING) { + int iVx[4], iVy[4], iVz[4]; + int clippedCount = 0; + for (int i = 0; i < 4; i++) { + double dx = floor((double)verts[i].x - cam->viewX); + double dy = floor((double)verts[i].y - cam->viewY); + double dz = floor((double)verts[i].z - cam->viewZ); + iVx[i] = (int)(dx * proj->view[0][0] + dy * proj->view[1][0] + + dz * proj->view[2][0]); + iVy[i] = (int)(dx * proj->view[0][1] + dy * proj->view[1][1] + + dz * proj->view[2][1]); + iVz[i] = (int)(dx * proj->view[0][2] + dy * proj->view[1][2] + + dz * proj->view[2][2]); + directVz[i] = (float)iVz[i]; } - - if (subpolyType == SUBPOLY_WALL) set_starts(1u); - - int useDirect = 0; - if (options.subThreshold > 0.0f || subpolyType == SUBPOLY_BUILDING) { - float minZ = directVz[0]; - if (directVz[1] < minZ) minZ = directVz[1]; - if (directVz[2] < minZ) minZ = directVz[2]; - if (directVz[3] < minZ) minZ = directVz[3]; - if (options.subThreshold <= minZ) - useDirect = 1; + int viewDist = (int)cam->fovScale; + for (int i = 0; i < 4; i++) { + if (iVz[i] < 80) { + iVz[i] = 80; + clippedCount++; + } + int xp = iVx[i] * viewDist / iVz[i] + proj->centerX; + int yp = iVy[i] * viewDist / iVz[i] + proj->centerY; + poly.vertices[i].x = (proj->screenScale * xp) >> 6; + poly.vertices[i].y = (proj->screenScale * (199 - yp)) >> 6; + subVx[i] = (float)iVx[i]; + subVy[i] = (float)iVy[i]; + subVz[i] = (float)iVz[i]; } - - if (useDirect && handle == SCENE_TEXTURE_HANDLE_INVALID) { - POLYFLAT(screen_pointer, &poly); - } else if (useDirect) { - SceneTextureSlot *slot = &sw->texSlots[handle]; - POLYTEX(slot->pixels, screen_pointer, &poly, - slot->tex_idx, slot->texHalfRes); - } else { - subdivide(screen_pointer, &poly, - subVx[0], subVy[0], subVz[0], - subVx[1], subVy[1], subVz[1], - subVx[2], subVy[2], subVz[2], - subVx[3], subVy[3], subVz[3], - subpolyType, proj->texHalfRes); + if (clippedCount >= 4) + return; + } else { + int useCarProjection = subpolyType >= 3; + double viewDist = (double)cam->fovScale; + for (int i = 0; i < 4; i++) { + double dx = (double)(verts[i].x - cam->viewX); + double dy = (double)(verts[i].y - cam->viewY); + double dz = (double)(verts[i].z - cam->viewZ); + float fVx = (float)(dx * proj->view[0][0] + dy * proj->view[1][0] + + dz * proj->view[2][0]); + float fVy = (float)(dx * proj->view[0][1] + dy * proj->view[1][1] + + dz * proj->view[2][1]); + double dCameraZ = + dx * proj->view[0][2] + dy * proj->view[1][2] + dz * proj->view[2][2]; + float fVz = (float)dCameraZ; + float fProjectedZ = fVz; + if (fProjectedZ < 80.0f) + fProjectedZ = 80.0f; + double dInvZ = 1.0 / (double)fProjectedZ; + int xp; + int yp; + if (useCarProjection || useCloudProjection) { + xp = (int)(viewDist * (double)fVx * dInvZ + (double)proj->centerX); + yp = (int)(dInvZ * (viewDist * (double)fVy) + (double)proj->centerY); + } else { + xp = (int)round(viewDist * (double)fVx * dInvZ + (double)proj->centerX); + yp = (int)round(dInvZ * (viewDist * (double)fVy) + + (double)proj->centerY); + } + poly.vertices[i].x = (xp * proj->screenScale) >> 6; + poly.vertices[i].y = (proj->screenScale * (199 - yp)) >> 6; + subVx[i] = fVx; + subVy[i] = fVy; + subVz[i] = (useCarProjection || useCloudProjection) + ? fVz + : (float)((int)round(dCameraZ)); + directVz[i] = subVz[i]; } + } + + if (subpolyType == SUBPOLY_WALL) + set_starts(1u); + + int useDirect = 0; + if (options.subThreshold > 0.0f || subpolyType == SUBPOLY_BUILDING) { + float minZ = directVz[0]; + if (directVz[1] < minZ) + minZ = directVz[1]; + if (directVz[2] < minZ) + minZ = directVz[2]; + if (directVz[3] < minZ) + minZ = directVz[3]; + if (options.subThreshold <= minZ) + useDirect = 1; + } + + if (useDirect && handle == SCENE_TEXTURE_HANDLE_INVALID) { + POLYFLAT(screen_pointer, &poly); + } else if (useDirect) { + SceneTextureSlot *slot = &sw->texSlots[handle]; + POLYTEX(slot->pixels, screen_pointer, &poly, slot->tex_idx, + slot->texHalfRes); + } else { + subdivide(screen_pointer, &poly, subVx[0], subVy[0], subVz[0], subVx[1], + subVy[1], subVz[1], subVx[2], subVy[2], subVz[2], subVx[3], + subVy[3], subVz[3], subpolyType, proj->texHalfRes); + } - if (subpolyType == SUBPOLY_WALL) set_starts(0); + if (subpolyType == SUBPOLY_WALL) + set_starts(0); } diff --git a/PROJECTS/ROLLER/scene_render_software.h b/PROJECTS/ROLLER/scene_render_software.h index e4f9d0ce..6536a26b 100644 --- a/PROJECTS/ROLLER/scene_render_software.h +++ b/PROJECTS/ROLLER/scene_render_software.h @@ -12,17 +12,17 @@ void scene_render_sw_destroy(SceneRendererSoftware *sw); void scene_render_sw_set_target(SceneRendererSoftware *sw, uint8 *buffer, int stride, int width, int height); -void scene_render_sw_set_viewport(SceneRendererSoftware *sw, - int x, int y, int w, int h); +void scene_render_sw_set_viewport(SceneRendererSoftware *sw, int x, int y, + int w, int h); void scene_render_sw_set_camera(SceneRendererSoftware *sw, const SceneRenderCamera *camera); void scene_render_sw_set_projection(SceneRendererSoftware *sw, const SceneRenderProjection *proj); SceneTextureHandle scene_render_sw_load_texture(SceneRendererSoftware *sw, - uint8 *pixelData, - int width, int height, - int tex_idx, int texHalfRes); + uint8 *pixelData, int width, + int height, int tex_idx, + int texHalfRes); void scene_render_sw_free_texture(SceneRendererSoftware *sw, SceneTextureHandle handle); SceneTextureHandle scene_render_sw_get_texture_handle(SceneRendererSoftware *sw, diff --git a/PROJECTS/ROLLER/snapshot.c b/PROJECTS/ROLLER/snapshot.c index c5d05e16..c8369c64 100644 --- a/PROJECTS/ROLLER/snapshot.c +++ b/PROJECTS/ROLLER/snapshot.c @@ -18,42 +18,46 @@ //------------------------------------------------------------------------------------------------- int g_bSnapshotMode = 0; -tSnapshotConfig g_SnapshotConfig = { 0 }; +tSnapshotConfig g_SnapshotConfig = {0}; //------------------------------------------------------------------------------------------------- -void SnapshotSetReplay(const char *szReplay) -{ - if (!szReplay) return; +void SnapshotSetReplay(const char *szReplay) { + if (!szReplay) + return; g_SnapshotConfig.eKind = SNAPSHOT_KIND_REPLAY; - strncpy(g_SnapshotConfig.szReplayName, szReplay, sizeof(g_SnapshotConfig.szReplayName) - 1); - g_SnapshotConfig.szReplayName[sizeof(g_SnapshotConfig.szReplayName) - 1] = '\0'; + strncpy(g_SnapshotConfig.szReplayName, szReplay, + sizeof(g_SnapshotConfig.szReplayName) - 1); + g_SnapshotConfig.szReplayName[sizeof(g_SnapshotConfig.szReplayName) - 1] = + '\0'; } //------------------------------------------------------------------------------------------------- -void SnapshotSetScene(const char *szScene) -{ - if (!szScene) return; +void SnapshotSetScene(const char *szScene) { + if (!szScene) + return; g_SnapshotConfig.eKind = SNAPSHOT_KIND_SCENE; - strncpy(g_SnapshotConfig.szSceneName, szScene, sizeof(g_SnapshotConfig.szSceneName) - 1); + strncpy(g_SnapshotConfig.szSceneName, szScene, + sizeof(g_SnapshotConfig.szSceneName) - 1); g_SnapshotConfig.szSceneName[sizeof(g_SnapshotConfig.szSceneName) - 1] = '\0'; } //------------------------------------------------------------------------------------------------- -void SnapshotSetOutDir(const char *szOutDir) -{ - if (!szOutDir) return; - strncpy(g_SnapshotConfig.szOutDir, szOutDir, sizeof(g_SnapshotConfig.szOutDir) - 1); +void SnapshotSetOutDir(const char *szOutDir) { + if (!szOutDir) + return; + strncpy(g_SnapshotConfig.szOutDir, szOutDir, + sizeof(g_SnapshotConfig.szOutDir) - 1); g_SnapshotConfig.szOutDir[sizeof(g_SnapshotConfig.szOutDir) - 1] = '\0'; } //------------------------------------------------------------------------------------------------- -int SnapshotParseFrames(const char *szFramesArg) -{ - if (!szFramesArg || !*szFramesArg) return 1; +int SnapshotParseFrames(const char *szFramesArg) { + if (!szFramesArg || !*szFramesArg) + return 1; char szBuf[512]; strncpy(szBuf, szFramesArg, sizeof(szBuf) - 1); @@ -67,11 +71,14 @@ int SnapshotParseFrames(const char *szFramesArg) char *pSaveptr = NULL; char *pTok = strtok_r(szBuf, ",", &pSaveptr); while (pTok) { - while (*pTok == ' ' || *pTok == '\t') ++pTok; - if (!*pTok) return 1; + while (*pTok == ' ' || *pTok == '\t') + ++pTok; + if (!*pTok) + return 1; char *pEnd = NULL; long lVal = strtol(pTok, &pEnd, 10); - if (pEnd == pTok || (*pEnd != '\0' && *pEnd != ' ' && *pEnd != '\t') || lVal < 0) + if (pEnd == pTok || (*pEnd != '\0' && *pEnd != ' ' && *pEnd != '\t') || + lVal < 0) return 1; if (g_SnapshotConfig.iNumFrames >= SNAPSHOT_MAX_FRAMES) return 1; @@ -86,20 +93,19 @@ int SnapshotParseFrames(const char *szFramesArg) //------------------------------------------------------------------------------------------------- -void SnapshotZeroScreen(void) -{ - if (!g_bSnapshotMode || !scrbuf) return; +void SnapshotZeroScreen(void) { + if (!g_bSnapshotMode || !scrbuf) + return; size_t bytes = (size_t)(SVGA_ON ? 256000 : 64000); memset(scrbuf, 0, bytes); } //------------------------------------------------------------------------------------------------- -static void SnapshotCopyStem(char *szStem, size_t uiStemSize) -{ +static void SnapshotCopyStem(char *szStem, size_t uiStemSize) { const char *szSource = g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE - ? g_SnapshotConfig.szSceneName - : g_SnapshotConfig.szReplayName; + ? g_SnapshotConfig.szSceneName + : g_SnapshotConfig.szReplayName; strncpy(szStem, szSource, uiStemSize - 1); szStem[uiStemSize - 1] = '\0'; @@ -108,41 +114,42 @@ static void SnapshotCopyStem(char *szStem, size_t uiStemSize) char *pSlash = strrchr(szStem, '/'); char *pBack = strrchr(szStem, '\\'); char *pBase = pSlash; - if (pBack && (!pBase || pBack > pBase)) pBase = pBack; - if (pBase) memmove(szStem, pBase + 1, strlen(pBase + 1) + 1); + if (pBack && (!pBase || pBack > pBase)) + pBase = pBack; + if (pBase) + memmove(szStem, pBase + 1, strlen(pBase + 1) + 1); // Strip extension. char *pDot = strrchr(szStem, '.'); - if (pDot) *pDot = '\0'; + if (pDot) + *pDot = '\0'; // Lowercase. for (char *p = szStem; *p; ++p) { - if (*p >= 'A' && *p <= 'Z') *p = (char)(*p + ('a' - 'A')); + if (*p >= 'A' && *p <= 'Z') + *p = (char)(*p + ('a' - 'A')); } } -static void SnapshotBuildPath(char *szOut, size_t uiOutSize, int iFrame) -{ +static void SnapshotBuildPath(char *szOut, size_t uiOutSize, int iFrame) { char szStem[64]; SnapshotCopyStem(szStem, sizeof(szStem)); size_t uiDirLen = strlen(g_SnapshotConfig.szOutDir); - int bHasSep = uiDirLen > 0 && - (g_SnapshotConfig.szOutDir[uiDirLen - 1] == '/' || - g_SnapshotConfig.szOutDir[uiDirLen - 1] == '\\'); - snprintf(szOut, uiOutSize, "%s%s%s_%d.png", - g_SnapshotConfig.szOutDir, - bHasSep ? "" : "/", - szStem, - iFrame); + int bHasSep = + uiDirLen > 0 && (g_SnapshotConfig.szOutDir[uiDirLen - 1] == '/' || + g_SnapshotConfig.szOutDir[uiDirLen - 1] == '\\'); + snprintf(szOut, uiOutSize, "%s%s%s_%d.png", g_SnapshotConfig.szOutDir, + bHasSep ? "" : "/", szStem, iFrame); } //------------------------------------------------------------------------------------------------- -void SnapshotPresent(void) -{ - if (!g_bSnapshotMode || !scrbuf) return; - if (!g_bPaletteSet) return; +void SnapshotPresent(void) { + if (!g_bSnapshotMode || !scrbuf) + return; + if (!g_bPaletteSet) + return; int iCaptureKey = currentreplayframe; if (g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE) { @@ -166,7 +173,8 @@ void SnapshotPresent(void) int iRc = RollerWriteIndexedPng(szPath, scrbuf, palette, 640, 400); if (iRc != 0) { - fprintf(stderr, "snapshot: PNG write failed (rc=%d) for '%s'\n", iRc, szPath); + fprintf(stderr, "snapshot: PNG write failed (rc=%d) for '%s'\n", iRc, + szPath); } else { fprintf(stdout, "snapshot: wrote '%s' (frame %d)\n", szPath, iCaptureKey); fflush(stdout); @@ -175,8 +183,10 @@ void SnapshotPresent(void) } if (g_SnapshotConfig.iCapturedCount >= g_SnapshotConfig.iNumFrames || - (g_SnapshotConfig.eKind != SNAPSHOT_KIND_SCENE && currentreplayframe >= g_SnapshotConfig.iMaxFrame) || - (g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE && g_SnapshotConfig.iPresentFrame >= g_SnapshotConfig.iMaxFrame)) { + (g_SnapshotConfig.eKind != SNAPSHOT_KIND_SCENE && + currentreplayframe >= g_SnapshotConfig.iMaxFrame) || + (g_SnapshotConfig.eKind == SNAPSHOT_KIND_SCENE && + g_SnapshotConfig.iPresentFrame >= g_SnapshotConfig.iMaxFrame)) { quit_game = 1; racing = 0; } @@ -184,50 +194,48 @@ void SnapshotPresent(void) //------------------------------------------------------------------------------------------------- -int SnapshotShouldStop(void) -{ +int SnapshotShouldStop(void) { return g_bSnapshotMode && g_SnapshotConfig.iCapturedCount >= g_SnapshotConfig.iNumFrames; } //------------------------------------------------------------------------------------------------- -void SnapshotQueueRawKey(uint8 byRawKey) -{ - if (!g_bSnapshotMode) return; +void SnapshotQueueRawKey(uint8 byRawKey) { + if (!g_bSnapshotMode) + return; key_buffer[write_key] = byRawKey; write_key = (write_key + 1) & 0x3F; } //------------------------------------------------------------------------------------------------- -void SnapshotAdvanceTick(void) -{ - if (!g_bSnapshotMode) return; +void SnapshotAdvanceTick(void) { + if (!g_bSnapshotMode) + return; tickhandler(); } //------------------------------------------------------------------------------------------------- -void SnapshotApplyFixedSettings(void) -{ +void SnapshotApplyFixedSettings(void) { // Replaces load_fatal_config() in snapshot mode. Pinning these defaults // makes the captured pixels independent of the developer's local // fatal.ini (which would otherwise toggle texturing options, draw // distance, screen size, etc., and silently drift the baselines). - fatal_ini_loaded = -1; // skip the auto-config branch keyed on machine_speed - textures_off = 0; // every rendering feature enabled - game_svga = -1; // SVGA / 640x400 framebuffer - game_size = 128; // full game screen size - game_view[0] = 1; // chase camera + fatal_ini_loaded = -1; // skip the auto-config branch keyed on machine_speed + textures_off = 0; // every rendering feature enabled + game_svga = -1; // SVGA / 640x400 framebuffer + game_size = 128; // full game screen size + game_view[0] = 1; // chase camera game_view[1] = 1; - allengines = -1; // engine particles on - view_limit = 32; // max draw distance - cheat_mode = 0; // no cheats + allengines = -1; // engine particles on + view_limit = 32; // max draw distance + cheat_mode = 0; // no cheats replay_record = 0; - soundon = 0; // headless: no audio + soundon = 0; // headless: no audio musicon = 0; - names_on = 1; // standard player-name overlay setting + names_on = 1; // standard player-name overlay setting level = 0; damage_level = 0; infinite_laps = 0; diff --git a/PROJECTS/ROLLER/snapshot.h b/PROJECTS/ROLLER/snapshot.h index c333a172..a4c5ea38 100644 --- a/PROJECTS/ROLLER/snapshot.h +++ b/PROJECTS/ROLLER/snapshot.h @@ -6,15 +6,13 @@ #define SNAPSHOT_MAX_FRAMES 64 -typedef enum -{ +typedef enum { SNAPSHOT_KIND_NONE = 0, SNAPSHOT_KIND_REPLAY, SNAPSHOT_KIND_SCENE, } eSnapshotKind; -typedef struct -{ +typedef struct { eSnapshotKind eKind; char szReplayName[64]; char szSceneName[64]; diff --git a/PROJECTS/ROLLER/snapshot_scenes.c b/PROJECTS/ROLLER/snapshot_scenes.c index e3e47168..bf7b32da 100644 --- a/PROJECTS/ROLLER/snapshot_scenes.c +++ b/PROJECTS/ROLLER/snapshot_scenes.c @@ -5,14 +5,11 @@ #include #include -static int SnapshotSceneCapturedAll(void) -{ +static int SnapshotSceneCapturedAll(void) { return g_SnapshotConfig.iCapturedCount == g_SnapshotConfig.iNumFrames ? 0 : 1; } - -int SnapshotRunScene(void) -{ +int SnapshotRunScene(void) { if (strcmp(g_SnapshotConfig.szSceneName, "menu-main") == 0) { snapshot_render_menu_main(); return SnapshotSceneCapturedAll(); @@ -42,6 +39,7 @@ int SnapshotRunScene(void) return SnapshotSceneCapturedAll(); } - fprintf(stderr, "ERROR: unknown snapshot scene '%s'\n", g_SnapshotConfig.szSceneName); + fprintf(stderr, "ERROR: unknown snapshot scene '%s'\n", + g_SnapshotConfig.szSceneName); return 1; } diff --git a/PROJECTS/ROLLER/sound.c b/PROJECTS/ROLLER/sound.c index c8bff25c..2de269da 100644 --- a/PROJECTS/ROLLER/sound.c +++ b/PROJECTS/ROLLER/sound.c @@ -29,133 +29,162 @@ #else #include #include -#define O_BINARY 0 //linux does not differentiate between text and binary +#define O_BINARY 0 // linux does not differentiate between text and binary #endif //------------------------------------------------------------------------------------------------- -int samplespending = 0; //000A4690 -int writesample = 0; //000A4694 -int readsample = 0; //000A4698 -int lastsample = 0; //000A469C -int musicon = -1; //000A46A0 -int soundon = -1; //000A46A4 -int allengines = -1; //000A46A8 -int cheat_samples = 0; //000A46AC -int palette_brightness = 32;//000A46B0 -int last_inp[2] = { 0, 0 }; //000A46BC -void *pal_selector = (void *)-1; //000A46B4 -char SourcePath[64] = { 0 }; //000A46C4 -char DestinationPath[64] = { 0 }; //000A4704 -char languagename[32] = { 0 }; //000A4744 -int writeptr = 0; //000A476C -int readptr = 0; //000A4770 -int SoundCard = 0; //000A4774 -int SoundPort = 0; //000A4778 -int SoundIRQ = 0; //000A477C -int SoundDMA = 0; //000A4780 -int EngineVolume = 32; //000A4784 -int SFXVolume = 56; //000A4788 -int SpeechVolume = 127; //000A478C -int MusicVolume = 108; //000A4790 -int MusicCard = 0; //000A4794 -int MusicCD = 0; //000A4798 -int MusicPort = 0; //000A479C -uint8 *SongPtr = NULL; //000A47A0 -int SongHandle = 0; //000A47A4 -int CDSong[20] = { 10, 10, 10, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0 }; //000A47A8 -int GMSong[21] = { 0, 1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0 }; //000A47F8 -tSampleData SampleData = { NULL, 0u, 0, 0, 2, 32767, 0, 0, 0, 0, 18176, 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1701995379 } }; //000A484C -tSampleData SampleFixed = { NULL, 0u, 0, 0, 2, 32767, 0, 0, 0, 0, 256, 0, 0, 0, 0, 0, 0x8000, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; //000A48C4 Modified by ROLLER to have center pan -tSampleData SamplePanned = { NULL, 0u, 0, 0, 2, 32767, 0, 0, 0, 0, 768, 0, 0, 0, 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; //000A493C -uint8 rud_gr[2] = { 0, 0 }; //000A4A08 -uint8 rud_strat[2] = { 0, 0 }; //000A4A0A -int Joy1used = 0; //000A4A0C -int Joy2used = 0; //000A4A0C -int fraction = 0; //000A4A14 -int x1ok = 0; //000A4A30 -int y1ok = 0; //000A4A34 -int x2ok = 0; //000A4A38 -int y2ok = 0; //000A4A3C -int bitaccept = 0; //000A4A40 -uint8 *frontendspeechptr = NULL;//000A4A44 -int frontendspeechhandle = -1; //000A4A48 +int samplespending = 0; // 000A4690 +int writesample = 0; // 000A4694 +int readsample = 0; // 000A4698 +int lastsample = 0; // 000A469C +int musicon = -1; // 000A46A0 +int soundon = -1; // 000A46A4 +int allengines = -1; // 000A46A8 +int cheat_samples = 0; // 000A46AC +int palette_brightness = 32; // 000A46B0 +int last_inp[2] = {0, 0}; // 000A46BC +void *pal_selector = (void *)-1; // 000A46B4 +char SourcePath[64] = {0}; // 000A46C4 +char DestinationPath[64] = {0}; // 000A4704 +char languagename[32] = {0}; // 000A4744 +int writeptr = 0; // 000A476C +int readptr = 0; // 000A4770 +int SoundCard = 0; // 000A4774 +int SoundPort = 0; // 000A4778 +int SoundIRQ = 0; // 000A477C +int SoundDMA = 0; // 000A4780 +int EngineVolume = 32; // 000A4784 +int SFXVolume = 56; // 000A4788 +int SpeechVolume = 127; // 000A478C +int MusicVolume = 108; // 000A4790 +int MusicCard = 0; // 000A4794 +int MusicCD = 0; // 000A4798 +int MusicPort = 0; // 000A479C +uint8 *SongPtr = NULL; // 000A47A0 +int SongHandle = 0; // 000A47A4 +int CDSong[20] = {10, 10, 10, 2, 3, 4, 5, 6, 7, + 8, 0, 0, 0, 0, 0, 0, 0}; // 000A47A8 +int GMSong[21] = {0, 1, 2, 3, 4, 5, 6, 3, 4, + 5, 6, 0, 0, 0, 0, 0, 0, 0}; // 000A47F8 +tSampleData SampleData = { + NULL, 0u, 0, + 0, 2, 32767, + 0, 0, 0, + 0, 18176, 0, + 0, 0, 0, + 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1701995379}}; // 000A484C +tSampleData SampleFixed = { + NULL, + 0u, + 0, + 0, + 2, + 32767, + 0, + 0, + 0, + 0, + 256, + 0, + 0, + 0, + 0, + 0, + 0x8000, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0}}; // 000A48C4 Modified by ROLLER to have center pan +tSampleData SamplePanned = { + NULL, 0u, 0, 0, 2, 32767, + 0, 0, 0, 0, 768, 0, + 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; // 000A493C +uint8 rud_gr[2] = {0, 0}; // 000A4A08 +uint8 rud_strat[2] = {0, 0}; // 000A4A0A +int Joy1used = 0; // 000A4A0C +int Joy2used = 0; // 000A4A0C +int fraction = 0; // 000A4A14 +int x1ok = 0; // 000A4A30 +int y1ok = 0; // 000A4A34 +int x2ok = 0; // 000A4A38 +int y2ok = 0; // 000A4A3C +int bitaccept = 0; // 000A4A40 +uint8 *frontendspeechptr = NULL; // 000A4A44 +int frontendspeechhandle = -1; // 000A4A48 uint32 frontendlen = 0; -int holdmusic = 0; //000A4A4C -int drivertype = -1; //000A4A50 -uint8 unmangleinbuf[1024]; //00149EF0 -uint8 *musicbuffer; //0014EBF8 -int lastvolume[16]; //001603F8 -int lastpitch[16]; //00160438 -int lastpan[16]; //00160478 -int net_time[16]; //001604B8 -int joyvalue[8]; //001604F8 -tJoyPos rud_Joy_pos; //00160518 -int rud_turn[2]; //00160538 -int rud_swheel[2]; //00160540 -int rud_steer[2]; //00160548 -uint32 SampleLen[120]; //00160560 -uint8 *SamplePtr[120]; //00160750 -tSampleHandleCar SampleHandleCar[120]; //00160930 -char Sample[120][15]; //00162730 -char lang[16][32]; //00162E38 -int TrackMap[32]; //00163038 -char TextExt[64]; //001630CA -char SampleExt[64]; //0016310A -int Pending[16]; //0016314C -tSamplePending SamplePending[16][20]; //0016318C -int HandleCar[32]; //00163B8C -int HandleSample[32]; //00163C0C -tCarSoundData enginedelay[16]; //00163C8C -int car_to_player[16]; //0016748C -int player_to_car[16]; //001674CC -tSpeechInfo speechinfo[16]; //0016750C -int load_times[16]; //0016760C -tCopyData copy_multiple[512][16]; //0016764C -int unmangleinpoff; //0016F64C -uint8 *unmangledst; //0016F650 -int unmangleoverflow; //0016F654 -FILE *unmanglefile; //0016F658 -int unmanglebufpos; //0016F65C -volatile int s7; //0016F660 -int network_timeout; //0016F668 -void *MT32Data; //0016F66C -void *FMDrums; //0016F670 -void *FMInstruments; //0016F674 -int network_sync_error; //0016F678 -int ticks_received; //0016F680 -int network_limit; //0016F684 -int MIDIHandle; //0016F68C -int DIGIHandle; //0016F690 -volatile int frames; //0016F694 -char Song[20][15]; //0016F708 -uint32 tickhandle; //0016F834 -DPMI_RMI RMI; //0016F838 -tColor *pal_addr; //0016F86C -int user_inp; //0016F87C -int nummusictracks; //0016F8A8 -int winchampsong; //0016F8AC -int winsong; //0016F8B0 -int delaywritex; //0016F8B4 -int delayreadx; //0016F8B8 -int leaderboardsong; //0016F8BC -int optionssong; //0016F8C0 -int titlesong; //0016F8C4 -int delaywrite; //0016F8C8 -int delayread; //0016F8CC -int numsamples; //0016F8D0 -int cheatsample; //0016F8D4 -int languages; //0016F8D8 -int net_loading; //0016F8DC -int already_quit; //0016F8E0 -int network_error; //0017C97C +int holdmusic = 0; // 000A4A4C +int drivertype = -1; // 000A4A50 +uint8 unmangleinbuf[1024]; // 00149EF0 +uint8 *musicbuffer; // 0014EBF8 +int lastvolume[16]; // 001603F8 +int lastpitch[16]; // 00160438 +int lastpan[16]; // 00160478 +int net_time[16]; // 001604B8 +int joyvalue[8]; // 001604F8 +tJoyPos rud_Joy_pos; // 00160518 +int rud_turn[2]; // 00160538 +int rud_swheel[2]; // 00160540 +int rud_steer[2]; // 00160548 +uint32 SampleLen[120]; // 00160560 +uint8 *SamplePtr[120]; // 00160750 +tSampleHandleCar SampleHandleCar[120]; // 00160930 +char Sample[120][15]; // 00162730 +char lang[16][32]; // 00162E38 +int TrackMap[32]; // 00163038 +char TextExt[64]; // 001630CA +char SampleExt[64]; // 0016310A +int Pending[16]; // 0016314C +tSamplePending SamplePending[16][20]; // 0016318C +int HandleCar[32]; // 00163B8C +int HandleSample[32]; // 00163C0C +tCarSoundData enginedelay[16]; // 00163C8C +int car_to_player[16]; // 0016748C +int player_to_car[16]; // 001674CC +tSpeechInfo speechinfo[16]; // 0016750C +int load_times[16]; // 0016760C +tCopyData copy_multiple[512][16]; // 0016764C +int unmangleinpoff; // 0016F64C +uint8 *unmangledst; // 0016F650 +int unmangleoverflow; // 0016F654 +FILE *unmanglefile; // 0016F658 +int unmanglebufpos; // 0016F65C +volatile int s7; // 0016F660 +int network_timeout; // 0016F668 +void *MT32Data; // 0016F66C +void *FMDrums; // 0016F670 +void *FMInstruments; // 0016F674 +int network_sync_error; // 0016F678 +int ticks_received; // 0016F680 +int network_limit; // 0016F684 +int MIDIHandle; // 0016F68C +int DIGIHandle; // 0016F690 +volatile int frames; // 0016F694 +char Song[20][15]; // 0016F708 +uint32 tickhandle; // 0016F834 +DPMI_RMI RMI; // 0016F838 +tColor *pal_addr; // 0016F86C +int user_inp; // 0016F87C +int nummusictracks; // 0016F8A8 +int winchampsong; // 0016F8AC +int winsong; // 0016F8B0 +int delaywritex; // 0016F8B4 +int delayreadx; // 0016F8B8 +int leaderboardsong; // 0016F8BC +int optionssong; // 0016F8C0 +int titlesong; // 0016F8C4 +int delaywrite; // 0016F8C8 +int delayread; // 0016F8CC +int numsamples; // 0016F8D0 +int cheatsample; // 0016F8D4 +int languages; // 0016F8D8 +int net_loading; // 0016F8DC +int already_quit; // 0016F8E0 +int network_error; // 0017C97C //------------------------------------------------------------------------------------------------- static int frontendspeechgeneration = -1; -static int frontendspeech_current_handle() -{ +static int frontendspeech_current_handle() { int iGeneration; if (frontendspeechhandle == -1) @@ -165,23 +194,20 @@ static int frontendspeech_current_handle() return iGeneration != -1 && iGeneration == frontendspeechgeneration; } -static void clear_frontendspeech_handle() -{ +static void clear_frontendspeech_handle() { frontendspeechhandle = -1; frontendspeechgeneration = -1; } -static void stop_frontendspeech_handle() -{ +static void stop_frontendspeech_handle() { if (frontendspeech_current_handle()) DIGIStopSample(frontendspeechhandle); clear_frontendspeech_handle(); } //------------------------------------------------------------------------------------------------- -//000394C0 -void realmode(uint8 byRealModeInterrupt) -{ +// 000394C0 +void realmode(uint8 byRealModeInterrupt) { /*union REGS regs; // [esp+0h] [ebp-34h] BYREF struct SREGS sregs; // [esp+1Ch] [ebp-18h] BYREF @@ -205,9 +231,8 @@ void realmode(uint8 byRealModeInterrupt) } //------------------------------------------------------------------------------------------------- -//00039520 -bool loadDOS(const char *szFilename, void **out_buffer) -{ +// 00039520 +bool loadDOS(const char *szFilename, void **out_buffer) { FILE *file = ROLLERfopen(szFilename, "rb"); if (!file) { *out_buffer = NULL; @@ -287,50 +312,49 @@ bool loadDOS(const char *szFilename, void **out_buffer) } //------------------------------------------------------------------------------------------------- -//000395D0 -int claimDOS(int iSizeParagraphs, uint32 *uiSelectorOut) -{ - //int iRequestedParagraphs; // ecx - //uint16 ax; // dx - //union REGS regs; // [esp+0h] [ebp-34h] BYREF - //struct SREGS sregs; // [esp+1Ch] [ebp-18h] BYREF +// 000395D0 +int claimDOS(int iSizeParagraphs, uint32 *uiSelectorOut) { + // int iRequestedParagraphs; // ecx + // uint16 ax; // dx + // union REGS regs; // [esp+0h] [ebp-34h] BYREF + // struct SREGS sregs; // [esp+1Ch] [ebp-18h] BYREF // //// Calculate adjusted size in paragraphs - //iRequestedParagraphs = ((iSizeParagraphs - (__CFSHL__(iSizeParagraphs >> 31, 4) + 16 * (iSizeParagraphs >> 31))) >> 4) - // + 1; - //memset(&sregs, 0, sizeof(sregs)); - //regs.w.bx = iRequestedParagraphs; - //regs.w.ax = 0x100; // AX = 0x100 (Allocate DOS Memory Block) - //int386x(0x31, ®s, ®s, &sregs); + // iRequestedParagraphs = ((iSizeParagraphs - (__CFSHL__(iSizeParagraphs >> + // 31, 4) + 16 * (iSizeParagraphs >> 31))) >> 4) + // + 1; + // memset(&sregs, 0, sizeof(sregs)); + // regs.w.bx = iRequestedParagraphs; + // regs.w.ax = 0x100; // AX = 0x100 (Allocate DOS + // Memory Block) int386x(0x31, ®s, ®s, &sregs); // //// // Check if allocation failed (carry flag set) - //if (regs.x.cflag) { - *uiSelectorOut = -1; // Return error indicator - return 0; // Failed allocation + // if (regs.x.cflag) { + *uiSelectorOut = -1; // Return error indicator + return 0; // Failed allocation //} else { // ax = regs.w.ax; // *uiSelectorOut = regs.w.dx; // Store real-mode segment - // return 16 * ax; // Return linear address (real-mode segment * 16) + // return 16 * ax; // Return linear address + // (real-mode segment * 16) //} } //------------------------------------------------------------------------------------------------- -//00039650 -void releaseDOS(uint16 nSegment) -{ - //union REGS regs; // [esp+0h] [ebp-34h] BYREF - //struct SREGS sregs; // [esp+1Ch] [ebp-18h] BYREF +// 00039650 +void releaseDOS(uint16 nSegment) { + // union REGS regs; // [esp+0h] [ebp-34h] BYREF + // struct SREGS sregs; // [esp+1Ch] [ebp-18h] BYREF // - //memset(&sregs, 0, sizeof(sregs)); - //regs.w.dx = nSegment; - //regs.w.ax = 0x101; // EAX = 0x101 (Function: Free DOS Memory Block) - //int386x(0x31, ®s, ®s, &sregs); + // memset(&sregs, 0, sizeof(sregs)); + // regs.w.dx = nSegment; + // regs.w.ax = 0x101; // EAX = 0x101 (Function: + // Free DOS Memory Block) int386x(0x31, ®s, ®s, &sregs); } //------------------------------------------------------------------------------------------------- -//00039690 -bool setpal(const char *szFilename) -{ +// 00039690 +bool setpal(const char *szFilename) { void *pFileData = NULL; // Free old palette memory, if it was set @@ -340,7 +364,7 @@ bool setpal(const char *szFilename) pal_selector = (void *)-1; } - g_bPaletteSet = false; //added by ROLLER + g_bPaletteSet = false; // added by ROLLER /*if ( (int)pal_selector >= 0 ) { v4 = (unsigned __int16)pal_selector; @@ -385,9 +409,8 @@ bool setpal(const char *szFilename) } //------------------------------------------------------------------------------------------------- -//000397B0 -void blankpal() -{ +// 000397B0 +void blankpal() { if (!pal_addr) return; @@ -437,9 +460,8 @@ void blankpal() } //------------------------------------------------------------------------------------------------- -//00039890 -void resetpal() -{ +// 00039890 +void resetpal() { /* RMI.eax = 4114; RMI.ebx = 0; @@ -457,10 +479,10 @@ void resetpal() } //------------------------------------------------------------------------------------------------- -//000398F0 -void Initialise_SOS() -{ - //sosTIMERInitSystem(0xFF00, 0); // 0xFF00 maybe a special case for a slow rate timer? +// 000398F0 +void Initialise_SOS() { + // sosTIMERInitSystem(0xFF00, 0); // 0xFF00 maybe a special + // case for a slow rate timer? if (MusicCD) SetAudioVolume(MusicVolume); if (MusicCard) { @@ -469,32 +491,32 @@ void Initialise_SOS() printf("Initialising MIDI device %4X...", MusicCard); fflush(stdout); memset(TrackMap, 255, 0x20 * sizeof(unsigned int)); - //sosMIDIInitSystem(0, 0); - //MIDIInitDriver_variable_1 = 0; - //MIDIHardware = MusicPort; - //MIDIInitDriver_variable_2 = 0; - //if (sosMIDIInitDriver( - // MusicCard, - // 0, - // (unsigned int)&MIDIHardware, - // __DS__, - // (int)&MIDIInitDriver, - // (unsigned __int16)__DS__, - // (unsigned int)&MIDIHandle, - // (unsigned __int16)__DS__)) { - // MusicCard = 0; - // sosMIDIUnInitSystem(); - // printf("Failed\n"); - //} else { - // printf("OK\n"); - // devicespecificinit(); - // sosMIDISetMasterVolume(MusicVolume); - //} + // sosMIDIInitSystem(0, 0); + // MIDIInitDriver_variable_1 = 0; + // MIDIHardware = MusicPort; + // MIDIInitDriver_variable_2 = 0; + // if (sosMIDIInitDriver( + // MusicCard, + // 0, + // (unsigned int)&MIDIHardware, + // __DS__, + // (int)&MIDIInitDriver, + // (unsigned __int16)__DS__, + // (unsigned int)&MIDIHandle, + // (unsigned __int16)__DS__)) { + // MusicCard = 0; + // sosMIDIUnInitSystem(); + // printf("Failed\n"); + // } else { + // printf("OK\n"); + // devicespecificinit(); + // sosMIDISetMasterVolume(MusicVolume); + // } } if (SoundCard) { printf("Initialising DIGI device %4X...", SoundCard); fflush(stdout); - //sosDIGIInitSystem(0, 0); + // sosDIGIInitSystem(0, 0); printf("OK\n"); } select8bitdriver(); @@ -509,21 +531,20 @@ void Initialise_SOS() } //------------------------------------------------------------------------------------------------- -//00039A40 -void updatejoy() -{ - int iX1Scaled; // eax +// 00039A40 +void updatejoy() { + int iX1Scaled; // eax int iX1Clamped2; // eax - int iX1Clamped; // eax - int iY1Scaled; // eax + int iX1Clamped; // eax + int iY1Scaled; // eax int iY1Clamped2; // eax - int iY1Clamped; // eax - int iX2Scaled; // eax + int iY1Clamped; // eax + int iX2Scaled; // eax int iX2Clamped2; // eax - int iX2Clamped; // eax - int iY2Scaled; // eax + int iX2Clamped; // eax + int iY2Scaled; // eax int iY2Clamped2; // eax - int iY2Clamped; // eax + int iY2Clamped; // eax memset(joyvalue, 0, sizeof(joyvalue)); if (Joy1used || Joy2used) @@ -531,8 +552,9 @@ void updatejoy() if (Joy1used) { keys[WHIP_SCANCODE_J1B1] = rud_Joy_pos.iJ1Button1; keys[WHIP_SCANCODE_J1B2] = rud_Joy_pos.iJ1Button2; - iX1Scaled = ((2 * rud_Joy_pos.iJ1XAxis - JAXmax - JAXmin) << 10) / (JAXmax - JAXmin); - //apply 100-unit deadzone + iX1Scaled = ((2 * rud_Joy_pos.iJ1XAxis - JAXmax - JAXmin) << 10) / + (JAXmax - JAXmin); + // apply 100-unit deadzone if (iX1Scaled >= 0) { iX1Clamped = iX1Scaled - 100; if (iX1Clamped < 0) @@ -544,8 +566,9 @@ void updatejoy() iX1Clamped2 = 0; joyvalue[0] = -iX1Clamped2; } - iY1Scaled = ((2 * rud_Joy_pos.iJ1YAxis - JAYmax - JAYmin) << 10) / (JAYmax - JAYmin); - //apply 100-unit deadzone + iY1Scaled = ((2 * rud_Joy_pos.iJ1YAxis - JAYmax - JAYmin) << 10) / + (JAYmax - JAYmin); + // apply 100-unit deadzone if (iY1Scaled >= 0) { iY1Clamped = iY1Scaled - 100; if (iY1Clamped < 0) @@ -561,8 +584,9 @@ void updatejoy() if (Joy2used) { keys[WHIP_SCANCODE_J2B1] = rud_Joy_pos.iJ2Button1; keys[WHIP_SCANCODE_J2B2] = rud_Joy_pos.iJ2Button2; - iX2Scaled = ((2 * rud_Joy_pos.iJ2XAxis - JBXmax - JBXmin) << 10) / (JBXmax - JBXmin); - //apply 100-unit deadzone + iX2Scaled = ((2 * rud_Joy_pos.iJ2XAxis - JBXmax - JBXmin) << 10) / + (JBXmax - JBXmin); + // apply 100-unit deadzone if (iX2Scaled >= 0) { iX2Clamped = iX2Scaled - 100; if (iX2Clamped < 0) @@ -574,8 +598,9 @@ void updatejoy() iX2Clamped2 = 0; joyvalue[4] = -iX2Clamped2; } - iY2Scaled = ((2 * rud_Joy_pos.iJ2YAxis - JBYmax - JBYmin) << 10) / (JBYmax - JBYmin); - //apply 100-unit deadzone + iY2Scaled = ((2 * rud_Joy_pos.iJ2YAxis - JBYmax - JBYmin) << 10) / + (JBYmax - JBYmin); + // apply 100-unit deadzone if (iY2Scaled >= 0) { iY2Clamped = iY2Scaled - 100; if (iY2Clamped < 0) @@ -591,40 +616,39 @@ void updatejoy() } //------------------------------------------------------------------------------------------------- -//00039C20 -void readuserdata(int iPlayer) -{ - int iHalfKeyIndex; // esi - int iPlayerIdx; // eax - tCarEngine *pEngine; // ebx - int iKeyIndex; // esi - unsigned int uiAccelKey; // eax - unsigned int uiBrakeKey; // eax - uint8 byLeftKey; // bl - int iTurnRate; // ebp - int iTurnRate_1; // edx - int iPlayerIdx2; // eax - int iSteering; // ebx - int iMaxSteering; // edi - int iTurnRate_2; // edx - int iSteering_1; // ebx - int iMinSteering_1; // edx - int iSteering_2; // eax - int iSteering_4; // edx - int iSteering_3; // edx - unsigned int iJoyLeft; // eax - unsigned int iJoyRight; // ebx - int iLeftEffect; // eax - int iMinSteering; // eax - int16 nButtonFlags_1; // bx - int16 nButtonFlags; // ax - unsigned int uiGearUpKey; // edx - int iGearChange; // eax +// 00039C20 +void readuserdata(int iPlayer) { + int iHalfKeyIndex; // esi + int iPlayerIdx; // eax + tCarEngine *pEngine; // ebx + int iKeyIndex; // esi + unsigned int uiAccelKey; // eax + unsigned int uiBrakeKey; // eax + uint8 byLeftKey; // bl + int iTurnRate; // ebp + int iTurnRate_1; // edx + int iPlayerIdx2; // eax + int iSteering; // ebx + int iMaxSteering; // edi + int iTurnRate_2; // edx + int iSteering_1; // ebx + int iMinSteering_1; // edx + int iSteering_2; // eax + int iSteering_4; // edx + int iSteering_3; // edx + unsigned int iJoyLeft; // eax + unsigned int iJoyRight; // ebx + int iLeftEffect; // eax + int iMinSteering; // eax + int16 nButtonFlags_1; // bx + int16 nButtonFlags; // ax + unsigned int uiGearUpKey; // edx + int iGearChange; // eax unsigned int uiGearDownKey; // edx - int iStrategyFlags; // eax - int iNode; // edx - int iMessageIdx; // eax - char iAccelState; // [esp+0h] [ebp-1Ch] + int iStrategyFlags; // eax + int iNode; // edx + int iMessageIdx; // eax + char iAccelState; // [esp+0h] [ebp-1Ch] // Skip processing during countdown phase if (countdown >= 140) { @@ -653,8 +677,9 @@ void readuserdata(int iPlayer) // Process acceleration and brake inputs uiAccelKey = userkey[iKeyIndex + 2]; if (uiAccelKey > 0x83) { - //if ((unsigned int)musicbuffer_variable_1[uiAccelKey] <= 0xC8)// joyvalue[uiAccelKey] - if ((unsigned int)joyvalue[uiAccelKey- 132] <= 0xC8)// + // if ((unsigned int)musicbuffer_variable_1[uiAccelKey] <= 0xC8)// + // joyvalue[uiAccelKey] + if ((unsigned int)joyvalue[uiAccelKey - 132] <= 0xC8) // goto LABEL_9; } else if (!keys[uiAccelKey]) { goto LABEL_9; @@ -663,8 +688,9 @@ void readuserdata(int iPlayer) LABEL_9: uiBrakeKey = userkey[iKeyIndex + 3]; if (uiBrakeKey > 0x83) { - //if ((unsigned int)musicbuffer_variable_1[uiBrakeKey] <= 0xC8)// joyvalue[uiBrakeKey] - if ((unsigned int)joyvalue[uiBrakeKey- 132] <= 0xC8)// + // if ((unsigned int)musicbuffer_variable_1[uiBrakeKey] <= 0xC8)// + // joyvalue[uiBrakeKey] + if ((unsigned int)joyvalue[uiBrakeKey - 132] <= 0xC8) // goto LABEL_14; } else if (!keys[uiBrakeKey]) { goto LABEL_14; @@ -676,16 +702,27 @@ void readuserdata(int iPlayer) byLeftKey = userkey[iKeyIndex]; if (byLeftKey > 0x83u) { // joystick steering processing - //iJoyLeft = (unsigned int)(80 * musicbuffer_variable_1[byLeftKey]) >> 8;// joyvalue[byLeftKey] - iJoyLeft = (unsigned int)(80 * joyvalue[byLeftKey - 132]) >> 8;// + // iJoyLeft = (unsigned int)(80 * musicbuffer_variable_1[byLeftKey]) >> 8;// + // joyvalue[byLeftKey] + iJoyLeft = (unsigned int)(80 * joyvalue[byLeftKey - 132]) >> 8; // if (iJoyLeft > 0x102) iJoyLeft = 0x102; - //iJoyRight = (unsigned int)(80 * musicbuffer_variable_1[userkey[iKeyIndex + 1]]) >> 8;// joyvalue[byRightKey] - iJoyRight = (unsigned int)(80 * joyvalue[userkey[iKeyIndex + 1] - 132]) >> 8;// - iLeftEffect = (int)(p_joyk1[iPlayer] * ((int)(iJoyLeft * iJoyLeft * iJoyLeft) >> 8) + p_joyk2[iPlayer] * iJoyLeft) >> 16; + // iJoyRight = (unsigned int)(80 * musicbuffer_variable_1[userkey[iKeyIndex + // + 1]]) >> 8;// joyvalue[byRightKey] + iJoyRight = + (unsigned int)(80 * joyvalue[userkey[iKeyIndex + 1] - 132]) >> 8; // + iLeftEffect = + (int)(p_joyk1[iPlayer] * ((int)(iJoyLeft * iJoyLeft * iJoyLeft) >> 8) + + p_joyk2[iPlayer] * iJoyLeft) >> + 16; if (iJoyRight > 0x102) iJoyRight = 0x102; - rud_swheel[iPlayer] = iLeftEffect - ((int)(p_joyk1[iPlayer] * ((int)(iJoyRight * iJoyRight * iJoyRight) >> 8) + p_joyk2[iPlayer] * iJoyRight) >> 16); + rud_swheel[iPlayer] = + iLeftEffect - + ((int)(p_joyk1[iPlayer] * + ((int)(iJoyRight * iJoyRight * iJoyRight) >> 8) + + p_joyk2[iPlayer] * iJoyRight) >> + 16); // Clamp steering to valid range iMinSteering = -rud_steer[iPlayer]; @@ -705,7 +742,10 @@ void readuserdata(int iPlayer) rud_turn[iPlayer] = 32 * p_eng[iPlayer]->iTurnDecayRate + iTurnRate; else // calculate new turn rate - rud_turn[iPlayer] = (int)(abs(rud_swheel[iPlayer]) * ((p_eng[iPlayer]->iMaxTurnRate << 8) - 32 * p_eng[iPlayer]->iTurnDecayRate)) / rud_steer[iPlayer]; + rud_turn[iPlayer] = (int)(abs(rud_swheel[iPlayer]) * + ((p_eng[iPlayer]->iMaxTurnRate << 8) - + 32 * p_eng[iPlayer]->iTurnDecayRate)) / + rud_steer[iPlayer]; iTurnRate_1 = p_eng[iPlayer]->iMaxTurnRate << 8; if (iTurnRate_1 < rud_turn[iPlayer]) rud_turn[iPlayer] = iTurnRate_1; @@ -716,15 +756,18 @@ void readuserdata(int iPlayer) iMaxSteering = rud_steer[iPlayer]; rud_swheel[iPlayer] = iSteering; if (iSteering > iMaxSteering) - LABEL_43: - rud_swheel[iPlayerIdx2] = iMaxSteering; + LABEL_43: + rud_swheel[iPlayerIdx2] = iMaxSteering; } // process right steering else if (keys[userkey[iKeyIndex + 1]]) { if (rud_turn[iPlayer] >= 0) rud_turn[iPlayer] += 32 * p_eng[iPlayer]->iTurnDecayRate; else - rud_turn[iPlayer] = (int)(abs(rud_swheel[iPlayer]) * ((p_eng[iPlayer]->iMaxTurnRate << 8) - 32 * p_eng[iPlayer]->iTurnDecayRate)) / rud_steer[iPlayer]; + rud_turn[iPlayer] = (int)(abs(rud_swheel[iPlayer]) * + ((p_eng[iPlayer]->iMaxTurnRate << 8) - + 32 * p_eng[iPlayer]->iTurnDecayRate)) / + rud_steer[iPlayer]; iTurnRate_2 = p_eng[iPlayer]->iMaxTurnRate << 8; if (iTurnRate_2 < rud_turn[iPlayer]) rud_turn[iPlayer] = iTurnRate_2; @@ -738,12 +781,14 @@ void readuserdata(int iPlayer) iSteering_2 = rud_swheel[iPlayer]; rud_turn[iPlayer] = -1; if (iSteering_2 <= 0) { - iSteering_3 = (p_eng[iPlayer]->iWheelCenteringRate << 8) + rud_swheel[iPlayer]; + iSteering_3 = + (p_eng[iPlayer]->iWheelCenteringRate << 8) + rud_swheel[iPlayer]; rud_swheel[iPlayer] = iSteering_3; if (iSteering_3 > 0) rud_swheel[iPlayer] = 0; } else { - iSteering_4 = rud_swheel[iPlayer] - (p_eng[iPlayer]->iWheelCenteringRate << 8); + iSteering_4 = + rud_swheel[iPlayer] - (p_eng[iPlayer]->iWheelCenteringRate << 8); rud_swheel[iPlayer] = iSteering_4; if (iSteering_4 < 0) rud_swheel[iPlayer] = 0; @@ -757,39 +802,42 @@ void readuserdata(int iPlayer) nButtonFlags_1 |= 2; nButtonFlags &= 0x00FF; // LOBYTE(nButtonFlags_1) = nButtonFlags_1 | 2; - //HIBYTE(nButtonFlags) = 0; + // HIBYTE(nButtonFlags) = 0; // Process special buttons if (iPlayer) { - if (userkey[13] > 0x83u) // USERKEY_P2CHEAT + if (userkey[13] > 0x83u) // USERKEY_P2CHEAT { - //if ((unsigned int)musicbuffer_variable_1[userkey[13]] <= 0xC8)// joyvalue[userkey[USERKEY_P2CHEAT]] - if ((unsigned int)joyvalue[userkey[USERKEY_P2CHEAT]- 132] <= 0xC8)// + // if ((unsigned int)musicbuffer_variable_1[userkey[13]] <= 0xC8)// + // joyvalue[userkey[USERKEY_P2CHEAT]] + if ((unsigned int)joyvalue[userkey[USERKEY_P2CHEAT] - 132] <= 0xC8) // goto LABEL_57; - } else if (!keys[userkey[13]]) // USERKEY_P2CHEAT + } else if (!keys[userkey[13]]) // USERKEY_P2CHEAT { goto LABEL_57; } - } else if (userkey[12] > 0x83u) // USERKEY_P2DOWNGEAR + } else if (userkey[12] > 0x83u) // USERKEY_P2DOWNGEAR { - //if ((unsigned int)musicbuffer_variable_1[userkey[12]] <= 0xC8)// joyvalue[userkey[USERKEY_P2DOWNGEAR]] - if ((unsigned int)joyvalue[userkey[USERKEY_P2DOWNGEAR]- 132] <= 0xC8)// + // if ((unsigned int)musicbuffer_variable_1[userkey[12]] <= 0xC8)// + // joyvalue[userkey[USERKEY_P2DOWNGEAR]] + if ((unsigned int)joyvalue[userkey[USERKEY_P2DOWNGEAR] - 132] <= 0xC8) // goto LABEL_57; - } else if (!keys[userkey[12]]) // USERKEY_P2DOWNGEAR + } else if (!keys[userkey[12]]) // USERKEY_P2DOWNGEAR { goto LABEL_57; } - //TODO look a this again - //LOBYTE(nButtonFlags) = nButtonFlags_1 | 0x20; // special action flag - //nButtonFlags_1 = nButtonFlags; + // TODO look a this again + // LOBYTE(nButtonFlags) = nButtonFlags_1 | 0x20; // special action flag + // nButtonFlags_1 = nButtonFlags; nButtonFlags_1 |= 0x20; LABEL_57: // process gear shifting uiGearUpKey = userkey[iKeyIndex + 4]; iGearChange = 0; if (uiGearUpKey > 0x83) { - //if ((unsigned int)musicbuffer_variable_1[uiGearUpKey] <= 0xC8)// joyvalue[uiGearUpKey] - if ((unsigned int)joyvalue[uiGearUpKey- 132] <= 0xC8)// + // if ((unsigned int)musicbuffer_variable_1[uiGearUpKey] <= 0xC8)// + // joyvalue[uiGearUpKey] + if ((unsigned int)joyvalue[uiGearUpKey - 132] <= 0xC8) // goto LABEL_62; } else if (!keys[uiGearUpKey]) { goto LABEL_62; @@ -798,8 +846,9 @@ void readuserdata(int iPlayer) LABEL_62: uiGearDownKey = userkey[iKeyIndex + 5]; if (uiGearDownKey > 0x83) { - //if ((unsigned int)musicbuffer_variable_1[uiGearDownKey] <= 0xC8)// joyvalue[uiGearDownKey] - if ((unsigned int)joyvalue[uiGearDownKey- 132] <= 0xC8)// + // if ((unsigned int)musicbuffer_variable_1[uiGearDownKey] <= 0xC8)// + // joyvalue[uiGearDownKey] + if ((unsigned int)joyvalue[uiGearDownKey - 132] <= 0xC8) // goto LABEL_67; } else if (!keys[uiGearDownKey]) { goto LABEL_67; @@ -813,31 +862,27 @@ void readuserdata(int iPlayer) // Update gear state if (iGearChange > 0) { - //LOBYTE(nButtonFlags_1) = nButtonFlags_1 | 4; // gear up flag - nButtonFlags_1 |= 4; // gear up flag - rud_gr[iPlayer] = -1; // gear changed + // LOBYTE(nButtonFlags_1) = nButtonFlags_1 | 4; // gear up flag + nButtonFlags_1 |= 4; // gear up flag + rud_gr[iPlayer] = -1; // gear changed } if (iGearChange < 0) { - //LOBYTE(nButtonFlags_1) = nButtonFlags_1 | 8; // gear down flag - nButtonFlags_1 |= 8; // gear down flag - rud_gr[iPlayer] = -1; // gear changed + // LOBYTE(nButtonFlags_1) = nButtonFlags_1 | 8; // gear down flag + nButtonFlags_1 |= 8; // gear down flag + rud_gr[iPlayer] = -1; // gear changed } // Process strategy buttons (F1-F4) if (lastsample >= 0) goto LABEL_107; iStrategyFlags = 0; - if (keys[WHIP_SCANCODE_F5]) - { + if (keys[WHIP_SCANCODE_F5]) { iStrategyFlags = 0x40; - } else if (keys[WHIP_SCANCODE_F6]) - { + } else if (keys[WHIP_SCANCODE_F6]) { iStrategyFlags = 0x80; - } else if (keys[WHIP_SCANCODE_F7]) - { + } else if (keys[WHIP_SCANCODE_F7]) { iStrategyFlags = 0x100; - } else if (keys[WHIP_SCANCODE_F8]) - { + } else if (keys[WHIP_SCANCODE_F8]) { iStrategyFlags = 0x200; } if (!iStrategyFlags) @@ -855,7 +900,7 @@ void readuserdata(int iPlayer) if (human_control[message_node]) message_node = car_to_player[message_node]; else - message_node = -2; // invalid target + message_node = -2; // invalid target } // Send message if valid target and player hasn't finished @@ -873,7 +918,7 @@ void readuserdata(int iPlayer) if ((iStrategyFlags & 0x200) == 0) { LABEL_105: iStrategyFlags &= 0xFFFF0000; - //LOWORD(iStrategyFlags) = 0; + // LOWORD(iStrategyFlags) = 0; goto LABEL_106; } iNode = message_node; @@ -888,19 +933,19 @@ void readuserdata(int iPlayer) } } LABEL_106: - nButtonFlags_1 |= iStrategyFlags; // add strategy buttons to buttons state - rud_strat[iPlayer] = -1; // mark strategy button pressed + nButtonFlags_1 |= iStrategyFlags; // add strategy buttons to buttons state + rud_strat[iPlayer] = -1; // mark strategy button pressed LABEL_107: // Handle quit request if (I_Want_Out && !already_quit) { I_Want_Out = 0; already_quit = -1; if (wConsoleNode == master) - //HIBYTE(nButtonFlags_1) |= 8u; // master quit flag - nButtonFlags_1 |= 0x0800u; // master quit flag + // HIBYTE(nButtonFlags_1) |= 8u; // master quit flag + nButtonFlags_1 |= 0x0800u; // master quit flag else - //HIBYTE(nButtonFlags_1) |= 4u; // client quit flag - nButtonFlags_1 |= 0x0400u; // client quit flag + // HIBYTE(nButtonFlags_1) |= 4u; // client quit flag + nButtonFlags_1 |= 0x0400u; // client quit flag } // store final input state @@ -908,9 +953,8 @@ void readuserdata(int iPlayer) } //------------------------------------------------------------------------------------------------- -//0003A270 -void tickhandler() -{ +// 0003A270 +void tickhandler() { if (network_on && syncleft) { do_sync_stuff(); return; @@ -963,12 +1007,16 @@ void tickhandler() // Update and clamp tick position ticks += iTickAdvance; - if (ticks < 0) ticks = 0; - if (ticks >= replayframes) ticks = replayframes - 1; + if (ticks < 0) + ticks = 0; + if (ticks >= replayframes) + ticks = replayframes - 1; // Handle boundary conditions - if (ticks == 0 && fraction < 0) fraction = 0; - if (ticks == replayframes - 1 && fraction > 0) fraction = 0; + if (ticks == 0 && fraction < 0) + fraction = 0; + if (ticks == replayframes - 1 && fraction > 0) + fraction = 0; } // Handle normal game mode else { @@ -1023,40 +1071,65 @@ void tickhandler() if (player_type == 2) { // Process both players - tEngineSoundData *pSound = &enginedelay[ViewType[0]].engineSoundData[delayreadx]; + tEngineSoundData *pSound = + &enginedelay[ViewType[0]].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_ENGINE, + pSound->iEngineVol, pSound->iEnginePitch, + pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_ENGINE2, + pSound->iEngine2Vol, pSound->iEngine2Pitch, + pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); - pSound = &enginedelay[ViewType[1]].engineSoundData[delayreadx]; + loopsample(ViewType[0], SOUND_SAMPLE_SKID1, + pSound->iSkid1Vol, pSound->iSkid1Pitch, + pSound->iPan); + pSound = + &enginedelay[ViewType[1]].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(ViewType[1], SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(ViewType[1], SOUND_SAMPLE_ENGINE, + pSound->iEngineVol, pSound->iEnginePitch, + pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(ViewType[1], SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(ViewType[1], SOUND_SAMPLE_ENGINE2, + pSound->iEngine2Vol, pSound->iEngine2Pitch, + pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(ViewType[1], SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); + loopsample(ViewType[1], SOUND_SAMPLE_SKID1, + pSound->iSkid1Vol, pSound->iSkid1Pitch, + pSound->iPan); } else if (allengines) { // Process all cars for (int i = 0; i < numcars; i++) { - tEngineSoundData *pSound = &enginedelay[i].engineSoundData[delayreadx]; + tEngineSoundData *pSound = + &enginedelay[i].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(i, SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_ENGINE, pSound->iEngineVol, + pSound->iEnginePitch, pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(i, SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, + pSound->iEngine2Pitch, pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(i, SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, + pSound->iSkid1Pitch, pSound->iPan); } } else { // Process only player 1 - tEngineSoundData *pSound = &enginedelay[ViewType[0]].engineSoundData[delayreadx]; + tEngineSoundData *pSound = + &enginedelay[ViewType[0]].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_ENGINE, + pSound->iEngineVol, pSound->iEnginePitch, + pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_ENGINE2, + pSound->iEngine2Vol, pSound->iEngine2Pitch, + pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_SKID1, + pSound->iSkid1Vol, pSound->iSkid1Pitch, + pSound->iPan); } // Advance buffer @@ -1078,8 +1151,7 @@ void tickhandler() net_time[i] = frames; } if (i != master && net_players[i] && - (frames > net_time[i] + network_limit) && - !send_finished) { + (frames > net_time[i] + network_limit) && !send_finished) { network_error = 222; } } @@ -1093,7 +1165,8 @@ void tickhandler() if (network_on - 1 == start_multiple) { // Copy previous frame data memcpy(copy_multiple[writeptr], - copy_multiple[(writeptr - 1 + REPLAY_BUFFER_SIZE) % REPLAY_BUFFER_SIZE], + copy_multiple[(writeptr - 1 + REPLAY_BUFFER_SIZE) % + REPLAY_BUFFER_SIZE], sizeof(tCopyData) * MAX_CARS); // Reset connection flags @@ -1121,9 +1194,11 @@ void tickhandler() if (countdown >= 0) { active_nodes = 0; for (int i = 0; i < network_on; i++) { - if (player_ready[i]) active_nodes++; + if (player_ready[i]) + active_nodes++; if (player_ready[i] == 666 && net_players[i]) { - copy_multiple[writeptr][player_to_car[i]].data.unFlags |= FLAG_DISCONNECT; + copy_multiple[writeptr][player_to_car[i]].data.unFlags |= + FLAG_DISCONNECT; net_players[i] = 0; } } @@ -1139,17 +1214,19 @@ void tickhandler() } } send_multiple(); - + // Handle master transition if (network_on - 1 == start_multiple) { for (int i = 0; i < numcars; i++) { - if (copy_multiple[writeptr][i].data.unFlags & FLAG_DISCONNECT) { + if (copy_multiple[writeptr][i].data.unFlags & + FLAG_DISCONNECT) { net_players[car_to_player[i]] = 0; network_timeout = frames; } } - if (copy_multiple[writeptr][player1_car].data.unFlags & FLAG_MASTER_CHANGE) { + if (copy_multiple[writeptr][player1_car].data.unFlags & + FLAG_MASTER_CHANGE) { // Reset network state read_check = -1; write_check = -1; @@ -1167,9 +1244,12 @@ void tickhandler() } // Update flags - uint16 unFlags = copy_multiple[writeptr][player1_car].data.unFlags; + uint16 unFlags = + copy_multiple[writeptr][player1_car].data.unFlags; unFlags ^= FLAG_DISCONNECT; - copy_multiple[(writeptr + 1) % REPLAY_BUFFER_SIZE][player1_car].data.unFlags = unFlags; + copy_multiple[(writeptr + 1) % REPLAY_BUFFER_SIZE] + [player1_car] + .data.unFlags = unFlags; network_timeout = frames; } @@ -1183,7 +1263,8 @@ void tickhandler() if (paused) { network_timeout = frames; } - if (frames > network_timeout + network_limit && human_finishers < players) { + if (frames > network_timeout + network_limit && + human_finishers < players) { network_error = 123; } @@ -1194,7 +1275,10 @@ void tickhandler() receive_multiple(); // Handle master change - if (copy_multiple[(writeptr - 1 + REPLAY_BUFFER_SIZE) % REPLAY_BUFFER_SIZE][player_to_car[master]].uiFullData & 0x8000000) { + if (copy_multiple[(writeptr - 1 + REPLAY_BUFFER_SIZE) % + REPLAY_BUFFER_SIZE][player_to_car[master]] + .uiFullData & + 0x8000000) { read_check = -1; write_check = -1; memset(player_checks, -1, sizeof(player_checks)); @@ -1215,10 +1299,13 @@ void tickhandler() // Check for disconnections for (int i = 0; i < numcars; i++) { - uint32 uiData = copy_multiple[(writeptr - 1 + REPLAY_BUFFER_SIZE) % REPLAY_BUFFER_SIZE][i].uiFullData; + uint32 uiData = + copy_multiple[(writeptr - 1 + REPLAY_BUFFER_SIZE) % + REPLAY_BUFFER_SIZE][i] + .uiFullData; if (uiData & 0x10000000) { - network_error = 0; // Reset error on valid data + network_error = 0; // Reset error on valid data } if (uiData & 0x4000000) { net_players[car_to_player[i]] = 0; @@ -1238,35 +1325,46 @@ void tickhandler() copy_multiple[writeptr][player1_car].uiFullData = user_inp; // Set disconnect flag - copy_multiple[writeptr][player1_car].data.unFlags |= FLAG_DISCONNECT; + copy_multiple[writeptr][player1_car].data.unFlags |= + FLAG_DISCONNECT; writeptr = (writeptr + 1) % REPLAY_BUFFER_SIZE; } // Process sound if (soundon && !paused) { - if (delayread >= delaywrite) return; + if (delayread >= delaywrite) + return; delayreadx = delayread % DELAY_BUFFER_SIZE; if (allengines) { for (int i = 0; i < numcars; i++) { - tEngineSoundData *pSound = &enginedelay[i].engineSoundData[delayreadx]; + tEngineSoundData *pSound = + &enginedelay[i].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(i, SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_ENGINE, pSound->iEngineVol, + pSound->iEnginePitch, pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(i, SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, + pSound->iEngine2Pitch, pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(i, SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, + pSound->iSkid1Pitch, pSound->iPan); } } else { - tEngineSoundData *pSound = &enginedelay[ViewType[0]].engineSoundData[delayreadx]; + tEngineSoundData *pSound = + &enginedelay[ViewType[0]].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_ENGINE, pSound->iEngineVol, + pSound->iEnginePitch, pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_ENGINE2, + pSound->iEngine2Vol, pSound->iEngine2Pitch, + pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(ViewType[0], SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); + loopsample(ViewType[0], SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, + pSound->iSkid1Pitch, pSound->iPan); } // Advance by ticks received @@ -1285,11 +1383,14 @@ void tickhandler() for (int i = 0; i < numcars; i++) { tEngineSoundData *pSound = &enginedelay[i].engineSoundData[delayreadx]; if (pSound->iEngineVol >= 0) - loopsample(i, SOUND_SAMPLE_ENGINE, pSound->iEngineVol, pSound->iEnginePitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_ENGINE, pSound->iEngineVol, + pSound->iEnginePitch, pSound->iPan); if (pSound->iEngine2Vol >= 0) - loopsample(i, SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, pSound->iEngine2Pitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_ENGINE2, pSound->iEngine2Vol, + pSound->iEngine2Pitch, pSound->iPan); if (pSound->iSkid1Vol >= 0) - loopsample(i, SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, pSound->iSkid1Pitch, pSound->iPan); + loopsample(i, SOUND_SAMPLE_SKID1, pSound->iSkid1Vol, + pSound->iSkid1Pitch, pSound->iPan); } if (delaywrite - delayread >= 6) { @@ -1300,16 +1401,17 @@ void tickhandler() } //------------------------------------------------------------------------------------------------- -//0003B0E0 -void claim_ticktimer(unsigned int uiRateHz) -{ +// 0003B0E0 +void claim_ticktimer(unsigned int uiRateHz) { /*** - * ADDED BY ROLLER - ***/ - tickhandle = ROLLERAddTimer(uiRateHz, SDLTickTimerCallback, NULL); //may as well re-use tickhandle, it is also a uint32 + * ADDED BY ROLLER + ***/ + tickhandle = ROLLERAddTimer( + uiRateHz, SDLTickTimerCallback, + NULL); // may as well re-use tickhandle, it is also a uint32 /*** - * END ROLLER CODE - ***/ + * END ROLLER CODE + ***/ /* if (sosTIMERRegisterEvent( @@ -1325,57 +1427,56 @@ void claim_ticktimer(unsigned int uiRateHz) } //------------------------------------------------------------------------------------------------- -//0003B120 -void release_ticktimer() -{ +// 0003B120 +void release_ticktimer() { /*** - * ADDED BY ROLLER - ***/ - ROLLERRemoveTimer(tickhandle); //may as well re-use tickhandle, it is also a uint32 + * ADDED BY ROLLER + ***/ + ROLLERRemoveTimer( + tickhandle); // may as well re-use tickhandle, it is also a uint32 /*** - * END ROLLER CODE - ***/ + * END ROLLER CODE + ***/ - //sosTIMERRemoveEvent(tickhandle); + // sosTIMERRemoveEvent(tickhandle); } //------------------------------------------------------------------------------------------------- -//0003B130 -void Uninitialise_SOS() -{ +// 0003B130 +void Uninitialise_SOS() { /*** - * ADDED BY ROLLER - ***/ - ROLLERRemoveTimer(tickhandle); //may as well re-use tickhandle, it is also a uint32 + * ADDED BY ROLLER + ***/ + ROLLERRemoveTimer( + tickhandle); // may as well re-use tickhandle, it is also a uint32 /*** - * END ROLLER CODE - ***/ - - //sosTIMERRemoveEvent(tickhandle); - //sosTIMERRemoveEvent(TimerEventHandle); - //sosTIMERUnInitSystem(0); - //if (SoundCard) { - // sosDIGIUnInitDriver(DIGIHandle, 1, 1); - // sosDIGIUnInitSystem(); - //} + * END ROLLER CODE + ***/ + + // sosTIMERRemoveEvent(tickhandle); + // sosTIMERRemoveEvent(TimerEventHandle); + // sosTIMERUnInitSystem(0); + // if (SoundCard) { + // sosDIGIUnInitDriver(DIGIHandle, 1, 1); + // sosDIGIUnInitSystem(); + // } if (MusicCard) { devicespecificuninit(); - //sosMIDIUnInitDriver(MIDIHandle, 1); - //sosMIDIUnInitSystem(); + // sosMIDIUnInitDriver(MIDIHandle, 1); + // sosMIDIUnInitSystem(); } } //------------------------------------------------------------------------------------------------- -//0003B1A0 -void loadsamples() -{ +// 0003B1A0 +void loadsamples() { int iWinnerSample; // edx - int iDesignCmp; // ecx - int iSampleIdx; // ebx - int iKills2; // edx - int iKillSample; // eax - int iWins; // eax - int iKills; // edx + int iDesignCmp; // ecx + int iSampleIdx; // ebx + int iKills2; // edx + int iKillSample; // eax + int iWins; // eax + int iKills; // edx iWinnerSample = winner_mode; if (winner_mode) { @@ -1424,8 +1525,10 @@ void loadsamples() iSampleIdx = 0; do { if (!winner_mode) { - if (iWinnerSample >= 71 && (iWinnerSample <= 78 || iWinnerSample >= 89)) { - if (Car[ViewType[0]].byCarDesignIdx != iDesignCmp || SamplePtr[iSampleIdx]) + if (iWinnerSample >= 71 && + (iWinnerSample <= 78 || iWinnerSample >= 89)) { + if (Car[ViewType[0]].byCarDesignIdx != iDesignCmp || + SamplePtr[iSampleIdx]) goto LABEL_13; LABEL_12: loadasample(iWinnerSample); @@ -1448,9 +1551,8 @@ void loadsamples() } //------------------------------------------------------------------------------------------------- -//0003B3A0 -void loadfatalsample() -{ +// 0003B3A0 +void loadfatalsample() { if (!SamplePtr[SOUND_SAMPLE_FATAL]) // 88 - Fatal sample loadasample(SOUND_SAMPLE_FATAL); if (!SamplePtr[SOUND_SAMPLE_BUTTON]) // 83 - Button sample @@ -1470,126 +1572,120 @@ void loadfatalsample() } //------------------------------------------------------------------------------------------------- -//0003B440 -void freefatalsample() -{ - fre((void**)&SamplePtr[SOUND_SAMPLE_FATAL]); // 88 - Fatal sample - fre((void**)&SamplePtr[SOUND_SAMPLE_BUTTON]); // 83 - Button sample - fre((void**)&SamplePtr[SOUND_SAMPLE_START]); // 87 - Start sample - fre((void**)&SamplePtr[SOUND_SAMPLE_CARIN]); // 84 - Car in sample - fre((void**)&SamplePtr[SOUND_SAMPLE_CAROUT]); // 85 - Car out sample - fre((void**)&SamplePtr[SOUND_SAMPLE_TRACK]); // 86 - Track sample +// 0003B440 +void freefatalsample() { + fre((void **)&SamplePtr[SOUND_SAMPLE_FATAL]); // 88 - Fatal sample + fre((void **)&SamplePtr[SOUND_SAMPLE_BUTTON]); // 83 - Button sample + fre((void **)&SamplePtr[SOUND_SAMPLE_START]); // 87 - Start sample + fre((void **)&SamplePtr[SOUND_SAMPLE_CARIN]); // 84 - Car in sample + fre((void **)&SamplePtr[SOUND_SAMPLE_CAROUT]); // 85 - Car out sample + fre((void **)&SamplePtr[SOUND_SAMPLE_TRACK]); // 86 - Track sample } //------------------------------------------------------------------------------------------------- -//0003B480 -void releasesamples() -{ +// 0003B480 +void releasesamples() { if (SoundCard) { for (int i = 0; i < 120; ++i) { - fre((void**)&SamplePtr[i]); + fre((void **)&SamplePtr[i]); SamplePtr[i] = NULL; } } } //------------------------------------------------------------------------------------------------- -//0003B4D0 -void play() -{ +// 0003B4D0 +void play() { if (musicon) { if (SongPtr) { MIDIStartSong(); - //InitSong.nSection = __DS__; - //InitSong.pData = (void *)SongPtr; - //InitSong.nUnk2 = 0; - //InitSong.iUnk1 = 0; - //return sosMIDIStartSong(*(int *)&SongHandle); + // InitSong.nSection = __DS__; + // InitSong.pData = (void *)SongPtr; + // InitSong.nUnk2 = 0; + // InitSong.iUnk1 = 0; + // return sosMIDIStartSong(*(int *)&SongHandle); } } } //------------------------------------------------------------------------------------------------- -//0003B520 -void stop() -{ +// 0003B520 +void stop() { if (MusicCard) { if (SongPtr) { MIDIStopSong(); - //sosMIDIStopSong(SongHandle); - //sosMIDIResetSong(SongHandle); + // sosMIDIStopSong(SongHandle); + // sosMIDIResetSong(SongHandle); } } } //------------------------------------------------------------------------------------------------- -//0003B580 -void devicespecificinit() -{ +// 0003B580 +void devicespecificinit() { int i; // esi unsigned int uiSize; switch (MusicCard) { - case 40961: - printf("Resetting SCC-1..."); - fflush(stdout); - //sosMIDISendMIDIData(MIDIHandle, 11, (int)&SCreset, __DS__); + case 40961: + printf("Resetting SCC-1..."); + fflush(stdout); + // sosMIDISendMIDIData(MIDIHandle, 11, (int)&SCreset, __DS__); + printf("OK\n"); + break; + case 40962: + case 40969: + printf("Loading Instrument bank file..."); + fflush(stdout); + loadfile("melodic.bnk", &FMInstruments, &uiSize, 0); + if (FMInstruments) { printf("OK\n"); - break; - case 40962: - case 40969: - printf("Loading Instrument bank file..."); - fflush(stdout); - loadfile("melodic.bnk", &FMInstruments, &uiSize, 0); - if (FMInstruments) { - printf("OK\n"); - //sosMIDISetInsData(MIDIHandle, 1, (int)FMInstruments, __DS__); - } else { - printf("Failed\n"); - MusicCard = 0; - } - printf("Loading Drums bank file..."); - fflush(stdout); - loadfile("drum.bnk", &FMDrums, &uiSize, 0); - if (FMDrums) { - printf("OK\n"); - //sosMIDISetInsData(MIDIHandle, 1, (int)FMDrums, __DS__); - } else { - printf("Failed\n"); - MusicCard = 0; - } - if (!MusicCard) { - //sosMIDIUnInitDriver(MIDIHandle, 1); - //sosMIDIUnInitSystem(); - } - break; - case 40964: - printf("Resetting LAPC-1..."); - //sosMIDISendMIDIData(MIDIHandle, 11, (int)&MT32reset, __DS__); + // sosMIDISetInsData(MIDIHandle, 1, (int)FMInstruments, __DS__); + } else { + printf("Failed\n"); + MusicCard = 0; + } + printf("Loading Drums bank file..."); + fflush(stdout); + loadfile("drum.bnk", &FMDrums, &uiSize, 0); + if (FMDrums) { + printf("OK\n"); + // sosMIDISetInsData(MIDIHandle, 1, (int)FMDrums, __DS__); + } else { + printf("Failed\n"); + MusicCard = 0; + } + if (!MusicCard) { + // sosMIDIUnInitDriver(MIDIHandle, 1); + // sosMIDIUnInitSystem(); + } + break; + case 40964: + printf("Resetting LAPC-1..."); + // sosMIDISendMIDIData(MIDIHandle, 11, (int)&MT32reset, __DS__); + fflush(stdout); + loadfile("mt32map.mtx", &MT32Data, &uiSize, 0); + if (MT32Data) { fflush(stdout); - loadfile("mt32map.mtx", &MT32Data, &uiSize, 0); - if (MT32Data) { + for (i = 0; i != 1104; i += 138) { + // sosMIDISendMIDIData(MIDIHandle, 138, (int)MT32Data + i, __DS__); + printf("."); fflush(stdout); - for (i = 0; i != 1104; i += 138) { - //sosMIDISendMIDIData(MIDIHandle, 138, (int)MT32Data + i, __DS__); - printf("."); - fflush(stdout); - } - printf("OK\n"); - } else { - printf("Failed\n"); } - break; - default: - return; + printf("OK\n"); + } else { + printf("Failed\n"); + } + break; + default: + return; } } //------------------------------------------------------------------------------------------------- -//0003B7B0 -int initgus() -{ +// 0003B7B0 +int initgus() { printf("DownLoading GRAVIS patches..."); fflush(stdout); system("..\\LOADPATS -Q -IFATALPAT.INI >NUL"); @@ -1597,37 +1693,34 @@ int initgus() } //------------------------------------------------------------------------------------------------- -//0003B810 -void devicespecificuninit() -{ +// 0003B810 +void devicespecificuninit() { switch (MusicCard) { - case 40961: - //sosMIDISendMIDIData(MIDIHandle, 11, (int)&SCreset, __DS__); - break; - case 40962: - case 40969: - fre(&FMInstruments); - fre(&FMDrums); - break; - case 40964: - //sosMIDISendMIDIData(MIDIHandle, 11, (int)&MT32reset, __DS__); - fre(&MT32Data); - break; + case 40961: + // sosMIDISendMIDIData(MIDIHandle, 11, (int)&SCreset, __DS__); + break; + case 40962: + case 40969: + fre(&FMInstruments); + fre(&FMDrums); + break; + case 40964: + // sosMIDISendMIDIData(MIDIHandle, 11, (int)&MT32reset, __DS__); + fre(&MT32Data); + break; } } //------------------------------------------------------------------------------------------------- -//0003B880 -void readsoundconfig(void) -{ +// 0003B880 +void readsoundconfig(void) { FILE *fp = ROLLERfopen("../config.ini", "rb"); char *pBuffer = NULL; long iSize; - if (!fp) - { + if (!fp) { autoselectsoundlanguage(); // Add by ROLLER to auto-select languagename - //added by ROLLER to ensure sound is always available + // added by ROLLER to ensure sound is always available if (!SoundCard) SoundCard = -1; return; @@ -1649,7 +1742,8 @@ void readsoundconfig(void) // Parse Language char *szVar = FindConfigVar(pBuffer, "Language"); - if (szVar) sscanf(szVar, "%s", languagename); + if (szVar) + sscanf(szVar, "%s", languagename); // Match language index language = 0; @@ -1662,11 +1756,13 @@ void readsoundconfig(void) // SourcePath szVar = FindConfigVar(pBuffer, "SourcePath"); - if (szVar) sscanf(szVar, "%s", SourcePath); + if (szVar) + sscanf(szVar, "%s", SourcePath); // DestinationPath szVar = FindConfigVar(pBuffer, "DestinationPath"); - if (szVar) sscanf(szVar, "%s", DestinationPath); + if (szVar) + sscanf(szVar, "%s", DestinationPath); // Sound settings szVar = FindConfigVar(pBuffer, "SoundCard"); @@ -1708,7 +1804,7 @@ void readsoundconfig(void) } // Cleanup - fre((void**)&pBuffer); + fre((void **)&pBuffer); fclose(fp); // Enable CD Audio @@ -1716,8 +1812,8 @@ void readsoundconfig(void) MusicCard = 0; MusicCD = -1; } - - //hack the SoundCard to be available too + + // hack the SoundCard to be available too if (!SoundCard) SoundCard = -1; @@ -1730,9 +1826,8 @@ void readsoundconfig(void) } //------------------------------------------------------------------------------------------------- -//0003BAF0 -char *FindConfigVar(const char *szConfigText, const char *szVarName) -{ +// 0003BAF0 +char *FindConfigVar(const char *szConfigText, const char *szVarName) { char *szMatch = strstr(szConfigText, szVarName); if (!szMatch) return NULL; @@ -1761,11 +1856,11 @@ char *FindConfigVar(const char *szConfigText, const char *szVarName) } //------------------------------------------------------------------------------------------------- -//0003BB50 -void loadfile(const char *szFile, void **pBuf, unsigned int *uiSize, int iIsSound) -{ - int iFile; // eax - void *pBuf2; // eax +// 0003BB50 +void loadfile(const char *szFile, void **pBuf, unsigned int *uiSize, + int iIsSound) { + int iFile; // eax + void *pBuf2; // eax uint8 *pUint8Buf; // edx *pBuf = 0; @@ -1774,7 +1869,8 @@ void loadfile(const char *szFile, void **pBuf, unsigned int *uiSize, int iIsSoun if (g_bSnapshotMode && iIsSound == 1 && !soundon) { return; } - iFile = ROLLERopen(szFile, O_RDONLY | O_BINARY); //0x200 is O_BINARY in WATCOM/h/fcntl.h + iFile = ROLLERopen( + szFile, O_RDONLY | O_BINARY); // 0x200 is O_BINARY in WATCOM/h/fcntl.h if (iFile == -1) { *uiSize = 0; *pBuf = 0; @@ -1795,9 +1891,8 @@ void loadfile(const char *szFile, void **pBuf, unsigned int *uiSize, int iIsSoun } //------------------------------------------------------------------------------------------------- -//0003BBD0 -void ReadJoys(tJoyPos *pJoy) -{ +// 0003BBD0 +void ReadJoys(tJoyPos *pJoy) { // Check joystick 1 (controller 1) pJoy->iJ1Button1 = g_rollerJoyPos.iJ1Button1; pJoy->iJ1Button2 = g_rollerJoyPos.iJ1Button2; @@ -1821,24 +1916,24 @@ void ReadJoys(tJoyPos *pJoy) } //------------------------------------------------------------------------------------------------- -//0003BDD0 -void check_joystickpresence() -{ - //TODO: integrate this with SDL +// 0003BDD0 +void check_joystickpresence() { + // TODO: integrate this with SDL int iTimeoutCounter; // ebx - int iY1Temp; // esi - int iX2Temp; // ecx - int iY2Temp; // edi + int iY1Temp; // esi + int iX2Temp; // ecx + int iY2Temp; // edi int iGameportStatus; // eax - int iX1Temp; // [esp+0h] [ebp-18h] + int iX1Temp; // [esp+0h] [ebp-18h] - iTimeoutCounter = 0; // Initialize timeout counter - x1ok = 1; // Initialize joystick axis detection flags (bit masks for port 0x201) + iTimeoutCounter = 0; // Initialize timeout counter + x1ok = + 1; // Initialize joystick axis detection flags (bit masks for port 0x201) y1ok = 2; x2ok = 4; y2ok = 8; bitaccept = 15; - JAXmin = 10000; // Initialize joystick axis calibration min/max values + JAXmin = 10000; // Initialize joystick axis calibration min/max values JAXmax = -10000; JAYmin = 10000; JAYmax = -10000; @@ -1846,25 +1941,31 @@ void check_joystickpresence() JBXmax = -10000; JBYmin = 10000; JBYmax = -10000; - //__outbyte(0x201u, 0xFFu); // Trigger joystick measurement by writing 0xFF to gameport 0x201 + //__outbyte(0x201u, 0xFFu); // Trigger joystick + // measurement by writing 0xFF to gameport 0x201 iX1Temp = x1ok; iY1Temp = y1ok; iX2Temp = x2ok; iY2Temp = y2ok; do { - iGameportStatus = 0; // Main detection loop: read gameport and test axis presence - //LOBYTE(iGameportStatus) = __inbyte(0x201u); // Read current status from gameport 0x201 - if (x1ok) // Test X1 axis (bit 0) - if enabled, check if still active + iGameportStatus = + 0; // Main detection loop: read gameport and test axis presence + // LOBYTE(iGameportStatus) = __inbyte(0x201u); // Read current status from + // gameport 0x201 + if (x1ok) // Test X1 axis (bit 0) - if enabled, check if still active iX1Temp = iGameportStatus & 1; - if (y1ok) // Test Y1 axis (bit 1) - if enabled, check if still active + if (y1ok) // Test Y1 axis (bit 1) - if enabled, check if still active iY1Temp = iGameportStatus & 2; - if (x2ok) // Test X2 axis (bit 2) - if enabled, check if still active + if (x2ok) // Test X2 axis (bit 2) - if enabled, check if still active iX2Temp = iGameportStatus & 4; - if (y2ok) // Test Y2 axis (bit 3) - if enabled, check if still active + if (y2ok) // Test Y2 axis (bit 3) - if enabled, check if still active iY2Temp = iGameportStatus & 8; ++iTimeoutCounter; - } while ((iGameportStatus & bitaccept) != 0 && iTimeoutCounter < 10000);// Continue loop while any expected axes are still active and timeout not reached - if (iX1Temp) // Disable axes that didn't respond (indicating no joystick connected to that axis) + } while ((iGameportStatus & bitaccept) != 0 && + iTimeoutCounter < 10000); // Continue loop while any expected axes + // are still active and timeout not reached + if (iX1Temp) // Disable axes that didn't respond (indicating no joystick + // connected to that axis) x1ok = 0; if (iX2Temp) x2ok = 0; @@ -1872,83 +1973,84 @@ void check_joystickpresence() y1ok = 0; if (iY2Temp) y2ok = 0; - bitaccept = y2ok | y1ok | x1ok | x2ok; // Update bitaccept mask with only the axes that are actually present + bitaccept = y2ok | y1ok | x1ok | x2ok; // Update bitaccept mask with only the + // axes that are actually present } //------------------------------------------------------------------------------------------------- -//0003BF20 -void initsounds() -{ - //int iNumCars; // ebx - //int iLoopItr; // eax - //int i; // ecx - //int iCar; // edx - //int SampleHandleCarOffset; // eax - //int iPendingOffset; // eax +// 0003BF20 +void initsounds() { + // int iNumCars; // ebx + // int iLoopItr; // eax + // int i; // ecx + // int iCar; // edx + // int SampleHandleCarOffset; // eax + // int iPendingOffset; // eax // - //iNumCars = numcars; - //iLoopItr = 2; + // iNumCars = numcars; + // iLoopItr = 2; for (int i = 0; i < 32; ++i) { HandleSample[i] = -1; HandleCar[i] = -1; } - //HandleSample[0] = -1; - //HandleCar[0] = -1; - //HandleSample[1] = -1; - //HandleCar[1] = -1; - //do { - // iLoopItr += 5; - // HandleCar[iLoopItr + 27] = -1; // offset into HandleSample - // SamplePending_variable_3[iLoopItr] = -1; // offset into HandleCar - // HandleCar[iLoopItr + 28] = -1; - // SamplePending_variable_4[iLoopItr] = -1; - // HandleCar[iLoopItr + 29] = -1; - // SamplePending_variable_5[iLoopItr] = -1; - // HandleCar[iLoopItr + 30] = -1; - // SamplePending_variable_6[iLoopItr] = -1; - // HandleCar[iLoopItr + 31] = -1; - // SamplePending_variable_7[iLoopItr] = -1; - //} while (iLoopItr != 32); + // HandleSample[0] = -1; + // HandleCar[0] = -1; + // HandleSample[1] = -1; + // HandleCar[1] = -1; + // do { + // iLoopItr += 5; + // HandleCar[iLoopItr + 27] = -1; // offset into HandleSample + // SamplePending_variable_3[iLoopItr] = -1; // offset into HandleCar + // HandleCar[iLoopItr + 28] = -1; + // SamplePending_variable_4[iLoopItr] = -1; + // HandleCar[iLoopItr + 29] = -1; + // SamplePending_variable_5[iLoopItr] = -1; + // HandleCar[iLoopItr + 30] = -1; + // SamplePending_variable_6[iLoopItr] = -1; + // HandleCar[iLoopItr + 31] = -1; + // SamplePending_variable_7[iLoopItr] = -1; + // } while (iLoopItr != 32); for (int i = 0; i < 120; ++i) { SampleHandleCar[i].handles[0] = -1; } - //for (i = 0; i != 7680; i += 64) { - // iCar = 0; - // if (iNumCars > 0) { - // SampleHandleCarOffset = i; - // do { - // SampleHandleCarOffset += 4; - // ++iCar; - // *(uint8 **)((char *)&SamplePtr[119] + SampleHandleCarOffset) = (uint8 *)-1;// offsets into SampleHandleCar - // } while (iCar < iNumCars); - // } - //} + // for (i = 0; i != 7680; i += 64) { + // iCar = 0; + // if (iNumCars > 0) { + // SampleHandleCarOffset = i; + // do { + // SampleHandleCarOffset += 4; + // ++iCar; + // *(uint8 **)((char *)&SamplePtr[119] + SampleHandleCarOffset) = (uint8 + // *)-1;// offsets into SampleHandleCar + // } while (iCar < iNumCars); + // } + // } for (int i = 0; i < numcars; ++i) { Pending[i] = 0; } - //if (iNumCars > 0) { - // iPendingOffset = 0; - // do { - // iPendingOffset += 4; - // *(_DWORD *)&SampleExt[iPendingOffset + 62] = 0;// offsets into Pending - // } while (iPendingOffset < 4 * iNumCars); - //} - //numcars = iNumCars; + // if (iNumCars > 0) { + // iPendingOffset = 0; + // do { + // iPendingOffset += 4; + // *(_DWORD *)&SampleExt[iPendingOffset + 62] = 0;// offsets into Pending + // } while (iPendingOffset < 4 * iNumCars); + // } + // numcars = iNumCars; } //------------------------------------------------------------------------------------------------- -//0003BFF0 -void stopallsamples() -{ +// 0003BFF0 +void stopallsamples() { //_disable(); // Clear/initialize engine sound volume data for all cars for (int iCarIndex = 0; iCarIndex < numcars; ++iCarIndex) { for (int iEngineDataIdx = 0; iEngineDataIdx < 32; ++iEngineDataIdx) { - tEngineSoundData *pEngineData = &enginedelay[iCarIndex].engineSoundData[iEngineDataIdx]; + tEngineSoundData *pEngineData = + &enginedelay[iCarIndex].engineSoundData[iEngineDataIdx]; pEngineData->iEngineVol = -1; pEngineData->iEngine2Vol = -1; @@ -1959,9 +2061,9 @@ void stopallsamples() for (int iSample = 0; iSample < numsamples; ++iSample) { for (int iCar = 0; iCar < numcars; ++iCar) { int iCurrHandle = SampleHandleCar[iSample].handles[iCar]; - if ( iCurrHandle != -1 ) + if (iCurrHandle != -1) DIGIStopSample(iCurrHandle); - //sosDIGIStopSample(*(int *)&DIGIHandle, iCurrHandle); + // sosDIGIStopSample(*(int *)&DIGIHandle, iCurrHandle); SampleHandleCar[iSample].handles[iCar] = -1; } } @@ -1976,355 +2078,387 @@ void stopallsamples() } //------------------------------------------------------------------------------------------------- -//0003C110 -void pannedsample(int iSampleIdx, int iHandle, int iPan) -{ +// 0003C110 +void pannedsample(int iSampleIdx, int iHandle, int iPan) { int iLocalHandle; // edi - //int iSampleOffset; // ebp - int iExistingHandle; // ebx - uint8 *pSampleData; // eax - unsigned int iNewHandle; // eax + // int iSampleOffset; // ebp + int iExistingHandle; // ebx + uint8 *pSampleData; // eax + unsigned int iNewHandle; // eax unsigned int iOldSampleIdx; // ecx iLocalHandle = iHandle; if (soundon && SamplePtr[iSampleIdx]) { - //iSampleOffset = iSampleIdx << 6; + // iSampleOffset = iSampleIdx << 6; iExistingHandle = SampleHandleCar[iSampleIdx].handles[0]; if (iExistingHandle != -1) { //_disable(); iHandle = SampleHandleCar[iSampleIdx].handles[0]; - //if (!sosDIGISampleDone(*(int *)&DIGIHandle, iExistingHandle)) { + // if (!sosDIGISampleDone(*(int *)&DIGIHandle, iExistingHandle)) { if (!DIGISampleDone(iExistingHandle)) { iHandle = iExistingHandle; DIGIStopSample(iExistingHandle); - //sosDIGIStopSample(*(int *)&DIGIHandle, iExistingHandle); + // sosDIGIStopSample(*(int *)&DIGIHandle, iExistingHandle); //*(int *)((char *)SampleHandleCar[0].handles + iSampleOffset) = -1; SampleHandleCar[iSampleIdx].handles[0] = -1; HandleSample[iExistingHandle] = -1; } //_enable(); } - //SamplePanned.unSegment = __DS__; // Set up panned sample structure with audio parameters + // SamplePanned.unSegment = __DS__; // Set up panned sample + // structure with audio parameters SamplePanned.iSampleIndex = iSampleIdx; SamplePanned.iVolume = iLocalHandle; pSampleData = SamplePtr[iSampleIdx]; SamplePanned.iPan = iPan; SamplePanned.pSample = pSampleData; SamplePanned.iLength = SampleLen[iSampleIdx]; - //_disable(); // Start playing the new panned sample and get handle + //_disable(); // Start playing the new + // panned sample and get handle iNewHandle = DIGISampleStart(&SamplePanned); - //LOWORD(iNewHandle) = sosDIGIStartSample(*(int *)&DIGIHandle, iHandle, &SamplePanned); + // LOWORD(iNewHandle) = sosDIGIStartSample(*(int *)&DIGIHandle, iHandle, + // &SamplePanned); SampleHandleCar[iSampleIdx].handles[0] = iNewHandle; //_enable(); - if (iNewHandle != -1) // Update handle tracking tables if sample started successfully - { // Validate handle is within expected range (< 32) - //if (iNewHandle >= 0x20) - // _assert(0, "s>=0 && s<32", a3, 2071); - iOldSampleIdx = HandleSample[iNewHandle]; // Clean up any existing handle mappings before assigning new ones + if (iNewHandle != + -1) // Update handle tracking tables if sample started successfully + { // Validate handle is within expected range (< 32) + // if (iNewHandle >= 0x20) + // _assert(0, "s>=0 && s<32", a3, 2071); + iOldSampleIdx = + HandleSample[iNewHandle]; // Clean up any existing handle mappings + // before assigning new ones if (iOldSampleIdx != -1) { - //if (iOldSampleIdx >= 0x78) - // _assert(0, "HandleSample[s]>=0 && HandleSample[s]= 16) - // _assert(0, "HandleCar[s]>=0 && HandleCar[s]= 0x78) + // _assert(0, "HandleSample[s]>=0 && HandleSample[s]= 16) + // _assert(0, "HandleCar[s]>=0 && HandleCar[s] lastsample) speechsample(iSampleIdx, iVolume, iDelay, iCarIdx); } //------------------------------------------------------------------------------------------------- -//0003C2E0 -void speechsample(int iSampleIdx, int iVolume, int iDelay, int iCarIdx) -{ - int iWriteIndex; // edi - int iGameOverCount; // eax +// 0003C2E0 +void speechsample(int iSampleIdx, int iVolume, int iDelay, int iCarIdx) { + int iWriteIndex; // edi + int iGameOverCount; // eax int iCurrentWriteIndex; // eax - iWriteIndex = writesample; // Get current write position in speech queue - if (!disable_messages) // Only queue samples if messages are not disabled - { // Special handling for game over sample (index 30) + iWriteIndex = writesample; // Get current write position in speech queue + if (!disable_messages) // Only queue samples if messages are not disabled + { // Special handling for game over sample (index 30) if (iSampleIdx == 30) { iGameOverCount = ++game_overs; - if (player_type != 2 || iGameOverCount == 2)// Disable further messages after 2 game overs in multiplayer or any in single player + if (player_type != 2 || + iGameOverCount == 2) // Disable further messages after 2 game overs in + // multiplayer or any in single player disable_messages = -1; } - if (!winner_mode || iSampleIdx >= 89) // Only queue certain samples when in winner mode (samples >= 89) + if (!winner_mode || iSampleIdx >= 89) // Only queue certain samples when in + // winner mode (samples >= 89) { - iCurrentWriteIndex = writesample; // Queue speech sample data into the circular buffer + iCurrentWriteIndex = + writesample; // Queue speech sample data into the circular buffer speechinfo[iCurrentWriteIndex].iSampleIdx = iSampleIdx; speechinfo[iCurrentWriteIndex].iVolume = iVolume; speechinfo[iCurrentWriteIndex].iDelay = iDelay; ++iWriteIndex; speechinfo[iCurrentWriteIndex].iCarIdx = iCarIdx; - if (iWriteIndex == 16) // Wrap around queue index when it reaches buffer size (16) + if (iWriteIndex == + 16) // Wrap around queue index when it reaches buffer size (16) iWriteIndex = 0; } } - writesample = iWriteIndex; // Update global write position for next sample + writesample = iWriteIndex; // Update global write position for next sample } //------------------------------------------------------------------------------------------------- -//0003C530 -void analysespeechsamples() -{ - int iCarIdx; // ecx - int iCarIdxUpper; // esi - int iIsPlayerCar; // edx +// 0003C530 +void analysespeechsamples() { + int iCarIdx; // ecx + int iCarIdxUpper; // esi + int iIsPlayerCar; // edx const char *pszMessage; // eax - char *pszText; // eax - int iLap; // eax - int iWinCount; // edx - int iKillCount; // edi - int iResultKills; // ecx - int iSampleIdx; // eax - int iSampleDuration; // eax - - --lastsample; // Decrement sample timer - if (readsample != writesample && -speechinfo[readsample].iDelay > lastsample)// Check if there are samples to process and timing is right + char *pszText; // eax + int iLap; // eax + int iWinCount; // edx + int iKillCount; // edi + int iResultKills; // ecx + int iSampleIdx; // eax + int iSampleDuration; // eax + + --lastsample; // Decrement sample timer + if (readsample != writesample && + -speechinfo[readsample].iDelay > + lastsample) // Check if there are samples to process and timing is + // right { - iCarIdx = (uint8)speechinfo[readsample].iCarIdx;// Extract car index from speech info + iCarIdx = (uint8)speechinfo[readsample] + .iCarIdx; // Extract car index from speech info iCarIdxUpper = speechinfo[readsample].iCarIdx >> 8; - iIsPlayerCar = player_type == 2 && iCarIdx != player1_car;// Check if this is about player car vs other cars + iIsPlayerCar = + player_type == 2 && + iCarIdx != + player1_car; // Check if this is about player car vs other cars switch (speechinfo[readsample].iSampleIdx) { - case 0xE: - start_zoom(&language_buffer[1920], iIsPlayerCar);// Case 0xE: Handle crash/damage announcement - if (Car[iCarIdx].byDamageSourceTimer) - goto LABEL_13; - goto LABEL_61; - case 0xF: - iLap = Car[iCarIdx].byLap; // Case 0xF: Handle lap count announcements - if (NoOfLaps == iLap) - goto LABEL_15; - sprintf(buffer, "%i %s", NoOfLaps + 1 - iLap, &language_buffer[3712]); - pszText = buffer; - goto LABEL_60; - case 0x10: - case 0x11: - case 0x12: - LABEL_15: - pszText = &language_buffer[2240]; - goto LABEL_60; - case 0x15: - if ((char)Car[Victim].byLives <= 0) // Case 0x15: Handle player elimination/death announcement - pszMessage = &language_buffer[1984]; - else - pszMessage = &language_buffer[1920]; - start_zoom(pszMessage, iIsPlayerCar); - sprintf(buffer, "%s %s", &language_buffer[2048], driver_names[Victim]); - subzoom(buffer); - goto LABEL_61; - case 0x16: - pszText = &language_buffer[2560]; - goto LABEL_60; - case 0x17: - case 0x18: - case 0x19: - pszText = &language_buffer[64 * Car[iCarIdx].byRacePosition + 384]; - goto LABEL_60; - case 0x1A: - pszText = &language_buffer[2624]; - goto LABEL_60; - case 0x1E: - pszText = &language_buffer[2112]; - goto LABEL_60; - case 0x25: - case 0x26: - start_zoom(&language_buffer[2752], iIsPlayerCar);// Cases 0x25-0x26: Handle best lap time announcements - make_time(buffer, Car[iCarIdx].fBestLapTime); - subzoom(buffer); - goto LABEL_61; - case 0x27: - start_zoom(&language_buffer[2816], iIsPlayerCar); - make_time(buffer, Car[iCarIdx].fBestLapTime); - subzoom(buffer); - goto LABEL_61; - case 0x28: - start_zoom(&language_buffer[2880], iIsPlayerCar); - make_time(buffer, Car[iCarIdx].fBestLapTime); + case 0xE: + start_zoom(&language_buffer[1920], + iIsPlayerCar); // Case 0xE: Handle crash/damage announcement + if (Car[iCarIdx].byDamageSourceTimer) + goto LABEL_13; + goto LABEL_61; + case 0xF: + iLap = Car[iCarIdx].byLap; // Case 0xF: Handle lap count announcements + if (NoOfLaps == iLap) + goto LABEL_15; + sprintf(buffer, "%i %s", NoOfLaps + 1 - iLap, &language_buffer[3712]); + pszText = buffer; + goto LABEL_60; + case 0x10: + case 0x11: + case 0x12: + LABEL_15: + pszText = &language_buffer[2240]; + goto LABEL_60; + case 0x15: + if ((char)Car[Victim].byLives <= + 0) // Case 0x15: Handle player elimination/death announcement + pszMessage = &language_buffer[1984]; + else + pszMessage = &language_buffer[1920]; + start_zoom(pszMessage, iIsPlayerCar); + sprintf(buffer, "%s %s", &language_buffer[2048], driver_names[Victim]); + subzoom(buffer); + goto LABEL_61; + case 0x16: + pszText = &language_buffer[2560]; + goto LABEL_60; + case 0x17: + case 0x18: + case 0x19: + pszText = &language_buffer[64 * Car[iCarIdx].byRacePosition + 384]; + goto LABEL_60; + case 0x1A: + pszText = &language_buffer[2624]; + goto LABEL_60; + case 0x1E: + pszText = &language_buffer[2112]; + goto LABEL_60; + case 0x25: + case 0x26: + start_zoom( + &language_buffer[2752], + iIsPlayerCar); // Cases 0x25-0x26: Handle best lap time announcements + make_time(buffer, Car[iCarIdx].fBestLapTime); + subzoom(buffer); + goto LABEL_61; + case 0x27: + start_zoom(&language_buffer[2816], iIsPlayerCar); + make_time(buffer, Car[iCarIdx].fBestLapTime); + subzoom(buffer); + goto LABEL_61; + case 0x28: + start_zoom(&language_buffer[2880], iIsPlayerCar); + make_time(buffer, Car[iCarIdx].fBestLapTime); + subzoom(buffer); + goto LABEL_61; + case 0x2B: + pszText = &language_buffer[2944]; + goto LABEL_60; + case 0x2C: + pszText = &language_buffer[3008]; + goto LABEL_60; + case 0x2D: + start_zoom(&language_buffer[1984], iIsPlayerCar); + if (Car[iCarIdx].byDamageSourceTimer) { + LABEL_13: + sprintf(buffer, "%s %s", &language_buffer[2176], + driver_names[Car[iCarIdx].byAttacker]); subzoom(buffer); - goto LABEL_61; - case 0x2B: - pszText = &language_buffer[2944]; - goto LABEL_60; - case 0x2C: - pszText = &language_buffer[3008]; - goto LABEL_60; - case 0x2D: - start_zoom(&language_buffer[1984], iIsPlayerCar); - if (Car[iCarIdx].byDamageSourceTimer) { - LABEL_13: - sprintf(buffer, "%s %s", &language_buffer[2176], driver_names[Car[iCarIdx].byAttacker]); - subzoom(buffer); - } - goto LABEL_61; - case 0x2E: - pszText = &language_buffer[2688]; - goto LABEL_60; - case 0x33: - pszText = &language_buffer[6080]; - goto LABEL_60; - case 0x34: - pszText = &language_buffer[6144]; - goto LABEL_60; - case 0x35: - pszText = &language_buffer[2496]; - goto LABEL_60; - case 0x36: - pszText = &language_buffer[2432]; - goto LABEL_60; - case 0x37: - pszText = &language_buffer[2368]; - goto LABEL_60; - case 0x38: - pszText = &language_buffer[2304]; - goto LABEL_60; - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - small_zoom(&language_buffer[4992]); - subzoom(&language_buffer[64 * speechinfo[readsample].iSampleIdx + 1408]); - goto LABEL_61; - case 0x41: - case 0x42: - small_zoom(&language_buffer[4928]); + } + goto LABEL_61; + case 0x2E: + pszText = &language_buffer[2688]; + goto LABEL_60; + case 0x33: + pszText = &language_buffer[6080]; + goto LABEL_60; + case 0x34: + pszText = &language_buffer[6144]; + goto LABEL_60; + case 0x35: + pszText = &language_buffer[2496]; + goto LABEL_60; + case 0x36: + pszText = &language_buffer[2432]; + goto LABEL_60; + case 0x37: + pszText = &language_buffer[2368]; + goto LABEL_60; + case 0x38: + pszText = &language_buffer[2304]; + goto LABEL_60; + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + small_zoom(&language_buffer[4992]); + subzoom(&language_buffer[64 * speechinfo[readsample].iSampleIdx + 1408]); + goto LABEL_61; + case 0x41: + case 0x42: + small_zoom(&language_buffer[4928]); + subzoom(&language_buffer[64 * iCarIdxUpper + 1152]); + goto LABEL_61; + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + small_zoom( + &language_buffer[64 * speechinfo[readsample].iSampleIdx + 768]); + switch (iCarIdxUpper) { + case '=': + case '>': + case '?': + case '@': subzoom(&language_buffer[64 * iCarIdxUpper + 1152]); + break; + case 'C': + subzoom(&language_buffer[5952]); + break; + case 'D': + subzoom(&language_buffer[6016]); + break; + case 'E': + subzoom(&language_buffer[5888]); + break; + case 'F': + subzoom(&language_buffer[5824]); + break; + default: goto LABEL_61; - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - small_zoom(&language_buffer[64 * speechinfo[readsample].iSampleIdx + 768]); - switch (iCarIdxUpper) { - case '=': - case '>': - case '?': - case '@': - subzoom(&language_buffer[64 * iCarIdxUpper + 1152]); - break; - case 'C': - subzoom(&language_buffer[5952]); - break; - case 'D': - subzoom(&language_buffer[6016]); - break; - case 'E': - subzoom(&language_buffer[5888]); - break; - case 'F': - subzoom(&language_buffer[5824]); - break; - default: - goto LABEL_61; - } - goto LABEL_61; - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - iWinCount = total_wins[champorder[0]]; // Cases 0x59-0x60: Handle championship win count announcements - if (iWinCount == 1) - sprintf(buffer, "%s", &config_buffer[6784]); + } + goto LABEL_61; + case 0x59: + case 0x5A: + case 0x5B: + case 0x5C: + case 0x5D: + case 0x5E: + case 0x5F: + case 0x60: + iWinCount = + total_wins[champorder[0]]; // Cases 0x59-0x60: Handle championship win + // count announcements + if (iWinCount == 1) + sprintf(buffer, "%s", &config_buffer[6784]); + else + sprintf(buffer, "%s %i %s", &config_buffer[6656], iWinCount, + &config_buffer[6720]); + pszText = buffer; + goto LABEL_59; + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x66: + case 0x67: + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + case 0x70: + case 0x71: + if (champ_mode) // Cases 0x61-0x71: Handle kill count announcements + { + iKillCount = total_kills[champorder[0]]; + if (iKillCount == 1) + sprintf(buffer, "%s", &config_buffer[6464]); else - sprintf(buffer, "%s %i %s", &config_buffer[6656], iWinCount, &config_buffer[6720]); + sprintf(buffer, "%s %i %s", &config_buffer[6528], iKillCount, + &config_buffer[6592]); pszText = buffer; - goto LABEL_59; - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - if (champ_mode) // Cases 0x61-0x71: Handle kill count announcements - { - iKillCount = total_kills[champorder[0]]; - if (iKillCount == 1) - sprintf(buffer, "%s", &config_buffer[6464]); - else - sprintf(buffer, "%s %i %s", &config_buffer[6528], iKillCount, &config_buffer[6592]); + } else { + iResultKills = result_kills[result_order[0]]; + if (iResultKills != 1) { + sprintf(buffer, "%s %i %s", &config_buffer[6528], iResultKills, + &config_buffer[6592]); + iIsPlayerCar = 0; pszText = buffer; - } else { - iResultKills = result_kills[result_order[0]]; - if (iResultKills != 1) { - sprintf(buffer, "%s %i %s", &config_buffer[6528], iResultKills, &config_buffer[6592]); - iIsPlayerCar = 0; - pszText = buffer; - goto LABEL_60; - } - pszText = &config_buffer[6464]; - } - LABEL_59: - iIsPlayerCar = 0; - LABEL_60: - start_zoom(pszText, iIsPlayerCar); - LABEL_61: - if (soundon) // Play the actual audio sample if sound is enabled - { - iSampleIdx = speechinfo[readsample].iSampleIdx; - if (SamplePtr[iSampleIdx]) - dospeechsample(iSampleIdx, speechinfo[readsample].iVolume); + goto LABEL_60; } - iSampleDuration = (int)(36 * SampleLen[speechinfo[readsample++].iSampleIdx]) / 11025;// Calculate sample duration and advance to next sample in queue - lastsample = iSampleDuration; - if (readsample == 16) - readsample = 0; - break; - case 0x73: - if (result_kills[result_order[0]] <= 0 && result_order[0] != FastestLap) - goto LABEL_61; - pszText = &config_buffer[6080]; - goto LABEL_59; - case 0x74: - pszText = &config_buffer[6144]; - goto LABEL_59; - case 0x75: - pszText = &config_buffer[6208]; - goto LABEL_59; - default: - goto LABEL_61; // Process different types of speech samples based on sample index + pszText = &config_buffer[6464]; + } + LABEL_59: + iIsPlayerCar = 0; + LABEL_60: + start_zoom(pszText, iIsPlayerCar); + LABEL_61: + if (soundon) // Play the actual audio sample if sound is enabled + { + iSampleIdx = speechinfo[readsample].iSampleIdx; + if (SamplePtr[iSampleIdx]) + dospeechsample(iSampleIdx, speechinfo[readsample].iVolume); + } + iSampleDuration = + (int)(36 * SampleLen[speechinfo[readsample++].iSampleIdx]) / + 11025; // Calculate sample duration and advance to next sample in + // queue + lastsample = iSampleDuration; + if (readsample == 16) + readsample = 0; + break; + case 0x73: + if (result_kills[result_order[0]] <= 0 && result_order[0] != FastestLap) + goto LABEL_61; + pszText = &config_buffer[6080]; + goto LABEL_59; + case 0x74: + pszText = &config_buffer[6144]; + goto LABEL_59; + case 0x75: + pszText = &config_buffer[6208]; + goto LABEL_59; + default: + goto LABEL_61; // Process different types of speech samples based on + // sample index } } } //------------------------------------------------------------------------------------------------- -//0003CAD0 -void dospeechsample(int iSampleIdx, int iVolume) -{ +// 0003CAD0 +void dospeechsample(int iSampleIdx, int iVolume) { int iUseVolume; int iHandle, iSampleHandle; // Check sample pointer is valid if (SamplePtr[iSampleIdx] == 0) { - SDL_Log("dospeechsample: Sample pointer is NULL for sample index %d", iSampleIdx); + SDL_Log("dospeechsample: Sample pointer is NULL for sample index %d", + iSampleIdx); return; } @@ -2352,7 +2486,7 @@ void dospeechsample(int iSampleIdx, int iVolume) } // Setup sample parameters - //SampleFixed.unSegment = __DS__; + // SampleFixed.unSegment = __DS__; SampleFixed.iSampleIndex = iSampleIdx; SampleFixed.iVolume = iUseVolume; SampleFixed.pSample = SamplePtr[iSampleIdx]; @@ -2376,9 +2510,8 @@ void dospeechsample(int iSampleIdx, int iVolume) } //------------------------------------------------------------------------------------------------- -//0003CC00 -void loadfrontendsample(char *fileName) -{ +// 0003CC00 +void loadfrontendsample(char *fileName) { if (!SoundCard) return; @@ -2387,7 +2520,7 @@ void loadfrontendsample(char *fileName) // Free any existing frontend speech pointer if (frontendspeechptr) - fre((void**)&frontendspeechptr); + fre((void **)&frontendspeechptr); char szFilenameBuf[32]; // construct sample filename @@ -2395,7 +2528,8 @@ void loadfrontendsample(char *fileName) char *szDst = szFilenameBuf; while (*szSrc) { *szDst++ = *szSrc++; - if (!*szSrc) break; + if (!*szSrc) + break; *szDst++ = *szSrc++; } *szDst = '\0'; @@ -2404,7 +2538,7 @@ void loadfrontendsample(char *fileName) convertname(szFilenameBuf); SDL_Log("Loading track sample: %s\n", szFilenameBuf); // load file into memory - loadfile(szFilenameBuf, (void**)&frontendspeechptr, &frontendlen, 1); + loadfile(szFilenameBuf, (void **)&frontendspeechptr, &frontendlen, 1); if (cheatsample && frontendspeechptr) { uint8 *pData = frontendspeechptr; @@ -2421,7 +2555,7 @@ void loadfrontendsample(char *fileName) // if using 50Hz timer if (frontendspeechptr && (cheat_mode & CHEAT_MODE_50HZ_TIMER)) { - if (cheat_mode & CHEAT_MODE_100HZ_TIMER) { //100Hz timer + if (cheat_mode & CHEAT_MODE_100HZ_TIMER) { // 100Hz timer // halve the sample length, keep only even-indexed bytes int iLen = frontendlen; uint8 *pData = frontendspeechptr; @@ -2445,9 +2579,8 @@ void loadfrontendsample(char *fileName) } //------------------------------------------------------------------------------------------------- -//0003CD90 -int frontendsample(int iVol) -{ +// 0003CD90 +int frontendsample(int iVol) { int iPrevSample; if (iVol > 0x7FFF) @@ -2474,7 +2607,8 @@ int frontendsample(int iVol) iPrevSample = HandleSample[frontendspeechhandle]; if (iPrevSample != -1) { if (HandleCar[frontendspeechhandle] != -1) - SampleHandleCar[iPrevSample].handles[HandleCar[frontendspeechhandle]] = -1; + SampleHandleCar[iPrevSample].handles[HandleCar[frontendspeechhandle]] = + -1; HandleSample[frontendspeechhandle] = -1; HandleCar[frontendspeechhandle] = -1; } @@ -2484,26 +2618,24 @@ int frontendsample(int iVol) } //------------------------------------------------------------------------------------------------- -//0003CE20 -void remove_frontendspeech() -{ +// 0003CE20 +void remove_frontendspeech() { // Clear any existing frontend speech sample stop_frontendspeech_handle(); -// Free any existing frontend speech pointer + // Free any existing frontend speech pointer if (frontendspeechptr) - fre((void**)&frontendspeechptr); + fre((void **)&frontendspeechptr); } //------------------------------------------------------------------------------------------------- -//0003CE70 -int sfxplaying(int iSampleIdx) -{ - //int iSampleHandleCarOffset; // ecx +// 0003CE70 +int sfxplaying(int iSampleIdx) { + // int iSampleHandleCarOffset; // ecx int iCurrHandle; // ebx - int iReturn0; // eax + int iReturn0; // eax - //iSampleHandleCarOffset = iSampleIdx << 6; + // iSampleHandleCarOffset = iSampleIdx << 6; iCurrHandle = SampleHandleCar[iSampleIdx].handles[0]; if (iCurrHandle == -1) return 0; @@ -2516,9 +2648,8 @@ int sfxplaying(int iSampleIdx) } //------------------------------------------------------------------------------------------------- -//0003CEC0 -int cheatsampleok(int iCarIdx) -{ +// 0003CEC0 +int cheatsampleok(int iCarIdx) { if (iCarIdx == player1_car || iCarIdx == player2_car) return -1; else @@ -2526,9 +2657,8 @@ int cheatsampleok(int iCarIdx) } //------------------------------------------------------------------------------------------------- -//0003CEF0 -void sfxsample(int iSample, int iVol) -{ +// 0003CEF0 +void sfxsample(int iSample, int iVol) { if (SamplePtr[iSample] == 0) { SDL_Log("sfxsample: Sample pointer is NULL for sample index %d", iSample); return; @@ -2558,7 +2688,7 @@ void sfxsample(int iSample, int iVol) } // Prepare sample data - //SampleFixed.unSegment = ds; + // SampleFixed.unSegment = ds; SampleFixed.iSampleIndex = iSample; SampleFixed.iVolume = iScaledVol; SampleFixed.pSample = SamplePtr[iSample]; @@ -2566,7 +2696,7 @@ void sfxsample(int iSample, int iVol) // cli(); Disable interrupts // Calculate offset in SampleHandleCar array (64 bytes per element) - //int iHandleOffset = iSample << 6; + // int iHandleOffset = iSample << 6; int iNewHandle = DIGISampleStart(&SampleFixed); // Store new handle SampleHandleCar[iSample].handles[0] = iNewHandle; @@ -2585,28 +2715,28 @@ void sfxsample(int iSample, int iVol) HandleCar[iNewHandle] = 0; // Always use first slot in handles array } - //------------------------------------------------------------------------------------------------- -//0003D020 -void sample2(int iCarIndex, int iSampleIndex, int iVolume, int iPitch, int iPan, int iByteOffset) -{ - //int iOffset; // edi - int iHandle; // eax +// 0003D020 +void sample2(int iCarIndex, int iSampleIndex, int iVolume, int iPitch, int iPan, + int iByteOffset) { + // int iOffset; // edi + int iHandle; // eax int iOldHandle; // ecx uint8 *pSample; // [esp+0h] [ebp-14h] if (soundon) { if (!paused) { // Only proceed if no sample is currently playing in this slot - //iOffset = 4 * iCarIndex + (iSampleIndex << 6); - if (SampleHandleCar[iSampleIndex].handles[iCarIndex] == -1)// SampleHandleCar[iSampleIndex].handles[iCarIndex]? + // iOffset = 4 * iCarIndex + (iSampleIndex << 6); + if (SampleHandleCar[iSampleIndex].handles[iCarIndex] == + -1) // SampleHandleCar[iSampleIndex].handles[iCarIndex]? { // Prepare sample data structure SampleData.iSampleIndex = iSampleIndex; SampleData.iPitch = iPitch; pSample = SamplePtr[iSampleIndex]; SampleData.iLength = SampleLen[iSampleIndex]; - //SampleData.unSegment = __DS__; + // SampleData.unSegment = __DS__; SampleData.iPan = iPan; SampleData.pSample = pSample; SampleData.iByteOffset = iByteOffset; @@ -2614,10 +2744,12 @@ void sample2(int iCarIndex, int iSampleIndex, int iVolume, int iPitch, int iPan, // Start sample playback iHandle = DIGISampleStart(&SampleData); - //LOWORD(iHandle) = sosDIGIStartSample(*(int *)&DIGIHandle, iSampleIndex, &SampleData); + // LOWORD(iHandle) = sosDIGIStartSample(*(int *)&DIGIHandle, + // iSampleIndex, &SampleData); // Store new handle - SampleHandleCar[iSampleIndex].handles[iCarIndex] = iHandle;// SampleHandleCar[iSampleIndex].handles[iCarIndex]? + SampleHandleCar[iSampleIndex].handles[iCarIndex] = + iHandle; // SampleHandleCar[iSampleIndex].handles[iCarIndex]? if (iHandle != -1) { // Clear any previous assignment of this handle iOldHandle = HandleSample[iHandle]; @@ -2634,83 +2766,98 @@ void sample2(int iCarIndex, int iSampleIndex, int iVolume, int iPitch, int iPan, } //------------------------------------------------------------------------------------------------- -//0003D110 -void sfxpend(int iSampleIdx, int iDriverIdx, int iVolume) -{ - int iClampedVolume; // edi +// 0003D110 +void sfxpend(int iSampleIdx, int iDriverIdx, int iVolume) { + int iClampedVolume; // edi int iAdjustedVolume; // edi - //int iDriverIndex; // ebx + // int iDriverIndex; // ebx int bSampleFound; // esi - //int iArrayIndex; // eax - //int iLoopCounter; // edx - //int iPendingOffset; // eax - //int iNewPendingCount; // ecx + // int iArrayIndex; // eax + // int iLoopCounter; // edx + // int iPendingOffset; // eax + // int iNewPendingCount; // ecx - iClampedVolume = iVolume; // Clamp volume to maximum allowed value (32767) + iClampedVolume = iVolume; // Clamp volume to maximum allowed value (32767) if (iVolume > 0x7FFF) iClampedVolume = 0x7FFF; - if (replaytype != 2) // Store replay information if not in replay playback mode + if (replaytype != + 2) // Store replay information if not in replay playback mode { newrepsample[iDriverIdx] = iSampleIdx; repvolume[iDriverIdx] = iClampedVolume / 256; - //repvolume[iDriverIdx] = (unsigned __int16)(iClampedVolume - (__CFSHL__(iClampedVolume >> 31, 8) + ((unsigned __int16)(iClampedVolume >> 31) << 8))) >> 8; + // repvolume[iDriverIdx] = (unsigned __int16)(iClampedVolume - + // (__CFSHL__(iClampedVolume >> 31, 8) + ((unsigned __int16)(iClampedVolume + // >> 31) << 8))) >> 8; } - iAdjustedVolume = iClampedVolume * SFXVolume / 127;// Calculate final volume based on global SFX volume setting - if (soundon && Pending[iDriverIdx] != 5) // Only queue sample if sound is enabled and pending queue isn't full + iAdjustedVolume = + iClampedVolume * SFXVolume / + 127; // Calculate final volume based on global SFX volume setting + if (soundon && + Pending[iDriverIdx] != 5) // Only queue sample if sound is enabled and + // pending queue isn't full { // Check if this sample is already pending for this driver bSampleFound = 0; - for (int iSampleIndex = 0; iSampleIndex < Pending[iDriverIdx]; iSampleIndex++) { + for (int iSampleIndex = 0; iSampleIndex < Pending[iDriverIdx]; + iSampleIndex++) { if (iSampleIdx == SamplePending[iDriverIdx][iSampleIndex].iHandle) { bSampleFound = -1; - break; // No need to continue once found + break; // No need to continue once found } } - //iDriverIndex = iDriverIdx; - //bSampleFound = 0; // Initialize duplicate detection flag and array indexing - //iArrayIndex = 40 * iDriverIdx; - //for (iLoopCounter = 0; iLoopCounter < Pending[iDriverIndex]; iArrayIndex += 2)// Check if this sample is already pending for this driver + // iDriverIndex = iDriverIdx; + // bSampleFound = 0; // Initialize duplicate + // detection flag and array indexing iArrayIndex = 40 * iDriverIdx; for + // (iLoopCounter = 0; iLoopCounter < Pending[iDriverIndex]; iArrayIndex += + // 2)// Check if this sample is already pending for this driver //{ - // if (iSampleIdx == SamplePending[0][iArrayIndex]) - // bSampleFound = -1; - // ++iLoopCounter; - //} + // if (iSampleIdx == SamplePending[0][iArrayIndex]) + // bSampleFound = -1; + // ++iLoopCounter; + // } if (!bSampleFound) { - // Add sample to pending queue if it's not a duplicate + // Add sample to pending queue if it's not a duplicate int iNextSlot = Pending[iDriverIdx]; SamplePending[iDriverIdx][iNextSlot].iHandle = iSampleIdx; SamplePending[iDriverIdx][iNextSlot].iVolume = iAdjustedVolume; - Pending[iDriverIdx]++; // Increment pending count for this driver + Pending[iDriverIdx]++; // Increment pending count for this driver } - //if (!bSampleFound) // Add sample to pending queue if it's not a duplicate + // if (!bSampleFound) // Add sample to pending queue + // if it's not a duplicate //{ - // iPendingOffset = 160 * iDriverIdx + 8 * Pending[iDriverIndex];// Calculate offset in pending array and store sample data - // *(int *)((char *)SamplePending[0] + iPendingOffset) = iSampleIdx; - // iNewPendingCount = Pending[iDriverIndex] + 1; - // *(int *)((char *)&SamplePending[0][1] + iPendingOffset) = iAdjustedVolume; - // Pending[iDriverIndex] = iNewPendingCount; // Increment pending count for this driver - //} + // iPendingOffset = 160 * iDriverIdx + 8 * Pending[iDriverIndex];// + // Calculate offset in pending array and store sample data + // *(int *)((char *)SamplePending[0] + iPendingOffset) = iSampleIdx; + // iNewPendingCount = Pending[iDriverIndex] + 1; + // *(int *)((char *)&SamplePending[0][1] + iPendingOffset) = + // iAdjustedVolume; Pending[iDriverIndex] = iNewPendingCount; // Increment + // pending count for this driver + // } } } //------------------------------------------------------------------------------------------------- -//0003D200 -void enginesounds2(int iPlayer1Car, int iPlayer2Car) -{ +// 0003D200 +void enginesounds2(int iPlayer1Car, int iPlayer2Car) { int iEngine1Offset; // ecx int iEngine2Offset; // ecx if (soundon) { delaywritex = delaywrite & 0x1F; iEngine1Offset = 32 * iPlayer1Car; - enginedelay[0].engineSoundData[(delaywrite & 0x1F) + iEngine1Offset].iEngineVol = -1; - enginedelay[0].engineSoundData[delaywritex + iEngine1Offset].iEngine2Vol = -1; + enginedelay[0] + .engineSoundData[(delaywrite & 0x1F) + iEngine1Offset] + .iEngineVol = -1; + enginedelay[0].engineSoundData[delaywritex + iEngine1Offset].iEngine2Vol = + -1; enginedelay[0].engineSoundData[delaywritex + iEngine1Offset].iSkid1Vol = -1; iEngine2Offset = 32 * iPlayer2Car; - enginedelay[0].engineSoundData[delaywritex + iEngine2Offset].iEngineVol = -1; - enginedelay[0].engineSoundData[delaywritex + iEngine2Offset].iEngine2Vol = -1; + enginedelay[0].engineSoundData[delaywritex + iEngine2Offset].iEngineVol = + -1; + enginedelay[0].engineSoundData[delaywritex + iEngine2Offset].iEngine2Vol = + -1; enginedelay[0].engineSoundData[delaywritex + iEngine2Offset].iSkid1Vol = -1; enginesound(iPlayer1Car, 0.0, 0.0, 2000.0, 0x8000); enginesound(iPlayer2Car, 0.0, 0.0, 2000.0, 0x8000); @@ -2719,87 +2866,89 @@ void enginesounds2(int iPlayer1Car, int iPlayer2Car) } //------------------------------------------------------------------------------------------------- -//0003D310 -void enginesounds(int iFocusCarIndex) -{ - //unsigned int uiInitOffset; // eax - //int iTotalOffset; // ebp - tCar *pFocusCar; // eax - int iCurrChunk; // edx - tData *pChunkData; // edx - int iCarYaw; // ebx - double dSpeedCos; // st7 - double dSpeedSin; // st6 - int iChunkIdx; // ebp - double dCosRoll; // st7 - int iCarIndex; // ecx - tCar *pCurrentCar; // ebx - int iEnableSound; // eax - int iCarChunk; // esi - int iChunkDiff; // esi - int iCurrentCarChunk; // eax - tData *pCarChunkData; // eax - int iYaw3; // esi +// 0003D310 +void enginesounds(int iFocusCarIndex) { + // unsigned int uiInitOffset; // eax + // int iTotalOffset; // ebp + tCar *pFocusCar; // eax + int iCurrChunk; // edx + tData *pChunkData; // edx + int iCarYaw; // ebx + double dSpeedCos; // st7 + double dSpeedSin; // st6 + int iChunkIdx; // ebp + double dCosRoll; // st7 + int iCarIndex; // ecx + tCar *pCurrentCar; // ebx + int iEnableSound; // eax + int iCarChunk; // esi + int iChunkDiff; // esi + int iCurrentCarChunk; // eax + tData *pCarChunkData; // eax + int iYaw3; // esi double dCurrentCarSpeedCos; // st7 double dCurrentCarSpeedSin; // st6 - int iHorizontalAngle; // edx - int iVerticalAngle; // eax - double dVolumeCalc; // st7 - float fTempVolumeCalc; // [esp+0h] [ebp-9Ch] - int iRoll; // [esp+4h] [ebp-98h] BYREF - int iYaw; // [esp+8h] [ebp-94h] BYREF - int iPitch; // [esp+10h] [ebp-8Ch] BYREF - float fHorizontalDistance; // [esp+14h] [ebp-88h] - float fTransformedX; // [esp+18h] [ebp-84h] - float fOrientMatrix_XX; // [esp+20h] [ebp-7Ch] - float fOrientMatrix_ZX; // [esp+24h] [ebp-78h] - float fOrientMatrix_ZZ; // [esp+28h] [ebp-74h] - float fOrientMatrix_YX; // [esp+2Ch] [ebp-70h] - float fOrientMatrix_YY; // [esp+30h] [ebp-6Ch] - float fOrientMatrix_XY; // [esp+34h] [ebp-68h] - float fListenerDirY; // [esp+38h] [ebp-64h] - float fListenerDirX; // [esp+3Ch] [ebp-60h] - float fListenerDirZ; // [esp+40h] [ebp-5Ch] - float fZ; // [esp+44h] [ebp-58h] - float fX; // [esp+48h] [ebp-54h] - float fY; // [esp+4Ch] [ebp-50h] - float fListenerDopplerVel; // [esp+50h] [ebp-4Ch] - float fCarDopplerVel; // [esp+54h] [ebp-48h] - float fCarVelY; // [esp+58h] [ebp-44h] - float fCarPosX; // [esp+5Ch] [ebp-40h] - float fCarVelZ; // [esp+60h] [ebp-3Ch] - float fCarPosZ; // [esp+64h] [ebp-38h] - float fTotalDistance; // [esp+68h] [ebp-34h] - int iStereoVolume; // [esp+6Ch] [ebp-30h] - float fRelativeY; // [esp+70h] [ebp-2Ch] - float fRelativeZ; // [esp+74h] [ebp-28h] - float fRelativeX; // [esp+78h] [ebp-24h] - float fCarPosY; // [esp+7Ch] [ebp-20h] - float fCarVelX; // [esp+80h] [ebp-1Ch] - - if (soundon) // Check if sound is enabled globally + int iHorizontalAngle; // edx + int iVerticalAngle; // eax + double dVolumeCalc; // st7 + float fTempVolumeCalc; // [esp+0h] [ebp-9Ch] + int iRoll; // [esp+4h] [ebp-98h] BYREF + int iYaw; // [esp+8h] [ebp-94h] BYREF + int iPitch; // [esp+10h] [ebp-8Ch] BYREF + float fHorizontalDistance; // [esp+14h] [ebp-88h] + float fTransformedX; // [esp+18h] [ebp-84h] + float fOrientMatrix_XX; // [esp+20h] [ebp-7Ch] + float fOrientMatrix_ZX; // [esp+24h] [ebp-78h] + float fOrientMatrix_ZZ; // [esp+28h] [ebp-74h] + float fOrientMatrix_YX; // [esp+2Ch] [ebp-70h] + float fOrientMatrix_YY; // [esp+30h] [ebp-6Ch] + float fOrientMatrix_XY; // [esp+34h] [ebp-68h] + float fListenerDirY; // [esp+38h] [ebp-64h] + float fListenerDirX; // [esp+3Ch] [ebp-60h] + float fListenerDirZ; // [esp+40h] [ebp-5Ch] + float fZ; // [esp+44h] [ebp-58h] + float fX; // [esp+48h] [ebp-54h] + float fY; // [esp+4Ch] [ebp-50h] + float fListenerDopplerVel; // [esp+50h] [ebp-4Ch] + float fCarDopplerVel; // [esp+54h] [ebp-48h] + float fCarVelY; // [esp+58h] [ebp-44h] + float fCarPosX; // [esp+5Ch] [ebp-40h] + float fCarVelZ; // [esp+60h] [ebp-3Ch] + float fCarPosZ; // [esp+64h] [ebp-38h] + float fTotalDistance; // [esp+68h] [ebp-34h] + int iStereoVolume; // [esp+6Ch] [ebp-30h] + float fRelativeY; // [esp+70h] [ebp-2Ch] + float fRelativeZ; // [esp+74h] [ebp-28h] + float fRelativeX; // [esp+78h] [ebp-24h] + float fCarPosY; // [esp+7Ch] [ebp-20h] + float fCarVelX; // [esp+80h] [ebp-1Ch] + + if (soundon) // Check if sound is enabled globally { - delaywritex = delaywrite & 0x1F; // Get current delay buffer write index (0-31) - + delaywritex = + delaywrite & 0x1F; // Get current delay buffer write index (0-31) for (int iCar = 0; iCar < numcars; ++iCar) { enginedelay[iCar].engineSoundData[delaywritex].iEngineVol = -1; enginedelay[iCar].engineSoundData[delaywritex].iEngine2Vol = -1; enginedelay[iCar].engineSoundData[delaywritex].iSkid1Vol = -1; } - //if (numcars > 0) // Initialize engine sound data for all cars + // if (numcars > 0) // Initialize engine sound data + // for all cars //{ - // uiInitOffset = 0; - // iTotalOffset = 896 * numcars; - // do { - // enginedelay[0].engineSoundData[delaywritex + uiInitOffset / 0x1C].iEngineVol = -1; - // enginedelay[0].engineSoundData[delaywritex + uiInitOffset / 0x1C].iEngine2Vol = -1; - // uiInitOffset += 896; - // SamplePending[12][7 * delaywritex + 5 + uiInitOffset / 4] = -1; - // } while ((int)uiInitOffset < iTotalOffset); - //} - if (DriveView[0] == 3 || DriveView[0] == 6)// Check for external camera view (3) or tower view (6) - { // Setup listener position for tower view camera + // uiInitOffset = 0; + // iTotalOffset = 896 * numcars; + // do { + // enginedelay[0].engineSoundData[delaywritex + uiInitOffset / + // 0x1C].iEngineVol = -1; enginedelay[0].engineSoundData[delaywritex + + // uiInitOffset / 0x1C].iEngine2Vol = -1; uiInitOffset += 896; + // SamplePending[12][7 * delaywritex + 5 + uiInitOffset / 4] = -1; + // } while ((int)uiInitOffset < iTotalOffset); + // } + if (DriveView[0] == 3 || + DriveView[0] == + 6) // Check for external camera view (3) or tower view (6) + { // Setup listener position for tower view camera if (DriveView[0] == 6) { fX = -localdata[2].pointAy[3].fX; fY = -localdata[2].pointAy[3].fY; @@ -2815,7 +2964,8 @@ void enginesounds(int iFocusCarIndex) fListenerDirY = 0.0; fListenerDirZ = 0.0; } else { - enginesound(iFocusCarIndex, 0.0, 0.0, 2000.0, 0x8000);// Process engine sound for focus car (in-car view) + enginesound(iFocusCarIndex, 0.0, 0.0, 2000.0, + 0x8000); // Process engine sound for focus car (in-car view) pFocusCar = &Car[iFocusCarIndex]; iCurrChunk = pFocusCar->nCurrChunk; if (iCurrChunk == -1) { @@ -2826,25 +2976,30 @@ void enginesounds(int iFocusCarIndex) fListenerDirY = pFocusCar->direction.fY; fListenerDirZ = pFocusCar->direction.fZ; } else { - pChunkData = &localdata[iCurrChunk]; // Transform car position from chunk coordinates to world coordinates - fX = pChunkData->pointAy[0].fY * pFocusCar->pos.fY - + pChunkData->pointAy[0].fX * pFocusCar->pos.fX - + pChunkData->pointAy[0].fZ * pFocusCar->pos.fZ - - pChunkData->pointAy[3].fX; - fY = pChunkData->pointAy[1].fY * pFocusCar->pos.fY - + pChunkData->pointAy[1].fX * pFocusCar->pos.fX - + pChunkData->pointAy[1].fZ * pFocusCar->pos.fZ - - pChunkData->pointAy[3].fY; - fZ = pChunkData->pointAy[2].fY * pFocusCar->pos.fY - + pChunkData->pointAy[2].fX * pFocusCar->pos.fX - + pChunkData->pointAy[2].fZ * pFocusCar->pos.fZ - - pChunkData->pointAy[3].fZ; + pChunkData = + &localdata[iCurrChunk]; // Transform car position from chunk + // coordinates to world coordinates + fX = pChunkData->pointAy[0].fY * pFocusCar->pos.fY + + pChunkData->pointAy[0].fX * pFocusCar->pos.fX + + pChunkData->pointAy[0].fZ * pFocusCar->pos.fZ - + pChunkData->pointAy[3].fX; + fY = pChunkData->pointAy[1].fY * pFocusCar->pos.fY + + pChunkData->pointAy[1].fX * pFocusCar->pos.fX + + pChunkData->pointAy[1].fZ * pFocusCar->pos.fZ - + pChunkData->pointAy[3].fY; + fZ = pChunkData->pointAy[2].fY * pFocusCar->pos.fY + + pChunkData->pointAy[2].fX * pFocusCar->pos.fX + + pChunkData->pointAy[2].fZ * pFocusCar->pos.fZ - + pChunkData->pointAy[3].fZ; iCarYaw = pFocusCar->nActualYaw; dSpeedCos = pFocusCar->fFinalSpeed * tcos[iCarYaw]; dSpeedSin = pFocusCar->fFinalSpeed * tsin[iCarYaw]; - fListenerDirX = (float)(pChunkData->pointAy[0].fY * dSpeedSin + pChunkData->pointAy[0].fX * dSpeedCos); - fListenerDirY = (float)(pChunkData->pointAy[1].fX * dSpeedCos + pChunkData->pointAy[1].fY * dSpeedSin); - fListenerDirZ = (float)(dSpeedCos * pChunkData->pointAy[2].fX + dSpeedSin * pChunkData->pointAy[2].fY); + fListenerDirX = (float)(pChunkData->pointAy[0].fY * dSpeedSin + + pChunkData->pointAy[0].fX * dSpeedCos); + fListenerDirY = (float)(pChunkData->pointAy[1].fX * dSpeedCos + + pChunkData->pointAy[1].fY * dSpeedSin); + fListenerDirZ = (float)(dSpeedCos * pChunkData->pointAy[2].fX + + dSpeedSin * pChunkData->pointAy[2].fY); } iChunkIdx = pFocusCar->nCurrChunk; if (iChunkIdx == -1) @@ -2852,26 +3007,33 @@ void enginesounds(int iFocusCarIndex) } if (DriveView[0] != 3 && DriveView[0] != 6) { if (Car[iFocusCarIndex].iControlType == 3) { - getworldangles(Car[iFocusCarIndex].nYaw, Car[iFocusCarIndex].nPitch, Car[iFocusCarIndex].nRoll, Car[iFocusCarIndex].nCurrChunk, &iYaw, &iPitch, &iRoll); + getworldangles(Car[iFocusCarIndex].nYaw, Car[iFocusCarIndex].nPitch, + Car[iFocusCarIndex].nRoll, + Car[iFocusCarIndex].nCurrChunk, &iYaw, &iPitch, &iRoll); } else { iYaw = Car[iFocusCarIndex].nYaw; iPitch = Car[iFocusCarIndex].nPitch; iRoll = Car[iFocusCarIndex].nRoll; } - fOrientMatrix_XX = tcos[iYaw] * tcos[iPitch];// Calculate camera orientation matrix from yaw/pitch/roll angles - fOrientMatrix_XY = tcos[iYaw] * tsin[iPitch] * tsin[iRoll] - tsin[iYaw] * tcos[iRoll]; + fOrientMatrix_XX = + tcos[iYaw] * tcos[iPitch]; // Calculate camera orientation matrix from + // yaw/pitch/roll angles + fOrientMatrix_XY = + tcos[iYaw] * tsin[iPitch] * tsin[iRoll] - tsin[iYaw] * tcos[iRoll]; fOrientMatrix_YX = tsin[iYaw] * tcos[iPitch]; - fOrientMatrix_YY = tsin[iYaw] * tsin[iPitch] * tsin[iRoll] + tcos[iYaw] * tcos[iRoll]; + fOrientMatrix_YY = + tsin[iYaw] * tsin[iPitch] * tsin[iRoll] + tcos[iYaw] * tcos[iRoll]; dCosRoll = -tsin[iRoll] * tcos[iPitch]; fOrientMatrix_ZZ = tsin[iPitch]; fOrientMatrix_ZX = (float)dCosRoll; } - iCarIndex = 0; // Main loop: Process engine sounds for each car + iCarIndex = 0; // Main loop: Process engine sounds for each car if (numcars > 0) { pCurrentCar = Car; do { iEnableSound = -1; - if ((Car[iCarIndex].byLives & 0x80u) != 0)// Check if car is alive (bit 7 of byLives indicates death) + if ((Car[iCarIndex].byLives & 0x80u) != + 0) // Check if car is alive (bit 7 of byLives indicates death) iEnableSound = 0; if (DriveView[0] == 3 || DriveView[0] == 6) { if (iCarIndex == iFocusCarIndex || allengines) @@ -2890,7 +3052,8 @@ void enginesounds(int iFocusCarIndex) iChunkDiff += TRAK_LEN; if (iChunkDiff > TRAK_LEN / 2) iChunkDiff -= TRAK_LEN; - if ((int)abs(iChunkDiff) >= 40) // Cull car sounds if more than 40 chunks away + if ((int)abs(iChunkDiff) >= + 40) // Cull car sounds if more than 40 chunks away { enginesound(iCarIndex, 0.0, 0.0, 1048576.0, 0x8000); } else { @@ -2904,81 +3067,115 @@ void enginesounds(int iFocusCarIndex) fCarVelZ = pCurrentCar->direction.fZ; } else { pCarChunkData = &localdata[iCurrentCarChunk]; - fCarPosX = pCarChunkData->pointAy[0].fY * pCurrentCar->pos.fY - + pCarChunkData->pointAy[0].fX * pCurrentCar->pos.fX - + pCarChunkData->pointAy[0].fZ * pCurrentCar->pos.fZ - - pCarChunkData->pointAy[3].fX; - fCarPosY = pCarChunkData->pointAy[1].fY * pCurrentCar->pos.fY - + pCarChunkData->pointAy[1].fX * pCurrentCar->pos.fX - + pCarChunkData->pointAy[1].fZ * pCurrentCar->pos.fZ - - pCarChunkData->pointAy[3].fY; - fCarPosZ = pCarChunkData->pointAy[2].fY * pCurrentCar->pos.fY - + pCarChunkData->pointAy[2].fX * pCurrentCar->pos.fX - + pCarChunkData->pointAy[2].fZ * pCurrentCar->pos.fZ - - pCarChunkData->pointAy[3].fZ; + fCarPosX = pCarChunkData->pointAy[0].fY * pCurrentCar->pos.fY + + pCarChunkData->pointAy[0].fX * pCurrentCar->pos.fX + + pCarChunkData->pointAy[0].fZ * pCurrentCar->pos.fZ - + pCarChunkData->pointAy[3].fX; + fCarPosY = pCarChunkData->pointAy[1].fY * pCurrentCar->pos.fY + + pCarChunkData->pointAy[1].fX * pCurrentCar->pos.fX + + pCarChunkData->pointAy[1].fZ * pCurrentCar->pos.fZ - + pCarChunkData->pointAy[3].fY; + fCarPosZ = pCarChunkData->pointAy[2].fY * pCurrentCar->pos.fY + + pCarChunkData->pointAy[2].fX * pCurrentCar->pos.fX + + pCarChunkData->pointAy[2].fZ * pCurrentCar->pos.fZ - + pCarChunkData->pointAy[3].fZ; iYaw3 = pCurrentCar->nActualYaw; dCurrentCarSpeedCos = pCurrentCar->fFinalSpeed * tcos[iYaw3]; dCurrentCarSpeedSin = pCurrentCar->fFinalSpeed * tsin[iYaw3]; - fCarVelX = (float)(pCarChunkData->pointAy[0].fY * dCurrentCarSpeedSin + pCarChunkData->pointAy[0].fX * dCurrentCarSpeedCos); - fCarVelY = (float)(pCarChunkData->pointAy[1].fX * dCurrentCarSpeedCos + pCarChunkData->pointAy[1].fY * dCurrentCarSpeedSin); - fCarVelZ = (float)(dCurrentCarSpeedCos * pCarChunkData->pointAy[2].fX + dCurrentCarSpeedSin * pCarChunkData->pointAy[2].fY); + fCarVelX = + (float)(pCarChunkData->pointAy[0].fY * dCurrentCarSpeedSin + + pCarChunkData->pointAy[0].fX * dCurrentCarSpeedCos); + fCarVelY = + (float)(pCarChunkData->pointAy[1].fX * dCurrentCarSpeedCos + + pCarChunkData->pointAy[1].fY * dCurrentCarSpeedSin); + fCarVelZ = + (float)(dCurrentCarSpeedCos * pCarChunkData->pointAy[2].fX + + dCurrentCarSpeedSin * pCarChunkData->pointAy[2].fY); } - fRelativeX = fCarPosX - fX; // Calculate relative position vector from listener to car + fRelativeX = + fCarPosX - + fX; // Calculate relative position vector from listener to car fRelativeY = fCarPosY - fY; fRelativeZ = fCarPosZ - fZ; - fHorizontalDistance = fRelativeX * fRelativeX + fRelativeY * fRelativeY;// Calculate horizontal and total 3D distances + fHorizontalDistance = + fRelativeX * fRelativeX + + fRelativeY * + fRelativeY; // Calculate horizontal and total 3D distances fTotalDistance = fRelativeZ * fRelativeZ + fHorizontalDistance; fHorizontalDistance = (float)sqrt(fHorizontalDistance); fTotalDistance = (float)sqrt(fTotalDistance); - iHorizontalAngle = getangle(fRelativeX, fRelativeY);// Calculate horizontal and vertical angles for 3D positioning + iHorizontalAngle = getangle( + fRelativeX, fRelativeY); // Calculate horizontal and vertical + // angles for 3D positioning iVerticalAngle = getangle(fHorizontalDistance, fRelativeZ); - fListenerDopplerVel = (fListenerDirX * tcos[iHorizontalAngle] + fListenerDirY * tsin[iHorizontalAngle]) * tcos[iVerticalAngle] - + fListenerDirZ * tsin[iVerticalAngle];// Calculate Doppler velocities for listener and car - fCarDopplerVel = -(fCarVelX * tcos[iHorizontalAngle] + fCarVelY * tsin[iHorizontalAngle]) * tcos[iVerticalAngle] + fCarVelZ * tsin[iVerticalAngle]; + fListenerDopplerVel = + (fListenerDirX * tcos[iHorizontalAngle] + + fListenerDirY * tsin[iHorizontalAngle]) * + tcos[iVerticalAngle] + + fListenerDirZ * + tsin[iVerticalAngle]; // Calculate Doppler velocities for + // listener and car + fCarDopplerVel = -(fCarVelX * tcos[iHorizontalAngle] + + fCarVelY * tsin[iHorizontalAngle]) * + tcos[iVerticalAngle] + + fCarVelZ * tsin[iVerticalAngle]; if (DriveView[0] == 3 || DriveView[0] == 6) { iStereoVolume = 0x8000; } else { - fTransformedX = fRelativeX * fOrientMatrix_XX + fRelativeY * fOrientMatrix_YX + fRelativeZ * fOrientMatrix_ZZ;// Calculate stereo position using camera orientation matrix - fTempVolumeCalc = fRelativeX * fOrientMatrix_XY + fRelativeY * fOrientMatrix_YY + fRelativeZ * fOrientMatrix_ZX; - dVolumeCalc = (1.0 - tsin[getangle(fTransformedX, fTempVolumeCalc)]) * 32768.0; + fTransformedX = + fRelativeX * fOrientMatrix_XX + + fRelativeY * fOrientMatrix_YX + + fRelativeZ * + fOrientMatrix_ZZ; // Calculate stereo position using + // camera orientation matrix + fTempVolumeCalc = fRelativeX * fOrientMatrix_XY + + fRelativeY * fOrientMatrix_YY + + fRelativeZ * fOrientMatrix_ZX; + dVolumeCalc = + (1.0 - tsin[getangle(fTransformedX, fTempVolumeCalc)]) * + 32768.0; //_CHP(); iStereoVolume = (int)dVolumeCalc; if ((int)dVolumeCalc >= 0x10000) iStereoVolume = 0xFFFF; } - enginesound(iCarIndex, fListenerDopplerVel, fCarDopplerVel, fTotalDistance, iStereoVolume);// Output final engine sound with calculated parameters + enginesound(iCarIndex, fListenerDopplerVel, fCarDopplerVel, + fTotalDistance, + iStereoVolume); // Output final engine sound with + // calculated parameters } } ++iCarIndex; ++pCurrentCar; } while (iCarIndex < numcars); } - ++delaywrite; // Advance to next delay buffer frame for next iteration + ++delaywrite; // Advance to next delay buffer frame for next iteration } } //------------------------------------------------------------------------------------------------- -//0003D990 -void loopsample(int iCarIdx, int iSample, int iVolume, int iPitch, int iPan) -{ - //int iCarOffset; // ebx - //int iCarOffset2; // ebx +// 0003D990 +void loopsample(int iCarIdx, int iSample, int iVolume, int iPitch, int iPan) { + // int iCarOffset; // ebx + // int iCarOffset2; // ebx unsigned int iSampleHandle; // edx - int iVolumeFixed; // esi - int iPitchFixed; // ecx - int iCarIdx2; // ebp - int iPanFixed; // [esp+14h] [ebp+4h] + int iVolumeFixed; // esi + int iPitchFixed; // ecx + int iCarIdx2; // ebp + int iPanFixed; // [esp+14h] [ebp+4h] if (soundon && SamplePtr[iSample]) { - //iCarOffset = 4 * iCarIdx + (iSample << 6); - // *(int *)((char *)SampleHandleCar[0].handles + iCarOffset) = SampleHandleCar[iSampleIdx].handles[iCarIdx]; + // iCarOffset = 4 * iCarIdx + (iSample << 6); + // *(int *)((char *)SampleHandleCar[0].handles + iCarOffset) = + // SampleHandleCar[iSampleIdx].handles[iCarIdx]; if (SampleHandleCar[iSample].handles[iCarIdx] == -1 || iVolume) { - //iCarOffset2 = (iSample << 6) + 4 * iCarIdx; + // iCarOffset2 = (iSample << 6) + 4 * iCarIdx; iSampleHandle = SampleHandleCar[iSample].handles[iCarIdx]; if (iSampleHandle == -1) { // Start new sample playback if (iVolume) - sample2(iCarIdx, iSample, iVolume, iPitch, iPan, SampleHandleCar[iSample].handles[iCarIdx]); + sample2(iCarIdx, iSample, iVolume, iPitch, iPan, + SampleHandleCar[iSample].handles[iCarIdx]); } else if (iVolume) { // Clamp pitch value between 0x800 and 0x80000 if (iPitch < 0x800) @@ -2987,26 +3184,29 @@ void loopsample(int iCarIdx, int iSample, int iVolume, int iPitch, int iPan) iPitch = 0x80000; // Convert parameters to fixed-point format - iVolumeFixed = iVolume >> 10; // convert to 10.6 fixed-point - iPitchFixed = iPitch >> 10; // convert to 10.6 fixed-point - iPanFixed = iPan >> 12; // convert to 4.12 fixed-point + iVolumeFixed = iVolume >> 10; // convert to 10.6 fixed-point + iPitchFixed = iPitch >> 10; // convert to 10.6 fixed-point + iPanFixed = iPan >> 12; // convert to 4.12 fixed-point // Update volume if changed if (iVolumeFixed != lastvolume[iCarIdx]) { - DIGISetSampleVolume(SampleHandleCar[iSample].handles[iCarIdx], (int16)iVolumeFixed << 10); + DIGISetSampleVolume(SampleHandleCar[iSample].handles[iCarIdx], + (int16)iVolumeFixed << 10); lastvolume[iCarIdx] = iVolumeFixed; } // Update pitch if changed if (iPitchFixed != lastpitch[iCarIdx]) { - DIGISetPitch(SampleHandleCar[iSample].handles[iCarIdx], iPitchFixed << 10); + DIGISetPitch(SampleHandleCar[iSample].handles[iCarIdx], + iPitchFixed << 10); lastpitch[iCarIdx] = iPitchFixed; } // Update pan if changed iCarIdx2 = iCarIdx; if (iPanFixed != lastpan[iCarIdx2]) { - DIGISetPanLocation(SampleHandleCar[iSample].handles[iCarIdx2], (int16)iPanFixed << 12); + DIGISetPanLocation(SampleHandleCar[iSample].handles[iCarIdx2], + (int16)iPanFixed << 12); lastpan[iCarIdx2] = iPanFixed; } } else { @@ -3024,108 +3224,147 @@ void loopsample(int iCarIdx, int iSample, int iVolume, int iPitch, int iPan) } //------------------------------------------------------------------------------------------------- -//0003DB40 -void enginesound(int iCarIdx, float fListenerDopplerVel, float fCarDopplerVel, float fDistance, int iStereoVolume) -{ - double dVolumeCalc; // st7 - double dBasePitch; // st7 - double dWheelSpinPitch; // st7 - double dFinalEnginePitch; // st7 - int iCurrChunk; // edx - int iPrevChunkIdx; // edx - int iNextChunkIdx; // edx - double dTunnelDistanceTemp; // st7 - float fMinTunnelDistance; // eax - int iCarOffset; // edx - int iYaw; // edx - int iYaw3; // ebx - int iYawDifference; // eax - int iAbsYawDifference; // eax - double dSkidVolumeBase; // st7 +// 0003DB40 +void enginesound(int iCarIdx, float fListenerDopplerVel, float fCarDopplerVel, + float fDistance, int iStereoVolume) { + double dVolumeCalc; // st7 + double dBasePitch; // st7 + double dWheelSpinPitch; // st7 + double dFinalEnginePitch; // st7 + int iCurrChunk; // edx + int iPrevChunkIdx; // edx + int iNextChunkIdx; // edx + double dTunnelDistanceTemp; // st7 + float fMinTunnelDistance; // eax + int iCarOffset; // edx + int iYaw; // edx + int iYaw3; // ebx + int iYawDifference; // eax + int iAbsYawDifference; // eax + double dSkidVolumeBase; // st7 double dSkidVolumeWithSpeed; // st7 - double dFinalSkidVolume; // st7 - //int iCarStructOffset; // eax + double dFinalSkidVolume; // st7 + // int iCarStructOffset; // eax double dSkidPitchCalc; // st7 - //int iPendingSampleOffset; // ecx - //int iCarIndexCopy; // ebp - //int iPendingCounter; // esi - //int i; // ecx - //double dSampleVolume; // st7 - float fTunnelDistance; // [esp+Ch] [ebp-4Ch] - float fDopplerFactor; // [esp+10h] [ebp-48h] - int iTunnelFlag; // [esp+14h] [ebp-44h] - int iLaneType; // [esp+18h] [ebp-40h] - float fHealthFactor; // [esp+20h] [ebp-38h] - int iBaseEngineVolume; // [esp+24h] [ebp-34h] - int iCalculatedEngineVolume; // [esp+24h] [ebp-34h] - int iFinalEngineVolume; // [esp+24h] [ebp-34h] - int iSkidBaseVolume; // [esp+28h] [ebp-30h] - int iSkidVolumeWithSpeed; // [esp+28h] [ebp-30h] - int iFinalSkidVolume; // [esp+28h] [ebp-30h] - int iFinalPitch; // [esp+2Ch] [ebp-2Ch] - float fDistanceAttenuation; // [esp+30h] [ebp-28h] - float fTunnelDistanceBack; // [esp+34h] [ebp-24h] + // int iPendingSampleOffset; // ecx + // int iCarIndexCopy; // ebp + // int iPendingCounter; // esi + // int i; // ecx + // double dSampleVolume; // st7 + float fTunnelDistance; // [esp+Ch] [ebp-4Ch] + float fDopplerFactor; // [esp+10h] [ebp-48h] + int iTunnelFlag; // [esp+14h] [ebp-44h] + int iLaneType; // [esp+18h] [ebp-40h] + float fHealthFactor; // [esp+20h] [ebp-38h] + int iBaseEngineVolume; // [esp+24h] [ebp-34h] + int iCalculatedEngineVolume; // [esp+24h] [ebp-34h] + int iFinalEngineVolume; // [esp+24h] [ebp-34h] + int iSkidBaseVolume; // [esp+28h] [ebp-30h] + int iSkidVolumeWithSpeed; // [esp+28h] [ebp-30h] + int iFinalSkidVolume; // [esp+28h] [ebp-30h] + int iFinalPitch; // [esp+2Ch] [ebp-2Ch] + float fDistanceAttenuation; // [esp+30h] [ebp-28h] + float fTunnelDistanceBack; // [esp+34h] [ebp-24h] float fTunnelDistanceForward; // [esp+38h] [ebp-20h] - //int iPendingSampleVolume; // [esp+3Ch] [ebp-1Ch] + // int iPendingSampleVolume; // [esp+3Ch] [ebp-1Ch] if (soundon) { - fDopplerFactor = (fListenerDopplerVel + 1476.0f) / (1476.0f - fCarDopplerVel);// Calculate Doppler effect factor (sound speed / (sound speed - source velocity)) - fDistanceAttenuation = 65536000.0f / (fDistance * fDistance + 65536000.0f);// Calculate distance attenuation factor (inverse square law with minimum) - if (Car[iCarIdx].fRPMRatio >= 0.1) // Calculate base engine volume based on RPM ratio + fDopplerFactor = + (fListenerDopplerVel + 1476.0f) / + (1476.0f - fCarDopplerVel); // Calculate Doppler effect factor (sound + // speed / (sound speed - source velocity)) + fDistanceAttenuation = + 65536000.0f / (fDistance * fDistance + + 65536000.0f); // Calculate distance attenuation factor + // (inverse square law with minimum) + if (Car[iCarIdx].fRPMRatio >= + 0.1) // Calculate base engine volume based on RPM ratio { iBaseEngineVolume = 258 * EngineVolume; } else { - dVolumeCalc = Car[iCarIdx].fRPMRatio * 258.0 * 10.0 * (double)EngineVolume; + dVolumeCalc = + Car[iCarIdx].fRPMRatio * 258.0 * 10.0 * (double)EngineVolume; //_CHP(); iBaseEngineVolume = (int)dVolumeCalc; } - iCalculatedEngineVolume = (Car[iCarIdx].iEngineState * iBaseEngineVolume) / 8; - //iCalculatedEngineVolume = (Car[iCarIdx].iEngineState * iBaseEngineVolume - // - (__CFSHL__((Car[iCarIdx].iEngineState * iBaseEngineVolume) >> 31, 3) - // + 8 * ((Car[iCarIdx].iEngineState * iBaseEngineVolume) >> 31))) >> 3;// Apply engine state modifier to volume (divide by 8) + iCalculatedEngineVolume = + (Car[iCarIdx].iEngineState * iBaseEngineVolume) / 8; + // iCalculatedEngineVolume = (Car[iCarIdx].iEngineState * iBaseEngineVolume + // - (__CFSHL__((Car[iCarIdx].iEngineState * + // iBaseEngineVolume) >> 31, 3) + // + 8 * ((Car[iCarIdx].iEngineState * + // iBaseEngineVolume) >> 31))) >> 3;// Apply + // engine state modifier to volume (divide by 8) if (iCalculatedEngineVolume > 0x7FFF) iCalculatedEngineVolume = 0x7FFF; //_CHP(); - iFinalEngineVolume = (int)((double)iCalculatedEngineVolume * fDistanceAttenuation); + iFinalEngineVolume = + (int)((double)iCalculatedEngineVolume * fDistanceAttenuation); if (iFinalEngineVolume < 256) iFinalEngineVolume = 0; if (fDistance >= 1048576.0) iFinalEngineVolume = 0; - dBasePitch = Car[iCarIdx].fRPMRatio * 100000.0 + 8192.0;// Calculate engine pitch: base RPM + wheel spin effect + dBasePitch = Car[iCarIdx].fRPMRatio * 100000.0 + + 8192.0; // Calculate engine pitch: base RPM + wheel spin effect //_CHP(); - dWheelSpinPitch = Car[iCarIdx].fWheelSpinAccumulation * 50000.0 / (Car[iCarIdx].fWheelSpinAccumulation + 2000.0) + (double)(int)dBasePitch; + dWheelSpinPitch = Car[iCarIdx].fWheelSpinAccumulation * 50000.0 / + (Car[iCarIdx].fWheelSpinAccumulation + 2000.0) + + (double)(int)dBasePitch; //_CHP(); - fHealthFactor = (Car[iCarIdx].fHealth + 34.0f) * 0.01f;// Calculate health factor for engine roughness (damaged cars sound rougher) + fHealthFactor = (Car[iCarIdx].fHealth + 34.0f) * + 0.01f; // Calculate health factor for engine roughness + // (damaged cars sound rougher) if (fHealthFactor > 1.0) fHealthFactor = 1.0; - dFinalEnginePitch = tsin[Car[iCarIdx].iEngineVibrateOffset] * (1.0 - fHealthFactor) * 10000.0 + (double)(6 * Car[iCarIdx].iPitchCameraOffset + (int)dWheelSpinPitch);// Add engine vibration/roughness based on health and camera offset + dFinalEnginePitch = + tsin[Car[iCarIdx].iEngineVibrateOffset] * (1.0 - fHealthFactor) * + 10000.0 + + (double)(6 * Car[iCarIdx].iPitchCameraOffset + + (int)dWheelSpinPitch); // Add engine vibration/roughness based + // on health and camera offset //_CHP(); //_CHP(); iTunnelFlag = 0; iCurrChunk = Car[iCarIdx].nCurrChunk; iLaneType = Car[iCarIdx].iLaneType; iFinalPitch = (int)(dFinalEnginePitch * fDopplerFactor); - if (iCurrChunk != -1 && (TrakColour[iCurrChunk][iLaneType] & SURFACE_FLAG_ECHO) != 0)// Check if car is in tunnel section (bit 29 of TrakColour) + if (iCurrChunk != -1 && + (TrakColour[iCurrChunk][iLaneType] & SURFACE_FLAG_ECHO) != + 0) // Check if car is in tunnel section (bit 29 of TrakColour) { iTunnelFlag = -1; - fTunnelDistanceBack = localdata[iCurrChunk].fTrackHalfLength + Car[iCarIdx].pos.fX;// Calculate tunnel distance going backward through track + fTunnelDistanceBack = + localdata[iCurrChunk].fTrackHalfLength + + Car[iCarIdx] + .pos.fX; // Calculate tunnel distance going backward through track iPrevChunkIdx = iCurrChunk - 1; if (!iPrevChunkIdx) iPrevChunkIdx = TRAK_LEN - 1; - //iPrevChunkIdx check added by ROLLER - while (iPrevChunkIdx >= 0 && (TrakColour[iPrevChunkIdx][iLaneType] & SURFACE_FLAG_ECHO) != 0 && fTunnelDistanceBack < 6400.0) { - fTunnelDistanceBack = 2.0f * localdata[iPrevChunkIdx--].fTrackHalfLength + fTunnelDistanceBack; + // iPrevChunkIdx check added by ROLLER + while (iPrevChunkIdx >= 0 && + (TrakColour[iPrevChunkIdx][iLaneType] & SURFACE_FLAG_ECHO) != 0 && + fTunnelDistanceBack < 6400.0) { + fTunnelDistanceBack = + 2.0f * localdata[iPrevChunkIdx--].fTrackHalfLength + + fTunnelDistanceBack; if (!iPrevChunkIdx) iPrevChunkIdx = TRAK_LEN - 1; } - iNextChunkIdx = Car[iCarIdx].nCurrChunk + 1;// Calculate tunnel distance going forward through track - fTunnelDistanceForward = localdata[Car[iCarIdx].nCurrChunk].fTrackHalfLength - Car[iCarIdx].pos.fX; + iNextChunkIdx = + Car[iCarIdx].nCurrChunk + + 1; // Calculate tunnel distance going forward through track + fTunnelDistanceForward = + localdata[Car[iCarIdx].nCurrChunk].fTrackHalfLength - + Car[iCarIdx].pos.fX; if (iNextChunkIdx == TRAK_LEN) iNextChunkIdx ^= TRAK_LEN; - while ((TrakColour[iNextChunkIdx][iLaneType] & SURFACE_FLAG_ECHO) != 0 && fTunnelDistanceForward < 6400.0) { - dTunnelDistanceTemp = 2.0 * localdata[iNextChunkIdx++].fTrackHalfLength + fTunnelDistanceForward; + while ((TrakColour[iNextChunkIdx][iLaneType] & SURFACE_FLAG_ECHO) != 0 && + fTunnelDistanceForward < 6400.0) { + dTunnelDistanceTemp = + 2.0 * localdata[iNextChunkIdx++].fTrackHalfLength + + fTunnelDistanceForward; fTunnelDistanceForward = (float)dTunnelDistanceTemp; if (iNextChunkIdx == TRAK_LEN) iNextChunkIdx ^= TRAK_LEN; @@ -3139,49 +3378,72 @@ void enginesound(int iCarIdx, float fListenerDopplerVel, float fCarDopplerVel, f fTunnelDistance = 6400.0; } iCarOffset = 32 * iCarIdx; - enginedelay[iCarIdx].engineSoundData[delaywritex].iPan = iStereoVolume;// Write engine sound data to delay buffer - enginedelay[iCarIdx].engineSoundData[delaywritex].iEnginePitch = iFinalPitch; - enginedelay[iCarIdx].engineSoundData[delaywritex].iEngineVol = iFinalEngineVolume; - enginedelay[iCarIdx].engineSoundData[delaywritex].iEngine2Pitch = iFinalPitch; + enginedelay[iCarIdx].engineSoundData[delaywritex].iPan = + iStereoVolume; // Write engine sound data to delay buffer + enginedelay[iCarIdx].engineSoundData[delaywritex].iEnginePitch = + iFinalPitch; + enginedelay[iCarIdx].engineSoundData[delaywritex].iEngineVol = + iFinalEngineVolume; + enginedelay[iCarIdx].engineSoundData[delaywritex].iEngine2Pitch = + iFinalPitch; if (iTunnelFlag) { - //_CHP(); // Apply tunnel reverb effect to secondary engine sound - enginedelay[iCarIdx].engineSoundData[delaywritex].iEngine2Vol = (int)(fTunnelDistance * 0.6 * 0.00015625 * (double)iFinalEngineVolume); + //_CHP(); // Apply tunnel reverb effect + // to secondary engine sound + enginedelay[iCarIdx].engineSoundData[delaywritex].iEngine2Vol = + (int)(fTunnelDistance * 0.6 * 0.00015625 * + (double)iFinalEngineVolume); } else { enginedelay[iCarIdx].engineSoundData[delaywritex].iEngine2Vol = 0; } - if (Car[iCarIdx].iControlType != 3 || (iYaw = Car[iCarIdx].nYaw, iYaw3 = Car[iCarIdx].nActualYaw, iYaw == iYaw3)) { + if (Car[iCarIdx].iControlType != 3 || + (iYaw = Car[iCarIdx].nYaw, iYaw3 = Car[iCarIdx].nActualYaw, + iYaw == iYaw3)) { iFinalSkidVolume = 0; } else { - iYawDifference = iYaw - iYaw3 + (iYaw - iYaw3 < 0 ? 0x4000 : 0);// Calculate angular difference between input yaw and actual yaw + iYawDifference = + iYaw - iYaw3 + + (iYaw - iYaw3 < 0 ? 0x4000 : 0); // Calculate angular difference + // between input yaw and actual yaw if (iYawDifference > 0x2000) iYawDifference -= 0x4000; iAbsYawDifference = abs(iYawDifference); - if (iAbsYawDifference >= 200) // Calculate skid volume based on angular mismatch (understeer/oversteer) + if (iAbsYawDifference >= 200) // Calculate skid volume based on angular + // mismatch (understeer/oversteer) { - dSkidVolumeBase = (double)(iAbsYawDifference - 400) * 65536.0 * 4.0 * 0.00006103515625; + dSkidVolumeBase = (double)(iAbsYawDifference - 400) * 65536.0 * 4.0 * + 0.00006103515625; //_CHP(); iSkidBaseVolume = (int)dSkidVolumeBase; } else { iSkidBaseVolume = 0; } - dSkidVolumeWithSpeed = (double)iSkidBaseVolume * Car[iCarIdx].fFinalSpeed * 0.0049999999;// Apply speed factor to skid volume (louder at higher speeds) + dSkidVolumeWithSpeed = (double)iSkidBaseVolume * + Car[iCarIdx].fFinalSpeed * + 0.0049999999; // Apply speed factor to skid volume + // (louder at higher speeds) //_CHP(); iSkidVolumeWithSpeed = (int)dSkidVolumeWithSpeed; if ((int)dSkidVolumeWithSpeed > 0x7FFF) iSkidVolumeWithSpeed = 0x7FFF; - dFinalSkidVolume = (double)(SFXVolume * iSkidVolumeWithSpeed / 127) * fDistanceAttenuation; + dFinalSkidVolume = (double)(SFXVolume * iSkidVolumeWithSpeed / 127) * + fDistanceAttenuation; //_CHP(); iFinalSkidVolume = (int)dFinalSkidVolume; if ((int)dFinalSkidVolume < 256) iFinalSkidVolume = 0; - //_CHP(); // DECOMPILER BUG: Missing iCarStructOffset = iCarIdx * 0x134 (sizeof(tCar)=308) - dSkidPitchCalc = (Car[iCarIdx].fFinalSpeed + 6400.0) * 0.00015625 * (double)(int)(fDopplerFactor * 65536.0); - //dSkidPitchCalc = (*(float *)((char *)&Car[0].fFinalSpeed + iCarStructOffset) + 6400.0) * 0.00015625 * (double)(int)(fDopplerFactor * 65536.0); - //_CHP(); + //_CHP(); // DECOMPILER BUG: Missing + // iCarStructOffset = iCarIdx * 0x134 (sizeof(tCar)=308) + dSkidPitchCalc = (Car[iCarIdx].fFinalSpeed + 6400.0) * 0.00015625 * + (double)(int)(fDopplerFactor * 65536.0); + // dSkidPitchCalc = (*(float *)((char *)&Car[0].fFinalSpeed + + // iCarStructOffset) + 6400.0) * 0.00015625 * (double)(int)(fDopplerFactor + // * 65536.0); _CHP(); iFinalPitch = (int)dSkidPitchCalc; } - enginedelay[iCarIdx].engineSoundData[delaywritex].iSkid1Pitch = iFinalPitch;// Write tire skid sound data to delay buffer - enginedelay[iCarIdx].engineSoundData[delaywritex].iSkid1Vol = iFinalSkidVolume; + enginedelay[iCarIdx].engineSoundData[delaywritex].iSkid1Pitch = + iFinalPitch; // Write tire skid sound data to delay buffer + enginedelay[iCarIdx].engineSoundData[delaywritex].iSkid1Vol = + iFinalSkidVolume; // Process pending sound effects for this car int iPendingCount = Pending[iCarIdx]; @@ -3203,27 +3465,28 @@ void enginesound(int iCarIdx, float fListenerDopplerVel, float fCarDopplerVel, f // Clear pending sample count for next frame Pending[iCarIdx] = 0; - //iPendingSampleOffset = 5 * iCarIdx; // Process pending sound effects for this car - //iCarIndexCopy = iCarIdx; - //iPendingCounter = 0; - //for (i = 8 * iPendingSampleOffset; iPendingCounter < Pending[iCarIndexCopy]; i += 2) { - // iPendingSampleVolume = SamplePending[0][i + 1]; - // if (iPendingSampleVolume > 0x8000) - // iPendingSampleVolume = 0x8000; - // dSampleVolume = (double)iPendingSampleVolume * fDistanceAttenuation;// Apply distance attenuation to sample and output if loud enough - // //_CHP(); - // if ((int)dSampleVolume >= 256) - // pannedsample(SamplePending[0][i], (int)dSampleVolume, iStereoVolume); - // ++iPendingCounter; - //} - //Pending[iCarIndexCopy] = 0; // Clear pending sample count for next frame + // iPendingSampleOffset = 5 * iCarIdx; // Process pending sound + // effects for this car iCarIndexCopy = iCarIdx; iPendingCounter = 0; for (i + // = 8 * iPendingSampleOffset; iPendingCounter < Pending[iCarIndexCopy]; i + // += 2) { + // iPendingSampleVolume = SamplePending[0][i + 1]; + // if (iPendingSampleVolume > 0x8000) + // iPendingSampleVolume = 0x8000; + // dSampleVolume = (double)iPendingSampleVolume * fDistanceAttenuation;// + // Apply distance attenuation to sample and output if loud enough + // //_CHP(); + // if ((int)dSampleVolume >= 256) + // pannedsample(SamplePending[0][i], (int)dSampleVolume, iStereoVolume); + // ++iPendingCounter; + // } + // Pending[iCarIndexCopy] = 0; // Clear pending sample count + // for next frame } } //------------------------------------------------------------------------------------------------- -//0003E1C0 -void startmusic(int iSong) -{ +// 0003E1C0 +void startmusic(int iSong) { g_iCurrentSong = iSong; int musicOrTitle = 0; if (MusicCD && track_playing) { @@ -3270,13 +3533,14 @@ void startmusic(int iSong) if (musicon) { uint32_t musiclength; - loadfile((const char *)&Song[GMSong[iMusic]], (void *)&musicbuffer, &musiclength, 0); + loadfile((const char *)&Song[GMSong[iMusic]], (void *)&musicbuffer, + &musiclength, 0); SongPtr = musicbuffer; if (musicbuffer) { // Init song in the MIDI system tInitSong InitSong = { - .pData = (void *)musicbuffer, - .iLength = musiclength, + .pData = (void *)musicbuffer, + .iLength = musiclength, }; MIDIInitSong(&InitSong); fre((void **)&musicbuffer); @@ -3288,34 +3552,33 @@ void startmusic(int iSong) } //------------------------------------------------------------------------------------------------- -//0003E370 -void stopmusic() -{ +// 0003E370 +void stopmusic() { if (MusicCD && track_playing) { StopTrack(); } else if (MusicCard && SongPtr) { if (MusicCard) { if (SongPtr) { - //sosMIDIStopSong(SongHandle); - //sosMIDIResetSong(SongHandle); + // sosMIDIStopSong(SongHandle); + // sosMIDIResetSong(SongHandle); MIDIStopSong(); } } - //sosMIDIUnInitSong(*(unsigned int *)&SongHandle); + // sosMIDIUnInitSong(*(unsigned int *)&SongHandle); SongPtr = 0; } } //------------------------------------------------------------------------------------------------- -//0003E3E0 -void load_language_map() -{ +// 0003E3E0 +void load_language_map() { FILE *pFile; int i; // open file pFile = ROLLERfopen("LANGUAGE.INI", "r"); - if (!pFile) return; + if (!pFile) + return; // read number of languages into languages readline(pFile, "i", &languages); @@ -3336,8 +3599,8 @@ void load_language_map() readline(pFile, "ccc", szLangPtr, szTextExtPtr, szSampleExtPtr); // Move pointers forward to next slots - szLangPtr += 32; // Each lang entry is 32 bytes - szTextExtPtr += 4; // Each extension is 4 bytes + szLangPtr += 32; // Each lang entry is 32 bytes + szTextExtPtr += 4; // Each extension is 4 bytes szSampleExtPtr += 4; } @@ -3346,11 +3609,11 @@ void load_language_map() } //------------------------------------------------------------------------------------------------- -//0003E460 -void initmusic() -{ +// 0003E460 +void initmusic() { FILE *pFile = ROLLERfopen("SOUND.INI", "r"); - if (!pFile) return; + if (!pFile) + return; readline(pFile, "i", &numsamples); int iSongCount = 0; @@ -3364,7 +3627,8 @@ void initmusic() // add extension ".RAW" char *szEnd = &szBuf[strlen(szBuf)]; - if (szEnd) strcpy(szEnd, ".RAW"); + if (szEnd) + strcpy(szEnd, ".RAW"); strncpy(Sample[i], szBuf, 15); Sample[i][14] = '\0'; @@ -3377,7 +3641,8 @@ void initmusic() // add extension ".HMP" char *szEnd = &szBuf[strlen(szBuf)]; - if (szEnd) strcpy(szEnd, ".HMP"); + if (szEnd) + strcpy(szEnd, ".HMP"); strncpy(Song[i], szBuf, 15); Song[i][14] = '\0'; @@ -3399,22 +3664,19 @@ void initmusic() } //------------------------------------------------------------------------------------------------- -//0003E670 -void SOSTimerCallbackS7() -{ - ++s7; -} +// 0003E670 +void SOSTimerCallbackS7() { ++s7; } //------------------------------------------------------------------------------------------------- -//0003E680 -void fade_palette(int iTargetBrightness) -{ +// 0003E680 +void fade_palette(int iTargetBrightness) { if (g_bSnapshotMode) { // In snapshot capture, fade animations are skipped: PNGs are the raw // pixels with the active palette. Keep palette_brightness in sync and // signal that the palette is valid so the snapshot hook will write. palette_brightness = iTargetBrightness; - if (pal_addr) g_bPaletteSet = true; + if (pal_addr) + g_bPaletteSet = true; return; } int iOriginalTickOn = tick_on; @@ -3425,7 +3687,7 @@ void fade_palette(int iTargetBrightness) disable_keyboard(); if (iTargetBrightness == 32 && soundon) { - //sosDIGISetMasterVolume(DIGIHandle, 0x7FFF); + // sosDIGISetMasterVolume(DIGIHandle, 0x7FFF); DIGISetMasterVolume(0x7FFF); // Set max volume for sound effects } @@ -3438,11 +3700,12 @@ void fade_palette(int iTargetBrightness) s7 = 0; if (current_mode != 0) { - uiTimerHandle = ROLLERAddTimer(70, SDLS7TimerCallback, NULL); //added by ROLLER + uiTimerHandle = + ROLLERAddTimer(70, SDLS7TimerCallback, NULL); // added by ROLLER } if (iTargetBrightness > iCurrentBrightness) { - // FADE IN LOOP + // FADE IN LOOP for (int iStep = iCurrentBrightness; iStep <= iTargetBrightness; iStep++) { for (int i = 0; i < 256; i++) { pal_addr[i].byR = (palette[i].byR * iStep) >> 5; @@ -3451,36 +3714,37 @@ void fade_palette(int iTargetBrightness) } if (current_mode != 0 && !g_bSnapshotMode) { - //could also do this instead of SDL timer - //uint32 uiStartTime = SDL_GetTicks(); - //while (SDL_GetTicks() - uiStartTime < 70) { - // SDL_Delay(1); - //} + // could also do this instead of SDL timer + // uint32 uiStartTime = SDL_GetTicks(); + // while (SDL_GetTicks() - uiStartTime < 70) { + // SDL_Delay(1); + // } int iPrev = s7; - while (s7 == iPrev); // Wait for timer tick + while (s7 == iPrev) + ; // Wait for timer tick } else { - //wait for retrace - //aka VSYNC for DOS + // wait for retrace + // aka VSYNC for DOS } - //set dac palette + // set dac palette g_bPaletteSet = true; UpdateSDL(); UpdateSDLWindow(); } } else { - // FADE OUT LOOP + // FADE OUT LOOP int iVolumeStep = (iTargetBrightness << 15) - iTargetBrightness; for (int iStep = iCurrentBrightness; iStep >= iTargetBrightness; iStep--) { if (iTargetBrightness == 0 && !holdmusic) { if (musicon) { - //sosMIDISetMasterVolume(((MusicVolume * iStep) >> 5) & 0xFF); + // sosMIDISetMasterVolume(((MusicVolume * iStep) >> 5) & 0xFF); MIDISetMasterVolume(((MusicVolume * iStep) >> 5) & 0xFF); } if (soundon) { - //sosDIGISetMasterVolume(DIGIHandle, (iVolumeStep >> 5)); + // sosDIGISetMasterVolume(DIGIHandle, (iVolumeStep >> 5)); DIGISetMasterVolume(iVolumeStep >> 5); } @@ -3497,13 +3761,14 @@ void fade_palette(int iTargetBrightness) if (current_mode != 0 && !g_bSnapshotMode) { int iPrevS7 = s7; - while (s7 == iPrevS7); // Wait for timer tick + while (s7 == iPrevS7) + ; // Wait for timer tick } else { - //wait for retrace - //aka VSYNC for DOS + // wait for retrace + // aka VSYNC for DOS } - //set dac palette + // set dac palette g_bPaletteSet = true; UpdateSDL(); UpdateSDLWindow(); @@ -3513,11 +3778,12 @@ void fade_palette(int iTargetBrightness) } if (current_mode != 0) { - ROLLERRemoveTimer(uiTimerHandle); //added by ROLLER + ROLLERRemoveTimer(uiTimerHandle); // added by ROLLER } - //memcpy(pal_addr, palette, 768); //REMOVED by ROLLER (why is this here? causes palette change flicker) - + // memcpy(pal_addr, palette, 768); //REMOVED by ROLLER (why is this here? + // causes palette change flicker) + palette_brightness = iTargetBrightness; tick_on = iOriginalTickOn; ticks = iOriginalTicks; @@ -3530,7 +3796,7 @@ void fade_palette(int iTargetBrightness) StopTrack(); else if (MusicCard && SongPtr) { stop(); - //sosMIDIUnInitSong(SongHandle); + // sosMIDIUnInitSong(SongHandle); SongPtr = 0; } } @@ -3538,42 +3804,46 @@ void fade_palette(int iTargetBrightness) //------------------------------------------------------------------------------------------------- -void fade_music_start(int iTargetBrightness) -{ - if (iTargetBrightness == 32 && soundon) { - DIGISetMasterVolume(0x7FFF); - } +void fade_music_start(int iTargetBrightness) { + if (iTargetBrightness == 32 && soundon) { + DIGISetMasterVolume(0x7FFF); + } } -void fade_music_step(int iStep) -{ - if (holdmusic) return; - if (musicon) - MIDISetMasterVolume(((MusicVolume * iStep) >> 5) & 0xFF); - if (soundon) { - int iVolumeStep = (iStep << 15) - iStep; - DIGISetMasterVolume(iVolumeStep >> 5); - } - if (MusicCD) - SetAudioVolume(((MusicVolume * iStep) >> 5) & 0xFF); +void fade_music_step(int iStep) { + if (holdmusic) + return; + if (musicon) + MIDISetMasterVolume(((MusicVolume * iStep) >> 5) & 0xFF); + if (soundon) { + int iVolumeStep = (iStep << 15) - iStep; + DIGISetMasterVolume(iVolumeStep >> 5); + } + if (MusicCD) + SetAudioVolume(((MusicVolume * iStep) >> 5) & 0xFF); } -void fade_music_finish(int iTargetBrightness) -{ - if (iTargetBrightness != 0 || holdmusic) return; - if (MusicCD && track_playing) StopTrack(); - else if (MusicCard && SongPtr) { stop(); SongPtr = 0; } +void fade_music_finish(int iTargetBrightness) { + if (iTargetBrightness != 0 || holdmusic) + return; + if (MusicCD && track_playing) + StopTrack(); + else if (MusicCard && SongPtr) { + stop(); + SongPtr = 0; + } } //------------------------------------------------------------------------------------------------- -//0003EA00 -void set_palette(int iBrightness) -{ +// 0003EA00 +void set_palette(int iBrightness) { if (iBrightness == palette_brightness) return; - if (iBrightness < 0) iBrightness = 0; - if (iBrightness > 31) iBrightness = 31; + if (iBrightness < 0) + iBrightness = 0; + if (iBrightness > 31) + iBrightness = 31; for (int i = 0; i < 256; ++i) { pal_addr[i].byR = (palette[i].byR * iBrightness) / 31; @@ -3582,24 +3852,23 @@ void set_palette(int iBrightness) } // Update the SDL palette - //SDL_Color sdl_colors[256]; + // SDL_Color sdl_colors[256]; // - //for (int i = 0; i < 256; ++i) { + // for (int i = 0; i < 256; ++i) { // sdl_colors[i].r = pal_addr[i].r; // sdl_colors[i].g = pal_addr[i].g; // sdl_colors[i].b = pal_addr[i].b; // sdl_colors[i].a = 255; //} - //SDL_SetPaletteColors(sdl_palette, sdl_colors, 0, 256); + // SDL_SetPaletteColors(sdl_palette, sdl_colors, 0, 256); palette_brightness = iBrightness; } //------------------------------------------------------------------------------------------------- -//0003EAB0 -void check_joystick_usage() -{ - int i; // eax +// 0003EAB0 +void check_joystick_usage() { + int i; // eax uint8 byKey1; // dl uint8 byKey2; // cl @@ -3616,9 +3885,8 @@ void check_joystick_usage() } //------------------------------------------------------------------------------------------------- -//0003EB20 -void convertname(char *szFilename) -{ +// 0003EB20 +void convertname(char *szFilename) { char szTemp[32]; char *p = szTemp; char *s = szFilename; @@ -3628,16 +3896,18 @@ void convertname(char *szFilename) // copy filename to temp buffer (word-wise copy, handling 2 bytes at a time) while (1) { *p++ = *s; - if (*s++ == '\0') break; + if (*s++ == '\0') + break; *p++ = *s; - if (*s++ == '\0') break; + if (*s++ == '\0') + break; } // check for cheat sample conversion if (cheat_samples && language == 0) { char *ext = strstr(szFilename, ".RAW"); if (ext) { - ext[1] = 'K'; // Change to ".KC" + ext[1] = 'K'; // Change to ".KC" ext[2] = 'C'; ext[3] = '\0'; @@ -3670,19 +3940,20 @@ void convertname(char *szFilename) p = szFilename; while (1) { *p++ = *s; - if (*s++ == '\0') break; + if (*s++ == '\0') + break; *p++ = *s; - if (*s++ == '\0') break; + if (*s++ == '\0') + break; } } //------------------------------------------------------------------------------------------------- -//0003EC40 -void decode(uint8 *pData, int iLength, uint32 uiStep, uint32 uiOffset) -{ - int i; // edx - uint8 byOriginal; // bh - uint8 byXorValue; // bl +// 0003EC40 +void decode(uint8 *pData, int iLength, uint32 uiStep, uint32 uiOffset) { + int i; // edx + uint8 byOriginal; // bh + uint8 byXorValue; // bl uint32 uiNextOffset; // [esp+0h] [ebp-Ch] for (i = 0; i < iLength; *(pData - 1) = byXorValue ^ byOriginal) { @@ -3697,9 +3968,8 @@ void decode(uint8 *pData, int iLength, uint32 uiStep, uint32 uiOffset) } //------------------------------------------------------------------------------------------------- -//0003EC70 -void loadasample(int iIndex) -{ +// 0003EC70 +void loadasample(int iIndex) { char szFilenameBuf[32]; // construct sample filename @@ -3707,7 +3977,8 @@ void loadasample(int iIndex) char *szDst = szFilenameBuf; while (*szSrc) { *szDst++ = *szSrc++; - if (!*szSrc) break; + if (!*szSrc) + break; *szDst++ = *szSrc++; } *szDst = '\0'; @@ -3716,7 +3987,7 @@ void loadasample(int iIndex) convertname(szFilenameBuf); SDL_Log("loadasample: %s\n", szFilenameBuf); // load file into memory - loadfile(szFilenameBuf, (void**)&SamplePtr[iIndex], &SampleLen[iIndex], 1); + loadfile(szFilenameBuf, (void **)&SamplePtr[iIndex], &SampleLen[iIndex], 1); // check if cheat sample flag is set and process if needed if (cheatsample && SamplePtr[iIndex]) { @@ -3747,7 +4018,7 @@ void loadasample(int iIndex) // if using 50Hz timer if (SamplePtr[iIndex] && (cheat_mode & CHEAT_MODE_50HZ_TIMER)) { - if (cheat_mode & CHEAT_MODE_100HZ_TIMER) { //100Hz timer + if (cheat_mode & CHEAT_MODE_100HZ_TIMER) { // 100Hz timer // halve the sample length, keep only even-indexed bytes int iLen = SampleLen[iIndex]; uint8 *pData = SamplePtr[iIndex]; @@ -3771,59 +4042,68 @@ void loadasample(int iIndex) } //------------------------------------------------------------------------------------------------- -//0003EE40 -void select8bitdriver() -{ - //TODO: integrate with SDL? - if (SoundCard) { // If previous driver was type 1, clean up existing audio resources +// 0003EE40 +void select8bitdriver() { + // TODO: integrate with SDL? + if (SoundCard) { // If previous driver was type 1, clean up existing audio + // resources if (drivertype == 1) { - //sosTIMERRemoveEvent(TimerEventHandle); // Remove existing timer event from SOS system - //sosDIGIUnInitDriver(DIGIHandle, 1, 1); // Uninitialize existing digital audio driver + // sosTIMERRemoveEvent(TimerEventHandle); // Remove existing timer + // event from SOS system sosDIGIUnInitDriver(DIGIHandle, 1, 1); // + // Uninitialize existing digital audio driver } - resetsamplearray(); // Reset internal sample array/buffer management - if (drivertype) // If any driver type was active, proceed with 8-bit driver initialization + resetsamplearray(); // Reset internal sample array/buffer management + if (drivertype) // If any driver type was active, proceed with 8-bit driver + // initialization { - drivertype = 0; // Set driver type to 0 (8-bit mode) and initialize driver configuration structure - //memset(&InitDriver, 0, sizeof(InitDriver)); - //InitDriver.dwBufferSize = 4096; // Configure audio parameters: 4096 buffer size, auto-detect (-1), 11025 Hz sample rate - //InitDriver.dwParam1 = -1; - //InitDriver.dwSampleRateHz = 11025; - //Hardware.dwPort = SoundPort; // Configure hardware settings: I/O port, IRQ, and DMA channel from global settings - //Hardware.dwIRQ = SoundIRQ; - //Hardware.dwDMA = SoundDMA; - //InitDriver.iUnk7 = 0; - //if (sosDIGIInitDriver( - // SoundCard, - // 0, - // (unsigned int)&Hardware, - // __DS__, - // (unsigned int)&InitDriver, - // (unsigned __int16)__DS__, - // (unsigned int)&DIGIHandle, - // (unsigned __int16)__DS__)) // Initialize SOS digital audio driver with configured parameters + drivertype = 0; // Set driver type to 0 (8-bit mode) and initialize driver + // configuration structure + // memset(&InitDriver, 0, sizeof(InitDriver)); + // InitDriver.dwBufferSize = 4096; // Configure audio + // parameters: 4096 buffer size, auto-detect (-1), 11025 Hz sample rate + // InitDriver.dwParam1 = -1; + // InitDriver.dwSampleRateHz = 11025; + // Hardware.dwPort = SoundPort; // Configure hardware + // settings: I/O port, IRQ, and DMA channel from global settings + // Hardware.dwIRQ = SoundIRQ; + // Hardware.dwDMA = SoundDMA; + // InitDriver.iUnk7 = 0; + // if (sosDIGIInitDriver( + // SoundCard, + // 0, + // (unsigned int)&Hardware, + // __DS__, + // (unsigned int)&InitDriver, + // (unsigned __int16)__DS__, + // (unsigned int)&DIGIHandle, + // (unsigned __int16)__DS__)) // Initialize SOS digital audio + // driver with configured parameters //{ - // sosDIGIUnInitSystem(); // If driver initialization failed, cleanup and disable sound card - // SoundCard = 0; - //} else { - // sosTIMERRegisterEvent(300u, 0x7FFF, (int)InitDriver.lpDriverMemoryCS, (__int16)InitDriver.lpTimerMemory, (unsigned int)&TimerEventHandle, (unsigned __int16)__DS__);// Driver initialized successfully: register timer event and set maximum volume - // sosDIGISetMasterVolume(DIGIHandle, 0x7FFFu);// Set digital audio master volume to maximum (0x7FFF) - //} + // sosDIGIUnInitSystem(); // If driver initialization + // failed, cleanup and disable sound card SoundCard = 0; + // } else { + // sosTIMERRegisterEvent(300u, 0x7FFF, (int)InitDriver.lpDriverMemoryCS, + // (__int16)InitDriver.lpTimerMemory, (unsigned int)&TimerEventHandle, + // (unsigned __int16)__DS__);// Driver initialized successfully: + // register timer event and set maximum volume + // sosDIGISetMasterVolume(DIGIHandle, 0x7FFFu);// Set digital audio + // master volume to maximum (0x7FFF) + // } } } } //------------------------------------------------------------------------------------------------- -//0003EF50 -void resetsamplearray() -{ - //int iNumCars; // ebx - //int i; // ecx - //int iCar; // edx - //int iEngineDelayOffset; // eax - //int iSampleOffset; // eax - //unsigned int iSampleHandleCarOffset; // esi - //int j; // ecx - //int iHandleOffset; // eax +// 0003EF50 +void resetsamplearray() { + // int iNumCars; // ebx + // int i; // ecx + // int iCar; // edx + // int iEngineDelayOffset; // eax + // int iSampleOffset; // eax + // unsigned int iSampleHandleCarOffset; // esi + // int j; // ecx + // int iHandleOffset; // eax for (int i = 0; i < numcars; ++i) { for (int j = 0; j < 32; ++j) { @@ -3832,65 +4112,68 @@ void resetsamplearray() enginedelay[i].engineSoundData[j].iSkid1Vol = -1; } } - //iNumCars = numcars; - //for (i = 0; i != sizeof(tCarSoundData); i += sizeof(tEngineSoundData)) { - // iCar = 0; - // if (iNumCars > 0) { - // iEngineDelayOffset = i; - // do { - // *(int *)((char *)&enginedelay[0].engineSoundData[0].iEngineVol + iEngineDelayOffset) = -1; - // *(int *)((char *)&enginedelay[0].engineSoundData[0].iEngine2Vol + iEngineDelayOffset) = -1; - // *(int *)((char *)&enginedelay[0].engineSoundData[0].iSkid1Vol + iEngineDelayOffset) = -1; - // ++iCar; - // iEngineDelayOffset += sizeof(tCarSoundData); - // } while (iCar < iNumCars); - // } - //} + // iNumCars = numcars; + // for (i = 0; i != sizeof(tCarSoundData); i += sizeof(tEngineSoundData)) { + // iCar = 0; + // if (iNumCars > 0) { + // iEngineDelayOffset = i; + // do { + // *(int *)((char *)&enginedelay[0].engineSoundData[0].iEngineVol + + // iEngineDelayOffset) = -1; + // *(int *)((char *)&enginedelay[0].engineSoundData[0].iEngine2Vol + + // iEngineDelayOffset) = -1; + // *(int *)((char *)&enginedelay[0].engineSoundData[0].iSkid1Vol + + // iEngineDelayOffset) = -1; + // ++iCar; + // iEngineDelayOffset += sizeof(tCarSoundData); + // } while (iCar < iNumCars); + // } + // } for (int i = 0; i < 32; ++i) { HandleSample[i] = -1; HandleCar[i] = -1; } - //iSampleOffset = 2; - //HandleSample[0] = -1; - //HandleCar[0] = -1; - //HandleSample[1] = -1; - //HandleCar[1] = -1; - //do { - // iSampleOffset += 5; - // HandleCar[iSampleOffset + 27] = -1; // offset into HandleSample - // SamplePending[15][iSampleOffset + 35] = -1; // offset into HandleCar - // HandleCar[iSampleOffset + 28] = -1; - // SamplePending[15][iSampleOffset + 36] = -1; - // HandleCar[iSampleOffset + 29] = -1; - // SamplePending[15][iSampleOffset + 37] = -1; - // HandleCar[iSampleOffset + 30] = -1; - // SamplePending[15][iSampleOffset + 38] = -1; - // HandleCar[iSampleOffset + 31] = -1; - // SamplePending[15][iSampleOffset + 39] = -1; - //} while (iSampleOffset != 32); + // iSampleOffset = 2; + // HandleSample[0] = -1; + // HandleCar[0] = -1; + // HandleSample[1] = -1; + // HandleCar[1] = -1; + // do { + // iSampleOffset += 5; + // HandleCar[iSampleOffset + 27] = -1; // offset into HandleSample + // SamplePending[15][iSampleOffset + 35] = -1; // offset into HandleCar + // HandleCar[iSampleOffset + 28] = -1; + // SamplePending[15][iSampleOffset + 36] = -1; + // HandleCar[iSampleOffset + 29] = -1; + // SamplePending[15][iSampleOffset + 37] = -1; + // HandleCar[iSampleOffset + 30] = -1; + // SamplePending[15][iSampleOffset + 38] = -1; + // HandleCar[iSampleOffset + 31] = -1; + // SamplePending[15][iSampleOffset + 39] = -1; + // } while (iSampleOffset != 32); for (int i = 0; i < 120; ++i) { for (int j = 0; j < 16; ++j) { SampleHandleCar[i].handles[j] = -1; } } - //iSampleHandleCarOffset = sizeof(tSampleHandleCar); - //for (j = 0; j < 120; ++j) { - // iHandleOffset = j << 6; - // do { - // iHandleOffset += 4; - // *(uint8 **)((char *)&SamplePtr[119] + iHandleOffset) = (uint8 *)-1;// offset into SampleHandleCar - // } while (iHandleOffset != iSampleHandleCarOffset); - // iSampleHandleCarOffset += sizeof(tSampleHandleCar); - //} - //numcars = iNumCars; + // iSampleHandleCarOffset = sizeof(tSampleHandleCar); + // for (j = 0; j < 120; ++j) { + // iHandleOffset = j << 6; + // do { + // iHandleOffset += 4; + // *(uint8 **)((char *)&SamplePtr[119] + iHandleOffset) = (uint8 *)-1;// + // offset into SampleHandleCar + // } while (iHandleOffset != iSampleHandleCarOffset); + // iSampleHandleCarOffset += sizeof(tSampleHandleCar); + // } + // numcars = iNumCars; } //------------------------------------------------------------------------------------------------- -//0003F050 -void reinitmusic() -{ +// 0003F050 +void reinitmusic() { int iSong; // eax if (musicon) { @@ -3907,16 +4190,15 @@ void reinitmusic() } else if (MusicCard) { if (SongPtr) { stop(); - //sosMIDIUnInitSong(*(unsigned int *)&SongHandle); + // sosMIDIUnInitSong(*(unsigned int *)&SongHandle); SongPtr = 0; } } } //------------------------------------------------------------------------------------------------- -//0003F0D0 -void waitsampledone(int iSampleIdx) -{ +// 0003F0D0 +void waitsampledone(int iSampleIdx) { if (!soundon) return; @@ -3927,7 +4209,7 @@ void waitsampledone(int iSampleIdx) for (int i = 0; i < 16; i++) { int iSampleHandle = SampleHandleCar[iSampleIdx].handles[i]; while (!DIGISampleDone(iSampleHandle)) { - UpdateSDL(); //added by ROLLER + UpdateSDL(); // added by ROLLER } } @@ -3935,56 +4217,51 @@ void waitsampledone(int iSampleIdx) } //------------------------------------------------------------------------------------------------- -//0003F110 -int getcompactedfilelength(const char *szFile) -{ +// 0003F110 +int getcompactedfilelength(const char *szFile) { FILE *pFile; // esi int iLength; // [esp+0h] [ebp-14h] BYREF pFile = ROLLERfopen(szFile, "rb"); - if (!pFile) ErrorBoxExit("Could not open file %s", szFile); + if (!pFile) + ErrorBoxExit("Could not open file %s", szFile); fread(&iLength, 1u, 4u, pFile); fclose(pFile); return iLength; } //------------------------------------------------------------------------------------------------- -//0003F150 -int initmangle(const char *szFile) -{ +// 0003F150 +int initmangle(const char *szFile) { unmangleinpoff = 4; unmanglebufpos = 4; unmangleoverflow = 0; unmanglefile = ROLLERfopen(szFile, "rb"); - if (!unmanglefile) ErrorBoxExit("Could not open file %s", szFile); + if (!unmanglefile) + ErrorBoxExit("Could not open file %s", szFile); fseek(unmanglefile, unmanglebufpos, 0); return (int)fread(unmangleinbuf, 1u, 0x400u, unmanglefile); } //------------------------------------------------------------------------------------------------- -//0003F1B0 -int uninitmangle() -{ - return fclose(unmanglefile); -} +// 0003F1B0 +int uninitmangle() { return fclose(unmanglefile); } //------------------------------------------------------------------------------------------------- -//0003F1C0 -int loadcompactedfile(const char *szFile, uint8 *pBuf) -{ +// 0003F1C0 +int loadcompactedfile(const char *szFile, uint8 *pBuf) { initmangle(szFile); loadcompactedfilepart(pBuf, 1000000000u); return fclose(unmanglefile); } //------------------------------------------------------------------------------------------------- -//0003F1E0 -void readmangled(uint8 *pBufRet, int iLength) -{ +// 0003F1E0 +void readmangled(uint8 *pBufRet, int iLength) { int iLengthToRead; // ebp - uint8 *pBufUnit8; // ebx - int iOverflow; // ecx - int iDelta; // esi + uint8 *pBufUnit8; // ebx + int iOverflow; // ecx + int iDelta; // esi iLengthToRead = iLength; pBufUnit8 = pBufRet + 40000; @@ -4007,12 +4284,12 @@ void readmangled(uint8 *pBufRet, int iLength) } //------------------------------------------------------------------------------------------------- -//0003F290 -void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) -{ +// 0003F290 +void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) { int c; int u, v; - unsigned char *pt;; + unsigned char *pt; + ; // Do the unmangle unmangledst = pDest; @@ -4021,29 +4298,31 @@ void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) break; c = *unmangleGet(unmangleinpoff++, 1); - if (!c) break; // done + if (!c) + break; // done if (c & 128) { - // Bit 7 : 1 : BLOCK + // Bit 7 : 1 : BLOCK if (c & 64) { - // Bit 6 : 1 Block size + // Bit 6 : 1 Block size if (c & 32) { - // Bit 5 : 1 Long - pt = unmangledst - ((c & 31) << 8) - *unmangleGet(unmangleinpoff++, 1) - 3; // offset - c = *unmangleGet(unmangleinpoff++, 1) + 5; // size + // Bit 5 : 1 Long + pt = unmangledst - ((c & 31) << 8) - + *unmangleGet(unmangleinpoff++, 1) - 3; // offset + c = *unmangleGet(unmangleinpoff++, 1) + 5; // size while (c--) *unmangledst++ = *pt++; } else { - // Bit 5 : 0 Medium - pt = unmangledst - ((c & 3) << 8) - *unmangleGet(unmangleinpoff++, 1) - 3; // offset - c = ((c >> 2) & 7) + 4; // size + // Bit 5 : 0 Medium + pt = unmangledst - ((c & 3) << 8) - + *unmangleGet(unmangleinpoff++, 1) - 3; // offset + c = ((c >> 2) & 7) + 4; // size while (c--) *unmangledst++ = *pt++; - } } else { - // Bit 6 : 0 : Short + // Bit 6 : 0 : Short pt = unmangledst - (c & 63) - 3; *unmangledst = *pt; *(unmangledst + 1) = *(pt + 1); @@ -4051,14 +4330,14 @@ void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) unmangledst += 3; } } else { - // Bit 7 : 0 + // Bit 7 : 0 if (c & 64) { - // Bit 6 : 1 Seq/Diff or String + // Bit 6 : 1 Seq/Diff or String if (c & 32) { - // Bit 5 : 1 : Sequence + // Bit 5 : 1 : Sequence if (c & 16) { - // Bit 4 : 1 : Word sequence - c = (c & 15) + 2; // bits 3-0 = len 2->17 + // Bit 4 : 1 : Word sequence + c = (c & 15) + 2; // bits 3-0 = len 2->17 memcpy(&v, unmangledst - 2, 2); v = (short)v; while (c--) { @@ -4066,29 +4345,40 @@ void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) unmangledst += 2; } } else { - // Bit 4 : 0 : Byte sequence - c = (c & 15) + 3; // bits 3-0 = len 3->18 + // Bit 4 : 0 : Byte sequence + c = (c & 15) + 3; // bits 3-0 = len 3->18 v = *(unmangledst - 1); while (c--) *unmangledst++ = (signed char)v; } } else { - // Bit 5 : 0 : Difference + // Bit 5 : 0 : Difference if (c & 16) { - // Bit 4 : 1 : Word difference - c = (c & 15) + 2; // bits 3-0 = len 2->17 - { short tmp_s; memcpy(&tmp_s, unmangledst - 2, 2); u = tmp_s; } // start word - { short tmp_s; memcpy(&tmp_s, unmangledst - 4, 2); v = u - tmp_s; } // dif + // Bit 4 : 1 : Word difference + c = (c & 15) + 2; // bits 3-0 = len 2->17 + { + short tmp_s; + memcpy(&tmp_s, unmangledst - 2, 2); + u = tmp_s; + } // start word + { + short tmp_s; + memcpy(&tmp_s, unmangledst - 4, 2); + v = u - tmp_s; + } // dif while (c--) { u += v; - { short tmp_s = (short)u; memcpy(unmangledst, &tmp_s, 2); } + { + short tmp_s = (short)u; + memcpy(unmangledst, &tmp_s, 2); + } unmangledst += 2; } } else { - // Bit 4 : 0 : Byte difference - c = (c & 15) + 3; // bits 3-0 = len 3->18 - u = *(unmangledst - 1); // start byte - v = u - *(unmangledst - 2); // dif + // Bit 4 : 0 : Byte difference + c = (c & 15) + 3; // bits 3-0 = len 3->18 + u = *(unmangledst - 1); // start byte + v = u - *(unmangledst - 2); // dif while (c--) { u += v; @@ -4097,8 +4387,8 @@ void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) } } } else { - // Bit 6 : 0 : String - c &= 63; // len + // Bit 6 : 0 : String + c &= 63; // len memcpy(unmangledst, unmangleGet(unmangleinpoff, c), c); unmangledst += c; unmangleinpoff += c; @@ -4108,17 +4398,17 @@ void loadcompactedfilepart(uint8 *pDest, uint32 uiDestLength) } //------------------------------------------------------------------------------------------------- -//0003F550 -uint8 *unmangleGet(unsigned int uiPos, unsigned int uiLookahead) -{ +// 0003F550 +uint8 *unmangleGet(unsigned int uiPos, unsigned int uiLookahead) { // if what we want to read is not currently in the // buffer load it into the buffer from the file - if (uiPos < (uint32)unmanglebufpos || uiPos + uiLookahead >(uint32)unmanglebufpos + 1024) { + if (uiPos < (uint32)unmanglebufpos || + uiPos + uiLookahead > (uint32)unmanglebufpos + 1024) { unmanglebufpos = uiPos; fseek(unmanglefile, uiPos, 0); fread(unmangleinbuf, 1u, 0x400u, unmanglefile); } - return &unmangleinbuf[uiPos - (uint32)unmanglebufpos];// return new pos + return &unmangleinbuf[uiPos - (uint32)unmanglebufpos]; // return new pos } //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/sound.h b/PROJECTS/ROLLER/sound.h index 9c8abd8d..caf47664 100644 --- a/PROJECTS/ROLLER/sound.h +++ b/PROJECTS/ROLLER/sound.h @@ -132,55 +132,52 @@ //------------------------------------------------------------------------------------------------- -#define BUTTON_FLAG_ACCEL 0x0001 -#define BUTTON_FLAG_BRAKE 0x0002 -#define BUTTON_FLAG_UPGEAR 0x0004 -#define BUTTON_FLAG_DOWNGEAR 0x0008 -#define BUTTON_FLAG_SPECIAL 0x0020 -#define BUTTON_FLAG_F1 0x0040 -#define BUTTON_FLAG_F2 0x0080 -#define BUTTON_FLAG_F3 0x0100 -#define BUTTON_FLAG_F4 0x0200 -#define BUTTON_FLAG_SLAVE_QUIT 0x0400 +#define BUTTON_FLAG_ACCEL 0x0001 +#define BUTTON_FLAG_BRAKE 0x0002 +#define BUTTON_FLAG_UPGEAR 0x0004 +#define BUTTON_FLAG_DOWNGEAR 0x0008 +#define BUTTON_FLAG_SPECIAL 0x0020 +#define BUTTON_FLAG_F1 0x0040 +#define BUTTON_FLAG_F2 0x0080 +#define BUTTON_FLAG_F3 0x0100 +#define BUTTON_FLAG_F4 0x0200 +#define BUTTON_FLAG_SLAVE_QUIT 0x0400 #define BUTTON_FLAG_MASTER_QUIT 0x0800 //------------------------------------------------------------------------------------------------- -#define REPLAY_BUFFER_SIZE 512 -#define DELAY_BUFFER_SIZE 32 +#define REPLAY_BUFFER_SIZE 512 +#define DELAY_BUFFER_SIZE 32 //------------------------------------------------------------------------------------------------- // Flag constants for copy_multiple data -#define FLAG_DISCONNECT 0x0400 -#define FLAG_MASTER_CHANGE 0x0800 -#define FLAG_FINISHED 0x1000 +#define FLAG_DISCONNECT 0x0400 +#define FLAG_MASTER_CHANGE 0x0800 +#define FLAG_FINISHED 0x1000 //------------------------------------------------------------------------------------------------- -#define SAMPLE_FLAG_PLAYING 0x0020 -#define SAMPLE_FLAG_LOOP 0x0040 -#define SAMPLE_FLAG_ACTIVE 0x0080 +#define SAMPLE_FLAG_PLAYING 0x0020 +#define SAMPLE_FLAG_LOOP 0x0040 +#define SAMPLE_FLAG_ACTIVE 0x0080 //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { DWORD edi, esi, ebp, reserved, ebx, edx, ecx, eax; - WORD flags, es, ds, fs, gs, ip, cs, sp, ss; + WORD flags, es, ds, fs, gs, ip, cs, sp, ss; } DPMI_RMI; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int handles[16]; } tSampleHandleCar; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { void *pSample; uint16 unSegment; int iLength; @@ -203,8 +200,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { void *pData; int nUnk2; int iUnk1; @@ -213,28 +209,25 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ - int iEnginePitch; //ENGINE.RAW +typedef struct { + int iEnginePitch; // ENGINE.RAW int iEngineVol; - int iEngine2Pitch; //ENGINE2.RAW + int iEngine2Pitch; // ENGINE2.RAW int iEngine2Vol; - int iSkid1Pitch; //SKID1.RAW + int iSkid1Pitch; // SKID1.RAW int iSkid1Vol; int iPan; } tEngineSoundData; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tEngineSoundData engineSoundData[32]; } tCarSoundData; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iJ1Button1; int iJ1Button2; int iJ1XAxis; @@ -247,22 +240,19 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint16 unInput; uint16 unFlags; } tCarInputData; -typedef union -{ +typedef union { tCarInputData data; uint32 uiFullData; } tCopyData; //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iSampleIdx; int iVolume; int iDelay; @@ -271,8 +261,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iHandle; int iVolume; } tSamplePending; @@ -420,7 +409,8 @@ int initgus(); void devicespecificuninit(); void readsoundconfig(); char *FindConfigVar(const char *szConfigText, const char *szVarName); -void loadfile(const char *szFile, void **pBuf, unsigned int *uiSize, int iIsSound); +void loadfile(const char *szFile, void **pBuf, unsigned int *uiSize, + int iIsSound); void ReadJoys(tJoyPos *pJoy); void check_joystickpresence(); void initsounds(); @@ -436,12 +426,14 @@ void remove_frontendspeech(); int sfxplaying(int iSampleIdx); int cheatsampleok(int iCarIdx); void sfxsample(int iSample, int iVol); -void sample2(int iCarIndex, int iSampleIndex, int iVolume, int iPitch, int iPan, int iByteOffset); +void sample2(int iCarIndex, int iSampleIndex, int iVolume, int iPitch, int iPan, + int iByteOffset); void sfxpend(int iSampleIdx, int iDriverIdx, int iVolume); void enginesounds2(int iPlayer1Car, int iPlayer2Car); void enginesounds(int iFocusCarIndex); void loopsample(int iCarIdx, int iSampleIdx, int iVolume, int iPitch, int iPan); -void enginesound(int iCarIdx, float fListenerDopplerVel, float fCarDopplerVel, float fDistance, int iStereoVolume); +void enginesound(int iCarIdx, float fListenerDopplerVel, float fCarDopplerVel, + float fDistance, int iStereoVolume); void startmusic(int iSong); void stopmusic(); void load_language_map(); diff --git a/PROJECTS/ROLLER/svgacpy.c b/PROJECTS/ROLLER/svgacpy.c index 98c7afec..d9eda379 100644 --- a/PROJECTS/ROLLER/svgacpy.c +++ b/PROJECTS/ROLLER/svgacpy.c @@ -4,228 +4,229 @@ #include //------------------------------------------------------------------------------------------------- -int Vbytesperline; //00178068 -int winrange; //0017806C +int Vbytesperline; // 00178068 +int winrange; // 0017806C //------------------------------------------------------------------------------------------------- -//0004E4B0 -int vesastart(int iX, int iY) -{ - //RMI.ecx = iX; - //RMI.edx = iY; - //RMI.es = vmode_inf >> 4; // Convert vmode_inf to segment address - //RMI.ebx = 0; // Subfunction: Set Display Start - //RMI.eax = 0x4F07; // VESA Function: Set/Get Display Start +// 0004E4B0 +int vesastart(int iX, int iY) { + // RMI.ecx = iX; + // RMI.edx = iY; + // RMI.es = vmode_inf >> 4; // Convert vmode_inf to + // segment address RMI.ebx = 0; // + // Subfunction: Set Display Start RMI.eax = 0x4F07; // VESA Function: Set/Get + // Display Start // //// Make real-mode interrupt call - //realmode(0x10u); + // realmode(0x10u); // //// Check VESA function support - //if (LOBYTE(RMI.eax) == 0x4F) - // return BYTE1(RMI.eax) != 0; // Check function success status - //puts("VESA function not supported."); - //return 2; + // if (LOBYTE(RMI.eax) == 0x4F) + // return BYTE1(RMI.eax) != 0; // Check function success + // status + // puts("VESA function not supported."); + // return 2; return 0; } //------------------------------------------------------------------------------------------------- -//0004E530 -int tryvesa(int iModeNumber) -{ - //RMI.ecx = iModeNumber; // VESA mode number to query - //RMI.es = vmode_inf >> 4; // Convert vmode_inf to segment address - //RMI.eax = 0x4F01; // VESA Function: Get Mode Information - //RMI.edi = 0; // Offset part of buffer pointer +// 0004E530 +int tryvesa(int iModeNumber) { + // RMI.ecx = iModeNumber; // VESA mode number to query + // RMI.es = vmode_inf >> 4; // Convert vmode_inf to + // segment address RMI.eax = 0x4F01; // VESA + // Function: Get Mode Information RMI.edi = 0; // Offset part of buffer + // pointer // //// Make real-mode interrupt call - //realmode(0x10u); + // realmode(0x10u); // //// Check VESA function support - //if (LOBYTE(RMI.eax) == 0x4F) - // return BYTE1(RMI.eax) != 0; // Check function success status + // if (LOBYTE(RMI.eax) == 0x4F) + // return BYTE1(RMI.eax) != 0; // Check function success + // status // - //puts("VESA function not supported."); - //return 2; + // puts("VESA function not supported."); + // return 2; return 0; } //------------------------------------------------------------------------------------------------- -//0004E5A0 -void *VESASource(int iX, int iY, int iOffset) -{ +// 0004E5A0 +void *VESASource(int iX, int iY, int iOffset) { //// Get bytes per pixel from VESA mode info - //unsigned char bpp_byte = *(unsigned char *)(vmode_inf[0] + 0x19); - //int iBytesPerPixel = bpp_byte >> 3; // Convert bits to bytes + // unsigned char bpp_byte = *(unsigned char *)(vmode_inf[0] + 0x19); + // int iBytesPerPixel = bpp_byte >> 3; // Convert bits to bytes // //// Calculate buffer offset: y * pitch + x * bpp + additional offset - //int iBufferOffset = iY * Vbytesperline + iX * iBytesPerPixel + iOffset; + // int iBufferOffset = iY * Vbytesperline + iX * iBytesPerPixel + iOffset; // //// Calculate window index and window-relative offset - //int iWindowIndex = iBufferOffset / winrange; - //int iWindowOffset = iBufferOffset % winrange; + // int iWindowIndex = iBufferOffset / winrange; + // int iWindowOffset = iBufferOffset % winrange; // //// Set new window if needed - //if (iWindowIndex != vmode_inf[1]) { - // union REGS regs; - // regs.x.ax = 0x4F05; // VESA function: Window Control - // regs.x.bx = 0x0001; // Set window (subfunction 1 for source) - // regs.x.dx = window_index; // Window position - // int386(0x10, ®s); // Call VESA BIOS + // if (iWindowIndex != vmode_inf[1]) { + // union REGS regs; + // regs.x.ax = 0x4F05; // VESA function: Window Control + // regs.x.bx = 0x0001; // Set window (subfunction 1 for source) + // regs.x.dx = window_index; // Window position + // int386(0x10, ®s); // Call VESA BIOS // - // vmode_inf[1] = window_index; // Update current window index - //} + // vmode_inf[1] = window_index; // Update current window index + // } // //// Return pointer to source location - //return (uint8 *)VesaSBase + iWindowOffset; + // return (uint8 *)VesaSBase + iWindowOffset; return NULL; } //------------------------------------------------------------------------------------------------- -//0004E630 -void *VESADest(int iX, int iY, int iOffset) -{ +// 0004E630 +void *VESADest(int iX, int iY, int iOffset) { //// Get bytes per pixel from VESA mode info - //unsigned char bpp_byte = *(unsigned char *)(vmode_inf + 0x19); - //int iBytesPerPixel = bpp_byte >> 3; // Convert bits to bytes + // unsigned char bpp_byte = *(unsigned char *)(vmode_inf + 0x19); + // int iBytesPerPixel = bpp_byte >> 3; // Convert bits to bytes // //// Calculate buffer offset: y * pitch + x * bpp + additional offset - //int iBufferOffset = iY * Vbytesperline + iX * iBytesPerPixel + iOffset; + // int iBufferOffset = iY * Vbytesperline + iX * iBytesPerPixel + iOffset; // //// Calculate window index and window-relative offset - //int window_index = iBufferOffset / winrange; - //int window_offset = iBufferOffset % winrange; + // int window_index = iBufferOffset / winrange; + // int window_offset = iBufferOffset % winrange; // //// Set new window if needed - //if (window_index != vmode_inf[2]) { - // union REGS regs; - // regs.x.ax = 0x4F05; // VESA function: Window Control - // regs.x.bx = 0x0000; // Set window (subfunction 0 for destination) - // regs.x.dx = window_index; // Window position - // int386(0x10, ®s); // Call VESA BIOS + // if (window_index != vmode_inf[2]) { + // union REGS regs; + // regs.x.ax = 0x4F05; // VESA function: Window Control + // regs.x.bx = 0x0000; // Set window (subfunction 0 for destination) + // regs.x.dx = window_index; // Window position + // int386(0x10, ®s); // Call VESA BIOS // - // vmode_inf[2] = window_index; // Update current window index - //} + // vmode_inf[2] = window_index; // Update current window index + // } // //// Return pointer to destination location - //return (char *)VesaDBase + window_offset; + // return (char *)VesaDBase + window_offset; return NULL; } //------------------------------------------------------------------------------------------------- -//0004E6C0 -int VESAmode(int *vesaModeAy) -{ - //int iRetVal; // ebx - //int16 *pnModes; // edx - //int iMode; // eax - //int iNextMode; // ecx - //uint16 unModeInf; // ax - //union REGS regs; // [esp+0h] [ebp-3Ch] BYREF - //struct SREGS sregs; // [esp+1Ch] [ebp-20h] BYREF - //memset(&sregs, 0, sizeof(sregs)); +// 0004E6C0 +int VESAmode(int *vesaModeAy) { + // int iRetVal; // ebx + // int16 *pnModes; // edx + // int iMode; // eax + // int iNextMode; // ecx + // uint16 unModeInf; // ax + // union REGS regs; // [esp+0h] [ebp-3Ch] BYREF + // struct SREGS sregs; // [esp+1Ch] [ebp-20h] BYREF + // memset(&sregs, 0, sizeof(sregs)); // //// Initialize VESA controller info if needed - //if (!vesa_inf) { - // // Allocate DOS memory for VESA info - // regs.w.ax = 0x100; - // regs.w.bx = 0x10; - // int386x(0x31, ®s, ®s, &sregs); - // vesa_inf = (char *)(16 * regs.w.ax); // Convert segment to linear address - // if (regs.x.cflag) { - // puts("Internal error : VESA display could not allocate core memory."); - // return -1; - // } + // if (!vesa_inf) { + // // Allocate DOS memory for VESA info + // regs.w.ax = 0x100; + // regs.w.bx = 0x10; + // int386x(0x31, ®s, ®s, &sregs); + // vesa_inf = (char *)(16 * regs.w.ax); // Convert segment to linear + // address if (regs.x.cflag) { + // puts("Internal error : VESA display could not allocate core memory."); + // return -1; + // } // - // // Get VESA controller information - // RMI.edi = 0; // Offset 0 in segment - // RMI.es = (16 * regs.w.ax) >> 4; // Segment part - // RMI.eax = 0x4F00; // VESA get controller info - // realmode(0x10u); + // // Get VESA controller information + // RMI.edi = 0; // Offset 0 in segment + // RMI.es = (16 * regs.w.ax) >> 4; // Segment part + // RMI.eax = 0x4F00; // VESA get controller info + // realmode(0x10u); // - // // Check for VESA support - // if (LOBYTE(RMI.eax) != 0x4F) - // goto LABEL_5; - // if (BYTE1(RMI.eax)) { - // LABEL_7: - // puts("VESA function call failed."); - // return -1; - // } + // // Check for VESA support + // if (LOBYTE(RMI.eax) != 0x4F) + // goto LABEL_5; + // if (BYTE1(RMI.eax)) { + // LABEL_7: + // puts("VESA function call failed."); + // return -1; + // } // - // // Verify VESA signature - // if (strncmp(vesa_inf, "VESA", 4)) - // puts("Internal error : VESA not initialised."); - //} + // // Verify VESA signature + // if (strncmp(vesa_inf, "VESA", 4)) + // puts("Internal error : VESA not initialised."); + // } // //// Initialize mode info buffer if needed - //if (vmode_inf[0] - // || (regs.w.ax = 0x100, - // regs.w.bx = 0x10, - // int386x(0x31, ®s, ®s, &sregs), - // vmode_inf[0] = 16 * regs.w.ax, - // !regs.x.cflag)) { - // iRetVal = -1; - // if (*vesaModeAy != -1) { - // do { - // if (iRetVal != -1) - // break; + // if (vmode_inf[0] + // || (regs.w.ax = 0x100, + // regs.w.bx = 0x10, + // int386x(0x31, ®s, ®s, &sregs), + // vmode_inf[0] = 16 * regs.w.ax, + // !regs.x.cflag)) { + // iRetVal = -1; + // if (*vesaModeAy != -1) { + // do { + // if (iRetVal != -1) + // break; // - // // Get pointer to mode list from VESA info - // for (pnModes = (int16 *)(((*(int *)(vesa_inf + 14) >> 12) & 0xFFFF0) - // + (unsigned __int16)*(_DWORD *)(vesa_inf + 14)); ; ++pnModes) { - // iMode = *pnModes; - // if (iMode == -1) - // break; - // if (iMode == *vesaModeAy && !tryvesa(iMode)) { - // iRetVal = *pnModes; - // break; - // } - // } - // iNextMode = vesaModeAy[1]; - // ++vesaModeAy; - // } while (iNextMode != -1); - // } - // if (iRetVal <= -1) { - // puts(NoSupportedVesaMode); // No supported VESA mode available. - // } else { - // // Set up mode parameters - // winrange = *(__int16 *)(vmode_inf[0] + 4) << 10;// Win size in KB -> bytes - // Vbytesperline = *(__int16 *)(vmode_inf[0] + 16);// Bytes per scanline + // // Get pointer to mode list from VESA info + // for (pnModes = (int16 *)(((*(int *)(vesa_inf + 14) >> 12) & 0xFFFF0) + // + (unsigned __int16)*(_DWORD *)(vesa_inf + + // 14)); ; ++pnModes) { + // iMode = *pnModes; + // if (iMode == -1) + // break; + // if (iMode == *vesaModeAy && !tryvesa(iMode)) { + // iRetVal = *pnModes; + // break; + // } + // } + // iNextMode = vesaModeAy[1]; + // ++vesaModeAy; + // } while (iNextMode != -1); + // } + // if (iRetVal <= -1) { + // puts(NoSupportedVesaMode); // No supported VESA mode + // available. + // } else { + // // Set up mode parameters + // winrange = *(__int16 *)(vmode_inf[0] + 4) << 10;// Win size in KB -> + // bytes Vbytesperline = *(__int16 *)(vmode_inf[0] + 16);// Bytes per + // scanline // - // // Calculate base addresses (segment * 16) - // unModeInf = *(_WORD *)(vmode_inf[0] + 10); - // VesaSBase = 16 * *(unsigned __int16 *)(vmode_inf[0] + 8); - // RMI.ebx = iRetVal; - // VesaDBase = 16 * unModeInf; - // RMI.eax = 0x4F02; - // realmode(0x10u); + // // Calculate base addresses (segment * 16) + // unModeInf = *(_WORD *)(vmode_inf[0] + 10); + // VesaSBase = 16 * *(unsigned __int16 *)(vmode_inf[0] + 8); + // RMI.ebx = iRetVal; + // VesaDBase = 16 * unModeInf; + // RMI.eax = 0x4F02; + // realmode(0x10u); // - // // Verify mode set success - // if (LOBYTE(RMI.eax) != 0x4F) { - // LABEL_5: - // puts("VESA function not supported."); - // return -1; - // } - // if (BYTE1(RMI.eax)) - // goto LABEL_7; - // } - // return iRetVal; - //} else { - // puts("Internal error : VESA display could not allocate core memory."); - // return -1; - //} + // // Verify mode set success + // if (LOBYTE(RMI.eax) != 0x4F) { + // LABEL_5: + // puts("VESA function not supported."); + // return -1; + // } + // if (BYTE1(RMI.eax)) + // goto LABEL_7; + // } + // return iRetVal; + // } else { + // puts("Internal error : VESA display could not allocate core memory."); + // return -1; + // } - return 0; //added by ROLLER, pretend to be VESA mode 0 + return 0; // added by ROLLER, pretend to be VESA mode 0 } //------------------------------------------------------------------------------------------------- -//0004E940 -void svgacopy(uint8 *pSrc, int16 iX, int16 iY, int iWidth, int iHeight) -{ - return; //added by ROLLER +// 0004E940 +void svgacopy(uint8 *pSrc, int16 iX, int16 iY, int iWidth, int iHeight) { + return; // added by ROLLER // Calculate initial video memory offset int iOffset = iX * Vbytesperline + iY; @@ -234,19 +235,21 @@ void svgacopy(uint8 *pSrc, int16 iX, int16 iY, int iWidth, int iHeight) uint8 *pVideoPtr = (uint8 *)0xA0000 + iWindowOffset; // Set initial VESA window - //union REGS regs; - //regs.x.ax = 0x4F05; // VESA function 05h: Window Control - //regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) - //regs.x.dx = iWindowIdx; // Window position in granularity units - //int386(0x10, ®s, ®s); + // union REGS regs; + // regs.x.ax = 0x4F05; // VESA function 05h: Window Control + // regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) + // regs.x.dx = iWindowIdx; // Window position in granularity units + // int386(0x10, ®s, ®s); while (iHeight > 0) { // Calculate rows that fit in current window int iBytesLeft = winrange - iWindowOffset; int iRowsInWindow = iBytesLeft / Vbytesperline; - if (iRowsInWindow <= 0) iRowsInWindow = 1; // At least 1 partial row - if (iRowsInWindow > iHeight) iRowsInWindow = iHeight; + if (iRowsInWindow <= 0) + iRowsInWindow = 1; // At least 1 partial row + if (iRowsInWindow > iHeight) + iRowsInWindow = iHeight; // Copy full rows for (int row = 0; row < iRowsInWindow; row++) { @@ -257,7 +260,8 @@ void svgacopy(uint8 *pSrc, int16 iX, int16 iY, int iWidth, int iHeight) } iHeight -= iRowsInWindow; - if (iHeight <= 0) break; + if (iHeight <= 0) + break; // Update position for next segment iOffset += iRowsInWindow * Vbytesperline; @@ -265,27 +269,28 @@ void svgacopy(uint8 *pSrc, int16 iX, int16 iY, int iWidth, int iHeight) iWindowOffset = iOffset % winrange; // Set new VESA window - //union REGS regs; - //regs.x.ax = 0x4F05; // VESA function 05h: Window Control - //regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) - //regs.x.dx = iWindowIdx; // Window position in granularity units - //int386(0x10, ®s, ®s); + // union REGS regs; + // regs.x.ax = 0x4F05; // VESA function 05h: Window Control + // regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) + // regs.x.dx = iWindowIdx; // Window position in granularity units + // int386(0x10, ®s, ®s); pVideoPtr = (uint8 *)0xA0000 + iWindowOffset; // Handle partial row at window boundary int iSegment1 = Vbytesperline - iWindowOffset; - if (iSegment1 > iWidth) iSegment1 = iWidth; + if (iSegment1 > iWidth) + iSegment1 = iWidth; memcpy(pVideoPtr, pSrc, iSegment1); // Handle remainder if row crosses window boundary if (iSegment1 < iWidth) { int iSegment2 = iWidth - iSegment1; - //union REGS regs; - //regs.x.ax = 0x4F05; // VESA function 05h: Window Control - //regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) - //regs.x.dx = iWindowIdx + 1; // Window position in granularity units - //int386(0x10, ®s, ®s); + // union REGS regs; + // regs.x.ax = 0x4F05; // VESA function 05h: Window Control + // regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) + // regs.x.dx = iWindowIdx + 1; // Window position in granularity units + // int386(0x10, ®s, ®s); memcpy((unsigned char *)0xA0000, pSrc + iSegment1, iSegment2); iWindowOffset = iSegment2; pVideoPtr = (unsigned char *)0xA0000 + iSegment2; @@ -297,11 +302,11 @@ void svgacopy(uint8 *pSrc, int16 iX, int16 iY, int iWidth, int iHeight) } // Reset to window 0 before returning - //union REGS regs; - //regs.x.ax = 0x4F05; // VESA function 05h: Window Control - //regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) - //regs.x.dx = 0; // Window position in granularity units - //int386(0x10, ®s, ®s); + // union REGS regs; + // regs.x.ax = 0x4F05; // VESA function 05h: Window Control + // regs.x.bx = 0x0000; // BH=0 (Window A), BL=0 (Set window position) + // regs.x.dx = 0; // Window position in granularity units + // int386(0x10, ®s, ®s); } //------------------------------------------------------------------------------------------------- diff --git a/PROJECTS/ROLLER/tower.c b/PROJECTS/ROLLER/tower.c index 0fff4915..15e78fcd 100644 --- a/PROJECTS/ROLLER/tower.c +++ b/PROJECTS/ROLLER/tower.c @@ -7,139 +7,182 @@ #include //------------------------------------------------------------------------------------------------- -int TowerSect[MAX_TRACK_CHUNKS]; //001A1FA0 -float TowerX[32]; //001A2770 -float TowerY[32]; //001A27F0 -float TowerZ[32]; //001A2870 -tTowerBase TowerBase[32]; //001A28F0 -tPolyParams TowerPol; //001A2B70 -int NumTowers; //001A2B9C +int TowerSect[MAX_TRACK_CHUNKS]; // 001A1FA0 +float TowerX[32]; // 001A2770 +float TowerY[32]; // 001A27F0 +float TowerZ[32]; // 001A2870 +tTowerBase TowerBase[32]; // 001A28F0 +tPolyParams TowerPol; // 001A2B70 +int NumTowers; // 001A2B9C //------------------------------------------------------------------------------------------------- -//00075700 -void InitTowers() -{ - int iTowerIndex; // esi - int iTowerBaseIndex; // edx - int iTowerArrayIndex; // ebx - int iTrackSegmentIndex; // edi - int iNextSegmentIndex; // ecx +// 00075700 +void InitTowers() { + int iTowerIndex; // esi + int iTowerBaseIndex; // edx + int iTowerArrayIndex; // ebx + int iTrackSegmentIndex; // edi + int iNextSegmentIndex; // ecx tData *pCurrentTrackData; // eax - tData *pNextTrackData; // ebp - int iTotalTowers; // ecx - float fNegTrackX; // [esp+4h] [ebp-34h] - float fNegTrackY; // [esp+8h] [ebp-30h] - float fTrackDistance; // [esp+Ch] [ebp-2Ch] - float fTowerOffset; // [esp+10h] [ebp-28h] - float fTrackDeltaX; // [esp+14h] [ebp-24h] - float fTrackDeltaY; // [esp+18h] [ebp-20h] - float fTowerHeight; // [esp+1Ch] [ebp-1Ch] + tData *pNextTrackData; // ebp + int iTotalTowers; // ecx + float fNegTrackX; // [esp+4h] [ebp-34h] + float fNegTrackY; // [esp+8h] [ebp-30h] + float fTrackDistance; // [esp+Ch] [ebp-2Ch] + float fTowerOffset; // [esp+10h] [ebp-28h] + float fTrackDeltaX; // [esp+14h] [ebp-24h] + float fTrackDeltaY; // [esp+18h] [ebp-20h] + float fTowerHeight; // [esp+1Ch] [ebp-1Ch] - memset(TowerSect, 255, sizeof(TowerSect)); // Initialize tower sector array to -1 (no towers) + memset(TowerSect, 255, + sizeof(TowerSect)); // Initialize tower sector array to -1 (no towers) iTowerIndex = 0; - if (NumTowers > 0) // Process each tower if any towers exist + if (NumTowers > 0) // Process each tower if any towers exist { iTowerBaseIndex = 0; iTowerArrayIndex = 0; do { - iTrackSegmentIndex = TowerBase[iTowerBaseIndex].iChunkIdx;// Get track segment index for this tower - iNextSegmentIndex = iTrackSegmentIndex + 1;// Calculate next track segment with wraparound - fTowerOffset = (float)TowerBase[iTowerBaseIndex].iHOffset;// Convert tower offset to float + iTrackSegmentIndex = + TowerBase[iTowerBaseIndex] + .iChunkIdx; // Get track segment index for this tower + iNextSegmentIndex = iTrackSegmentIndex + + 1; // Calculate next track segment with wraparound + fTowerOffset = (float)TowerBase[iTowerBaseIndex] + .iHOffset; // Convert tower offset to float if (iTrackSegmentIndex + 1 >= TRAK_LEN) iNextSegmentIndex -= TRAK_LEN; - pCurrentTrackData = &localdata[iTrackSegmentIndex];// Get track data for current and next segments + pCurrentTrackData = + &localdata[iTrackSegmentIndex]; // Get track data for current and next + // segments fNegTrackY = -pCurrentTrackData->pointAy[3].fY; pNextTrackData = &localdata[iNextSegmentIndex]; - fTowerHeight = (float)((double)(32 * TowerBase[iTowerBaseIndex].iVOffset) - (double)pCurrentTrackData->pointAy[3].fZ);// Calculate tower height from track Z and tower height parameter - fTrackDeltaX = pCurrentTrackData->pointAy[3].fX - pNextTrackData->pointAy[3].fX;// Calculate track direction vector between segments - fTrackDeltaY = pCurrentTrackData->pointAy[3].fY - pNextTrackData->pointAy[3].fY; - fTrackDistance = (float)sqrt(fTrackDeltaX * fTrackDeltaX + fTrackDeltaY * fTrackDeltaY);// Calculate distance between track segments - if ( fabs(fTrackDeltaX) > 0.0f ) - //if ((LODWORD(fTrackDeltaX) & 0x7FFFFFFF) != 0)// Normalize direction vector components + fTowerHeight = + (float)((double)(32 * TowerBase[iTowerBaseIndex].iVOffset) - + (double)pCurrentTrackData->pointAy[3] + .fZ); // Calculate tower height from track Z and tower + // height parameter + fTrackDeltaX = + pCurrentTrackData->pointAy[3].fX - + pNextTrackData->pointAy[3] + .fX; // Calculate track direction vector between segments + fTrackDeltaY = + pCurrentTrackData->pointAy[3].fY - pNextTrackData->pointAy[3].fY; + fTrackDistance = (float)sqrt( + fTrackDeltaX * fTrackDeltaX + + fTrackDeltaY * + fTrackDeltaY); // Calculate distance between track segments + if (fabs(fTrackDeltaX) > 0.0f) + // if ((LODWORD(fTrackDeltaX) & 0x7FFFFFFF) != 0)// Normalize direction + // vector components fTrackDeltaX = fTrackDeltaX / fTrackDistance; - if (fabs(pCurrentTrackData->pointAy[3].fY - pNextTrackData->pointAy[3].fY)) + if (fabs(pCurrentTrackData->pointAy[3].fY - + pNextTrackData->pointAy[3].fY)) fTrackDeltaY = fTrackDeltaY / fTrackDistance; fNegTrackX = -pCurrentTrackData->pointAy[3].fX; - TowerX[iTowerArrayIndex] = fNegTrackX - fTowerOffset * fTrackDeltaY * 32.0f;// Calculate tower X position with perpendicular offset + TowerX[iTowerArrayIndex] = + fNegTrackX - + fTowerOffset * fTrackDeltaY * + 32.0f; // Calculate tower X position with perpendicular offset iTotalTowers = NumTowers; - - //loop offset fix + + // loop offset fix TowerZ[iTowerArrayIndex] = fTowerHeight; - TowerY[iTowerArrayIndex] = fTowerOffset * fTrackDeltaX * 32.0f + fNegTrackY; + TowerY[iTowerArrayIndex] = + fTowerOffset * fTrackDeltaX * 32.0f + fNegTrackY; ++iTowerBaseIndex; ++iTowerArrayIndex; - TowerSect[iTrackSegmentIndex] = iTowerIndex++;// Store tower index in track segment lookup table - //TowerY[iTowerArrayIndex + 31] = fTowerHeight;// offset into TowerZ - //TowerX[iTowerArrayIndex + 31] = fTowerOffset * fTrackDeltaX * 32.0 + fNegTrackY;// offset into TowerY + TowerSect[iTrackSegmentIndex] = + iTowerIndex++; // Store tower index in track segment lookup table + // TowerY[iTowerArrayIndex + 31] = fTowerHeight;// offset into TowerZ + // TowerX[iTowerArrayIndex + 31] = fTowerOffset * fTrackDeltaX * 32.0 + + // fNegTrackY;// offset into TowerY } while (iTowerIndex < iTotalTowers); } - TowerPol.uiNumVerts = 4; // Set tower polygon to 4 vertices (rectangular) + TowerPol.uiNumVerts = 4; // Set tower polygon to 4 vertices (rectangular) } //------------------------------------------------------------------------------------------------- -//00075850 -void DrawTower(int iTowerIdx, uint8 *pScrBuf) -{ +// 00075850 +void DrawTower(int iTowerIdx, uint8 *pScrBuf) { double TowerMinusViewX; // st7 double TowerMinusViewY; // st6 double TowerMinusViewZ; // st5 double dTransformed3DZ; // st7 - double dViewDistance; // st7 - double dZInverse; // st6 - double dScreenX; // st5 - double dScreenY; // st7 - int iScreenSize; // ebp - int iPixelOffsetX; // ecx - int iPixelX; // ecx - int iPixelY; // ebx - float fTransformed3DY; // [esp+20h] [ebp-20h] - float fTransformed3DX; // [esp+24h] [ebp-1Ch] - float fOriginalZ; // [esp+28h] [ebp-18h] - float fClampedZ; // [esp+2Ch] [ebp-14h] + double dViewDistance; // st7 + double dZInverse; // st6 + double dScreenX; // st5 + double dScreenY; // st7 + int iScreenSize; // ebp + int iPixelOffsetX; // ecx + int iPixelX; // ecx + int iPixelY; // ebx + float fTransformed3DY; // [esp+20h] [ebp-20h] + float fTransformed3DX; // [esp+24h] [ebp-1Ch] + float fOriginalZ; // [esp+28h] [ebp-18h] + float fClampedZ; // [esp+2Ch] [ebp-14h] - if (iTowerIdx != NearTow && TowerBase[iTowerIdx].iEnabled > -1) {// Skip if tower is nearby or disabled - TowerMinusViewX = TowerX[iTowerIdx] - viewx;// Calculate tower position relative to camera view + if (iTowerIdx != NearTow && TowerBase[iTowerIdx].iEnabled > + -1) { // Skip if tower is nearby or disabled + TowerMinusViewX = TowerX[iTowerIdx] - + viewx; // Calculate tower position relative to camera view TowerMinusViewY = TowerY[iTowerIdx] - viewy; TowerMinusViewZ = TowerZ[iTowerIdx] - viewz; - fTransformed3DX = (float)TowerMinusViewX * vk1 + (float)TowerMinusViewY * vk4 + (float)TowerMinusViewZ * vk7;// Transform 3D tower position using view matrix - fTransformed3DY = (float)TowerMinusViewX * vk2 + (float)TowerMinusViewY * vk5 + (float)TowerMinusViewZ * vk8; - dTransformed3DZ = (float)TowerMinusViewX * vk3 + (float)TowerMinusViewY * vk6 + (float)TowerMinusViewZ * vk9; + fTransformed3DX = (float)TowerMinusViewX * vk1 + + (float)TowerMinusViewY * vk4 + + (float)TowerMinusViewZ * + vk7; // Transform 3D tower position using view matrix + fTransformed3DY = (float)TowerMinusViewX * vk2 + + (float)TowerMinusViewY * vk5 + + (float)TowerMinusViewZ * vk8; + dTransformed3DZ = (float)TowerMinusViewX * vk3 + + (float)TowerMinusViewY * vk6 + + (float)TowerMinusViewZ * vk9; fClampedZ = (float)dTransformed3DZ; fOriginalZ = fClampedZ; - if (dTransformed3DZ < 80.0) // Clamp Z distance to minimum for perspective division + if (dTransformed3DZ < + 80.0) // Clamp Z distance to minimum for perspective division fClampedZ = 80.0; - dViewDistance = (double)VIEWDIST; // Project 3D coordinates to 2D screen space + dViewDistance = + (double)VIEWDIST; // Project 3D coordinates to 2D screen space dZInverse = 1.0 / fClampedZ; dScreenX = dViewDistance * fTransformed3DX * dZInverse + (double)xbase; //_CHP(); xp = (int)dScreenX; dScreenY = dZInverse * (dViewDistance * fTransformed3DY) + (double)ybase; iScreenSize = scr_size; - iPixelOffsetX = scr_size * (int)dScreenX; // Calculate pixel buffer coordinates with bit shift scaling + iPixelOffsetX = + scr_size * (int)dScreenX; // Calculate pixel buffer coordinates with bit + // shift scaling //_CHP(); yp = (int)dScreenY; iPixelX = iPixelOffsetX >> 6; - iPixelY = (iScreenSize * (199 - (int)dScreenY)) >> 6;// Complex visibility test for different distance ranges - if (fOriginalZ >= 5000.0 && xp >= -50 && xp < 370 && yp >= -50 && yp < 250 - || fOriginalZ > -1000.0 && fOriginalZ < 5000.0 && (fTransformed3DX > -1000.0 && fTransformed3DX < 1000.0 || xp > -200 && xp < 520)) { + iPixelY = (iScreenSize * (199 - (int)dScreenY)) >> + 6; // Complex visibility test for different distance ranges + if (fOriginalZ >= 5000.0 && xp >= -50 && xp < 370 && yp >= -50 && + yp < 250 || + fOriginalZ > -1000.0 && fOriginalZ < 5000.0 && + (fTransformed3DX > -1000.0 && fTransformed3DX < 1000.0 || + xp > -200 && xp < 520)) { GameRenderVertex verts[4]; - float fHalfPixelSize = fClampedZ * 3.0f * 64.0f / ((float)scr_size * (float)VIEWDIST); - float viewOffsetX[4] = { fHalfPixelSize, -fHalfPixelSize, -fHalfPixelSize, fHalfPixelSize }; - float viewOffsetY[4] = { fHalfPixelSize, fHalfPixelSize, -fHalfPixelSize, -fHalfPixelSize }; + float fHalfPixelSize = + fClampedZ * 3.0f * 64.0f / ((float)scr_size * (float)VIEWDIST); + float viewOffsetX[4] = {fHalfPixelSize, -fHalfPixelSize, -fHalfPixelSize, + fHalfPixelSize}; + float viewOffsetY[4] = {fHalfPixelSize, fHalfPixelSize, -fHalfPixelSize, + -fHalfPixelSize}; for (int vi = 0; vi < 4; vi++) { - verts[vi].x = TowerX[iTowerIdx] + viewOffsetX[vi] * vk1 + viewOffsetY[vi] * vk2; - verts[vi].y = TowerY[iTowerIdx] + viewOffsetX[vi] * vk4 + viewOffsetY[vi] * vk5; - verts[vi].z = TowerZ[iTowerIdx] + viewOffsetX[vi] * vk7 + viewOffsetY[vi] * vk8; + verts[vi].x = + TowerX[iTowerIdx] + viewOffsetX[vi] * vk1 + viewOffsetY[vi] * vk2; + verts[vi].y = + TowerY[iTowerIdx] + viewOffsetX[vi] * vk4 + viewOffsetY[vi] * vk5; + verts[vi].z = + TowerZ[iTowerIdx] + viewOffsetX[vi] * vk7 + viewOffsetY[vi] * vk8; verts[vi].u = 0.0f; verts[vi].v = 0.0f; } - game_render_quad_world( - g_pGameRenderer, - verts, - TEXTURE_HANDLE_INVALID, - SURFACE_FLAG_FLIP_BACKFACE | 0xE7, - 1.0f); + game_render_quad_world(g_pGameRenderer, verts, TEXTURE_HANDLE_INVALID, + SURFACE_FLAG_FLIP_BACKFACE | 0xE7, 1.0f); } } } diff --git a/PROJECTS/ROLLER/tower.h b/PROJECTS/ROLLER/tower.h index cc997f90..f4fd2f51 100644 --- a/PROJECTS/ROLLER/tower.h +++ b/PROJECTS/ROLLER/tower.h @@ -4,8 +4,7 @@ #include "polyf.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { int iChunkIdx; int iHOffset; int iVOffset; diff --git a/PROJECTS/ROLLER/transfrm.c b/PROJECTS/ROLLER/transfrm.c index 7a5bf7b0..a3182503 100644 --- a/PROJECTS/ROLLER/transfrm.c +++ b/PROJECTS/ROLLER/transfrm.c @@ -6,39 +6,38 @@ #include //------------------------------------------------------------------------------------------------- -float vk1; //00189950 -int xp; //00189954 -float vk2; //00189958 -float vk3; //0018995C -float vk4; //00189960 -float vk5; //00189964 -float vk6; //00189968 -float vk7; //0018996C -float vk8; //00189970 -float vk9; //00189974 -int yp; //00189978 +float vk1; // 00189950 +int xp; // 00189954 +float vk2; // 00189958 +float vk3; // 0018995C +float vk4; // 00189960 +float vk5; // 00189964 +float vk6; // 00189968 +float vk7; // 0018996C +float vk8; // 00189970 +float vk9; // 00189974 +int yp; // 00189978 //------------------------------------------------------------------------------------------------- -//00060A40 -void calculatetransform(int iTrackChunkIdx, int iDirection, int iElevation, int iTilt, - float fViewX, float fViewY, float fViewZ, - float fPosX, float fPosY, float fPosZ) -{ - double v10; // st7 - double v11; // st7 - double dVk9; // st7 +// 00060A40 +void calculatetransform(int iTrackChunkIdx, int iDirection, int iElevation, + int iTilt, float fViewX, float fViewY, float fViewZ, + float fPosX, float fPosY, float fPosZ) { + double v10; // st7 + double v11; // st7 + double dVk9; // st7 tData *pData; // eax - double v14; // st6 - double dZ; // st5 - float v16; // [esp+0h] [ebp-2Ch] - float v17; // [esp+4h] [ebp-28h] - float v18; // [esp+8h] [ebp-24h] - float v19; // [esp+Ch] [ebp-20h] - float v20; // [esp+10h] [ebp-1Ch] - float v21; // [esp+14h] [ebp-18h] - float v22; // [esp+1Ch] [ebp-10h] - float v23; // [esp+20h] [ebp-Ch] - float v24; // [esp+24h] [ebp-8h] + double v14; // st6 + double dZ; // st5 + float v16; // [esp+0h] [ebp-2Ch] + float v17; // [esp+4h] [ebp-28h] + float v18; // [esp+8h] [ebp-24h] + float v19; // [esp+Ch] [ebp-20h] + float v20; // [esp+10h] [ebp-1Ch] + float v21; // [esp+14h] [ebp-18h] + float v22; // [esp+1Ch] [ebp-10h] + float v23; // [esp+20h] [ebp-Ch] + float v24; // [esp+24h] [ebp-8h] v10 = tcos[iDirection] * tsin[iElevation]; vk1 = tsin[iDirection] * tcos[iTilt] - (float)v10 * tsin[iTilt]; @@ -57,26 +56,28 @@ void calculatetransform(int iTrackChunkIdx, int iDirection, int iElevation, int vk9 = (float)dVk9; if (iTrackChunkIdx != -1) { pData = &localdata[iTrackChunkIdx]; - viewx = pData->pointAy[0].fX * fViewX - - pData->pointAy[3].fX - + pData->pointAy[0].fY * fViewY - + pData->pointAy[0].fZ * fViewZ; - viewy = pData->pointAy[1].fX * fViewX - - pData->pointAy[3].fY - + pData->pointAy[1].fY * fViewY - + pData->pointAy[1].fZ * fViewZ; - viewz = fViewY * pData->pointAy[2].fY - + fViewX * pData->pointAy[2].fX - - pData->pointAy[3].fZ - + fViewZ * pData->pointAy[2].fZ; - v21 = pData->pointAy[0].fY * vk4 + pData->pointAy[0].fX * vk1 + pData->pointAy[0].fZ * vk7; - v24 = pData->pointAy[0].fY * vk5 + pData->pointAy[0].fX * vk2 + pData->pointAy[0].fZ * vk8; - v16 = pData->pointAy[0].fY * vk6 + pData->pointAy[0].fX * vk3 + pData->pointAy[0].fZ * vk9; - v20 = pData->pointAy[1].fX * vk1 + pData->pointAy[1].fY * vk4 + pData->pointAy[1].fZ * vk7; - v18 = pData->pointAy[1].fX * vk2 + pData->pointAy[1].fY * vk5 + pData->pointAy[1].fZ * vk8; - v19 = pData->pointAy[1].fX * vk3 + pData->pointAy[1].fY * vk6 + pData->pointAy[1].fZ * vk9; - v17 = pData->pointAy[2].fX * vk1 + pData->pointAy[2].fY * vk4 + pData->pointAy[2].fZ * vk7; - v22 = vk8 * pData->pointAy[2].fZ + pData->pointAy[2].fX * vk2 + pData->pointAy[2].fY * vk5; + viewx = pData->pointAy[0].fX * fViewX - pData->pointAy[3].fX + + pData->pointAy[0].fY * fViewY + pData->pointAy[0].fZ * fViewZ; + viewy = pData->pointAy[1].fX * fViewX - pData->pointAy[3].fY + + pData->pointAy[1].fY * fViewY + pData->pointAy[1].fZ * fViewZ; + viewz = fViewY * pData->pointAy[2].fY + fViewX * pData->pointAy[2].fX - + pData->pointAy[3].fZ + fViewZ * pData->pointAy[2].fZ; + v21 = pData->pointAy[0].fY * vk4 + pData->pointAy[0].fX * vk1 + + pData->pointAy[0].fZ * vk7; + v24 = pData->pointAy[0].fY * vk5 + pData->pointAy[0].fX * vk2 + + pData->pointAy[0].fZ * vk8; + v16 = pData->pointAy[0].fY * vk6 + pData->pointAy[0].fX * vk3 + + pData->pointAy[0].fZ * vk9; + v20 = pData->pointAy[1].fX * vk1 + pData->pointAy[1].fY * vk4 + + pData->pointAy[1].fZ * vk7; + v18 = pData->pointAy[1].fX * vk2 + pData->pointAy[1].fY * vk5 + + pData->pointAy[1].fZ * vk8; + v19 = pData->pointAy[1].fX * vk3 + pData->pointAy[1].fY * vk6 + + pData->pointAy[1].fZ * vk9; + v17 = pData->pointAy[2].fX * vk1 + pData->pointAy[2].fY * vk4 + + pData->pointAy[2].fZ * vk7; + v22 = vk8 * pData->pointAy[2].fZ + pData->pointAy[2].fX * vk2 + + pData->pointAy[2].fY * vk5; v14 = pData->pointAy[2].fX * vk3 + pData->pointAy[2].fY * vk6; dZ = pData->pointAy[2].fZ; vk1 = v21; @@ -96,112 +97,114 @@ void calculatetransform(int iTrackChunkIdx, int iDirection, int iElevation, int } //------------------------------------------------------------------------------------------------- -//00060DE0 -void initlocaltrack() -{ // Initialize each track segment's local data - int i; // edx +// 00060DE0 +void initlocaltrack() { // Initialize each track segment's local data + int i; // edx for (i = 0; i < TRAK_LEN; ++i) initlocalsection(i); - dopitchchanges(0, 2); // Calculate pitch angles for inner track lanes (left=0, right=2) - dopitchchanges(3, 4); // Calculate pitch angles for outer track lanes (left=3, right=4) + dopitchchanges( + 0, 2); // Calculate pitch angles for inner track lanes (left=0, right=2) + dopitchchanges( + 3, 4); // Calculate pitch angles for outer track lanes (left=3, right=4) } //------------------------------------------------------------------------------------------------- -//00060E20 -void initlocalsection(int iChunkIdx) -{ - int iNextChunk; // ecx +// 00060E20 +void initlocalsection(int iChunkIdx) { + int iNextChunk; // ecx int iNextNextChunk; // esi - int iArrayIndex; // eax - tData *pData; // edx - uint32 uiOffset; // eax - double fTemp; // st7 - int iLoop1; // ebx - double fAngleY; // st7 - double dSinY; // rt0 - double dTempRot; // st5 - int iLoop2; // ebx - double fAngleZ; // st7 - double dSinZ; // st6 - double dTempRotZ; // st5 - int iLoop3; // ebx - double dAngleX; // st6 - double dCosX; // st7 - double dTempRotX; // st5 - //int16 nFpStatus1; // fps + int iArrayIndex; // eax + tData *pData; // edx + uint32 uiOffset; // eax + double fTemp; // st7 + int iLoop1; // ebx + double fAngleY; // st7 + double dSinY; // rt0 + double dTempRot; // st5 + int iLoop2; // ebx + double fAngleZ; // st7 + double dSinZ; // st6 + double dTempRotZ; // st5 + int iLoop3; // ebx + double dAngleX; // st6 + double dCosX; // st7 + double dTempRotX; // st5 + // int16 nFpStatus1; // fps double fBankAngle; // st7 - //int16 nFpStatus2; // fps - double fBankDelta; // st7 - double dCosAngleY; // rt0 - double dCosAngleZ; // rt1 - uint32 uiOffset2; // eax - double dMatrix_2_2; // st7 - double dMatrix_0_2; // st6 - double dMatrix_1_2; // st5 - double dMatrix_2_1; // st4 - double dMatrix_0_1; // st3 - double dTransformedZ; // st2 - int iLoop4; // ebx - double dNextAngleY; // st7 - double dSinNextY; // rt0 - double dTemPRotNextY; // st5 - int iLoop5; // ebx - double dNextAngleZ; // st7 - double dSinNextZ; // st6 - double dTempRotNextZ; // st5 - double dAngleYFixed; // st7 - double dAngleZFixed; // st7 - double dAngleXFixed; // st7 - int iYawTemp; // esi - int iPitchTemp; // ebp - int iRollTemp; // ebx - double matrixWork[30]; // [esp+0h] [ebp-2A8h] - double pointArray[27]; // [esp+F0h] [ebp-1B8h] - double dRotatedZ; // [esp+1C8h] [ebp-E0h] - double dRotatedY; // [esp+1D0h] [ebp-D8h] - double dRotatedX; // [esp+1D8h] [ebp-D0h] - double dAngleZSaved; // [esp+1E0h] [ebp-C8h] - double dCosXSaved; // [esp+1E8h] [ebp-C0h] - double dSinXSaved; // [esp+1F0h] [ebp-B8h] - double dCosY_1; // [esp+1F8h] [ebp-B0h] - double dCosYSinZ; // [esp+208h] [ebp-A0h] - double dSinZMat; // [esp+210h] [ebp-98h] - double dAngleXBank; // [esp+218h] [ebp-90h] + // int16 nFpStatus2; // fps + double fBankDelta; // st7 + double dCosAngleY; // rt0 + double dCosAngleZ; // rt1 + uint32 uiOffset2; // eax + double dMatrix_2_2; // st7 + double dMatrix_0_2; // st6 + double dMatrix_1_2; // st5 + double dMatrix_2_1; // st4 + double dMatrix_0_1; // st3 + double dTransformedZ; // st2 + int iLoop4; // ebx + double dNextAngleY; // st7 + double dSinNextY; // rt0 + double dTemPRotNextY; // st5 + int iLoop5; // ebx + double dNextAngleZ; // st7 + double dSinNextZ; // st6 + double dTempRotNextZ; // st5 + double dAngleYFixed; // st7 + double dAngleZFixed; // st7 + double dAngleXFixed; // st7 + int iYawTemp; // esi + int iPitchTemp; // ebp + int iRollTemp; // ebx + double matrixWork[30]; // [esp+0h] [ebp-2A8h] + double pointArray[27]; // [esp+F0h] [ebp-1B8h] + double dRotatedZ; // [esp+1C8h] [ebp-E0h] + double dRotatedY; // [esp+1D0h] [ebp-D8h] + double dRotatedX; // [esp+1D8h] [ebp-D0h] + double dAngleZSaved; // [esp+1E0h] [ebp-C8h] + double dCosXSaved; // [esp+1E8h] [ebp-C0h] + double dSinXSaved; // [esp+1F0h] [ebp-B8h] + double dCosY_1; // [esp+1F8h] [ebp-B0h] + double dCosYSinZ; // [esp+208h] [ebp-A0h] + double dSinZMat; // [esp+210h] [ebp-98h] + double dAngleXBank; // [esp+218h] [ebp-90h] double dNextAngleZSaved; // [esp+220h] [ebp-88h] - double dMatrix00; // [esp+228h] [ebp-80h] - double dMatrix01; // [esp+230h] [ebp-78h] - double dSinZSaved; // [esp+238h] [ebp-70h] - double dMatrix10; // [esp+240h] [ebp-68h] - double dMatrix12; // [esp+248h] [ebp-60h] - double dMatrix02; // [esp+250h] [ebp-58h] - double dMatrix21; // [esp+258h] [ebp-50h] - double dMatrix10_2; // [esp+260h] [ebp-48h] - double dCosY; // [esp+268h] [ebp-40h] + double dMatrix00; // [esp+228h] [ebp-80h] + double dMatrix01; // [esp+230h] [ebp-78h] + double dSinZSaved; // [esp+238h] [ebp-70h] + double dMatrix10; // [esp+240h] [ebp-68h] + double dMatrix12; // [esp+248h] [ebp-60h] + double dMatrix02; // [esp+250h] [ebp-58h] + double dMatrix21; // [esp+258h] [ebp-50h] + double dMatrix10_2; // [esp+260h] [ebp-48h] + double dCosY; // [esp+268h] [ebp-40h] double dNextAngleYSaved; // [esp+270h] [ebp-38h] - double dMatrix22; // [esp+278h] [ebp-30h] - double dWorkAngle; // [esp+280h] [ebp-28h] - double dAngleYSaved; // [esp+288h] [ebp-20h] + double dMatrix22; // [esp+278h] [ebp-30h] + double dWorkAngle; // [esp+280h] [ebp-28h] + double dAngleYSaved; // [esp+288h] [ebp-20h] - iNextChunk = iChunkIdx + 1; // Get next chunk index with wraparound + iNextChunk = iChunkIdx + 1; // Get next chunk index with wraparound if (iChunkIdx + 1 == TRAK_LEN) iNextChunk ^= TRAK_LEN; - iNextNextChunk = iNextChunk + 1; // Get chunk index two ahead with wraparound + iNextNextChunk = iNextChunk + 1; // Get chunk index two ahead with wraparound if (iNextChunk + 1 == TRAK_LEN) iNextNextChunk ^= TRAK_LEN; iArrayIndex = iChunkIdx; // Extract track points for current chunk (left and right edges) - pointArray[0] = TrakPt[iArrayIndex].pointAy[2].fX;// Point 0: Current left edge + pointArray[0] = + TrakPt[iArrayIndex].pointAy[2].fX; // Point 0: Current left edge pointArray[1] = TrakPt[iArrayIndex].pointAy[2].fY; pointArray[2] = TrakPt[iArrayIndex].pointAy[2].fZ; - pointArray[3] = TrakPt[iArrayIndex].pointAy[3].fX;// Point 1: Current right edge + pointArray[3] = + TrakPt[iArrayIndex].pointAy[3].fX; // Point 1: Current right edge pointArray[4] = TrakPt[iArrayIndex].pointAy[3].fY; pointArray[5] = TrakPt[iArrayIndex].pointAy[3].fZ; - pointArray[6] = TrakPt[iNextChunk].pointAy[2].fX;// Point 2: Next left edge + pointArray[6] = TrakPt[iNextChunk].pointAy[2].fX; // Point 2: Next left edge pointArray[7] = TrakPt[iNextChunk].pointAy[2].fY; pointArray[8] = TrakPt[iNextChunk].pointAy[2].fZ; - pointArray[9] = TrakPt[iNextChunk].pointAy[3].fX;// Point 3: Next right edge + pointArray[9] = TrakPt[iNextChunk].pointAy[3].fX; // Point 3: Next right edge pointArray[10] = TrakPt[iNextChunk].pointAy[3].fY; pointArray[11] = TrakPt[iNextChunk].pointAy[3].fZ; // Calculate midpoints between left and right track edges @@ -226,9 +229,10 @@ void initlocalsection(int iChunkIdx) pData->pointAy[3].fX = (float)-pointArray[24]; pData->pointAy[3].fY = (float)-pointArray[25]; uiOffset = 0; - pData->pointAy[3].fZ = (float) - pointArray[26]; + pData->pointAy[3].fZ = (float)-pointArray[26]; do { - // Transform all points to local coordinate system (centered at track section) + // Transform all points to local coordinate system (centered at track + // section) pointArray[uiOffset] = pData->pointAy[3].fX + pointArray[uiOffset]; pointArray[uiOffset + 1] = pData->pointAy[3].fY + pointArray[uiOffset + 1]; pointArray[uiOffset + 2] = pData->pointAy[3].fZ + pointArray[uiOffset + 2]; @@ -239,35 +243,44 @@ void initlocalsection(int iChunkIdx) pointArray[uiOffset + 7] = pData->pointAy[3].fY + pointArray[uiOffset + 7]; fTemp = pData->pointAy[3].fZ + pointArray[uiOffset + 8]; - //moving this above offset increment + // moving this above offset increment pointArray[uiOffset + 8] = fTemp; - + uiOffset += 9u; - //matrixWork[uiOffset + 29] = fTemp; // pointArray[uiOffset + 8] = if moved above uiOffset increment + // matrixWork[uiOffset + 29] = fTemp; // pointArray[uiOffset + 8] = + // if moved above uiOffset increment } while (uiOffset != 27); iLoop1 = 0; - fAngleY = getdirection(pointArray[15] - pointArray[12], pointArray[16] - pointArray[13]);// Calculate Y rotation angle from track direction + fAngleY = getdirection( + pointArray[15] - pointArray[12], + pointArray[16] - + pointArray[13]); // Calculate Y rotation angle from track direction dAngleYSaved = fAngleY; do { - dSinY = sin(-fAngleY); // Apply Y-axis rotation to align track with coordinate axes + dSinY = sin( + -fAngleY); // Apply Y-axis rotation to align track with coordinate axes dCosY = cos(-fAngleY); dTempRot = pointArray[iLoop1 + 1] * dSinY; dCosY_1 = dCosY; dRotatedX = pointArray[iLoop1] * dCosY - dTempRot; dRotatedY = dSinY * pointArray[iLoop1] + pointArray[iLoop1 + 1] * dCosY; - //moving this above loop increment + // moving this above loop increment pointArray[iLoop1] = dRotatedX; pointArray[iLoop1 + 1] = dRotatedY; iLoop1 += 3; - //LODWORD(matrixWork[iLoop1 + 27]) = LODWORD(dRotatedX);// pointArray[iLoop] = if moved above iLoop increment - //HIDWORD(matrixWork[iLoop1 + 27]) = HIDWORD(dRotatedX); - //LODWORD(matrixWork[iLoop1 + 28]) = LODWORD(dRotatedY); - //HIDWORD(matrixWork[iLoop1 + 28]) = HIDWORD(dRotatedY); + // LODWORD(matrixWork[iLoop1 + 27]) = LODWORD(dRotatedX);// + // pointArray[iLoop] = if moved above iLoop increment + // HIDWORD(matrixWork[iLoop1 + 27]) = HIDWORD(dRotatedX); + // LODWORD(matrixWork[iLoop1 + 28]) = LODWORD(dRotatedY); + // HIDWORD(matrixWork[iLoop1 + 28]) = HIDWORD(dRotatedY); } while (iLoop1 != 27); iLoop2 = 0; - fAngleZ = getdirection(pointArray[15] - pointArray[12], pointArray[17] - pointArray[14]);// Calculate Z rotation angle (track slope/elevation) + fAngleZ = getdirection( + pointArray[15] - pointArray[12], + pointArray[17] - + pointArray[14]); // Calculate Z rotation angle (track slope/elevation) dAngleZSaved = fAngleZ; do { dSinZ = sin(fAngleZ); @@ -277,18 +290,22 @@ void initlocalsection(int iChunkIdx) dRotatedX = dTempRotZ + pointArray[iLoop2] * dCosY; dRotatedZ = pointArray[iLoop2 + 2] * dCosY + -dSinZ * pointArray[iLoop2]; - //moving this above loop increment + // moving this above loop increment pointArray[iLoop2] = dRotatedX; pointArray[iLoop2 + 2] = dRotatedZ; iLoop2 += 3; - //LODWORD(matrixWork[iLoop2 + 27]) = LODWORD(dRotatedX);// pointArray[iLoop2] = if moved above iLoop2 increment - //HIDWORD(matrixWork[iLoop2 + 27]) = HIDWORD(dRotatedX); - //LODWORD(matrixWork[iLoop2 + 29]) = LODWORD(dRotatedZ); - //HIDWORD(matrixWork[iLoop2 + 29]) = HIDWORD(dRotatedZ); + // LODWORD(matrixWork[iLoop2 + 27]) = LODWORD(dRotatedX);// + // pointArray[iLoop2] = if moved above iLoop2 increment + // HIDWORD(matrixWork[iLoop2 + 27]) = HIDWORD(dRotatedX); + // LODWORD(matrixWork[iLoop2 + 29]) = LODWORD(dRotatedZ); + // HIDWORD(matrixWork[iLoop2 + 29]) = HIDWORD(dRotatedZ); } while (iLoop2 != 27); iLoop3 = 0; - dAngleXBank = getdirection(pointArray[19] - pointArray[22], pointArray[23] - pointArray[20]);// Calculate X rotation angle (track banking) + dAngleXBank = getdirection( + pointArray[19] - pointArray[22], + pointArray[23] - + pointArray[20]); // Calculate X rotation angle (track banking) dAngleX = dAngleXBank; do { dCosX = cos(dAngleX); @@ -298,24 +315,32 @@ void initlocalsection(int iChunkIdx) dRotatedY = dTempRotX - pointArray[iLoop3 + 2] * dCosY; dRotatedZ = pointArray[iLoop3 + 1] * dCosY + pointArray[iLoop3 + 2] * dCosX; - //moving this above loop increment + // moving this above loop increment pointArray[iLoop3 + 1] = dRotatedY; pointArray[iLoop3 + 2] = dRotatedZ; iLoop3 += 3; - //LODWORD(matrixWork[iLoop3 + 28]) = LODWORD(dRotatedY);// pointArray[iLoop3] = if moved above iLoop3 increment - //HIDWORD(matrixWork[iLoop3 + 28]) = HIDWORD(dRotatedY); - //LODWORD(matrixWork[iLoop3 + 29]) = LODWORD(dRotatedZ); - //HIDWORD(matrixWork[iLoop3 + 29]) = HIDWORD(dRotatedZ); + // LODWORD(matrixWork[iLoop3 + 28]) = LODWORD(dRotatedY);// + // pointArray[iLoop3] = if moved above iLoop3 increment + // HIDWORD(matrixWork[iLoop3 + 28]) = HIDWORD(dRotatedY); + // LODWORD(matrixWork[iLoop3 + 29]) = LODWORD(dRotatedZ); + // HIDWORD(matrixWork[iLoop3 + 29]) = HIDWORD(dRotatedZ); } while (iLoop3 != 27); dCosXSaved = dCosX; // Calculate banking angle difference for physics - fBankAngle = atan2(pointArray[7] - pointArray[10], pointArray[11] - pointArray[8]); - //fBankAngle = IF_DATAN2(nFpStatus1, pointArray[7] - pointArray[10], pointArray[11] - pointArray[8]); - fBankDelta = (fBankAngle - atan2(pointArray[1] - pointArray[4], pointArray[5] - pointArray[2])) * 16384.0 / 6.28318530718 + 0.5; - //fBankDelta = (fBankAngle - atan2(pointArray[5] - pointArray[2], fBankAngle)) * 16384.0 / 6.28318530718 + 0.5; - //fBankDelta = (fBankAngle - IF_DATAN2(nFpStatus2, pointArray[5] - pointArray[2], fBankAngle)) * 16384.0 / 6.28318530718 + 0.5; + fBankAngle = + atan2(pointArray[7] - pointArray[10], pointArray[11] - pointArray[8]); + // fBankAngle = IF_DATAN2(nFpStatus1, pointArray[7] - pointArray[10], + // pointArray[11] - pointArray[8]); + fBankDelta = (fBankAngle - atan2(pointArray[1] - pointArray[4], + pointArray[5] - pointArray[2])) * + 16384.0 / 6.28318530718 + + 0.5; + // fBankDelta = (fBankAngle - atan2(pointArray[5] - pointArray[2], + // fBankAngle)) * 16384.0 / 6.28318530718 + 0.5; fBankDelta = (fBankAngle - + // IF_DATAN2(nFpStatus2, pointArray[5] - pointArray[2], fBankAngle)) * 16384.0 + // / 6.28318530718 + 0.5; floor(fBankDelta); //_CHP(); pData->iBankDelta = (int)-fBankDelta; @@ -387,20 +412,24 @@ void initlocalsection(int iChunkIdx) dMatrix_2_1 = dMatrix21; dMatrix_0_1 = dMatrix01; do { - matrixWork[uiOffset2 + 3] = (pData->pointAy[3].fY + pointArray[uiOffset2 + 1]) * dMatrix10_2 - + (pData->pointAy[3].fX + pointArray[uiOffset2]) * dMatrix00 - + (pData->pointAy[3].fZ + pointArray[uiOffset2 + 2]) * dSinZSaved; - matrixWork[uiOffset2 + 4] = (pData->pointAy[3].fY + pointArray[uiOffset2 + 1]) * dMatrix10 - + (pData->pointAy[3].fX + pointArray[uiOffset2]) * dMatrix_0_1 - + (pData->pointAy[3].fZ + pointArray[uiOffset2 + 2]) * dMatrix_2_1; - dTransformedZ = (pData->pointAy[3].fY + pointArray[uiOffset2 + 1]) * dMatrix_1_2 - + (pData->pointAy[3].fX + pointArray[uiOffset2]) * dMatrix_0_2 - + (pData->pointAy[3].fZ + pointArray[uiOffset2 + 2]) * dMatrix_2_2; + matrixWork[uiOffset2 + 3] = + (pData->pointAy[3].fY + pointArray[uiOffset2 + 1]) * dMatrix10_2 + + (pData->pointAy[3].fX + pointArray[uiOffset2]) * dMatrix00 + + (pData->pointAy[3].fZ + pointArray[uiOffset2 + 2]) * dSinZSaved; + matrixWork[uiOffset2 + 4] = + (pData->pointAy[3].fY + pointArray[uiOffset2 + 1]) * dMatrix10 + + (pData->pointAy[3].fX + pointArray[uiOffset2]) * dMatrix_0_1 + + (pData->pointAy[3].fZ + pointArray[uiOffset2 + 2]) * dMatrix_2_1; + dTransformedZ = + (pData->pointAy[3].fY + pointArray[uiOffset2 + 1]) * dMatrix_1_2 + + (pData->pointAy[3].fX + pointArray[uiOffset2]) * dMatrix_0_2 + + (pData->pointAy[3].fZ + pointArray[uiOffset2 + 2]) * dMatrix_2_2; uiOffset2 += 3; matrixWork[uiOffset2 + 2] = dTransformedZ; } while (uiOffset2 != 27); iLoop4 = 0; - dNextAngleY = getdirection(matrixWork[18] - matrixWork[15], matrixWork[19] - matrixWork[16]); + dNextAngleY = getdirection(matrixWork[18] - matrixWork[15], + matrixWork[19] - matrixWork[16]); dNextAngleYSaved = dNextAngleY; do { dSinNextY = sin(-dNextAngleY); @@ -408,18 +437,20 @@ void initlocalsection(int iChunkIdx) dTemPRotNextY = matrixWork[iLoop4 + 4] * dSinNextY; dCosY = dWorkAngle; dRotatedX = matrixWork[iLoop4 + 3] * dWorkAngle - dTemPRotNextY; - dRotatedY = dSinNextY * matrixWork[iLoop4 + 3] + matrixWork[iLoop4 + 4] * dWorkAngle; + dRotatedY = dSinNextY * matrixWork[iLoop4 + 3] + + matrixWork[iLoop4 + 4] * dWorkAngle; iLoop4 += 3; matrixWork[iLoop4] = dRotatedX; matrixWork[iLoop4 + 1] = dRotatedY; - //LODWORD(matrixWork[iLoop4]) = LODWORD(dRotatedX); - //HIDWORD(matrixWork[iLoop4]) = HIDWORD(dRotatedX); - //LODWORD(matrixWork[iLoop4 + 1]) = LODWORD(dRotatedY); - //HIDWORD(matrixWork[iLoop4 + 1]) = HIDWORD(dRotatedY); + // LODWORD(matrixWork[iLoop4]) = LODWORD(dRotatedX); + // HIDWORD(matrixWork[iLoop4]) = HIDWORD(dRotatedX); + // LODWORD(matrixWork[iLoop4 + 1]) = LODWORD(dRotatedY); + // HIDWORD(matrixWork[iLoop4 + 1]) = HIDWORD(dRotatedY); } while (iLoop4 != 27); iLoop5 = 0; - dNextAngleZ = getdirection(matrixWork[18] - matrixWork[15], matrixWork[20] - matrixWork[17]); + dNextAngleZ = getdirection(matrixWork[18] - matrixWork[15], + matrixWork[20] - matrixWork[17]); dNextAngleZSaved = dNextAngleZ; do { dSinNextZ = sin(dNextAngleZ); @@ -427,19 +458,22 @@ void initlocalsection(int iChunkIdx) dTempRotNextZ = matrixWork[iLoop5 + 5] * dSinNextZ; dCosY_1 = dWorkAngle; dRotatedX = dTempRotNextZ + matrixWork[iLoop5 + 3] * dWorkAngle; - dRotatedZ = matrixWork[iLoop5 + 5] * dWorkAngle + -dSinNextZ * matrixWork[iLoop5 + 3]; + dRotatedZ = matrixWork[iLoop5 + 5] * dWorkAngle + + -dSinNextZ * matrixWork[iLoop5 + 3]; iLoop5 += 3; matrixWork[iLoop5] = dRotatedX; matrixWork[iLoop5 + 2] = dRotatedZ; - //LODWORD(matrixWork[iLoop5]) = LODWORD(dRotatedX); - //HIDWORD(matrixWork[iLoop5]) = HIDWORD(dRotatedX); - //LODWORD(matrixWork[iLoop5 + 2]) = LODWORD(dRotatedZ); - //HIDWORD(matrixWork[iLoop5 + 2]) = HIDWORD(dRotatedZ); + // LODWORD(matrixWork[iLoop5]) = LODWORD(dRotatedX); + // HIDWORD(matrixWork[iLoop5]) = HIDWORD(dRotatedX); + // LODWORD(matrixWork[iLoop5 + 2]) = LODWORD(dRotatedZ); + // HIDWORD(matrixWork[iLoop5 + 2]) = HIDWORD(dRotatedZ); } while (iLoop5 != 27); - dWorkAngle = getdirection(matrixWork[22] - matrixWork[25], matrixWork[26] - matrixWork[23]); - dCosY = 1.0 / 6.28318530718; // Convert angles to internal fixed-point format (16384 = 2pi radians) + dWorkAngle = getdirection(matrixWork[22] - matrixWork[25], + matrixWork[26] - matrixWork[23]); + dCosY = 1.0 / 6.28318530718; // Convert angles to internal fixed-point format + // (16384 = 2pi radians) dAngleYFixed = dNextAngleYSaved * 16384.0 * dCosY + 0.5; floor(dAngleYFixed); //_CHP(); @@ -462,109 +496,111 @@ void initlocalsection(int iChunkIdx) iRollTemp = pData->iRoll; if (iRollTemp > 0x2000) pData->iRoll = iRollTemp - 0x4000; - pData->gravity.fX = (float)(dSinZSaved * -3.0); // Store up vector scaled by -3 for physics calculations + pData->gravity.fX = + (float)(dSinZSaved * + -3.0); // Store up vector scaled by -3 for physics calculations pData->gravity.fY = (float)(dMatrix21 * -3.0); pData->gravity.fZ = (float)(dMatrix22 * -3.0); } //------------------------------------------------------------------------------------------------- -//00061C90 -void dopitchchanges(int iLLaneIdx, int iRLaneIdx) -{ - int iTrackIndex; // esi - int iLeftLaneOffset; // ebp - int iRightLaneOffset; // edi - int iNextTrackIndex; // ecx - tData *pCurrentTrackData; // ebx - int uiLoopCounter1; // eax - double dTransformZ1; // st7 - int iBankAngle1; // eax - int iBankAngle2; // eax - int uiLoopCounter2; // eax - double dTransformZ2; // st7 - int iPointIndex; // eax - double dLaneCenterOffsetZ; // st7 - double dLaneCenterOffsetY; // st6 - double dLaneCenterOffsetX; // st5 - double dTempValue; // st4 - int iRotationIndex1; // ebx - double dLaneDirection1; // st7 - double dSinValue1; // rt0 - double dCosValue1; // st5 - int iRotationIndex2; // ebx - double dLaneDirection2; // st7 - double dSinValue2; // st6 - double dCosValue2; // st5 - int iRotationIndex3; // ebx - double dLaneDirection3; // st6 - double dCosValue3; // st7 - double dSinValue3; // st5 - double dMatrixComp1; // rt2 - double dMatrixComp2; // st6 - tData *pNextTrackData; // ebx - int uiTransformLoop; // eax - double dNextTransformZ; // st7 - int iNextBankAngle1; // eax - int iNextBankAngle2; // eax - int uiNextTransformLoop; // eax +// 00061C90 +void dopitchchanges(int iLLaneIdx, int iRLaneIdx) { + int iTrackIndex; // esi + int iLeftLaneOffset; // ebp + int iRightLaneOffset; // edi + int iNextTrackIndex; // ecx + tData *pCurrentTrackData; // ebx + int uiLoopCounter1; // eax + double dTransformZ1; // st7 + int iBankAngle1; // eax + int iBankAngle2; // eax + int uiLoopCounter2; // eax + double dTransformZ2; // st7 + int iPointIndex; // eax + double dLaneCenterOffsetZ; // st7 + double dLaneCenterOffsetY; // st6 + double dLaneCenterOffsetX; // st5 + double dTempValue; // st4 + int iRotationIndex1; // ebx + double dLaneDirection1; // st7 + double dSinValue1; // rt0 + double dCosValue1; // st5 + int iRotationIndex2; // ebx + double dLaneDirection2; // st7 + double dSinValue2; // st6 + double dCosValue2; // st5 + int iRotationIndex3; // ebx + double dLaneDirection3; // st6 + double dCosValue3; // st7 + double dSinValue3; // st5 + double dMatrixComp1; // rt2 + double dMatrixComp2; // st6 + tData *pNextTrackData; // ebx + int uiTransformLoop; // eax + double dNextTransformZ; // st7 + int iNextBankAngle1; // eax + int iNextBankAngle2; // eax + int uiNextTransformLoop; // eax double dNextSegmentTransformZ; // st7 - int uiFinalRotationLoop; // eax - double dMatrixRotValue1; // st7 - double dMatrixRotValue2; // st6 - double dPointY; // st5 - double dPointX; // st3 - double dPointZ; // rt2 - int iDirectionCalcLoop; // ebx - double dFinalDirection; // st7 - double dSinFinal; // rtt - double dCosFinal; // st5 - double dFinalLanePitchAngle; // st7 - tData *pOutputTrackData; // edx - //double transformCoordsOffset[3]; // [esp+0h] [ebp-3DCh] + int uiFinalRotationLoop; // eax + double dMatrixRotValue1; // st7 + double dMatrixRotValue2; // st6 + double dPointY; // st5 + double dPointX; // st3 + double dPointZ; // rt2 + int iDirectionCalcLoop; // ebx + double dFinalDirection; // st7 + double dSinFinal; // rtt + double dCosFinal; // st5 + double dFinalLanePitchAngle; // st7 + tData *pOutputTrackData; // edx + // double transformCoordsOffset[3]; // [esp+0h] [ebp-3DCh] double transformCoords[27]; // [esp+18h] [ebp-3C4h] - double bankRotData[24]; // [esp+F0h] [ebp-2ECh] - //double laneCornerPointsOffset[3]; // [esp+1B0h] [ebp-22Ch] - double laneCornerPoints[27]; // [esp+1C8h] [ebp-214h] - double dRotMatrix00; // [esp+2A0h] [ebp-13Ch] - double dRotMatrix01; // [esp+2A8h] [ebp-134h] - double dRotMatrix02; // [esp+2B0h] [ebp-12Ch] - double dRotMatrix10; // [esp+2B8h] [ebp-124h] - double dRotMatrix11; // [esp+2C0h] [ebp-11Ch] - double dRotMatrix12; // [esp+2C8h] [ebp-114h] - double dRotMatrix20; // [esp+2D0h] [ebp-10Ch] - double dRotMatrix21; // [esp+2D8h] [ebp-104h] - double dRotMatrix22; // [esp+2E8h] [ebp-F4h] - double dTempRotValue1; // [esp+2F0h] [ebp-ECh] - double dSinBank2; // [esp+2F8h] [ebp-E4h] - double dNextSinBank2; // [esp+300h] [ebp-DCh] - double dNextSinBank1; // [esp+308h] [ebp-D4h] - double dSinBank1; // [esp+310h] [ebp-CCh] - double dNextCosBank1; // [esp+318h] [ebp-C4h] - double dLaneDirection1Stored; // [esp+320h] [ebp-BCh] - double dLaneDirectionAngle; // [esp+328h] [ebp-B4h] - double dCosMatrix22; // [esp+330h] [ebp-ACh] - double dSinMatrix10; // [esp+338h] [ebp-A4h] - double dNegSinMatrix20; // [esp+340h] [ebp-9Ch] - double dCosMatrix11; // [esp+348h] [ebp-94h] - double dCosMatrix00; // [esp+350h] [ebp-8Ch] - double dLaneDirection2Stored; // [esp+358h] [ebp-84h] - double dCosDirection3; // [esp+360h] [ebp-7Ch] - double dSinDirection3; // [esp+368h] [ebp-74h] - double dNegCenterOffsetY; // [esp+370h] [ebp-6Ch] - double dNegCenterOffsetZ; // [esp+378h] [ebp-64h] - double dNegCenterOffsetX; // [esp+380h] [ebp-5Ch] - double dTempSin; // [esp+388h] [ebp-54h] - double dStoredPitchAngle; // [esp+390h] [ebp-4Ch] - double dNextCosBank2; // [esp+398h] [ebp-44h] - double dCosBank2; // [esp+3A0h] [ebp-3Ch] - double dCosBank1; // [esp+3A8h] [ebp-34h] - double dTempCos; // [esp+3B0h] [ebp-2Ch] - unsigned int uiLeftLaneOffset12; // [esp+3B8h] [ebp-24h] + double bankRotData[24]; // [esp+F0h] [ebp-2ECh] + // double laneCornerPointsOffset[3]; // [esp+1B0h] [ebp-22Ch] + double laneCornerPoints[27]; // [esp+1C8h] [ebp-214h] + double dRotMatrix00; // [esp+2A0h] [ebp-13Ch] + double dRotMatrix01; // [esp+2A8h] [ebp-134h] + double dRotMatrix02; // [esp+2B0h] [ebp-12Ch] + double dRotMatrix10; // [esp+2B8h] [ebp-124h] + double dRotMatrix11; // [esp+2C0h] [ebp-11Ch] + double dRotMatrix12; // [esp+2C8h] [ebp-114h] + double dRotMatrix20; // [esp+2D0h] [ebp-10Ch] + double dRotMatrix21; // [esp+2D8h] [ebp-104h] + double dRotMatrix22; // [esp+2E8h] [ebp-F4h] + double dTempRotValue1; // [esp+2F0h] [ebp-ECh] + double dSinBank2; // [esp+2F8h] [ebp-E4h] + double dNextSinBank2; // [esp+300h] [ebp-DCh] + double dNextSinBank1; // [esp+308h] [ebp-D4h] + double dSinBank1; // [esp+310h] [ebp-CCh] + double dNextCosBank1; // [esp+318h] [ebp-C4h] + double dLaneDirection1Stored; // [esp+320h] [ebp-BCh] + double dLaneDirectionAngle; // [esp+328h] [ebp-B4h] + double dCosMatrix22; // [esp+330h] [ebp-ACh] + double dSinMatrix10; // [esp+338h] [ebp-A4h] + double dNegSinMatrix20; // [esp+340h] [ebp-9Ch] + double dCosMatrix11; // [esp+348h] [ebp-94h] + double dCosMatrix00; // [esp+350h] [ebp-8Ch] + double dLaneDirection2Stored; // [esp+358h] [ebp-84h] + double dCosDirection3; // [esp+360h] [ebp-7Ch] + double dSinDirection3; // [esp+368h] [ebp-74h] + double dNegCenterOffsetY; // [esp+370h] [ebp-6Ch] + double dNegCenterOffsetZ; // [esp+378h] [ebp-64h] + double dNegCenterOffsetX; // [esp+380h] [ebp-5Ch] + double dTempSin; // [esp+388h] [ebp-54h] + double dStoredPitchAngle; // [esp+390h] [ebp-4Ch] + double dNextCosBank2; // [esp+398h] [ebp-44h] + double dCosBank2; // [esp+3A0h] [ebp-3Ch] + double dCosBank1; // [esp+3A8h] [ebp-34h] + double dTempCos; // [esp+3B0h] [ebp-2Ch] + unsigned int uiLeftLaneOffset12; // [esp+3B8h] [ebp-24h] unsigned int uiRightLaneOffset12; // [esp+3BCh] [ebp-20h] - int iNextTrackIndex2; // [esp+3C0h] [ebp-1Ch] - int iLeftLaneIndex; // [esp+3C4h] [ebp-18h] + int iNextTrackIndex2; // [esp+3C0h] [ebp-1Ch] + int iLeftLaneIndex; // [esp+3C4h] [ebp-18h] - // a1 = iLeftLaneIndex (0=inner left, 3=outer left), a2 = iRightLaneIndex (2=inner right, 4=outer right) + // a1 = iLeftLaneIndex (0=inner left, 3=outer left), a2 = iRightLaneIndex + // (2=inner right, 4=outer right) iLeftLaneIndex = iLLaneIdx; iTrackIndex = 0; @@ -583,71 +619,120 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) iNextTrackIndex2 = iNextTrackIndex + 1; if (iNextTrackIndex + 1 == TRAK_LEN) iNextTrackIndex2 = 0; - laneCornerPoints[0] = TrakPt[0].pointAy[iLeftLaneOffset].fX;// Load current track segment lane corner points into working array + laneCornerPoints[0] = TrakPt[0] + .pointAy[iLeftLaneOffset] + .fX; // Load current track segment lane corner + // points into working array laneCornerPoints[1] = TrakPt[0].pointAy[iLeftLaneOffset].fY; laneCornerPoints[2] = TrakPt[0].pointAy[iLeftLaneOffset].fZ; laneCornerPoints[3] = TrakPt[0].pointAy[iRightLaneOffset].fX; laneCornerPoints[4] = TrakPt[0].pointAy[iRightLaneOffset].fY; laneCornerPoints[5] = TrakPt[0].pointAy[iRightLaneOffset].fZ; - laneCornerPoints[6] = TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fX; - laneCornerPoints[7] = TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fY; - laneCornerPoints[8] = TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fZ; - laneCornerPoints[9] = TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fX; - laneCornerPoints[10] = TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fY; + laneCornerPoints[6] = + TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fX; + laneCornerPoints[7] = + TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fY; + laneCornerPoints[8] = + TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fZ; + laneCornerPoints[9] = + TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fX; + laneCornerPoints[10] = + TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fY; pCurrentTrackData = &localdata[iTrackIndex]; uiLoopCounter1 = 0; - laneCornerPoints[11] = TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fZ; + laneCornerPoints[11] = + TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fZ; do { - transformCoords[uiLoopCounter1] = (pCurrentTrackData->pointAy[3].fY + laneCornerPoints[uiLoopCounter1 + 1]) * pCurrentTrackData->pointAy[1].fX - + (pCurrentTrackData->pointAy[3].fX + laneCornerPoints[uiLoopCounter1]) * pCurrentTrackData->pointAy[0].fX - + (pCurrentTrackData->pointAy[3].fZ + laneCornerPoints[uiLoopCounter1 + 2]) * pCurrentTrackData->pointAy[2].fX;// Transform points using matrix multiplication - transformCoords[uiLoopCounter1 + 1] = (pCurrentTrackData->pointAy[3].fY + laneCornerPoints[uiLoopCounter1 + 1]) * pCurrentTrackData->pointAy[1].fY - + (pCurrentTrackData->pointAy[3].fX + laneCornerPoints[uiLoopCounter1]) * pCurrentTrackData->pointAy[0].fY - + (pCurrentTrackData->pointAy[3].fZ + laneCornerPoints[uiLoopCounter1 + 2]) * pCurrentTrackData->pointAy[2].fY; - dTransformZ1 = (pCurrentTrackData->pointAy[3].fY + laneCornerPoints[uiLoopCounter1 + 1]) * pCurrentTrackData->pointAy[1].fZ - + (pCurrentTrackData->pointAy[3].fX + laneCornerPoints[uiLoopCounter1]) * pCurrentTrackData->pointAy[0].fZ - + (pCurrentTrackData->pointAy[3].fZ + laneCornerPoints[uiLoopCounter1 + 2]) * pCurrentTrackData->pointAy[2].fZ; + transformCoords[uiLoopCounter1] = + (pCurrentTrackData->pointAy[3].fY + + laneCornerPoints[uiLoopCounter1 + 1]) * + pCurrentTrackData->pointAy[1].fX + + (pCurrentTrackData->pointAy[3].fX + + laneCornerPoints[uiLoopCounter1]) * + pCurrentTrackData->pointAy[0].fX + + (pCurrentTrackData->pointAy[3].fZ + + laneCornerPoints[uiLoopCounter1 + 2]) * + pCurrentTrackData->pointAy[2] + .fX; // Transform points using matrix multiplication + transformCoords[uiLoopCounter1 + 1] = + (pCurrentTrackData->pointAy[3].fY + + laneCornerPoints[uiLoopCounter1 + 1]) * + pCurrentTrackData->pointAy[1].fY + + (pCurrentTrackData->pointAy[3].fX + + laneCornerPoints[uiLoopCounter1]) * + pCurrentTrackData->pointAy[0].fY + + (pCurrentTrackData->pointAy[3].fZ + + laneCornerPoints[uiLoopCounter1 + 2]) * + pCurrentTrackData->pointAy[2].fY; + dTransformZ1 = (pCurrentTrackData->pointAy[3].fY + + laneCornerPoints[uiLoopCounter1 + 1]) * + pCurrentTrackData->pointAy[1].fZ + + (pCurrentTrackData->pointAy[3].fX + + laneCornerPoints[uiLoopCounter1]) * + pCurrentTrackData->pointAy[0].fZ + + (pCurrentTrackData->pointAy[3].fZ + + laneCornerPoints[uiLoopCounter1 + 2]) * + pCurrentTrackData->pointAy[2].fZ; transformCoords[uiLoopCounter1 + 2] = dTransformZ1; uiLoopCounter1 += 3; - //transformCoordsOffset[uiLoopCounter1 + 2] = dTransformZ1;// Store Z coordinate into transformCoords[2+loop_index] via offset alias + // transformCoordsOffset[uiLoopCounter1 + 2] = dTransformZ1;// Store Z + // coordinate into transformCoords[2+loop_index] via offset alias } while (uiLoopCounter1 != 12); // Calculate bank angle for rotation (negative half) iBankAngle1 = (-pCurrentTrackData->iBankDelta / 2) & 0x3FFF; - dCosBank1 = tcos[iBankAngle1]; // Get cosine from lookup table + dCosBank1 = tcos[iBankAngle1]; // Get cosine from lookup table dSinBank1 = tsin[iBankAngle1]; - bankRotData[1] = transformCoords[1] * dCosBank1 - transformCoords[2] * dSinBank1;// Apply first bank rotation transformation - bankRotData[2] = transformCoords[1] * dSinBank1 + transformCoords[2] * dCosBank1; - bankRotData[4] = transformCoords[4] * dCosBank1 - transformCoords[5] * dSinBank1; - bankRotData[5] = transformCoords[4] * dSinBank1 + transformCoords[5] * dCosBank1; + bankRotData[1] = + transformCoords[1] * dCosBank1 - + transformCoords[2] * + dSinBank1; // Apply first bank rotation transformation + bankRotData[2] = + transformCoords[1] * dSinBank1 + transformCoords[2] * dCosBank1; + bankRotData[4] = + transformCoords[4] * dCosBank1 - transformCoords[5] * dSinBank1; + bankRotData[5] = + transformCoords[4] * dSinBank1 + transformCoords[5] * dCosBank1; bankRotData[0] = transformCoords[0]; bankRotData[3] = transformCoords[3]; - iBankAngle2 = (pCurrentTrackData->iBankDelta / 2) & 0x3FFF;// Calculate bank angle for rotation (positive half) + iBankAngle2 = (pCurrentTrackData->iBankDelta / 2) & + 0x3FFF; // Calculate bank angle for rotation (positive half) dCosBank2 = tcos[iBankAngle2]; dSinBank2 = tsin[iBankAngle2]; - bankRotData[7] = transformCoords[7] * dCosBank2 - transformCoords[8] * dSinBank2;// Apply second bank rotation transformation - bankRotData[8] = transformCoords[7] * dSinBank2 + transformCoords[8] * dCosBank2; - bankRotData[10] = transformCoords[10] * dCosBank2 - transformCoords[11] * dSinBank2; + bankRotData[7] = + transformCoords[7] * dCosBank2 - + transformCoords[8] * + dSinBank2; // Apply second bank rotation transformation + bankRotData[8] = + transformCoords[7] * dSinBank2 + transformCoords[8] * dCosBank2; + bankRotData[10] = + transformCoords[10] * dCosBank2 - transformCoords[11] * dSinBank2; bankRotData[6] = transformCoords[6]; bankRotData[9] = transformCoords[9]; uiLoopCounter2 = 0; - bankRotData[11] = transformCoords[10] * dSinBank2 + transformCoords[11] * dCosBank2; + bankRotData[11] = + transformCoords[10] * dSinBank2 + transformCoords[11] * dCosBank2; do { - laneCornerPoints[uiLoopCounter2] = pCurrentTrackData->pointAy[0].fY * bankRotData[uiLoopCounter2 + 1] - + pCurrentTrackData->pointAy[0].fX * bankRotData[uiLoopCounter2] - + pCurrentTrackData->pointAy[0].fZ * bankRotData[uiLoopCounter2 + 2] - - pCurrentTrackData->pointAy[3].fX;// Transform coordinates and subtract offset - laneCornerPoints[uiLoopCounter2 + 1] = pCurrentTrackData->pointAy[1].fY * bankRotData[uiLoopCounter2 + 1] - + pCurrentTrackData->pointAy[1].fX * bankRotData[uiLoopCounter2] - + pCurrentTrackData->pointAy[1].fZ * bankRotData[uiLoopCounter2 + 2] - - pCurrentTrackData->pointAy[3].fY; - dTransformZ2 = pCurrentTrackData->pointAy[2].fY * bankRotData[uiLoopCounter2 + 1] - + pCurrentTrackData->pointAy[2].fX * bankRotData[uiLoopCounter2] - + pCurrentTrackData->pointAy[2].fZ * bankRotData[uiLoopCounter2 + 2] - - pCurrentTrackData->pointAy[3].fZ; + laneCornerPoints[uiLoopCounter2] = + pCurrentTrackData->pointAy[0].fY * bankRotData[uiLoopCounter2 + 1] + + pCurrentTrackData->pointAy[0].fX * bankRotData[uiLoopCounter2] + + pCurrentTrackData->pointAy[0].fZ * bankRotData[uiLoopCounter2 + 2] - + pCurrentTrackData->pointAy[3] + .fX; // Transform coordinates and subtract offset + laneCornerPoints[uiLoopCounter2 + 1] = + pCurrentTrackData->pointAy[1].fY * bankRotData[uiLoopCounter2 + 1] + + pCurrentTrackData->pointAy[1].fX * bankRotData[uiLoopCounter2] + + pCurrentTrackData->pointAy[1].fZ * bankRotData[uiLoopCounter2 + 2] - + pCurrentTrackData->pointAy[3].fY; + dTransformZ2 = + pCurrentTrackData->pointAy[2].fY * bankRotData[uiLoopCounter2 + 1] + + pCurrentTrackData->pointAy[2].fX * bankRotData[uiLoopCounter2] + + pCurrentTrackData->pointAy[2].fZ * bankRotData[uiLoopCounter2 + 2] - + pCurrentTrackData->pointAy[3].fZ; laneCornerPoints[uiLoopCounter2 + 2] = dTransformZ2; uiLoopCounter2 += 3; - //laneCornerPointsOffset[uiLoopCounter2 + 2] = dTransformZ2;// laneCornerPoints[uiLoopCounter2 + 2] when above loop inc + // laneCornerPointsOffset[uiLoopCounter2 + 2] = dTransformZ2;// + // laneCornerPoints[uiLoopCounter2 + 2] when above loop inc } while (uiLoopCounter2 != 12); // Calculate midpoints between corner pairs @@ -663,9 +748,12 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) laneCornerPoints[21] = (laneCornerPoints[3] + laneCornerPoints[9]) * 0.5; laneCornerPoints[22] = (laneCornerPoints[4] + laneCornerPoints[10]) * 0.5; laneCornerPoints[23] = (laneCornerPoints[5] + laneCornerPoints[11]) * 0.5; - laneCornerPoints[24] = (laneCornerPoints[12] + laneCornerPoints[15]) * 0.5; - laneCornerPoints[25] = (laneCornerPoints[13] + laneCornerPoints[16]) * 0.5; - laneCornerPoints[26] = (laneCornerPoints[14] + laneCornerPoints[17]) * 0.5; + laneCornerPoints[24] = + (laneCornerPoints[12] + laneCornerPoints[15]) * 0.5; + laneCornerPoints[25] = + (laneCornerPoints[13] + laneCornerPoints[16]) * 0.5; + laneCornerPoints[26] = + (laneCornerPoints[14] + laneCornerPoints[17]) * 0.5; dNegCenterOffsetX = -laneCornerPoints[24]; dNegCenterOffsetY = -laneCornerPoints[25]; dNegCenterOffsetZ = -laneCornerPoints[26]; @@ -677,24 +765,40 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) dLaneCenterOffsetY = dNegCenterOffsetY; dLaneCenterOffsetX = dNegCenterOffsetX; do { - laneCornerPoints[iPointIndex] = laneCornerPoints[iPointIndex] + dLaneCenterOffsetX; - laneCornerPoints[iPointIndex + 1] = laneCornerPoints[iPointIndex + 1] + dLaneCenterOffsetY; - laneCornerPoints[iPointIndex + 2] = laneCornerPoints[iPointIndex + 2] + dLaneCenterOffsetZ; - laneCornerPoints[iPointIndex + 3] = laneCornerPoints[iPointIndex + 3] + dLaneCenterOffsetX; - laneCornerPoints[iPointIndex + 4] = laneCornerPoints[iPointIndex + 4] + dLaneCenterOffsetY; - laneCornerPoints[iPointIndex + 5] = laneCornerPoints[iPointIndex + 5] + dLaneCenterOffsetZ; - laneCornerPoints[iPointIndex + 6] = laneCornerPoints[iPointIndex + 6] + dLaneCenterOffsetX; - laneCornerPoints[iPointIndex + 7] = laneCornerPoints[iPointIndex + 7] + dLaneCenterOffsetY; - laneCornerPoints[iPointIndex + 8] = laneCornerPoints[iPointIndex + 8] + dLaneCenterOffsetZ; - laneCornerPoints[iPointIndex + 9] = laneCornerPoints[iPointIndex + 9] + dLaneCenterOffsetX; - laneCornerPoints[iPointIndex + 10] = laneCornerPoints[iPointIndex + 10] + dLaneCenterOffsetY; + laneCornerPoints[iPointIndex] = + laneCornerPoints[iPointIndex] + dLaneCenterOffsetX; + laneCornerPoints[iPointIndex + 1] = + laneCornerPoints[iPointIndex + 1] + dLaneCenterOffsetY; + laneCornerPoints[iPointIndex + 2] = + laneCornerPoints[iPointIndex + 2] + dLaneCenterOffsetZ; + laneCornerPoints[iPointIndex + 3] = + laneCornerPoints[iPointIndex + 3] + dLaneCenterOffsetX; + laneCornerPoints[iPointIndex + 4] = + laneCornerPoints[iPointIndex + 4] + dLaneCenterOffsetY; + laneCornerPoints[iPointIndex + 5] = + laneCornerPoints[iPointIndex + 5] + dLaneCenterOffsetZ; + laneCornerPoints[iPointIndex + 6] = + laneCornerPoints[iPointIndex + 6] + dLaneCenterOffsetX; + laneCornerPoints[iPointIndex + 7] = + laneCornerPoints[iPointIndex + 7] + dLaneCenterOffsetY; + laneCornerPoints[iPointIndex + 8] = + laneCornerPoints[iPointIndex + 8] + dLaneCenterOffsetZ; + laneCornerPoints[iPointIndex + 9] = + laneCornerPoints[iPointIndex + 9] + dLaneCenterOffsetX; + laneCornerPoints[iPointIndex + 10] = + laneCornerPoints[iPointIndex + 10] + dLaneCenterOffsetY; dTempValue = laneCornerPoints[iPointIndex + 11] + dLaneCenterOffsetZ; laneCornerPoints[iPointIndex + 11] = dTempValue; iPointIndex += 12; - //laneCornerPointsOffset[iPointIndex + 2] = dTempValue;// laneCornerPoints[iPointIndex + 11] when before loop inc + // laneCornerPointsOffset[iPointIndex + 2] = dTempValue;// + // laneCornerPoints[iPointIndex + 11] when before loop inc } while (iPointIndex != 27); iRotationIndex1 = 0; - dLaneDirection1 = getdirection(laneCornerPoints[15] - laneCornerPoints[12], laneCornerPoints[16] - laneCornerPoints[13]);// Get direction angle for first rotation axis + dLaneDirection1 = + getdirection(laneCornerPoints[15] - laneCornerPoints[12], + laneCornerPoints[16] - + laneCornerPoints[13]); // Get direction angle for + // first rotation axis dLaneDirection1Stored = dLaneDirection1; do { // First rotation pass around calculated direction @@ -702,18 +806,28 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) dTempCos = cos(-dLaneDirection1); dCosValue1 = laneCornerPoints[iRotationIndex1 + 1] * dSinValue1; dRotMatrix21 = dTempCos; - dRotMatrix02 = laneCornerPoints[iRotationIndex1] * dTempCos - dCosValue1; - dRotMatrix01 = dSinValue1 * laneCornerPoints[iRotationIndex1] + laneCornerPoints[iRotationIndex1 + 1] * dTempCos; + dRotMatrix02 = + laneCornerPoints[iRotationIndex1] * dTempCos - dCosValue1; + dRotMatrix01 = dSinValue1 * laneCornerPoints[iRotationIndex1] + + laneCornerPoints[iRotationIndex1 + 1] * dTempCos; laneCornerPoints[iRotationIndex1] = dRotMatrix02; - laneCornerPoints[iRotationIndex1 + 1] = dRotMatrix01; + laneCornerPoints[iRotationIndex1 + 1] = dRotMatrix01; iRotationIndex1 += 3; - //LODWORD(laneCornerPointsOffset[iRotationIndex1]) = LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex1]) = HIDWORD(dRotMatrix02); - //LODWORD(laneCornerPointsOffset[iRotationIndex1 + 1]) = LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex1 + 1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex1 + 1]) = HIDWORD(dRotMatrix01); + // LODWORD(laneCornerPointsOffset[iRotationIndex1]) = + // LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex1] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex1]) = + // HIDWORD(dRotMatrix02); LODWORD(laneCornerPointsOffset[iRotationIndex1 + // + 1]) = LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex1 + + // 1] when before loop inc + // HIDWORD(laneCornerPointsOffset[iRotationIndex1 + 1]) = + // HIDWORD(dRotMatrix01); } while (iRotationIndex1 != 27); iRotationIndex2 = 0; - dLaneDirection2 = getdirection(laneCornerPoints[15] - laneCornerPoints[12], laneCornerPoints[17] - laneCornerPoints[14]);// Get direction angle for second rotation axis + dLaneDirection2 = + getdirection(laneCornerPoints[15] - laneCornerPoints[12], + laneCornerPoints[17] - + laneCornerPoints[14]); // Get direction angle for + // second rotation axis dLaneDirection2Stored = dLaneDirection2; do { // Second rotation pass around calculated direction @@ -721,33 +835,48 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) dTempCos = cos(dLaneDirection2); dCosValue2 = laneCornerPoints[iRotationIndex2 + 2] * dSinValue2; dRotMatrix21 = dTempCos; - dRotMatrix02 = dCosValue2 + laneCornerPoints[iRotationIndex2] * dTempCos; - dRotMatrix00 = laneCornerPoints[iRotationIndex2 + 2] * dTempCos + -dSinValue2 * laneCornerPoints[iRotationIndex2]; + dRotMatrix02 = + dCosValue2 + laneCornerPoints[iRotationIndex2] * dTempCos; + dRotMatrix00 = laneCornerPoints[iRotationIndex2 + 2] * dTempCos + + -dSinValue2 * laneCornerPoints[iRotationIndex2]; laneCornerPoints[iRotationIndex2] = dRotMatrix02; laneCornerPoints[iRotationIndex2 + 2] = dRotMatrix00; iRotationIndex2 += 3; - //LODWORD(laneCornerPointsOffset[iRotationIndex2]) = LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex2] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex2]) = HIDWORD(dRotMatrix02); - //LODWORD(laneCornerPointsOffset[iRotationIndex2 + 2]) = LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex2 + 2] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex2 + 2]) = HIDWORD(dRotMatrix00); + // LODWORD(laneCornerPointsOffset[iRotationIndex2]) = + // LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex2] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex2]) = + // HIDWORD(dRotMatrix02); LODWORD(laneCornerPointsOffset[iRotationIndex2 + // + 2]) = LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex2 + + // 2] when before loop inc + // HIDWORD(laneCornerPointsOffset[iRotationIndex2 + 2]) = + // HIDWORD(dRotMatrix00); } while (iRotationIndex2 != 27); iRotationIndex3 = 0; - dLaneDirectionAngle = getdirection(laneCornerPoints[19] - laneCornerPoints[22], laneCornerPoints[23] - laneCornerPoints[20]);// Get direction for third rotation axis + dLaneDirectionAngle = getdirection( + laneCornerPoints[19] - laneCornerPoints[22], + laneCornerPoints[23] - + laneCornerPoints[20]); // Get direction for third rotation axis dLaneDirection3 = dLaneDirectionAngle; do { dCosValue3 = cos(dLaneDirection3); dTempCos = sin(dLaneDirection3); dSinValue3 = laneCornerPoints[iRotationIndex3 + 1] * dCosValue3; dSinDirection3 = dTempCos; - dRotMatrix01 = dSinValue3 - laneCornerPoints[iRotationIndex3 + 2] * dTempCos; - dRotMatrix00 = laneCornerPoints[iRotationIndex3 + 1] * dTempCos + laneCornerPoints[iRotationIndex3 + 2] * dCosValue3; + dRotMatrix01 = + dSinValue3 - laneCornerPoints[iRotationIndex3 + 2] * dTempCos; + dRotMatrix00 = laneCornerPoints[iRotationIndex3 + 1] * dTempCos + + laneCornerPoints[iRotationIndex3 + 2] * dCosValue3; laneCornerPoints[iRotationIndex3 + 1] = dRotMatrix01; laneCornerPoints[iRotationIndex3 + 2] = dRotMatrix00; iRotationIndex3 += 3; - //LODWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex3 + 1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = HIDWORD(dRotMatrix01); - //LODWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) = LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex3 + 2] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) = HIDWORD(dRotMatrix00); + // LODWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = + // LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex3 + 1] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) + // = HIDWORD(dRotMatrix01); + // LODWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) = + // LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex3 + 2] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) + // = HIDWORD(dRotMatrix00); } while (iRotationIndex3 != 27); // Prepare rotation matrix components @@ -760,78 +889,133 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) dTempRotValue1 = dMatrixComp1 * dRotMatrix22; dTempCos = dTempSin; dRotMatrix10 = dTempRotValue1 * dSinDirection3 + -dTempSin * dCosValue3; - dNegSinMatrix20 = -dTempSin * dSinDirection3 - dTempRotValue1 * dCosValue3; + dNegSinMatrix20 = + -dTempSin * dSinDirection3 - dTempRotValue1 * dCosValue3; dSinMatrix10 = dTempSin * dMatrixComp2; - dCosMatrix11 = dTempSin * dRotMatrix22 * dSinDirection3 + dMatrixComp1 * dCosValue3; - dRotMatrix11 = dMatrixComp1 * dSinDirection3 - dTempSin * dRotMatrix22 * dCosValue3; + dCosMatrix11 = + dTempSin * dRotMatrix22 * dSinDirection3 + dMatrixComp1 * dCosValue3; + dRotMatrix11 = + dMatrixComp1 * dSinDirection3 - dTempSin * dRotMatrix22 * dCosValue3; dRotMatrix20 = dSinDirection3 * -dMatrixComp2; dCosMatrix22 = dCosValue3 * dMatrixComp2; dRotMatrix12 = dRotMatrix22; // Load next track segment lane points for pitch comparison - laneCornerPoints[0] = TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fX; - laneCornerPoints[1] = TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fY; - laneCornerPoints[2] = TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fZ; - laneCornerPoints[3] = TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fX; - laneCornerPoints[4] = TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fY; - laneCornerPoints[5] = TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fZ; - laneCornerPoints[6] = TrakPt[iNextTrackIndex2].pointAy[uiLeftLaneOffset12 / 0xC].fX; - laneCornerPoints[7] = TrakPt[iNextTrackIndex2].pointAy[uiLeftLaneOffset12 / 0xC].fY; - laneCornerPoints[8] = TrakPt[iNextTrackIndex2].pointAy[uiLeftLaneOffset12 / 0xC].fZ; - laneCornerPoints[9] = TrakPt[iNextTrackIndex2].pointAy[uiRightLaneOffset12 / 0xC].fX; - laneCornerPoints[10] = TrakPt[iNextTrackIndex2].pointAy[uiRightLaneOffset12 / 0xC].fY; + laneCornerPoints[0] = + TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fX; + laneCornerPoints[1] = + TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fY; + laneCornerPoints[2] = + TrakPt[iNextTrackIndex].pointAy[uiLeftLaneOffset12 / 0xC].fZ; + laneCornerPoints[3] = + TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fX; + laneCornerPoints[4] = + TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fY; + laneCornerPoints[5] = + TrakPt[iNextTrackIndex].pointAy[uiRightLaneOffset12 / 0xC].fZ; + laneCornerPoints[6] = + TrakPt[iNextTrackIndex2].pointAy[uiLeftLaneOffset12 / 0xC].fX; + laneCornerPoints[7] = + TrakPt[iNextTrackIndex2].pointAy[uiLeftLaneOffset12 / 0xC].fY; + laneCornerPoints[8] = + TrakPt[iNextTrackIndex2].pointAy[uiLeftLaneOffset12 / 0xC].fZ; + laneCornerPoints[9] = + TrakPt[iNextTrackIndex2].pointAy[uiRightLaneOffset12 / 0xC].fX; + laneCornerPoints[10] = + TrakPt[iNextTrackIndex2].pointAy[uiRightLaneOffset12 / 0xC].fY; pNextTrackData = &localdata[iNextTrackIndex]; uiTransformLoop = 0; - laneCornerPoints[11] = TrakPt[iNextTrackIndex2].pointAy[uiRightLaneOffset12 / 0xC].fZ; + laneCornerPoints[11] = + TrakPt[iNextTrackIndex2].pointAy[uiRightLaneOffset12 / 0xC].fZ; do { - transformCoords[uiTransformLoop] = (pNextTrackData->pointAy[3].fY + laneCornerPoints[uiTransformLoop + 1]) * pNextTrackData->pointAy[1].fX - + (pNextTrackData->pointAy[3].fX + laneCornerPoints[uiTransformLoop]) * pNextTrackData->pointAy[0].fX - + (pNextTrackData->pointAy[3].fZ + laneCornerPoints[uiTransformLoop + 2]) * pNextTrackData->pointAy[2].fX; - transformCoords[uiTransformLoop + 1] = (pNextTrackData->pointAy[3].fY + laneCornerPoints[uiTransformLoop + 1]) * pNextTrackData->pointAy[1].fY - + (pNextTrackData->pointAy[3].fX + laneCornerPoints[uiTransformLoop]) * pNextTrackData->pointAy[0].fY - + (pNextTrackData->pointAy[3].fZ + laneCornerPoints[uiTransformLoop + 2]) * pNextTrackData->pointAy[2].fY; - dNextTransformZ = (pNextTrackData->pointAy[3].fY + laneCornerPoints[uiTransformLoop + 1]) * pNextTrackData->pointAy[1].fZ - + (pNextTrackData->pointAy[3].fX + laneCornerPoints[uiTransformLoop]) * pNextTrackData->pointAy[0].fZ - + (pNextTrackData->pointAy[3].fZ + laneCornerPoints[uiTransformLoop + 2]) * pNextTrackData->pointAy[2].fZ; + transformCoords[uiTransformLoop] = + (pNextTrackData->pointAy[3].fY + + laneCornerPoints[uiTransformLoop + 1]) * + pNextTrackData->pointAy[1].fX + + (pNextTrackData->pointAy[3].fX + + laneCornerPoints[uiTransformLoop]) * + pNextTrackData->pointAy[0].fX + + (pNextTrackData->pointAy[3].fZ + + laneCornerPoints[uiTransformLoop + 2]) * + pNextTrackData->pointAy[2].fX; + transformCoords[uiTransformLoop + 1] = + (pNextTrackData->pointAy[3].fY + + laneCornerPoints[uiTransformLoop + 1]) * + pNextTrackData->pointAy[1].fY + + (pNextTrackData->pointAy[3].fX + + laneCornerPoints[uiTransformLoop]) * + pNextTrackData->pointAy[0].fY + + (pNextTrackData->pointAy[3].fZ + + laneCornerPoints[uiTransformLoop + 2]) * + pNextTrackData->pointAy[2].fY; + dNextTransformZ = (pNextTrackData->pointAy[3].fY + + laneCornerPoints[uiTransformLoop + 1]) * + pNextTrackData->pointAy[1].fZ + + (pNextTrackData->pointAy[3].fX + + laneCornerPoints[uiTransformLoop]) * + pNextTrackData->pointAy[0].fZ + + (pNextTrackData->pointAy[3].fZ + + laneCornerPoints[uiTransformLoop + 2]) * + pNextTrackData->pointAy[2].fZ; transformCoords[uiTransformLoop + 2] = dNextTransformZ; uiTransformLoop += 3; - //transformCoordsOffset[uiTransformLoop + 2] = dNextTransformZ;// transformCoords[uiTransformLoop + 2] when before loop inc + // transformCoordsOffset[uiTransformLoop + 2] = dNextTransformZ;// + // transformCoords[uiTransformLoop + 2] when before loop inc } while (uiTransformLoop != 12); iNextBankAngle1 = (-pNextTrackData->iBankDelta / 2) & 0x3FFF; dNextCosBank2 = tcos[iNextBankAngle1]; dNextSinBank1 = tsin[iNextBankAngle1]; - bankRotData[1] = transformCoords[1] * dNextCosBank2 - transformCoords[2] * dNextSinBank1; - bankRotData[2] = transformCoords[1] * dNextSinBank1 + transformCoords[2] * dNextCosBank2; - bankRotData[4] = transformCoords[4] * dNextCosBank2 - transformCoords[5] * dNextSinBank1; - bankRotData[5] = transformCoords[4] * dNextSinBank1 + transformCoords[5] * dNextCosBank2; + bankRotData[1] = transformCoords[1] * dNextCosBank2 - + transformCoords[2] * dNextSinBank1; + bankRotData[2] = transformCoords[1] * dNextSinBank1 + + transformCoords[2] * dNextCosBank2; + bankRotData[4] = transformCoords[4] * dNextCosBank2 - + transformCoords[5] * dNextSinBank1; + bankRotData[5] = transformCoords[4] * dNextSinBank1 + + transformCoords[5] * dNextCosBank2; bankRotData[0] = transformCoords[0]; bankRotData[3] = transformCoords[3]; iNextBankAngle2 = (pNextTrackData->iBankDelta / 2) & 0x3FFF; dNextCosBank1 = tcos[iNextBankAngle2]; dNextSinBank2 = tsin[iNextBankAngle2]; - bankRotData[7] = transformCoords[7] * dNextCosBank1 - transformCoords[8] * dNextSinBank2; - bankRotData[8] = transformCoords[7] * dNextSinBank2 + transformCoords[8] * dNextCosBank1; - bankRotData[10] = transformCoords[10] * dNextCosBank1 - transformCoords[11] * dNextSinBank2; + bankRotData[7] = transformCoords[7] * dNextCosBank1 - + transformCoords[8] * dNextSinBank2; + bankRotData[8] = transformCoords[7] * dNextSinBank2 + + transformCoords[8] * dNextCosBank1; + bankRotData[10] = transformCoords[10] * dNextCosBank1 - + transformCoords[11] * dNextSinBank2; bankRotData[6] = transformCoords[6]; bankRotData[9] = transformCoords[9]; uiNextTransformLoop = 0; - bankRotData[11] = transformCoords[10] * dNextSinBank2 + transformCoords[11] * dNextCosBank1; + bankRotData[11] = transformCoords[10] * dNextSinBank2 + + transformCoords[11] * dNextCosBank1; do { - laneCornerPoints[uiNextTransformLoop] = pNextTrackData->pointAy[0].fY * bankRotData[uiNextTransformLoop + 1] - + pNextTrackData->pointAy[0].fX * bankRotData[uiNextTransformLoop] - + pNextTrackData->pointAy[0].fZ * bankRotData[uiNextTransformLoop + 2] - - pNextTrackData->pointAy[3].fX; - laneCornerPoints[uiNextTransformLoop + 1] = pNextTrackData->pointAy[1].fY * bankRotData[uiNextTransformLoop + 1] - + pNextTrackData->pointAy[1].fX * bankRotData[uiNextTransformLoop] - + pNextTrackData->pointAy[1].fZ * bankRotData[uiNextTransformLoop + 2] - - pNextTrackData->pointAy[3].fY; - dNextSegmentTransformZ = pNextTrackData->pointAy[2].fY * bankRotData[uiNextTransformLoop + 1] - + pNextTrackData->pointAy[2].fX * bankRotData[uiNextTransformLoop] - + pNextTrackData->pointAy[2].fZ * bankRotData[uiNextTransformLoop + 2] - - pNextTrackData->pointAy[3].fZ; + laneCornerPoints[uiNextTransformLoop] = + pNextTrackData->pointAy[0].fY * + bankRotData[uiNextTransformLoop + 1] + + pNextTrackData->pointAy[0].fX * bankRotData[uiNextTransformLoop] + + pNextTrackData->pointAy[0].fZ * + bankRotData[uiNextTransformLoop + 2] - + pNextTrackData->pointAy[3].fX; + laneCornerPoints[uiNextTransformLoop + 1] = + pNextTrackData->pointAy[1].fY * + bankRotData[uiNextTransformLoop + 1] + + pNextTrackData->pointAy[1].fX * bankRotData[uiNextTransformLoop] + + pNextTrackData->pointAy[1].fZ * + bankRotData[uiNextTransformLoop + 2] - + pNextTrackData->pointAy[3].fY; + dNextSegmentTransformZ = + pNextTrackData->pointAy[2].fY * + bankRotData[uiNextTransformLoop + 1] + + pNextTrackData->pointAy[2].fX * bankRotData[uiNextTransformLoop] + + pNextTrackData->pointAy[2].fZ * + bankRotData[uiNextTransformLoop + 2] - + pNextTrackData->pointAy[3].fZ; laneCornerPoints[uiNextTransformLoop + 2] = dNextSegmentTransformZ; uiNextTransformLoop += 3; - //laneCornerPointsOffset[uiNextTransformLoop + 2] = dNextSegmentTransformZ;// laneCornerPoints[uiNextTransformLoop + 2] when before loop inc + // laneCornerPointsOffset[uiNextTransformLoop + 2] = + // dNextSegmentTransformZ;// laneCornerPoints[uiNextTransformLoop + 2] + // when before loop inc } while (uiNextTransformLoop != 12); laneCornerPoints[12] = (laneCornerPoints[0] + laneCornerPoints[3]) * 0.5; laneCornerPoints[13] = (laneCornerPoints[1] + laneCornerPoints[4]) * 0.5; @@ -845,10 +1029,13 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) laneCornerPoints[21] = (laneCornerPoints[3] + laneCornerPoints[9]) * 0.5; laneCornerPoints[22] = (laneCornerPoints[4] + laneCornerPoints[10]) * 0.5; laneCornerPoints[23] = (laneCornerPoints[5] + laneCornerPoints[11]) * 0.5; - laneCornerPoints[24] = (laneCornerPoints[12] + laneCornerPoints[15]) * 0.5; - laneCornerPoints[25] = (laneCornerPoints[13] + laneCornerPoints[16]) * 0.5; + laneCornerPoints[24] = + (laneCornerPoints[12] + laneCornerPoints[15]) * 0.5; + laneCornerPoints[25] = + (laneCornerPoints[13] + laneCornerPoints[16]) * 0.5; uiFinalRotationLoop = 0; - laneCornerPoints[26] = (laneCornerPoints[14] + laneCornerPoints[17]) * 0.5; + laneCornerPoints[26] = + (laneCornerPoints[14] + laneCornerPoints[17]) * 0.5; dMatrixRotValue1 = dNegSinMatrix20; dMatrixRotValue2 = dRotMatrix10; do { @@ -856,37 +1043,59 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) dPointY = laneCornerPoints[uiFinalRotationLoop + 1] + dNegCenterOffsetY; dPointX = laneCornerPoints[uiFinalRotationLoop] + dNegCenterOffsetX; dPointZ = laneCornerPoints[uiFinalRotationLoop + 2] + dNegCenterOffsetZ; - transformCoords[uiFinalRotationLoop] = dSinMatrix10 * dPointY + dCosMatrix00 * dPointX + dRotMatrix12 * dPointZ; - transformCoords[uiFinalRotationLoop + 1] = dCosMatrix11 * dPointY + dMatrixRotValue2 * dPointX + dRotMatrix20 * dPointZ; - transformCoords[uiFinalRotationLoop + 2] = dPointY * dRotMatrix11 + dPointX * dMatrixRotValue1 + dPointZ * dCosMatrix22; + transformCoords[uiFinalRotationLoop] = dSinMatrix10 * dPointY + + dCosMatrix00 * dPointX + + dRotMatrix12 * dPointZ; + transformCoords[uiFinalRotationLoop + 1] = dCosMatrix11 * dPointY + + dMatrixRotValue2 * dPointX + + dRotMatrix20 * dPointZ; + transformCoords[uiFinalRotationLoop + 2] = dPointY * dRotMatrix11 + + dPointX * dMatrixRotValue1 + + dPointZ * dCosMatrix22; uiFinalRotationLoop += 3; - //transformCoordsOffset[uiFinalRotationLoop + 2] = dPointY * dRotMatrix11 + dPointX * dMatrixRotValue1 + dPointZ * dCosMatrix22;// transformCoords[uiFinalRotationLoop + 1] when before loop inc + // transformCoordsOffset[uiFinalRotationLoop + 2] = dPointY * + // dRotMatrix11 + dPointX * dMatrixRotValue1 + dPointZ * dCosMatrix22;// + // transformCoords[uiFinalRotationLoop + 1] when before loop inc } while (uiFinalRotationLoop != 27); iDirectionCalcLoop = 0; - dFinalDirection = getdirection(transformCoords[15] - transformCoords[12], transformCoords[16] - transformCoords[13]);// Get final direction angle for last rotation + dFinalDirection = getdirection( + transformCoords[15] - transformCoords[12], + transformCoords[16] - transformCoords[13]); // Get final direction + // angle for last rotation do { // Final rotation transformation dSinFinal = sin(-dFinalDirection); dTempCos = cos(-dFinalDirection); dCosFinal = transformCoords[iDirectionCalcLoop + 1] * dSinFinal; dTempSin = dTempCos; - dRotMatrix02 = transformCoords[iDirectionCalcLoop] * dTempCos - dCosFinal; - dRotMatrix01 = dSinFinal * transformCoords[iDirectionCalcLoop] + transformCoords[iDirectionCalcLoop + 1] * dTempCos; + dRotMatrix02 = + transformCoords[iDirectionCalcLoop] * dTempCos - dCosFinal; + dRotMatrix01 = dSinFinal * transformCoords[iDirectionCalcLoop] + + transformCoords[iDirectionCalcLoop + 1] * dTempCos; transformCoords[iDirectionCalcLoop] = dRotMatrix02; transformCoords[iDirectionCalcLoop + 1] = dRotMatrix01; iDirectionCalcLoop += 3; - //LODWORD(transformCoordsOffset[iDirectionCalcLoop]) = LODWORD(dRotMatrix02);// transformCoords[iDirectionCalcLoop] when before loop inc - //HIDWORD(transformCoordsOffset[iDirectionCalcLoop]) = HIDWORD(dRotMatrix02); - //LODWORD(transformCoordsOffset[iDirectionCalcLoop + 1]) = LODWORD(dRotMatrix01);// transformCoords[iDirectionCalcLoop + 1] when before loop inc - //HIDWORD(transformCoordsOffset[iDirectionCalcLoop + 1]) = HIDWORD(dRotMatrix01); + // LODWORD(transformCoordsOffset[iDirectionCalcLoop]) = + // LODWORD(dRotMatrix02);// transformCoords[iDirectionCalcLoop] when + // before loop inc HIDWORD(transformCoordsOffset[iDirectionCalcLoop]) = + // HIDWORD(dRotMatrix02); + // LODWORD(transformCoordsOffset[iDirectionCalcLoop + 1]) = + // LODWORD(dRotMatrix01);// transformCoords[iDirectionCalcLoop + 1] when + // before loop inc HIDWORD(transformCoordsOffset[iDirectionCalcLoop + + // 1]) = HIDWORD(dRotMatrix01); } while (iDirectionCalcLoop != 27); // Calculate final pitch angle in degrees and store result - dFinalLanePitchAngle = getdirection(transformCoords[15] - transformCoords[12], transformCoords[17] - transformCoords[14]) * 16384.0 / 6.28318530718 + 0.5; + dFinalLanePitchAngle = + getdirection(transformCoords[15] - transformCoords[12], + transformCoords[17] - transformCoords[14]) * + 16384.0 / 6.28318530718 + + 0.5; pOutputTrackData = &localdata[iTrackIndex]; dStoredPitchAngle = dFinalLanePitchAngle; - // Store calculated pitch angle: iUnk18 for inner lanes, iUnk19 for outer lanes + // Store calculated pitch angle: iUnk18 for inner lanes, iUnk19 for outer + // lanes if (iLeftLaneIndex) { floor(dStoredPitchAngle); //_CHP(); @@ -904,74 +1113,74 @@ void dopitchchanges(int iLLaneIdx, int iRLaneIdx) } //------------------------------------------------------------------------------------------------- -//00062F10 -int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) -{ - int iNextTrackIndex; // ecx +// 00062F10 +int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) { + int iNextTrackIndex; // ecx tData *pCurrentTrackData; // ebx - int iNextTrackIndex2; // ebp - int iLaneAOffset; // eax - int iLaneBOffset; // eax - int iPointIndex; // eax - double dOffsetZ; // st7 - double dOffsetY; // st6 - double dOffsetX; // st5 - double dTempValue; // st4 - int iRotationIndex1; // edx - double dDirection1; // st7 - double dSin1; // rt0 - double dCos1; // st5 - int iRotationIndex2; // edx - double dDirection2; // st7 - double dSin2; // st6 - double dCos2; // st5 - int iRotationIndex3; // edx - double dDirection3; // st6 - double dCos3; // st7 - double dSin3; // st5 - double dPitchAngle1; // st7 - double dPitchAngle2; // st7 - //int iNextLaneAOffset; // eax - int iTransformIndex; // eax - double dCurrentZ; // st7 - double dCurrentY; // st6 - double dPointY; // st5 - double dPointX; // st3 - double dPointZ; // rt0 + int iNextTrackIndex2; // ebp + int iLaneAOffset; // eax + int iLaneBOffset; // eax + int iPointIndex; // eax + double dOffsetZ; // st7 + double dOffsetY; // st6 + double dOffsetX; // st5 + double dTempValue; // st4 + int iRotationIndex1; // edx + double dDirection1; // st7 + double dSin1; // rt0 + double dCos1; // st5 + int iRotationIndex2; // edx + double dDirection2; // st7 + double dSin2; // st6 + double dCos2; // st5 + int iRotationIndex3; // edx + double dDirection3; // st6 + double dCos3; // st7 + double dSin3; // st5 + double dPitchAngle1; // st7 + double dPitchAngle2; // st7 + // int iNextLaneAOffset; // eax + int iTransformIndex; // eax + double dCurrentZ; // st7 + double dCurrentY; // st6 + double dPointY; // st5 + double dPointX; // st3 + double dPointZ; // rt0 int iFinalRotationIndex; // edx - double dFinalDirection; // st7 - double dFinalSin; // rt1 - double dFinalCos; // st5 + double dFinalDirection; // st7 + double dFinalSin; // rt1 + double dFinalCos; // st5 double dFinalPitchAngle; // st7 - //double laneCornerPointsOffset[3]; // [esp+0h] [ebp-28Ch] + // double laneCornerPointsOffset[3]; // [esp+0h] [ebp-28Ch] double laneCornerPoints[27]; // [esp+18h] [ebp-274h] - double transformCoords[27]; // [esp+F0h] [ebp-19Ch] - double dRotMatrix02; // [esp+1C8h] [ebp-C4h] - double dRotMatrix01; // [esp+1D0h] [ebp-BCh] - double dRotMatrix00; // [esp+1D8h] [ebp-B4h] - double dCurrentMatrixY; // [esp+1E0h] [ebp-ACh] - double dMatrixRotX; // [esp+1E8h] [ebp-A4h] - double dMatrixScaleY; // [esp+1F0h] [ebp-9Ch] - double dCurrentMatrixX; // [esp+1F8h] [ebp-94h] - double dMatrixRotZ; // [esp+200h] [ebp-8Ch] - double dMatrixScaleZ; // [esp+208h] [ebp-84h] - double dMatrixRotY; // [esp+210h] [ebp-7Ch] - double dMatrixScaleX; // [esp+218h] [ebp-74h] - double dTempCos; // [esp+220h] [ebp-6Ch] - double dTempSin; // [esp+228h] [ebp-64h] - double dTempCos3; // [esp+230h] [ebp-5Ch] - double dNegOffsetX; // [esp+238h] [ebp-54h] - double dNegOffsetY; // [esp+240h] [ebp-4Ch] - double dNegOffsetZ; // [esp+248h] [ebp-44h] - double dDirection3Stored; // [esp+250h] [ebp-3Ch] - double dTempSin3; // [esp+258h] [ebp-34h] - double dFinalCosSin; // [esp+260h] [ebp-2Ch] - double dCurrentMatrixZ; // [esp+268h] [ebp-24h] - int iTrack72ByteOffset; // [esp+270h] [ebp-1Ch] - int iLane12ByteOffset; // [esp+274h] [ebp-18h] - int iOriginalTrackIndex; // [esp+278h] [ebp-14h] - - iNextTrackIndex = iChunkIdx + 1; // Calculate next track indices with wraparound + double transformCoords[27]; // [esp+F0h] [ebp-19Ch] + double dRotMatrix02; // [esp+1C8h] [ebp-C4h] + double dRotMatrix01; // [esp+1D0h] [ebp-BCh] + double dRotMatrix00; // [esp+1D8h] [ebp-B4h] + double dCurrentMatrixY; // [esp+1E0h] [ebp-ACh] + double dMatrixRotX; // [esp+1E8h] [ebp-A4h] + double dMatrixScaleY; // [esp+1F0h] [ebp-9Ch] + double dCurrentMatrixX; // [esp+1F8h] [ebp-94h] + double dMatrixRotZ; // [esp+200h] [ebp-8Ch] + double dMatrixScaleZ; // [esp+208h] [ebp-84h] + double dMatrixRotY; // [esp+210h] [ebp-7Ch] + double dMatrixScaleX; // [esp+218h] [ebp-74h] + double dTempCos; // [esp+220h] [ebp-6Ch] + double dTempSin; // [esp+228h] [ebp-64h] + double dTempCos3; // [esp+230h] [ebp-5Ch] + double dNegOffsetX; // [esp+238h] [ebp-54h] + double dNegOffsetY; // [esp+240h] [ebp-4Ch] + double dNegOffsetZ; // [esp+248h] [ebp-44h] + double dDirection3Stored; // [esp+250h] [ebp-3Ch] + double dTempSin3; // [esp+258h] [ebp-34h] + double dFinalCosSin; // [esp+260h] [ebp-2Ch] + double dCurrentMatrixZ; // [esp+268h] [ebp-24h] + int iTrack72ByteOffset; // [esp+270h] [ebp-1Ch] + int iLane12ByteOffset; // [esp+274h] [ebp-18h] + int iOriginalTrackIndex; // [esp+278h] [ebp-14h] + + iNextTrackIndex = + iChunkIdx + 1; // Calculate next track indices with wraparound pCurrentTrackData = &localdata[iChunkIdx]; if (iChunkIdx + 1 == TRAK_LEN) iNextTrackIndex ^= TRAK_LEN; @@ -979,16 +1188,19 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) if (iNextTrackIndex + 1 == TRAK_LEN) iNextTrackIndex2 ^= TRAK_LEN; iOriginalTrackIndex = iChunkIdx; - iTrack72ByteOffset = 72 * iChunkIdx; // Calculate byte offsets for track and lane data access + iTrack72ByteOffset = + 72 * iChunkIdx; // Calculate byte offsets for track and lane data access iLane12ByteOffset = 12 * iLLaneIdx; iLaneAOffset = 12 * iLLaneIdx + 72 * iChunkIdx; laneCornerPoints[0] = TrakPt[iChunkIdx].pointAy[iLLaneIdx].fX; laneCornerPoints[1] = TrakPt[iChunkIdx].pointAy[iLLaneIdx].fY; laneCornerPoints[2] = TrakPt[iChunkIdx].pointAy[iLLaneIdx].fZ; - //laneCornerPoints[0] = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iLaneAOffset);// Load current track segment corner points for lanes a2 and a3 - //laneCornerPoints[1] = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iLaneAOffset); - //laneCornerPoints[2] = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iLaneAOffset); + // laneCornerPoints[0] = *(float *)((char *)&TrakPt[0].pointAy[0].fX + + // iLaneAOffset);// Load current track segment corner points for lanes a2 and + // a3 laneCornerPoints[1] = *(float *)((char *)&TrakPt[0].pointAy[0].fY + + // iLaneAOffset); laneCornerPoints[2] = *(float *)((char + // *)&TrakPt[0].pointAy[0].fZ + iLaneAOffset); iOriginalTrackIndex = 12 * iRLaneIdx; iLaneBOffset = 12 * iRLaneIdx + iTrack72ByteOffset; @@ -996,9 +1208,10 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) laneCornerPoints[3] = TrakPt[iChunkIdx].pointAy[iRLaneIdx].fX; laneCornerPoints[4] = TrakPt[iChunkIdx].pointAy[iRLaneIdx].fY; laneCornerPoints[5] = TrakPt[iChunkIdx].pointAy[iRLaneIdx].fZ; - //laneCornerPoints[3] = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iLaneBOffset); - //laneCornerPoints[4] = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iLaneBOffset); - //laneCornerPoints[5] = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iLaneBOffset); + // laneCornerPoints[3] = *(float *)((char *)&TrakPt[0].pointAy[0].fX + + // iLaneBOffset); laneCornerPoints[4] = *(float *)((char + // *)&TrakPt[0].pointAy[0].fY + iLaneBOffset); laneCornerPoints[5] = *(float + // *)((char *)&TrakPt[0].pointAy[0].fZ + iLaneBOffset); laneCornerPoints[6] = TrakPt[iNextTrackIndex].pointAy[iLLaneIdx].fX; laneCornerPoints[7] = TrakPt[iNextTrackIndex].pointAy[iLLaneIdx].fY; @@ -1006,7 +1219,8 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) laneCornerPoints[9] = TrakPt[iNextTrackIndex].pointAy[iRLaneIdx].fX; laneCornerPoints[10] = TrakPt[iNextTrackIndex].pointAy[iRLaneIdx].fY; laneCornerPoints[11] = TrakPt[iNextTrackIndex].pointAy[iRLaneIdx].fZ; - laneCornerPoints[12] = (laneCornerPoints[0] + laneCornerPoints[3]) * 0.5;// Calculate midpoints between lane corner pairs + laneCornerPoints[12] = (laneCornerPoints[0] + laneCornerPoints[3]) * + 0.5; // Calculate midpoints between lane corner pairs laneCornerPoints[13] = (laneCornerPoints[1] + laneCornerPoints[4]) * 0.5; laneCornerPoints[14] = (laneCornerPoints[2] + laneCornerPoints[5]) * 0.5; laneCornerPoints[15] = (laneCornerPoints[6] + laneCornerPoints[9]) * 0.5; @@ -1021,10 +1235,13 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) laneCornerPoints[24] = (laneCornerPoints[12] + laneCornerPoints[15]) * 0.5; laneCornerPoints[25] = (laneCornerPoints[13] + laneCornerPoints[16]) * 0.5; laneCornerPoints[26] = (laneCornerPoints[14] + laneCornerPoints[17]) * 0.5; - dNegOffsetX = -pCurrentTrackData->pointAy[3].fX;// Calculate negative track offset coordinates + dNegOffsetX = -pCurrentTrackData->pointAy[3] + .fX; // Calculate negative track offset coordinates dNegOffsetY = -pCurrentTrackData->pointAy[3].fY; dNegOffsetZ = -pCurrentTrackData->pointAy[3].fZ; - laneCornerPoints[0] = laneCornerPoints[0] + dNegOffsetX;// Apply offset to all corner points to center at origin + laneCornerPoints[0] = + laneCornerPoints[0] + + dNegOffsetX; // Apply offset to all corner points to center at origin laneCornerPoints[1] = laneCornerPoints[1] + dNegOffsetY; iPointIndex = 3; laneCornerPoints[2] = laneCornerPoints[2] + dNegOffsetZ; @@ -1033,66 +1250,96 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) dOffsetX = dNegOffsetX; do { laneCornerPoints[iPointIndex] = laneCornerPoints[iPointIndex] + dOffsetX; - laneCornerPoints[iPointIndex + 1] = laneCornerPoints[iPointIndex + 1] + dOffsetY; - laneCornerPoints[iPointIndex + 2] = laneCornerPoints[iPointIndex + 2] + dOffsetZ; - laneCornerPoints[iPointIndex + 3] = laneCornerPoints[iPointIndex + 3] + dOffsetX; - laneCornerPoints[iPointIndex + 4] = laneCornerPoints[iPointIndex + 4] + dOffsetY; - laneCornerPoints[iPointIndex + 5] = laneCornerPoints[iPointIndex + 5] + dOffsetZ; - laneCornerPoints[iPointIndex + 6] = laneCornerPoints[iPointIndex + 6] + dOffsetX; - laneCornerPoints[iPointIndex + 7] = laneCornerPoints[iPointIndex + 7] + dOffsetY; - laneCornerPoints[iPointIndex + 8] = laneCornerPoints[iPointIndex + 8] + dOffsetZ; - laneCornerPoints[iPointIndex + 9] = laneCornerPoints[iPointIndex + 9] + dOffsetX; - laneCornerPoints[iPointIndex + 10] = laneCornerPoints[iPointIndex + 10] + dOffsetY; + laneCornerPoints[iPointIndex + 1] = + laneCornerPoints[iPointIndex + 1] + dOffsetY; + laneCornerPoints[iPointIndex + 2] = + laneCornerPoints[iPointIndex + 2] + dOffsetZ; + laneCornerPoints[iPointIndex + 3] = + laneCornerPoints[iPointIndex + 3] + dOffsetX; + laneCornerPoints[iPointIndex + 4] = + laneCornerPoints[iPointIndex + 4] + dOffsetY; + laneCornerPoints[iPointIndex + 5] = + laneCornerPoints[iPointIndex + 5] + dOffsetZ; + laneCornerPoints[iPointIndex + 6] = + laneCornerPoints[iPointIndex + 6] + dOffsetX; + laneCornerPoints[iPointIndex + 7] = + laneCornerPoints[iPointIndex + 7] + dOffsetY; + laneCornerPoints[iPointIndex + 8] = + laneCornerPoints[iPointIndex + 8] + dOffsetZ; + laneCornerPoints[iPointIndex + 9] = + laneCornerPoints[iPointIndex + 9] + dOffsetX; + laneCornerPoints[iPointIndex + 10] = + laneCornerPoints[iPointIndex + 10] + dOffsetY; dTempValue = laneCornerPoints[iPointIndex + 11] + dOffsetZ; - - //loop offset fix + + // loop offset fix laneCornerPoints[iPointIndex + 11] = dTempValue; - + iPointIndex += 12; - //laneCornerPointsOffset[iPointIndex + 2] = dTempValue;// laneCornerPoints[iPointIndex + 11] when before loop inc + // laneCornerPointsOffset[iPointIndex + 2] = dTempValue;// + // laneCornerPoints[iPointIndex + 11] when before loop inc } while (iPointIndex != 27); iRotationIndex1 = 0; - dDirection1 = getdirection(laneCornerPoints[15] - laneCornerPoints[12], laneCornerPoints[16] - laneCornerPoints[13]);// First rotation pass around calculated direction + dDirection1 = + getdirection(laneCornerPoints[15] - laneCornerPoints[12], + laneCornerPoints[16] - + laneCornerPoints[13]); // First rotation pass around + // calculated direction do { dSin1 = sin(-dDirection1); dTempCos = cos(-dDirection1); dCos1 = laneCornerPoints[iRotationIndex1 + 1] * dSin1; dTempSin = dTempCos; dRotMatrix00 = laneCornerPoints[iRotationIndex1] * dTempCos - dCos1; - dRotMatrix01 = dSin1 * laneCornerPoints[iRotationIndex1] + laneCornerPoints[iRotationIndex1 + 1] * dTempCos; - - //loop offset fix + dRotMatrix01 = dSin1 * laneCornerPoints[iRotationIndex1] + + laneCornerPoints[iRotationIndex1 + 1] * dTempCos; + + // loop offset fix laneCornerPoints[iRotationIndex1] = dRotMatrix00; laneCornerPoints[iRotationIndex1 + 1] = dRotMatrix01; - iRotationIndex1 += 3; - //LODWORD(laneCornerPointsOffset[iRotationIndex1]) = LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex1]) = HIDWORD(dRotMatrix00); - //LODWORD(laneCornerPointsOffset[iRotationIndex1 + 1]) = LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex1 + 1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex1 + 1]) = HIDWORD(dRotMatrix01); + iRotationIndex1 += 3; + // LODWORD(laneCornerPointsOffset[iRotationIndex1]) = + // LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex1] when before + // loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex1]) = + // HIDWORD(dRotMatrix00); LODWORD(laneCornerPointsOffset[iRotationIndex1 + + // 1]) = LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex1 + 1] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex1 + 1]) = + // HIDWORD(dRotMatrix01); } while (iRotationIndex1 != 27); iRotationIndex2 = 0; - dDirection2 = getdirection(laneCornerPoints[15] - laneCornerPoints[12], laneCornerPoints[17] - laneCornerPoints[14]);// Second rotation pass around different direction + dDirection2 = + getdirection(laneCornerPoints[15] - laneCornerPoints[12], + laneCornerPoints[17] - + laneCornerPoints[14]); // Second rotation pass around + // different direction do { dSin2 = sin(dDirection2); dTempCos = cos(dDirection2); dCos2 = laneCornerPoints[iRotationIndex2 + 2] * dSin2; dTempSin = dTempCos; dRotMatrix00 = dCos2 + laneCornerPoints[iRotationIndex2] * dTempCos; - dRotMatrix02 = laneCornerPoints[iRotationIndex2 + 2] * dTempCos + -dSin2 * laneCornerPoints[iRotationIndex2]; - - //loop offset fix + dRotMatrix02 = laneCornerPoints[iRotationIndex2 + 2] * dTempCos + + -dSin2 * laneCornerPoints[iRotationIndex2]; + + // loop offset fix laneCornerPoints[iRotationIndex2] = dRotMatrix00; laneCornerPoints[iRotationIndex2 + 2] = dRotMatrix02; - + iRotationIndex2 += 3; - //LODWORD(laneCornerPointsOffset[iRotationIndex2]) = LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex2] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex2]) = HIDWORD(dRotMatrix00); - //LODWORD(laneCornerPointsOffset[iRotationIndex2 + 2]) = LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex2 + 1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex2 + 2]) = HIDWORD(dRotMatrix02); + // LODWORD(laneCornerPointsOffset[iRotationIndex2]) = + // LODWORD(dRotMatrix00);// laneCornerPoints[iRotationIndex2] when before + // loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex2]) = + // HIDWORD(dRotMatrix00); LODWORD(laneCornerPointsOffset[iRotationIndex2 + + // 2]) = LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex2 + 1] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex2 + 2]) = + // HIDWORD(dRotMatrix02); } while (iRotationIndex2 != 27); iRotationIndex3 = 0; - dDirection3Stored = getdirection(laneCornerPoints[19] - laneCornerPoints[22], laneCornerPoints[23] - laneCornerPoints[20]);// Third rotation pass around third direction + dDirection3Stored = getdirection( + laneCornerPoints[19] - laneCornerPoints[22], + laneCornerPoints[23] - + laneCornerPoints[20]); // Third rotation pass around third direction dDirection3 = dDirection3Stored; do { dCos3 = cos(dDirection3); @@ -1100,27 +1347,44 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) dSin3 = laneCornerPoints[iRotationIndex3 + 1] * dCos3; dTempSin3 = dTempSin; dRotMatrix01 = dSin3 - laneCornerPoints[iRotationIndex3 + 2] * dTempSin; - dRotMatrix02 = laneCornerPoints[iRotationIndex3 + 1] * dTempSin + laneCornerPoints[iRotationIndex3 + 2] * dCos3; - - //loop offset fix + dRotMatrix02 = laneCornerPoints[iRotationIndex3 + 1] * dTempSin + + laneCornerPoints[iRotationIndex3 + 2] * dCos3; + + // loop offset fix laneCornerPoints[iRotationIndex3 + 1] = dRotMatrix01; laneCornerPoints[iRotationIndex3 + 2] = dRotMatrix02; - + iRotationIndex3 += 3; - //LODWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex3 + 1] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = HIDWORD(dRotMatrix01); - //LODWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) = LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex3 + 2] when before loop inc - //HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) = HIDWORD(dRotMatrix02); + // LODWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = + // LODWORD(dRotMatrix01);// laneCornerPoints[iRotationIndex3 + 1] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 1]) = + // HIDWORD(dRotMatrix01); LODWORD(laneCornerPointsOffset[iRotationIndex3 + + // 2]) = LODWORD(dRotMatrix02);// laneCornerPoints[iRotationIndex3 + 2] when + // before loop inc HIDWORD(laneCornerPointsOffset[iRotationIndex3 + 2]) = + // HIDWORD(dRotMatrix02); } while (iRotationIndex3 != 27); dTempCos3 = dCos3; - dPitchAngle1 = atan2(laneCornerPoints[7] - laneCornerPoints[10], laneCornerPoints[11] - laneCornerPoints[8]);// Calculate intermediate pitch angle using atan2 - //dPitchAngle1 = IF_DATAN2(v27, laneCornerPoints[7] - laneCornerPoints[10], laneCornerPoints[11] - laneCornerPoints[8]);// Calculate intermediate pitch angle using atan2 - dPitchAngle2 = (dPitchAngle1 - atan2(laneCornerPoints[5] - laneCornerPoints[2], dPitchAngle1)) * 16384.0 / 6.28318530718 + 0.5;// Calculate and store banking angle difference - //dPitchAngle2 = (dPitchAngle1 - IF_DATAN2(v29, laneCornerPoints[5] - laneCornerPoints[2], dPitchAngle1)) * 16384.0 / 6.28318530718 + 0.5;// Calculate and store banking angle difference + dPitchAngle1 = atan2(laneCornerPoints[7] - laneCornerPoints[10], + laneCornerPoints[11] - + laneCornerPoints[8]); // Calculate intermediate pitch + // angle using atan2 + // dPitchAngle1 = IF_DATAN2(v27, laneCornerPoints[7] - laneCornerPoints[10], + // laneCornerPoints[11] - laneCornerPoints[8]);// Calculate intermediate pitch + // angle using atan2 + dPitchAngle2 = + (dPitchAngle1 - + atan2(laneCornerPoints[5] - laneCornerPoints[2], dPitchAngle1)) * + 16384.0 / 6.28318530718 + + 0.5; // Calculate and store banking angle difference + // dPitchAngle2 = (dPitchAngle1 - IF_DATAN2(v29, laneCornerPoints[5] - + // laneCornerPoints[2], dPitchAngle1)) * 16384.0 / 6.28318530718 + 0.5;// + // Calculate and store banking angle difference floor(dPitchAngle2); //_CHP(); pCurrentTrackData->iBankAngleDelta = (int)-dPitchAngle2; - dCurrentMatrixX = pCurrentTrackData->pointAy[0].fX;// Load current track transformation matrix components + dCurrentMatrixX = + pCurrentTrackData->pointAy[0] + .fX; // Load current track transformation matrix components dCurrentMatrixY = pCurrentTrackData->pointAy[0].fY; dCurrentMatrixZ = pCurrentTrackData->pointAy[0].fZ; dMatrixRotX = pCurrentTrackData->pointAy[1].fX; @@ -1133,10 +1397,12 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) laneCornerPoints[0] = TrakPt[iNextTrackIndex].pointAy[iLLaneIdx].fX; laneCornerPoints[1] = TrakPt[iNextTrackIndex].pointAy[iLLaneIdx].fY; laneCornerPoints[2] = TrakPt[iNextTrackIndex].pointAy[iLLaneIdx].fZ; - //iNextLaneAOffset = 72 * iNextTrackIndex + 12 * iLLaneIdx;// Load next track segment points for comparison - //laneCornerPoints[0] = *(float *)((char *)&TrakPt[0].pointAy[0].fX + iNextLaneAOffset); - //laneCornerPoints[1] = *(float *)((char *)&TrakPt[0].pointAy[0].fY + iNextLaneAOffset); - //laneCornerPoints[2] = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + iNextLaneAOffset); + // iNextLaneAOffset = 72 * iNextTrackIndex + 12 * iLLaneIdx;// Load next track + // segment points for comparison laneCornerPoints[0] = *(float *)((char + // *)&TrakPt[0].pointAy[0].fX + iNextLaneAOffset); laneCornerPoints[1] = + // *(float *)((char *)&TrakPt[0].pointAy[0].fY + iNextLaneAOffset); + // laneCornerPoints[2] = *(float *)((char *)&TrakPt[0].pointAy[0].fZ + + // iNextLaneAOffset); laneCornerPoints[3] = TrakPt[iNextTrackIndex].pointAy[iRLaneIdx].fX; laneCornerPoints[4] = TrakPt[iNextTrackIndex].pointAy[iRLaneIdx].fY; @@ -1166,77 +1432,95 @@ int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx) dCurrentZ = dCurrentMatrixZ; dCurrentY = dCurrentMatrixY; do { - dPointY = laneCornerPoints[iTransformIndex + 1] + dNegOffsetY;// Transform points using current track matrix + dPointY = laneCornerPoints[iTransformIndex + 1] + + dNegOffsetY; // Transform points using current track matrix dPointX = laneCornerPoints[iTransformIndex] + dNegOffsetX; dPointZ = laneCornerPoints[iTransformIndex + 2] + dNegOffsetZ; - transformCoords[iTransformIndex] = dMatrixRotX * dPointY + dCurrentMatrixX * dPointX + dMatrixScaleX * dPointZ; - transformCoords[iTransformIndex + 1] = dMatrixRotY * dPointY + dCurrentY * dPointX + dMatrixScaleY * dPointZ; - - //loop offset fix - transformCoords[iTransformIndex + 2] = dPointY * dMatrixRotZ + dPointX * dCurrentZ + dPointZ * dMatrixScaleZ; - + transformCoords[iTransformIndex] = dMatrixRotX * dPointY + + dCurrentMatrixX * dPointX + + dMatrixScaleX * dPointZ; + transformCoords[iTransformIndex + 1] = + dMatrixRotY * dPointY + dCurrentY * dPointX + dMatrixScaleY * dPointZ; + + // loop offset fix + transformCoords[iTransformIndex + 2] = + dPointY * dMatrixRotZ + dPointX * dCurrentZ + dPointZ * dMatrixScaleZ; + iTransformIndex += 3; - //laneCornerPoints[iTransformIndex + 26] = dPointY * dMatrixRotZ + dPointX * dCurrentZ + dPointZ * dMatrixScaleZ;// transformCoords[iTransformIndex + 2] when before loop inc + // laneCornerPoints[iTransformIndex + 26] = dPointY * dMatrixRotZ + dPointX + // * dCurrentZ + dPointZ * dMatrixScaleZ;// transformCoords[iTransformIndex + // + 2] when before loop inc } while (iTransformIndex != 27); iFinalRotationIndex = 0; - dFinalDirection = getdirection(transformCoords[15] - transformCoords[12], transformCoords[16] - transformCoords[13]);// Final rotation pass for pitch calculation + dFinalDirection = getdirection( + transformCoords[15] - transformCoords[12], + transformCoords[16] - + transformCoords[13]); // Final rotation pass for pitch calculation do { dFinalSin = sin(-dFinalDirection); dFinalCosSin = cos(-dFinalDirection); dFinalCos = transformCoords[iFinalRotationIndex + 1] * dFinalSin; dTempSin = dFinalCosSin; - dRotMatrix00 = transformCoords[iFinalRotationIndex] * dFinalCosSin - dFinalCos; - dRotMatrix01 = dFinalSin * transformCoords[iFinalRotationIndex] + transformCoords[iFinalRotationIndex + 1] * dFinalCosSin; - - //loop offset fix + dRotMatrix00 = + transformCoords[iFinalRotationIndex] * dFinalCosSin - dFinalCos; + dRotMatrix01 = dFinalSin * transformCoords[iFinalRotationIndex] + + transformCoords[iFinalRotationIndex + 1] * dFinalCosSin; + + // loop offset fix transformCoords[iFinalRotationIndex] = dRotMatrix00; transformCoords[iFinalRotationIndex + 1] = dRotMatrix01; - + iFinalRotationIndex += 3; - //LODWORD(laneCornerPoints[iFinalRotationIndex + 24]) = LODWORD(dRotMatrix00);// transformCoords[iFinalRotationIndex] when before loop inc - //HIDWORD(laneCornerPoints[iFinalRotationIndex + 24]) = HIDWORD(dRotMatrix00); - //LODWORD(laneCornerPoints[iFinalRotationIndex + 25]) = LODWORD(dRotMatrix01);// transformCoords[iFinalRotationIndex + 1] when before loop inc - //HIDWORD(laneCornerPoints[iFinalRotationIndex + 25]) = HIDWORD(dRotMatrix01); + // LODWORD(laneCornerPoints[iFinalRotationIndex + 24]) = + // LODWORD(dRotMatrix00);// transformCoords[iFinalRotationIndex] when before + // loop inc HIDWORD(laneCornerPoints[iFinalRotationIndex + 24]) = + // HIDWORD(dRotMatrix00); LODWORD(laneCornerPoints[iFinalRotationIndex + + // 25]) = LODWORD(dRotMatrix01);// transformCoords[iFinalRotationIndex + 1] + // when before loop inc HIDWORD(laneCornerPoints[iFinalRotationIndex + 25]) + // = HIDWORD(dRotMatrix01); } while (iFinalRotationIndex != 27); - dFinalPitchAngle = getdirection(transformCoords[15] - transformCoords[12], transformCoords[17] - transformCoords[14]) * 16384.0 / 6.28318530718 + 0.5;// Calculate final pitch change angle and return as integer + dFinalPitchAngle = + getdirection(transformCoords[15] - transformCoords[12], + transformCoords[17] - transformCoords[14]) * + 16384.0 / 6.28318530718 + + 0.5; // Calculate final pitch change angle and return as integer floor(dFinalPitchAngle); //_CHP(); return (int)dFinalPitchAngle; } //------------------------------------------------------------------------------------------------- -//00063990 -void getworldangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimuth, int *piElevation, int *piBank) -{ - double dCosPitch; // st7 - int iYaw_1; // ecx - double dDirX; // st7 - double dDirY; // st6 - double dDirZ; // st5 - tData *pData; // edx - int iNewAzimuth; // eax - int iNewAzimuth_1; // ebx - int iNewElevation; // eax - double dRollSin; // st7 - double dRollVecX; // st7 +// 00063990 +void getworldangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, + int *piAzimuth, int *piElevation, int *piBank) { + double dCosPitch; // st7 + int iYaw_1; // ecx + double dDirX; // st7 + double dDirY; // st6 + double dDirZ; // st5 + tData *pData; // edx + int iNewAzimuth; // eax + int iNewAzimuth_1; // ebx + int iNewElevation; // eax + double dRollSin; // st7 + double dRollVecX; // st7 double fRollRotatedX; // st7 - float fCosPitch; // [esp+0h] [ebp-40h] - float fRollVecX; // [esp+0h] [ebp-40h] - float fRollProjZ; // [esp+4h] [ebp-3Ch] - float fFinalX; // [esp+4h] [ebp-3Ch] - float fProjZ; // [esp+8h] [ebp-38h] - float fProjY; // [esp+Ch] [ebp-34h] - float fProjX; // [esp+10h] [ebp-30h] - float fRotatedX; // [esp+10h] [ebp-30h] - float fRollProjX; // [esp+20h] [ebp-20h] - float fRollVecY; // [esp+24h] [ebp-1Ch] - float fRollProjY; // [esp+28h] [ebp-18h] - float fRollRotatedY; // [esp+28h] [ebp-18h] - float fRollCos; // [esp+2Ch] [ebp-14h] - float fRollVecZ; // [esp+2Ch] [ebp-14h] - float fRollSin_1; // [esp+30h] [ebp-10h] - float fRollVecW; // [esp+30h] [ebp-10h] - + float fCosPitch; // [esp+0h] [ebp-40h] + float fRollVecX; // [esp+0h] [ebp-40h] + float fRollProjZ; // [esp+4h] [ebp-3Ch] + float fFinalX; // [esp+4h] [ebp-3Ch] + float fProjZ; // [esp+8h] [ebp-38h] + float fProjY; // [esp+Ch] [ebp-34h] + float fProjX; // [esp+10h] [ebp-30h] + float fRotatedX; // [esp+10h] [ebp-30h] + float fRollProjX; // [esp+20h] [ebp-20h] + float fRollVecY; // [esp+24h] [ebp-1Ch] + float fRollProjY; // [esp+28h] [ebp-18h] + float fRollRotatedY; // [esp+28h] [ebp-18h] + float fRollCos; // [esp+2Ch] [ebp-14h] + float fRollVecZ; // [esp+2Ch] [ebp-14h] + float fRollSin_1; // [esp+30h] [ebp-10h] + float fRollVecW; // [esp+30h] [ebp-10h] // Compute base vector components dCosPitch = tcos[iPitch] * 25600.0; @@ -1250,9 +1534,12 @@ void getworldangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimu pData = &localdata[iChunkIdx]; // Project reference points onto a direction vector - fProjX = (float)(pData->pointAy[0].fY * dDirY + pData->pointAy[0].fX * dDirX + pData->pointAy[0].fZ * dDirZ); - fProjY = (float)(pData->pointAy[1].fX * dDirX + pData->pointAy[1].fY * dDirY + pData->pointAy[1].fZ * dDirZ); - fProjZ = (float)(dDirX * pData->pointAy[2].fX + dDirY * pData->pointAy[2].fY + dDirZ * pData->pointAy[2].fZ); + fProjX = (float)(pData->pointAy[0].fY * dDirY + pData->pointAy[0].fX * dDirX + + pData->pointAy[0].fZ * dDirZ); + fProjY = (float)(pData->pointAy[1].fX * dDirX + pData->pointAy[1].fY * dDirY + + pData->pointAy[1].fZ * dDirZ); + fProjZ = (float)(dDirX * pData->pointAy[2].fX + dDirY * pData->pointAy[2].fY + + dDirZ * pData->pointAy[2].fZ); // Calculate azimuth iNewAzimuth = getangle(fProjX, fProjY); @@ -1279,53 +1566,62 @@ void getworldangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimu fRollVecW = fRollSin_1 * tcos[iPitch]; // Project reference points onto roll-adjusted vector - fRollProjX = pData->pointAy[0].fY * fRollVecZ + pData->pointAy[0].fX * fRollVecY + pData->pointAy[0].fZ * fRollVecW; - fRollProjY = pData->pointAy[1].fX * fRollVecY + pData->pointAy[1].fY * fRollVecZ + pData->pointAy[1].fZ * fRollVecW; - fRollProjZ = pData->pointAy[2].fX * fRollVecY + pData->pointAy[2].fY * fRollVecZ + pData->pointAy[2].fZ * fRollVecW; + fRollProjX = pData->pointAy[0].fY * fRollVecZ + + pData->pointAy[0].fX * fRollVecY + + pData->pointAy[0].fZ * fRollVecW; + fRollProjY = pData->pointAy[1].fX * fRollVecY + + pData->pointAy[1].fY * fRollVecZ + + pData->pointAy[1].fZ * fRollVecW; + fRollProjZ = pData->pointAy[2].fX * fRollVecY + + pData->pointAy[2].fY * fRollVecZ + + pData->pointAy[2].fZ * fRollVecW; // Rotate projections using azimuth - fRollRotatedX = fRollProjX * tcos[iNewAzimuth_1] + fRollProjY * tsin[iNewAzimuth_1]; - fRollRotatedY = -fRollProjX * tsin[iNewAzimuth_1] + fRollProjY * tcos[iNewAzimuth_1]; + fRollRotatedX = + fRollProjX * tcos[iNewAzimuth_1] + fRollProjY * tsin[iNewAzimuth_1]; + fRollRotatedY = + -fRollProjX * tsin[iNewAzimuth_1] + fRollProjY * tcos[iNewAzimuth_1]; // Apply elevation rotation - fFinalX = (float)(fRollRotatedX * tsin[iNewElevation] - fRollProjZ * tcos[iNewElevation]); + fFinalX = (float)(fRollRotatedX * tsin[iNewElevation] - + fRollProjZ * tcos[iNewElevation]); // Calculate bank *piBank = getangle(fRollRotatedY, fFinalX); } //------------------------------------------------------------------------------------------------- -//00063B90 -void getlocalangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimuth, int *piElevation, int *piBank) -{ - double dCosPitch; // st7 - int iYaw2; // ecx - double dDirX; // st7 - double dDirY; // st6 - double dDirZ; // st5 - tData *pData; // edx - int iNewAzimuth; // eax - int iAz2; // ebx - int iElevation; // eax - double fRollSin; // st7 +// 00063B90 +void getlocalangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, + int *piAzimuth, int *piElevation, int *piBank) { + double dCosPitch; // st7 + int iYaw2; // ecx + double dDirX; // st7 + double dDirY; // st6 + double dDirZ; // st5 + tData *pData; // edx + int iNewAzimuth; // eax + int iAz2; // ebx + int iElevation; // eax + double fRollSin; // st7 double fNegRollSinTimesPitchSin; // st7 - double fRollRotatedX; // st7 - float fCosPitch; // [esp+0h] [ebp-40h] + double fRollRotatedX; // st7 + float fCosPitch; // [esp+0h] [ebp-40h] float fNegRollSinTimesPitchSin2; // [esp+0h] [ebp-40h] - float v24; // [esp+4h] [ebp-3Ch] - float fRollProjZ; // [esp+4h] [ebp-3Ch] - float fProjZ; // [esp+8h] [ebp-38h] - float fProjY; // [esp+Ch] [ebp-34h] - float fProjX; // [esp+10h] [ebp-30h] - float fRotatedX; // [esp+10h] [ebp-30h] - float fRollProjX; // [esp+20h] [ebp-20h] - float fRollVecX; // [esp+24h] [ebp-1Ch] - float fRollProjY; // [esp+28h] [ebp-18h] - float fRollRotatedY; // [esp+28h] [ebp-18h] - float fRollCos; // [esp+2Ch] [ebp-14h] - float fRollVecY; // [esp+2Ch] [ebp-14h] - float fRollSin2; // [esp+30h] [ebp-10h] - float fRollVecZ; // [esp+30h] [ebp-10h] + float v24; // [esp+4h] [ebp-3Ch] + float fRollProjZ; // [esp+4h] [ebp-3Ch] + float fProjZ; // [esp+8h] [ebp-38h] + float fProjY; // [esp+Ch] [ebp-34h] + float fProjX; // [esp+10h] [ebp-30h] + float fRotatedX; // [esp+10h] [ebp-30h] + float fRollProjX; // [esp+20h] [ebp-20h] + float fRollVecX; // [esp+24h] [ebp-1Ch] + float fRollProjY; // [esp+28h] [ebp-18h] + float fRollRotatedY; // [esp+28h] [ebp-18h] + float fRollCos; // [esp+2Ch] [ebp-14h] + float fRollVecY; // [esp+2Ch] [ebp-14h] + float fRollSin2; // [esp+30h] [ebp-10h] + float fRollVecZ; // [esp+30h] [ebp-10h] // direction vector components dCosPitch = tcos[iPitch] * 25600.0; @@ -1341,9 +1637,12 @@ void getlocalangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimu pData = &localdata[iChunkIdx]; // Project reference points onto direction vector - fProjX = (float)(pData->pointAy[1].fX * dDirY + pData->pointAy[0].fX * dDirX + pData->pointAy[2].fX * dDirZ); - fProjY = (float)(pData->pointAy[0].fY * dDirX + pData->pointAy[1].fY * dDirY + pData->pointAy[2].fY * dDirZ); - fProjZ = (float)(dDirX * pData->pointAy[0].fZ + dDirY * pData->pointAy[1].fZ + dDirZ * pData->pointAy[2].fZ); + fProjX = (float)(pData->pointAy[1].fX * dDirY + pData->pointAy[0].fX * dDirX + + pData->pointAy[2].fX * dDirZ); + fProjY = (float)(pData->pointAy[0].fY * dDirX + pData->pointAy[1].fY * dDirY + + pData->pointAy[2].fY * dDirZ); + fProjZ = (float)(dDirX * pData->pointAy[0].fZ + dDirY * pData->pointAy[1].fZ + + dDirZ * pData->pointAy[2].fZ); // Calculate azimuth iNewAzimuth = getangle(fProjX, fProjY); @@ -1365,21 +1664,29 @@ void getlocalangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimu // Apply pitch and yaw transformations to roll vector fNegRollSinTimesPitchSin = -fRollSin * tsin[iPitch]; fNegRollSinTimesPitchSin2 = (float)fNegRollSinTimesPitchSin; - fRollVecX = (float)(fNegRollSinTimesPitchSin * tcos[iYaw2] - fRollCos * tsin[iYaw2]); - fRollVecY = (float)(fNegRollSinTimesPitchSin2 * tsin[iYaw2] + fRollCos * tcos[iYaw2]); + fRollVecX = + (float)(fNegRollSinTimesPitchSin * tcos[iYaw2] - fRollCos * tsin[iYaw2]); + fRollVecY = + (float)(fNegRollSinTimesPitchSin2 * tsin[iYaw2] + fRollCos * tcos[iYaw2]); fRollVecZ = (float)(fRollSin2 * tcos[iPitch]); // Project reference points onto roll-adjusted vector - fRollProjX = pData->pointAy[1].fX * fRollVecY + pData->pointAy[0].fX * fRollVecX + pData->pointAy[2].fX * fRollVecZ; - fRollProjY = pData->pointAy[0].fY * fRollVecX + pData->pointAy[1].fY * fRollVecY + pData->pointAy[2].fY * fRollVecZ; - v24 = pData->pointAy[0].fZ * fRollVecX + pData->pointAy[1].fZ * fRollVecY + pData->pointAy[2].fZ * fRollVecZ; + fRollProjX = pData->pointAy[1].fX * fRollVecY + + pData->pointAy[0].fX * fRollVecX + + pData->pointAy[2].fX * fRollVecZ; + fRollProjY = pData->pointAy[0].fY * fRollVecX + + pData->pointAy[1].fY * fRollVecY + + pData->pointAy[2].fY * fRollVecZ; + v24 = pData->pointAy[0].fZ * fRollVecX + pData->pointAy[1].fZ * fRollVecY + + pData->pointAy[2].fZ * fRollVecZ; // Apply azimuth rotation fRollRotatedX = fRollProjX * tcos[iAz2] + fRollProjY * tsin[iAz2]; fRollRotatedY = -fRollProjX * tsin[iAz2] + fRollProjY * tcos[iAz2]; // Apply elevation rotation - fRollProjZ = (float)(fRollRotatedX * tsin[iElevation] - v24 * tcos[iElevation]); + fRollProjZ = + (float)(fRollRotatedX * tsin[iElevation] - v24 * tcos[iElevation]); // Calculate bank *piBank = getangle(fRollRotatedY, fRollProjZ); diff --git a/PROJECTS/ROLLER/transfrm.h b/PROJECTS/ROLLER/transfrm.h index 342db6f5..f0a1e026 100644 --- a/PROJECTS/ROLLER/transfrm.h +++ b/PROJECTS/ROLLER/transfrm.h @@ -16,15 +16,17 @@ extern int yp; //------------------------------------------------------------------------------------------------- -void calculatetransform(int iTrackChunkIdx, int iDirection, int iElevation, int iTilt, - float fViewX, float fViewY, float fViewZ, +void calculatetransform(int iTrackChunkIdx, int iDirection, int iElevation, + int iTilt, float fViewX, float fViewY, float fViewZ, float fPosX, float fPosY, float fPosZ); void initlocaltrack(); void initlocalsection(int iChunkIdx); void dopitchchanges(int iLLaneIdx, int iRLaneIdx); int getpitchchange(int iChunkIdx, int iLLaneIdx, int iRLaneIdx); -void getworldangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimuth, int *piElevation, int *piBank); -void getlocalangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, int *piAzimuth, int *piElevation, int *piBank); +void getworldangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, + int *piAzimuth, int *piElevation, int *piBank); +void getlocalangles(int iYaw, int iPitch, int iRoll, int iChunkIdx, + int *piAzimuth, int *piElevation, int *piBank); //------------------------------------------------------------------------------------------------- #endif \ No newline at end of file diff --git a/PROJECTS/ROLLER/types.h b/PROJECTS/ROLLER/types.h index 54dd16ee..d9c8db66 100644 --- a/PROJECTS/ROLLER/types.h +++ b/PROJECTS/ROLLER/types.h @@ -5,7 +5,7 @@ #include //------------------------------------------------------------------------------------------------- -#if defined (WIN32) || defined (_WIN32) +#if defined(WIN32) || defined(_WIN32) #define IS_WINDOWS #elif defined(__linux__) || defined(linux) || defined(__linux) #define IS_LINUX @@ -36,136 +36,144 @@ //------------------------------------------------------------------------------------------------- // surface type flags -#define SURFACE_FLAG_WALL_31 0x80000000 -#define SURFACE_FLAG_BOUNCE_30 0x40000000 -#define SURFACE_FLAG_ECHO 0x20000000 -#define SURFACE_FLAG_AI_MAX_SPEED 0x10000000 -#define SURFACE_FLAG_NO_SPAWN 0x08000000 -#define SURFACE_FLAG_PIT_BOX 0x04000000 -#define SURFACE_FLAG_PIT 0x02000000 -#define SURFACE_FLAG_PIT_ZONE 0x01000000 -#define SURFACE_FLAG_AI_FAST_STRAT 0x00800000 -#define SURFACE_FLAG_WALL_22 0x00400000 -#define SURFACE_FLAG_TRANSPARENT 0x00200000 -#define SURFACE_FLAG_BOUNCE_20 0x00100000 -#define SURFACE_FLAG_NON_MAGNETIC 0x00080000 -#define SURFACE_FLAG_FLIP_VERT 0x00040000 -#define SURFACE_FLAG_SKIP_RENDER 0x00020000 -#define SURFACE_FLAG_TEXTURE_PAIR 0x00010000 -#define SURFACE_FLAG_PREVENT_JUMP 0x00008000 -#define SURFACE_FLAG_CONCAVE 0x00004000 -#define SURFACE_FLAG_FLIP_BACKFACE 0x00002000 -#define SURFACE_FLAG_FLIP_HORIZ 0x00001000 -#define SURFACE_FLAG_BACK 0x00000800 -#define SURFACE_FLAG_PARTIAL_TRANS 0x00000400 -#define SURFACE_FLAG_NO_EXTRAS 0x00000200 -#define SURFACE_FLAG_APPLY_TEXTURE 0x00000100 -#define SURFACE_MASK_FLAGS 0xFFFFFF00 -#define SURFACE_MASK_TEXTURE_INDEX 0x000000FF +#define SURFACE_FLAG_WALL_31 0x80000000 +#define SURFACE_FLAG_BOUNCE_30 0x40000000 +#define SURFACE_FLAG_ECHO 0x20000000 +#define SURFACE_FLAG_AI_MAX_SPEED 0x10000000 +#define SURFACE_FLAG_NO_SPAWN 0x08000000 +#define SURFACE_FLAG_PIT_BOX 0x04000000 +#define SURFACE_FLAG_PIT 0x02000000 +#define SURFACE_FLAG_PIT_ZONE 0x01000000 +#define SURFACE_FLAG_AI_FAST_STRAT 0x00800000 +#define SURFACE_FLAG_WALL_22 0x00400000 +#define SURFACE_FLAG_TRANSPARENT 0x00200000 +#define SURFACE_FLAG_BOUNCE_20 0x00100000 +#define SURFACE_FLAG_NON_MAGNETIC 0x00080000 +#define SURFACE_FLAG_FLIP_VERT 0x00040000 +#define SURFACE_FLAG_SKIP_RENDER 0x00020000 +#define SURFACE_FLAG_TEXTURE_PAIR 0x00010000 +#define SURFACE_FLAG_PREVENT_JUMP 0x00008000 +#define SURFACE_FLAG_CONCAVE 0x00004000 +#define SURFACE_FLAG_FLIP_BACKFACE 0x00002000 +#define SURFACE_FLAG_FLIP_HORIZ 0x00001000 +#define SURFACE_FLAG_BACK 0x00000800 +#define SURFACE_FLAG_PARTIAL_TRANS 0x00000400 +#define SURFACE_FLAG_NO_EXTRAS 0x00000200 +#define SURFACE_FLAG_APPLY_TEXTURE 0x00000100 +#define SURFACE_MASK_FLAGS 0xFFFFFF00 +#define SURFACE_MASK_TEXTURE_INDEX 0x000000FF //------------------------------------------------------------------------------------------------- // car-specific texture flags -#define CAR_FLAG_ANMS_LIVERY 0x00008000 -#define CAR_FLAG_ANMS_LOOKUP 0x00000200 +#define CAR_FLAG_ANMS_LIVERY 0x00008000 +#define CAR_FLAG_ANMS_LOOKUP 0x00000200 //------------------------------------------------------------------------------------------------- // cheat_mode flags -#define CHEAT_MODE_CHEAT_CAR 0x00000001 -#define CHEAT_MODE_DEATH_MODE 0x00000002 -#define CHEAT_MODE_INVINCIBLE 0x00000004 -#define CHEAT_MODE_GRAYSCALE 0x00000008 -#define CHEAT_MODE_END_SEQUENCE 0x00000010 -#define CHEAT_MODE_RACE_HISTORY 0x00000020 -#define CHEAT_MODE_WIDESCREEN 0x00000040 -#define CHEAT_MODE_CREDITS 0x00000080 -#define CHEAT_MODE_ADVANCED_CARS 0x00000100 -#define CHEAT_MODE_KILLER_OPPONENTS 0x00000200 -#define CHEAT_MODE_ICY_ROAD 0x00000400 -#define CHEAT_MODE_50HZ_TIMER 0x00000800 -#define CHEAT_MODE_DOUBLE_TRACK 0x00001000 -#define CHEAT_MODE_100HZ_TIMER 0x00002000 -#define CHEAT_MODE_CLONES 0x00004000 -#define CHEAT_MODE_TINY_CARS 0x00008000 -#define CHEAT_MODE_WARP 0x00010000 -#define CHEAT_MODE_FREAKY 0x00020000 +#define CHEAT_MODE_CHEAT_CAR 0x00000001 +#define CHEAT_MODE_DEATH_MODE 0x00000002 +#define CHEAT_MODE_INVINCIBLE 0x00000004 +#define CHEAT_MODE_GRAYSCALE 0x00000008 +#define CHEAT_MODE_END_SEQUENCE 0x00000010 +#define CHEAT_MODE_RACE_HISTORY 0x00000020 +#define CHEAT_MODE_WIDESCREEN 0x00000040 +#define CHEAT_MODE_CREDITS 0x00000080 +#define CHEAT_MODE_ADVANCED_CARS 0x00000100 +#define CHEAT_MODE_KILLER_OPPONENTS 0x00000200 +#define CHEAT_MODE_ICY_ROAD 0x00000400 +#define CHEAT_MODE_50HZ_TIMER 0x00000800 +#define CHEAT_MODE_DOUBLE_TRACK 0x00001000 +#define CHEAT_MODE_100HZ_TIMER 0x00002000 +#define CHEAT_MODE_CLONES 0x00004000 +#define CHEAT_MODE_TINY_CARS 0x00008000 +#define CHEAT_MODE_WARP 0x00010000 +#define CHEAT_MODE_FREAKY 0x00020000 //------------------------------------------------------------------------------------------------- // textures_off flags -#define TEX_OFF_GROUND_TEXTURES 0x00000001 -#define TEX_OFF_ROAD_TEXTURES 0x00000002 -#define TEX_OFF_WALL_TEXTURES 0x00000004 -#define TEX_OFF_CLOUDS 0x00000008 -#define TEX_OFF_HORIZON 0x00000010 -#define TEX_OFF_PANEL_OFF 0x00000020 -#define TEX_OFF_CAR_TEXTURES 0x00000040 -#define TEX_OFF_BUILDING_TEXTURES 0x00000080 -#define TEX_OFF_SHADOWS 0x00000100 -#define TEX_OFF_BUILDINGS 0x00000200 -#define TEX_OFF_KMH 0x00000400 -#define TEX_OFF_GLASS_WALLS 0x00000800 -#define TEX_OFF_PREMIER_CUP_AVAILABLE 0x00001000 -#define TEX_OFF_WIDESCREEN 0x00002000 -#define TEX_OFF_CAR_SET_AVAILABLE 0x00008000 -#define TEX_OFF_ADVANCED_CARS 0x00010000 -#define TEX_OFF_BONUS_CUP_AVAILABLE 0x00020000 -#define TEX_OFF_PANEL_RESTRICTED 0x00040000 -#define TEX_OFF_PERSPECTIVE_CORRECTION 0x00080000 +#define TEX_OFF_GROUND_TEXTURES 0x00000001 +#define TEX_OFF_ROAD_TEXTURES 0x00000002 +#define TEX_OFF_WALL_TEXTURES 0x00000004 +#define TEX_OFF_CLOUDS 0x00000008 +#define TEX_OFF_HORIZON 0x00000010 +#define TEX_OFF_PANEL_OFF 0x00000020 +#define TEX_OFF_CAR_TEXTURES 0x00000040 +#define TEX_OFF_BUILDING_TEXTURES 0x00000080 +#define TEX_OFF_SHADOWS 0x00000100 +#define TEX_OFF_BUILDINGS 0x00000200 +#define TEX_OFF_KMH 0x00000400 +#define TEX_OFF_GLASS_WALLS 0x00000800 +#define TEX_OFF_PREMIER_CUP_AVAILABLE 0x00001000 +#define TEX_OFF_WIDESCREEN 0x00002000 +#define TEX_OFF_CAR_SET_AVAILABLE 0x00008000 +#define TEX_OFF_ADVANCED_CARS 0x00010000 +#define TEX_OFF_BONUS_CUP_AVAILABLE 0x00020000 +#define TEX_OFF_PANEL_RESTRICTED 0x00040000 +#define TEX_OFF_PERSPECTIVE_CORRECTION 0x00080000 //------------------------------------------------------------------------------------------------- // -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; -typedef uint8_t uint8; +typedef int8_t int8; +typedef int16_t int16; +typedef int32_t int32; +typedef int64_t int64; +typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; typedef uint64_t uint64; // Windows-specific types when needed #if !defined(IS_WINDOWS) - typedef uint32_t DWORD; - typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef uint16_t WORD; #endif //------------------------------------------------------------------------------------------------- -//16.16 fixed point math helpers +// 16.16 fixed point math helpers typedef int32 fixed16_16; #define TO_FIXED(x) ((fixed16_16)((x) * 65536.0f)) #define FROM_FIXED(x) ((float)(x) / 65536.0f) #define GET_HIWORD(x) (((x) >> 16)) -#define SET_HIWORD(lval, rval) (lval = (lval & 0x0000FFFF) | ((uint32)(rval) << 16)) +#define SET_HIWORD(lval, rval) \ + (lval = (lval & 0x0000FFFF) | ((uint32)(rval) << 16)) #define GET_LOWORD(x) ((x) & 0xFFFF) -#define SET_LOWORD(lval, rval) (lval = (lval & 0xFFFF0000) | ((rval) & 0x0000FFFF)) +#define SET_LOWORD(lval, rval) \ + (lval = (lval & 0xFFFF0000) | ((rval) & 0x0000FFFF)) #define INC_HIWORD(x) (SET_HIWORD(x, GET_HIWORD(x) + 1)) #define DEC_HIWORD(x) (SET_HIWORD(x, GET_HIWORD(x) - 1)) #define INC_LOWORD(x) (SET_LOWORD(x, GET_LOWORD(x) + 1)) #define DEC_LOWORD(x) (SET_LOWORD(x, GET_LOWORD(x) - 1)) -#define GET_SHIWORD(x) (int16)GET_HIWORD(x) -#define GET_SLOWORD(x) (int16)GET_LOWORD(x) +#define GET_SHIWORD(x) (int16) GET_HIWORD(x) +#define GET_SLOWORD(x) (int16) GET_LOWORD(x) -#define SET_BYTE1(lval, rval) (lval = (lval & 0xFFFF00FF) | ((rval) & 0x000000FF)) +#define SET_BYTE1(lval, rval) \ + (lval = (lval & 0xFFFF00FF) | ((rval) & 0x000000FF)) #define GET_HIBYTE(x) (((x) >> 24)) -//64-bit helpers -#define SET_BYTE1_64(lval, rval) (lval = (lval & 0xFFFFFFFFFFFF00FF) | ((rval) & 0x000000000000FF00)) -#define SET_LOWORD_64(lval, rval) (lval = (lval & 0xFFFFFFFFFFFF0000) | ((rval) & 0x000000000000FFFF)) +// 64-bit helpers +#define SET_BYTE1_64(lval, rval) \ + (lval = (lval & 0xFFFFFFFFFFFF00FF) | ((rval) & 0x000000000000FF00)) +#define SET_LOWORD_64(lval, rval) \ + (lval = (lval & 0xFFFFFFFFFFFF0000) | ((rval) & 0x000000000000FFFF)) #define GET_HIDWORD(x) (((x) >> 32) & 0xFFFFFFFF) -#define SET_HIDWORD(lval, rval) (lval = (lval & 0x00000000FFFFFFFF) | ((uint64)(rval) << 32)) +#define SET_HIDWORD(lval, rval) \ + (lval = (lval & 0x00000000FFFFFFFF) | ((uint64)(rval) << 32)) #define GET_LODWORD(x) ((x) & 0xFFFFFFFF) -#define SET_LODWORD(lval, rval) (lval = (lval & 0xFFFFFFFF00000000) | ((rval) & 0x00000000FFFFFFFF)) +#define SET_LODWORD(lval, rval) \ + (lval = (lval & 0xFFFFFFFF00000000) | ((rval) & 0x00000000FFFFFFFF)) #define __PAIR64__(high, low) (((uint64)(uint32)(high) << 32) | (uint32)(low)) -//other bitwise helpers -#define SET_LOBYTE(lval, rval) (lval = (lval & 0xFFFFFF00) | ((rval) & 0x000000FF)) +// other bitwise helpers +#define SET_LOBYTE(lval, rval) \ + (lval = (lval & 0xFFFFFF00) | ((rval) & 0x000000FF)) #define SIGN_EXTEND_24(x) ((int32)((x & 0xFFFFFF) ^ 0x800000) - 0x800000) -#define PACK_24_WITH_TAG(val, tag) ((((uint32)(tag) & 0xFF) << 24) | ((uint32)(val) & 0xFFFFFF)) +#define PACK_24_WITH_TAG(val, tag) \ + ((((uint32)(tag) & 0xFF) << 24) | ((uint32)(val) & 0xFFFFFF)) //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fX; float fY; float fZ; @@ -173,8 +181,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef enum -{ +typedef enum { CAR_AUTO = 0x1, CAR_DESILVA = 0x2, CAR_PULSE = 0x3, @@ -206,8 +213,7 @@ typedef enum //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { uint8 byR; uint8 byB; uint8 byG; diff --git a/PROJECTS/ROLLER/userfns.c b/PROJECTS/ROLLER/userfns.c index 0ce422c1..9665e683 100644 --- a/PROJECTS/ROLLER/userfns.c +++ b/PROJECTS/ROLLER/userfns.c @@ -1,9 +1,8 @@ #include "userfns.h" #include //------------------------------------------------------------------------------------------------- -//00075D50 -double getdirection(double x, double y) -{ +// 00075D50 +double getdirection(double x, double y) { if (x == 0.0 && y == 0.0) { return -1.0; } diff --git a/PROJECTS/ROLLER/view.c b/PROJECTS/ROLLER/view.c index b6ec0c25..6a7d6883 100644 --- a/PROJECTS/ROLLER/view.c +++ b/PROJECTS/ROLLER/view.c @@ -11,117 +11,115 @@ #include //------------------------------------------------------------------------------------------------- -tViewData viewdata[2] = //000A74A8 -{ - { 4500.0, 500.0, 640.0, -240.0, 200.0, 160.0 }, - { 2000.0, 500.0, 450.0, 350.0, 200.0, 100.0 } -}; -int chaseview[2] = { 0, 0 }; //000A74D8 -float CHASE_DIST[2] = { 4500.0, 4500.0 }; //000A74E0 -float CHASE_MIN[2] = { 500.0, 500.0 }; //000A74E8 -float PULLZ[2] = { 640.0, 640.0 }; //000A74F0 -float LOOKZ[2] = { 160.0, 160.0 }; //000A74F8 -int nextpoint[2] = { 0, 0 }; //000A7500 -tCameraPos lastpos[2][64]; //001A1250 -float TowerGx; //001A1A54 -float TowerGy; //001A1A58 -float TowerGz; //001A1A5C -int lastcamelevation; //001A1A60 -int lastcamdirection; //001A1A64 -int NearTow; //001A1A68 -float chase_x; //001A1A6C -float chase_y; //001A1A70 -float chase_z; //001A1A74 +tViewData viewdata[2] = // 000A74A8 + {{4500.0, 500.0, 640.0, -240.0, 200.0, 160.0}, + {2000.0, 500.0, 450.0, 350.0, 200.0, 100.0}}; +int chaseview[2] = {0, 0}; // 000A74D8 +float CHASE_DIST[2] = {4500.0, 4500.0}; // 000A74E0 +float CHASE_MIN[2] = {500.0, 500.0}; // 000A74E8 +float PULLZ[2] = {640.0, 640.0}; // 000A74F0 +float LOOKZ[2] = {160.0, 160.0}; // 000A74F8 +int nextpoint[2] = {0, 0}; // 000A7500 +tCameraPos lastpos[2][64]; // 001A1250 +float TowerGx; // 001A1A54 +float TowerGy; // 001A1A58 +float TowerGz; // 001A1A5C +int lastcamelevation; // 001A1A60 +int lastcamdirection; // 001A1A64 +int NearTow; // 001A1A68 +float chase_x; // 001A1A6C +float chase_y; // 001A1A70 +float chase_z; // 001A1A74 //------------------------------------------------------------------------------------------------- -//000729C0 -void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) -{ - int iClosestTowerIdx; // esi - int iCarIndex; // eax - int iChunkIndex; // eax +// 000729C0 +void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) { + int iClosestTowerIdx; // esi + int iCarIndex; // eax + int iChunkIndex; // eax tData *pTransformMatrix; // eax - int iTowerLoopIdx; // edx - int iTowerArrayIdx; // ebx - //int iTempValue; // eax - int iTowerType; // eax - double dWorldZOffset; // st7 - int iChunkIdxMinus2; // eax - float *pTransformMinus2; // eax - double dDeltaX; // st7 - double dDeltaY; // st6 - double dDeltaZ; // st4 - double dInvMagnitude; // st3 - int iCalculatedElevation; // eax - float fCarPosZ; // edx - int iCarChunk; // eax - tData *pCarTransform; // eax - float fCarPosZ2; // edx - int iCarChunk2; // eax - tData *pCarTransform2; // eax - int iRollCalculated; // eax - int iPitchCalculated; // edi - int iPitchCalculated2; // edi - int iCarIndex2; // edi - int iYaw; // edx - int iCurrChunk; // ecx - float fX; // [esp-18h] [ebp-E4h] - float fY; // [esp-14h] [ebp-E0h] - float fZ; // [esp-10h] [ebp-DCh] - double dChunkDistance; // [esp+0h] [ebp-CCh] - double dMinDistance; // [esp+8h] [ebp-C4h] - double dWrapDistance; // [esp+10h] [ebp-BCh] - float fCameraOffsetX; // [esp+2Ch] [ebp-A0h] - float fCameraOffsetY; // [esp+30h] [ebp-9Ch] - float fCameraOffsetZ; // [esp+34h] [ebp-98h] - float fPosX; // [esp+38h] [ebp-94h] - float fPosZ; // [esp+3Ch] [ebp-90h] - float fPosY; // [esp+40h] [ebp-8Ch] - float fHorizontalDistance; // [esp+44h] [ebp-88h] - float fVerticalDistance; // [esp+48h] [ebp-84h] - float fTowerVerticalDistance; // [esp+4Ch] [ebp-80h] + int iTowerLoopIdx; // edx + int iTowerArrayIdx; // ebx + // int iTempValue; // eax + int iTowerType; // eax + double dWorldZOffset; // st7 + int iChunkIdxMinus2; // eax + float *pTransformMinus2; // eax + double dDeltaX; // st7 + double dDeltaY; // st6 + double dDeltaZ; // st4 + double dInvMagnitude; // st3 + int iCalculatedElevation; // eax + float fCarPosZ; // edx + int iCarChunk; // eax + tData *pCarTransform; // eax + float fCarPosZ2; // edx + int iCarChunk2; // eax + tData *pCarTransform2; // eax + int iRollCalculated; // eax + int iPitchCalculated; // edi + int iPitchCalculated2; // edi + int iCarIndex2; // edi + int iYaw; // edx + int iCurrChunk; // ecx + float fX; // [esp-18h] [ebp-E4h] + float fY; // [esp-14h] [ebp-E0h] + float fZ; // [esp-10h] [ebp-DCh] + double dChunkDistance; // [esp+0h] [ebp-CCh] + double dMinDistance; // [esp+8h] [ebp-C4h] + double dWrapDistance; // [esp+10h] [ebp-BCh] + float fCameraOffsetX; // [esp+2Ch] [ebp-A0h] + float fCameraOffsetY; // [esp+30h] [ebp-9Ch] + float fCameraOffsetZ; // [esp+34h] [ebp-98h] + float fPosX; // [esp+38h] [ebp-94h] + float fPosZ; // [esp+3Ch] [ebp-90h] + float fPosY; // [esp+40h] [ebp-8Ch] + float fHorizontalDistance; // [esp+44h] [ebp-88h] + float fVerticalDistance; // [esp+48h] [ebp-84h] + float fTowerVerticalDistance; // [esp+4Ch] [ebp-80h] float fTowerHorizontalDistance; // [esp+50h] [ebp-7Ch] - float fDeltaX; // [esp+54h] [ebp-78h] - float fDeltaY; // [esp+58h] [ebp-74h] - float fCarPosY; // [esp+5Ch] [ebp-70h] - float fTowerDeltaX; // [esp+60h] [ebp-6Ch] - float fCarPosY2; // [esp+64h] [ebp-68h] - float fTowerDeltaY; // [esp+6Ch] [ebp-60h] - float fCarPosX; // [esp+70h] [ebp-5Ch] - float fCarPosZ3; // [esp+74h] [ebp-58h] - float fCarPosY3; // [esp+78h] [ebp-54h] - float fCarPosX2; // [esp+7Ch] [ebp-50h] - float fCarPosX3; // [esp+80h] [ebp-4Ch] - float fCarPosZ4; // [esp+84h] [ebp-48h] - float fTransformedPosZ; // [esp+88h] [ebp-44h] - float fTransformedPosX; // [esp+8Ch] [ebp-40h] - float fTransformedPosY; // [esp+90h] [ebp-3Ch] - int iTilt; // [esp+94h] [ebp-38h] - float fWorldPosX; // [esp+98h] [ebp-34h] - float fWorldPosX2; // [esp+9Ch] [ebp-30h] - float fWorldPosZ; // [esp+A0h] [ebp-2Ch] - int iElevation2; // [esp+A4h] [ebp-28h] - int iLastValidChunk; // [esp+A8h] [ebp-24h] - float fClosestTowerDistance; // [esp+ACh] [ebp-20h] - float fMinTowerDistance; // [esp+B0h] [ebp-1Ch] - float fCurrentTowerDistance; // [esp+B4h] [ebp-18h] - float fChunkIdx; // [esp+B8h] [ebp-14h] - float fChunkIndexDiff; // [esp+B8h] [ebp-14h] + float fDeltaX; // [esp+54h] [ebp-78h] + float fDeltaY; // [esp+58h] [ebp-74h] + float fCarPosY; // [esp+5Ch] [ebp-70h] + float fTowerDeltaX; // [esp+60h] [ebp-6Ch] + float fCarPosY2; // [esp+64h] [ebp-68h] + float fTowerDeltaY; // [esp+6Ch] [ebp-60h] + float fCarPosX; // [esp+70h] [ebp-5Ch] + float fCarPosZ3; // [esp+74h] [ebp-58h] + float fCarPosY3; // [esp+78h] [ebp-54h] + float fCarPosX2; // [esp+7Ch] [ebp-50h] + float fCarPosX3; // [esp+80h] [ebp-4Ch] + float fCarPosZ4; // [esp+84h] [ebp-48h] + float fTransformedPosZ; // [esp+88h] [ebp-44h] + float fTransformedPosX; // [esp+8Ch] [ebp-40h] + float fTransformedPosY; // [esp+90h] [ebp-3Ch] + int iTilt; // [esp+94h] [ebp-38h] + float fWorldPosX; // [esp+98h] [ebp-34h] + float fWorldPosX2; // [esp+9Ch] [ebp-30h] + float fWorldPosZ; // [esp+A0h] [ebp-2Ch] + int iElevation2; // [esp+A4h] [ebp-28h] + int iLastValidChunk; // [esp+A8h] [ebp-24h] + float fClosestTowerDistance; // [esp+ACh] [ebp-20h] + float fMinTowerDistance; // [esp+B0h] [ebp-1Ch] + float fCurrentTowerDistance; // [esp+B4h] [ebp-18h] + float fChunkIdx; // [esp+B8h] [ebp-14h] + float fChunkIndexDiff; // [esp+B8h] [ebp-14h] - VIEWDIST = 200; // Set default view distance + VIEWDIST = 200; // Set default view distance iClosestTowerIdx = -1; - if (iViewMode < -1) // Handle different view modes - set camera offset values + if (iViewMode < -1) // Handle different view modes - set camera offset values { if (iViewMode != -2) goto LABEL_8; LABEL_6: - ext_x = 11.0; // Rear external view (mode -2) or cockpit view (mode 1) - behind car + ext_x = 11.0; // Rear external view (mode -2) or cockpit view (mode 1) - + // behind car ext_y = 0.0; ext_z = 9.0; goto LABEL_9; } if (iViewMode <= 0) { - ext_x = 0.0; // Driver view (mode 0) - inside car + ext_x = 0.0; // Driver view (mode 0) - inside car ext_y = 0.0; ext_z = 3.0; goto LABEL_9; @@ -129,68 +127,91 @@ void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) if (iViewMode == 1) goto LABEL_6; LABEL_8: - ext_x = -1.0; // Invalid view mode - set error values + ext_x = -1.0; // Invalid view mode - set error values ext_y = -1.0; ext_z = -1.0; LABEL_9: iCarIndex = iCarIdx; - if (iViewMode < 3) // Check if view mode is less than 3 (standard car views) - { // Standard car camera views (driver, cockpit, chase) + if (iViewMode < 3) // Check if view mode is less than 3 (standard car views) + { // Standard car camera views (driver, cockpit, chase) if (iViewMode >= 0) { - mirror = 0; // Normal view modes (non-mirror) - if (iViewMode == 1) // Check if cockpit view (mode 1) - { // Calculate pitch for cockpit view - check if car is stunned + mirror = 0; // Normal view modes (non-mirror) + if (iViewMode == 1) // Check if cockpit view (mode 1) + { // Calculate pitch for cockpit view - check if car is stunned if (Car[iCarIdx].iStunned) - iPitchCalculated = Car[iCarIdx].iPitchCameraOffset + Car[iCarIdx].nPitch; + iPitchCalculated = + Car[iCarIdx].iPitchCameraOffset + Car[iCarIdx].nPitch; else - iPitchCalculated = Car[iCarIdx].iPitchDynamicOffset + Car[iCarIdx].iPitchCameraOffset + Car[iCarIdx].nPitch; + iPitchCalculated = Car[iCarIdx].iPitchDynamicOffset + + Car[iCarIdx].iPitchCameraOffset + + Car[iCarIdx].nPitch; iElevation2 = ((int16)iPitchCalculated + 0x2000) & 0x3FFF; - iRollCalculated = Car[iCarIdx].iRollDynamicOffset + Car[iCarIdx].iRollCameraOffset + Car[iCarIdx].nRoll + 0x2000; - } else { // Calculate pitch for driver view - check if car is stunned + iRollCalculated = Car[iCarIdx].iRollDynamicOffset + + Car[iCarIdx].iRollCameraOffset + Car[iCarIdx].nRoll + + 0x2000; + } else { // Calculate pitch for driver view - check if car is stunned if (Car[iCarIdx].iStunned) - iPitchCalculated2 = Car[iCarIdx].iPitchCameraOffset + Car[iCarIdx].nPitch; + iPitchCalculated2 = + Car[iCarIdx].iPitchCameraOffset + Car[iCarIdx].nPitch; else - iPitchCalculated2 = Car[iCarIdx].iPitchDynamicOffset + Car[iCarIdx].iPitchCameraOffset + Car[iCarIdx].nPitch; + iPitchCalculated2 = Car[iCarIdx].iPitchDynamicOffset + + Car[iCarIdx].iPitchCameraOffset + + Car[iCarIdx].nPitch; iElevation2 = ((int16)iPitchCalculated2 + 455) & 0x3FFF; - iRollCalculated = Car[iCarIdx].iRollDynamicOffset + Car[iCarIdx].iRollCameraOffset + Car[iCarIdx].nRoll; + iRollCalculated = Car[iCarIdx].iRollDynamicOffset + + Car[iCarIdx].iRollCameraOffset + Car[iCarIdx].nRoll; } } else { - mirror = -1; // Mirror view mode - set mirror flag - iElevation2 = ((uint16)(Car[iCarIdx].iPitchCameraOffset) + Car[iCarIdx].nPitch + 0x2000) & 0x3FFF; - iRollCalculated = Car[iCarIdx].iRollCameraOffset + Car[iCarIdx].nRoll + 0x2000; + mirror = -1; // Mirror view mode - set mirror flag + iElevation2 = ((uint16)(Car[iCarIdx].iPitchCameraOffset) + + Car[iCarIdx].nPitch + 0x2000) & + 0x3FFF; + iRollCalculated = + Car[iCarIdx].iRollCameraOffset + Car[iCarIdx].nRoll + 0x2000; } iTilt = iRollCalculated & 0x3FFF; NearTow = -1; - if (iViewMode == 2) // Check if chase view mode + if (iViewMode == 2) // Check if chase view mode { - newchaseview(iCarIdx, iChaseCamIdx); // Handle chase view - call specialized function + newchaseview( + iCarIdx, + iChaseCamIdx); // Handle chase view - call specialized function return; } - fCameraOffsetY = ext_y * 64.0f; // Scale camera offsets and apply to display position + fCameraOffsetY = + ext_y * 64.0f; // Scale camera offsets and apply to display position fCameraOffsetZ = ext_z * 32.0f; fCameraOffsetX = ext_x * 64.0f; fPosX = DDX + fCameraOffsetY; iCarIndex2 = iCarIdx; fPosY = DDY + fCameraOffsetZ; fPosZ = DDZ - fCameraOffsetX; - if (iViewMode == 1) // Check if cockpit view for special handling + if (iViewMode == 1) // Check if cockpit view for special handling { - fZ = Car[iCarIdx].pos.fZ; // Cockpit view - get car position and orientation + fZ = Car[iCarIdx] + .pos.fZ; // Cockpit view - get car position and orientation fY = Car[iCarIdx].pos.fY; fX = Car[iCarIdx].pos.fX; iYaw = Car[iCarIdx].nYaw; - VIEWDIST = 120; // Set closer view distance for cockpit - calculatetransform(Car[iCarIndex2].nCurrChunk, iYaw, iElevation2, iTilt, fX, fY, fZ, fPosX, fPosY, fPosZ);// Calculate transformation matrix for cockpit view + VIEWDIST = 120; // Set closer view distance for cockpit + calculatetransform( + Car[iCarIndex2].nCurrChunk, iYaw, iElevation2, iTilt, fX, fY, fZ, + fPosX, fPosY, + fPosZ); // Calculate transformation matrix for cockpit view iCurrChunk = Car[iCarIndex2].nCurrChunk; - if (iCurrChunk == -1) // Check if car is off-track (chunk = -1) + if (iCurrChunk == -1) // Check if car is off-track (chunk = -1) { - worlddirn = Car[iCarIndex2].nYaw; // Car off-track - use raw orientation values + worlddirn = + Car[iCarIndex2].nYaw; // Car off-track - use raw orientation values worldelev = iElevation2; worldtilt = iTilt; return; } } else { - calculatetransform(Car[iCarIdx].nCurrChunk, Car[iCarIdx].nYaw, iElevation2, iTilt, Car[iCarIdx].pos.fX, Car[iCarIdx].pos.fY, Car[iCarIdx].pos.fZ, fPosX, fPosY, fPosZ);// Driver view - calculate transformation matrix + calculatetransform( + Car[iCarIdx].nCurrChunk, Car[iCarIdx].nYaw, iElevation2, iTilt, + Car[iCarIdx].pos.fX, Car[iCarIdx].pos.fY, Car[iCarIdx].pos.fZ, fPosX, + fPosY, fPosZ); // Driver view - calculate transformation matrix iCurrChunk = Car[iCarIdx].nCurrChunk; if (iCurrChunk == -1) { worlddirn = Car[iCarIdx].nYaw; @@ -199,51 +220,57 @@ void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) return; } } - getworldangles(Car[iCarIndex2].nYaw, iElevation2, iTilt, iCurrChunk, &worlddirn, &worldelev, &worldtilt);// Convert car angles to world coordinates - } else if (iViewMode == 3) // Tower/spectator view mode (mode 3) + getworldangles(Car[iCarIndex2].nYaw, iElevation2, iTilt, iCurrChunk, + &worlddirn, &worldelev, + &worldtilt); // Convert car angles to world coordinates + } else if (iViewMode == 3) // Tower/spectator view mode (mode 3) { - fCarPosX3 = Car[iCarIdx].pos.fX; // Get car position for tower view + fCarPosX3 = Car[iCarIdx].pos.fX; // Get car position for tower view fCarPosY2 = Car[iCarIdx].pos.fY; iChunkIndex = Car[iCarIdx].nCurrChunk; fCarPosZ3 = Car[iCarIdx].pos.fZ; iLastValidChunk = iChunkIndex; - if (iChunkIndex == -1) // Check if car is off-track + if (iChunkIndex == -1) // Check if car is off-track { - fWorldPosX2 = Car[iCarIdx].pos.fX; // Car off-track - use raw position + fWorldPosX2 = Car[iCarIdx].pos.fX; // Car off-track - use raw position fWorldPosZ = Car[iCarIdx].pos.fZ; fWorldPosX = Car[iCarIdx].pos.fY; } else { - pTransformMatrix = &localdata[iChunkIndex];// Transform car position to world coordinates - fWorldPosX2 = pTransformMatrix->pointAy[0].fY * fCarPosY2 - + pTransformMatrix->pointAy[0].fX * fCarPosX3 - + pTransformMatrix->pointAy[0].fZ * fCarPosZ3 - - pTransformMatrix->pointAy[3].fX; - fWorldPosX = pTransformMatrix->pointAy[1].fX * fCarPosX3 - + pTransformMatrix->pointAy[1].fY * fCarPosY2 - + pTransformMatrix->pointAy[1].fZ * fCarPosZ3 - - pTransformMatrix->pointAy[3].fY; - fWorldPosZ = fCarPosY2 * pTransformMatrix->pointAy[2].fY - + fCarPosX3 * pTransformMatrix->pointAy[2].fX - + fCarPosZ3 * pTransformMatrix->pointAy[2].fZ - - pTransformMatrix->pointAy[3].fZ; + pTransformMatrix = &localdata[iChunkIndex]; // Transform car position to + // world coordinates + fWorldPosX2 = pTransformMatrix->pointAy[0].fY * fCarPosY2 + + pTransformMatrix->pointAy[0].fX * fCarPosX3 + + pTransformMatrix->pointAy[0].fZ * fCarPosZ3 - + pTransformMatrix->pointAy[3].fX; + fWorldPosX = pTransformMatrix->pointAy[1].fX * fCarPosX3 + + pTransformMatrix->pointAy[1].fY * fCarPosY2 + + pTransformMatrix->pointAy[1].fZ * fCarPosZ3 - + pTransformMatrix->pointAy[3].fY; + fWorldPosZ = fCarPosY2 * pTransformMatrix->pointAy[2].fY + + fCarPosX3 * pTransformMatrix->pointAy[2].fX + + fCarPosZ3 * pTransformMatrix->pointAy[2].fZ - + pTransformMatrix->pointAy[3].fZ; } - if (NumTowers <= 0) // Check if towers are available for spectator mode + if (NumTowers <= 0) // Check if towers are available for spectator mode { - dWorldZOffset = fWorldPosZ + 16384.0; // No towers - use default elevated view + dWorldZOffset = + fWorldPosZ + 16384.0; // No towers - use default elevated view worldx = fWorldPosX2; worldy = fWorldPosX; LABEL_39: worldz = (float)dWorldZOffset; - } else { // Find closest tower to car position + } else { // Find closest tower to car position if (iLastValidChunk == -1) iLastValidChunk = Car[iCarIdx].iLastValidChunk; iClosestTowerIdx = 0; - iTowerLoopIdx = 0; // Initialize tower search variables + iTowerLoopIdx = 0; // Initialize tower search variables fMinTowerDistance = 9.9999998e17f; if (NumTowers > 0) { - iTowerArrayIdx = 0; // Loop through all towers + iTowerArrayIdx = 0; // Loop through all towers do { - fChunkIdx = (float)TowerBase[iTowerArrayIdx].iChunkIdx;// Calculate distance considering track wraparound + fChunkIdx = + (float)TowerBase[iTowerArrayIdx] + .iChunkIdx; // Calculate distance considering track wraparound fChunkIndexDiff = (float)((double)iLastValidChunk - fChunkIdx); fClosestTowerDistance = (float)TRAK_LEN; dWrapDistance = fabs(fChunkIndexDiff - fClosestTowerDistance); @@ -254,16 +281,17 @@ void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) } else { dMinDistance = dChunkDistance; } - //if (dChunkDistance >= dWrapDistance) { - // iTempValue = HIDWORD(dWrapDistance); - // LODWORD(dMinDistance) = LODWORD(dWrapDistance); - //} else { - // iTempValue = HIDWORD(dChunkDistance); - // LODWORD(dMinDistance) = LODWORD(dChunkDistance); - //} - //HIDWORD(dMinDistance) = iTempValue; + // if (dChunkDistance >= dWrapDistance) { + // iTempValue = HIDWORD(dWrapDistance); + // LODWORD(dMinDistance) = LODWORD(dWrapDistance); + // } else { + // iTempValue = HIDWORD(dChunkDistance); + // LODWORD(dMinDistance) = LODWORD(dChunkDistance); + // } + // HIDWORD(dMinDistance) = iTempValue; - if (dMinDistance < fMinTowerDistance)// Update closest tower if this one is nearer + if (dMinDistance < + fMinTowerDistance) // Update closest tower if this one is nearer { iClosestTowerIdx = iTowerLoopIdx; fCurrentTowerDistance = (float)dMinDistance; @@ -273,165 +301,190 @@ void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) ++iTowerArrayIdx; } while (iTowerLoopIdx < NumTowers); } - worldx = TowerX[iClosestTowerIdx]; // Use closest tower position + worldx = TowerX[iClosestTowerIdx]; // Use closest tower position worldy = TowerY[iClosestTowerIdx]; - iTowerType = TowerBase[iClosestTowerIdx].iTowerType - 1;// Set view distance based on tower type + iTowerType = TowerBase[iClosestTowerIdx].iTowerType - + 1; // Set view distance based on tower type worldz = TowerZ[iClosestTowerIdx]; switch (iTowerType) { - case 0: - VIEWDIST = 120; // Tower type 1 - medium view distance - break; - case 1: - VIEWDIST = 75; // Tower type 2 - close view distance - break; - case 2: - VIEWDIST = 500; // Tower type 3 - far view distance - break; - case 3: - VIEWDIST = 750; // Tower type 4 - very far view distance - break; - default: - break; + case 0: + VIEWDIST = 120; // Tower type 1 - medium view distance + break; + case 1: + VIEWDIST = 75; // Tower type 2 - close view distance + break; + case 2: + VIEWDIST = 500; // Tower type 3 - far view distance + break; + case 3: + VIEWDIST = 750; // Tower type 4 - very far view distance + break; + default: + break; } switch (TowerBase[iClosestTowerIdx].iEnabled) { - case 0xFFFFFFFB: - dWorldZOffset = (double)(TowerBase[iClosestTowerIdx].iVOffset << 7) + fWorldPosZ;// Mode -5: Elevated view with vertical offset - worldx = fWorldPosX2; - worldy = fWorldPosX; - goto LABEL_39; - case 0xFFFFFFFC: - iChunkIdxMinus2 = TowerBase[iClosestTowerIdx].iChunkIdx - 2;// Mode -4: Look back 2 chunks - if (iChunkIdxMinus2 < 0) - iChunkIdxMinus2 += TRAK_LEN; - pTransformMinus2 = (float *)&localdata[iChunkIdxMinus2]; - fWorldPosX2 = -pTransformMinus2[9]; - fWorldPosX = -pTransformMinus2[10]; - fWorldPosZ = -pTransformMinus2[11]; - break; - case 0xFFFFFFFD: - case 2: - dDeltaX = worldx - fWorldPosX2; // Mode -3/2: Directional offset from tower - dDeltaY = worldy - fWorldPosX; - dDeltaZ = worldz - fWorldPosZ; - dInvMagnitude = 1.0 / sqrt(dDeltaX * dDeltaX + dDeltaY * dDeltaY + dDeltaZ * dDeltaZ); - worldx = (float)(dDeltaX * 2560.0 * dInvMagnitude + fWorldPosX2); - worldy = (float)(dDeltaY * 2560.0 * dInvMagnitude + fWorldPosX); - worldz = (float)(dInvMagnitude * (dDeltaZ * 2560.0) + fWorldPosZ); - break; - case 0xFFFFFFFE: - case 1: - worldx = (worldx - fWorldPosX2) * 0.25f + fWorldPosX2;// Mode -2/1: Interpolated position - worldy = fWorldPosX + (worldy - fWorldPosX) * 0.25f; - dWorldZOffset = (worldz - fWorldPosZ) * 0.25f + fWorldPosZ; - goto LABEL_39; - case 0: - dWorldZOffset = worldz + 3200.0; // Mode 0: Fixed height offset - goto LABEL_39; - default: - break; // Handle different tower camera modes + case 0xFFFFFFFB: + dWorldZOffset = + (double)(TowerBase[iClosestTowerIdx].iVOffset << 7) + + fWorldPosZ; // Mode -5: Elevated view with vertical offset + worldx = fWorldPosX2; + worldy = fWorldPosX; + goto LABEL_39; + case 0xFFFFFFFC: + iChunkIdxMinus2 = TowerBase[iClosestTowerIdx].iChunkIdx - + 2; // Mode -4: Look back 2 chunks + if (iChunkIdxMinus2 < 0) + iChunkIdxMinus2 += TRAK_LEN; + pTransformMinus2 = (float *)&localdata[iChunkIdxMinus2]; + fWorldPosX2 = -pTransformMinus2[9]; + fWorldPosX = -pTransformMinus2[10]; + fWorldPosZ = -pTransformMinus2[11]; + break; + case 0xFFFFFFFD: + case 2: + dDeltaX = + worldx - fWorldPosX2; // Mode -3/2: Directional offset from tower + dDeltaY = worldy - fWorldPosX; + dDeltaZ = worldz - fWorldPosZ; + dInvMagnitude = 1.0 / sqrt(dDeltaX * dDeltaX + dDeltaY * dDeltaY + + dDeltaZ * dDeltaZ); + worldx = (float)(dDeltaX * 2560.0 * dInvMagnitude + fWorldPosX2); + worldy = (float)(dDeltaY * 2560.0 * dInvMagnitude + fWorldPosX); + worldz = (float)(dInvMagnitude * (dDeltaZ * 2560.0) + fWorldPosZ); + break; + case 0xFFFFFFFE: + case 1: + worldx = (worldx - fWorldPosX2) * 0.25f + + fWorldPosX2; // Mode -2/1: Interpolated position + worldy = fWorldPosX + (worldy - fWorldPosX) * 0.25f; + dWorldZOffset = (worldz - fWorldPosZ) * 0.25f + fWorldPosZ; + goto LABEL_39; + case 0: + dWorldZOffset = worldz + 3200.0; // Mode 0: Fixed height offset + goto LABEL_39; + default: + break; // Handle different tower camera modes } } TowerGx = worldx; TowerGy = worldy; TowerGz = worldz; - fTowerDeltaX = fWorldPosX2 - worldx; // Calculate direction and elevation to look at car + fTowerDeltaX = fWorldPosX2 - + worldx; // Calculate direction and elevation to look at car fTowerDeltaY = fWorldPosX - worldy; NearTow = iClosestTowerIdx; fTowerVerticalDistance = fWorldPosZ - worldz; - //if ((LODWORD(fTowerDeltaX) & 0x7FFFFFFF) != 0 || fabs(fWorldPosX - worldy)) + // if ((LODWORD(fTowerDeltaX) & 0x7FFFFFFF) != 0 || fabs(fWorldPosX - + // worldy)) if (fabs(fTowerDeltaX) > FLT_EPSILON || fabs(fWorldPosX - worldy)) - vdirection = getangle(fTowerDeltaX, fTowerDeltaY);// Calculate horizontal direction angle + vdirection = getangle( + fTowerDeltaX, fTowerDeltaY); // Calculate horizontal direction angle else vdirection = 0; - fTowerHorizontalDistance = (float)sqrt(fTowerDeltaX * fTowerDeltaX + fTowerDeltaY * fTowerDeltaY); - //if ((LODWORD(fTowerHorizontalDistance) & 0x7FFFFFFF) != 0 || (LODWORD(fTowerVerticalDistance) & 0x7FFFFFFF) != 0) - if (fabs(fTowerHorizontalDistance) > FLT_EPSILON || fabs(fTowerVerticalDistance) > FLT_EPSILON) - iCalculatedElevation = getangle(fTowerHorizontalDistance, fTowerVerticalDistance);// Calculate elevation angle + fTowerHorizontalDistance = + (float)sqrt(fTowerDeltaX * fTowerDeltaX + fTowerDeltaY * fTowerDeltaY); + // if ((LODWORD(fTowerHorizontalDistance) & 0x7FFFFFFF) != 0 || + // (LODWORD(fTowerVerticalDistance) & 0x7FFFFFFF) != 0) + if (fabs(fTowerHorizontalDistance) > FLT_EPSILON || + fabs(fTowerVerticalDistance) > FLT_EPSILON) + iCalculatedElevation = + getangle(fTowerHorizontalDistance, + fTowerVerticalDistance); // Calculate elevation angle else iCalculatedElevation = 0; velevation = iCalculatedElevation; vtilt = 0; - calculatetransform(-1, vdirection, iCalculatedElevation, 0, worldx, worldy, worldz, DDX, DDY, DDZ);// Set up tower view transformation + calculatetransform(-1, vdirection, iCalculatedElevation, 0, worldx, worldy, + worldz, DDX, DDY, + DDZ); // Set up tower view transformation worlddirn = vdirection; worldelev = velevation; worldtilt = vtilt; - } else { // Map view mode (mode 6) + } else { // Map view mode (mode 6) if (iViewMode == 6) { - worldx = -localdata[2].pointAy[3].fX; // Set map view position from chunk 2 data + worldx = -localdata[2] + .pointAy[3] + .fX; // Set map view position from chunk 2 data worldy = -localdata[2].pointAy[3].fY; - VIEWDIST = 400; // Set map view distance - fCarPosX = Car[iCarIdx].pos.fX; // Get car position for map view + VIEWDIST = 400; // Set map view distance + fCarPosX = Car[iCarIdx].pos.fX; // Get car position for map view fCarPosY3 = Car[iCarIdx].pos.fY; fCarPosZ = Car[iCarIdx].pos.fZ; fCarPosZ4 = Car[iCarIndex].pos.fZ; iCarChunk = Car[iCarIndex].nCurrChunk; worldz = 1024.0f - localdata[2].pointAy[3].fZ; - if (iCarChunk == -1) // Transform car position if on track + if (iCarChunk == -1) // Transform car position if on track { fTransformedPosX = fCarPosX; fTransformedPosZ = fCarPosZ; fTransformedPosY = fCarPosY3; } else { pCarTransform = &localdata[iCarChunk]; - fTransformedPosX = pCarTransform->pointAy[0].fY * fCarPosY3 - + pCarTransform->pointAy[0].fX * fCarPosX - + pCarTransform->pointAy[0].fZ * fCarPosZ4 - - pCarTransform->pointAy[3].fX; - fTransformedPosY = pCarTransform->pointAy[1].fX * fCarPosX - + pCarTransform->pointAy[1].fY * fCarPosY3 - + pCarTransform->pointAy[1].fZ * fCarPosZ4 - - pCarTransform->pointAy[3].fY; - fTransformedPosZ = fCarPosY3 * pCarTransform->pointAy[2].fY - + fCarPosX * pCarTransform->pointAy[2].fX - + fCarPosZ4 * pCarTransform->pointAy[2].fZ - - pCarTransform->pointAy[3].fZ; + fTransformedPosX = pCarTransform->pointAy[0].fY * fCarPosY3 + + pCarTransform->pointAy[0].fX * fCarPosX + + pCarTransform->pointAy[0].fZ * fCarPosZ4 - + pCarTransform->pointAy[3].fX; + fTransformedPosY = pCarTransform->pointAy[1].fX * fCarPosX + + pCarTransform->pointAy[1].fY * fCarPosY3 + + pCarTransform->pointAy[1].fZ * fCarPosZ4 - + pCarTransform->pointAy[3].fY; + fTransformedPosZ = fCarPosY3 * pCarTransform->pointAy[2].fY + + fCarPosX * pCarTransform->pointAy[2].fX + + fCarPosZ4 * pCarTransform->pointAy[2].fZ - + pCarTransform->pointAy[3].fZ; } } else { - fCarPosX2 = Car[iCarIdx].pos.fX; // Top view mode (other modes) + fCarPosX2 = Car[iCarIdx].pos.fX; // Top view mode (other modes) fCarPosY = Car[iCarIdx].pos.fY; fCarPosZ2 = Car[iCarIdx].pos.fZ; iCarChunk2 = Car[iCarIndex].nCurrChunk; - if (iCarChunk2 == -1) // Transform car position for top view + if (iCarChunk2 == -1) // Transform car position for top view { fTransformedPosX = fCarPosX2; fTransformedPosZ = fCarPosZ2; fTransformedPosY = fCarPosY; } else { pCarTransform2 = &localdata[iCarChunk2]; - fTransformedPosX = pCarTransform2->pointAy[0].fY * fCarPosY - + pCarTransform2->pointAy[0].fX * fCarPosX2 - + pCarTransform2->pointAy[0].fZ * fCarPosZ2 - - pCarTransform2->pointAy[3].fX; - fTransformedPosY = pCarTransform2->pointAy[1].fX * fCarPosX2 - + pCarTransform2->pointAy[1].fY * fCarPosY - + pCarTransform2->pointAy[1].fZ * fCarPosZ2 - - pCarTransform2->pointAy[3].fY; - fTransformedPosZ = fCarPosY * pCarTransform2->pointAy[2].fY - + fCarPosX2 * pCarTransform2->pointAy[2].fX - + fCarPosZ2 * pCarTransform2->pointAy[2].fZ - - pCarTransform2->pointAy[3].fZ; + fTransformedPosX = pCarTransform2->pointAy[0].fY * fCarPosY + + pCarTransform2->pointAy[0].fX * fCarPosX2 + + pCarTransform2->pointAy[0].fZ * fCarPosZ2 - + pCarTransform2->pointAy[3].fX; + fTransformedPosY = pCarTransform2->pointAy[1].fX * fCarPosX2 + + pCarTransform2->pointAy[1].fY * fCarPosY + + pCarTransform2->pointAy[1].fZ * fCarPosZ2 - + pCarTransform2->pointAy[3].fY; + fTransformedPosZ = fCarPosY * pCarTransform2->pointAy[2].fY + + fCarPosX2 * pCarTransform2->pointAy[2].fX + + fCarPosZ2 * pCarTransform2->pointAy[2].fZ - + pCarTransform2->pointAy[3].fZ; } - worldx = fTransformedPosX; // Set world position with top view height + worldx = fTransformedPosX; // Set world position with top view height worldy = fTransformedPosY; worldz = TopViewHeight + fTransformedPosZ; } - fDeltaX = fTransformedPosX - worldx; // Calculate viewing angles for top/map view + fDeltaX = + fTransformedPosX - worldx; // Calculate viewing angles for top/map view fDeltaY = fTransformedPosY - worldy; NearTow = -1; fVerticalDistance = fTransformedPosZ - worldz; - //if ((LODWORD(fDeltaX) & 0x7FFFFFFF) != 0 || fabs(fTransformedPosY - worldy)) + // if ((LODWORD(fDeltaX) & 0x7FFFFFFF) != 0 || fabs(fTransformedPosY - + // worldy)) if (fabs(fDeltaX) > FLT_EPSILON || fabs(fTransformedPosY - worldy)) vdirection = getangle(fDeltaX, fDeltaY); else vdirection = 0; fHorizontalDistance = (float)sqrt(fDeltaX * fDeltaX + fDeltaY * fDeltaY); - //if ((LODWORD(fHorizontalDistance) & 0x7FFFFFFF) != 0 || (LODWORD(fVerticalDistance) & 0x7FFFFFFF) != 0) - if (fabs(fHorizontalDistance) > FLT_EPSILON || fabs(fVerticalDistance) > FLT_EPSILON) + // if ((LODWORD(fHorizontalDistance) & 0x7FFFFFFF) != 0 || + // (LODWORD(fVerticalDistance) & 0x7FFFFFFF) != 0) + if (fabs(fHorizontalDistance) > FLT_EPSILON || + fabs(fVerticalDistance) > FLT_EPSILON) velevation = getangle(fHorizontalDistance, fVerticalDistance); else velevation = 0; vtilt = 0; - calculatetransform(-1, vdirection, velevation, 0, worldx, worldy, worldz, DDX, DDY, DDZ);// Set up final transformation and world angles + calculatetransform(-1, vdirection, velevation, 0, worldx, worldy, worldz, + DDX, DDY, + DDZ); // Set up final transformation and world angles worlddirn = vdirection; worldelev = velevation; worldtilt = vtilt; @@ -439,56 +492,64 @@ void calculateview(int iViewMode, int iCarIdx, int iChaseCamIdx) } //------------------------------------------------------------------------------------------------- -//00073570 -void initcarview(int iCarIdx, int iPlayer) -{ - int iSelectedView; // ecx - int iChaseViewIdx; // esi +// 00073570 +void initcarview(int iCarIdx, int iPlayer) { + int iSelectedView; // ecx + int iChaseViewIdx; // esi unsigned int iControlType; // ebx - float fChasePullDefault; // esi - int iYaw; // esi - int iPitch; // edi - int iRoll; // ecx - double dChaseDist; // st7 - double dChaseDistMul; // st7 - int iCurrChunk; // eax - tData *pData; // eax - double dTransformZ; // st7 - //int iPlayerShift; // eax + float fChasePullDefault; // esi + int iYaw; // esi + int iPitch; // edi + int iRoll; // ecx + double dChaseDist; // st7 + double dChaseDistMul; // st7 + int iCurrChunk; // eax + tData *pData; // eax + double dTransformZ; // st7 + // int iPlayerShift; // eax double dLastPosW; // st7 - float fDirX; // [esp+0h] [ebp-3Ch] - float fDirY; // [esp+4h] [ebp-38h] - float fDirZ; // [esp+8h] [ebp-34h] - float fRightX; // [esp+Ch] [ebp-30h] - float fUpZ; // [esp+10h] [ebp-2Ch] - float fSinPitch; // [esp+14h] [ebp-28h] - float fCameraX; // [esp+18h] [ebp-24h] - float fCameraZ; // [esp+1Ch] [ebp-20h] - float fCameraY; // [esp+20h] [ebp-1Ch] + float fDirX; // [esp+0h] [ebp-3Ch] + float fDirY; // [esp+4h] [ebp-38h] + float fDirZ; // [esp+8h] [ebp-34h] + float fRightX; // [esp+Ch] [ebp-30h] + float fUpZ; // [esp+10h] [ebp-2Ch] + float fSinPitch; // [esp+14h] [ebp-28h] + float fCameraX; // [esp+18h] [ebp-24h] + float fCameraZ; // [esp+1Ch] [ebp-20h] + float fCameraY; // [esp+20h] [ebp-1Ch] - iSelectedView = SelectedView[iPlayer]; // Get the selected view type for the current player + iSelectedView = SelectedView[iPlayer]; // Get the selected view type for the + // current player if (iSelectedView != 1 && iSelectedView != 3 && iCarIdx >= 0) - return; // Only process if view is cockpit (1) or chase (3) and car index is valid + return; // Only process if view is cockpit (1) or chase (3) and car index is + // valid if (iCarIdx >= 0) { - iChaseViewIdx = chaseview[iPlayer]; // Initialize chase camera parameters from viewdata for valid car + iChaseViewIdx = chaseview[iPlayer]; // Initialize chase camera parameters + // from viewdata for valid car CHASE_DIST[iPlayer] = viewdata[iChaseViewIdx].fChaseDistance; CHASE_MIN[iPlayer] = viewdata[iChaseViewIdx].fChaseMinDistance; LOOKZ[iPlayer] = viewdata[iChaseViewIdx].fChaseLookAhead; } else { - CHASE_DIST[0] = viewdata[1].fChaseDistance; // Special case: use default chase view for invalid car index + CHASE_DIST[0] = + viewdata[1].fChaseDistance; // Special case: use default chase view for + // invalid car index CHASE_MIN[0] = viewdata[1].fChaseMinDistance; iPlayer = 0; iCarIdx = -iCarIdx - 1; LOOKZ[0] = viewdata[1].fChaseLookAhead; } - iControlType = Car[iCarIdx].iControlType; // Get car control type (human player, AI, etc) + iControlType = + Car[iCarIdx].iControlType; // Get car control type (human player, AI, etc) if (!iControlType) { - fChasePullDefault = viewdata[chaseview[iPlayer]].fChasePullDefault;// Human player: use default chase pull factor + fChasePullDefault = + viewdata[chaseview[iPlayer]] + .fChasePullDefault; // Human player: use default chase pull factor SET_PULL_FACTOR: PULLZ[iPlayer] = fChasePullDefault; goto CALCULATE_CAMERA_POSITION; } - if (iControlType >= 2 && iControlType <= 3) { // AI cars: choose pull factor based on crash state + if (iControlType >= 2 && + iControlType <= 3) { // AI cars: choose pull factor based on crash state if (Car[iCarIdx].iStunned) fChasePullDefault = viewdata[chaseview[iPlayer]].fChasePullCrash; else @@ -496,34 +557,45 @@ void initcarview(int iCarIdx, int iPlayer) goto SET_PULL_FACTOR; } CALCULATE_CAMERA_POSITION: - if (Car[iCarIdx].nCurrChunk == -1) // Get car orientation: use actual angles if not in a chunk + if (Car[iCarIdx].nCurrChunk == + -1) // Get car orientation: use actual angles if not in a chunk { iYaw = Car[iCarIdx].nYaw; iPitch = Car[iCarIdx].nPitch; iRoll = Car[iCarIdx].nRoll; } else { - iYaw = 0; // Car is in a chunk: use neutral orientation + iYaw = 0; // Car is in a chunk: use neutral orientation iPitch = 0; iRoll = 0; } - fSinPitch = tsin[iPitch]; // Calculate sine of pitch angle for camera matrix - if (replaytype == 2 && replaydirection == -1)// Reverse chase distance if in replay mode with reverse direction + fSinPitch = tsin[iPitch]; // Calculate sine of pitch angle for camera matrix + if (replaytype == 2 && + replaydirection == + -1) // Reverse chase distance if in replay mode with reverse direction dChaseDist = -CHASE_DIST[iPlayer]; else dChaseDist = CHASE_DIST[iPlayer]; dChaseDistMul = -(dChaseDist * 2.0); - fDirX = -tcos[iYaw] * fSinPitch * tcos[iRoll] - tsin[iYaw] * tsin[iRoll];// Calculate camera direction vector X component using rotation matrix - fDirY = tcos[iYaw] * tcos[iPitch]; // Calculate camera direction vector Y component - fCameraX = (float)(dChaseDistMul * fDirY + PULLZ[iPlayer] * fDirX + Car[iCarIdx].pos.fX);// Calculate final camera X position with distance and pull factors + fDirX = -tcos[iYaw] * fSinPitch * tcos[iRoll] - + tsin[iYaw] * tsin[iRoll]; // Calculate camera direction vector X + // component using rotation matrix + fDirY = tcos[iYaw] * + tcos[iPitch]; // Calculate camera direction vector Y component + fCameraX = (float)(dChaseDistMul * fDirY + PULLZ[iPlayer] * fDirX + + Car[iCarIdx].pos.fX); // Calculate final camera X position + // with distance and pull factors fDirZ = tsin[iYaw] * tcos[iPitch]; fRightX = -tsin[iYaw] * fSinPitch * tcos[iRoll] + tcos[iYaw] * tsin[iRoll]; - fCameraY = (float)(dChaseDistMul * fDirZ + PULLZ[iPlayer] * fRightX + Car[iCarIdx].pos.fY);// Calculate final camera Y position + fCameraY = (float)(dChaseDistMul * fDirZ + PULLZ[iPlayer] * fRightX + + Car[iCarIdx].pos.fY); // Calculate final camera Y position fUpZ = tcos[iPitch] * tcos[iRoll]; - fCameraZ = (float)(dChaseDistMul * fSinPitch + PULLZ[iPlayer] * fUpZ + Car[iCarIdx].pos.fZ);// Calculate final camera Z position + fCameraZ = (float)(dChaseDistMul * fSinPitch + PULLZ[iPlayer] * fUpZ + + Car[iCarIdx].pos.fZ); // Calculate final camera Z position iCurrChunk = Car[iCarIdx].nCurrChunk; - if (iCurrChunk == -1) // Branch: handle camera position based on chunk state + if (iCurrChunk == -1) // Branch: handle camera position based on chunk state { - chase_x = fCameraX; // No chunk: directly set global chase position and lastpos array + chase_x = fCameraX; // No chunk: directly set global chase position and + // lastpos array chase_y = fCameraY; lastpos[iPlayer][0].fDistance = 0.0; chase_z = fCameraZ; @@ -531,133 +603,173 @@ void initcarview(int iCarIdx, int iPlayer) lastpos[iPlayer][0].pos.fY = fCameraY; lastpos[iPlayer][0].pos.fZ = fCameraZ; } else { - pData = &localdata[iCurrChunk]; // In chunk: transform camera position using chunk transformation matrix - chase_x = pData->pointAy[0].fY * fCameraY + pData->pointAy[0].fX * fCameraX + pData->pointAy[0].fZ * fCameraZ - pData->pointAy[3].fX; - chase_y = pData->pointAy[1].fX * fCameraX + pData->pointAy[1].fY * fCameraY + pData->pointAy[1].fZ * fCameraZ - pData->pointAy[3].fY; - chase_z = pData->pointAy[2].fX * fCameraX + pData->pointAy[2].fY * fCameraY + pData->pointAy[2].fZ * fCameraZ - pData->pointAy[3].fZ; + pData = &localdata[iCurrChunk]; // In chunk: transform camera position using + // chunk transformation matrix + chase_x = pData->pointAy[0].fY * fCameraY + + pData->pointAy[0].fX * fCameraX + + pData->pointAy[0].fZ * fCameraZ - pData->pointAy[3].fX; + chase_y = pData->pointAy[1].fX * fCameraX + + pData->pointAy[1].fY * fCameraY + + pData->pointAy[1].fZ * fCameraZ - pData->pointAy[3].fY; + chase_z = pData->pointAy[2].fX * fCameraX + + pData->pointAy[2].fY * fCameraY + + pData->pointAy[2].fZ * fCameraZ - pData->pointAy[3].fZ; lastpos[iPlayer][0].pos.fX = chase_x; - lastpos[iPlayer][0].pos.fY = pData->pointAy[1].fX * fCameraX + pData->pointAy[1].fY * fCameraY + pData->pointAy[1].fZ * fCameraZ - pData->pointAy[3].fY; - dTransformZ = fCameraY * pData->pointAy[2].fY + fCameraX * pData->pointAy[2].fX + fCameraZ * pData->pointAy[2].fZ - pData->pointAy[3].fZ; + lastpos[iPlayer][0].pos.fY = + pData->pointAy[1].fX * fCameraX + pData->pointAy[1].fY * fCameraY + + pData->pointAy[1].fZ * fCameraZ - pData->pointAy[3].fY; + dTransformZ = fCameraY * pData->pointAy[2].fY + + fCameraX * pData->pointAy[2].fX + + fCameraZ * pData->pointAy[2].fZ - pData->pointAy[3].fZ; lastpos[iPlayer][0].fDistance = 0.0; lastpos[iPlayer][0].pos.fZ = (float)dTransformZ; } // Copy current position to backup slots for interpolation lastpos[iPlayer][1].pos.fX = lastpos[iPlayer][0].pos.fX; - lastpos[iPlayer][1].pos.fY = lastpos[iPlayer][0].pos.fY; + lastpos[iPlayer][1].pos.fY = lastpos[iPlayer][0].pos.fY; lastpos[iPlayer][1].pos.fZ = lastpos[iPlayer][0].pos.fZ; - //iPlayerShift = iPlayer << 10; // Copy current position to backup slots for interpolation - //*(float *)((char *)&lastpos[0][1].pos.fX + iPlayerShift) = lastpos[iPlayer][0].pos.fX; - //*(float *)((char *)&lastpos[0][1].pos.fY + iPlayerShift) = lastpos[iPlayer][0].pos.fY; - //*(float *)((char *)&lastpos[0][1].pos.fZ + iPlayerShift) = lastpos[iPlayer][0].pos.fZ; + // iPlayerShift = iPlayer << 10; // Copy current position to + // backup slots for interpolation + //*(float *)((char *)&lastpos[0][1].pos.fX + iPlayerShift) = + // lastpos[iPlayer][0].pos.fX; + //*(float *)((char *)&lastpos[0][1].pos.fY + iPlayerShift) = + // lastpos[iPlayer][0].pos.fY; + //*(float *)((char *)&lastpos[0][1].pos.fZ + iPlayerShift) = + // lastpos[iPlayer][0].pos.fZ; dLastPosW = lastpos[iPlayer][0].fDistance; - nextpoint[iPlayer] = 1; // Set nextpoint flag to indicate new camera position is ready + nextpoint[iPlayer] = + 1; // Set nextpoint flag to indicate new camera position is ready lastpos[iPlayer][1].fDistance = (float)dLastPosW; //*(float *)((char *)&lastpos[0][1].fDistance + iPlayerShift) = dLastPosW; } //------------------------------------------------------------------------------------------------- -//00073920 -void newchaseview(int iCarIdx, int iChaseCamIdx) -{ - int iCarIndex; // eax - int nYaw; // ebx - int nPitch; // ecx - int nRoll; // edx - double dBackwardX; // st7 - double dBackwardY; // st6 - double dBackwardZ; // st5 - int iCurrChunk; // eax - float *pTransformMatrix; // eax - float fLookTempX; // edx +// 00073920 +void newchaseview(int iCarIdx, int iChaseCamIdx) { + int iCarIndex; // eax + int nYaw; // ebx + int nPitch; // ecx + int nRoll; // edx + double dBackwardX; // st7 + double dBackwardY; // st6 + double dBackwardZ; // st5 + int iCurrChunk; // eax + float *pTransformMatrix; // eax + float fLookTempX; // edx double dLookTransformedY; // st7 - float fLookTempY; // edx - float fPullTempX; // edx + float fLookTempY; // edx + float fPullTempX; // edx double dPullTransformedY; // st7 - float fPullTempY; // edx - int iPrevIndex; // eax - int iPrevArrayIndex; // eax - //int iCurrArrayOffset; // edx + float fPullTempY; // edx + int iPrevIndex; // eax + int iPrevArrayIndex; // eax + // int iCurrArrayOffset; // edx double dDistanceFromPrev; // st7 - int iNextIndex; // edx - //int iNewArrayOffset; // edx - int iLoopCounter; // ebx - int iSearchIndex; // edx + int iNextIndex; // edx + // int iNewArrayOffset; // edx + int iLoopCounter; // ebx + int iSearchIndex; // edx double dAccumulatedDistance; // st7 - int iPrevSearchIndex; // eax - //int iCarArrayOffset; // edi - //int iSearchArrayIndex; // edx - //int iPrevArrayOffset; // eax + int iPrevSearchIndex; // eax + // int iCarArrayOffset; // edi + // int iSearchArrayIndex; // edx + // int iPrevArrayOffset; // eax int iNextPosIndex; // eax - //int iCarArrayOffset2; // edi - //int iNextArrayOffset; // eax - int iCalculatedDirection; // eax - int iCalculatedElevation; // eax - float fLookTempX2; // [esp+8h] [ebp-88h] - float fPullTempX2; // [esp+8h] [ebp-88h] - float fZ; // [esp+18h] [ebp-78h] - float fY; // [esp+24h] [ebp-6Ch] - float fX; // [esp+28h] [ebp-68h] - float fPrevPosZ; // [esp+2Ch] [ebp-64h] - float fPrevPosY; // [esp+30h] [ebp-60h] - float fPrevPosX; // [esp+34h] [ebp-5Ch] - float fCurrentDistance; // [esp+38h] [ebp-58h] - float fVerticalDelta; // [esp+3Ch] [ebp-54h] - float fHorizontalDistance; // [esp+40h] [ebp-50h] + // int iCarArrayOffset2; // edi + // int iNextArrayOffset; // eax + int iCalculatedDirection; // eax + int iCalculatedElevation; // eax + float fLookTempX2; // [esp+8h] [ebp-88h] + float fPullTempX2; // [esp+8h] [ebp-88h] + float fZ; // [esp+18h] [ebp-78h] + float fY; // [esp+24h] [ebp-6Ch] + float fX; // [esp+28h] [ebp-68h] + float fPrevPosZ; // [esp+2Ch] [ebp-64h] + float fPrevPosY; // [esp+30h] [ebp-60h] + float fPrevPosX; // [esp+34h] [ebp-5Ch] + float fCurrentDistance; // [esp+38h] [ebp-58h] + float fVerticalDelta; // [esp+3Ch] [ebp-54h] + float fHorizontalDistance; // [esp+40h] [ebp-50h] float fInterpolationFactor; // [esp+44h] [ebp-4Ch] - float fViewZ; // [esp+48h] [ebp-48h] - float fViewY; // [esp+4Ch] [ebp-44h] - float fViewX; // [esp+50h] [ebp-40h] - float fHorizontalDeltaX; // [esp+54h] [ebp-3Ch] - float fLookAtX; // [esp+58h] [ebp-38h] - float fHorizontalDeltaY; // [esp+5Ch] [ebp-34h] - float fLookAtY; // [esp+60h] [ebp-30h] - float fLookAtZ; // [esp+64h] [ebp-2Ch] - float fCameraPosX; // [esp+68h] [ebp-28h] - float fCameraPosY; // [esp+6Ch] [ebp-24h] - float fCameraPosZ; // [esp+70h] [ebp-20h] - float fAccumulatedDist; // [esp+74h] [ebp-1Ch] + float fViewZ; // [esp+48h] [ebp-48h] + float fViewY; // [esp+4Ch] [ebp-44h] + float fViewX; // [esp+50h] [ebp-40h] + float fHorizontalDeltaX; // [esp+54h] [ebp-3Ch] + float fLookAtX; // [esp+58h] [ebp-38h] + float fHorizontalDeltaY; // [esp+5Ch] [ebp-34h] + float fLookAtY; // [esp+60h] [ebp-30h] + float fLookAtZ; // [esp+64h] [ebp-2Ch] + float fCameraPosX; // [esp+68h] [ebp-28h] + float fCameraPosY; // [esp+6Ch] [ebp-24h] + float fCameraPosZ; // [esp+70h] [ebp-20h] + float fAccumulatedDist; // [esp+74h] [ebp-1Ch] float fTempAccumulatedDist; // [esp+78h] [ebp-18h] iCarIndex = iCarIdx; - nYaw = Car[iCarIndex].nYaw; // Get car orientation and position + nYaw = Car[iCarIndex].nYaw; // Get car orientation and position nPitch = Car[iCarIndex].nPitch; fX = Car[iCarIndex].pos.fX; fY = Car[iCarIndex].pos.fY; fZ = Car[iCarIndex].pos.fZ; nRoll = Car[iCarIndex].nRoll; - dBackwardX = -tcos[nYaw] * tsin[nPitch] * tcos[nRoll] - tsin[nYaw] * tsin[nRoll];// Calculate backward direction vector from car orientation - // Uses trigonometric transformation to get direction opposite to car's forward vector - dBackwardY = -tsin[nYaw] * tsin[nPitch] * tcos[nRoll] + tcos[nYaw] * tsin[nRoll]; + dBackwardX = + -tcos[nYaw] * tsin[nPitch] * tcos[nRoll] - + tsin[nYaw] * + tsin[nRoll]; // Calculate backward direction vector from car + // orientation Uses trigonometric transformation to get + // direction opposite to car's forward vector + dBackwardY = + -tsin[nYaw] * tsin[nPitch] * tcos[nRoll] + tcos[nYaw] * tsin[nRoll]; dBackwardZ = tcos[nPitch] * tcos[nRoll]; - fCameraPosX = PULLZ[iChaseCamIdx] * (float)dBackwardX + fX;// Calculate camera position (behind car) using PULLZ distance + fCameraPosX = + PULLZ[iChaseCamIdx] * (float)dBackwardX + + fX; // Calculate camera position (behind car) using PULLZ distance fCameraPosY = PULLZ[iChaseCamIdx] * (float)dBackwardY + fY; fCameraPosZ = PULLZ[iChaseCamIdx] * (float)dBackwardZ + fZ; - fLookAtX = (float)dBackwardX * LOOKZ[iChaseCamIdx] + fX;// Calculate look-at position (in front of car) using LOOKZ distance + fLookAtX = + (float)dBackwardX * LOOKZ[iChaseCamIdx] + + fX; // Calculate look-at position (in front of car) using LOOKZ distance fLookAtY = (float)dBackwardY * LOOKZ[iChaseCamIdx] + fY; iCurrChunk = Car[iCarIndex].nCurrChunk; fLookAtZ = (float)dBackwardZ * LOOKZ[iChaseCamIdx] + fZ; - if (iCurrChunk != -1) // Transform positions to world coordinates if car is on track + if (iCurrChunk != + -1) // Transform positions to world coordinates if car is on track { - pTransformMatrix = (float *)&localdata[iCurrChunk];// Apply transformation matrix to convert from car-local to world coordinates + pTransformMatrix = + (float + *)&localdata[iCurrChunk]; // Apply transformation matrix to convert + // from car-local to world coordinates fLookTempX = (float)dBackwardX * LOOKZ[iChaseCamIdx] + fX; - fLookAtX = pTransformMatrix[1] * fLookAtY + *pTransformMatrix * fLookAtX + pTransformMatrix[2] * fLookAtZ - pTransformMatrix[9]; + fLookAtX = pTransformMatrix[1] * fLookAtY + *pTransformMatrix * fLookAtX + + pTransformMatrix[2] * fLookAtZ - pTransformMatrix[9]; fLookTempX2 = fLookTempX; - dLookTransformedY = pTransformMatrix[3] * fLookTempX + pTransformMatrix[4] * fLookAtY + pTransformMatrix[5] * fLookAtZ - pTransformMatrix[10]; + dLookTransformedY = pTransformMatrix[3] * fLookTempX + + pTransformMatrix[4] * fLookAtY + + pTransformMatrix[5] * fLookAtZ - pTransformMatrix[10]; fLookTempY = (float)dBackwardY * LOOKZ[iChaseCamIdx] + fY; fLookAtY = (float)dLookTransformedY; - fLookAtZ = pTransformMatrix[6] * fLookTempX2 + pTransformMatrix[7] * fLookTempY + pTransformMatrix[8] * fLookAtZ - pTransformMatrix[11]; + fLookAtZ = pTransformMatrix[6] * fLookTempX2 + + pTransformMatrix[7] * fLookTempY + + pTransformMatrix[8] * fLookAtZ - pTransformMatrix[11]; fPullTempX = fCameraPosX; - fCameraPosX = pTransformMatrix[1] * fCameraPosY + *pTransformMatrix * fCameraPosX + pTransformMatrix[2] * fCameraPosZ - pTransformMatrix[9]; + fCameraPosX = pTransformMatrix[1] * fCameraPosY + + *pTransformMatrix * fCameraPosX + + pTransformMatrix[2] * fCameraPosZ - pTransformMatrix[9]; fPullTempX2 = fPullTempX; - dPullTransformedY = pTransformMatrix[3] * fPullTempX + pTransformMatrix[4] * fCameraPosY + pTransformMatrix[5] * fCameraPosZ - pTransformMatrix[10]; + dPullTransformedY = + pTransformMatrix[3] * fPullTempX + pTransformMatrix[4] * fCameraPosY + + pTransformMatrix[5] * fCameraPosZ - pTransformMatrix[10]; fPullTempY = PULLZ[iChaseCamIdx] * (float)dBackwardY + fY; fCameraPosY = (float)dPullTransformedY; - fCameraPosZ = pTransformMatrix[6] * fPullTempX2 + pTransformMatrix[7] * fPullTempY + pTransformMatrix[8] * fCameraPosZ - pTransformMatrix[11]; + fCameraPosZ = pTransformMatrix[6] * fPullTempX2 + + pTransformMatrix[7] * fPullTempY + + pTransformMatrix[8] * fCameraPosZ - pTransformMatrix[11]; } - iPrevIndex = nextpoint[iChaseCamIdx] - 1; // Get previous position index in circular buffer + iPrevIndex = nextpoint[iChaseCamIdx] - + 1; // Get previous position index in circular buffer if (iPrevIndex < 0) iPrevIndex = 63; iPrevArrayIndex = iPrevIndex; @@ -667,18 +779,27 @@ void newchaseview(int iCarIdx, int iChaseCamIdx) fPrevPosX = lastpos[iChaseCamIdx][iPositionIndex].pos.fX; fPrevPosY = lastpos[iChaseCamIdx][iPositionIndex].pos.fY; fPrevPosZ = lastpos[iChaseCamIdx][iPositionIndex].pos.fZ; - //iCurrArrayOffset = 16 * nextpoint[iChaseCamIdx] + (iChaseCamIdx << 10);// Get current position data from position history buffer - //fPrevPosX = *(float *)((char *)&lastpos[0][0].pos.fX + iCurrArrayOffset); - //fPrevPosY = *(float *)((char *)&lastpos[0][0].pos.fY + iCurrArrayOffset); - //fPrevPosZ = *(float *)((char *)&lastpos[0][0].pos.fZ + iCurrArrayOffset); + // iCurrArrayOffset = 16 * nextpoint[iChaseCamIdx] + (iChaseCamIdx << 10);// + // Get current position data from position history buffer fPrevPosX = *(float + // *)((char *)&lastpos[0][0].pos.fX + iCurrArrayOffset); fPrevPosY = *(float + // *)((char *)&lastpos[0][0].pos.fY + iCurrArrayOffset); fPrevPosZ = *(float + // *)((char *)&lastpos[0][0].pos.fZ + iCurrArrayOffset); dDistanceFromPrev = sqrt( - (fCameraPosX - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fX) * (fCameraPosX - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fX) - + (fCameraPosY - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fY) * (fCameraPosY - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fY) - + (fCameraPosZ - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fZ) * (fCameraPosZ - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fZ));// Calculate distance from previous recorded position - if (dDistanceFromPrev >= 3200.0) // Check if car has moved far enough to record new position (3200 units) + (fCameraPosX - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fX) * + (fCameraPosX - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fX) + + (fCameraPosY - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fY) * + (fCameraPosY - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fY) + + (fCameraPosZ - lastpos[iChaseCamIdx][iPrevArrayIndex].pos.fZ) * + (fCameraPosZ - + lastpos[iChaseCamIdx][iPrevArrayIndex] + .pos.fZ)); // Calculate distance from previous recorded position + if (dDistanceFromPrev >= 3200.0) // Check if car has moved far enough to + // record new position (3200 units) { - iNextIndex = nextpoint[iChaseCamIdx] + 1; // Car moved enough - advance to next position in circular buffer + iNextIndex = + nextpoint[iChaseCamIdx] + + 1; // Car moved enough - advance to next position in circular buffer nextpoint[iChaseCamIdx] = iNextIndex; if (iNextIndex == 64) nextpoint[iChaseCamIdx] = 0; @@ -688,18 +809,30 @@ void newchaseview(int iCarIdx, int iChaseCamIdx) lastpos[iChaseCamIdx][iNewPositionIndex].pos.fX = fCameraPosX; lastpos[iChaseCamIdx][iNewPositionIndex].pos.fY = fCameraPosY; lastpos[iChaseCamIdx][iNewPositionIndex].pos.fZ = fCameraPosZ; - lastpos[iChaseCamIdx][iNewPositionIndex].fDistance = (float)sqrt( - (fPrevPosX - fCameraPosX) * (fPrevPosX - fCameraPosX) - + (fPrevPosY - fCameraPosY) * (fPrevPosY - fCameraPosY) - + (fPrevPosZ - fCameraPosZ) * (fPrevPosZ - fCameraPosZ)); - //iNewArrayOffset = 16 * nextpoint[iChaseCamIdx] + (iChaseCamIdx << 10);// Store new position and distance in history buffer + lastpos[iChaseCamIdx][iNewPositionIndex].fDistance = + (float)sqrt((fPrevPosX - fCameraPosX) * (fPrevPosX - fCameraPosX) + + (fPrevPosY - fCameraPosY) * (fPrevPosY - fCameraPosY) + + (fPrevPosZ - fCameraPosZ) * (fPrevPosZ - fCameraPosZ)); + // iNewArrayOffset = 16 * nextpoint[iChaseCamIdx] + (iChaseCamIdx << 10);// + // Store new position and distance in history buffer //*(float *)((char *)&lastpos[0][0].pos.fX + iNewArrayOffset) = fCameraPosX; //*(float *)((char *)&lastpos[0][0].pos.fY + iNewArrayOffset) = fCameraPosY; //*(float *)((char *)&lastpos[0][0].pos.fZ + iNewArrayOffset) = fCameraPosZ; //*(float *)((char *)&lastpos[0][0].fDistance + iNewArrayOffset) = sqrt( - // (fPrevPosX - fCameraPosX) * (fPrevPosX - fCameraPosX) - // + (fPrevPosY - fCameraPosY) * (fPrevPosY - fCameraPosY) - // + (fPrevPosZ - fCameraPosZ) * (fPrevPosZ - fCameraPosZ)); + // (fPrevPosX + // - + // fCameraPosX) + // * (fPrevPosX - fCameraPosX) + // + + // (fPrevPosY + // - + // fCameraPosY) + // * (fPrevPosY - fCameraPosY) + // + + // (fPrevPosZ + // - + // fCameraPosZ) + // * (fPrevPosZ - fCameraPosZ)); } else { // Car hasn't moved enough - update current position in place lastpos[iChaseCamIdx][iPositionIndex].pos.fX = fCameraPosX; @@ -707,90 +840,129 @@ void newchaseview(int iCarIdx, int iChaseCamIdx) lastpos[iChaseCamIdx][iPositionIndex].pos.fZ = fCameraPosZ; fCurrentDistance = (float)dDistanceFromPrev; lastpos[iChaseCamIdx][iPositionIndex].fDistance = fCurrentDistance; - //*(float *)((char *)&lastpos[0][0].pos.fX + iCurrArrayOffset) = fCameraPosX;// Car hasn't moved enough - update current position in place - //*(float *)((char *)&lastpos[0][0].pos.fY + iCurrArrayOffset) = fCameraPosY; - //*(float *)((char *)&lastpos[0][0].pos.fZ + iCurrArrayOffset) = fCameraPosZ; - //fCurrentDistance = dDistanceFromPrev; - //*(float *)((char *)&lastpos[0][0].fDistance + iCurrArrayOffset) = fCurrentDistance; + //*(float *)((char *)&lastpos[0][0].pos.fX + iCurrArrayOffset) = + // fCameraPosX;// Car hasn't moved enough - update current position in place + //*(float *)((char *)&lastpos[0][0].pos.fY + iCurrArrayOffset) = + // fCameraPosY; + //*(float *)((char *)&lastpos[0][0].pos.fZ + iCurrArrayOffset) = + // fCameraPosZ; fCurrentDistance = dDistanceFromPrev; + //*(float *)((char *)&lastpos[0][0].fDistance + iCurrArrayOffset) = + // fCurrentDistance; } - iLoopCounter = 62; // Search for chase camera position at specified distance behind car - // Loop through position history to find point at CHASE_DIST distance + iLoopCounter = + 62; // Search for chase camera position at specified distance behind car + // Loop through position history to find point at CHASE_DIST distance fAccumulatedDist = 0.0; iSearchIndex = nextpoint[iChaseCamIdx]; while (1) { - dAccumulatedDistance = fAccumulatedDist + lastpos[iChaseCamIdx][iSearchIndex].fDistance;// Accumulate distance from position history + dAccumulatedDistance = + fAccumulatedDist + + lastpos[iChaseCamIdx][iSearchIndex] + .fDistance; // Accumulate distance from position history if (dAccumulatedDistance >= CHASE_DIST[iChaseCamIdx] || iLoopCounter < 0) - break; // Check if reached target chase distance or exhausted history + break; // Check if reached target chase distance or exhausted history fTempAccumulatedDist = (float)dAccumulatedDistance; fAccumulatedDist = fTempAccumulatedDist; iSearchIndex = iSearchIndex - 1 + (iSearchIndex - 1 < 0 ? 0x40 : 0); --iLoopCounter; } if (iLoopCounter <= 0) { - iNextPosIndex = nextpoint[iChaseCamIdx] + 1;// Not enough history - use position ahead of current + iNextPosIndex = nextpoint[iChaseCamIdx] + + 1; // Not enough history - use position ahead of current if (nextpoint[iChaseCamIdx] == 63) iNextPosIndex = 0; fViewX = lastpos[iChaseCamIdx][iNextPosIndex].pos.fX; fViewY = lastpos[iChaseCamIdx][iNextPosIndex].pos.fY; fViewZ = lastpos[iChaseCamIdx][iNextPosIndex].pos.fZ; - //iCarArrayOffset2 = iChaseCamIdx << 10; - //iNextArrayOffset = 16 * iNextPosIndex; - //fViewX = *(float *)((char *)&lastpos[0][0].pos.fX + iCarArrayOffset2 + iNextArrayOffset); - //fViewY = *(float *)((char *)&lastpos[0][0].pos.fY + iCarArrayOffset2 + iNextArrayOffset); - //fViewZ = *(float *)((char *)&lastpos[0][0].pos.fZ + iCarArrayOffset2 + iNextArrayOffset); + // iCarArrayOffset2 = iChaseCamIdx << 10; + // iNextArrayOffset = 16 * iNextPosIndex; + // fViewX = *(float *)((char *)&lastpos[0][0].pos.fX + iCarArrayOffset2 + + // iNextArrayOffset); fViewY = *(float *)((char *)&lastpos[0][0].pos.fY + + // iCarArrayOffset2 + iNextArrayOffset); fViewZ = *(float *)((char + // *)&lastpos[0][0].pos.fZ + iCarArrayOffset2 + iNextArrayOffset); } else { - iPrevSearchIndex = iSearchIndex - 1; // Interpolate camera position between two history points - // Calculate exact position at target distance using linear interpolation - fInterpolationFactor = (lastpos[iChaseCamIdx][iSearchIndex].fDistance + fAccumulatedDist - CHASE_DIST[iChaseCamIdx]) / lastpos[iChaseCamIdx][iSearchIndex].fDistance; - + iPrevSearchIndex = + iSearchIndex - 1; // Interpolate camera position between two history + // points Calculate exact position at target distance + // using linear interpolation + fInterpolationFactor = (lastpos[iChaseCamIdx][iSearchIndex].fDistance + + fAccumulatedDist - CHASE_DIST[iChaseCamIdx]) / + lastpos[iChaseCamIdx][iSearchIndex].fDistance; // Handle circular buffer wraparound for previous index - int iPrevIndex = (iPrevSearchIndex < 0) ? (iPrevSearchIndex + 64) : iPrevSearchIndex; - fViewX = (lastpos[iChaseCamIdx][iSearchIndex].pos.fX - lastpos[iChaseCamIdx][iPrevIndex].pos.fX) - * fInterpolationFactor - + lastpos[iChaseCamIdx][iPrevIndex].pos.fX; - fViewY = (lastpos[iChaseCamIdx][iSearchIndex].pos.fY - lastpos[iChaseCamIdx][iPrevIndex].pos.fY) - * fInterpolationFactor - + lastpos[iChaseCamIdx][iPrevIndex].pos.fY; - fViewZ = fInterpolationFactor - * (lastpos[iChaseCamIdx][iSearchIndex].pos.fZ - lastpos[iChaseCamIdx][iPrevIndex].pos.fZ) - + lastpos[iChaseCamIdx][iPrevIndex].pos.fZ; - //iCarArrayOffset = iChaseCamIdx << 10; - //iSearchArrayIndex = iSearchIndex; - //iPrevArrayOffset = 16 * (iPrevSearchIndex + (iPrevSearchIndex < 0 ? 64 : 0)); - //fViewX = (*(float *)((char *)&lastpos[0][iSearchArrayIndex].pos.fX + iCarArrayOffset) - *(float *)((char *)&lastpos[0][0].pos.fX + iCarArrayOffset + iPrevArrayOffset)) - // * fInterpolationFactor - // + *(float *)((char *)&lastpos[0][0].pos.fX + iCarArrayOffset + iPrevArrayOffset); - //fViewY = (*(float *)((char *)&lastpos[0][iSearchArrayIndex].pos.fY + iCarArrayOffset) - *(float *)((char *)&lastpos[0][0].pos.fY + iCarArrayOffset + iPrevArrayOffset)) - // * fInterpolationFactor - // + *(float *)((char *)&lastpos[0][0].pos.fY + iCarArrayOffset + iPrevArrayOffset); - //fViewZ = fInterpolationFactor - // * (*(float *)((char *)&lastpos[0][iSearchArrayIndex].pos.fZ + iCarArrayOffset) - *(float *)((char *)&lastpos[0][0].pos.fZ + iCarArrayOffset + iPrevArrayOffset)) - // + *(float *)((char *)&lastpos[0][0].pos.fZ + iCarArrayOffset + iPrevArrayOffset); + int iPrevIndex = + (iPrevSearchIndex < 0) ? (iPrevSearchIndex + 64) : iPrevSearchIndex; + fViewX = (lastpos[iChaseCamIdx][iSearchIndex].pos.fX - + lastpos[iChaseCamIdx][iPrevIndex].pos.fX) * + fInterpolationFactor + + lastpos[iChaseCamIdx][iPrevIndex].pos.fX; + fViewY = (lastpos[iChaseCamIdx][iSearchIndex].pos.fY - + lastpos[iChaseCamIdx][iPrevIndex].pos.fY) * + fInterpolationFactor + + lastpos[iChaseCamIdx][iPrevIndex].pos.fY; + fViewZ = + fInterpolationFactor * (lastpos[iChaseCamIdx][iSearchIndex].pos.fZ - + lastpos[iChaseCamIdx][iPrevIndex].pos.fZ) + + lastpos[iChaseCamIdx][iPrevIndex].pos.fZ; + // iCarArrayOffset = iChaseCamIdx << 10; + // iSearchArrayIndex = iSearchIndex; + // iPrevArrayOffset = 16 * (iPrevSearchIndex + (iPrevSearchIndex < 0 ? 64 : + // 0)); fViewX = (*(float *)((char *)&lastpos[0][iSearchArrayIndex].pos.fX + + // iCarArrayOffset) - *(float *)((char *)&lastpos[0][0].pos.fX + + // iCarArrayOffset + iPrevArrayOffset)) + // * fInterpolationFactor + // + *(float *)((char *)&lastpos[0][0].pos.fX + iCarArrayOffset + + // iPrevArrayOffset); + // fViewY = (*(float *)((char *)&lastpos[0][iSearchArrayIndex].pos.fY + + // iCarArrayOffset) - *(float *)((char *)&lastpos[0][0].pos.fY + + // iCarArrayOffset + iPrevArrayOffset)) + // * fInterpolationFactor + // + *(float *)((char *)&lastpos[0][0].pos.fY + iCarArrayOffset + + // iPrevArrayOffset); + // fViewZ = fInterpolationFactor + // * (*(float *)((char *)&lastpos[0][iSearchArrayIndex].pos.fZ + + // iCarArrayOffset) - *(float *)((char *)&lastpos[0][0].pos.fZ + + // iCarArrayOffset + iPrevArrayOffset)) + // + *(float *)((char *)&lastpos[0][0].pos.fZ + iCarArrayOffset + + // iPrevArrayOffset); } - fHorizontalDeltaX = fLookAtX - fViewX; // Calculate direction from camera to look-at point + fHorizontalDeltaX = + fLookAtX - fViewX; // Calculate direction from camera to look-at point fHorizontalDeltaY = fLookAtY - fViewY; - //if ((LODWORD(fHorizontalDeltaX) & 0x7FFFFFFF) != 0 || fabs(fLookAtY - fViewY))// Calculate horizontal direction angle (yaw) - if (fabs(fHorizontalDeltaX) > FLT_EPSILON || fabs(fLookAtY - fViewY))// Calculate horizontal direction angle (yaw) + // if ((LODWORD(fHorizontalDeltaX) & 0x7FFFFFFF) != 0 || fabs(fLookAtY - + // fViewY))// Calculate horizontal direction angle (yaw) + if (fabs(fHorizontalDeltaX) > FLT_EPSILON || + fabs(fLookAtY - fViewY)) // Calculate horizontal direction angle (yaw) iCalculatedDirection = getangle(fHorizontalDeltaX, fHorizontalDeltaY); else - iCalculatedDirection = lastcamdirection; // Use last camera direction if no movement detected + iCalculatedDirection = + lastcamdirection; // Use last camera direction if no movement detected vdirection = iCalculatedDirection; - fHorizontalDistance = (float)sqrt(fHorizontalDeltaX * fHorizontalDeltaX + fHorizontalDeltaY * fHorizontalDeltaY);// Calculate elevation angle (pitch) from horizontal distance and height difference - //if ((LODWORD(fHorizontalDistance) & 0x7FFFFFFF) != 0 || fabs(fLookAtZ - fViewZ)) { + fHorizontalDistance = (float)sqrt( + fHorizontalDeltaX * fHorizontalDeltaX + + fHorizontalDeltaY * + fHorizontalDeltaY); // Calculate elevation angle (pitch) from + // horizontal distance and height difference + // if ((LODWORD(fHorizontalDistance) & 0x7FFFFFFF) != 0 || fabs(fLookAtZ - + // fViewZ)) { if (fabs(fHorizontalDistance) > FLT_EPSILON || fabs(fLookAtZ - fViewZ)) { fVerticalDelta = fLookAtZ - fViewZ; iCalculatedElevation = getangle(fHorizontalDistance, fVerticalDelta); } else { - iCalculatedElevation = lastcamelevation; // Use last camera elevation if no height difference + iCalculatedElevation = + lastcamelevation; // Use last camera elevation if no height difference } velevation = iCalculatedElevation; vtilt = 0; - calculatetransform(-1, vdirection, iCalculatedElevation, 0, fViewX, fViewY, fViewZ, DDX, DDY, DDZ);// Set up camera transformation matrix with calculated position and orientation - lastcamdirection = vdirection; // Save camera angles for next frame to avoid sudden changes + calculatetransform(-1, vdirection, iCalculatedElevation, 0, fViewX, fViewY, + fViewZ, DDX, DDY, + DDZ); // Set up camera transformation matrix with + // calculated position and orientation + lastcamdirection = + vdirection; // Save camera angles for next frame to avoid sudden changes lastcamelevation = velevation; - worlddirn = vdirection; // Set global world orientation values + worlddirn = vdirection; // Set global world orientation values worldelev = velevation; worldtilt = vtilt; } diff --git a/PROJECTS/ROLLER/view.h b/PROJECTS/ROLLER/view.h index d12a639f..22497120 100644 --- a/PROJECTS/ROLLER/view.h +++ b/PROJECTS/ROLLER/view.h @@ -4,8 +4,7 @@ #include "types.h" //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { float fChaseDistance; float fChaseMinDistance; float fChasePullNormal; @@ -16,8 +15,7 @@ typedef struct //------------------------------------------------------------------------------------------------- -typedef struct -{ +typedef struct { tVec3 pos; float fDistance; } tCameraPos; diff --git a/hk.pkl b/hk.pkl new file mode 100644 index 00000000..f27b7251 --- /dev/null +++ b/hk.pkl @@ -0,0 +1,38 @@ +amends "package://github.com/jdx/hk/releases/download/v1.45.0/hk@1.45.0#/Config.pkl" + +hooks { + ["pre-commit"] { + fix = true + stash = "git" + steps { + ["clang-format"] { + glob = List( + "PROJECTS/ROLLER/**/*.c", + "PROJECTS/ROLLER/**/*.h", + "tests/**/*.c", + "tests/**/*.h", + "resource.h", + ) + check_first = true + check = "clang-format --dry-run -Werror {{ files }}" + fix = "clang-format -i {{ files }}" + } + } + } + + ["check"] { + fix = false + steps { + ["clang-format"] { + glob = List( + "PROJECTS/ROLLER/**/*.c", + "PROJECTS/ROLLER/**/*.h", + "tests/**/*.c", + "tests/**/*.h", + "resource.h", + ) + check = "clang-format --dry-run -Werror {{ files }}" + } + } + } +} diff --git a/mise.toml b/mise.toml index 31f99f15..1a36f1d3 100644 --- a/mise.toml +++ b/mise.toml @@ -1,9 +1,18 @@ [tools] +clang-format = "latest" +hk = "1.45.0" python = "3" "ubi:zigtools/zls" = "0.15.0" usage = "latest" zig = "0.15.2" +[env] +HK_MISE = "1" +HK_PKL_BACKEND = "pklr" + +[hooks] +postinstall = "hk install --mise" + [tasks.build] description = "Build for specific platform" run = "python scripts/build.py" @@ -15,3 +24,7 @@ run = "rm -rf zig-out .zig-cache" [tasks.test] description = "Run tests" run = "zig build test" + +[tasks.pre-commit] +description = "Run pre-commit hooks" +run = "hk run pre-commit" diff --git a/resource.h b/resource.h index f10614f3..25d95d98 100644 --- a/resource.h +++ b/resource.h @@ -2,15 +2,15 @@ // Microsoft Visual C++ generated include file. // Used by ROLLER.rc // -#define IDI_ICON1 104 +#define IDI_ICON1 104 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/tests/render_queue_3d_test.c b/tests/render_queue_3d_test.c index dba53e52..9e1f5f5a 100644 --- a/tests/render_queue_3d_test.c +++ b/tests/render_queue_3d_test.c @@ -2,8 +2,7 @@ #include #include -static void test_sort_matches_legacy_zcmp(void) -{ +static void test_sort_matches_legacy_zcmp(void) { RenderQueue3D queue; render_queue_3d_clear(&queue); @@ -21,8 +20,7 @@ static void test_sort_matches_legacy_zcmp(void) assert(queue.entries[3].nChunkIdx == 100); } -static void test_building_priority_mapping_and_legacy_guard(void) -{ +static void test_building_priority_mapping_and_legacy_guard(void) { RenderQueue3D queue; tTrackZOrderEntry *entry; render_queue_3d_clear(&queue); @@ -34,16 +32,13 @@ static void test_building_priority_mapping_and_legacy_guard(void) assert(entry->fZDepth == 123.0f); assert(render_queue_3d_count(&queue) == 1); - assert(render_queue_3d_add_legacy_priority(&queue, - RENDER_QUEUE_3D_BUILDING_LEGACY_PRIORITY, - 7, - 123.0f) == NULL); + assert(render_queue_3d_add_legacy_priority( + &queue, RENDER_QUEUE_3D_BUILDING_LEGACY_PRIORITY, 7, 123.0f) == + NULL); assert(render_queue_3d_count(&queue) == 1); } - -static void test_start_light_priority_mapping_and_legacy_guard(void) -{ +static void test_start_light_priority_mapping_and_legacy_guard(void) { RenderQueue3D queue; tTrackZOrderEntry *entry; render_queue_3d_clear(&queue); @@ -55,28 +50,26 @@ static void test_start_light_priority_mapping_and_legacy_guard(void) assert(entry->fZDepth == 42.0f); assert(render_queue_3d_count(&queue) == 1); - assert(render_queue_3d_add_legacy_priority(&queue, - RENDER_QUEUE_3D_START_LIGHT_LEGACY_PRIORITY, - 7, - 42.0f) == NULL); + assert(render_queue_3d_add_legacy_priority( + &queue, RENDER_QUEUE_3D_START_LIGHT_LEGACY_PRIORITY, 7, 42.0f) == + NULL); assert(render_queue_3d_count(&queue) == 1); } -static void test_car_priority_mapping_payload_and_legacy_guard(void) -{ +static void test_car_priority_mapping_payload_and_legacy_guard(void) { RenderQueue3D queue; tTrackZOrderEntry *entry; const RenderCommand3D *command; const uint8 color_remap[2] = {3, 9}; const GameRenderCarPose pose = { - .position = {10.0f, 20.0f, 30.0f}, - .yaw = 100, - .pitch = 200, - .roll = 300, + .position = {10.0f, 20.0f, 30.0f}, + .yaw = 100, + .pitch = 200, + .roll = 300, }; const GameRenderCarOptions options = { - .anim_frame = 7, - .color_remap = color_remap, + .anim_frame = 7, + .color_remap = color_remap, }; render_queue_3d_clear(&queue); @@ -101,26 +94,23 @@ static void test_car_priority_mapping_payload_and_legacy_guard(void) assert(command->payload.car.options.anim_frame == 7); assert(command->payload.car.options.color_remap == color_remap); - assert(render_queue_3d_add_legacy_priority(&queue, - RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY, - 7, - 321.0f) == NULL); + assert(render_queue_3d_add_legacy_priority( + &queue, RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY, 7, 321.0f) == NULL); assert(render_queue_3d_count(&queue) == 1); } -static void test_sort_keeps_typed_car_payload_with_sorted_entry(void) -{ +static void test_sort_keeps_typed_car_payload_with_sorted_entry(void) { RenderQueue3D queue; const RenderCommand3D *command; const GameRenderCarPose pose = { - .position = {1.0f, 2.0f, 3.0f}, - .yaw = 4, - .pitch = 5, - .roll = 6, + .position = {1.0f, 2.0f, 3.0f}, + .yaw = 4, + .pitch = 5, + .roll = 6, }; const GameRenderCarOptions options = { - .anim_frame = 8, - .color_remap = NULL, + .anim_frame = 8, + .color_remap = NULL, }; render_queue_3d_clear(&queue); @@ -132,7 +122,8 @@ static void test_sort_keeps_typed_car_payload_with_sorted_entry(void) assert(render_queue_3d_count(&queue) == 2); assert(queue.entries[0].nChunkIdx == 101); assert(render_queue_3d_command_at(&queue, 0) == NULL); - assert(queue.entries[1].nRenderPriority == RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY); + assert(queue.entries[1].nRenderPriority == + RENDER_QUEUE_3D_CAR_LEGACY_PRIORITY); assert(queue.entries[1].nChunkIdx == 4); command = render_queue_3d_command_at(&queue, 1); assert(command != NULL); @@ -143,9 +134,7 @@ static void test_sort_keeps_typed_car_payload_with_sorted_entry(void) assert(command->payload.car.options.anim_frame == 8); } - -int main(int argc, const char **argv, const char **envp) -{ +int main(int argc, const char **argv, const char **envp) { (void)argc; (void)argv; (void)envp;