.HideIconBar LDA #HI(nameBuffer0+27*32) ; Set SC(1 0) to the address of the first tile on STA SC+1 ; tile row 27 in nametable buffer 0 LDA #LO(nameBuffer0+27*32) STA SC LDA #HI(nameBuffer1+27*32) ; Set SC2(1 0) to the address of the first tile on STA SC2+1 ; tile row 27 in nametable buffer 1 LDA #LO(nameBuffer1+27*32) STA SC2 LDY #63 ; Set Y as an index, which will count down from 63 to 1, ; so we blank tile 1 to 63 of the icon bar in the ; following loop LDA #0 ; Set A = 0 to store in the nametable buffers, as tile 0 ; is the empty background tile .hbar1 STA (SC),Y ; Set the Y-th nametable entry for the icon bar to the STA (SC2),Y ; empty tile in A DEY ; Decrement the index counter BNE hbar1 ; Loop back until we have replaced all 63 tiles with the ; background tile LDA #32 ; Set A = 32 as the pattern number to show at the start ; of row 27 (though I don't know why we do this, as ; pattern 32 is part of the icon bar pattern, so this ; seems a bit strange) LDY #0 ; Set the first nametable entry on tile row 27 to A STA (SC),Y STA (SC2),Y RTS ; Return from the subroutineName: HideIconBar [Show more] Type: Subroutine Category: Icon bar Summary: Remove the icon bar from the screen by replacing it with background tilesContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar calls HideIconBar.SetupIconBarPause ; By default the icon bar shows all possible icons, so ; now we work our way through the buttons, hiding any ; icons that do not apply LDA JSTGY ; If JSTGY is 0 then the game is not configured to BEQ pbar1 ; reverse the controller y-axis, so jump to pbar1 to ; skip the following and leave the default icon showing LDY #2 ; Draw four tiles over the top of the first button to JSR Draw4OptionTiles ; show that the controller y-axis is reversed .pbar1 LDA DAMP ; If DAMP is 0 then controller damping is disabled, so BEQ pbar2 ; jump to pbar2 to skip the following and leave the ; default icon showing LDY #4 ; Draw six tiles over the top of the second button to JSR Draw6OptionTiles ; shot that controller damping is enabled .pbar2 LDA disableMusic ; If bit 7 of disableMusic is clear then music is BPL pbar3 ; enabled, so jump to pbar3 to skip the following and ; leave the default icon showing LDY #7 ; Draw four tiles over the top of the third button to JSR Draw4OptionTiles ; show that music is disabled .pbar3 LDA DNOIZ ; If bit 7 of DNOIZ is set then sound is on, so jump to BMI pbar4 ; pbar4 to skip the following and leave the default icon ; showing LDY #9 ; Draw six tiles over the top of the fourth button to JSR Draw6OptionTiles ; shot that sound is disabled .pbar4 LDA numberOfPilots ; If the game is configured for two pilots, jump to BNE pbar5 ; pbar5 to skip the following and leave the default icon ; showing LDY #12 ; Draw four tiles over the top of the fifth button to JSR Draw4OptionTiles ; show that one pilot is configured .pbar5 JSR BlankButtons6To11 ; Blank from the sixth to the eleventh button on the ; icon bar ; Fall through into SetIconBarButtonsS to jump to ; SetIconBarButtons to set the correct list of button ; numbers for the icon barName: SetupIconBarPause [Show more] Type: Subroutine Category: Icon bar Summary: Set up the game options shown on the icon bar when the game is pausedContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar calls SetupIconBarPause.SetIconBarButtonsS JMP SetIconBarButtons ; Jump to SetIconBarButtons to set the barButtons ; variable to point to the correct list of button ; numbers for the icon bar we are setting up, returning ; from the subroutine using a tail callName: SetIconBarButtonsS [Show more] Type: Subroutine Category: Icon bar Summary: Set the correct list of button numbers for the icon bar (this is a jump so we can call this routine using a branch instruction)Context: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar calls SetIconBarButtonsS.SetupIconBar TAY ; Copy the icon bar type into Y BMI HideIconBar ; If the icon bar type has bit 7 set, then this must be ; type $FF, so jump to HideIconBar to hide the icon bar ; on row 27, returning from the subroutine using a tail ; call STA iconBarType ; Set the type of the current icon bar in iconBarType to ; to the new type in A SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 JSR DrawIconBar ; Draw the icon bar into the nametable buffers for both ; bitplanes LDA iconBarType ; If iconBarType = 0 then jump to SetupIconBarDocked to BEQ SetupIconBarDocked ; set up the Docked icon bar, returning from the ; subroutine using a tail call CMP #1 ; If iconBarType = 1 then jump to SetupIconBarFlight to BEQ SetupIconBarFlight ; set up the Flight icon bar, returning from the ; subroutine using a tail call CMP #3 ; If iconBarType = 3 then jump to SetupIconBarPause to BEQ SetupIconBarPause ; set up the Pause icon bar, returning from the ; subroutine using a tail call CMP #2 ; If iconBarType <> 2 then it must be 4, so this is the BNE SetIconBarButtonsS ; title screen and we need to show the title screen ; copyright message in place of the icon bar, so jump to ; SetIconBarButtons via SetIconBarButtonsS to skip ; setting up any bespoke buttons and simply display the ; copyright message patterns as they are, returning from ; the subroutine using a tail call JMP SetupIconBarCharts ; Otherwise iconBarType must be 2, so jump to ; SetupIconBarCharts to set up the Charts icon bar, ; returning from the subroutine using a tail callName: SetupIconBar [Show more] Type: Subroutine Category: Icon bar Summary: Set up the icons on the icon bar to show all available optionsContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar_b3 calls SetupIconBar * UpdateIconBar calls SetupIconBar
Arguments: A The type of the icon bar to set up: * 0 = Docked * 1 = Flight * 2 = Charts * 3 = Pause * 4 = Title screen copyright message * $FF = Hide the icon bar on row 27.SetupIconBarFlight ; By default the icon bar shows all possible icons, so ; now we work our way through the buttons, hiding any ; icons that do not apply LDA SSPR ; If we are inside the space station safe zone then SSPR BNE fbar1 ; is non-zero, so jump to fbar1 to leave the first ; button showing the docking computer icon LDY #2 ; Otherwise blank the first button on the icon bar to JSR DrawBlankButton2x2 ; hide the docking computer icon as we can't activate ; the docking computer outside of the safe zone .fbar1 LDA ECM ; If we have an E.C.M. fitted, jump to fbar2 to leave BNE fbar2 ; the seventh button showing the E.C.M. icon LDY #17 ; Otherwise blank the seventh button on the icon bar to JSR DrawBlankButton2x2 ; hide the E.C.M. icon we don't have an E.C.M. fitted .fbar2 LDA QQ22+1 ; Fetch QQ22+1, which contains the number that's shown ; on-screen during hyperspace countdown BNE fbar3 ; If it is non-zero then there is a hyperspace countdown ; in progress, so jump to fbar3 to blank the sixth ; button on the icon bar, as otherwise it would show the ; hyperspace icon (which we can't choose as we are ; already counting down) LDA selectedSystemFlag ; If bit 6 of selectedSystemFlag is set, then we can ASL A ; hyperspace to the currently selected system, so jump BMI fbar4 ; to fbar4 to leave the sixth button showing the ; hyperspace icon .fbar3 LDY #14 ; If we get here then there is either a hyperspace JSR DrawBlankButton3x2 ; countdown already in progress, or we can't hyperspace ; to the selected system, so blank the sixth button on ; the icon bar to hide the hyperspace icon .fbar4 LDA QQ11 ; If this is the space view, jump to fbar5 to process BEQ fbar5 ; the weapon buttons JSR BlankButtons8To11 ; Otherwise this is not a space view and we don't want ; to show the weapon buttons, so blank from the eighth ; to the eleventh button on the icon bar JMP fbar10 ; Jump to fbar10 to process the eleventh button on the ; icon bar .fbar5 LDA NOMSL ; If we have at least one missile fitted then NOMSL will BNE fbar6 ; be non-zero, so jump to fbar6 to leave the eighth ; button showing the target missile icon LDY #19 ; Otherwise we have no missiles fitted so blank the JSR DrawBlankButton3x2 ; eighth button on the icon bar to hide the target ; missile icon .fbar6 LDA MSTG ; If MSTG is positive (i.e. it does not have bit 7 set), BPL fbar7 ; then it indicates we already have a missile locked on ; a target (in which case MSTG contains the ship number ; of the target), so jump to fbar7 to leave the ninth ; button showing the fire missile icon LDY #22 ; Otherwise the missile is not targeted, so blank the JSR DrawBlankButton2x2 ; ninth button on the icon bar to hide the fire missile ; icon .fbar7 LDA BOMB ; If we do have an energy bomb fitted, jump to fbar8 to BNE fbar8 ; leave the tenth button showing the energy bomb icon LDY #24 ; Otherwise we do not have an energy bomb fitted, so JSR DrawBlankButton3x2 ; blank the tenth button on the icon bar to hide the ; energy bomb icon .fbar8 LDA MJ ; If we are in witchspace (i.e. MJ is non-zero), jump to BNE fbar9 ; fbar9 to hide the escape pod icon, as we can't use the ; escape pod in witchspace LDA ESCP ; If we have an escape pod fitted, jump to fbar10 to BNE fbar10 ; leave the eleventh button showing the escape pod icon .fbar9 LDY #27 ; If we get here then we are either in space or don't JSR DrawBlankButton2x2 ; have an escape pod fitted, so blank the eleventh ; button on the icon bar to hide the escape pod icon .fbar10 LDA allowInSystemJump ; If bits 6 and 7 of allowInSystemJump are clear then we AND #%11000000 ; are allowed to do an in-system jump, so jump to dock2 BEQ dock2 ; in SetupIconBarDocked to leave the twelfth button ; showing the fast-forward icon and move on to ; processing the second button on the icon bar .fbar11 LDY #29 ; Otherwise we can't do an in-system jump, so blank the JSR DrawBlankButton3x2 ; twelfth button on the icon bar to hide the ; fast-forward icon JMP dock2 ; Jump to dock2 in SetupIconBarDocked to move on to ; processing the second button on the icon barName: SetupIconBarFlight [Show more] Type: Subroutine Category: Icon bar Summary: Set up the Flight icon barContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar calls SetupIconBarFlight * SetupIconBarCharts calls via fbar8 * SetupIconBarCharts calls via fbar11
Other entry points: fbar8 Process the escape pod, fast-forward and Market Price buttons fbar11 Process the fast-forward and Market Price buttons.SetupIconBarDocked ; By default the icon bar shows all possible icons, so ; now we work our way through the buttons, hiding any ; icons that do not apply LDA COK ; If COK is non-zero then cheat mode has been applied, BNE dock1 ; so jump to dock1 to hide the button to change the ; commander name (as cheats can't change their commander ; name away from "CHEATER") LDA QQ11 ; If the view type in QQ11 is $BB (Save and load with CMP #$BB ; the normal and highlight fonts loaded), jump to ifon1 BEQ dock2 ; to leave the seventh button showing the icon to change ; the commander name .dock1 LDY #17 ; If we get here then either cheat mode has been applied JSR DrawBlankButton2x2 ; or this is not the save screen, so blank the seventh ; button on the icon bar to hide the change commander ; name icon .dock2 LDA QQ11 ; If the view type in QQ11 is not $BA (Market Price), CMP #$BA ; then jump to SetIconBarButtons to skip the following BNE SetIconBarButtons ; two instructions LDY #4 ; This is the Market Price screen, so blank the second JSR DrawBlankButton3x2 ; button on the icon bar (though as we are going to draw ; the Inventory button over the top, this isn't strictly ; necessary) ; Fall through into SetIconBarButtons to set the correct ; list of button numbers for the icon barName: SetupIconBarDocked [Show more] Type: Subroutine Category: Icon bar Summary: Set up the Docked icon barContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar calls SetupIconBarDocked * SetupIconBarFlight calls via dock2
Other entry points: dock2 Process the second button on the Docked or Flight icon bars.SetIconBarButtons SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA iconBarType ; Set barButtons(1 0) = iconBarButtons ASL A ; + iconBarType * 16 ASL A ; ASL A ; So barButtons(1 0) points to list of button numbers in ASL A ; the iconBarButtons table for this icon bar type ADC #LO(iconBarButtons) STA barButtons LDA #HI(iconBarButtons) ADC #0 STA barButtons+1 RTS ; Return from the subroutineName: SetIconBarButtons [Show more] Type: Subroutine Category: Icon bar Summary: Set the correct list of button numbers for the icon barContext: See this subroutine on its own page References: This subroutine is called as follows: * SetIconBarButtonsS calls SetIconBarButtons * SetupIconBarDocked calls SetIconBarButtons.SetupIconBarCharts ; By default the icon bar shows all possible icons, so ; now we work our way through the buttons, hiding any ; icons that do not apply LDX #4 ; Set X = 4 (though this appears to be unused) LDA QQ12 ; If we are in space (QQ12 = 0) then jump to char1 to BEQ char1 ; leave the fifth button showing the laser view icon ; and process the rest of the icon bar ; If we get here then we setting up the Charts icon bar ; when are docked LDY #12 ; Blank the fifth button on the icon bar to hide the JSR DrawBlankButton2x2 ; laser view button, as this doesn't apply when we are ; docked JSR BlankButtons8To11 ; Blank from the eighth to the eleventh button on the ; icon bar as none of these icons apply when we are ; docked JMP fbar11 ; Jump to fbar11 in SetupIconBarFlight to process the ; fast-forward and Market Price buttons, returning from ; the subroutine using a tail call .char1 ; If we get here then we setting up the Charts icon bar ; when we are in space LDY #2 ; Blank the first button on the icon bar to hide the JSR DrawBlankButton2x2 ; docking computer icon so we can't activate it while ; looking at the charts while in space LDA QQ22+1 ; Fetch QQ22+1, which contains the number that's shown ; on-screen during hyperspace countdown BEQ char2 ; If the counter is zero then there is no countdown in ; progress, so jump to char2 to leave the "Return ; pointer to current system" and "Search for system" ; icons visible LDY #14 ; Blank the sixth button on the icon bar to hide the JSR DrawBlankButton3x2 ; "Return pointer to current system" icon, as this ; can't be done during a hyperspace countdown LDY #17 ; Blank the seventh button on the icon bar to hide the JSR DrawBlankButton2x2 ; "Search for system" icon, as this can't be done during ; a hyperspace countdown JMP char3 ; Jump to char3 to move on to the eighth button on the ; icon bar .char2 ; If we get here then there is no hyperspace countdown LDA selectedSystemFlag ; If bit 6 of selectedSystemFlag is set, then we can ASL A ; hyperspace to the currently selected system, so jump BMI char4 ; to char4 to leave the eighth button showing the ; hyperspace icon .char3 LDY #19 ; Blank the eighth button on the icon bar to hide the JSR DrawBlankButton3x2 ; hyperspace icon, as we can't hyperspace to the ; currently selected system .char4 LDA GHYP ; If we have a galactic hyperdrive fitted, jump to char5 BNE char5 ; to leave the ninth button showing the galactic ; hyperspace icon LDY #22 ; Blank the ninth button on the icon bar to hide the JSR DrawBlankButton2x2 ; galactic hyperspace icon, as we don't have a galactic ; hyperdrive fitted .char5 LDA ECM ; If we have an E.C.M. fitted, jump to char6 to leave BNE char6 ; the seventh tenth showing the E.C.M. icon LDY #24 ; Otherwise blank the tenth button on the icon bar to JSR DrawBlankButton3x2 ; hide the E.C.M. icon we don't have an E.C.M. fitted .char6 JMP fbar8 ; Jump to fbar8 in SetupIconBarFlight to process the ; escape pod, fast-forward and Market Price buttons, ; returning from the subroutine using a tail callName: SetupIconBarCharts [Show more] Type: Subroutine Category: Icon bar Summary: Set up the Charts icon barContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBar calls SetupIconBarCharts.DrawBlankButton2x2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA #4 ; Set A = 4, which is the number of the top-left pattern ; for a blank 2x2 icon bar button STA (SC),Y ; Set the top-left corner of the 2x2 tile block we want STA (SC2),Y ; to draw to the pattern in A, in both nametable buffers INY ; Increment Y to move right by one tile LDA #5 ; Set A = 5, which is the number of the top-right ; pattern for a blank 2x2 icon bar button STA (SC),Y ; Set the top-right corner of the 2x2 tile block we want STA (SC2),Y ; to draw to the pattern in A, in both nametable buffers TYA ; Set Y = Y + 31 CLC ; ADC #31 ; So Y now points to the bottom-left tile of the 2x2 TAY ; tile block that we want to draw buffers (as there are ; 32 tiles in a row and we already moved right by one) LDA #36 ; Set A = 36, which is the number of the bottom-left ; pattern for a blank 2x2 icon bar button STA (SC),Y ; Set the bottom-left corner of the 2x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers INY ; Increment Y to move right by one tile LDA #37 ; Set A = 37, which is the number of the bottom-right ; pattern for a blank 2x2 icon bar button STA (SC),Y ; Set the bottom-right corner of the 2x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers RTS ; Return from the subroutineName: DrawBlankButton2x2 [Show more] Type: Subroutine Category: Icon bar Summary: Draw a blank icon bar button as a 2x2 tile blockContext: See this subroutine on its own page References: This subroutine is called as follows: * BlankAllButtons calls DrawBlankButton2x2 * BlankButtons6To11 calls DrawBlankButton2x2 * BlankButtons8To11 calls DrawBlankButton2x2 * SetupIconBarCharts calls DrawBlankButton2x2 * SetupIconBarDocked calls DrawBlankButton2x2 * SetupIconBarFlight calls DrawBlankButton2x2
Arguments: Y The number of the top-left tile of the icon bar button we want to draw, given as a nametable offset from the first tile in the icon bar (i.e. the tile in the top-left corner of the icon bar) SC(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 0 SC2(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 1.DrawBlankButton3x2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA #6 ; Set A = 6, which is the number of the top-left pattern ; for a blank 3x2 icon bar button STA (SC),Y ; Set the top-left corner of the 3x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers INY ; Increment Y to move right by one tile LDA #7 ; Set A = 7, which is the number of the top-middle ; pattern for a blank 3x2 icon bar button STA (SC),Y ; Set the top-middle tile of the 3x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers INY ; Increment Y to move right by one tile LDA #8 ; Set A = 8, which is the number of the top-right ; pattern for a blank 3x2 icon bar button STA (SC),Y ; Set the top-right corner of the 3x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers TYA ; Set Y = Y + 30 CLC ; ADC #30 ; So Y now points to the bottom-left tile of the 3x2 TAY ; tile block that we want to draw buffers (as there are ; 32 tiles in a row and we already moved right by two) LDA #38 ; Set A = 36, which is the number of the bottom-left ; pattern for a blank 3x2 icon bar button STA (SC),Y ; Set the bottom-left corner of the 3x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers INY ; Increment Y to move right by one tile LDA #37 ; Set A = 37, which is the number of the bottom-middle ; pattern for a blank 3x2 icon bar button STA (SC),Y ; Set the bottom-middle tile of the 3x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers INY ; Increment Y to move right by one tile LDA #39 ; Set A = 39, which is the number of the bottom-right ; pattern for a blank 3x2 icon bar button STA (SC),Y ; Set the bottom-right corner of the 3x2 tile block we STA (SC2),Y ; want to draw to the pattern in A, in both nametable ; buffers RTS ; Return from the subroutineName: DrawBlankButton3x2 [Show more] Type: Subroutine Category: Icon bar Summary: Draw a blank icon bar button as a 3x2 tile blockContext: See this subroutine on its own page References: This subroutine is called as follows: * BlankAllButtons calls DrawBlankButton3x2 * BlankButtons6To11 calls DrawBlankButton3x2 * BlankButtons8To11 calls DrawBlankButton3x2 * SetupIconBarCharts calls DrawBlankButton3x2 * SetupIconBarDocked calls DrawBlankButton3x2 * SetupIconBarFlight calls DrawBlankButton3x2
Arguments: Y The number of the top-left tile of the icon bar button we want to draw, given as a nametable offset from the first tile in the icon bar (i.e. the tile in the top-left corner of the icon bar) SC(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 0 SC2(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 1.Draw6OptionTiles JSR Draw2OptionTiles ; Call Draw2OptionTiles to draw two tiles over the top ; of the option icon specified in Y INY ; Increment Y to move along to the next tile column ; Fall through into Draw4OptionTiles to draw four more ; tilesName: Draw6OptionTiles [Show more] Type: Subroutine Category: Icon bar Summary: Draw six tiles over the top of an icon bar button in the Pause icon bar to change an option icon to a non-default stateContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBarPause calls Draw6OptionTiles
Arguments: Y The tile column of the top-left tile in the block of six tiles that we want to draw (three across and two high) SC(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 0 SC2(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 1
Returns: Y Y is preserved.Draw4OptionTiles SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 JSR Draw2OptionTiles ; Call Draw2OptionTiles to draw two tiles over the top ; of the option icon specified in Y INY ; Increment Y to move along to the next tile column ; Fall through into Draw4OptionTiles to draw two more ; tilesName: Draw4OptionTiles [Show more] Type: Subroutine Category: Icon bar Summary: Draw four tiles over the top of an icon bar button in the Pause icon bar to change an option icon to a non-default stateContext: See this subroutine on its own page References: This subroutine is called as follows: * SetupIconBarPause calls Draw4OptionTiles
Arguments: Y The tile column of the top-left tile in the 2x2 block of four tiles that we want to draw SC(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 0 SC2(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 1
Returns: Y Y is preserved.Draw2OptionTiles LDA barNames3+14,Y ; Set A to the nametable entry for the top tile of this ; option's icon when it is not in the default state, ; which can be found in entry Y + 14 of the barNames3 ; table STA (SC),Y ; Set the top tile of the block we want to draw to the STA (SC2),Y ; pattern in A, in both nametable buffers STY T ; Store Y in T so we can retrieve it below TYA ; Set Y = Y + 32 CLC ; ADC #32 ; So Y now points to the next tile down in the row below TAY ; (as there are 32 tiles in a row) LDA barNames3+14,Y ; Set A to the nametable entry for the bottom tile of ; this option's icon when it is not in the default ; state, which can be found in entry Y + 14 of the ; barNames3 table STA (SC),Y ; Set the bottom tile of the block we want to draw to STA (SC2),Y ; the pattern in A, in both nametable buffers LDY T ; Restore Y from T so it is preserved RTS ; Return from the subroutineName: Draw2OptionTiles [Show more] Type: Subroutine Category: Icon bar Summary: Draw a top and bottom tile over the top of an icon bar button in the Pause icon bar to change an option icon to a non-default stateContext: See this subroutine on its own page References: This subroutine is called as follows: * Draw4OptionTiles calls Draw2OptionTiles * Draw6OptionTiles calls Draw2OptionTiles
Arguments: Y The tile column of the top and bottom tiles that we want to draw SC(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 0 SC2(1 0) The address of the nametable entries for the on-screen icon bar in nametable buffer 1
Returns: Y Y is preserved.vpat1 LDX #4 ; This is the Start screen with no fonts loaded, so set STX firstFreePattern ; firstFreePattern to 4 RTS ; Return from the subroutine without copying anything to ; the pattern buffers .vpat2 LDX #37 ; This is the Space view with the normal font loaded, STX firstFreePattern ; so set firstFreePattern to 37 RTS ; Return from the subroutine without copying anything to ; the pattern buffers .SetLinePatterns LDA QQ11 ; If the view type in QQ11 is $CF (Start screen with no CMP #$CF ; font loaded), jump to vpat1 to set firstFreePattern to BEQ vpat1 ; 4 and return from the subroutine CMP #$10 ; If the view type in QQ11 is $10 (Space view with BEQ vpat2 ; the normal font loaded), jump to vpat2 to set ; firstFreePattern to 37 and return from the subroutine LDX #66 ; Set X = 66 to use as the value of firstFreePattern ; then there is no dashboard LDA QQ11 ; If bit 7 of the view type in QQ11 is set then there BMI vpat3 ; is no dashboard, so jump to vpat3 to keep X = 66 LDX #60 ; There is a dashboard, so set X = 60 to use as the ; value of firstFreePattern .vpat3 STX firstFreePattern ; Set firstFreePattern to the value we set in X, so it ; is 66 when there is no dashboard, or 60 when there is ; ; We now load the image data for the horizontal line, ; vertical line and block images, starting at pattern 37 ; and ending at the pattern in firstFreePattern (60 or ; 66) LDA #HI(lineImage) ; Set V(1 0) = lineImage so we copy the pattern data for STA V+1 ; the line images into the pattern buffers below LDA #LO(lineImage) STA V LDA #HI(pattBuffer0+8*37) ; Set SC(1 0) to the address of pattern 37 in STA SC+1 ; pattern buffer 0 LDA #LO(pattBuffer0+8*37) STA SC LDA #HI(pattBuffer1+8*37) ; Set SC2(1 0) to the address of pattern 37 in STA SC2+1 ; pattern buffer 1 LDA #LO(pattBuffer1+8*37) STA SC2 LDY #0 ; We are about to copy data into the pattern buffers, ; so set an index counter in Y LDX #37 ; We are copying the image data into patterns 37 to 60, ; so set a pattern counter in X .vpat4 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 ; We repeat the following code eight times, so it copies ; eight bytes of each pattern into both pattern buffers LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC),Y ; into pattern buffers 0 and 1, and increment the index STA (SC2),Y ; in Y INY BNE vpat5 ; If we just incremented Y back around to 0, then INC V+1 ; increment the high bytes of V(1 0), SC(1 0) and INC SC+1 ; SC2(1 0) to point to the next page in memory INC SC2+1 .vpat5 INX ; Increment the pattern counter in X CPX #60 ; Loop back until we have copied patterns 37 to 59 BNE vpat4 .vpat6 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 CPX firstFreePattern ; If the pattern counter in X matches firstFreePattern, BEQ vpat8 ; jump to vpat8 to exit the following loop ; Otherwise we keep copying tiles until X matches ; firstFreePattern LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the line image table STA (SC2),Y ; into pattern buffer 1, zero the Y-th byte of pattern LDA #0 ; buffer 0, and increment the index STA (SC),Y INY BNE vpat7 ; If we just incremented Y back around to 0, then INC V+1 ; increment the high bytes of V(1 0), SC(1 0) and INC SC+1 ; SC2(1 0) to point to the next page in memory INC SC2+1 .vpat7 INX ; Increment the pattern counter in X JMP vpat6 ; Loop back to copy more patterns, if required .vpat8 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 ; Finally, we reset the next six patterns (i.e. the ones ; from firstFreePattern onwards), so we need to zero 48 ; bytes, as there are eight bytes in each pattern ; ; We keep using the index in Y, as it already points to ; the correct place in the buffers LDA #0 ; Set A = 0 so we can zero the pattern buffers LDX #48 ; Set X as a byte counter .vpat9 STA (SC2),Y ; Zero the Y-th byte of both pattern buffers STA (SC),Y INY ; Increment the index counter BNE vpat10 ; If we just incremented Y back around to 0, then INC SC2+1 ; increment the high bytes of SC(1 0) and SC2(1 0) INC SC+1 ; to point to the next page in memory .vpat10 DEX ; Decrement the byte counter BNE vpat9 ; Loop back until we have zeroed all 48 bytes SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 RTS ; Return from the subroutineName: SetLinePatterns [Show more] Type: Subroutine Category: Drawing the screen Summary: Copy the patterns for horizontal line, vertical line and block images into the pattern buffers, depending on the view Deep dive: Drawing lines in the NES versionContext: See this subroutine on its own page References: This subroutine is called as follows: * SetLinePatterns_b3 calls SetLinePatterns.LoadNormalFont STA SC ; Set SC to the pattern number where we need to load the ; font patterns SEC ; Set asciiToPattern = A - ASCII code for space SBC #' ' ; = start pattern - ASCII for space STA asciiToPattern ; ; The font that we load starts with a space character as ; the first entry, so asciiToPattern is the number we ; need to add to an ASCII code to get the corresponding ; character pattern LDA SC ; Set firstFreePattern = SC + 95 CLC ; ADC #95 ; There are 95 characters in the font, and we are about STA firstFreePattern ; to load them at pattern number SC in the buffers, so ; this sets the next free pattern number in ; firstFreePattern to the pattern after the 95 font ; patterns we are loading ; ; The font pattern data at fontImage actually contains ; 96 characters, but we ignore the last one, which is ; full of random workspace noise left over from the ; assembly process LDX #0 ; Set X = 0 to use in the font inversion logic below LDA QQ11 ; If the view type in QQ11 is not $BB (Save and load CMP #$BB ; with the normal and highlight fonts loaded), jump to BNE ifon1 ; ifon1 to skip the following instruction DEX ; This is the Save and Load screen with font loaded in ; both bitplanes, so set X = $FF to use in the font ; inversion logic below .ifon1 STX T ; Set T = X, so we have the following: ; ; * T = $FF if QQ11 is $BB (Save and Load screen with ; the normal and highlight fonts loaded) ; ; * T = 0 for all other screens ; ; This is used to invert the font characters below LDA #0 ; Set SC2(1 0) = pattBuffer0 + SC * 8 ASL SC ; ROL A ; So this points to the pattern in pattern buffer 0 that ASL SC ; corresponds to tile number SC ROL A ASL SC ROL A ADC #HI(pattBuffer0) STA SC2+1 ADC #8 ; Set SC(1 0) = SC2(1 0) + (8 0) STA SC+1 ; LDA SC ; Pattern buffer 0 consists of 8 pages of memory and is STA SC2 ; followed by pattern buffer 1, so this sets SC(1 0) to ; the pattern in pattern buffer 1 that corresponds to ; tile number SC LDA #HI(fontImage) ; Set V(1 0) = fontImage, so we copy the font patterns STA V+1 ; to the pattern buffers in the following LDA #LO(fontImage) STA V LDX #95 ; There are 95 characters in the game font, so set a ; character counter in X to count down from 95 to 1 LDY #0 ; Set Y to use as an index counter as we copy the font ; to the pattern buffers .ifon2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 ; We repeat the following code eight times, so it sends ; all eight bytes of this character's font pattern to ; both pattern buffers ; ; In each of the following, the font character is copied ; into pattern buffer 0 unchanged, but when the same ; character is copied into pattern buffer 1, the ; following transformation is applied: ; ; AND T ; EOR T ; ; T is 0, unless this is the Save and Load screen, in ; which case T is $FF ; ; When T = 0, we have A AND 0 EOR 0, which is 0, so ; pattern buffer 1 gets filled with zeroes, and as ; pattern buffer 0 contains the font, this means the ; pattern buffer contains the font in colour 1 on a ; colour 0 background (i.e. a black background) ; ; When T = $FF, we have A AND $FF EOR $FF, which is the ; same as A EOR $FF, which is the value in A inverted, ; so pattern buffer 1 gets filled with the font, but ; with ones for the background and zeroes for the ; foreground, which means the pattern buffer contains ; the font in colour 2 on a colour 1 background LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a row of eight filled pixels or as an EOR T ; inverted font, and increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC2),Y ; buffer 0, and copy the same pattern to pattern buffer AND T ; 1, either as a white block or as an inverted font, and EOR T ; increment the index in Y STA (SC),Y INY BNE ifon3 ; If we just incremented Y back around to 0, then INC V+1 ; increment the high bytes of V(1 0), SC(1 0) and INC SC2+1 ; SC2(1 0) to point to the next page in memory INC SC+1 .ifon3 DEX ; Decrement the character counter in X BNE ifon2 ; Loop back until we have copied all 95 characters to ; the pattern buffers RTS ; Return from the subroutineName: LoadNormalFont [Show more] Type: Subroutine Category: Text Summary: Load the normal font into the pattern buffer from pattern 66 to 160 Deep dive: Fonts in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * LoadNormalFont_b3 calls LoadNormalFont
This routine fills the pattern buffer from pattern 66 to 160 with the font in colour 1 on a colour 0 background (typically a white or cyan font on a black background). If the view type in QQ11 is $BB (Save and load with the normal and highlight fonts loaded), then the font is in colour 1 on a colour 2 background (which is a grey font on a red background in that view's palette). This is always called with A = 66, so it always loads the fonts from pattern 66 to 160.
Arguments: A The pattern number to start at when loading the font patterns into the pattern buffers.LoadHighFont LDA #HI(pattBuffer0+8*161) ; Set SC(1 0) to the address of pattern 161 in STA SC2+1 ; pattern buffer 0 LDA #LO(pattBuffer0+8*161) STA SC2 LDA #HI(pattBuffer1+8*161) ; Set SC(1 0) to the address of pattern 161 in STA SC+1 ; pattern buffer 1 LDA #LO(pattBuffer1+8*161) STA SC LDX #95 ; There are 95 characters in the game font, so set a ; character counter in X to count down from 95 to 1 ; ; The font pattern data at fontImage actually contains ; 96 characters, but we ignore the last one, which is ; full of random workspace noise left over from the ; assembly process LDA QQ11 ; If the view type in QQ11 is not $BB (Save and load CMP #$BB ; with the normal and highlight fonts loaded), jump to BNE font1 ; font1 to skip the following instruction LDX #70 ; This is the Save and Load screen with font loaded in ; both bitplanes, so set X = 70 so that we only copy 70 ; characters from the font .font1 TXA ; Set firstFreePattern = firstFreePattern + X CLC ; ADC firstFreePattern ; We are about to copy X character patterns for the STA firstFreePattern ; font, so this sets the next free pattern number in ; firstFreePattern to the pattern that is X patterns ; after its current value, i.e. just after the font we ; are copying LDA #HI(fontImage) ; Set V(1 0) = fontImage, so we copy the font patterns STA V+1 ; to the pattern buffers in the following LDA #LO(fontImage) STA V LDY #0 ; Set Y to use as an index counter as we copy the font ; to the pattern buffers .font2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 ; We repeat the following code eight times, so it sends ; all eight bytes of this character's font pattern to ; both pattern buffers LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY LDA (V),Y ; Copy the Y-th pattern byte from the font to pattern STA (SC),Y ; buffer 1, set the Y-th pattern byte in pattern buffer LDA #$FF ; 0 to a row of eight set pixels, and increment the STA (SC2),Y ; index in Y INY BNE font3 ; If we just incremented Y back around to 0, then INC V+1 ; increment the high bytes of V(1 0), SC(1 0) and INC SC+1 ; SC2(1 0) to point to the next page in memory INC SC2+1 .font3 DEX ; Decrement the character counter in X BNE font2 ; Loop back until we have copied all 95 characters to ; the pattern buffers RTS ; Return from the subroutineName: LoadHighFont [Show more] Type: Subroutine Category: Text Summary: Load the highlight font into the pattern buffer from pattern 161 to 255 Deep dive: Fonts in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * LoadHighFont_b3 calls LoadHighFont
This routine fills the pattern buffer from pattern 161 to 255 with the font in colour 3 on a colour 1 background (which is typically a green font on a grey background that can be used for drawing highlighted text in menu selections). If the view type in QQ11 is $BB (Save and load with the normal and highlight fonts loaded), then only the first 70 characters of the font are loaded, into patterns 161 to 230..DrawSystemImage ; The system image is made up of two layers: ; ; * A greyscale background that's displayed using the ; nametable tiles, whose patterns are extracted into ; the pattern buffers by the GetSystemBack routine ; ; * A colourful foreground that's displayed as a set ; of sprites, whose patterns are sent to the PPU ; by the GetSystemImage routine, from pattern 69 ; onwards ; ; We start by drawing the background into the nametable ; buffers STX K ; Set K = X, so we can pass the number of columns in the ; image to DrawBackground and DrawSpriteImage below STY K+1 ; Set K+1 = Y, so we can pass the number of rows in the ; image to DrawBackground and DrawSpriteImage below LDA firstFreePattern ; Set picturePattern to the number of the next free STA picturePattern ; pattern in firstFreePattern ; ; We use this when setting K+2 below, so the call to ; DrawBackground displays the patterns at ; picturePattern, and it's also used to specify where ; to load the system image data when we call ; GetSystemImage from SendViewToPPU when showing the ; Data on System screen CLC ; Add 56 to firstFreePattern, as we are going to use 56 ADC #56 ; patterns for the system image (7 rows of 8 tiles) STA firstFreePattern LDA picturePattern ; Set K+2 to the value we stored above, so K+2 is the STA K+2 ; number of the first pattern to use for the system ; image's greyscale background JSR DrawBackground_b3 ; Draw the background by writing the nametable buffer ; entries for the greyscale part of the system image ; (this is the image that is extracted into the pattern ; buffers by the GetSystemBack routine) ; Now that the background is drawn, we move on to the ; sprite-based foreground ; ; We draw the foreground image from sprites with ; sequential patterns, so now we configure the variables ; to pass to the DrawSpriteImage routine LDA #69 ; Set K+2 = 69, so we draw the system image using STA K+2 ; pattern 69 onwards LDA #8 ; Set K+3 = 8, so we build the image from sprite 8 STA K+3 ; onwards LDX #0 ; Set X and Y to zero, so we draw the system image at LDY #0 ; (XC, YC), without any indents JSR DrawSpriteImage_b6 ; Draw the system image from sprites, using pattern 69 ; onwards ; We now draw a frame around the system image we just ; drew, so we set up the variables so the DrawImageFrame ; can do just that DEC XC ; We just drew the image at (XC, YC), so decrement them DEC YC ; both so we can pass (XC, YC) to the DrawImageFrame ; routine to draw a frame around the image, with the ; top-left corner one block up and left from the image ; corner INC K ; Increment the number of columns in K to pass to the ; DrawImageFrame routine, so we draw a frame that's the ; correct width (DrawImageFrame expects K to be the ; frame width minus 1) INC K+1 ; Increment K+1 twice so the DrawImageFrame will draw a INC K+1 ; frame that is the height of the image, plus two rows ; for the top and bottom of the frame ; Fall through into DrawImageFrame to draw a frame ; around the system imageName: DrawSystemImage [Show more] Type: Subroutine Category: Universe Summary: Draw the system image as a coloured foreground in front of a greyscale backgroundContext: See this subroutine on its own page References: This subroutine is called as follows: * DrawSystemImage_b3 calls DrawSystemImage
Arguments: X The number of columns in the image (i.e. the number of tiles in each row of the image) Y The number of tile rows in the image.DrawImageFrame JSR GetNameAddress ; Get the addresses in the nametable buffers for the ; tile at text coordinate (XC, YC), as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 LDY #0 ; Set the tile at the top-left corner of the picture LDA #64 ; frame to pattern 64 STA (SC),Y STA (SC2),Y LDA #60 ; Draw the top edge of the frame using pattern 60 JSR DrawRowOfTiles LDA #62 ; Set the tile at the top-right corner of the picture STA (SC),Y ; frame to pattern 62 STA (SC2),Y DEC K+1 ; Decrement the number of rows to draw, as we have just ; drawn one JMP fram2 ; Jump to fram2to start drawing the sides of the frame .fram1 JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA #1 ; Set the tile at the start of the row (at offset 0) to LDY #0 ; pattern 1, to draw the left edge of the frame STA (SC),Y STA (SC2),Y LDA #2 ; Set the tile at the end of the row (at offset K) to LDY K ; pattern 2, to draw the right edge of the frame STA (SC),Y STA (SC2),Y .fram2 LDA SC ; Set SC(1 0) = SC(1 0) + 32 CLC ; ADC #32 ; Starting with the low bytes STA SC ; ; So SC(1 0) now points at the next row down (as there ; are 32 tiles on each row) STA SC2 ; Set SC2(1 0) = SC2(1 0) + 32 ; ; Starting with the low bytes ; ; So SC2(1 0) now points at the next row down (as there ; are 32 tiles on each row) BCC fram3 ; If the above addition overflowed, increment the high INC SC+1 ; high bytes of SC(1 0) and SC2(1 0) accordingly INC SC2+1 .fram3 DEC K+1 ; Decrement the number of rows to draw, as we have just ; moved down a row BNE fram1 ; Loop back to fram1 to draw the frame edges, until we ; have drawn the correct number of rows (i.e. K+1 - 1) LDY #0 ; Set the tile at the bottom-left corner of the picture LDA #65 ; frame to pattern 65 STA (SC),Y STA (SC2),Y LDA #61 ; Draw the top edge of the frame using pattern 61 JSR DrawRowOfTiles LDA #63 ; Set the tile at the bottom-right corner of the picture STA (SC),Y ; frame to pattern 63 STA (SC2),Y RTS ; Return from the subroutineName: DrawImageFrame [Show more] Type: Subroutine Category: Drawing the screen Summary: Draw a frame around the system image or commander headshotContext: See this subroutine on its own page References: This subroutine is called as follows: * DrawImageFrame_b3 calls DrawImageFrame
Arguments: XC The tile column for the top-left corner of the frame YC The tile row for the top-left corner of the frame K The number of tiles to draw, minus 1 (so we draw K - 1 tiles) K+1 The number of rows to draw SC(1 0) The address in nametable buffer 0 for the start of the row, less 1 (we draw from SC(1 0) + 1 onwards) SC2(1 0) The address in nametable buffer 1 for the start of the row, less 1 (we draw from SC2(1 0) + 1 onwards).DrawRowOfTiles LDY #1 ; We start drawing from SC(1 0) + 1, so set an index ; counter in Y .drow1 STA (SC),Y ; Draw the pattern in A into the Y-th nametable entry STA (SC2),Y ; in both the nametable buffers INY ; Increment the index counter CPY K ; Loop back until we have drawn K - 1 tiles BNE drow1 RTS ; Return from the subroutineName: DrawRowOfTiles [Show more] Type: Subroutine Category: Drawing the screen Summary: Draw a row of tiles into the nametable bufferContext: See this subroutine on its own page References: This subroutine is called as follows: * DrawImageFrame calls DrawRowOfTiles * DrawSmallBox calls DrawRowOfTiles
This routine effectively draws K tiles at SC(1 0) and SC2(1 0), but omitting the first tile.
Arguments: A The pattern number to use for the row of tiles K The number of tiles to draw, minus 1 (so we draw K - 1 tiles) SC(1 0) The address in nametable buffer 0 for the start of the row, less 1 (we draw from SC(1 0) + 1 onwards) SC2(1 0) The address in nametable buffer 1 for the start of the row, less 1 (we draw from SC2(1 0) + 1 onwards).GetNameAddress JSR GetRowNameAddress ; Get the addresses in the nametable buffers for the ; start of character row YC, as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 LDA SC ; Set SC(1 0) = SC(1 0) + XC CLC ; ADC XC ; Starting with the low bytes STA SC ; ; So SC(1 0) contains the address in nametable buffer 0 ; of the text character at column XC on row YC STA SC2 ; Set SC2(1 0) = SC2(1 0) + XC ; ; Starting with the low bytes ; ; So SC2(1 0) contains the address in nametable buffer 1 ; of the text character at column XC on row YC BCC nadd1 ; If the above addition overflowed, then increment the INC SC+1 ; high bytes of SC(1 0) and SC2(1 0) accordingly INC SC2+1 .nadd1 RTS ; Return from the subroutineName: GetNameAddress [Show more] Type: Subroutine Category: Drawing the screen Summary: Get the addresses in the nametable buffers for a given tileContext: See this subroutine on its own page References: This subroutine is called as follows: * DrawImageFrame calls GetNameAddress * DrawSmallBox calls GetNameAddress
Arguments: XC The tile column YC The tile row
Returns: SC(1 0) The address in nametable buffer 0 for the tile SC2(1 0) The address in nametable buffer 1 for the tile.DrawSmallBox LDA K+2 ; Set the text cursor in XC to column K+2, to pass to STA XC ; GetNameAddress below LDA K+3 ; Set the text cursor in YC to row K+3, to pass to STA YC ; GetNameAddress below JSR GetNameAddress ; Get the addresses in the nametable buffers for the ; tile at text coordinate (XC, YC), as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 ; ; So these point to the address in the nametable buffer ; of the top-left corner of the box LDA #61 ; Draw a row of K tiles using pattern 61, which contains JSR DrawRowOfTiles ; a thick horizontal line along the bottom of the ; pattern, so this draws the top of the box LDX K+1 ; Set X to the number of rows in the box we want to draw ; from K+1, to use as a counter for the height of the ; box JMP sbox2 ; Jump into the loop below at sbox2 .sbox1 JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA SC ; Add 32 to SC(1 0) to move down to the next row in CLC ; nametable buffer 0, starting with the low byte ADC #32 STA SC STA SC2 ; Update the low byte of SC2(1 0) as well to move down ; in nametable buffer 1 too BCC sbox2 ; If the addition overflowed, increment the high bytes INC SC+1 ; as well INC SC2+1 .sbox2 LDA #1 ; We draw the left edge of the box using pattern 1, ; which contains a thick vertical line along the right ; edge of the pattern, so set A = 1 to poke into the ; nametable LDY #0 ; Draw the left edge of the box at the address in STA (SC),Y ; SC(1 0) and SC2(1 0), which draws it in both STA (SC2),Y ; nametable buffers LDA #2 ; We draw the right edge of the box using pattern 2, ; which contains a thick vertical line along the left ; edge of the pattern, so set A = 2 to poke into the ; nametable LDY K ; Draw the left edge of the box at the address in STA (SC),Y ; SC(1 0) and SC2(1 0) + K, which draws it K blocks to STA (SC2),Y ; the right of the left edge in both nametable buffers DEX ; Decrement the row counter in X BNE sbox1 ; Loop back to draw the left and right edges for the ; next row LDA #60 ; Draw a row of K tiles using pattern 61, which contains JMP DrawRowOfTiles ; a thick horizontal line along the top of the pattern, ; so this draws the bottom of the box, returning from ; the subroutine using a tail callName: DrawSmallBox [Show more] Type: Subroutine Category: Drawing the screen Summary: Draw a small box, typically used for popups or outlinesContext: See this subroutine on its own page References: This subroutine is called as follows: * DrawSmallBox_b3 calls DrawSmallBox
Arguments: K The width of the box to draw in tiles K+1 The height of the box to draw in tiles K+2 The text row on which to draw the top-left corner of the small box K+3 The text column on which to draw the top-left corner of the small box.DrawBackground JSR GetRowNameAddress ; Get the addresses in the nametable buffers for the ; start of character row YC, as follows: ; ; SC(1 0) = the address in nametable buffer 0 ; ; SC2(1 0) = the address in nametable buffer 1 LDA SC ; Set SC(1 0) = SC(1 0) + XC CLC ; ADC XC ; Starting with the low bytes STA SC ; ; So SC(1 0) contains the address in nametable buffer 0 ; of the text character at column XC on row YC STA SC2 ; Set SC2(1 0) = SC2(1 0) + XC ; ; Starting with the low bytes ; ; So SC2(1 0) contains the address in nametable buffer 1 ; of the text character at column XC on row YC BCC back1 ; If the above addition overflowed, then increment the INC SC+1 ; high bytes of SC(1 0) and SC2(1 0) accordingly INC SC2+1 .back1 LDX K+1 ; Set X = K+1 to use as a counter for each row in the ; image .back2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDY #0 ; Set Y as a tile index as we work through the tiles in ; the image LDA K+2 ; Set A to the pattern number of the first tile in K+2 .back3 STA (SC2),Y ; Set the Y-th nametable entry in both nametable buffers STA (SC),Y ; to the pattern number in A CLC ; Increment A so we fill the background with incremental ADC #1 ; pattern numbers INY ; Increment the index counter CPY K ; Loop back until we have drawn K - 1 tiles BNE back3 STA K+2 ; Update K+2 to the pattern number of the next tile LDA SC ; Set SC(1 0) = SC(1 0) + 32 CLC ; ADC #32 ; Starting with the low bytes STA SC ; ; So SC(1 0) now points at the next row down (as there ; are 32 tiles on each row) STA SC2 ; Set SC2(1 0) = SC2(1 0) + 32 ; ; Starting with the low bytes ; ; So SC2(1 0) now points at the next row down (as there ; are 32 tiles on each row) BCC back4 ; If the above addition overflowed, increment the high INC SC+1 ; high bytes of SC(1 0) and SC2(1 0) accordingly INC SC2+1 .back4 DEX ; Decrement the number of rows to draw, as we have just ; moved down a row BNE back2 ; Loop back until we have drawn all X rows in the image RTS ; Return from the subroutineName: DrawBackground [Show more] Type: Subroutine Category: Drawing the screen Summary: Draw the background of a system or commander image into the nametable bufferContext: See this subroutine on its own page References: This subroutine is called as follows: * DrawBackground_b3 calls DrawBackground
We draw an image background using patterns with incremental pattern numbers, as the image's patterns have already been sent to the pattern buffers one after the other.
Arguments: K The number of columns in the image (i.e. the number of tiles in each row of the image) K+1 The number of tile rows in the image K+2 The pattern number of the start of the image pattern data in the pattern table K+3 Number of the first free sprite in the sprite buffer, where we can build the sprites to make up the image.ClearScreen LDA #0 ; Set SC(1 0) = 66 * 8 STA SC+1 ; LDA #66 ; We use this to calculate the address of pattern 66 in ASL A ; the pattern buffers below ROL SC+1 ASL A ROL SC+1 ASL A ROL SC+1 STA SC STA SC2 ; Set SC2(1 0) = pattBuffer1 + SC(1 0) LDA SC+1 ; = pattBuffer1 + 66 * 8 ADC #HI(pattBuffer1) ; STA SC2+1 ; So SC2(1 0) contains the address of pattern 66 in ; pattern buffer 1, as each pattern in the buffer ; contains eight bytes LDA SC+1 ; Set SC(1 0) = pattBuffer0 + SC(1 0) ADC #HI(pattBuffer0) ; = pattBuffer0 + 66 * 8 STA SC+1 ; ; So SC2(1 0) contains the address of pattern 66 in ; pattern buffer 0 LDX #66 ; We want to zero pattern 66 onwards, so set a counter ; in X to count the tile number, starting from 66 LDY #0 ; Set Y to use as a byte index as we zero 8 bytes for ; each tile .clsc1 LDA #0 ; We are going to zero the tiles to clear the patterns, ; so set A = 0 so we can poke it into memory ; We repeat the following code eight times, so it clears ; one whole pattern of eight bytes STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y STA (SC),Y ; Zero the Y-th pattern byte in SC(1 0) and SC2(1 0), to STA (SC2),Y ; clear both pattern buffer 0 and 1, and increment the INY ; byte counter in Y BNE clsc2 ; If Y is non-zero then jump to clsc2 to skip the ; following INC SC+1 ; Y just wrapped around to zero, so increment the high INC SC2+1 ; bytes of SC(1 0) and SC2(1 0) so that SC(1 0) + Y ; and SC2(1 0) + Y continue to point to the correct ; addresses in the pattern buffers .clsc2 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 INX ; Increment the tile number in X, as we just cleared a ; whole pattern BNE clsc1 ; Loop back to clsc1 to keep clearing patterns until we ; have cleared patterns 66 through 255 ; We have cleared the pattern buffers, so now to clear ; the nametable buffers LDA #LO(nameBuffer0) ; Set SC(1 0) = nameBuffer0 STA SC STA SC2 LDA #HI(nameBuffer0) STA SC+1 LDA #HI(nameBuffer1) ; Set SC2(1 0) = nameBuffer1 STA SC2+1 LDX #28 ; We are going to clear 28 rows of 32 tiles, so set a ; row counter in X to count down from 28 .clsc3 LDY #32 ; We are going to clear 32 tiles on each row, so set a ; tile counter in Y to count down from 32 LDA #0 ; We are going to zero the nametable entry so it uses ; the blank background tile, so set A = 0 so we can poke ; it into memory .clsc4 STA (SC),Y ; Zero the Y-th nametable entry in SC(1 0), which resets ; nametable 0 STA (SC2),Y ; Zero the Y-th nametable entry in SC2(1 0), which ; resets nametable 1 DEY ; Decrement the tile counter in Y BPL clsc4 ; Loop back until we have zeroed all 32 tiles on this ; row SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA SC ; Add 32 to both SC(1 0) and SC2(1 0) so they point to CLC ; the next row down in the nametables, starting with the ADC #32 ; low bytes STA SC STA SC2 BCC clsc5 ; And then the high bytes INC SC+1 INC SC2+1 .clsc5 DEX ; Decrement the row counter in X BNE clsc3 ; Loop back until we have cleared all 28 rows RTS ; Return from the subroutineName: ClearScreen [Show more] Type: Subroutine Category: Drawing the screen Summary: Clear the screen by clearing patterns 66 to 255 in both pattern buffers, and clearing both nametable buffers to the backgroundContext: See this subroutine on its own page References: This subroutine is called as follows: * ClearScreen_b3 calls ClearScreen.viewPalettes EQUB $0F, $2C, $0F, $2C ; Palette 0: Space view, Game Over screen EQUB $0F, $28, $00, $1A EQUB $0F, $10, $00, $16 EQUB $0F, $10, $00, $1C EQUB $0F, $38, $2A, $15 EQUB $0F, $1C, $22, $28 EQUB $0F, $16, $28, $27 EQUB $0F, $15, $20, $25 EQUB $0F, $38, $38, $38 ; Palette 1: Market Price EQUB $0F, $10, $06, $1A EQUB $0F, $22, $00, $28 EQUB $0F, $10, $00, $1C EQUB $0F, $38, $10, $15 EQUB $0F, $10, $0F, $1C EQUB $0F, $06, $28, $25 EQUB $0F, $15, $20, $25 EQUB $0F, $2C, $0F, $2C ; Palette 2: Title screen EQUB $0F, $28, $00, $1A EQUB $0F, $10, $00, $16 EQUB $0F, $10, $00, $3A EQUB $0F, $38, $10, $15 EQUB $0F, $1C, $10, $28 EQUB $0F, $06, $10, $27 EQUB $0F, $00, $10, $25 EQUB $0F, $2C, $0F, $2C ; Palette 3: Short-range Chart EQUB $0F, $10, $1A, $28 EQUB $0F, $10, $00, $16 EQUB $0F, $10, $00, $1C EQUB $0F, $38, $2A, $15 EQUB $0F, $1C, $22, $28 EQUB $0F, $06, $28, $27 EQUB $0F, $15, $20, $25 EQUB $0F, $2C, $0F, $2C ; Palette 4: Long-range Chart EQUB $0F, $20, $28, $25 EQUB $0F, $10, $00, $16 EQUB $0F, $10, $00, $1C EQUB $0F, $38, $2A, $15 EQUB $0F, $1C, $22, $28 EQUB $0F, $06, $28, $27 EQUB $0F, $15, $20, $25 EQUB $0F, $28, $10, $06 ; Palette 5: Equip Ship EQUB $0F, $10, $00, $1A EQUB $0F, $0C, $1C, $2C EQUB $0F, $10, $00, $1C EQUB $0F, $0C, $1C, $2C EQUB $0F, $18, $28, $38 EQUB $0F, $25, $35, $25 EQUB $0F, $15, $20, $25 EQUB $0F, $2A, $00, $06 ; Palette 6: Data on System EQUB $0F, $20, $00, $2A EQUB $0F, $10, $00, $20 EQUB $0F, $10, $00, $1C EQUB $0F, $38, $2A, $15 EQUB $0F, $27, $28, $17 EQUB $0F, $06, $28, $27 EQUB $0F, $15, $20, $25 EQUB $0F, $28, $0F, $25 ; Palette 7: Save and load EQUB $0F, $10, $06, $1A EQUB $0F, $10, $0F, $1A EQUB $0F, $10, $00, $1C EQUB $0F, $38, $2A, $15 EQUB $0F, $18, $28, $38 EQUB $0F, $06, $2C, $2C EQUB $0F, $15, $20, $25 EQUB $0F, $1C, $10, $30 ; Palette 8: Inventory, Status Mode EQUB $0F, $20, $00, $2A EQUB $0F, $2A, $00, $06 EQUB $0F, $10, $00, $1C EQUB $0F, $0F, $10, $30 EQUB $0F, $17, $27, $37 EQUB $0F, $0F, $28, $38 EQUB $0F, $15, $25, $25 EQUB $0F, $1C, $2C, $3C ; Palette 9: Start screen EQUB $0F, $38, $11, $11 EQUB $0F, $16, $00, $20 EQUB $0F, $2B, $00, $25 EQUB $0F, $10, $1A, $25 EQUB $0F, $08, $18, $27 EQUB $0F, $0F, $28, $38 EQUB $0F, $00, $10, $30 EQUB $0F, $2C, $0F, $2C ; Palette 10: Mission briefings EQUB $0F, $10, $28, $1A EQUB $0F, $10, $00, $16 EQUB $0F, $10, $00, $1C EQUB $0F, $38, $2A, $15 EQUB $0F, $1C, $22, $28 EQUB $0F, $06, $28, $27 EQUB $0F, $15, $20, $25Name: viewPalettes [Show more] Type: Variable Category: Drawing the screen Summary: The palettes to use for the different viewsContext: See this variable on its own page References: This variable is used as follows: * GetViewPalettes uses viewPalettes.fadeColours EQUB $0F, $0F, $0F, $0F ; Fade colours with value &0v to black ($0F) EQUB $0F, $0F, $0F, $0F EQUB $0F, $0F, $0F, $0F EQUB $0F, $0F, $0F, $0F EQUB $00, $01, $02, $03 ; Fade colours with value &1v to &0v EQUB $04, $05, $06, $07 EQUB $08, $09, $0A, $0B EQUB $0C, $0F, $0F, $0F EQUB $10, $11, $12, $13 ; Fade colours with value &2v to &1v EQUB $14, $15, $16, $17 EQUB $18, $19, $1A, $1B EQUB $1C, $0F, $0F, $0F EQUB $20, $21, $22, $23 ; Fade colours with value &3v to &2v EQUB $24, $25, $26, $27 EQUB $28, $29, $2A, $2B EQUB $2C, $0F, $0F, $0FName: fadeColours [Show more] Type: Variable Category: Drawing the screen Summary: Lookup table that converts a NES colour to the same colour but with a smaller brightness value Deep dive: Views and view types in NES EliteContext: See this variable on its own page References: This variable is used as follows: * FadeColours uses fadeColours
Colours on the NES are stored as hue and value, using an HSV model but without the saturation. Specifically the hue (i.e. blue, red etc.) is stored in the low nibble, while the value (i.e. the brightness) is stored in bits 4 and 5 of the high nibble. Bits 6 and 7 are unused and are always zero. This means that given a colour value in hexadecimal, it is in the form &vh where v is the value (brightness) and h is the hue. We can therefore alter the brightness of a colour by increasing or decreasing the high nibble between 0 and 3, with &0h being the darkest and &3h being the brightest. The NES only supports 54 of the 64 possible colours in this scheme, with colours &vE and &vF all being black, as well as $0D. The convention is to use $0F for all these variants of black. Given a colour &vh, the table entry at fadeColours + &vh contains the same colour but with a reduced brightness in &v. Specifically, it returns the colour with a brightness of &v - 1. We can therefore use this table to fade a colour to black, which will take up to four steps depending on the brightness of the starting colour. See the FadeColours routine for an example..GetViewPalettes LDA QQ11a ; Set X to the old view type in the low nibble of AND #%00001111 ; QQ11a TAX LDA #0 ; Set SC+1 = 0, though this is superfluous as we do the STA SC+1 ; the same thing just below LDA paletteForView,X ; Set A to the palette number to load for view X LDY #0 ; Set SC+1 = 0 for use as the high byte in the address STY SC+1 ; we are about to construct ASL A ; Set (SC+1 A) = A * 32 ASL A ASL A ASL A ASL A ROL SC+1 ADC #LO(viewPalettes) ; Set SC(1 0) = (SC+1 A) + viewPalettes STA SC ; = viewPalettes + 32 * A LDA #HI(viewPalettes) ; ADC SC+1 ; As each of the palettes in the viewPalettes table STA SC+1 ; consists of 32 bytes, this sets SC(1 0) to the address ; of the A-th palette in the table, which is the palette ; that corresponds to the view type in QQ11a that we ; fetched above LDY #32 ; We now want to copy the 32 bytes from the selected ; palette into the palette table at XX3, so set an index ; counter in Y .gpal1 LDA (SC),Y ; Copy the Y-th byte from SC(1 0) to the Y-th byte of STA XX3,Y ; the table at XX3 DEY ; Decrement the index counter BPL gpal1 ; Loop back until we have copied all 32 bytes to XX3 LDA QQ11a ; If the old view type in QQ11a is $00 (Space view with BEQ gpal3 ; no fonts loaded), jump to gpal3 to set the visible and ; hidden colours CMP #$98 ; If the old view type in QQ11a is $98 (Status Mode), BEQ SetPaletteColours ; jump to SetPaletteColours to set the view's palette ; from the entries in the XX3 palette table, returning ; from the subroutine using a tail call CMP #$96 ; If the old view type in QQ11a is not $96 (Data on BNE gpal2 ; System), jump to SetPaletteColours via gpal2 to set ; the view's palette from the entries in the XX3 palette ; table, returning from the subroutine using a tail call ; This is the Data on System view, so we set the palette ; according to the system's seeds LDA QQ15 ; Set A to the EOR of the s0_lo, s2_hi and s1_lo seeds EOR QQ15+5 ; for the current system, shifted right by two places EOR QQ15+2 ; and with bits 2 and 3 flipped LSR A ; LSR A ; This gives us a number that varies between each system EOR #%00001100 ; that we can use to choose one of the eight system ; palettes AND #%00011100 ; Restrict the result in A to multiples of 4 between 0 TAX ; and 28 and set X to the result ; ; We can now use X as an index into the systemPalettes ; table, as there are eight palettes in the table, each ; of which takes up four bytes LDA systemPalettes,X ; Set the four bytes at XX3+20 to the palette entry from STA XX3+20 ; the systemPalettes table that corresponds to the LDA systemPalettes+1,X ; current system STA XX3+21 LDA systemPalettes+2,X STA XX3+22 LDA systemPalettes+3,X STA XX3+23 .gpal2 JMP SetPaletteColours ; Jump to SetPaletteColours to set the view's palette ; from the entries in the XX3 palette table, returning ; from the subroutine using a tail call .gpal3 ; If we get here then the old view type in QQ11a is $00 ; (Space view with no fonts loaded), so we now set the ; hidden and visible colours LDA XX3 ; Set A to the background colour in the first palette ; entry (which will be black) LDY XX3+3 ; Set Y to the foreground colour in the last palette ; entry (which will be cyan) LDA hiddenBitplane ; If the hidden bitplane is 1, jump to gpal4 BNE gpal4 STA XX3+1 ; The hidden bitplane is 0, so set the second colour to STY XX3+2 ; black and the third colour to cyan, so: ; ; * Colour %01 (1) is the hidden colour (black) ; ; * Colour %10 (2) is the visible colour (cyan) RTS ; Return from the subroutine .gpal4 STY XX3+1 ; The hidden bitplane is 1, so set the second colour to STA XX3+2 ; cyan and the third colour to black ; ; * Colour %01 (1) is the visible colour (cyan) ; ; * Colour %10 (2) is the hidden colour (black) RTS ; Return from the subroutineName: GetViewPalettes [Show more] Type: Subroutine Category: Drawing the screen Summary: Get the palette for the view type in QQ11a and store it in a table at XX3 Deep dive: Bitplanes in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * FadeToBlack calls GetViewPalettes * FadeToColour calls GetViewPalettes * SetupViewInNMI calls GetViewPalettes.FadeColoursTwice JSR FadeColours ; Call FadeColours to fade the screen colours towards ; black ; Fall through into FadeColours to fade the screen ; colours a second timeName: FadeColoursTwice [Show more] Type: Subroutine Category: Drawing the screen Summary: Fade the screen colours towards black twiceContext: See this subroutine on its own page References: This subroutine is called as follows: * FadeToColour calls FadeColoursTwice.FadeColours ; We are about to go through 31 entries in the colour ; palette at XX3, fading each colour in turn (and ; ignoring the first entry, which is already black) LDX #31 ; Set an index counter in X .fade1 LDY XX3,X ; Set Y to the X-th colour from the palette LDA fadeColours,Y ; Fetch a faded version of colour Y from the fadeColours STA XX3,X ; table and store it back in the same location in XX3 DEX ; Decrement the counter in X BNE fade1 ; Loop back until we have faded all 31 colours ; Fall through into SetPaletteColours to set the view's ; palette to the now-faded colours from the XX3 tableName: FadeColours [Show more] Type: Subroutine Category: Drawing the screen Summary: Fade the screen colours towards black Deep dive: Views and view types in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * FadeColoursTwice calls FadeColours * FadeToBlack calls FadeColours * FadeToColour calls FadeColours.SetPaletteColours LDA #$0F ; Set hiddenColour to $0F, which is the HSV value for STA hiddenColour ; black, so this hides any pixels that use the hidden ; colour in palette 0 ; In the following we check the view type in QQ11a, ; which contains the old view (if we are changing views) ; or the current view (if we aren't changing views) ; ; This ensures that we set the palette for the old view ; so that it fades away correctly when changing views LDA QQ11a ; If the old view type in QQ11a has bit 7 clear, then it BPL pale1 ; has a dashboard, so jump to pale1 CMP #$C4 ; If the old view type in QQ11a is $C4 (Game Over BEQ pale1 ; screen), jump to pale1 CMP #$98 ; If the old view type in QQ11a is $98 (Status Mode), BEQ pale2 ; jump to pale2 LDA XX3+21 ; Set the palette to entries 21 to 23 from the XX3 STA visibleColour ; table, which contain the palette for the current LDA XX3+22 ; system (so this caters for the Data on System view) STA paletteColour2 LDA XX3+23 STA paletteColour3 RTS ; Return from the subroutine .pale1 ; If we get here then the view either has a dashboard or ; it is the Game Over screen LDA XX3+3 ; Set the visible colour to entry 3 from the XX3 table, STA visibleColour ; which is the visible colour for the space view and ; Game Over screen RTS ; Return from the subroutine .pale2 ; If we get here then the view is the Status Mode LDA XX3+1 ; Set the palette to entries 1 to 3 from the XX3 table, STA visibleColour ; which contains the palette for the commander image (so LDA XX3+2 ; this caters for the Status Mode view) STA paletteColour2 LDA XX3+3 STA paletteColour3 RTS ; Return from the subroutineName: SetPaletteColours [Show more] Type: Subroutine Category: Drawing the screen Summary: Set the view's palette from the entries in the XX3 palette tableContext: See this subroutine on its own page References: This subroutine is called as follows: * FadeToColour calls SetPaletteColours * GetViewPalettes calls SetPaletteColours.FadeToBlack LDA QQ11a ; If the old view type in QQ11a is $FF (Segue screen CMP #$FF ; from Title screen to Demo) then jump to ftob1 to skip BEQ ftob1 ; the fading process, as the screen is already faded LDA screenFadedToBlack ; If bit 7 of screenFadedToBlack is set then we have BMI ftob1 ; already faded the screen to black, so jump to ftob1 to ; skip the fading process ; If we get here then we want to fade the screen to ; black JSR WaitForPPUToFinish ; Wait until both bitplanes of the screen have been ; sent to the PPU, so the screen is fully updated and ; there is no more data waiting to be sent to the PPU JSR WaitForNMI ; Wait until the next NMI interrupt has passed (i.e. the ; next VBlank) JSR GetViewPalettes ; Get the palette for the view type in QQ11a and store ; it in a table at XX3 DEC updatePaletteInNMI ; Decrement updatePaletteInNMI to a non-zero value so we ; do send palette data from XX3 to the PPU during NMI, ; which will ensure the screen updates with the colours ; as we fade to black JSR FadeColours ; Fade the screen colours one step towards black JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) JSR FadeColours ; Fade the screen colours a second step towards black JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) JSR FadeColours ; Fade the screen colours a third step towards black JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) JSR FadeColours ; Fade the screen colours a fourth and final step ; towards black, which is guaranteed to fade the screen ; all the way to black as each colour only has four ; brightness levels (stored as the value part of the ; colour in bits 4 and 5) JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) INC updatePaletteInNMI ; Increment updatePaletteInNMI back to the value it had ; before we decremented it above .ftob1 LDA #$FF ; Set bit 7 of screenFadedToBlack to indicate that we STA screenFadedToBlack ; have faded the screen to black RTS ; Return from the subroutineName: FadeToBlack [Show more] Type: Subroutine Category: Drawing the screen Summary: Fade the screen to black over the next four VBlanks Deep dive: Views and view types in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * FadeToBlack_b3 calls FadeToBlack.FadeToColour JSR WaitForNMI ; Wait until the next NMI interrupt has passed (i.e. the ; next VBlank) JSR GetViewPalettes ; Get the palette for the view type in QQ11a and store ; it in a table at XX3 JSR FadeColoursTwice ; Fade the screen colours two steps towards black JSR FadeColours ; Fade the screen colours a third step towards black, so ; the palette in XX3 is now one step brighter than full ; black (as it takes four steps to fully black-out the ; normal palette) DEC updatePaletteInNMI ; Decrement updatePaletteInNMI to a non-zero value so we ; do send palette data from XX3 to the PPU during NMI, ; which will ensure the screen updates with the colours ; as we reverse the back to full colour JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) JSR GetViewPalettes ; Get the palette for the view type in QQ11a and store ; it in a table at XX3 JSR FadeColoursTwice ; Fade the screen colours two steps towards black, so ; the palette in XX3 is now two steps brighter than full ; black JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) JSR GetViewPalettes ; Get the palette for the view type in QQ11a and store ; it in a table at XX3 JSR FadeColours ; Fade the screen colours one step towards black, so the ; palette in XX3 is now three steps brighter than full ; black JSR WaitFor2NMIs ; Wait until two NMI interrupts have passed (i.e. the ; next two VBlanks) JSR GetViewPalettes ; Get the palette for the view type in QQ11a and store ; it in a table at XX3 JSR SetPaletteColours ; Set the view's palette from the entries in the XX3 ; palette table, so the screen is now at full brightness ; once again JSR WaitForNMI ; Wait until the next NMI interrupt has passed (i.e. the ; next VBlank) INC updatePaletteInNMI ; Increment updatePaletteInNMI back to the value it had ; before we decremented it above LSR screenFadedToBlack ; Clear bit 7 of screenFadedToBlack to indicate that the ; screen has faded back up to full colour RTS ; Return from the subroutineName: FadeToColour [Show more] Type: Subroutine Category: Drawing the screen Summary: Reverse-fade the screen from black to full colour over the next four VBlanks Deep dive: Views and view types in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * FadeToColour_b3 calls FadeToColour.systemPalettes EQUB $0F, $25, $16, $15 ; Palette 0, as used for Lave EQUB $0F, $35, $16, $25 ; Palette 1, as used for Diso EQUB $0F, $34, $04, $14 ; Palette 2, as used for Zaonce EQUB $0F, $27, $28, $17 ; Palette 3, as used for Leesti EQUB $0F, $29, $2C, $19 ; Palette 4, as used for Onrira EQUB $0F, $2A, $1B, $0A ; Palette 5, as used for Reorte EQUB $0F, $32, $21, $02 ; Palette 6, as used for Uszaa EQUB $0F, $2C, $22, $1C ; Palette 7, as used for OrerveName: systemPalettes [Show more] Type: Variable Category: Universe Summary: Palettes for the system imagesContext: See this variable on its own page References: This variable is used as follows: * GetViewPalettes uses systemPalettes.viewAttrCount EQUW 24Name: viewAttrCount [Show more] Type: Variable Category: Drawing the screen Summary: The number of sets of view attributes in the viewAttrOffset tableContext: See this variable on its own page References: This variable is used as follows: * SetViewAttrs uses viewAttrCount * viewAttrOffset uses viewAttrCount.viewAttrOffset EQUW viewAttributes0 - viewAttrCount EQUW viewAttributes1 - viewAttrCount EQUW viewAttributes2 - viewAttrCount EQUW viewAttributes3 - viewAttrCount EQUW viewAttributes4 - viewAttrCount EQUW viewAttributes5 - viewAttrCount EQUW viewAttributes6 - viewAttrCount EQUW viewAttributes7 - viewAttrCount EQUW viewAttributes8 - viewAttrCount EQUW viewAttributes9 - viewAttrCount EQUW viewAttributes10 - viewAttrCount EQUW viewAttributes11 - viewAttrCount EQUW viewAttributes12 - viewAttrCount EQUW viewAttributes13 - viewAttrCount EQUW viewAttributes14 - viewAttrCount EQUW viewAttributes15 - viewAttrCount EQUW viewAttributes16 - viewAttrCount EQUW viewAttributes17 - viewAttrCount EQUW viewAttributes18 - viewAttrCount EQUW viewAttributes19 - viewAttrCount EQUW viewAttributes20 - viewAttrCount EQUW viewAttributes21 - viewAttrCount EQUW viewAttributes22 - viewAttrCount EQUW viewAttributes23 - viewAttrCountName: viewAttrOffset [Show more] Type: Variable Category: Drawing the screen Summary: Offset to the data for each of the 24 sets of view attributesContext: See this variable on its own page References: This variable is used as follows: * SetViewAttrs uses viewAttrOffset.viewAttributes0 EQUB $31, $3F, $27, $0F, $21, $33, $07, $21 EQUB $33, $07, $21, $33, $07, $21, $33, $07 EQUB $FF, $BF, $23, $AF, $22, $AB, $AE, $77 EQUB $99, $25, $AA, $5A, $32, $07, $09, $25 EQUB $0A, $21, $0F, $3FName: viewAttributes0 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 0Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes0
When unpacked, the PPU attributes for this view's screen are as follows: 3F 0F 0F 0F 0F 0F 0F 0F 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 FF BF AF AF AF AB AB AE 77 99 AA AA AA AA AA 5A 07 09 0A 0A 0A 0A 0A 0F.viewAttributes1 EQUB $31, $3F, $27, $0F, $21, $33, $07, $21 EQUB $33, $07, $21, $33, $07, $21, $33, $07 EQUB $12, $26, $AF, $77, $DD, $25, $AA, $5A EQUB $32, $07, $0D, $24, $0F, $32, $0E, $05 EQUB $3FName: viewAttributes1 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 1Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes1
When unpacked, the PPU attributes for this view's screen are as follows: 3F 0F 0F 0F 0F 0F 0F 0F 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 FF FF AF AF AF AF AF AF 77 DD AA AA AA AA AA 5A 07 0D 0F 0F 0F 0F 0E 05.viewAttributes2 EQUB $18, $77, $27, $55, $77, $27, $55, $77 EQUB $27, $55, $77, $27, $55, $77, $27, $55 EQUB $18, $28, $0F, $3FName: viewAttributes2 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 2Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes2
When unpacked, the PPU attributes for this view's screen are as follows: FF FF FF FF FF FF FF FF 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes3 EQUB $18, $77, $27, $55, $77, $27, $55, $77 EQUB $27, $55, $77, $27, $55, $77, $27, $55 EQUB $15, $22, $BF, $EF, $25, $0F, $22, $0B EQUB $21, $0E, $3FName: viewAttributes3 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 3Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes3
When unpacked, the PPU attributes for this view's screen are as follows: FF FF FF FF FF FF FF FF 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 FF FF FF FF FF BF BF EF 0F 0F 0F 0F 0F 0B 0B 0E.viewAttributes4 EQUB $31, $3F, $27, $0F, $21, $33, $07, $73 EQUB $27, $50, $77, $27, $55, $77, $27, $55 EQUB $77, $27, $55, $F7, $FD, $14, $FE, $F5 EQUB $28, $0F, $3FName: viewAttributes4 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 4Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes4
When unpacked, the PPU attributes for this view's screen are as follows: 3F 0F 0F 0F 0F 0F 0F 0F 33 00 00 00 00 00 00 00 73 50 50 50 50 50 50 50 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 F7 FD FF FF FF FF FE F5 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes5 EQUB $31, $3F, $27, $0F, $21, $33, $07, $21 EQUB $33, $07, $21, $33, $07, $21, $33, $07 EQUB $21, $33, $07, $21, $33, $07, $28, $0F EQUB $3FName: viewAttributes5 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 5Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes5
When unpacked, the PPU attributes for this view's screen are as follows: 3F 0F 0F 0F 0F 0F 0F 0F 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes6 EQUB $28, $AF, $77, $27, $55, $77, $27, $55 EQUB $77, $27, $55, $77, $27, $55, $77, $27 EQUB $55, $18, $28, $0F, $3FName: viewAttributes6 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 6Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes6
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF AF AF AF AF AF 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes7 EQUB $28, $AF, $77, $27, $5A, $77, $27, $55 EQUB $77, $27, $55, $77, $27, $55, $77, $27 EQUB $55, $18, $28, $0F, $3FName: viewAttributes7 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 7Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes7
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF AF AF AF AF AF 77 5A 5A 5A 5A 5A 5A 5A 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes8 EQUB $28, $AF, $77, $27, $55, $77, $27, $55 EQUB $77, $27, $55, $77, $27, $55, $77, $27 EQUB $55, $18, $28, $0F, $3FName: viewAttributes8 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 8Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes8
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF AF AF AF AF AF 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes9 EQUB $28, $5F, $77, $27, $55, $77, $27, $55 EQUB $77, $27, $55, $77, $27, $55, $BB, $27 EQUB $AA, $FB, $27, $FA, $18, $3FName: viewAttributes9 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 9Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes9
When unpacked, the PPU attributes for this view's screen are as follows: 5F 5F 5F 5F 5F 5F 5F 5F 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 77 55 55 55 55 55 55 55 BB AA AA AA AA AA AA AA FB FA FA FA FA FA FA FA FF FF FF FF FF FF FF FF.viewAttributes10 EQUB $23, $0F, $25, $5F, $21, $33, $00, $21 EQUB $04, $45, $24, $55, $21, $33, $02, $54 EQUB $55, $99, $22, $AA, $21, $33, $00, $21 EQUB $04, $22, $55, $99, $22, $AA, $F7, $27 EQUB $F5, $1F, $11, $28, $0F, $3FName: viewAttributes10 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 10Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes10
When unpacked, the PPU attributes for this view's screen are as follows: 0F 0F 0F 5F 5F 5F 5F 5F 33 00 04 45 55 55 55 55 33 00 00 54 55 99 AA AA 33 00 04 55 55 99 AA AA F7 F5 F5 F5 F5 F5 F5 F5 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes11 EQUB $23, $0F, $4F, $24, $5F, $21, $33, $02 EQUB $25, $55, $21, $33, $00, $40, $54, $55 EQUB $99, $22, $AA, $21, $33, $00, $21, $04 EQUB $45, $55, $99, $22, $AA, $1F, $19, $28 EQUB $0F, $3FName: viewAttributes11 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 11Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes11
When unpacked, the PPU attributes for this view's screen are as follows: 0F 0F 0F 4F 5F 5F 5F 5F 33 00 00 55 55 55 55 55 33 00 40 54 55 99 AA AA 33 00 04 45 55 99 AA AA FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes12 EQUB $23, $0F, $25, $5F, $21, $33, $00, $21 EQUB $04, $45, $24, $55, $21, $33, $00, $22 EQUB $50, $55, $99, $22, $AA, $21, $33, $00 EQUB $21, $04, $22, $55, $99, $22, $AA, $1F EQUB $1F, $12, $3FName: viewAttributes12 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 12Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes12
When unpacked, the PPU attributes for this view's screen are as follows: 0F 0F 0F 5F 5F 5F 5F 5F 33 00 04 45 55 55 55 55 33 00 50 50 55 99 AA AA 33 00 04 55 55 99 AA AA FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF.viewAttributes13 EQUB $23, $AF, $25, $5F, $BB, $22, $AA, $22 EQUB $5A, $23, $55, $BB, $AA, $22, $A5, $22 EQUB $55, $02, $FB, $24, $FA, $FF, $02, $16 EQUB $22, $F0, $1F, $19, $3FName: viewAttributes13 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 13Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes13
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF 5F 5F 5F 5F 5F BB AA AA 5A 5A 55 55 55 BB AA A5 A5 55 55 00 00 FB FA FA FA FA FF 00 00 FF FF FF FF FF FF F0 F0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF.viewAttributes14 EQUB $25, $AF, $23, $5F, $BB, $AA, $6A, $23 EQUB $5A, $22, $55, $BB, $22, $AA, $65, $22 EQUB $55, $02, $FB, $24, $FA, $FF, $02, $16 EQUB $22, $F0, $1F, $11, $28, $0F, $3FName: viewAttributes14 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 14Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes14
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF AF AF 5F 5F 5F BB AA 6A 5A 5A 5A 55 55 BB AA AA 65 55 55 00 00 FB FA FA FA FA FF 00 00 FF FF FF FF FF FF F0 F0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes15 EQUB $23, $AF, $6F, $24, $5F, $BB, $23, $AA EQUB $5A, $56, $22, $55, $BB, $AA, $6A, $56 EQUB $22, $55, $22, $05, $FB, $24, $FA, $FF EQUB $02, $16, $02, $1F, $19, $3FName: viewAttributes15 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 15Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes15
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF 6F 5F 5F 5F 5F BB AA AA AA 5A 56 55 55 BB AA 6A 56 55 55 05 05 FB FA FA FA FA FF 00 00 FF FF FF FF FF FF 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF.viewAttributes16 EQUB $18, $73, $22, $50, $22, $A0, $60, $22 EQUB $50, $77, $00, $99, $22, $AA, $66, $22 EQUB $55, $73, $22, $50, $22, $AA, $66, $22 EQUB $55, $77, $55, $99, $22, $AA, $66, $22 EQUB $55, $33, $37, $05, $09, $22, $AA, $A6 EQUB $22, $A5, $F3, $22, $F0, $24, $FA, $19 EQUB $3FName: viewAttributes16 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 16Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes16
When unpacked, the PPU attributes for this view's screen are as follows: FF FF FF FF FF FF FF FF 73 50 50 A0 A0 60 50 50 77 00 99 AA AA 66 55 55 73 50 50 AA AA 66 55 55 77 55 99 AA AA 66 55 55 37 05 09 AA AA A6 A5 A5 F3 F0 F0 FA FA FA FA FF FF FF FF FF FF FF FF FF.viewAttributes17 EQUB $18, $73, $22, $50, $22, $A0, $60, $22 EQUB $50, $77, $00, $99, $22, $AA, $66, $22 EQUB $55, $73, $22, $50, $22, $AA, $66, $22 EQUB $55, $77, $55, $99, $22, $AA, $66, $22 EQUB $55, $33, $37, $05, $09, $8A, $AA, $A6 EQUB $22, $A5, $F3, $22, $F0, $F8, $23, $FA EQUB $19, $3FName: viewAttributes17 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 17Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes17
When unpacked, the PPU attributes for this view's screen are as follows: FF FF FF FF FF FF FF FF 73 50 50 A0 A0 60 50 50 77 00 99 AA AA 66 55 55 73 50 50 AA AA 66 55 55 77 55 99 AA AA 66 55 55 37 05 09 8A AA A6 A5 A5 F3 F0 F0 F8 FA FA FA FF FF FF FF FF FF FF FF FF.viewAttributes18 EQUB $18, $73, $22, $50, $22, $A0, $60, $22 EQUB $50, $77, $00, $99, $22, $AA, $66, $22 EQUB $55, $73, $22, $50, $22, $AA, $66, $22 EQUB $55, $77, $55, $99, $22, $AA, $66, $22 EQUB $55, $33, $37, $05, $09, $8A, $AA, $A6 EQUB $22, $A5, $F3, $22, $F0, $F8, $23, $FA EQUB $19, $3FName: viewAttributes18 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 18Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes18
When unpacked, the PPU attributes for this view's screen are as follows: FF FF FF FF FF FF FF FF 73 50 50 A0 A0 60 50 50 77 00 99 AA AA 66 55 55 73 50 50 AA AA 66 55 55 77 55 99 AA AA 66 55 55 37 05 09 8A AA A6 A5 A5 F3 F0 F0 F8 FA FA FA FF FF FF FF FF FF FF FF FF.viewAttributes19 EQUB $AF, $27, $5F, $FB, $FA, $26, $F5, $1F EQUB $1F, $1A, $28, $0F, $3FName: viewAttributes19 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 19Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes19
When unpacked, the PPU attributes for this view's screen are as follows: AF 5F 5F 5F 5F 5F 5F 5F FB FA F5 F5 F5 F5 F5 F5 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes20 EQUB $23, $AF, $25, $5F, $FB, $22, $FA, $25 EQUB $F5, $1F, $1F, $1A, $28, $0F, $3FName: viewAttributes20 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 20Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes20
When unpacked, the PPU attributes for this view's screen are as follows: AF AF AF 5F 5F 5F 5F 5F FB FA FA F5 F5 F5 F5 F5 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes21 EQUB $22, $AF, $6F, $25, $5F, $FB, $FA, $F6 EQUB $25, $F5, $1F, $1F, $1A, $28, $0F, $3FName: viewAttributes21 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 21Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes21
When unpacked, the PPU attributes for this view's screen are as follows: AF AF 6F 5F 5F 5F 5F 5F FB FA F6 F5 F5 F5 F5 F5 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes22 EQUB $31, $3F, $27, $0F, $21, $33, $07, $21 EQUB $33, $07, $21, $33, $07, $21, $33, $07 EQUB $21, $33, $07, $18, $28, $0F, $3FName: viewAttributes22 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 22Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes22
When unpacked, the PPU attributes for this view's screen are as follows: 3F 0F 0F 0F 0F 0F 0F 0F 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes23 EQUB $31, $3F, $27, $0F, $21, $33, $07, $21 EQUB $33, $07, $21, $33, $07, $21, $33, $07 EQUB $F3, $27, $F0, $FB, $27, $5A, $28, $0F EQUB $3FName: viewAttributes23 [Show more] Type: Variable Category: Drawing the screen Summary: Packed view attribute data for attribute set 23Context: See this variable on its own page References: This variable is used as follows: * viewAttrOffset uses viewAttributes23
When unpacked, the PPU attributes for this view's screen are as follows: 3F 0F 0F 0F 0F 0F 0F 0F 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 F3 F0 F0 F0 F0 F0 F0 F0 FB 5A 5A 5A 5A 5A 5A 5A 0F 0F 0F 0F 0F 0F 0F 0F.viewAttributes_EN EQUB 0 ; 0 = Space view EQUB 1 ; 1 = Title screen EQUB 22 ; 2 = Mission 1 briefing: rotating ship EQUB 4 ; 3 = Mission 1 briefing: ship and text EQUB 5 ; 4 = Game Over screen EQUB 2 ; 5 = Text-based mission briefing EQUB 10 ; 6 = Data on System EQUB 19 ; 7 = Inventory EQUB 13 ; 8 = Status Mode EQUB 9 ; 9 = Equip Ship EQUB 6 ; 10 = Market Price EQUB 16 ; 11 = Save and Load EQUB 3 ; 12 = Short-range Chart EQUB 3 ; 13 = Long-range Chart EQUB 2 ; 14 = Unused EQUB 23 ; 15 = Start screenName: viewAttributes_EN [Show more] Type: Variable Category: Drawing the screen Summary: The view attributes to use for each view type in English Deep dive: Multi-language support in NES EliteContext: See this variable on its own page References: This variable is used as follows: * viewAttributesHi uses viewAttributes_EN * viewAttributesLo uses viewAttributes_EN.viewAttributes_DE EQUB 0 ; 0 = Space view EQUB 1 ; 1 = Title screen EQUB 22 ; 2 = Mission 1 briefing: rotating ship EQUB 4 ; 3 = Mission 1 briefing: ship and text EQUB 5 ; 4 = Game Over screen EQUB 2 ; 5 = Text-based mission briefing EQUB 11 ; 6 = Data on System EQUB 20 ; 7 = Inventory EQUB 14 ; 8 = Status Mode EQUB 9 ; 9 = Equip Ship EQUB 7 ; 10 = Market Price EQUB 17 ; 11 = Save and Load EQUB 3 ; 12 = Short-range Chart EQUB 3 ; 13 = Long-range Chart EQUB 2 ; 14 = Unused EQUB 2 ; 15 = Start screenName: viewAttributes_DE [Show more] Type: Variable Category: Drawing the screen Summary: The view attributes to use for each view type in German Deep dive: Multi-language support in NES EliteContext: See this variable on its own page References: This variable is used as follows: * viewAttributesHi uses viewAttributes_DE * viewAttributesLo uses viewAttributes_DE.viewAttributes_FR EQUB 0 ; 0 = Space view EQUB 1 ; 1 = Title screen EQUB 22 ; 2 = Mission 1 briefing: rotating ship EQUB 4 ; 3 = Mission 1 briefing: ship and text EQUB 5 ; 4 = Game Over screen EQUB 2 ; 5 = Text-based mission briefing EQUB 12 ; 6 = Data on System EQUB 21 ; 7 = Inventory EQUB 15 ; 8 = Status Mode EQUB 9 ; 9 = Equip Ship EQUB 8 ; 10 = Market Price EQUB 18 ; 11 = Save and Load EQUB 3 ; 12 = Short-range Chart EQUB 3 ; 13 = Long-range Chart EQUB 2 ; 14 = Unused EQUB 23 ; 15 = Start screenName: viewAttributes_FR [Show more] Type: Variable Category: Drawing the screen Summary: The view attributes to use for each view type in French Deep dive: Multi-language support in NES EliteContext: See this variable on its own page References: This variable is used as follows: * viewAttributesHi uses viewAttributes_FR * viewAttributesLo uses viewAttributes_FR.viewAttributesLo EQUB LO(viewAttributes_EN) ; English EQUB LO(viewAttributes_DE) ; German EQUB LO(viewAttributes_FR) ; French EQUB LO(viewAttributes_EN) ; There is no fourth language, so this byte is ; ignoredName: viewAttributesLo [Show more] Type: Variable Category: Drawing the screen Summary: The low byte of the view attributes lookup table for each language Deep dive: Multi-language support in NES EliteContext: See this variable on its own page References: This variable is used as follows: * SetViewAttrs uses viewAttributesLo.viewAttributesHi EQUB HI(viewAttributes_EN) ; English EQUB HI(viewAttributes_DE) ; German EQUB HI(viewAttributes_FR) ; French EQUB HI(viewAttributes_EN) ; There is no fourth language, so this byte is ; ignoredName: viewAttributesHi [Show more] Type: Variable Category: Drawing the screen Summary: The high byte of the view attributes lookup table for each language Deep dive: Multi-language support in NES EliteContext: See this variable on its own page References: This variable is used as follows: * SetViewAttrs uses viewAttributesHi.SetViewAttrs LDX languageIndex ; Set X to the index of the chosen language LDA viewAttributesLo,X ; Set V(1 0) = viewAttributes_EN, _FR or _DE, according STA V ; to the chosen language LDA viewAttributesHi,X STA V+1 LDA QQ11 ; Set Y to the low nibble of the view type, which is AND #$0F ; the view type with the flags stripped off (so it's TAY ; in the range 0 to 15) LDA (V),Y ; Set X to the Y-th entry from the viewAttributes_XX ASL A ; table for the chosen language, which contains the TAX ; number of the set of view attributes that we need to ; apply to this view LDA viewAttrOffset,X ; Set V(1 0) viewAttrOffset for set X + viewAttrCount ADC #LO(viewAttrCount) ; STA V ; So V(1 0) points to viewAttrributes0 when X = 0, LDA viewAttrOffset+1,X ; viewAttrributes1 when X = 1, and so on up to ADC #HI(viewAttrCount) ; viewAttrributes23 when X = 23 STA V+1 LDA #HI(attrBuffer0) ; Set SC(1 0) to the address of attribute buffer 0 STA SC+1 LDA #LO(attrBuffer0) STA SC JMP UnpackToRAM ; Unpack the data at V(1 0) into SC(1 0), updating ; V(1 0) as we go ; ; SC(1 0) is attribute buffer 0, so this unpacks the set ; of view attributes for the view in QQ11 into attribute ; buffer 0 ; ; We then return from the subroutine using a tail callName: SetViewAttrs [Show more] Type: Subroutine Category: Drawing the screen Summary: Set up attribute buffer 0 for the chosen viewContext: See this subroutine on its own page References: This subroutine is called as follows: * SetViewAttrs_b3 calls SetViewAttrs.HideSightSprites LDA #240 ; Set A to the y-coordinate that's just below the bottom ; of the screen, so we can hide the sight sprites by ; moving them off-screen STA ySprite5 ; Set the y-coordinates for the five laser sight sprites STA ySprite6 ; to 240, to move them off-screen STA ySprite7 STA ySprite8 STA ySprite9 RTS ; Return from the subroutineName: HideSightSprites [Show more] Type: Subroutine Category: Flight Summary: Hide the sprites for the laser sights in the space viewContext: See this subroutine on its own page References: This subroutine is called as follows: * SIGHT calls HideSightSprites.SIGHT LDY VIEW ; Fetch the laser power for the current view LDA LASER,Y BEQ HideSightSprites ; If it is zero (i.e. there is no laser fitted to this ; view), jump to HideSightSprites to hide the sight ; sprites and return from the subroutine using a tail ; call CMP #POW+9 ; If the laser power in A is not equal to a pulse laser, BNE sigh1 ; jump to sigh1 to process the other laser types JMP sigh4 ; The laser is a pulse laser, so jump to sigh4 to draw ; the sights for a pulse laser .sigh1 CMP #POW+128 ; If the laser power in A is not equal to a beam laser, BNE sigh2 ; jump to sigh2 to process the other laser types JMP sigh5 ; The laser is a beam laser, so jump to sigh4 to draw ; the sights for a beam laser .sigh2 CMP #Armlas ; If the laser power in A is not equal to a military BNE sigh3 ; laser, jump to sigh3 to draw the sights for a mining ; laser ; The laser is a military laser, so we draw the military ; laser sights with a sprite for each of the left, ; right, top and bottom sights LDA #%10000000 ; Set the attributes for sprite 8 (for the bottom sight) STA attrSprite8 ; as follows: ; ; * Bits 0-1 = sprite palette 0 ; * Bit 5 clear = show in front of background ; * Bit 6 clear = do not flip horizontally ; * Bit 7 set = flip vertically LDA #%01000000 ; Set the attributes for sprite 6 (for the right sight) STA attrSprite6 ; as follows: ; ; * Bits 0-1 = sprite palette 0 ; * Bit 5 clear = show in front of background ; * Bit 6 set = flip horizontally ; * Bit 7 clear = do not flip vertically LDA #%00000000 ; Set the attributes for sprites 5 and 7 (for the left STA attrSprite7 ; and top sights respectively) as follows: STA attrSprite5 ; ; * Bits 0-1 = sprite palette 0 ; * Bit 5 clear = show in front of background ; * Bit 6 clear = do not flip horizontally ; * Bit 7 clear = do not flip vertically LDY #207 ; Set the pattern number for sprites 5 and 6 to 207, STY pattSprite5 ; for the left and right sights respectively STY pattSprite6 INY ; Set the pattern number for sprites 7 and 8 to 208, STY pattSprite7 ; for the top and bottom sights respectively STY pattSprite8 LDA #118 ; Position the sprites as follows: STA xSprite5 ; LDA #134 ; * Sprite 5 at (118, 83) for the left sight STA xSprite6 ; * Sprite 6 at (134, 83) for the right sight LDA #126 ; * Sprite 7 at (126, 75) for the top sight STA xSprite7 ; * Sprite 8 at (126, 91) for the bottom sight STA xSprite8 LDA #83+YPAL STA ySprite5 STA ySprite6 LDA #75+YPAL STA ySprite7 LDA #91+YPAL STA ySprite8 RTS ; Return from the subroutine .sigh3 ; The laser is a mining laser, so we draw the mining ; laser sights with a sprite for each of the top-left, ; top-right, bottom-left and bottom-right sights LDA #%00000011 ; Set the attributes for sprite 5 (for the top-left STA attrSprite5 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 3 ; * Bit 5 clear = show in front of background ; * Bit 6 clear = do not flip horizontally ; * Bit 7 clear = do not flip vertically LDA #%01000011 ; Set the attributes for sprite 6 (for the top-right STA attrSprite6 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 3 ; * Bit 5 clear = show in front of background ; * Bit 6 set = flip horizontally ; * Bit 7 clear = do not flip vertically LDA #%10000011 ; Set the attributes for sprite 7 (for the bottom-left STA attrSprite7 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 3 ; * Bit 5 clear = show in front of background ; * Bit 6 clear = do not flip horizontally ; * Bit 7 set = flip vertically LDA #%11000011 ; Set the attributes for sprite 8 (for the bottom-right STA attrSprite8 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 0 ; * Bit 5 clear = show in front of background ; * Bit 6 set = flip horizontally ; * Bit 7 set = flip vertically LDA #209 ; Set the pattern number for all four sprites to 209 STA pattSprite5 STA pattSprite6 STA pattSprite7 STA pattSprite8 LDA #118 ; Position the sprites as follows: STA xSprite5 ; STA xSprite7 ; * Sprite 5 at (118, 75) for the top-left sight LDA #134 ; * Sprite 6 at (134, 75) for the top-right sight STA xSprite6 ; * Sprite 7 at (118, 91) for the bottom-left sight STA xSprite8 ; * Sprite 8 at (134, 91) for the bottom-right sight LDA #75+YPAL STA ySprite5 STA ySprite6 LDA #91+YPAL STA ySprite7 STA ySprite8 RTS ; Return from the subroutine .sigh4 ; The laser is a pulse laser, so we draw the pulse laser ; sights with a sprite for each of the left, right, top ; and bottom sights LDA #%00000001 ; Set the attributes for all four sprites as follows: LDY #$CC ; STA attrSprite5 ; * Bits 0-1 = sprite palette 1 STA attrSprite6 ; * Bit 5 clear = show in front of background STA attrSprite7 ; * Bit 6 clear = do not flip horizontally STA attrSprite8 ; * Bit 7 clear = do not flip vertically STY pattSprite5 ; Set the pattern number for sprites 5 and 6 to 204, STY pattSprite6 ; for the left and right sights respectively INY ; Set the pattern number for sprites 7 and 8 to 205, STY pattSprite7 ; for the top and bottom sights respectively STY pattSprite8 LDA #114 ; Position the sprites as follows: STA xSprite5 ; LDA #138 ; * Sprite 5 at (118, 83) for the left sight STA xSprite6 ; * Sprite 6 at (134, 83) for the right sight LDA #126 ; * Sprite 7 at (126, 75) for the top sight STA xSprite7 ; * Sprite 8 at (126, 91) for the bottom sight STA xSprite8 LDA #83+YPAL STA ySprite5 STA ySprite6 LDA #71+YPAL STA ySprite7 LDA #95+YPAL STA ySprite8 RTS ; Return from the subroutine .sigh5 ; The laser is a beam laser, so we draw the beam laser ; sights with a sprite for each of the top-left, ; top-right, bottom-left and bottom-right sights LDA #%00000010 ; Set the attributes for sprite 5 (for the top-left STA attrSprite5 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 2 ; * Bit 5 clear = show in front of background ; * Bit 6 clear = do not flip horizontally ; * Bit 7 clear = do not flip vertically LDA #%01000010 ; Set the attributes for sprite 6 (for the top-right STA attrSprite6 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 2 ; * Bit 5 clear = show in front of background ; * Bit 6 set = flip horizontally ; * Bit 7 clear = do not flip vertically LDA #%10000010 ; Set the attributes for sprite 7 (for the bottom-left STA attrSprite7 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 2 ; * Bit 5 clear = show in front of background ; * Bit 6 clear = do not flip horizontally ; * Bit 7 set = flip vertically LDA #%11000010 ; Set the attributes for sprite 8 (for the bottom-right STA attrSprite8 ; sight) as follows: ; ; * Bits 0-1 = sprite palette 2 ; * Bit 5 clear = show in front of background ; * Bit 6 set = flip horizontally ; * Bit 7 set = flip vertically LDA #206 ; Set the pattern number for all four sprites to 206 STA pattSprite5 STA pattSprite6 STA pattSprite7 STA pattSprite8 LDA #122 ; Position the sprites as follows: STA xSprite5 ; STA xSprite7 ; * Sprite 5 at (122, 75) for the top-left sight LDA #130 ; * Sprite 6 at (130, 75) for the top-right sight STA xSprite6 ; * Sprite 7 at (122, 91) for the bottom-left sight STA xSprite8 ; * Sprite 8 at (130, 91) for the bottom-right sight LDA #75+YPAL STA ySprite5 STA ySprite6 LDA #91+YPAL STA ySprite7 STA ySprite8 RTS ; Return from the subroutineName: SIGHT [Show more] Type: Subroutine Category: Flight Summary: Draw the laser crosshairs Deep dive: Sprite usage in NES EliteContext: See this subroutine on its own page References: This subroutine is called as follows: * SIGHT_b3 calls SIGHTFOR I%, P%, $BFF9 EQUB $FF ; Pad out the rest of the ROM bank with $FF NEXT IF _NTSC EQUW Interrupts_b3+$4000 ; Vector to the NMI handler in case this bank is ; loaded into $C000 during start-up (the handler ; contains an RTI so the interrupt is processed but ; has no effect) EQUW ResetMMC1_b3+$4000 ; Vector to the RESET handler in case this bank is ; loaded into $C000 during start-up (the handler ; resets the MMC1 mapper to map bank 7 into $C000 ; instead) EQUW Interrupts_b3+$4000 ; Vector to the IRQ/BRK handler in case this bank is ; loaded into $C000 during start-up (the handler ; contains an RTI so the interrupt is processed but ; has no effect) ELIF _PAL EQUW NMI ; Vector to the NMI handler EQUW ResetMMC1_b3+$4000 ; Vector to the RESET handler in case this bank is ; loaded into $C000 during start-up (the handler ; resets the MMC1 mapper to map bank 7 into $C000 ; instead) EQUW IRQ ; Vector to the IRQ/BRK handler ENDIFName: Vectors_b3 [Show more] Type: Variable Category: Utility routines Summary: Vectors and padding at the end of ROM bank 3 Deep dive: Splitting NES Elite across multiple ROM banksContext: See this variable on its own page References: No direct references to this variable in this source filePRINT "S.bank3.bin ", ~CODE%, " ", ~P%, " ", ~LOAD%, " ", ~LOAD% SAVE "3-assembled-output/bank3.bin", CODE%, P%, LOAD%Save bank3.bin[X]Configuration variable ArmlasMilitary laser power[X]Subroutine BlankButtons6To11 (category: Icon bar)Blank from the sixth to the eleventh button on the icon bar[X]Subroutine BlankButtons8To11 (category: Icon bar)Blank from the eighth to the eleventh button on the icon bar[X]Subroutine Draw2OptionTiles (category: Icon bar)Draw a top and bottom tile over the top of an icon bar button in the Pause icon bar to change an option icon to a non-default state[X]Subroutine Draw4OptionTiles (category: Icon bar)Draw four tiles over the top of an icon bar button in the Pause icon bar to change an option icon to a non-default state[X]Subroutine Draw6OptionTiles (category: Icon bar)Draw six tiles over the top of an icon bar button in the Pause icon bar to change an option icon to a non-default state[X]Subroutine DrawBackground_b3 (category: Drawing the screen)Call the DrawBackground routine in ROM bank 3[X]Subroutine DrawBlankButton2x2 (category: Icon bar)Draw a blank icon bar button as a 2x2 tile block[X]Subroutine DrawBlankButton3x2 (category: Icon bar)Draw a blank icon bar button as a 3x2 tile block[X]Subroutine DrawIconBar (category: Icon bar)Draw the icon bar into the nametable buffers for both bitplanes[X]Subroutine DrawRowOfTiles (category: Drawing the screen)Draw a row of tiles into the nametable buffer[X]Subroutine DrawSpriteImage_b6 (category: Drawing sprites)Call the DrawSpriteImage routine in ROM bank 6[X]Subroutine FadeColours (category: Drawing the screen)Fade the screen colours towards black[X]Subroutine FadeColoursTwice (category: Drawing the screen)Fade the screen colours towards black twice[X]Subroutine GetNameAddress (category: Drawing the screen)Get the addresses in the nametable buffers for a given tile[X]Subroutine GetRowNameAddress (category: Drawing the screen)Get the addresses in the nametable buffers for the start of a given character row[X]Subroutine GetViewPalettes (category: Drawing the screen)Get the palette for the view type in QQ11a and store it in a table at XX3[X]Subroutine HideIconBar (category: Icon bar)Remove the icon bar from the screen by replacing it with background tiles[X]Subroutine HideSightSprites (category: Flight)Hide the sprites for the laser sights in the space view[X]Subroutine IRQ (category: Utility routines)Handle IRQ interrupts by doing nothing[X]Subroutine Interrupts_b3 (category: Start and end)The IRQ and NMI handler while the MMC1 mapper reset routine is still running[X]Subroutine NMI (category: Utility routines)The NMI interrupt handler that gets called every VBlank and which updates the screen, reads the controllers and plays music[X]Configuration variable POWPulse laser power in the NES version is POW + 9, rather than just POW in the other versions (all other lasers are the same)[X]Subroutine ResetMMC1_b3 (category: Start and end)The MMC1 mapper reset routine at the start of the ROM bank[X]Macro SETUP_PPU_FOR_ICON_BAR (category: PPU)If the PPU has started drawing the icon bar, configure the PPU to use nametable 0 and pattern table 0[X]Subroutine SetIconBarButtons (category: Icon bar)Set the correct list of button numbers for the icon bar[X]Subroutine SetIconBarButtonsS (category: Icon bar)Set the correct list of button numbers for the icon bar (this is a jump so we can call this routine using a branch instruction)[X]Subroutine SetPaletteColours (category: Drawing the screen)Set the view's palette from the entries in the XX3 palette table[X]Subroutine SetupIconBarCharts (category: Icon bar)Set up the Charts icon bar[X]Subroutine SetupIconBarDocked (category: Icon bar)Set up the Docked icon bar[X]Subroutine SetupIconBarFlight (category: Icon bar)Set up the Flight icon bar[X]Subroutine SetupIconBarPause (category: Icon bar)Set up the game options shown on the icon bar when the game is paused[X]Subroutine SetupPPUForIconBar (category: PPU)If the PPU has started drawing the icon bar, configure the PPU to use nametable 0 and pattern table 0, while preserving A[X]Subroutine UnpackToRAM (category: Utility routines)Unpack compressed image data to RAM[X]Subroutine WaitFor2NMIs (category: Utility routines)Wait until two NMI interrupts have passed (i.e. the next two VBlanks)[X]Subroutine WaitForNMI (category: Utility routines)Wait until the next NMI interrupt has passed (i.e. the next VBlank)[X]Subroutine WaitForPPUToFinish (category: PPU)Wait until the NMI handler has finished updating both bitplanes, so the screen is no longer refreshing[X]Workspace XX3 (category: Workspaces)Temporary storage space for complex calculations[X]Configuration variable YPALA margin of 6 pixels that is applied to a number of y-coordinates for the PAL version only (as the PAL version has a taller screen than NTSC)[X]Variable allowInSystemJump in workspace WPBits 6 and 7 record whether it is safe to perform an in-system jump[X]Variable asciiToPattern in workspace ZPThe number to add to an ASCII code to get the pattern number in the PPU of the corresponding character image[X]Variable attrBuffer0 in workspace Cartridge WRAMThe buffer for attribute table 0 that gets sent to the PPU during VBlank[X]Variable attrSprite5 in workspace Sprite bufferAttributes for sprite 5[X]Variable attrSprite6 in workspace Sprite bufferAttributes for sprite 6[X]Variable attrSprite7 in workspace Sprite bufferAttributes for sprite 7[X]Variable attrSprite8 in workspace Sprite bufferAttributes for sprite 8[X]Label back1 in subroutine DrawBackground[X]Label back2 in subroutine DrawBackground[X]Label back3 in subroutine DrawBackground[X]Label back4 in subroutine DrawBackground[X]Variable barButtons in workspace ZPThe address of the list of button numbers in the iconBarButtons table for the current icon bar[X]Variable barNames3 (category: Icon bar)Nametable entries for icon bar 3 (Pause)[X]Label char1 in subroutine SetupIconBarCharts[X]Label char2 in subroutine SetupIconBarCharts[X]Label char3 in subroutine SetupIconBarCharts[X]Label char4 in subroutine SetupIconBarCharts[X]Label char5 in subroutine SetupIconBarCharts[X]Label char6 in subroutine SetupIconBarCharts[X]Label clsc1 in subroutine ClearScreen[X]Label clsc2 in subroutine ClearScreen[X]Label clsc3 in subroutine ClearScreen[X]Label clsc4 in subroutine ClearScreen[X]Label clsc5 in subroutine ClearScreen[X]Variable disableMusic in workspace WPMusic on/off configuration setting[X]Label dock1 in subroutine SetupIconBarDocked[X]Entry point dock2 in subroutine SetupIconBarDocked (category: Icon bar)Process the second button on the Docked or Flight icon bars[X]Label drow1 in subroutine DrawRowOfTiles[X]Label fade1 in subroutine FadeColours[X]Variable fadeColours (category: Drawing the screen)Lookup table that converts a NES colour to the same colour but with a smaller brightness value[X]Label fbar1 in subroutine SetupIconBarFlight[X]Label fbar10 in subroutine SetupIconBarFlight[X]Entry point fbar11 in subroutine SetupIconBarFlight (category: Icon bar)Process the fast-forward and Market Price buttons[X]Label fbar2 in subroutine SetupIconBarFlight[X]Label fbar3 in subroutine SetupIconBarFlight[X]Label fbar4 in subroutine SetupIconBarFlight[X]Label fbar5 in subroutine SetupIconBarFlight[X]Label fbar6 in subroutine SetupIconBarFlight[X]Label fbar7 in subroutine SetupIconBarFlight[X]Entry point fbar8 in subroutine SetupIconBarFlight (category: Icon bar)Process the escape pod, fast-forward and Market Price buttons[X]Label fbar9 in subroutine SetupIconBarFlight[X]Variable firstFreePattern in workspace ZPContains the number of the first free pattern in the pattern buffer that we can draw into next (or 0 if there are no free patterns)[X]Label font1 in subroutine LoadHighFont[X]Label font2 in subroutine LoadHighFont[X]Label font3 in subroutine LoadHighFont[X]Variable fontImage (category: Text)Image data for the text font[X]Label fram1 in subroutine DrawImageFrame[X]Label fram2 in subroutine DrawImageFrame[X]Label fram3 in subroutine DrawImageFrame[X]Label ftob1 in subroutine FadeToBlack[X]Label gpal1 in subroutine GetViewPalettes[X]Label gpal2 in subroutine GetViewPalettes[X]Label gpal3 in subroutine GetViewPalettes[X]Label gpal4 in subroutine GetViewPalettes[X]Label hbar1 in subroutine HideIconBar[X]Variable iconBarButtons (category: Icon bar)A list of button numbers for each icon bar type[X]Variable iconBarType in workspace WPThe type of the current icon bar[X]Label ifon1 in subroutine LoadNormalFont[X]Label ifon2 in subroutine LoadNormalFont[X]Label ifon3 in subroutine LoadNormalFont[X]Variable languageIndex in workspace WPThe language that was chosen on the Start screen as an index into the various lookup tables[X]Variable lineImage (category: Drawing lines)Image data for the horizontal line, vertical line and block images[X]Label nadd1 in subroutine GetNameAddress[X]Variable nameBuffer0 in workspace Cartridge WRAMThe buffer for nametable 0 that gets sent to the PPU during VBlank[X]Variable nameBuffer1 in workspace Cartridge WRAMThe buffer for nametable 1 that gets sent to the PPU during VBlank[X]Variable numberOfPilots in workspace WPA flag to determine whether the game is configured for one or two pilots[X]Label pale1 in subroutine SetPaletteColours[X]Label pale2 in subroutine SetPaletteColours[X]Variable paletteColour2 in workspace ZPContains the colour to use for palette entry 2 in the current (non-space) view[X]Variable paletteColour3 in workspace ZPContains the colour to use for palette entry 3 in the current (non-space) view[X]Variable paletteForView (category: Drawing the screen)Palette numbers for each view[X]Variable pattBuffer0 in workspace Cartridge WRAMThe pattern buffer for bitplane 0 (1 bit per pixel) that gets sent to the PPU during VBlank[X]Variable pattBuffer1 in workspace Cartridge WRAMThe pattern buffer for bitplane 1 (1 bit per pixel) that gets sent to the PPU during VBlank[X]Variable pattSprite5 in workspace Sprite bufferPattern number for sprite 5[X]Variable pattSprite6 in workspace Sprite bufferPattern number for sprite 6[X]Variable pattSprite7 in workspace Sprite bufferPattern number for sprite 7[X]Variable pattSprite8 in workspace Sprite bufferPattern number for sprite 8[X]Label pbar1 in subroutine SetupIconBarPause[X]Label pbar2 in subroutine SetupIconBarPause[X]Label pbar3 in subroutine SetupIconBarPause[X]Label pbar4 in subroutine SetupIconBarPause[X]Label pbar5 in subroutine SetupIconBarPause[X]Variable picturePattern in workspace WPThe number of the first free pattern where commander and system images can be stored in the buffers[X]Label sbox1 in subroutine DrawSmallBox[X]Label sbox2 in subroutine DrawSmallBox[X]Variable screenFadedToBlack in workspace WPRecords whether the screen has been faded to black[X]Variable selectedSystemFlag in workspace WPFlags for the currently selected system[X]Variable systemPalettes (category: Universe)Palettes for the system images[X]Variable updatePaletteInNMI in workspace ZPA flag that controls whether to send the palette data from XX3 to the PPU during NMI[X]Variable viewAttrCount (category: Drawing the screen)The number of sets of view attributes in the viewAttrOffset table[X]Variable viewAttrOffset (category: Drawing the screen)Offset to the data for each of the 24 sets of view attributes[X]Variable viewAttributes0 (category: Drawing the screen)Packed view attribute data for attribute set 0[X]Variable viewAttributes1 (category: Drawing the screen)Packed view attribute data for attribute set 1[X]Variable viewAttributes10 (category: Drawing the screen)Packed view attribute data for attribute set 10[X]Variable viewAttributes11 (category: Drawing the screen)Packed view attribute data for attribute set 11[X]Variable viewAttributes12 (category: Drawing the screen)Packed view attribute data for attribute set 12[X]Variable viewAttributes13 (category: Drawing the screen)Packed view attribute data for attribute set 13[X]Variable viewAttributes14 (category: Drawing the screen)Packed view attribute data for attribute set 14[X]Variable viewAttributes15 (category: Drawing the screen)Packed view attribute data for attribute set 15[X]Variable viewAttributes16 (category: Drawing the screen)Packed view attribute data for attribute set 16[X]Variable viewAttributes17 (category: Drawing the screen)Packed view attribute data for attribute set 17[X]Variable viewAttributes18 (category: Drawing the screen)Packed view attribute data for attribute set 18[X]Variable viewAttributes19 (category: Drawing the screen)Packed view attribute data for attribute set 19[X]Variable viewAttributes2 (category: Drawing the screen)Packed view attribute data for attribute set 2[X]Variable viewAttributes20 (category: Drawing the screen)Packed view attribute data for attribute set 20[X]Variable viewAttributes21 (category: Drawing the screen)Packed view attribute data for attribute set 21[X]Variable viewAttributes22 (category: Drawing the screen)Packed view attribute data for attribute set 22[X]Variable viewAttributes23 (category: Drawing the screen)Packed view attribute data for attribute set 23[X]Variable viewAttributes3 (category: Drawing the screen)Packed view attribute data for attribute set 3[X]Variable viewAttributes4 (category: Drawing the screen)Packed view attribute data for attribute set 4[X]Variable viewAttributes5 (category: Drawing the screen)Packed view attribute data for attribute set 5[X]Variable viewAttributes6 (category: Drawing the screen)Packed view attribute data for attribute set 6[X]Variable viewAttributes7 (category: Drawing the screen)Packed view attribute data for attribute set 7[X]Variable viewAttributes8 (category: Drawing the screen)Packed view attribute data for attribute set 8[X]Variable viewAttributes9 (category: Drawing the screen)Packed view attribute data for attribute set 9[X]Variable viewAttributesHi (category: Drawing the screen)The high byte of the view attributes lookup table for each language[X]Variable viewAttributesLo (category: Drawing the screen)The low byte of the view attributes lookup table for each language[X]Variable viewAttributes_DE (category: Drawing the screen)The view attributes to use for each view type in German[X]Variable viewAttributes_EN (category: Drawing the screen)The view attributes to use for each view type in English[X]Variable viewAttributes_FR (category: Drawing the screen)The view attributes to use for each view type in French[X]Variable viewPalettes (category: Drawing the screen)The palettes to use for the different views[X]Variable visibleColour in workspace ZPContains the colour to use for pixels that are visible in palette 0, e.g. $2C for cyan[X]Label vpat1 in subroutine SetLinePatterns[X]Label vpat10 in subroutine SetLinePatterns[X]Label vpat2 in subroutine SetLinePatterns[X]Label vpat3 in subroutine SetLinePatterns[X]Label vpat4 in subroutine SetLinePatterns[X]Label vpat5 in subroutine SetLinePatterns[X]Label vpat6 in subroutine SetLinePatterns[X]Label vpat7 in subroutine SetLinePatterns[X]Label vpat8 in subroutine SetLinePatterns[X]Label vpat9 in subroutine SetLinePatterns[X]Variable xSprite5 in workspace Sprite bufferScreen x-coordinate for sprite 5[X]Variable xSprite6 in workspace Sprite bufferScreen x-coordinate for sprite 6[X]Variable xSprite7 in workspace Sprite bufferScreen x-coordinate for sprite 7[X]Variable xSprite8 in workspace Sprite bufferScreen x-coordinate for sprite 8[X]Variable ySprite5 in workspace Sprite bufferScreen y-coordinate for sprite 5[X]Variable ySprite6 in workspace Sprite bufferScreen y-coordinate for sprite 6[X]Variable ySprite7 in workspace Sprite bufferScreen y-coordinate for sprite 7[X]Variable ySprite8 in workspace Sprite bufferScreen y-coordinate for sprite 8[X]Variable ySprite9 in workspace Sprite bufferScreen y-coordinate for sprite 9