.dobs4 \ If we get here then there is an object at \ (R8, R9) of type R0 STRB R0, [R11, #objectType] \ Store the object type in objectType ] typeOffset = P% + 8 - objectTypes \ Set typeOffset to the offset back to the \ objectTypes table from the next \ instruction [ OPT pass% ADD R0, PC, R0, LSL #2 \ Set R14 to the address in entry R0 in the LDR R14, [R0, #-typeOffset] \ objectTypes table, which is the address of \ the blueprint for this object type STR R14, [R11, #objectData] \ Store the address of the blueprint in \ objectData BL GetLandscapeAltitude \ Set R0 to the altitude of the landscape at \ coordinates (R8, R9), which is where we \ are drawing our object MOV R1, R0 \ Make a copy of the altitude in R1, so R1 \ contains the y-coordinate of the object as \ it sits on the landscape CMP R0, #SEA_LEVEL \ If the object is on the sea, jump back to BEQ dobs3 \ dobs3 to move on to the next object, as \ there are no objects on the sea \ \ This check sounds unnecessary as there \ shouldn't be any objects in the sea in the \ object map anyway, as this check is also \ performed when populating the object map \ \ However, because the landscape in Lander \ is infinite but the object map is finite, \ the object map gets repeated every 256 \ tiles in each direction, and objects that \ appear on land in one instance of the \ object may well appear in the sea in \ another instance, so this check prevents \ that from happening LDR R14, [R11, #xCamera] \ Set R0 = R8 - xCamera SUB R0, R8, R14 \ = x - xCamera \ \ So R0 contains the x-coordinate of the \ object relative to the camera LDR R14, [R11, #zCamera] \ Set R2 = R9 - zCamera SUB R2, R9, R14 \ \ So R2 contains the z-coordinate of the \ object relative to the camera ADD R2, R2, #LANDSCAPE_Z \ Move the coordinate back by the landscape \ offset, so (R0, R2) contains the \ coordinate of the particle relative to the \ back-centre point of the landscape LDR R14, [R11, #yCamera] \ Set R1 = R1 - yCamera SUB R1, R1, R14 \ = y - yCamera \ \ So R1 contains the y-coordinate of the \ object relative to the camera LDRB R14, [R11, #objectType] \ If the object type is 12 or more, then it CMP R14, #12 \ represents a destroyed object, so jump to BHS dobs6 \ dobs6 .dobs5 ADD R3, R11, #rotationMatrix \ Set R3 to the address of the object's \ rotation matrix, to pass to DrawObject BL DrawObject \ Draw the object B dobs3 \ Jump back to dobs3 to move on to the next \ objectName: DrawObjects (Part 2 of 3) [Show more] Type: Subroutine Category: 3D objects Summary: Draw the object that we have found on the object map Deep dive: Drawing 3D objectsContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine DrawObject (Part 1 of 5) (category: 3D objects)
Draw a 3D object and its shadow
[X]
Subroutine GetLandscapeAltitude (category: Landscape)
Calculate the altitude of the landscape for a given coordinate
[X]
Configuration variable LANDSCAPE_Z = LANDSCAPE_Z_DEPTH + (10 * TILE_SIZE)
The z-coordinate of the landscape offset, which is set to push the landscape away from the viewer by ten tile sizes
[X]
Configuration variable SEA_LEVEL = &05500000
The altitude of sea level
[X]
Label dobs3 in subroutine DrawObjects (Part 1 of 3)
[X]
Label dobs6 in subroutine DrawObjects (Part 3 of 3)
[X]
Configuration variable objectData = &110
The address of the blueprint for the object currently being drawn
[X]
Configuration variable objectType = &F4
The type of the object currently being drawn
[X]
Configuration variable rotationMatrix = &30
The rotation matrix of the object currently being drawn (i.e. the matrix formed from the object's three orientation vectors)
[X]
Configuration variable typeOffset is local to this routine
Set typeOffset to the offset back to the objectTypes table from the next instruction
[X]
Configuration variable xCamera = &13C
The 3D x-coordinate of the camera position (though note that the camera position is actually at the back of the on-screen landscape, not the front)
[X]
Configuration variable yCamera = &140
The 3D y-coordinate of the camera position (though note that the camera position is actually at the back of the on-screen landscape, not the front)
[X]
Configuration variable zCamera = &144
The 3D z-coordinate of the camera position (though note that the camera position is actually at the back of the on-screen landscape, not the front, so the camera's z-coordinate is larger than it would be for a more traditional camera position; it is more like the camera's focal point than position, in a sense)