Skip to navigation

Main title Loop: ResetTilesObjects

Name: ResetTilesObjects [Show more] Type: Subroutine Category: Main title Loop Summary: Reset the tile visibility table and deallocate all object numbers
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MainGameLoop calls ResetTilesObjects
.ResetTilesObjects \ We now set the following variable block to %11111111 \ to indicate that all tiles are visible: \ \ * tileVisibility to tileVisibility+127 \ \ and the following variable block to %10000000 to \ deallocate all the object numbers: \ \ * objectFlags to objectFlags+63 LDX #63 \ Set X to use as a byte counter to run from 63 to 0, \ so we can initialise the 64-byte objectFlags table and \ the 128-byte tileVisibility table .resv1 LDA #%11111111 \ Set the X-th and X+64-th bytes of tileVisibility to STA tileVisibility,X \ all set bits, to indicate visible tiles STA tileVisibility+64,X LDA #%10000000 \ Set bit 7 of the X-th byte of objectFlags, to denote STA objectFlags,X \ that object #X is not allocated to an object DEX \ Decrement the byte counter BPL resv1 \ Loop back until we have processed X from &3F to 0 INC seedNumberLFSR+2 \ Set bit 16 of the five-byte linear feedback shift \ register in seedNumberLFSR(4 3 2 1 0), as we need a \ non-zero element for the seed number generator to \ work (as otherwise the EOR feedback will not affect \ the contents of the shift register and it won't start \ generating non-zero numbers) JSR SetColumnBufferMax \ Call SetColumnBufferMax to set the maximum and minimum \ pitch angles for the column buffer RTS \ Return from the subroutine