Skip to navigation


Ship hangar: HALL

[BBC Micro disc version, Docked]

Name: HALL [Show more] Type: Subroutine Category: Ship hangar Summary: Draw the ships in the ship hangar, then draw the hangar
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * DOENTRY calls HALL

Half the time this will draw one of the four pre-defined ship hangar groups in HATB, and half the time this will draw a solitary Sidewinder, Mamba, Krait or Adder on a random position. In all cases, the ships will be randomly spun around on the ground so they can face in any direction, and larger ships are drawn higher up off the ground than smaller ships.
.HALL JSR UNWISE \ Call UNWISE to switch the main line-drawing routine \ between EOR and OR logic (in this case, switching it \ to OR logic so that it overwrites anything that's \ on-screen) LDA #0 \ Clear the top part of the screen, draw a white border, JSR TT66 \ and set the current view type in QQ11 to 0 (space \ view) JSR DORND \ Set A and X to random numbers BPL HA7 \ Jump to HA7 if A is positive (50% chance) AND #3 \ Reduce A to a random number in the range 0-3 STA T \ Set X = A * 8 + A ASL A \ = 9 * A ASL A \ ASL A \ so X is a random number, either 0, 9, 18 or 27 ADC T TAX \ The following double loop calls the HAS1 routine three \ times to display three ships on screen. For each call, \ the values passed to HAS1 in XX15+2 to XX15 are taken \ from the HATB table, depending on the value in X, as \ follows: \ \ * If X = 0, pass bytes #0 to #2 of HATB to HAS1 \ then bytes #3 to #5 \ then bytes #6 to #8 \ \ * If X = 9, pass bytes #9 to #11 of HATB to HAS1 \ then bytes #12 to #14 \ then bytes #15 to #17 \ \ * If X = 18, pass bytes #18 to #20 of HATB to HAS1 \ then bytes #21 to #23 \ then bytes #24 to #26 \ \ * If X = 27, pass bytes #27 to #29 of HATB to HAS1 \ then bytes #30 to #32 \ then bytes #33 to #35 \ \ Note that the values are passed in reverse, so for the \ first call, for example, where we pass bytes #0 to #2 \ of HATB to HAS1, we call HAS1 with: \ \ XX15 = HATB+2 \ XX15+1 = HATB+1 \ XX15+2 = HATB LDY #3 \ Set CNT2 = 3 to act as an outer loop counter going STY CNT2 \ from 3 to 1, so the HAL8 loop is run 3 times .HAL8 LDY #2 \ Set Y = 2 to act as an inner loop counter going from \ 2 to 0 .HAL9 LDA HATB,X \ Copy the X-th byte of HATB to the Y-th byte of XX15, STA XX15,Y \ as described above INX \ Increment X to point to the next byte in HATB DEY \ Decrement Y to point to the previous byte in XX15 BPL HAL9 \ Loop back to copy the next byte until we have copied \ three of them (i.e. Y was 3 before the DEY) TXA \ Store X on the stack so we can retrieve it after the PHA \ call to HAS1 (as it contains the index of the next \ byte in HATB JSR HAS1 \ Call HAS1 to draw this ship in the hangar PLA \ Restore the value of X, so X points to the next byte TAX \ in HATB after the three bytes we copied into XX15 DEC CNT2 \ Decrement the outer loop counter in CNT2 BNE HAL8 \ Loop back to HAL8 to do it 3 times, once for each ship \ in the HATB table LDY #128 \ Set Y = 128 to send as byte #2 of the parameter block \ to the OSWORD 248 command below, to tell the I/O \ processor that there are multiple ships in the hangar BNE HA9 \ Jump to HA9 to display the ship hangar (this BNE is \ effectively a JMP as Y is never zero) .HA7 \ If we get here, A is a positive random number in the \ range 0-127 LSR A \ Set XX15+1 = A / 2 (random number 0-63) STA XX15+1 JSR DORND \ Set XX15 = random number 0-255 STA XX15 JSR DORND \ Set XX15+2 = random number 0-7 AND #7 \ STA XX15+2 \ which is either 0 (no ships in the hangar) or one of \ the first 7 ship types in the ship hangar blueprints \ table, i.e. a cargo canister, Shuttle, Transporter, \ Cobra Mk III, Python, Viper or Krait JSR HAS1 \ Call HAS1 to draw this ship in the hangar, with the \ following properties: \ \ * Random x-coordinate from -63 to +63 \ \ * Randomly chosen cargo canister, Shuttle, \ Transporter, Cobra Mk III, Python, Viper or Krait \ \ * Random z-coordinate from +256 to +639 LDY #0 \ Set Y = 0 to use in the following instruction, to tell \ the hangar-drawing routine that there is just one ship \ in the hangar, so it knows not to draw between the \ ships .HA9 STY YSAV \ Store Y in YSAV to specify whether there are multiple \ ships in the hangar JSR UNWISE \ Call UNWISE to switch the main line-drawing routine \ between EOR and OR logic (in this case, switching it \ back to EOR logic so that we can erase anything we \ draw on-screen) \ Fall through into HANGER to draw the hangar background