.vmod1 ADD R4, R11, #xVertexRotated \ Modification code to store the result of \ the vector addition in xVertexRotated .vmod2 ADD R4, R11, #xCoord \ Modification code to restore the result of \ the vector addition to xCoord .vmod3 MOV R4, R12 \ Modification code to store the result of \ the vector addition in R12 .vmod4 ADD R4, R11, #xLandscapeCol \ Modification code to store the result of \ the vector addition in xLandscapeCol .vmod5 ADD R4, R11, #xLandscapeRow \ Modification code to store the result of \ the vector addition in xLandscapeRow .AddVectors STMFD R13!, {R14} \ Store the return address on the stack \ We now modify the following instruction in \ the AddVectorToVertices routine to change \ the way it works: \ \ ADD R3, R11, #xCoord \ \ Interestingly, though, none of the \ modifications above will work properly, as \ they all change R4 rather than R3, so \ presumably the modified subroutine was \ refactored and this unused routine wasn't \ updated \ \ If this routine worked, it would use the \ modifications to change the address where \ we stored the result LDR R1, vmod3 \ Modify the eighth instruction in the STR R1, AddVectorToVertices+28 \ AddVectorToVertices routine to the \ instruction in vmod3 LDMIA R0, {R0-R2} \ Fetch the coordinate from R0 into \ (R0, R1, R2) MOV R3, R12 \ Set R3 = R12 to use as the address of the \ second vector to add BL AddVectorToVertices+8 \ Add the vector (R0, R1, R2) to the vector \ at the address in R3 (by skipping the \ first two instructions in the modified \ routine LDR R1, vmod2 \ Revert the eighth instruction in the STR R1, AddVectorToVertices+28 \ AddVectorToVertices routine to the \ instruction in vmod2 (though note that \ this doesn't actually revert the \ instruction, it corrupts it, for the \ reasons noted above) LDMFD R13!, {PC} \ Return from the subroutineName: AddVectors [Show more] Type: Subroutine Category: Maths (Geometry) Summary: An unused routine that adds two vectors and uses self-modifying code to store the results in a specified location Deep dive: Unused code in LanderContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine AddVectorToVertices (category: Maths (Geometry))
Add a vector to the rotated vertex coordinates to get the vertex coordinates in 3D space
[X]
Label vmod2 is local to this routine
[X]
Label vmod3 is local to this routine
[X]
Configuration variable xCoord = &74
The x-coordinate of the vertex being processed, in the game's 3D coordinate system
[X]
Configuration variable xLandscapeCol = &170
The x-coordinate of the far-left corner of the column (i.e. tile) that we are drawing in the current landscape row, where columns run in and out of the screen (this is a relative coordinate)
[X]
Configuration variable xLandscapeRow = &160
The x-coordinate of the far-left corner of the landscape row that we are drawing, where rows run from left to right across the screen (this is a relative coordinate)
[X]
Configuration variable xVertexRotated = &64
The x-coordinate of the vertex after being rotated by the object's rotation matrix