Skip to navigation

Aviator on the BBC Micro

Dashboard: DrawRadarBlip

Name: DrawRadarBlip [Show more] Type: Subroutine Category: Dashboard Summary: Draw a blip on the radar (runway or alien)
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ResetRadar calls DrawRadarBlip

Arguments: xPointLo The radar x-coordinate of the blip to update xPointHi The sign of the x-coordinate in bit 7 zPointLo The radar y-coordinate of the blip to update (we use the real-world z-coordinate, as the radar is a top-down view) zPointHi The sign of the y-coordinate in bit 7 alien The blip to update on the radar: * 0 = update the runway * 1 = update the alien
.DrawRadarBlip LDX alien \ Set X = alien to point to the blip to update on the \ radar (0 for the runway, 1 for the alien) LDA xRadarBuffer,X \ Set I = the X-th byte of xRadarBuffer, which contains STA I \ the x-coordinate of the current line or dot on the \ radar from a previous call to DrawRadarBlip LDA yRadarBuffer,X \ Set J = the X-th byte of yRadarBuffer, which contains STA J \ the y-coordinate of the current line or dot on the \ radar from a previous call to DrawRadarBlip LDA #128 \ Set N = 128 so the call to DrawVectorLine erases the STA N \ current line LDA previousCompass \ Set A = previousCompass, so it contains the value of A \ from the last call to GetRadarVector, i.e. for the \ current line on the radar JSR GetRadarVector \ Calculate the vector for the current line on the radar JSR DrawVectorLine \ Erase a line from (I, J) as a vector (T, U) with \ direction V LDX alien \ If alien is non-zero then we just erased a dot from BNE drbl1 \ the radar, so jump to drbl1 as we don't need to redraw \ the cross at the centre of the radar \ If we get here then we just erased a line from the \ radar, which may have corrupted the cross in the \ centre, so we redraw it LDA #%10001000 \ Redraw the top-but-one pixel of the cross (though, STA row25_block35_6 \ oddly, not the very top pixel) STA row26_block35_0 \ Redraw the bottom two pixels of the cross STA row26_block35_1 LDA #%00010001 \ Redraw the left pixel of the cross STA row25_block34_7 LDA #%11001100 \ Redraw the centre and right pixels of the cross STA row25_block35_7 .drbl1 \ Now to calculate the position of the new line or dot \ to draw on the radar LDA xPointLo \ Set A = xPointLo, the x-coordinate of the alien or \ runway BIT xPointHi \ If the high byte in xPointHi is positive, jump to BPL drbl2 \ drbl2 to skip the following three instructions EOR #&FF \ Otherwise negate A using two's complement, so A is CLC \ positive, i.e. A = |xPointLo| ADC #1 .drbl2 CMP #13 \ If A >= 13, jump to drbl4 to return from the BCS drbl4 \ subroutine, as the item is off the side of the radar LDA zPointLo \ Set A = zPointLo, the y-coordinate of the alien or \ runway BIT zPointHi \ If the high byte in zPointHi is positive, jump to BPL drbl3 \ drbl3 to skip the following three instructions EOR #&FF \ Otherwise negate A using two's complement, so A is CLC \ positive, i.e. A = |zPointLo| ADC #1 .drbl3 CMP #26 \ If A >= 26, jump to drbl4 to return from the BCS drbl4 \ subroutine, as the item is off the top or bottom of \ the radar LDA xPointLo \ Set I = xPointLo + 140 CLC \ ADC #140 \ to move the coordinate onto the radar, whose centre STA I \ cross on-screen is at (140, 207) STA xRadarBuffer,X \ Store the x-coordinate in the relevant byte of \ xRadarBuffer, so we can easily erase this item from \ the radar when we want to move it again LDA zPointLo \ Set J = zPointLo + 208 CLC \ ADC #208 \ to move the coordinate onto the radar, whose centre STA J \ cross on-screen is at (140, 207) STA yRadarBuffer,X \ Store the x-coordinate in the relevant byte of \ yRadarBuffer, so we can easily erase this item from \ the radar when we want to move it again LDA #0 \ Set N = 0 so the call to DrawVectorLine draws the STA N \ new line LDA yRotationHi \ Set A to the current compass heading, for use in the \ call to GetRadarVector if this is the runway (if this \ is an alien, this value is ignored) JSR GetRadarVector \ Calculate the vector for the new line on the radar JSR DrawVectorLine \ Draw a line from (I, J) as a vector (T, U) with \ direction V .drbl4 RTS \ Return from the subroutine