Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .inesprg 2 ; 2x 16KB PRG code
- .ineschr 1 ; 1x 8KB CHR data
- .inesmap 0 ; mapper 0 = NROM, no bank swapping
- .inesmir 1 ; background mirroring
- ;;;;;;;;;;;;;;;
- .include "zeropage.asm"
- STATELOADTITLE = $00
- STATETITLE = $01
- STATELOADPLAYING = $02
- STATEPLAYING = $03
- STATELOADGAMEOVER = $04
- STATEGAMEOVER = $05
- STATELOADCREDITS = $06
- STATECREDITS = $07
- .bank 0
- .org $8000
- .include "famitone.asm"
- .include "soundeffects.asm"
- PlaySoundEffect:
- LDA PlaySound
- CMP #$01
- BNE .End
- LDA SoundEffect
- LDX #FT_SFX_CH1
- JSR FamiToneSfxStart
- LDA #$00
- STA PlaySound
- .End:
- RTS
- TitleLoadSprites:
- LDX #$00 ; start at 0
- TitleLoadSpritesLoop:
- LDA Titlesprites, x ; load data from address (sprites + x)
- STA $0200, x ; store into RAM address ($0200 + x)
- INX ; X = X + 1
- CPX #$04 ; Compare X to hex $20, decimal 32
- BNE TitleLoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
- ; if compare was equal to 32, keep going down
- RTS
- Titlesprites:
- ;vert tile attr horiz
- .db $50, $38, $01, $20 ;sprite 0
- Titlebackground:
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9 ;;row 1
- .db $aa,$ab,$ac,$ad,$ae,$af,$d0,$d1,$d2,$d3,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9 ;;row 1
- .db $ba,$bb,$bc,$bd,$be,$bf,$e0,$e1,$e2,$e3,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$c0,$c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9 ;;row 1
- .db $ca,$cb,$cc,$cd,$ce,$cf,$f0,$f1,$f2,$f3,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all skytop
- .db $25,$25,$25,$25,$25,$0E,$0A,$1C,$22,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$16,$0E,$0D,$12,$1E,$16,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$11,$0A,$1B,$0D,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$0C,$1B,$0E,$0D,$12,$1D,$1C,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all skytop
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$19,$1b,$0E,$1C,$1C,$25 ;;row 1
- .db $1C,$1D,$0A,$1B,$1D,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all skytop
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$26,$02,$48,$01,$05,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- Titlepalette:
- .db $0f,$29,$18,$2D, $0f,$29,$12,$38, $0f,$38,$29,$2D, $0f,$04,$18,$29 ;;background palette
- .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
- Titleattribute:
- .db %00000000, %01010101, %01010101, %01010101, %01010101, %01010101, %01010101, %00000000
- .db %00000000, %01010101, %01010101, %01010101, %01010101, %01010101, %01010101, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- LoadGameOverPalettes:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$3F
- STA $2006 ; write the high byte of $3F00 address
- LDA #$00
- STA $2006 ; write the low byte of $3F00 address
- LDX #$00 ; start out at 0
- LoadGameOverPalettesLoop:
- LDA GameOverPalette, x ; load data from address (palette + the value in x)
- ; 1st time through loop it will load palette+0
- ; 2nd time through loop it will load palette+1
- ; 3rd time through loop it will load palette+2
- ; etc
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
- BNE LoadGameOverPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
- ; if compare was equal to 32, keep going down
- RTS
- DrawWinScreen:
- LDA WinFlag ;WinFlag is set to #$01 when the game is won or lost.
- CMP #$01
- BNE .End
- LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
- LDA WinLose
- CMP #$02
- BEQ .Lose
- LDA CurrentRow ;CurrentRow is set to #$08 if the player doesn't guess correctly after 7 tries (I think).
- CMP #$07
- BEQ .Lose
- ;;draw winning tiles
- LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
- LDA $2002
- LDA #$20 ;we are drawing to the background address $2153
- STA $2006
- LDA #$6F
- STA $2006
- .Loop:
- LDA WinTiles,x ;this will look at the tiles defined in the data labeled "WinTiles."
- STA $2007
- INX
- CPX #$08 ;scroll through this loop #$07 times, to get all letters.
- BNE .Loop
- RTS
- .Lose:
- LDA $2002
- LDA #$20 ;we are drawing to the background address $2153
- STA $2006
- LDA #$6F
- STA $2006
- .Loop2:
- LDA LoseTiles,x ;this will look at the tiles defined in the data labeled "WinTiles."
- STA $2007
- INX
- CPX #$09 ;scroll through this loop #$07 times, to get all letters.
- BNE .Loop2
- RTS
- ;;draw losing tiles
- RTS
- .End:
- ;;skip all this.
- RTS
- DrawWinScreen2:
- LDA WinFlag ;WinFlag is set to #$01 when the game is won or lost.
- CMP #$01
- BNE .End
- LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
- LDA WinLose
- CMP #$02
- BEQ .Lose
- LDX #$00
- LDA CurrentRow ;CurrentRow is set to #$08 if the player doesn't guess correctly after 7 tries (I think).
- CMP #$07
- BEQ .Lose
- ;;draw winning tiles
- LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
- LDA $2002
- LDA #$20 ;we are drawing to the background address $2153
- STA $2006
- LDA #$8F
- STA $2006
- .Loop:
- LDA WinTiles2,x ;this will look at the tiles defined in the data labeled "WinTiles."
- STA $2007
- INX
- CPX #$08 ;scroll through this loop #$07 times, to get all letters.
- BNE .Loop
- RTS
- .Lose:
- LDA $2002
- LDA #$20 ;we are drawing to the background address $2153
- STA $2006
- LDA #$8F
- STA $2006
- .Loop2:
- LDA LoseTiles2,x ;this will look at the tiles defined in the data labeled "WinTiles."
- STA $2007
- INX
- CPX #$09 ;scroll through this loop #$07 times, to get all letters.
- BNE .Loop2
- RTS
- ;;draw losing tiles
- RTS
- .End:
- ;;skip all this.
- RTS
- DrawWinScreen3:
- LDA WinFlag ;WinFlag is set to #$01 when the game is won or lost.
- CMP #$01
- BNE .End
- LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
- LDA WinLose
- CMP #$02
- BEQ .Lose
- LDX #$00
- LDA CurrentRow ;CurrentRow is set to #$08 if the player doesn't guess correctly after 7 tries (I think).
- CMP #$07
- BEQ .Lose
- ;;draw winning tiles
- LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
- LDA $2002
- LDA #$20 ;we are drawing to the background address $2153
- STA $2006
- LDA #$AF
- STA $2006
- .Loop:
- LDA WinTiles3,x ;this will look at the tiles defined in the data labeled "WinTiles."
- STA $2007
- INX
- CPX #$08 ;scroll through this loop #$07 times, to get all letters.
- BNE .Loop
- RTS
- .Lose:
- LDA $2002
- LDA #$20 ;we are drawing to the background address $2153
- STA $2006
- LDA #$AF
- STA $2006
- .Loop2:
- LDA LoseTiles3,x ;this will look at the tiles defined in the data labeled "WinTiles."
- STA $2007
- INX
- CPX #$09 ;scroll through this loop #$07 times, to get all letters.
- BNE .Loop2
- RTS
- ;;draw losing tiles
- RTS
- .End:
- ;;skip all this.
- RTS
- WinTiles: ;this is the tile data for the letters Y,O,U,BLANK,W,I,N
- .db $77,$78,$79,$7A,$7B,$7C,$7D,$7E ;you win
- LoseTiles: ;this is the tile data for the letters Y,O,U,BLANK,L,O,S,E
- .db $D4,$D5,$4C,$4D,$D6,$D7,$D8,$D9,$7E ;you lose
- WinTiles2: ;this is the tile data for the letters Y,O,U,BLANK,W,I,N
- .db $87,$88,$89,$8A,$8B,$8C,$8D,$8E ;you win
- LoseTiles2: ;this is the tile data for the letters Y,O,U,BLANK,L,O,S,E
- .db $E4,$E5,$5C,$5D,$E6,$E7,$E8,$E9,$8E ;you lose
- WinTiles3: ;this is the tile data for the letters Y,O,U,BLANK,W,I,N
- .db $97,$98,$99,$9A,$9B,$9C,$9D,$9E ;you win
- LoseTiles3: ;this is the tile data for the letters Y,O,U,BLANK,L,O,S,E
- .db $F4,$F5,$6C,$6D,$F6,$F7,$F8,$F9,$9E ;you lose
- LoadGameOverNametable:
- LDA $2002
- LDA #$20
- STA $2006
- LDA #$00
- STA $2006
- LDA #low(GameOverBackground)
- STA AddrLow ; load low bytes of background data
- LDA #high(GameOverBackground)
- STA AddrHigh ; load high bytes of background data
- LDX #$04 ; Loop X 4 times
- LDY #$00 ; Loop Y 256 times
- LoadGameOverBackgroundsLoop:
- LDA [AddrLow],y
- STA $2007
- INY
- BNE LoadGameOverBackgroundsLoop
- ; Outer loop
- INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
- DEX ; one chunk done so X = X - 1.
- BNE LoadGameOverBackgroundsLoop ; if X isn't zero, do again
- RTS
- LoadGameOverAttribute:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$23
- STA $2006 ; write the high byte of $23C0 address
- LDA #$C0
- STA $2006 ; write the low byte of $23C0 address
- LDX #$00 ; start out at 0
- LoadGameOverAttributeLoop:
- LDA GameOverAttribute, x ; load data from address (attribute + the value in x)
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
- BNE LoadGameOverAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
- ; if compare was equal to 128, keep going down
- RTS
- GameOverPalette:
- .db $0f,$29,$18,$2D, $0f,$06,$18,$12, $0f,$38,$18,$1A, $0f,$04,$18,$29 ;;background palette
- .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
- ;;as you can see, I am pulling from all three palettes in the attribute table. some sections are using
- ;;palette %01, some are using palette %10, and some are using palette %11.
- ;;remember, these are binary numbers. %01=1, %10=2, %11=3.
- GameOverAttribute:
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %01000000, %10010000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00001000, %00001111, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .bank 1
- .org $A000
- SeventhRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$23
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$09 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$23 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$29
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP .Palette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP .Palette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP .Palette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- .Palette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$F2 ;;Load lo byte of attribute location
- STA $2006
- LDA #%00000101 ;;Store new attribute data (From palette 1)
- STA $2007
- LDA #%00000001 ;;Store this info in a variable
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA #%00000001
- STA $2007
- LDA #%00000001
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA Palette2 ;;this circle uses two different attribute locations, so it's more complicated to code.
- ORA #%00000100 ;;it uses part of Circle 2's attribute location.
- STA $2007
- LDA #$23
- STA $2006
- LDA #$F4
- STA $2006
- LDA #%00000001
- STA $2007
- LDA #%00000001
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F4
- STA $2006
- LDA Palette3 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
- ORA #%00000100
- STA $2007
- LDA #%00000001
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette2: ;;same as previous code, except the player is selecting a color using the second palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F2
- STA $2006
- LDA #%00001010
- STA $2007
- LDA #%00000010
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette2:
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA #%00000010
- STA $2007
- LDA #%00000010
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2:
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA Palette2
- ORA #%00001000
- STA $2007
- LDA #$23
- STA $2006
- LDA #$F4
- STA $2006
- LDA #%00000010
- STA $2007
- LDA #%00000010
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2:
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F4
- STA $2006
- LDA Palette3
- ORA #%00001000
- STA $2007
- LDA #%00000010
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F2
- STA $2006
- LDA #%00001111
- STA $2007
- LDA #%00000011
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette3:
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA #%00000011
- STA $2007
- LDA #%00000011
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3:
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA Palette2
- ORA #%00001100
- STA $2007
- LDA #$23
- STA $2006
- LDA #$F4
- STA $2006
- LDA #%00000011
- STA $2007
- LDA #%00000011
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3:
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F4
- STA $2006
- LDA Palette3
- ORA #%00001100
- STA $2007
- LDA #%00000011
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$23
- STA $2006
- TXA
- CLC
- ADC #$09
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$23 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$29
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP .Palette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP .Palette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP .Palette3
- .Done:
- RTS
- .Palette1:
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F2
- STA $2006
- LDA #%00000101
- STA $2007
- LDA #%00000001
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette1:
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA #%00000001
- STA $2007
- LDA #%00000001
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1:
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA Palette2
- ORA #%00000100
- STA $2007
- LDA #$23
- STA $2006
- LDA #$F4
- STA $2006
- LDA #%00000001
- STA $2007
- LDA #%00000001
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1:
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$F4
- STA $2006
- LDA Palette3
- ORA #%00000100
- STA $2007
- LDA #%00000001
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette2:
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F2
- STA $2006
- LDA #%00001010
- STA $2007
- LDA #%00000010
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette2:
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA #%00000010
- STA $2007
- LDA #%00000010
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2:
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA Palette2
- ORA #%00001000
- STA $2007
- LDA #$23
- STA $2006
- LDA #$F4
- STA $2006
- LDA #%00000010
- STA $2007
- LDA #%00000010
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2:
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$F4
- STA $2006
- LDA Palette3
- ORA #%00001000
- STA $2007
- LDA #%00000010
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row.
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette3:
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F2
- STA $2006
- LDA #%00001111
- STA $2007
- LDA #%00000011
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette3:
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA #%00000011
- STA $2007
- LDA #%00000011
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3:
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F3
- STA $2006
- LDA Palette2
- ORA #%00001100
- STA $2007
- LDA #$23
- STA $2006
- LDA #$F4
- STA $2006
- LDA #%00000011
- STA $2007
- LDA #%00000011
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3:
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$F4
- STA $2006
- LDA Palette3
- ORA #%00001100
- STA $2007
- LDA #%00000011
- STA Palette4
- LDA #$00 ;;reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- SixthRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite2 ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite2
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite2
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite2
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$22
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$A9 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$22 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$C9
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP .Palette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP .Palette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP .Palette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- .Palette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$EA ;;Load lo byte of attribute location
- STA $2006
- LDA #%01010101 ;;Store new attribute data (From palette 1)
- STA $2007
- LDA #%01010101 ;;Store this info in a variable
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA #%00010001
- STA $2007
- LDA #%00010001
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA Palette2 ;;this circle uses two different attribute locations, so it's more complicated to code.
- ORA #%01000100 ;;it uses part of Circle 2's attribute location.
- STA $2007
- LDA #$23
- STA $2006
- LDA #$EC
- STA $2006
- LDA #%00010001
- STA $2007
- LDA #%00010001
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EC
- STA $2006
- LDA Palette3 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
- ORA #%01000100
- STA $2007
- LDA #%00000001
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette2: ;;same as previous code, except the player is selecting a color using the second palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EA
- STA $2006
- LDA #%10101010
- STA $2007
- LDA #%10101010
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette2:
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA #%00100010
- STA $2007
- LDA #%00100010
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2:
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA Palette2
- ORA #%10001000
- STA $2007
- LDA #$23
- STA $2006
- LDA #$EC
- STA $2006
- LDA #%00100010
- STA $2007
- LDA #%00100010
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2:
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EC
- STA $2006
- LDA Palette3
- ORA #%10001000
- STA $2007
- LDA #%00000010
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EA
- STA $2006
- LDA #%11111111
- STA $2007
- LDA #%11111111
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette3:
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA #%00110011
- STA $2007
- LDA #%00110011
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3:
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA Palette2
- ORA #%11001100
- STA $2007
- LDA #$23
- STA $2006
- LDA #$EC
- STA $2006
- LDA #%00110011
- STA $2007
- LDA #%00110011
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3:
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EC
- STA $2006
- LDA Palette3
- ORA #%11001100
- STA $2007
- LDA #%00000011
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite2: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$22
- STA $2006
- TXA
- CLC
- ADC #$A9
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$22 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$C9
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP .Palette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP .Palette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP .Palette3
- .Done:
- RTS
- .Palette1:
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EA
- STA $2006
- LDA #%01010101
- STA $2007
- LDA #%01010101
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette1:
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA #%00010001
- STA $2007
- LDA #%00010001
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1:
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA Palette2
- ORA #%01000100
- STA $2007
- LDA #$23
- STA $2006
- LDA #$EC
- STA $2006
- LDA #%00010001
- STA $2007
- LDA #%00010001
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1:
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$EC
- STA $2006
- LDA Palette3
- ORA #%01000100
- STA $2007
- LDA #%00000001
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette2:
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EA
- STA $2006
- LDA #%10101010
- STA $2007
- LDA #%10101010
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette2:
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA #%00100010
- STA $2007
- LDA #%00100010
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2:
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA Palette2
- ORA #%10001000
- STA $2007
- LDA #$23
- STA $2006
- LDA #$EC
- STA $2006
- LDA #%00100010
- STA $2007
- LDA #%00100010
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2:
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$EC
- STA $2006
- LDA Palette3
- ORA #%10001000
- STA $2007
- LDA #%10000010
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row.
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- .Palette3:
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EA
- STA $2006
- LDA #%11111111
- STA $2007
- LDA #%11111111
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette3:
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA #%00110011
- STA $2007
- LDA #%00110011
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3:
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EB
- STA $2006
- LDA Palette2
- ORA #%11001100
- STA $2007
- LDA #$23
- STA $2006
- LDA #$EC
- STA $2006
- LDA #%00110011
- STA $2007
- LDA #%00110011
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3:
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$EC
- STA $2006
- LDA Palette3
- ORA #%11001100
- STA $2007
- LDA #%00000011
- STA Palette4
- LDA #$00 ;;reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FifthRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite3 ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite3
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite3
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite3
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$22
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$49 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$22 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$69
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP FifthRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP FifthRowPalette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP FifthRowPalette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- FifthRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$E2 ;;Load lo byte of attribute location
- STA $2006
- LDA #%01010000 ;;Store new attribute data (From palette 1)
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00010000
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA Palette2 ;;this circle uses two different attribute locations, so it's more complicated to code.
- ORA #%01000000 ;;it uses part of Circle 2's attribute location.
- STA $2007
- STA Palette3
- STA Palette3Dash1
- LDA #$23
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00010000
- STA $2007
- STA Palette3Dash2
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%01000000
- ORA Palette3Dash2
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FifthRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$E2
- STA $2006
- LDA #%10100000
- STA $2007
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette2:
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00100000
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2:
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA Palette2
- ORA #%10000000
- STA $2007
- STA Palette3
- STA Palette3Dash1
- LDA #$23
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00100000
- STA $2007
- STA Palette3Dash2
- INC CurrentColor
- RTS
- .FourthPalette2:
- LDA $2002
- LDA #$23 ;;change attribute color to second palette
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%10000000
- ORA Palette3Dash2
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FifthRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$E2
- STA $2006
- LDA #%11110000
- STA $2007
- STA Palette1
- INC CurrentColor
- RTS
- .SecondPalette3:
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00110000
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3:
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA Palette2
- ORA #%11000000
- STA $2007
- STA Palette3
- STA Palette3Dash1
- LDA #$23
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00110000
- STA $2007
- STA Palette3Dash2
- INC CurrentColor
- RTS
- .FourthPalette3:
- LDA $2002
- LDA #$23 ;;change attribute color to third palette
- STA $2006
- LDA #$E4
- STA $2006
- LDA Palette3
- LDA #%11000000
- ORA Palette3Dash2
- STA $2007
- STA Palette4
- LDA #$00 ;;reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite3: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$22
- STA $2006
- TXA
- CLC
- ADC #$49
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$22 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$69
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP FifthRowPalette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP FifthRowPalette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP FifthRowPalette3
- .Done:
- RTS
- FourthRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite4 ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite4
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite4
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite4
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$21
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$E9 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$22 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$09
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP FourthRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP FourthRowPalette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP FourthRowPalette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- FourthRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$E2 ;;Load lo byte of attribute location
- STA $2006
- LDA Palette1
- ORA #%00000101 ;;Store new attribute data (From palette 1)
- STA $2007
- LDA #$23
- STA $2006
- LDA #$DA
- STA $2006
- LDA #%01010000
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00000001
- ORA Palette2
- ORA Palette3Dash1
- STA $2007
- STA Palette2Bottom
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00010000
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00000100
- ORA Palette2Bottom
- ORA Palette3Dash1
- STA $2007
- STA Palette3
- LDA #$23
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00000001
- ORA Palette3Dash2
- ORA Palette4
- STA $2007
- STA Palette3Dash2
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%01000000
- ORA Palette2
- STA $2007
- STA Palette3Dash1
- LDA #$23
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00010000
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00000100 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
- ORA Palette4
- ORA Palette3Dash2
- STA $2007
- LDA #$23
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%01000000
- ORA Palette3
- STA $2007
- STA Palette4Dash2
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FourthRowPalette2: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$E2 ;;Load lo byte of attribute location
- STA $2006
- LDA Palette1
- ORA #%00001010 ;;Store new attribute data (From palette 1)
- STA $2007
- LDA #$23
- STA $2006
- LDA #$DA
- STA $2006
- LDA #%10100000
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00000010
- ORA Palette2
- ORA Palette3Dash1
- STA $2007
- STA Palette2Bottom
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00100000
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00001000
- ORA Palette2Bottom
- ORA Palette3Dash1
- STA $2007
- STA Palette3
- LDA #$23
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00000010
- ORA Palette3Dash2
- ORA Palette4
- STA $2007
- STA Palette3Dash2
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%10000000
- ORA Palette2
- STA $2007
- STA Palette3Dash1
- LDA #$23
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00100000
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00001000 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
- ORA Palette4
- ORA Palette3Dash2
- STA $2007
- LDA #$23
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%10000000
- ORA Palette3
- STA $2007
- STA Palette4Dash2
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FourthRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$E2 ;;Load lo byte of attribute location
- STA $2006
- LDA Palette1
- ORA #%00001111 ;;Store new attribute data (From palette 1)
- STA $2007
- LDA #$23
- STA $2006
- LDA #$DA
- STA $2006
- LDA #%11110000
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00000011
- ORA Palette2
- ORA Palette3Dash1
- STA $2007
- STA Palette2Bottom
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00110000
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E3
- STA $2006
- LDA #%00001100
- ORA Palette2Bottom
- ORA Palette3Dash1
- STA $2007
- STA Palette3
- LDA #$23
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00000011
- ORA Palette3Dash2
- ORA Palette4
- STA $2007
- STA Palette3Dash2
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%11000000
- ORA Palette2
- STA $2007
- STA Palette3Dash1
- LDA #$23
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00110000
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$E4
- STA $2006
- LDA #%00001100 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
- ORA Palette4
- ORA Palette3Dash2
- STA $2007
- LDA #$23
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%11000000
- ORA Palette3
- STA $2007
- STA Palette4Dash2
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite4: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$21
- STA $2006
- TXA
- CLC
- ADC #$E9
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$22 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$09
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP FourthRowPalette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP FourthRowPalette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP FourthRowPalette3
- .Done:
- RTS
- ThirdRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite5 ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite5
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite5
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite5
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$21
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$89 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$21 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$A9
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP ThirdRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP ThirdRowPalette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP ThirdRowPalette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- ThirdRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$DA ;;Load lo byte of attribute location
- STA $2006
- LDA #%00000101 ;;Store new attribute data (From palette 1)
- ORA Palette1
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00000001
- ORA Palette2
- ORA Palette3Dash1
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00000100
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00000001
- ORA Palette4Dash2
- ; ORA Palette2
- STA $2007
- STA Palette3
- ; STA Palette3Dash1
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00000100
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- ThirdRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$DA ;;Load lo byte of attribute location
- STA $2006
- LDA #%00001010 ;;Store new attribute data (From palette 1)
- ORA Palette1
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00000010
- ORA Palette2
- ORA Palette3Dash1
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00001000
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00000010
- ORA Palette4Dash2
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00001000
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- ThirdRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$DA ;;Load lo byte of attribute location
- STA $2006
- LDA #%00001111 ;;Store new attribute data (From palette 1)
- ORA Palette1
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00000011
- ORA Palette2
- ORA Palette3Dash1
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$DB
- STA $2006
- LDA #%00001100
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00000011
- ORA Palette4Dash2
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$DC
- STA $2006
- LDA #%00001100
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite5: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$21
- STA $2006
- TXA
- CLC
- ADC #$89
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$21 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$A9
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP ThirdRowPalette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP ThirdRowPalette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP ThirdRowPalette3
- .Done:
- RTS
- SecondRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite6 ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite6
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite6
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite6
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$21
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$29 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$21 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$49
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP SecondRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP SecondRowPalette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP SecondRowPalette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- SecondRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$D2 ;;Load lo byte of attribute location
- STA $2006
- LDA #%01010101 ;;Store new attribute data (From palette 1)
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D3
- STA $2006
- LDA #%00010001
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$D3
- STA $2006
- LDA #%01000100
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D4
- STA $2006
- LDA #%00010001
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D4
- STA $2006
- LDA #%01000100
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- SecondRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$D2 ;;Load lo byte of attribute location
- STA $2006
- LDA #%10101010 ;;Store new attribute data (From palette 1)
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D3
- STA $2006
- LDA #%00100010
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$D3
- STA $2006
- LDA #%10001000
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D4
- STA $2006
- LDA #%00100010
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D4
- STA $2006
- LDA #%10001000
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- SecondRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$D2 ;;Load lo byte of attribute location
- STA $2006
- LDA #%11111111 ;;Store new attribute data (From palette 1)
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D3
- STA $2006
- LDA #%00110011
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$D3
- STA $2006
- LDA #%11001100
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D4
- STA $2006
- LDA #%00110011
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$D4
- STA $2006
- LDA #%11001100
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite6: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$21
- STA $2006
- TXA
- CLC
- ADC #$29
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$21 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$49
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP SecondRowPalette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP SecondRowPalette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP SecondRowPalette3
- .Done:
- RTS
- FirstRowGuesses:
- ;;four possible color positions per row
- LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
- CMP #$00
- BNE .1
- LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
- STA Choice1
- ;;first spot
- LDX #$00 ;;Always make sure X is #$00 to start the loop.
- .Loop0:
- LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
- INX
- CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
- BNE .Loop0
- JMP PlaceSecondSprite7 ;;If not, jump to PlaceSecondSprite
- .1:
- CMP #$01
- BNE .2
- ;;second spot
- LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
- STA Choice2
- LDX #$00
- .Loop1:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop1
- JMP PlaceSecondSprite7
- .2:
- CMP #$02
- BNE .3
- ;;third spot
- LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
- STA Choice3
- LDX #$00
- .Loop2:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop2
- JMP PlaceSecondSprite7
- .3:
- CMP #$03
- BNE .End
- ;;fourth spot
- LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
- STA Choice4
- LDX #$00
- .Loop3:
- LDA ColorPosition
- CMP FirstSpriteColors,x
- BEQ .PlaceFirstSprite
- INX
- CPX #$03
- BNE .Loop3
- JMP PlaceSecondSprite7
- .End:
- RTS
- .PlaceFirstSprite:
- LDX #$00 ;;make sure X is reset to #$00 when starting this loop
- LDY CurrentColor ;;store CurrentColor as Y
- .PreLoop:
- CPY #$00 ;;if Y is $00 from the start, branch to .Continue
- BEQ .Continue
- DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
- INX ;;of the background tiles we are replacing. The color locations are offset by $03.
- INX
- INX
- JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$20
- STA $2006 ;;Hi byte of background tile is $23
- TXA
- CLC
- ADC #$C9 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
- STA $2006 ;;of the bottom row of circles is $2309.
- LDA #$61 ;;Store first two tiles of correct color.
- STA $2007
- LDA #$62
- STA $2007
- LDA #$20 ;;Store bottom two tiles of correct color.
- STA $2006
- TXA
- CLC
- ADC #$E9
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$00
- BNE .Try2
- JMP FirstRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
- .Try2:
- CMP #$02
- BNE .Try3
- JMP FirstRowPalette2 ;;if it's ColorPosition 2, use Palette2
- .Try3:
- CMP #$04
- BNE .Done
- JMP FirstRowPalette3 ;;if it's ColorPosition 4, use Palette3
- .Done:
- RTS
- FirstRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette1
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$CA ;;Load lo byte of attribute location
- STA $2006
- LDA #%01010000 ;;Store new attribute data (From palette 1)
- ORA Answer1Attr
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette1
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00010000
- ORA Answer2Attr
- ORA Answer3Attr1
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette1
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%01000000
- ORA Palette2
- ORA Answer3Attr1
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00010000
- ORA Answer3Attr2
- ORA Answer4Attr
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%01000000
- ORA Palette3
- ORA Answer4Attr
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FirstRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette2
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$CA ;;Load lo byte of attribute location
- STA $2006
- LDA #%10100000 ;;Store new attribute data (From palette 1)
- ORA Answer1Attr
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette2
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00100000
- ORA Answer2Attr
- ORA Answer3Attr1
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette2
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%10000000
- ORA Palette2
- ORA Answer3Attr1
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00100000
- ORA Answer3Attr2
- ORA Answer4Attr
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%10000000
- ORA Answer4Attr
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- FirstRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
- LDA CurrentColor
- CMP #$00
- BNE .SecondPalette3
- LDA $2002 ;;Load PPU for writing
- LDA #$23 ;;Load hi byte of attribute location
- STA $2006
- LDA #$CA ;;Load lo byte of attribute location
- STA $2006
- LDA #%11110000 ;;Store new attribute data (From palette 1)
- ORA Answer1Attr
- STA $2007
- STA Palette1
- INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
- RTS
- .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
- CMP #$01
- BNE .ThirdPalette3
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00110000
- ORA Answer3Attr1
- ORA Answer2Attr
- STA $2007
- STA Palette2
- INC CurrentColor
- RTS
- .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
- CMP #$02
- BNE .FourthPalette3
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%11000000
- ORA Answer3Attr1
- ORA Palette2
- STA $2007
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00110000
- STA Answer3Attr2
- ORA Answer4Attr
- STA $2007
- STA Palette3
- INC CurrentColor
- RTS
- .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
- LDA $2002
- LDA #$23 ;;change attribute color to first palette
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%11000000
- ORA Answer4Attr
- ORA Palette3
- STA $2007
- STA Palette4
- LDA #$00 ;;Reset CurrentColor for next row
- STA CurrentColor
- LDA #$01
- STA Checking
- ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
- RTS
- PlaceSecondSprite7: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
- LDX #$00 ;;This uses background tiles #65-#68.
- LDY CurrentColor
- .PreLoop:
- CPY #$00
- BEQ .Continue
- DEY
- INX
- INX
- INX
- JMP .PreLoop
- .Continue:
- LDA $2002 ;;place top half of colored circle
- LDA #$20
- STA $2006
- TXA
- CLC
- ADC #$C9
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$20 ;;place bottom half of colored circle
- STA $2006
- TXA
- CLC
- ADC #$E9
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- ;;ColorPosition is the position in the select your color area
- ;;CurrentColor is the current circle in the big gameboard
- LDA ColorPosition ;;change attribute color to correct palette
- CMP #$01
- BNE .Try2
- JMP FirstRowPalette1
- .Try2:
- CMP #$03
- BNE .Try3
- JMP FirstRowPalette2
- .Try3:
- CMP #$05
- BNE .Done
- JMP FirstRowPalette3
- .Done:
- RTS
- FirstSpriteColors:
- .db $00,$02,$04
- GameOverBackground:
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$49,$4a,$4B,$4C,$4D,$75,$76,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$59,$5A,$5B,$5C,$5D,$85,$86,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$69,$6A,$6B,$6C,$6D,$95,$96,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .bank 2
- .org $C000
- RESET:
- SEI ; disable IRQs
- CLD ; disable decimal mode
- LDX #$40
- STX $4017 ; disable APU frame IRQ
- LDX #$FF
- TXS ; Set up stack
- INX ; now X = 0
- STX $2000 ; disable NMI
- STX $2001 ; disable rendering
- STX $4010 ; disable DMC IRQs
- vblankwait1: ; First wait for vblank to make sure PPU is ready
- BIT $2002
- BPL vblankwait1
- clrmem:
- LDA #$00
- STA $0000, x
- STA $0100, x
- STA $0300, x
- STA $0400, x
- STA $0500, x
- STA $0600, x
- STA $0700, x
- LDA #$FE
- STA $0200, x
- INX
- BNE clrmem
- vblankwait2: ; Second wait for vblank, PPU is ready after this
- BIT $2002
- BPL vblankwait2
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;starting variables;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- JSR FamiToneInit
- LDX #LOW(sounds)
- LDY #HIGH(sounds)
- JSR FamiToneSfxInit
- LDA #STATELOADTITLE
- STA gamestate
- LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
- STA $2000
- LDA #%00011110 ; enable sprites, enable background, no clipping on left side
- STA $2001
- STA soft2001
- Forever:
- INC RandomLow
- BNE SeedComplete
- INC RandomHigh
- SeedComplete:
- JMP Forever ;jump back to Forever, infinite loop, waiting for NMI
- NMI:
- LDA #$00
- STA $2003 ; set the low byte (00) of the RAM address
- LDA #$02
- STA $4014 ; set the high byte (02) of the RAM address, start the transfer
- JSR LatchController
- ; JSR DrawWinScreen
- ;;This is the PPU clean up section, so rendering the next frame starts properly.
- LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
- STA $2000
- LDA soft2001 ; enable sprites, enable background, no clipping on left side
- STA $2001
- LDA #$00 ;;tell the ppu there is no background scrolling
- STA $2005
- STA $2005
- GameEngine:
- LDA gamestate
- CMP #STATELOADTITLE
- BNE NotLoadTitle
- JMP EngineLoadTitle
- NotLoadTitle:
- CMP #STATETITLE
- BNE NotTitle
- JMP EngineTitle
- NotTitle:
- CMP #STATELOADPLAYING
- BNE NotLoadPlaying
- JMP EngineLoadPlaying
- NotLoadPlaying:
- CMP #STATEPLAYING
- BNE NotPlaying
- JMP EnginePlaying
- NotPlaying:
- CMP #STATELOADGAMEOVER
- BNE NotLoadGameOver
- JMP LoadGameOver
- NotLoadGameOver:
- CMP #STATEGAMEOVER
- BNE CreditsLoad
- JMP GameOverEngine
- CreditsLoad:
- CMP #STATELOADCREDITS
- BNE NotCreditsLoad
- JMP LoadCredits
- NotCreditsLoad:
- CMP #STATECREDITS
- BNE GameEngineDone
- JMP CreditsEngine
- GameEngineDone:
- JSR FamiToneUpdate
- RTI ; return from interrupt
- CreditsEngine:
- JMP GameEngineDone
- LoadCredits:
- LDA #$00
- STA $2000
- STA $2001
- LDX #$00
- .Loop:
- LDA #$FF
- STA $0200,x
- INX
- INX
- INX
- INX
- CPX #$D0
- BNE .Loop
- ; JSR LoadCreditsPalettes
- JSR LoadCreditsNametable
- JSR LoadCreditsAttribute
- LDA #STATECREDITS
- STA gamestate
- RTS
- LoadCreditsNametable:
- LDA $2002
- LDA #$20
- STA $2006
- LDA #$00
- STA $2006
- LDA #low(CreditsBackground)
- STA AddrLow ; load low bytes of background data
- LDA #high(CreditsBackground)
- STA AddrHigh ; load high bytes of background data
- LDX #$04 ; Loop X 4 times
- LDY #$00 ; Loop Y 256 times
- LoadCreditsBackgroundsLoop:
- LDA [AddrLow],y
- STA $2007
- INY
- BNE LoadCreditsBackgroundsLoop
- ; Outer loop
- INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
- DEX ; one chunk done so X = X - 1.
- BNE LoadCreditsBackgroundsLoop ; if X isn't zero, do again
- RTS
- LoadCreditsAttribute:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$23
- STA $2006 ; write the high byte of $23C0 address
- LDA #$C0
- STA $2006 ; write the low byte of $23C0 address
- LDX #$00 ; start out at 0
- LoadCreditsAttributeLoop:
- LDA CreditsAttribute, x ; load data from address (attribute + the value in x)
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
- BNE LoadCreditsAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
- ; if compare was equal to 128, keep going down
- RTS
- CreditsPalette:
- .db $0f,$29,$18,$2D, $0f,$06,$18,$12, $0f,$38,$18,$1A, $0f,$04,$18,$29 ;;background palette
- .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
- ;;as you can see, I am pulling from all three palettes in the attribute table. some sections are using
- ;;palette %01, some are using palette %10, and some are using palette %11.
- ;;remember, these are binary numbers. %01=1, %10=2, %11=3.
- CreditsAttribute:
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %01000000, %10010000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00001000, %00001111, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- CreditsBackground:
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .bank 1
- .org $A000
- EngineLoadTitle:
- LDA #$00
- STA $2000
- STA $2001
- JSR LoadTitlePalettes
- JSR LoadTitleNametable
- JSR LoadTitleAttribute
- JSR TitleLoadSprites
- JSR DifficultySelect
- LDX #LOW(title_module)
- LDY #HIGH(title_module)
- JSR FamiToneMusicStart
- LDA #STATETITLE
- STA gamestate
- LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
- STA $2000
- LDA #%00011110 ; enable sprites, enable background, no clipping on left side
- STA soft2001
- JMP GameEngineDone
- EngineTitle:
- JMP GameEngineDone
- EngineLoadPlaying:
- LDA #$00
- STA $2000
- STA $2001
- JSR LoadPalettes
- JSR LoadNametable
- JSR LoadAttribute
- JSR LoadSprites
- JSR PickColors
- JSR DrawWinningColors
- LDX #LOW(trackone_module)
- LDY #HIGH(trackone_module)
- JSR FamiToneMusicStart
- LDA #STATEPLAYING
- STA gamestate
- LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
- STA $2000
- LDA #%00011110 ; enable sprites, enable background, no clipping on left side
- STA soft2001
- JMP GameEngineDone
- EnginePlaying:
- JSR GetColorPosition
- JSR CheckSolutions
- JSR MoveQuestionMarks
- JSR EndGame
- JSR PlaySoundEffect
- JSR RunTimer
- JMP GameEngineDone
- ;;;;;;;
- LoadGameOver:
- LDA #$00
- STA $2000
- STA $2001
- KillSprites2:
- LDX #$00
- .Loop:
- LDA #$FF
- STA $0200,x
- INX
- INX
- INX
- INX
- CPX #$D0
- BNE .Loop
- JSR LoadGameOverPalettes
- JSR LoadGameOverNametable
- JSR LoadGameOverAttribute
- JSR DrawWinScreen
- JSR DrawWinScreen2
- JSR DrawWinScreen3
- LDA #STATEGAMEOVER
- STA gamestate
- LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
- STA $2000
- LDA #%00011110 ; enable sprites, enable background, no clipping on left side
- STA soft2001
- JMP GameEngineDone
- ;;;;;;;
- GameOverEngine:
- JMP GameEngineDone
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;; SUBROUTINES ;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ResetVariables:
- LDA #$00
- STA CurrentRow
- STA CurrentColor
- STA WinFlag
- STA WinLose
- JSR KillSprites
- RTS
- KillSprites:
- LDX #$00
- .Loop:
- LDA #$FF
- STA $0200,x
- INX
- INX
- INX
- INX
- CPX #$D0
- BNE .Loop
- RTS
- DifficultySelect:
- LDA gamestate
- CMP #STATELOADTITLE ;if it isn't during title screen, ignore this whole routine.
- BNE End
- LDA $200
- CMP #$50
- BEQ Easy
- LDA $200
- CMP #$58
- BEQ Medium
- LDA $200
- CMP #$60
- LDA $200
- BEQ Hard
- LDA $200
- CMP #$70
- BEQ Panic
- Panic:
- LDA #$07
- STA difficulty
- RTS
- Credit:
- LDA #$06
- STA gamestate
- Hard:
- LDA #$15
- STA difficulty
- RTS
- Medium:
- LDA #$20
- STA difficulty
- RTS
- Easy:
- LDA #$40
- STA difficulty
- RTS
- End:
- RTS
- TitleScreenUp: ;Code for pressing Up during title screen.
- LDA gamestate
- CMP #STATETITLE ;if it isn't during title screen, ignore this whole routine.
- BNE .End
- LDA #$01
- STA SoundEffect
- STA PlaySound
- LDA $0200 ; look at $0203 and see if it's at the Up most position
- CMP #$50
- BNE .NotWrap ;if it's not, skip this and move Up as usual
- LDA #$68
- STA $0200 ;it is at Up-most point. reposition to #$B8
- RTS
- .NotWrap:
- LDA $0200 ; load sprite Y position
- SEC ; make sure carry flag is set
- SBC #$08 ; A = A - 10
- STA $0200 ; save sprite Y position
- .End:
- RTS
- TitleScreenDown: ;Code for pressing Down during title screen.
- LDA gamestate
- CMP #STATETITLE ;if it isn't during title screen, ignore this whole routine.
- BNE .End
- LDA #$01
- STA SoundEffect
- STA PlaySound
- LDA $0200 ; look at $0203 and see if it's at the Up most position
- CMP #$68
- BNE .NotWrap ;if it's not, skip this and move Up as usual
- LDA #$50
- STA $0200 ;it is at Up-most point. reposition to #$B8
- RTS
- .NotWrap:
- LDA $0200 ; load sprite Y position
- CLC ; make sure carry flag is set
- ADC #$08 ; A = A - 10
- STA $0200 ; save sprite Y position
- .End:
- RTS
- PlayingGameDown:
- LDA DownHeld ; if DownHeld is #$01, skip to end
- CMP #$01
- BEQ PlayingGameDownDone
- LDA WinFlag
- CMP #$01
- BEQ PlayingGameDownDone
- LDA #$01
- STA SoundEffect
- STA PlaySound
- LDA $0200 ; look at $0203 and see if it's at the Down most position
- CMP #$C0
- BNE .NotWrap ;if it's not, skip this and move Down as usual
- LDA #$B0
- STA $0200 ;it is at Down-most point. reposition to #$B8
- STA $0204
- CLC
- ADC #$08
- STA $0208
- STA $020C
- JMP PlayingGameDownDone
- .NotWrap:
- LDA $0200 ; load sprite Y position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A - 10
- STA $0200 ; save sprite Y position
- LDA $0204 ; load sprite2 Y position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A - 10
- STA $0204 ; save sprite2 Y position
- LDA $0208 ; load sprite3 Y position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A - 10
- STA $0208 ; save sprite3 Y position
- LDA $020c ; load sprite4 Y position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A - 10
- STA $020c ; save sprite4 Y position
- PlayingGameDownDone:
- PlayingGameUp: ;Code for pressing Up during gameplay.
- LDA gamestate
- CMP #STATEPLAYING ;if it isn't during gameplay, ignore this whole routine.
- BNE .End
- LDA WinFlag
- CMP #$01
- BEQ .End
- LDA #$01
- STA SoundEffect
- STA PlaySound
- LDA $0200 ; look at $0203 and see if it's at the Up most position
- CMP #$B0
- BNE .NotWrap ;if it's not, skip this and move Up as usual
- LDA #$C0
- STA $0200 ;it is at Up-most point. reposition to #$B8
- STA $0204
- CLC
- ADC #$08
- STA $0208
- STA $020C
- RTS
- .NotWrap:
- LDA $0200 ; load sprite Y position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A - 10
- STA $0200 ; save sprite Y position
- LDA $0204 ; load sprite2 Y position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A - 10
- STA $0204 ; save sprite2 Y position
- LDA $0208 ; load sprite3 Y position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A - 10
- STA $0208 ; save sprite3 Y position
- LDA $020c ; load sprite4 Y position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A - 10
- STA $020c ; save sprite4 Y position
- .End:
- RTS
- LoadTitlePalettes:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$3F
- STA $2006 ; write the high byte of $3F00 address
- LDA #$00
- STA $2006 ; write the low byte of $3F00 address
- LDX #$00 ; start out at 0
- LoadTitlePalettesLoop:
- LDA Titlepalette, x ; load data from address (palette + the value in x)
- ; 1st time through loop it will load palette+0
- ; 2nd time through loop it will load palette+1
- ; 3rd time through loop it will load palette+2
- ; etc
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
- BNE LoadTitlePalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
- ; if compare was equal to 32, keep going down
- RTS
- LoadTitleNametable:
- LDA $2002
- LDA #$20
- STA $2006
- LDA #$00
- STA $2006
- LDA #low(Titlebackground)
- STA AddrLow ; load low bytes of background data
- LDA #high(Titlebackground)
- STA AddrHigh ; load high bytes of background data
- LDX #$04 ; Loop X 4 times
- LDY #$00 ; Loop Y 256 times
- LoadTitleBackgroundsLoop:
- LDA [AddrLow],y
- STA $2007
- INY
- BNE LoadTitleBackgroundsLoop
- ; Outer loop
- INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
- DEX ; one chunk done so X = X - 1.
- BNE LoadTitleBackgroundsLoop ; if X isn't zero, do again
- RTS
- LoadTitleAttribute:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$23
- STA $2006 ; write the high byte of $23C0 address
- LDA #$C0
- STA $2006 ; write the low byte of $23C0 address
- LDX #$00 ; start out at 0
- LoadTitleAttributeLoop:
- LDA Titleattribute, x ; load data from address (attribute + the value in x)
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
- BNE LoadTitleAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
- ; if compare was equal to 128, keep going down
- RTS
- CheckSolutions:
- LDA Checking
- CMP #$01
- BNE .End
- LDX #$00
- .Loop:
- LDA Color1Guessed,x
- CMP #$01
- BEQ .Inc
- LDA Choice1
- CLC
- ADC #$01
- CMP Color1Answer,x
- BEQ .IncWin
- .Inc:
- INX
- CPX #$04
- BEQ SecondGuess
- JMP .Loop
- .End:
- RTS
- .IncWin:
- LDA #$01
- STA Color1Guessed,x
- INC NumberCorrect
- SecondGuess:
- LDX #$00
- .Loop:
- LDA Color1Guessed,x
- CMP #$01
- BEQ .Inc
- LDA Choice2
- CLC
- ADC #$01
- CMP Color1Answer,x
- BEQ .IncWin
- .Inc:
- INX
- CPX #$04
- BEQ ThirdGuess
- JMP .Loop
- .IncWin:
- LDA #$01
- STA Color1Guessed,x
- INC NumberCorrect
- ThirdGuess:
- LDX #$00
- .Loop:
- LDA Color1Guessed,x
- CMP #$01
- BEQ .Inc
- LDA Choice3
- CLC
- ADC #$01
- CMP Color1Answer,x
- BEQ .IncWin
- .Inc:
- INX
- CPX #$04
- BEQ FourthGuess
- JMP .Loop
- .IncWin:
- LDA #$01
- STA Color1Guessed,x
- INC NumberCorrect
- FourthGuess:
- LDX #$00
- .Loop:
- LDA Color1Guessed,x
- CMP #$01
- BEQ .Inc
- LDA Choice4
- CLC
- ADC #$01
- CMP Color1Answer,x
- BEQ .IncWin
- .Inc:
- INX
- CPX #$04
- BEQ Finish
- JMP .Loop
- .IncWin:
- LDA #$01
- STA Color1Guessed,x
- INC NumberCorrect
- Finish:
- ;;check for perfects
- LDA Choice1
- CLC
- ADC #$01
- CMP Color1Answer
- BNE .Second
- INC NumberPerfect
- DEC NumberCorrect
- .Second:
- LDA Choice2
- CLC
- ADC #$01
- CMP Color2Answer
- BNE .Third
- INC NumberPerfect
- DEC NumberCorrect
- .Third:
- LDA Choice3
- CLC
- ADC #$01
- CMP Color3Answer
- BNE .Fourth
- INC NumberPerfect
- DEC NumberCorrect
- .Fourth:
- LDA Choice4
- CLC
- ADC #$01
- CMP Color4Answer
- BNE .End
- INC NumberPerfect
- DEC NumberCorrect
- LDA NumberPerfect
- CMP #$04
- BNE .End
- LDA #$01
- STA WinFlag
- STA PlaySound
- LDA #$02
- STA SoundEffect
- JSR FamiToneMusicStop
- .End:
- JSR DrawCorrectSprites
- RTS
- DrawCorrectSprites:
- LDY CurrentRow
- LDA SpriteAdd,y
- TAX
- .PerfLoop:
- LDA NumberPerfect
- CMP #$00
- BEQ .Correct
- LDA #$48
- STA $0251,x
- DEC NumberPerfect
- INX
- INX
- INX
- INX
- JMP .PerfLoop
- .Correct:
- LDA NumberCorrect
- CMP #$00
- BEQ .End
- LDA #$38
- STA $0251,x
- DEC NumberCorrect
- INX
- INX
- INX
- INX
- JMP .Correct
- .End:
- LDA #$00
- STA Checking
- STA Color1Guessed
- STA Color2Guessed
- STA Color3Guessed
- STA Color4Guessed
- INC CurrentRow
- RTS
- SpriteAdd:
- .db $00,$10,$20,$30,$40,$50,$60
- LatchController:
- LDA #$01
- STA $4016
- LDA #$00
- STA $4016 ; tell both the controllers to latch buttons
- ReadA:
- LDA $4016 ; player 1 - A
- AND #%00000001 ; only look at bit 0
- BNE .ReadA
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00
- STA AHeld
- JMP ReadADone
- .ReadA:
- LDA AHeld
- CMP #$01
- BEQ ReadADone
- LDA gamestate
- CMP #$01
- BEQ ReadADone
- LDA WinFlag
- CMP #$01
- BEQ ReadADone
- LDA Checking
- CMP #$01
- BEQ ReadADone
- LDA #$00
- STA SoundEffect
- LDA #$01
- STA PlaySound
- JSR AssignColor
- LDA #$01
- STA AHeld
- LDA $0203 ; load sprite X position
- CLC ; make sure the carry flag is clear
- STA $0203 ; save sprite X position
- ReadADone: ; handling this button is done
- ReadB:
- LDA $4016 ; player 1 - B
- AND #%00000001 ; only look at bit 0
- BEQ ReadBDone ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1) LDA $4016 ; player 1 - Up
- AND #%00000001 ; only look at bit 0
- BNE ReadB2 ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00 ; Up is not being held. Set back to #$00.
- STA BHeld
- JMP ReadBDone
- ReadB2:
- LDA BHeld ; if BHeld is #$01, skip to end
- CMP #$01
- BEQ jump
- LDA #$01 ; set UpHeld to #$01.
- STA BHeld
- jump:
- ReadBDone: ; handling this button is done
- ReadSelect:
- LDA $4016 ; player 1 - select
- AND #%00000001 ; only look at bit 0
- BEQ ReadSelectDone ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA $0203 ; load sprite X position
- SEC ; make sure carry flag is set
- STA $0203 ; save sprite X position
- ReadSelectDone: ; handling this button is done
- ReadStart:
- LDA $4016 ; player 1 - Start
- AND #%00000001 ; only look at bit 0
- BNE ReadStart2 ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00 ; Up is not being held. Set back to #$00.
- STA StartHeld
- JMP ReadStartDone
- ReadStart2:
- LDA StartHeld ; if BHeld is #$01, skip to end
- CMP #$01
- BEQ ReadStartDone
- LDA #$01 ; set UpHeld to #$01.
- STA StartHeld
- LDA gamestate
- CMP #STATETITLE
- BNE .NotTitle
- LDA #STATELOADPLAYING
- STA gamestate
- JMP ReadStartDone
- .NotTitle:
- LDA WinFlag
- CMP #$01
- BNE ReadStartDone
- JSR ResetVariables
- LDA #STATELOADTITLE
- STA gamestate
- ReadStartDone: ; handling this button is done
- ReadUp:
- LDA $4016 ; player 1 - Up
- AND #%00000001 ; only look at bit 0
- BNE ReadUp2 ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00 ; Up is not being held. Set back to #$00.
- STA UpHeld
- JMP ReadUpDone
- ReadUp2:
- LDA UpHeld ; if UpHeld is #$01, skip to end
- CMP #$01
- BEQ ReadUpDone
- LDA #$01
- STA UpHeld
- JSR TitleScreenUp
- JSR PlayingGameUp
- JSR DifficultySelect
- ReadUpDone:
- ReadDown:
- LDA $4016 ; player 1 - Down
- AND #%00000001 ; only look at bit 0
- BNE ReadDown2 ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00 ; Down is not being held. Set back to #$00.
- STA DownHeld
- JMP ReadDownDone
- ReadDown2:
- LDA DownHeld ; if DownHeld is #$01, skip to end
- CMP #$01
- BEQ ReadDownDone
- LDA #$01
- STA DownHeld
- JSR TitleScreenDown
- JSR PlayingGameDown
- JSR DifficultySelect
- ReadDownDone:
- ReadLeft:
- LDA $4016 ; player 1 - Left
- AND #%00000001 ; only look at bit 0
- BNE ReadLeft2 ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00 ; Left is not being held. Set back to #$00.
- STA LeftHeld
- JMP ReadLeftDone
- ReadLeft2:
- LDA LeftHeld ; if LeftHeld is #$01, skip to end
- CMP #$01
- BEQ ReadLeftDone
- LDA gamestate
- CMP #$01
- BEQ ReadLeftDone
- LDA WinFlag
- CMP #$01
- BEQ ReadLeftDone
- LDA #$01 ; set LeftHeld to #$01.
- STA LeftHeld
- LDA #$01
- STA SoundEffect
- STA PlaySound
- LDA $0203 ; look at $0203 and see if it's at the Left most position
- CMP #$B0
- BNE .NotWrap ;if it's not, skip this and move Left as usual
- LDA #$D0
- STA $0203 ;it is at Left-most point. reposition to #$B8
- STA $020F
- CLC
- ADC #$08
- STA $020B
- STA $0207
- JMP ReadLeftDone
- .NotWrap:
- LDA $0203 ; load sprite X position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A + 10
- STA $0203 ; save sprite X position
- LDA $0207 ; load sprite2 X position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A + 10
- STA $0207 ; save sprite2 X position
- LDA $020B ; load sprite3 X position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A + 10
- STA $020B ; save sprite3 X position
- LDA $020F ; load sprite4 X position
- SEC ; make sure carry flag is set
- SBC #$10 ; A = A + 10
- STA $020F ; save sprite4 X position
- ReadLeftDone:
- ReadRight:
- LDA $4016 ; player 1 - Right
- AND #%00000001 ; only look at bit 0
- BNE ReadRight2 ; branch to ReadBDone if button is NOT pressed (0)
- ; add instructions here to do something when button IS pressed (1)
- LDA #$00 ; Right is not being held. Set back to #$00.
- STA RightHeld
- JMP ReadRightDone
- ReadRight2:
- LDA RightHeld ; if RightHeld is #$01, skip to end
- CMP #$01
- BEQ ReadRightDone
- LDA gamestate
- CMP #$01
- BEQ ReadRightDone
- LDA WinFlag
- CMP #$01
- BEQ ReadRightDone
- LDA #$01 ; set RightHeld to #$01.
- STA RightHeld
- LDA #$01
- STA SoundEffect
- STA PlaySound
- LDA $0203 ; look at $0203 and see if it's at the right most position
- CMP #$D0
- BNE .NotWrap ;if it's not, skip this and move right as usual
- LDA #$B0
- STA $0203 ;it is at right-most point. reposition to #$B8
- STA $020F
- CLC
- ADC #$08
- STA $0207
- STA $020B
- JMP ReadRightDone
- .NotWrap:
- LDA $0203 ; load sprite X position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A + 10
- STA $0203 ; save sprite X position
- LDA $0207 ; load sprite2 X position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A + 10
- STA $0207 ; save sprite2 X position
- LDA $020B ; load sprite3 X position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A + 10
- STA $020B ; save sprite3 X position
- LDA $020F ; load sprite4 X position
- CLC ; make sure carry flag is set
- ADC #$10 ; A = A + 10
- STA $020F ; save sprite4 X position
- ReadRightDone: ; handling this button is done
- RTS
- Random:
- ; See "linear-congruential random number generator" for more.
- ; rand = (rand * 5 + 0x3611) & 0xffff;
- ; return (rand >> 8) & 0xff;
- LDA RandomHigh ; multiply by 5
- STA RandomTemp
- LDA RandomLow
- ASL a ; rand = rand * 4 + rand
- ROL RandomTemp
- ASL a
- ROL RandomTemp
- CLC
- ADC RandomLow
- PHA
- LDA RandomTemp
- ADC RandomHigh
- STA RandomHigh
- PLA ; rand = rand + 0x3611
- CLC
- ADC #$11
- STA RandomLow
- LDA RandomHigh
- ADC #$36
- STA RandomHigh
- RTS
- PickColors:
- ;;choose a random color six times
- LDX #$00
- .Loop:
- JSR Random
- JSR GetCorrectValue
- INX
- JSR Random
- JSR GetCorrectValue
- INX
- JSR Random
- JSR GetCorrectValue
- INX
- JSR Random
- JSR GetCorrectValue
- INX
- JSR Random
- JSR GetCorrectValue
- INX
- JSR Random
- JSR GetCorrectValue
- RTS
- DrawWinningColors:
- LDX #$00
- LDY #$00
- DrawWinningColorsLoop:
- LDA Color1Answer,x
- CMP #$01
- BEQ .FirstSprite
- CMP #$03
- BEQ .FirstSprite
- CMP #$05
- BEQ .FirstSprite
- JMP .SecondSprite
- .FirstSprite:
- LDA $2002
- LDA #$20
- STA $2006
- TYA
- CLC
- ADC #$89
- STA $2006
- LDA #$61
- STA $2007
- LDA #$62
- STA $2007
- LDA #$20
- STA $2006
- TYA
- CLC
- ADC #$A9
- STA $2006
- LDA #$63
- STA $2007
- LDA #$64
- STA $2007
- JSR GetCorrectColor
- RTS
- .SecondSprite:
- LDA $2002
- LDA #$20
- STA $2006
- TYA
- CLC
- ADC #$89
- STA $2006
- LDA #$65
- STA $2007
- LDA #$66
- STA $2007
- LDA #$20
- STA $2006
- TYA
- CLC
- ADC #$A9
- STA $2006
- LDA #$67
- STA $2007
- LDA #$68
- STA $2007
- JSR GetCorrectColor
- RTS
- GetCorrectColor:
- CPX #$00
- BNE Color2
- Color1:
- LDA Color1Answer
- CMP #$03
- BCC .Palette1
- CMP #$05
- BCC .Palette2
- CMP #$07
- BCC .Palette3
- RTS
- .Palette1:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CA
- STA $2006
- LDA #%00000101
- STA $2007
- STA Answer1Attr
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- .Palette2:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CA
- STA $2006
- LDA #%00001010
- STA $2007
- STA Answer1Attr
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- .Palette3:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CA
- STA $2006
- LDA #%00001111
- STA $2007
- STA Answer1Attr
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- Color2:
- CPX #$01
- BNE Color3
- LDA Color2Answer
- CMP #$03
- BCC .Palette1
- CMP #$05
- BCC .Palette2
- CMP #$07
- BCC .Palette3
- RTS
- .Palette1:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00000001
- STA $2007
- STA Palette2
- STA Answer2Attr
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- .Palette2:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00000010
- STA $2007
- STA Palette2
- STA Answer2Attr
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- .Palette3:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00000011
- STA $2007
- STA Palette2
- STA Answer2Attr
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- Color3:
- CPX #$02
- BEQ .Cont
- JMP Color4
- .Cont:
- LDA Color3Answer
- CMP #$03
- BCC .Palette1
- CMP #$05
- BCC .Palette2
- CMP #$07
- BCC .Palette3
- RTS
- .Palette1:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00000100
- ORA Palette2
- STA $2007
- STA Answer3Attr1
- LDA #$23
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00000001
- STA $2007
- STA Palette3
- STA Answer3Attr2
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- .Palette2:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00001000
- ORA Palette2
- STA $2007
- STA Answer3Attr1
- LDA #$23
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00000010
- STA $2007
- STA Palette3
- STA Answer3Attr2
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- .Palette3:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CB
- STA $2006
- LDA #%00001100
- ORA Palette2
- STA $2007
- STA Answer3Attr1
- LDA #$23
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00000011
- STA $2007
- STA Palette3
- STA Answer3Attr2
- INX
- INY
- INY
- INY
- JMP DrawWinningColorsLoop
- Color4:
- LDA Color4Answer
- CMP #$03
- BCC .Palette1
- CMP #$05
- BCC .Palette2
- CMP #$07
- BCC .Palette3
- RTS
- .Palette1:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00000100
- ORA Palette3
- STA $2007
- STA Answer4Attr
- RTS
- .Palette2:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00001000
- ORA Palette3
- STA $2007
- STA Answer4Attr
- RTS
- .Palette3:
- LDA $2002
- LDA #$23
- STA $2006
- LDA #$CC
- STA $2006
- LDA #%00001100
- ORA Palette3
- STA $2007
- STA Answer4Attr
- RTS
- GetCorrectValue:
- CMP #$2A
- BCC .1
- CMP #$54
- BCC .2
- CMP #$7E
- BCC .3
- CMP #$A8
- BCC .4
- CMP #$D2
- BCC .5
- JMP .6
- .1:
- LDA #$01
- STA Color1Answer,x
- RTS
- .2:
- LDA #$02
- STA Color1Answer,x
- RTS
- .3:
- LDA #$03
- STA Color1Answer,x
- RTS
- .4:
- LDA #$04
- STA Color1Answer,x
- RTS
- .5:
- LDA #$05
- STA Color1Answer,x
- RTS
- .6:
- LDA #$06
- STA Color1Answer,x
- RTS
- LoadPalettes:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$3F
- STA $2006 ; write the high byte of $3F00 address
- LDA #$00
- STA $2006 ; write the low byte of $3F00 address
- LDX #$00 ; start out at 0
- LoadPalettesLoop:
- LDA palette, x ; load data from address (palette + the value in x)
- ; 1st time through loop it will load palette+0
- ; 2nd time through loop it will load palette+1
- ; 3rd time through loop it will load palette+2
- ; etc
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
- BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
- ; if compare was equal to 32, keep going down
- RTS
- LoadSprites:
- LDX #$00 ; start at 0
- LoadSpritesLoop:
- LDA sprites, x ; load data from address (sprites + x)
- STA $0200, x ; store into RAM address ($0200 + x)
- INX ; X = X + 1
- CPX #$d0 ; Compare X to hex $20, decimal 32
- BNE LoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
- ; if compare was equal to 32, keep going down
- RTS
- LoadNametable:
- LDA $2002
- LDA #$20
- STA $2006
- LDA #$00
- STA $2006
- LDA #low(background)
- STA AddrLow ; load low bytes of background data
- LDA #high(background)
- STA AddrHigh ; load high bytes of background data
- LDX #$04 ; Loop X 4 times
- LDY #$00 ; Loop Y 256 times
- LoadBackgroundsLoop:
- LDA [AddrLow],y
- STA $2007
- INY
- BNE LoadBackgroundsLoop
- ; Outer loop
- INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
- DEX ; one chunk done so X = X - 1.
- BNE LoadBackgroundsLoop ; if X isn't zero, do again
- RTS
- LoadAttribute:
- LDA $2002 ; read PPU status to reset the high/low latch
- LDA #$23
- STA $2006 ; write the high byte of $23C0 address
- LDA #$C0
- STA $2006 ; write the low byte of $23C0 address
- LDX #$00 ; start out at 0
- LoadAttributeLoop:
- LDA attribute, x ; load data from address (attribute + the value in x)
- STA $2007 ; write to PPU
- INX ; X = X + 1
- CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
- BNE LoadAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
- ; if compare was equal to 128, keep going down
- RTS
- GetColorPosition:
- Row1:
- LDA $0200
- CMP #$B0
- BNE Row2
- Box1:
- LDA $0203
- CMP #$B0
- BNE Box2
- LDA #$00
- STA ColorPosition
- RTS
- Box2:
- LDA $0203
- CMP #$C0
- BNE Box3
- LDA #$01
- STA ColorPosition
- RTS
- Box3:
- LDA $0203
- CMP #$D0
- BNE CountEnd
- LDA #$02
- STA ColorPosition
- RTS
- Row2:
- LDA $0200
- CMP #$C0
- BNE CountEnd
- Box4:
- LDA $0203
- CMP #$B0
- BNE Box5
- LDA #$03
- STA ColorPosition
- RTS
- Box5:
- LDA $0203
- CMP #$C0
- BNE Box6
- LDA #$04
- STA ColorPosition
- RTS
- Box6:
- LDA $0203
- CMP #$D0
- BNE CountEnd
- LDA #$05
- STA ColorPosition
- CountEnd:
- RTS
- EndGame:
- LDA CurrentRow
- CMP #$07
- BEQ .Finish
- RTS
- .Finish:
- LDA WinFlag
- CMP #$01
- BEQ .Skip
- LDA #$01
- STA WinFlag
- STA PlaySound
- LDA #$03
- STA SoundEffect
- JSR FamiToneMusicStop
- .Skip:
- RTS
- MoveQuestionMarks: ;; better way to write it
- LDA WinFlag
- CMP #$01
- BNE .End
- LDA $0240
- CMP #$11
- BEQ .Reset
- LDX #$40
- .Loop:
- DEC $020c,x
- DEX
- DEX
- DEX
- DEX
- CPX #$00
- BNE .Loop
- RTS
- .End:
- RTS
- .Reset:
- LDA #STATELOADGAMEOVER
- STA gamestate
- LDA #$00
- STA PlaySound
- RTS
- RunTimer:
- LDA WinFlag
- CMP #$01
- BEQ .GameOver
- INC CountdownTimer
- LDA CountdownTimer
- CMP difficulty ;;this number can change depending on how fast you want the timer to tick
- BEQ .Tick
- RTS
- .Tick:
- LDA #$00
- STA CountdownTimer
- .Ones: ;ones position (00x)
- ;;look at ones position
- ;;if it is zero, branch to .Tens to make it 9 and decrease tens position
- ;;otherwise, just decrease ones position
- LDA $02cD
- CMP #$F6
- BEQ .Tens
- DEC $02CD
- RTS
- .Tens: ;tens position (0x0)
- ;;look at tens position
- ;;if it is zero, branch to make it 9 and decrease hundreds position
- ;;otherwise, just decrease tens position and make ones position 9.
- LDA $02c9
- CMP #$F6
- BEQ .Hundreds
- DEC $02C9
- LDA #$FF
- STA $02cd
- RTS
- .Hundreds: ;hundreds position (x00)
- ;;look at hundreds position
- ;;if it is zero, the timer has expired. branch to .GameOver
- ;;otherwise, just decrease hundreds position and make tens position 9.
- LDA $02c5
- CMP #$F6
- BEQ .GameOvera
- DEC $02C5
- LDA #$FF
- STA $02c9
- STA $02CD
- RTS
- .GameOver:
- LDA #$01
- STA WinFlag
- STA PlaySound
- LDA #$03
- STA SoundEffect
- RTS
- .GameOvera:
- LDA #$02
- STA WinLose
- LDA WinLose
- CMP #$02
- BEQ .GameOver
- AssignColor:
- ;;The circle colors are assigned as follows:
- ;;X X X
- ;;X X X
- ;;top left circle uses tiles #61-#64/attribute table 1
- ;;top middle circle uses tiles #65-#68/attribute table 1
- ;;top right circle uses tiles #61-64/attribute table 2
- ;;bottom left circle uses tiles #65-68/attribute table 2
- ;;bottom middle circle uses tiles #61-64/attribute table 3
- ;;bottom right circle uses tiles #65-68/attribute table 3
- ;;you should just have to copy/paste the code from "SeventhRowGuesses" into each of the other rows.
- ;;what you'll need to edit is the locations of the tiles/attributes you're replacing.
- ;;that data always starts with $2002/LDA $xx/STA $2006 where xx is the hi byte of the background you're replacing
- ;;let me know if you have any questions! this is really, really complicated stuff, so don't feel bad if it's over your head
- LDA AHeld ;;quick check to only allow this to run once per A press
- CMP #$01
- BEQ .End
- ;;7 rows of guesses
- LDA CurrentRow ;;If CurrentRow is #$00, we are at the beginning row. If not, branch to .6
- CMP #$00
- BNE .6
- ;;7th row
- JSR SeventhRowGuesses ;;CurrentRow is #$00. Jump to the subroutine SeventhRowGuesses to assign colors for every button press
- RTS
- .6:
- CMP #$01
- BNE .5
- ;;6th row
- JSR SixthRowGuesses
- RTS
- .5:
- CMP #$02
- BNE .4
- ;;5th row
- JSR FifthRowGuesses
- RTS
- .4:
- CMP #$03
- BNE .3
- ;;4th row
- JSR FourthRowGuesses
- RTS
- .3:
- CMP #$04
- BNE .2
- ;;3rd row
- JSR ThirdRowGuesses
- RTS
- .2:
- CMP #$05
- BNE .1
- ;;2nd row
- JSR SecondRowGuesses
- RTS
- .1:
- CMP #$06
- BNE .End
- ;;1st row
- JSR FirstRowGuesses
- .End:
- RTS
- .include "title.asm"
- ;;;;;;;;;;;;;;
- .bank 3
- .org $E000
- .include "trackone.asm"
- ;;the different colored circles use colors from palettes 2, 3 and 4.
- ;; it always uses the second and fourth color, since the third color is the brown color of the background.
- ;; that forces that color to stay the same in all color palettes, sadly.
- palette:
- .db $0f,$29,$18,$2D, $0f,$06,$18,$12, $0f,$38,$18,$1A, $0f,$04,$18,$29 ;;background palette
- .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
- sprites:
- sprites:
- ;vert tile attr horiz
- .db $B0, $32, $00, $b0 ;sprite 0
- .db $B0, $33, $00, $b8 ;sprite 1
- .db $B8, $35, $00, $b8 ;sprite 2
- .db $B8, $34, $00, $b0 ;sprite 3
- .db $20, $36, $00, $49 ;sprite ?1tpl
- .db $20, $37, $00, $51 ;sprite ?1tpr
- .db $28, $46, $00, $49 ;sprite ?1bpl
- .db $28, $47, $00, $51 ;sprite ?1bpr
- .db $20, $36, $00, $61 ;sprite ?2tpl
- .db $20, $37, $00, $69 ;sprite ?2tpr
- .db $28, $46, $00, $61 ;sprite ?2bpl
- .db $28, $47, $00, $69 ;sprite ?2bpr
- .db $20, $36, $00, $79 ;sprite ?3tpl
- .db $20, $37, $00, $81 ;sprite ?3tpr
- .db $28, $46, $00, $79 ;sprite ?3bpl
- .db $28, $47, $00, $81 ;sprite ?3bpr
- .db $20, $36, $00, $91 ;sprite ?4tpl
- .db $20, $37, $00, $99 ;sprite ?4tpr
- .db $28, $46, $00, $91 ;sprite ?4bpl
- .db $28, $47, $00, $99 ;sprite ?4bpr
- .db $BF, $39, $01, $10 ;7th row dot ;0250
- .db $BF, $39, $01, $20 ;7th row dot
- .db $C7, $39, $01, $10 ;7th row dot
- .db $C7, $39, $01, $20 ;7th row dot
- .db $A7, $39, $01, $10 ;6th row dot
- .db $A7, $39, $01, $20 ;6th row dot
- .db $AF, $39, $01, $10 ;6th row dot
- .db $AF, $39, $01, $20 ;6th row dot
- .db $8F, $39, $01, $10 ;5th row dot
- .db $8F, $39, $01, $20 ;5th row dot
- .db $97, $39, $01, $10 ;5th row dot
- .db $97, $39, $01, $20 ;5th row dot
- .db $77, $39, $01, $10 ;4th row dot
- .db $77, $39, $01, $20 ;4th row dot
- .db $7F, $39, $01, $10 ;4th row dot
- .db $7F, $39, $01, $20 ;4th row dot
- .db $5F, $39, $01, $10 ;3rd row dot
- .db $5F, $39, $01, $20 ;3rd row dot
- .db $67, $39, $01, $10 ;3rd row dot
- .db $67, $39, $01, $20 ;3rd row dot
- .db $47, $39, $01, $10 ;2nd row dot
- .db $47, $39, $01, $20 ;2nd row dot
- .db $4F, $39, $01, $10 ;2nd row dot
- .db $4F, $39, $01, $20 ;2nd row dot
- .db $2F, $39, $01, $10 ;1st row dot
- .db $2F, $39, $01, $20 ;1st row dot
- .db $37, $39, $01, $10 ;1st row dot
- .db $37, $39, $01, $20 ;1st row dot
- .db $77, $38, $01, $B8 ;key dot
- .db $40, $f8, $01, $c0 ;100s
- .db $40, $f6, $01, $C8 ;10s
- .db $40, $f6, $01, $D0 ;1s
- ;;as you can see, I am pulling from all three palettes in the attribute table. some sections are using
- ;;palette %01, some are using palette %10, and some are using palette %11.
- ;;remember, these are binary numbers. %01=1, %10=2, %11=3.
- attribute:
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %01000000, %10010000, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00001000, %00001111, %00000000
- .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
- background:
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$70,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71 ;;row 2
- .db $71,$71,$71,$71,$71,$72,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;top
- .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60 ;;row 2
- .db $60,$60,$60,$60,$60,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;top
- .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60 ;;row 2
- .db $60,$60,$60,$60,$60,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;top
- .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;??? top
- .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;???bottom
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 7 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$25,$25,$1d,$12,$16,$0E,$1B,$25,$25,$25,$25 ;;guess 7 bottom
- .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
- .db $56,$56,$56,$56,$56,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;divider
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 6 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row
- .db $63,$64,$60,$63,$64,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 6 bottom
- .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
- .db $56,$56,$56,$56,$56,$83,$25,$70,$71,$71,$71,$71,$71,$71,$71,$72,$25 ;;divider
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$25,$82,$44,$28,$29,$2a,$2b,$2c,$2d,$83,$25 ;;guess 5 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$25,$82,$60,$28,$29,$2a,$3b,$3c,$60,$83,$25 ;;guess 5 bottom
- .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
- .db $56,$56,$56,$56,$56,$83,$25,$82,$56,$56,$56,$56,$56,$56,$56,$83,$25 ;;divider
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$25,$82,$60,$28,$29,$2A,$2B,$2C,$2D,$83,$25 ;;guess 4 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$25,$82,$60,$38,$39,$3A,$3B,$3C,$60,$83,$25 ;;guess 4 bottom
- .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
- .db $56,$56,$56,$56,$56,$83,$25,$7F,$80,$80,$80,$80,$80,$80,$80,$81,$25 ;;divider
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 3 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$19,$12,$0c,$14,$25,$22,$18,$1E,$1B,$25,$25 ;;guess 3 bottom
- .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
- .db $56,$56,$56,$56,$56,$83,$25,$25,$0c,$18,$15,$18,$1B,$25,$25,$25,$25 ;;divider
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$70,$71,$71,$71,$71,$71,$71,$71,$72,$25,$25 ;;guess 2 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$82,$61,$62,$65,$66,$61,$62,$60,$83,$25,$25 ;;guess 2 bottom
- .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
- .db $56,$56,$56,$56,$56,$83,$82,$63,$64,$67,$68,$63,$64,$60,$83,$25,$25 ;;divider
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
- .db $61,$62,$60,$61,$62,$83,$82,$65,$66,$61,$62,$65,$66,$60,$83,$25,$25 ;;guess 1 top
- .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
- .db $63,$64,$60,$63,$64,$83,$82,$67,$68,$63,$64,$67,$68,$60,$83,$25,$25 ;;guess 1 bottom
- .db $25,$7f,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80 ;;row 3
- .db $80,$80,$80,$80,$80,$81,$7F,$80,$80,$80,$80,$80,$80,$80,$81,$25,$25 ;;bottom
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
- .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
- .org $FFFA ;first of the three vectors starts here
- .dw NMI ;when an NMI happens (once per frame if enabled) the
- ;processor will jump to the label NMI
- .dw RESET ;when the processor first turns on or is reset, it will jump
- ;to the label RESET:
- .dw 0 ;external interrupt IRQ is not used in this tutorial
- ;;;;;;;;;;;;;;
- .bank 4
- .org $0000
- .incbin "mario.chr" ;includes 8KB graphics file from SMB1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement