.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_char35_6 \ oddly, not the very top pixel) STA row26_char35_0 \ Redraw the bottom two pixels of the cross STA row26_char35_1 LDA #%00010001 \ Redraw the left pixel of the cross STA row25_char34_7 LDA #%11001100 \ Redraw the centre and right pixels of the cross STA row25_char35_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 subroutineName: 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
[X]
Subroutine DrawVectorLine (Part 1 of 3) (category: Drawing lines)
Draw a line: set up pixel bytes and slope variables
[X]
Subroutine GetRadarVector (category: Dashboard)
Calculate the radar line vector for a line (the runway) or a dot (an alien)
[X]
Variable alien in workspace Main variable workspace
Temporary storage, used as a flag to indicate the alien when updating the radar (shares a memory location with the objCount variable)
[X]
Label drbl1 is local to this routine
[X]
Label drbl2 is local to this routine
[X]
Label drbl3 is local to this routine
[X]
Label drbl4 is local to this routine
[X]
Variable previousCompass (category: Dashboard)
Stores the value of the compass heading when we draw the runway on the radar, so we can erase the line later
[X]
Configuration variable row25_char34_7 = &7857
Left spur of the radar's cross
[X]
Configuration variable row25_char35_6 = &785E
Bottom pixel of the top spur of the radar's cross
[X]
Configuration variable row25_char35_7 = &785F
Centre and right spur of the radar's cross
[X]
Configuration variable row26_char35_0 = &7998
Top pixel of the bottom spur of the radar's cross
[X]
Configuration variable row26_char35_1 = &7999
Bottom pixel of the bottom spur of the radar's cross
[X]
Variable xPointHi (category: 3D geometry)
High byte of the x-coordinate for a point
[X]
Variable xPointLo in workspace Main variable workspace
The low byte of the x-coordinate for the point with ID X is at xPointLo,X
[X]
Variable xRadarBuffer (category: Dashboard)
The x-coordinates of the runway and alien on the radar
[X]
Variable yRadarBuffer (category: Dashboard)
The y-coordinates of the runway and alien on the radar
[X]
Variable yRotationHi in workspace Main variable workspace
Plane rotation angle around the y-axis (high byte)
[X]
Variable zPointHi (category: 3D geometry)
High byte of the z-coordinate for a point
[X]
Variable zPointLo in workspace Main variable workspace
The low byte of the z-coordinate for the point with ID X is at zPointLo,X