.MA18 \ --- Mod: Code removed for Demonstration Disc: -------> \LDA BOMB \ If we set off our energy bomb (see MA24 above), then \BPL MA77 \ BOMB is now negative, so this skips to MA21 if our \ \ energy bomb is not going off \ \ASL BOMB \ We set off our energy bomb, so rotate BOMB to the \ \ left by one place. BOMB was rotated left once already \ \ during this iteration of the main loop, back at MA24, \ \ so if this is the first pass it will already be \ \ %11111110, and this will shift it to %11111100 - so \ \ if we set off an energy bomb, it stays activated \ \ (BOMB > 0) for four iterations of the main loop \ \JSR WSCAN \ Call WSCAN to wait for the vertical sync, so the whole \ \ screen gets drawn and the following palette change \ \ won't kick in while the screen is still refreshing \ \LDA #%00110000 \ Set the palette byte at SHEILA &21 to map logical \STA VIA+&21 \ colour 0 to physical colour 7 (white), but with only \ \ one mapping (rather than the 7 mappings required to \ \ do the mapping properly). This makes the space screen \ \ flash with black and white stripes. See page 382 of \ \ the "Advanced User Guide for the BBC Micro" by Bray, \ \ Dickens and Holmes for details of why this single \ \ palette change creates a special effect \ \.MA77 \ \LDA MCNT \ Fetch the main loop counter and calculate MCNT mod 8, \AND #7 \ jumping to MA22 if it is non-zero (so the following \BNE MA22 \ code only runs every 8 iterations of the main loop) \ --- And replaced by: --------------------------------> LDA MCNT \ If the main loop counter is not equal to 200, jump to CMP #200 \ main2 to skip the following BNE main2 JSR DORND \ Set A and X to random numbers CMP #100 \ If A >= 100 (61% chance), jump to main1 to skip the BCS main1 \ following LDA attackingShip \ Set our target to the ship that is firing its lasers STA targetShip \ at us (39% chance) .main1 LDA #&FF \ Set enableLasers to a non-zero value to enable laser STA enableLasers \ fire, which might have been disabled while we had a \ missile lock, so this ensures we don't disable lasers \ for too long LDA #123 \ Jump to MA34 to print token 123 ("DEMONSTRATION") as JMP MA34 \ an in-flight message and continue the main flight loop \ in part 16 .main2 AND #7 \ Calculate MCNT mod 8, jumping to MA22 if it is BNE MA22 \ non-zero (so the following code only runs every 8 \ iterations of the main loop) \ --- End of replacement ------------------------------> LDX ENERGY \ Fetch our ship's energy levels and skip to b if bit 7 BPL b \ is not set, i.e. only charge the shields from the \ energy banks if they are at more than 50% charge LDX ASH \ Call SHD to recharge our aft shield and update the JSR SHD \ shield status in ASH STX ASH LDX FSH \ Call SHD to recharge our forward shield and update JSR SHD \ the shield status in FSH STX FSH .b SEC \ Set A = ENERGY + ENGY + 1, so our ship's energy LDA ENGY \ level goes up by 2 if we have an energy unit fitted, ADC ENERGY \ otherwise it goes up by 1 BCS P%+5 \ If the value of A did not overflow (the maximum STA ENERGY \ energy level is &FF), then store A in ENERGYName: Main flight loop (Part 13 of 16) [Show more] Type: Subroutine Category: Main loop Summary: Show energy bomb effect, charge shields and energy banks Deep dive: Program flow of the main game loop Scheduling tasks with the main loop counterContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
The main flight loop covers most of the flight-specific aspects of Elite. This section covers the following: * Show energy bomb effect (if applicable) * Charge shields and energy banks (every 7 iterations of the main loop)
[X]
Subroutine DORND (category: Maths (Arithmetic))
Generate random numbers
[X]
Label MA22 in subroutine Main flight loop (Part 15 of 16)
[X]
Label MA34 in subroutine Main flight loop (Part 15 of 16)
[X]
Subroutine SHD (category: Flight)
Charge a shield and drain some energy from the energy banks
[X]
Variable attackingShip in workspace WP
The slot number of the ship that is firing its lasers at us
[X]
Label b is local to this routine
[X]
Variable enableLasers in workspace WP
Determines whether our lasers are enabled, as they are disabled for a while when we get a missile lock
[X]
Label main1 is local to this routine
[X]
Label main2 is local to this routine
[X]
Variable targetShip in workspace WP
Our target ship