John Russell Ernest Posted May 2, 2012 Share Posted May 2, 2012 I'm just getting started learning 6502, and have 2 questions I need some help on. I'm using the Yars' Revenge source code and the 2600 Programming Guide to learn right now. 1st question: Here's a few lines in the code that confuse me: .setYarColorValues lda #DK_BLUE+12 sta yarColor ; save color for Yar sta COLUP1 ; set color for Yar sprite lda #BROWN+14 sta reservedYarColor lda #<player1Score sta playerScorePtr lda #<Qotile sta qotileGraphicPtrs lda #>Qotile sta qotileGraphicPtrs+1 lda #NEUTRAL_ZONE_MASK sta neutralZoneMask sta reserveNeutralZoneMask ldx #4 What do the > / < mean for lda and when is it appropriate to use them? I know the # is immediate addressing. The qotile in this case is the qotile graphic: Qotile .byte $00 ; |........| .byte $0F ; |....XXXX| .byte $1B ; |...XX.XX| .byte $33 ; |..XX..XX| .byte $E3 ; |XXX...XX| .byte $FF ; |XXXXXXXX| .byte $E3 ; |XXX...XX| .byte $33 ; |..XX..XX| .byte $1B ; |...XX.XX| .byte $0F ; |....XXXX| .byte $00 ; |........| 2nd question: On conditional branch statements (bmi, bcc, etc) does the code continue where it was before after execution of the branch (just making sure I understand branching vs. jumping)? Example: StartSwirlAnimation IF COMPILE_VERSION = NTSC lda #>SwirlSprites sta qotileGraphicPtrs+1 ENDIF lda #<SwirlSprites sta qotileGraphicPtrs lda #SWIRL_TRIPLE_FREQ bit gameState beq .jmpToCheckUpdateQotileMissile; branch if Swirl not firing at triple freq lda gameTimer ; get current game timer ror ; shift D0 to carry bcc .jmpToCheckUpdateQotileMissile; branch if this is an even frame ror bcs CheckToLaunchSwirl ; branch if D1 of game timer set .jmpToCheckUpdateQotileMissile jmp .checkToUpdateQotileMissile On the above bcc I bolded, does execution continue to the next ror on the line below after .jmpToCheckUpdateQotileMissile is called? Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted May 2, 2012 Share Posted May 2, 2012 (edited) 1. The < and > extract a specific byte of a 2-byte value. Using an example 2-byte value of $FF10 < extracts the LSB (Least Significant Byte), or $10 > extracts the MSB (Most Significant Byte), or $FF 2. The difference between Branching and Jumping is that Branching is conditional - the branch may, or may not, be taken depending on the condition specified by the 2 letters after the B (BCC = branch if carry clear, BCS = branch if carry set, BPL = branch if number is positive, etc). If the branch is taken, it's a one-way trip, just like it is for Jumping. JSR (Jump SubRoutine) is the command that returns to continue the following code. The return is triggered by RTS (ReTurn from Subroutine). Edited May 2, 2012 by SpiceWare 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.