Skip to navigation

Title screen: SpawnTitleObject

Name: SpawnTitleObject [Show more] Type: Subroutine Category: Title screen Summary: Spawn the title object (robot or the Sentinel) as object #1
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawTitleObject calls SpawnTitleObject * ShowGameOverScreen calls SpawnTitleObject

Arguments: A The type of object to spawn Y The configuration to use when spawning the object: * 0 = the object on the game over screen (i.e. the enemy that ended the game) * 1 = the Sentinel on the main title screen or the robot on the secret code screen * 2 = the tower on which the Sentinel or robot stands
.SpawnTitleObject \ We set up the object that we want to draw on the title \ screen in object #1, and we set up the viewing object \ for that object in object #2 \ \ The values come from the Y-th entry in each of the \ following configuration tables, so this routine sets \ up the following, depending on the object that we are \ spawning: \ \ * Object #1 (the object to draw) is set to a yaw \ of 128 for the game over screen (so the enemy \ stares directly out of the screen), or -114 for \ the object on the tower (so it looks towards the \ left of the viewer) or -50 for the tower (so it is \ rotated slightly to the left) \ \ * Object #1 (the object to draw) is set to a yaw \ of 128 for the game over screen, so the enemy \ stares directly out of the screen \ \ * Object #1 (the object to draw) is set to a yaw \ of -114 for the object on the tower, so the robot \ or Sentinel looks out of the screen, towards the \ left of the viewer \ \ * Object #1 (the object to draw) is set to a yaw \ of -50 for the tower, so it is rotated slightly to \ the left \ \ * Object #2 (the viewing object) is set to a pitch \ of -12 for the game over screen, so the camera \ points down, thus moving the object down the \ screen \ \ * Object #2 (the viewing object) is set to a pitch \ of -5 and a yaw of -8 for the title screen, so the \ camera points down and left, thus moving the tower \ and object to the right \ \ * Object #1 is always at the same x-coordinate as \ the viewing object \ \ * The tower and game over objects are at the same \ y-coordinate as the viewer (so they at the same \ altitude) \ \ * The object on the tower is higher than the viewer \ by one y-coordinate \ \ * The game over object is at a z-coordinate distance \ of 5 from the viewer, while the object and tower \ are at a distance of 7 STA objectTypes+1 \ Set the object type for object #1 to the argument in A LDA zTitleObject,Y \ Set the z-coordinate for object #1 to the z-coordinate CLC \ of object #2 plus the Y-th entry from the zTitleObject ADC zObject+2 \ table STA zObject+1 LDA yObjectHi+2 \ Set the high byte of the y-coordinate for object #1 to CLC \ the high byte of the y-coordinate of object #2 plus ADC yTitleObject,Y \ the Y-th entry from the yTitleObject table STA yObjectHi+1 LDA xObject+2 \ Set the x-coordinate for object #1 to the x-coordinate STA xObject+1 \ of object #2 LDA titleViewerPitch,Y \ Set the pitch angle of the viewer in object #2 to the STA objectPitchAngle+2 \ Y-th entry from the titleViewerPitch table LDA titleViewerYaw,Y \ Set the yaw angle of the viewer in object #2 to the STA objectYawAngle+2 \ Y-th entry from the titleViewerYaw table LDA #0 \ Zero the low bytes of the y-coordinates for both STA yObjectLo+2 \ objects STA yObjectLo+1 LDA titleObjectYaw,Y \ Set the yaw angle of object #1 to the Y-th entry from STA objectYawAngle+1 \ the titleObjectYaw LDX #2 \ Set the viewing object to object #2 so the screen will STX viewingObject \ be drawn from this perspective RTS \ Return from the subroutine