Skip to navigation

Revs on the BBC Micro

Setup: SetupGame

Name: SetupGame [Show more] Type: Subroutine Category: Setup Summary: Decrypt or unprotect the game code (disabled)
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MoveCode calls SetupGame * Protect calls SetupGame
IF _SUPERIOR OR _REVSPLUS .SuperiorSetupGame CLEAR &3850, &3880 \ In the Superior Software release of Revs, the routines ORG &3850 \ for computer assisted steering (CAS) take up extra \ memory, so we need to claw back some memory from \ somewhere \ \ The clever solution is to move the SetupGame routine, \ which is run when the game loads, but is never needed \ again, so in the Superior version, SetupGame is put \ into the same block of memory as the carSpeedLo, \ totalPointsLo and totalPointsLo variables, which are \ only used after the game has started \ \ These lines rewind BeebAsm's assembly back to \ carSpeedLo (which is at address &3850), and clear the \ block that is occupied by these three variables, so we \ can assemble SetupGame in the right place while \ retaining the correct addresses for the three \ variables \ \ We also make a note of the current address, so we can \ ORG back to it after assembling SetupGame ENDIF .SetupGame LDA #4 \ Call OSBYTE with A = 4, X = 1 and Y = 0 to disable LDY #0 \ cursor editing LDX #1 JSR OSBYTE JSR SetScreenMode7 \ Change to screen mode 7 and hide the cursor LDX #9 \ We now zero the ten bytes starting at configStop, so \ set a loop counter in X LDA #0 \ Set lineBufferSize = 0, to reset the line buffer STA lineBufferSize .setp1 STA configStop,X \ Zero the X-th byte at configStop \ \ The address in this instruction gets modified DEX \ Decrement the loop counter BPL setp1 \ Loop back until we have zeroed all ten bytes LDA #246 \ Set volumeLevel = -10, which sets the sound level to STA volumeLevel \ medium (-15 is full volume, 0 is silent) TSX \ Store the stack pointer in startingStack so we can STX startingStack \ restore it when restarting the game JSR CallTrackHook \ Call the hook code in the track file (for Silverstone \ the hook routine is just an RTS, so this does nothing) IF _ACORNSOFT OR _4TRACKS \ Fall through into the main game loop to start the game ELIF _SUPERIOR OR _REVSPLUS LDA #190 \ Call OSBYTE with A = 190, X = %00100000 and Y = 0 to LDY #0 \ configure the digital joystick port on the BBC Master LDX #%00100000 \ Compact conversion type to 32-bit conversion (as the JSR OSBYTE \ Superior Software release was updated to work on this \ machine) \ \ The configuration does the following: \ \ * Bit 7 clear = update channel values from cursor \ keys and/or digital joystick \ \ * Bit 6 clear = do not simulate key presses from the \ digital joystick \ \ * Bit 5 set = return fixed values to channels 1 and \ 2 as follows: \ \ Left = &FFFF to channel 1 \ Centre (horizontal) = &7FFF to channel 1 \ Right = 0 to channel 1 \ Down = &FFFF to channel 2 \ Centre (vertical) = &7FFF to channel 2 \ Up = 0 to channel 2 \ \ * Bit 4 is unused \ \ * Bits 0-3 clear = emulate the analogue speed of \ joystick movement by returning slowly changing \ values related to the joystick movement JMP MainLoop \ Jump to the main game loop to start the game EQUB &FF \ This byte appears to be unused ORG SuperiorSetupGame \ Switch back to the original address, so we can \ continue with the assembly ENDIF