Skip to navigation


Universe: Ze

[Elite-A, Flight]

Name: Ze [Show more] Type: Subroutine Category: Universe Summary: Initialise the INWK workspace to a hostile ship Deep dive: Fixing ship positions
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DEATH calls Ze * GTHG calls Ze * Main game loop (Part 3 of 6) calls Ze

Specifically, this routine does the following: * Reset the INWK ship workspace * Set the ship to a fair distance away in all axes, in front of us but randomly up or down, left or right * Give the ship a 4% chance of having E.C.M. * Set the ship to hostile, with AI enabled This routine also sets A, X, T1 and the C flag to random values. Note that because this routine uses the value of X returned by DORND, and X contains the value of A returned by the previous call to DORND, this routine does not necessarily set the new ship to a totally random location. See the deep dive on "Fixing ship positions" for details.
.Ze \ --- Mod: Code removed for Elite-A: ------------------> \JSR ZINF \ Call ZINF to reset the INWK ship workspace \ \JSR DORND \ Set A and X to random numbers \ \STA T1 \ Store A in T1 \ \AND #%10000000 \ Extract the sign of A and store in x_sign \STA INWK+2 \ \TXA \ Extract the sign of X and store in y_sign \AND #%10000000 \STA INWK+5 \ \LDA #25 \ Set x_hi = y_hi = z_hi = 25, a fair distance away \STA INWK+1 \STA INWK+4 \STA INWK+7 \ \JSR DORND \ Set A and X to random numbers \ --- And replaced by: --------------------------------> JSR rand_posn \ Call rand_posn to set up the INWK workspace for a ship \ in a random ship position, and set T1 to a random \ number \ --- End of replacement ------------------------------> CMP #245 \ Set the C flag if A >= 245 (4% chance) ROL A \ Set bit 0 of A to the C flag (i.e. there's a 4% \ chance of this ship having E.C.M.) ORA #%11000000 \ Set bits 6 and 7 of A, so the ship is hostile (bit 6 \ and has AI (bit 7) STA INWK+32 \ Store A in the AI flag of this ship \ Fall through into DORND2 to set A, X and the C flag \ randomly