Skip to navigation

Elite on the BBC Micro and NES

Version analysis of DELAY

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

Code variations between these versions are shown below.

Name: DELAY Type: Subroutine Category: Utility routines

Code variation 1 of 7A variation in the comments only

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

Summary: Wait for a specified time, in 1/50s of a second
Summary: Wait for a specified time

Code variation 2 of 7A variation in the comments only

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

Wait for the number of vertical syncs given in Y, so this effectively waits for Y/50 of a second (as the vertical sync occurs 50 times a second).
Loop round a convoluted loop-within-loop structure to pass the required amount of time.

Arguments:

Code variation 3 of 7A variation in the comments only

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

Y The number of vertical sync events to wait for
Y The number of delay loops to run


Code variation 4 of 7A variation in the comments only

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

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

Other entry points: DEL8 Wait for 8/50 of a second (0.16 seconds) DELAY-5 Wait for 2/50 of a second (0.04 seconds)
Other entry points: DEL8 Wait for 30 delay loops' worth of time DELAY-5 Wait for 1 delay loop's worth of time

Code variation 5 of 7Related to the Electron version

In the BBC versions, delays are implemented by waiting for a specified number of vertical syncs. The Electron's video system is different, so it has its own dedicated delay routine that isn't based around the screen refresh, but instead wastes time using a convoluted loop-within-loop structure.

See below for more variations related to this code.

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

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

LDY #2 \ Set Y to 2 vertical syncs EQUB &2C \ Skip the next instruction by turning it into \ &2C &A0 &08, or BIT &08A0, which does nothing apart \ from affect the flags .DEL8 LDY #8 \ Set Y to 8 vertical syncs and fall through into DELAY \ to wait for this long
LDY #1 \ Set Y to 1 so we run the delay loop once EQUB &2C \ Skip the next instruction by turning it into \ &2C &A0 &1E, or BIT &1EA0, which does nothing apart \ from affect the flags .DEL8 LDY #30 \ Set Y to 30 and fall through into DELAY so we run the \ delay loop 30 times
.DELAY

Code variation 6 of 7Related to the Electron version

See variation 5 above for details.

This variation is blank in the Electron version.

JSR WSCAN \ Call WSCAN to wait for the vertical sync, so the whole \ screen gets drawn
 DEY                    \ Decrement the counter in Y

Code variation 7 of 7A variation in the comments only

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

BNE DELAY \ If Y isn't yet at zero, jump back to DELAY to wait \ for another vertical sync
BNE DELAY \ If Y isn't yet at zero, jump back to DELAY to wait \ for another iteration of the delay loop
 RTS                    \ Return from the subroutine