Skip to navigation


Version analysis of MVEIT (Part 1 of 9)

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: MVEIT (Part 1 of 9) Type: Subroutine Category: Moving Summary: Move current ship: Tidy the orientation vectors Deep dive: Program flow of the ship-moving routine Scheduling tasks with the main loop counter
This routine has multiple stages. This stage does the following: * Tidy the orientation vectors for one of the ship slots
Arguments:

Code variation 1 of 3A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

INWK The current ship/planet/sun's data block XSAV The slot number of the current ship/planet/sun TYPE The type of the current ship/planet/sun
INWK The current ship/planet's data block XSAV The slot number of the current ship/planet TYPE The type of the current ship/planet
.MVEIT

Code variation 2 of 3Specific to an individual platform

Tap on a block to expand it, and tap it again to revert.

LDA INWK+31 \ If bits 5 or 7 of ship byte #31 are set, jump to MV30 AND #%10100000 \ as the ship is either exploding or has been killed, so BNE MV30 \ we don't need to tidy its orientation vectors or apply \ tactics
LDA INWK+31 \ If bit 5 of ship byte #31 is set, jump to MV3 as the AND #%00100000 \ ship is exploding, so we don't need to tidy its BNE MV3 \ orientation vectors
 LDA MCNT               \ Fetch the main loop counter

 EOR XSAV               \ Fetch the slot number of the ship we are moving, EOR
 AND #15                \ with the loop counter and apply mod 15 to the result.
 BNE MV3                \ The result will be zero when "counter mod 15" matches
                        \ the slot number, so this makes sure we call TIDY 12
                        \ times every 16 main loop iterations, like this:
                        \
                        \   Iteration 0, tidy the ship in slot 0
                        \   Iteration 1, tidy the ship in slot 1
                        \   Iteration 2, tidy the ship in slot 2
                        \     ...
                        \   Iteration 11, tidy the ship in slot 11
                        \   Iteration 12, do nothing
                        \   Iteration 13, do nothing
                        \   Iteration 14, do nothing
                        \   Iteration 15, do nothing
                        \   Iteration 16, tidy the ship in slot 0
                        \     ...
                        \
                        \ and so on

 JSR TIDY               \ Call TIDY to tidy up the orientation vectors, to
                        \ prevent the ship from getting elongated and out of
                        \ shape due to the imprecise nature of trigonometry
                        \ in assembly language

Code variation 3 of 3A variation in the labels only

This variation is blank in the Cassette, Disc (flight), 6502 Second Processor, Master and Electron versions.

.MV3 \ Fall through into part 7 (parts 2-6 are not required \ when we are docked)