.SpawnCharacter3D PHA \ Store the character on the stack so we can retrieve it \ below STA characterDef \ Store the character in the first byte of the OSWORD \ block at characterDef, so we can extract the operating \ system's character definition (if this is a printable \ character) AND #%11000000 \ Clear all bits of the character number except for bits \ 6 and 7 BPL spac2 \ If bit 7 is clear then this is a printable character, \ so jump to spac2 to spawn the character in 3D text \ blocks ASL A \ Bit 7 is set so this is a tile coordinate, so extract ASL A \ bit 6 of the character number into the C flag PLA \ Retrieve the character number from the stack and AND #%00011111 \ extract bits 0-4 to get the coordinate value BCS spac1 \ If bit 6 of the original character number is set then \ this is a tile z-coordinate, so jump to spac1 to set \ zTileCharacter STA xTileCharacter \ Bit 6 of the original character number is clear, so \ store bits 0-4 in xTileCharacter, so we can spawn the \ next printable character that's passed to the routine \ in the right place RTS \ Return from the subroutine .spac1 STA zTileCharacter \ Bit 6 of the original character number is set, so \ store bits 0-4 in zTileCharacter, so we can spawn the \ next printable character that's passed to the routine \ in the right place RTS \ Return from the subroutine .spac2 \ If we get here then we have a printable character in A TXA \ Store X and Y on the stack to we can preserve them PHA TYA PHA LDY #HI(characterDef) \ Call OSWORD with A = 10 to extract the operating LDX #LO(characterDef) \ system's character definition into the block at LDA #10 \ characterDef JSR OSWORD \ \ The first byte of the block contains the ASCII code \ of the character (which we stored above), and the call \ returns the character definition from the second byte \ onwards LDA zTileCharacter \ Set zTile to the z-coordinate where we want to spawn STA zTile \ the character LDX #7 \ We now loop through the top seven rows of the \ character definition, so set a row counter in X \ \ We actually loop through the character definition \ from the bottom to top, ignoring the very bottom row \ of the definition as this is always blank for the \ capital letters and digits that we are displaying \ (the bottom row is only used for descenders, and \ "THE SENTINEL" and landscape digits don't have them) \ \ Instead we insert a blank pixel row at the top of the \ definition, on the iteration when X is zero \ We now have a short interlude to check some of the \ anti-cracker code, so we can corrupt the secret code \ being drawn on-screen if this landscape has not been \ played through properlyName: SpawnCharacter3D (Part 1 of 2) [Show more] Type: Subroutine Category: Title screen Summary: Spawn a character on the landscape in large 3D blocks for drawing on the main title screen or secret code screenContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawTitleScreen calls SpawnCharacter3D * PrintDigit calls SpawnCharacter3D * SpawnSecretCode3D calls SpawnCharacter3D
Arguments: A The character to be spawned or the tile coordinates of the character on the landscape: * %00xxxxxx = bits 0-5 contain the ASCII code of the character to spawn * %10xxxxxx = bits 0-4 contain the tile x-coordinate of the character on the landscape * %11xxxxxx = bits 0-4 contain the tile z-coordinate of the character on the landscape
Returns: X X is preserved Y Y is preserved
[X]
Configuration variable OSWORD = &FFF1
The address for the OSWORD routine
[X]
Variable characterDef in workspace Main variable workspace
An OSWORD block for reading a character definition
[X]
Label spac1 is local to this routine
[X]
Label spac2 is local to this routine
[X]
Variable xTileCharacter in workspace Main variable workspace
The tile x-coordinate of the character being spawned in large 3D blocks on the landscape for the title screen
[X]
Variable zTileCharacter in workspace Main variable workspace
The tile z-coordinate of the character being spawned in large 3D blocks on the landscape for the title screen