Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 143.10 KB | None | 0 0
  1. .inesprg 2 ; 2x 16KB PRG code
  2. .ineschr 1 ; 1x 8KB CHR data
  3. .inesmap 0 ; mapper 0 = NROM, no bank swapping
  4. .inesmir 1 ; background mirroring
  5.  
  6.  
  7. ;;;;;;;;;;;;;;;
  8.  
  9. .include "zeropage.asm"
  10.  
  11. STATELOADTITLE = $00
  12. STATETITLE = $01
  13. STATELOADPLAYING = $02
  14. STATEPLAYING = $03
  15. STATELOADGAMEOVER = $04
  16. STATEGAMEOVER = $05
  17. STATELOADCREDITS = $06
  18. STATECREDITS = $07
  19.  
  20. .bank 0
  21. .org $8000
  22.  
  23. .include "famitone.asm"
  24. .include "soundeffects.asm"
  25.  
  26. PlaySoundEffect:
  27. LDA PlaySound
  28. CMP #$01
  29. BNE .End
  30.  
  31. LDA SoundEffect
  32. LDX #FT_SFX_CH1
  33. JSR FamiToneSfxStart
  34. LDA #$00
  35. STA PlaySound
  36. .End:
  37. RTS
  38.  
  39. TitleLoadSprites:
  40. LDX #$00 ; start at 0
  41. TitleLoadSpritesLoop:
  42. LDA Titlesprites, x ; load data from address (sprites + x)
  43. STA $0200, x ; store into RAM address ($0200 + x)
  44. INX ; X = X + 1
  45. CPX #$04 ; Compare X to hex $20, decimal 32
  46. BNE TitleLoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
  47. ; if compare was equal to 32, keep going down
  48. RTS
  49.  
  50. Titlesprites:
  51. ;vert tile attr horiz
  52. .db $50, $38, $01, $20 ;sprite 0
  53.  
  54. Titlebackground:
  55. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  56. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  57.  
  58. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  59. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  60.  
  61. .db $25,$25,$25,$25,$25,$25,$a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9 ;;row 1
  62. .db $aa,$ab,$ac,$ad,$ae,$af,$d0,$d1,$d2,$d3,$25,$25,$25,$25,$25,$25 ;;all sky
  63.  
  64. .db $25,$25,$25,$25,$25,$25,$b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9 ;;row 1
  65. .db $ba,$bb,$bc,$bd,$be,$bf,$e0,$e1,$e2,$e3,$25,$25,$25,$25,$25,$25 ;;all sky
  66.  
  67. .db $25,$25,$25,$25,$25,$25,$c0,$c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9 ;;row 1
  68. .db $ca,$cb,$cc,$cd,$ce,$cf,$f0,$f1,$f2,$f3,$25,$25,$25,$25,$25,$25 ;;all sky
  69.  
  70. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  71. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  72.  
  73. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  74. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  75.  
  76. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  77. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  78.  
  79. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  80. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  81.  
  82. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  83. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all skytop
  84.  
  85. .db $25,$25,$25,$25,$25,$0E,$0A,$1C,$22,$25,$25,$25,$25,$25,$25 ;;row 1
  86. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  87.  
  88. .db $25,$25,$25,$25,$25,$16,$0E,$0D,$12,$1E,$16,$25,$25,$25,$25 ;;row 1
  89. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  90.  
  91. .db $25,$25,$25,$25,$25,$11,$0A,$1B,$0D,$25,$25,$25,$25,$25,$25 ;;row 1
  92. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  93.  
  94. .db $25,$25,$25,$25,$25,$0C,$1B,$0E,$0D,$12,$1D,$1C,$25,$25,$25 ;;row 1
  95. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  96.  
  97. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  98. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  99.  
  100. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  101. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all skytop
  102.  
  103. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  104. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  105.  
  106. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  107. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  108.  
  109. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$19,$1b,$0E,$1C,$1C,$25 ;;row 1
  110. .db $1C,$1D,$0A,$1B,$1D,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  111.  
  112. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  113. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  114.  
  115. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  116. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  117.  
  118. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  119. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all skytop
  120.  
  121. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  122. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  123.  
  124. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  125. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  126.  
  127. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  128. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  129.  
  130. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  131. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  132.  
  133. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  134. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  135.  
  136. .db $25,$25,$26,$02,$48,$01,$05,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  137. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  138.  
  139. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  140. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  141.  
  142. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  143. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  144.  
  145. Titlepalette:
  146. .db $0f,$29,$18,$2D, $0f,$29,$12,$38, $0f,$38,$29,$2D, $0f,$04,$18,$29 ;;background palette
  147. .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
  148.  
  149. Titleattribute:
  150. .db %00000000, %01010101, %01010101, %01010101, %01010101, %01010101, %01010101, %00000000
  151. .db %00000000, %01010101, %01010101, %01010101, %01010101, %01010101, %01010101, %00000000
  152. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  153. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  154. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  155. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  156. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  157. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  158.  
  159. LoadGameOverPalettes:
  160. LDA $2002 ; read PPU status to reset the high/low latch
  161. LDA #$3F
  162. STA $2006 ; write the high byte of $3F00 address
  163. LDA #$00
  164. STA $2006 ; write the low byte of $3F00 address
  165. LDX #$00 ; start out at 0
  166. LoadGameOverPalettesLoop:
  167. LDA GameOverPalette, x ; load data from address (palette + the value in x)
  168. ; 1st time through loop it will load palette+0
  169. ; 2nd time through loop it will load palette+1
  170. ; 3rd time through loop it will load palette+2
  171. ; etc
  172. STA $2007 ; write to PPU
  173. INX ; X = X + 1
  174. CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  175. BNE LoadGameOverPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
  176. ; if compare was equal to 32, keep going down
  177. RTS
  178.  
  179.  
  180. DrawWinScreen:
  181. LDA WinFlag ;WinFlag is set to #$01 when the game is won or lost.
  182. CMP #$01
  183. BNE .End
  184. LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
  185. LDA WinLose
  186. CMP #$02
  187. BEQ .Lose
  188. LDA CurrentRow ;CurrentRow is set to #$08 if the player doesn't guess correctly after 7 tries (I think).
  189. CMP #$07
  190. BEQ .Lose
  191.  
  192. ;;draw winning tiles
  193. LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
  194. LDA $2002
  195. LDA #$20 ;we are drawing to the background address $2153
  196. STA $2006
  197. LDA #$6F
  198. STA $2006
  199. .Loop:
  200. LDA WinTiles,x ;this will look at the tiles defined in the data labeled "WinTiles."
  201. STA $2007
  202. INX
  203. CPX #$08 ;scroll through this loop #$07 times, to get all letters.
  204. BNE .Loop
  205. RTS
  206. .Lose:
  207. LDA $2002
  208. LDA #$20 ;we are drawing to the background address $2153
  209. STA $2006
  210. LDA #$6F
  211. STA $2006
  212. .Loop2:
  213. LDA LoseTiles,x ;this will look at the tiles defined in the data labeled "WinTiles."
  214. STA $2007
  215. INX
  216. CPX #$09 ;scroll through this loop #$07 times, to get all letters.
  217. BNE .Loop2
  218. RTS
  219. ;;draw losing tiles
  220. RTS
  221. .End:
  222. ;;skip all this.
  223. RTS
  224.  
  225. DrawWinScreen2:
  226. LDA WinFlag ;WinFlag is set to #$01 when the game is won or lost.
  227. CMP #$01
  228. BNE .End
  229. LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
  230. LDA WinLose
  231. CMP #$02
  232. BEQ .Lose
  233. LDX #$00
  234. LDA CurrentRow ;CurrentRow is set to #$08 if the player doesn't guess correctly after 7 tries (I think).
  235. CMP #$07
  236. BEQ .Lose
  237.  
  238. ;;draw winning tiles
  239. LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
  240. LDA $2002
  241. LDA #$20 ;we are drawing to the background address $2153
  242. STA $2006
  243. LDA #$8F
  244. STA $2006
  245. .Loop:
  246. LDA WinTiles2,x ;this will look at the tiles defined in the data labeled "WinTiles."
  247. STA $2007
  248. INX
  249. CPX #$08 ;scroll through this loop #$07 times, to get all letters.
  250. BNE .Loop
  251. RTS
  252. .Lose:
  253. LDA $2002
  254. LDA #$20 ;we are drawing to the background address $2153
  255. STA $2006
  256. LDA #$8F
  257. STA $2006
  258. .Loop2:
  259. LDA LoseTiles2,x ;this will look at the tiles defined in the data labeled "WinTiles."
  260. STA $2007
  261. INX
  262. CPX #$09 ;scroll through this loop #$07 times, to get all letters.
  263. BNE .Loop2
  264. RTS
  265. ;;draw losing tiles
  266. RTS
  267. .End:
  268. ;;skip all this.
  269. RTS
  270.  
  271. DrawWinScreen3:
  272. LDA WinFlag ;WinFlag is set to #$01 when the game is won or lost.
  273. CMP #$01
  274. BNE .End
  275. LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
  276. LDA WinLose
  277. CMP #$02
  278. BEQ .Lose
  279. LDX #$00
  280. LDA CurrentRow ;CurrentRow is set to #$08 if the player doesn't guess correctly after 7 tries (I think).
  281. CMP #$07
  282. BEQ .Lose
  283.  
  284. ;;draw winning tiles
  285. LDX #$00 ;make sure the X accumulator is set to #$00 everytime this loop starts
  286. LDA $2002
  287. LDA #$20 ;we are drawing to the background address $2153
  288. STA $2006
  289. LDA #$AF
  290. STA $2006
  291. .Loop:
  292. LDA WinTiles3,x ;this will look at the tiles defined in the data labeled "WinTiles."
  293. STA $2007
  294. INX
  295. CPX #$08 ;scroll through this loop #$07 times, to get all letters.
  296. BNE .Loop
  297. RTS
  298. .Lose:
  299. LDA $2002
  300. LDA #$20 ;we are drawing to the background address $2153
  301. STA $2006
  302. LDA #$AF
  303. STA $2006
  304. .Loop2:
  305. LDA LoseTiles3,x ;this will look at the tiles defined in the data labeled "WinTiles."
  306. STA $2007
  307. INX
  308. CPX #$09 ;scroll through this loop #$07 times, to get all letters.
  309. BNE .Loop2
  310. RTS
  311. ;;draw losing tiles
  312. RTS
  313. .End:
  314. ;;skip all this.
  315. RTS
  316.  
  317. WinTiles: ;this is the tile data for the letters Y,O,U,BLANK,W,I,N
  318. .db $77,$78,$79,$7A,$7B,$7C,$7D,$7E ;you win
  319.  
  320. LoseTiles: ;this is the tile data for the letters Y,O,U,BLANK,L,O,S,E
  321. .db $D4,$D5,$4C,$4D,$D6,$D7,$D8,$D9,$7E ;you lose
  322.  
  323. WinTiles2: ;this is the tile data for the letters Y,O,U,BLANK,W,I,N
  324. .db $87,$88,$89,$8A,$8B,$8C,$8D,$8E ;you win
  325.  
  326. LoseTiles2: ;this is the tile data for the letters Y,O,U,BLANK,L,O,S,E
  327. .db $E4,$E5,$5C,$5D,$E6,$E7,$E8,$E9,$8E ;you lose
  328.  
  329. WinTiles3: ;this is the tile data for the letters Y,O,U,BLANK,W,I,N
  330. .db $97,$98,$99,$9A,$9B,$9C,$9D,$9E ;you win
  331.  
  332. LoseTiles3: ;this is the tile data for the letters Y,O,U,BLANK,L,O,S,E
  333. .db $F4,$F5,$6C,$6D,$F6,$F7,$F8,$F9,$9E ;you lose
  334.  
  335. LoadGameOverNametable:
  336. LDA $2002
  337. LDA #$20
  338. STA $2006
  339. LDA #$00
  340. STA $2006
  341.  
  342. LDA #low(GameOverBackground)
  343. STA AddrLow ; load low bytes of background data
  344. LDA #high(GameOverBackground)
  345. STA AddrHigh ; load high bytes of background data
  346.  
  347. LDX #$04 ; Loop X 4 times
  348. LDY #$00 ; Loop Y 256 times
  349. LoadGameOverBackgroundsLoop:
  350. LDA [AddrLow],y
  351. STA $2007
  352. INY
  353. BNE LoadGameOverBackgroundsLoop
  354. ; Outer loop
  355. INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
  356. DEX ; one chunk done so X = X - 1.
  357. BNE LoadGameOverBackgroundsLoop ; if X isn't zero, do again
  358. RTS
  359.  
  360. LoadGameOverAttribute:
  361. LDA $2002 ; read PPU status to reset the high/low latch
  362. LDA #$23
  363. STA $2006 ; write the high byte of $23C0 address
  364. LDA #$C0
  365. STA $2006 ; write the low byte of $23C0 address
  366. LDX #$00 ; start out at 0
  367. LoadGameOverAttributeLoop:
  368. LDA GameOverAttribute, x ; load data from address (attribute + the value in x)
  369. STA $2007 ; write to PPU
  370. INX ; X = X + 1
  371. CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
  372. BNE LoadGameOverAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
  373. ; if compare was equal to 128, keep going down
  374. RTS
  375.  
  376.  
  377. GameOverPalette:
  378. .db $0f,$29,$18,$2D, $0f,$06,$18,$12, $0f,$38,$18,$1A, $0f,$04,$18,$29 ;;background palette
  379. .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
  380.  
  381. ;;as you can see, I am pulling from all three palettes in the attribute table. some sections are using
  382. ;;palette %01, some are using palette %10, and some are using palette %11.
  383. ;;remember, these are binary numbers. %01=1, %10=2, %11=3.
  384.  
  385. GameOverAttribute:
  386. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  387. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  388. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  389. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  390. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  391. .db %00000000, %00000000, %00000000, %00000000, %00000000, %01000000, %10010000, %00000000
  392. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00001000, %00001111, %00000000
  393. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  394.  
  395. .bank 1
  396. .org $A000
  397.  
  398. SeventhRowGuesses:
  399. ;;four possible color positions per row
  400. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  401. CMP #$00
  402. BNE .1
  403. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  404. STA Choice1
  405. ;;first spot
  406. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  407. .Loop0:
  408. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  409. CMP FirstSpriteColors,x
  410. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  411. INX
  412. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  413. BNE .Loop0
  414. JMP PlaceSecondSprite ;;If not, jump to PlaceSecondSprite
  415. .1:
  416. CMP #$01
  417. BNE .2
  418. ;;second spot
  419. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  420. STA Choice2
  421. LDX #$00
  422. .Loop1:
  423. LDA ColorPosition
  424. CMP FirstSpriteColors,x
  425. BEQ .PlaceFirstSprite
  426. INX
  427. CPX #$03
  428. BNE .Loop1
  429. JMP PlaceSecondSprite
  430. .2:
  431. CMP #$02
  432. BNE .3
  433. ;;third spot
  434. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  435. STA Choice3
  436. LDX #$00
  437. .Loop2:
  438. LDA ColorPosition
  439. CMP FirstSpriteColors,x
  440. BEQ .PlaceFirstSprite
  441. INX
  442. CPX #$03
  443. BNE .Loop2
  444. JMP PlaceSecondSprite
  445. .3:
  446. CMP #$03
  447. BNE .End
  448. ;;fourth spot
  449. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  450. STA Choice4
  451. LDX #$00
  452. .Loop3:
  453. LDA ColorPosition
  454. CMP FirstSpriteColors,x
  455. BEQ .PlaceFirstSprite
  456. INX
  457. CPX #$03
  458. BNE .Loop3
  459. JMP PlaceSecondSprite
  460. .End:
  461. RTS
  462. .PlaceFirstSprite:
  463. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  464. LDY CurrentColor ;;store CurrentColor as Y
  465. .PreLoop:
  466. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  467. BEQ .Continue
  468. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  469. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  470. INX
  471. INX
  472. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  473. .Continue:
  474. LDA $2002 ;;place top half of colored circle
  475. LDA #$23
  476. STA $2006 ;;Hi byte of background tile is $23
  477. TXA
  478. CLC
  479. ADC #$09 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  480. STA $2006 ;;of the bottom row of circles is $2309.
  481. LDA #$61 ;;Store first two tiles of correct color.
  482. STA $2007
  483. LDA #$62
  484. STA $2007
  485.  
  486. LDA #$23 ;;Store bottom two tiles of correct color.
  487. STA $2006
  488. TXA
  489. CLC
  490. ADC #$29
  491. STA $2006
  492. LDA #$63
  493. STA $2007
  494. LDA #$64
  495. STA $2007
  496.  
  497. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  498.  
  499. LDA ColorPosition ;;change attribute color to correct palette
  500. CMP #$00
  501. BNE .Try2
  502. JMP .Palette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  503. .Try2:
  504. CMP #$02
  505. BNE .Try3
  506. JMP .Palette2 ;;if it's ColorPosition 2, use Palette2
  507. .Try3:
  508. CMP #$04
  509. BNE .Done
  510. JMP .Palette3 ;;if it's ColorPosition 4, use Palette3
  511. .Done:
  512. RTS
  513. .Palette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  514. LDA CurrentColor
  515. CMP #$00
  516. BNE .SecondPalette1
  517. LDA $2002 ;;Load PPU for writing
  518. LDA #$23 ;;Load hi byte of attribute location
  519. STA $2006
  520. LDA #$F2 ;;Load lo byte of attribute location
  521. STA $2006
  522. LDA #%00000101 ;;Store new attribute data (From palette 1)
  523. STA $2007
  524. LDA #%00000001 ;;Store this info in a variable
  525. STA Palette1
  526. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  527. RTS
  528. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  529. CMP #$01
  530. BNE .ThirdPalette1
  531. LDA $2002
  532. LDA #$23 ;;change attribute color to first palette
  533. STA $2006
  534. LDA #$F3
  535. STA $2006
  536. LDA #%00000001
  537. STA $2007
  538. LDA #%00000001
  539. STA Palette2
  540. INC CurrentColor
  541. RTS
  542. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  543. CMP #$02
  544. BNE .FourthPalette1
  545. LDA $2002
  546. LDA #$23 ;;change attribute color to first palette
  547. STA $2006
  548. LDA #$F3
  549. STA $2006
  550. LDA Palette2 ;;this circle uses two different attribute locations, so it's more complicated to code.
  551. ORA #%00000100 ;;it uses part of Circle 2's attribute location.
  552. STA $2007
  553.  
  554. LDA #$23
  555. STA $2006
  556. LDA #$F4
  557. STA $2006
  558. LDA #%00000001
  559. STA $2007
  560. LDA #%00000001
  561. STA Palette3
  562. INC CurrentColor
  563. RTS
  564. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  565. LDA $2002
  566. LDA #$23 ;;change attribute color to first palette
  567. STA $2006
  568. LDA #$F4
  569. STA $2006
  570. LDA Palette3 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
  571. ORA #%00000100
  572. STA $2007
  573. LDA #%00000001
  574. STA Palette4
  575. LDA #$00 ;;Reset CurrentColor for next row
  576. STA CurrentColor
  577. LDA #$01
  578. STA Checking
  579. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  580. RTS
  581. .Palette2: ;;same as previous code, except the player is selecting a color using the second palette.
  582. LDA CurrentColor
  583. CMP #$00
  584. BNE .SecondPalette2
  585. LDA $2002
  586. LDA #$23 ;;change attribute color to second palette
  587. STA $2006
  588. LDA #$F2
  589. STA $2006
  590. LDA #%00001010
  591. STA $2007
  592. LDA #%00000010
  593. STA Palette1
  594. INC CurrentColor
  595. RTS
  596. .SecondPalette2:
  597. CMP #$01
  598. BNE .ThirdPalette2
  599. LDA $2002
  600. LDA #$23 ;;change attribute color to second palette
  601. STA $2006
  602. LDA #$F3
  603. STA $2006
  604. LDA #%00000010
  605. STA $2007
  606. LDA #%00000010
  607. STA Palette2
  608. INC CurrentColor
  609. RTS
  610. .ThirdPalette2:
  611. CMP #$02
  612. BNE .FourthPalette2
  613. LDA $2002
  614. LDA #$23 ;;change attribute color to second palette
  615. STA $2006
  616. LDA #$F3
  617. STA $2006
  618. LDA Palette2
  619. ORA #%00001000
  620. STA $2007
  621.  
  622. LDA #$23
  623. STA $2006
  624. LDA #$F4
  625. STA $2006
  626. LDA #%00000010
  627. STA $2007
  628. LDA #%00000010
  629. STA Palette3
  630. INC CurrentColor
  631. RTS
  632. .FourthPalette2:
  633. LDA $2002
  634. LDA #$23 ;;change attribute color to second palette
  635. STA $2006
  636. LDA #$F4
  637. STA $2006
  638. LDA Palette3
  639. ORA #%00001000
  640. STA $2007
  641. LDA #%00000010
  642. STA Palette4
  643. LDA #$00 ;;Reset CurrentColor for next row
  644. STA CurrentColor
  645. LDA #$01
  646. STA Checking
  647. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  648. RTS
  649. .Palette3: ;;same as previous code, except the player is selecting a color using the third palette.
  650. LDA CurrentColor
  651. CMP #$00
  652. BNE .SecondPalette3
  653. LDA $2002
  654. LDA #$23 ;;change attribute color to third palette
  655. STA $2006
  656. LDA #$F2
  657. STA $2006
  658. LDA #%00001111
  659. STA $2007
  660. LDA #%00000011
  661. STA Palette1
  662. INC CurrentColor
  663. RTS
  664. .SecondPalette3:
  665. CMP #$01
  666. BNE .ThirdPalette3
  667. LDA $2002
  668. LDA #$23 ;;change attribute color to third palette
  669. STA $2006
  670. LDA #$F3
  671. STA $2006
  672. LDA #%00000011
  673. STA $2007
  674. LDA #%00000011
  675. STA Palette2
  676. INC CurrentColor
  677. RTS
  678. .ThirdPalette3:
  679. CMP #$02
  680. BNE .FourthPalette3
  681. LDA $2002
  682. LDA #$23 ;;change attribute color to third palette
  683. STA $2006
  684. LDA #$F3
  685. STA $2006
  686. LDA Palette2
  687. ORA #%00001100
  688. STA $2007
  689.  
  690. LDA #$23
  691. STA $2006
  692. LDA #$F4
  693. STA $2006
  694. LDA #%00000011
  695. STA $2007
  696. LDA #%00000011
  697. STA Palette3
  698. INC CurrentColor
  699. RTS
  700. .FourthPalette3:
  701. LDA $2002
  702. LDA #$23 ;;change attribute color to third palette
  703. STA $2006
  704. LDA #$F4
  705. STA $2006
  706. LDA Palette3
  707. ORA #%00001100
  708. STA $2007
  709. LDA #%00000011
  710. STA Palette4
  711. LDA #$00 ;;Reset CurrentColor for next row
  712. STA CurrentColor
  713. LDA #$01
  714. STA Checking
  715. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  716. RTS
  717.  
  718. PlaceSecondSprite: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  719. LDX #$00 ;;This uses background tiles #65-#68.
  720. LDY CurrentColor
  721. .PreLoop:
  722. CPY #$00
  723. BEQ .Continue
  724. DEY
  725. INX
  726. INX
  727. INX
  728. JMP .PreLoop
  729. .Continue:
  730. LDA $2002 ;;place top half of colored circle
  731. LDA #$23
  732. STA $2006
  733. TXA
  734. CLC
  735. ADC #$09
  736. STA $2006
  737. LDA #$65
  738. STA $2007
  739. LDA #$66
  740. STA $2007
  741.  
  742. LDA #$23 ;;place bottom half of colored circle
  743. STA $2006
  744. TXA
  745. CLC
  746. ADC #$29
  747. STA $2006
  748. LDA #$67
  749. STA $2007
  750. LDA #$68
  751. STA $2007
  752.  
  753. ;;ColorPosition is the position in the select your color area
  754. ;;CurrentColor is the current circle in the big gameboard
  755.  
  756. LDA ColorPosition ;;change attribute color to correct palette
  757. CMP #$01
  758. BNE .Try2
  759. JMP .Palette1
  760. .Try2:
  761. CMP #$03
  762. BNE .Try3
  763. JMP .Palette2
  764. .Try3:
  765. CMP #$05
  766. BNE .Done
  767. JMP .Palette3
  768. .Done:
  769. RTS
  770. .Palette1:
  771. LDA CurrentColor
  772. CMP #$00
  773. BNE .SecondPalette1
  774. LDA $2002
  775. LDA #$23 ;;change attribute color to first palette
  776. STA $2006
  777. LDA #$F2
  778. STA $2006
  779. LDA #%00000101
  780. STA $2007
  781. LDA #%00000001
  782. STA Palette1
  783. INC CurrentColor
  784. RTS
  785. .SecondPalette1:
  786. CMP #$01
  787. BNE .ThirdPalette1
  788. LDA $2002
  789. LDA #$23 ;;change attribute color to first palette
  790. STA $2006
  791. LDA #$F3
  792. STA $2006
  793. LDA #%00000001
  794. STA $2007
  795. LDA #%00000001
  796. STA Palette2
  797. INC CurrentColor
  798. RTS
  799. .ThirdPalette1:
  800. CMP #$02
  801. BNE .FourthPalette1
  802. LDA $2002
  803. LDA #$23 ;;change attribute color to first palette
  804. STA $2006
  805. LDA #$F3
  806. STA $2006
  807. LDA Palette2
  808. ORA #%00000100
  809. STA $2007
  810.  
  811. LDA #$23
  812. STA $2006
  813. LDA #$F4
  814. STA $2006
  815. LDA #%00000001
  816. STA $2007
  817. LDA #%00000001
  818. STA Palette3
  819. INC CurrentColor
  820. RTS
  821. .FourthPalette1:
  822. LDA $2002
  823. LDA #$23 ;;change attribute color to first palette
  824. STA $2006
  825. LDA #$F4
  826. STA $2006
  827. LDA Palette3
  828. ORA #%00000100
  829. STA $2007
  830. LDA #%00000001
  831. STA Palette4
  832. LDA #$00 ;;Reset CurrentColor for next row
  833. STA CurrentColor
  834. LDA #$01
  835. STA Checking
  836. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  837. RTS
  838. .Palette2:
  839. LDA CurrentColor
  840. CMP #$00
  841. BNE .SecondPalette2
  842. LDA $2002
  843. LDA #$23 ;;change attribute color to second palette
  844. STA $2006
  845. LDA #$F2
  846. STA $2006
  847. LDA #%00001010
  848. STA $2007
  849. LDA #%00000010
  850. STA Palette1
  851. INC CurrentColor
  852. RTS
  853. .SecondPalette2:
  854. CMP #$01
  855. BNE .ThirdPalette2
  856. LDA $2002
  857. LDA #$23 ;;change attribute color to second palette
  858. STA $2006
  859. LDA #$F3
  860. STA $2006
  861. LDA #%00000010
  862. STA $2007
  863. LDA #%00000010
  864. STA Palette2
  865. INC CurrentColor
  866. RTS
  867. .ThirdPalette2:
  868. CMP #$02
  869. BNE .FourthPalette2
  870. LDA $2002
  871. LDA #$23 ;;change attribute color to second palette
  872. STA $2006
  873. LDA #$F3
  874. STA $2006
  875. LDA Palette2
  876. ORA #%00001000
  877. STA $2007
  878.  
  879. LDA #$23
  880. STA $2006
  881. LDA #$F4
  882. STA $2006
  883. LDA #%00000010
  884. STA $2007
  885. LDA #%00000010
  886. STA Palette3
  887. INC CurrentColor
  888. RTS
  889. .FourthPalette2:
  890. LDA $2002
  891. LDA #$23 ;;change attribute color to second palette
  892. STA $2006
  893. LDA #$F4
  894. STA $2006
  895. LDA Palette3
  896. ORA #%00001000
  897. STA $2007
  898. LDA #%00000010
  899. STA Palette4
  900. LDA #$00 ;;Reset CurrentColor for next row.
  901. STA CurrentColor
  902. LDA #$01
  903. STA Checking
  904. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  905. RTS
  906. .Palette3:
  907. LDA CurrentColor
  908. CMP #$00
  909. BNE .SecondPalette3
  910. LDA $2002
  911. LDA #$23 ;;change attribute color to third palette
  912. STA $2006
  913. LDA #$F2
  914. STA $2006
  915. LDA #%00001111
  916. STA $2007
  917. LDA #%00000011
  918. STA Palette1
  919. INC CurrentColor
  920. RTS
  921. .SecondPalette3:
  922. CMP #$01
  923. BNE .ThirdPalette3
  924. LDA $2002
  925. LDA #$23 ;;change attribute color to third palette
  926. STA $2006
  927. LDA #$F3
  928. STA $2006
  929. LDA #%00000011
  930. STA $2007
  931. LDA #%00000011
  932. STA Palette2
  933. INC CurrentColor
  934. RTS
  935. .ThirdPalette3:
  936. CMP #$02
  937. BNE .FourthPalette3
  938. LDA $2002
  939. LDA #$23 ;;change attribute color to third palette
  940. STA $2006
  941. LDA #$F3
  942. STA $2006
  943. LDA Palette2
  944. ORA #%00001100
  945. STA $2007
  946.  
  947. LDA #$23
  948. STA $2006
  949. LDA #$F4
  950. STA $2006
  951. LDA #%00000011
  952. STA $2007
  953. LDA #%00000011
  954. STA Palette3
  955. INC CurrentColor
  956. RTS
  957. .FourthPalette3:
  958. LDA $2002
  959. LDA #$23 ;;change attribute color to third palette
  960. STA $2006
  961. LDA #$F4
  962. STA $2006
  963. LDA Palette3
  964. ORA #%00001100
  965. STA $2007
  966. LDA #%00000011
  967. STA Palette4
  968. LDA #$00 ;;reset CurrentColor for next row
  969. STA CurrentColor
  970. LDA #$01
  971. STA Checking
  972. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  973. RTS
  974.  
  975. SixthRowGuesses:
  976. ;;four possible color positions per row
  977. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  978. CMP #$00
  979. BNE .1
  980. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  981. STA Choice1
  982. ;;first spot
  983. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  984. .Loop0:
  985. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  986. CMP FirstSpriteColors,x
  987. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  988. INX
  989. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  990. BNE .Loop0
  991. JMP PlaceSecondSprite2 ;;If not, jump to PlaceSecondSprite
  992. .1:
  993. CMP #$01
  994. BNE .2
  995. ;;second spot
  996. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  997. STA Choice2
  998. LDX #$00
  999. .Loop1:
  1000. LDA ColorPosition
  1001. CMP FirstSpriteColors,x
  1002. BEQ .PlaceFirstSprite
  1003. INX
  1004. CPX #$03
  1005. BNE .Loop1
  1006. JMP PlaceSecondSprite2
  1007. .2:
  1008. CMP #$02
  1009. BNE .3
  1010. ;;third spot
  1011. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  1012. STA Choice3
  1013. LDX #$00
  1014. .Loop2:
  1015. LDA ColorPosition
  1016. CMP FirstSpriteColors,x
  1017. BEQ .PlaceFirstSprite
  1018. INX
  1019. CPX #$03
  1020. BNE .Loop2
  1021. JMP PlaceSecondSprite2
  1022. .3:
  1023. CMP #$03
  1024. BNE .End
  1025. ;;fourth spot
  1026. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  1027. STA Choice4
  1028. LDX #$00
  1029. .Loop3:
  1030. LDA ColorPosition
  1031. CMP FirstSpriteColors,x
  1032. BEQ .PlaceFirstSprite
  1033. INX
  1034. CPX #$03
  1035. BNE .Loop3
  1036. JMP PlaceSecondSprite2
  1037. .End:
  1038. RTS
  1039. .PlaceFirstSprite:
  1040. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  1041. LDY CurrentColor ;;store CurrentColor as Y
  1042. .PreLoop:
  1043. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  1044. BEQ .Continue
  1045. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  1046. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  1047. INX
  1048. INX
  1049. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  1050. .Continue:
  1051. LDA $2002 ;;place top half of colored circle
  1052. LDA #$22
  1053. STA $2006 ;;Hi byte of background tile is $23
  1054. TXA
  1055. CLC
  1056. ADC #$A9 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  1057. STA $2006 ;;of the bottom row of circles is $2309.
  1058. LDA #$61 ;;Store first two tiles of correct color.
  1059. STA $2007
  1060. LDA #$62
  1061. STA $2007
  1062.  
  1063. LDA #$22 ;;Store bottom two tiles of correct color.
  1064. STA $2006
  1065. TXA
  1066. CLC
  1067. ADC #$C9
  1068. STA $2006
  1069. LDA #$63
  1070. STA $2007
  1071. LDA #$64
  1072. STA $2007
  1073.  
  1074. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  1075.  
  1076. LDA ColorPosition ;;change attribute color to correct palette
  1077. CMP #$00
  1078. BNE .Try2
  1079. JMP .Palette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  1080. .Try2:
  1081. CMP #$02
  1082. BNE .Try3
  1083. JMP .Palette2 ;;if it's ColorPosition 2, use Palette2
  1084. .Try3:
  1085. CMP #$04
  1086. BNE .Done
  1087. JMP .Palette3 ;;if it's ColorPosition 4, use Palette3
  1088. .Done:
  1089. RTS
  1090. .Palette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  1091. LDA CurrentColor
  1092. CMP #$00
  1093. BNE .SecondPalette1
  1094. LDA $2002 ;;Load PPU for writing
  1095. LDA #$23 ;;Load hi byte of attribute location
  1096. STA $2006
  1097. LDA #$EA ;;Load lo byte of attribute location
  1098. STA $2006
  1099. LDA #%01010101 ;;Store new attribute data (From palette 1)
  1100. STA $2007
  1101.  
  1102. LDA #%01010101 ;;Store this info in a variable
  1103. STA Palette1
  1104. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  1105. RTS
  1106. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  1107. CMP #$01
  1108. BNE .ThirdPalette1
  1109. LDA $2002
  1110. LDA #$23 ;;change attribute color to first palette
  1111. STA $2006
  1112. LDA #$EB
  1113. STA $2006
  1114. LDA #%00010001
  1115. STA $2007
  1116. LDA #%00010001
  1117. STA Palette2
  1118. INC CurrentColor
  1119. RTS
  1120. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  1121. CMP #$02
  1122. BNE .FourthPalette1
  1123. LDA $2002
  1124. LDA #$23 ;;change attribute color to first palette
  1125. STA $2006
  1126. LDA #$EB
  1127. STA $2006
  1128. LDA Palette2 ;;this circle uses two different attribute locations, so it's more complicated to code.
  1129. ORA #%01000100 ;;it uses part of Circle 2's attribute location.
  1130. STA $2007
  1131.  
  1132. LDA #$23
  1133. STA $2006
  1134. LDA #$EC
  1135. STA $2006
  1136. LDA #%00010001
  1137. STA $2007
  1138. LDA #%00010001
  1139. STA Palette3
  1140. INC CurrentColor
  1141. RTS
  1142. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  1143. LDA $2002
  1144. LDA #$23 ;;change attribute color to first palette
  1145. STA $2006
  1146. LDA #$EC
  1147. STA $2006
  1148. LDA Palette3 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
  1149. ORA #%01000100
  1150. STA $2007
  1151. LDA #%00000001
  1152. STA Palette4
  1153. LDA #$00 ;;Reset CurrentColor for next row
  1154. STA CurrentColor
  1155. LDA #$01
  1156. STA Checking
  1157. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1158. RTS
  1159. .Palette2: ;;same as previous code, except the player is selecting a color using the second palette.
  1160. LDA CurrentColor
  1161. CMP #$00
  1162. BNE .SecondPalette2
  1163. LDA $2002
  1164. LDA #$23 ;;change attribute color to second palette
  1165. STA $2006
  1166. LDA #$EA
  1167. STA $2006
  1168. LDA #%10101010
  1169. STA $2007
  1170. LDA #%10101010
  1171. STA Palette1
  1172. INC CurrentColor
  1173. RTS
  1174. .SecondPalette2:
  1175. CMP #$01
  1176. BNE .ThirdPalette2
  1177. LDA $2002
  1178. LDA #$23 ;;change attribute color to second palette
  1179. STA $2006
  1180. LDA #$EB
  1181. STA $2006
  1182. LDA #%00100010
  1183. STA $2007
  1184. LDA #%00100010
  1185. STA Palette2
  1186. INC CurrentColor
  1187. RTS
  1188. .ThirdPalette2:
  1189. CMP #$02
  1190. BNE .FourthPalette2
  1191. LDA $2002
  1192. LDA #$23 ;;change attribute color to second palette
  1193. STA $2006
  1194. LDA #$EB
  1195. STA $2006
  1196. LDA Palette2
  1197. ORA #%10001000
  1198. STA $2007
  1199.  
  1200. LDA #$23
  1201. STA $2006
  1202. LDA #$EC
  1203. STA $2006
  1204. LDA #%00100010
  1205. STA $2007
  1206. LDA #%00100010
  1207. STA Palette3
  1208. INC CurrentColor
  1209. RTS
  1210. .FourthPalette2:
  1211. LDA $2002
  1212. LDA #$23 ;;change attribute color to second palette
  1213. STA $2006
  1214. LDA #$EC
  1215. STA $2006
  1216. LDA Palette3
  1217. ORA #%10001000
  1218. STA $2007
  1219. LDA #%00000010
  1220. STA Palette4
  1221. LDA #$00 ;;Reset CurrentColor for next row
  1222. STA CurrentColor
  1223. LDA #$01
  1224. STA Checking
  1225. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1226. RTS
  1227. .Palette3: ;;same as previous code, except the player is selecting a color using the third palette.
  1228. LDA CurrentColor
  1229. CMP #$00
  1230. BNE .SecondPalette3
  1231. LDA $2002
  1232. LDA #$23 ;;change attribute color to third palette
  1233. STA $2006
  1234. LDA #$EA
  1235. STA $2006
  1236. LDA #%11111111
  1237. STA $2007
  1238. LDA #%11111111
  1239. STA Palette1
  1240. INC CurrentColor
  1241. RTS
  1242. .SecondPalette3:
  1243. CMP #$01
  1244. BNE .ThirdPalette3
  1245. LDA $2002
  1246. LDA #$23 ;;change attribute color to third palette
  1247. STA $2006
  1248. LDA #$EB
  1249. STA $2006
  1250. LDA #%00110011
  1251. STA $2007
  1252. LDA #%00110011
  1253. STA Palette2
  1254. INC CurrentColor
  1255. RTS
  1256. .ThirdPalette3:
  1257. CMP #$02
  1258. BNE .FourthPalette3
  1259. LDA $2002
  1260. LDA #$23 ;;change attribute color to third palette
  1261. STA $2006
  1262. LDA #$EB
  1263. STA $2006
  1264. LDA Palette2
  1265. ORA #%11001100
  1266. STA $2007
  1267.  
  1268. LDA #$23
  1269. STA $2006
  1270. LDA #$EC
  1271. STA $2006
  1272. LDA #%00110011
  1273. STA $2007
  1274. LDA #%00110011
  1275. STA Palette3
  1276. INC CurrentColor
  1277. RTS
  1278. .FourthPalette3:
  1279. LDA $2002
  1280. LDA #$23 ;;change attribute color to third palette
  1281. STA $2006
  1282. LDA #$EC
  1283. STA $2006
  1284. LDA Palette3
  1285. ORA #%11001100
  1286. STA $2007
  1287. LDA #%00000011
  1288. STA Palette4
  1289. LDA #$00 ;;Reset CurrentColor for next row
  1290. STA CurrentColor
  1291. LDA #$01
  1292. STA Checking
  1293. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1294. RTS
  1295.  
  1296. PlaceSecondSprite2: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  1297. LDX #$00 ;;This uses background tiles #65-#68.
  1298. LDY CurrentColor
  1299. .PreLoop:
  1300. CPY #$00
  1301. BEQ .Continue
  1302. DEY
  1303. INX
  1304. INX
  1305. INX
  1306. JMP .PreLoop
  1307. .Continue:
  1308. LDA $2002 ;;place top half of colored circle
  1309. LDA #$22
  1310. STA $2006
  1311. TXA
  1312. CLC
  1313. ADC #$A9
  1314. STA $2006
  1315. LDA #$65
  1316. STA $2007
  1317. LDA #$66
  1318. STA $2007
  1319.  
  1320. LDA #$22 ;;place bottom half of colored circle
  1321. STA $2006
  1322. TXA
  1323. CLC
  1324. ADC #$C9
  1325. STA $2006
  1326. LDA #$67
  1327. STA $2007
  1328. LDA #$68
  1329. STA $2007
  1330.  
  1331. ;;ColorPosition is the position in the select your color area
  1332. ;;CurrentColor is the current circle in the big gameboard
  1333.  
  1334. LDA ColorPosition ;;change attribute color to correct palette
  1335. CMP #$01
  1336. BNE .Try2
  1337. JMP .Palette1
  1338. .Try2:
  1339. CMP #$03
  1340. BNE .Try3
  1341. JMP .Palette2
  1342. .Try3:
  1343. CMP #$05
  1344. BNE .Done
  1345. JMP .Palette3
  1346. .Done:
  1347. RTS
  1348. .Palette1:
  1349. LDA CurrentColor
  1350. CMP #$00
  1351. BNE .SecondPalette1
  1352. LDA $2002
  1353. LDA #$23 ;;change attribute color to first palette
  1354. STA $2006
  1355. LDA #$EA
  1356. STA $2006
  1357. LDA #%01010101
  1358. STA $2007
  1359. LDA #%01010101
  1360. STA Palette1
  1361. INC CurrentColor
  1362. RTS
  1363. .SecondPalette1:
  1364. CMP #$01
  1365. BNE .ThirdPalette1
  1366. LDA $2002
  1367. LDA #$23 ;;change attribute color to first palette
  1368. STA $2006
  1369. LDA #$EB
  1370. STA $2006
  1371. LDA #%00010001
  1372. STA $2007
  1373. LDA #%00010001
  1374. STA Palette2
  1375. INC CurrentColor
  1376. RTS
  1377. .ThirdPalette1:
  1378. CMP #$02
  1379. BNE .FourthPalette1
  1380. LDA $2002
  1381. LDA #$23 ;;change attribute color to first palette
  1382. STA $2006
  1383. LDA #$EB
  1384. STA $2006
  1385. LDA Palette2
  1386. ORA #%01000100
  1387. STA $2007
  1388.  
  1389. LDA #$23
  1390. STA $2006
  1391. LDA #$EC
  1392. STA $2006
  1393. LDA #%00010001
  1394. STA $2007
  1395. LDA #%00010001
  1396. STA Palette3
  1397. INC CurrentColor
  1398. RTS
  1399. .FourthPalette1:
  1400. LDA $2002
  1401. LDA #$23 ;;change attribute color to first palette
  1402. STA $2006
  1403. LDA #$EC
  1404. STA $2006
  1405. LDA Palette3
  1406. ORA #%01000100
  1407. STA $2007
  1408. LDA #%00000001
  1409. STA Palette4
  1410. LDA #$00 ;;Reset CurrentColor for next row
  1411. STA CurrentColor
  1412. LDA #$01
  1413. STA Checking
  1414. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1415. RTS
  1416. .Palette2:
  1417. LDA CurrentColor
  1418. CMP #$00
  1419. BNE .SecondPalette2
  1420. LDA $2002
  1421. LDA #$23 ;;change attribute color to second palette
  1422. STA $2006
  1423. LDA #$EA
  1424. STA $2006
  1425. LDA #%10101010
  1426. STA $2007
  1427. LDA #%10101010
  1428. STA Palette1
  1429. INC CurrentColor
  1430. RTS
  1431. .SecondPalette2:
  1432. CMP #$01
  1433. BNE .ThirdPalette2
  1434. LDA $2002
  1435. LDA #$23 ;;change attribute color to second palette
  1436. STA $2006
  1437. LDA #$EB
  1438. STA $2006
  1439. LDA #%00100010
  1440. STA $2007
  1441. LDA #%00100010
  1442. STA Palette2
  1443. INC CurrentColor
  1444. RTS
  1445. .ThirdPalette2:
  1446. CMP #$02
  1447. BNE .FourthPalette2
  1448. LDA $2002
  1449. LDA #$23 ;;change attribute color to second palette
  1450. STA $2006
  1451. LDA #$EB
  1452. STA $2006
  1453. LDA Palette2
  1454. ORA #%10001000
  1455. STA $2007
  1456.  
  1457. LDA #$23
  1458. STA $2006
  1459. LDA #$EC
  1460. STA $2006
  1461. LDA #%00100010
  1462. STA $2007
  1463. LDA #%00100010
  1464. STA Palette3
  1465. INC CurrentColor
  1466. RTS
  1467. .FourthPalette2:
  1468. LDA $2002
  1469. LDA #$23 ;;change attribute color to second palette
  1470. STA $2006
  1471. LDA #$EC
  1472. STA $2006
  1473. LDA Palette3
  1474. ORA #%10001000
  1475. STA $2007
  1476. LDA #%10000010
  1477. STA Palette4
  1478. LDA #$00 ;;Reset CurrentColor for next row.
  1479. STA CurrentColor
  1480. LDA #$01
  1481. STA Checking
  1482. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1483. RTS
  1484. .Palette3:
  1485. LDA CurrentColor
  1486. CMP #$00
  1487. BNE .SecondPalette3
  1488. LDA $2002
  1489. LDA #$23 ;;change attribute color to third palette
  1490. STA $2006
  1491. LDA #$EA
  1492. STA $2006
  1493. LDA #%11111111
  1494. STA $2007
  1495. LDA #%11111111
  1496. STA Palette1
  1497. INC CurrentColor
  1498. RTS
  1499. .SecondPalette3:
  1500. CMP #$01
  1501. BNE .ThirdPalette3
  1502. LDA $2002
  1503. LDA #$23 ;;change attribute color to third palette
  1504. STA $2006
  1505. LDA #$EB
  1506. STA $2006
  1507. LDA #%00110011
  1508. STA $2007
  1509. LDA #%00110011
  1510. STA Palette2
  1511. INC CurrentColor
  1512. RTS
  1513. .ThirdPalette3:
  1514. CMP #$02
  1515. BNE .FourthPalette3
  1516. LDA $2002
  1517. LDA #$23 ;;change attribute color to third palette
  1518. STA $2006
  1519. LDA #$EB
  1520. STA $2006
  1521. LDA Palette2
  1522. ORA #%11001100
  1523. STA $2007
  1524.  
  1525. LDA #$23
  1526. STA $2006
  1527. LDA #$EC
  1528. STA $2006
  1529. LDA #%00110011
  1530. STA $2007
  1531. LDA #%00110011
  1532. STA Palette3
  1533. INC CurrentColor
  1534. RTS
  1535. .FourthPalette3:
  1536. LDA $2002
  1537. LDA #$23 ;;change attribute color to third palette
  1538. STA $2006
  1539. LDA #$EC
  1540. STA $2006
  1541. LDA Palette3
  1542. ORA #%11001100
  1543. STA $2007
  1544. LDA #%00000011
  1545. STA Palette4
  1546. LDA #$00 ;;reset CurrentColor for next row
  1547. STA CurrentColor
  1548. LDA #$01
  1549. STA Checking
  1550. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1551. RTS
  1552.  
  1553. FifthRowGuesses:
  1554. ;;four possible color positions per row
  1555. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  1556. CMP #$00
  1557. BNE .1
  1558. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  1559. STA Choice1
  1560. ;;first spot
  1561. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  1562. .Loop0:
  1563. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  1564. CMP FirstSpriteColors,x
  1565. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  1566. INX
  1567. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  1568. BNE .Loop0
  1569. JMP PlaceSecondSprite3 ;;If not, jump to PlaceSecondSprite
  1570. .1:
  1571. CMP #$01
  1572. BNE .2
  1573. ;;second spot
  1574. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  1575. STA Choice2
  1576. LDX #$00
  1577. .Loop1:
  1578. LDA ColorPosition
  1579. CMP FirstSpriteColors,x
  1580. BEQ .PlaceFirstSprite
  1581. INX
  1582. CPX #$03
  1583. BNE .Loop1
  1584. JMP PlaceSecondSprite3
  1585. .2:
  1586. CMP #$02
  1587. BNE .3
  1588. ;;third spot
  1589. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  1590. STA Choice3
  1591. LDX #$00
  1592. .Loop2:
  1593. LDA ColorPosition
  1594. CMP FirstSpriteColors,x
  1595. BEQ .PlaceFirstSprite
  1596. INX
  1597. CPX #$03
  1598. BNE .Loop2
  1599. JMP PlaceSecondSprite3
  1600. .3:
  1601. CMP #$03
  1602. BNE .End
  1603. ;;fourth spot
  1604. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  1605. STA Choice4
  1606. LDX #$00
  1607. .Loop3:
  1608. LDA ColorPosition
  1609. CMP FirstSpriteColors,x
  1610. BEQ .PlaceFirstSprite
  1611. INX
  1612. CPX #$03
  1613. BNE .Loop3
  1614. JMP PlaceSecondSprite3
  1615. .End:
  1616. RTS
  1617. .PlaceFirstSprite:
  1618. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  1619. LDY CurrentColor ;;store CurrentColor as Y
  1620. .PreLoop:
  1621. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  1622. BEQ .Continue
  1623. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  1624. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  1625. INX
  1626. INX
  1627. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  1628. .Continue:
  1629. LDA $2002 ;;place top half of colored circle
  1630. LDA #$22
  1631. STA $2006 ;;Hi byte of background tile is $23
  1632. TXA
  1633. CLC
  1634. ADC #$49 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  1635. STA $2006 ;;of the bottom row of circles is $2309.
  1636. LDA #$61 ;;Store first two tiles of correct color.
  1637. STA $2007
  1638. LDA #$62
  1639. STA $2007
  1640.  
  1641. LDA #$22 ;;Store bottom two tiles of correct color.
  1642. STA $2006
  1643. TXA
  1644. CLC
  1645. ADC #$69
  1646. STA $2006
  1647. LDA #$63
  1648. STA $2007
  1649. LDA #$64
  1650. STA $2007
  1651.  
  1652. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  1653.  
  1654. LDA ColorPosition ;;change attribute color to correct palette
  1655. CMP #$00
  1656. BNE .Try2
  1657. JMP FifthRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  1658. .Try2:
  1659. CMP #$02
  1660. BNE .Try3
  1661. JMP FifthRowPalette2 ;;if it's ColorPosition 2, use Palette2
  1662. .Try3:
  1663. CMP #$04
  1664. BNE .Done
  1665. JMP FifthRowPalette3 ;;if it's ColorPosition 4, use Palette3
  1666. .Done:
  1667. RTS
  1668. FifthRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  1669. LDA CurrentColor
  1670. CMP #$00
  1671. BNE .SecondPalette1
  1672. LDA $2002 ;;Load PPU for writing
  1673. LDA #$23 ;;Load hi byte of attribute location
  1674. STA $2006
  1675. LDA #$E2 ;;Load lo byte of attribute location
  1676. STA $2006
  1677. LDA #%01010000 ;;Store new attribute data (From palette 1)
  1678. STA $2007
  1679. STA Palette1
  1680. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  1681. RTS
  1682. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  1683. CMP #$01
  1684. BNE .ThirdPalette1
  1685. LDA $2002
  1686. LDA #$23 ;;change attribute color to first palette
  1687. STA $2006
  1688. LDA #$E3
  1689. STA $2006
  1690. LDA #%00010000
  1691. STA $2007
  1692. STA Palette2
  1693. INC CurrentColor
  1694. RTS
  1695. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  1696. CMP #$02
  1697. BNE .FourthPalette1
  1698. LDA $2002
  1699. LDA #$23 ;;change attribute color to first palette
  1700. STA $2006
  1701. LDA #$E3
  1702. STA $2006
  1703. LDA Palette2 ;;this circle uses two different attribute locations, so it's more complicated to code.
  1704. ORA #%01000000 ;;it uses part of Circle 2's attribute location.
  1705. STA $2007
  1706. STA Palette3
  1707. STA Palette3Dash1
  1708.  
  1709. LDA #$23
  1710. STA $2006
  1711. LDA #$E4
  1712. STA $2006
  1713. LDA #%00010000
  1714. STA $2007
  1715. STA Palette3Dash2
  1716. INC CurrentColor
  1717. RTS
  1718. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  1719. LDA $2002
  1720. LDA #$23 ;;change attribute color to first palette
  1721. STA $2006
  1722. LDA #$E4
  1723. STA $2006
  1724. LDA #%01000000
  1725. ORA Palette3Dash2
  1726. STA $2007
  1727. STA Palette4
  1728. LDA #$00 ;;Reset CurrentColor for next row
  1729. STA CurrentColor
  1730. LDA #$01
  1731. STA Checking
  1732. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1733. RTS
  1734. FifthRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
  1735. LDA CurrentColor
  1736. CMP #$00
  1737. BNE .SecondPalette2
  1738. LDA $2002
  1739. LDA #$23 ;;change attribute color to second palette
  1740. STA $2006
  1741. LDA #$E2
  1742. STA $2006
  1743. LDA #%10100000
  1744. STA $2007
  1745. STA Palette1
  1746. INC CurrentColor
  1747. RTS
  1748. .SecondPalette2:
  1749. CMP #$01
  1750. BNE .ThirdPalette2
  1751. LDA $2002
  1752. LDA #$23 ;;change attribute color to second palette
  1753. STA $2006
  1754. LDA #$E3
  1755. STA $2006
  1756. LDA #%00100000
  1757. STA $2007
  1758. STA Palette2
  1759. INC CurrentColor
  1760. RTS
  1761. .ThirdPalette2:
  1762. CMP #$02
  1763. BNE .FourthPalette2
  1764. LDA $2002
  1765. LDA #$23 ;;change attribute color to second palette
  1766. STA $2006
  1767. LDA #$E3
  1768. STA $2006
  1769. LDA Palette2
  1770. ORA #%10000000
  1771. STA $2007
  1772. STA Palette3
  1773. STA Palette3Dash1
  1774.  
  1775. LDA #$23
  1776. STA $2006
  1777. LDA #$E4
  1778. STA $2006
  1779. LDA #%00100000
  1780. STA $2007
  1781. STA Palette3Dash2
  1782. INC CurrentColor
  1783. RTS
  1784. .FourthPalette2:
  1785. LDA $2002
  1786. LDA #$23 ;;change attribute color to second palette
  1787. STA $2006
  1788. LDA #$E4
  1789. STA $2006
  1790. LDA #%10000000
  1791. ORA Palette3Dash2
  1792. STA $2007
  1793. STA Palette4
  1794. LDA #$00 ;;Reset CurrentColor for next row
  1795. STA CurrentColor
  1796. LDA #$01
  1797. STA Checking
  1798. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1799. RTS
  1800. FifthRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
  1801. LDA CurrentColor
  1802. CMP #$00
  1803. BNE .SecondPalette3
  1804. LDA $2002
  1805. LDA #$23 ;;change attribute color to third palette
  1806. STA $2006
  1807. LDA #$E2
  1808. STA $2006
  1809. LDA #%11110000
  1810. STA $2007
  1811. STA Palette1
  1812. INC CurrentColor
  1813. RTS
  1814. .SecondPalette3:
  1815. CMP #$01
  1816. BNE .ThirdPalette3
  1817. LDA $2002
  1818. LDA #$23 ;;change attribute color to third palette
  1819. STA $2006
  1820. LDA #$E3
  1821. STA $2006
  1822. LDA #%00110000
  1823. STA $2007
  1824. STA Palette2
  1825. INC CurrentColor
  1826. RTS
  1827. .ThirdPalette3:
  1828. CMP #$02
  1829. BNE .FourthPalette3
  1830. LDA $2002
  1831. LDA #$23 ;;change attribute color to third palette
  1832. STA $2006
  1833. LDA #$E3
  1834. STA $2006
  1835. LDA Palette2
  1836. ORA #%11000000
  1837. STA $2007
  1838. STA Palette3
  1839. STA Palette3Dash1
  1840.  
  1841. LDA #$23
  1842. STA $2006
  1843. LDA #$E4
  1844. STA $2006
  1845. LDA #%00110000
  1846. STA $2007
  1847. STA Palette3Dash2
  1848. INC CurrentColor
  1849. RTS
  1850. .FourthPalette3:
  1851. LDA $2002
  1852. LDA #$23 ;;change attribute color to third palette
  1853. STA $2006
  1854. LDA #$E4
  1855. STA $2006
  1856. LDA Palette3
  1857. LDA #%11000000
  1858. ORA Palette3Dash2
  1859. STA $2007
  1860. STA Palette4
  1861. LDA #$00 ;;reset CurrentColor for next row
  1862. STA CurrentColor
  1863. LDA #$01
  1864. STA Checking
  1865. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  1866. RTS
  1867.  
  1868. PlaceSecondSprite3: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  1869. LDX #$00 ;;This uses background tiles #65-#68.
  1870. LDY CurrentColor
  1871. .PreLoop:
  1872. CPY #$00
  1873. BEQ .Continue
  1874. DEY
  1875. INX
  1876. INX
  1877. INX
  1878. JMP .PreLoop
  1879. .Continue:
  1880. LDA $2002 ;;place top half of colored circle
  1881. LDA #$22
  1882. STA $2006
  1883. TXA
  1884. CLC
  1885. ADC #$49
  1886. STA $2006
  1887. LDA #$65
  1888. STA $2007
  1889. LDA #$66
  1890. STA $2007
  1891.  
  1892. LDA #$22 ;;place bottom half of colored circle
  1893. STA $2006
  1894. TXA
  1895. CLC
  1896. ADC #$69
  1897. STA $2006
  1898. LDA #$67
  1899. STA $2007
  1900. LDA #$68
  1901. STA $2007
  1902.  
  1903. ;;ColorPosition is the position in the select your color area
  1904. ;;CurrentColor is the current circle in the big gameboard
  1905.  
  1906. LDA ColorPosition ;;change attribute color to correct palette
  1907. CMP #$01
  1908. BNE .Try2
  1909. JMP FifthRowPalette1
  1910. .Try2:
  1911. CMP #$03
  1912. BNE .Try3
  1913. JMP FifthRowPalette2
  1914. .Try3:
  1915. CMP #$05
  1916. BNE .Done
  1917. JMP FifthRowPalette3
  1918. .Done:
  1919. RTS
  1920.  
  1921. FourthRowGuesses:
  1922. ;;four possible color positions per row
  1923. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  1924. CMP #$00
  1925. BNE .1
  1926. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  1927. STA Choice1
  1928. ;;first spot
  1929. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  1930. .Loop0:
  1931. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  1932. CMP FirstSpriteColors,x
  1933. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  1934. INX
  1935. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  1936. BNE .Loop0
  1937. JMP PlaceSecondSprite4 ;;If not, jump to PlaceSecondSprite
  1938. .1:
  1939. CMP #$01
  1940. BNE .2
  1941. ;;second spot
  1942. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  1943. STA Choice2
  1944. LDX #$00
  1945. .Loop1:
  1946. LDA ColorPosition
  1947. CMP FirstSpriteColors,x
  1948. BEQ .PlaceFirstSprite
  1949. INX
  1950. CPX #$03
  1951. BNE .Loop1
  1952. JMP PlaceSecondSprite4
  1953. .2:
  1954. CMP #$02
  1955. BNE .3
  1956. ;;third spot
  1957. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  1958. STA Choice3
  1959. LDX #$00
  1960. .Loop2:
  1961. LDA ColorPosition
  1962. CMP FirstSpriteColors,x
  1963. BEQ .PlaceFirstSprite
  1964. INX
  1965. CPX #$03
  1966. BNE .Loop2
  1967. JMP PlaceSecondSprite4
  1968. .3:
  1969. CMP #$03
  1970. BNE .End
  1971. ;;fourth spot
  1972. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  1973. STA Choice4
  1974. LDX #$00
  1975. .Loop3:
  1976. LDA ColorPosition
  1977. CMP FirstSpriteColors,x
  1978. BEQ .PlaceFirstSprite
  1979. INX
  1980. CPX #$03
  1981. BNE .Loop3
  1982. JMP PlaceSecondSprite4
  1983. .End:
  1984. RTS
  1985. .PlaceFirstSprite:
  1986. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  1987. LDY CurrentColor ;;store CurrentColor as Y
  1988. .PreLoop:
  1989. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  1990. BEQ .Continue
  1991. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  1992. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  1993. INX
  1994. INX
  1995. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  1996. .Continue:
  1997. LDA $2002 ;;place top half of colored circle
  1998. LDA #$21
  1999. STA $2006 ;;Hi byte of background tile is $23
  2000. TXA
  2001. CLC
  2002. ADC #$E9 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  2003. STA $2006 ;;of the bottom row of circles is $2309.
  2004. LDA #$61 ;;Store first two tiles of correct color.
  2005. STA $2007
  2006. LDA #$62
  2007. STA $2007
  2008.  
  2009. LDA #$22 ;;Store bottom two tiles of correct color.
  2010. STA $2006
  2011. TXA
  2012. CLC
  2013. ADC #$09
  2014. STA $2006
  2015. LDA #$63
  2016. STA $2007
  2017. LDA #$64
  2018. STA $2007
  2019.  
  2020. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  2021.  
  2022. LDA ColorPosition ;;change attribute color to correct palette
  2023. CMP #$00
  2024. BNE .Try2
  2025. JMP FourthRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  2026. .Try2:
  2027. CMP #$02
  2028. BNE .Try3
  2029. JMP FourthRowPalette2 ;;if it's ColorPosition 2, use Palette2
  2030. .Try3:
  2031. CMP #$04
  2032. BNE .Done
  2033. JMP FourthRowPalette3 ;;if it's ColorPosition 4, use Palette3
  2034. .Done:
  2035. RTS
  2036. FourthRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  2037. LDA CurrentColor
  2038. CMP #$00
  2039. BNE .SecondPalette1
  2040. LDA $2002 ;;Load PPU for writing
  2041. LDA #$23 ;;Load hi byte of attribute location
  2042. STA $2006
  2043. LDA #$E2 ;;Load lo byte of attribute location
  2044. STA $2006
  2045. LDA Palette1
  2046. ORA #%00000101 ;;Store new attribute data (From palette 1)
  2047. STA $2007
  2048.  
  2049. LDA #$23
  2050. STA $2006
  2051. LDA #$DA
  2052. STA $2006
  2053. LDA #%01010000
  2054. STA $2007
  2055. STA Palette1
  2056. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2057. RTS
  2058. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  2059. CMP #$01
  2060. BNE .ThirdPalette1
  2061. LDA $2002
  2062. LDA #$23 ;;change attribute color to first palette
  2063. STA $2006
  2064. LDA #$E3
  2065. STA $2006
  2066. LDA #%00000001
  2067. ORA Palette2
  2068. ORA Palette3Dash1
  2069. STA $2007
  2070. STA Palette2Bottom
  2071.  
  2072. LDA #$23
  2073. STA $2006
  2074. LDA #$DB
  2075. STA $2006
  2076. LDA #%00010000
  2077. STA $2007
  2078. STA Palette2
  2079. INC CurrentColor
  2080. RTS
  2081. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  2082. CMP #$02
  2083. BNE .FourthPalette1
  2084. LDA $2002
  2085. LDA #$23 ;;change attribute color to first palette
  2086. STA $2006
  2087. LDA #$E3
  2088. STA $2006
  2089. LDA #%00000100
  2090. ORA Palette2Bottom
  2091. ORA Palette3Dash1
  2092. STA $2007
  2093. STA Palette3
  2094.  
  2095. LDA #$23
  2096. STA $2006
  2097. LDA #$E4
  2098. STA $2006
  2099. LDA #%00000001
  2100. ORA Palette3Dash2
  2101. ORA Palette4
  2102. STA $2007
  2103. STA Palette3Dash2
  2104.  
  2105. LDA #$23
  2106. STA $2006
  2107. LDA #$DB
  2108. STA $2006
  2109. LDA #%01000000
  2110. ORA Palette2
  2111. STA $2007
  2112. STA Palette3Dash1
  2113.  
  2114. LDA #$23
  2115. STA $2006
  2116. LDA #$DC
  2117. STA $2006
  2118. LDA #%00010000
  2119. STA $2007
  2120. STA Palette3
  2121. INC CurrentColor
  2122. RTS
  2123. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  2124. LDA $2002
  2125. LDA #$23 ;;change attribute color to first palette
  2126. STA $2006
  2127. LDA #$E4
  2128. STA $2006
  2129. LDA #%00000100 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
  2130. ORA Palette4
  2131. ORA Palette3Dash2
  2132. STA $2007
  2133.  
  2134. LDA #$23
  2135. STA $2006
  2136. LDA #$DC
  2137. STA $2006
  2138. LDA #%01000000
  2139. ORA Palette3
  2140. STA $2007
  2141. STA Palette4Dash2
  2142.  
  2143. LDA #$00 ;;Reset CurrentColor for next row
  2144. STA CurrentColor
  2145. LDA #$01
  2146. STA Checking
  2147. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2148. RTS
  2149. FourthRowPalette2: ;;set Palette for first choice, assuming CurrentColor is #00.
  2150. LDA CurrentColor
  2151. CMP #$00
  2152. BNE .SecondPalette2
  2153. LDA $2002 ;;Load PPU for writing
  2154. LDA #$23 ;;Load hi byte of attribute location
  2155. STA $2006
  2156. LDA #$E2 ;;Load lo byte of attribute location
  2157. STA $2006
  2158. LDA Palette1
  2159. ORA #%00001010 ;;Store new attribute data (From palette 1)
  2160. STA $2007
  2161.  
  2162. LDA #$23
  2163. STA $2006
  2164. LDA #$DA
  2165. STA $2006
  2166. LDA #%10100000
  2167. STA $2007
  2168. STA Palette1
  2169. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2170. RTS
  2171. .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
  2172. CMP #$01
  2173. BNE .ThirdPalette2
  2174. LDA $2002
  2175. LDA #$23 ;;change attribute color to first palette
  2176. STA $2006
  2177. LDA #$E3
  2178. STA $2006
  2179. LDA #%00000010
  2180. ORA Palette2
  2181. ORA Palette3Dash1
  2182. STA $2007
  2183. STA Palette2Bottom
  2184.  
  2185. LDA #$23
  2186. STA $2006
  2187. LDA #$DB
  2188. STA $2006
  2189. LDA #%00100000
  2190. STA $2007
  2191. STA Palette2
  2192. INC CurrentColor
  2193. RTS
  2194. .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
  2195. CMP #$02
  2196. BNE .FourthPalette2
  2197. LDA $2002
  2198. LDA #$23 ;;change attribute color to first palette
  2199. STA $2006
  2200. LDA #$E3
  2201. STA $2006
  2202. LDA #%00001000
  2203. ORA Palette2Bottom
  2204. ORA Palette3Dash1
  2205. STA $2007
  2206. STA Palette3
  2207.  
  2208. LDA #$23
  2209. STA $2006
  2210. LDA #$E4
  2211. STA $2006
  2212. LDA #%00000010
  2213. ORA Palette3Dash2
  2214. ORA Palette4
  2215. STA $2007
  2216. STA Palette3Dash2
  2217.  
  2218. LDA #$23
  2219. STA $2006
  2220. LDA #$DB
  2221. STA $2006
  2222. LDA #%10000000
  2223. ORA Palette2
  2224. STA $2007
  2225. STA Palette3Dash1
  2226.  
  2227. LDA #$23
  2228. STA $2006
  2229. LDA #$DC
  2230. STA $2006
  2231. LDA #%00100000
  2232. STA $2007
  2233. STA Palette3
  2234. INC CurrentColor
  2235. RTS
  2236. .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
  2237. LDA $2002
  2238. LDA #$23 ;;change attribute color to first palette
  2239. STA $2006
  2240. LDA #$E4
  2241. STA $2006
  2242. LDA #%00001000 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
  2243. ORA Palette4
  2244. ORA Palette3Dash2
  2245. STA $2007
  2246.  
  2247. LDA #$23
  2248. STA $2006
  2249. LDA #$DC
  2250. STA $2006
  2251. LDA #%10000000
  2252. ORA Palette3
  2253. STA $2007
  2254. STA Palette4Dash2
  2255.  
  2256. LDA #$00 ;;Reset CurrentColor for next row
  2257. STA CurrentColor
  2258. LDA #$01
  2259. STA Checking
  2260. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2261. RTS
  2262. FourthRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
  2263. LDA CurrentColor
  2264. CMP #$00
  2265. BNE .SecondPalette3
  2266. LDA $2002 ;;Load PPU for writing
  2267. LDA #$23 ;;Load hi byte of attribute location
  2268. STA $2006
  2269. LDA #$E2 ;;Load lo byte of attribute location
  2270. STA $2006
  2271. LDA Palette1
  2272. ORA #%00001111 ;;Store new attribute data (From palette 1)
  2273. STA $2007
  2274.  
  2275. LDA #$23
  2276. STA $2006
  2277. LDA #$DA
  2278. STA $2006
  2279. LDA #%11110000
  2280. STA $2007
  2281. STA Palette1
  2282. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2283. RTS
  2284. .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
  2285. CMP #$01
  2286. BNE .ThirdPalette3
  2287. LDA $2002
  2288. LDA #$23 ;;change attribute color to first palette
  2289. STA $2006
  2290. LDA #$E3
  2291. STA $2006
  2292. LDA #%00000011
  2293. ORA Palette2
  2294. ORA Palette3Dash1
  2295. STA $2007
  2296. STA Palette2Bottom
  2297.  
  2298. LDA #$23
  2299. STA $2006
  2300. LDA #$DB
  2301. STA $2006
  2302. LDA #%00110000
  2303. STA $2007
  2304. STA Palette2
  2305. INC CurrentColor
  2306. RTS
  2307. .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
  2308. CMP #$02
  2309. BNE .FourthPalette3
  2310. LDA $2002
  2311. LDA #$23 ;;change attribute color to first palette
  2312. STA $2006
  2313. LDA #$E3
  2314. STA $2006
  2315. LDA #%00001100
  2316. ORA Palette2Bottom
  2317. ORA Palette3Dash1
  2318. STA $2007
  2319. STA Palette3
  2320.  
  2321. LDA #$23
  2322. STA $2006
  2323. LDA #$E4
  2324. STA $2006
  2325. LDA #%00000011
  2326. ORA Palette3Dash2
  2327. ORA Palette4
  2328. STA $2007
  2329. STA Palette3Dash2
  2330.  
  2331. LDA #$23
  2332. STA $2006
  2333. LDA #$DB
  2334. STA $2006
  2335. LDA #%11000000
  2336. ORA Palette2
  2337. STA $2007
  2338. STA Palette3Dash1
  2339.  
  2340. LDA #$23
  2341. STA $2006
  2342. LDA #$DC
  2343. STA $2006
  2344. LDA #%00110000
  2345. STA $2007
  2346. STA Palette3
  2347. INC CurrentColor
  2348. RTS
  2349. .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
  2350. LDA $2002
  2351. LDA #$23 ;;change attribute color to first palette
  2352. STA $2006
  2353. LDA #$E4
  2354. STA $2006
  2355. LDA #%00001100 ;;this circle uses part of the third circle's attribute location, so it's more complciated to code.
  2356. ORA Palette4
  2357. ORA Palette3Dash2
  2358. STA $2007
  2359.  
  2360. LDA #$23
  2361. STA $2006
  2362. LDA #$DC
  2363. STA $2006
  2364. LDA #%11000000
  2365. ORA Palette3
  2366. STA $2007
  2367. STA Palette4Dash2
  2368.  
  2369. LDA #$00 ;;Reset CurrentColor for next row
  2370. STA CurrentColor
  2371. LDA #$01
  2372. STA Checking
  2373. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2374. RTS
  2375.  
  2376. PlaceSecondSprite4: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  2377. LDX #$00 ;;This uses background tiles #65-#68.
  2378. LDY CurrentColor
  2379. .PreLoop:
  2380. CPY #$00
  2381. BEQ .Continue
  2382. DEY
  2383. INX
  2384. INX
  2385. INX
  2386. JMP .PreLoop
  2387. .Continue:
  2388. LDA $2002 ;;place top half of colored circle
  2389. LDA #$21
  2390. STA $2006
  2391. TXA
  2392. CLC
  2393. ADC #$E9
  2394. STA $2006
  2395. LDA #$65
  2396. STA $2007
  2397. LDA #$66
  2398. STA $2007
  2399.  
  2400. LDA #$22 ;;place bottom half of colored circle
  2401. STA $2006
  2402. TXA
  2403. CLC
  2404. ADC #$09
  2405. STA $2006
  2406. LDA #$67
  2407. STA $2007
  2408. LDA #$68
  2409. STA $2007
  2410.  
  2411. ;;ColorPosition is the position in the select your color area
  2412. ;;CurrentColor is the current circle in the big gameboard
  2413.  
  2414. LDA ColorPosition ;;change attribute color to correct palette
  2415. CMP #$01
  2416. BNE .Try2
  2417. JMP FourthRowPalette1
  2418. .Try2:
  2419. CMP #$03
  2420. BNE .Try3
  2421. JMP FourthRowPalette2
  2422. .Try3:
  2423. CMP #$05
  2424. BNE .Done
  2425. JMP FourthRowPalette3
  2426. .Done:
  2427. RTS
  2428.  
  2429. ThirdRowGuesses:
  2430. ;;four possible color positions per row
  2431. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  2432. CMP #$00
  2433. BNE .1
  2434. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  2435. STA Choice1
  2436. ;;first spot
  2437. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  2438. .Loop0:
  2439. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  2440. CMP FirstSpriteColors,x
  2441. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  2442. INX
  2443. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  2444. BNE .Loop0
  2445. JMP PlaceSecondSprite5 ;;If not, jump to PlaceSecondSprite
  2446. .1:
  2447. CMP #$01
  2448. BNE .2
  2449. ;;second spot
  2450. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  2451. STA Choice2
  2452. LDX #$00
  2453. .Loop1:
  2454. LDA ColorPosition
  2455. CMP FirstSpriteColors,x
  2456. BEQ .PlaceFirstSprite
  2457. INX
  2458. CPX #$03
  2459. BNE .Loop1
  2460. JMP PlaceSecondSprite5
  2461. .2:
  2462. CMP #$02
  2463. BNE .3
  2464. ;;third spot
  2465. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  2466. STA Choice3
  2467. LDX #$00
  2468. .Loop2:
  2469. LDA ColorPosition
  2470. CMP FirstSpriteColors,x
  2471. BEQ .PlaceFirstSprite
  2472. INX
  2473. CPX #$03
  2474. BNE .Loop2
  2475. JMP PlaceSecondSprite5
  2476. .3:
  2477. CMP #$03
  2478. BNE .End
  2479. ;;fourth spot
  2480. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  2481. STA Choice4
  2482. LDX #$00
  2483. .Loop3:
  2484. LDA ColorPosition
  2485. CMP FirstSpriteColors,x
  2486. BEQ .PlaceFirstSprite
  2487. INX
  2488. CPX #$03
  2489. BNE .Loop3
  2490. JMP PlaceSecondSprite5
  2491. .End:
  2492. RTS
  2493. .PlaceFirstSprite:
  2494. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  2495. LDY CurrentColor ;;store CurrentColor as Y
  2496. .PreLoop:
  2497. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  2498. BEQ .Continue
  2499. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  2500. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  2501. INX
  2502. INX
  2503. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  2504. .Continue:
  2505. LDA $2002 ;;place top half of colored circle
  2506. LDA #$21
  2507. STA $2006 ;;Hi byte of background tile is $23
  2508. TXA
  2509. CLC
  2510. ADC #$89 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  2511. STA $2006 ;;of the bottom row of circles is $2309.
  2512. LDA #$61 ;;Store first two tiles of correct color.
  2513. STA $2007
  2514. LDA #$62
  2515. STA $2007
  2516.  
  2517. LDA #$21 ;;Store bottom two tiles of correct color.
  2518. STA $2006
  2519. TXA
  2520. CLC
  2521. ADC #$A9
  2522. STA $2006
  2523. LDA #$63
  2524. STA $2007
  2525. LDA #$64
  2526. STA $2007
  2527.  
  2528. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  2529.  
  2530. LDA ColorPosition ;;change attribute color to correct palette
  2531. CMP #$00
  2532. BNE .Try2
  2533. JMP ThirdRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  2534. .Try2:
  2535. CMP #$02
  2536. BNE .Try3
  2537. JMP ThirdRowPalette2 ;;if it's ColorPosition 2, use Palette2
  2538. .Try3:
  2539. CMP #$04
  2540. BNE .Done
  2541. JMP ThirdRowPalette3 ;;if it's ColorPosition 4, use Palette3
  2542. .Done:
  2543. RTS
  2544. ThirdRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  2545. LDA CurrentColor
  2546. CMP #$00
  2547. BNE .SecondPalette1
  2548. LDA $2002 ;;Load PPU for writing
  2549. LDA #$23 ;;Load hi byte of attribute location
  2550. STA $2006
  2551. LDA #$DA ;;Load lo byte of attribute location
  2552. STA $2006
  2553. LDA #%00000101 ;;Store new attribute data (From palette 1)
  2554. ORA Palette1
  2555. STA $2007
  2556. STA Palette1
  2557. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2558. RTS
  2559. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  2560. CMP #$01
  2561. BNE .ThirdPalette1
  2562. LDA $2002
  2563. LDA #$23 ;;change attribute color to first palette
  2564. STA $2006
  2565. LDA #$DB
  2566. STA $2006
  2567. LDA #%00000001
  2568. ORA Palette2
  2569. ORA Palette3Dash1
  2570. STA $2007
  2571. STA Palette2
  2572. INC CurrentColor
  2573. RTS
  2574. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  2575. CMP #$02
  2576. BNE .FourthPalette1
  2577. LDA $2002
  2578.  
  2579. LDA #$23
  2580. STA $2006
  2581. LDA #$DB
  2582. STA $2006
  2583. LDA #%00000100
  2584. ORA Palette2
  2585. STA $2007
  2586.  
  2587. LDA #$23 ;;change attribute color to first palette
  2588. STA $2006
  2589. LDA #$DC
  2590. STA $2006
  2591. LDA #%00000001
  2592. ORA Palette4Dash2
  2593. ; ORA Palette2
  2594. STA $2007
  2595. STA Palette3
  2596. ; STA Palette3Dash1
  2597.  
  2598. INC CurrentColor
  2599. RTS
  2600. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  2601. LDA $2002
  2602. LDA #$23 ;;change attribute color to first palette
  2603. STA $2006
  2604. LDA #$DC
  2605. STA $2006
  2606. LDA #%00000100
  2607. ORA Palette3
  2608. STA $2007
  2609. STA Palette4
  2610. LDA #$00 ;;Reset CurrentColor for next row
  2611. STA CurrentColor
  2612. LDA #$01
  2613. STA Checking
  2614. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2615. RTS
  2616. ThirdRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
  2617. LDA CurrentColor
  2618. CMP #$00
  2619. BNE .SecondPalette2
  2620. LDA $2002 ;;Load PPU for writing
  2621. LDA #$23 ;;Load hi byte of attribute location
  2622. STA $2006
  2623. LDA #$DA ;;Load lo byte of attribute location
  2624. STA $2006
  2625. LDA #%00001010 ;;Store new attribute data (From palette 1)
  2626. ORA Palette1
  2627. STA $2007
  2628. STA Palette1
  2629. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2630. RTS
  2631. .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
  2632. CMP #$01
  2633. BNE .ThirdPalette2
  2634. LDA $2002
  2635. LDA #$23 ;;change attribute color to first palette
  2636. STA $2006
  2637. LDA #$DB
  2638. STA $2006
  2639. LDA #%00000010
  2640. ORA Palette2
  2641. ORA Palette3Dash1
  2642. STA $2007
  2643. STA Palette2
  2644. INC CurrentColor
  2645. RTS
  2646. .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
  2647. CMP #$02
  2648. BNE .FourthPalette2
  2649. LDA $2002
  2650.  
  2651. LDA #$23
  2652. STA $2006
  2653. LDA #$DB
  2654. STA $2006
  2655. LDA #%00001000
  2656. ORA Palette2
  2657. STA $2007
  2658.  
  2659. LDA #$23 ;;change attribute color to first palette
  2660. STA $2006
  2661. LDA #$DC
  2662. STA $2006
  2663. LDA #%00000010
  2664. ORA Palette4Dash2
  2665. STA $2007
  2666. STA Palette3
  2667.  
  2668. INC CurrentColor
  2669. RTS
  2670. .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
  2671. LDA $2002
  2672. LDA #$23 ;;change attribute color to first palette
  2673. STA $2006
  2674. LDA #$DC
  2675. STA $2006
  2676. LDA #%00001000
  2677. ORA Palette3
  2678. STA $2007
  2679. STA Palette4
  2680. LDA #$00 ;;Reset CurrentColor for next row
  2681. STA CurrentColor
  2682. LDA #$01
  2683. STA Checking
  2684. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2685. RTS
  2686. ThirdRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
  2687. LDA CurrentColor
  2688. CMP #$00
  2689. BNE .SecondPalette3
  2690. LDA $2002 ;;Load PPU for writing
  2691. LDA #$23 ;;Load hi byte of attribute location
  2692. STA $2006
  2693. LDA #$DA ;;Load lo byte of attribute location
  2694. STA $2006
  2695. LDA #%00001111 ;;Store new attribute data (From palette 1)
  2696. ORA Palette1
  2697. STA $2007
  2698. STA Palette1
  2699. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2700. RTS
  2701. .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
  2702. CMP #$01
  2703. BNE .ThirdPalette3
  2704. LDA $2002
  2705. LDA #$23 ;;change attribute color to first palette
  2706. STA $2006
  2707. LDA #$DB
  2708. STA $2006
  2709. LDA #%00000011
  2710. ORA Palette2
  2711. ORA Palette3Dash1
  2712. STA $2007
  2713. STA Palette2
  2714. INC CurrentColor
  2715. RTS
  2716. .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
  2717. CMP #$02
  2718. BNE .FourthPalette3
  2719. LDA $2002
  2720.  
  2721. LDA #$23
  2722. STA $2006
  2723. LDA #$DB
  2724. STA $2006
  2725. LDA #%00001100
  2726. ORA Palette2
  2727. STA $2007
  2728.  
  2729. LDA #$23 ;;change attribute color to first palette
  2730. STA $2006
  2731. LDA #$DC
  2732. STA $2006
  2733. LDA #%00000011
  2734. ORA Palette4Dash2
  2735. STA $2007
  2736. STA Palette3
  2737.  
  2738. INC CurrentColor
  2739. RTS
  2740. .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
  2741. LDA $2002
  2742. LDA #$23 ;;change attribute color to first palette
  2743. STA $2006
  2744. LDA #$DC
  2745. STA $2006
  2746. LDA #%00001100
  2747. ORA Palette3
  2748. STA $2007
  2749. STA Palette4
  2750. LDA #$00 ;;Reset CurrentColor for next row
  2751. STA CurrentColor
  2752. LDA #$01
  2753. STA Checking
  2754. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2755. RTS
  2756.  
  2757. PlaceSecondSprite5: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  2758. LDX #$00 ;;This uses background tiles #65-#68.
  2759. LDY CurrentColor
  2760. .PreLoop:
  2761. CPY #$00
  2762. BEQ .Continue
  2763. DEY
  2764. INX
  2765. INX
  2766. INX
  2767. JMP .PreLoop
  2768. .Continue:
  2769. LDA $2002 ;;place top half of colored circle
  2770. LDA #$21
  2771. STA $2006
  2772. TXA
  2773. CLC
  2774. ADC #$89
  2775. STA $2006
  2776. LDA #$65
  2777. STA $2007
  2778. LDA #$66
  2779. STA $2007
  2780.  
  2781. LDA #$21 ;;place bottom half of colored circle
  2782. STA $2006
  2783. TXA
  2784. CLC
  2785. ADC #$A9
  2786. STA $2006
  2787. LDA #$67
  2788. STA $2007
  2789. LDA #$68
  2790. STA $2007
  2791.  
  2792. ;;ColorPosition is the position in the select your color area
  2793. ;;CurrentColor is the current circle in the big gameboard
  2794.  
  2795. LDA ColorPosition ;;change attribute color to correct palette
  2796. CMP #$01
  2797. BNE .Try2
  2798. JMP ThirdRowPalette1
  2799. .Try2:
  2800. CMP #$03
  2801. BNE .Try3
  2802. JMP ThirdRowPalette2
  2803. .Try3:
  2804. CMP #$05
  2805. BNE .Done
  2806. JMP ThirdRowPalette3
  2807. .Done:
  2808. RTS
  2809.  
  2810. SecondRowGuesses:
  2811. ;;four possible color positions per row
  2812. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  2813. CMP #$00
  2814. BNE .1
  2815. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  2816. STA Choice1
  2817. ;;first spot
  2818. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  2819. .Loop0:
  2820. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  2821. CMP FirstSpriteColors,x
  2822. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  2823. INX
  2824. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  2825. BNE .Loop0
  2826. JMP PlaceSecondSprite6 ;;If not, jump to PlaceSecondSprite
  2827. .1:
  2828. CMP #$01
  2829. BNE .2
  2830. ;;second spot
  2831. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  2832. STA Choice2
  2833. LDX #$00
  2834. .Loop1:
  2835. LDA ColorPosition
  2836. CMP FirstSpriteColors,x
  2837. BEQ .PlaceFirstSprite
  2838. INX
  2839. CPX #$03
  2840. BNE .Loop1
  2841. JMP PlaceSecondSprite6
  2842. .2:
  2843. CMP #$02
  2844. BNE .3
  2845. ;;third spot
  2846. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  2847. STA Choice3
  2848. LDX #$00
  2849. .Loop2:
  2850. LDA ColorPosition
  2851. CMP FirstSpriteColors,x
  2852. BEQ .PlaceFirstSprite
  2853. INX
  2854. CPX #$03
  2855. BNE .Loop2
  2856. JMP PlaceSecondSprite6
  2857. .3:
  2858. CMP #$03
  2859. BNE .End
  2860. ;;fourth spot
  2861. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  2862. STA Choice4
  2863. LDX #$00
  2864. .Loop3:
  2865. LDA ColorPosition
  2866. CMP FirstSpriteColors,x
  2867. BEQ .PlaceFirstSprite
  2868. INX
  2869. CPX #$03
  2870. BNE .Loop3
  2871. JMP PlaceSecondSprite6
  2872. .End:
  2873. RTS
  2874. .PlaceFirstSprite:
  2875. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  2876. LDY CurrentColor ;;store CurrentColor as Y
  2877. .PreLoop:
  2878. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  2879. BEQ .Continue
  2880. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  2881. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  2882. INX
  2883. INX
  2884. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  2885. .Continue:
  2886. LDA $2002 ;;place top half of colored circle
  2887. LDA #$21
  2888. STA $2006 ;;Hi byte of background tile is $23
  2889. TXA
  2890. CLC
  2891. ADC #$29 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  2892. STA $2006 ;;of the bottom row of circles is $2309.
  2893. LDA #$61 ;;Store first two tiles of correct color.
  2894. STA $2007
  2895. LDA #$62
  2896. STA $2007
  2897.  
  2898. LDA #$21 ;;Store bottom two tiles of correct color.
  2899. STA $2006
  2900. TXA
  2901. CLC
  2902. ADC #$49
  2903. STA $2006
  2904. LDA #$63
  2905. STA $2007
  2906. LDA #$64
  2907. STA $2007
  2908.  
  2909. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  2910.  
  2911. LDA ColorPosition ;;change attribute color to correct palette
  2912. CMP #$00
  2913. BNE .Try2
  2914. JMP SecondRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  2915. .Try2:
  2916. CMP #$02
  2917. BNE .Try3
  2918. JMP SecondRowPalette2 ;;if it's ColorPosition 2, use Palette2
  2919. .Try3:
  2920. CMP #$04
  2921. BNE .Done
  2922. JMP SecondRowPalette3 ;;if it's ColorPosition 4, use Palette3
  2923. .Done:
  2924. RTS
  2925. SecondRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  2926. LDA CurrentColor
  2927. CMP #$00
  2928. BNE .SecondPalette1
  2929. LDA $2002 ;;Load PPU for writing
  2930. LDA #$23 ;;Load hi byte of attribute location
  2931. STA $2006
  2932. LDA #$D2 ;;Load lo byte of attribute location
  2933. STA $2006
  2934. LDA #%01010101 ;;Store new attribute data (From palette 1)
  2935. STA $2007
  2936. STA Palette1
  2937. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  2938. RTS
  2939. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  2940. CMP #$01
  2941. BNE .ThirdPalette1
  2942. LDA $2002
  2943. LDA #$23 ;;change attribute color to first palette
  2944. STA $2006
  2945. LDA #$D3
  2946. STA $2006
  2947. LDA #%00010001
  2948. STA $2007
  2949. STA Palette2
  2950. INC CurrentColor
  2951. RTS
  2952. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  2953. CMP #$02
  2954. BNE .FourthPalette1
  2955. LDA $2002
  2956.  
  2957. LDA #$23
  2958. STA $2006
  2959. LDA #$D3
  2960. STA $2006
  2961. LDA #%01000100
  2962. ORA Palette2
  2963. STA $2007
  2964.  
  2965. LDA #$23 ;;change attribute color to first palette
  2966. STA $2006
  2967. LDA #$D4
  2968. STA $2006
  2969. LDA #%00010001
  2970. STA $2007
  2971. STA Palette3
  2972.  
  2973. INC CurrentColor
  2974. RTS
  2975. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  2976. LDA $2002
  2977. LDA #$23 ;;change attribute color to first palette
  2978. STA $2006
  2979. LDA #$D4
  2980. STA $2006
  2981. LDA #%01000100
  2982. ORA Palette3
  2983. STA $2007
  2984. STA Palette4
  2985. LDA #$00 ;;Reset CurrentColor for next row
  2986. STA CurrentColor
  2987. LDA #$01
  2988. STA Checking
  2989. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  2990. RTS
  2991. SecondRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
  2992. LDA CurrentColor
  2993. CMP #$00
  2994. BNE .SecondPalette2
  2995. LDA $2002 ;;Load PPU for writing
  2996. LDA #$23 ;;Load hi byte of attribute location
  2997. STA $2006
  2998. LDA #$D2 ;;Load lo byte of attribute location
  2999. STA $2006
  3000. LDA #%10101010 ;;Store new attribute data (From palette 1)
  3001. STA $2007
  3002. STA Palette1
  3003. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  3004. RTS
  3005. .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
  3006. CMP #$01
  3007. BNE .ThirdPalette2
  3008. LDA $2002
  3009. LDA #$23 ;;change attribute color to first palette
  3010. STA $2006
  3011. LDA #$D3
  3012. STA $2006
  3013. LDA #%00100010
  3014. STA $2007
  3015. STA Palette2
  3016. INC CurrentColor
  3017. RTS
  3018. .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
  3019. CMP #$02
  3020. BNE .FourthPalette2
  3021. LDA $2002
  3022.  
  3023. LDA #$23
  3024. STA $2006
  3025. LDA #$D3
  3026. STA $2006
  3027. LDA #%10001000
  3028. ORA Palette2
  3029. STA $2007
  3030.  
  3031. LDA #$23 ;;change attribute color to first palette
  3032. STA $2006
  3033. LDA #$D4
  3034. STA $2006
  3035. LDA #%00100010
  3036. STA $2007
  3037. STA Palette3
  3038.  
  3039. INC CurrentColor
  3040. RTS
  3041. .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
  3042. LDA $2002
  3043. LDA #$23 ;;change attribute color to first palette
  3044. STA $2006
  3045. LDA #$D4
  3046. STA $2006
  3047. LDA #%10001000
  3048. ORA Palette3
  3049. STA $2007
  3050. STA Palette4
  3051. LDA #$00 ;;Reset CurrentColor for next row
  3052. STA CurrentColor
  3053. LDA #$01
  3054. STA Checking
  3055. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  3056. RTS
  3057. SecondRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
  3058. LDA CurrentColor
  3059. CMP #$00
  3060. BNE .SecondPalette3
  3061. LDA $2002 ;;Load PPU for writing
  3062. LDA #$23 ;;Load hi byte of attribute location
  3063. STA $2006
  3064. LDA #$D2 ;;Load lo byte of attribute location
  3065. STA $2006
  3066. LDA #%11111111 ;;Store new attribute data (From palette 1)
  3067. STA $2007
  3068. STA Palette1
  3069. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  3070. RTS
  3071. .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
  3072. CMP #$01
  3073. BNE .ThirdPalette3
  3074. LDA $2002
  3075. LDA #$23 ;;change attribute color to first palette
  3076. STA $2006
  3077. LDA #$D3
  3078. STA $2006
  3079. LDA #%00110011
  3080. STA $2007
  3081. STA Palette2
  3082. INC CurrentColor
  3083. RTS
  3084. .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
  3085. CMP #$02
  3086. BNE .FourthPalette3
  3087. LDA $2002
  3088.  
  3089. LDA #$23
  3090. STA $2006
  3091. LDA #$D3
  3092. STA $2006
  3093. LDA #%11001100
  3094. ORA Palette2
  3095. STA $2007
  3096.  
  3097. LDA #$23 ;;change attribute color to first palette
  3098. STA $2006
  3099. LDA #$D4
  3100. STA $2006
  3101. LDA #%00110011
  3102. STA $2007
  3103. STA Palette3
  3104.  
  3105. INC CurrentColor
  3106. RTS
  3107. .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
  3108. LDA $2002
  3109. LDA #$23 ;;change attribute color to first palette
  3110. STA $2006
  3111. LDA #$D4
  3112. STA $2006
  3113. LDA #%11001100
  3114. ORA Palette3
  3115. STA $2007
  3116. STA Palette4
  3117. LDA #$00 ;;Reset CurrentColor for next row
  3118. STA CurrentColor
  3119. LDA #$01
  3120. STA Checking
  3121. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  3122. RTS
  3123.  
  3124. PlaceSecondSprite6: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  3125. LDX #$00 ;;This uses background tiles #65-#68.
  3126. LDY CurrentColor
  3127. .PreLoop:
  3128. CPY #$00
  3129. BEQ .Continue
  3130. DEY
  3131. INX
  3132. INX
  3133. INX
  3134. JMP .PreLoop
  3135. .Continue:
  3136. LDA $2002 ;;place top half of colored circle
  3137. LDA #$21
  3138. STA $2006
  3139. TXA
  3140. CLC
  3141. ADC #$29
  3142. STA $2006
  3143. LDA #$65
  3144. STA $2007
  3145. LDA #$66
  3146. STA $2007
  3147.  
  3148. LDA #$21 ;;place bottom half of colored circle
  3149. STA $2006
  3150. TXA
  3151. CLC
  3152. ADC #$49
  3153. STA $2006
  3154. LDA #$67
  3155. STA $2007
  3156. LDA #$68
  3157. STA $2007
  3158.  
  3159. ;;ColorPosition is the position in the select your color area
  3160. ;;CurrentColor is the current circle in the big gameboard
  3161.  
  3162. LDA ColorPosition ;;change attribute color to correct palette
  3163. CMP #$01
  3164. BNE .Try2
  3165. JMP SecondRowPalette1
  3166. .Try2:
  3167. CMP #$03
  3168. BNE .Try3
  3169. JMP SecondRowPalette2
  3170. .Try3:
  3171. CMP #$05
  3172. BNE .Done
  3173. JMP SecondRowPalette3
  3174. .Done:
  3175. RTS
  3176.  
  3177. FirstRowGuesses:
  3178. ;;four possible color positions per row
  3179. LDA CurrentColor ;;CurrentColor is either 0-3. 0 is first circle in bottom row, 1 is second circle in bottom row, etc.
  3180. CMP #$00
  3181. BNE .1
  3182. LDA ColorPosition ;;CurrentColor is #$00, so store whatever color the player is picking to Choice1.
  3183. STA Choice1
  3184. ;;first spot
  3185. LDX #$00 ;;Always make sure X is #$00 to start the loop.
  3186. .Loop0:
  3187. LDA ColorPosition ;;Load the cursor position to see if it's in position 00, 02, or 04. They all use bkgd sprite #61-#64.
  3188. CMP FirstSpriteColors,x
  3189. BEQ .PlaceFirstSprite ;;If it is, branch to .PlaceFirstSprite
  3190. INX
  3191. CPX #$03 ;;Compare X to #$03, since there are three options in FirstSpriteColors.
  3192. BNE .Loop0
  3193. JMP PlaceSecondSprite7 ;;If not, jump to PlaceSecondSprite
  3194. .1:
  3195. CMP #$01
  3196. BNE .2
  3197. ;;second spot
  3198. LDA ColorPosition ;;CurrentColor is #$01, so store whatever color the player is picking to Choice2.
  3199. STA Choice2
  3200. LDX #$00
  3201. .Loop1:
  3202. LDA ColorPosition
  3203. CMP FirstSpriteColors,x
  3204. BEQ .PlaceFirstSprite
  3205. INX
  3206. CPX #$03
  3207. BNE .Loop1
  3208. JMP PlaceSecondSprite7
  3209. .2:
  3210. CMP #$02
  3211. BNE .3
  3212. ;;third spot
  3213. LDA ColorPosition ;;CurrentColor is #$02, so store whatever color the player is picking to Choice3.
  3214. STA Choice3
  3215. LDX #$00
  3216. .Loop2:
  3217. LDA ColorPosition
  3218. CMP FirstSpriteColors,x
  3219. BEQ .PlaceFirstSprite
  3220. INX
  3221. CPX #$03
  3222. BNE .Loop2
  3223. JMP PlaceSecondSprite7
  3224. .3:
  3225. CMP #$03
  3226. BNE .End
  3227. ;;fourth spot
  3228. LDA ColorPosition ;;CurrentColor is #$03, so store whatever color the player is picking to Choice4.
  3229. STA Choice4
  3230. LDX #$00
  3231. .Loop3:
  3232. LDA ColorPosition
  3233. CMP FirstSpriteColors,x
  3234. BEQ .PlaceFirstSprite
  3235. INX
  3236. CPX #$03
  3237. BNE .Loop3
  3238. JMP PlaceSecondSprite7
  3239. .End:
  3240. RTS
  3241. .PlaceFirstSprite:
  3242. LDX #$00 ;;make sure X is reset to #$00 when starting this loop
  3243. LDY CurrentColor ;;store CurrentColor as Y
  3244. .PreLoop:
  3245. CPY #$00 ;;if Y is $00 from the start, branch to .Continue
  3246. BEQ .Continue
  3247. DEY ;;if Y isn't $00, that means we need to add an offset to X to get the correct location
  3248. INX ;;of the background tiles we are replacing. The color locations are offset by $03.
  3249. INX
  3250. INX
  3251. JMP .PreLoop ;;Jump back to .PreLoop to loop until Y is #$00.
  3252. .Continue:
  3253. LDA $2002 ;;place top half of colored circle
  3254. LDA #$20
  3255. STA $2006 ;;Hi byte of background tile is $23
  3256. TXA
  3257. CLC
  3258. ADC #$C9 ;;Low byte of background tile is $09+x offset. (If you look at the Nametable viewer, the first tile
  3259. STA $2006 ;;of the bottom row of circles is $2309.
  3260. LDA #$61 ;;Store first two tiles of correct color.
  3261. STA $2007
  3262. LDA #$62
  3263. STA $2007
  3264.  
  3265. LDA #$20 ;;Store bottom two tiles of correct color.
  3266. STA $2006
  3267. TXA
  3268. CLC
  3269. ADC #$E9
  3270. STA $2006
  3271. LDA #$63
  3272. STA $2007
  3273. LDA #$64
  3274. STA $2007
  3275.  
  3276. ;;Now that the correct tiles are placed, we need to make sure it's displaying the correct color.
  3277.  
  3278. LDA ColorPosition ;;change attribute color to correct palette
  3279. CMP #$00
  3280. BNE .Try2
  3281. JMP FirstRowPalette1 ;;if it's ColorPosition 0, use Palette1 (remember, ColorPosition 1,3,5 use another subroutine)
  3282. .Try2:
  3283. CMP #$02
  3284. BNE .Try3
  3285. JMP FirstRowPalette2 ;;if it's ColorPosition 2, use Palette2
  3286. .Try3:
  3287. CMP #$04
  3288. BNE .Done
  3289. JMP FirstRowPalette3 ;;if it's ColorPosition 4, use Palette3
  3290. .Done:
  3291. RTS
  3292. FirstRowPalette1: ;;set Palette for first choice, assuming CurrentColor is #00.
  3293. LDA CurrentColor
  3294. CMP #$00
  3295. BNE .SecondPalette1
  3296. LDA $2002 ;;Load PPU for writing
  3297. LDA #$23 ;;Load hi byte of attribute location
  3298. STA $2006
  3299. LDA #$CA ;;Load lo byte of attribute location
  3300. STA $2006
  3301. LDA #%01010000 ;;Store new attribute data (From palette 1)
  3302. ORA Answer1Attr
  3303. STA $2007
  3304. STA Palette1
  3305. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  3306. RTS
  3307. .SecondPalette1: ;;if we get to here, player is selecting Palette 1 for second choice.
  3308. CMP #$01
  3309. BNE .ThirdPalette1
  3310. LDA $2002
  3311. LDA #$23 ;;change attribute color to first palette
  3312. STA $2006
  3313. LDA #$CB
  3314. STA $2006
  3315. LDA #%00010000
  3316. ORA Answer2Attr
  3317. ORA Answer3Attr1
  3318. STA $2007
  3319. STA Palette2
  3320. INC CurrentColor
  3321. RTS
  3322. .ThirdPalette1: ;;if we get to here, player is selecting Palette 1 for third choice.
  3323. CMP #$02
  3324. BNE .FourthPalette1
  3325. LDA $2002
  3326.  
  3327. LDA #$23
  3328. STA $2006
  3329. LDA #$CB
  3330. STA $2006
  3331. LDA #%01000000
  3332. ORA Palette2
  3333. ORA Answer3Attr1
  3334. STA $2007
  3335.  
  3336. LDA #$23 ;;change attribute color to first palette
  3337. STA $2006
  3338. LDA #$CC
  3339. STA $2006
  3340. LDA #%00010000
  3341. ORA Answer3Attr2
  3342. ORA Answer4Attr
  3343. STA $2007
  3344. STA Palette3
  3345.  
  3346. INC CurrentColor
  3347. RTS
  3348. .FourthPalette1: ;;if we get to here, player is selecting Palette 1 for last choice.
  3349. LDA $2002
  3350. LDA #$23 ;;change attribute color to first palette
  3351. STA $2006
  3352. LDA #$CC
  3353. STA $2006
  3354. LDA #%01000000
  3355. ORA Palette3
  3356. ORA Answer4Attr
  3357. STA $2007
  3358. STA Palette4
  3359. LDA #$00 ;;Reset CurrentColor for next row
  3360. STA CurrentColor
  3361. LDA #$01
  3362. STA Checking
  3363. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  3364. RTS
  3365. FirstRowPalette2: ;;same as previous code, except the player is selecting a color using the second palette.
  3366. LDA CurrentColor
  3367. CMP #$00
  3368. BNE .SecondPalette2
  3369. LDA $2002 ;;Load PPU for writing
  3370. LDA #$23 ;;Load hi byte of attribute location
  3371. STA $2006
  3372. LDA #$CA ;;Load lo byte of attribute location
  3373. STA $2006
  3374. LDA #%10100000 ;;Store new attribute data (From palette 1)
  3375. ORA Answer1Attr
  3376. STA $2007
  3377. STA Palette1
  3378. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  3379. RTS
  3380. .SecondPalette2: ;;if we get to here, player is selecting Palette 1 for second choice.
  3381. CMP #$01
  3382. BNE .ThirdPalette2
  3383. LDA $2002
  3384. LDA #$23 ;;change attribute color to first palette
  3385. STA $2006
  3386. LDA #$CB
  3387. STA $2006
  3388. LDA #%00100000
  3389. ORA Answer2Attr
  3390. ORA Answer3Attr1
  3391. STA $2007
  3392. STA Palette2
  3393. INC CurrentColor
  3394. RTS
  3395. .ThirdPalette2: ;;if we get to here, player is selecting Palette 1 for third choice.
  3396. CMP #$02
  3397. BNE .FourthPalette2
  3398. LDA $2002
  3399.  
  3400. LDA #$23
  3401. STA $2006
  3402. LDA #$CB
  3403. STA $2006
  3404. LDA #%10000000
  3405. ORA Palette2
  3406. ORA Answer3Attr1
  3407. STA $2007
  3408.  
  3409. LDA #$23 ;;change attribute color to first palette
  3410. STA $2006
  3411. LDA #$CC
  3412. STA $2006
  3413. LDA #%00100000
  3414. ORA Answer3Attr2
  3415. ORA Answer4Attr
  3416. STA $2007
  3417. STA Palette3
  3418.  
  3419. INC CurrentColor
  3420. RTS
  3421. .FourthPalette2: ;;if we get to here, player is selecting Palette 1 for last choice.
  3422. LDA $2002
  3423. LDA #$23 ;;change attribute color to first palette
  3424. STA $2006
  3425. LDA #$CC
  3426. STA $2006
  3427. LDA #%10000000
  3428. ORA Answer4Attr
  3429. ORA Palette3
  3430. STA $2007
  3431. STA Palette4
  3432. LDA #$00 ;;Reset CurrentColor for next row
  3433. STA CurrentColor
  3434. LDA #$01
  3435. STA Checking
  3436. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  3437. RTS
  3438. FirstRowPalette3: ;;same as previous code, except the player is selecting a color using the third palette.
  3439. LDA CurrentColor
  3440. CMP #$00
  3441. BNE .SecondPalette3
  3442. LDA $2002 ;;Load PPU for writing
  3443. LDA #$23 ;;Load hi byte of attribute location
  3444. STA $2006
  3445. LDA #$CA ;;Load lo byte of attribute location
  3446. STA $2006
  3447. LDA #%11110000 ;;Store new attribute data (From palette 1)
  3448. ORA Answer1Attr
  3449. STA $2007
  3450. STA Palette1
  3451. INC CurrentColor ;;increment CurrentColor is that the game knows we're now on choice #2.
  3452. RTS
  3453. .SecondPalette3: ;;if we get to here, player is selecting Palette 1 for second choice.
  3454. CMP #$01
  3455. BNE .ThirdPalette3
  3456. LDA $2002
  3457. LDA #$23 ;;change attribute color to first palette
  3458. STA $2006
  3459. LDA #$CB
  3460. STA $2006
  3461. LDA #%00110000
  3462. ORA Answer3Attr1
  3463. ORA Answer2Attr
  3464. STA $2007
  3465. STA Palette2
  3466. INC CurrentColor
  3467. RTS
  3468. .ThirdPalette3: ;;if we get to here, player is selecting Palette 1 for third choice.
  3469. CMP #$02
  3470. BNE .FourthPalette3
  3471. LDA $2002
  3472.  
  3473. LDA #$23
  3474. STA $2006
  3475. LDA #$CB
  3476. STA $2006
  3477. LDA #%11000000
  3478. ORA Answer3Attr1
  3479. ORA Palette2
  3480. STA $2007
  3481.  
  3482. LDA #$23 ;;change attribute color to first palette
  3483. STA $2006
  3484. LDA #$CC
  3485. STA $2006
  3486. LDA #%00110000
  3487. STA Answer3Attr2
  3488. ORA Answer4Attr
  3489. STA $2007
  3490. STA Palette3
  3491.  
  3492. INC CurrentColor
  3493. RTS
  3494. .FourthPalette3: ;;if we get to here, player is selecting Palette 1 for last choice.
  3495. LDA $2002
  3496. LDA #$23 ;;change attribute color to first palette
  3497. STA $2006
  3498. LDA #$CC
  3499. STA $2006
  3500. LDA #%11000000
  3501. ORA Answer4Attr
  3502. ORA Palette3
  3503. STA $2007
  3504. STA Palette4
  3505. LDA #$00 ;;Reset CurrentColor for next row
  3506. STA CurrentColor
  3507. LDA #$01
  3508. STA Checking
  3509. ; INC CurrentRow ;;increment CurrentRow so code knows we're going to next row of guesses
  3510. RTS
  3511.  
  3512. PlaceSecondSprite7: ;;same as all the code above, except the player is using ColorPosition 1, 3, or 5.
  3513. LDX #$00 ;;This uses background tiles #65-#68.
  3514. LDY CurrentColor
  3515. .PreLoop:
  3516. CPY #$00
  3517. BEQ .Continue
  3518. DEY
  3519. INX
  3520. INX
  3521. INX
  3522. JMP .PreLoop
  3523. .Continue:
  3524. LDA $2002 ;;place top half of colored circle
  3525. LDA #$20
  3526. STA $2006
  3527. TXA
  3528. CLC
  3529. ADC #$C9
  3530. STA $2006
  3531. LDA #$65
  3532. STA $2007
  3533. LDA #$66
  3534. STA $2007
  3535.  
  3536. LDA #$20 ;;place bottom half of colored circle
  3537. STA $2006
  3538. TXA
  3539. CLC
  3540. ADC #$E9
  3541. STA $2006
  3542. LDA #$67
  3543. STA $2007
  3544. LDA #$68
  3545. STA $2007
  3546.  
  3547. ;;ColorPosition is the position in the select your color area
  3548. ;;CurrentColor is the current circle in the big gameboard
  3549.  
  3550. LDA ColorPosition ;;change attribute color to correct palette
  3551. CMP #$01
  3552. BNE .Try2
  3553. JMP FirstRowPalette1
  3554. .Try2:
  3555. CMP #$03
  3556. BNE .Try3
  3557. JMP FirstRowPalette2
  3558. .Try3:
  3559. CMP #$05
  3560. BNE .Done
  3561. JMP FirstRowPalette3
  3562. .Done:
  3563. RTS
  3564.  
  3565. FirstSpriteColors:
  3566. .db $00,$02,$04
  3567.  
  3568. GameOverBackground:
  3569. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3570. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3571.  
  3572. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3573. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3574.  
  3575. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3576. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3577.  
  3578. .db $25,$25,$25,$25,$25,$25,$49,$4a,$4B,$4C,$4D,$75,$76,$25,$25 ;;row 1
  3579. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3580.  
  3581. .db $25,$25,$25,$25,$25,$25,$59,$5A,$5B,$5C,$5D,$85,$86,$25,$25 ;;row 1
  3582. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3583.  
  3584. .db $25,$25,$25,$25,$25,$25,$69,$6A,$6B,$6C,$6D,$95,$96,$25,$25 ;;row 1
  3585. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3586.  
  3587. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3588. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3589.  
  3590. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3591. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3592.  
  3593. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3594. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3595.  
  3596. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3597. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3598.  
  3599. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3600. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3601.  
  3602. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3603. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3604.  
  3605. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3606. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3607.  
  3608. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3609. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3610.  
  3611. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3612. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3613.  
  3614. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3615. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3616.  
  3617. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3618. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3619.  
  3620. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3621. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3622.  
  3623. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3624. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3625.  
  3626. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3627. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3628.  
  3629. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3630. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3631.  
  3632. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3633. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3634.  
  3635. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3636. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3637.  
  3638. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3639. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3640.  
  3641. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3642. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3643.  
  3644. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3645. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3646.  
  3647. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3648. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3649.  
  3650.  
  3651. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3652. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3653.  
  3654. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3655. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3656.  
  3657. .bank 2
  3658. .org $C000
  3659.  
  3660. RESET:
  3661. SEI ; disable IRQs
  3662. CLD ; disable decimal mode
  3663. LDX #$40
  3664. STX $4017 ; disable APU frame IRQ
  3665. LDX #$FF
  3666. TXS ; Set up stack
  3667. INX ; now X = 0
  3668. STX $2000 ; disable NMI
  3669. STX $2001 ; disable rendering
  3670. STX $4010 ; disable DMC IRQs
  3671.  
  3672.  
  3673. vblankwait1: ; First wait for vblank to make sure PPU is ready
  3674. BIT $2002
  3675. BPL vblankwait1
  3676.  
  3677. clrmem:
  3678. LDA #$00
  3679. STA $0000, x
  3680. STA $0100, x
  3681. STA $0300, x
  3682. STA $0400, x
  3683. STA $0500, x
  3684. STA $0600, x
  3685. STA $0700, x
  3686. LDA #$FE
  3687. STA $0200, x
  3688. INX
  3689. BNE clrmem
  3690.  
  3691. vblankwait2: ; Second wait for vblank, PPU is ready after this
  3692. BIT $2002
  3693. BPL vblankwait2
  3694.  
  3695. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3696. ;;;;;;;;starting variables;;;;;;;
  3697. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3698.  
  3699. JSR FamiToneInit
  3700.  
  3701. LDX #LOW(sounds)
  3702. LDY #HIGH(sounds)
  3703. JSR FamiToneSfxInit
  3704.  
  3705. LDA #STATELOADTITLE
  3706. STA gamestate
  3707.  
  3708. LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  3709. STA $2000
  3710.  
  3711. LDA #%00011110 ; enable sprites, enable background, no clipping on left side
  3712. STA $2001
  3713. STA soft2001
  3714.  
  3715.  
  3716. Forever:
  3717. INC RandomLow
  3718. BNE SeedComplete
  3719. INC RandomHigh
  3720. SeedComplete:
  3721. JMP Forever ;jump back to Forever, infinite loop, waiting for NMI
  3722.  
  3723. NMI:
  3724. LDA #$00
  3725. STA $2003 ; set the low byte (00) of the RAM address
  3726. LDA #$02
  3727. STA $4014 ; set the high byte (02) of the RAM address, start the transfer
  3728.  
  3729. JSR LatchController
  3730. ; JSR DrawWinScreen
  3731.  
  3732. ;;This is the PPU clean up section, so rendering the next frame starts properly.
  3733. LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  3734. STA $2000
  3735. LDA soft2001 ; enable sprites, enable background, no clipping on left side
  3736. STA $2001
  3737. LDA #$00 ;;tell the ppu there is no background scrolling
  3738. STA $2005
  3739. STA $2005
  3740.  
  3741. GameEngine:
  3742. LDA gamestate
  3743. CMP #STATELOADTITLE
  3744. BNE NotLoadTitle
  3745. JMP EngineLoadTitle
  3746. NotLoadTitle:
  3747. CMP #STATETITLE
  3748. BNE NotTitle
  3749. JMP EngineTitle
  3750. NotTitle:
  3751. CMP #STATELOADPLAYING
  3752. BNE NotLoadPlaying
  3753. JMP EngineLoadPlaying
  3754. NotLoadPlaying:
  3755. CMP #STATEPLAYING
  3756. BNE NotPlaying
  3757. JMP EnginePlaying
  3758. NotPlaying:
  3759. CMP #STATELOADGAMEOVER
  3760. BNE NotLoadGameOver
  3761. JMP LoadGameOver
  3762. NotLoadGameOver:
  3763. CMP #STATEGAMEOVER
  3764. BNE CreditsLoad
  3765. JMP GameOverEngine
  3766. CreditsLoad:
  3767. CMP #STATELOADCREDITS
  3768. BNE NotCreditsLoad
  3769. JMP LoadCredits
  3770. NotCreditsLoad:
  3771. CMP #STATECREDITS
  3772. BNE GameEngineDone
  3773. JMP CreditsEngine
  3774. GameEngineDone:
  3775.  
  3776. JSR FamiToneUpdate
  3777.  
  3778. RTI ; return from interrupt
  3779. CreditsEngine:
  3780.  
  3781. JMP GameEngineDone
  3782.  
  3783. LoadCredits:
  3784. LDA #$00
  3785. STA $2000
  3786. STA $2001
  3787.  
  3788. LDX #$00
  3789. .Loop:
  3790. LDA #$FF
  3791. STA $0200,x
  3792. INX
  3793. INX
  3794. INX
  3795. INX
  3796. CPX #$D0
  3797. BNE .Loop
  3798.  
  3799. ; JSR LoadCreditsPalettes
  3800. JSR LoadCreditsNametable
  3801. JSR LoadCreditsAttribute
  3802. LDA #STATECREDITS
  3803. STA gamestate
  3804. RTS
  3805.  
  3806.  
  3807. LoadCreditsNametable:
  3808. LDA $2002
  3809. LDA #$20
  3810. STA $2006
  3811. LDA #$00
  3812. STA $2006
  3813.  
  3814. LDA #low(CreditsBackground)
  3815. STA AddrLow ; load low bytes of background data
  3816. LDA #high(CreditsBackground)
  3817. STA AddrHigh ; load high bytes of background data
  3818.  
  3819. LDX #$04 ; Loop X 4 times
  3820. LDY #$00 ; Loop Y 256 times
  3821. LoadCreditsBackgroundsLoop:
  3822. LDA [AddrLow],y
  3823. STA $2007
  3824. INY
  3825. BNE LoadCreditsBackgroundsLoop
  3826. ; Outer loop
  3827. INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
  3828. DEX ; one chunk done so X = X - 1.
  3829. BNE LoadCreditsBackgroundsLoop ; if X isn't zero, do again
  3830. RTS
  3831.  
  3832. LoadCreditsAttribute:
  3833. LDA $2002 ; read PPU status to reset the high/low latch
  3834. LDA #$23
  3835. STA $2006 ; write the high byte of $23C0 address
  3836. LDA #$C0
  3837. STA $2006 ; write the low byte of $23C0 address
  3838. LDX #$00 ; start out at 0
  3839. LoadCreditsAttributeLoop:
  3840. LDA CreditsAttribute, x ; load data from address (attribute + the value in x)
  3841. STA $2007 ; write to PPU
  3842. INX ; X = X + 1
  3843. CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
  3844. BNE LoadCreditsAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
  3845. ; if compare was equal to 128, keep going down
  3846. RTS
  3847.  
  3848.  
  3849. CreditsPalette:
  3850. .db $0f,$29,$18,$2D, $0f,$06,$18,$12, $0f,$38,$18,$1A, $0f,$04,$18,$29 ;;background palette
  3851. .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
  3852.  
  3853. ;;as you can see, I am pulling from all three palettes in the attribute table. some sections are using
  3854. ;;palette %01, some are using palette %10, and some are using palette %11.
  3855. ;;remember, these are binary numbers. %01=1, %10=2, %11=3.
  3856.  
  3857. CreditsAttribute:
  3858. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  3859. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  3860. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  3861. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  3862. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  3863. .db %00000000, %00000000, %00000000, %00000000, %00000000, %01000000, %10010000, %00000000
  3864. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00001000, %00001111, %00000000
  3865. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  3866.  
  3867. CreditsBackground:
  3868. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3869. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3870.  
  3871. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3872. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3873.  
  3874. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3875. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3876.  
  3877. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3878. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3879.  
  3880. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3881. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3882.  
  3883. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3884. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3885.  
  3886. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3887. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3888.  
  3889. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3890. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3891.  
  3892. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3893. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3894.  
  3895. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3896. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3897.  
  3898. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3899. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3900.  
  3901. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3902. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3903.  
  3904. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3905. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3906.  
  3907. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3908. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3909.  
  3910. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3911. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3912.  
  3913. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3914. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3915.  
  3916. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3917. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3918.  
  3919. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3920. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3921.  
  3922. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3923. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3924.  
  3925. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3926. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3927.  
  3928. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3929. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3930.  
  3931. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3932. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3933.  
  3934. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3935. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3936.  
  3937. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3938. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3939.  
  3940. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3941. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3942.  
  3943. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3944. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3945.  
  3946. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3947. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3948.  
  3949.  
  3950. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3951. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3952.  
  3953. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  3954. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  3955.  
  3956. .bank 1
  3957. .org $A000
  3958.  
  3959. EngineLoadTitle:
  3960. LDA #$00
  3961. STA $2000
  3962. STA $2001
  3963.  
  3964. JSR LoadTitlePalettes
  3965. JSR LoadTitleNametable
  3966. JSR LoadTitleAttribute
  3967. JSR TitleLoadSprites
  3968. JSR DifficultySelect
  3969.  
  3970. LDX #LOW(title_module)
  3971. LDY #HIGH(title_module)
  3972. JSR FamiToneMusicStart
  3973.  
  3974. LDA #STATETITLE
  3975. STA gamestate
  3976.  
  3977. LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  3978. STA $2000
  3979.  
  3980. LDA #%00011110 ; enable sprites, enable background, no clipping on left side
  3981. STA soft2001
  3982.  
  3983. JMP GameEngineDone
  3984.  
  3985. EngineTitle:
  3986. JMP GameEngineDone
  3987.  
  3988. EngineLoadPlaying:
  3989. LDA #$00
  3990. STA $2000
  3991. STA $2001
  3992.  
  3993. JSR LoadPalettes
  3994. JSR LoadNametable
  3995. JSR LoadAttribute
  3996. JSR LoadSprites
  3997. JSR PickColors
  3998. JSR DrawWinningColors
  3999.  
  4000. LDX #LOW(trackone_module)
  4001. LDY #HIGH(trackone_module)
  4002. JSR FamiToneMusicStart
  4003.  
  4004. LDA #STATEPLAYING
  4005. STA gamestate
  4006.  
  4007. LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  4008. STA $2000
  4009.  
  4010. LDA #%00011110 ; enable sprites, enable background, no clipping on left side
  4011. STA soft2001
  4012.  
  4013.  
  4014.  
  4015. JMP GameEngineDone
  4016.  
  4017. EnginePlaying:
  4018. JSR GetColorPosition
  4019. JSR CheckSolutions
  4020. JSR MoveQuestionMarks
  4021. JSR EndGame
  4022. JSR PlaySoundEffect
  4023. JSR RunTimer
  4024.  
  4025. JMP GameEngineDone
  4026.  
  4027. ;;;;;;;
  4028.  
  4029. LoadGameOver:
  4030.  
  4031. LDA #$00
  4032. STA $2000
  4033. STA $2001
  4034.  
  4035. KillSprites2:
  4036. LDX #$00
  4037. .Loop:
  4038. LDA #$FF
  4039. STA $0200,x
  4040. INX
  4041. INX
  4042. INX
  4043. INX
  4044. CPX #$D0
  4045. BNE .Loop
  4046.  
  4047.  
  4048. JSR LoadGameOverPalettes
  4049. JSR LoadGameOverNametable
  4050. JSR LoadGameOverAttribute
  4051. JSR DrawWinScreen
  4052. JSR DrawWinScreen2
  4053. JSR DrawWinScreen3
  4054. LDA #STATEGAMEOVER
  4055. STA gamestate
  4056.  
  4057.  
  4058.  
  4059.  
  4060. LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  4061. STA $2000
  4062.  
  4063. LDA #%00011110 ; enable sprites, enable background, no clipping on left side
  4064. STA soft2001
  4065.  
  4066.  
  4067. JMP GameEngineDone
  4068.  
  4069. ;;;;;;;
  4070.  
  4071. GameOverEngine:
  4072.  
  4073. JMP GameEngineDone
  4074.  
  4075. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4076. ;;;;;;;; SUBROUTINES ;;;;;;;;;;;
  4077. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4078.  
  4079. ResetVariables:
  4080. LDA #$00
  4081. STA CurrentRow
  4082. STA CurrentColor
  4083. STA WinFlag
  4084. STA WinLose
  4085. JSR KillSprites
  4086. RTS
  4087.  
  4088. KillSprites:
  4089. LDX #$00
  4090. .Loop:
  4091. LDA #$FF
  4092. STA $0200,x
  4093. INX
  4094. INX
  4095. INX
  4096. INX
  4097. CPX #$D0
  4098. BNE .Loop
  4099. RTS
  4100. DifficultySelect:
  4101. LDA gamestate
  4102. CMP #STATELOADTITLE ;if it isn't during title screen, ignore this whole routine.
  4103. BNE End
  4104. LDA $200
  4105. CMP #$50
  4106. BEQ Easy
  4107. LDA $200
  4108. CMP #$58
  4109. BEQ Medium
  4110. LDA $200
  4111. CMP #$60
  4112. LDA $200
  4113. BEQ Hard
  4114. LDA $200
  4115. CMP #$70
  4116. BEQ Panic
  4117. Panic:
  4118. LDA #$07
  4119. STA difficulty
  4120. RTS
  4121. Credit:
  4122. LDA #$06
  4123. STA gamestate
  4124. Hard:
  4125. LDA #$15
  4126. STA difficulty
  4127. RTS
  4128. Medium:
  4129. LDA #$20
  4130. STA difficulty
  4131. RTS
  4132. Easy:
  4133. LDA #$40
  4134. STA difficulty
  4135. RTS
  4136. End:
  4137. RTS
  4138.  
  4139. TitleScreenUp: ;Code for pressing Up during title screen.
  4140. LDA gamestate
  4141. CMP #STATETITLE ;if it isn't during title screen, ignore this whole routine.
  4142. BNE .End
  4143. LDA #$01
  4144. STA SoundEffect
  4145. STA PlaySound
  4146.  
  4147. LDA $0200 ; look at $0203 and see if it's at the Up most position
  4148. CMP #$50
  4149. BNE .NotWrap ;if it's not, skip this and move Up as usual
  4150. LDA #$68
  4151. STA $0200 ;it is at Up-most point. reposition to #$B8
  4152.  
  4153. RTS
  4154.  
  4155. .NotWrap:
  4156. LDA $0200 ; load sprite Y position
  4157. SEC ; make sure carry flag is set
  4158. SBC #$08 ; A = A - 10
  4159. STA $0200 ; save sprite Y position
  4160. .End:
  4161. RTS
  4162.  
  4163.  
  4164.  
  4165. TitleScreenDown: ;Code for pressing Down during title screen.
  4166. LDA gamestate
  4167. CMP #STATETITLE ;if it isn't during title screen, ignore this whole routine.
  4168. BNE .End
  4169. LDA #$01
  4170. STA SoundEffect
  4171. STA PlaySound
  4172.  
  4173. LDA $0200 ; look at $0203 and see if it's at the Up most position
  4174. CMP #$68
  4175. BNE .NotWrap ;if it's not, skip this and move Up as usual
  4176. LDA #$50
  4177. STA $0200 ;it is at Up-most point. reposition to #$B8
  4178. RTS
  4179. .NotWrap:
  4180. LDA $0200 ; load sprite Y position
  4181. CLC ; make sure carry flag is set
  4182. ADC #$08 ; A = A - 10
  4183. STA $0200 ; save sprite Y position
  4184. .End:
  4185. RTS
  4186.  
  4187. PlayingGameDown:
  4188. LDA DownHeld ; if DownHeld is #$01, skip to end
  4189. CMP #$01
  4190. BEQ PlayingGameDownDone
  4191.  
  4192. LDA WinFlag
  4193. CMP #$01
  4194. BEQ PlayingGameDownDone
  4195.  
  4196.  
  4197. LDA #$01
  4198. STA SoundEffect
  4199. STA PlaySound
  4200.  
  4201. LDA $0200 ; look at $0203 and see if it's at the Down most position
  4202. CMP #$C0
  4203. BNE .NotWrap ;if it's not, skip this and move Down as usual
  4204. LDA #$B0
  4205. STA $0200 ;it is at Down-most point. reposition to #$B8
  4206. STA $0204
  4207. CLC
  4208. ADC #$08
  4209. STA $0208
  4210. STA $020C
  4211. JMP PlayingGameDownDone
  4212. .NotWrap:
  4213. LDA $0200 ; load sprite Y position
  4214. CLC ; make sure carry flag is set
  4215. ADC #$10 ; A = A - 10
  4216. STA $0200 ; save sprite Y position
  4217.  
  4218. LDA $0204 ; load sprite2 Y position
  4219. CLC ; make sure carry flag is set
  4220. ADC #$10 ; A = A - 10
  4221. STA $0204 ; save sprite2 Y position
  4222.  
  4223. LDA $0208 ; load sprite3 Y position
  4224. CLC ; make sure carry flag is set
  4225. ADC #$10 ; A = A - 10
  4226. STA $0208 ; save sprite3 Y position
  4227.  
  4228. LDA $020c ; load sprite4 Y position
  4229. CLC ; make sure carry flag is set
  4230. ADC #$10 ; A = A - 10
  4231. STA $020c ; save sprite4 Y position
  4232. PlayingGameDownDone:
  4233.  
  4234. PlayingGameUp: ;Code for pressing Up during gameplay.
  4235. LDA gamestate
  4236. CMP #STATEPLAYING ;if it isn't during gameplay, ignore this whole routine.
  4237. BNE .End
  4238. LDA WinFlag
  4239. CMP #$01
  4240. BEQ .End
  4241.  
  4242. LDA #$01
  4243. STA SoundEffect
  4244. STA PlaySound
  4245.  
  4246. LDA $0200 ; look at $0203 and see if it's at the Up most position
  4247. CMP #$B0
  4248. BNE .NotWrap ;if it's not, skip this and move Up as usual
  4249. LDA #$C0
  4250. STA $0200 ;it is at Up-most point. reposition to #$B8
  4251. STA $0204
  4252. CLC
  4253. ADC #$08
  4254. STA $0208
  4255. STA $020C
  4256. RTS
  4257.  
  4258. .NotWrap:
  4259. LDA $0200 ; load sprite Y position
  4260. SEC ; make sure carry flag is set
  4261. SBC #$10 ; A = A - 10
  4262. STA $0200 ; save sprite Y position
  4263.  
  4264. LDA $0204 ; load sprite2 Y position
  4265. SEC ; make sure carry flag is set
  4266. SBC #$10 ; A = A - 10
  4267. STA $0204 ; save sprite2 Y position
  4268.  
  4269. LDA $0208 ; load sprite3 Y position
  4270. SEC ; make sure carry flag is set
  4271. SBC #$10 ; A = A - 10
  4272. STA $0208 ; save sprite3 Y position
  4273.  
  4274. LDA $020c ; load sprite4 Y position
  4275. SEC ; make sure carry flag is set
  4276. SBC #$10 ; A = A - 10
  4277. STA $020c ; save sprite4 Y position
  4278. .End:
  4279. RTS
  4280. LoadTitlePalettes:
  4281. LDA $2002 ; read PPU status to reset the high/low latch
  4282. LDA #$3F
  4283. STA $2006 ; write the high byte of $3F00 address
  4284. LDA #$00
  4285. STA $2006 ; write the low byte of $3F00 address
  4286. LDX #$00 ; start out at 0
  4287. LoadTitlePalettesLoop:
  4288. LDA Titlepalette, x ; load data from address (palette + the value in x)
  4289. ; 1st time through loop it will load palette+0
  4290. ; 2nd time through loop it will load palette+1
  4291. ; 3rd time through loop it will load palette+2
  4292. ; etc
  4293. STA $2007 ; write to PPU
  4294. INX ; X = X + 1
  4295. CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  4296. BNE LoadTitlePalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
  4297. ; if compare was equal to 32, keep going down
  4298. RTS
  4299.  
  4300.  
  4301.  
  4302. LoadTitleNametable:
  4303. LDA $2002
  4304. LDA #$20
  4305. STA $2006
  4306. LDA #$00
  4307. STA $2006
  4308.  
  4309. LDA #low(Titlebackground)
  4310. STA AddrLow ; load low bytes of background data
  4311. LDA #high(Titlebackground)
  4312. STA AddrHigh ; load high bytes of background data
  4313.  
  4314. LDX #$04 ; Loop X 4 times
  4315. LDY #$00 ; Loop Y 256 times
  4316. LoadTitleBackgroundsLoop:
  4317. LDA [AddrLow],y
  4318. STA $2007
  4319. INY
  4320. BNE LoadTitleBackgroundsLoop
  4321. ; Outer loop
  4322. INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
  4323. DEX ; one chunk done so X = X - 1.
  4324. BNE LoadTitleBackgroundsLoop ; if X isn't zero, do again
  4325. RTS
  4326.  
  4327. LoadTitleAttribute:
  4328. LDA $2002 ; read PPU status to reset the high/low latch
  4329. LDA #$23
  4330. STA $2006 ; write the high byte of $23C0 address
  4331. LDA #$C0
  4332. STA $2006 ; write the low byte of $23C0 address
  4333. LDX #$00 ; start out at 0
  4334. LoadTitleAttributeLoop:
  4335. LDA Titleattribute, x ; load data from address (attribute + the value in x)
  4336. STA $2007 ; write to PPU
  4337. INX ; X = X + 1
  4338. CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
  4339. BNE LoadTitleAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
  4340. ; if compare was equal to 128, keep going down
  4341. RTS
  4342.  
  4343. CheckSolutions:
  4344. LDA Checking
  4345. CMP #$01
  4346. BNE .End
  4347. LDX #$00
  4348. .Loop:
  4349. LDA Color1Guessed,x
  4350. CMP #$01
  4351. BEQ .Inc
  4352. LDA Choice1
  4353. CLC
  4354. ADC #$01
  4355. CMP Color1Answer,x
  4356. BEQ .IncWin
  4357. .Inc:
  4358. INX
  4359. CPX #$04
  4360. BEQ SecondGuess
  4361. JMP .Loop
  4362. .End:
  4363. RTS
  4364. .IncWin:
  4365. LDA #$01
  4366. STA Color1Guessed,x
  4367. INC NumberCorrect
  4368. SecondGuess:
  4369. LDX #$00
  4370. .Loop:
  4371. LDA Color1Guessed,x
  4372. CMP #$01
  4373. BEQ .Inc
  4374. LDA Choice2
  4375. CLC
  4376. ADC #$01
  4377. CMP Color1Answer,x
  4378. BEQ .IncWin
  4379. .Inc:
  4380. INX
  4381. CPX #$04
  4382. BEQ ThirdGuess
  4383. JMP .Loop
  4384. .IncWin:
  4385. LDA #$01
  4386. STA Color1Guessed,x
  4387. INC NumberCorrect
  4388. ThirdGuess:
  4389. LDX #$00
  4390. .Loop:
  4391. LDA Color1Guessed,x
  4392. CMP #$01
  4393. BEQ .Inc
  4394. LDA Choice3
  4395. CLC
  4396. ADC #$01
  4397. CMP Color1Answer,x
  4398. BEQ .IncWin
  4399. .Inc:
  4400. INX
  4401. CPX #$04
  4402. BEQ FourthGuess
  4403. JMP .Loop
  4404. .IncWin:
  4405. LDA #$01
  4406. STA Color1Guessed,x
  4407. INC NumberCorrect
  4408. FourthGuess:
  4409. LDX #$00
  4410. .Loop:
  4411. LDA Color1Guessed,x
  4412. CMP #$01
  4413. BEQ .Inc
  4414. LDA Choice4
  4415. CLC
  4416. ADC #$01
  4417. CMP Color1Answer,x
  4418. BEQ .IncWin
  4419. .Inc:
  4420. INX
  4421. CPX #$04
  4422. BEQ Finish
  4423. JMP .Loop
  4424. .IncWin:
  4425. LDA #$01
  4426. STA Color1Guessed,x
  4427. INC NumberCorrect
  4428. Finish:
  4429. ;;check for perfects
  4430. LDA Choice1
  4431. CLC
  4432. ADC #$01
  4433. CMP Color1Answer
  4434. BNE .Second
  4435. INC NumberPerfect
  4436. DEC NumberCorrect
  4437. .Second:
  4438. LDA Choice2
  4439. CLC
  4440. ADC #$01
  4441. CMP Color2Answer
  4442. BNE .Third
  4443. INC NumberPerfect
  4444. DEC NumberCorrect
  4445. .Third:
  4446. LDA Choice3
  4447. CLC
  4448. ADC #$01
  4449. CMP Color3Answer
  4450. BNE .Fourth
  4451. INC NumberPerfect
  4452. DEC NumberCorrect
  4453. .Fourth:
  4454. LDA Choice4
  4455. CLC
  4456. ADC #$01
  4457. CMP Color4Answer
  4458. BNE .End
  4459. INC NumberPerfect
  4460. DEC NumberCorrect
  4461. LDA NumberPerfect
  4462. CMP #$04
  4463. BNE .End
  4464. LDA #$01
  4465. STA WinFlag
  4466. STA PlaySound
  4467. LDA #$02
  4468. STA SoundEffect
  4469. JSR FamiToneMusicStop
  4470. .End:
  4471. JSR DrawCorrectSprites
  4472. RTS
  4473. DrawCorrectSprites:
  4474. LDY CurrentRow
  4475. LDA SpriteAdd,y
  4476. TAX
  4477. .PerfLoop:
  4478. LDA NumberPerfect
  4479. CMP #$00
  4480. BEQ .Correct
  4481. LDA #$48
  4482. STA $0251,x
  4483. DEC NumberPerfect
  4484. INX
  4485. INX
  4486. INX
  4487. INX
  4488. JMP .PerfLoop
  4489. .Correct:
  4490. LDA NumberCorrect
  4491. CMP #$00
  4492. BEQ .End
  4493. LDA #$38
  4494. STA $0251,x
  4495. DEC NumberCorrect
  4496. INX
  4497. INX
  4498. INX
  4499. INX
  4500. JMP .Correct
  4501. .End:
  4502. LDA #$00
  4503. STA Checking
  4504. STA Color1Guessed
  4505. STA Color2Guessed
  4506. STA Color3Guessed
  4507. STA Color4Guessed
  4508. INC CurrentRow
  4509. RTS
  4510.  
  4511. SpriteAdd:
  4512. .db $00,$10,$20,$30,$40,$50,$60
  4513.  
  4514. LatchController:
  4515. LDA #$01
  4516. STA $4016
  4517. LDA #$00
  4518. STA $4016 ; tell both the controllers to latch buttons
  4519.  
  4520. ReadA:
  4521. LDA $4016 ; player 1 - A
  4522. AND #%00000001 ; only look at bit 0
  4523. BNE .ReadA
  4524. ; add instructions here to do something when button IS pressed (1)
  4525. LDA #$00
  4526. STA AHeld
  4527. JMP ReadADone
  4528. .ReadA:
  4529. LDA AHeld
  4530. CMP #$01
  4531. BEQ ReadADone
  4532. LDA gamestate
  4533. CMP #$01
  4534. BEQ ReadADone
  4535. LDA WinFlag
  4536. CMP #$01
  4537. BEQ ReadADone
  4538. LDA Checking
  4539. CMP #$01
  4540. BEQ ReadADone
  4541.  
  4542. LDA #$00
  4543. STA SoundEffect
  4544. LDA #$01
  4545. STA PlaySound
  4546.  
  4547. JSR AssignColor
  4548. LDA #$01
  4549. STA AHeld
  4550. LDA $0203 ; load sprite X position
  4551. CLC ; make sure the carry flag is clear
  4552. STA $0203 ; save sprite X position
  4553. ReadADone: ; handling this button is done
  4554.  
  4555. ReadB:
  4556. LDA $4016 ; player 1 - B
  4557. AND #%00000001 ; only look at bit 0
  4558. BEQ ReadBDone ; branch to ReadBDone if button is NOT pressed (0)
  4559. ; add instructions here to do something when button IS pressed (1) LDA $4016 ; player 1 - Up
  4560. AND #%00000001 ; only look at bit 0
  4561. BNE ReadB2 ; branch to ReadBDone if button is NOT pressed (0)
  4562. ; add instructions here to do something when button IS pressed (1)
  4563. LDA #$00 ; Up is not being held. Set back to #$00.
  4564. STA BHeld
  4565. JMP ReadBDone
  4566. ReadB2:
  4567. LDA BHeld ; if BHeld is #$01, skip to end
  4568. CMP #$01
  4569. BEQ jump
  4570.  
  4571. LDA #$01 ; set UpHeld to #$01.
  4572. STA BHeld
  4573. jump:
  4574.  
  4575. ReadBDone: ; handling this button is done
  4576.  
  4577. ReadSelect:
  4578. LDA $4016 ; player 1 - select
  4579. AND #%00000001 ; only look at bit 0
  4580. BEQ ReadSelectDone ; branch to ReadBDone if button is NOT pressed (0)
  4581. ; add instructions here to do something when button IS pressed (1)
  4582. LDA $0203 ; load sprite X position
  4583. SEC ; make sure carry flag is set
  4584. STA $0203 ; save sprite X position
  4585. ReadSelectDone: ; handling this button is done
  4586.  
  4587.  
  4588. ReadStart:
  4589. LDA $4016 ; player 1 - Start
  4590. AND #%00000001 ; only look at bit 0
  4591. BNE ReadStart2 ; branch to ReadBDone if button is NOT pressed (0)
  4592. ; add instructions here to do something when button IS pressed (1)
  4593. LDA #$00 ; Up is not being held. Set back to #$00.
  4594. STA StartHeld
  4595. JMP ReadStartDone
  4596. ReadStart2:
  4597. LDA StartHeld ; if BHeld is #$01, skip to end
  4598. CMP #$01
  4599. BEQ ReadStartDone
  4600.  
  4601. LDA #$01 ; set UpHeld to #$01.
  4602. STA StartHeld
  4603.  
  4604. LDA gamestate
  4605. CMP #STATETITLE
  4606. BNE .NotTitle
  4607. LDA #STATELOADPLAYING
  4608. STA gamestate
  4609. JMP ReadStartDone
  4610. .NotTitle:
  4611. LDA WinFlag
  4612. CMP #$01
  4613. BNE ReadStartDone
  4614.  
  4615. JSR ResetVariables
  4616.  
  4617. LDA #STATELOADTITLE
  4618. STA gamestate
  4619. ReadStartDone: ; handling this button is done
  4620.  
  4621.  
  4622. ReadUp:
  4623. LDA $4016 ; player 1 - Up
  4624. AND #%00000001 ; only look at bit 0
  4625. BNE ReadUp2 ; branch to ReadBDone if button is NOT pressed (0)
  4626. ; add instructions here to do something when button IS pressed (1)
  4627. LDA #$00 ; Up is not being held. Set back to #$00.
  4628. STA UpHeld
  4629. JMP ReadUpDone
  4630. ReadUp2:
  4631. LDA UpHeld ; if UpHeld is #$01, skip to end
  4632. CMP #$01
  4633. BEQ ReadUpDone
  4634.  
  4635. LDA #$01
  4636. STA UpHeld
  4637.  
  4638. JSR TitleScreenUp
  4639. JSR PlayingGameUp
  4640. JSR DifficultySelect
  4641. ReadUpDone:
  4642.  
  4643. ReadDown:
  4644. LDA $4016 ; player 1 - Down
  4645. AND #%00000001 ; only look at bit 0
  4646. BNE ReadDown2 ; branch to ReadBDone if button is NOT pressed (0)
  4647. ; add instructions here to do something when button IS pressed (1)
  4648. LDA #$00 ; Down is not being held. Set back to #$00.
  4649. STA DownHeld
  4650. JMP ReadDownDone
  4651. ReadDown2:
  4652. LDA DownHeld ; if DownHeld is #$01, skip to end
  4653. CMP #$01
  4654. BEQ ReadDownDone
  4655.  
  4656. LDA #$01
  4657. STA DownHeld
  4658.  
  4659. JSR TitleScreenDown
  4660. JSR PlayingGameDown
  4661. JSR DifficultySelect
  4662. ReadDownDone:
  4663.  
  4664. ReadLeft:
  4665. LDA $4016 ; player 1 - Left
  4666. AND #%00000001 ; only look at bit 0
  4667. BNE ReadLeft2 ; branch to ReadBDone if button is NOT pressed (0)
  4668. ; add instructions here to do something when button IS pressed (1)
  4669. LDA #$00 ; Left is not being held. Set back to #$00.
  4670. STA LeftHeld
  4671. JMP ReadLeftDone
  4672. ReadLeft2:
  4673. LDA LeftHeld ; if LeftHeld is #$01, skip to end
  4674. CMP #$01
  4675. BEQ ReadLeftDone
  4676.  
  4677. LDA gamestate
  4678. CMP #$01
  4679. BEQ ReadLeftDone
  4680.  
  4681. LDA WinFlag
  4682. CMP #$01
  4683. BEQ ReadLeftDone
  4684.  
  4685. LDA #$01 ; set LeftHeld to #$01.
  4686. STA LeftHeld
  4687.  
  4688. LDA #$01
  4689. STA SoundEffect
  4690. STA PlaySound
  4691.  
  4692. LDA $0203 ; look at $0203 and see if it's at the Left most position
  4693. CMP #$B0
  4694. BNE .NotWrap ;if it's not, skip this and move Left as usual
  4695. LDA #$D0
  4696. STA $0203 ;it is at Left-most point. reposition to #$B8
  4697. STA $020F
  4698. CLC
  4699. ADC #$08
  4700. STA $020B
  4701. STA $0207
  4702. JMP ReadLeftDone
  4703. .NotWrap:
  4704. LDA $0203 ; load sprite X position
  4705. SEC ; make sure carry flag is set
  4706. SBC #$10 ; A = A + 10
  4707. STA $0203 ; save sprite X position
  4708.  
  4709. LDA $0207 ; load sprite2 X position
  4710. SEC ; make sure carry flag is set
  4711. SBC #$10 ; A = A + 10
  4712. STA $0207 ; save sprite2 X position
  4713.  
  4714. LDA $020B ; load sprite3 X position
  4715. SEC ; make sure carry flag is set
  4716. SBC #$10 ; A = A + 10
  4717. STA $020B ; save sprite3 X position
  4718.  
  4719. LDA $020F ; load sprite4 X position
  4720. SEC ; make sure carry flag is set
  4721. SBC #$10 ; A = A + 10
  4722. STA $020F ; save sprite4 X position
  4723. ReadLeftDone:
  4724.  
  4725. ReadRight:
  4726. LDA $4016 ; player 1 - Right
  4727. AND #%00000001 ; only look at bit 0
  4728. BNE ReadRight2 ; branch to ReadBDone if button is NOT pressed (0)
  4729. ; add instructions here to do something when button IS pressed (1)
  4730. LDA #$00 ; Right is not being held. Set back to #$00.
  4731. STA RightHeld
  4732. JMP ReadRightDone
  4733. ReadRight2:
  4734. LDA RightHeld ; if RightHeld is #$01, skip to end
  4735. CMP #$01
  4736. BEQ ReadRightDone
  4737.  
  4738. LDA gamestate
  4739. CMP #$01
  4740. BEQ ReadRightDone
  4741.  
  4742. LDA WinFlag
  4743. CMP #$01
  4744. BEQ ReadRightDone
  4745.  
  4746. LDA #$01 ; set RightHeld to #$01.
  4747. STA RightHeld
  4748.  
  4749. LDA #$01
  4750. STA SoundEffect
  4751. STA PlaySound
  4752.  
  4753. LDA $0203 ; look at $0203 and see if it's at the right most position
  4754. CMP #$D0
  4755. BNE .NotWrap ;if it's not, skip this and move right as usual
  4756. LDA #$B0
  4757. STA $0203 ;it is at right-most point. reposition to #$B8
  4758. STA $020F
  4759. CLC
  4760. ADC #$08
  4761. STA $0207
  4762. STA $020B
  4763. JMP ReadRightDone
  4764. .NotWrap:
  4765. LDA $0203 ; load sprite X position
  4766. CLC ; make sure carry flag is set
  4767. ADC #$10 ; A = A + 10
  4768. STA $0203 ; save sprite X position
  4769.  
  4770. LDA $0207 ; load sprite2 X position
  4771. CLC ; make sure carry flag is set
  4772. ADC #$10 ; A = A + 10
  4773. STA $0207 ; save sprite2 X position
  4774.  
  4775. LDA $020B ; load sprite3 X position
  4776. CLC ; make sure carry flag is set
  4777. ADC #$10 ; A = A + 10
  4778. STA $020B ; save sprite3 X position
  4779.  
  4780. LDA $020F ; load sprite4 X position
  4781. CLC ; make sure carry flag is set
  4782. ADC #$10 ; A = A + 10
  4783. STA $020F ; save sprite4 X position
  4784. ReadRightDone: ; handling this button is done
  4785. RTS
  4786.  
  4787. Random:
  4788. ; See "linear-congruential random number generator" for more.
  4789. ; rand = (rand * 5 + 0x3611) & 0xffff;
  4790. ; return (rand >> 8) & 0xff;
  4791.  
  4792. LDA RandomHigh ; multiply by 5
  4793. STA RandomTemp
  4794. LDA RandomLow
  4795. ASL a ; rand = rand * 4 + rand
  4796. ROL RandomTemp
  4797. ASL a
  4798. ROL RandomTemp
  4799. CLC
  4800. ADC RandomLow
  4801. PHA
  4802. LDA RandomTemp
  4803. ADC RandomHigh
  4804. STA RandomHigh
  4805. PLA ; rand = rand + 0x3611
  4806. CLC
  4807. ADC #$11
  4808. STA RandomLow
  4809. LDA RandomHigh
  4810. ADC #$36
  4811. STA RandomHigh
  4812. RTS
  4813.  
  4814. PickColors:
  4815. ;;choose a random color six times
  4816. LDX #$00
  4817. .Loop:
  4818. JSR Random
  4819. JSR GetCorrectValue
  4820. INX
  4821. JSR Random
  4822. JSR GetCorrectValue
  4823. INX
  4824. JSR Random
  4825. JSR GetCorrectValue
  4826. INX
  4827. JSR Random
  4828. JSR GetCorrectValue
  4829. INX
  4830. JSR Random
  4831. JSR GetCorrectValue
  4832. INX
  4833. JSR Random
  4834. JSR GetCorrectValue
  4835. RTS
  4836.  
  4837. DrawWinningColors:
  4838. LDX #$00
  4839. LDY #$00
  4840. DrawWinningColorsLoop:
  4841. LDA Color1Answer,x
  4842. CMP #$01
  4843. BEQ .FirstSprite
  4844. CMP #$03
  4845. BEQ .FirstSprite
  4846. CMP #$05
  4847. BEQ .FirstSprite
  4848. JMP .SecondSprite
  4849. .FirstSprite:
  4850. LDA $2002
  4851. LDA #$20
  4852. STA $2006
  4853. TYA
  4854. CLC
  4855. ADC #$89
  4856. STA $2006
  4857. LDA #$61
  4858. STA $2007
  4859. LDA #$62
  4860. STA $2007
  4861.  
  4862. LDA #$20
  4863. STA $2006
  4864. TYA
  4865. CLC
  4866. ADC #$A9
  4867. STA $2006
  4868. LDA #$63
  4869. STA $2007
  4870. LDA #$64
  4871. STA $2007
  4872. JSR GetCorrectColor
  4873. RTS
  4874.  
  4875. .SecondSprite:
  4876. LDA $2002
  4877. LDA #$20
  4878. STA $2006
  4879. TYA
  4880. CLC
  4881. ADC #$89
  4882. STA $2006
  4883. LDA #$65
  4884. STA $2007
  4885. LDA #$66
  4886. STA $2007
  4887.  
  4888. LDA #$20
  4889. STA $2006
  4890. TYA
  4891. CLC
  4892. ADC #$A9
  4893. STA $2006
  4894. LDA #$67
  4895. STA $2007
  4896. LDA #$68
  4897. STA $2007
  4898. JSR GetCorrectColor
  4899. RTS
  4900.  
  4901. GetCorrectColor:
  4902. CPX #$00
  4903. BNE Color2
  4904. Color1:
  4905. LDA Color1Answer
  4906. CMP #$03
  4907. BCC .Palette1
  4908. CMP #$05
  4909. BCC .Palette2
  4910. CMP #$07
  4911. BCC .Palette3
  4912. RTS
  4913. .Palette1:
  4914. LDA $2002
  4915. LDA #$23
  4916. STA $2006
  4917. LDA #$CA
  4918. STA $2006
  4919. LDA #%00000101
  4920. STA $2007
  4921. STA Answer1Attr
  4922. INX
  4923. INY
  4924. INY
  4925. INY
  4926. JMP DrawWinningColorsLoop
  4927. .Palette2:
  4928. LDA $2002
  4929. LDA #$23
  4930. STA $2006
  4931. LDA #$CA
  4932. STA $2006
  4933. LDA #%00001010
  4934. STA $2007
  4935. STA Answer1Attr
  4936. INX
  4937. INY
  4938. INY
  4939. INY
  4940. JMP DrawWinningColorsLoop
  4941. .Palette3:
  4942. LDA $2002
  4943. LDA #$23
  4944. STA $2006
  4945. LDA #$CA
  4946. STA $2006
  4947. LDA #%00001111
  4948. STA $2007
  4949. STA Answer1Attr
  4950. INX
  4951. INY
  4952. INY
  4953. INY
  4954. JMP DrawWinningColorsLoop
  4955. Color2:
  4956. CPX #$01
  4957. BNE Color3
  4958. LDA Color2Answer
  4959. CMP #$03
  4960. BCC .Palette1
  4961. CMP #$05
  4962. BCC .Palette2
  4963. CMP #$07
  4964. BCC .Palette3
  4965. RTS
  4966. .Palette1:
  4967. LDA $2002
  4968. LDA #$23
  4969. STA $2006
  4970. LDA #$CB
  4971. STA $2006
  4972. LDA #%00000001
  4973. STA $2007
  4974. STA Palette2
  4975. STA Answer2Attr
  4976. INX
  4977. INY
  4978. INY
  4979. INY
  4980. JMP DrawWinningColorsLoop
  4981. .Palette2:
  4982. LDA $2002
  4983. LDA #$23
  4984. STA $2006
  4985. LDA #$CB
  4986. STA $2006
  4987. LDA #%00000010
  4988. STA $2007
  4989. STA Palette2
  4990. STA Answer2Attr
  4991. INX
  4992. INY
  4993. INY
  4994. INY
  4995. JMP DrawWinningColorsLoop
  4996. .Palette3:
  4997. LDA $2002
  4998. LDA #$23
  4999. STA $2006
  5000. LDA #$CB
  5001. STA $2006
  5002. LDA #%00000011
  5003. STA $2007
  5004. STA Palette2
  5005. STA Answer2Attr
  5006. INX
  5007. INY
  5008. INY
  5009. INY
  5010. JMP DrawWinningColorsLoop
  5011. Color3:
  5012. CPX #$02
  5013. BEQ .Cont
  5014. JMP Color4
  5015. .Cont:
  5016. LDA Color3Answer
  5017. CMP #$03
  5018. BCC .Palette1
  5019. CMP #$05
  5020. BCC .Palette2
  5021. CMP #$07
  5022. BCC .Palette3
  5023. RTS
  5024. .Palette1:
  5025. LDA $2002
  5026. LDA #$23
  5027. STA $2006
  5028. LDA #$CB
  5029. STA $2006
  5030. LDA #%00000100
  5031. ORA Palette2
  5032. STA $2007
  5033. STA Answer3Attr1
  5034.  
  5035. LDA #$23
  5036. STA $2006
  5037. LDA #$CC
  5038. STA $2006
  5039. LDA #%00000001
  5040. STA $2007
  5041. STA Palette3
  5042. STA Answer3Attr2
  5043. INX
  5044. INY
  5045. INY
  5046. INY
  5047. JMP DrawWinningColorsLoop
  5048. .Palette2:
  5049. LDA $2002
  5050. LDA #$23
  5051. STA $2006
  5052. LDA #$CB
  5053. STA $2006
  5054. LDA #%00001000
  5055. ORA Palette2
  5056. STA $2007
  5057. STA Answer3Attr1
  5058.  
  5059. LDA #$23
  5060. STA $2006
  5061. LDA #$CC
  5062. STA $2006
  5063. LDA #%00000010
  5064. STA $2007
  5065. STA Palette3
  5066. STA Answer3Attr2
  5067. INX
  5068. INY
  5069. INY
  5070. INY
  5071. JMP DrawWinningColorsLoop
  5072. .Palette3:
  5073. LDA $2002
  5074. LDA #$23
  5075. STA $2006
  5076. LDA #$CB
  5077. STA $2006
  5078. LDA #%00001100
  5079. ORA Palette2
  5080. STA $2007
  5081. STA Answer3Attr1
  5082.  
  5083. LDA #$23
  5084. STA $2006
  5085. LDA #$CC
  5086. STA $2006
  5087. LDA #%00000011
  5088. STA $2007
  5089. STA Palette3
  5090. STA Answer3Attr2
  5091. INX
  5092. INY
  5093. INY
  5094. INY
  5095. JMP DrawWinningColorsLoop
  5096. Color4:
  5097. LDA Color4Answer
  5098. CMP #$03
  5099. BCC .Palette1
  5100. CMP #$05
  5101. BCC .Palette2
  5102. CMP #$07
  5103. BCC .Palette3
  5104. RTS
  5105. .Palette1:
  5106. LDA $2002
  5107. LDA #$23
  5108. STA $2006
  5109. LDA #$CC
  5110. STA $2006
  5111. LDA #%00000100
  5112. ORA Palette3
  5113. STA $2007
  5114. STA Answer4Attr
  5115. RTS
  5116. .Palette2:
  5117. LDA $2002
  5118. LDA #$23
  5119. STA $2006
  5120. LDA #$CC
  5121. STA $2006
  5122. LDA #%00001000
  5123. ORA Palette3
  5124. STA $2007
  5125. STA Answer4Attr
  5126. RTS
  5127. .Palette3:
  5128. LDA $2002
  5129. LDA #$23
  5130. STA $2006
  5131. LDA #$CC
  5132. STA $2006
  5133. LDA #%00001100
  5134. ORA Palette3
  5135. STA $2007
  5136. STA Answer4Attr
  5137. RTS
  5138.  
  5139. GetCorrectValue:
  5140. CMP #$2A
  5141. BCC .1
  5142. CMP #$54
  5143. BCC .2
  5144. CMP #$7E
  5145. BCC .3
  5146. CMP #$A8
  5147. BCC .4
  5148. CMP #$D2
  5149. BCC .5
  5150. JMP .6
  5151. .1:
  5152. LDA #$01
  5153. STA Color1Answer,x
  5154. RTS
  5155. .2:
  5156. LDA #$02
  5157. STA Color1Answer,x
  5158. RTS
  5159. .3:
  5160. LDA #$03
  5161. STA Color1Answer,x
  5162. RTS
  5163. .4:
  5164. LDA #$04
  5165. STA Color1Answer,x
  5166. RTS
  5167. .5:
  5168. LDA #$05
  5169. STA Color1Answer,x
  5170. RTS
  5171. .6:
  5172. LDA #$06
  5173. STA Color1Answer,x
  5174. RTS
  5175.  
  5176.  
  5177. LoadPalettes:
  5178. LDA $2002 ; read PPU status to reset the high/low latch
  5179. LDA #$3F
  5180. STA $2006 ; write the high byte of $3F00 address
  5181. LDA #$00
  5182. STA $2006 ; write the low byte of $3F00 address
  5183. LDX #$00 ; start out at 0
  5184. LoadPalettesLoop:
  5185. LDA palette, x ; load data from address (palette + the value in x)
  5186. ; 1st time through loop it will load palette+0
  5187. ; 2nd time through loop it will load palette+1
  5188. ; 3rd time through loop it will load palette+2
  5189. ; etc
  5190. STA $2007 ; write to PPU
  5191. INX ; X = X + 1
  5192. CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
  5193. BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
  5194. ; if compare was equal to 32, keep going down
  5195. RTS
  5196.  
  5197. LoadSprites:
  5198. LDX #$00 ; start at 0
  5199. LoadSpritesLoop:
  5200. LDA sprites, x ; load data from address (sprites + x)
  5201. STA $0200, x ; store into RAM address ($0200 + x)
  5202. INX ; X = X + 1
  5203. CPX #$d0 ; Compare X to hex $20, decimal 32
  5204. BNE LoadSpritesLoop ; Branch to LoadSpritesLoop if compare was Not Equal to zero
  5205. ; if compare was equal to 32, keep going down
  5206. RTS
  5207.  
  5208. LoadNametable:
  5209. LDA $2002
  5210. LDA #$20
  5211. STA $2006
  5212. LDA #$00
  5213. STA $2006
  5214.  
  5215. LDA #low(background)
  5216. STA AddrLow ; load low bytes of background data
  5217. LDA #high(background)
  5218. STA AddrHigh ; load high bytes of background data
  5219.  
  5220. LDX #$04 ; Loop X 4 times
  5221. LDY #$00 ; Loop Y 256 times
  5222. LoadBackgroundsLoop:
  5223. LDA [AddrLow],y
  5224. STA $2007
  5225. INY
  5226. BNE LoadBackgroundsLoop
  5227. ; Outer loop
  5228. INC AddrHigh ; increment high byte of address backg to next 256 byte chunk
  5229. DEX ; one chunk done so X = X - 1.
  5230. BNE LoadBackgroundsLoop ; if X isn't zero, do again
  5231. RTS
  5232.  
  5233. LoadAttribute:
  5234. LDA $2002 ; read PPU status to reset the high/low latch
  5235. LDA #$23
  5236. STA $2006 ; write the high byte of $23C0 address
  5237. LDA #$C0
  5238. STA $2006 ; write the low byte of $23C0 address
  5239. LDX #$00 ; start out at 0
  5240. LoadAttributeLoop:
  5241. LDA attribute, x ; load data from address (attribute + the value in x)
  5242. STA $2007 ; write to PPU
  5243. INX ; X = X + 1
  5244. CPX #$40 ; Compare X to hex $08, decimal 8 - copying 8 bytes
  5245. BNE LoadAttributeLoop ; Branch to LoadAttributeLoop if compare was Not Equal to zero
  5246. ; if compare was equal to 128, keep going down
  5247. RTS
  5248.  
  5249. GetColorPosition:
  5250. Row1:
  5251. LDA $0200
  5252. CMP #$B0
  5253. BNE Row2
  5254. Box1:
  5255. LDA $0203
  5256. CMP #$B0
  5257. BNE Box2
  5258. LDA #$00
  5259. STA ColorPosition
  5260. RTS
  5261. Box2:
  5262. LDA $0203
  5263. CMP #$C0
  5264. BNE Box3
  5265. LDA #$01
  5266. STA ColorPosition
  5267. RTS
  5268. Box3:
  5269. LDA $0203
  5270. CMP #$D0
  5271. BNE CountEnd
  5272. LDA #$02
  5273. STA ColorPosition
  5274. RTS
  5275. Row2:
  5276. LDA $0200
  5277. CMP #$C0
  5278. BNE CountEnd
  5279. Box4:
  5280. LDA $0203
  5281. CMP #$B0
  5282. BNE Box5
  5283. LDA #$03
  5284. STA ColorPosition
  5285. RTS
  5286. Box5:
  5287. LDA $0203
  5288. CMP #$C0
  5289. BNE Box6
  5290. LDA #$04
  5291. STA ColorPosition
  5292. RTS
  5293. Box6:
  5294. LDA $0203
  5295. CMP #$D0
  5296. BNE CountEnd
  5297. LDA #$05
  5298. STA ColorPosition
  5299. CountEnd:
  5300. RTS
  5301.  
  5302. EndGame:
  5303. LDA CurrentRow
  5304. CMP #$07
  5305. BEQ .Finish
  5306. RTS
  5307. .Finish:
  5308. LDA WinFlag
  5309. CMP #$01
  5310. BEQ .Skip
  5311. LDA #$01
  5312. STA WinFlag
  5313. STA PlaySound
  5314. LDA #$03
  5315. STA SoundEffect
  5316. JSR FamiToneMusicStop
  5317. .Skip:
  5318. RTS
  5319.  
  5320. MoveQuestionMarks: ;; better way to write it
  5321. LDA WinFlag
  5322. CMP #$01
  5323. BNE .End
  5324. LDA $0240
  5325. CMP #$11
  5326. BEQ .Reset
  5327. LDX #$40
  5328. .Loop:
  5329. DEC $020c,x
  5330. DEX
  5331. DEX
  5332. DEX
  5333. DEX
  5334. CPX #$00
  5335. BNE .Loop
  5336. RTS
  5337. .End:
  5338. RTS
  5339. .Reset:
  5340. LDA #STATELOADGAMEOVER
  5341. STA gamestate
  5342. LDA #$00
  5343. STA PlaySound
  5344. RTS
  5345.  
  5346. RunTimer:
  5347. LDA WinFlag
  5348. CMP #$01
  5349. BEQ .GameOver
  5350. INC CountdownTimer
  5351. LDA CountdownTimer
  5352. CMP difficulty ;;this number can change depending on how fast you want the timer to tick
  5353. BEQ .Tick
  5354. RTS
  5355. .Tick:
  5356. LDA #$00
  5357. STA CountdownTimer
  5358.  
  5359.  
  5360. .Ones: ;ones position (00x)
  5361. ;;look at ones position
  5362. ;;if it is zero, branch to .Tens to make it 9 and decrease tens position
  5363. ;;otherwise, just decrease ones position
  5364. LDA $02cD
  5365. CMP #$F6
  5366. BEQ .Tens
  5367. DEC $02CD
  5368.  
  5369. RTS
  5370.  
  5371. .Tens: ;tens position (0x0)
  5372. ;;look at tens position
  5373. ;;if it is zero, branch to make it 9 and decrease hundreds position
  5374. ;;otherwise, just decrease tens position and make ones position 9.
  5375. LDA $02c9
  5376. CMP #$F6
  5377. BEQ .Hundreds
  5378. DEC $02C9
  5379. LDA #$FF
  5380. STA $02cd
  5381. RTS
  5382. .Hundreds: ;hundreds position (x00)
  5383. ;;look at hundreds position
  5384. ;;if it is zero, the timer has expired. branch to .GameOver
  5385. ;;otherwise, just decrease hundreds position and make tens position 9.
  5386. LDA $02c5
  5387. CMP #$F6
  5388. BEQ .GameOvera
  5389. DEC $02C5
  5390. LDA #$FF
  5391. STA $02c9
  5392. STA $02CD
  5393. RTS
  5394. .GameOver:
  5395. LDA #$01
  5396. STA WinFlag
  5397. STA PlaySound
  5398. LDA #$03
  5399. STA SoundEffect
  5400. RTS
  5401. .GameOvera:
  5402. LDA #$02
  5403. STA WinLose
  5404. LDA WinLose
  5405. CMP #$02
  5406. BEQ .GameOver
  5407.  
  5408.  
  5409.  
  5410. AssignColor:
  5411. ;;The circle colors are assigned as follows:
  5412. ;;X X X
  5413. ;;X X X
  5414. ;;top left circle uses tiles #61-#64/attribute table 1
  5415. ;;top middle circle uses tiles #65-#68/attribute table 1
  5416. ;;top right circle uses tiles #61-64/attribute table 2
  5417. ;;bottom left circle uses tiles #65-68/attribute table 2
  5418. ;;bottom middle circle uses tiles #61-64/attribute table 3
  5419. ;;bottom right circle uses tiles #65-68/attribute table 3
  5420.  
  5421. ;;you should just have to copy/paste the code from "SeventhRowGuesses" into each of the other rows.
  5422. ;;what you'll need to edit is the locations of the tiles/attributes you're replacing.
  5423. ;;that data always starts with $2002/LDA $xx/STA $2006 where xx is the hi byte of the background you're replacing
  5424. ;;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
  5425.  
  5426.  
  5427. LDA AHeld ;;quick check to only allow this to run once per A press
  5428. CMP #$01
  5429. BEQ .End
  5430.  
  5431. ;;7 rows of guesses
  5432. LDA CurrentRow ;;If CurrentRow is #$00, we are at the beginning row. If not, branch to .6
  5433. CMP #$00
  5434. BNE .6
  5435. ;;7th row
  5436. JSR SeventhRowGuesses ;;CurrentRow is #$00. Jump to the subroutine SeventhRowGuesses to assign colors for every button press
  5437. RTS
  5438. .6:
  5439. CMP #$01
  5440. BNE .5
  5441. ;;6th row
  5442. JSR SixthRowGuesses
  5443. RTS
  5444. .5:
  5445. CMP #$02
  5446. BNE .4
  5447. ;;5th row
  5448. JSR FifthRowGuesses
  5449. RTS
  5450. .4:
  5451. CMP #$03
  5452. BNE .3
  5453. ;;4th row
  5454. JSR FourthRowGuesses
  5455. RTS
  5456. .3:
  5457. CMP #$04
  5458. BNE .2
  5459. ;;3rd row
  5460. JSR ThirdRowGuesses
  5461. RTS
  5462. .2:
  5463. CMP #$05
  5464. BNE .1
  5465. ;;2nd row
  5466. JSR SecondRowGuesses
  5467. RTS
  5468. .1:
  5469. CMP #$06
  5470. BNE .End
  5471. ;;1st row
  5472. JSR FirstRowGuesses
  5473. .End:
  5474. RTS
  5475.  
  5476. .include "title.asm"
  5477.  
  5478. ;;;;;;;;;;;;;;
  5479.  
  5480. .bank 3
  5481. .org $E000
  5482.  
  5483. .include "trackone.asm"
  5484.  
  5485. ;;the different colored circles use colors from palettes 2, 3 and 4.
  5486. ;; it always uses the second and fourth color, since the third color is the brown color of the background.
  5487. ;; that forces that color to stay the same in all color palettes, sadly.
  5488.  
  5489. palette:
  5490. .db $0f,$29,$18,$2D, $0f,$06,$18,$12, $0f,$38,$18,$1A, $0f,$04,$18,$29 ;;background palette
  5491. .db $0f,$29,$18,$14, $0f,$30,$38,$0f, $0f,$1C,$15,$14, $0f,$02,$38,$3C ;;sprite palette
  5492.  
  5493. sprites:
  5494. sprites:
  5495. ;vert tile attr horiz
  5496. .db $B0, $32, $00, $b0 ;sprite 0
  5497. .db $B0, $33, $00, $b8 ;sprite 1
  5498. .db $B8, $35, $00, $b8 ;sprite 2
  5499. .db $B8, $34, $00, $b0 ;sprite 3
  5500.  
  5501. .db $20, $36, $00, $49 ;sprite ?1tpl
  5502. .db $20, $37, $00, $51 ;sprite ?1tpr
  5503. .db $28, $46, $00, $49 ;sprite ?1bpl
  5504. .db $28, $47, $00, $51 ;sprite ?1bpr
  5505.  
  5506. .db $20, $36, $00, $61 ;sprite ?2tpl
  5507. .db $20, $37, $00, $69 ;sprite ?2tpr
  5508. .db $28, $46, $00, $61 ;sprite ?2bpl
  5509. .db $28, $47, $00, $69 ;sprite ?2bpr
  5510.  
  5511. .db $20, $36, $00, $79 ;sprite ?3tpl
  5512. .db $20, $37, $00, $81 ;sprite ?3tpr
  5513. .db $28, $46, $00, $79 ;sprite ?3bpl
  5514. .db $28, $47, $00, $81 ;sprite ?3bpr
  5515.  
  5516. .db $20, $36, $00, $91 ;sprite ?4tpl
  5517. .db $20, $37, $00, $99 ;sprite ?4tpr
  5518. .db $28, $46, $00, $91 ;sprite ?4bpl
  5519. .db $28, $47, $00, $99 ;sprite ?4bpr
  5520.  
  5521. .db $BF, $39, $01, $10 ;7th row dot ;0250
  5522. .db $BF, $39, $01, $20 ;7th row dot
  5523. .db $C7, $39, $01, $10 ;7th row dot
  5524. .db $C7, $39, $01, $20 ;7th row dot
  5525.  
  5526. .db $A7, $39, $01, $10 ;6th row dot
  5527. .db $A7, $39, $01, $20 ;6th row dot
  5528. .db $AF, $39, $01, $10 ;6th row dot
  5529. .db $AF, $39, $01, $20 ;6th row dot
  5530.  
  5531. .db $8F, $39, $01, $10 ;5th row dot
  5532. .db $8F, $39, $01, $20 ;5th row dot
  5533. .db $97, $39, $01, $10 ;5th row dot
  5534. .db $97, $39, $01, $20 ;5th row dot
  5535.  
  5536. .db $77, $39, $01, $10 ;4th row dot
  5537. .db $77, $39, $01, $20 ;4th row dot
  5538. .db $7F, $39, $01, $10 ;4th row dot
  5539. .db $7F, $39, $01, $20 ;4th row dot
  5540.  
  5541. .db $5F, $39, $01, $10 ;3rd row dot
  5542. .db $5F, $39, $01, $20 ;3rd row dot
  5543. .db $67, $39, $01, $10 ;3rd row dot
  5544. .db $67, $39, $01, $20 ;3rd row dot
  5545.  
  5546. .db $47, $39, $01, $10 ;2nd row dot
  5547. .db $47, $39, $01, $20 ;2nd row dot
  5548. .db $4F, $39, $01, $10 ;2nd row dot
  5549. .db $4F, $39, $01, $20 ;2nd row dot
  5550.  
  5551. .db $2F, $39, $01, $10 ;1st row dot
  5552. .db $2F, $39, $01, $20 ;1st row dot
  5553. .db $37, $39, $01, $10 ;1st row dot
  5554. .db $37, $39, $01, $20 ;1st row dot
  5555.  
  5556. .db $77, $38, $01, $B8 ;key dot
  5557. .db $40, $f8, $01, $c0 ;100s
  5558. .db $40, $f6, $01, $C8 ;10s
  5559. .db $40, $f6, $01, $D0 ;1s
  5560.  
  5561. ;;as you can see, I am pulling from all three palettes in the attribute table. some sections are using
  5562. ;;palette %01, some are using palette %10, and some are using palette %11.
  5563. ;;remember, these are binary numbers. %01=1, %10=2, %11=3.
  5564.  
  5565. attribute:
  5566. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  5567. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  5568. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  5569. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  5570. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  5571. .db %00000000, %00000000, %00000000, %00000000, %00000000, %01000000, %10010000, %00000000
  5572. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00001000, %00001111, %00000000
  5573. .db %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000
  5574.  
  5575. background:
  5576. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  5577. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  5578.  
  5579. .db $25,$70,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71,$71 ;;row 2
  5580. .db $71,$71,$71,$71,$71,$72,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;top
  5581.  
  5582. .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60 ;;row 2
  5583. .db $60,$60,$60,$60,$60,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;top
  5584.  
  5585. .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60,$60 ;;row 2
  5586. .db $60,$60,$60,$60,$60,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;top
  5587.  
  5588. .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5589. .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;??? top
  5590.  
  5591. .db $25,$82,$60,$60,$60,$60,$60,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5592. .db $63,$64,$60,$63,$64,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;???bottom
  5593.  
  5594. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5595. .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 7 top
  5596.  
  5597. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5598. .db $63,$64,$60,$63,$64,$83,$25,$25,$1d,$12,$16,$0E,$1B,$25,$25,$25,$25 ;;guess 7 bottom
  5599.  
  5600. .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
  5601. .db $56,$56,$56,$56,$56,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;divider
  5602.  
  5603. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5604. .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 6 top
  5605.  
  5606. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row
  5607. .db $63,$64,$60,$63,$64,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 6 bottom
  5608.  
  5609. .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
  5610. .db $56,$56,$56,$56,$56,$83,$25,$70,$71,$71,$71,$71,$71,$71,$71,$72,$25 ;;divider
  5611.  
  5612. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5613. .db $61,$62,$60,$61,$62,$83,$25,$82,$44,$28,$29,$2a,$2b,$2c,$2d,$83,$25 ;;guess 5 top
  5614.  
  5615. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5616. .db $63,$64,$60,$63,$64,$83,$25,$82,$60,$28,$29,$2a,$3b,$3c,$60,$83,$25 ;;guess 5 bottom
  5617.  
  5618. .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
  5619. .db $56,$56,$56,$56,$56,$83,$25,$82,$56,$56,$56,$56,$56,$56,$56,$83,$25 ;;divider
  5620.  
  5621. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5622. .db $61,$62,$60,$61,$62,$83,$25,$82,$60,$28,$29,$2A,$2B,$2C,$2D,$83,$25 ;;guess 4 top
  5623.  
  5624. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5625. .db $63,$64,$60,$63,$64,$83,$25,$82,$60,$38,$39,$3A,$3B,$3C,$60,$83,$25 ;;guess 4 bottom
  5626.  
  5627. .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
  5628. .db $56,$56,$56,$56,$56,$83,$25,$7F,$80,$80,$80,$80,$80,$80,$80,$81,$25 ;;divider
  5629.  
  5630. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5631. .db $61,$62,$60,$61,$62,$83,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;guess 3 top
  5632.  
  5633. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5634. .db $63,$64,$60,$63,$64,$83,$19,$12,$0c,$14,$25,$22,$18,$1E,$1B,$25,$25 ;;guess 3 bottom
  5635.  
  5636. .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
  5637. .db $56,$56,$56,$56,$56,$83,$25,$25,$0c,$18,$15,$18,$1B,$25,$25,$25,$25 ;;divider
  5638.  
  5639. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5640. .db $61,$62,$60,$61,$62,$83,$70,$71,$71,$71,$71,$71,$71,$71,$72,$25,$25 ;;guess 2 top
  5641.  
  5642. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5643. .db $63,$64,$60,$63,$64,$83,$82,$61,$62,$65,$66,$61,$62,$60,$83,$25,$25 ;;guess 2 bottom
  5644.  
  5645. .db $25,$82,$56,$56,$56,$56,$57,$56,$56,$56,$56,$56,$56,$56,$56 ;;row 3
  5646. .db $56,$56,$56,$56,$56,$83,$82,$63,$64,$67,$68,$63,$64,$60,$83,$25,$25 ;;divider
  5647.  
  5648. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$61,$62,$60,$61,$62,$60 ;;row 3
  5649. .db $61,$62,$60,$61,$62,$83,$82,$65,$66,$61,$62,$65,$66,$60,$83,$25,$25 ;;guess 1 top
  5650.  
  5651. .db $25,$82,$42,$60,$42,$60,$54,$60,$60,$63,$64,$60,$63,$64,$60 ;;row 3
  5652. .db $63,$64,$60,$63,$64,$83,$82,$67,$68,$63,$64,$67,$68,$60,$83,$25,$25 ;;guess 1 bottom
  5653.  
  5654. .db $25,$7f,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80 ;;row 3
  5655. .db $80,$80,$80,$80,$80,$81,$7F,$80,$80,$80,$80,$80,$80,$80,$81,$25,$25 ;;bottom
  5656.  
  5657. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  5658. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  5659.  
  5660. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  5661. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  5662.  
  5663. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;row 1
  5664. .db $25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25,$25 ;;all sky
  5665.  
  5666. .org $FFFA ;first of the three vectors starts here
  5667. .dw NMI ;when an NMI happens (once per frame if enabled) the
  5668.  
  5669. ;processor will jump to the label NMI
  5670. .dw RESET ;when the processor first turns on or is reset, it will jump
  5671. ;to the label RESET:
  5672. .dw 0 ;external interrupt IRQ is not used in this tutorial
  5673.  
  5674.  
  5675.  
  5676. ;;;;;;;;;;;;;;
  5677.  
  5678. .bank 4
  5679. .org $0000
  5680. .incbin "mario.chr" ;includes 8KB graphics file from SMB1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement