Guest User

Untitled

a guest
Nov 18th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; -------------------
  2. ; METROID source code
  3. ; -------------------
  4. ; MAIN PROGRAMMERS
  5. ;     HAI YUKAMI
  6. ;   ZARU SOBAJIMA
  7. ;    GPZ SENGOKU
  8. ;    N.SHIOTANI
  9. ;     M.HOUDAI
  10. ; (C) 1986 NINTENDO
  11. ;
  12. ;Commented by Dirty McDingus (nmikstas@yahoo.com)
  13. ;Disassembled using TRaCER.
  14. ;Can be reassembled using Ophis.
  15. ;Last updated: 3/9/2010
  16.  
  17. ;Title/end (memory page 0)
  18.  
  19. .org $8000
  20.  
  21. .include "MetroidDefines.txt"
  22.  
  23. ;-------------------------------------[ Forward declarations ]--------------------------------------
  24.  
  25. .alias startup          $C01A
  26. .alias NMI          $C0D9
  27. .alias ClearNameTables      $C158
  28. .alias ClearNameTable0      $C16D
  29. .alias EraseAllSprites      $C1A3
  30. .alias RemoveIntroSprites   $C1BC
  31. .alias ClearRAM_33_DF       $C1D4
  32. .alias PreparePPUProcess_   $C20E
  33. .alias ChooseRoutine        $C27C
  34. .alias AddYToPtr02      $C2B3
  35. .alias Adiv16           $C2BF
  36. .alias Adiv8            $C2C0
  37. .alias Amul16           $C2C5
  38. .alias Amul8            $C2C6
  39. .alias ProcessPPUString     $C30C
  40. .alias EraseTile        $C328
  41. .alias WritePPUByte     $C36B
  42. .alias PrepPPUPaletteString $C37E
  43. .alias TwosCompliment       $C3D4
  44. .alias WaitNMIPass      $C42C
  45. .alias ScreenOff        $C439
  46. .alias WaitNMIPass_     $C43F
  47. .alias ScreenOn         $C447
  48. .alias ExitSub          $C45C
  49. .alias ScreenNmiOff     $C45D
  50. .alias VBOffAndHorzWrite    $C47D
  51. .alias NmiOn            $C487
  52. .alias SetTimer         $C4AA
  53. .alias ClearSamusStats      $C578
  54. .alias InitEndGFX       $C5D0
  55. .alias LoadSamusGFX     $C5DC
  56. .alias InitGFX7         $C6D6
  57. .alias BankTable        $CA30
  58. .alias ChooseEnding     $CAF5
  59. .alias SilenceMusic     $CB8E
  60.  
  61. ;-----------------------------------------[ Start of code ]------------------------------------------
  62.  
  63. MainTitleRoutine:
  64. L8000:  lda TitleRoutine        ;
  65. L8002:  cmp #$15            ;If intro routines not running, branch.
  66. L8004:  bcs ++              ;
  67. L8006:  lda Joy1Change          ;
  68. L8008:  and #$10            ;if start has not been pressed, branch.
  69. L800A:  beq +               ;
  70. L800C:  ldy #$00            ;
  71. L800E:  sty SpareMemD1          ;Not accessed by game.
  72. L8010:  sty SpareMemBB          ;Not accessed by game.
  73. L8012:  sty SpareMemB7          ;Accessed by unused routine.
  74. L8014:  sty SpareMemB8          ;Accessed by unused routine.
  75. L8016:  lda PPUCNT0ZP           ;  
  76. L8018:  and #$FC            ;Set name table to name table 0.
  77. L801A:  sta PPUCNT0ZP           ;
  78. L801C:  lda #$1B            ;If start pressed, load START/CONTINUE screen.
  79. L801E:  sta TitleRoutine        ;
  80. L8020:  bne ++              ;Branch always.
  81. L8022:* jsr RemoveIntroSprites      ;($C1BC)Remove sparkle and crosshair sprites from screen.
  82. L8025:  lda TitleRoutine        ;
  83. L8027:* jsr ChooseRoutine       ;($C27C)Jump to proper routine below.
  84.  
  85. L802A:  .word InitializeAfterReset  ;($8071)First routine after reset.
  86. L802C:  .word DrawIntroBackground   ;($80D0)Draws ground on intro screen.
  87. L802E:  .word FadeInDelay       ;($80F9)Sets up METROID fade in delay.
  88. L8030:  .word METROIDFadeIn     ;($812C)Fade METROID onto screen.
  89. L8032:  .word LoadFlashTimer        ;($8142)Load timer for METROID flash.
  90. L8034:  .word FlashEffect       ;($8109)Makes METROID flash.
  91. L8036:  .word METROIDSparkle        ;($814D)Top and bottom "sparkles" on METROID.
  92. L8038:  .word METROIDFadeOut        ;($8163)Fades METROID off the screen.
  93. L803A:  .word Crosshairs        ;($8182)Displays "crosshairs" effect on screen.
  94. L803C:  .word MoreCrosshairs        ;($81D1)Continue "crosshairs" effect.
  95. L803E:  .word IncTitleRoutine       ;($806E)Increment TitleRoutine.
  96. L8040:  .word IncTitleRoutine       ;($806E)Increment TitleRoutine.
  97. L8042:  .word ChangeIntroNameTable  ;($822E)Change from name table 0 to name table 1.
  98. L8044:  .word MessageFadeIn     ;($8243)Fade in intro sequence message.
  99. L8046:  .word MessageFadeOut        ;($8263)Fade out intro sequence message.
  100. L8048:  .word DelayIntroReplay      ;($8283)Set Delay time before intro sequence restarts.
  101. L804A:  .word ClearSpareMem     ;($8068)clears some memory addresses not used by game.
  102. L804C:  .word PrepIntroRestart      ;($82A3)Prepare to restart intro routines.
  103. L804E:  .word TitleScreenOff        ;($82ED)Turn screen off.
  104. L8050:  .word TitleRoutineReturn    ;($82F3)Rts.
  105. L8052:  .word TitleRoutineReturn    ;($82F3)Rts.
  106. L8054:  .word StartContinueScreen   ;($90BA)Displays START/Continue screen.
  107. L8056:  .word ChooseStartContinue   ;($90D7)player chooses between START and CONTINUE.
  108. L8058:  .word LoadPasswordScreen    ;($911A)Loads password entry screen.
  109. L805A:  .word EnterPassword     ;($9147)User enters password.
  110. L805C:  .word DisplayPassword       ;($9359)After game over, display password on screen.
  111. L805E:  .word WaitForSTART      ;($9394)Wait for START when showing password.
  112. L8060:  .word StartContinueScreen   ;($90BA)Displays START/Continue screen.
  113. L8062:  .word GameOver          ;($939E)Displays "GAME OVER".
  114. L8064:  .word EndGame           ;($9AA7)Show ending of the game.
  115. L8066:  .word SetTimer          ;($C4AA)Set delay timer.
  116.  
  117. ;----------------------------------------[ Intro routines ]------------------------------------------
  118.  
  119. ClearSpareMem:
  120. L8068:  lda #$00            ;
  121. L806A:  sta SpareMemCB          ;Clears two memory addresses not used by the game.
  122. L806C:  sta SpareMemC9          ;
  123.  
  124. IncTitleRoutine:
  125. L806E:  inc TitleRoutine        ;Increment to next title routine.
  126. L8070:  rts             ;
  127.  
  128. InitializeAfterReset:
  129. L8071:  ldy #$02            ;Y=2.
  130. L8073:  sty SpareMemCF          ;Not accessed by game.
  131. L8075:  sty SpareMemCC          ;Not accessed by game.
  132. L8077:  dey             ;Y=1.
  133. L8078:  sty SpareMemCE          ;Not accessed by game.
  134. L807A:  sty SpareMemD1          ;Not accessed by game.
  135. L807C:  dey             ;Y=0.
  136. L807D:  sty SpareMemD0          ;Not accessed by game.
  137. L807F:  sty SpareMemCD          ;Not accessed by game.
  138. L8081:  sty SpareMemD3          ;Not accessed by game.
  139. L8083:  sty NARPASSWORD         ;Set NARPASSWORD not active.   
  140. L8086:  sty SpareMemCB          ;Not accessed by game.
  141. L8088:  sty SpareMemC9          ;Not accessed by game.
  142. L808A:  lda #$02            ;A=2.
  143. L808C:  sta IntroMusicRestart       ;Title rountines cycle twice before restart of music.
  144. L808E:  sty SpareMemB7          ;Accessed by unused routine.
  145. L8090:  sty SpareMemB8          ;Accessed by unused routine.
  146. L8092:  sty PalDataIndex        ;Reset index to palette data.
  147. L8094:  sty ScreenFlashPalIndex     ;Reset index into screen flash palette data.
  148. L8096:  sty IntroStarOffset     ;Reset index into IntroStarPntr table.
  149. L8098:  sty FadeDataIndex       ;Reset index into fade out palette data.
  150. L809A:  sty $00             ;
  151. L809C:  ldx #$60            ;Set $0000 to point to address $6000.
  152.  
  153. L809E:* stx $01             ;
  154. L80A0:  txa             ;
  155. L80A1:  and #$03            ;
  156. L80A3:  asl             ;
  157. L80A4:  tay             ;The following loop Loads the -->
  158. L80A5:  sty $02             ;RAM with the following values: -->
  159. L80A7:  lda RamValueTbl, y      ;$6000 thru $62FF = #$00.
  160. L80AA:  ldy #$00            ;$6300 thru $633F = #$C0.
  161. L80AC:* sta ($00), y            ;$6340 thru $63FF = #$C4.
  162. L80AE:  iny             ;$6400 thru $66FF = #$00.
  163. L80AF:  beq +               ;$6700 thru $673F = #$C0.
  164. L80B1:  cpy #$40            ;$6740 thru $67FF = #$C4.
  165. L80B3:  bne -               ;
  166. L80B5:  ldy $02             ;
  167. L80B7:  lda RamValueTbl+1, y        ;
  168. L80BA:  ldy #$40            ;
  169. L80BC:  bpl -               ;
  170. L80BE:* inx             ;
  171. L80BF:  cpx #$68            ;
  172. L80C1:  bne ---             ;
  173.  
  174. L80C3:  inc TitleRoutine        ;Draw intro background next.           
  175. L80C5:  jmp LoadStarSprites     ;($98AE)Loads stars on intro screen.       
  176.  
  177. ;The following table is used by the code above for writing values to RAM.
  178.  
  179. RamValueTbl:
  180. L80C8:  .byte $00, $00, $00, $00, $00, $00, $C0, $C4
  181.  
  182. DrawIntroBackground:
  183. L80D0:  LDA #$10            ;Intro music flag.
  184. L80D2:  STA ABStatus            ;Never accessed by game.
  185. L80D4:  STA MultiSFXFlag        ;Initiates intro music.
  186. L80D7:  JSR ScreenOff           ;($C439)Turn screen off.
  187. L80DA:  JSR ClearNameTables     ;($C158)Erase name table data.
  188. L80DD:  LDX #$F4            ;Lower address of PPU information.
  189. L80DF:  LDY #$82            ;Upper address of PPU information.
  190. L80E1:  JSR PreparePPUProcess_      ;($C20E) Writes background of intro screen to name tables.
  191. L80E4:  LDA #$01            ;
  192. L80E6:  STA PalDataPending      ;Prepare to load palette data.
  193. L80E8:  STA SpareMemC5          ;Not accessed by game.
  194. L80EA:  LDA PPUCNT0ZP           ;
  195. L80EC:  AND #$FC            ;Switch to name table 0
  196. L80EE:  STA PPUCNT0ZP           ;
  197. L80F0:  INC TitleRoutine        ;Next routine sets up METROID fade in delay.
  198. L80F2:  LDA #$00            ;
  199. L80F4:  STA SpareMemD7          ;Not accessed by game.
  200. L80F6:  JMP ScreenOn            ;($C447)Turn screen on.
  201.  
  202. FadeInDelay:
  203. L80F9:  LDA PPUCNT0ZP           ;
  204. L80FB:  AND #$FE            ;Switch to name table 0 or 2.
  205. L80FD:  STA PPUCNT0ZP           ;
  206. L80FF:  LDA #$08            ;Loads Timer3 with #$08. Delays Fade in routine.-->
  207. L8101:  STA Timer3          ;Delays fade in by 80 frames (1.3 seconds).
  208. L8103:  LSR             ;
  209. L8104:  STA PalDataIndex        ;Loads PalDataIndex with #$04
  210. L8106:  INC TitleRoutine        ;Increment to next routine.
  211. L8108:  RTS             ;
  212.  
  213. FlashEffect:
  214. L8109:  LDA FrameCount          ;Every third frame, run change palette-->
  215. L810B:  AND #$03            ;Creates METROID flash effect.
  216. L810D:  BNE +               ;
  217. L810F:  LDA PalDataIndex        ;Uses only the first three palette-->
  218. L8111:  AND #$03            ;data sets in the flash routine.
  219. L8113:  STA PalDataIndex        ;
  220. L8115:  JSR LoadPalData         ;
  221. L8118:  LDA Timer3          ;If Timer 3 has not expired, branch-->
  222. L811A:  BNE +               ;so routine will keep running.
  223. L811C:  LDA PalDataIndex        ;
  224. L811E:  CMP #$04            ;Ensures the palette index is back at 0.
  225. L8120:  BNE +               ;
  226. L8122:  INC TitleRoutine        ;Increment to next routine.
  227. L8124:  JSR LoadSparkleData     ;($87AB) Loads data for next routine.
  228. L8127:  LDA #$18            ;Sets Timer 3 for a delay of 240 frames-->
  229. L8129:  STA Timer3          ;(4 seconds).
  230. L812B:* RTS             ;
  231.  
  232. METROIDFadeIn:
  233. L812C:  LDA Timer3          ;
  234. L812E:  BNE +               ;
  235. L8130:  LDA FrameCount          ;Every 16th FrameCount, Change palette.-->
  236. L8132:  AND #$0F            ;Causes the fade in effect.
  237. L8134:  BNE +               ;
  238. L8136:  JSR LoadPalData         ;($8A8C)Load data into Palettes.
  239. L8139:  BNE +               ;
  240. L813B:  LDA #$20            ;Set timer delay for METROID flash effect.-->
  241. L813D:  STA Timer3          ;Delays flash by 320 frames (5.3 seconds).
  242. L813F:  INC TitleRoutine        ;
  243. L8141:* RTS             ;
  244.  
  245. LoadFlashTimer:
  246. L8142:  LDA Timer3          ;If 320 frames have not passed, exit
  247. L8144:  BNE -               ;
  248. L8146:  LDA #$08            ;
  249. L8148:  STA Timer3          ;Stores a value of 80 frames in Timer3-->
  250. L814A:  INC TitleRoutine        ;(1.3 seconds).
  251. L814C:  RTS             ;
  252.  
  253. METROIDSparkle:
  254. L814D:  LDA Timer3          ;Wait until 3 seconds have passed since-->
  255. L814F:  BNE ++              ;last routine before continuing.
  256. L8151:  LDA IntroSpr0Complete       ;Check if sparkle sprites are done moving.
  257. L8154:  AND IntroSpr1Complete       ;
  258. L8157:  CMP #$01            ;Is sparkle routine finished? If so,-->
  259. L8159:  BNE +               ;go to next title routine, else continue-->
  260. L815B:  INC TitleRoutine        ;with sparkle routine.
  261. L815D:  BNE ++              ;
  262. L815F:* JSR UpdateSparkleSprites    ;($87CF)Update sparkle sprites on the screen.
  263. L8162:* RTS             ;
  264.  
  265. METROIDFadeOut:
  266. L8163:  LDA FrameCount          ;Wait until the frame count is a multiple-->
  267. L8165:  AND #$07            ;of eight before proceeding.  
  268. L8167:  BNE ++              ;
  269. L8169:  LDA FadeDataIndex       ;If FadeDataIndex is less than #$04, keep-->
  270. L816B:  CMP #$04            ;doing the palette changing routine.
  271. L816D:  BNE +               ;
  272. L816F:  JSR LoadInitialSpriteData   ;($8897)Load initial sprite values for crosshair routine.
  273. L8172:  LDA #$08            ;
  274. L8174:  STA Timer3          ;Load Timer3 with a delay of 80 frames(1.3 seconds).
  275. L8176:  STA First4SlowCntr      ;Set counter for slow sprite movement for 8 frames,
  276. L8178:  LDA #$00            ;
  277. L817A:  STA SecondCrosshairSprites  ;Set SecondCrosshairSprites = #$00
  278. L817C:  INC TitleRoutine        ;Move to next routine
  279. L817E:* JSR DoFadeOut           ;($8B5F)Fades METROID off the screen.
  280. L8181:* RTS             ;
  281.  
  282. Crosshairs:
  283. L8182:  LDA FlashScreen         ;Is it time to flash the screen white?-->
  284. L8184:  BEQ +               ;If not, branch.
  285. L8186:  JSR FlashIntroScreen        ;($8AA7)Flash screen white.
  286. L8189:* LDA Timer3          ;Wait 80 frames from last routine-->
  287. L818B:  BNE ++++            ;before running this one.
  288. L818D:  LDA IntroSpr0Complete       ;
  289. L8190:  AND IntroSpr1Complete       ;Check if first 4 sprites have completed-->
  290. L8193:  AND IntroSpr2Complete       ;their movements.  If not, branch.
  291. L8196:  AND IntroSpr3Complete       ;
  292. L8199:  BEQ ++              ;
  293. L819B:  LDA #$01            ;Prepare to flash screen and draw cross.
  294. L819D:  CMP SecondCrosshairSprites  ;Branch if second crosshair sprites are already-->
  295. L819F:  BEQ +               ;active.
  296. L81A1:  INC SecondCrosshairSprites  ;Indicates second crosshair sprites are active.
  297. L81A3:  STA DrawCross           ;Draw cross animation on screen.
  298. L81A5:  STA FlashScreen         ;Flash screen white.
  299. L81A7:  LDA #$00            ;
  300. L81A9:  STA CrossDataIndex      ;Reset index to cross sprite data.
  301. L81AB:* AND IntroSpr4Complete       ;
  302. L81AE:  AND IntroSpr5Complete       ;Check if second 4 sprites have completed-->
  303. L81AF:  AND IntroSpr6Complete       ;their movements.  If not, branch.
  304. L81B4:  AND IntroSpr7Complete       ;
  305. L81B7:  BEQ +               ;
  306. L81B9:  LDA #$01            ;Prepare to flash screen and draw cross.
  307. L81BB:  STA DrawCross           ;Draw cross animation on screen.
  308. L81BD:  STA FlashScreen         ;Flash screen white.
  309. L81BF:  JSR LoadStarSprites     ;($98AE)Loads stars on intro screen.
  310. L81C2:  LDA #$00            ;
  311. L81C4:  STA CrossDataIndex      ;Reset index to cross sprite data.
  312. L81C6:  INC TitleRoutine        ;Do MoreCrosshairs next frame.
  313. L81C8:  BNE ++              ;Branch always.
  314. L81CA:* JSR DrawCrosshairsSprites   ;($88FE)Draw sprites that converge in center of screen.
  315. L81CD:* JSR DrawCrossSprites        ;($8976)Draw cross sprites in middle of the screen.
  316. L81D0:* RTS             ;
  317.  
  318. MoreCrosshairs:
  319. L81D1:  LDA FlashScreen         ;Is it time to flash the screen white?-->
  320. L81D3:  BEQ +               ;If not, branch.
  321. L81D5:  JSR DrawCrossSprites        ;($8976)Draw cross sprites in middle of the screen.
  322. L81D8:  JMP FlashIntroScreen        ;($8AA7)Flash screen white.
  323. L81DB:* INC TitleRoutine        ;ChangeIntroNameTable is next routine to run.
  324. L81DD:  LDA #$60            ;
  325. L81DF:  STA ObjectY         ;
  326. L81E2:  LDA #$7C            ;These values are written into memory, but they are-->
  327. L81E4:  STA ObjectX         ;not used later in the title routine.  This is the-->
  328. L81E7:  LDA AnimResetIndex      ;remnants of some abandoned code.
  329. L81EA:  STA AnimIndex           ;
  330. L81ED:  RTS             ;
  331.  
  332. UnusedIntroRoutine1:
  333. L81EE:  LDA #$01            ;
  334. L81F0:  STA SpareMemBB          ;
  335. L81F2:  LDA #$04            ;
  336. L81F4:  STA SpritePagePos       ;
  337. L81F6:  STA Joy1Change          ;
  338. L81F8:  STA Joy1Status          ;Unused intro routine.
  339. L81FA:  STA Joy1Retrig          ;
  340. L81FC:  LDA #$03            ;
  341. L81FE:  STA ObjAction           ;
  342. L8201:  STA ScrollDir           ;
  343. L8203:  INC TitleRoutine        ;
  344. L8205:  RTS             ;
  345.  
  346. UnusedIntroRoutine2:
  347. L8206:  LDA ObjAction           ;
  348. L8209:  CMP #$04            ;
  349. L820B:  BNE +               ;
  350. L820D:  LDA #$00            ;
  351. L820F:  STA ObjAction           ;
  352. L8212:  LDA #$0B            ;Unused intro routine. It looks like this routine-->
  353. L8214:  STA AnimResetIndex      ;was going to be used to manipulate sprite objects.
  354. L8217:  LDA #$0C            ;
  355. L8219:  STA AnimIndex           ;
  356. L821C:  LDA #$07            ;
  357. L821E:  STA AnimFrame           ;
  358. L8221:  LDA #$08            ;
  359. L8223:  STA Timer3          ;
  360. L8225:  LDA #$00            ;
  361. L8227:  STA SpareMemC9          ;Not accessed by game.
  362. L8229:  STA SpareMemCB          ;Not accessed by game.
  363. L822B:  INC TitleRoutine        ;
  364. L822D:* RTS             ;
  365.  
  366. ChangeIntroNameTable:
  367. L822E:  LDA PPUCNT0ZP           ;
  368. L8230:  ORA #$01            ;Change to name table 1.
  369. L8232:  STA PPUCNT0ZP           ;
  370. L8234:  INC TitleRoutine        ;Next routine to run is MessageFadeIn.
  371. L8236:  LDA #$08            ;
  372. L8238:  STA Timer3          ;Set Timer3 for 80 frames(1.33 seconds).
  373. L823A:  LDA #$06            ;Index to FadeInPalData.
  374. L823C:  STA FadeDataIndex       ;
  375. L823E:  LDA #$00            ;
  376. L8240:  STA SpareMemC9          ;Not accessed by game.
  377. L8242:  RTS             ;
  378.  
  379. MessageFadeIn:
  380. L8243:  LDA Timer3          ;Check if delay timer has expired.  If not, branch-->
  381. L8245:  BNE ++              ;to exit, else run this rouine.
  382. L8247:  LDA FrameCount          ;
  383. L8249:  AND #$07            ;Perform next step of fade every 8th frame.
  384. L824B:  BNE ++              ;
  385. L824D:  LDA FadeDataIndex       ;
  386. L824F:  CMP #$0B            ;Has end of fade in palette data been reached?-->
  387. L8251:  BNE +               ;If not, branch.
  388. L8253:  LDA #$00            ;
  389. L8255:  STA FadeDataIndex       ;Clear FadeDataIndex.
  390. L8257:  LDA #$30            ;
  391. L8259:  STA Timer3          ;Set Timer3 to 480 frames(8 seconds).
  392. L825B:  INC TitleRoutine        ;Next routine is MessageFadeOut.
  393. L825D:  BNE ++              ;Branch always.
  394. L825F:* JSR DoFadeOut           ;($8B5F)Fade message onto screen.
  395. L8262:* RTS             ;
  396.  
  397. MessageFadeOut:
  398. L8263:  LDA Timer3          ;Check if delay timer has expired.  If not, branch-->
  399. L8265:  BNE ++              ;to exit, else run this rouine.
  400. L8267:  LDA FrameCount          ;
  401. L8269:  AND #$07            ;Perform next step of fade every 8th frame.
  402. L826B:  BNE ++              ;
  403. L826D:  LDA FadeDataIndex       ;
  404. L826F:  CMP #$05            ;Has end of fade out palette data been reached?-->
  405. L8271:  BNE +               ;If not, branch.
  406. L8273:  LDA #$06            ;
  407. L8275:  STA FadeDataIndex       ;Set index to start of fade in data.
  408. L8277:  LDA #$00            ;
  409. L8279:  STA SpareMemCB          ;Not accessed by game.
  410. L827B:  INC TitleRoutine        ;Next routine is DelayIntroReplay.
  411. L827D:  BNE ++              ;Branch always.
  412. L827F:* JSR DoFadeOut           ;($8B5F)Fade message off of screen.
  413. L8282:* RTS             ;
  414.  
  415. DelayIntroReplay:
  416. L8283:  INC TitleRoutine        ;Increment to next routine.
  417. L8285:  LDA #$10            ;
  418. L8287:  STA Timer3          ;Set Timer3 for a delay of 160 frames(2.6 seconds).
  419. L8289:  RTS             ;
  420.  
  421. UnusedIntroRoutine3:
  422. L828A:  LDA Timer3          ;
  423. L828C:  BNE +               ;
  424. L828E:  LDA SpareMemB7          ;
  425. L8290:  BNE +               ;
  426. L8292:  LDA SpareMemB8          ;
  427. L8294:  AND #$0F            ;Unused intro routine.
  428. L8296:  BNE +               ;
  429. L8298:  LDA #$01            ;
  430. L829A:  STA SpareMemD2          ;
  431. L829C:  LDA #$10            ;
  432. L829E:  STA Timer3          ;
  433. L82A0:  INC TitleRoutine        ;
  434. L82A2:* RTS             ;
  435.  
  436. PrepIntroRestart:
  437. L82A3:  LDA Timer3          ;Check if delay timer has expired.  If not, branch-->
  438. L82A5:  BNE ++              ;to exit, else run this rouine.
  439. L82A7:  STA SpareMemD2          ;Not accessed by game.
  440. L82A9:  STA SpareMemBB          ;Not accessed by game.
  441. L82AB:  STA IsSamus         ;Clear IsSamus memory address.
  442. L82AD:  LDY #$1F            ;
  443. L82AF:* STA ObjAction,Y         ;
  444. L82B2:  DEY             ;Clear RAM $0300 thru $031F.
  445. L82B3:  BPL -               ;
  446. L82B5:  LDA PPUCNT0ZP           ;Change to name table 0.
  447. L82B7:  AND #$FC            ;
  448. L82B9:  STA PPUCNT0ZP           ;
  449. L82BB:  INY             ;Y=0.
  450. L82BC:  STY SpareMemB7          ;Accessed by unused routine.
  451. L82BE:  STY SpareMemB8          ;Accessed by unused routine.
  452. L82C0:  STY PalDataIndex        ;
  453. L82C2:  STY ScreenFlashPalIndex     ;Clear all index values from these addresses.
  454. L82C4:  STY IntroStarOffset     ;
  455. L82C6:  STY FadeDataIndex       ;
  456. L82C8:  STY SpareMemCD          ;Not accessed by game.
  457. L82CA:  STY Joy1Change          ;
  458. L82CC:  STY Joy1Status          ;Clear addresses that were going to be written to by an-->
  459. L82CE:  STY Joy1Retrig          ;unused intro routine.
  460. L82D0:  STY SpareMemD7          ;Not accessed by game.
  461. L82D2:  INY             ;Y=1.
  462. L82D3:  STY SpareMemCE          ;Not accessed by game.
  463. L82D5:  INY             ;Y=2.
  464. L82D6:  STY SpareMemCC          ;Not accessed by game.
  465. L82D8:  STY SpareMemCF          ;Not accessed by game.
  466. L82DA:  STY TitleRoutine        ;Next routine sets up METROID fade in delay.
  467. L82DC:  LDA IntroMusicRestart       ;Check to see if intro music needs to be restarted.-->
  468. L82DE:  BNE ++              ;Branch if not.
  469. L82E0:  LDA #$10            ;
  470. L82E2:  STA MultiSFXFlag        ;Restart intro music.
  471. L82E5:  LDA #$02            ;Set restart of intro music after another two cycles-->
  472. L82E7:  STA IntroMusicRestart       ;of the title routines.
  473. L82E9:* RTS             ;
  474.  
  475. L82EA:* DEC IntroMusicRestart       ;One title routine cycle complete. Decrement intro-->
  476. L82EC:  RTS             ;music restart counter.
  477.  
  478. TitleScreenOff:
  479. L82ED:  JSR ScreenOff           ;($C439)Turn screen off.
  480. L82F0:  INC TitleRoutine        ;Next routine is TitleRoutineReturn.
  481. L82F2:  RTS             ;This routine should not be reached.
  482.  
  483. TitleRoutineReturn:
  484. L82F3:  RTS             ;Last title routine function. Should not be reached.
  485.  
  486. ;The following data fills name table 0 with the intro screen background graphics.
  487.  
  488. ;Information to be stored in attribute table 0.
  489. L82F4:  .byte $23           ;PPU address high byte.
  490. L82F5:  .byte $C0           ;PPU address low byte.
  491. L82F6:  .byte $20           ;PPU string length.
  492. L82F7:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  493. L8307:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  494.  
  495. L8317:  .byte $23           ;PPU address high byte.
  496. L8318:  .byte $E0           ;PPU address low byte.
  497. L8319:  .byte $20           ;PPU string length.
  498. L831A:  .byte $FF, $FF, $BF, $AF, $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00, $00, $00, $00
  499. L832A:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  500.  
  501. ;Writes row $22E0 (24th row from top).
  502. L833A:  .byte $22           ;PPU address high byte.
  503. L833B:  .byte $E0           ;PPU address low byte.
  504. L833C:  .byte $20           ;PPU string length.
  505. L833D:  .byte $FF, $FF, $FF, $FF, $FF, $8C, $FF, $FF, $FF, $FF, $FF, $8D, $FF, $FF, $8E, $FF
  506. L834D:  .byte $FF, $FF, $FF, $FF, $FF, $8C, $FF, $FF, $FF, $FF, $FF, $8D, $FF, $FF, $8E, $FF
  507.  
  508. ;Writes row $2300 (25th row from top).
  509. L835D:  .byte $23           ;PPU address high byte.
  510. L835E:  .byte $00           ;PPU address low byte.
  511. L835F:  .byte $20           ;PPU string length.
  512. L8360:  .byte $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81
  513. L8370:  .byte $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81
  514.  
  515. ;Writes row $2320 (26th row from top).
  516. L8380:  .byte $23           ;PPU address high byte.
  517. L8381:  .byte $20           ;PPU address low byte.
  518. L8382:  .byte $20           ;PPU string length.
  519. L8383:  .byte $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83
  520. L8393:  .byte $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83
  521.  
  522. ;Writes row $2340 (27th row from top).
  523. L83A3:  .byte $23           ;PPU address high byte.
  524. L83A4:  .byte $40           ;PPU address low byte.
  525. L83A5:  .byte $20           ;PPU string length.
  526. L83A6:  .byte $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85
  527. L83B6:  .byte $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85
  528.  
  529. ;Writes row $2360 (28th row from top).
  530. L83C6:  .byte $23           ;PPU address high byte.
  531. L83C7:  .byte $60           ;PPU address low byte.
  532. L83C8:  .byte $20           ;PPU string length.
  533. L83C9:  .byte $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87
  534. L83D9:  .byte $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87
  535.  
  536. ;Writes row $2380 (29th row from top).
  537. L83E9:  .byte $23           ;PPU address high byte.
  538. L83EA:  .byte $80           ;PPU address low byte.
  539. L83EB:  .byte $20           ;PPU string length.
  540. L83EC:  .byte $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89
  541. L83FC:  .byte $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89
  542.  
  543. ;Writes row $23A0 (Bottom row).
  544. L840C:  .byte $23           ;PPU address high byte.
  545. L840D:  .byte $A0           ;PPU address low byte.
  546. L840E:  .byte $20           ;PPU string length.
  547. L840F:  .byte $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B
  548. L841F:  .byte $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B
  549.  
  550. ;Writes some blank spaces in row $20A0 (6th row from top).
  551. L842F:  .byte $20           ;PPU address high byte.
  552. L8430:  .byte $A8           ;PPU address low byte.
  553. L8431:  .byte $4F           ;PPU string length.
  554. L8432:  .byte $FF           ;Since RLE bit set, repeat 16 blanks starting at $20A8.
  555.  
  556. ;Writes METROID graphics in row $2100 (9th row from top).
  557. L8433:  .byte $21           ;PPU address high byte.
  558. L8434:  .byte $03           ;PPU address low byte.
  559. L8435:  .byte $1C           ;PPU string length.
  560. L8436:  .byte $40, $5D, $56, $5D, $43, $40, $5D, $43, $40, $5D, $5D, $43, $40, $5D, $5D, $63
  561. L8446:  .byte $62, $5D, $5D, $63, $40, $43, $40, $5D, $5D, $63, $1D, $16
  562.  
  563. ;Writes METROID graphics in row $2120 (10th row from top).
  564. L8452:  .byte $21           ;PPU address high byte.
  565. L8453:  .byte $23           ;PPU address low byte.
  566. L8454:  .byte $1A           ;PPU string length.
  567. L8455:  .byte $44, $50, $50, $50, $47, $44, $57, $58, $74, $75, $76, $77, $44, $57, $69, $47
  568. L8465:  .byte $44, $57, $69, $47, $44, $47, $44, $68, $69, $47
  569.  
  570. ;Writes METROID graphics in row $2140 (11th row from top).
  571. L846F:  .byte $21           ;PPU address high byte.
  572. L8470:  .byte $43           ;PPU address low byte.
  573. L8471:  .byte $1A           ;PPU string length.
  574. L8472:  .byte $44, $41, $7E, $49, $47, $44, $59, $5A, $78, $79, $7A, $7B, $44, $59, $6D, $70
  575. L8482:  .byte $44, $73, $72, $47, $44, $47, $44, $73, $72, $47
  576.  
  577. ;Writes METROID graphics in row $2160 (12th row from top).
  578. L848C:  .byte $21           ;PPU address high byte.
  579. L848D:  .byte $63           ;PPU address low byte.
  580. L848E:  .byte $1A           ;PPU string length.
  581. L848F:  .byte $44, $42, $7F, $4A, $47, $44, $5B, $5C, $FF, $44, $47, $FF, $44, $5B, $6F, $71
  582. L849F:  .byte $44, $45, $46, $47, $44, $47, $44, $45, $46, $47
  583.  
  584. ;Writes METROID graphics in row $2180 (13th row from top).
  585. L84A9:  .byte $21           ;PPU address high byte.
  586. L84AA:  .byte $83           ;PPU address low byte.
  587. L84AB:  .byte $1A           ;PPU string length.
  588. L84AC:  .byte $44, $47, $FF, $44, $47, $44, $5F, $60, $FF, $44, $47, $FF, $44, $7D, $7C, $47
  589. L84BC:  .byte $44, $6A, $6B, $47, $44, $47, $44, $6A, $6B, $47
  590.  
  591. ;Writes METROID graphics in row $21A0 (14th row from top).
  592. L84C6:  .byte $21           ;PPU address high byte.
  593. L84C7:  .byte $A3           ;PPU address low byte.
  594. L84C8:  .byte $1A           ;PPU string length.
  595. L84C9:  .byte $4C, $4F, $FF, $4C, $4F, $4C, $5E, $4F, $FF, $4C, $4F, $FF, $4C, $4D, $4E, $4F
  596. L84D9:  .byte $66, $5E, $5E, $64, $4C, $4F, $4C, $5E, $5E, $64
  597.  
  598. ;Writes METROID graphics in row $21C0 (15th row from top).
  599. L84E3:  .byte $21           ;PPU address high byte.
  600. L84E4:  .byte $C3           ;PPU address low byte.
  601. L84E5:  .byte $1A           ;PPU string length.
  602. L84E6:  .byte $51, $52, $FF, $51, $52, $51, $61, $52, $FF, $51, $52, $FF, $51, $53, $54, $52
  603. L84F6:  .byte $67, $61, $61, $65, $51, $52, $51, $61, $61, $65
  604.  
  605. ;Writes PUSH START BUTTON in row $2220 (18th row from top).
  606. L8500:  .byte $22           ;PPU address high byte.
  607. L8501:  .byte $27           ;PPU address low byte.
  608. L8502:  .byte $15           ;PPU string length.
  609. ;             '_    P    U    S    H    _    S    T    A    R    T    _    B    U    T    T
  610. L8503:  .byte $FF, $19, $1E, $1C, $11, $FF, $1C, $1D, $0A, $1B, $1D, $FF, $0B, $1E, $1D, $1D
  611. ;          O    N    _    _    _'
  612. L8513:  .byte $18, $17, $FF, $FF, $FF
  613.  
  614. ;Writes C 1986 NINTENDO in row $2260 (20th row from top).
  615. L8518:  .byte $22           ;PPU memory high byte.
  616. L8519:  .byte $69           ;PPU memory low byte.
  617. L851A:  .byte $12           ;PPU string length.
  618. ;             'C    _    1    9    8    6    _    N    I    N    T    E    N    D    O    _
  619. L851B:  .byte $8F, $FF, $01, $09, $08, $06, $FF, $17, $12, $17, $1D, $0E, $17, $0D, $18, $FF
  620. ;          _    _'
  621. L852B:  .byte $FF, $FF
  622.  
  623. ;The following data fills name table 1 with the intro screen background graphics.
  624.  
  625. ;Information to be stored in attribute table 1.
  626. L852D:  .byte $27           ;PPU memory high byte.
  627. L852E:  .byte $C0           ;PPU memory low byte.
  628. L852F:  .byte $20           ;PPU string length.
  629. L8530:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  630. L8540:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  631.  
  632. ;Writes row $27E0 (24th row from top).
  633. L8550:  .byte $27           ;PPU memory high byte.
  634. L8551:  .byte $E0           ;PPU memory low byte.
  635. L8552:  .byte $20           ;PPU string length.
  636. L8553:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00, $00, $00, $00
  637. L8563:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  638.  
  639. ;Writes row $26E0 (24th row from top).
  640. L8573:  .byte $26           ;PPU memory high byte.
  641. L8574:  .byte $E0           ;PPU memory low byte.
  642. L8575:  .byte $20           ;PPU string length.
  643. L8576:  .byte $FF, $FF, $FF, $FF, $FF, $8C, $FF, $FF, $FF, $FF, $FF, $8D, $FF, $FF, $8E, $FF
  644. L8586:  .byte $FF, $FF, $FF, $FF, $FF, $8C, $FF, $FF, $FF, $FF, $FF, $8D, $FF, $FF, $8E, $FF
  645.  
  646. ;Writes row $2700 (25th row from top).
  647. L8595:  .byte $27           ;PPU memory high byte.
  648. L8597:  .byte $00           ;PPU memory low byte.
  649. L8598:  .byte $20           ;PPU string length.
  650. L8599:  .byte $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81
  651. L85A9:  .byte $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81, $80, $81
  652.  
  653. ;Writes row $2720 (26th row from top).
  654. L85B9:  .byte $27           ;PPU memory high byte.
  655. L85BA:  .byte $20           ;PPU memory low byte.
  656. L85BB:  .byte $20           ;PPU string length.
  657. L85BC:  .byte $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83
  658. L85CC:  .byte $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83, $82, $83
  659.  
  660. ;Writes row $2740 (27th row from top).
  661. L85DC:  .byte $27           ;PPU memory high byte.
  662. L85DD:  .byte $40           ;PPU memory low byte.
  663. L85DE:  .byte $20           ;PPU string length.
  664. L85DF:  .byte $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85
  665. L85EF:  .byte $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85, $84, $85
  666.  
  667. ;Writes row $2760 (28th row from top).
  668. L85FF:  .byte $27           ;PPU memory high byte.
  669. L8600:  .byte $60           ;PPU memory low byte.
  670. L8601:  .byte $20           ;PPU string length.
  671. L8602:  .byte $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87
  672. L8612:  .byte $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87, $86, $87
  673.  
  674. ;Writes row $2780 (29th row from top).
  675. L8622:  .byte $27           ;PPU memory high byte.
  676. L8623:  .byte $80           ;PPU memory low byte.
  677. L8624:  .byte $20           ;PPU string length.
  678. L8625:  .byte $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89
  679. L8635:  .byte $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89, $88, $89
  680.  
  681. ;Writes row $27A0 (bottom row).
  682. L8645:  .byte $27           ;PPU memory high byte.
  683. L8646:  .byte $A0           ;PPU memory low byte.
  684. L8647:  .byte $20           ;PPU string length.
  685. L8648:  .byte $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B
  686. L8658:  .byte $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B, $8A, $8B
  687.  
  688. ;Writes row $2480 (5th row from top).
  689. L8668:  .byte $24           ;PPU memory high byte.
  690. L8669:  .byte $88           ;PPU memory low byte.
  691. L866A:  .byte $0F           ;PPU string length.
  692. ;             'E    M    E    R    G    E    N    C    Y    _    O    R    D    E    R'
  693. L866B:  .byte $0E, $16, $0E, $1B, $10, $0E, $17, $0C, $22, $FF, $18, $1B, $0D, $0E, $1B
  694.  
  695. ;Writes row $2500 (9th row from top).
  696. L867A:  .byte $25           ;PPU memory high byte.
  697. L867B:  .byte $04           ;PPU memory low byte.
  698. L867C:  .byte $1C           ;PPU string length.
  699. ;             'D    E    F    E    A    T    _    T    H    E    _    M    E    T    R    0
  700. L867D:  .byte $0D, $0E, $0F, $0E, $0A, $1D, $FF, $1D, $11, $0E, $FF, $16, $0E, $1D, $1B, $18
  701. ;          I    D    _    O    F    _    _    _    _    _    _    _'
  702. L868D:  .byte $12, $0D, $FF, $18, $0F, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  703.  
  704. ;Writes row $2540 (11th row from top).
  705. L8699:  .byte $25           ;PPU memory high byte.
  706. L869A:  .byte $44           ;PPU memory low byte.
  707. L869B:  .byte $1A           ;PPU string length.
  708. ;             'T    H    E    _    P    L    A    N    E    T    _    Z    E    B    E    T
  709. L869C:  .byte $1D, $11, $0E, $FF, $19, $15, $0A, $17, $0E, $1D, $FF, $23, $0E, $0B, $0E, $1D
  710. ;          H    _    A    N    D    _    _    _    _    _'
  711. L86AC:  .byte $11, $FF, $0A, $17, $0D, $FF, $FF, $FF, $FF, $FF
  712.  
  713. ;Writes row $2580 (13th row from top).
  714. L86B6:  .byte $25           ;PPU memory high byte.
  715. L86B7:  .byte $84           ;PPU memory low byte.
  716. L86B8:  .byte $1A           ;PPU string length.
  717. ;             'D    E    S    T    R    O    Y    _    T    H    E    _    M    O    T    H
  718. L86B9:  .byte $0D, $0E, $1C, $1D, $1B, $18, $22, $FF, $1D, $11, $0E, $FF, $16, $18, $1D, $11
  719. ;          E    R    _    B    R    A    I    N    _    _'
  720. L86C9:  .byte $0E, $1B, $FF, $0B, $1B, $0A, $12, $17, $FF, $FF
  721.  
  722. ;Writes row $25C0 (15th row from top).
  723. L86D3:  .byte $25           ;PPU memory high byte.
  724. L86D4:  .byte $C4           ;PPU memory low byte.
  725. L86D5:  .byte $1A           ;PPU string length.
  726. ;             'T    H    E    _    M    E    C    H    A    N    I    C    A    L    _    L
  727. L86D6:  .byte $1D, $11, $0E, $FF, $16, $0E, $0C, $11, $0A, $17, $12, $0C, $0A, $15, $FF, $15
  728. ;          I    F    E    _    V    E    I    N    _    _'
  729. L86E9:  .byte $12, $0F, $0E, $FF, $1F, $0E, $12, $17, $FF, $FF
  730.  
  731. ;Writes row $2620 (18th row from top).
  732. L86F0:  .byte $26           ;PPU memory high byte.
  733. L86F1:  .byte $27           ;PPU memory low byte.
  734. L86F2:  .byte $15           ;PPU string length.
  735. ;             'G    A    L    A    X    Y    _    F    E    D    E    R    A    L    _    P
  736. L86F3:  .byte $10, $0A, $15, $0A, $21, $22, $FF, $0F, $0E, $0D, $0E, $1B, $0A, $15, $FF, $19
  737. ;          O    L    I    C    E'
  738. L8703:  .byte $18, $15, $12, $0C, $0E
  739.  
  740. ;Writes row $2660 (20th row from top).
  741. L8708:  .byte $26           ;PPU memory high byte.
  742. L8709:  .byte $69           ;PPU memory low byte.
  743. L870A:  .byte $12           ;PPU string length.
  744. ;             '_    _    _    _    _    _    _    _    _    _    _    _    _    _    M    5
  745. L870B:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $16, $05
  746. ;          1    0'
  747. L871B:  .byte $01, $00
  748.  
  749. L871D:  .byte $00           ;End PPU string write.
  750.  
  751. ;The following data does not appear to be used.
  752. L871E:  .byte $46, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  753. L872E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $20, $00, $00, $00, $00, $00, $00
  754. L873E:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  755. L874E:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  756.  
  757. ;The following error message is diplayed if the player enters an incorrect password.
  758. ;             'E    R    R    O    R    _    T    R    Y    _    A    G    A    I    N'
  759. L8759:  .byte $0E, $1B, $1B, $18, $1B, $FF, $1D, $1B, $22, $FF, $0A, $10, $0A, $12, $17
  760.  
  761. ;If the error message above is not being displayed on the password
  762. ;screen, the following fifteen blanks spaces are used to cover it up.
  763. ;             '_    _    _    _    _    _    _    _    _    _    _    _    _    _    _'
  764. L8768:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  765.  
  766. ;Not used.
  767. L8777:  .byte $79, $87, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $00, $00, $02, $00
  768. L8787:  .byte $00, $03, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $00, $00, $02, $00
  769. L8797:  .byte $00, $03, $A1, $87, $A2, $87, $A5, $87, $A8, $87, $00, $18, $CC, $00, $18, $CD
  770. L87A7:  .byte $00, $18, $CE, $00
  771.  
  772. LoadSparkleData:
  773. L87AB:  LDX #$0A            ;
  774. L87AD:* LDA InitSparkleDataTbl,X    ;
  775. L87B0:  STA IntroSpr0YCoord,X       ;Loads $6EA0 thru $6EAA with the table below.
  776. L87B3:  STA IntroSpr1YCoord,X       ;Loads $6EB0 thru $6EBA with the table below.
  777. L87B6:  DEX             ;
  778. L87B7:  BPL -               ;Loop until all values from table below are loaded.
  779. L87B9:  LDA #$6B            ;
  780. L87BB:  STA IntroSpr1YCoord     ;$6EA0 thru $6EAA = #$3C, #$C6, #$01, #$18, #$00,-->
  781. L87BE:  LDA #$DC            ;#$00, #$00, #$00, #$20, #$00, #$00, initial.
  782. L87C0:  STA IntroSpr1XCoord     ;$6EB0 thru $6EBA = #$6B, #$C6, #$01, #$DC, #$00,-->
  783. L87C3:  RTS             ;#$00, #$00, #$00, #$20, #$00, #$00, initial.
  784.  
  785. ;Used by above routine to load Metroid initial sparkle data into $6EA0
  786. ;thru $6EAA and $6EB0 thru $6EBA.
  787.  
  788. InitSparkleDataTbl:
  789. L87C4:  .byte $3C, $C6, $01, $18, $00, $00, $00, $00, $20, $00, $00
  790.  
  791. UpdateSparkleSprites:
  792. L87CF:  LDX #$00            ;
  793. L87D1:  JSR DoOneSparkleUpdate      ;($87D6)Performs calculations on top sparkle sprite.
  794. L87D4:  LDX #$10            ;Performs calculations on bottom sparkle sprite.
  795.  
  796. DoOneSparkleUpdate:
  797. L87D6:  JSR SparkleUpdate       ;($87D9)Update sparkle sprite data.
  798.  
  799. SparkleUpdate:
  800. L87D9:  LDA IntroSpr0NextCntr,X     ;If $6EA5 has not reached #$00, skip next routine.
  801. L87DC:  BNE +               ;
  802. L87DE:  JSR DoSparkleSpriteCoord    ;($881A)Update sparkle sprite screen position.
  803. L87E1:* LDA IntroSpr0Complete,X     ;
  804. L87E4:  BNE ++              ;If sprite is already done, skip routine.
  805. L87E6:  DEC IntroSpr0NextCntr,X     ;
  806.  
  807. L87E9:  LDA SparkleSpr0YChange,X    ;
  808. L87EC:  CLC                 ;
  809. L87ED:  ADC IntroSpr0YCoord,X       ;Updates sparkle sprite Y coord.
  810. L87F0:  STA IntroSpr0YCoord,X       ;
  811.  
  812. L87F3:  LDA SparkleSpr0XChange,X    ;          
  813. L87F6:  CLC                 ;
  814. L87F7:  ADC IntroSpr0XCoord,X       ;Updates sparkle sprite X coord.
  815. L87FA:  STA IntroSpr0XCoord,X       ;
  816.  
  817. L87FD:  DEC IntroSpr0ChngCntr,X     ;Decrement IntroSpr0ChngCntr. If 0, time to change-->
  818. L8800:  BNE +               ;sprite graphic.
  819. L8802:  LDA IntroSpr0PattTbl,X      ;
  820. L8805:  EOR #$03            ;If IntroSpr0ChngCntr=$00, the sparkle sprite graphic is-->
  821. L8807:  STA IntroSpr0PattTbl,X      ;changed back and forth between pattern table-->
  822. L880A:  LDA #$20            ;graphic $C6 and $C7.  IntroSpr0ChngCntr is reset to #$20.
  823. L880C:  STA IntroSpr0ChngCntr,X     ;
  824. L880F:  ASL             ;
  825. L8810:  EOR IntroSpr0Cntrl,X        ;Flips pattern at $C5 in pattern table-->
  826. L8813:  STA IntroSpr0Cntrl,X        ;horizontally when displayed.
  827. L8816:* JMP WriteIntroSprite        ;($887B)Transfer sprite info into sprite RAM.
  828. L8819:* RTS             ;
  829.  
  830. DoSparkleSpriteCoord:
  831. L881A:  TXA             ;
  832. L881B:  JSR Adiv8           ;($C2C0)Y=0 when working with top sparkle sprite-->
  833. L881E:  TAY                 ;and y=2 when working with bottom sparkle sprite.
  834. L881F:  LDA SparkleAddressTbl,Y     ;Base is $89AF.
  835. L8822:  STA $00             ;When working with top sparkle sprite, E1,E0=$89B3-->
  836. L8824:  LDA SparkleAddressTbl+1,Y   ;and when botton sparkle sprite, E1,E0=$89E9.
  837. L8827:  STA $01             ;
  838. L8829:  LDY IntroSpr0Index,X        ;Loads index for finding sparkle data (x=$00 or $10).
  839. L882C:  LDA ($00),Y         ;
  840. L882E:  BPL +               ;If data byte MSB is set, set $6EA9 to #$01 and move to-->
  841. L8830:  LDA #$01            ;next index for sparkle sprite data.
  842. L8832:  STA IntroSpr0ByteType,X     ;
  843. L8835:* BNE +               ;
  844. L8837:  LDA #$01            ;If value is equal to zero, sparkle sprite-->
  845. L8839:  STA IntroSpr0Complete,X     ;processing is complete.
  846. L883C:* STA IntroSpr0NextCntr,X     ;
  847. L883F:  INY             ;
  848. L8840:  LDA ($00),y         ;Get x/y position byte.
  849. L8842:  DEC IntroSpr0ByteType,X     ;If MSB of second byte is set, branch.
  850. L8845:  BMI +               ;
  851. L8847:  LDA #$00            ;This code is run when the MSB of the first byte-->
  852. L8849:  STA SparkleSpr0YChange,X    ;is set.  This allows the sprite to change X coord-->
  853. L884C:  LDA ($00),Y         ;by more than 7.  Ensures Y coord does not change.
  854. L884E:  BMI ++              ;
  855. L8850:* PHA             ;Store value twice so X and Y-->
  856. L8851:  PHA             ;coordinates can be extracted.
  857. L8852:  LDA #$00            ;
  858. L8854:  STA IntroSpr0ByteType,X     ;Set IntroSpr0ByteType to #$00 after processing.
  859. L8857:  PLA             ;
  860. L8858:  JSR Adiv16          ;($C2BF)Move upper 4 bits to lower 4 bits.
  861. L885B:  JSR NibbleSubtract      ;($8871)Check if nibble to be converted to twos compliment.
  862. L885E:  STA SparkleSpr0YChange,X    ;Twos compliment stored if Y coord decreasing.
  863. L8861:  PLA             ;
  864. L8862:  AND #$0F            ;Discard upper 4 bits.
  865. L8864:  JSR NibbleSubtract      ;($8871)Check if nibble to be converted to twos compliment.
  866. L8867:* STA SparkleSpr0XChange,X    ;Store amount to move spite in x direction.
  867. L886A:  INC IntroSpr0Index,X        ;
  868. L886D:  INC IntroSpr0Index,X        ;Add two to find index for next data byte.
  869. L8870:  RTS             ;
  870.  
  871. NibbleSubtract:
  872. L8871:  CMP #$08            ;If bit 3 is set, nibble is a negative number-->
  873. L8873:  BCC +               ;and lower three bits are converted to twos-->
  874. L8875:  AND #$07            ;compliment for subtraction, else exit.
  875. L8877:  JSR TwosCompliment      ;($C3D4)Prepare for subtraction with twos compliment.
  876. L887A:* RTS             ;
  877.  
  878. WriteIntroSprite:
  879. L887B:  LDA IntroSpr0YCoord,X       ;
  880. L887E:  SEC             ;Subtract #$01 from first byte to get proper y coordinate.
  881. L887F:  SBC #$01            ;
  882. L8881:  STA Sprite04RAM,X       ;
  883. L8884:  LDA IntroSpr0PattTbl,X      ;
  884. L8887:  STA Sprite04RAM+1,X     ;Load the four bytes for the-->
  885. L888A:  LDA IntroSpr0Cntrl,X        ;intro sprites into sprite RAM.
  886. L888D:  STA Sprite04RAM+2,X     ;
  887. L8890:  LDA IntroSpr0XCoord,X       ;
  888. L8893:  STA Sprite04RAM+3,X     ;
  889. L8896:  RTS             ;
  890.  
  891. LoadInitialSpriteData:
  892. L8897:  LDA #$20            ;
  893. L8899:  STA Second4Delay        ;Set delay for second 4 sprites to 32 frames.
  894. L889B:  LDX #$3F            ;Prepare to loop 64 times.
  895.  
  896. L889D:* LDA Sprite0and4InitTbl,X    ;Load data from tables below.
  897. L88A0:  CMP $FF             ;If #$FF, skip loading that byte and move to next item.
  898. L88A2:  BEQ +               ;
  899. L88A4:  STA IntroSpr0YCoord,X       ;Store initial values for sprites 0 thru 3.
  900. L88A7:  STA IntroSpr4YCoord,X       ;Store initial values for sprites 4 thru 7.
  901. L88AA:* DEX             ;
  902. L88AB:  BPL --              ;Loop until all data is loaded.
  903.  
  904. L88AD:  LDA #$B8            ;Special case for sprite 6 and 7.
  905. L88AF:  STA IntroSpr6YCoord     ;
  906. L88B2:  STA IntroSpr7YCoord     ;Change sprite 6 and 7 initial y position.
  907. L88B5:  LDA #$16            ;
  908. L88B7:  STA IntroSpr6YRise      ;Change sprite 6 and 7 y displacement. The combination-->
  909. L88BA:  STA IntroSpr7YRise      ;of these two changes the slope of the sprite movement.
  910. L88BD:  RTS             ;
  911.  
  912. ;The following tables are loaded into RAM as initial sprite control values for the crosshair sprites.
  913.  
  914. Sprite0and4InitTbl:
  915. L88BE:  .byte $20           ;Initial starting y screen position.
  916. L88BF:  .byte $C5           ;Sprite pattern table index.
  917. L88C0:  .byte $80           ;Sprite control byte.
  918. L88C1:  .byte $00           ;Initial starting x screen position.
  919. L88C2:  .byte $FF           ;Not used.
  920. L88C3:  .byte $FF           ;Not used.
  921. L88C4:  .byte $74           ;Intro sprite x total movement distance.
  922. L88C5:  .byte $58           ;Intro sprite y total movement distance.
  923. L88C6:  .byte $FF           ;Not used.
  924. L88C7:  .byte $FF           ;Not used.
  925. L88C8:  .byte $00           ;Sprite task complete idicator.
  926. L88C9:  .byte $FF           ;Not used.
  927. L88CA:  .byte $1D           ;x displacement of sprite movement(run).
  928. L88CB:  .byte $0E           ;y displacement of sprite movement(rise).
  929. L88CC:  .byte $01           ;Change sprite x coord in positive direction.
  930. L88CD:  .byte $01           ;Change sprite y coord in positive direction.
  931.  
  932. Sprite1and5InitTbl:
  933. L88CE:  .byte $20           ;Initial starting y screen position.
  934. L88CF:  .byte $C5           ;Sprite pattern table index.
  935. L88D0:  .byte $C0           ;Sprite control byte.
  936. L88D1:  .byte $F8           ;Initial starting x screen position.
  937. L88D2:  .byte $FF           ;Not used.
  938. L88D3:  .byte $FF           ;Not used.
  939. L88D4:  .byte $7C           ;Intro sprite x total movement distance.
  940. L88D5:  .byte $58           ;Intro sprite y total movement distance.
  941. L88D6:  .byte $FF           ;Not used.
  942. L88D7:  .byte $FF           ;Not used.
  943. L88D8:  .byte $00           ;Sprite task complete idicator.
  944. L88D9:  .byte $FF           ;Not used.
  945. L88DA:  .byte $1F           ;x displacement of sprite movement(run).
  946. L88DB:  .byte $0E           ;y displacement of sprite movement(rise).
  947. L88DC:  .byte $80           ;Change sprite x coord in negative direction.
  948. L88DD:  .byte $01           ;Change sprite y coord in positive direction.
  949.  
  950. Sprite2and6InitTbl:
  951. L88DE:  .byte $C8           ;Initial starting y screen position.
  952. L88DF:  .byte $C5           ;Sprite pattern table index.
  953. L88E0:  .byte $00           ;Sprite control byte.
  954. L88E1:  .byte $00           ;Initial starting x screen position.
  955. L88E2:  .byte $FF           ;Not used.
  956. L88E3:  .byte $FF           ;Not used.
  957. L88E4:  .byte $74           ;Intro sprite x total movement distance.
  958. L88E5:  .byte $60           ;Intro sprite y total movement distance.
  959. L88E6:  .byte $FF           ;Not used.
  960. L88E7:  .byte $FF           ;Not used.
  961. L88E8:  .byte $00           ;Sprite task complete idicator.
  962. L88E9:  .byte $FF           ;Not used.
  963. L88EA:  .byte $1D           ;x displacement of sprite movement(run).
  964. L88EB:  .byte $1A           ;y displacement of sprite movement(rise).
  965. L88EC:  .byte $01           ;Change sprite x coord in positive direction.
  966. L88ED:  .byte $80           ;Change sprite y coord in negative direction.
  967.  
  968. Sprite3and7InitTbl:
  969. L88EE:  .byte $C8           ;Initial starting y screen position.
  970. L88EF:  .byte $C5           ;Sprite pattern table index.
  971. L88F0:  .byte $40           ;Sprite control byte.
  972. L88F1:  .byte $F8           ;Initial starting x screen position.
  973. L88F2:  .byte $FF           ;Not used.
  974. L88F3:  .byte $FF           ;Not used.
  975. L88F4:  .byte $7C           ;Intro sprite x total movement distance.
  976. L88F5:  .byte $60           ;Intro sprite y total movement distance.
  977. L88F6:  .byte $FF           ;Not used.
  978. L88F7:  .byte $FF           ;Not used.
  979. L88F8:  .byte $00           ;Sprite task complete idicator.
  980. L88F9:  .byte $FF           ;Not used.
  981. L88FA:  .byte $1F           ;x displacement of sprite movement(run).
  982. L88FB:  .byte $1A           ;y displacement of sprite movement(rise).
  983. L88FC:  .byte $80           ;Change sprite x coord in negative direction.
  984. L88FD:  .byte $80           ;Change sprite y coord in negative direction.
  985.  
  986. DrawCrosshairsSprites:
  987. L88FE:  LDA First4SlowCntr      ;
  988. L8900:  BEQ +               ;Has First4SlowCntr already hit 0? If so, branch.
  989. L8902:  DEC First4SlowCntr      ;
  990. L8904:  BNE +               ;Is First4SlowCntr now equal to 0? if not, branch.
  991. L8906:  ASL IntroSpr0XRun       ;
  992. L8909:  ASL IntroSpr0YRise      ;
  993. L890C:  ASL IntroSpr1XRun       ;
  994. L890F:  ASL IntroSpr1YRise      ;
  995. L8912:  ASL IntroSpr2XRun       ;
  996. L8915:  ASL IntroSpr2YRise      ;
  997. L8918:  ASL IntroSpr3XRun       ;Multiply the rise and run of the 8 sprites by 2.-->
  998. L891B:  ASL IntroSpr3YRise      ;This doubles their speed.
  999. L891E:  ASL IntroSpr4XRun       ;
  1000. L8921:  ASL IntroSpr4YRise      ;
  1001. L8924:  ASL IntroSpr5XRun       ;
  1002. L8927:  ASL IntroSpr5YRise      ;
  1003. L892A:  ASL IntroSpr6XRun       ;
  1004. L892D:  ASL IntroSpr6YRise      ;
  1005. L8930:  ASL IntroSpr7XRun       ;
  1006. L8933:  ASL IntroSpr7YRise      ;
  1007. L8936:* LDX #$00            ;
  1008. L8938:  JSR DoSpriteMovement        ;($8963)Move sprite 0.
  1009. L893B:  LDX #$10            ;
  1010. L893D:  JSR DoSpriteMovement        ;($8963)Move sprite 1.
  1011. L8940:  LDX #$20            ;
  1012. L8942:  JSR DoSpriteMovement        ;($8963)Move sprite 2.
  1013. L8945:  LDX #$30            ;
  1014. L8947:  LDA Second4Delay        ;Check to see if the delay to start movement of the second-->
  1015. L8949:  BEQ +               ;4 sprites has ended.  If so, start drawing those sprites.
  1016. L894B:  DEC Second4Delay        ;
  1017. L894D:  BNE ++              ;
  1018. L894F:* JSR DoSpriteMovement        ;($8963)Move sprite 3.
  1019. L8952:  LDX #$40            ;
  1020. L8954:  JSR DoSpriteMovement        ;($8963)Move sprite 4.
  1021. L8957:  LDX #$50            ;
  1022. L8959:  JSR DoSpriteMovement        ;($8963)Move sprite 5.
  1023. L895C:  LDX #$60            ;
  1024. L895E:  JSR DoSpriteMovement        ;($8963)Move sprite 6.
  1025. L8961:  LDX #$70            ;($8963)Move sprite 7.
  1026.  
  1027. DoSpriteMovement:
  1028. L8963:* LDA IntroSpr0Complete,X     ;If the current sprite has finished-->
  1029. L8966:  BNE ++              ;its movements, exit this routine.
  1030. L8968:  JSR UpdateSpriteCoords      ;($981E)Calculate new sprite position.
  1031. L896B:  BCS +               ;If sprite not at final position, branch to move next frame.
  1032. L896D:  LDA #$01            ;Sprite movement complete.
  1033. L896F:  STA IntroSpr0Complete,X     ;
  1034. L8972:* JMP WriteIntroSprite        ;($887B)Write sprite data to sprite RAM.
  1035. L8975:* RTS             ;
  1036.  
  1037. DrawCrossSprites:
  1038. L8976:  LDA DrawCross           ;If not ready to draw crosshairs,-->
  1039. L8978:  BEQ ++++            ;branch to exit.
  1040. L897A:  LDY CrossDataIndex      ;
  1041. L897C:  CPY #$04            ;Check to see if at last index in table.  If so, branch-->
  1042. L897E:  BCC +               ;to draw cross sprites.
  1043. L8980:  BNE ++++            ;If beyond last index, branch to exit.
  1044. L8982:  LDA #$00            ;
  1045. L8984:  STA DrawCross           ;If at last index, clear indicaor to draw cross sprites.
  1046. L8986:* LDA CrossSpriteIndexTbl,Y   ;
  1047. L8989:  STA $00             ;
  1048. L898B:  LDY #$00            ;Reset index into CrossSpriteDataTbl
  1049.  
  1050. L898D:* LDX CrossSpriteDataTbl,Y    ;Get offet into sprite RAM to load sprite.
  1051. L8990:  INY             ;
  1052. L8991:* LDA CrossSpriteDataTbl,Y    ;Get sprite data byte.
  1053. L8994:  STA Sprite00RAM,X       ;Store byte in sprite RAM.
  1054. L8997:  INX             ;Move to next sprite RAM address.
  1055. L8998:  INY             ;Move to next data byte in table.
  1056. L8999:  TXA             ;
  1057. L899A:  AND #$03            ;Is new sprite position reached?-->
  1058. L899C:  BNE -               ;if not, branch to load next sprite data byte.
  1059. L899E:  CPY $00             ;Has all the sprites been loaded for cross graphic?-->
  1060. L89A0:  BNE --              ;If not, branch to load next set of sprite data.
  1061.  
  1062. L89A2:  LDA FrameCount          ;
  1063. L89A4:  LSR             ;Increment index into CrossSpriteIndexTbl every-->
  1064. L89A5:  BCC +               ;other frame.  This updates the cross sprites-->
  1065. L89A7:  INC CrossDataIndex      ;every two frames.
  1066. L89A9:* RTS             ;
  1067.  
  1068. ;The following table tells the routine above how many data bytes to load from CrossSpriteDataTbl.
  1069. ;The more data that is loaded, the bigger the cross that is drawn on the screen.  The table below
  1070. ;starts the cross out small, it then grows bigger and gets small again.
  1071.  
  1072. CrossSpriteIndexTbl:
  1073. L89AA: .byte $05, $19, $41, $19, $05
  1074.  
  1075. ;The following table is used to find the data for the sparkle routine in the table below:
  1076.  
  1077. SparkleAddressTbl:
  1078. L89AF:  .word TopSparkleDataTbl     ;($89B3)Table for top sparkle data.
  1079. L89B1:  .word BottomSparkleDataTbl  ;($89E9)Table for bottom sparkle data.
  1080.  
  1081. ;The following two tables are the data tables for controlling the movement of the sparkle sprites
  1082. ;in the title routine.  Here's how thw data in the tables work: The first byte is a counter byte.
  1083. ;It is loaded into a memory address and decremented every frame. Whilt that value is not 0, the
  1084. ;second byte is used to change the sprite's x and y coordinates in the screen.  The upper 4 bits
  1085. ;of the second byte are amount to change the y coordinates every frame.  If bit 7 is set, the
  1086. ;y coordinates of the sprite are reduced every frame by the amount stored in bits 4,5 and 6. The
  1087. ;lower 4 bits of the second byte are used to change the x coordinates of the sprite in the same
  1088. ;manner.  If bit 3 is set, the x coordinates of the sprite are reduced every frame by the amount
  1089. ;stored in bits 0, 1 and 2.
  1090. ;Special case: If MSB of the first byte is set(in the case of this data, the first byte is #$FF),
  1091. ;The counter byte is set to only 1 frame and the second byte contains only x coordinates to move
  1092. ;the sprite.  The y coordinates do not change.  This allows 8 bytes to move the x coordinate
  1093. ;instead of only 4.  This allows the sprite to "jump" across the edges of the letters. If the MSB
  1094. ;of the second byte is set, the x coordinate of the sprite is decreased by the amount stored in
  1095. ;the other seven bytes.
  1096.  
  1097. TopSparkleDataTbl:
  1098. L89B3:  .byte $01, $00
  1099. L89B5:  .byte $01, $00
  1100. L89B7:  .byte $01, $01
  1101. L89B9:  .byte $06, $00
  1102. L89BB:  .byte $07, $01
  1103. L89BD:  .byte $10, $01
  1104. L89BF:  .byte $03, $01
  1105. L89C1:  .byte $01, $00
  1106. L89C3:  .byte $01, $01
  1107. L89C5:  .byte $01, $00
  1108. L89C7:  .byte $01, $01
  1109. L89C9:  .byte $01, $00
  1110. L89CB:  .byte $09, $01
  1111. L89CD:  .byte $04, $00
  1112. L89CF:  .byte $27, $01
  1113. L89D1:  .byte $01, $00
  1114. L89D3:  .byte $01, $00
  1115. L89D5:  .byte $06, $01
  1116. L89D7:  .byte $01, $00
  1117. L89D9:  .byte $15, $01
  1118. L89DB:  .byte $06, $00
  1119. L89DD:  .byte $01, $01
  1120. L89DF:  .byte $08, $01
  1121. L89E1:  .byte $0E, $02
  1122. L89E3:  .byte $02, $03
  1123. L89E5:  .byte $06, $04
  1124. L89E7:  .byte $00, $00
  1125.  
  1126. BottomSparkleDataTbl:
  1127. L89E9:  .byte $01, $00
  1128. L89EB:  .byte $08, $09
  1129. L89ED:  .byte $01, $99
  1130. L89EF:  .byte $01, $09
  1131. L89F1:  .byte $01, $99
  1132. L89F3:  .byte $01, $09
  1133. L89F5:  .byte $01, $99
  1134. L89F7:  .byte $01, $09
  1135. L89F9:  .byte $01, $99
  1136. L89FB:  .byte $01, $09
  1137. L89FD:  .byte $01, $99
  1138. L89FF:  .byte $01, $09
  1139. L8A01:  .byte $01, $99
  1140. L8A03:  .byte $01, $09
  1141. L8A05:  .byte $01, $99
  1142. L8A07:  .byte $01, $09
  1143. L8A09:  .byte $01, $99
  1144. L8A0B:  .byte $01, $09
  1145. L8A0D:  .byte $01, $99
  1146. L8A0F:  .byte $01, $09
  1147. L8A11:  .byte $01, $99
  1148. L8A13:  .byte $01, $19
  1149. L8A15:  .byte $01, $11
  1150. L8A17:  .byte $01, $10
  1151. L8A19:  .byte $01, $11
  1152. L8A1B:  .byte $01, $10
  1153. L8A1D:  .byte $01, $11
  1154. L8A1F:  .byte $01, $10
  1155. L8A21:  .byte $01, $11
  1156. L8A23:  .byte $01, $10
  1157. L8A25:  .byte $01, $11
  1158. L8A27:  .byte $01, $10
  1159. L8A29:  .byte $01, $11
  1160. L8A2B:  .byte $01, $10
  1161. L8A2D:  .byte $01, $11
  1162. L8A2F:  .byte $01, $10
  1163. L8A31:  .byte $02, $11
  1164. L8A33:  .byte $01, $10
  1165. L8A35:  .byte $01, $11
  1166. L8A37:  .byte $10, $09
  1167. L8A39:  .byte $FF, $EF          ;MSB of first byte set. move sprite x pos -17 pixles.
  1168. L8A3B:  .byte $11, $09
  1169. L8A3D:  .byte $FF, $F3          ;MSB of first byte set. move sprite x pos -13 pixles.
  1170. L8A3F:  .byte $1F, $09
  1171. L8A41:  .byte $FF, $EC          ;MSB of first byte set. move sprite x pos -20 pixles.
  1172. L8A43:  .byte $0F, $09
  1173. L8A45:  .byte $FF, $ED          ;MSB of first byte set. move sprite x pos -19 pixles.
  1174. L8A47:  .byte $16, $09
  1175. L8A49:  .byte $00, $00
  1176.  
  1177. ;The following table is used by the DrawCrossSprites routine to draw the sprites on the screen that
  1178. ;make up the cross that appears during the Crosshairs routine.  The single byte is the index into
  1179. ;the sprite RAM where the sprite data is to be written.  The 4 bytes that follow it are the actual
  1180. ;sprite data bytes.
  1181.  
  1182. CrossSpriteDataTbl:
  1183. L8A4B:  .byte $10           ;Load following sprite data into Sprite04RAM.
  1184. L8A4C:  .byte $5A, $C0, $00, $79    ;Sprite data.
  1185. L8A50:  .byte $14           ;Load following sprite data into Sprite05RAM.
  1186. L8A51:  .byte $52, $C8, $00, $79    ;Sprite data.
  1187. L8A55:  .byte $18           ;Load following sprite data into Sprite06RAM.
  1188. L8A56:  .byte $5A, $C2, $40, $71    ;Sprite data.
  1189. L8A5A:  .byte $1C           ;Load following sprite data into Sprite07RAM.
  1190. L8A5B:  .byte $5A, $C2, $00, $81    ;Sprite data.
  1191. L8A5F:  .byte $20           ;Load following sprite data into Sprite08RAM.
  1192. L8A60:  .byte $62, $C8, $80, $79    ;Sprite data.
  1193. L8A64:  .byte $14           ;Load following sprite data into Sprite05RAM.
  1194. L8A65:  .byte $52, $C9, $00, $79    ;Sprite data.
  1195. L8A69:  .byte $18           ;Load following sprite data into Sprite06RAM.
  1196. L8A6A:  .byte $5A, $C1, $00, $71    ;Sprite data.
  1197. L8A6E:  .byte $1C           ;Load following sprite data into Sprite07RAM.
  1198. L8A6F:  .byte $5A, $C1, $00, $81    ;Sprite data.
  1199. L8A73:  .byte $20           ;Load following sprite data into Sprite08RAM.
  1200. L8A74:  .byte $62, $C9, $00, $79    ;Sprite data.
  1201. L8A78:  .byte $24           ;Load following sprite data into Sprite09RAM.
  1202. L8A79:  .byte $4A, $C8, $00, $79    ;Sprite data.
  1203. L8A7D:  .byte $28           ;Load following sprite data into Sprite0ARAM.
  1204. L8A7E:  .byte $5A, $C2, $40, $69    ;Sprite data.
  1205. L8A82:  .byte $2C           ;Load following sprite data into Sprite0BRAM.
  1206. L8A83:  .byte $5A, $C2, $00, $89    ;Sprite data.
  1207. L8A87:  .byte $30           ;Load following sprite data into Sprite0CRAM.
  1208. L8A88:  .byte $6A, $C8, $80, $79    ;Sprite data.
  1209.  
  1210. LoadPalData:
  1211. L8A8C:  lDY PalDataIndex        ;
  1212. L8A8E:  LDA PalSelectTbl,Y      ;Chooses which set of palette data-->
  1213. L8A91:  CMP #$FF            ;to load from the table below.
  1214. L8A93:  BEQ +               ;
  1215. L8A95:  STA PalDataPending      ;Prepare to write palette data.
  1216. L8A97:  INC PalDataIndex        ;
  1217. L8A99:* RTS                 ;
  1218.  
  1219. ;The table below is used by above routine to pick the proper palette.
  1220.  
  1221. PalSelectTbl:
  1222. L8A9A:  .byte $02, $03, $04, $05, $06, $07, $08, $09, $0A, $0B, $0C, $0C, $FF
  1223.  
  1224. FlashIntroScreen:
  1225. L8AA7:  LDY ScreenFlashPalIndex     ;Load index into table below.
  1226. L8AA9:  LDA ScreenFlashPalTbl,Y     ;Load palette data byte.
  1227. L8AAC:  CMP #$FF            ;Has the end of the table been reached?-->
  1228. L8AAE:  BNE +               ;If not, branch.
  1229. L8AB0:  LDA #$00            ;
  1230. L8AB2:  STA ScreenFlashPalIndex     ;Clear screen flash palette index and reset-->
  1231. L8AB4:  STA FlashScreen         ;screen flash control address.
  1232. L8AB6:  BEQ ++              ;Branch always.
  1233. L8AB8:* STA PalDataPending      ;Store palette change data.
  1234. L8ABA:  INC ScreenFlashPalIndex     ;Increment index into table below.
  1235. L8ABC:* RTS             ;
  1236.  
  1237. ScreenFlashPalTbl:
  1238. L8ABD:  .byte $11, $01, $11, $01, $11, $11, $01, $11, $01, $FF
  1239.  
  1240. ;----------------------------------[ Intro star palette routines ]-----------------------------------
  1241.  
  1242. StarPalSwitch:
  1243. L8AC7:  LDA FrameCount          ;
  1244. L8AC9:  AND #$0F            ;Change star palette every 16th frame.
  1245. L8ACB:  BNE +               ;
  1246. L8ACD:  LDA PPUStrIndex         ;
  1247. L8AD0:  BEQ ++              ;Is any other PPU data waiting? If so, exit.
  1248. L8AD2:* RTS             ;
  1249.  
  1250. L8AD3:* LDA #$19            ;
  1251. L8AD5:  STA $00             ;Prepare to write to the sprite palette-->
  1252. L8AD7:  LDA #$3F            ;starting at address $3F19.
  1253. L8AD9:  STA $01             ;
  1254. L8ADB:  LDA IntroStarOffset     ;Use only first 3 bits of byte since the pointer-->
  1255. L8ADD:  AND #$07            ;table only has 8 entries.
  1256. L8ADF:  ASL             ;*2 to find entry in IntroStarPntr table.
  1257. L8AE0:  TAY             ;
  1258. L8AE1:  LDA IntroStarPntr,Y     ;Stores starting address of palette data to write-->
  1259. L8AE4:  STA $02             ;into $02 and $03 from IntroStarPntr table.
  1260. L8AE6:  LDA IntroStarPntr+1,Y       ;
  1261. L8AE9:  STA $03             ;
  1262. L8AEB:  INC IntroStarOffset     ;Increment index for next palette change.
  1263. L8AED:  JSR PrepPPUPaletteString    ;($C37E)Prepare and write new palette data.
  1264. L8AF0:  LDA #$1D            ;
  1265. L8AF2:  STA $00             ;
  1266. L8AF4:  LDA #$3F            ;Prepare another write to the sprite palette.-->
  1267. L8AF6:  STA $01             ;This tie starting at address $3F1D.
  1268. L8AF8:  INY                 ;
  1269. L8AF9:  JSR AddYToPtr02         ;($C2B3)Find new data base of palette data.
  1270. L8AFC:  JMP PrepPPUPaletteString    ;($C37E)Prepare and write new palette data.
  1271.  
  1272. ;The following table is a list of pointers into the table below. It contains
  1273. ;the palette data for the twinkling stars in the intro scene.  The palette data
  1274. ;is changed every 16 frames by the above routine.
  1275.  
  1276. IntroStarPntr:
  1277. L8AFF:  .word $8B0F, $8B19, $8B23, $8B2D, $8B37, $8B41, $8B4B, $8B55
  1278.  
  1279. ;The following table contains the platette data that is changed in the intro
  1280. ;scene to give the stars a twinkling effect. All entries in the table are
  1281. ;non-repeating.
  1282.  
  1283. IntroStarPal:
  1284. L8B0F:  .byte $03, $0F, $02, $13, $00, $03, $00, $34, $0F, $00
  1285. L8B10:  .byte $03, $06, $01, $23, $00, $03, $0F, $34, $09, $00
  1286. L8B23:  .byte $03, $16, $0F, $23, $00, $03, $0F, $24, $1A, $00
  1287. L8B2D:  .byte $03, $17, $0F, $13, $00, $03, $00, $04, $28, $00
  1288. L8B37:  .byte $03, $17, $01, $14, $00, $03, $10, $0F, $28, $00
  1289. L8B41:  .byte $03, $16, $02, $0F, $00, $03, $30, $0F, $1A, $00
  1290. L8B4B:  .byte $03, $06, $12, $0F, $00, $03, $30, $04, $09, $00
  1291. L8B55:  .byte $03, $0F, $12, $14, $00, $03, $10, $24, $0F, $00
  1292.  
  1293. ;----------------------------------------------------------------------------------------------------
  1294.  
  1295. DoFadeOut:
  1296. L8B5F:  LDY FadeDataIndex       ;Load palette data from table below.
  1297. L8B61:  LDA FadeOutPalData,Y        ;
  1298. L8B64:  CMP #$FF            ;If palette data = #$FF, exit.
  1299. L8B66:  BEQ +               ;
  1300. L8B68:  STA PalDataPending      ;Store new palette data.
  1301. L8B6A:  INC FadeDataIndex       ;
  1302. L8B6C:* RTS             ;
  1303.  
  1304. FadeOutPalData:
  1305. L8B6D:  .byte $0D, $0E, $0F, $10, $01, $FF
  1306.  
  1307. FadeInPalData:
  1308. L8B73:  .Byte $01, $10, $0F, $0E, $0D, $FF
  1309.  
  1310. ;----------------------------------------[ Password routines ]---------------------------------------
  1311.  
  1312. ProcessUniqueItems:
  1313. L8B79:  LDA NumberOfUniqueItems     ;
  1314. L8B7C:  STA $03             ;Store NumberOfUniqueItems at $03.
  1315. L8B7E:  LDY #$00            ;
  1316. L8B80:  STY $04             ;Set $04 to #$00.
  1317. L8B82:* LDY $04             ;Use $04 at index into unique itme list.           
  1318. L8B84:  INY             ;
  1319. L8B85:  LDA UniqueItemHistory-1,Y   ;
  1320. L8B88:  STA $00             ;Load the two bytes representing the aquired-->
  1321. L8B8A:  INY                 ;Unique item and store them in $00 and $01.
  1322. L8B8B:  LDA UniqueItemHistory-1,Y   ;
  1323. L8B8E:  STA $01             ;
  1324. L8B90:  STY $04             ;Increment $04 by two (load unique item complete).
  1325. L8B92:  JSR UniqueItemSearch        ;($8B9C)Find unique item.
  1326. L8B95:  LDY $04             ;
  1327. L8B97:  CPY $03             ;If all unique items processed, return, else-->
  1328. L8B99:  BCC -               ;branch to process next unique item.
  1329. L8B9B:  RTS             ;
  1330.  
  1331. UniqueItemSearch:
  1332. L8B9C:  LDX #$00            ;
  1333. L8B9E:* TXA             ;Transfer X to A(Item number).
  1334. L8B9F:  ASL             ;Multiply by 2.
  1335. L8BA0:  TAY             ;Store multiplied value in y.
  1336. L8BA1:  LDA ItemData,Y          ;Load unique item reference starting at $9029(2 bytes).
  1337. L8BA4:  CMP $00             ;
  1338. L8BA6:  BNE +               ;
  1339. L8BA8:  LDA ItemData+1,Y        ;Get next byte of unique item.
  1340. L8BAB:  CMP $01             ;
  1341. L8BAD:  BEQ ++              ;If unique item found, branch to UniqueItemFound.
  1342. L8BAF:* INX             ;
  1343. L8BB0:  CPX #$3C            ;If the unque item is a Zeebetite, return-->
  1344. L8BB2:  BCC --              ;else branch to find next unique item.
  1345. L8BB4:  RTS             ;
  1346.  
  1347. ;The following routine sets the item bits for aquired items in addresses $6988 thru $698E.-->
  1348. ;Items 1 thru 7 masked in $6988, 8 thru 15 in $6989, etc.
  1349.  
  1350. UniqueItemFound:
  1351. L8BB5:* TXA             ;
  1352. L8BB6:  JSR Adiv8           ;($C2C0)Divide by 8.
  1353. L8BB9:  STA $05             ;Shifts 5 MSBs to LSBs of item # and saves results in $05.
  1354. L8BBB:  JSR Amul8           ;($C2C6)Multiply by 8.
  1355. L8BBE:  STA $02             ;Restores 5 MSBs of item # and drops 3 LSBs; saves in $02.
  1356. L8BC0:  TXA             ;
  1357. L8BC1:  SEC             ;
  1358. L8BC2:  SBC $02             ;
  1359. L8BC4:  STA $06             ;Remove 5 MSBs and stores 3 LSBs in $06.
  1360. L8BC6:  LDX $05             ;
  1361. L8BC8:  LDA PasswordByte00,X        ;
  1362. L8BCB:  LDY $06             ;
  1363. L8BCD:  ORA PasswordBitmaskTbl,Y    ;
  1364. L8BD0:  STA PasswordByte00,X        ;Masks each unique item in the proper item address-->
  1365. L8BD3:  RTS             ;(addresses $6988 thru $698E).
  1366.  
  1367. LoadUniqueItems:
  1368. L8BD4:  LDA #$00            ;
  1369. L8BD6:  STA NumberOfUniqueItems     ;
  1370. L8BD9:  STA $05             ;$05 offset of password byte currently processing(0 thru 7).
  1371. L8BDB:  STA $06             ;$06 bit of password byte currently processing(0 thru 7).
  1372. L8BDD:  LDA #$3B            ;
  1373. L8BDF:  STA $07             ;Maximum number of unique items(59 or #$3B).
  1374. L8BE1:  LDY $05             ;
  1375. L8BE3:  LDA PasswordByte00,Y        ;
  1376. L8BE6:  STA $08             ;$08 stores contents of password byte currently processing.
  1377. L8BE8:  LDX #$00            ;
  1378. L8BEA:  STX $09             ;Stores number of unique items processed(#$0 thru #$3B).
  1379. L8BEC:  LDX $06             ;
  1380. L8BEE:  BEQ ++              ;If start of new byte, branch.
  1381.  
  1382. L8BF0:  LDX #$01            ;
  1383. L8BF2:  STX $02             ;
  1384. L8BF4:  CLC                 ;
  1385. L8BF5:* ROR                 ;
  1386. L8BF6:  STA $08             ;This code does not appear to ever be executed.
  1387. L8BF8:  LDX $02             ;
  1388. L8BFA:  CPX $06             ;
  1389. L8BFC:  BEQ +               ;
  1390. L8BFE:  INC $02             ;
  1391. L8C00:  JMP -               ;
  1392.  
  1393. ProcessNextItem:
  1394. L8C03:  LDY $05             ;Locates next password byte to process-->
  1395. L8C05:  LDA PasswordByte00,Y        ;and loads it into $08.
  1396. L8C08:  STA $08             ;
  1397.  
  1398. ProcessNewItemByte:
  1399. L8C0A:* LDA $08             ;
  1400. L8C0C:  ROR             ;Rotates next bit to be processed to the carry flag.
  1401. L8C0D:  STA $08             ;
  1402. L8C0F:  BCC +               ;
  1403. L8C11:  JSR SamusHasItem        ;($8C39)Store item in unique item history.
  1404. L8C14:* LDY $06             ;If last bit of item byte has been-->
  1405. L8C16:  CPY #$07            ;checked, move to next byte.
  1406. L8C18:  BCS +               ;
  1407. L8C1A:  INC $06             ;
  1408. L8C1C:  INC $09             ;
  1409. L8C1E:  LDX $09             ;If all 59 unique items have been-->
  1410. L8C20:  CPX $07             ;searched through, exit.
  1411. L8C22:  BCS ++              ;
  1412. L8C24:  JMP ProcessNewItemByte      ;($8C0A)Repeat routine for next item byte.
  1413. L8C27:* LDY #$00            ;
  1414. L8C29:  STY $06             ;
  1415. L8C2B:  INC $05             ;
  1416. L8C2D:  INC $09             ;
  1417. L8C2F:  LDX $09             ;If all 59 unique items have been-->
  1418. L8C31:  CPX $07             ;searched through, exit.
  1419. L8C33:  BCS +               ;
  1420. L8C35:  JMP ProcessNextItem     ;($8C03)Process next item.
  1421. L8C38:* RTS             ;
  1422.  
  1423. SamusHasItem:
  1424. L8C39:  LDA $05             ;$05 becomes the upper part of the item offset-->
  1425. L8C3B:  JSR Amul8           ;while $06 becomes the lower part of the item offset.
  1426. L8C3E:  CLC             ;
  1427. L8C3F:  ADC $06             ;
  1428. L8C41:  ASL             ;* 2. Each item is two bytes in length.
  1429. L8C42:  TAY             ;
  1430. L8C43:  LDA ItemData+1,Y        ;
  1431. L8C46:  STA $01             ;$00 and $01 store the two bytes of-->
  1432. L8C48:  LDA ItemData,Y          ;the unique item to process.
  1433. L8C4B:  STA $00             ;
  1434. L8C4D:  LDY NumberOfUniqueItems     ;
  1435. L8C50:  STA UniqueItemHistory,Y     ;Store the two bytes of the unique item-->
  1436. L8C53:  LDA $01             ;in RAM in the unique item history.
  1437. L8C55:  INY             ;
  1438. L8C56:  STA UniqueItemHistory,Y     ;
  1439. L8C59:  INY             ;
  1440. L8C5A:  STY NumberOfUniqueItems     ;Keeps a running total of unique items.
  1441. L8C5D:  RTS             ;
  1442.  
  1443. CheckPassword:
  1444. L8C5E:  JSR ConsolidatePassword     ;($8F60)Convert password characters to password bytes.
  1445. L8C61:  JSR ValidatePassword        ;($8DDE)Verify password is correct.
  1446. L8C64:  BCS +               ;Branch if incorrect password.
  1447. L8C66:  JMP InitializeGame      ;($92D4)Preliminary housekeeping before game starts.
  1448. L8C69:* LDA MultiSFXFlag        ;
  1449. L8C6C:  ORA #$01            ;Set IncorrectPassword SFX flag.
  1450. L8C6E:  STA MultiSFXFlag        ;
  1451. L8C71:  LDA #$0C            ;
  1452. L8C73:  STA Timer3          ;Set Timer3 time for 120 frames (2 seconds).
  1453. L8C75:  LDA #$18            ;
  1454. L8C77:  STA TitleRoutine        ;Run EnterPassword routine.
  1455. L8C79:  RTS             ;
  1456.  
  1457. CalculatePassword:
  1458. L8C7A:  LDA #$00            ;
  1459. L8C7C:  LDY #$0F            ;Clears values at addresses -->
  1460. L8C7E:* STA PasswordByte00,Y        ;$6988 thru $6997 and -->
  1461. L8C81:  STA PasswordChar00,Y        ;$699A thru $69A9.
  1462. L8C84:  DEY             ;
  1463. L8C85:  BPL -               ;
  1464. L8C87:  JSR ProcessUniqueItems      ;($8B79)Determine what items Samus has collected.
  1465. L8C8A:  LDA PasswordByte07      ;
  1466. L8C8D:  AND #$04            ;Check to see if mother brain has been defeated,-->
  1467. L8C8F:  BEQ +               ;If so, restore mother brain, zeebetites and-->
  1468. L8C91:  LDA #$00            ;all missile doors in Tourian as punishment for-->
  1469. L8C93:  STA PasswordByte07      ;dying after mother brain defeated. Only reset in the-->
  1470. L8C96:  LDA PasswordByte06      ;password.  Continuing without resetting will not-->
  1471. L8C99:  AND #$03            ;restore those items.
  1472. L8C9B:  STA PasswordByte06      ;
  1473. L8C9E:* LDA InArea          ;Store InArea in bits 0 thru 5 in-->
  1474. L8CA0:  AND #$3F            ;address $6990.
  1475. L8CA2:  LDY JustInBailey        ;
  1476. L8CA5:  BEQ +               ;
  1477. L8CA7:  ORA #$80            ;Sets MSB of $6990 is Samus is suitless.
  1478. L8CA9:* STA PasswordByte08      ;
  1479. L8CAC:  LDA SamusGear           ;
  1480. L8CAF:  STA PasswordByte09      ;SamusGear stored in $6991.
  1481. L8CB2:  LDA MissileCount        ;
  1482. L8CB5:  STA PasswordByte0A      ;MissileCount stored in $6992.
  1483. L8CB8:  LDA #$00            ;
  1484. L8CBA:  STA $00             ;
  1485. L8CBC:  LDA KraidStatueStatus       ;
  1486. L8CBF:  AND #$80            ;
  1487. L8CC1:  BEQ +               ;If statue not up, branch.
  1488. L8CC3:  LDA $00             ;
  1489. L8CC5:  ORA #$80            ;Set bit 7 of $00-->
  1490. L8CC7:  STA $00             ;if Kraid statue up.
  1491. L8CC9:* LDA KraidStatueStatus       ;
  1492. L8CCC:  AND #$01            ;
  1493. L8CCE:  BEQ +               ;Branch if Kraid not yet defeated.
  1494. L8CD0:  LDA $00             ;
  1495. L8CD2:  ORA #$40            ;Set bit 6 of $00-->
  1496. L8CD4:  STA $00             ;If Kraid defeated.
  1497. L8CD6:* LDA RidleyStatueStatus      ;
  1498. L8CD9:  AND #$80            ;
  1499. L8CDB:  BEQ +               ;Branch if Ridley statue not up.
  1500. L8CDD:  LDA $00             ;
  1501. L8CDF:  ORA #$20            ;Set bit 5 of $00-->
  1502. L8CE1:  STA $00             ;if Ridley statue up.
  1503. L8CE3:* LDA RidleyStatueStatus      ;
  1504. L8CE6:  AND #$02            ;
  1505. L8CE8:  BEQ +               ;Branch if Ridley not yet defeated.
  1506. L8CEA:  LDA $00             ;
  1507. L8CEC:  ORA #$10            ;Set bit 4 of $00-->
  1508. L8CEE:  STA $00             ;if Ridley defeated.
  1509. L8CF0:* LDA $00             ;
  1510. L8CF2:  STA PasswordByte0F      ;Stores statue statuses in 4 MSB at $6997.
  1511. L8CF5:  LDY #$03            ;
  1512. L8CF7:* LDA SamusAge,Y          ;Store SamusAge in $6993,-->
  1513. L8CFA:  STA PasswordByte0B,Y        ;SamusAge+1 in $6994 and-->
  1514. L8CFD:  DEY                 ;SamusAe+2 in $6995.
  1515. L8CFE:  BPL -               ;
  1516. L8D00:* JSR $C000           ;
  1517. L8D03:  LDA RandomNumber1       ;
  1518. L8D05:  AND #$0F            ;Store the value of $2E at $6998-->
  1519. L8D07:  BEQ -               ;When any of the 4 LSB are set. (Does not-->
  1520. L8D09:  STA PasswordByte10      ;allow RandomNumber1 to be a multiple of 16).
  1521. L8D0C:  JSR PasswordChecksumAndScramble ;($8E17)Calculate checksum and scramble password.
  1522. L8D0F:  JMP LoadPasswordChar        ;($8E6C)Calculate password characters.
  1523.  
  1524. LoadPasswordData:
  1525. L8D12:  LDA NARPASSWORD         ;If invincible Samus active, skip-->
  1526. L8D15:  BNE +++             ;further password processing.
  1527. L8D17:  JSR LoadUniqueItems     ;($8BD4)Load unique items from password.
  1528. L8D1A:  JSR LoadTanksAndMissiles    ;($8D3D)Calculate number of missiles from password.
  1529. L8D1D:  LDY #$00            ;
  1530. L8D1F:  LDA PasswordByte08      ;If MSB in PasswordByte08 is set,-->
  1531. L8D22:  AND #$80            ;Samus is not wearing her suit.
  1532. L8D24:  BEQ +               ;          
  1533. L8D26:  INY                 ;
  1534. L8D27:* STY JustInBailey        ;
  1535. L8D2A:  LDA PasswordByte08      ;Extract first 5 bits from PasswordByte08-->
  1536. L8D2D:  AND #$3F            ;and use it to determine starting area.
  1537. L8D2F:  STA InArea          ;
  1538. L8D31:  LDY #$03            ;
  1539. L8D33:* LDA PasswordByte0B,Y        ;Load Samus' age.
  1540. L8D36:  STA SamusAge,Y          ;
  1541. L8D39:  DEY             ;
  1542. L8D3A:  BPL -               ;Loop to load all 3 age bytes.
  1543. L8D3C:* RTS             ;
  1544.  
  1545. LoadTanksAndMissiles:
  1546. L8D3D:  LDA PasswordByte09      ;Loads Samus gear.
  1547. L8D40:  STA SamusGear           ;Save Samus gear.
  1548. L8D43:  LDA PasswordByte0A      ;Loads current number of missiles.
  1549. L8D46:  STA MissileCount        ;Save missile count.
  1550. L8D49:  LDA #$00            ;
  1551. L8D4B:  STA $00             ;
  1552. L8D4D:  STA $02             ;
  1553. L8D4F:  LDA PasswordByte0F      ;
  1554. L8D52:  AND #$80            ;If MSB is set, Kraid statue is up.
  1555. L8D54:  BEQ +               ;
  1556. L8D56:  LDA $00             ;
  1557. L8D58:  ORA #$80            ;If Kraid statue is up, set MSB in $00.
  1558. L8D5A:  STA $00             ;
  1559. L8D5C:* LDA PasswordByte0F      ;
  1560. L8D5F:  AND #$40            ;If bit 6 is set, Kraid is defeated.
  1561. L8D61:  BEQ +               ;
  1562. L8D63:  LDA $00             ;
  1563. L8D65:  ORA #$01            ;If Kraid is defeated, set LSB in $00.
  1564. L8D67:  STA $00             ;
  1565. L8D69:* LDA $00             ;
  1566. L8D6B:  STA KraidStatueStatus       ;Store Kraid status.
  1567. L8D6E:  LDA PasswordByte0F      ;
  1568. L8D71:  AND #$20            ;If bit 5 is set, Ridley statue is up.
  1569. L8D73:  BEQ +               ;
  1570. L8D75:  LDA $02             ;
  1571. L8D77:  ORA #$80            ;If Ridley statue is up, set MSB in $02.
  1572. L8D79:  STA $02             ;
  1573. L8D7B:* LDA PasswordByte0F      ;
  1574. L8D7E:  AND #$10            ;If bit 4 is set, Ridley is defeated.
  1575. L8D80:  BEQ +               ;
  1576. L8D82:  LDA $02             ;
  1577. L8D84:  ORA #$02            ;If Ridley is defeated, set bit 1 of $02.
  1578. L8D86:  STA $02             ;
  1579. L8D88:* LDA $02             ;
  1580. L8D8A:  STA RidleyStatueStatus      ;Store Ridley status.
  1581. L8D8D:  LDA #$00            ;
  1582. L8D8F:  STA $00             ;
  1583. L8D91:  STA $02             ;
  1584. L8D93:  LDY #$00            ;
  1585. L8D95:* LDA UniqueItemHistory+1,Y   ;Load second byte of item and compare-->
  1586. L8D98:  AND #$FC            ;the 6 MSBs to #$20. If it matches,-->  
  1587. L8D9A:  CMP #$20            ;an energy tank has been found.
  1588. L8D9C:  BNE +               ;
  1589. L8D9E:  INC $00             ;Increment number of energy tanks found.
  1590. L8DA0:  JMP IncrementToNextItem     ;
  1591. L8DA3:* CMP #$24            ;Load second byte of item and compare the 6 MSBs to-->
  1592. L8DA5:  BNE +               ;#$24. If it matches, missiles have been found.
  1593. L8DA7:  INC $02             ;Increment number of missiles found.
  1594.  
  1595. IncrementToNextItem:
  1596. L8DA9:* INY             ;
  1597. L8DAA:  INY             ;Increment twice. Each item is 2 bytes.
  1598. L8DAB:  CPY #$84            ;7 extra item slots in unique item history.
  1599. L8DAD:  BCC ---             ;Loop until all unique item history checked.
  1600. L8DAF:  LDA $00             ;
  1601. L8DB1:  CMP #$06            ;Ensure the Tank Count does not exceed 6-->
  1602. L8DB3:  BCC +               ;tanks. Then stores the number of-->
  1603. L8DB5:  LDA #$06            ;energy tanks found in TankCount.
  1604. L8DB7:* STA TankCount           ;
  1605. L8DBA:  LDA #$00            ;
  1606. L8DBC:  LDY $02             ;
  1607. L8DBE:  BEQ ++              ;Branch if no missiles found.
  1608. L8DC0:  CLC             ;
  1609. L8DC1:* ADC #$05            ;
  1610. L8DC3:  DEY                 ;For every missile item found, this-->
  1611. L8DC4:  BNE -               ;loop adds 5 missiles to MaxMissiles.
  1612. L8DC6:* LDY KraidStatueStatus       ;
  1613. L8DC9:  BEQ +               ;
  1614. L8DCB:  ADC #$4B            ;75 missiles are added to MaxMissiles-->
  1615. L8DCD:  BCS ++              ;if Kraid has been defeated and another-->
  1616. L8DCF:* LDY RidleyStatueStatus      ;75 missiles are added if the ridley-->
  1617. L8DD2:  BEQ ++              ;has been defeated.
  1618. L8DD4:  ADC #$4B            ;
  1619. L8DD6:  BCC ++              ;
  1620. L8DD8:* LDA #$FF            ;If number of missiles exceeds 255, it stays at 255.
  1621. L8DDA:* STA MaxMissiles         ;
  1622. L8DDD:  RTS             ;
  1623.  
  1624. ValidatePassword:
  1625. L8DDE:  LDA NARPASSWORD         ;
  1626. L8DE1:  BNE ++              ;If invincible Samus already active, branch.
  1627. L8DE3:  LDY #$0F            ;
  1628. L8DE5:* LDA PasswordChar00,Y        ;
  1629. L8DE8:  CMP NARPASSWORDTbl,Y        ;If NARPASSWORD was entered at the-->
  1630. L8DEB:  BNE +               ;password screen, activate invincible-->
  1631. L8DED:  DEY                 ;Samus, else continue to process password.
  1632. L8DEE:  BPL -               ;
  1633. L8DF0:  LDA #$01            ;
  1634. L8DF2:  STA NARPASSWORD         ;
  1635. L8DF5:  BNE ++              ;
  1636. L8DF7:* JSR UnscramblePassword      ;($8E4E)Unscramble password.
  1637. L8DFA:  JSR PasswordChecksum        ;($8E21)Calculate password checksum.
  1638. L8DFD:  CMP PasswordByte11      ;Verify proper checksum.
  1639. L8E00:  BEQ +               ;
  1640. L8E02:  SEC             ;If password is invalid, sets carry flag.
  1641. L8E03:  BCS ++              ;
  1642. L8E05:* CLC             ;If password is valid, clears carry flag.
  1643. L8E06:* RTS             ;
  1644.  
  1645. ;The table below is used by the code above. It checks to see if NARPASSWORD has been entered.
  1646. ;NOTE: any characters after the 16th character will be ignored if the first 16 characters
  1647. ;match the values below.
  1648.  
  1649. NARPASSWORDTbl:
  1650. L8E07:  .byte $17           ;N
  1651. L8E08:  .byte $0A           ;A
  1652. L8E09:  .byte $1B           ;R
  1653. L8E0A:  .byte $19           ;P
  1654. L8E0B:  .byte $0A           ;A
  1655. L8E0C:  .byte $1C           ;S
  1656. L8E0D:  .byte $1C           ;S
  1657. L8E0E:  .byte $20           ;W
  1658. L8E0F:  .byte $18           ;O
  1659. L8E10:  .byte $1B           ;R
  1660. L8E11:  .byte $0D           ;D
  1661. L8E12:  .byte $00           ;0(or no entry).
  1662. L8E13:  .byte $00           ;0(or no entry).
  1663. L8E14:  .byte $00           ;0(or no entry).
  1664. L8E15:  .byte $00           ;0(or no entry).
  1665. L8E16:  .byte $00           ;0(or no entry).
  1666.  
  1667. PasswordChecksumAndScramble:
  1668. L8E17:  JSR PasswordChecksum        ;($8E21)Store the combined added value of-->
  1669. L8E1A:  STA PasswordByte11      ;addresses $6988 thu $6998 in $6999.
  1670. L8E1D:  JSR PasswordScramble        ;($8E2D)Scramble password.
  1671. L8E20:  RTS             ;
  1672.  
  1673. PasswordChecksum:
  1674. L8E21:  LDY #$10            ;
  1675. L8E23:  LDA #$00            ;
  1676. L8E25:* CLC                 ;Add the values at addresses-->
  1677. L8E26:  ADC PasswordByte00,Y        ;$6988 thru $6998 together.
  1678. L8E29:  DEY                 ;
  1679. L8E2A:  BPL -               ;
  1680. L8E2C:  RTS             ;
  1681.  
  1682. PasswordScramble:
  1683. L8E2D:  LDA PasswordByte10      ;
  1684. L8E30:  STA $02             ;
  1685. L8E32:* LDA PasswordByte00      ;Store contents of $6988 in $00 for-->
  1686. L8E35:  STA $00             ;further processing after rotation.
  1687. L8E37:  LDX #$00            ;
  1688. L8E39:  LDY #$0F            ;
  1689. L8E3B:* ROR PasswordByte00,X        ;Rotate right, including carry, all values in-->
  1690. L8E3E:  INX                 ;addresses $6988 thru $6997.
  1691. L8E3F:  DEY                 ;
  1692. L8E40:  BPL -               ;
  1693. L8E42:  ROR $00             ;Rotate right $6988 to ensure the LSB-->
  1694. L8E44:  LDA $00             ;from address $6997 is rotated to the-->
  1695. L8E46:  STA PasswordByte00      ;MSB of $6988.
  1696. L8E49:  DEC $02             ;
  1697. L8E4B:  BNE --              ;Continue rotating until $02 = 0.
  1698. L8E4D:  RTS             ;
  1699.  
  1700. UnscramblePassword:
  1701. L8E4E:  LDA PasswordByte10      ;Stores random number used to scramble the password.
  1702. L8E51:  STA $02             ;
  1703. L8E53:* LDA PasswordByte0F      ;Preserve MSB that may have been rolled from $6988.
  1704. L8E56:  STA $00             ;
  1705. L8E58:  LDX #$0F            ;
  1706. L8E5A:* ROL PasswordByte00,X        ;The following loop rolls left the first 16 bytes-->
  1707. L8E5D:  DEX                 ;of the password one time.
  1708. L8E5E:  BPL -               ;
  1709. L8E60:  ROL $00             ;Rolls byte in $6997 to ensure MSB from $6988 is not lost.
  1710. L8E62:  LDA $00             ;
  1711. L8E64:  STA PasswordByte0F      ;
  1712. L8E67:  DEC $02             ;
  1713. L8E69:  BNE --              ;Loop repeats the number of times decided by the random-->
  1714. L8E6B:  RTS                 ;number in $6998 to properly unscramble the password.
  1715.  
  1716. ;The following code takes the 18 password bytes and converts them into 24 characters
  1717. ;to be displayed to the player as the password.  NOTE: the two MSBs will always be 0.
  1718.  
  1719. LoadPasswordChar:
  1720. L8E6C:  LDY #$00            ;Password byte #$00.
  1721. L8E6E:  JSR SixUpperBits        ;($8F2D)
  1722. L8E71:  STA PasswordChar00      ;Store results.
  1723. L8E74:  LDY #$00            ;Password bytes #$00 and #$01.
  1724. L8E76:  JSR TwoLowerAndFourUpper    ;($8F33)
  1725. L8E79:  STA PasswordChar01      ;Store results.
  1726. L8E7C:  LDY #$01            ;Password bytes #$01 and #$02.
  1727. L8E7E:  JSR FourLowerAndTwoUpper    ;($8F46)
  1728. L8E81:  STA PasswordChar02      ;Store results.
  1729. L8E84:  LDY #$02            ;Password byte #$02.
  1730. L8E86:  JSR SixLowerBits        ;($8F5A)
  1731. L8E89:  STA PasswordChar03      ;Store results.
  1732. L8E8C:  LDY #$03            ;Password byte #$03.
  1733. L8E8E:  JSR SixUpperBits        ;($8F2D)
  1734. L8E91:  STA PasswordChar04      ;Store results.
  1735. L8E94:  LDY #$03            ;Password bytes #$03 and #$04.
  1736. L8E96:  JSR TwoLowerAndFourUpper    ;($8F33)
  1737. L8E99:  STA PasswordChar05      ;Store results.
  1738. L8E9C:  LDY #$04            ;Password bytes #$04 and #$05.
  1739. L8E9E:  JSR FourLowerAndTwoUpper    ;($8F46)
  1740. L8EA1:  STA PasswordChar06      ;Store results.
  1741. L8EA4:  LDY #$05            ;Password byte #$05.
  1742. L8EA6:  JSR SixLowerBits        ;($8F5A)
  1743. L8EA9:  STA PasswordChar07      ;Store results.
  1744. L8EAC:  LDY #$06            ;Password byte #$06.
  1745. L8EAE:  JSR SixUpperBits        ;($8F2D)
  1746. L8EB1:  STA PasswordChar08      ;Store results.
  1747. L8EB4:  LDY #$06            ;Password bytes #$06 and #$07.
  1748. L8EB6:  JSR TwoLowerAndFourUpper    ;($8F33)
  1749. L8EB9:  STA PasswordChar09      ;Store results.
  1750. L8EBC:  LDY #$07            ;Password bytes #$07 and #$08.
  1751. L8EBE:  JSR FourLowerAndTwoUpper    ;($8F46)
  1752. L8EC1:  STA PasswordChar0A      ;Store results.
  1753. L8EC4:  LDY #$08            ;Password byte #$08.
  1754. L8EC6:  JSR SixLowerBits        ;($8F5A)
  1755. L8EC9:  STA PasswordChar0B      ;Store results.
  1756. L8ECC:  LDY #$09            ;Password byte #$09.
  1757. L8ECE:  JSR SixUpperBits        ;($8F2D)
  1758. L8ED1:  STA PasswordChar0C      ;Store results.
  1759. L8ED4:  LDY #$09            ;Password bytes #$09 and #$0A.
  1760. L8ED6:  JSR TwoLowerAndFourUpper    ;($8F33)
  1761. L8ED9:  STA PasswordChar0D      ;Store results.
  1762. L8EDC:  LDY #$0A            ;Password bytes #$0A and #$0B.
  1763. L8EDE:  JSR FourLowerAndTwoUpper    ;($8F46)
  1764. L8EE1:  STA PasswordChar0E      ;Store results.
  1765. L8EE4:  LDY #$0B            ;Password byte #$0B.
  1766. L8EE6:  JSR SixLowerBits        ;($8F5A)
  1767. L8EE9:  STA PasswordChar0F      ;Store results.
  1768. L8EEC:  LDY #$0C            ;Password byte #$0C.
  1769. L8EEE:  JSR SixUpperBits        ;($8F2D)
  1770. L8EF1:  STA PasswordChar10      ;Store results.
  1771. L8EF4:  LDY #$0C            ;Password bytes #$0C and #$0D.
  1772. L8EF6:  JSR TwoLowerAndFourUpper    ;($8F33)
  1773. L8EF9:  STA PasswordChar11      ;Store results.
  1774. L8EFC:  LDY #$0D            ;Password bytes #$0D and #$0E.
  1775. L8EFE:  JSR FourLowerAndTwoUpper    ;($8F46)
  1776. L8F01:  STA PasswordChar12      ;Store results.
  1777. L8F04:  LDY #$0E            ;Password byte #$0E.
  1778. L8F06:  JSR SixLowerBits        ;($8F5A)
  1779. L8F09:  STA PasswordChar13      ;Store results.
  1780. L8F0C:  LDY #$0F            ;Password byte #$0F.
  1781. L8F0E:  JSR SixUpperBits        ;($8F2D)
  1782. L8F11:  STA PasswordChar14      ;Store results.
  1783. L8F14:  LDY #$0F            ;Password bytes #$0F and #$10.
  1784. L8F16:  JSR TwoLowerAndFourUpper    ;($8F33)
  1785. L8F19:  STA PasswordChar15      ;Store results.
  1786. L8F1C:  LDY #$10            ;Password bytes #$10 and #$11.
  1787. L8F1E:  JSR FourLowerAndTwoUpper    ;($8F46)
  1788. L8F21:  STA PasswordChar16      ;Store results.
  1789. L8F24:  LDY #$11            ;Password byte #$11.
  1790. L8F26:  JSR SixLowerBits        ;($8F5A)
  1791. L8F29:  STA PasswordChar17      ;Store results.
  1792. L8F2C:  RTS             ;
  1793.  
  1794. SixUpperBits:
  1795. L8F2D:  LDA PasswordByte00,Y        ;Uses six upper bits to create a new byte.-->
  1796. L8F30:  LSR             ;Bits are right shifted twice and two lower-->
  1797. L8F31:  LSR             ;bits are discarded.
  1798. L8F32:  RTS             ;
  1799.  
  1800. TwoLowerAndFourUpper:
  1801. L8F33:  LDA PasswordByte00,Y        ;
  1802. L8F36:  AND #$03            ;Saves two lower bits and stores them-->
  1803. L8F38:  JSR Amul16          ;($C2C5)in bits 4 and 5.
  1804. L8F3B:  STA $00             ;
  1805. L8F3D:  LDA PasswordByte01,Y        ;Saves upper 4 bits and stores them-->
  1806. L8F40:  JSR Adiv16          ;($C2BF)bits 0, 1, 2 and 3.
  1807. L8F43:  ORA $00             ;Add two sets of bits together to make a byte-->
  1808. L8F45:  RTS             ;where bits 6 and 7 = 0.
  1809.  
  1810. FourLowerAndTwoUpper:
  1811. L8F46:  LDA PasswordByte00,Y        ;
  1812. L8F49:  AND #$0F            ;Keep lower 4 bits.
  1813. L8F4B:  ASL             ;Move lower 4 bits to bits 5, 4, 3 and 2.
  1814. L8F4C:  ASL             ;
  1815. L8F4D:  STA $00             ;
  1816. L8F4F:  LDA PasswordByte01,Y        ;Move upper two bits-->
  1817. L8F52:  ROL             ;to bits 1 and 0.
  1818. L8F53:  ROL             ;
  1819. L8F54:  ROL             ;
  1820. L8F55:  AND #$03            ;Add two sets of bits together to make a byte-->   
  1821. L8F57:  ORA $00             ;where bits 6 and 7 = 0.
  1822. L8F59:  RTS             ;
  1823.  
  1824. SixLowerBits:
  1825. L8F5A:  LDA PasswordByte00,Y        ;Discard bits 6 and 7.
  1826. L8F5D:  AND #$3F            ;
  1827. L8F5F:  RTS
  1828.  
  1829. ;The following routine converts the 24 user entered password characters into the 18 password
  1830. ;bytes used by the program to store Samus' stats and unique item history.
  1831.  
  1832. ConsolidatePassword:
  1833. L8F60:  LDY #$00            ;Password characters #$00 and #$01.
  1834. L8F62:  JSR SixLowerAndTwoUpper     ;($8FF1)
  1835. L8F65:  STA PasswordByte00      ;Store results.
  1836. L8F68:  LDY #$01            ;Password characters #$01 and #$02.
  1837. L8F6A:  JSR FourLowerAndFiveThruTwo ;($9001)
  1838. L8F6D:  STA PasswordByte01      ;Store results.
  1839. L8F70:  LDY #$02            ;Password characters #$02 and #$03.
  1840. L8F72:  JSR TwoLowerAndSixLower     ;($9011)
  1841. L8F75:  STA PasswordByte02      ;Store results.
  1842. L8F78:  LDY #$04            ;Password characters #$04 and #$05.
  1843. L8F7A:  JSR SixLowerAndTwoUpper     ;($8FF1)
  1844. L8F7D:  STA PasswordByte03      ;Store results.
  1845. L8F80:  LDY #$05            ;Password characters #$05 and #$05.
  1846. L8F82:  JSR FourLowerAndFiveThruTwo ;($9001)
  1847. L8F85:  STA PasswordByte04      ;Store results.
  1848. L8F88:  LDY #$06            ;Password characters #$06 and #$07.
  1849. L8F8A:  JSR TwoLowerAndSixLower     ;($9011)
  1850. L8F8D:  STA PasswordByte05      ;Store results.
  1851. L8F90:  LDY #$08            ;Password characters #$08 and #$09.
  1852. L8F92:  JSR SixLowerAndTwoUpper     ;($8FF1)
  1853. L8F95:  STA PasswordByte06      ;Store results.
  1854. L8F98:  LDY #$09            ;Password characters #$09 and #$0A.
  1855. L8F9A:  JSR FourLowerAndFiveThruTwo ;($9001)
  1856. L8F9D:  STA PasswordByte07      ;Store results.
  1857. L8FA0:  LDY #$0A            ;Password characters #$0A and #$0B.
  1858. L8FA2:  JSR TwoLowerAndSixLower     ;($9011)
  1859. L8FA5:  STA PasswordByte08      ;Store results.
  1860. L8FA8:  LDY #$0C            ;Password characters #$0C and #$0D.
  1861. L8FAA:  JSR SixLowerAndTwoUpper     ;($8FF1)
  1862. L8FAD:  STA PasswordByte09      ;Store results.
  1863. L8FB0:  LDY #$0D            ;Password characters #$0D and #$0E.
  1864. L8FB2:  JSR FourLowerAndFiveThruTwo ;($9001)
  1865. L8FB5:  STA PasswordByte0A      ;Store results.
  1866. L8FB8:  LDY #$0E            ;Password characters #$0E and #$0F.
  1867. L8FBA:  JSR TwoLowerAndSixLower     ;($9011)
  1868. L8FBD:  STA PasswordByte0B      ;Store results.
  1869. L8FC0:  LDY #$10            ;Password characters #$10 and #$11.
  1870. L8FC2:  JSR SixLowerAndTwoUpper     ;($8FF1)
  1871. L8FC5:  STA PasswordByte0C      ;Store results.
  1872. L8FC8:  LDY #$11            ;Password characters #$11 and #$12.
  1873. L8FCA:  JSR FourLowerAndFiveThruTwo ;($9001)
  1874. L8FCD:  STA PasswordByte0D      ;Store results.
  1875. L8FD0:  LDY #$12            ;Password characters #$12 and #$13.
  1876. L8FD2:  JSR TwoLowerAndSixLower     ;($9011)
  1877. L8FD5:  STA PasswordByte0E      ;Store results.
  1878. L8FD8:  LDY #$14            ;Password characters #$15 and #$15.
  1879. L8FDA:  JSR SixLowerAndTwoUpper     ;($8FF1)
  1880. L8FDD:  STA PasswordByte0F      ;Store results.
  1881. L8FE0:  LDY #$15            ;Password characters #$15 and #$16.
  1882. L8FE2:  JSR FourLowerAndFiveThruTwo ;($9001)
  1883. L8FE5:  STA PasswordByte10      ;Store results.
  1884. L8FE8:  LDY #$16            ;Password characters #$16 and #$17.
  1885. L8FEA:  JSR TwoLowerAndSixLower     ;($9011)
  1886. L8FED:  STA PasswordByte11      ;Store results.
  1887. L8FF0:  RTS             ;
  1888.  
  1889. SixLowerAndTwoUpper:
  1890. L8FF1:  LDA PasswordChar00,Y        ;Remove upper two bits and transfer-->
  1891. L8FF4:  ASL             ;lower six bits to upper six bits.
  1892. L8FF5:  ASL             ;
  1893. L8FF6:  STA $00             ;
  1894. L8FF8:  LDA PasswordChar01,Y        ;Move bits 4and 5 to lower two-->
  1895. L8FFB:  JSR Adiv16          ;($C2BF)bits and discard the rest.
  1896. L8FFE:  ORA $00             ;Combine the two bytes together.
  1897. L9000:  RTS             ;
  1898.  
  1899. FourLowerAndFiveThruTwo:
  1900. L9001:  LDA PasswordChar00,Y        ;Take four lower bits and transfer-->
  1901. L9004:  JSR Amul16          ;($C2C5)them to upper four bits. Discard the rest.
  1902. L9007:  STA $00             ;
  1903. L9009:  LDA PasswordChar01,Y        ;Remove two lower bits and transfer-->
  1904. L900C:  LSR             ;bits 5 thru 2 to lower four bits.
  1905. L900D:  LSR             ;
  1906. L900E:  ORA $00             ;Combine the two bytes together.
  1907. L9010:  RTS             ;
  1908.  
  1909. TwoLowerAndSixLower:
  1910. L9011:  LDA PasswordChar00,Y        ;Shifts two lower bits to two higest bits-->
  1911. L9014:  ROR                 ;and discards the rest
  1912. L9015:  ROR                 ;
  1913. L9016:  ROR                 ;
  1914. L9017:  AND #$C0            ;
  1915. L9019:  STA $00             ;
  1916. L901B:  LDA PasswordChar01,Y        ;Add six lower bits to previous results.
  1917. L901E:  ORA $00             ;
  1918. L9020:  RTS             ;
  1919.  
  1920. PasswordBitmaskTbl:
  1921. L9021:  .byte $01, $02, $04, $08, $10, $20, $40, $80
  1922.  
  1923. ;The following table contains the unique items in the game.  The two bytes can be deciphered
  1924. ;as follows:IIIIIIXX XXXYYYYY. I = item type, X = X coordinate on world map, Y = Y coordinate
  1925. ;on world map.  The items have the following values of IIIIII:
  1926. ;High jump     = 000001
  1927. ;Long beam     = 000010 (Not considered a unique item).
  1928. ;Screw attack  = 000011
  1929. ;Maru Mari     = 000100
  1930. ;Varia suit    = 000101
  1931. ;Wave beam     = 000110 (Not considered a unique item).
  1932. ;Ice beam      = 000111 (Not considered a unique item).
  1933. ;Energy tank   = 001000
  1934. ;Missiles      = 001001
  1935. ;Missile door  = 001010
  1936. ;Bombs         = 001100
  1937. ;Mother brain  = 001110
  1938. ;1st Zeebetite = 001111
  1939. ;2nd Zeebetite = 010000
  1940. ;3rd Zeebetite = 010001
  1941. ;4th Zeebetite = 010010
  1942. ;5th Zeebetite = 010011
  1943.  
  1944. ItemData:
  1945. L9029:  .word $104E         ;Maru Mari at coord 02,0E                    (Item 0)
  1946. L902B:  .word $264B         ;Missiles at coord 12,0B                     (Item 1)
  1947. L902D:  .word $28E5         ;Red door to long beam at coord 07,05        (Item 2)
  1948. L902F:  .word $2882         ;Red door to Tourian elevator at coord 05,02 (Item 3)
  1949. L9031:  .word $2327         ;Energy tank at coord 19,07                  (Item 4)
  1950. L9033:  .word $2B25         ;Red door to bombs at coord 1A,05            (Item 5)
  1951. L9035:  .word $0325         ;Bombs at coord 19,05                        (Item 6)
  1952. L9037:  .word $2A69         ;Red door to ice beam at coord 13,09         (Item 7)
  1953. L9039:  .word $2703         ;Missiles at coord 18,03                     (Item 8)
  1954. L903B:  .word $2363         ;Energy tank at coord 1B,03                  (Item 9)
  1955. L903D:  .word $29E2         ;Red door to varia suit at coord 0F,02       (Item 10)
  1956. L903F:  .word $15E2         ;Varia suit at coord 0F,02                   (Item 11)
  1957. L9041:  .word $212E         ;Energy tank at coord 09,0E                  (Item 12)
  1958. L9043:  .word $264E         ;Missiles at coord 12,0E                     (Item 13)
  1959. L9045:  .word $262F         ;Missiles at coord 11,0F                     (Item 14)
  1960. L9047:  .word $2B4C         ;Red door to ice beam at coord 1B,0C         (Item 15)
  1961. L9049:  .word $276A         ;Missiles at coord 1B,0A                     (Item 16)
  1962. L904B:  .word $278A         ;Missiles at coord 1C,0A                     (Item 17)
  1963. L904D:  .word $278B         ;Missiles at coord 1C,0B                     (Item 18)
  1964. L904F:  .word $276B         ;Missiles at coord 1B,0B                     (Item 19)
  1965. L9051:  .word $274B         ;Missiles at coord 1A,0B                     (Item 20)
  1966. L9053:  .word $268F         ;Missiles at coord 14,0F                     (Item 21)
  1967. L9055:  .word $266F         ;Missiles at coord 13,0F                     (Item 22)
  1968. L9057:  .word $2B71         ;Red door to high jump at coord 1C,11        (Item 23)
  1969. L9059:  .word $0771         ;High jump at coord 1B,11                    (Item 24)
  1970. L905B:  .word $29F0         ;Red door to screw attack at coord 0E,10     (Item 25)
  1971. L905D:  .word $0DF0         ;Screw attack at coord 0D,1D                 (Item 26)
  1972. L905F:  .word $2676         ;Missiles at coord 13,16                     (Item 27)
  1973. L9061:  .word $2696         ;Misslies at coord 14,16                     (Item 28)
  1974. L9063:  .word $2A55         ;Red door to wave beam at coord 1C,15        (Item 29)
  1975. L9065:  .word $2353         ;Energy tank at coord 1A,13                  (Item 30)
  1976. L9067:  .word $2794         ;Missiles at coord 1C,14                     (Item 31)
  1977. L9069:  .word $28F5         ;Red door at coord 07,15                     (Item 32)
  1978. L906B:  .word $2535         ;Missiles at coord 09,15                     (Item 33)
  1979. L906D:  .word $2495         ;Missiles at coord 04,15                     (Item 34)
  1980. L906F:  .word $28F6         ;Red door at coord 07,16                     (Item 35)
  1981. L9071:  .word $2156         ;Energy tank at coord 0A,16                  (Item 36)
  1982. L9073:  .word $28F8         ;Red door at coord 07,18                     (Item 37)
  1983. L9075:  .word $287B         ;Red door at coord 03,1B                     (Item 38)
  1984. L9077:  .word $24BB         ;Missiles at coord 05,1B                     (Item 39)
  1985. L9079:  .word $2559         ;Missiles at coord 0A,19                     (Item 40)
  1986. L907B:  .word $291D         ;Red door to Kraid at coord 08,1D            (Item 41)
  1987. L907D:  .word $211D         ;Energy tank at coord 08,1D(Kraid's room)    (Item 42)
  1988. L907F:  .word $2658         ;Missiles at coord 12,18                     (Item 43)
  1989. L9081:  .word $2A39         ;Red door at coord 11,19                     (Item 44)
  1990. L9083:  .word $2239         ;Energy tank at coord 11,19                  (Item 45)
  1991. L9085:  .word $269E         ;Missiles at coord 14,1E                     (Item 46)
  1992. L9087:  .word $2A1D         ;purple door at coord 10,1D(Ridley's room)   (Item 47)
  1993. L9089:  .word $21FD         ;Energy tank at coord 0F,1D                  (Item 48)
  1994. L908B:  .word $271B         ;Missile at coord 18,1B                      (Item 49)
  1995. L908D:  .word $2867         ;Orange door at coord 03,07                  (Item 50)
  1996. L908F:  .word $2927         ;Red door at coord 09,07                     (Item 51)
  1997. L9091:  .word $292B         ;Red door at coord 0A,0B                     (Item 52)
  1998. L9093:  .word $3C00         ;1st Zeebetite in mother brain room          (Item 53)
  1999. L9095:  .word $4000         ;2nd Zeebetite in mother brain room          (Item 54)
  2000. L9097:  .word $4400         ;3rd Zeebetite in mother brain room          (Item 55)
  2001. L9099:  .word $4800         ;4th Zeebetite in mother brain room          (Item 56)
  2002. L909B:  .word $4C00         ;5th Zeebetite in mother brain room          (Item 57)
  2003. L909D:  .word $3800         ;Mother brain                                (Item 58)
  2004.  
  2005. ClearAll:
  2006. L909F:  jsr ScreenOff           ;($C439)Turn screen off.
  2007. L90A2:  jsr ClearNameTables     ;Turn off screen, clear sprites and name tables.
  2008. L90A5:  jsr EraseAllSprites     ;
  2009. L90A8:  lda PPUCNT0ZP           ;Set Name table address to $2000.
  2010. L90AA:  and #$FC            ;
  2011. L90AC:  sta PPUCNT0ZP           ;
  2012. L90AE:  lda #$00            ;
  2013. L90B0:  sta ScrollY         ;Reset scroll offsets.
  2014. L90B2:  sta ScrollX         ;
  2015. L90B4:  jsr WaitNMIPass         ;($C42C)Wait for NMI to end.
  2016. L90B7:  jmp VBOffAndHorzWrite       ;($C47D)Set PPU for horizontal write and turn off VBlank.
  2017.  
  2018. StartContinueScreen:
  2019. L90BA:  jsr ClearAll            ;($909F)Turn off screen, erase sprites and nametables.
  2020. L90BD:  ldx #$84            ;Low address for PPU write.
  2021. L90BF:  ldy #$99            ;High address for PPU write.
  2022. L90C1:  jsr PreparePPUProcess       ;($9449)Clears screen and writes "START CONTINUE".
  2023. L90C4:  LDY #$00            ;
  2024. L90C6:  STY StartContinue       ;Set selection sprite at START.
  2025. L90C9:  LDA #$0D            ;
  2026. L90CB:  STA PalDataPending      ;Change palette and title routine.
  2027. L90CD:  LDA #$16            ;Next routine is ChooseStartContinue.
  2028. L90CF:  STA TitleRoutine        ;
  2029.  
  2030. TurnOnDisplay:
  2031. L90D1:  JSR NMIOn           ;($C487)Turn on the nonmaskable interrupt.
  2032. L90D4:  JMP ScreenOn            ;($C447)Turn screen on.
  2033.  
  2034. ChooseStartContinue:
  2035. L90D7:  LDA Joy1Change          ;
  2036. L90D9:  AND #$30            ;Checks both select and start buttons.
  2037. L90DB:  CMP #$10            ;Check if START has been pressed.
  2038. L90DD:  BNE ++              ;Branch if START not pressed.
  2039. L90DF:  LDY StartContinue       ;
  2040. L90E2:  BNE +               ;if CONTINUE selected, branch.
  2041. L90E4:  JMP InitializeStats     ;($932B)Zero out all stats.
  2042. L90E7:* LDY #$17            ;Next routine is LoadPasswordScreen.
  2043. L90E9:  STY TitleRoutine        ;
  2044. L90EB:* CMP #$20            ;check if SELECT has been pressed.
  2045. L90ED:  BNE +               ;Branch if SELECT not pressed.
  2046. L90EF:  LDA StartContinue       ;
  2047. L90F2:  EOR #$01            ;Chooses between START and CONTINUE-->
  2048. L90F4:  STA StartContinue       ;on game select screen.
  2049. L90F7:  LDA TriangleSFXFlag     ;
  2050. L90FA:  ORA #$08            ;Set SFX flag for select being pressed.-->
  2051. L90FC:  STA TriangleSFXFlag     ;Uses triangle channel.
  2052. L90FF:* LDY StartContinue       ;
  2053. L9102:  LDA StartContTbl,Y      ;Get y pos of selection sprite.
  2054. L9105:  STA Sprite00RAM         ;
  2055. L9108:  LDA #$6E            ;Load sprite info for square selection sprite.
  2056. L910A:  STA Sprite00RAM+1       ;
  2057. L910D:  LDA #$03            ;
  2058. L910F:  STA Sprite00RAM+2       ;
  2059. L9112:  LDA #$50            ;Set data for selection sprite.
  2060. L9114:  STA Sprite00RAM+3       ;
  2061. L9117:  RTS             ;
  2062.  
  2063. StartContTbl:
  2064. L9118:  .byte $60           ;Y sprite position for START.
  2065. L9119:  .byte $78           ;Y sprite position for CONTINUE.
  2066.  
  2067. LoadPasswordScreen:
  2068. L911A:  JSR ClearAll            ;($909F)Turn off screen, erase sprites and nametables.
  2069. L911D:  LDX #$E3            ;Loads PPU with info to display-->
  2070. L911F:  LDY #$99            ;PASS WORD PLEASE.
  2071. L9121:  JSR PreparePPUProcess       ;($9449)Load "PASSWORD PLEASE" on screen.
  2072. L9124:  JSR InitGFX7            ;($C6D6)Loads the font for the password.
  2073. L9127:  JSR DisplayInputCharacters  ;($940B)Write password character to screen.
  2074. L912A:  LDA #$13            ;
  2075. L912C:  STA PalDataPending      ;Change palette.
  2076. L912E:  LDA #$00            ;
  2077. L9130:  STA InputRow            ;Sets character select cursor to-->
  2078. L9133:  STA InputColumn         ;upper left character (0).
  2079. L9136:  STA Timer3          ;
  2080. L9138:  LDA #$00            ;
  2081. L913A:  STA PasswordCursor      ;Sets password cursor to password character 0.
  2082. L913D:  LDY #$00            ;
  2083. L913F:  STY PasswordStat00      ;Appears to have no function.
  2084. L9142:  INC TitleRoutine        ;
  2085. L9144:  JMP TurnOnDisplay       ;($90D1)Turn on screen and NMI.
  2086.  
  2087. EnterPassword:
  2088. L9147:  JSR EraseAllSprites     ;($C1A3)Remove sprites from screen.
  2089. L914A:  LDA Joy1Change          ;
  2090. L914C:  AND #$10            ;Check to see if START has been pressed.
  2091. L914E:  BEQ +               ;If not, branch.
  2092. L9150:  JMP CheckPassword       ;($8C5E)Check if password is correct.
  2093. L9153:* LDX #$01            ;
  2094. L9155:  STX PPUDataPending      ;Prepare to write the password screen data to PPU.
  2095. L9157:  LDX PPUStrIndex         ;
  2096. L915A:  LDA #$21            ;Upper byte of PPU string.
  2097. L915C:  JSR WritePPUByte        ;($C36B)Write byte to PPU.
  2098. L915F:  LDA #$A8            ;Lower byte of PPU string.
  2099. L9161:  JSR WritePPUByte        ;($C36B)Write byte to PPU.
  2100. L9164:  LDA #$0F            ;PPU string length.
  2101. L9166:  JSR WritePPUByte        ;($C36B)Write byte to PPU.
  2102. L9169:  LDA Timer3          ;
  2103. L916B:  BEQ +               ;
  2104. L916D:  LDA #$59            ;
  2105. L916F:  STA $02             ;Writes 'ERROR TRY AGAIN' on the screen-->
  2106. L9171:  LDA #$87            ;if Timer3 is anything but #$00.
  2107. L9173:  STA $03             ;
  2108. L9175:  JMP ++              ;
  2109. L9178:* LDA #$68            ;
  2110. L917A:  STA $02             ;
  2111. L917C:  LDA #$87            ;
  2112. L917E:  STA $03             ;Writes the blank lines that cover-->
  2113. L9180:* LDY #$00            ;the message 'ERROR TRY AGAIN'.
  2114. L9182:* LDA ($02),Y         ;
  2115. L9184:  JSR WritePPUByte        ;
  2116. L9187:  INY                 ;
  2117. L9188:  CPY #$0F            ;
  2118. L918A:  BNE -               ;
  2119. L918C:  LDA Joy1Change          ;If button A pressed, branch.
  2120. L918E:  BMI +               ;
  2121. L9190:  JMP CheckBackspace      ;($91FB)Check if backspace pressed.
  2122. L9193:* LDA TriangleSFXFlag     ;Initiate BombLaunch SFX if a character-->
  2123. L9196:  ORA #$01            ;has been written to the screen.
  2124. L9198:  STA TriangleSFXFlag     ;
  2125. L919B:  LDA PasswordCursor      ;
  2126. L919E:  CMP #$12            ;Check to see if password cursor is on-->
  2127. L91A0:  BCC +               ;character 19 thru 24.  If not, branch.
  2128. L91A2:  CLC             ;
  2129. L91A3:  ADC #$3E            ;Will equal #$50 thru #$55.
  2130. L91A5:  JMP LoadRowAndColumn        ;($91BF)
  2131. L91A8:* CMP #$0C            ;Check to see if password cursor is on-->
  2132. L91AA:  BCC +               ;character 13 thru 18.  If not, branch.
  2133. L91AC:  CLC             ;
  2134. L91AD:  ADC #$3D            ;Will equal #$49 thru #$4E.
  2135. L91AF:  JMP LoadRowAndColumn        ;($91BF)
  2136. L91B2:* CMP #$06            ;Check to see if password cursor is on-->
  2137. L91B4:  BCC +               ;character 7 thru 12.  If not, branch.
  2138. L91B6:  CLC             ;
  2139. L91B7:  ADC #$0A            ;Will equal #$10 thru #$15.
  2140. L91B9:  JMP LoadRowAndColumn        ;($91BF)
  2141. L91BC:* CLC             ;
  2142. L91BD:  ADC #$09            ;Will equal #$09 thru #$0E.
  2143.  
  2144. LoadRowAndColumn:
  2145. L91BF:* STA $06             ;
  2146. L91C1:  LDA InputRow            ;
  2147. L91C4:  ASL             ;*2. address pointer is two bytes.
  2148. L91C5:  TAY             ;
  2149. L91C6:  LDA PasswordRowTbl,Y        ;Store lower byte of row pointer.
  2150. L91C9:  STA $00             ;
  2151. L91CB:  LDA PasswordRowTbl+1,Y      ;Store upper byte of row pointer.
  2152. L91CE:  STA $01             ;
  2153. L91D0:  LDY InputColumn         ;Uses InputColumn value to find proper index-->    
  2154. L91D3:  LDA ($00),Y         ;of current character selected.
  2155. L91D5:  PHA             ;Temp storage of A.
  2156. L91D6:  STA TileInfo0           ;Store value of current character slected.
  2157. L91D9:  LDA #$11            ;
  2158. L91DB:  STA TileSize            ;
  2159. L91DE:  LDX $06             ;Replace password character tile with-->
  2160. L91E0:  LDY #$21            ;the one selected by the player.
  2161. L91E2:  JSR PrepareEraseTiles       ;($9450)
  2162. L91E5:  LDX PasswordCursor      ;
  2163. L91E8:  PLA                 ;Store the currently selected password character-->
  2164. L91E9:  STA PasswordChar00,X        ;in the proper PasswordChar RAM location.
  2165. L91EC:  LDA PasswordCursor      ;
  2166. L91EF:  CLC             ;
  2167. L91F0:  ADC #$01            ;
  2168. L91F2:  CMP #$18            ;
  2169. L91F4:  BCC +               ;Increment PasswordCursor.  If at last character,-->
  2170. L91F6:  LDA #$00            ;loop back to the first character.
  2171. L91F8:* STA PasswordCursor      ;
  2172.  
  2173. CheckBackspace:
  2174. L91FB:  LDA Joy1Change          ;
  2175. L91FD:  AND #$40            ;If button B (backspace) has not-->
  2176. L91FF:  BEQ ++              ;been pressed, branch.
  2177. L9201:  LDA PasswordCursor      ;
  2178. L9204:  SEC             ;Subtract 1 from PasswordCursor.  If-->
  2179. L9205:  SBC #$01            ;PasswordCursor is negative, load-->
  2180. L9207:  BCS +               ;PasswordCursor with #$17 (last character).
  2181. L9209:  LDA #$17            ;
  2182. L920B:* STA PasswordCursor      ;
  2183. L920E:* LDY PasswordStat00      ;Appears to have no function.
  2184. L9211:  LDA FrameCount          ;
  2185. L9213:  AND #$08            ;If FrameCount bit 3 not set, branch.
  2186. L9215:  BEQ +++             ;
  2187. L9217:  LDA #$3F            ;
  2188. L9219:  LDX PasswordCursor      ;Load A with #$3F if PasswordCursor is on-->
  2189. L921C:  CPX #$0C            ;character 0 thru 11, else load it with #$4F.
  2190. L921E:  BCC +               ;
  2191. L9220:  LDA #$4F            ;
  2192. L9222:* STA Sprite01RAM         ;Set Y-coord of password cursor sprite.
  2193. L9225:  LDA #$6E            ;
  2194. L9227:  STA Sprite01RAM+1       ;Set pattern for password cursor sprite.
  2195. L922A:  LDA #$20            ;
  2196. L922C:  STA Sprite01RAM+2       ;Set attributes for password cursor sprite.
  2197. L922F:  LDA PasswordCursor      ;If the password cursor is at the 12th-->
  2198. L9232:  CMP #$0C            ;character or less, branch.
  2199. L9234:  BCC +               ;
  2200. L9236:  SBC #$0C            ;Calculate how many characters the password cursor-->
  2201. L9238:* TAX                 ;is from the left if on the second row of password.
  2202. L9239:  LDA CursorPosTbl,X      ;Load X position of PasswordCursor.
  2203. L923C:  STA Sprite01RAM+3       ;
  2204. L923F:* LDX InputRow            ;Load X and Y with row and column-->
  2205. L9242:  LDY InputColumn         ;of current character selected.
  2206. L9245:  LDA Joy1Retrig          ;
  2207. L9247:  AND #$0F            ;If no directional buttons are in-->
  2208. L9249:  BEQ ++++++++++          ;retrigger mode, branch.
  2209. L924B:  PHA             ;Temp storage of A.
  2210. L924C:  LDA TriangleSFXFlag     ;Initiate BeepSFX when the player pushes-->
  2211. L924F:  ORA #$08            ;a button on the directional pad.
  2212. L9251:  STA TriangleSFXFlag     ;
  2213. L9254:  PLA             ;Restore A.
  2214. L9255:  LSR             ;Put status of right directional button in carry bit.
  2215. L9256:  BCC +++             ;Branch if right button has not been pressed.
  2216. L9258:  INY             ;
  2217. L9259:  CPY #$0D            ;Increment Y(column).  If Y is greater than #$0C,-->
  2218. L925B:  BNE ++              ;increment X(Row).  If X is greater than #$04,-->
  2219. L925D:  INX                 ;set X to #$00(start back at top row) and store-->
  2220. L925E:  CPX #$05            ;new row in InputRow.
  2221. L9260:  BNE +               ;
  2222. L9262:  LDX #$00            ;
  2223. L9264:* STX InputRow            ;
  2224. L9267:  LDY #$00            ;Store new column in InputColumn.
  2225. L9269:* STY InputColumn         ;
  2226. L926C:* LSR             ;Put status of left directional button in carry bit.
  2227. L926D:  BCC +++             ;Branch if left button has not been pressed.
  2228. L926F:  DEY             ;
  2229. L9270:  BPL ++              ;Decrement Y(column).  If Y is less than #$00,-->
  2230. L9272:  DEX             ;Decrement X(row).  If X is less than #$00,-->
  2231. L9273:  BPL +               ;set X to #$04(last row) and store new row-->
  2232. L9275:  LDX #$04            ;in InputRow.
  2233. L9277:* STX InputRow            ;
  2234. L927A:  LDY #$0C            ;Store new column in InputColumn.
  2235. L927C:* STY InputColumn         ;
  2236. L927F:* LSR             ;Put status of down directional button in carry bit.
  2237. L9280:  BCC ++              ;Branch if down button has not been pressed.
  2238. L9282:  INX             ;
  2239. L9283:  CPX #$05            ;Increment X(row).  if X is greater than #$04,-->
  2240. L9285:  BNE +               ;set X to #$00(first row) and store new-->
  2241. L9287:  LDX #$00            ;row in InputRow.
  2242. L9289:* STX InputRow            ;
  2243. L928C:* LSR             ;Put status of up directional button in carry bit.
  2244. L928D:  BCC ++              ;Branch if up button has not been pressed.
  2245. L928F:  DEX             ;
  2246. L9290:  BPL +               ;Decrement X(row).  if X is less than #$00,-->
  2247. L9292:  LDX #$04            ;set X to #$04(last row) and store new-->
  2248. L9294:* STX InputRow            ;row in InputRow.
  2249. L9297:* LDA FrameCount          ;
  2250. L9299:  AND #$08            ;If FrameCount bit 3 not set, branch.
  2251. L929B:  BEQ +               ;
  2252. L929D:  LDA CharSelectYTbl,X        ;Set Y-coord of character selection sprite.
  2253. L92A0:  STA Sprite02RAM         ;
  2254. L92A3:  LDA #$6E            ;Set pattern for character selection sprite.
  2255. L92A5:  STA Sprite02RAM+1       ;
  2256. L92A8:  LDA #$20            ;Set attributes for character selection sprite.
  2257. L92AA:  STA Sprite02RAM+2       ;
  2258. L92AD:  LDA CharSelectXTbl,Y        ;Set x-Coord of character selection sprite.
  2259. L92B0:  STA Sprite02RAM+3       ;
  2260. L92B3:* RTS             ;
  2261.  
  2262. ;The following data does not appear to be used in the program.
  2263. L92B4:  .byte $21, $20
  2264.  
  2265. ;The following table is used to determine the proper Y position of the character
  2266. ;selection sprite on password entry screen.
  2267.  
  2268. CharSelectYTbl:
  2269. L92B6:  .byte $77, $87, $97, $A7, $B7
  2270.  
  2271. ;The following table is used to determine the proper X position of the character
  2272. ;selection sprite on password entry screen.
  2273.  
  2274. CharSelectXTbl:
  2275. L92BB:  .byte $20, $30, $40, $50, $60, $70, $80, $90, $A0, $B0, $C0, $D0, $E0
  2276.  
  2277. ;When the PasswordCursor is on the second row of the password, the following table is used
  2278. ;to determine the proper x position of the password cursor sprite(password characters 12-23).
  2279.  
  2280. CursorPosTbl:
  2281. L92C8:  .byte $48, $50, $58, $60, $68, $70, $80, $88, $90, $98, $A0, $A8
  2282.  
  2283. InitializeGame:
  2284. L92D4:  JSR ClearRAM_33_DF      ;($C1D4)Clear RAM.
  2285. L92D7:  JSR ClearSamusStats     ;($C578)Reset Samus stats for a new game.
  2286. L92DA:  JSR LoadPasswordData        ;($8D12)Load data from password.
  2287. L92DD:  LDY #$00            ;
  2288. L92DF:  STY SpritePagePos       ;
  2289. L92E1:  STY PageIndex           ;Clear object data.
  2290. L92E3:  STY ObjectCntrl         ;
  2291. L92E5:  STY ObjectHi            ;
  2292. L92E8:  JSR SilenceMusic        ;($CB8E)Turn off music.
  2293. L92EB:  LDA #$5A            ;
  2294. L92ED:  STA AnimFrame           ;Set animframe index. changed by initializing routines.
  2295. L92F0:  LDX #$01            ;x is the index into the position tables below.
  2296. L92F2:  LDA InArea          ;Load starting area.
  2297. L92F4:  AND #$0F            ;
  2298. L92F6:  BNE +               ;If in area other than Brinstar, get second item in tables.
  2299. L92F8:  DEX             ;Starting in Brinstar. Get forst item in each table.
  2300. L92F9:* LDA RestartYPosTbl,X        ;
  2301. L92FC:  STA ObjectY         ;Set Samus restart y position on screen.
  2302. L92FF:  LDA RestartXPosTbl,X        ;
  2303. L9302:  STA ObjectX         ;Set Samus restart x position on screen.
  2304. L9305:  INC SamusStat02         ;The combination of SamusStat02 and 03 keep track of how-->
  2305. L9308:  BNE +               ;many times Samus has died and beaten the game as they are-->
  2306. L930A:  INC SamusStat03         ;incremented every time this routine is run, but they are-->
  2307. L930D:* LDA #$01            ;not accessed anywhere else.
  2308. L930F:  STA MainRoutine         ;Initialize starting area.
  2309. L9311:  JSR ScreenNmiOff        ;($C45D)Turn off screen.
  2310. L9314:  JSR LoadSamusGFX        ;($C5DC)Load Samus GFX into pattern table.
  2311. L9317:  JSR NmiOn           ;($C487)Turn on the non-maskable interrupt.
  2312. L931A:  LDA InArea          ;Load area Samus is to start in.
  2313. L931C:  AND #$0F            ;
  2314. L931E:  TAY             ;
  2315. L931F:  LDA BankTable,Y         ;Change to proper memory page.
  2316. L9322:  STA SwitchPending       ;
  2317. L9324:  RTS
  2318.  
  2319. ;The following two tables are used to find Samus y and x positions on the screen after the game
  2320. ;restarts.  The third entry in each table are not used.
  2321.  
  2322. RestartYPosTbl:
  2323. L9325:  .byte $64           ;Brinstar
  2324. L9326:  .byte $8C           ;All other areas.
  2325. L9327:  .byte $5C           ;Not used.
  2326.  
  2327. RestartXPosTbl:
  2328. L9328:  .byte $78           ;Brinstar
  2329. L9329:  .byte $78           ;All other areas.
  2330. L932A:  .byte $5C           ;Not used.
  2331.  
  2332. InitializeStats:
  2333. L932B:  LDA #$00            ;
  2334. L932D:  STA SamusStat00         ;
  2335. L9330:  STA TankCount           ;
  2336. L9333:  STA SamusGear           ;
  2337. L9336:  STA MissileCount        ;
  2338. L9339:  STA MaxMissiles         ;
  2339. L933C:  STA KraidStatueStatus       ;Set all of Samus' stats to 0 when starting new game.
  2340. L933F:  STA RidleyStatueStatus      ;
  2341. L9342:  STA SamusAge            ;
  2342. L9345:  STA SamusAge+1          ;
  2343. L9348:  STA SamusAge+2          ;
  2344. L934B:  STA SamusStat01         ;
  2345. L934E:  STA AtEnding            ;
  2346. L9351:  STA JustInBailey        ;
  2347. L9354:  LDA #$02            ;
  2348. L9356:  STA SwitchPending       ;Prepare to switch to Brinstar memory page.
  2349. L9358:  RTS             ;
  2350.  
  2351. DisplayPassword:
  2352. L9359:  LDA Timer3          ;Wait for "GAME OVER" to be displayed-->
  2353. L935B:  BNE $9324           ;for 160 frames (2.6 seconds).
  2354. L935D:  JSR ClearAll            ;($909F)Turn off screen, erase sprites and nametables.
  2355. L9360:  LDX #$7F            ;Low byte of start of PPU data.
  2356. L9362:  LDY #$93            ;High byte of start of PPU data.
  2357. L9364:  JSR PreparePPUProcess       ;($9449)Clears screen and writes "PASS WORD".
  2358. L9367:  JSR InitGFX7            ;($C6D6)Loads the font for the password.
  2359. L936A:  JSR CalculatePassword       ;($8C7A)Calculates the password.
  2360. L936D:  JSR NmiOn           ;($C487)Turn on the nonmaskable interrupt.
  2361. L9370:  JSR PasswordToScreen        ;($93C6)Displays password on screen.
  2362. L9373:  JSR WaitNMIPass         ;($C42C)Wait for NMI to end.
  2363. L9376:  LDA #$13            ;
  2364. L9378:  STA PalDataPending      ;Change palette.
  2365. L937A:  INC TitleRoutine        ;
  2366. L937C:  JMP ScreenOn            ;($C447)Turn screen on.
  2367.  
  2368. ;Information below is for above routine to display "PASS WORD" on the screen.
  2369. L937F:  .byte $21           ;PPU memory high byte.
  2370. L9380:  .byte $4B           ;PPU memory low byte.
  2371. L9381:  .byte $09           ;PPU string length.
  2372. ;             'P    A    S    S    _    W    O    R    D'
  2373. L9382:  .byte $19, $0A, $1C, $1C, $FF, $20, $18, $1B, $0D
  2374.  
  2375. ;Information to be stored in attribute table 0.
  2376. L938B:  .byte $23           ;PPU memory high byte.
  2377. L938C:  .byte $D0           ;PPU memory low byte.
  2378. L938D:  .byte $48           ;RLE bit set, repeat entry 8 times.
  2379. L938E:  .byte $00           ;Clears line below "PASS WORD".
  2380.  
  2381. L938F:  .byte $23           ;PPU memory high byte.
  2382. L9390:  .byte $D8           ;PPU memory low byte.
  2383. L9391:  .byte $60           ;RLE bit set, repeat entry 32 times.
  2384. L9392:  .byte $55           ;Turn color on to display password characters.
  2385.  
  2386. L9393:  .byte $00           ;End PPU string write.
  2387.  
  2388. WaitForSTART:
  2389. L9394:  LDA Joy1Change          ;Waits for START to be ressed proceed-->
  2390. L9396:  AND #$10            ;past the GAME OVER screen.
  2391. L9398:  BEQ +               ;If start not pressed, branch.
  2392. L939A:  JMP CheckPassword       ;($8C5E)Check if password is correct.
  2393. L939D:* RTS             ;
  2394.  
  2395. GameOver:
  2396. L939E:  JSR ClearAll            ;($909F)Turn off screen, erase sprites and nametables.
  2397. L93A1:  LDX #$B9            ;Low byte of start of PPU data.
  2398. L93A3:  LDY #$93            ;High byte of start of PPU data.
  2399. L93A5:  JSR PreparePPUProcess       ;($9449)Clears screen and writes "GAME OVER".
  2400. L93A8:  JSR InitGFX7            ;($C6D6)Loads the font for the password.
  2401. L93AB:  JSR NmiOn           ;($C487)Turn on the nonmaskable interrupt.
  2402. L93AE:  LDA #$10            ;Load Timer3 with a delay of 160 frames-->
  2403. L93B0:  STA Timer3          ;(2.6 seconds) for displaying "GAME OVER".
  2404. L93B2:  LDA #$19            ;Loads TitleRoutine with -->
  2405. L93B4:  STA TitleRoutine        ;DisplayPassword.
  2406. L93B6:  JMP ScreenOn            ;($C447)Turn screen on.
  2407.  
  2408. ;Information below is for above routine to display "GAME OVER" on the screen.
  2409. L93B9:  .byte $21           ;PPU memory high byte.
  2410. L93BA:  .byte $8C           ;PPU memory low byte.
  2411. L93BB:  .byte $09           ;PPU string length.
  2412. ;             'G    A    M    E    _    O    V    E    R'
  2413. L93BC:  .byte $10, $0A, $16, $0E, $FF, $18, $1F, $0E, $1B
  2414.  
  2415. L93C4:  .byte $00           ;End PPU string write.
  2416.  
  2417. PasswordToScreen:
  2418. L93C6:  JSR WaitNMIPass         ;($C42C)Wait for NMI to end.
  2419. L93C9:  LDY #$05            ;Index to find password characters(base=$699A).
  2420. L93CB:  JSR LoadPasswordTiles       ;($93F9)Load tiles on screen.
  2421. L93CE:  LDX #$A9            ;PPU low address byte.
  2422. L93D0:  LDY #$21            ;PPU high address byte.
  2423. L93D2:  JSR PrepareEraseTiles       ;($9450)Erase tiles on screen.
  2424. L93D5:  LDY #$0B            ;Index to find password characters(base=$699A).
  2425. L93D7:  JSR LoadPasswordTiles       ;($93F9)Load tiles on screen.
  2426. L93DA:  LDX #$B0            ;PPU low address byte.
  2427. L93DC:  LDY #$21            ;PPU high address byte.
  2428. L93DE:  JSR PrepareEraseTiles       ;($9450)Erase tiles on screen.
  2429. L93E1:  LDY #$11            ;Index to find password characters(base=$699A).
  2430. L93E3:  JSR LoadPasswordTiles       ;($93F9)Load tiles on screen.
  2431. L93E6:  LDX #$E9            ;PPU low address byte.
  2432. L93E8:  LDY #$21            ;PPU high address byte.
  2433. L93EA:  JSR PrepareEraseTiles       ;($9450)Erase tiles on screen.
  2434. L93ED:  LDY #$17            ;Index to find password characters(base=$699A).
  2435. L93EF:  JSR LoadPasswordTiles       ;($93F9)Load tiles on screen.
  2436. L93F2:  LDX #$F0            ;PPU low address byte.
  2437. L93F4:  LDY #$21            ;PPU high address byte.
  2438. L93F6:  JMP PrepareEraseTiles       ;($9450)Erase tiles on screen.
  2439.  
  2440. LoadPasswordTiles:
  2441. L93F9:  LDA #$16            ;Tiles to replace are one block-->
  2442. L93FB:  STA TileSize            ;high and 6 blocks long.
  2443. L93FE:  LDX #$05            ;
  2444. L9400:* LDA PasswordChar00,Y        ;
  2445. L9403:  STA TileInfo0,X         ;
  2446. L9406:  DEY             ;Transfer password characters to-->
  2447. L9407:  DEX             ;TileInfo addresses.
  2448. L9408:  BPL-                ;
  2449. L940A:  RTS             ;
  2450.  
  2451. DisplayInputCharacters:
  2452. L940B:  LDA PPUStatus           ;Clear address latches.
  2453. L940E:  LDY #$00            ;
  2454. L9410:  TYA                 ;Initially sets $00 an $01.
  2455. L9411:  STA $00             ;to #$00.
  2456. L9413:  STA $01             ;Also, initialy sets x and y to #$00.
  2457. L9415:* ASL             ;
  2458. L9416:  TAX             ;
  2459. L9417:  LDA PasswordRowsTbl,X       ;
  2460. L941A:  STA PPUAddress          ;
  2461. L941D:  LDA PasswordRowsTbl+1,X     ;Displays the list of characters -->
  2462. L9420:  sTA PPUAddress          ;to choose from on the password-->
  2463. L9423:  LDX #$00            ;entry screen.
  2464. L9425:* LDA PasswordRow0,Y      ;Base is $99A2.
  2465. L9428:  STA PPUIOReg            ;
  2466. L942B:  LDA #$FF            ;Blank tile.
  2467. L942D:  STA PPUIOReg            ;
  2468. L9430:  INY             ;
  2469. L9431:  INX             ;
  2470. L9432:  CPX #$0D            ;13 characters in current row?
  2471. L9434:  BNE -               ;if not, add another character.
  2472. L9436:  INC $01             ;
  2473. L9438:  LDA $01             ;
  2474. L943A:  CMP #$05            ;5 rows?
  2475. L943C:  BNE --              ;If not, go to next row.
  2476. L943E:  RTS             ;
  2477.  
  2478. ;The table below is used by the code above to determine the positions
  2479. ;of the five character rows on the password entry screen.
  2480.  
  2481. PasswordRowsTbl:
  2482. L943F:  .byte $21, $E4          ;
  2483. L9441:  .byte $22, $24          ;The two entries in each row are the upper and lower address-->
  2484. L9443:  .byte $22, $64          ;bytes to start writing to the name table, respectively.
  2485. L9445:  .byte $22, $A4          ;
  2486. L9447:  .byte $22, $E4          ;
  2487.  
  2488.  
  2489. PreparePPUProcess:
  2490. L9449:  stx $00             ;Lower byte of pointer to PPU string
  2491. L944B:  sty $01             ;Upper byte of pointer to PPU string
  2492. L944D:  jmp ProcessPPUString        ;($C30C)
  2493.  
  2494. PrepareEraseTiles:
  2495. L9450:  STX $00             ;PPU low address byte
  2496. L9452:  STY $01             ;PPU high address byte
  2497. L9454:  LDX #$80            ;
  2498. L9456:  LDY #$07            ;
  2499. L9458:  STX $02             ;Address of byte where tile size-->  
  2500. L945A:  STY $03             ;of tile to be erased is stored.
  2501. L945C:  JMP EraseTile           ;($C328)Erase the selected tiles.
  2502.  
  2503. ;---------------------------------------[ Unused intro routines ]------------------------------------
  2504.  
  2505. ;The following routines are intro routines that are not used in this version of the game.  It
  2506. ;appears that the intro routine was originally going to be more complex with a more advanced
  2507. ;sprite control mechanism and name table writing routines. The intro routines are a mess! In
  2508. ;addition to unused routines, there are several unused memory addresses that are written to but
  2509. ;never read.
  2510.  
  2511. UnusedIntroRoutine4:
  2512. L945F:  STX PPUStrIndex         ;
  2513. L9462:  LDA #$00            ;
  2514. L9464:  STA PPUDataString,X     ;The following unused routine writes something to the-->
  2515. L9467:  LDA #$01            ;PPU string and prepares for a PPU write.
  2516. L9469:  STA PPUDataPending      ;
  2517. L946B:  RTS             ;
  2518.  
  2519. UnusedIntroRoutine5:
  2520. L946C:  STA $05             ;
  2521. L946E:  AND #$F0            ;
  2522. L9470:  LSR             ;
  2523. L9471:  LSR             ;
  2524. L9472:  LSR             ;
  2525. L9473:  LSR             ;
  2526. L9474:  JSR +               ;
  2527. L9477:  LDA $05             ;Unused intro routine. It looks like originally the-->
  2528. L9479:  AND #$0F            ;title routines were going to write data to the name-->
  2529. L947B:* STA PPUDataString,X     ;tables in the middle of the title sequences.
  2530. L947E:  INX             ;
  2531. L947F:  TXA             ;
  2532. L9480:  CMP #$55            ;
  2533. L9482:  BCC ++              ;
  2534. L9484:  LDX PPUStrIndex         ;
  2535. L9487:* LDA #$00            ;
  2536. L9489:  STA PPUDataString,X     ;
  2537. L948C:  BEQ -               ;
  2538. L948E:* RTS             ;
  2539.  
  2540. UnusedIntroRoutine6:
  2541. L948F:  TYA             ;
  2542. L9490:  PHA             ;
  2543. L9491:  JSR Amul16          ;($C2C5)Multiply by 16.
  2544. L9494:  TAY             ;
  2545. L9495:  LDA $684B,Y         ;
  2546. L9498:  STA $0B             ;
  2547. L949A:  LDA $684A,Y         ;
  2548. L949D:  STA $0A             ;
  2549. L949F:  JSR UnusedIntroRoutine8     ;($94DA)
  2550. L94A2:  LDA $06             ;
  2551. L94A4:  STA $683D,X         ;Another unused intro routine.
  2552. L94A7:  LDA $07             ;
  2553. L94A9:  STA $683C,X         ;
  2554. L94AC:  PLA             ;
  2555. L94AD:  TAY             ;
  2556. L94AE:  RTS             ;
  2557.  
  2558. UnusedIntroRoutine7:
  2559. L94AF:  TYA             ;
  2560. L94B0:  PHA             ;
  2561. L94B1:  JSR Amul16          ;($C2C5)Multiply by 16.
  2562. L94B4:  TAY             ;
  2563. L94B5:  LDA $684D,Y         ;
  2564. L94B8:  STA $0B             ;
  2565. L94BA:  LDA $684C,Y         ;
  2566. L94BD:  STA $0A             ;
  2567. L94BF:  JSR UnusedIntroRoutine8     ;($94DA)
  2568. L94C2:  LDA $06             ;
  2569. L94C4:  STA $6834,X         ;
  2570. L94C7:  LDA $07             ;
  2571. L94C9:  STA $6833,X         ;
  2572. L94CC:  LDA $6842,Y         ;Another unused intro routine.
  2573. L94CF:  PHA             ;
  2574. L94D0:  TXA             ;
  2575. L94D1:  LSR             ;
  2576. L94D2:  TAY             ;
  2577. L94D3:  PLA             ;
  2578. L94D4:  STA $6839,Y         ;
  2579. L94D7:  PLA             ;
  2580. L94D8:  TAY             ;
  2581. L94D9:  RTS             ;
  2582.  
  2583. UnusedIntroRoutine8:
  2584. L94DA:  LDA #$FF            ;
  2585. L94DC:  STA $01             ;
  2586. L94DE:  STA $02             ;
  2587. L94E0:  STA $03             ;
  2588. L94E2:  SEC             ;
  2589. L94E3:* LDA $0A             ;
  2590. L94E5:  SBC #$E8            ;
  2591. L94E7:  STA $0A             ;
  2592. L94E9:  LDA $0B             ;
  2593. L94EB:  SBC #$03            ;
  2594. L94ED:  STA $0B             ;
  2595. L94EF:  INC $03             ;
  2596. L94F1:  BCS -               ;
  2597. L94F3:  LDA $0A             ;
  2598. L94F5:  ADC #$E8            ;
  2599. L94F7:  STA $0A             ;
  2600. L94F9:  LDA $0B             ;
  2601. L94FB:  ADC #$03            ;
  2602. L94FD:  STA $0B             ;
  2603. L94FF:  LDA $0A             ;
  2604. L9501:* SEC             ;Unused intro routine. Looks like the intro routines may-->
  2605. L9502:* SBC #$64            ;have had more complicated sprite control routines-->
  2606. L9504:  INC $02             ;that it does now.
  2607. L9506:  BCS -               ;
  2608. L9508:  DEC $0B             ;
  2609. L950A:  BPL --              ;
  2610. L950C:  ADC #$64            ;
  2611. L950E:  SEC             ;
  2612. L950F:* SBC #$0A            ;
  2613. L9511:  INC $01             ;
  2614. L9513:  BCS -               ;
  2615. L9515:  ADC #$0A            ;
  2616. L9517:  STA $06             ;
  2617. L9519:  LDA $01             ;
  2618. L951B:  JSR Amul16          ;($C2C5)Multiply by 16.
  2619. L951E:  ORA $06             ;
  2620. L9520:  STA $06             ;
  2621. L9522:  LDA $03             ;
  2622. L9524:  JSR Amul16          ;($C2C5)Multiply by 16.
  2623. L9527:  ORA $02             ;
  2624. L9529:  STA $07             ;
  2625. L952B:  RTS             ;
  2626.  
  2627. ;Not used.
  2628. L952C:  .byte $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00, $00, $00, $00, $FF, $FF, $FF, $FF
  2629. L953C:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00, $00, $00, $00
  2630. L954C:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  2631. L955C:  .byte $00, $00, $00, $00
  2632.  
  2633. ;--------------------------------------[ Palette data ]---------------------------------------------
  2634.  
  2635. ;The following table points to the palette data
  2636. ;used in the intro and ending portions of the game.
  2637.  
  2638. PaletteColorsPointerTable:
  2639. L9560:  .word Palette00         ;($9586)
  2640. L9562:  .word Palette01         ;($95AA)
  2641. L9564:  .word Palette02         ;($95CE)
  2642. L9566:  .word Palette03         ;($95F2)
  2643. L9568:  .word Palette04         ;($9616)
  2644. L956A:  .word Palette05         ;($963A)
  2645. L956C:  .word Palette06         ;($965E)
  2646. L956E:  .word Palette07         ;($9682)
  2647. L9570:  .word Palette08         ;($96A6)
  2648. L9572:  .word Palette09         ;($96CA)
  2649. L9574:  .word Palette0A         ;($96EE)
  2650. L9576:  .word Palette0B         ;($9712)
  2651. L9578:  .word Palette0C         ;($9736)
  2652. L957A:  .word Palette0D         ;($975A)
  2653. L957C:  .word Palette0E         ;($977E)
  2654. L957E:  .word Palette0F         ;($97A2)
  2655. L9580:  .word Palette10         ;($97C6)
  2656. L9582:  .word Palette11         ;($97EA)
  2657. L9584:  .word Palette12         ;($97F2)
  2658.  
  2659. Palette00:
  2660. L9586:  .byte $3F           ;Upper byte of PPU palette adress.
  2661. L9587:  .byte $00           ;Lower byte of PPU palette adress.
  2662. L9588:  .byte $20           ;Palette data length.
  2663. ;The following values are written to the background palette:
  2664. L9589:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $0F, $0F, $0F, $0F, $0F, $0F, $0F
  2665. ;The following values are written to the sprite palette:
  2666. L9599:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2667.  
  2668. L95A9:  .byte $00           ;End Palette01 info.
  2669.  
  2670. Palette01:
  2671. L95AA:  .byte $3F           ;Upper byte of PPU palette adress.
  2672. L95AB:  .byte $00           ;Lower byte of PPU palette adress.
  2673. L96AC:  .byte $20           ;Palette data length.
  2674. ;The following values are written to the background palette:
  2675. L95AD:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $35, $35, $04, $0F, $35, $14, $04
  2676. ;The following values are written to the sprite palette:
  2677. L95BD:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2678.  
  2679. L95CD:  .byte $00           ;End Palette02 info.
  2680.  
  2681. Palette02:
  2682. L95CE:  .byte $3F           ;Upper byte of PPU palette adress.
  2683. L95CF:  .byte $00           ;Lower byte of PPU palette adress.
  2684. L95D0:  .byte $20           ;Palette data length.
  2685. ;The following values are written to the background palette:
  2686. L95D1:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $39, $39, $09, $0F, $39, $29, $09
  2687. ;The following values are written to the sprite palette:
  2688. L95E1:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2689.  
  2690. L95F1:  .byte $00           ;End Palette03 info.
  2691.  
  2692. Palette03:
  2693. L95F2:  .byte $3F           ;Upper byte of PPU palette adress.
  2694. L95F3:  .byte $00           ;Lower byte of PPU palette adress.
  2695. L95F4:  .byte $20           ;Palette data length.
  2696. ;The following values are written to the background palette:
  2697. L95F5:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $36, $36, $06, $0F, $36, $15, $06
  2698. ;The following values are written to the sprite palette:
  2699. L9605:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2700.  
  2701. L9615:  .byte $00           ;End Palette04 info.
  2702.  
  2703. Palette04:
  2704. L9616:  .byte $3F           ;Upper byte of PPU palette adress.
  2705. L9617:  .byte $00           ;Lower byte of PPU palette adress.
  2706. L9618:  .byte $20           ;Palette data length.
  2707. ;The following values are written to the background palette:
  2708. L9619:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $27, $27, $12, $0F, $27, $21, $12
  2709. ;The following values are written to the sprite palette:
  2710. L9629:  .byte $0F, $16, $1A, $27, $0F, $31, $20, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2711.  
  2712. L9639:  .byte $00           ;End Palette05 info.
  2713.  
  2714. Palette05:
  2715. L963A:  .byte $3F           ;Upper byte of PPU palette adress.
  2716. L963B:  .byte $00           ;Lower byte of PPU palette adress.
  2717. L963C:  .byte $20           ;Palette data length.
  2718. ;The following values are written to the background palette:
  2719. L963D:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $01, $01, $0F, $0F, $01, $0F, $0F
  2720. ;The following values are written to the sprite palette:
  2721. L964D:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2722.  
  2723. L965D:  .byte $00           ;End Palette06 info.
  2724.  
  2725. Palette06:
  2726. L965E:  .byte $3F           ;Upper byte of PPU palette adress.
  2727. L965F:  .byte $00           ;Lower byte of PPU palette adress.
  2728. L9660:  .byte $20           ;Palette data length.
  2729. ;The following values are written to the background palette:
  2730. L9661:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $01, $01, $0F, $0F, $01, $01, $0F
  2731. ;The following values are written to the sprite palette:
  2732. L9671:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2733.  
  2734. L9681:  .byte $00           ;End Palette07 info.
  2735.  
  2736. Palette07:
  2737. L9682:  .byte $3F           ;Upper byte of PPU palette adress.
  2738. L9683:  .byte $00           ;Lower byte of PPU palette adress.
  2739. L9684:  .byte $20           ;Palette data length.
  2740. ;The following values are written to the background palette:
  2741. L9685:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $02, $02, $01, $0F, $02, $02, $01
  2742. ;The following values are written to the sprite palette:
  2743. L9695:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2744.  
  2745. L96A5:  .byte $00           ;End Palette08 info.
  2746.  
  2747. Palette08:
  2748. L96A6:  .byte $3F           ;Upper byte of PPU palette adress.
  2749. L96A7:  .byte $00           ;Lower byte of PPU palette adress.
  2750. L96A8:  .byte $20           ;Palette data length.
  2751. ;The following values are written to the background palette:
  2752. L96A9:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $02, $02, $01, $0F, $02, $01, $01
  2753. ;The following values are written to the sprite palette:
  2754. L96B9:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2755.  
  2756. L96C9:  .byte $00           ;End Palette09 info.
  2757.  
  2758. Palette09:
  2759. L96CA:  .byte $3F           ;Upper byte of PPU palette adress.
  2760. L96CB:  .byte $00           ;Lower byte of PPU palette adress.
  2761. L96CC:  .byte $20           ;Palette data length.
  2762. ;The following values are written to the background palette:
  2763. L96CD:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $12, $12, $02, $0F, $12, $12, $02
  2764. ;The following values are written to the sprite palette:
  2765. L96DD:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2766.  
  2767. L96ED:  .byte $00           ;End Palette0A info.
  2768.  
  2769. Palette0A:
  2770. L96EE:  .byte $3F           ;Upper byte of PPU palette adress.
  2771. L96EF:  .byte $00           ;Lower byte of PPU palette adress.
  2772. L96F0:  .byte $20           ;Palette data length.
  2773. ;The following values are written to the background palette:
  2774. L96F1:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $11, $11, $02, $0F, $11, $02, $02
  2775. ;The following values are written to the sprite palette:
  2776. L9701:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2777.  
  2778. L9711:  .byte $00           ;End Palette0B info.
  2779.  
  2780. Palette0B:
  2781. L9712:  .byte $3F           ;Upper byte of PPU palette adress.
  2782. L9713:  .byte $00           ;Lower byte of PPU palette adress.
  2783. L9714:  .byte $20           ;Palette data length.
  2784. ;The following values are written to the background palette:
  2785. L9715:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $31, $31, $01, $0F, $31, $11, $01
  2786. ;The following values are written to the sprite palette:
  2787. L9716:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2788.  
  2789. L9735:  .byte $00           ;End Palette0C info.
  2790.  
  2791. Palette0C:
  2792. L9736:  .byte $3F           ;Upper byte of PPU palette adress.
  2793. L9737:  .byte $00           ;Lower byte of PPU palette adress.
  2794. L9738:  .byte $20           ;Palette data length.
  2795. ;The following values are written to the background palette:
  2796. L9739:  .byte $0F, $28, $18, $08, $0F, $12, $30, $21, $0F, $27, $28, $29, $0F, $31, $31, $01
  2797. ;The following values are written to the sprite palette:
  2798. L9749:  .byte $0F, $16, $2A, $27, $0F, $12, $30, $21, $0F, $27, $24, $2C, $0F, $15, $21, $38
  2799.  
  2800. L9759:  .byte $00           ;End Palette0D info.
  2801.  
  2802. Palette0D:
  2803. L975A:  .byte $3F           ;Upper byte of PPU palette adress.
  2804. L975B:  .byte $00           ;Lower byte of PPU palette adress.
  2805. L975C:  .byte $20           ;Palette data length.
  2806. ;The following values are written to the background palette:
  2807. L975D:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $12, $12, $01, $0F, $12, $02, $01
  2808. ;The following values are written to the sprite palette:
  2809. L975E:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2810.  
  2811. L977D:  .byte $00           ;End Palette0E info.
  2812.  
  2813. Palette0E:
  2814. L977E:  .byte $3F           ;Upper byte of PPU palette adress.
  2815. L977F:  .byte $00           ;Lower byte of PPU palette adress.
  2816. L9780:  .byte $20           ;Palette data length.
  2817. ;The following values are written to the background palette:
  2818. L9781:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $02, $02, $0F, $0F, $02, $01, $0F
  2819. ;The following values are written to the sprite palette:
  2820. L9791:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2821.  
  2822. L97A1:  .byte $00           ;End Palette0F info.
  2823.  
  2824. Palette0F:
  2825. L97A2:  .byte $3F           ;Upper byte of PPU palette adress.
  2826. L97A3:  .byte $00           ;Lower byte of PPU palette adress.
  2827. L97A4:  .byte $20           ;Palette data length.
  2828. ;The following values are written to the background palette:
  2829. L97A5:  .byte $0F, $28, $18, $08, $0F, $29, $1B, $1A, $0F, $01, $01, $0F, $0F, $01, $0F, $0F
  2830. ;The following values are written to the sprite palette:
  2831. L97B5:  .byte $0F, $16, $1A, $27, $0F, $37, $3A, $1B, $0F, $17, $31, $37, $0F, $32, $22, $12
  2832.  
  2833. L97C5:  .byte $00           ;End Palette10 info.
  2834.  
  2835. Palette10:
  2836. L97C6:  .byte $3F           ;Upper byte of PPU palette adress.
  2837. L97C7:  .byte $00           ;Lower byte of PPU palette adress.
  2838. L97C8:  .byte $20           ;Palette data length.
  2839. ;The following values are written to the background palette:
  2840. L97C9:  .byte $30, $28, $18, $08, $30, $29, $1B, $1A, $30, $30, $30, $30, $30, $30, $30, $30
  2841. ;The following values are written to the sprite palette:
  2842. L97D9:  .byte $30, $16, $1A, $27, $30, $37, $3A, $1B, $30, $17, $31, $37, $30, $32, $22, $12
  2843.  
  2844. L97E9:  .byte $00           ;End Palette11 info.
  2845.  
  2846. Palette11:
  2847. L97EA:  .byte $3F           ;Upper byte of PPU palette adress.
  2848. L97EB:  .byte $00           ;Lower byte of PPU palette adress.
  2849. L97EC:  .byte $04           ;Palette data length.
  2850. ;The following values are written to the background palette:
  2851. L97ED:  .byte $0F, $30, $30, $21
  2852.  
  2853. L98F1:  .byte $00           ;End Palette12 info.
  2854.  
  2855. Palette12:
  2856. L97F2:  .byte $3F           ;Upper byte of PPU palette adress.
  2857. L97F3:  .byte $00           ;Lower byte of PPU palette adress.
  2858. L97F4:  .byte $10           ;Palette data length.
  2859. ;The following values are written to the background palette:
  2860. L97F5:  .byte $0F, $30, $30, $0F, $0F, $2A, $2A, $21, $0F, $31, $31, $0F, $0F, $2A, $2A, $21
  2861.  
  2862. L9805:  .byte $00           ;End Palette13 data.
  2863.  
  2864. EndGamePal0B:
  2865. L9806:  .byte $3F           ;Upper byte of PPU palette adress.
  2866. L9807:  .byte $00           ;Lower byte of PPU palette adress.
  2867. L9808:  .byte $10           ;Palette data length.
  2868. ;The following values are written to the background palette:
  2869. L9809:  .byte $0F, $2C, $2C, $2C, $0F, $2C, $2C, $2C, $0F, $2C, $2C, $2C, $0F, $2C, $2C, $2C
  2870.  
  2871. EndGamePal0C:
  2872. L9819:  .byte $3F           ;Upper byte of PPU palette adress.
  2873. L981A:  .byte $10           ;Lower byte of PPU palette adress.
  2874. L981B:  .byte $50           ;Palette data length.
  2875. L981C:  .byte $0F           ;Repeat bit set. Fill sprite palette with #$0F.
  2876.  
  2877. L981D:  .byte $00           ;End EndGamePal0C data.
  2878.  
  2879. UpdateSpriteCoords:
  2880. L981E:  LDA IntroSpr0XRun,X     ;Load sprite run(sprite x component).
  2881. L9821:  JSR CalcDisplacement        ;($9871)Calculate sprite displacement in x direction.
  2882. L9824:  LDY IntroSpr0XDir,X     ;Get byte describing if sprite increasing or decreasing pos.
  2883. L9827:  BPL +               ;
  2884.  
  2885. L9829:  EOR #$FF            ;If MSB is set, sprite is decreasing position. convert-->
  2886. L982B:  CLC             ;value in A (result from CalcDisplacement) to twos compliment.
  2887. L982C:  ADC #$01            ;
  2888.  
  2889. L982E:* CLC             ;
  2890. L982F:  ADC IntroSpr0XCoord,X       ;Add change to sprite x coord.
  2891. L9832:  STA IntroSpr0XCoord,X       ;
  2892. L9835:  SEC             ;
  2893. L9836:  SBC IntroSpr0XChange,X      ;Subtract total sprite movemnt value from current sprite x pos.
  2894. L9839:  PHP             ;Transfer processor status to A.
  2895. L983A:  PLA             ;
  2896. L983B:  EOR IntroSpr0XDir,X     ;Eor carry bit with direction byte to see if sprite has-->   
  2897. L983E:  LSR             ;reached its end point.
  2898. L983F:  BCC++               ;Branch if sprite has reached the end of x movement.
  2899.  
  2900. L9841:  LDA IntroSpr0YRise,X        ;Load sprite rise(sprite y component).
  2901. L9844:  JSR CalcDisplacement        ;($9871)Calculate sprite displacement in y direction.
  2902. L9847:  LDY IntroSpr0YDir,X     ;Get byte describing if sprite increasing or decreasing pos.
  2903. L984A:  BPL +               ;
  2904.  
  2905. L984C:  EOR #$FF            ;If MSB is set, sprite is decreasing position. convert-->
  2906. L984E:  CLC             ;value in A (result from CalcDisplacement) to twos compliment.
  2907. L984F:  ADC #$01            ;
  2908.  
  2909. L9851:* CLC             ;
  2910. L9852:  ADC IntroSpr0YCoord,X       ;Add change to sprite y coord.
  2911. L9855:  STA IntroSpr0YCoord,X       ;
  2912. L9858:  SEC             ;
  2913. L9859:  SBC IntroSpr0YChange,X      ;Subtract total sprite movemnt value from current sprite y pos.
  2914. L985C:  PHP             ;Transfer processor status to A.
  2915. L985D:  PLA             ;
  2916. L985E:  EOR IntroSpr0YDir,X     ;Eor carry bit with direction byte to see if sprite has-->
  2917. L9861:  LSR             ;reached its end point.
  2918. L9862:  BCS ++              ;Branch if sprite has not reached the end of y movement.
  2919.  
  2920. L9864:* LDA IntroSpr0YChange,X      ;After sprite has reached its final position, this code-->
  2921. L9867:  STA IntroSpr0YCoord,X       ;explicitly writes final the x and y coords to to sprite-->
  2922. L986A:  LDA IntroSpr0XChange,X      ;position addresses to make sure the sprites don't-->
  2923. L986D:  STA IntroSpr0XCoord,X       ;overshoot their mark.
  2924. L9870:* RTS             ;
  2925.  
  2926. CalcDisplacement:
  2927. L9871:  STA $04             ;
  2928. L9873:  LDA #$08            ;Time division. The higher the number, the slower the sprite.
  2929. L9875:  STA $00             ;
  2930. L9877:* LSR $04             ;
  2931. L9879:  BCC +               ;
  2932. L987B:  LDA FrameCount          ;
  2933. L987D:  AND $00             ;Calculate the change in the sprite position by taking the-->
  2934. L987F:  BNE +               ;value in a and dividing it by the time division. The time-->
  2935. L9881:  INC $04             ;time division in this case is #$08.
  2936. L9883:* LSR $00             ;
  2937. L9885:  BNE --              ;
  2938. L9887:  LDA $04             ;
  2939. L9889:  RTS             ;Return A/time.
  2940.  
  2941. ;This function decrements the y coordinate of the 40 intro star sprites.
  2942.  
  2943. DecSpriteYCoord:
  2944. L988A:  LDA TitleRoutine        ;
  2945. L988C:  CMP #$1D            ;
  2946. L988E:  BCS ++              ;If the end game is playing, branch to exit.
  2947. L9890:  LDA SpriteLoadPending       ;      
  2948. L9892:  BEQ ++              ;If no sprite load is pending, branch to exit.
  2949. L9894:  LDA FrameCount          ;
  2950. L9896:  LSR             ;
  2951. L9897:  BCS ++              ;If not on an odd numbered frame, branch to exit.
  2952. L9899:  LDX #$9F            ;
  2953. L989B:* DEC IntroStarSprite00,X     ;Decrement y coord of the intro star sprites.
  2954. L989E:  DEC Sprite18RAM,X       ;Decrement y coord of 40 sprites.
  2955. L98A1:  DEX             ;
  2956. L98A2:  DEX             ;
  2957. L98A3:  DEX             ;Move to next sprite.
  2958. L98A4:  DEX             ;
  2959. L98A5:  CPX #$FF            ;
  2960. L98A7:  BNE -               ;Loop 40 times.
  2961. L98A9:  LDA #$00            ;
  2962. L98AB:  STA SpriteLoadPending       ;Sprite RAM load complete.
  2963. L98AD:* RTS             ;
  2964.  
  2965. LoadStarSprites:
  2966. L98AE:  LDY #$9F            ;
  2967. L98B0:* LDA IntroStarSprite00,Y     ;
  2968. L98B3:  STA Sprite18RAM,Y       ;Store RAM contents of $6E00 thru $6E9F -->
  2969. L98B6:  DEY                 ;in sprite RAM at locations $0260 thru $02FF.
  2970. L98B7:  CPY #$FF            ;
  2971. L98B9:  BNE -               ;
  2972. L98BB:  LDA #$00            ;              
  2973. L98BD:  STA SpriteLoadPending       ;Set $C8 to #$00.
  2974. L98BF:  RTS                 ;
  2975.  
  2976. ;The following values are loaded into RAM $6E00 thru $6E9F in InitBank0
  2977. ;routine.  These values are then loaded into sprite RAM at $0260 thru $02FF
  2978. ;in above routine.  They are the stars in the title screen.
  2979.  
  2980. IntroStarsData:
  2981. L98C0:  .byte $73, $CC, $22, $F2, $48, $CD, $63, $EE, $2A, $CE, $A2, $DC, $36, $CF, $E2, $C6
  2982. L98D0:  .byte $11, $CC, $23, $B7, $53, $CD, $63, $A0, $BB, $CE, $A2, $9A, $0F, $CF, $E2, $8B
  2983. L98E0:  .byte $85, $CC, $E2, $70, $9D, $CD, $A3, $6B, $A0, $CE, $63, $58, $63, $CF, $23, $4F
  2984. L98F0:  .byte $0A, $CC, $22, $39, $1F, $CD, $23, $2A, $7F, $CE, $A3, $1F, $56, $CF, $A2, $03
  2985. L9900:  .byte $4D, $CC, $E3, $AF, $3E, $CD, $63, $2B, $61, $CE, $E2, $4F, $29, $CF, $62, $6F
  2986. L9910:  .byte $8A, $CC, $23, $82, $98, $CD, $A3, $07, $AE, $CE, $E2, $CA, $B6, $CF, $63, $E3
  2987. L9920:  .byte $0F, $CC, $62, $18, $1F, $CD, $22, $38, $22, $CE, $A3, $5F, $53, $CF, $E2, $78
  2988. L9930:  .byte $48, $CC, $E3, $94, $37, $CD, $A3, $B3, $6F, $CE, $A3, $DC, $78, $CF, $22, $FE
  2989. L9940:  .byte $83, $CC, $62, $0B, $9F, $CD, $23, $26, $A0, $CE, $62, $39, $BD, $CF, $A2, $1C
  2990. L9950:  .byte $07, $CC, $E3, $A4, $87, $CD, $63, $5D, $5A, $CE, $62, $4F, $38, $CF, $23, $85
  2991.  
  2992. ;Not used.
  2993. L9960:  .byte $3F, $00, $20, $02, $20, $1B, $3A, $02, $20, $21, $01, $02, $2C, $30, $27, $02
  2994. L9970:  .byte $26, $31, $17, $02, $16, $19, $27, $02, $16, $20, $27, $02, $16, $20, $11, $02
  2995. L9980:  .byte $01, $20, $21, $00
  2996.  
  2997. L9984:  .byte $21           ;PPU address high byte.
  2998. L9985:  .byte $8C           ;PPU address low byte.
  2999. L9986:  .byte $05           ;PPU string length.
  3000. ;             'S    T    A    R    T'
  3001. L9987:  .byte $1C, $1D, $0A, $1B, $1D                  
  3002.  
  3003. L998C:  .byte $21           ;PPU address high byte.
  3004. L998D:  .byte $EC           ;PPU address low byte.
  3005. L998E:  .byte $08           ;PPU string length.
  3006. ;             'C    O    N    T    I    N    U    E'
  3007. L998F:  .byte $0C, $18, $17, $1D, $12, $17, $1E, $0E
  3008.  
  3009. L9997:  .byte $00       ;End PPU string write
  3010.  
  3011. ;The following pointer table is used to find the start
  3012. ;of each row on the password screen in the data below.
  3013.  
  3014. PasswordRowTbl:
  3015. L9998:  .word PasswordRow0      ;($99A2)
  3016. L999A:  .word PasswordRow1      ;($99AF)
  3017. L999C:  .word PasswordRow2      ;($99BC)
  3018. L999E:  .word PasswordRow3      ;($99C9)
  3019. L99A0:  .word PasswordRow4      ;($99D6)
  3020.  
  3021. ;The following data is used to load the name table With the password characters:
  3022. PasswordRow0:
  3023. L99A2:  .byte $00           ;0
  3024. L99A3:  .byte $01           ;1
  3025. L99A4:  .byte $02           ;2
  3026. L99A5:  .byte $03           ;3
  3027. L99A6:  .byte $04           ;4
  3028. L99A7:  .byte $05           ;5
  3029. L99A8:  .byte $06           ;6
  3030. L99A9:  .byte $07           ;7
  3031. L99AA:  .byte $08           ;8
  3032. L99AB:  .byte $09           ;9
  3033. L99AC:  .byte $0A           ;A
  3034. L99AD:  .byte $0B           ;B
  3035. L99AE:  .byte $0C           ;C
  3036.  
  3037. PasswordRow1:
  3038. L99AF:  .byte $0D           ;D
  3039. L99B0:  .byte $0E           ;E
  3040. L99B1:  .byte $0F           ;F
  3041. L99B2:  .byte $10           ;G
  3042. L99B3:  .byte $11           ;H
  3043. L99B4:  .byte $12           ;I
  3044. L99B5:  .byte $13           ;J
  3045. L99B6:  .byte $14           ;K
  3046. L99B7:  .byte $15           ;L
  3047. L99B8:  .byte $16           ;M
  3048. L99B9:  .byte $17           ;N
  3049. L99BA:  .byte $18           ;O
  3050. L99BB:  .byte $19           ;P
  3051.  
  3052. PasswordRow2:
  3053. L99BC:  .byte $1A           ;Q
  3054. L99BD:  .byte $1B           ;R
  3055. L99BE:  .byte $1C           ;S
  3056. L99BF:  .byte $1D           ;T
  3057. L99C0:  .byte $1E           ;U
  3058. L99C1:  .byte $1F           ;V
  3059. L99C2:  .byte $20           ;W
  3060. L99C3:  .byte $21           ;X
  3061. L99C4:  .byte $22           ;Y
  3062. L99C5:  .byte $23           ;Z
  3063. L99C6:  .byte $24           ;a
  3064. L99C7:  .byte $25           ;b
  3065. L99C8:  .byte $26           ;c
  3066.  
  3067. PasswordRow3:
  3068. L99C9:  .byte $27           ;d
  3069. L99CA:  .byte $28           ;e
  3070. L99CB:  .byte $29           ;f
  3071. L99CC:  .byte $2A           ;g
  3072. L99CD:  .byte $2B           ;h
  3073. L99CE:  .byte $2C           ;i
  3074. L99CF:  .byte $2D           ;j
  3075. L99D0:  .byte $2E           ;k
  3076. L99D1:  .byte $2F           ;l
  3077. L99D2:  .byte $30           ;m
  3078. L99D3:  .byte $31           ;n
  3079. L99D4:  .byte $32           ;o
  3080. L99D5:  .byte $33           ;p
  3081.  
  3082. PasswordRow4:
  3083. L99D6:  .byte $34           ;q
  3084. L99D7:  .byte $35           ;r
  3085. L99D8:  .byte $36           ;s
  3086. L99D9:  .byte $37           ;t
  3087. L99DA:  .byte $38           ;u
  3088. L99DB:  .byte $39           ;v
  3089. L99DC:  .byte $3A           ;w
  3090. L99DD:  .byte $3B           ;x
  3091. L99DE:  .byte $3C           ;y
  3092. L99DF:  .byte $3D           ;z
  3093. L99E0:  .byte $3E           ;?
  3094. L99E1:  .byte $3F           ;-
  3095. L99E2:  .byte $FF           ;Space
  3096.  
  3097. ;Writes 'PASSWORD PLEASE' on name table 0 in row $2080 (5th row from top).
  3098. L99E3:  .byte $20           ;PPU address high byte.
  3099. L99E4:  .byte $88           ;PPU address low byte.
  3100. L99E5:  .byte $10           ;PPU string length.
  3101. ;             'P    A    S    S    _    W    O    R    D    _    P    L    E    A    S    E'
  3102. L99E6:  .byte $19, $0A, $1C, $1C, $FF, $20, $18, $1B, $0D, $FF, $19, $15, $0E, $0A, $1C, $0E
  3103.  
  3104. ;Clears attribute table 0 starting at address $23C0.
  3105. L99F6:  .byte $23           ;PPU address high byte.
  3106. L99F7:  .byte $C0           ;PPU address low byte.
  3107. L99F8:  .byte $50           ;PPU string length.
  3108. L99F9:  .byte $00           ;Repeat bit set. Repeats entry 16 times.
  3109.  
  3110. ;Writes to attribute table 0 starting at address $23D0.
  3111. L99FA:  .byte $23           ;PPU address high byte.
  3112. L99FB:  .byte $D0           ;PPU address low byte.
  3113. L99FC:  .byte $48           ;PPU string length.
  3114. L99FD:  .byte $55           ;Repeat bit set. Repeats entry 8 times.
  3115.  
  3116. ;Writes to attribute table 0 starting at address $23D8.
  3117. L99FE:  .byte $23           ;PPU address high byte.
  3118. L99FF:  .byte $D8           ;PPU address low byte.
  3119. L9A00:  .byte $60           ;PPU string length.
  3120. L9A01:  .byte $FF           ;Repeat bit set. Repeats entry 32 times.
  3121.  
  3122. ;Writes to attribute table 0 starting at address $23DA.
  3123. L9A02:  .byte $23           ;PPU address high byte.
  3124. L9A03:  .byte $DA           ;PPU address low byte.
  3125. L9A04:  .byte $44           ;PPU string length.
  3126. L9A05:  .byte $F0           ;Repeat bit set. Repeats entry 4 times.
  3127.  
  3128. L9A06:  .byte $00           ;End PPU string write.
  3129.  
  3130. ;----------------------------------------[ Ending routines ]-----------------------------------------
  3131.  
  3132. ;The following routine is accessed via the NMI routine every frame.
  3133. NMIScreenWrite:
  3134. L9A07:  LDA TitleRoutine        ;
  3135. L9A09:  CMP #$1D            ;If titleRoutine not at end game, exit.
  3136. L9A0B:  BCC Exit100         ;
  3137. L9A0D:  JSR LoadCredits         ;($9C45)Display end credits on screen.
  3138. L9A10:  LDA EndMsgWrite         ;
  3139. L9A12:  BEQ +               ;If not time to write end message, branch
  3140. L9A14:  CMP #$05            ;
  3141. L9A16:  BCS +               ;If end message is finished being written, branch
  3142. L9A18:  ASL             ;
  3143. L9A19:  TAY             ;
  3144. L9A1A:  LDX EndMessageStringTbl0-2,Y    ;Writes the end message on name table 0
  3145. L9A1D:  LDA EndMessageStringTbl0-1,Y    ;
  3146. L9A20:  TAY             ;
  3147. L9A21:  JSR PreparePPUProcess_      ;($C20E)Prepare to write to PPU.
  3148. L9A24:* LDA HideShowEndMsg      ;
  3149. L9A26:  BEQ Exit100         ;If not time to erase end message, branch
  3150. L9A28:  CMP #$05            ;
  3151. L9A2A:  BCS Exit100         ;If end message is finished being erased, branch
  3152. L9A2C:  ASL             ;
  3153. L9A2D:  TAY             ;
  3154. L9A2E:  LDX EndMessageStringTbl1-2,Y    ;Erases the end message on name table 0
  3155. L9A31:  LDA EndMessageStringTbl1-1,Y    ;
  3156. L9A34:  TAY                 ;
  3157. L9A35:  JMP PreparePPUProcess_      ;($C20E)Prepare to write to PPU.
  3158.  
  3159. Exit100:
  3160. L9A38:  RTS             ;Exit from above and below routines.
  3161.  
  3162. Restart:
  3163. L9A39:  LDA Joy1Status          ;
  3164. L9A3B:  AND #$10            ;If start has not been pressed, branch to exit.
  3165. L9A3D:  BEQ Exit100         ;
  3166. L9A3F:  LDY #$11            ;
  3167. L9A41:  LDA #$00            ;
  3168. L9A43:* STA PasswordByte00,Y        ;Erase PasswordByte00 thru PasswordByte11.
  3169. L9A46:  DEY             ;
  3170. L9A47:  BPL -               ;
  3171. L9A49:  INY             ;Y = #$00.
  3172. L9A4A:* STA UniqueItemHistory,Y     ;
  3173. L9A4D:  INY             ;Erase Unique item history.
  3174. L9A4E:  BNE -               ;
  3175. L9A50:  LDA SamusGear           ;
  3176. L9A53:  AND #$10            ;
  3177. L9A55:  BEQ +               ;If Samus does not have Maru Mari, branch.-->
  3178. L9A57:  LDA #$01            ;Else load Maru Mari data into PasswordByte00.
  3179. L9A59:  STA PasswordByte00      ;
  3180. L9A5C:* LDA SamusGear           ;
  3181. L9A5F:  AND #$01            ;
  3182. L9A61:  BEQ +               ;If Samus does not have bombs, branch.-->
  3183. L9A63:  LDA PasswordByte00      ;Else load bomb data into PasswordByte00.
  3184. L9A66:  ORA #$40            ;
  3185. L9A68:  STA PasswordByte00      ;
  3186. L9A6B:* LDA SamusGear           ;
  3187. L9A6E:  AND #$20            ;
  3188. L9A70:  BEQ +               ;If Samus does not have varia suit, branch.-->
  3189. L9A72:  LDA #$08            ;Else load varia suit data into PasswordByte01.
  3190. L9A74:  STA PasswordByte01      ;
  3191. L9A77:* LDA SamusGear           ;
  3192. L9A7A:  AND #$02            ;
  3193. L9A7C:  BEQ +               ;If Samus does not have high jump, branch.-->
  3194. L9A7E:  LDA #$01            ;Else load high jump data into PasswordByte03.
  3195. L9A80:  STA PasswordByte03      ;
  3196. L9A83:* LDA SamusGear           ;
  3197. L9A86:  AND #$10            ;If Samus does not have Maru Mari, branch.-->
  3198. L9A88:  BEQ +               ;Else load screw attack data into PasswordByte03.-->
  3199. L9A8A:  LDA PasswordByte03      ;A programmer error?  Should check for screw-->
  3200. L9A8D:  ORA #$04            ;attack data.
  3201. L9A8F:  STA PasswordByte03      ;
  3202. L9A92:* LDA SamusGear           ;
  3203. L9A95:  STA PasswordByte09      ;Store Samus gear data in PasswordByte09.
  3204. L9A98:  LDA #$00            ;
  3205. L9A9A:  LDY JustInBailey        ;
  3206. L9A9D:  BEQ +               ;If Samus is wearing suit, branch.  Else-->
  3207. L9A9F:  LDA #$80            ;load suitless Samus data into PasswordByte08.
  3208. L9AA1:* STA PasswordByte08      ;
  3209. L9AA4:  JMP InitializeGame      ;($92D4)Clear RAM to restart game at beginning.
  3210.  
  3211. EndGame:
  3212. L9AA7:  JSR LoadEndStarSprites      ;($9EAA)Load stars in end scene onto screen.
  3213. L9AAA:  LDA IsCredits           ;Skips palette change when rolling credits.
  3214. L9AAC:  BNE +               ;
  3215. L9AAE:  LDA FrameCount          ;
  3216. L9AB0:  AND #$0F            ;Changes star palettes every 16th frame.
  3217. L9AB2:  BNE +               ;
  3218. L9AB4:  INC PalDataPending      ;
  3219. L9AB6:  LDA PalDataPending      ;Reset palette data to #$01 after it-->
  3220. L9AB8:  CMP #$09            ;reaches #$09.
  3221. L9ABA:  BNE +               ;
  3222. L9ABC:  LDA #$01            ;
  3223. L9ABE:  STA PalDataPending      ;
  3224. L9AC0:* LDA RoomPtr         ;RoomPtr used in end of game to determine-->
  3225. L9AC2:  JSR ChooseRoutine       ;($C27C)which subroutine to run below.
  3226.  
  3227. L9AC5:  .word LoadEndGFX        ;($9AD5)Load end GFX to pattern tables.
  3228. L9AC7:  .word ShowEndSamus      ;($9B1C)Show Samus and end message.
  3229. L9AC9:  .word EndSamusFlash     ;($9B34)Samus flashes and changes.
  3230. L9ACB:  .word SamusWave         ;($9B93)Samus waving in ending if suitless.
  3231. L9ACD:  .word EndFadeOut        ;($9BCD)Fade out Samus in ending.
  3232. L9ACF:  .word RollCredits       ;($9BFC)Rolls ending credits.
  3233. L9AD1:  .word Restart           ;($9A39)Starts at beginning after game completed.
  3234. L9AD3:  .word ExitSub           ;($C45C)Rts.
  3235.  
  3236. LoadEndGFX:
  3237. L9AD5:  JSR ClearAll            ;($909F)Turn off screen, erase sprites and nametables.
  3238. L9AD8:  JSR InitEndGFX          ;($C5D0)Prepare to load end GFX.
  3239. L9ADB:  LDA #$04            ;
  3240. L9ADD:  LDY JustInBailey        ;Checks if game was played as suitless-->
  3241. L9AE0:  BNE +               ;Samus.  If so, branch.
  3242. L9AE2:  LDA #$00            ;Loads SpritePointerIndex with #$00(suit on).
  3243. L9AE4:* STA EndingType          ;
  3244. L9AE7:  ASL             ;Loads SpritePointerIndex with #$08(suitless).
  3245. L9AE8:  STA SpritePointerIndex      ;
  3246. L9AEA:  LDX #$52            ;Loads the screen where Samus stands on-->
  3247. L9AEC:  LDY #$A0            ;the surface of the planet in end of game.
  3248. L9AEE:  JSR PreparePPUProcess_      ;($C20E)Prepare to write to PPU.
  3249. L9AF1:  JSR NmiOn           ;($C487)Turn on non-maskable interrupt.
  3250. L9AF4:  LDA #$20            ;Initiate end game music.
  3251. L9AF6:  STA MultiSFXFlag        ;
  3252. L9AF9:  LDA #$60            ;Loads Timer3 with a delay of 960 frames-->
  3253. L9AFB:  STA Timer3          ;(16 seconds).
  3254. L9AFD:  LDA #$36            ;#$36/#$03 = #$12.  Number of sprites-->
  3255. L9AFF:  STA SpriteByteCounter       ;used to draw end graphic of Samus.
  3256. L9B01:  LDA #$00            ;
  3257. L9B03:  STA SpriteAttribByte        ;
  3258. L9B05:  STA ColorCntIndex       ;
  3259. L9B07:  STA IsCredits           ;The following values are-->
  3260. L9B09:  STA EndMsgWrite         ;initialized to #$00.
  3261. L9B0B:  STA HideShowEndMsg      ;
  3262. L9B0D:  STA CreditPageNumber        ;
  3263. L9B0F:  LDA #$01            ;
  3264. L9B11:  STA PalDataPending      ;Change palette.
  3265. L9B13:  LDA #$08            ;
  3266. L9B15:  STA ClrChangeCounter        ;Initialize ClrChangeCounter with #$08.
  3267. L9B17:  INC RoomPtr         ;
  3268. L9B19:  JMP ScreenOn            ;($C447)Turn screen on.
  3269.  
  3270. ShowEndSamus:
  3271. L9B1C:  JSR LoadEndSamusSprites     ;($9C9A)Load end image of Samus.
  3272. L9B1F:  LDA Timer3          ;Once 960 frames (16 seconds) have expired,-->
  3273. L9B21:  BNE +               ;Move to EndSamusFlash routine.
  3274. L9B23:  INC RoomPtr         ;
  3275. L9B25:  RTS             ;
  3276.  
  3277. L9B26:* CMP #$50            ;After 160 frames have past-->
  3278. L9B28:  BNE +               ;(2.6 seconds), write end message.
  3279. L9B2A:  INC EndMsgWrite         ;
  3280. L9B2C:  RTS             ;
  3281. L9B2D:* CMP #$01            ;After 950 frames have past-->
  3282. L9B2F:  BNE +               ;(15.8 seconds), erase end message.
  3283. L9B31:  INC HideShowEndMsg      ;
  3284. L9B33:* RTS             ;
  3285.  
  3286. EndSamusFlash:
  3287. L9B34:  LDA FrameCount          ;If FrameCount not divisible by 32, branch.
  3288. L9B36:  AND #$1F            ;
  3289. L9B38:  BNE +++             ;
  3290. L9B3A:  INC ColorCntIndex       ;Every 32 frame, increment the ColorCntInex-->
  3291. L9B3C:  LDA ColorCntIndex       ;value.  Flashing Samus lasts for 512-->
  3292. L9B3E:  CMP #$08            ;frames (8.5 seconds).
  3293. L9B40:  BNE +               ;
  3294. L9B42:  JSR ChooseEnding        ;($CAF5)Choose which Samus ending to show.
  3295. L9B45:  JSR CalculatePassword       ;($8C7A)Calculate game password.
  3296. L9B48:  LDA EndingType          ;
  3297. L9B4B:  ASL             ;When EndSamusFlash routine is half way-->
  3298. L9B4C:  STA SpritePointerIndex      ;done, this code will calculate the-->
  3299. L9B4E:  LDA #$36            ;password and choose the proper ending.
  3300. L9B50:  STA SpriteByteCounter       ;
  3301. L9B52:* CMP #$10            ;
  3302. L9B54:  BNE ++              ;Once flashing Samus is compete, set Timer3-->
  3303. L9B56:  STA Timer3          ;for a 160 frame(2.6 seconds) delay.
  3304. L9B58:  LDY #$00            ;
  3305. L9B5A:  LDA EndingType          ;
  3306. L9B5D:  CMP #$04            ;If one of the suitless Samus endings,-->
  3307. L9B5F:  BCC +               ;increment sprite color for proper-->
  3308. L9B61:  INY             ;color to be displayed and increment-->
  3309. L9B62:* STY SpriteAttribByte        ;RoomPtr and erase the sprites.
  3310. L9B64:  INC RoomPtr         ;
  3311. L9B66:  JMP EraseAllSprites     ;($C1A3)Clear all sprites off the screen.
  3312. L9B69:* DEC ClrChangeCounter        ;Decrement ClrChangeCounter.
  3313. L9B6B:  BNE +               ;
  3314. L9B6D:  LDY ColorCntIndex       ;
  3315. L9B6F:  LDA PalChangeTable,Y        ;When ClrChangeCounter=#$00, fetch new-->
  3316. L9B72:  STA ClrChangeCounter        ;ClrChangeCounter value. and increment-->
  3317. L9B74:  INC SpriteAttribByte        ;sprite color.  
  3318. L9B76:  LDA SpriteAttribByte        ;
  3319. L9B78:  CMP #$03            ;
  3320. L9B7A:  BNE +               ;  
  3321. L9B7C:  LDA #$00            ;If sprite color=#$03, set sprite-->
  3322. L9B7E:  STA SpriteAttribByte        ;color to #$00.
  3323. L9B80:* JMP LoadEndSamusSprites     ;($9C9A)Load end image of Samus.
  3324.  
  3325. ;The following table is used by the above routine to load ClrChangeCounter.  ClrChangeCounter
  3326. ;decrements every frame, When ClrChangeCounter reaches zero, the sprite colors for Samus
  3327. ;changes.  This has the effect of making Samus flash.  The flashing starts slow, speeds up,
  3328. ;then slows down again.
  3329. PalChangeTable:
  3330. L9B83:  .byte $08, $07, $06, $05, $04, $03, $02, $01, $01, $02, $03, $04, $05, $06, $07, $08
  3331.  
  3332. SamusWave:
  3333. L9B93:  LDA Timer3          ;If 160 frame timer from previous routine-->
  3334. L9B95:  BNE +               ;has not expired, branch(waves for 2.6 seconds).
  3335. L9B97:  LDA #$10            ;
  3336. L9B99:  STA Timer3          ;Load Timer3 with 160 frame delay-->
  3337. L9B9B:  LDA #$08            ;(2.6 seconds).
  3338. L9B9D:  STA PalDataPending      ;Change palette
  3339. L9B9F:  INC RoomPtr         ;Increment RoomPtr
  3340. L9BA1:  RTS             ;
  3341.  
  3342. L9BA2:* LDA EndingType          ;If suitless Samus-->
  3343. L9BA5:  CMP #$04            ;ending, branch.
  3344. L9BA7:  BCS +               ;
  3345. L9BA9:  JMP LoadEndSamusSprites     ;($9C9A)
  3346. L9BAC:* SBC #$04            ;If jumpsuit Samus ending,-->
  3347. L9BAE:  ASL             ;WaveSpritePointer=#$00, if bikini-->
  3348. L9BAF:  ASL             ;Samus ending, WaveSpritePointer=#$04.
  3349. L9BB0:  STA WaveSpritePointer       ;
  3350. L9BB2:  LDA FrameCount          ;
  3351. L9BB4:  AND #$08            ;Every eigth frame count, change wave sprite data.
  3352. L9BB6:  BNE +               ;
  3353. L9BB8:  LDY #$10            ;Load WaveSpriteCounter with #$10(16 bytes of-->
  3354. L9BBA:  STY WaveSpriteCounter       ;sprite data to be loaded).
  3355. L9BBC:  BNE ++              ;Branch always.
  3356. L9BBE:* INC WaveSpritePointer       ;
  3357. L9BC0:  INC WaveSpritePointer       ;When bit 3 of FrameCount is not set,-->
  3358. L9BC2:  LDY #$10            ;Samus' waving hand is down.
  3359. L9BC4:  STY WaveSpriteCounter       ;
  3360. L9BC6:* LDA #$2D            ;Load SpriteByteCounter in preparation for-->
  3361. L9BC8:  STA SpriteByteCounter       ;refreshing Samus sprite bytes.
  3362. L9BCA:  JMP LoadWaveSprites     ;($9C7F)Load sprites for waving Samus.
  3363.  
  3364. EndFadeOut:
  3365. L9BCD:  LDA Timer3          ;If 160 frame delay from last routine has not-->
  3366. L9BCF:  BNE ++              ;yet expired, branch.
  3367. L9BD1:  LDA IsCredits           ;
  3368. L9BD3:  BNE +               ;Branch always.
  3369.  
  3370. L9BD5:  LDA #$08            ;*This code does not appear to be used.
  3371. L9BD7:  STA PalDataPending      ;*Change palette.
  3372. L9BD9:  INC IsCredits           ;*Increment IsCredits.
  3373.  
  3374. L9BDB:* LDA FrameCount          ;
  3375. L9BDD:  AND #$07            ;Every seventh frame, increment the palette info-->
  3376. L9BDF:  BNE +               ;If PalDataPending is not equal to #$0C, keep-->
  3377. L9BE1:  INC PalDataPending      ;incrementing every seventh frame until it does.-->
  3378. L9BE3:  LDA PalDataPending      ;This creates the fade out effect.
  3379. L9BE5:  CMP #$0C            ;
  3380. L9BE7:  BNE +               ;
  3381. L9BE9:  LDA #$10            ;After fadeout complete, load Timer3 with 160 frame-->
  3382. L9BEB:  STA Timer3          ;delay(2.6 seconds) and increment RoomPtr.
  3383. L9BED:  INC RoomPtr         ;
  3384. L9BEF:* LDA EndingType          ;
  3385. L9BF2:  CMP #$04            ;If suitless Samus ending, load hand wave sprites,-->
  3386. L9BF4:  BCS +               ;else just load regular Samus sprites
  3387. L9BF6:  JMP LoadEndSamusSprites     ;($9C9A)Load end image of Samus.
  3388. L9BF9:* JMP LoadWaveSprites     ;($9C7F)Load sprites for waving Samus.
  3389.  
  3390. RollCredits:
  3391. L9BFC:  LDA Timer3          ;If 160 frame timer delay from previous-->
  3392. L9BFE:  BEQ +               ;routine has expired, branch.
  3393. L9C00:  CMP #$02            ;If not 20 frames left in Timer3, branch to exit.
  3394. L9C02:  BNE ++++            ;
  3395. L9C04:  JSR ScreenOff           ;($C439)When 20 frames left in Timer3,-->
  3396. L9C07:  JSR ClearNameTable0     ;($C16D)clear name table 0 and sprites.-->
  3397. L9C0A:  JSR EraseAllSprites     ;($C1A3)prepares screen for credits.
  3398. L9C0D:  LDA #$0D            ;
  3399. L9C0F:  STA PalDataPending      ;Change to proper palette for credits.
  3400. L9C11:  JSR ScreenOn            ;($C447)Turn screen on.
  3401. L9C14:  JMP WaitNMIPass_        ;($C43F)Wait for NMI to end.
  3402. L9C17:* LDA CreditPageNumber        ;If first page of credits has not started to-->
  3403. L9C19:  BNE +               ;roll, start it now, else branch.
  3404. L9C1B:  INC CreditPageNumber        ;
  3405. L9C1D:* CMP #$06            ;If not at last page of credits, branch.
  3406. L9C1F:  BNE +               ;
  3407. L9C21:  LDA ScrollY         ;
  3408. L9C23:  CMP #$88            ;If last page of credits is not finished-->
  3409. L9C25:  BCC +               ;scrolling, branch.  Else increment to next-->
  3410. L9C27:  INC RoomPtr         ;routine.
  3411. L9C29:  RTS             ;
  3412.  
  3413. L9C2A:* LDA FrameCount          ;credits scroll up one position every 3 frames.
  3414. L9C2C:  AND #$03            ;
  3415. L9C2E:  BNE +               ;Ready to scroll? If not, branch.
  3416. L9C30:  INC ScrollY         ;
  3417. L9C32:  LDA ScrollY         ;Load ScrollY and check it to see if its-->
  3418. L9C34:  CMP #$F0            ;position is at the very bottom on name table.-->
  3419. L9C36:  BNE +               ;if not, branch.
  3420. L9C38:  INC CreditPageNumber        ;
  3421. L9C3A:  LDA #$00            ;
  3422. L9C3C:  STA ScrollY         ;When Scrolly is at bottom of the name table,-->
  3423. L9C3E:  LDA PPUCNT0ZP           ;Swap to next name table(0 or 2) and increment-->
  3424. L9C40:  EOR #$02            ;CreditPageNumber.
  3425. L9C42:  STA PPUCNT0ZP           ;
  3426. L9C44:* RTS
  3427.  
  3428. ;The following routine is checked every frame and is accessed via the NMIScreenWrite routine.
  3429. ;The LoadCredits routine works like this: The Y scroll position is checked every frame.  When
  3430. ;it is in the first four positions of the current name table (0, 1, 2 or 3), or the four
  3431. ;positions right after 127 (128, 129, 130 and 131), the routine will then load the ending
  3432. ;credits into the positions on the name table that were just scrolled over.  For example, If
  3433. ;the scroll window is currently half way down name table 0, the LoadCredits routine will load
  3434. ;the contents of the upper half of name table 0.  Also, name table 0 contains odd numbered
  3435. ;pages and name table 2 contains even numbered pages.
  3436.  
  3437. LoadCredits:
  3438. L9C45:  LDY CreditPageNumber        ;
  3439. L9C47:  BEQ ++++            ;If credits are not being displayed, exit.
  3440. L9C49:  CPY #$07            ;
  3441. L9C4B:  BCS ++++            ;If CreditPageNumber is higher than #$06, exit.
  3442. L9C4D:  LDX #$00            ;
  3443. L9C4F:  LDA ScrollY         ;If ScrollY is less than #$80 (128), branch.
  3444. L9C51:  BPL +               ;
  3445. L9C53:  INX             ;Load X with sign bit (#$01) and remove-->
  3446. L9C54:  SEC             ;sign bit from A.
  3447. L9C55:  SBC #$80            ;
  3448. L9C57:* CMP #$04            ;
  3449. L9C59:  BCS +++             ;If ScrollY is not #$04, branch to exit.
  3450. L9C5B:  STA $01             ;Store #$00, #$01, #$02 or #$03 in address $01.
  3451. L9C5D:  DEY             ;Y now contains CreditPageNumber - 1.
  3452. L9C5E:  TXA             ;
  3453. L9C5F:  BNE +               ;If ScrollY is #$80 (128) or greater, branch.
  3454. L9C61:  DEY             ;Y now contains CreditPageNumber - 2.
  3455. L9C62:  BMI +++             ;If on Credit page less than two , branch to exit.
  3456. L9C64:  TYA             ;
  3457. L9C65:  ASL             ;Start with CreditPageNumber - 2-->
  3458. L9C66:  ASL             ;* 8 + 4 + $01 * 2.
  3459. L9C67:  ASL             ;This formula is used when ScrollY = 0, 1, 2 and 3.
  3460. L9C68:  ADC #$04            ;Result is index to find proper credits to load.
  3461. L9C6A:  BNE ++              ;Branch always.
  3462. L9C6C:* TYA             ;
  3463. L9C6D:  ASL             ;Start with CreditPageNumber - 1-->
  3464. L9C6E:  ASL             ;* 8 + $01 * 2.
  3465. L9C6F:  ASL             ;This formula is used when ScrollY = 128,-->
  3466. L9C70:* ADC $01             ;129, 130 and 131.
  3467. L9C72:  ASL             ;Result is index to find proper credits to load.
  3468. L9C73:  TAY                 ;
  3469. L9C74:  LDX CreditsPointerTbl,Y     ;Base is $A291. Lower byte of pointer to PPU string.
  3470. L9C77:  LDA CreditsPointerTbl+1,Y   ;Upper byte of pointer to PPU string.
  3471. L9C7A:  TAY                 ;
  3472. L9C7B:  JMP PreparePPUProcess_      ;($C20E)Prepare to write to PPU.
  3473. L9C7E:* RTS             ;
  3474.  
  3475. LoadWaveSprites:
  3476. L9C7F:  LDX WaveSpritePointer       ;
  3477. L9C81:  LDA WavePointerTable,X      ;
  3478. L9C84:  STA $00             ;Load pointer to wave sprite data-->
  3479. L9C86:  LDA WavePointerTable+1,X    ;into addresses $00 and $01.
  3480. L9C89:  STA $01             ;
  3481. L9C8B:  LDX #$20            ;Offset for sprite RAM load.
  3482. L9C8D:  LDY #$00            ;
  3483. L9C8F:* LDA ($00),Y         ;
  3484. L9C91:  STA Sprite00RAM,X       ;Load wave sprites into sprite RAM starting at-->
  3485. L9C94:  INX             ;location $220 (Sprite08RAM).
  3486. L9C95:  INY             ;
  3487. L9C96:  CPY WaveSpriteCounter       ;Check to see if sprite RAM load complete.-->
  3488. L9C98:  BNE -               ;If not, branch and load another byte.
  3489.  
  3490. LoadEndSamusSprites:
  3491. L9C9A:  LDX #$30            ;Index for loading Samus sprite data into sprite RAM.
  3492. L9C9C:  LDY SpritePointerIndex      ;
  3493. L9C9E:  LDA EndSamusAddrTbl,Y       ;Base is $9D5A.
  3494. L9CA1:  STA $00             ;Load $00 and $01 with pointer to the sprite-->
  3495. L9CA3:  LDA EndSamusAddrTbl+1,Y     ;data that shows Samus at the end of the game.
  3496. L9CA6:  STA $01             ;
  3497. L9CA8:  LDY #$00            ;
  3498. L9CAA:* LDA ($00),Y         ;Load sprite data starting at Sprite0CRAM.
  3499. L9CAC:  STA Sprite00RAM,X       ;Load sprite Y-coord.
  3500. L9CAF:  INX             ;
  3501. L9CB0:  INY             ;Increment X and Y.
  3502. L9CB1:  LDA ($00),Y         ;
  3503. L9CB3:  BPL +               ;If sprite pattern byte MSB cleared, branch.
  3504. L9CB5:  AND #$7F            ;
  3505. L9CB7:  STA Sprite00RAM,X       ;Remove MSB and write sprite pattern data-->
  3506. L9CBA:  LDA SpriteAttribByte        ;to sprite RAM.
  3507. L9CBC:  EOR #$40            ;
  3508. L9CBE:  BNE ++              ;
  3509. L9CC0:* STA Sprite00RAM,X       ;Writes sprite pattern byte to-->
  3510. L9CC3:  LDA SpriteAttribByte        ;sprite RAM if its MSB is not set.
  3511. L9CC5:* INX             ;
  3512. L9CC6:  STA Sprite00RAM,X       ;Writes sprite attribute byte to sprite RAM.
  3513. L9CC9:  INY             ;
  3514. L9CCA:  INX                 ;Increment X and Y.
  3515. L9CCB:  LDA ($00),Y         ;
  3516. L9CCD:  STA Sprite00RAM,X       ;Load sprite X-coord.
  3517. L9CD0:  INY             ;
  3518. L9CD1:  INX             ;Increment X and Y.
  3519. L9CD2:  CPY SpriteByteCounter       ;
  3520. L9CD4:  BNE ---             ;Repeat until sprite load is complete.
  3521. L9CD6:  LDA RoomPtr         ;
  3522. L9CD8:  CMP #$02            ;If not running the EndSamusFlash routine, branch.
  3523. L9CDA:  BCC ++              ;
  3524. L9CDC:  LDA ColorCntIndex       ;
  3525. L9CDE:  CMP #$08            ;If EndSamusFlash routine is more than half-->
  3526. L9CE0:  BCC ++              ;way done, Check ending type for the Samus helmet-->
  3527. L9CE2:  LDA EndingType          ;off ending.  If not helmet off ending, branch.
  3528. L9CE5:  CMP #$03            ;
  3529. L9CE7:  BNE ++              ;
  3530. L9CE9:  LDY #$00            ;
  3531. L9CEB:  LDX #$00            ;
  3532. L9CED:* LDA SamusHeadSpriteTble,Y   ;The following code loads the sprite graphics-->
  3533. L9CF0:  STA Sprite00RAM,X       ;when the helmet off ending is playing.  The-->
  3534. L9CF3:  INY                 ;sprites below keep Samus head from flashing-->
  3535. L9CF4:  INX                 ;while the rest of her body does.
  3536. L9CF5:  CPY #$18            ;
  3537. L9CF7:  BNE -               ;
  3538. L9CF9:* RTS             ;
  3539.  
  3540. ;The following table is used by the routine above to keep Samus'
  3541. ;head from flashing during the helmet off ending.
  3542.  
  3543. SamusHeadSpriteTble:
  3544. L9CFA:  .byte $93, $36, $01, $70    ;Sprite00RAM
  3545. L9CFE:  .byte $93, $37, $01, $78    ;Sprite01RAM
  3546. L9D02:  .byte $93, $38, $01, $80    ;Sprite02RAM
  3547. L9D06:  .byte $9B, $46, $01, $70    ;Sprite03RAM
  3548. L9D0A:  .byte $9B, $47, $01, $78    ;Sprite04RAM
  3549. L9D0E:  .byte $9B, $48, $01, $80    ;Sprite05RAM
  3550.  
  3551. ;The following table is a pointer table to the sprites that makes Samus wave in the end
  3552. ;of the game when she is suitless.  The top two pointers are for when she is in the jumpsuit
  3553. ;and the bottom two pointers are for when she is in the bikini.
  3554.  
  3555. WavePointerTable:
  3556. L9D12:  .word $9D1A         ;Jumpsuit Samus hand up.
  3557. L9D14:  .word $9D2A         ;Jumpsuit Samus hand down.
  3558. L9D16:  .word $9D3A         ;Bikini Samus hand up.
  3559. L9D18:  .word $9D4A         ;Bikini Samus hand down.
  3560.  
  3561. ;Sprite data table used when Samus is in jumpsuit and her waving hand is up.
  3562. JsHandUpTable:
  3563. L9D1A:  .byte $9B, $1F, $01, $80, $A3, $2F, $01, $80, $AB, $3F, $01, $80, $F4, $3F, $01, $80
  3564.  
  3565. ;Sprite data table used when Samus is in jumpsuit and her waving hand is down.
  3566. JsHandDownTable:
  3567. L9D2A:  .byte $9B, $2A, $01, $80, $9B, $2B, $01, $88, $A3, $3A, $01, $80, $AB, $3F, $01, $80
  3568.  
  3569. ;Sprite data table used when Samus is in bikini and her waving hand is up.
  3570. BkHandUpTable:
  3571. L9D3A:  .byte $9B, $0C, $01, $80, $A3, $1C, $01, $80, $AB, $3F, $01, $80, $F4, $3F, $01, $80
  3572.  
  3573. ;Sprite data table used when Samus is in bikini and her waving hand is down.
  3574. BkHandDownTable:
  3575. L9D4A:  .byte $9B, $4A, $01, $80, $9B, $4B, $01, $88, $A3, $4D, $01, $80, $AB, $3F, $01, $80
  3576.  
  3577. EndSamusAddrTbl:
  3578. L9D5A:  .word NormalSamus       ;($9D66)Pointer to end graphic of Samus wearing suit.
  3579. L9D5C:  .word BackTurnedSamus       ;($9D9C)Pointer to end graphic of back turned Samus.
  3580. L9D5E:  .word FistRaisedSamus       ;($9DD2)Pointer to end graphic of fist raised Samus.
  3581. L9D60:  .word HelmetOffSamus        ;($9E08)Pointer to end graphic of helmet off Samus.
  3582. L9D62:  .word JumpsuitSamus     ;($9E3E)Pointer to end graphic of jumpsuit Samus.
  3583. L9D64:  .word BikiniSamus       ;($9E74)Pointer to end graphic of bikini Samus.
  3584.  
  3585. ;The following three bytes are loaded into sprite RAM.  The third byte (attribute byte) is
  3586. ;not included.  Instead, if the MSB of the second byte (pattern byte) is set, the pattern
  3587. ;byte is flipped horizontally (mirror image).  If pattern byte MSB is not set, the attribute
  3588. ;byte is stored as #$00.  This is done so the code can generate the flashing Samus effect at
  3589. ;the end of the game.
  3590.  
  3591. NormalSamus:
  3592. L9D66:  .byte $93, $00, $70
  3593. L9D69:  .byte $93, $01, $78
  3594. L9D6C:  .byte $93, $80, $80     ;Mirrored pattern at pattern table location $00.
  3595. L9D6F:  .byte $9B, $10, $70
  3596. L9D72:  .byte $9B, $11, $78
  3597. L9D75:  .byte $9B, $90, $80     ;Mirrored pattern at pattern table location $10.
  3598. L9D78:  .byte $A3, $20, $70
  3599. L9D7B:  .byte $A3, $21, $78
  3600. L9D7E:  .byte $A3, $22, $80
  3601. L9D81:  .byte $AB, $30, $70
  3602. L9D84:  .byte $AB, $31, $78
  3603. L9D87:  .byte $AB, $32, $80
  3604. L9D8A:  .byte $B3, $40, $70
  3605. L9D8D:  .byte $B3, $41, $78
  3606. L9D90:  .byte $B3, $C0, $80
  3607. L9D93:  .byte $BB, $50, $70
  3608. L9D96:  .byte $BB, $49, $78
  3609. L9D99:  .byte $BB, $D0, $80     ;Mirrored pattern at pattern table location $50.
  3610.  
  3611. BackTurnedSamus:
  3612. L9D9C:  .byte $93, $02, $70
  3613. L9D9F:  .byte $93, $03, $78
  3614. L9DA2:  .byte $93, $04, $80
  3615. L9DA5:  .byte $9B, $12, $70
  3616. L9DA8:  .byte $9B, $13, $78
  3617. L9DAB:  .byte $9B, $14, $80
  3618. L9DAE:  .byte $A3, $05, $70
  3619. L9DB1:  .byte $A3, $06, $78
  3620. L9DB4:  .byte $A3, $07, $80
  3621. L9DB7:  .byte $AB, $15, $70
  3622. L9DBA:  .byte $AB, $16, $78
  3623. L9DBD:  .byte $AB, $17, $80
  3624. L9DC0:  .byte $B3, $08, $70
  3625. L9DC3:  .byte $B3, $09, $78
  3626. L9DC6:  .byte $B3, $88, $80     ;Mirrored pattern at pattern table location $08.
  3627. L9DC9:  .byte $BB, $18, $70
  3628. L9DCC:  .byte $BB, $19, $78
  3629. L9DDF:  .byte $BB, $98, $80     ;Mirrored pattern at pattern table location $18.
  3630.  
  3631. FistRaisedSamus:
  3632. L9DD2:  .byte $93, $00, $70
  3633. L9DD5:  .byte $93, $01, $78
  3634. L9DD8:  .byte $93, $34, $80
  3635. L9DDB:  .byte $9B, $10, $70
  3636. L9DDE:  .byte $9B, $11, $78
  3637. L9DE1:  .byte $9B, $44, $80
  3638. L9DE4:  .byte $A3, $20, $70
  3639. L9DE7:  .byte $A3, $21, $78
  3640. L9DEA:  .byte $A3, $33, $80
  3641. L9DED:  .byte $AB, $30, $70
  3642. L9DF0:  .byte $AB, $31, $78
  3643. L9DF3:  .byte $AB, $43, $80
  3644. L9DF6:  .byte $B3, $40, $70
  3645. L9DF9:  .byte $B3, $41, $78
  3646. L9DFC:  .byte $B3, $C0, $80     ;Mirrored pattern at pattern table location $40.
  3647. L9DFF:  .byte $BB, $50, $70
  3648. L9E02:  .byte $BB, $49, $78
  3649. L9E05:  .byte $BB, $D0, $80     ;Mirrored pattern at pattern table location $50.
  3650.  
  3651. HelmetOffSamus:
  3652. L9E08:  .byte $93, $0D, $70
  3653. L9E0B:  .byte $93, $0E, $78
  3654. L9E0E:  .byte $93, $0F, $80
  3655. L9E11:  .byte $9B, $35, $70
  3656. L9E14:  .byte $9B, $27, $78
  3657. L9E17:  .byte $9B, $28, $80
  3658. L9E1A:  .byte $A3, $20, $70
  3659. L9E1D:  .byte $A3, $21, $78
  3660. L9E20:  .byte $A3, $22, $80
  3661. L9E23:  .byte $AB, $30, $70
  3662. L9E26:  .byte $AB, $31, $78
  3663. L9E29:  .byte $AB, $32, $80
  3664. L9E2C:  .byte $B3, $40, $70
  3665. L9E2F:  .byte $B3, $41, $78
  3666. L9E32:  .byte $B3, $C0, $80     ;Mirrored pattern at pattern table location $40.
  3667. L9E35:  .byte $BB, $50, $70
  3668. L9E38:  .byte $BB, $49, $78
  3669. L9E3B:  .byte $BB, $D0, $80     ;Mirrored pattern at pattern table location $50.
  3670.  
  3671. JumpsuitSamus:
  3672. L9E3E:  .byte $93, $0D, $70
  3673. L9E41:  .byte $93, $0E, $78
  3674. L9E44:  .byte $93, $0F, $80
  3675. L9E47:  .byte $9B, $1D, $70
  3676. L9E4A:  .byte $9B, $1E, $78
  3677. L9E4D:  .byte $A3, $2D, $70
  3678. L9E50:  .byte $A3, $2E, $78
  3679. L9E53:  .byte $AB, $3D, $70
  3680. L9E56:  .byte $AB, $3E, $78
  3681. L9E59:  .byte $B3, $08, $70
  3682. L9E5C:  .byte $B3, $4E, $78
  3683. L9E5F:  .byte $B3, $4F, $80
  3684. L9E62:  .byte $BB, $45, $70
  3685. L9E65:  .byte $BB, $3B, $78
  3686. L9E68:  .byte $BB, $51, $80
  3687. L9E6B:  .byte $9B, $29, $80
  3688. L9E6E:  .byte $A3, $39, $80
  3689. L9E71:  .byte $AB, $4C, $80
  3690.  
  3691. BikiniSamus:
  3692. L9E74:  .byte $93, $0D, $70
  3693. L9E77:  .byte $93, $0E, $78
  3694. L9E7A:  .byte $93, $0F, $80
  3695. L9E7D:  .byte $9B, $0A, $70
  3696. L9E80:  .byte $9B, $0B, $78
  3697. L9E83:  .byte $A3, $1A, $70
  3698. L9E86:  .byte $A3, $1B, $78
  3699. L9E89:  .byte $AB, $3D, $70
  3700. L9E8C:  .byte $AB, $3E, $78
  3701. L9E8F:  .byte $B3, $08, $70
  3702. L9E92:  .byte $B3, $4E, $78
  3703. L9E95:  .byte $B3, $4F, $80
  3704. L9E98:  .byte $BB, $45, $70
  3705. L9E9B:  .byte $BB, $3B, $78
  3706. L9E9E:  .byte $BB, $51, $80
  3707. L9EA1:  .byte $9B, $2C, $80
  3708. L9EA4:  .byte $A3, $3C, $80
  3709. L9EA7:  .byte $AB, $4C, $80
  3710.  
  3711. LoadEndStarSprites:
  3712. L9EAA:  LDY #$00            ;
  3713. L9EAC:* LDA EndStarDataTable,Y      ;
  3714. L9EAF:  STA Sprite1CRAM,Y       ;Load the table below into sprite RAM-->
  3715. L9EB2:  INY                 ;starting at address $0270.
  3716. L9EB3:  CPY #$9C            ;
  3717. L9EB5:  BNE -               ;
  3718. L9EB7:  RTS
  3719.  
  3720. ;Loaded into sprite RAM by routine above. Displays stars at the end of the game.
  3721.  
  3722. EndStarDataTable:
  3723. L9EB8:  .byte $08, $23, $22, $10
  3724. L9EBC:  .byte $68, $23, $23, $60
  3725. L9EC0:  .byte $00, $23, $22, $60
  3726. L9EC4:  .byte $7F, $23, $23, $6A
  3727. L9EC8:  .byte $7F, $23, $22, $D4
  3728. L9ECC:  .byte $33, $23, $23, $B2
  3729. L9ED0:  .byte $93, $23, $22, $47
  3730. L9ED4:  .byte $B3, $23, $23, $95
  3731. L9ED8:  .byte $0B, $23, $22, $E2
  3732. L9EDC:  .byte $1C, $23, $23, $34
  3733. L9EE0:  .byte $84, $23, $22, $18
  3734. L9EE4:  .byte $B2, $23, $23, $EE
  3735. L9EE8:  .byte $40, $23, $22, $22
  3736. L9EEC:  .byte $5A, $23, $23, $68
  3737. L9EF0:  .byte $1A, $23, $22, $90
  3738. L9EF4:  .byte $AA, $23, $23, $22
  3739. L9EF8:  .byte $81, $24, $22, $88
  3740. L9EFC:  .byte $6A, $24, $23, $D0
  3741. L9F00:  .byte $A8, $24, $22, $A0
  3742. L9F04:  .byte $10, $24, $23, $70
  3743. L9F08:  .byte $15, $25, $22, $42
  3744. L9F0C:  .byte $4A, $25, $23, $7D
  3745. L9F10:  .byte $30, $25, $22, $50
  3746. L9F14:  .byte $5A, $25, $23, $49
  3747. L9F18:  .byte $50, $25, $22, $B9
  3748. L9F1C:  .byte $91, $25, $23, $B0
  3749. L9F20:  .byte $19, $25, $22, $C0
  3750. L9F24:  .byte $53, $25, $23, $BA
  3751. L9F28:  .byte $A4, $25, $22, $D6
  3752. L9F2C:  .byte $98, $25, $23, $1A
  3753. L9F30:  .byte $68, $25, $22, $0C
  3754. L9F34:  .byte $97, $25, $23, $EA
  3755. L9F38:  .byte $33, $25, $22, $92
  3756. L9F3C:  .byte $43, $25, $23, $65
  3757. L9F40:  .byte $AC, $25, $22, $4A
  3758. L9F44:  .byte $2A, $25, $23, $71
  3759. L9F48:  .byte $7C, $26, $22, $B2
  3760. L9F4C:  .byte $73, $26, $23, $E7
  3761. L9F50:  .byte $0C, $26, $22, $AA
  3762.  
  3763. EndGamePalWrite:
  3764. L9F54:  LDA PalDataPending      ;If no palette data pending, branch to exit.
  3765. L9F56:  BEQ ++              ;
  3766. L9F58:  CMP #$0C            ;If PalDataPending has loaded last palette,-->
  3767. L9F5A:  BEQ ++              ;branch to exit.
  3768. L9F5C:  CMP #$0D            ;Once end palettes have been cycled through,-->
  3769. L9F5E:  BNE +               ;start over.
  3770. L9F60:  LDY #$00            ;
  3771. L9F62:  STY PalDataPending      ;
  3772. L9F64:* ASL             ;* 2, pointer is two bytes.
  3773. L9F65:  TAY             ;
  3774. L9F66:  LDA EndGamePalPntrTbl-1,Y   ;High byte of PPU data pointer.
  3775. L9F69:  LDX EndGamePalPntrTbl-2,Y   ;Low byte of PPU data pointer.
  3776. L9F6C:  TAY             ;
  3777. L9F6D:  JSR PreparePPUProcess_      ;($C20E)Prepare to write data string to PPU.
  3778. L9F70:  LDA #$3F            ;
  3779. L9F72:  STA PPUAddress          ;
  3780. L9F75:  LDA #$00            ;
  3781. L9F77:  STA PPUAddress          ;Set PPU address to $3F00.
  3782. L9F7A:  STA PPUAddress          ;
  3783. L9F7D:  STA PPUAddress          ;Set PPU address to $0000.
  3784. L9F80:* RTS             ;
  3785.  
  3786. ;The following pointer table is used by the routine above to
  3787. ;find the proper palette data during the EndGame routine.
  3788.  
  3789. EndGamePalPntrTbl:
  3790. L9F81:  .word EndGamePal00      ;($9F9B)
  3791. L9F83:  .word EndGamePal01      ;($9FBF)
  3792. L9F85:  .word EndGamePal02      ;($9FCB)
  3793. L9F87:  .word EndGamePal03      ;($9FD7)
  3794. L9F89:  .word EndGamePal04      ;($9FE3)
  3795. L9F8B:  .word EndGamePal05      ;($9FEF)
  3796. L9F8D:  .word EndGamePal06      ;($9FFB)
  3797. L9F8F:  .word EndGamePal07      ;($A007)
  3798. L9F91:  .word EndGamePal08      ;($A013)
  3799. L9F93:  .word EndGamePal09      ;($A02E)
  3800. L9F95:  .word EndGamePal0A      ;($A049)
  3801. L9F97:  .word EndGamePal0A      ;($A049)
  3802. L9F99:  .word EndGamePal0B      ;($9806)
  3803.  
  3804. EndGamePal00:
  3805. L9F9B:  .byte $3F           ;PPU address high byte.
  3806. L9F9C:  .byte $00           ;PPU address low byte.
  3807. L9F9D:  .byte $20           ;PPU string length.
  3808. ;The following values are written to the background palette:
  3809. L9F9E:  .byte $0F, $21, $11, $02, $0F, $29, $1B, $1A, $0F, $27, $28, $29, $0F, $28, $18, $08
  3810. ;The following values are written to the sprite palette:
  3811. L9FAE:  .byte $0F, $16, $19, $27, $0F, $36, $15, $17, $0F, $12, $21, $20, $0F, $35, $12, $16
  3812.  
  3813. L9FBE:  .byte $00           ;End EndGamePal00 data.
  3814.  
  3815. EndGamePal01:
  3816. L9FBF:  .byte $3F           ;PPU address high byte.
  3817. L9FC0:  .byte $18           ;PPU address low byte.
  3818. L9FC1:  .byte $08           ;PPU string length.
  3819. ;The following values are written to the sprite palette starting at $3F18:
  3820. L9FC2:  .byte $0F, $10, $20, $30, $0F, $0F, $0F, $0F
  3821.  
  3822. L9FCA:  .byte $00           ;End EndGamePal01 data.
  3823.  
  3824. EndGamePal02:
  3825. L9FCB:  .byte $3F           ;PPU address high byte.
  3826. L9FCC:  .byte $18           ;PPU address low byte.
  3827. L9FCD:  .byte $08           ;PPU string length.
  3828. ;The following values are written to the sprite palette starting at $3F18:
  3829. L9FCE:  .byte $0F, $12, $22, $32, $0F, $0B, $1B, $2B
  3830.  
  3831. L9FD6:  .byte $00           ;End EndGamePal02 data.
  3832.  
  3833. EndGamePal03:
  3834. L9FD7:  .byte $3F           ;PPU address high byte.
  3835. L9FD8:  .byte $18           ;PPU address low byte.
  3836. L9FD9:  .byte $08           ;PPU string length.
  3837. ;The following values are written to the sprite palette starting at $3F18:
  3838. L9FDA:  .byte $0F, $14, $24, $34, $0F, $09, $19, $29
  3839.  
  3840. L9FE2:  .byte $00           ;End EndGamePal03 data.
  3841.  
  3842. EndGamePal04:
  3843. L9FE3:  .byte $3F           ;PPU address high byte.
  3844. L9FE4:  .byte $18           ;PPU address low byte.
  3845. L9FE5:  .byte $08           ;PPU string length.
  3846. ;The following values are written to the sprite palette starting at $3F18:
  3847. L9FE6:  .byte $0F, $16, $26, $36, $0F, $07, $17, $27
  3848.  
  3849. L9FEE:  .byte $00           ;End EndGamePal04 data.
  3850.  
  3851. EndGamePal05:
  3852. L9FEF:  .byte $3F           ;PPU address high byte.
  3853. L9FF0:  .byte $18           ;PPU address low byte.
  3854. L9FF1:  .byte $08           ;PPU string length.
  3855. ;The following values are written to the sprite palette starting at $3F18:
  3856. L9FF2:  .byte $0F, $18, $28, $38, $0F, $05, $15, $25
  3857.  
  3858. L9FFA:  .byte $00           ;End EndGamePal05 data.
  3859.  
  3860. EndGamePal06:
  3861. L9FFB:  .byte $3F           ;PPU address high byte.
  3862. L9FFC:  .byte $18           ;PPU address low byte.
  3863. L9FFD:  .byte $08           ;PPU string length.
  3864. ;The following values are written to the sprite palette starting at $3F18:
  3865. L9FFE:  .byte $0F, $1A, $2A, $3A, $0F, $03, $13, $13
  3866.  
  3867. LA006:  .byte $00           ;End EndGamePal06 data.
  3868.  
  3869. EndGamePal07:
  3870. LA007:  .byte $3F           ;PPU address high byte.
  3871. LA008:  .byte $18           ;PPU address low byte.
  3872. LA009:  .byte $08           ;PPU string length.
  3873. ;The following values are written to the sprite palette starting at $3F18:
  3874. LA00A:  .byte $0F, $1C, $2C, $3C, $0F, $01, $11, $21
  3875.  
  3876. LA012:  .byte $00           ;End EndGamePal07 data.
  3877.  
  3878. EndGamePal08:
  3879. LA013:  .byte $3F           ;PPU address high byte.
  3880. LA014:  .byte $0C           ;PPU address low byte.
  3881. LA015:  .byte $04           ;PPU string length.
  3882. ;The following values are written to the background palette starting at $3F0C:
  3883. LA016:  .byte $0F, $18, $08, $07
  3884.  
  3885. LA01A:  .byte $3F           ;PPU address high byte.
  3886. LA01B:  .byte $10           ;PPU address low byte.
  3887. LA01C:  .byte $10           ;PPU string length.
  3888. ;The following values are written to the sprite palette:
  3889. LA01D:  .byte $0F, $26, $05, $07, $0F, $26, $05, $07, $0F, $01, $01, $05, $0F, $13, $1C, $0C
  3890.  
  3891. LA02D:  .byte $00           ;End EndGamePal08 data.
  3892.  
  3893. EndGamePal09:
  3894. LA02E:  .byte $3F           ;PPU address high byte.
  3895. LA02F:  .byte $0C           ;PPU address low byte.
  3896. LA030:  .byte $04           ;PPU string length.
  3897. ;The following values are written to the background palette starting at $3F0C:
  3898. LA031:  .byte $0F, $08, $07, $0F
  3899.  
  3900. LA035:  .byte $3F           ;PPU address high byte.
  3901. LA036:  .byte $10           ;PPU address low byte.
  3902. LA037:  .byte $10           ;PPU string length.
  3903. ;The following values are written to the sprite palette:
  3904. LA038:  .byte $0F, $06, $08, $0F, $0F, $06, $08, $0F, $0F, $00, $10, $0F, $0F, $01, $0C, $0F
  3905.  
  3906. LA048:  .byte $00           ;End EndGamePal09 data.
  3907.  
  3908. EndGamePal0A:
  3909. LA049:  .byte $3F           ;PPU address high byte.
  3910. LA04A:  .byte $0C           ;PPU address low byte.
  3911. LA04B:  .byte $44           ;PPU string length.
  3912. LA04C:  .byte $0F           ;Repeat bit set. Fill background palette with #$0F-->
  3913.                     ;starting at $0C.
  3914. LA04D:  .byte $3F           ;PPU address high byte.
  3915. LA04E:  .byte $10           ;PPU address low byte.
  3916. LA04F:  .byte $50           ;PPU string length.
  3917. LA050:  .byte $0F           ;Repeat bit set. Fill sprite palette with #$0F.
  3918.  
  3919. LA051:  .byte $00           ;End EndGamePal0A data.
  3920.  
  3921. ;The following data writes the end game backgroud graphics.
  3922.  
  3923. ;Writes ground graphics on name table 0 in row $2300 (25th row from top).
  3924. LA052:  .byte $23           ;PPU address high byte.
  3925. LA053:  .byte $00           ;PPU address low byte.
  3926. LA054:  .byte $20           ;PPU string length.
  3927. LA055:  .byte $30, $31, $30, $31, $30, $31, $30, $31, $30, $31, $30, $31, $30, $31, $30, $31
  3928. LA065:  .byte $30, $31, $30, $31, $30, $31, $30, $31, $30, $31, $30, $31, $30, $31, $30, $31
  3929.  
  3930. ;Writes ground graphics on name table 0 in row $2320 (26th row from top).
  3931. LA075:  .byte $23           ;PPU address high byte.
  3932. LA076:  .byte $20           ;PPU address low byte.
  3933. LA077:  .byte $20           ;PPU string length.
  3934. LA078:  .byte $32, $33, $32, $33, $32, $33, $32, $33, $32, $33, $32, $33, $32, $33, $32, $33
  3935. LA088:  .byte $32, $33, $32, $33, $32, $33, $32, $33, $32, $33, $32, $33, $32, $33, $32, $33
  3936.  
  3937. ;Writes ground graphics on name table 0 in row $2340 (27th row from top).
  3938. LA098:  .byte $23           ;PPU address high byte.
  3939. LA099:  .byte $40           ;PPU address low byte.
  3940. LA09A:  .byte $20           ;PPU string length.
  3941. LA09B:  .byte $34, $35, $34, $35, $34, $35, $34, $35, $34, $35, $34, $35, $34, $35, $34, $35
  3942. LA0AB:  .byte $34, $35, $34, $35, $34, $35, $34, $35, $34, $35, $34, $35, $34, $35, $34, $35
  3943.  
  3944. ;Writes ground graphics on name table 0 in row $2360 (28th row from top).
  3945. LA0BB:  .byte $23           ;PPU address high byte.
  3946. LA0BC:  .byte $60           ;PPU address low byte.
  3947. LA0BD:  .byte $20           ;PPU string length.
  3948. LA0BE:  .byte $36, $37, $36, $37, $36, $37, $36, $37, $36, $37, $36, $37, $36, $37, $36, $37
  3949. LA0CE:  .byte $36, $37, $36, $37, $36, $37, $36, $37, $36, $37, $36, $37, $36, $37, $36, $37
  3950.  
  3951. ;Writes ground graphics on name table 0 in row $2380 (29th row from top).
  3952. LA0DE:  .byte $23           ;PPU address high byte.
  3953. LA0DF:  .byte $80           ;PPU address low byte.
  3954. LA0E0:  .byte $20           ;PPU string length.
  3955. LA0E1:  .byte $38, $39, $38, $39, $38, $39, $38, $39, $38, $39, $38, $39, $38, $39, $38, $39
  3956. LA0F1:  .byte $38, $39, $38, $39, $38, $39, $38, $39, $38, $39, $38, $39, $38, $39, $38, $39
  3957.  
  3958. ;Writes ground graphics on name table 0 in row $23A0 (bottom row).
  3959. LA101:  .byte $23           ;PPU address high byte.
  3960. LA102:  .byte $A0           ;PPU address low byte.
  3961. LA103:  .byte $20           ;PPU string length.
  3962. LA104:  .byte $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B
  3963. LA114:  .byte $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B, $3A, $3B
  3964.  
  3965. ;Sets all color bits in attribute table 0 starting at $23F0.
  3966. LA124:  .byte $23           ;PPU address high byte.
  3967. LA125:  .byte $F0           ;PPU address low byte.
  3968. LA126:  .byte $50           ;PPU string length.
  3969. LA127:  .byte $FF           ;Repeat bit set. Repeats entry 16 times.
  3970.  
  3971. ;Writes credits on name table 2 in row $2820 (2nd row from top).
  3972. LA128:  .byte $28           ;PPU address high byte.
  3973. LA129:  .byte $2E           ;PPU address low byte.
  3974. LA12A:  .byte $05           ;PPU string length.
  3975. ;             'S    T    A    F    F'
  3976. LA12B:  .byte $1C, $1D, $0A, $0F, $0F
  3977.  
  3978. ;Writes credits on name table 2 in row $28A0 (6th row from top).
  3979. LA130:  .byte $28           ;PPU address high byte.
  3980. LA131:  .byte $A8           ;PPU address low byte.
  3981. LA132:  .byte $13           ;PPU string length.
  3982. ;             'S    C    E    N    A    R    I    O    _    W    R    I    T    T    E    N'
  3983. LA133:  .byte $1C, $0C, $0E, $17, $0A, $1B, $12, $18, $FF, $20, $1B, $12, $1D, $1D, $0E, $17
  3984. ;             '_    B    Y'
  3985. LA143:  .byte $FF, $0B, $22
  3986.  
  3987. ;Writes credits on name table 2 in row $28E0 (8th row from top).
  3988. LA146:  .byte $28           ;PPU address high byte.
  3989. LA147:  .byte $EE           ;PPU address low byte.
  3990. LA148:  .byte $05           ;PPU string length.
  3991. ;             'K    A    N    O    H'
  3992. LA149:  .byte $14, $0A, $17, $18, $11
  3993.  
  3994. ;Writes credits on name table 2 in row $2960 (12th row from top).
  3995. LA14E:  .byte $29           ;PPU address high byte.
  3996. LA14F:  .byte $66           ;PPU address low byte.
  3997. LA150:  .byte $15           ;PPU string length.
  3998. ;             'C    H    A    R    A    C    T    E    R    _    D    E    S    I    G    N'
  3999. LA151:  .byte $0C, $11, $0A, $1B, $0A, $0C, $1D, $0E, $1B, $FF, $0D, $0E, $1C, $12, $10, $17
  4000. ;             'E    D    _    B    Y'
  4001. LA161:  .byte $0E, $0D, $FF, $0B, $22
  4002.  
  4003. ;Writes credits on name table 2 in row $29A0 (14th row from top).
  4004. LA166:  .byte $29           ;PPU address high byte.
  4005. LA167:  .byte $AC           ;PPU address low byte.
  4006. LA168:  .byte $08           ;PPU string length.
  4007. ;             'K    I    Y    O    T    A    K    E'
  4008. LA169:  .byte $14, $12, $22, $18, $1D, $0A, $14, $0E
  4009.  
  4010. ;Writes credits on name table 2 in row $2A20 (18th row from top).
  4011. LA16A:  .byte $2A           ;PPU address high byte.
  4012. LA16B:  .byte $2B           ;PPU address low byte.
  4013. LA173:  .byte $0C           ;PPU string length.
  4014. ;             'N    E    W    _    M    A    T    S    U    O    K    A'
  4015. LA174:  .byte $17, $0E, $20, $FF, $16, $0A, $1D, $1C, $1E, $18, $14, $0A
  4016.  
  4017. ;Writes credits on name table 2 in row $2A60 (20th row from top).
  4018. LA180:  .byte $2A           ;PPU address high byte.
  4019. LA181:  .byte $6C           ;PPU address low byte.
  4020. LA182:  .byte $09           ;PPU string length.
  4021. ;             'S    H    I    K    A    M    O    T    O'
  4022. LA183:  .byte $1C, $11, $12, $14, $0A, $16, $18, $1D, $18
  4023.  
  4024. ;Writes credits on name table 2 in row $2AE0 (24th row from top).
  4025. LA18C:  .byte $2A           ;PPU address high byte.
  4026. LA18D:  .byte $EC           ;PPU address low byte.
  4027. LA18E:  .byte $08           ;PPU string length.
  4028. ;             'M    U    S    I    C    _    B    Y'
  4029. LA18F:  .byte $16, $1E, $1C, $12, $0C, $FF, $0B, $22
  4030.  
  4031. ;Writes credits on name table 2 in row $2B20 (26th row from top)
  4032. LA197:  .byte $2B           ;PPU address high byte.
  4033. LA198:  .byte $2B           ;PPU address low byte.
  4034. LA199:  .byte $0A           ;PPU string length.
  4035. ;             'H    I    P    _    T    A    N    A    K    A'
  4036. LA19A:  .byte $11, $12, $19, $FF, $1D, $0A, $17, $0A, $14, $0A
  4037.  
  4038. ;Writes credits on name table 2 in row $2BA0 (bottom row).
  4039. LA1A4:  .byte $2B           ;PPU address high byte.
  4040. LA1A5:  .byte $A7           ;PPU address low byte.
  4041. LA1A6:  .byte $12           ;PPU string length.
  4042. ;             '_    M    A    I    N    _    P    R    O    G    R    A    M    M    E    R'
  4043. LA1A7:  .byte $FF, $16, $0A, $12, $17, $FF, $19, $1B, $18, $10, $1B, $0A, $16, $16, $0E, $1B
  4044. ;             'S    _'
  4045. LA1B7:  .byte $1C, $FF
  4046.  
  4047. LA1B9:  .byte $00           ;End PPU string write.
  4048.  
  4049. ;The following pointer table is accessed by the NMIScreenWrite routine.
  4050. ;It is used to locate the start of the PPU strings below.
  4051.  
  4052. EndMessageStringTbl0:
  4053. LA1BA:  .word $A1C2, $A1EB, $A20F, $A240
  4054.  
  4055. ;Writes end message on name table 0 in row $2060 (4th row from top).
  4056. LA1C2:  .byte $20           ;PPU address high byte.
  4057. LA1C3:  .byte $6D           ;PPU address low byte.
  4058. LA1C4:  .byte $08           ;PPU string length.
  4059. ;             'G    R    E    A    T    _    !    !'
  4060. LA1C5:  .byte $10, $1B, $0E, $0A, $1D, $FF, $3F, $3F
  4061.  
  4062. ;Writes end message on name table 0 in row $20C0 (7th row from top).
  4063. LA1CD:  .byte $20           ;PPU address high byte.
  4064. LA1CE:  .byte $C3           ;PPU address low byte.
  4065. LA1CF:  .byte $1A           ;PPU string length.
  4066. ;             'Y    O    U    _    F    U    L    F    I    L    E    D    _    Y    O    U'
  4067. LA1D0:  .byte $22, $18, $1E, $FF, $0F, $1E, $15, $0F, $12, $15, $0E, $0D, $FF, $22, $18, $1E
  4068. ;             'R    _    M    I    S    S    I    O    N    .'
  4069. LA1E0:  .byte $1B, $FF, $16, $12, $1C, $1C, $12, $18, $17, $07
  4070.  
  4071. LA1EA:  .byte $00           ;End PPU string write.
  4072.  
  4073. ;Writes end message on name table 0 in row $2100 (9th row from top).
  4074. LA1EB:  .byte $21           ;PPU address high byte.
  4075. LA1EC:  .byte $03           ;PPU address low byte.
  4076. LA1ED:  .byte $17           ;PPU string length.
  4077. ;             'I    T    _    W    I    L    L    _    R    E    V    I    V    E    _    P'
  4078. LA1EE:  .byte $12, $1D, $FF, $20, $12, $15, $15, $FF, $1B, $0E, $1F, $12, $1F, $0E, $FF, $19
  4079. ;             'E    A    C    E    _    I    N'
  4080. LA1FE:  .byte $0E, $0A, $0C, $0E, $FF, $12, $17
  4081.  
  4082. ;Writes end message on name table 0 in row $2140 (11th row from top).
  4083. LA205:  .byte $21           ;PPU address high byte.
  4084. LA206:  .byte $42           ;PPU address low byte.
  4085. LA207:  .byte $06           ;PPU string length.
  4086. ;             'S    P    A    C    E    .'
  4087. LA208:  .byte $1C, $19, $0A, $0C, $0E, $07
  4088.  
  4089. LA209:  .byte $00           ;End PPU string write.
  4090.  
  4091. ;Writes end message on name table 0 in row $2180 (13th row from top).
  4092. LA20F:  .byte $21           ;PPU address high byte.
  4093. LA210:  .byte $83           ;PPU address low byte.
  4094. LA211:  .byte $18           ;PPU string length.
  4095. ;             'B    U    T    ,    I    T    _    M    A    Y    _    B    E    _    I    N'
  4096. LA212:  .byte $0B, $1E, $1D, $00, $12, $1D, $FF, $16, $0A, $22, $FF, $0B, $0E, $FF, $12, $17
  4097. ;             'V    A    D    E    D    _    B    Y'
  4098. LA222:  .byte $1F, $0A, $0D, $0E, $0D, $FF, $0B, $22
  4099.  
  4100. ;Writes end message on name table 0 in row $21C0 (15th row from top).
  4101. LA22A:  .byte $21           ;PPU address high byte.
  4102. LA22B:  .byte $C2           ;PPU address low byte.
  4103. LA22C:  .byte $12           ;PPU string length.
  4104. ;             'T    H    E    _    O    T    H    E    R    _    M    E    T    R    O    I'
  4105. LA22D:  .byte $1D, $11, $0E, $FF, $18, $1D, $11, $0E, $1B, $FF, $16, $0E, $1D, $1B, $18, $12
  4106. ;             'D    .'
  4107. LA23D:  .byte $0D, $07
  4108.  
  4109. LA23F:  .byte $00           ;End PPU string write.
  4110.  
  4111. ;Writes end message on name table 0 in row $2200 (18th row from top).
  4112. LA240:  .byte $22           ;PPU address high byte.
  4113. LA241:  .byte $03           ;PPU address low byte.
  4114. LA242:  .byte $18           ;PPU string length.
  4115. ;             'P    R    A    Y    _    F    O    R    _    A    _    T    R    U    E    _'
  4116. LA243:  .byte $19, $1B, $0A, $22, $FF, $0F, $18, $1B, $FF, $0A, $FF, $1D, $1B, $1E, $0E, $FF
  4117. ;             'P    E    A    C    E    _    I    N'
  4118. LA253:  .byte $19, $0E, $0A, $0C, $0E, $FF, $12, $17
  4119.  
  4120. ;Writes end message on name table 0 in row $2240 (19th row from top).
  4121. LA25B:  .byte $22           ;PPU address high byte.
  4122. LA25C:  .byte $42           ;PPU address low byte.
  4123. LA25D:  .byte $06           ;PPU string length.
  4124. ;             'S    P    A    C    E    !'
  4125. LA25E:  .byte $1C, $19, $0A, $0C, $0E, $3F
  4126.  
  4127. LA25F:  .byte $00           ;End PPU string write.
  4128.  
  4129. ;The following pointer table is accessed by the NMIScreenWrite routine.
  4130. ;It is used to locate the start of the PPU strings below.
  4131.  
  4132. EndMessageStringTbl1:
  4133. LA265:  .word $A26D, $A276, $A27F, $A288
  4134.  
  4135. ;Erases end message on name table 0 in row $2060 (4th row from top).
  4136. LA26D:  .byte $20           ;PPU address high byte.
  4137. LA26E:  .byte $6D           ;PPU address low byte.
  4138. LA26F:  .byte $48           ;PPU string length.
  4139. LA270:  .byte $FF           ;Repeat bit set. Repeats entry 8 times.
  4140.  
  4141. ;Erases end message on name table 0 in row $20C0 (7th row from top).
  4142. LA271:  .byte $20           ;PPU address high byte.
  4143. LA272:  .byte $C3           ;PPU address low byte.
  4144. LA273:  .byte $5A           ;PPU string length.
  4145. LA274:  .byte $FF           ;Repeat bit set. Repeats entry 26 times.
  4146.  
  4147. LA275:  .byte $00           ;End PPU string write.
  4148.  
  4149. ;Erases end message on name table 0 in row $2100 (9th row from top).
  4150. LA276:  .byte $21           ;PPU address high byte.
  4151. LA277:  .byte $03           ;PPU address low byte.
  4152. LA278:  .byte $57           ;PPU string length.
  4153. LA279:  .byte $FF           ;Repeat bit set. Repeats entry 23 times.
  4154.  
  4155. ;Erases end message on name table 0 in row $2140 (11th row from top).
  4156. LA27A:  .byte $21           ;PPU address high byte.
  4157. LA27B:  .byte $42           ;PPU address low byte.
  4158. LA27C:  .byte $4A           ;PPU string length.
  4159. LA27D:  .byte $FF           ;Repeat bit set. Repeats entry 10 times.
  4160.  
  4161. LA27E:  .byte $00           ;End PPU string write.
  4162.  
  4163. ;Erases end message on name table 0 in row $2180 (13th row from top).
  4164. LA27F:  .byte $21           ;PPU address high byte.
  4165. LA280:  .byte $83           ;PPU address low byte.
  4166. LA281:  .byte $58           ;PPU string length.
  4167. LA282:  .byte $FF           ;Repeat bit set. Repeats entry 24 times.
  4168.  
  4169. ;Erases end message on name table 0 in row $21C0 (15th row from top).
  4170. LA283:  .byte $21           ;PPU address high byte.
  4171. LA284:  .byte $C2           ;PPU address low byte.
  4172. LA285:  .byte $52           ;PPU string length.
  4173. LA286:  .byte $FF           ;Repeat bit set. Repeats entry 12 times.
  4174.  
  4175. LA287:  .byte $00           ;End PPU string write.
  4176.  
  4177. ;Erases end message on name table 0 in row $2200 (18th row from top).
  4178. LA288:  .byte $22           ;PPU address high byte.
  4179. LA289:  .byte $03           ;PPU address low byte.
  4180. LA28A:  .byte $58           ;PPU string length.
  4181. LA28B:  .byte $FF           ;Repeat bit set. Repeats entry 24 times.
  4182.  
  4183.  
  4184. ;Erases end message on name table 0 in row $2240 (19th row from top).
  4185. LA28C:  .byte $22           ;PPU address high byte.
  4186. LA28D:  .byte $42           ;PPU address low byte.
  4187. LA28E:  .byte $4A           ;PPU string length.
  4188. LA28F:  .byte $FF           ;Repeat bit set. Repeats entry 10 times.
  4189.  
  4190. LA290:  .byte $00           ;End PPU string write
  4191.  
  4192. ;The following table is used by the LoadCredits routine to load the end credits on the screen.
  4193.  
  4194. CreditsPointerTbl:
  4195. LA291:  .word $A2E9, $A2FB, $A31A, $A31B, $A32D, $A339, $A34F, $A362, $A375, $A384, $A39F, $A3AA
  4196. LA2A9:  .word $A3C8, $A3D8, $A3F1, $A412, $A417, $A426, $A442, $A46B, $A470, $A493, $A49C, $A4AD
  4197. LA2C1:  .word $A4BD, $A4CD, $A4D2, $A4D7, $A4DC, $A4E1, $A4E6, $A4EB, $A4EF, $A4F0, $A508, $A51A
  4198. LA2D9:  .word $A51F, $A524, $A51F, $A524, $A538, $A53D, $A538, $A53D
  4199.  
  4200. ;Writes credits on name table 0 in row $2020 (2nd row from top).
  4201. LA2E9:  .byte $20           ;PPU address high byte.
  4202. LA2EA:  .byte $2C           ;PPU address low byte.
  4203. LA2EB:  .byte $0A           ;PPU string length.
  4204. ;             'H    A    I    _    Y    U    K    A    M    I'
  4205. LA2EC:  .byte $11, $0A, $12, $FF, $22, $1E, $14, $0A, $16, $12
  4206.  
  4207. ;Clears attribute table 0 starting at $23C0.
  4208. LA2F6:  .byte $23           ;PPU address high byte.
  4209. LA2F7:  .byte $C0           ;PPU address low byte.
  4210. LA2F8:  .byte $60           ;PPU string length.
  4211. LA2F9:  .byte $00           ;Repeat bit set. Repeats entry 32 times.
  4212.  
  4213. LA2FA:  .byte $00           ;End PPU string write.
  4214.  
  4215. ;Writes credits on name table 0 in row $2060 (4th row from top)
  4216. LA2FB:  .byte $20           ;PPU address high byte.
  4217. LA2FC:  .byte $6A           ;PPU address low byte.
  4218. LA2FD:  .byte $0D           ;PPU string length.
  4219. ;             'Z    A    R    U    _    S    O    B    A    J    I    M    A'
  4220. LA2FE:  .byte $23, $0A, $1B, $1E, $FF, $1C, $18, $0B, $0A, $13, $12, $16, $0A
  4221.  
  4222. ;Writes credits on name table 0 in row $20A0 (6th row from top).
  4223. LA30B:  .byte $20           ;PPU address high byte.
  4224. LA30C:  .byte $AB           ;PPU address low byte.
  4225. LA30D:  .byte $0B           ;PPU string length.
  4226. ;             'G    P    Z    _    S    E    N    G    O    K    U'
  4227. LA30E:  .byte $10, $19, $23, $FF, $1C, $0E, $17, $10, $18, $14, $1E
  4228.  
  4229. LA319:  .byte $00           ;End PPU string write.
  4230. LA31A:  .byte $00           ;End PPU string write.
  4231.  
  4232. ;Writes credits on name table 0 in row $2160 (12th row from top).
  4233. LA31B:  .byte $21           ;PPU address high byte.
  4234. LA31C:  .byte $6A           ;PPU address low byte.
  4235. LA31D:  .byte $0A           ;PPU string length.
  4236. ;             'N    .    S    H    I    O    T    A    N    I'
  4237. LA31E:  .byte $17, $07, $1C, $11, $12, $18, $1D, $0A, $17, $12
  4238.  
  4239. ;Clears attribute table 0 starting at $23E0
  4240. LA328:  .byte $23           ;PPU address high byte.
  4241. LA329:  .byte $E0           ;PPU address low byte.
  4242. LA32A:  .byte $60           ;PPU string length.
  4243. LA32B:  .byte $00           ;Repeat bit set. Repeats entry 32 times.
  4244.  
  4245. LA32C:  .byte $00           ;End PPU string write.
  4246.  
  4247. ;Writes credits on name table 0 in row $21E0 (16th row from top).
  4248. LA32D:  .byte $21           ;PPU address high byte.
  4249. LA32E:  .byte $EB           ;PPU address low byte.
  4250. LA32F:  .byte $08           ;PPU string length.
  4251. ;             'M    .    H    O    U    D    A    I'
  4252. LA330:  .byte $16, $07, $11, $18, $1E, $0D, $0A, $12
  4253.  
  4254. LA338:  .byte $00           ;End PPU string write.
  4255.  
  4256. ;Writes credits on name table 0 in row $22A0 (22nd row from top).
  4257. LA339:  .byte $22           ;PPU address high byte.
  4258. LA33A:  .byte $A7           ;PPU address low byte.
  4259. LA33B:  .byte $12           ;PPU string length.
  4260. ;             'S    P    E    C    I    A    L    _    T    H    A    N    K    S    _    _ '
  4261. LA33C:  .byte $1C, $19, $0E, $0C, $12, $0A, $15, $FF, $1D, $11, $0A, $17, $14, $1C, $FF, $FF
  4262. ;             'T    O'
  4263. LA34C:  .byte $1D, $18
  4264.  
  4265. LA34E:  .byte $00           ;End PPU string write.
  4266.  
  4267. ;Writes credits on name table 0 in row $22E0 (24nd row from top).
  4268. LA34F:  .byte $22           ;PPU address high byte.
  4269. LA350:  .byte $EC           ;PPU address low byte.
  4270. LA351:  .byte $08           ;PPU string length.
  4271. ;             'K    E    N    _    Z    U    R    I'
  4272. LA352:  .byte $14, $0E, $17, $FF, $23, $1E, $1B, $12
  4273.  
  4274. ;Writes credits on name table 0 in row $2320 (26nd row from top).
  4275. LA35A:  .byte $23           ;PPU address high byte.
  4276. LA35B:  .byte $2E           ;PPU address low byte.
  4277. LA35C:  .byte $04           ;PPU string length.
  4278. ;             'S    U    M    I'
  4279. LA35D:  .byte $1C, $1E, $16, $12
  4280.  
  4281. LA361:  .byte $00           ;End PPU string write.
  4282.  
  4283. ;Writes credits on name table 0 in row $2360 (28nd row from top).
  4284. LA362:  .byte $23           ;PPU address high byte.
  4285. LA363:  .byte $6C           ;PPU address low byte.
  4286. LA364:  .byte $07           ;PPU string length.
  4287. ;             'I    N    U    S    A    W    A'
  4288. LA365:  .byte $12, $17, $1E, $1C, $0A, $20, $0A
  4289.  
  4290. ;Writes credits on name table 0 in row $23A0 (bottom row).
  4291. LA36C:  .byte $23           ;PPU address high byte.
  4292. LA36D:  .byte $AD           ;PPU address low byte.
  4293. LA36E:  .byte $05           ;PPU string length.
  4294. ;             'K    A    C    H    O'
  4295. LA36F:  .byte $14, $0A, $0C, $11, $18
  4296.  
  4297. LA374:  .byte $00           ;End PPU string write.
  4298.  
  4299. ;Writes credits on name table 2 in row $2820 (2nd row from top).
  4300. LA375:  .byte $28           ;PPU address high byte.
  4301. LA376:  .byte $28           ;PPU address low byte.
  4302. LA377:  .byte $4E           ;PPU string length.
  4303. LA378:  .byte $FF           ;Repeat bit set. Repeats entry 14 times.
  4304.  
  4305. ;Writes credits on name table 2 in row $2860 (4th row from top).
  4306. LA379:  .byte $28           ;PPU address high byte.
  4307. LA37A:  .byte $6C           ;PPU address low byte.
  4308. LA37B:  .byte $07           ;PPU string length.
  4309. ;             'H    Y    A    K    K    A    N'
  4310. LA37C:  .byte $11, $22, $0A, $14, $14, $0A, $17
  4311.  
  4312. LA383:  .byte $00           ;End PPU string write.
  4313.  
  4314. ;Writes credits on name table 2 in row $28A0 (6th row from top).
  4315. LA384:  .byte $28           ;PPU address high byte.
  4316. LA385:  .byte $A8           ;PPU address low byte.
  4317. LA386:  .byte $13           ;PPU string length.
  4318. ;             '_    _    _    _    _    G    O    Y    A    K    E    _    _    _    _    _'
  4319. LA387:  .byte $FF, $FF, $FF, $FF, $FF, $10, $18, $22, $0A, $14, $0E, $FF, $FF, $FF, $FF, $FF
  4320. ;             '_    _    _'
  4321. LA397:  .byte $FF, $FF, $FF
  4322.  
  4323. ;Writes credits on name table 2 in row $28E0 (8th row from top).
  4324. LA39A:  .byte $28           ;PPU address high byte.
  4325. LA39B:  .byte $E8           ;PPU address low byte.
  4326. LA39C:  .byte $4F           ;PPU string length.
  4327. LA39D:  .byte $FF           ;Repeat bit set. Repeats entry 15 times.
  4328.  
  4329. LA39E:  .byte $00           ;End PPU string write.
  4330.  
  4331. ;Writes credits on name table 2 in row $2920 (10th row from top).
  4332. LA39F:  .byte $29           ;PPU address high byte.
  4333. LA3A0:  .byte $2C           ;PPU address low byte.
  4334. LA3A1:  .byte $07           ;PPU string length.
  4335. ;             'H    A    R    A    D    A    _'
  4336. LA3A2:  .byte $11, $0A, $1B, $0A, $0D, $0A, $FF
  4337.  
  4338. LA3A9:  .byte $00           ;End PPU string write.
  4339.  
  4340. ;Writes credits on name table 2 in row $2960 (12th row from top).
  4341. LA3AA:  .byte $29           ;PPU address high byte.
  4342. LA3AB:  .byte $66           ;PPU address low byte.
  4343. LA3AC:  .byte $16           ;PPU string length.
  4344. ;             '_    _    _    _    _    _    _    P    E    N    P    E    N    _    _    _'
  4345. LA3AD:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $19, $0E, $17, $19, $0E, $17, $FF, $FF, $FF
  4346. ;             '_    _    _    _    _    _'
  4347. LA3BD:  .byte $FF, $FF, $FF, $FF, $FF, $FF
  4348.  
  4349. ;Writes credits on name table 2 in row $29A0 (14th row from top).
  4350. LA3C3:  .byte $29           ;PPU address high byte.
  4351. LA3C4:  .byte $A8           ;PPU address low byte.
  4352. LA3C5:  .byte $4F           ;PPU string length.
  4353. LA3C6:  .byte $FF           ;Repeat bit set. Repeats entry 15 times.
  4354.  
  4355. LA3C7:  .byte $00           ;End PPU string write.
  4356.  
  4357. ;Writes credits on name table 2 in row $29E0 (16th row from top).
  4358. LA3C8:  .byte $29           ;PPU address high byte.
  4359. LA3C9:  .byte $EA           ;PPU address low byte.
  4360. LA3CA:  .byte $0C           ;PPU string length.
  4361. ;             'C    O    N    V    E    R    T    E    D    _    B    Y'
  4362. LA3CB:  .byte $0C, $18, $17, $1F, $0E, $1B, $1D, $0E, $0D, $FF, $0B, $22
  4363.  
  4364. LA3D7:  .byte $00           ;End PPU string write.
  4365.  
  4366. ;Writes credits on name table 2 in row $2A20 (18th row from top).
  4367. LA3D8:  .byte $2A           ;PPU address high byte.
  4368. LA3D9:  .byte $26           ;PPU address low byte.
  4369. LA3DA:  .byte $11           ;PPU string length.
  4370. ;             '_    _    _    _    _    T    .    N    A    R    I    H    I    R    O    _'
  4371. LA3DB:  .byte $FF, $FF, $FF, $FF, $FF, $1D, $07, $17, $0A, $1B, $12, $11, $12, $1B, $18, $FF
  4372. ;             '_'
  4373. LA3EB:  .byte $FF
  4374.  
  4375. ;Writes credits on name table 2 in row $2A60 (20th row from top).
  4376. LA3EC:  .byte $2A           ;PPU address high byte.
  4377. LA3ED:  .byte $67           ;PPU address low byte.
  4378. LA3EE:  .byte $51           ;PPU string length.
  4379. LA3EF:  .byte $FF           ;Repeat bit set. Repeats entry 17 times.
  4380.  
  4381. LA3F0:  .byte $00           ;End PPU string write.
  4382.  
  4383. ;Writes credits on name table 2 in row $2AE0 (24th row from top).
  4384. LA3F1:  .byte $2A           ;PPU address high byte.
  4385. LA3F2:  .byte $EB           ;PPU address low byte.
  4386. LA3F3:  .byte $0B           ;PPU string length.
  4387. ;             'A    S    S    I    S    T    E    D    _    B    Y'
  4388. LA3F4:  .byte $0A, $1C, $1C, $12, $1C, $1D, $0E, $0D, $FF, $0B, $22
  4389.  
  4390. ;Writes credits on name table 2 in row $2B20 (26th row from top).
  4391. LA3FF:  .byte $2B           ;PPU address high byte.
  4392. LA400:  .byte $28           ;PPU address low byte.
  4393. LA401:  .byte $0F           ;PPU string length.
  4394. ;             '_    _    _    M    A    K    O    T    O    _    K    A    N    O    H'
  4395. LA402:  .byte $FF, $FF, $FF, $16, $0A, $14, $18, $1D, $18, $FF, $14, $0A, $17, $18, $11
  4396.  
  4397. LA411:  .byte $00           ;End PPU string write.
  4398.  
  4399. ;Writes credits on name table 2 in row $2BA0 (bottom row).
  4400. LA412:  .byte $2B           ;PPU address high byte.
  4401. LA413:  .byte $A6           ;PPU address low byte.
  4402. LA414:  .byte $53           ;PPU string length.
  4403. LA415:  .byte $FF           ;Repeat bit set. Repeats entry 19 times.
  4404.  
  4405. LA416:  .byte $00           ;End PPU string write.
  4406.  
  4407. ;Writes credits on name table 0 in row $2020 (2nd row from the top).
  4408. LA417:  .byte $20           ;PPU address high byte.
  4409. LA418:  .byte $2B           ;PPU address low byte.
  4410. LA419:  .byte $0B           ;PPU string length.
  4411. ;             'D    I    R    E    C    T    E    D    _    B    Y'
  4412. LA41A:  .byte $0D, $12, $1B, $0E, $0C, $1D, $0E, $0D, $FF, $0B, $22
  4413.  
  4414. LA425:  .byte $00           ;End PPU string write.
  4415.  
  4416. ;Writes credits on name table 0 in row $2060 (4th row from the top).
  4417. LA426:  .byte $20           ;PPU address high byte.
  4418. LA427:  .byte $67           ;PPU address low byte.
  4419. LA428:  .byte $14           ;PPU string length.
  4420. ;             '_    _    _    _    _    Y    A    M    A    M    O    T    O    _    _    _'
  4421. LA429:  .byte $FF, $FF, $FF, $FF, $FF, $22, $0A, $16, $0A, $16, $18, $1D, $18, $FF, $FF, $FF
  4422. ;             '_    _    _    _'
  4423. LA439:  .byte $FF, $FF, $FF, $FF
  4424.  
  4425. ;Writes credits on name table 0 in row $20A0 (6th row from the top).
  4426. LA43D:  .byte $20           ;PPU address high byte.
  4427. LA43E:  .byte $AA           ;PPU address low byte.
  4428. LA43F:  .byte $4E           ;PPU string length.
  4429. LA440:  .byte $FF           ;Repeat bit set. Repeats entry 14 times.
  4430.  
  4431. LA441:  .byte $00           ;End PPU string write.
  4432.  
  4433. ;Writes credits on name table 0 in row $2120 (10th row from the top).
  4434. LA442:  .byte $21           ;PPU address high byte.
  4435. LA443:  .byte $27           ;PPU address low byte.
  4436. LA444:  .byte $11           ;PPU string length.
  4437. ;             '_    _    C    H    I    E    F    _    D    I    R    E    C    T    O    R'
  4438. LA445:  .byte $FF, $FF, $0C, $11, $12, $0E, $0F, $FF, $0D, $12, $1B, $0E, $0C, $1D, $18, $1B
  4439. ;             '_'
  4440. LA455:  .byte $FF
  4441.  
  4442. ;Writes credits on name table 0 in row $2160 (12th row from the top).
  4443. LA456:  .byte $21           ;PPU address high byte.
  4444. LA457:  .byte $68           ;PPU address low byte.
  4445. LA458:  .byte $11           ;PPU string length.
  4446. ;             '_    _    S    A    T    O    R    U    _    O    K    A    D    A    _    _'
  4447. LA459:  .byte $FF, $FF, $1C, $0A, $1D, $18, $1B, $1E, $FF, $18, $14, $0A, $0D, $0A, $FF, $FF
  4448. ;             '_'
  4449. LA469:  .byte $FF
  4450.  
  4451. LA46A:  .byte $00           ;End PPU string write.
  4452.  
  4453. ;Writes credits on name table 0 in row $21E0 (16th row from the top).
  4454. LA46B:  .byte $21           ;PPU address high byte.
  4455. LA46C:  .byte $E6           ;PPU address low byte.
  4456. LA46D:  .byte $58           ;PPU string length.
  4457. LA46E:  .byte $FF           ;Repeat bit set. Repeats entry 24 times.
  4458.  
  4459. LA46F:  .byte $00           ;End PPU string write.
  4460.  
  4461. ;Writes credits on name table 0 in row $2220 (18th row from the top).
  4462. LA470:  .byte $22           ;PPU address high byte.
  4463. LA471:  .byte $2B           ;PPU address low byte.
  4464. LA472:  .byte $10           ;PPU string length.
  4465. ;             'P    R    O    D    U    C    E    D    _    B    Y    _    _    _    _    _'
  4466. LA473:  .byte $19, $1B, $18, $0D, $1E, $0C, $0E, $0D, $FF, $0B, $22, $FF, $FF, $FF, $FF, $FF
  4467.  
  4468. ;Writes credits on name table 0 in row $2260 (20th row from the top).
  4469. LA483:  .byte $22           ;PPU address high byte.
  4470. LA484:  .byte $6A           ;PPU address low byte.
  4471. LA485:  .byte $0C           ;PPU string length.
  4472. ;             'G    U    N    P    E    I    _    Y    O    K    O    I'
  4473. LA486:  .byte $10, $1E, $17, $19, $0E, $12, $FF, $22, $18, $14, $18, $12
  4474.  
  4475. LA492:  .byte $00           ;End PPU string write.
  4476.  
  4477. ;Writes credits on name table 0 in row $22A0 (22nd row from the top).
  4478. LA493:  .byte $22           ;PPU address high byte.
  4479. LA494:  .byte $A6           ;PPU address low byte.
  4480. LA495:  .byte $53           ;PPU string length.
  4481. LA496:  .byte $FF           ;Repeat bit set. Repeats entry 19 times.
  4482.  
  4483. ;Writes credits on name table 0 in row $22E0 (24th row from the top).
  4484. LA497:  .byte $22           ;PPU address high byte.
  4485. LA498:  .byte $E8           ;PPU address low byte.
  4486. LA499:  .byte $4F           ;PPU string length.
  4487. LA49A:  .byte $FF           ;Repeat bit set. Repeats entry 15 times.
  4488.  
  4489. LA49B:  .byte $00           ;End PPU string write.
  4490.  
  4491. ;Writes credits on name table 0 in row $2320 (26th row from the top).
  4492. LA49C:  .byte $23           ;PPU address high byte.
  4493. LA49D:  .byte $29           ;PPU address low byte.
  4494. LA49E:  .byte $4D           ;PPU string length.
  4495. LA49F:  .byte $FF           ;Repeat bit set. Repeats entry 13 times.
  4496.  
  4497. ;Writes credits on name table 0 in row $2340 (27th row from the top).
  4498. LA4A0:  .byte $23           ;PPU address high byte.
  4499. LA4A1:  .byte $4B           ;PPU address low byte.
  4500. LA4A2:  .byte $09           ;PPU string length.
  4501. ;             'C    O    P    Y    R    I    G    H    T'
  4502. LA4A3:  .byte $0C, $18, $19, $22, $1B, $12, $10, $11, $1D
  4503.  
  4504. LA4AC:  .byte $00           ;End PPU string write.
  4505.  
  4506. ;Writes credits on name table 0 in row $2360 (28th row from the top).
  4507. LA4AD:  .byte $23           ;PPU address high byte.
  4508. LA4AE:  .byte $6B           ;PPU address low byte.
  4509. LA4AF:  .byte $4A           ;PPU string length.
  4510. LA4B0:  .byte $FF           ;Repeat bit set. Repeats entry 10 times.
  4511.  
  4512. ;Writes credits on name table 0 in row $2380 (29th row from the top).
  4513. LA4B1:  .byte $23           ;PPU address high byte.
  4514. LA4B2:  .byte $8E           ;PPU address low byte.
  4515. LA4B3:  .byte $04           ;PPU string length.
  4516. ;             '1    9    8    6'
  4517. LA4B4:  .byte $01, $09, $08, $06
  4518.  
  4519. ;Writes credits on name table 0 in row $23A0 (bottom row).
  4520. LA4B8:  .byte $23           ;PPU address high byte.
  4521. LA4B9:  .byte $A8           ;PPU address low byte.
  4522. LA4BA:  .byte $4F           ;PPU string length.
  4523. LA4BB:  .byte $FF           ;Repeat bit set. Repeats entry 10 times.
  4524.  
  4525. LA4BC:  .byte $00           ;End PPU string write.
  4526.  
  4527. ;Writes credits on name table 2 in row $2800 (top row)
  4528. LA4BD:  .byte $28           ;PPU address high byte.
  4529. LA4BE:  .byte $0C           ;PPU address low byte.
  4530. LA4BF:  .byte $08           ;PPU string length.
  4531. ;             'N    I    N    T    E    N    D    O'
  4532. LA4C0:  .byte $17, $12, $17, $1D, $0E, $17, $0D, $18
  4533.  
  4534. ;Writes credits on name table 2 in row $2860 (4th row from top).
  4535. LA4C8:  .byte $28           ;PPU address high byte.
  4536. LA4C9:  .byte $66           ;PPU address low byte.
  4537. LA4CA:  .byte $51           ;PPU string length.
  4538. LA4CB:  .byte $FF           ;Repeat bit set. Repeats entry 17 times.
  4539.  
  4540. LA4CC:  .byte $00           ;End PPU string write.
  4541.  
  4542. ;Writes credits on name table 2 in row $28A0 (6th row from top).
  4543. LA4CD:  .byte $28           ;PPU address high byte.
  4544. LA4CE:  .byte $AA           ;PPU address low byte.
  4545. LA4CF:  .byte $4C           ;PPU string length.
  4546. LA4D0:  .byte $FF           ;Repeat bit set. Repeats entry 12 times.
  4547.  
  4548. LA4D1:  .byte $00           ;End PPU string write.
  4549.  
  4550. ;Writes credits on name table 2 in row $2920 (10th row from top).
  4551. LA4D2:  .byte $29           ;PPU address high byte.
  4552. LA4D3:  .byte $26           ;PPU address low byte.
  4553. LA4D4:  .byte $5B           ;PPU string length.
  4554. LA4D5:  .byte $FF           ;Repeat bit set. Repeats entry 27 times.
  4555.  
  4556. LA4D6:  .byte $00           ;End PPU string write.
  4557.  
  4558. ;Writes credits on name table 2 in row $2960 (12th row from top).
  4559. LA4D7:  .byte $29           ;PPU address high byte.
  4560. LA4D8:  .byte $67           ;PPU address low byte.
  4561. LA4D9:  .byte $52           ;PPU string length.
  4562. LA4DA:  .byte $FF           ;Repeat bit set. Repeats entry 18 times.
  4563.  
  4564. LA4DB:  .byte $00           ;End PPU string write.
  4565.  
  4566. ;Writes credits on name table 2 in row $29E0 (16th row from top).
  4567. LA4DC:  .byte $29           ;PPU address high byte.
  4568. LA4DD:  .byte $E6           ;PPU address low byte.
  4569. LA4DE:  .byte $54           ;PPU string length.
  4570. LA4DF:  .byte $FF           ;Repeat bit set. Repeats entry 20 times.
  4571.  
  4572. LA4E0:  .byte $00           ;End PPU string write.
  4573.  
  4574. ;Writes credits on name table 2 in row $2A20 (18th row from top).
  4575. LA4E1:  .byte $2A           ;PPU address high byte.
  4576. LA4E2:  .byte $28           ;PPU address low byte.
  4577. LA4E3:  .byte $55           ;PPU string length.
  4578. LA4E4:  .byte $FF           ;Repeat bit set. Repeats entry 21 times.
  4579.  
  4580. LA4E5:  .byte $00           ;End PPU string write.
  4581.  
  4582. ;Writes credits on name table 2 in row $2AE0 (24th row from top).
  4583. LA4E6:  .byte $2A           ;PPU address high byte.
  4584. LA4E7:  .byte $E6           ;PPU address low byte.
  4585. LA4E8:  .byte $50           ;PPU string length.
  4586. LA4E9:  .byte $FF           ;Repeat bit set. Repeats entry 16 times.
  4587.  
  4588. LA4EA:  .byte $00           ;End PPU string write.
  4589.  
  4590. ;Writes credits on name table 2 in row $2B20 (26th row from top).
  4591. LA4EB:  .byte $2B           ;PPU address high byte.
  4592. LA4EC:  .byte $29           ;PPU address low byte.
  4593. LA4ED:  .byte $4E           ;PPU string length.
  4594. LA4EE:  .byte $FF           ;Repeat bit set. Repeats entry 14 times.
  4595.  
  4596. LA4EF:  .byte $00           ;End PPU string write.
  4597.  
  4598. ;Writes the top half of 'The End' on name table 0 in row $2020 (2nd row from top).
  4599. LA4F0:  .byte $20           ;PPU address high byte.
  4600. LA4F1:  .byte $26           ;PPU address low byte.
  4601. LA4F2:  .byte $14           ;PPU string length.
  4602. LA4F3:  .byte $FF, $FF, $FF, $FF, $FF, $24, $25, $26, $27, $FF, $FF, $2C, $2D, $2E, $2F, $FF
  4603. LA503:  .byte $FF, $FF, $FF, $FF
  4604.  
  4605. LA507:  .byte $00           ;End PPU string write.
  4606.  
  4607. ;Writes the bottom half of 'The End' on name table 0 in row $2040 (3rd row from top).
  4608. LA508:  .byte $20           ;PPU address high byte.
  4609. LA509:  .byte $4B           ;PPU address low byte.
  4610. LA50A:  .byte $0A           ;PPU string length.
  4611. LA50B:  .byte $28, $29, $2A, $2B, $FF, $FF, $02, $03, $04, $05
  4612.  
  4613. ;Writes credits on name table 0 in row $2060 (4th row from top).
  4614. LA515:  .byte $20           ;PPU address high byte.
  4615. LA516:  .byte $6A           ;PPU address low byte.
  4616. LA517:  .byte $4C           ;PPU string length.
  4617. LA518:  .byte $FF           ;Repeat bit set. Repeats entry 12 times.
  4618.  
  4619. LA519:  .byte $00           ;End PPU string write.
  4620.  
  4621. ;Writes credits on name table 0 in row $2120 (10th row from top).
  4622. LA51A:  .byte $21           ;PPU address high byte.
  4623. LA51B:  .byte $26           ;PPU address low byte.
  4624. LA51C:  .byte $53           ;PPU string length.
  4625. LA51D:  .byte $FF           ;Repeat bit set. Repeats entry 19 times.
  4626.  
  4627. LA51E:  .byte $00           ;End PPU string write.
  4628.  
  4629. ;Writes credits on name table 0 in row $2160 (12th row from top).
  4630. LA51F:  .byte $21           ;PPU address high byte.
  4631. LA520:  .byte $6A           ;PPU address low byte.
  4632. LA521:  .byte $4C           ;PPU string length.
  4633. LA522:  .byte $FF           ;Repeat bit set. Repeats entry 12 times.
  4634.  
  4635. LA523:  .byte $00           ;End PPU string write.
  4636.  
  4637. ;Writes credits on name table 0 in row $2180 (13th row from top).
  4638. LA524:  .byte $21           ;PPU address high byte.
  4639. LA525:  .byte $88           ;PPU address low byte.
  4640. LA526:  .byte $11           ;PPU string length.
  4641. ;             '_    _    _    _    _    _    _    _    _    _    _    _    _    _    _    _'
  4642. LA527:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  4643. ;             '_'
  4644. LA537:  .byte $FF
  4645.  
  4646. ;Writes credits on name table 0 in row $2220 (18th row from top).
  4647. LA538:  .byte $22           ;PPU address high byte.
  4648. LA539:  .byte $26           ;PPU address low byte.
  4649. LA53A:  .byte $4B           ;PPU string length.
  4650. LA53B:  .byte $FF           ;Repeat bit set. Repeats entry 11 times.
  4651.  
  4652. LA53C:  .byte $00           ;End PPU string write.
  4653.  
  4654. LA53D:  .byte $00           ;End PPU block write.
  4655.  
  4656. ;-------------------------------------------[ World map ]--------------------------------------------
  4657.  
  4658. WorldMap:
  4659. LA53E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  4660. LA54E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  4661. LA55E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08, $FF, $08, $FF, $FF
  4662. LA56E:  .byte $FF, $FF, $FF, $FF, $08, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  4663. LA57E:  .byte $FF, $FF, $FF, $2C, $2B, $27, $15, $15, $16, $14, $13, $04, $FF, $06, $08, $0A
  4664. LA58E:  .byte $1A, $29, $29, $28, $2E, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08, $FF
  4665. LA59E:  .byte $FF, $0E, $FF, $01, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $03, $1F, $23
  4666. LA5AE:  .byte $25, $24, $26, $20, $1E, $1F, $21, $21, $07, $22, $1D, $1B, $21, $20, $04, $FF
  4667. LA5BE:  .byte $FF, $10, $FF, $0E, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $06, $FF, $FF
  4668. LA5CE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $02, $FF
  4669. LA5DE:  .byte $FF, $10, $FF, $0B, $FF, $FF, $08, $0A, $1A, $29, $28, $04, $FF, $06, $FF, $FF
  4670. LA5EE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08, $0A, $1A, $29, $29, $28, $04, $FF
  4671. LA5FE:  .byte $FF, $10, $FF, $0B, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $06, $FF, $FF
  4672. LA60E:  .byte $FF, $FF, $08, $FF, $FF, $FF, $08, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF
  4673. LA61E:  .byte $FF, $10, $FF, $0F, $11, $13, $14, $14, $13, $12, $0D, $03, $00, $05, $0C, $0E
  4674. LA62E:  .byte $0E, $0D, $10, $0C, $0F, $0D, $10, $0C, $0E, $1B, $0F, $0E, $0F, $0D, $04, $FF
  4675. LA63E:  .byte $FF, $10, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $0C, $06, $FF, $06, $FF, $FF
  4676. LA64E:  .byte $FF, $FF, $11, $FF, $FF, $FF, $06, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08, $FF
  4677. LA65E:  .byte $FF, $10, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $0C, $06, $FF, $06, $FF, $FF
  4678. LA66E:  .byte $FF, $FF, $11, $0A, $1A, $28, $04, $FF, $06, $FF, $FF, $FF, $FF, $FF, $06, $FF
  4679. LA67E:  .byte $FF, $10, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $0C, $06, $FF, $06, $FF, $FF
  4680. LA68E:  .byte $FF, $FF, $08, $FF, $FF, $FF, $08, $FF, $08, $1B, $06, $19, $19, $2A, $0B, $FF
  4681. LA69E:  .byte $FF, $0F, $04, $03, $02, $05, $06, $07, $08, $09, $0A, $06, $FF, $03, $12, $14
  4682. LA6AE:  .byte $15, $14, $07, $16, $15, $13, $0B, $FF, $0C, $07, $19, $19, $19, $2A, $0E, $FF
  4683. LA6BE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $08, $FF, $FF
  4684. LA6CE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $01, $FF, $0A, $1B, $04, $0F, $06, $2A, $0E, $FF
  4685. LA6DE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $06, $FF, $FF
  4686. LA6EE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $02, $FF, $06, $FF, $FF, $FF, $FF, $FF, $09, $FF
  4687. LA6FE:  .byte $FF, $08, $17, $09, $14, $13, $18, $12, $14, $19, $13, $04, $FF, $08, $1D, $1F
  4688. LA70E:  .byte $06, $1F, $19, $1E, $1E, $1C, $03, $28, $29, $29, $29, $2B, $29, $2A, $0E, $FF
  4689. LA71E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $FF, $FF, $FF, $08, $FF, $08, $1D, $1F
  4690. LA72E:  .byte $1E, $19, $07, $19, $19, $2C, $06, $06, $2B, $2B, $1A, $1A, $1A, $2A, $0B, $FF
  4691. LA73E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $0B, $FF, $FF, $0B, $FF, $06, $07, $04
  4692. LA74E:  .byte $0F, $10, $0B, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $09, $FF
  4693. LA75E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $06, $FF, $07, $17, $18, $0C, $FF, $08, $21, $25
  4694. LA76E:  .byte $25, $22, $03, $21, $25, $20, $00, $27, $2C, $2C, $06, $04, $0F, $10, $0E, $FF
  4695. LA77E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $03, $1C, $07, $17, $18, $0C, $FF, $0A, $21, $23
  4696. LA78E:  .byte $25, $22, $03, $21, $24, $24, $24, $23, $23, $06, $24, $25, $22, $11, $2D, $FF
  4697. LA79E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $08, $01, $07, $17, $18, $0C, $FF, $09, $FF, $FF
  4698. LA7AE:  .byte $FF, $06, $06, $FF, $FF, $FF, $FF, $FF, $FF, $07, $26, $25, $22, $0B, $2D, $FF
  4699. LA7BE:  .byte $FF, $0B, $FF, $FF, $FF, $FF, $FF, $02, $0B, $FF, $FF, $08, $FF, $0A, $12, $14
  4700. LA7CE:  .byte $13, $03, $12, $15, $13, $0D, $12, $14, $06, $14, $18, $15, $19, $07, $09, $FF
  4701. LA7DE:  .byte $FF, $09, $17, $1C, $10, $19, $18, $03, $13, $10, $18, $0C, $FF, $06, $FF, $FF
  4702. LA7EE:  .byte $FF, $09, $04, $0F, $10, $0B, $FF, $FF, $08, $12, $16, $16, $16, $13, $0E, $FF
  4703. LA7FE:  .byte $FF, $0A, $17, $1C, $1C, $1C, $18, $03, $13, $19, $12, $0B, $FF, $00, $FF, $FF
  4704. LA80E:  .byte $0B, $08, $12, $19, $19, $07, $FF, $FF, $08, $05, $FF, $FF, $FF, $FF, $06, $FF
  4705. LA81E:  .byte $FF, $05, $FF, $FF, $0B, $FF, $FF, $08, $FF, $FF, $FF, $FF, $0B, $FF, $FF, $FF
  4706. LA82E:  .byte $FF, $06, $FF, $FF, $FF, $FF, $FF, $05, $06, $01, $FF, $FF, $FF, $FF, $0B, $FF
  4707. LA83E:  .byte $FF, $05, $FF, $FF, $07, $17, $18, $04, $13, $14, $14, $16, $0C, $FF, $05, $FF
  4708. LA84E:  .byte $FF, $05, $0F, $18, $17, $18, $19, $29, $05, $02, $FF, $FF, $FF, $FF, $05, $FF
  4709. LA85E:  .byte $FF, $05, $FF, $FF, $08, $FF, $FF, $05, $FF, $0B, $10, $18, $0D, $FF, $0A, $20
  4710. LA86E:  .byte $22, $0D, $25, $26, $26, $26, $1D, $0E, $0E, $03, $23, $24, $24, $15, $07, $FF
  4711. LA87E:  .byte $FF, $05, $FF, $FF, $23, $17, $18, $06, $22, $0C, $FF, $0B, $0E, $FF, $0B, $FF
  4712. LA88E:  .byte $FF, $04, $FF, $FF, $FF, $FF, $05, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08, $FF
  4713. LA89E:  .byte $FF, $23, $22, $1A, $13, $10, $14, $1C, $16, $06, $21, $0C, $0E, $FF, $0A, $1C
  4714. LA8AE:  .byte $1D, $03, $20, $21, $21, $22, $06, $23, $0F, $28, $27, $27, $27, $19, $07, $FF
  4715. LA8BE:  .byte $FF, $0B, $FF, $1E, $1F, $20, $20, $20, $0F, $15, $21, $24, $0E, $FF, $04, $FF
  4716. LA8CE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $04, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $08, $FF
  4717. LA8DE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $1D, $1B, $17, $18, $0C, $FF, $04, $11
  4718. LA8EE:  .byte $10, $12, $13, $14, $14, $15, $03, $1C, $1E, $1E, $1F, $1F, $1F, $1D, $07, $FF
  4719. LA8FE:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $0B, $FF, $0C, $16
  4720. LA90E:  .byte $18, $17, $18, $17, $0F, $17, $17, $1A, $1A, $17, $1B, $1B, $17, $19, $09, $FF
  4721. LA91E:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  4722. LA91F:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF
  4723.  
  4724. CopyMap:
  4725. LA93E:  LDA #$3E            ;
  4726. LA940:  STA $00             ;
  4727. LA942:  LDA #$A5            ;
  4728. LA944:  STA $01             ;
  4729. LA946:  LDA #$00            ;
  4730. LA948:  STA $02             ;
  4731. LA94A:  LDA #$70            ;Loads contents of world map into -->
  4732. LA94C:  STA $03             ;RAM at addresses $7000 thru $73FF.
  4733. LA94E:  LDX #$04            ;
  4734. LA950:* LDY #$00            ;
  4735. LA952:* LDA ($00),Y         ;
  4736. LA954:  STA ($02),Y         ;
  4737. LA956:  INY                 ;
  4738. LA957:  BNE -               ;
  4739. LA959:  INC $01             ;
  4740. LA95B:  INC $03             ;
  4741. LA95D:  DEX                 ;
  4742. LA95E:  BNE --              ;
  4743. LA960:  RTS             ;
  4744.  
  4745. ;Unused tile patterns.
  4746. LA961:  .byte $00, $40, $90, $D0, $08, $5C, $0C, $00, $00, $C0, $70, $F8, $FC, $F4, $FC, $10
  4747. LA962:  .byte $22, $56, $03, $2B, $74, $37, $0D, $3F, $5F, $7D, $7F, $7F, $5F, $3F, $0F, $68
  4748. LA981:  .byte $F6, $BC, $5E, $3C, $DE, $7C, $F0, $FC, $DE, $FE, $FE, $FE, $FE, $FC, $F0, $00
  4749. LA991:  .byte $00, $7F, $80, $80, $FF, $7F, $00, $00, $7F, $80, $7F, $FF, $FF, $7F, $00, $00
  4750. LA9A1:  .byte $00, $FC, $01, $03, $FF, $FE, $00, $00, $FE, $03, $FF, $FF, $FF, $FE, $00, $00
  4751. LA9B1:  .byte $10, $20, $20, $00, $20, $00, $00, $3C, $42, $81, $81, $81, $81, $42, $3C, $7F
  4752. LA9C1:  .byte $7F, $3F, $1F, $80, $0F, $08, $88, $12, $80, $C0, $E0, $E0, $EF, $E8, $E8, $FC
  4753. LA9D1:  .byte $FC, $FC, $F8, $1C, $DC, $58, $5C, $48, $04, $0C, $18, $1C, $DC, $18, $1C, $0F
  4754. LA9E1:  .byte $00, $9F, $3F, $7F, $DB, $00, $00, $E0, $E0, $FF, $FF, $FF, $DB, $00, $00, $DC
  4755. LA9F1:  .byte $18, $EC, $F4, $F8, $6C, $00, $00, $1C, $18, $FC, $FC, $FC, $6C, $00, $00, $FF
  4756. LAA01:  .byte $FF, $C0, $C0, $CF, $CB, $CC, $CC, $00, $00, $1F, $3F, $3F, $38, $3B, $3B, $FC
  4757. LAA11:  .byte $FC, $0C, $0C, $CC, $4C, $CC, $CC, $00, $04, $EC, $FC, $FC, $3C, $BC, $BC, $CB
  4758. LAA21:  .byte $CF, $C0, $C0, $FF, $FF, $00, $00, $3B, $30, $3F, $1F, $7F, $FF, $00, $00, $4C
  4759. LAA31:  .byte $CC, $0C, $0C, $FC, $FC, $00, $00, $3C, $3C, $FC, $EC, $FC, $FC, $00, $00, $FE
  4760. LAA41:  .byte $82, $82, $82, $82, $FE, $00, $00, $00, $7E, $56, $56, $7E, $FE, $00, $00, $20
  4761. LAA51:  .byte $00, $00, $18, $20, $00, $00, $18, $1C, $F7, $3C, $18, $1C, $F7, $3C, $18, $E2
  4762. LAA61:  .byte $80, $10, $20, $00, $00, $80, $00, $E2, $98, $2C, $5E, $7E, $3C, $98, $00, $7E
  4763. LAA71:  .byte $00, $7E, $00, $7E, $00, $7E, $00, $6E, $00, $6E, $00, $6E, $00, $6E, $00, $10
  4764. LAA81:  .byte $F4, $08, $04, $C5, $24, $23, $05, $E8, $F8, $0E, $E6, $F7, $37, $2E, $FD, $00
  4765. LAA91:  .byte $5F, $20, $48, $D7, $88, $18, $80, $3F, $3F, $E0, $C7, $CF, $B8, $98, $7F, $F8
  4766. LAAA1:  .byte $10, $10, $10, $D7, $08, $00, $EF, $F8, $10, $30, $B7, $F7, $30, $DF, $EF, $FF
  4767. LAAB1:  .byte $00, $08, $08, $EF, $08, $10, $EF, $FF, $00, $18, $DB, $FF, $38, $F7, $EF, $FF
  4768. LAAC1:  .byte $7F, $3F, $5F, $4F, $07, $03, $01, $00, $B0, $C0, $E0, $F0, $F8, $FC, $FE, $FE
  4769. LAAD1:  .byte $FE, $FE, $FA, $FA, $FE, $FE, $FE, $00, $1A, $06, $0A, $1A, $3E, $7E, $FE, $01
  4770. LAAE1:  .byte $03, $07, $4F, $5F, $27, $7F, $00, $FF, $FF, $FF, $FF, $FF, $E7, $FF, $00, $7E
  4771. LAAF1:  .byte $BE, $DA, $EA, $F6, $CA, $FC, $00, $FE, $FE, $FA, $FA, $FE, $CE, $FE, $00, $CF
  4772. LAB01:  .byte $BF, $70, $60, $C4, $C8, $C0, $C0, $47, $BF, $70, $27, $4B, $57, $5F, $DF, $CC
  4773. LAB11:  .byte $F4, $38, $18, $0C, $0C, $0C, $0C, $CC, $F4, $38, $98, $CC, $EC, $EC, $EC, $C0
  4774. LAB21:  .byte $C0, $60, $70, $BF, $CF, $00, $00, $DF, $CF, $67, $70, $BF, $4F, $00, $00, $0C
  4775. LAB31:  .byte $0C, $18, $38, $F4, $CC, $00, $00, $EC, $CC, $98, $38, $F4, $CC, $00, $00, $FF
  4776. LAB41:  .byte $FF, $C0, $DF, $D0, $D0, $DF, $C0, $00, $00, $3F, $3F, $35, $35, $20, $3F, $FC
  4777. LAB51:  .byte $FC, $0C, $EC, $2C, $2C, $EC, $0C, $00, $04, $FC, $FC, $5C, $5C, $1C, $FC, $FF
  4778. LAB61:  .byte $00, $00, $E4, $00, $CF, $00, $00, $7F, $00, $00, $E3, $00, $BF, $00, $00, $FC
  4779. LAB71:  .byte $00, $00, $F9, $00, $87, $00, $00, $FC, $00, $00, $F7, $00, $67, $00, $00, $FE
  4780. LAB81:  .byte $02, $02, $02, $FE, $00, $00, $7F, $00, $FE, $0E, $FE, $FE, $00, $00, $00, $7F
  4781. LAB91:  .byte $40, $40, $40, $7F, $00, $00, $FE, $00, $3F, $30, $3F, $7F, $00, $00, $00, $40
  4782. LABA1:  .byte $40, $40, $7F, $00, $00, $00, $FF, $3F, $30, $3F, $7F, $00, $00, $FF, $FF, $02
  4783. LABB1:  .byte $02, $02, $FE, $00, $00, $00, $FF, $FE, $0E, $FE, $FE, $00, $00, $FF, $FF, $FF
  4784. LABC1:  .byte $FF, $C0, $D0, $C0, $C0, $C0, $C0, $00, $00, $3F, $27, $3F, $3F, $3F, $3F, $FC
  4785. LABD1:  .byte $FC, $0C, $4C, $0C, $0C, $0C, $0C, $00, $04, $FC, $9C, $FC, $FC, $FC, $FC, $C0
  4786. LABE1:  .byte $C0, $D0, $C0, $FF, $FF, $00, $00, $3F, $3F, $27, $3F, $3F, $7F, $00, $00, $0C
  4787. LABF1:  .byte $0C, $4C, $0C, $FC, $FC, $00, $00, $FC, $FC, $9C, $FC, $FC, $FC, $00, $00
  4788.  
  4789. ;------------------------------------------[ Area music data ]---------------------------------------
  4790.  
  4791. ;There are 3 control bytes associated with the music data and the rest are musical note indexes.
  4792. ;If the byte has the binary format 1011xxxx ($Bx), then the byte is an index into the corresponding
  4793. ;musical notes table and is used to set the note length until it is set by another note length
  4794. ;byte. The lower 4 bits are the index into the note length table. Another control byte is the loop
  4795. ;and counter btye. The loop and counter byte has the format 11xxxxxx. Bits 0 thru 6 contain the
  4796. ;number of times to loop.  The third control byte is #$FF. This control byte marks the end of a loop
  4797. ;and decrements the loop counter. If #$00 is found in the music data, the music has reached the end.
  4798. ;A #$00 in any of the different music channel data segments will mark the end of the music. The
  4799. ;remaining bytes are indexes into the MusicNotesTbl and should only be even numbers as there are 2
  4800. ;bytes of data per musical note.
  4801.  
  4802. EndSQ1Data:
  4803. LAC00:  .byte $C2           ;
  4804. LAC01:  .byte $B4           ;7/8 seconds    +
  4805. LAc02:  .byte $2A           ;A3     |
  4806. LAC03:  .byte $30           ;C4     | Repeat 2 times.
  4807. LAC04:  .byte $2E           ;B3     |
  4808. LAC05:  .byte $2C           ;A#3        +
  4809. LAC06:  .byte $FF           ;
  4810. LAC07:  .byte $2A           ;A3
  4811. LAC08:  .byte $2A           ;A3
  4812. LAC09:  .byte $C2           ;
  4813. LAC0A:  .byte $B0           ;1/4 seconds    +
  4814. LAC0B:  .byte $3C           ;F#4        |
  4815. LAC0C:  .byte $42           ;A4     |
  4816. LAC0D:  .byte $4C           ;D5     |
  4817. LAC0E:  .byte $54           ;F#5        |
  4818. LAC0F:  .byte $B2           ;7/32 seconds   |
  4819. LAC10:  .byte $5A           ;A5     |
  4820. LAC11:  .byte $56           ;G5     |
  4821. LAC12:  .byte $54           ;F#5        |
  4822. LAC13:  .byte $B4           ;7/8 seconds    |
  4823. LAC14:  .byte $4C           ;D5     |
  4824. LAC15:  .byte $B0           ;1/4 seconds    |
  4825. LAC16:  .byte $38           ;E4     | Repeat 2 times.
  4826. LAC17:  .byte $3C           ;F#4        |
  4827. LAC18:  .byte $3E           ;G4     |
  4828. LAC19:  .byte $42           ;A4     |
  4829. LAC1A:  .byte $B2           ;7/32 seconds   |
  4830. LAC1B:  .byte $4C           ;D5     |
  4831. LAC1C:  .byte $42           ;A4     |
  4832. LAC1D:  .byte $B0           ;1/4 seconds    |
  4833. LAC1E:  .byte $56           ;G5     |
  4834. LAC1F:  .byte $54           ;F#5        |
  4835. LAC20:  .byte $4C           ;D5     |
  4836. LAC21:  .byte $42           ;A4     |
  4837. LAC22:  .byte $B3           ;7/16 seconds   |
  4838. LAC23:  .byte $3E           ;G4     |
  4839. LAC24:  .byte $4C           ;D5     +
  4840. LAC25:  .byte $FF           ;
  4841. LAC26:  .byte $C2           ;
  4842. LAC27:  .byte $B3           ;7/16 seconds   +
  4843. LAC28:  .byte $4A           ;C#5        |
  4844. LAC29:  .byte $B2           ;7/32 seconds   |
  4845. LAC2A:  .byte $4C           ;D5     |
  4846. LAC2B:  .byte $42           ;A4     |
  4847. LAC2C:  .byte $54           ;F#5        |
  4848. LAC2D:  .byte $50           ;E5     |
  4849. LAC2E:  .byte $56           ;G5     |
  4850. LAC2F:  .byte $54           ;F#5        |
  4851. LAC30:  .byte $B1           ;7/64 seconds   |
  4852. LAC31:  .byte $50           ;E5     |
  4853. LAC32:  .byte $4C           ;D5     | Repeat 2 times.
  4854. LAC33:  .byte $44           ;A#4        |
  4855. LAC34:  .byte $3E           ;G4     |
  4856. LAC35:  .byte $B2           ;7/32 seconds   |
  4857. LAC36:  .byte $3C           ;F#4        |
  4858. LAC37:  .byte $4C           ;D5     |
  4859. LAC38:  .byte $B1           ;7/64 seconds   |
  4860. LAC39:  .byte $40           ;Ab4        |
  4861. LAC3A:  .byte $46           ;B4     |
  4862. LAC3B:  .byte $B2           ;7/32 seconds   |
  4863. LAC3C:  .byte $50           ;E5     |
  4864. LAC3D:  .byte $4C           ;D5     |
  4865. LAC3E:  .byte $50           ;E5     +
  4866. LAC3F:  .byte $FF           ;
  4867. LAC40:  .byte $C4           ;
  4868. LAC41:  .byte $B3           ;7/16 seconds   +
  4869. LAC42:  .byte $2A           ;A3     |
  4870. LAC43:  .byte $30           ;C4     | Repeat 4 times.
  4871. LAC44:  .byte $2E           ;B3     |
  4872. LAC45:  .byte $2C           ;A#3        +
  4873. LAC46:  .byte $FF           ;
  4874. LAC47:  .byte $B4           ;7/8 seconds
  4875. LAC48:  .byte $34           ;D4
  4876. LAC49:  .byte $B3           ;7/16 seconds
  4877. LAC4A:  .byte $38           ;E4
  4878. LAC4B:  .byte $3E           ;G4
  4879. LAC4C:  .byte $B4           ;7/8 seconds
  4880. LAC4D:  .byte $3C           ;F#4
  4881. LAC4E:  .byte $B3           ;7/16 seconds
  4882. LAC4F:  .byte $3E           ;G4
  4883. LAC50:  .byte $44           ;A#4
  4884. LAC51:  .byte $B5           ;1 13/16 seconds
  4885. LAC52:  .byte $34           ;D4
  4886. LAC53:  .byte $B1           ;7/64 seconds
  4887. LAC54:  .byte $2A           ;A3
  4888. LAC55:  .byte $B6           ;21/32 seconds
  4889. LAC56:  .byte $1C           ;D3
  4890. LAC57:  .byte $B2           ;7/32 seconds
  4891. LAC58:  .byte $02           ;No sound
  4892. LAC59:  .byte $B5           ;1 13/16 seconds
  4893. LAC5A:  .byte $26           ;G3
  4894. LAC5B:  .byte $B1           ;7/64 seconds
  4895. LAC5C:  .byte $24           ;F#3
  4896. LAC5D:  .byte $B8           ;21/64 seconds
  4897. LAC5E:  .byte $06           ;D2
  4898. LAC5F:  .byte $12           ;A2
  4899. LAC60:  .byte $1C           ;D3
  4900. LAC61:  .byte $B9           ;9/32 seconds
  4901. LAC62:  .byte $02           ;No sound
  4902. LAC63:  .byte $B8           ;21/64 seconds
  4903. LAC64:  .byte $24           ;F#3
  4904. LAC65:  .byte $2A           ;A3
  4905. LAC66:  .byte $34           ;D4
  4906. LAC67:  .byte $B9           ;9/32 seconds
  4907. LAC68:  .byte $02           ;No sound
  4908. LAC69:  .byte $B5           ;1 13/16 seconds
  4909. LAC6A:  .byte $38           ;E4
  4910. LAC6B:  .byte $B1           ;7/64 seconds
  4911. LAC6C:  .byte $2C           ;A#3
  4912. LAC6D:  .byte $B3           ;7/16 seconds
  4913. LAC6E:  .byte $26           ;G3
  4914. LAC6F:  .byte $2A           ;A3
  4915. LAC70:  .byte $B5           ;1 13/16 seconds
  4916. LAC71:  .byte $2A           ;A3
  4917. LAC72:  .byte $B1           ;7/64 seconds
  4918. LAC73:  .byte $02           ;No sound
  4919. LAC74:  .byte $B8           ;21/64 seconds
  4920. LAC75:  .byte $26           ;G3
  4921. LAC76:  .byte $24           ;F#3
  4922. LAC77:  .byte $1C           ;D3
  4923. LAC78:  .byte $B9           ;9/32 seconds
  4924. LAC79:  .byte $02           ;No sound
  4925. LAC7A:  .byte $B8           ;21/64 seconds
  4926. LAC7B:  .byte $20           ;E3
  4927. LAC7C:  .byte $1C           ;D3
  4928. LAC7D:  .byte $20           ;E3
  4929. LAC7E:  .byte $B9           ;9/32 seconds
  4930. LAC7F:  .byte $02           ;No sound
  4931. LAC80:  .byte $B4           ;7/8 seconds
  4932. LAC81:  .byte $1C           ;D3
  4933. LAC82:  .byte $B8           ;21/64 seconds
  4934. LAC83:  .byte $26           ;G3
  4935. LAC84:  .byte $2C           ;A#3
  4936. LAC85:  .byte $34           ;D4
  4937. LAC86:  .byte $B9           ;9/32 seconds
  4938. LAC87:  .byte $02           ;No sound
  4939. LAC88:  .byte $B8           ;21/64 seconds
  4940. LAC89:  .byte $3E           ;G4
  4941. LAC8A:  .byte $44           ;A#4
  4942. LAC8B:  .byte $4C           ;D5
  4943. LAC8C:  .byte $B9           ;9/32 seconds
  4944. LAC8D:  .byte $02           ;No sound
  4945. LAC8E:  .byte $C8           ;
  4946. LAC8F:  .byte $B0           ;1/4 seconds    +
  4947. LAC90:  .byte $3C           ;F#4        |
  4948. LAC91:  .byte $42           ;A4     |
  4949. LAC92:  .byte $3C           ;F#4        |
  4950. LAC93:  .byte $42           ;A4     |
  4951. LAC94:  .byte $42           ;A4     |
  4952. LAC95:  .byte $46           ;B4     |
  4953. LAC96:  .byte $42           ;A4     |
  4954. LAC97:  .byte $46           ;B4     | Repeat 8 times.
  4955. LAC98:  .byte $4C           ;D5     |
  4956. LAC99:  .byte $50           ;E5     |
  4957. LAC9A:  .byte $4C           ;D5     |
  4958. LAC9B:  .byte $50           ;E5     |
  4959. LAC9C:  .byte $50           ;E5     |
  4960. LAC9D:  .byte $54           ;F#5        |
  4961. LAC9E:  .byte $50           ;E5     |
  4962. LAC9F:  .byte $54           ;F#5        +
  4963. LACA0:  .byte $FF           ;
  4964. LACA1:  .byte $C2           ;
  4965. LACA2:  .byte $B4           ;7/8 seconds    +
  4966. LACA3:  .byte $2A           ;A3     |
  4967. LACA4:  .byte $B3           ;7/16 seconds   |
  4968. LACA5:  .byte $34           ;D4     |
  4969. LACA6:  .byte $B5           ;1 13/16 seconds|
  4970. LACA7:  .byte $32           ;C#4        |
  4971. LACA8:  .byte $B1           ;7/64 seconds   |
  4972. LACA9:  .byte $2E           ;B3     | Repeat 2 times.
  4973. LACAA:  .byte $B4           ;7/8 seconds    |
  4974. LACAB:  .byte $2A           ;A3     |
  4975. LACAC:  .byte $B3           ;7/16 seconds   |
  4976. LACAD:  .byte $1C           ;D3     |
  4977. LACAE:  .byte $B5           ;1 13/16 seconds|
  4978. LACAF:  .byte $26           ;G3     |
  4979. LACB0:  .byte $B1           ;7/64 seconds   |
  4980. LACB1:  .byte $24           ;F#3        +
  4981. LACB2:  .byte $FF           ;
  4982. LACB3:  .byte $B4           ;7/8 seconds
  4983. LACB4:  .byte $2A           ;A3
  4984. LACB5:  .byte $B8           ;21/64 seconds
  4985. LACB6:  .byte $18           ;C3
  4986. LACB7:  .byte $26           ;G3
  4987. LACB8:  .byte $30           ;C4
  4988. LACB9:  .byte $B9           ;9/32 seconds
  4989. LACBA:  .byte $02           ;No sound
  4990. LACBB:  .byte $B8           ;21/64 seconds
  4991. LACBC:  .byte $1C           ;D3
  4992. LACBD:  .byte $26           ;G3
  4993. LACBE:  .byte $30           ;C4
  4994. LACBF:  .byte $B9           ;9/32 seconds
  4995. LACC0:  .byte $02           ;No sound
  4996. LACC1:  .byte $B4           ;7/8 seconds
  4997. LACC2:  .byte $34           ;D4
  4998. LACC3:  .byte $B8           ;21/64 seconds
  4999. LACC4:  .byte $3A           ;F4
  5000. LACC5:  .byte $30           ;C4
  5001. LAcc6:  .byte $26           ;G3
  5002. LACC7:  .byte $B9           ;9/32 seconds
  5003. LACC8:  .byte $02           ;No sound
  5004. LACC9:  .byte $B8           ;21/64 seconds
  5005. LACCA:  .byte $3E           ;G4
  5006. LACCB:  .byte $38           ;E4
  5007. LACCC:  .byte $30           ;C4
  5008. LACCD:  .byte $B9           ;9/32 seconds
  5009. LACCE:  .byte $02           ;No sound
  5010. LACCF:  .byte $B4           ;7/8 seconds
  5011. LACD0:  .byte $34           ;D4
  5012. LACD1:  .byte $B2           ;7/32 seconds
  5013. LACD2:  .byte $1C           ;D3
  5014. LACD3:  .byte $2A           ;A3
  5015. LACD4:  .byte $26           ;G3
  5016. LACD5:  .byte $30           ;C4
  5017. LACD6:  .byte $C2           ;
  5018. LACD7:  .byte $B0           ;1/4 seconds    +
  5019. LACD8:  .byte $38           ;E4     |
  5020. LACD9:  .byte $38           ;E4     |
  5021. LACDA:  .byte $38           ;E4     |
  5022. LACDB:  .byte $02           ;No sound   |
  5023. LACDC:  .byte $02           ;No sound   |
  5024. LACDD:  .byte $02           ;No sound   |
  5025. LACDE:  .byte $38           ;E4     |
  5026. LACDF:  .byte $38           ;E4     | Repeat 2 times.
  5027. LACE0:  .byte $38           ;E4     |
  5028. LACE1:  .byte $02           ;No sound   |
  5029. LACE2:  .byte $38           ;E4     |
  5030. LACE3:  .byte $38           ;E4     |
  5031. LACE4:  .byte $38           ;E4     |
  5032. LACE5:  .byte $38           ;E4     |
  5033. LACE6:  .byte $38           ;E4     |
  5034. LACE7:  .byte $02           ;No sound   +
  5035. LACE8:  .byte $FF           ;
  5036. LACE9:  .byte $B4           ;7/8 seconds
  5037. LACEA:  .byte $38           ;E4
  5038. LACEB:  .byte $B2           ;7/32 seconds
  5039. LACEC:  .byte $02           ;No sound
  5040. LACED:  .byte $B0           ;1/4 seconds
  5041. LACEE:  .byte $1C           ;D3
  5042. LACEF:  .byte $02           ;No sound
  5043. LACF0:  .byte $1C           ;D3
  5044. LACF1:  .byte $1C           ;D3
  5045. LACF2:  .byte $B2           ;7/32 seconds
  5046. LACF3:  .byte $06           ;D2
  5047. LACF4:  .byte $00           ;End of end music.
  5048.  
  5049. EndTriangleData:
  5050. LACF5:  .byte $CA           ;
  5051. LACF6:  .byte $B0           ;1/4 seconds    +
  5052. LACF7:  .byte $2A           ;A3     |
  5053. LACF8:  .byte $2A           ;A3     |
  5054. LACF9:  .byte $2A           ;A3     |
  5055. LACFA:  .byte $02           ;No sound   |
  5056. LACFB:  .byte $02           ;No sound   |
  5057. LACFC:  .byte $02           ;No sound   |
  5058. LACFD:  .byte $2A           ;A3     | Repeat 10 times.
  5059. LACFE:  .byte $2A           ;A3     |
  5060. LACFF:  .byte $2A           ;A3     |
  5061. LAD00:  .byte $02           ;No sound   |
  5062. LAD01:  .byte $2A           ;A3     |
  5063. LAD02:  .byte $2A           ;A3     |
  5064. LAD03:  .byte $2A           ;A3     |
  5065. LAD04:  .byte $2A           ;A3     |
  5066. LAD05:  .byte $2A           ;A3     |
  5067. LAD06:  .byte $02           ;No sound   +
  5068. LAD07:  .byte $FF           ;
  5069. LAD08:  .byte $C2           ;
  5070. LAD09:  .byte $B2           ;7/32 seconds   +
  5071. LAD0A:  .byte $34           ;D4     |
  5072. LAD0B:  .byte $34           ;D4     |
  5073. LAD0C:  .byte $32           ;C#4        |
  5074. LAD0D:  .byte $32           ;C#4        |
  5075. LAD0E:  .byte $2E           ;B3     |
  5076. LAD0f:  .byte $2E           ;B3     |
  5077. LAD10:  .byte $2A           ;A3     |
  5078. LAD11:  .byte $2A           ;A3     | Repeat 2 times.
  5079. LAD12:  .byte $26           ;G3     |
  5080. LAD13:  .byte $26           ;G3     |
  5081. LAD14:  .byte $24           ;F#3        |
  5082. LAD15:  .byte $24           ;F#3        |
  5083. LAD16:  .byte $20           ;E3     |
  5084. LAD17:  .byte $20           ;E3     |
  5085. LAD18:  .byte $2A           ;A3     |
  5086. LAD19:  .byte $2A           ;A3     +
  5087. LAD1A:  .byte $FF           ;
  5088. LAD1B:  .byte $C2           ;
  5089. LAD1C:  .byte $26           ;G3     +
  5090. LAD1D:  .byte $26           ;G3     |
  5091. LAD1E:  .byte $24           ;F#3        |
  5092. LAD1F:  .byte $24           ;F#3        |
  5093. LAD20:  .byte $30           ;C4     |
  5094. LAD21:  .byte $30           ;C4     |
  5095. LAD22:  .byte $2E           ;B3     |
  5096. LAD23:  .byte $2E           ;B3     | Repeat 2 times.
  5097. LAD24:  .byte $2C           ;A#3        |
  5098. LAD25:  .byte $2C           ;A#3        |
  5099. LAD26:  .byte $2A           ;A3     |
  5100. LAD27:  .byte $2A           ;A3     |
  5101. LAD28:  .byte $28           ;Ab3        |
  5102. LAD29:  .byte $28           ;Ab3        |
  5103. LAD2A:  .byte $2A           ;A3     |
  5104. LAD2B:  .byte $2A           ;A3     +
  5105. LAD2C:  .byte $FF           ;
  5106. LAD2D:  .byte $C8           ;
  5107. LAD2E:  .byte $B0           ;1/4 seconds    +
  5108. LAD2F:  .byte $1C           ;D3     |
  5109. LAD30:  .byte $1C           ;D3     |
  5110. LAD31:  .byte $1C           ;D3     |
  5111. LAD32:  .byte $02           ;No sound   |
  5112. LAD33:  .byte $02           ;No sound   |
  5113. LAD34:  .byte $02           ;No sound   |
  5114. LAD35:  .byte $1C           ;D3     | Repeat 8 times.
  5115. LAD36:  .byte $1C           ;D3     |
  5116. LAD37:  .byte $1C           ;D3     |
  5117. LAD38:  .byte $02           ;No sound   |
  5118. LAD39:  .byte $1C           ;D3     |
  5119. LAD3A:  .byte $1C           ;D3     |
  5120. LAD3B:  .byte $1C           ;D3     |
  5121. LAD3C:  .byte $1C           ;D3     |
  5122. LAD3D:  .byte $1C           ;D3     |
  5123. LAD3E:  .byte $02           ;No sound   +
  5124. LAD3F:  .byte $FF           ;
  5125. LAD40:  .byte $D8           ;
  5126. LAD41:  .byte $BA           ;1/32 seconds   +
  5127. LAD42:  .byte $64           ;D6     |
  5128. LAD43:  .byte $02           ;No sound   |
  5129. LAD44:  .byte $64           ;D6     |
  5130. LAD45:  .byte $02           ;No sound   |
  5131. LAD46:  .byte $B9           ;9/32 seconds   |
  5132. LAD47:  .byte $02           ;No sound   |
  5133. LAD48:  .byte $BA           ;1/32 Seconds   |
  5134. LAD49:  .byte $72           ;A6     |
  5135. LAD4A:  .byte $02           ;No sound   |
  5136. LAD4B:  .byte $72           ;A6     |
  5137. LAD4C:  .byte $02           ;No sound   |
  5138. LAD4D:  .byte $B9           ;9/32 seconds   | Repeat 24 times.
  5139. LAD4E:  .byte $02           ;No sound   |
  5140. LAD4F:  .byte $BA           ;1/32 seconds   |
  5141. LAD50:  .byte $7C           ;D7     |
  5142. LAD51:  .byte $02           ;No sound   |
  5143. LAD52:  .byte $7C           ;D7     |
  5144. LAD53:  .byte $02           ;No sound   |
  5145. LAD54:  .byte $B9           ;9/32 seconds   |
  5146. LAD55:  .byte $02           ;No sound   |
  5147. LAD56:  .byte $BA           ;1/32 seconds   |
  5148. LAD57:  .byte $72           ;A6     |
  5149. LAD58:  .byte $02           ;No sound   |
  5150. LAD59:  .byte $72           ;A6     |
  5151. LAD5A:  .byte $02           ;No sound   |
  5152. LAD5B:  .byte $B9           ;9/32 seconds   |
  5153. LAD5C:  .byte $02           ;No sound   +
  5154. LAD5D:  .byte $FF           ;
  5155. LAD5E:  .byte $C4           ;
  5156. LAD5F:  .byte $B1           ;7/64 seconds   +
  5157. LAD60:  .byte $34           ;D4     |
  5158. LAD61:  .byte $34           ;D4     |
  5159. LAD62:  .byte $34           ;D4     |
  5160. LAD63:  .byte $34           ;D4     |
  5161. LAD64:  .byte $02           ;No sound   |
  5162. LAD65:  .byte $24           ;F#3        |
  5163. LAD66:  .byte $24           ;F#3        |
  5164. LAD67:  .byte $24           ;F#3        |
  5165. LAD68:  .byte $20           ;E3     |
  5166. LAD69:  .byte $20           ;E3     |
  5167. LAD6A:  .byte $20           ;E3     |
  5168. LAD6B:  .byte $20           ;E3     |
  5169. LAD6C:  .byte $2A           ;A3     |
  5170. LAD6D:  .byte $2A           ;A3     |
  5171. LAD6E:  .byte $2A           ;A3     |
  5172. LAD6F:  .byte $2A           ;A3     | Repeat 4 times.
  5173. LAD70:  .byte $02           ;No sound   |
  5174. LAD71:  .byte $24           ;F#3        |
  5175. LAD72:  .byte $24           ;F#3        |
  5176. LAD73:  .byte $24           ;F#3        |
  5177. LAD74:  .byte $24           ;F#3        |
  5178. LAD75:  .byte $24           ;F#3        |
  5179. LAD76:  .byte $24           ;F#3        |
  5180. LAD77:  .byte $24           ;F#3        |
  5181. LAD78:  .byte $B8           ;21/64 seconds  |
  5182. LAD79:  .byte $26           ;G3     |
  5183. LAD7A:  .byte $1C           ;D3     |
  5184. LAD7B:  .byte $20           ;E3     |
  5185. LAD7C:  .byte $B9           ;9/32 seconds   |
  5186. LAD7D:  .byte $02           ;No sound   |
  5187. LAD7E:  .byte $B8           ;21/64 seconds  |
  5188. LAD7F:  .byte $2C           ;A#3        |
  5189. LAD80:  .byte $2A           ;A3     |
  5190. LAD81:  .byte $26           ;G3     |
  5191. LAD82:  .byte $B9           ;9/32 seconds   |
  5192. LAD83:  .byte $02           ;No sound   +
  5193. LAD84:  .byte $FF           ;
  5194. LAD85:  .byte $C3           ;
  5195. LAD86:  .byte $B0           ;1/4 seconds    +
  5196. LAD87:  .byte $34           ;D4     |
  5197. LAD88:  .byte $34           ;D4     |
  5198. LAD89:  .byte $34           ;D4     |
  5199. LAD8A:  .byte $02           ;No sound   |
  5200. LAD8B:  .byte $02           ;No sound   |
  5201. LAD8C:  .byte $02           ;No sound   |
  5202. LAD8D:  .byte $34           ;D4     |
  5203. LAD8E:  .byte $34           ;D4     |
  5204. LAD8F:  .byte $34           ;D4     |
  5205. LAD90:  .byte $02           ;No sound   |
  5206. LAD91:  .byte $34           ;D4     |
  5207. LAD92:  .byte $34           ;D4     |
  5208. LAD93:  .byte $34           ;D4     |
  5209. LAD94:  .byte $34           ;D4     | Repeat 3 times.
  5210. LAD95:  .byte $34           ;D4     |
  5211. LAD96:  .byte $02           ;No sound   |
  5212. LAD97:  .byte $2C           ;A#3        |
  5213. LAD98:  .byte $2C           ;A#3        |
  5214. LAD99:  .byte $2C           ;A#3        |
  5215. LAD9A:  .byte $02           ;No sound   |
  5216. LAD9B:  .byte $02           ;No sound   |
  5217. LAD9C:  .byte $02           ;No sound   |
  5218. LAD9D:  .byte $2C           ;A#3        |
  5219. LAD9E:  .byte $2C           ;A#3        |
  5220. LAD9F:  .byte $30           ;C4     |
  5221. LADA0:  .byte $02           ;No sound   |
  5222. LADA1:  .byte $30           ;C4     |
  5223. LADA2:  .byte $30           ;C4     |
  5224. LADA3:  .byte $30           ;C4     |
  5225. LADA4:  .byte $30           ;C4     |
  5226. LADA5:  .byte $30           ;C4     |
  5227. LADA6:  .byte $02           ;No sound   +
  5228. LADA7:  .byte $FF           ;
  5229. LADA8:  .byte $C2           ;
  5230. LADA9:  .byte $1C           ;D3     +
  5231. LADAA:  .byte $1C           ;D3     |
  5232. LADAB:  .byte $1C           ;D3     |
  5233. LADAC:  .byte $02           ;No sound   |
  5234. LADAD:  .byte $02           ;No sound   |
  5235. LADAE:  .byte $02           ;No sound   |
  5236. LADAF:  .byte $1C           ;D3     | Repeat 2 times.
  5237. LADB0:  .byte $1C           ;D3     |
  5238. LADB1:  .byte $1C           ;D3     |
  5239. LADB2:  .byte $02           ;No sound   |
  5240. LADB3:  .byte $1C           ;D3     |
  5241. LADB4:  .byte $1C           ;D3     |
  5242. LADB5:  .byte $1C           ;D3     |
  5243. LADB6:  .byte $1C           ;D3     |
  5244. LADB7:  .byte $1C           ;D3     |
  5245. LADB8:  .byte $02           ;No sound   +
  5246. LADB9:  .byte $FF           ;
  5247. LADBA:  .byte $B4           ;7/8 seconds
  5248. LADBB:  .byte $1C           ;D3
  5249. LADBC:  .byte $B2           ;7/32 seconds
  5250. LADBD:  .byte $02           ;No sound
  5251. LADBE:  .byte $B0           ;1/4 seconds
  5252. LADBF:  .byte $1C           ;D3
  5253. LADC0:  .byte $02           ;No sound
  5254. LADC1:  .byte $1C           ;D3
  5255. LADC2:  .byte $1C           ;D3
  5256. LADC3:  .byte $B2           ;7/32 seconds
  5257. LADC4:  .byte $1C           ;D3
  5258.  
  5259. EndSQ2Data:
  5260. LADC5:  .byte $C2           ;
  5261. LADC6:  .byte $B4           ;7/8 seconds    +
  5262. LADC7:  .byte $20           ;E3     |
  5263. LADC8:  .byte $2A           ;A3     | Repeat 2 times.
  5264. LADC9:  .byte $28           ;Ab3        |
  5265. LADCA:  .byte $26           ;G3     +
  5266. LADCB:  .byte $FF           ;
  5267. LADCC:  .byte $20           ;E3
  5268. LADCD:  .byte $20           ;E3
  5269. LADCE:  .byte $C2           ;
  5270. LADCF:  .byte $B0           ;1/4 seconds    +
  5271. LADD0:  .byte $34           ;D4     |
  5272. LADD1:  .byte $3C           ;F#4        |
  5273. LADD2:  .byte $42           ;A4     |
  5274. LADD3:  .byte $4C           ;D5     |
  5275. LADD4:  .byte $B2           ;7/32 seconds   |
  5276. LADD5:  .byte $54           ;F#5        |
  5277. LADD6:  .byte $50           ;E5     |
  5278. LADD7:  .byte $4C           ;D5     |
  5279. LADD8:  .byte $B3           ;7/16 seconds   |
  5280. LADD9:  .byte $42           ;A4     | Repeat 2 times.
  5281. LADDA:  .byte $3C           ;F#4        |
  5282. LADDB:  .byte $B3           ;7/16 seconds   |
  5283. LADDC:  .byte $46           ;B4     |
  5284. LADDD:  .byte $B2           ;7/32 seconds   |
  5285. LADDE:  .byte $34           ;D4     |
  5286. LADDF:  .byte $B1           ;7/64 seconds   |
  5287. LADE0:  .byte $4C           ;D5     |
  5288. LADE1:  .byte $B0           ;1/4 seconds    |
  5289. LADE2:  .byte $42           ;A4     |
  5290. LADE3:  .byte $3C           ;F#4        |
  5291. LADE4:  .byte $B3           ;7/16 seconds   |
  5292. LADE5:  .byte $38           ;E4     |
  5293. LADE6:  .byte $46           ;B4     +
  5294. LADE7:  .byte $FF           ;
  5295. LADE8:  .byte $C2           ;
  5296. LADE9:  .byte $B3           ;7/16 seconds   +
  5297. LADEA:  .byte $38           ;E4     |
  5298. LADEB:  .byte $B2           ;7/32 seconds   |
  5299. LADEC:  .byte $3C           ;F#4        |
  5300. LADED:  .byte $34           ;D4     |
  5301. LADEE:  .byte $34           ;D4     |
  5302. LADEF:  .byte $30           ;C4     |
  5303. LADF0:  .byte $38           ;E4     |
  5304. LADF1:  .byte $34           ;D4     |
  5305. LADF2:  .byte $44           ;A#4        | Repeat 2 times.
  5306. LADF3:  .byte $38           ;E4     |
  5307. LADF4:  .byte $34           ;D4     |
  5308. LADF5:  .byte $42           ;A4     |
  5309. LADF6:  .byte $B1           ;7/64 seconds   |
  5310. LADF7:  .byte $3A           ;F4     |
  5311. LADF8:  .byte $40           ;Ab4        |
  5312. LADF9:  .byte $B2           ;7/32 seconds   |
  5313. LADFA:  .byte $46           ;B4     |
  5314. LADFB:  .byte $3E           ;G4     |
  5315. LADFC:  .byte $3E           ;G4     +
  5316. LADFD:  .byte $FF           ;
  5317. LADFE:  .byte $C4           ;
  5318. LADFF:  .byte $B2           ;7/32 seconds   +
  5319. LAE00:  .byte $3C           ;F#4        |
  5320. LAE01:  .byte $42           ;A4     |
  5321. LAE02:  .byte $4C           ;D5     |
  5322. LAE03:  .byte $42           ;A4     | Repeat 4 times.
  5323. LAE04:  .byte $3E           ;G4     |
  5324. LAE05:  .byte $42           ;A4     |
  5325. LAE06:  .byte $4C           ;D5     |
  5326. LAE07:  .byte $3E           ;G4     +
  5327. LAE08:  .byte $FF           ;
  5328. LAE09:  .byte $C2           ;
  5329. LAE0A:  .byte $72           ;A6     +
  5330. LAE0B:  .byte $6E           ;G6     |
  5331. LAE0C:  .byte $6C           ;F#6        |
  5332. LAE0D:  .byte $68           ;E6     |
  5333. LAE0E:  .byte $6E           ;G6     |
  5334. LAE0F:  .byte $6C           ;F#6        |
  5335. LAE10:  .byte $64           ;D6     |
  5336. LAE11:  .byte $68           ;E6     +
  5337. LAE12:  .byte $FF           ;
  5338. LAE13:  .byte $B4           ;7/8 seconds
  5339. LAE14:  .byte $4C           ;D5
  5340. LAE15:  .byte $B3           ;7/16 seconds
  5341. LAE16:  .byte $56           ;G5
  5342. LAE17:  .byte $50           ;E5
  5343. LAE18:  .byte $B4           ;7/8 seconds
  5344. LAE19:  .byte $54           ;F#5
  5345. LAE1A:  .byte $B3           ;7/16 seconds
  5346. LAE1B:  .byte $56           ;G5
  5347. LAE1C:  .byte $5C           ;A#5
  5348. LAE1D:  .byte $B4           ;7/8 seconds
  5349. LAE1E:  .byte $4C           ;D5
  5350. LAE1F:  .byte $B3           ;7/16 seconds
  5351. LAE20:  .byte $50           ;E5
  5352. LAE21:  .byte $56           ;G5
  5353. LAE22:  .byte $B4           ;7/8 seconds
  5354. LAE23:  .byte $54           ;F#5
  5355. LAE24:  .byte $B3           ;7/16 seconds
  5356. LAE25:  .byte $56           ;G5
  5357. LAE26:  .byte $5C           ;A#5
  5358. LAE27:  .byte $C4           ;
  5359. LAE28:  .byte $B1           ;7/64 seconds   +
  5360. LAE29:  .byte $5A           ;A5     |
  5361. LAE2A:  .byte $42           ;A4     |
  5362. LAE2B:  .byte $56           ;G5     |
  5363. LAE2C:  .byte $42           ;A4     |
  5364. LAE2D:  .byte $54           ;F#5        |
  5365. LAE2E:  .byte $42           ;A4     |
  5366. LAE2F:  .byte $50           ;E5     | Repeat 4 times.
  5367. LAE30:  .byte $42           ;A4     |
  5368. LAE31:  .byte $56           ;G5     |
  5369. LAE32:  .byte $3E           ;G4     |
  5370. LAE33:  .byte $54           ;F#5        |
  5371. LAE34:  .byte $3E           ;G4     |
  5372. LAE35:  .byte $4C           ;D5     |
  5373. LAE36:  .byte $3E           ;G4     |
  5374. LAE37:  .byte $50           ;E5     |
  5375. LAE38:  .byte $3E           ;G4     +
  5376. LAE39:  .byte $FF           ;
  5377. LAE3A:  .byte $C8           ;
  5378. LAE3B:  .byte $B0           ;1/4 seconds    +
  5379. LAE3C:  .byte $3C           ;F#4        |
  5380. LAE3D:  .byte $3E           ;G4     |
  5381. LAE3E:  .byte $3C           ;F#4        |
  5382. LAE3F:  .byte $3E           ;G4     |
  5383. LAE40:  .byte $42           ;A4     |
  5384. LAE41:  .byte $46           ;B4     |
  5385. LAE42:  .byte $42           ;A4     | Repeat 8 times.
  5386. LAE43:  .byte $46           ;B4     |
  5387. LAE44:  .byte $4C           ;D5     |
  5388. LAE45:  .byte $50           ;E5     |
  5389. LAE46:  .byte $4C           ;D5     |
  5390. LAE47:  .byte $50           ;E5     |
  5391. LAE48:  .byte $50           ;E5     |
  5392. LAE49:  .byte $54           ;F#5        |
  5393. LAE4A:  .byte $50           ;E5     |
  5394. LAE4B:  .byte $54           ;F#5        +
  5395. LAE4C:  .byte $FF           ;
  5396. LAE4D:  .byte $C3           ;
  5397. LAE4E:  .byte $B0           ;1/4 seconds    +
  5398. LAE4F:  .byte $42           ;A4     |
  5399. LAE50:  .byte $42           ;A4     |
  5400. LAE51:  .byte $42           ;A4     |
  5401. LAE52:  .byte $02           ;No sound   |
  5402. LAE53:  .byte $02           ;No sound   |
  5403. LAE54:  .byte $02           ;No sound   |
  5404. LAE55:  .byte $42           ;A4     |
  5405. LAE56:  .byte $42           ;A4     |
  5406. LAE57:  .byte $42           ;A4     |
  5407. LAE58:  .byte $02           ;No sound   |
  5408. LAE59:  .byte $42           ;A4     |
  5409. LAE5A:  .byte $42           ;A4     |
  5410. LAE5B:  .byte $42           ;A4     |
  5411. LAE5C:  .byte $42           ;A4     |
  5412. LAE5D:  .byte $42           ;A4     | Repeat 3 times.
  5413. LAE5E:  .byte $02           ;No sound   |
  5414. LAE5F:  .byte $3A           ;F4     |
  5415. LAE60:  .byte $3A           ;F4     |
  5416. LAE61:  .byte $3A           ;F4     |
  5417. LAE62:  .byte $02           ;No sound   |
  5418. LAE63:  .byte $02           ;No sound   |
  5419. LAE64:  .byte $02           ;No sound   |
  5420. LAE65:  .byte $3A           ;F4     |
  5421. LAE66:  .byte $3A           ;F4     |
  5422. LAE67:  .byte $3E           ;G4     |
  5423. LAE68:  .byte $02           ;No sound   |
  5424. LAE69:  .byte $3E           ;G4     |
  5425. LAE6A:  .byte $3E           ;G4     |
  5426. LAE6B:  .byte $3E           ;G4     |
  5427. LAE6C:  .byte $3E           ;G4     |
  5428. LAE6D:  .byte $3E           ;G4     |
  5429. LAE6E:  .byte $02           ;No sound   +
  5430. LAE6F:  .byte $FF           ;
  5431. LAE70:  .byte $C2           ;
  5432. LAE71:  .byte $42           ;A4     +
  5433. LAE72:  .byte $42           ;A4     |
  5434. LAE73:  .byte $42           ;A4     |
  5435. LAE74:  .byte $02           ;No sound   |
  5436. LAE75:  .byte $02           ;No sound   |
  5437. LAE76:  .byte $02           ;No sound   |
  5438. LAE77:  .byte $42           ;A4     |
  5439. LAE78:  .byte $42           ;A4     | Repeat 2 times.
  5440. LAE79:  .byte $42           ;A4     |
  5441. LAE7A:  .byte $02           ;No sound   |
  5442. LAE7B:  .byte $42           ;A4     |
  5443. LAE7C:  .byte $42           ;A4     |
  5444. LAE7D:  .byte $42           ;A4     |
  5445. LAE7E:  .byte $42           ;A4     |
  5446. LAE7F:  .byte $42           ;A4     |
  5447. LAE80:  .byte $02           ;No sound   +
  5448. LAE81:  .byte $FF           ;
  5449. LAE82:  .byte $B4           ;7/8 seconds
  5450. LAE83:  .byte $2A           ;A3
  5451. LAE84:  .byte $B2           ;7/32 seconds
  5452. LAE85:  .byte $02           ;No sound
  5453. LAE86:  .byte $B0           ;1/4 seconds
  5454. LAE87:  .byte $2A           ;A3
  5455. LAE88:  .byte $02           ;No sound
  5456. LAE89:  .byte $2A           ;A3
  5457. LAE8A:  .byte $2A           ;A3
  5458. LAE8B:  .byte $B2           ;7/32 seconds
  5459. LAE8C:  .byte $2A           ;A3
  5460. LAE8D:  .byte $00           ;End of end music.
  5461.  
  5462. EndNoiseData:
  5463. LAE8E:  .byte $CA           ;
  5464. LAE8F:  .byte $B0           ;1/4 seconds    +
  5465. LAE90:  .byte $04           ;Drumbeat 01    |
  5466. LAE91:  .byte $04           ;Drumbeat 01    |
  5467. LAE92:  .byte $04           ;Drumbeat 01    |
  5468. LAE93:  .byte $01           ;Drumbeat 00    |
  5469. LAE94:  .byte $01           ;Drumbeat 00    |
  5470. LAE95:  .byte $01           ;Drumbeat 00    |
  5471. LAE96:  .byte $04           ;Drumbeat 01    |
  5472. LAE97:  .byte $04           ;Drumbeat 01    | Repeat 10 times.
  5473. LAE98:  .byte $04           ;Drumbeat 01    |
  5474. LAE99:  .byte $01           ;Drumbeat 00    |
  5475. LAE9A:  .byte $04           ;Drumbeat 01    |
  5476. LAE9B:  .byte $04           ;Drumbeat 01    |
  5477. LAE9C:  .byte $04           ;Drumbeat 01    |
  5478. LAE9D:  .byte $04           ;Drumbeat 01    |
  5479. LAE9E:  .byte $04           ;Drumbeat 01    |
  5480. LAE9F:  .byte $01           ;Drumbeat 00    +
  5481. LAEA0:  .byte $FF           ;
  5482. LAEA1:  .byte $D8           ;
  5483. LAEA2:  .byte $B2           ;7/32 seconds   +
  5484. LAEA3:  .byte $04           ;Drumbeat 01    | Repeat 24 times.
  5485. LAEA4:  .byte $07           ;Drumbeat 02    +
  5486. LAEA5:  .byte $FF           ;
  5487. LAEA6:  .byte $C4           ;
  5488. LAEA7:  .byte $B0           ;1/4 seconds    +
  5489. LAEA8:  .byte $04           ;Drumbeat 01    |
  5490. LAEA9:  .byte $04           ;Drumbeat 01    |
  5491. LAEAA:  .byte $04           ;Drumbeat 01    |
  5492. LAEAB:  .byte $01           ;Drumbeat 00    |
  5493. LAEAC:  .byte $01           ;Drumbeat 00    |
  5494. LAEAD:  .byte $01           ;Drumbeat 00    |
  5495. LAEAE:  .byte $04           ;Drumbeat 01    | Repeat 4 times.
  5496. LAEAF:  .byte $04           ;Drumbeat 01    |
  5497. LAEB0:  .byte $04           ;Drumbeat 01    |
  5498. LAEB1:  .byte $01           ;Drumbeat 00    |
  5499. LAEB2:  .byte $04           ;Drumbeat 01    |
  5500. LAEB3:  .byte $04           ;Drumbeat 01    |
  5501. LAEB4:  .byte $04           ;Drumbeat 01    |
  5502. LAEB5:  .byte $04           ;Drumbeat 01    |
  5503. LAEB6:  .byte $04           ;Drumbeat 01    |
  5504. LAEB7:  .byte $01           ;Drumbeat 00    +
  5505. LAEB8:  .byte $FF           ;
  5506. LAEB9:  .byte $C8           ;
  5507. LAEBA:  .byte $B1           ;7/64 seconds   +
  5508. LAEBB:  .byte $04           ;Drumbeat 01    |
  5509. LAEBC:  .byte $B0           ;1/4 seconds    |
  5510. LAEBD:  .byte $04           ;Drumbeat 01    |
  5511. LAEBE:  .byte $04           ;Drumbeat 01    |
  5512. LAEBF:  .byte $B1           ;7/64 seconds   |
  5513. LAEC0:  .byte $04           ;Drumbeat 01    |
  5514. LAEC1:  .byte $B0           ;1/4 seconds    |
  5515. LAEC2:  .byte $04           ;Drumbeat 01    |
  5516. LAEC3:  .byte $04           ;Drumbeat 01    | Repeat 8 times.
  5517. LAEC4:  .byte $B1           ;7/64 seconds   |
  5518. LAEC5:  .byte $04           ;Drumbeat 01    |
  5519. LAEC6:  .byte $B0           ;1/4 seconds    |
  5520. LAEC7:  .byte $04           ;Drumbeat 01    |
  5521. LAEC8:  .byte $04           ;Drumbeat 01    |
  5522. LAEC9:  .byte $B1           ;7/64 seconds   |
  5523. LAECA:  .byte $07           ;Drumbeat 02    |
  5524. LAECB:  .byte $B0           ;1/4 seconds    |
  5525. LAECC:  .byte $04           ;Drumbeat 01    |
  5526. LAECD:  .byte $04           ;Drumbeat 01    +
  5527. LAECE:  .byte $FF           ;
  5528. LAECF:  .byte $D0           ;
  5529. LAED0:  .byte $B2           ;7/32 seconds   + Repeat 16 times.
  5530. LAED1:  .byte $04           ;Drumbeat01 +
  5531. LAED2:  .byte $FF           ;
  5532. LAED3:  .byte $E0           ;
  5533. LAED4:  .byte $B1           ;7/64 seconds   +
  5534. LAED5:  .byte $04           ;Drumbeat 01    | Repeat 32 times.
  5535. LAED6:  .byte $04           ;Drumbeat 01    +
  5536. LAED7:  .byte $FF           ;
  5537. LAED8:  .byte $E0           ;
  5538. LAED9:  .byte $B0           ;1/4 seconds    +
  5539. LAEDA:  .byte $04           ;Drumbeat 01    |
  5540. LAEDB:  .byte $04           ;Drumbeat 01    |
  5541. LAEDC:  .byte $B1           ;7/64 seconds   |
  5542. LAEDD:  .byte $07           ;Drumbeat 02    | Repeat 32 times.
  5543. LAEDE:  .byte $B0           ;1/4 seconds    |
  5544. LAEDF:  .byte $0A           ;Drumbeat 03    |
  5545. LAEE0:  .byte $04           ;Drumbeat 01    |
  5546. LAEE1:  .byte $B1           ;7/64 seconds   |
  5547. LAEE2:  .byte $07           ;Drumbeat 02    +
  5548. LAEE3:  .byte $FF           ;
  5549. LAEE4:  .byte $C8           ;
  5550. LAEE5:  .byte $B0           ;1/4 seconds    +
  5551. LAEE6:  .byte $04           ;Drumbeat 01    |
  5552. LAEE7:  .byte $04           ;Drumbeat 01    |
  5553. LAEE8:  .byte $04           ;Drumbeat 01    |
  5554. LAEE9:  .byte $01           ;Drumbeat 00    |
  5555. LAEEA:  .byte $01           ;Drumbeat 00    |
  5556. LAEEB:  .byte $01           ;Drumbeat 00    |
  5557. LAEEC:  .byte $04           ;Drumbeat 01    | Repeat 8 times.
  5558. LAEED:  .byte $04           ;Drumbeat 01    |
  5559. LAEEE:  .byte $04           ;Drumbeat 01    |
  5560. LAEEF:  .byte $01           ;Drumbeat 00    |
  5561. LAEF0:  .byte $04           ;Drumbeat 01    |
  5562. LAEF1:  .byte $04           ;Drumbeat 01    |
  5563. LAEF2:  .byte $04           ;Drumbeat 01    |
  5564. LAEF3:  .byte $04           ;Drumbeat 01    |
  5565. LAEF4:  .byte $04           ;Drumbeat 01    |
  5566. LAEF5:  .byte $01           ;Drumbeat 00    +
  5567. LAEF6:  .byte $FF           ;
  5568. LAEF7:  .byte $B4           ;7/8 seconds
  5569. LAEF8:  .byte $07           ;Drumbeat 02
  5570. LAEF9:  .byte $B2           ;7/32 seconds
  5571. LAEFA:  .byte $01           ;Drumbeat 00
  5572. LAEFB:  .byte $B0           ;1/4 seconds
  5573. LAEFC:  .byte $07           ;Drumbeat 02
  5574. LAEFD:  .byte $01           ;Drumbeat 00
  5575. LAEFE:  .byte $07           ;Drumbeat 02
  5576. LAEFF:  .byte $07           ;Drumbeat 02
  5577. LAF00:  .byte $B2           ;7/32 seconds
  5578. LAF01:  .byte $07           ;Drumbeat 02
  5579. LAF02:  .byte $00           ;End of end music.
  5580.  
  5581. ;Unused tile patterns.
  5582. LAF03:  .byte $80, $40, $20, $10, $88, $00, $00, $00, $00, $00, $00, $00, $80, $04, $00, $02
  5583. LAF13:  .byte $02, $00, $00, $00, $00, $07, $03, $03, $03, $01, $00, $00, $00, $84, $C4, $42
  5584. LAF23:  .byte $62, $21, $31, $11, $11, $80, $C0, $C0, $E0, $E0, $F0, $F0, $F0, $00, $00, $00
  5585. LAF33:  .byte $00, $00, $00, $00, $01, $00, $00, $00, $00, $01, $01, $03, $03, $11, $11, $31
  5586. LAF43:  .byte $21, $63, $62, $C4, $84, $F0, $F0, $F0, $E0, $E0, $E0, $C0, $80, $01, $13, $16
  5587. LAF53:  .byte $2C, $78, $B3, $EC, $F0, $07, $1F, $1E, $3C, $78, $F0, $E0, $00, $08, $10, $20
  5588. LAF63:  .byte $40, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $82, $CC, $4E
  5589. LAF73:  .byte $4C, $40, $4C, $4C, $4C, $82, $CC, $CE, $CC, $C0, $CC, $CC, $CC, $00, $00, $00
  5590. LAF83:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  5591. LAF93:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  5592. LAFA3:  .byte $01, $03, $06, $0C, $18, $00, $00, $00, $00, $00, $01, $03, $07, $0F, $3C, $E0
  5593. LAFB3:  .byte $84, $08, $30, $60, $E0, $00, $02, $1F, $7A, $F4, $C8, $98, $10, $19, $31, $33
  5594. LABC3:  .byte $63, $63, $67, $E7, $E7, $06, $0E, $0C, $1C, $1C, $18, $18, $18, $C0, $C0, $80
  5595. LAFD3:  .byte $80, $80, $00, $00, $00, $30, $30, $60, $60, $60, $E0, $E0, $E0, $C7, $C7, $C7
  5596. LAFE3:  .byte $C7, $C7, $C7, $C7, $C7, $38, $38, $38, $38, $38, $38, $38, $38, $20, $20, $20
  5597. LAFF3:  .byte $20, $20, $20, $20, $20, $C0, $C0, $C0, $C0, $C0, $C0, $C0, $C0
  5598.  
  5599. IntroSQ2Data:
  5600. LB000:  .byte $C2           ;
  5601. LB001:  .byte $B4           ;7/8 seconds    +
  5602. LB002:  .byte $64           ;D6     |
  5603. LB003:  .byte $74           ;A#6        |
  5604. LB004:  .byte $6A           ;F6     |
  5605. LB005:  .byte $02           ;No sound   | Repeat 2 times.
  5606. LB006:  .byte $64           ;D6     |
  5607. LB007:  .byte $78           ;C7     |
  5608. LB008:  .byte $74           ;A#6        |
  5609. LB009:  .byte $02           ;No sound   +
  5610. LB00A:  .byte $FF           ;
  5611. LB00B:  .byte $C2           ;
  5612. LB00C:  .byte $B2           ;7/32 seconds   +
  5613. LB00D:  .byte $72           ;A6     |
  5614. LB00E:  .byte $5A           ;A5     |
  5615. LB00F:  .byte $6E           ;G6     |
  5616. LB010:  .byte $56           ;G5     |
  5617. LB011:  .byte $6C           ;F#6        |
  5618. LB012:  .byte $54           ;F#5        |
  5619. LB013:  .byte $68           ;E6     | Repeat 2 times.
  5620. LB014:  .byte $50           ;E5     |
  5621. LB015:  .byte $6E           ;G6     |
  5622. LB016:  .byte $56           ;G5     |
  5623. LB017:  .byte $6C           ;F#6        |
  5624. LB018:  .byte $54           ;F#5        |
  5625. LB019:  .byte $68           ;E6     |
  5626. LB01A:  .byte $50           ;E5     |
  5627. LB01B:  .byte $64           ;D6     |
  5628. LB01C:  .byte $4C           ;D5     +
  5629. LB01D:  .byte $FF           ;
  5630. LB01E:  .byte $C4           ;
  5631. LB01F:  .byte $72           ;A6     +
  5632. LB020:  .byte $5A           ;A5     |
  5633. LB021:  .byte $6E           ;G6     |
  5634. LB022:  .byte $5A           ;A5     |
  5635. LB023:  .byte $6C           ;F#6        |
  5636. LB024:  .byte $5A           ;A5     |
  5637. LB025:  .byte $68           ;E6     |
  5638. LB026:  .byte $5A           ;A5     | Repeat 4 times.
  5639. LB027:  .byte $6E           ;G6     |
  5640. LB028:  .byte $56           ;G5     |
  5641. LB029:  .byte $6C           ;F#6        |
  5642. LB02A:  .byte $56           ;G5     |
  5643. LB02B:  .byte $68           ;E6     |
  5644. LB02C:  .byte $56           ;G5     |
  5645. LB02D:  .byte $64           ;D6     |
  5646. LB02E:  .byte $56           ;G5     +
  5647. LB02F:  .byte $FF           ;
  5648. LB030:  .byte $B2           ;7/32 seconds
  5649. LB031:  .byte $5A           ;A5
  5650. LB032:  .byte $B1           ;7/64 seconds
  5651. LB033:  .byte $42           ;A4
  5652. LB034:  .byte $B2           ;7/32 seconds
  5653. LB035:  .byte $56           ;G5
  5654. LB036:  .byte $B1           ;7/64 seconds
  5655. LB037:  .byte $42           ;A4
  5656. LB038:  .byte $B2           ;7/32 seconds
  5657. LB039:  .byte $54           ;F#5
  5658. LB03A:  .byte $B1           ;7/64 seconds
  5659. LB03B:  .byte $42           ;A4
  5660. LB03C:  .byte $B2           ;7/32 seconds
  5661. LB03D:  .byte $50           ;E5
  5662. LB03E:  .byte $B1           ;7/64 seconds
  5663. LB03F:  .byte $42           ;A4
  5664. LB040:  .byte $B2           ;7/32 seconds
  5665. LB041:  .byte $5A           ;A5
  5666. LB042:  .byte $B1           ;7/64 seconds
  5667. LB043:  .byte $42           ;A4
  5668. LB044:  .byte $B2           ;7/32 seconds
  5669. LB045:  .byte $56           ;G5
  5670. LB046:  .byte $B1           ;7/64 seconds
  5671. LB047:  .byte $42           ;A4
  5672. LB048:  .byte $B2           ;7/32 seconds
  5673. LB049:  .byte $52           ;F5
  5674. LB04A:  .byte $B1           ;7/64 seconds
  5675. LB04B:  .byte $42           ;A4
  5676. LB04C:  .byte $B2           ;7/32 seconds
  5677. LB04D:  .byte $50           ;E5
  5678. LB04E:  .byte $B1           ;7/64 seconds
  5679. LB04F:  .byte $42           ;A4
  5680. LB050:  .byte $B2           ;7/32 seconds
  5681. LB051:  .byte $5A           ;A5
  5682. LB052:  .byte $B1           ;7/64 seconds
  5683. LB053:  .byte $44           ;A#4
  5684. LB054:  .byte $B2           ;7/32 seconds
  5685. LB055:  .byte $56           ;G5
  5686. LB056:  .byte $B1           ;7/64 seconds
  5687. LB057:  .byte $44           ;A#4
  5688. LB058:  .byte $B2           ;7/32 seconds
  5689. LB059:  .byte $52           ;F5
  5690. LB05A:  .byte $B1           ;7/64 seconds
  5691. LB05B:  .byte $44           ;A#4
  5692. LB05C:  .byte $B2           ;7/32 seconds
  5693. LB05D:  .byte $56           ;G5
  5694. LB05E:  .byte $B1           ;7/64 seconds
  5695. LB05F:  .byte $44           ;A#4
  5696. LB060:  .byte $C4           ;
  5697. LB061:  .byte $5A           ;A5     +
  5698. LB062:  .byte $50           ;E5     | Repeat 4 times.
  5699. LB063:  .byte $46           ;B4     +
  5700. LB064:  .byte $FF           ;
  5701. LB065:  .byte $C3           ;
  5702. LB066:  .byte $58           ;Ab5        +
  5703. LB067:  .byte $50           ;E5     | Repeat 3 times.
  5704. LB068:  .byte $46           ;B4     +
  5705. LB069:  .byte $FF           ;
  5706. LB06A:  .byte $58           ;Ab5
  5707. LB06B:  .byte $50           ;E5
  5708. LB06C:  .byte $B0           ;1/4 seconds
  5709. LB06D:  .byte $46           ;B4
  5710. LB06E:  .byte $02           ;No sound
  5711. LB06F:  .byte $E0           ;
  5712. LB070:  .byte $B6           ;21/32 seconds  +
  5713. LB071:  .byte $1C           ;D3     | Repeat 32 times.
  5714. LB072:  .byte $B2           ;7/32 seconds   |
  5715. LB073:  .byte $02           ;No sound   +
  5716. LB074:  .byte $FF           ;
  5717. LB075:  .byte $00           ;End intro music.
  5718.  
  5719. IntroTriangleData:
  5720. LB076:  .byte $D0
  5721. LB077:  .byte $B6           ;21/32 seconds  +
  5722. LB078:  .byte $2A           ;A3     |
  5723. LB079:  .byte $B1           ;7/64 seconds   | Repeat 16 times.
  5724. LB07A:  .byte $2A           ;A3     |
  5725. LB07B:  .byte $B1           ;7/64 seconds   |
  5726. LB07C:  .byte $02           ;No sound   +
  5727. LB07D:  .byte $FF           ;
  5728. LB07E:  .byte $B4           ;7/8 seconds
  5729. LB07F:  .byte $4C           ;D5
  5730. LB080:  .byte $60           ;C6
  5731. LB081:  .byte $5E           ;B5
  5732. LB082:  .byte $5C           ;A#5
  5733. LB083:  .byte $54           ;F#5
  5734. LB084:  .byte $60           ;C6
  5735. LB085:  .byte $5C           ;A#5
  5736. LB086:  .byte $56           ;G5
  5737. LB087:  .byte $C2           ;
  5738. LB088:  .byte $34           ;D4     +
  5739. LB089:  .byte $48           ;C5     |
  5740. LB08A:  .byte $46           ;B4     |
  5741. LB08B:  .byte $44           ;A#4        | Repeat 2 times.
  5742. LB08C:  .byte $3C           ;F#4        |
  5743. LB08D:  .byte $48           ;C5     |
  5744. LB08E:  .byte $44           ;A#4        |
  5745. LB08F:  .byte $3E           ;G4     +
  5746. LB090:  .byte $FF           ;
  5747. LB091:  .byte $C2           ;
  5748. LB092:  .byte $B2           ;7/32 seconds   +
  5749. LB093:  .byte $34           ;D4     |
  5750. LB094:  .byte $B1           ;7/64 seconds   | Repeat 2 times.
  5751. LB095:  .byte $42           ;A4     |
  5752. LB096:  .byte $B5           ;1 13/16 seconds|
  5753. LB097:  .byte $4C           ;D5     +
  5754. LB098:  .byte $FF           ;
  5755. LB099:  .byte $C2           ;
  5756. LB09A:  .byte $B2           ;7/32 seconds   +
  5757. LB09B:  .byte $2C           ;A#3        |
  5758. LB09C:  .byte $B1           ;7/64 seconds   | Repeat 2 times.
  5759. LB09D:  .byte $3A           ;F4     |
  5760. LB09E:  .byte $B5           ;1 13/16 seconds|
  5761. LB09F:  .byte $48           ;C5     +
  5762. LB0A0:  .byte $FF           ;
  5763. LB0A1:  .byte $C2           ;
  5764. LB0A2:  .byte $B2           ;7/32 seconds   +
  5765. LB0A3:  .byte $1E           ;D#3        |
  5766. LB0A4:  .byte $B1           ;7/64 seconds   | Repeat 2 times.
  5767. LB0A5:  .byte $2C           ;A#3        |
  5768. LB0A6:  .byte $B5           ;1 13/16 seconds|
  5769. LB0A7:  .byte $36           ;D#4        +
  5770. LB0A8:  .byte $FF           ;
  5771. LB0A9:  .byte $C4           ;
  5772. LB0AA:  .byte $B2           ;7/32 seconds   +
  5773. LB0AB:  .byte $20           ;E3     |
  5774. LB0AC:  .byte $B1           ;7/64 seconds   | Repeat 4 times.
  5775. LB0AD:  .byte $2E           ;B3     |
  5776. LB0AE:  .byte $B5           ;1 13/16 seconds|
  5777. LB0AF:  .byte $38           ;E4     +
  5778. LB0B0:  .byte $FF           ;
  5779. LB0B1:  .byte $E0           ;
  5780. LB0B2:  .byte $B6           ;21/32 seconds  +
  5781. LB0B3:  .byte $2A           ;A3     |
  5782. LB0B4:  .byte $B1           ;7/64 seconds   | Repeat 32 times.
  5783. LB0B5:  .byte $2A           ;A3     |
  5784. LB0B6:  .byte $B1           ;7/64 seconds   |
  5785. LB0B7:  .byte $02           ;No sound   +
  5786. LB0B8:  .byte $FF           ;
  5787.  
  5788. IntroSQ1Data:
  5789. LB0B9:  .byte $D0           ;
  5790. LB0BA:  .byte $B6           ;21/32 seconds  +
  5791. LB0BB:  .byte $06           ;D2     | Repeat 16 times.
  5792. LB0BC:  .byte $B2           ;7/32 seconds   |
  5793. LB0BD:  .byte $02           ;No sound   +
  5794. LB0BE:  .byte $FF           ;
  5795. LB0BF:  .byte $C8           ;
  5796. LB0C0:  .byte $B4           ;7/8 seconds    + Repeat 8 times.
  5797. LB0C1:  .byte $02           ;No sound   +
  5798. LB0C2:  .byte $FF           ;
  5799. LB0C3:  .byte $B2           ;7/32 seconds
  5800. LB0C4:  .byte $24           ;F#3
  5801. LB0C5:  .byte $26           ;G3
  5802. LB0C6:  .byte $2A           ;A3
  5803. LB0C7:  .byte $2E           ;B3
  5804. LB0C8:  .byte $34           ;D4
  5805. LB0C9:  .byte $38           ;E4
  5806. LB0CA:  .byte $3C           ;F#4
  5807. LB0CB:  .byte $3E           ;G4
  5808. LB0CC:  .byte $B6           ;21/32 seconds
  5809. LB0CD:  .byte $42           ;A4
  5810. LB0CE:  .byte $B1           ;7/64 seconds
  5811. LB0CF:  .byte $3E           ;G4
  5812. LB0D0:  .byte $3C           ;F#4
  5813. LB0D1:  .byte $B6           ;21/32 seconds
  5814. LB0D2:  .byte $3E           ;G4
  5815. LB0D3:  .byte $B1           ;7/64 seconds
  5816. LB0D4:  .byte $3C           ;F#4
  5817. LB0D5:  .byte $38           ;E4
  5818. LB0D6:  .byte $B6           ;21/32 seconds
  5819. LB0D7:  .byte $34           ;D4
  5820. LB0D8:  .byte $B2           ;7/32 seconds
  5821. LB0D9:  .byte $42           ;A4
  5822. LB0DA:  .byte $B4           ;7/8 seconds
  5823. LB0DB:  .byte $4C           ;D5
  5824. LB0DC:  .byte $B3           ;7/16 seconds
  5825. LB0DD:  .byte $44           ;A#4
  5826. LB0DE:  .byte $42           ;A4
  5827. LB0DF:  .byte $3E           ;G4
  5828. LB0E0:  .byte $3C           ;F#4
  5829. LB0E1:  .byte $B6           ;21/32 seconds
  5830. LB0E2:  .byte $38           ;E4
  5831. LB0E3:  .byte $B2           ;7/32 seconds
  5832. LB0E4:  .byte $3C           ;F#4
  5833. LB0E5:  .byte $B6           ;21/32 seconds
  5834. LB0E6:  .byte $42           ;A4
  5835. LB0E7:  .byte $B2           ;7/32 seconds
  5836. LB0E8:  .byte $4C           ;D5
  5837. LB0E9:  .byte $B6           ;21/32 seconds
  5838. LB0EA:  .byte $38           ;E4
  5839. LB0EB:  .byte $B2           ;7/32 seconds
  5840. LB0EC:  .byte $3C           ;F#4
  5841. LB0ED:  .byte $B4           ;7/8 seconds
  5842. LB0EE:  .byte $34           ;D4
  5843. LB0EF:  .byte $B3           ;7/16 seconds
  5844. LB0F0:  .byte $2A           ;A3
  5845. LB0F1:  .byte $2E           ;B3
  5846. LB0F2:  .byte $34           ;D4
  5847. LB0F3:  .byte $38           ;E4
  5848. LB0F4:  .byte $B6           ;21/32 seconds
  5849. LB0F5:  .byte $34           ;D4
  5850. LB0F6:  .byte $B2           ;7/32 seconds
  5851. LB0F7:  .byte $2C           ;A#3
  5852. LB0F8:  .byte $B4           ;7/8 seconds
  5853. LB0F9:  .byte $26           ;G3
  5854. LB0FA:  .byte $B5           ;1 13/16 seconds
  5855. LB0FB:  .byte $38           ;E4
  5856. LB0FC:  .byte $3C           ;F#4
  5857. LB0FD:  .byte $42           ;A4
  5858. LB0FE:  .byte $4C           ;D5
  5859. LB0FF:  .byte $34           ;D4
  5860. LB100:  .byte $3A           ;F4
  5861. LB101:  .byte $48           ;C5
  5862. LB102:  .byte $42           ;A4
  5863. LB103:  .byte $36           ;D#4
  5864. LB104:  .byte $3E           ;G4
  5865. LB105:  .byte $4C           ;D5
  5866. LB106:  .byte $44           ;A#4
  5867. LB107:  .byte $42           ;A4
  5868. LB108:  .byte $38           ;E4
  5869. LB109:  .byte $2E           ;B3
  5870. LB10A:  .byte $38           ;E4
  5871. LB10B:  .byte $40           ;Ab4
  5872. LB10C:  .byte $38           ;E4
  5873. LB10D:  .byte $2E           ;B3
  5874. LB10E:  .byte $38           ;E4
  5875. LB10F:  .byte $E0           ;
  5876. LB110:  .byte $B6           ;21/32 seconds  +
  5877. LB111:  .byte $06           ;D2     | Repeat 32 times.
  5878. LB112:  .byte $B2           ;7/32 seconds   |
  5879. LB113:  .byte $02           ;No sound   +
  5880. LB114:  .byte $FF           ;
  5881.  
  5882. IntroNoiseIndexData:
  5883. LB115:  .byte $D0           ;
  5884. LB116:  .byte $B4           ;7/8 Seconds    + Repeat 16 times.
  5885. LB117:  .byte $04           ;Drumbeat 01    +
  5886. LB118:  .byte $FF           ;
  5887. LB119:  .byte $CC           ;
  5888. LB11A:  .byte $B2           ;7/32 Seconds   +
  5889. LB11B:  .byte $04           ;Drumbeat 01    |
  5890. LB11C:  .byte $04           ;Drumbeat 01    |
  5891. LB11D:  .byte $B5           ;1 13/16 Seconds|
  5892. LB11E:  .byte $07           ;Drumbeat 02    |
  5893. LB11F:  .byte $B0           ;1/4 Seconds    |
  5894. LB120:  .byte $04           ;Drumbeat 01    | Repeat 12 times.
  5895. LB121:  .byte $04           ;Drumbeat 01    |
  5896. LB122:  .byte $B6           ;21/32 Seconds  |
  5897. LB123:  .byte $04           ;Drumbeat 01    |
  5898. LB124:  .byte $B1           ;7/64 Seconds   |
  5899. LB125:  .byte $04           ;Drumbeat 01    |
  5900. LB126:  .byte $04           ;Drumbeat 01    +
  5901. LB127:  .byte $FF           ;
  5902. LB128:  .byte $CA           ;
  5903. LB129:  .byte $B1           ;7/64 Seconds   +
  5904. LB12A:  .byte $04           ;Drumbeat 01    |
  5905. LB12B:  .byte $04           ;Drumbeat 01    |
  5906. LB12C:  .byte $04           ;Drumbeat 01    | Repeat 10 times.
  5907. LB12D:  .byte $07           ;Drumbeat 02    |
  5908. LB12E:  .byte $04           ;Drumbeat 01    |
  5909. LB12F:  .byte $04           ;Drumbeat 01    +
  5910. LB130:  .byte $FF           ;
  5911. LB131:  .byte $E0           ;
  5912. LB132:  .byte $B4           ;7/8 Seconds    + Repeat 32 times.
  5913. LB133:  .byte $04           ;Drumbeat 01    +
  5914. LB134:  .byte $FF           ;
  5915.  
  5916. ;Unused tile patterns.
  5917. LB135:  .byte $E0, $E0, $F0, $00, $00, $00, $00, $00, $00, $00, $00, $21, $80, $40, $02, $05
  5918. LB145:  .byte $26, $52, $63, $00, $00, $00, $06, $07, $67, $73, $73, $FF, $AF, $2F, $07, $0B
  5919. LB155:  .byte $8D, $A7, $B1, $00, $00, $00, $00, $00, $80, $80, $80, $F8, $B8, $F8, $F8, $F0
  5920. LB165:  .byte $F0, $F8, $FC, $00, $00, $00, $00, $00, $00, $00, $00, $07, $07, $07, $07, $07
  5921. LB175:  .byte $03, $03, $01, $00, $00, $00, $00, $00, $00, $00, $80, $FF, $C7, $83, $03, $C7
  5922. LB185:  .byte $CF, $FE, $EC, $00, $30, $78, $F8, $30, $00, $01, $12, $F5, $EA, $FB, $FD, $F9
  5923. LB195:  .byte $1E, $0E, $44, $07, $03, $03, $01, $01, $E0, $10, $48, $2B, $3B, $1B, $5A, $D0
  5924. LB1A5:  .byte $D1, $C3, $C3, $3B, $3B, $9B, $DA, $D0, $D0, $C0, $C0, $2C, $23, $20, $20, $30
  5925. LB1B5:  .byte $98, $CF, $C7, $00, $00, $00, $00, $00, $00, $00, $30, $1F, $80, $C0, $C0, $60
  5926. LB1C5:  .byte $70, $FC, $C0, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $00
  5927. LB1D5:  .byte $00, $00, $00, $80, $80, $C0, $78, $4C, $C7, $80, $80, $C4, $A5, $45, $0B, $1B
  5928. LB1E5:  .byte $03, $03, $00, $3A, $13, $31, $63, $C3, $83, $03, $04, $E6, $E6, $C4, $8E, $1C
  5929. LB1F5:  .byte $3C, $18, $30, $E8, $E8, $C8, $90, $60, $00, $00, $00
  5930.  
  5931. ;------------------------------------------[ Sound Engine ]------------------------------------------
  5932.  
  5933. ;SFXdata. The top four entries are used by the noise music player for drum beats.
  5934. LB200:  .byte $00           ;Base for drum beat music data.
  5935.  
  5936. DrumBeat00SFXData:
  5937. LB201:  .byte $10, $01, $18     ;Noise channel music data #$01.
  5938. DrumBeat01SFXData:
  5939. LB204:  .byte $00, $01, $38     ;Noise channel music data #$04.
  5940. DrumBeat02SFXData:
  5941. LB207:  .byte $01, $02, $40     ;Noise channel music data #$07.
  5942. DrumBeat03SFXData:
  5943. LB20A:  .byte $00, $09, $58     ;Noise channel music data #$0A.
  5944. GamePausedSFXData:
  5945. LB20D:  .byte $80, $7F, $80, $48
  5946. ScrewAttSFXData:
  5947. LB211:  .byte $35, $7F, $00, $B0
  5948. MissileLaunchSFXData:
  5949. LB215:  .byte $19, $7F, $0E, $A0
  5950. BombExplodeSFXData:
  5951. LB219:  .byte $0D, $7F, $0F, $08
  5952. SamusWalkSFXData:
  5953. LB21D:  .byte $16, $7F, $0B, $18
  5954. SpitFlameSFXData:
  5955. LB221:  .byte $13, $7F, $0E, $F8
  5956. SamusHitSQ1SQ2SFXData:
  5957. LC225:  .byte $C1, $89, $02, $0F
  5958. BossHitSQ2SFXData:
  5959. LB229:  .byte $34, $BA, $E0, $05
  5960. BossHitSQ1SFXData:
  5961. LB22D:  .byte $34, $BB, $CE, $05
  5962. IncorrectPasswordSQ1SFXData:
  5963. LB231:  .byte $B6, $7F, $00, $C2
  5964. IncorrectPasswordSQ2SFXData:
  5965. LB235:  .byte $B6, $7F, $04, $C2
  5966. TimeBombTickSFXData:
  5967. LB239:  .byte $17, $7F, $66, $89
  5968. EnergyPickupSFXData:
  5969. LB23D:  .byte $89, $7F, $67, $18
  5970. MissilePickupSFXData:
  5971. LB241:  .byte $8B, $7F, $FD, $28
  5972. MetalSFXData:
  5973. LB245:  .byte $02, $7F, $A8, $F8
  5974. LongRangeShotSFXData:
  5975. LB249:  .byte $D7, $83, $58, $F8
  5976. ShortRangeShotSFXData:
  5977. LB24D:  .byte $D6, $82, $58, $F8
  5978. JumpSFXData:
  5979. LB251:  .byte $95, $8C, $40, $B9
  5980. EnemyHitSFXData:
  5981. LB255:  .byte $1D, $9A, $20, $8F
  5982. BugOutOFHoleSFXData:
  5983. LB259:  .byte $16, $8D, $E0, $42
  5984. WaveBeamSFXData:
  5985. LB25D:  .byte $19, $7F, $6F, $40
  5986. IceBeamSFXData:
  5987. LB261:  .byte $18, $7F, $80, $40
  5988. BombLaunch1SFXData:
  5989. LB265:  .byte $07, $7F, $40, $28
  5990. BombLaunch2SFXData:
  5991. LB269:  .byte $07, $7F, $45, $28
  5992. SamusToBallSFXData:
  5993. LB26D:  .byte $7F, $7F, $DD, $3B
  5994. MetroidHitSFXData:
  5995. LB26E:  .byte $7F, $7F, $FF, $98
  5996. SamusDieSFXData:
  5997. LB275:  .byte $7F, $7F, $40, $08
  5998. SamusBeepSFXData:
  5999. LB279:  .byte $09, $7F, $30, $48
  6000. BigEnemyHitSFXData:
  6001. LB27D:  .byte $03, $7F, $42, $18
  6002. StatueRaiseSFXData:
  6003. LB281:  .byte $03, $7F, $11, $09
  6004. DoorSFXData:
  6005. LB285:  .byte $7F, $7F, $30, $B2
  6006.  
  6007. ;The following table is used by the CheckSFXFlag routine.  The first two bytes of each row
  6008. ;are the address of the pointer table used for handling SFX and music  routines for set flags.
  6009. ;The second pair of bytes is the address of the routine to next jump to if no SFX or music
  6010. ;flags were found.  The final byte represents what type of channel is currently being
  6011. ;processed: 0=Noise, 1=SQ1, 3=Triangle, 4=Multiple channels.
  6012.  
  6013. ChooseNextSFXRoutineTbl:
  6014.  
  6015. LB289:  .word $B2BB, $B322      ;Noise init SFX     (1st).
  6016. LB28D:  .byte $00
  6017.    
  6018. LB28E:  .word $B2CB, $B4EE      ;Noise continue SFX (2nd).
  6019. LB292:  .byte $00
  6020.  
  6021. LB293:  .word $B2DB, $B330      ;SQ1 init SFX       (5th).
  6022. LB297:  .byte $01
  6023.  
  6024. LB298:  .word $B2EB, $B4EE      ;SQ2 continue SFX   (6th).
  6025. LB29C:  .byte $01
  6026.  
  6027. LB29D:  .word $B2FB, $B344      ;Triangle init SFX  (7th).
  6028. LB2A1:  .byte $03
  6029.  
  6030. LB2A2:  .word $B30B, $B4EE      ;Triangle continue SFX  (8th).
  6031. LB2A6:  .byte $03
  6032.  
  6033. LB2A7:  .word $BC06, $B35C      ;Multi init SFX     (3rd).
  6034. LB2AB:  .byte $04
  6035.  
  6036. LB2AC:  .word $BC16, $B364      ;Multi continue SFX (4th).
  6037. LB2B0:  .byte $04
  6038.  
  6039. LB2B1:  .word $BC26, $BC4B      ;temp flag Music    (10th).
  6040. LB2B5:  .byte $00
  6041.  
  6042. LB2B6:  .word $BC26, $BC3D      ;Music          (9th).
  6043. LB2BA:  .byte $00
  6044.  
  6045. ;The tables below contain addresses for SFX handling routines.
  6046.  
  6047. ;Noise Init SFX handling routine addresses:
  6048. LB2BB:  .word $B4EE         ;No sound.
  6049. LB2BD:  .word $B52B         ;Screw attack init SFX.
  6050. LB2BF:  .word $B56E         ;Missile launch init SFX.
  6051. LB2C1:  .word $B583         ;Bomb explode init SFX.
  6052. LB2C3:  .word $B598         ;Samus walk init SFX.
  6053. LB2C5:  .word $B50F         ;Spit flame init SFX.
  6054. LB2C7:  .word $B4EE         ;No sound.
  6055. LB2C9:  .word $B4EE         ;No sound.
  6056.  
  6057. ;Noise Continue SFX handling routine addresses:
  6058.  
  6059. LB2CB:  .word $B4EE         ;No sound.
  6060. LB2CD:  .word $B539         ;Screw attack continue SFX.
  6061. LB2CF:  .word $B57B         ;Missile launch continue SFX.
  6062. LB2D1:  .word $B58A         ;Bomb explode continue SFX.
  6063. LB2D3:  .word $B58A         ;Samus walk continue SFX.
  6064. LB2D5:  .word $B516         ;Spit flame continue SFX.
  6065. LB2D7:  .word $B4EE         ;No sound.
  6066. LB2D9:  .word $B4EE         ;No sound.
  6067.  
  6068. ;SQ1 Init SFX handling routine addresses:
  6069.  
  6070. LB2DB:  .word $B6CD         ;Missile pickup init SFX.
  6071. LB2DD:  .word $B6E7         ;Energy pickup init SFX.
  6072. LB2DF:  .word $B735         ;Metal init SFX.
  6073. LB2E1:  .word $B716         ;Bullet fire init SFX.
  6074. LB2E3:  .word $B73C         ;Bird out of hole init SFX.
  6075. LB2E5:  .word $B710         ;Enemy hit init SFX.
  6076. LB2E7:  .word $B703         ;Samus jump init SFX.
  6077. LB2E9:  .word $B77A         ;Wave beam init SFX.
  6078.  
  6079. ;SQ1 Continue SFX handling routine addresses:
  6080.  
  6081. LB2EB:  .word $B6B0         ;Missile pickup continue SFX.
  6082. LB2ED:  .word $B6D3         ;Energy pickup continue SFX.
  6083. LB2EF:  .word $B6ED         ;Metal continue SFX.
  6084. LB2F1:  .word $B74F         ;Bullet fire continue SFX.
  6085. LB2F3:  .word $B6ED         ;Bird out of hole continue SFX.
  6086. LB2F5:  .word $B6ED         ;Enemy hit continue SFX.
  6087. LB2F7:  .word $B6ED         ;Samus jump continue SFX.
  6088. LB2F9:  .word $B781         ;Wave beam continue SFX.
  6089.  
  6090. ;Triangle init handling routine addresses:
  6091.  
  6092. LB2FB:  .word $B8D2         ;Samus die init SFX.
  6093. LB2FD:  .word $B7AC         ;Door open close init SFX.
  6094. LB2FF:  .word $B8A7         ;Metroid hit init SFX.
  6095. LB301:  .word $B921         ;Statue raise init SFX.
  6096. LB303:  .word $B7D9         ;Beep init SFX.
  6097. LB305:  .word $B7EF         ;Big enemy hit init SFX.
  6098. LB307:  .word $B834         ;Samus to ball init SFX.
  6099. LB309:  .word $B878         ;Bomb launch init SFX.
  6100.  
  6101. ;Triangle continue handling routine addresses:
  6102.  
  6103. LB30B:  .word $B8ED         ;Samus die continue SFX.
  6104. LB30E:  .word $B7CB         ;Door open close continue SFX.
  6105. LB30F:  .word $B8B1         ;Metroid hit continue SFX.
  6106. LB311:  .word $B940         ;Statue raise continue SFX.
  6107. LB313:  .word $B7E7         ;Beep continue SFX.
  6108. LB315:  .word $B80E         ;Big enemy hit continue SFX.
  6109. LB317:  .word $B84F         ;Samus to ball continue SFX.
  6110. LB319:  .word $B87F         ;Bomb launch continue SFX.
  6111.  
  6112. LoadNoiseSFXInitFlags:
  6113. LB31B:  LDA NoiseSFXFlag        ;Load A with Noise init SFX flags, (1st SFX cycle).
  6114. LB31E:  LDX #$89            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6115. LB320:  BNE GotoSFXCheckFlags       ;Branch always.
  6116.  
  6117. LoadNoiseSFXContFlags:
  6118. LB322:  LDA NoiseContSFX        ;Load A with Noise continue flags, (2nd SFX cycle).
  6119. LB325:  LDX #$8E            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6120. LB327:  BNE GotoSFXCheckFlags       ;Branch always.
  6121.  
  6122. LoadSQ1SFXInitFlags:
  6123. LB329:  LDA SQ1SFXFlag          ;Load A with SQ1 init flags, (5th SFX cycle).
  6124. LB32C:  LDX #$93            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6125. LB32E:  BNE GotoSFXCheckFlags       ;Branch always.
  6126.  
  6127. LoadSQ1SFXContFlags:
  6128. LB330:  LDA SQ1ContSFX          ;Load A with SQ1 continue flags, (6th SFX cycle).
  6129. LB333:  LDX #$98            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6130. LB335:  BNE GotoSFXCheckFlags       ;Branch always.
  6131.  
  6132. GotoSFXCheckFlags:
  6133. LB337:  JSR CheckSFXFlag        ;($B4BD)Checks to see if SFX flags set.    
  6134. LB33A:  JMP ($00E2)         ;if no flag found, Jump to next SFX cycle,-->
  6135.                     ;else jump to specific SFX handling routine.
  6136. LoadSTriangleSFXInitFlags:
  6137. LB33D:  LDA TriangleSFXFlag     ;Load A with Triangle init flags, (7th SFX cycle).
  6138. LB340:  LDX #$9D            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6139. LB342:  BNE GotoSFXCheckFlags       ;Brach always.
  6140.  
  6141. LoadTriangleSFXContFlags:
  6142. LB344:  LDA TriangleContSFX     ;Load A with Triangle continue flags, (8th SFX cycle).
  6143. LB347:  LDX #$A2            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6144. LB349:  BNE GotoSFXCheckFlags       ;Branch always.
  6145.  
  6146. LoadMultiSFXInitFlags:
  6147. LB34B:  LDA MultiSFXFlag        ;Load A with Multi init flags, (3rd SFX cycle).
  6148. LB34E:  LDX #$A7            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6149. LB350:  JSR CheckSFXFlag        ;($B4BD)Checks to see if SFX or music flags set.
  6150. LB353:  JSR FindMusicInitIndex      ;($BC53)Find bit containing music init flag.
  6151. LB356:  JSR Add8            ;($BC64)Add 8 to MusicInitIndex.
  6152. LB359:  JMP ($00E2)         ;If no flag found, Jump to next SFX cycle,-->
  6153.                     ;else jump to specific SFX handling subroutine.
  6154. LoadMultiSFXContFlags:
  6155. LB35C:  LDA MultiContSFX        ;Load A with $68C flags (4th SFX cycle).
  6156. LB35F:  LDX #$AC            ;Lower address byte in ChooseNextSFXRoutineTbl.
  6157. LB361:  JMP GotoSFXCheckFlags       ;($B337)Checks to see if SFX or music flags set.
  6158.  
  6159. LoadSQ1Flags:
  6160. LB364:  JSR LoadSQ1SFXInitFlags     ;($B329)Check for SQ1 init flags.
  6161. LB367:  RTS             ;
  6162.  
  6163. LoadSQ1ChannelSFX:          ;Used to determine which sound registers to change-->
  6164. LB368:  LDA #$00            ;($4000 - $4003) - SQ1.
  6165. LB36A:  BEQ +               ;Branch always.
  6166.  
  6167. LoadTriangleChannelSFX:         ;Used to determine which sound registers to change-->
  6168. LB36C:  LDA #$08            ;($4008 - $400B) - Triangle.
  6169. LB36E:  BNE +               ;Branch always.
  6170.  
  6171. LoadNoiseChannelSFX:            ;Used to determine which sound registers to change-->
  6172. LB370:  LDA #$0C            ;($400C - $400F) - Noise.
  6173. LB372:  BNE +               ;Branch always.
  6174.  
  6175. LoadSQ2ChannelSFX:          ;Used to determine which sound registers to change-->
  6176. LB374:  LDA #$04            ;($4004 - $4007) - SQ2.
  6177.  
  6178. LoadSFXData:
  6179. LB376:* STA $E0             ;Lower address byte of desired APU control register.
  6180. LB378:  LDA #$40            ;
  6181. LB37A:  STA $E1             ;Upper address byte of desired APU control register.
  6182. LB37C:  STY $E2             ;Lower address byte of data to load into sound channel.
  6183. LB37E:  LDA #$B2            ;
  6184. LB380:  STA $E3             ;Upper address byte of data to load into sound channel.
  6185. LB382:  LDY #$00            ;Starting index for loading four byte sound data.
  6186.  
  6187. LoadSFXRegisters:
  6188. LB384:* LDA ($E2),Y         ;Load A with SFX data byte.
  6189. LB386:  STA ($E0),Y         ;Store A in SFX register.
  6190. LB388:  INY                 ;
  6191. LB389:  TYA                 ;The four registers associated with each sound-->
  6192. LB38A:  CMP #$04            ;channel are loaded one after the other (the loop-->
  6193. LB38C:  BNE -               ;repeats four times).
  6194. LB38E:  RTS                 ;
  6195.  
  6196. PauseSFX:
  6197. LB38F:* INC SFXPaused           ;SFXPaused=#$01
  6198. LB392:  JSR ClearSounds         ;($B43E)Clear sound registers of data.     
  6199. LB395:  STA PauseSFXStatus      ;PauseSFXStatus=#$00
  6200. LB398:  RTS             ;
  6201.  
  6202. LB399:* LDA SFXPaused           ;Has SFXPaused been set? if not, branch
  6203. LB39C:  BEQ --              ;
  6204. LB39E:  LDA PauseSFXStatus      ;For the first #$12 frames after the game has been-->
  6205. LB3A1:  CMP #$12            ;paused, play GamePaused SFX.  If paused for #$12-->
  6206. LB3A3:  BEQ ++              ;frames or more, branch to exit.
  6207. LB3A5:  AND #$03            ;
  6208. LB3A7:  CMP #$03            ;Every fourth frame, repeat GamePaused SFX
  6209. LB3A9:  BNE +               ;
  6210. LB3AB:  LDY #$0D            ;Lower address byte of GamePaused SFX data(Base=$B200)
  6211. LB3AD:  JSR LoadSQ1ChannelSFX       ;($B368) Load GamePaused SFX data.
  6212. LB3B0:* INC PauseSFXStatus      ;
  6213. LB3B3:* RTS             ;
  6214.  
  6215. ;----------------------------------[ Sound Engine Entry Point ]-----------------------------------
  6216. ;NOTES:  
  6217. ;SFX take priority over music.
  6218. ;
  6219. ;There are 10 SFX cycles run every time the sound engine subroutine is called.  The cycles
  6220. ;search for set sound flags in the following registers in order:
  6221. ;$680, $688, $684, $68C, $681, $689, $683, $68B, $65D, $685
  6222. ;
  6223. ;The sound channels are assigned SFX numbers.  Those SFX numbers are:
  6224. ;Noise=0, sq1=1, sq2=2, triangle=3, Multi=4
  6225. ;The sound channels are assigned music numbers.  Those music numbers are:
  6226. ;SQ1=0, SQ2=1, Triangle=2, Noise=3
  6227.  
  6228. SoundEngine:
  6229. LB3B4:  LDA #$C0            ;Set APU to 5 frame cycle, disable frame interrupt.
  6230. LB3B6:  STA APUCommonCntrl1     ;
  6231. LB3B9:  LDA NoiseSFXFlag        ;is bit zero is set in NoiseSFXFlag(Silence-->
  6232. LB3BC:  LSR                 ;music)?  If yes, branch.
  6233. LB3BD:  BCS ++              ;
  6234. LB3BF:  LDA MainRoutine         ;
  6235. LB3C1:  CMP #$05            ;Is game paused?  If yes, branch.
  6236. LB3C3:  BEQ ---             ;
  6237. LB3C5:  LDA #$00            ;Clear SFXPaused when game is running.
  6238. LB3C7:  STA SFXPaused           ;
  6239. LB3CA:  JSR LoadNoiseSFXInitFlags   ;($B31B)Check noise SFX flags.
  6240. LB3CD:  JSR LoadMultiSFXInitFlags   ;($B34B)Check multichannel SFX flags.
  6241. LB3D0:  JSR LoadSTriangleSFXInitFlags   ;($B33D)Check triangle SFX flags.
  6242. LB3D3:  JSR LoadMusicTempFlags      ;($BC36)Check music flags.
  6243.  
  6244. ClearSFXFlags:
  6245. LB3D6:* LDA #$00            ;
  6246. LB3D8:  STA NoiseSFXFlag        ;
  6247. LB3DB:  STA SQ1SFXFlag          ;
  6248. LB3DE:  STA SQ2SFXFlag          ;Clear all SFX flags.
  6249. LB3E1:  STA TriangleSFXFlag     ;
  6250. LB3E4:  STA MultiSFXFlag        ;
  6251. LB3E7:  STA MusicInitFlag       ;
  6252. LB3EA:  RTS             ;
  6253.  
  6254. LB3EB:* JSR InitializeSoundAddresses    ;($B404)Prepare to start playing music.    
  6255. LB3EE:  BEQ --              ;Branch always.
  6256.  
  6257. CheckRepeatMusic:
  6258. LB3F0:  LDA MusicRepeat         ;
  6259. LB3F3:  BEQ +               ;If music is supposed to repeat, reset music,-->
  6260. LB3F5:  LDA CurrentMusic        ;flags else branch to exit.
  6261. LB3F8:  STA CurrentMusicRepeat      ;
  6262. LB3FB:  RTS             ;
  6263.  
  6264. CheckMusicFlags:
  6265. LB3FC:  LDA CurrentMusic        ;Loads A with current music flags and compares it-->
  6266. LB3FF:  CMP CurrentSFXFlags     ;with current SFX flags.  If both are equal,-->
  6267. LB402:  BEQ ++              ;just clear music counters, else clear everything.
  6268.  
  6269. InitializeSoundAddresses:       ;
  6270. LB404:* JSR ClearMusicAndSFXAddresses   ;($B41D)Jumps to all subroutines needed to reset-->
  6271. LB407:  JSR ClearSounds         ;($B43E)all sound addresses in order to start-->
  6272. LB40A:* JSR ClearSpecialAddresses   ;($B40E)playing music.
  6273. LB40D:  RTS                 ;
  6274.  
  6275. ClearSpecialAddresses:
  6276. LB40E:  LDA #$00            ;  
  6277. LB410:  STA TriangleCounterCntrl    ;Clears addresses used for repeating music,-->
  6278. LB413:  STA SFXPaused           ;pausing music and controlling triangle length.
  6279. LB416:  STA CurrentMusicRepeat      ;
  6280. LB419:  STA MusicRepeat         ;
  6281. LB41C:  RTS             ;
  6282.  
  6283. ClearMusicAndSFXAddresses:      ;
  6284. LB41D:  LDA #$00            ;
  6285. LB41F:  STA SQ1InUse            ;
  6286. LB422:  STA SQ2InUse            ;
  6287. LB425:  STA TriangleInUse       ;
  6288. LB428:  STA WriteMultiChannelData   ;
  6289. LB42B:  STA NoiseContSFX        ;Clears any SFX or music-->
  6290. LB42E:  STA SQ1ContSFX          ;currently being played.
  6291. LB431:  STA SQ2ContSFX          ;
  6292. LB434:  STA TriangleContSFX     ;
  6293. LB437:  STA MultiContSFX        ;
  6294. LB43A:  STA CurrentMusic        ;
  6295. LB43D:  RTS                 ;
  6296.  
  6297. ClearSounds:                ;
  6298. LB43E:  LDA #$10            ;
  6299. LB440:  STA SQ1Cntrl0           ;
  6300. LB443:  STA SQ2Cntrl0           ;
  6301. LB446:  STA NoiseCntrl0         ;Clears all sounds that might be in-->
  6302. LB449:  LDA #$00            ;The sound channel registers.
  6303. LB44B:  STA TriangleCntrl0      ;
  6304. LB44E:  STA DMCCntrl1           ;
  6305. LB451:  RTS                 ;
  6306.  
  6307. SelectSFXRoutine:
  6308. LB452:  LDX ChannelType         ;
  6309. LB455:  STA NoiseSFXLength,X        ;Stores frame length of SFX in corresponding address.
  6310. LB458:  TXA             ;
  6311. LB459:  BEQ ++              ;Branch if SFX uses noise channel.
  6312. LB45B:  CMP #$01            ;
  6313. LB45D:  BEQ +               ;Branch if SFX uses SQ1 channel.
  6314. LB45F:  CMP #$02            ;
  6315. LB461:  BEQ MusicBranch00       ;Branch if SFX uses SQ2 channel.
  6316. LB463:  CMP #$03            ;
  6317. LB465:  BEQ MusicBranch01       ;Branch if SFX uses triangle wave.
  6318. LB467:  RTS             ;Exit if SFX routine uses no channels.
  6319.  
  6320. LB468:* JSR LoadSQ1ChannelSFX       ;($B368)Prepare to load SQ1 channel with data.
  6321. LB46B:  BEQ ++              ;Branch always.
  6322. MusicBranch00:              ;
  6323. LB46D:  JSR LoadSQ2ChannelSFX       ;($B374)Prepare to load SQ2 channel with data.
  6324. LB470:  BEQ ++              ;Branch always.
  6325. MusicBranch01:              ;
  6326. LB472:  JSR LoadTriangleChannelSFX  ;($B36C)Prepare to load triangle channel with data.
  6327. LB475:  BEQ ++              ;Branch always.
  6328. LB477:* JSR LoadNoiseChannelSFX     ;($B370)Prepare to load noise channel with data.
  6329. LB47A:* JSR UpdateContFlags     ;($B493)Set continuation flags for this SFX.
  6330. LB47D:  TXA             ;
  6331. LB47E:  STA NoiseInUse,X        ;Indicate sound channel is in use.
  6332. LB481:  LDA #$00            ;
  6333. LB483:  STA ThisNoiseFrame,X        ;
  6334. LB486:  STA NoiseSFXData,X      ;Clears all the following addresses before going-->
  6335. LB489:  STA MultiSFXData,X      ;to the proper SFX handling routine.
  6336. LB48C:  STA ScrewAttackSFXData,X    ;
  6337. LB48F:  STA WriteMultiChannelData   ;
  6338. LB492:  RTS             ;
  6339.  
  6340. UpdateContFlags:
  6341. LB493:* LDX ChannelType         ;Loads X register with sound channel just changed.
  6342. LB496:  LDA NoiseContSFX,X      ;Clear existing continuation SFX-->
  6343. LB499:  AND #$00            ;flags for that channel.
  6344. LB49B:  ORA CurrentSFXFlags     ;Load new continuation flags.
  6345. LB49E:  STA NoiseContSFX,X      ;Save results.
  6346. LB4A1:  RTS             ;
  6347.  
  6348. ClearCurrentSFXFlags:
  6349. LB4A2:  LDA #$00            ;Once SFX has completed, this block clears the-->
  6350. LB4A4:  STA CurrentSFXFlags     ;SFX flag from the current flag register.
  6351. LB4A7:  BEQ -               ;
  6352.  
  6353. IncrementSFXFrame:
  6354. LB4A9:  LDX ChannelType         ;Load SFX channel number.
  6355. LB4AC:  INC ThisNoiseFrame,X        ;increment current frame to play on given channel.
  6356. LB4AF:  LDA ThisNoiseFrame,X        ;Load current frame to play on given channel.
  6357. LB4B2:  CMP NoiseSFXLength,X        ;Check to see if current frame is last frame to play.
  6358. LB4B5:  BNE +               ;
  6359. LB4B7:  LDA #$00            ;If current frame is last frame,-->
  6360. LB4B9:  STA ThisNoiseFrame,X        ;reset current frame to 0.
  6361. LB4BC:* RTS                 ;
  6362.  
  6363. ;The CheckSFXFlag routine loads E0 thru E3 with the below values:
  6364. ;1st  SFX cycle $E0=#$BB,$E1=#$B2,$E2=#$22,$E3=#$B3.  Base address=$B289
  6365. ;2nd  SFX cycle $E0=#$CB,$E1=#$B2,$E2=#$EE,$E3=#$B4.  Base address=$B28E
  6366. ;3rd  SFX cycle $E0=#$06,$E1=#$BC,$E2=#$5C,$E3=#$B3.  Base address=$B2A7
  6367. ;4th  SFX cycle $E0=#$16,$E1=#$BC,$E2=#$64,$E3=#$B3.  Base address=$B2AC
  6368. ;5th  SFX cycle $E0=#$DB,$E1=#$B2,$E2=#$30,$E3=#$B3.  Base address=$B293
  6369. ;6th  SFX cycle $E0=#$EB,$E1=#$B2,$E2=#$EE,$E3=#$B4.  Base address=$B298
  6370. ;7th  SFX cycle $E0=#$FB,$E1=#$B2,$E2=#$44,$E3=#$B3.  Base address=$B29D
  6371. ;8th  SFX cycle $E0=#$0B,$E1=#$B3,$E2=#$EE,$E3=#$B4.  Base address=$B2A2
  6372. ;9th  SFX cycle $E0=#$26,$E1=#$BC,$E2=#$3D,$E3=#$BC.  Base address=$B2B6
  6373. ;10th SFX cycle $E0=#$26,$E1=#$BC,$E2=#$4B,$E3=#$BC.  Base address=$B2B1
  6374.  
  6375. CheckSFXFlag:
  6376. LB4BD:  STA CurrentSFXFlags     ;Store any set flags in $064D.
  6377. LB4C0:  STX $E4             ;
  6378. LB4C2:  LDY #$B2            ;
  6379. LB4C4:  STY $E5             ;
  6380. LB4C6:  LDY #$00            ;Y=0 for counting loop ahead.
  6381. LB4C8:* LDA ($E4),Y         ;
  6382. LB4CA:  STA $00E0,Y         ;See table above for values loaded into $E0-->
  6383. LB4CD:  INY                 ;thru $E3 during this loop.
  6384. LB4CE:  TYA                 ;
  6385. LB4CF:  CMP #$04            ;Loop repeats four times to load the values.
  6386. LB4D1:  BNE -               ;
  6387. LB4D3:  LDA ($E4),Y         ;
  6388. LB4D5:  STA ChannelType         ;#$00=SQ1,#$01=SQ2,#$02=Triangle,#$03=Noise
  6389. LB4D8:  LDY #$00            ;Set y to 0 for counting loop ahead.
  6390. LB4DA:  LDA CurrentSFXFlags     ;
  6391. LB4DD:  PHA                 ;Push current SFX flags on stack.
  6392. LB4DE:* ASL CurrentSFXFlags     ;
  6393. LB4E1:  BCS +               ;This portion of the routine loops a maximum of-->
  6394. LB4E3:  INY             ;eight times looking for any SFX flags that have-->
  6395. LB4E4:  INY                 ;been set in the current SFX cycle.  If a flag-->
  6396. LB4E5:  TYA                 ;is found, Branch to SFXFlagFound for further-->
  6397. LB4E6:  CMP #$10            ;processing, if no flags are set, continue to-->
  6398. LB4E8:  BNE -               ;next SFX cycle.
  6399.  
  6400. RestoreSFXFlags:
  6401. LB4EA:  PLA             ;
  6402. LB4EB:  STA CurrentSFXFlags     ;Restore original data in CurrentSFXFlags.
  6403. LB4EE:  RTS             ;
  6404.  
  6405. SFXFlagFound:               ;
  6406. LB4EF:* LDA ($E0),Y         ;This routine stores the starting address of the-->
  6407. LB4F1:  STA $E2             ;specific SFX handling routine for the SFX flag-->
  6408. LB4F3:  INY                 ;found.  The address is stored in registers-->
  6409. LB4F4:  LDA ($E0),Y         ;$E2 and $E3.
  6410. LB4F6:  STA $E3             ;
  6411. LB4F8:  JMP RestoreSFXFlags     ;($B4EA)Restore original data in CurrentSFXFlags.
  6412.  
  6413. ;-----------------------------------[ SFX Handling Routines ]---------------------------------------
  6414.  
  6415. ;The following table is used by the SpitFlamesSFXContinue routine to change the volume-->
  6416. ;on the SFX.  It starts out quiet, then becomes louder then goes quiet again.
  6417. SpitFlamesTbl:
  6418. LB4FB:  .byte $12, $13, $14, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1B, $1A, $19, $17
  6419. LB50B:  .byte $16, $15, $14, $12
  6420.  
  6421. SpitFlameSFXStart:
  6422. LB50F:  LDA #$14            ;Number of frames to play sound before a change.
  6423. LB511:  LDY #$21            ;Lower byte of sound data start address(base=$B200).
  6424. LB513:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6425.  
  6426. SpitFlameSFXContinue:
  6427. LB516:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6428. LB519:  BNE +               ;If more frames to process, branch.
  6429. LB51B:  JMP EndNoiseSFX         ;($B58F)End SFX.
  6430. LB51E:* LDY NoiseSFXData        ;
  6431. LB521:  LDA $B4FB,Y         ;Load data from table above and store in NoiseCntrl0.
  6432. LB524:  STA NoiseCntrl0         ;
  6433. LB527:  INC NoiseSFXData        ;Increment to next entry in data table.
  6434. LB52A:  RTS
  6435.  
  6436. ScrewAttackSFXStart:
  6437. LB52B:  LDA #$05            ;Number of frames to play sound before a change.
  6438. LB52D:  LDY #$11            ;Lower byte of sound data start address(base=$B200).
  6439. LB52F:  JSR SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6440. LB532:  LDA $B213           ;#$00.
  6441. LB535:  STA NoiseSFXData        ;Clear NoiseSFXData.
  6442. LB538:* RTS             ;
  6443.  
  6444. ScrewAttackSFXContinue:
  6445. LB539:  LDA ScrewAttackSFXData      ;Prevents period index from being incremented until-->
  6446. LB53C:  CMP #$02            ;after the tenth frame of the SFX.
  6447. LB53E:  BEQ +               ;Branch if not ready to increment.
  6448. LB540:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6449. LB543:  BNE -               ;
  6450. LB545:  INC ScrewAttackSFXData      ;Increment every fifth frame.
  6451. LB548:  RTS             ;
  6452.  
  6453. LB549:* JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6454. LB54C:  BNE IncrementPeriodIndex    ;Start increasing period index after first ten frames.
  6455. LB54E:  DEC NoiseSFXData        ;
  6456. LB551:  DEC NoiseSFXData        ;Decrement NoiseSFXData by three every fifth frame.
  6457. LB554:  DEC NoiseSFXData        ;
  6458. LB557:  INC MultiSFXData        ;Increment MultiSFXData.  When it is equal to #$0F-->
  6459. LB55A:  LDA MultiSFXData        ;end screw attack SFX.  MultiSFXData does not-->
  6460. LB55D:  CMP #$0F            ;appear to be linked to multi SFX channels in-->
  6461. LB55F:  BNE --              ;this routine.
  6462. LB561:  JMP EndNoiseSFX         ;($B58F)End SFX.
  6463.  
  6464. IncrementPeriodIndex:
  6465. LB564:  INC NoiseSFXData        ;Incrementing the period index has the effect of-->
  6466. LB567:  LDA NoiseSFXData        ;lowering the frequency of the noise SFX.
  6467. LB56A:  STA NoiseCntrl2         ;
  6468. LB56D:  RTS             ;
  6469.  
  6470. MissileLaunchSFXStart:
  6471. LB56E:  LDA #$18            ;Number of frames to play sound before a change.
  6472. LB570:  LDY #$15            ;Lower byte of sound data start address(base=$B200).
  6473. LB572:  JSR GotoSelectSFXRoutine    ;($B587)Prepare to setup registers for SFX.
  6474. LB575:  LDA #$0A            ;
  6475. LB577:  STA NoiseSFXData        ;Start increment index for noise channel at #$0A.
  6476. LB57A:  RTS             ;
  6477.  
  6478. MissileLaunchSFXContine:
  6479. LB57B:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6480. LB57E:  BNE IncrementPeriodIndex    ;
  6481. LB580:  JMP EndNoiseSFX         ;($B58F)End SFX.
  6482.  
  6483. BombExplodeSFXStart:
  6484. LB583:  LDA #$30            ;Number of frames to play sound before a change.
  6485. LB585:  LDY #$19            ;Lower byte of sound data start address(base=$B200).
  6486.  
  6487. GotoSelectSFXRoutine:
  6488. LB587:* JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6489.  
  6490. ;The following routine is used to continue BombExplode and SamusWalk SFX.
  6491.  
  6492. NoiseSFXContinue:
  6493. LB58A:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6494. LB58D:  BNE MusicBranch02       ;If more frames to process, branch to exit.
  6495.  
  6496. EndNoiseSFX:
  6497. LB58F:  JSR ClearCurrentSFXFlags    ;($B4A2)Clear all SFX flags.
  6498. LB592:  LDA #$10            ;
  6499. LB594:  STA NoiseCntrl0         ;disable envelope generator(sound off).
  6500.  
  6501. MusicBranch02:
  6502. LB597:  RTS             ;Exit for multiple routines.
  6503.  
  6504. SamusWalkSFXStart:
  6505. LB598:  LDA NoiseContSFX        ;If MissileLaunch, SamusWalk or SpitFire SFX are-->
  6506. LB59B:  AND #$34            ;already being played, branch to exit.
  6507. LB59D:  BNE MusicBranch02       ;
  6508. LB59F:  LDA #$03            ;Number of frames to play sound before a change.
  6509. LB5A1:  LDY #$1D            ;Lower byte of sound data start address(base=$B200).
  6510. LB5A3:  BNE -               ;Branch always.
  6511.  
  6512. MultiSFXInit:
  6513. LB5A5:  STA MultiSFXLength      ;
  6514. LB5A8:  JSR LoadSQ2ChannelSFX       ;($B374)Set SQ2 SFX data.
  6515. LB5AB:  JSR UpdateContFlags     ;($B493)Set continue SFX flag.
  6516. LB5AE:  LDA #$01            ;
  6517. LB5B0:  STA SQ1InUse            ;Disable music from using SQ1 and SQ2 while-->
  6518. LB5B3:  LDA #$02            ;SFX are playing.
  6519. LB5B5:  STA SQ2InUse            ;
  6520. LB5B8:  LDA #$00            ;
  6521. LB5BA:  STA SQ1ContSFX          ;
  6522. LB5BD:  STA SQ1SFXData          ;
  6523. LB5C0:  STA SQ1SQ2SFXData       ;Clear all listed memory addresses.
  6524. LB5C3:  STA SQ1SFXPeriodLow     ;
  6525. LB5C6:  STA ThisMultiFrame      ;
  6526. LB5C9:  STA WriteMultiChannelData   ;
  6527. LB5CC:  RTS             ;
  6528.  
  6529. EndMultiSFX:
  6530. LB5CD:  LDA #$10            ;
  6531. LB5CF:  STA SQ1Cntrl0           ;Disable SQ1 envelope generator(sound off).
  6532. LB5D2:  STA SQ2Cntrl0           ;Disable SQ2 envelope generator(sound off).
  6533. LB5D5:  LDA #$7F            ;
  6534. LB5D7:  STA SQ1Cntrl1           ;Disable SQ1 sweep.
  6535. LB5DA:  STA SQ2Cntrl1           ;Disable SQ2 sweep.
  6536. LB5DD:  JSR ClearCurrentSFXFlags    ;($B4A2)Clear all SFX flags.
  6537. LB5E0:  LDA #$00            ;
  6538. LB5E2:  STA SQ1InUse            ;
  6539. LB5E5:  STA SQ2InUse            ;Allows music player to use SQ1 and SQ2 channels.
  6540. LB5E8:  INC WriteMultiChannelData   ;
  6541. LB5EB:  RTS             ;
  6542.  
  6543. BossHitSFXStart:
  6544. LB5EC:  LDY #$2D            ;Low byte of SQ1 sound data start address(base=$B200).
  6545. LB5EE:  JSR LoadSQ1ChannelSFX       ;($B368)Set SQ1 SFX data.
  6546. LB5F1:  LDY #$29            ;Low byte of SQ2 sound data start address(base=$B200).
  6547. LB5F3:  JMP MultiSFXInit        ;($B5A5)Initiate multi channel SFX.
  6548.  
  6549. BossHitSFXContinue:
  6550. LB5F6:  INC SQ1SFXData          ;Increment index to data in table below.
  6551. LB5F9:  LDY SQ1SFXData          ;
  6552. LB5FC:  LDA $B63C,Y         ;
  6553. LB5FF:  STA SQ1Cntrl0           ;Load SQ1Cntrl0 and SQ2Cntrl0 from table below.
  6554. LB602:  STA SQ2Cntrl0           ;
  6555. LB605:  LDA SQ1SFXData          ;
  6556. LB608:  CMP #$14            ;After #$14 frames, end SFX.
  6557. LB60A:  BEQ ++              ;
  6558. LB60C:  CMP #$06            ;After six or more frames of SFX, branch.
  6559. LB60E:  BCC +               ;
  6560. LB610:  LDA RandomNumber1       ;
  6561. LB612:  ORA #$10            ;Set bit 5.
  6562. LB614:  AND #$7F            ;Randomly set bits 7, 3, 2, 1 and 0.
  6563. LB616:  STA SQ1SFXPeriodLow     ;Store in SQ1 period low.
  6564. LB619:  ROL             ;
  6565. LB61A:  STA SQ1SQ2SFXData       ;
  6566. LB61D:  JMP WriteSQ1SQ2PeriodLow    ;($B62C)Write period low data to SQ1 and SQ2.
  6567. LB620:* INC SQ1SQ2SFXData       ;
  6568. LB623:  INC SQ1SQ2SFXData       ;Increment SQ1 and SQ2 period low by two.
  6569. LB626:  INC SQ1SFXPeriodLow     ;
  6570. LB629:  INC SQ1SFXPeriodLow     ;
  6571.  
  6572. WriteSQ1SQ2PeriodLow:
  6573. LB62C:  LDA SQ1SQ2SFXData       ;
  6574. LB62F:  STA SQ2Cntrl2           ;Write new SQ1 and SQ2 period lows to SQ1 and SQ2-->
  6575. LB632:  LDA SQ1SFXPeriodLow     ;channels.
  6576. LB635:  STA SQ1Cntrl2           ;
  6577. LB638:  RTS             ;
  6578.  
  6579. LB639:* JMP EndMultiSFX         ;($B5CD)End SFX.
  6580.  
  6581. BossHitSFXDataTbl:
  6582. LB63C:  .byte $38, $3D, $3F, $3F, $3F, $3F, $3F, $3D, $3B, $39, $3B, $3D, $3F, $3D, $3B, $39
  6583. LB64C:  .byte $3B, $3D, $3F, $39
  6584.  
  6585. SamusHitSFXContinue:
  6586. LB650:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6587. LB653:  BNE +               ;If more SFX frames to process, branch.
  6588. LB655:  JMP EndMultiSFX         ;($B5CD)End SFX.
  6589. LB658:* LDY #$25            ;Low byte of SQ1 sound data start address(base=$B200).
  6590. LB65A:  JSR LoadSQ1ChannelSFX       ;($B368)Set SQ1 SFX data.
  6591. LB65D:  LDA RandomNumber1       ;
  6592. LB65F:  AND #$0F            ;Randomly set last four bits of SQ1 period low.
  6593. LB661:  STA SQ1Cntrl2           ;
  6594. LB664:  LDY #$25            ;Low byte of SQ2 sound data start address(base=$B200).
  6595. LB666:  JSR LoadSQ2ChannelSFX       ;($B374)Set SQ2 SFX data.
  6596. LB669:  LDA RandomNumber1       ;
  6597. LB66B:  LSR             ;Multiply random number by 4.
  6598. LB66C:  LSR             ;
  6599. LB66D:  AND #$0F            ;
  6600. LB66F:  STA SQ2Cntrl2           ;Randomly set bits 2 and 3 of SQ2 period low.
  6601. LB672:  RTS             ;
  6602.  
  6603. SamusHitSFXStart:
  6604. LB673:  LDY #$25            ;Low byte of SQ1 sound data start address(base=$B200).
  6605. LB675:  JSR LoadSQ1ChannelSFX       ;($B368)Set SQ1 SFX data.
  6606. LB678:  LDA RandomNumber1       ;
  6607. LB67A:  AND #$0F            ;Randomly set last four bits of SQ1 period low.
  6608. LB67C:  STA SQ1Cntrl2           ;
  6609. LB67F:  CLC             ;
  6610. LB680:  LDA RandomNumber1       ;Randomly set last three bits of SQ2 period low+1.
  6611. LB682:  AND #$03            ;
  6612. LB684:  ADC #$01            ;Number of frames to play sound before a change.
  6613. LB686:  LDY #$25            ;Low byte of SQ2 sound data start address(base=$B200).
  6614. LB688:  JSR MultiSFXInit        ;($B5A5)Initiate multi channel SFX.
  6615. LB68B:  LDA RandomNumber1       ;
  6616. LB68D:  LSR             ;Multiply random number by 4.
  6617. LB68E:  LSR             ;
  6618. LB68F:  AND #$0F            ;
  6619. LB691:  STA SQ2Cntrl2           ;Randomly set bits 2 and 3 of SQ2 period low.
  6620. LB694:* RTS             ;
  6621.  
  6622. IncorrectPasswordSFXStart:
  6623. LB695:  LDY #$31            ;Low byte of SQ1 sound data start address(base=$B200).
  6624. LB697:  JSR LoadSQ1ChannelSFX       ;($B368)Set SQ1 SFX data.
  6625. LB69A:  LDA #$20            ;Number of frames to play sound before a change.
  6626. LB69C:  LDY #$35            ;Low byte of SQ2 sound data start address(base=$B200).
  6627. LB69E:  JMP MultiSFXInit        ;($B5A5)Initiate multi channel SFX.
  6628.  
  6629. IncorrectPasswordSFXContinue:
  6630. LB6A1:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6631. LB6A4:  BNE -               ;If more frames to process, branch to exit.
  6632. LB6A6:  JMP EndMultiSFX         ;($B5CD)End SFX.
  6633.  
  6634. ;The following table is used by the below routine to load SQ1Cntrl2 data in the
  6635. ;MissilePickupSFXContinue routine.
  6636.  
  6637. MissilePickupSFXTbl:
  6638. LB6A9:  .byte $BD, $8D, $7E, $5E, $46, $3E, $00
  6639.  
  6640. MissilePickupSFXContinue:
  6641. LB6B0:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6642. LB6B3:  BNE MusicBranch03       ;If more frames to process, branch to exit.
  6643. LB6B5:  LDY SQ1SFXData          ;
  6644. LB6B8:  LDA MissilePickupSFXTbl,Y   ;Load SFX data from table above.
  6645. LB6BB:  BNE +               ;
  6646. LB6BD:  JMP EndSQ1SFX           ;($B6F2)SFX completed.
  6647. LB6C0:* STA SQ1Cntrl2           ;
  6648. LB6C3:  LDA $B244           ;#$28.
  6649. LB6C6:  STA SQ1Cntrl3           ;load SQ1Cntrl3 with #$28.
  6650. LB6C9:  INC SQ1SFXData          ;Increment index to data table above every 5 frames.
  6651.  
  6652. MusicBranch03:
  6653. LB6CC:  RTS             ;Exit from multiple routines.
  6654.  
  6655. MissilePickupSFXStart:
  6656. LB6CD:  LDA #$05            ;Number of frames to play sound before a change.
  6657. LB6CF:  LDY #$41            ;Lower byte of sound data start address(base=$B200).
  6658. LB6D1:  BNE +++             ;Branch always.
  6659.  
  6660. EnergyPickupSFXContinue:
  6661. LB6D3:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6662. LB6D6:  BNE MusicBranch03       ;If more frames to process, branch to exit.
  6663. LB6D8:  INC SQ1SFXData          ;
  6664. LB6DB:  LDA SQ1SFXData          ;Every six frames, reload SFX info.  Does it-->
  6665. LB6DE:  CMP #$03            ;three times for a total of 18 frames.
  6666. LB6E0:  BEQ +               ;
  6667. LB6E2:  LDY #$3D            ;
  6668. LB6E4:  JMP LoadSQ1ChannelSFX       ;($B368)Set SQ1 SFX data.
  6669.  
  6670. EnergyPickupSFXStart:
  6671. LB6E7:  LDA #$06            ;Number of frames to play sound before a change.
  6672. LB6E9:  LDY #$3D            ;Lower byte of sound data start address(base=$B200).
  6673. LB6EB:  BNE +++             ;Branch always.
  6674.  
  6675. ;The following continue routine is used by the metal, out of hole,
  6676. ;enemy hit and the Samus jump SFXs.
  6677.  
  6678. SQ1SFXContinue:
  6679. LB6ED:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6680. LB6F0:  BNE MusicBranch03       ;
  6681.  
  6682. EndSQ1SFX:
  6683. LB6F2:* LDA #$10            ;
  6684. LB6F4:  STA SQ1Cntrl0           ;Disable envelope generator(sound off).
  6685. LB6F7:  LDA #$00            ;
  6686. LB6F9:  STA SQ1InUse            ;Allows music to use SQ1 channel.
  6687. LB6FC:  JSR ClearCurrentSFXFlags    ;($B4A2)Clear all SFX flags.
  6688. LB6FF:  INC WriteMultiChannelData   ;Allows music routines to load SQ1 and SQ2 music.
  6689. LB702:  RTS             ;
  6690.  
  6691. SamusJumpSFXStart:
  6692. LB703:  LDA CurrentMusic        ;If escape music is playing, exit without playing-->
  6693. LB706:  CMP #$04            ;Samus jump SFX.
  6694. LB708:  BEQ MusicBranch03       ;
  6695. LB70A:  LDA #$0C            ;Number of frames to play sound before a change.
  6696. LB70C:  LDY #$51            ;Lower byte of sound data start address(base=$B200).
  6697. LB70E:  BNE SelectSFX1          ;Branch always.
  6698.  
  6699. EnemyHitSFXStart:
  6700. LB710:  LDA #$08            ;Number of frames to play sound before a change.
  6701. LB712:  LDY #$55            ;Lower byte of sound data start address(base=$B200).
  6702. LB714:  BNE SelectSFX1          ;Branch always.
  6703.  
  6704. BulletFireSFXStart:
  6705. LB716:  LDA HasBeamSFX          ;
  6706. LB719:  LSR             ;If Samus has ice beam, branch.
  6707. LB71A:  BCS +++++           ;
  6708. LB71C:  LDA SQ1ContSFX          ;If MissilePickup, EnergyPickup, BirdOutOfHole-->
  6709. LB71F:  AND #$CC            ;or EnemyHit SFX already playing, branch to exit.
  6710. LB721:  BNE MusicBranch03       ;
  6711. LB723:  LDA HasBeamSFX          ;
  6712. LB726:  ASL             ;If Samus has long beam, branch.
  6713. LB727:  BCS +               ;
  6714. LB729:  LDA #$03            ;Number of frames to play sound before a change.
  6715. LB72B:  LDY #$4D            ;Lower byte of sound data start address(base=$B200).
  6716. LB72D:  BNE SelectSFX1          ;Branch always (Plays ShortBeamSFX).
  6717.  
  6718. HasLongBeamSFXStart:
  6719. LB72F:* LDA #$07            ;Number of frames to play sound before a change.
  6720. LB731:  LDY #$49            ;Lower byte of sound data start address(base=$B200).
  6721. LB733:  BNE SelectSFX1          ;Branch always.
  6722.  
  6723. MetalSFXStart:
  6724. LB735:  LDA #$0B            ;Number of frames to play sound before a change.
  6725. LB737:  LDY #$45            ;Lower byte of sound data start address(base=$B200).
  6726.  
  6727. SelectSFX1:
  6728. LB739:* JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6729.  
  6730. BirdOutOfHoleSFXStart:
  6731. LB73C:  LDA CurrentMusic        ;If escape music is playing, use this SFX to make-->
  6732. LB73F:  CMP #$04            ;the bomb ticking sound, else play regular SFX.
  6733. LB741:  BEQ +               ;
  6734. LB743:  LDA #$16            ;Number of frames to play sound before a change.
  6735. LB745:  LDY #$59            ;Lower byte of sound data start address(base=$B200).
  6736. LB747:  BNE SelectSFX1          ;Branch always.
  6737. LB749:* LDA #$07            ;Number of frames to play sound before a change.
  6738. LB74B:  LDY #$39            ;Lower byte of sound data start address(base=$B200).
  6739. LB74D:  BNE SelectSFX1          ;Branch always.
  6740.  
  6741. BulletFireSFXContinue:
  6742. LB74F:  LDA HasBeamSFX          ;
  6743. LB752:  LSR             ;If Samus has ice beam, branch.
  6744. LB753:  BCS +++             ;
  6745. LB755:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6746. LB758:  BNE +               ;If more frames to process, branch to exit.
  6747. LB75A:  JMP EndSQ1SFX           ;($B6F2)If SFX finished, jump.
  6748. LB75D:* RTS             ;
  6749.  
  6750. HasIceBeamSFXStart:
  6751. LB75E:* LDA #$07            ;Number of frames to play sound before a change.
  6752. LB760:  LDY #$61            ;Lower byte of sound data start address(base=$B200).
  6753. LB762:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6754.  
  6755. HasIceBeamSFXContinue:
  6756. LB765:* JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6757. LB768:  BNE +               ;If more frames to process, branch.
  6758. LB76A:  JMP EndSQ1SFX           ;($B6F2)If SFX finished, jump.
  6759. LB76D:* LDA SQ1SFXData          ;
  6760. LB770:  AND #$01            ;Determine index for IceBeamSFXDataTbl below.
  6761. LB772:  TAY             ;
  6762. LB773:  LDA IceBeamSFXDataTbl,Y     ;Loads A with value from IceBeamSFXDataTbl below.
  6763. LB776:  BNE ++              ;
  6764.  
  6765. IceBeamSFXDataTbl:
  6766. LB778:  .byte $93           ;Ice beam SFX period low data.
  6767. LB779:  .byte $81           ;
  6768.  
  6769. WaveBeamSFXStart:
  6770. LB77A:  LDA #$08            ;Number of frames to play sound before a change.
  6771. LB77C:  LDY #$5D            ;Lower byte of sound data start address(base=$B200).
  6772. LB77E:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6773.  
  6774. WaveBeamSFXContinue:
  6775. LB781:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6776. LB784:  BNE +               ;If more frames to process, branch.
  6777. LB786:  LDY SQ1SQ2SFXData       ;
  6778. LB789:  INC SQ1SQ2SFXData       ;Load wave beam SFXDisable/enable envelope length-->
  6779. LB78C:  LDA WaveBeamSFXDisLngthTbl,Y    ;data from WaveBeamSFXDisableLengthTbl.
  6780. LB78F:  STA SQ1Cntrl0           ;
  6781. LB792:  BNE MusicBranch10       ;If at end of WaveBeamSFXDisableLengthTbl, end SFX.
  6782. LB794:  JMP EndSQ1SFX           ;($B6F2)If SFX finished, jump.
  6783. LB797:* LDA SQ1SFXData
  6784. LB79A:  AND #$01            ;
  6785. LB79C:  TAY             ;Load wave beam SFX period low data from-->
  6786. LB79D:  LDA WaveBeamSFXPeriodLowTbl,Y   ;WaveBeamSFXPeriodLowTbl.
  6787.  
  6788. LoadSQ1PeriodLow:
  6789. LB7A0:* STA SQ1Cntrl2           ;Change the period low data for SQ1 channel.
  6790. LB7A3:  INC SQ1SFXData          ;
  6791.  
  6792. MusicBranch10:
  6793. LB7A6:  RTS             ;Exit for multiple routines.
  6794.  
  6795. WaveBeamSFXPeriodLowTbl:
  6796. LB7A7:  .byte $58           ;Wave beam SFX period low data.
  6797. LB7A8:  .byte $6F           ;
  6798.  
  6799. WaveBeamSFXDisLngthTbl:
  6800. LB7A9:  .byte $93           ;
  6801. LB7AA:  .byte $91           ;Wave beam SFX Disable/enable envelope length data.
  6802. LB7AB:  .byte $00           ;
  6803.  
  6804. DoorOpenCloseSFXStart:
  6805. LB7AC:  LDA $B287           ;#$30.
  6806. LB7AF:  STA TrianglePeriodLow       ;Set triangle period low data byte.
  6807. LB7B2:  LDA $B288           ;#$B2.
  6808. LB7B5:  AND #$07            ;Set triangle period high data byte.
  6809. LB7B7:  STA TrianglePeriodHigh      ;#$B7.
  6810. LB7BA:  LDA #$0F            ;
  6811. LB7BC:  STA TriangleChangeLow       ;Change triangle channel period low every frame by #$0F.
  6812. LB7BF:  LDA #$00            ;
  6813. LB7C1:  STA TriangleChangeHigh      ;No change in triangle channel period high.
  6814. LB7C4:  LDA #$1F            ;Number of frames to play sound before a change.
  6815. LB7C6:  LDY #$85            ;Lower byte of sound data start address(base=$B200).
  6816. LB7C8:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6817.  
  6818. DoorOpenCloseSFXContinue:
  6819. LB7CB:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6820. LB7CE:  BNE +               ;
  6821. LB7D0:  JMP EndTriangleSFX      ;($B896)End SFX.
  6822. LB7D3:* JSR DecreaseTrianglePeriods ;($B98C)Decrease periods.
  6823. LB7D6:  JMP WriteTrianglePeriods    ;($B869)Save new periods.
  6824.  
  6825. BeepSFXStart:
  6826. LB7D9:  LDA TriangleContSFX     ;If BombLaunchSFX is already playing, branch-->
  6827. LB7DC:  AND #$80            ;without playing BeepSFX.
  6828. LB7DE:  BNE MusicBranch10       ;
  6829. LB7E0:  LDA #$03            ;Number of frames to play sound before a change.
  6830. LB7E2:  LDY #$79            ;Lower byte of sound data start address(base=$B200).
  6831. LB7E4:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6832.  
  6833. BeepSFXContinue:
  6834. LB7E7:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6835. LB7EA:  BNE MusicBranch10       ;If more frames to process, branch to exit.
  6836. LB7EC:  JMP EndTriangleSFX      ;($B896)End SFX.
  6837.  
  6838. BigEnemyHitSFXStart:
  6839. LB7EF:  LDA #$12            ;Increase triangle low period by #$12 every frame.
  6840. LB7F1:  STA TriangleChangeLow       ;
  6841. LB7F4:  LDA #$00            ;
  6842. LB7F6:  STA TriangleChangeHigh      ;Does not change triangle period high.
  6843. LB7F9:  LDA $B27F           ;#$42.
  6844. LB7FC:  STA TrianglePeriodLow       ;Save new triangle period low data.
  6845. LB7FF:  LDA $B280           ;#$18.
  6846. LB802:  AND #$07            ;#$1F.
  6847. LB804:  STA TrianglePeriodHigh      ;Save new triangle period high data.
  6848. LB807:  LDA #$0A            ;Number of frames to play sound before a change.
  6849. LB809:  LDY #$7D            ;Lower byte of sound data start address(base=$B200).
  6850. LB80B:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6851.  
  6852. BigEnemyHitSFXContinue:
  6853. LB80E:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6854. LB811:  BNE +               ;If more frames to process, branch
  6855. LB813:  JMP EndTriangleSFX      ;($B896)End SFX
  6856. LB816:* JSR IncreaseTrianglePeriods ;($B978)Increase periods.
  6857. LB819:  LDA RandomNumber1       ;
  6858. LB81B:  AND #$3C            ;
  6859. LB81D:  STA TriangleSFXData     ;
  6860. LB820:  LDA TrianglePeriodLow       ;Randomly set or clear bits 2, 3, 4 and 5 in-->
  6861. LB823:  AND #$C3            ;triangle channel period low.
  6862. LB825:  ORA TriangleSFXData     ;
  6863. LB828:  STA TriangleCntrl2      ;
  6864. LB82B:  LDA TrianglePeriodHigh      ;
  6865. LB82E:  ORA #$40            ;Set 4th bit in triangle channel period high.
  6866. LB830:  STA TriangleCntrl3      ;
  6867. LB833:  RTS             ;
  6868.  
  6869. SamusToBallSFXStart:
  6870. LB834:  LDA #$08            ;Number of frames to play sound before a change.
  6871. LB836:  LDY #$6D            ;Lower byte of sound data start address(base=$B200).
  6872. LB838:  JSR SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6873. LB83B:  LDA #$05            ;
  6874. LB83D:  STA PercentDifference       ;Stores percent difference. In this case 5 = 1/5 = 20%.
  6875. LB840:  LDA $B26F           ;#$DD.
  6876. LB843:  STA TrianglePeriodLow       ;Save new triangle period low data.
  6877. LB846:  LDA $B270           ;#$3B.
  6878. LB849:  AND #$07            ;#$02.
  6879. LB84B:  STA TrianglePeriodHigh      ;Save new triangle period high data.
  6880. LB84E:  RTS             ;
  6881.  
  6882. SamusToBallSFXContinue:
  6883. LB84F:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6884. LB852:  BNE +               ;If more frames to process, branch.
  6885. LB854:  JMP EndTriangleSFX      ;($B896)End SFX.
  6886. LB857:* JSR DivideTrianglePeriods   ;($B9A0)reduces triangle period low by 20% each frame.
  6887. LB85A:  LDA TriangleLowPercentage   ;
  6888. LB85D:  STA TriangleChangeLow       ;Store new values to change triangle periods.
  6889. LB860:  LDA TriangleHighPercentage  ;
  6890. LB863:  STA TriangleChangeHigh      ;
  6891. LB866:  JSR DecreaseTrianglePeriods ;($B98C)Decrease periods.
  6892.  
  6893. WriteTrianglePeriods:
  6894. LB869:  LDA TrianglePeriodLow       ;Write TrianglePeriodLow to triangle channel.
  6895. LB86C:  STA TriangleCntrl2      ;
  6896. LB86F:  LDA TrianglePeriodHigh      ;
  6897. LB872:  ORA #$08            ;Write TrianglePeriodHigh to triangle channel.
  6898. LB874:  STA TriangleCntrl3      ;
  6899. LB877:  RTS             ;
  6900.  
  6901. BombLaunchSFXStart:
  6902. LB878:  LDA #$04            ;Number of frames to play sound before a change.
  6903. LB87A:  LDY #$65            ;Lower byte of sound data start address(base=$B200).
  6904. LB87C:  JMP SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6905.  
  6906. BombLaunchSFXContinue:
  6907. LB87F:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6908. LB882:  BNE MusicBranch04       ;If more frames to process, branch to exit.
  6909. LB884:  INC TriangleSFXData     ;
  6910. LB887:  LDA TriangleSFXData     ;After four frames, load second part of SFX.
  6911. LB88A:  CMP #$02            ;
  6912. LB88C:  BNE +               ;
  6913. LB88E:  JMP EndTriangleSFX      ;($B896)End SFX.
  6914. LB891:* LDY #$69            ;Lower byte of sound data start address(base=$B200).
  6915. LB893:  JMP LoadTriangleChannelSFX  ;($B36C)Prepare to load triangle channel with data.
  6916.  
  6917. EndTriangleSFX:
  6918. LB896:  LDA #$00            ;
  6919. LB898:  STA TriangleCntrl0      ;clear TriangleCntr0(sound off).
  6920. LB89B:  STA TriangleInUse       ;Allows music to use triangle channel.
  6921. LB89E:  LDA #$18            ;
  6922. LB8A0:  STA TriangleCntrl3      ;Set length index to #$03.
  6923. LB8A3:  JSR ClearCurrentSFXFlags    ;($B4A2)Clear all SFX flags.
  6924.  
  6925. MusicBranch04:
  6926. LB8A6:  RTS             ;Exit from for multiple routines.
  6927.  
  6928. MetroidHitSFXStart:
  6929. LB8A7:  LDA #$03            ;Number of frames to play sound before a change.
  6930. LB8A9:  LDY #$71            ;Lower byte of sound data start address(base=$B200).
  6931. LB8AB:  JSR SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6932. LB8AE:  JMP RndTrianglePeriods      ;($B8C3)MetroidHit SFX has several different sounds.
  6933.  
  6934. MetroiHitSFXContinue:
  6935. LB8B1:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6936. LB8B4:  BEQ +               ;
  6937. LB8B6:  INC TriangleSFXData     ;
  6938. LB8B9:  LDA TriangleSFXData     ;Randomize triangle periods nine times throughout-->
  6939. LB8BC:  CMP #$09            ;the course of the SFX.
  6940. LB8BE:  BNE MusicBranch04       ;If SFX not done, branch.
  6941. LB8C0:  JMP EndTriangleSFX      ;($B896)End SFX.
  6942.  
  6943. RndTrianglePeriods:
  6944. LB8C3:* LDA RandomNumber1       ;Randomly set or reset bits 7, 4, 2 and 1 of-->
  6945. LB8C5:  ORA #$6C            ;triangle channel period low.
  6946. LB8C7:  STA TriangleCntrl2      ;
  6947. LB8CA:  AND #$01            ;
  6948. LB8CC:  ORA #$F8            ;Randomly set or reset last bit of triangle-->
  6949. LB8CE:  STA TriangleCntrl3      ;channel period high.
  6950. LB8D1:  RTS             ;
  6951.  
  6952. SamusDieSFXStart:
  6953. LB8D2:  JSR InitializeSoundAddresses    ;($B404)Clear all sound addresses.
  6954. LB8D5:  LDA #$0E            ;Number of frames to play sound before a change.
  6955. LB8D7:  LDY #$75            ;Lower byte of sound data start address(base=$B200).
  6956. LB8D9:  JSR SelectSFXRoutine        ;($B452)Setup registers for SFX.
  6957. LB8DC:  LDA #$15            ;Decrease triangle SFX periods by 4.8% every frame.
  6958. LB8DE:  STA PercentDifference       ;
  6959. LB8E1:  LDA $B277           ;#$40.
  6960. LB8E4:  STA TrianglePeriodLow       ;
  6961. LB8E7:  LDA #$00            ;Initial values of triangle periods.
  6962. LB8E9:  STA TrianglePeriodHigh      ;
  6963. LB8EC:* RTS             ;
  6964.  
  6965. SamusDieSFXContinue:
  6966. LB8ED:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  6967. LB8F0:  BNE +               ;
  6968. LB8F2:  LDA #$20            ;Store change in triangle period low.
  6969. LB8F4:  STA TriangleChangeLow       ;
  6970. LB8F7:  LDA #$00            ;
  6971. LB8F9:  STA TriangleChangeHigh      ;No change in triangle period high.
  6972. LB8FC:  JSR DecreaseTrianglePeriods ;($B98C)Decrease periods.
  6973. LB8FF:  INC TriangleSFXData     ;
  6974. LB902:  LDA TriangleSFXData     ;
  6975. LB905:  CMP #$06            ;
  6976. LB907:  BNE -               ;If more frames to process, branch to exit.
  6977. LB909:  JMP EndTriangleSFX      ;($B896)End SFX.
  6978. LB90C:* JSR DivideTrianglePeriods   ;($B9A0)reduces triangle period low.
  6979. LB90F:  LDA TriangleLowPercentage   ;
  6980. LB912:  STA TriangleChangeLow       ;Update triangle periods.
  6981. LB915:  LDA TriangleHighPercentage  ;
  6982. LB918:  STA TriangleChangeHigh      ;
  6983. LB91B:  JSR IncreaseTrianglePeriods ;($B978)Increase periods.
  6984. LB91E:  JMP WriteTrianglePeriods    ;($B869)Save new periods.
  6985.  
  6986. StatueRaiseSFXStart:
  6987. LB921:  LDA $B283           ;#$11.
  6988. LB924:  STA TrianglePeriodLow       ;Save period low data.
  6989. LB927:  LDA $B284           ;#$09.
  6990. LB92A:  AND #$07            ;
  6991. LB92C:  STA TrianglePeriodHigh      ;Store last three bits in $B284.
  6992. LB92F:  LDA #$00            ;
  6993. LB931:  STA TriangleChangeHigh      ;No change in Triangle period high.
  6994. LB934:  LDA #$0B            ;
  6995. LB936:  STA TriangleChangeLow       ;
  6996. LB939:  LDA #$06            ;Number of frames to play sound before a change.
  6997. LB93B:  LDY #$81            ;Lower byte of sound data start address(base=$B200).
  6998. LB93D:  JMP SelectSFXroutine        ;($B452)Setup registers for SFX.
  6999.  
  7000. StatueRaiseSFXContinue:
  7001. LB940:  JSR IncrementSFXFrame       ;($B4A9)Get next databyte to process in SFX.
  7002. LB943:  BNE ++              ;
  7003. LB945:  INC TriangleSFXData     ;Increment TriangleSFXData every 6 frames.
  7004. LB948:  LDA TriangleSFXData     ;
  7005. LB94B:  CMP #$09            ;When TriangleSFXData = #$09, end SFX.
  7006. LB94D:  BNE +               ;
  7007. LB94F:  JMP EndTriangleSFX      ;($B896)End SFX.
  7008. LB952:* LDA TriangleChangeLow       ;
  7009. LB955:  PHA             ;Save triangle periods.
  7010. LB956:  LDA TriangleChangeHigh      ;
  7011. LB959:  PHA             ;
  7012. LB95A:  LDA #$25            ;
  7013. LB95C:  STA TriangleChangeLow       ;
  7014. LB95F:  LDA #$00            ;No change in triangle period high.
  7015. LB961:  STA TriangleChangeHigh      ;
  7016. LB964:  JSR IncreaseTrianglePeriods ;($B978)Increase periods.
  7017. LB967:  PLA             ;
  7018. LB968:  STA TriangleChangeHigh      ;Restore triangle periods.
  7019. LB96B:  PLA             ;
  7020. LB96C:  STA TriangleChangeLow       ;
  7021. LB96F:  JMP WriteTrianglePeriods    ;($B869)Save new periods.
  7022. LB972:* JSR DecreaseTrianglePeriods ;($B98C)Decrease periods.
  7023. LB975:  JMP WriteTrianglePeriods    ;($B869)Save new periods.
  7024.  
  7025. IncreaseTrianglePeriods:
  7026. LB978:  CLC
  7027. LB979:  LDA TrianglePeriodLow       ;
  7028. LB97C:  ADC TriangleChangeLow       ;Calculate new TrianglePeriodLow.
  7029. LB97F:  STA TrianglePeriodLow       ;
  7030. LB982:  LDA TrianglePeriodHigh      ;
  7031. LB985:  ADC TriangleChangeHigh      ;Calculate new TrianglePeriodHigh.
  7032. LB988:  STA TrianglePeriodHigh      ;
  7033. LB98B:  RTS             ;
  7034.  
  7035. DecreaseTrianglePeriods:
  7036. LB98C:  SEC
  7037. LB98D:  LDA TrianglePeriodLow       ;
  7038. LB990:  SBC TriangleChangeLow       ;Calculate new TrianglePeriodLow.
  7039. LB993:  STA TrianglePeriodLow       ;
  7040. LB996:  LDA TrianglePeriodHigh      ;
  7041. LB999:  SBC TriangleChangeHigh      ;Calculate new TrianglePeriodHigh.
  7042. LB99C:  STA TrianglePeriodHigh      ;
  7043. LB99F:  RTS             ;
  7044.  
  7045. DivideTrianglePeriods:
  7046. LB9A0:  LDA TrianglePeriodLow       ;
  7047. LB9A3:  PHA             ;Store TrianglePeriodLow and TrianglePeriodHigh.
  7048. LB9A4:  LDA TrianglePeriodHigh      ;
  7049. LB9A7:  PHA             ;
  7050. LB9A8:  LDA #$00            ;
  7051. LB9AA:  STA DivideData          ;
  7052. LB9AD:  LDX #$10            ;
  7053. LB9AF:  ROL TrianglePeriodLow       ;
  7054. LB9B2:  ROL TrianglePeriodHigh      ;
  7055. LB9B5:* ROL DivideData          ;The following routine takes the triangle period-->
  7056. LB9B8:  LDA DivideData          ;high and triangle period low values and reduces-->
  7057. LB9BB:  CMP PercentDifference       ;them by a certain percent.  The percent is-->
  7058. LB9BE:  BCC +               ;determined by the value stored in-->
  7059. LB9C0:  SBC PercentDifference       ;PercentDifference.  If PercentDifference=#$05,-->
  7060. LB9C3:  STA DivideData          ;then the values will be reduced by 20%(1/5).-->
  7061. LB9C6:* ROL TrianglePeriodLow       ;If PercentDifference=#$0A,Then the value will-->
  7062. LB9C9:  ROL TrianglePeriodHigh      ;be reduced by 10%(1/10), etc. This function is-->
  7063. LB9CC:  DEX             ;basically a software emulation of a sweep function.
  7064. LB9CD:  BNE --              ;
  7065. LB9CF:  LDA TrianglePeriodLow       ;
  7066. LB9D2:  STA TriangleLowPercentage   ;
  7067. LB9D5:  LDA TrianglePeriodHigh      ;
  7068. LB9D8:  STA TriangleHighPercentage  ;
  7069. LB9DB:  PLA             ;
  7070. LB9DC:  STA TrianglePeriodHigh      ;Restore TrianglePerodLow and TrianglePeriodHigh.
  7071. LB9DF:  PLA             ;
  7072. LB9E0:  STA TrianglePeriodLow       ;
  7073. LB9E3:  RTS             ;
  7074.  
  7075. ;--------------------------------------[ End SFX routines ]-------------------------------------
  7076.  
  7077. SetVolumeAndDisableSweep:
  7078. LB9E4:  LDA #$7F            ;
  7079. LB9E6:  STA MusicSQ1Sweep       ;Disable sweep generator on SQ1 and SQ2.
  7080. LB9E9:  STA MusicSQ2Sweep       ;
  7081. LB9EC:  STX SQ1DutyEnvelope     ;Store duty cycle and volume data for SQ1 and SQ2.
  7082. LB9EF:  STY SQ2DutyEnvelope     ;
  7083. LB9F2:  RTS             ;
  7084.  
  7085. ResetVolumeIndex:
  7086. LB9F3:  LDA SQ1MusicFrameCount      ;If at the beginning of a new SQ1 note, set-->
  7087. LB9F6:  CMP #$01            ;SQ1VolumeIndex = #$01.
  7088. LB9F8:  BNE +               ;
  7089. LB9FA:  STA SQ1VolumeIndex      ;
  7090. LB9FD:* LDA SQ2MusicFrameCount      ;
  7091. LBA00:  CMP #$01            ;If at the beginning of a new SQ2 note, set-->
  7092. LBA02:  BNE +               ;SQ2VolumeIndex = #$01.
  7093. LBA04:  STA SQ2VolumeIndex      ;
  7094. LBA07:* RTS                 ;
  7095.  
  7096. LoadSQ1SQ2Periods:
  7097. LBA08:  LDA WriteMultiChannelData   ;If a Multi channel data does not need to be-->
  7098. LBA0B:  BEQ +               ;loaded, branch to exit.
  7099. LBA0D:  LDA #$00            ;
  7100. LBA0F:  STA WriteMultiChannelData   ;Clear multi channel data write flag.
  7101. LBA12:  LDA MusicSQ1Sweep       ;
  7102. LBA15:  STA SQ1Cntrl1           ;
  7103. LBA18:  LDA MusicSQ1PeriodLow       ;
  7104. LBA1B:  STA SQ1Cntrl2           ;Loads SQ1 channel addresses $4001, $4002, $4003.
  7105. LBA1E:  LDA MusicSQ1PeriodHigh      ;
  7106. LBA21:  STA SQ1Cntrl3           ;
  7107. LBA24:  LDA MusicSQ2Sweep       ;
  7108. LBA27:  STA SQ2Cntrl1           ;
  7109. LBA2A:  LDA MusicSQ2PeriodLow       ;
  7110. LBA2D:  STA SQ2Cntrl2           ;Loads SQ2 channel addresses $4005, $4006, $4007.
  7111. LBA30:  LDA MusicSQ2PeriodHigh      ;
  7112. LBA33:  STA SQ2Cntrl3           ;
  7113. LBA36:* RTS             ;
  7114.  
  7115. LoadSQ1SQ2Channels:
  7116. LBA37:  LDX #$00            ;Load SQ1 channel data.
  7117. LBA39:  JSR WriteSQCntrl0       ;($BA41)Write Cntrl0 data.
  7118. LBA3C:  INX             ;Load SQ2 channel data.
  7119. LBA3D:  JSR WriteSQCntrl0       ;($BA41)Write Cntrl0 data.
  7120. LBA40:  RTS             ;
  7121.  
  7122. WriteSQCntrl0:
  7123. LBA41:  LDA SQ1VolumeCntrl,X        ;Load SQ channel volume data. If zero, branch to exit.
  7124. LBA44:  BEQ +++++           ;
  7125. LBA46:  STA VolumeCntrlAddress      ;
  7126. LBA48:  JSR LoadSQ1SQ2Periods       ;($BA08)Load SQ1 and SQ2 control information.
  7127. LBA4B:  LDA SQ1VolumeData,X     ;
  7128. LBA4E:  CMP #$10            ;If sound channel is not currently-->
  7129. LBA50:  BEQ +++++++         ;playing sound, branch.
  7130. LBA52:  LDY #$00            ;
  7131. LBA54:* DEC VolumeCntrlAddress      ;Desired entry in VolumeCntrlAdressTbl.
  7132. LBA56:  BEQ +               ;
  7133. LBA58:  INY             ;*2(2 byte address to find voulume control data).
  7134. LBA59:  INY             ;
  7135. LBA5A:  BNE -               ;Keep decrementing until desired address is found.
  7136. LBA5C:* LDA VolumeCntrlAddressTbl,Y ;Base is $BCB0.
  7137. LBA5F:  STA $EC             ;Volume data address low byte.
  7138. LBA61:  LDA VolumeCntrlAddressTbl+1,Y   ;Base is $BCB1.
  7139. LBA64:  STA $ED             ;Volume data address high byte.
  7140. LBA66:  LDY SQ1VolumeIndex,X        ;Index to desired volume data.
  7141. LBA69:  LDA ($EC),Y         ;Load desired volume for current channel into-->
  7142. LBA6B:  STA Cntrl0Data          ;Cntrl0Data.
  7143. LBA6D:  CMP #$FF            ;If last entry in volume table is #$FF, restore-->
  7144. LBA6F:  BEQ MusicBranch05       ;volume to its original level after done reading-->
  7145. LBA71:  CMP #$F0            ;Volume data.  If #$F0 is last entry, turn sound-->
  7146. LBA73:  BEQ MusicBranch06       ;off on current channel until next note.
  7147. LBA75:  LDA SQ1DutyEnvelope,X       ;Remove duty cycle data For current channel and-->
  7148. LBA78:  AND #$F0            ;add this frame of volume data and store results-->
  7149. LBA7A:  ORA Cntrl0Data          ;in Cntrl0Data.
  7150. LBA7C:  TAY             ;
  7151. LBA7D:* INC SQ1VolumeIndex,X        ;Increment Index to volume data.
  7152. LBA80:* LDA SQ1InUse,X          ;If SQ1 or SQ2(depends on loop iteration) in use,-->
  7153. LBA83:  BNE +               ;branch to exit, else write SQ(1 or 2)Cntrl0.
  7154. LBA85:  TXA             ;
  7155. LBA86:  BEQ ++              ;If currently on SQ1, branch to write SQ1 data.
  7156.  
  7157. WriteSQ2Cntrl0:             ;
  7158. LBA88:  STY SQ2Cntrl0           ;Write SQ2Cntrl0 data.
  7159. LBA8B:* RTS             ;
  7160.  
  7161. WriteSQ1Cntrl0:             ;
  7162. LBA8C:* STY SQ1Cntrl0           ;Write SQ1Cntrl0 data.
  7163. LBA8F:  RTS             ;
  7164.  
  7165. MusicBranch05:
  7166. LBA90:  LDY SQ1DutyEnvelope,X       ;Restore original volume of sound channel.
  7167. LBA93:  BNE ---             ;Branch always.
  7168.  
  7169. MusicBranch06:
  7170. LBA95:  LDY #$10            ;Disable envelope generator and set volume to 0.
  7171. LBA97:  BNE ---             ;Branch always.
  7172. LBA99:* LDY #$10            ;Disable envelope generator and set volume to 0.
  7173. LBA9B:  BNE -----           ;Branch always.
  7174.  
  7175. GotoCheckRepeatMusic:
  7176. LBA9D:* JSR CheckRepeatMusic        ;($B3F0)Resets music flags if music repeats.
  7177. LBAA0:  RTS             ;
  7178.  
  7179. GotoLoadSQ1SQ2Channels:
  7180. LBAA1:* JSR LoadSQ1SQ2Channels      ;($BA37)Load SQ1 and SQ2 channel data.
  7181. LBAA4:  RTS             ;
  7182.  
  7183. LoadCurrentMusicFrameData:
  7184. LBAA5:  JSR ResetVolumeIndex        ;($B9F3)Reset index if at the beginning of a new note.
  7185. LBAA8:  LDA #$00            ;
  7186. LBAAA:  TAX             ;X = #$00.
  7187. LBAAB:  STA ThisSoundChannel        ;(#$00, #$04, #$08 or #$0C).
  7188. LBAAE:  BEQ ++              ;
  7189. LBAB0:* TXA             ;
  7190. LBAB1:  LSR             ;
  7191. LBAB2:  TAX             ;Increment to next sound channel(1,2 or 3).
  7192.                     ;
  7193. IncrementToNextChannel:         ;
  7194. LBAB3:  INX             ;
  7195. LBAB4:  TXA             ;
  7196. LBAB5:  CMP #$04            ;If done with four sound channels, branch to load-->
  7197. LBAB7:  BEQ --              ;sound channel SQ1 SQ2 data.
  7198. LBAB9:  LDA ThisSoundChannel        ;Add 4 to the least significant byte of the current-->
  7199. LBABC:  CLC                 ;sound channel start address.  This moves to next-->
  7200. LBABD:  ADC #$04            ;sound channel address ranges to process.
  7201. LBABF:  STA ThisSoundChannel        ;
  7202. LBAC2:* TXA             ;
  7203. LBAC3:  ASL             ;*2(two bytes for sound channel info base address).
  7204. LBAC4:  TAX             ;
  7205. LBAC5:  LDA SQ1LowBaseByte,X        ;
  7206. LBAC8:  STA $E6             ;Load sound channel info base address into $E6-->
  7207. LBACA:  LDA SQ1HighBaseByte,X       ;and $E7. ($E6=low byte, $E7=high byte).
  7208. LBACD:  STA $E7             ;
  7209. LBACF:  LDA SQ1HighBaseByte,X       ;If no data for this sound channel, branch-->
  7210. LBAD2:  BEQ --              ;to find data for next sound channel.
  7211. LBAD4:  TXA             ;
  7212. LBAD5:  LSR             ;/2. Determine current sound channel (0,1,2 or3).
  7213. LBAD6:  TAX             ;
  7214. LBAD7:  DEC SQ1MusicFrameCount,X    ;Decrement the current sound channel frame count-->
  7215. LBADA:  BNE IncrementToNextChannel  ;If not zero, branch to check next channel, else-->
  7216.                     ;load the next set of sound channel data.
  7217. LoadNextChannelIndexData:
  7218. LBADC:  LDY SQ1MusicIndexIndex,X    ;Load current channel index to music data index.
  7219. LBADF:  INC SQ1MusicIndexIndex,X    ;Increment current channel index to music data index.
  7220. LBAE2:  LDA ($E6),Y         ;
  7221. LBAE4:  BEQ ----                ;Branch if music has reached the end.
  7222. LBAE6:  TAY             ;Transfer music data index to Y (base=$BE77) .
  7223. LBAE7:  CMP #$FF            ;
  7224. LBAE9:  BEQ +               ;At end of loop? If yes, branch.
  7225. LBAEB:  AND #$C0            ;
  7226. LBAED:  CMP #$C0            ;At beginnig of new loop? if yes, branch.
  7227. LBAEF:  BEQ ++              ;
  7228. LBAF1:  JMP LoadMusicChannel        ;($BB1C)Load music data into channel.
  7229.  
  7230. RepeatMusicLoop:
  7231. LBAF4:* LDA SQ1RepeatCounter,X      ;If loop counter has reached zero, branch to exit.
  7232. LBAF7:  BEQ ++              ;
  7233. LBAF9:  DEC SQ1RepeatCounter,X      ;Decrement loop counter.
  7234. LBAFC:  LDA SQ1LoopIndex,X      ;Load loop index for proper channel and store it in-->
  7235. LBAFF:  STA SQ1MusicIndexIndex,X    ;music index index address.
  7236. LBB02:  BNE ++              ;Branch unless music has reached the end.
  7237.  
  7238. StartNewMusicLoop:
  7239. LBB04:* TYA             ;
  7240. LBB05:  AND #$3F            ;Remove last six bits of loop controller and save-->
  7241. LBB07:  STA SQ1RepeatCounter,X      ;in repeat counter addresses.  # of times to loop.
  7242. LBB0A:  DEC SQ1RepeatCounter,X      ;Decrement loop counter.
  7243. LBB0D:  LDA SQ1MusicIndexIndex,X    ;Store location of loop start in loop index address.
  7244. LBB10:  STA SQ1LoopIndex,X      ;
  7245. LBB13:* JMP LoadNextChannelIndexData    ;($BADC)Load next channel index data.
  7246.  
  7247. LBB16:* JMP LoadNoiseChannelMusic   ;($BBDE)Load data for noise channel music.
  7248.  
  7249. LBB19:* JMP LoadTriangleCntrl0      ;($BBB7)Load Cntrl0 byte of triangle channel.
  7250.  
  7251. LoadMusicChannel:
  7252. LBB1C:  TYA             ;
  7253. LBB1D:  AND #$B0            ;
  7254. LBB1F:  CMP #$B0            ;Is data byte music note length data?  If not, branch.
  7255. LBB21:  BNE +               ;
  7256. LBB23:  TYA             ;
  7257. LBB24:  AND #$0F            ;Separate note length data.
  7258. LBB26:  CLC             ;
  7259. LBB27:  ADC NoteLengthTblOffset     ;Find proper note lengths table for current music.
  7260. LBB2A:  TAY             ;
  7261. LBB2B:  LDA NoteLengths0Tbl,Y       ;(Base is $BEF7)Load note length and store in-->
  7262. LBB2E:  STA SQ1FrameCountInit,X     ;frame count init address.
  7263. LBB31:  TAY             ;Y now contains note length.
  7264. LBB32:  TXA             ;
  7265. LBB33:  CMP #$02            ;If loading Triangle channel data, branch.
  7266. LBB35:  BEQ -               ;
  7267.  
  7268. LoadSoundDataIndexIndex:
  7269. LBB37:  LDY SQ1MusicIndexIndex,X    ;Load current index to sound data index.
  7270. LBB3A:  INC SQ1MusicIndexIndex,X    ;Increment music index index address.
  7271. LBB3D:  LDA ($E6),Y         ;Load index to sound channel music data.
  7272. LBB3F:  TAY             ;
  7273. LBB40:* TXA             ;
  7274. LBB41:  CMP #$03            ;If loading Noise channel data, branch.
  7275. LBB43:  BEQ ---             ;
  7276. LBB45:  PHA             ;Push music channel number on stack(0, 1 or 2).
  7277. LBB46:  LDX ThisSoundChannel        ;
  7278. LBB49:  LDA MusicNotesTbl+1,Y       ;(Base=$BE78)Load A with music channel period low data.
  7279. LBB4C:  BEQ +               ;If data is #$00, skip period high and low loading.
  7280. LBB4E:  STA MusicSQ1PeriodLow,X     ;Store period low data in proper period low address.
  7281. LBB51:  LDA MusicNotesTbl,Y     ;(Base=$BE77)Load A with music channel period high data.
  7282. LBB54:  ORA #$08            ;Ensure minimum index length of 1.
  7283. LBB56:  STA MusicSQ1PeriodHigh,X    ;Store period high data in proper period high address.
  7284. LBB59:* TAY             ;
  7285. LBB5A:  PLA             ;Pull stack and restore channel number to X.
  7286. LBB5B:  TAX             ;
  7287. LBB5C:  TYA             ;
  7288. LBB5D:  BNE +               ;If period information was present, branch.
  7289.                
  7290. NoPeriodInformation:
  7291. LBB5F:  LDA #$00            ;Turn off channel volume since no period data present.
  7292. LBB61:  STA Cntrl0Data          ;
  7293. LBB63:  TXA             ;
  7294. LBB64:  CMP #$02            ;If loading triangle channel data, branch.
  7295. LBB66:  BEQ ++              ;
  7296. LBB68:  LDA #$10            ;Turn off volume and disable env. generator(SQ1,SQ2).
  7297. LBB6A:  STA Cntrl0Data          ;
  7298. LBB6C:  BNE ++              ;Branch always.
  7299.  
  7300. PeriodInformationFound:
  7301. LBB6E:* LDA SQ1DutyEnvelope,X       ;Store channel duty cycle and volume info in $EA.
  7302. LBB71:  STA Cntrl0Data          ;
  7303. LBB73:* TXA             ;
  7304. LBB74:  DEC SQ1InUse,X          ;
  7305. LBB77:  CMP SQ1InUse,X          ;If SQ1 or SQ2 are being used by SFX routines, branch.
  7306. LBB7A:  BEQ +++             ;
  7307. LBB7C:  INC SQ1InUse,X          ;Restore not in use status of SQ1 or SQ2.
  7308. LBB7F:  LDY ThisSoundChannel        ;
  7309. LBB82:  TXA             ;
  7310. LBB83:  CMP #$02            ;If loading triangle channel data, branch.
  7311. LBB85:  BEQ +               ;
  7312. LBB87:  LDA SQ1VolumeCntrl,X        ;If $062E or $062F has volume data, skip writing-->
  7313. LBB8A:  BNE ++              ;Cntrl0Data to SQ1 or SQ2.
  7314. LBB8C:* LDA Cntrl0Data          ;
  7315. LBB8E:  STA SQ1Cntrl0,Y         ;Write Cntrl0Data.
  7316. LBB91:* LDA Cntrl0Data          ;
  7317. LBB93:  STA SQ1VolumeData,X     ;Store volume data index to volume data.
  7318. LBB96:  LDA MusicSQ1PeriodLow,Y     ;
  7319. LBB99:  STA SQ1Cntrl2,Y         ;
  7320. LBB9C:  LDA MusicSQ1PeriodHigh,Y    ;Write data to three sound channel addresses.
  7321. LBB9F:  STA SQ1Cntrl3,Y         ;
  7322. LBBA2:  LDA MusicSQ1Sweep,X     ;
  7323. LBBA5:  STA SQ1Cntrl1,Y         ;
  7324.  
  7325. LoadNewMusicFrameCount:
  7326. LBBA8:  LDA SQ1FrameCountInit,X     ;Load new music frame count and store it in music-->
  7327. LBBAB:  STA SQ1MusicFrameCount,X    ;frame count address.
  7328. LBBAE:  JMP IncrementToNextChannel  ;($BAB3)Move to next sound channel.
  7329.  
  7330. SQ1SQ2InUse:
  7331. LBBB1:* INC SQ1InUse,X          ;Restore in use status of SQ1 or SQ1.
  7332. LBBB4:  JMP LoadNewMusicFrameCount  ;($BBA8)Load new music frame count.
  7333.  
  7334. LoadTriangleCntrl0:
  7335. LBBB7:  LDA TriangleCounterCntrl    ;
  7336. LBBBA:  AND #$0F            ;If lower bits set, branch to play shorter note.
  7337. LBBBC:  BNE ++              ;
  7338. LBBBE:  LDA TriangleCounterCntrl    ;
  7339. LBBC1:  AND #$F0            ;If upper bits are set, branch to play longer note.
  7340. LBBC3:  BNE +               ;
  7341. LBBC5:  TYA             ;
  7342. LBBC6:  JMP AddTriangleLength       ;($BBCD)Calculate length to play note.
  7343. LBBC9:* LDA #$FF            ;Disable length cntr(play until triangle data changes).
  7344. LBBCB:  BNE +               ;Branch always.
  7345.  
  7346. AddTriangleLength:
  7347. LBBCD:  CLC                 ;
  7348. LBBCE:  ADC #$FF            ;Add #$FF(Effectively subtracts 1 from A).
  7349. LBBD0:  ASL             ;*2.
  7350. LBBD1:  ASL             ;*2.
  7351. LBBD2:  CMP #$3C            ;
  7352. LBBD4:  BCC +               ;If result is greater than #$3C, store #$3C(highest-->
  7353. LBBD6:  LDA #$3C            ;triangle linear count allowed).
  7354. LBBD8:* STA TriLinearCount      ;
  7355. LBBDB:* JMP LoadSoundDataIndexIndex ;($BB37)Load index to sound data index.
  7356.  
  7357. LoadNoiseChannelMusic:
  7358. LBBDE:  LDA NoiseContSFX        ;
  7359. LBBE1:  AND #$FC            ;If playing any Noise SFX, branch to exit.
  7360. LBBE3:  BNE +               ;
  7361. LBBE5:  LDA $B200,Y         ;
  7362. LBBE8:  STA NoiseCntrl0         ;Load noise channel with drum beat SFX starting-->
  7363. LBBEB:  LDA $B201,Y         ;at address B201.  The possible values of Y are-->
  7364. LBBEE:  STA NoiseCntrl2         ;#$01, #$04, #$07 or #$0A.
  7365. LBBF1:  LDA $B202,Y         ;
  7366. LBBF4:  STA NoiseCntrl3         ;
  7367. LBBF7:* JMP LoadNewMusicFrameCount  ;($BBA8)Load new music frame count.
  7368.  
  7369. ;The following table is used by the InitializeMusic routine to find the index for loading
  7370. ;addresses $062B thru $0637.  Base is $BD31.
  7371.  
  7372. InitMusicIndexTbl:
  7373. LBBFA:  .byte $41           ;Ridley area music.
  7374. LBBFB:  .byte $8F           ;Tourian music.
  7375. LBBFC:  .byte $34           ;Item room music.
  7376. LBBFD:  .byte $27           ;Kraid area music.
  7377. LBBFE:  .byte $1A           ;Norfair music.
  7378. LBBFF:  .byte $0D           ;Escape music.
  7379. LBC00:  .byte $00           ;Mother brain music.
  7380. LBC01:  .byte $82           ;Brinstar music.
  7381. LBC02:  .byte $68           ;Fade in music.
  7382. LBC03:  .byte $75           ;Power up music.
  7383. LBC04:  .byte $4E           ;End music.
  7384. LBC05:  .byte $5B           ;Intro music.
  7385.  
  7386. ;The tables below contain addresses for SFX and music handling routines.
  7387. ;Multi channel Init SFX and music handling routine addresses:
  7388.  
  7389. LBC06:  .word $BC80         ;Fade in music.
  7390. LBC08:  .word $BC7A         ;Power up music.
  7391. LBC0A:  .word $BC86         ;End game music.
  7392. LBC0C:  .word $BC7A         ;Intro music.
  7393. LBC0E:  .word $B4EE         ;No sound.
  7394. LBC10:  .word $B673         ;Samus hit init SFX.
  7395. LBC12:  .word $B5EC         ;Boss hit init SFX.
  7396. LBC14:  .word $B695         ;Incorrect password init SFX.
  7397.  
  7398. ;Multi channel continue SFX handling routine addresses:
  7399.  
  7400. LBC16:  .word $B4EE         ;No sound.
  7401. LBC18:  .word $B4EE         ;No sound.
  7402. LBC1A:  .word $B4EE         ;No sound.
  7403. LBC1C:  .word $B4EE         ;No sound.
  7404. LBC1E:  .word $B4EE         ;No sound.
  7405. LBC20:  .word $B650         ;Samus hit continue SFX.
  7406. LBC22:  .word $B5F6         ;Boss hit continue SFX.
  7407. LBC24:  .word $B6A1         ;Incorrect password continue SFX.
  7408.  
  7409. ;Music handling routine addresses:
  7410.  
  7411. LBC26:  .word $BC83         ;Ridley area music.
  7412. LBC28:  .word $BC77         ;Tourian music.
  7413. LBC2A:  .word $BC77         ;Item room music.
  7414. LBC2C:  .word $BC77         ;Kraid area music.
  7415. LBC2E:  .word $BC80         ;Norfair music.
  7416. LBC30:  .word $BC7D         ;Escape music.
  7417. LBC32:  .word $BC77         ;Mother brain music.
  7418. LBC34:  .word $BC80         ;Brinstar music.
  7419.  
  7420. ;-----------------------------------[ Entry point for music routines ]--------------------------------
  7421.  
  7422. LoadMusicTempFlags:
  7423. LBC36:  LDA CurrentMusicRepeat      ;Load A with temp music flags, (9th SFX cycle).
  7424. LBC39:  LDX #$B6            ;Lower address byte in ChooseNextSFXRoutineTbl.
  7425. LBC3B:  BNE +               ;Branch always.
  7426.  
  7427. LoadMusicInitFlags:
  7428. LBC3D:  LDA MusicInitFlag       ;Load A with Music flags, (10th SFX cycle).
  7429. LBC40:  LDX #$B1            ;Lower address byte in ChooseNextSFXRoutineTbl.
  7430. LBC42:* JSR CheckSFXFlag        ;($B4BD)Checks to see if SFX or music flags set.
  7431. LBC45:  JSR FindMusicInitIndex      ;($BC53)Find bit containing music init flag.
  7432. LBC48:  JMP ($00E2)         ;If no flag found, Jump to next SFX cycle,-->
  7433.                     ;else jump to specific SFX handling subroutine.
  7434.  
  7435. ContinueMusic:              ;11th and last SFX cycle.
  7436. LBC4B:  LDA CurrentMusic        ;
  7437. LBC4E:  BEQ +++             ;Branch to exit of no music playing.
  7438. LBC50:  JMP LoadCurrentMusicFrameData   ;($BAA5)Load info for current frame of music data.
  7439.  
  7440. ;MusicInitIndex values correspond to the following music:
  7441. ;#$00=Ridley area music, #$01=Tourian music, #$02=Item room music, #$03=Kraid area music,
  7442. ;#$04=Norfair music, #$05=Escape music, #$06=Mother brain music, #$07=Brinstar music,
  7443. ;#$08=Fade in music, #$09=Power up music, #$0A=End game music, #$0B=Intro music.
  7444.  
  7445. FindMusicInitIndex:
  7446. LBC53:  LDA #$FF            ;Load MusicInitIndex with #$FF.
  7447. LBC55:  STA MusicInitIndex      ;
  7448. LBC58:  LDA CurrentSFXFlags     ;
  7449. LBC5B:  BEQ ++              ;Branch to exit if no SFX flags set for Multi SFX.
  7450. LBC5D:* INC MusicInitIndex      ;
  7451. LBC60:  ASL             ;Shift left until bit flag is in carry bit.
  7452. LBC61:  BCC -               ;Loop until SFX flag found.  Store bit-->
  7453. LBC63:* RTS             ;number of music in MusicInitIndex.
  7454.  
  7455. ;The following routine is used to add eight to the music index when looking for music flags
  7456. ;in the MultiSFX address.  
  7457. Add8:
  7458. LBC64:  LDA MusicInitIndex      ;
  7459. LBC67:  CLC             ;
  7460. LBC68:  ADC #$08            ;Add #$08 to MusicInitIndex.
  7461. LBC6A:  STA MusicInitIndex      ;
  7462. LBC6D:  RTS             ;
  7463.  
  7464. LBC6E:  LDA CurrentMusic        ;
  7465. LBC71:  ORA #$F0            ;This code does not appear to be used in this page.
  7466. LBC73:  STA CurrentMusic        ;
  7467. LBC76:* RTS             ;
  7468.  
  7469. Music00Start:
  7470. LBC77:  JMP Music00Init         ;($BCAA)Initialize music 00.
  7471.  
  7472. Music01Start:
  7473. LBC7A:  JMP Music01Init         ;($BCA4)Initialize music 01.
  7474.  
  7475. Music02Start:
  7476. LBC7D:  JMP Music02Init         ;($BC9A)Initialize music 02.
  7477.  
  7478. Msic03Start:
  7479. LBC80:  JMP Music03Init         ;($BC96)Initialize music 03.
  7480.  
  7481. Music04Start:
  7482. LBC83:  JMP Music04Init         ;($BC89)Initialize music 04.
  7483.  
  7484. Music05Start:
  7485. LBC86:  JMP Music05Init         ;($BC9E)Initialize music 05.
  7486.  
  7487. Music04Init:
  7488. LBC89:  LDA #$B3            ;Duty cycle and volume data for SQ1 and SQ2.
  7489.  
  7490. XYMusicInit:
  7491. LBC8B:* TAX             ;Duty cycle and volume data for SQ1.
  7492. LBC8C:  TAY             ;Duty cycle and volume data for SQ2.
  7493.  
  7494. LBC8D:* JSR SetVolumeAndDisableSweep    ;($B9E4)Set duty cycle and volume data for SQ1 and SQ2.
  7495. LBC90:  JSR InitializeMusic     ;($BF19)Setup music registers.
  7496. LBC93:  JMP LoadCurrentMusicFrameData   ;($BAA5)Load info for current frame of music data.
  7497.  
  7498. Music03Init:
  7499. LBC96:  LDA #$34            ;Duty cycle and volume data for SQ1 and SQ2.
  7500. LBC98:  BNE --              ;Branch always
  7501.  
  7502. Music02Init:
  7503. LBC9A:  LDA #$F4            ;Duty cycle and volume data for SQ1 and SQ2.
  7504. LBC9C:  BNE --              ;Branch always
  7505.  
  7506. Music05Init:
  7507. LBC9E:  LDX #$F5            ;Duty cycle and volume data for SQ1.
  7508. LBCA0:  LDY #$F6            ;Duty cycle and volume data for SQ2.
  7509. LBCA2:  BNE -               ;Branch always
  7510.  
  7511. Music01Init:
  7512. LBCA4:  LDX #$B6            ;Duty cycle and volume data for SQ1.
  7513. LBCA6:  LDY #$F6            ;Duty cycle and volume data for SQ2.
  7514. LBCA8:  BNE -               ;Branch always
  7515.  
  7516. Music00Init:
  7517. LBCAA:  LDX #$92            ;Duty cycle and volume data for SQ1.
  7518. LBCAC:  LDY #$96            ;Duty cycle and volume data for SQ2.
  7519. LBCAE:  BNE -               ;Branch always
  7520.  
  7521. ;The following address table provides starting addresses of the volume data tables below:
  7522. VolumeCntrlAddressTbl:
  7523. LBCB0:  .word $BCBA, $BCC5, $BCCF, $BCDA, $BD03
  7524.  
  7525. VolumeDataTbl1:
  7526. LBCBA:  .byte $01, $02, $02, $03, $03, $04, $05, $06, $07, $08, $FF
  7527.  
  7528. VolumeDataTbl2:
  7529. LBCC5:  .byte $02, $04, $05, $06, $07, $08, $07, $06, $05, $FF
  7530.  
  7531. VolumeDataTbl3:
  7532. LBCCF:  .byte $00, $0D, $09, $07, $06, $05, $05, $05, $04, $04, $FF
  7533.  
  7534. VolumeDataTbl4:
  7535. LBCDA:  .byte $02, $06, $07, $07, $07, $06, $06, $06, $06, $05, $05, $05, $04, $04, $04, $03
  7536. LBCEA:  .byte $03, $03, $03, $02, $03, $03, $03, $03, $03, $02, $02, $02, $02, $02, $02, $02
  7537. LBCFA:  .byte $02, $02, $02, $01, $01, $01, $01, $01, $F0
  7538.  
  7539. VolumeDataTbl5:
  7540. LBD03:  .byte $0A, $0A, $09, $08, $07, $06, $05, $04, $03, $02, $07, $07, $06, $05, $04, $04
  7541. LBD13:  .byte $03, $02, $02, $02, $05, $05, $05, $04, $03, $02, $02, $02, $01, $01, $04, $04
  7542. LBD23:  .byte $03, $02, $01, $02, $02, $01, $01, $01, $02, $02, $02, $01, $01, $F0
  7543.  
  7544. ;The init music table loads addresses $062B thru $0637 with the initial data needed to play the
  7545. ;selected music.  The data for each entry in the table have the following format:
  7546. ;.byte $xx, $xx, $xx, $xx, $xx : .word $xxxx, $xxxx, $xxxx, $xxxx.
  7547. ;The first five bytes have the following functions:
  7548. ;Byte 0=index to proper note length table.  Will be either #$00, #$0B or #$17.
  7549. ;Byte 1=Repeat music byte. #$00=no repeat, any other value and the music repeats.
  7550. ;Byte 2=Controls length counter for triangle channel.
  7551. ;Byte 3=Volume control byte for SQ1.
  7552. ;Byte 4=Volume control byte for SQ2.
  7553. ;Address 0=Base address of SQ1 music data.
  7554. ;Address 1=Base address of SQ2 music data.
  7555. ;Address 2=Base address of triangle music data.
  7556. ;Address 3=Base address of noise music data.
  7557.  
  7558. InitMusicTbl:
  7559.  
  7560. ;Mother brain music(not used this memory page).
  7561. LBD31:  .byte $0B, $FF, $F5, $00, $00
  7562. LBD36:  .word $0100, $0300, $0500, $0000
  7563.  
  7564. ;Escape music(not used this memory page).
  7565. LBD3E:  .byte $0B, $FF, $00, $02, $02
  7566. LBD43:  .word $0100, $0300, $0500, $0700
  7567.  
  7568. ;Norfair music(not used this memory page).
  7569. LBD4B:  .byte $0B, $FF, $F0, $04, $04
  7570. LBD50:  .word $0100, $0300, $0500, $0700
  7571.  
  7572. ;Kraid area music(not used this memory page).
  7573. LBD58:  .byte $00, $FF, $F0, $00, $00
  7574. LBD5D:  .word $0100, $0300, $0500, $0000
  7575.  
  7576. ;Item room music.
  7577. LBD65:  .byte $0B, $FF, $03, $00, $00
  7578. LBD6A:  .word $BDDA, $BDDC, $BDCD, $0000
  7579.  
  7580. ;Ridley area music(not used this memory page).
  7581. LBD72:  .byte $0B, $FF, $F0, $01, $01
  7582. LBD77:  .word $0100, $0300, $0500, $0000
  7583.  
  7584. ;End game music
  7585. LBD7F:  .byte $17, $00, $00, $02, $01
  7586. LBD84:  .word $AC00, $ADC5, $ACF5, $AE8E
  7587.  
  7588. ;Intro music
  7589. LBD8C:  .byte $17, $00, $F0, $02, $05
  7590. LBD91:  .word $B0B9, $B000, $B076, $B115
  7591.  
  7592. ;Fade in music
  7593. LBD99:  .byte $0B, $00, $F0, $02, $00
  7594. LBD9E:  .word $BE3E, $BE1D, $BE36, $0000
  7595.  
  7596. ;Power up music
  7597. LBDA6:  .byte $00, $00, $F0, $01, $00
  7598. LBDAB:  .word $BDF7, $BE0D, $BE08, $0000
  7599.  
  7600. ;Brinstar music(not used this memory page).
  7601. LBDB3:  .byte $0B, $FF, $00, $02, $03
  7602. LBDB8:  .word $0100, $0300, $0500, $0700
  7603.  
  7604. ;Tourian music
  7605. LBDC0:  .byte $0B, $FF, $03, $00, $00
  7606. LBDC5:  .word $BE59, $BE47, $BE62, $0000
  7607.  
  7608. ItemRoomTriangleIndexData:
  7609. LBDCD:  .byte $C8           ;
  7610. LBDCE:  .byte $B0           ;3/32 seconds   +
  7611. LBDCF:  .byte $38           ;E3     |
  7612. LBDD0:  .byte $3A           ;F3     |
  7613. LBDD1:  .byte $3C           ;F#3        |
  7614. LBDD2:  .byte $3E           ;G3     |
  7615. LBDD3:  .byte $40           ;Ab3        | Repeat 8 times
  7616. LBDD4:  .byte $3E           ;G3     |
  7617. LBDD5:  .byte $3C           ;F#3        |
  7618. LBDD6:  .byte $3A           ;F3     |
  7619. LBDD7:  .byte $B6           ;1 3/16 seconds |
  7620. LBDD8:  .byte $02           ;no sound   +
  7621. LBDD9:  .byte $FF           ;
  7622.  
  7623. ItemRoomSQ1IndexData:
  7624. LBDDA:  .byte $B8           ;1/4 seconds
  7625. LBDDB:  .byte $02           ;No sound
  7626.  
  7627. ItemRoomSQ2IndexData:
  7628. LBDDC:  .byte $B3           ;3/4 seconds
  7629. LBDDD:  .byte $02           ;No sound
  7630. LBDDE:  .byte $B2           ;3/8 seconds
  7631. LBDDF:  .byte $74           ;A#6
  7632. LBDE0:  .byte $02           ;No sound
  7633. LBDE1:  .byte $6A           ;F5
  7634. LBDE2:  .byte $02           ;No sound
  7635. LBDE3:  .byte $72           ;A6
  7636. LBDE4:  .byte $02           ;No sound
  7637. LBDE5:  .byte $62           ;C#5
  7638. LBDE6:  .byte $B4           ;1 1/2 seconds
  7639. LBDE7:  .byte $02           ;No sound
  7640. LBDE8:  .byte $B2           ;3/8 seconds
  7641. LBDE9:  .byte $60           ;C5
  7642. LBDEA:  .byte $02           ;No sound
  7643. LBDEB:  .byte $6C           ;F#5
  7644. LBDEC:  .byte $02           ;No sound
  7645. LBDED:  .byte $76           ;B6
  7646. LBDEE:  .byte $B3           ;3/4 seconds
  7647. LBDEF:  .byte $02           ;No sound
  7648. LBDF0:  .byte $B2           ;3/8 seconds
  7649. LBDF1:  .byte $7E           ;F6
  7650. LBDF2:  .byte $02           ;No sound
  7651. LBDF3:  .byte $7C           ;D6
  7652. LBDF4:  .byte $B3           ;3/4 seconds
  7653. LBDF5:  .byte $02           ;No sound
  7654. LBDF6:  .byte $00           ;End item room music.
  7655.  
  7656. PowerUpSQ1IndexData:
  7657. LBDF7:  .byte $B3           ;1/2 seconds
  7658. LBDF8:  .byte $48           ;C4
  7659. LBDF9:  .byte $42           ;A4
  7660. LBDFA:  .byte $B2           ;1/4 seconds
  7661. LBDFB:  .byte $3E           ;G3
  7662. LBDFC:  .byte $38           ;E3
  7663. LBDFD:  .byte $30           ;C3
  7664. LBDFE:  .byte $38           ;E3
  7665. LBDFF:  .byte $4C           ;D4
  7666. LBE00:  .byte $44           ;A#4
  7667. LBE01:  .byte $3E           ;G3
  7668. LBE02:  .byte $36           ;D#3
  7669. LBE03:  .byte $C8           ;
  7670. LBE04:  .byte $B0           ;1/16 seconds   +
  7671. LBE05:  .byte $38           ;E3     | Repeat 8 times
  7672. LBE06:  .byte $3C           ;F#3        +
  7673. LBE07:  .byte $FF
  7674.  
  7675. PowerUpTriangleIndexData:
  7676. LBE08:  .byte $B4           ;1 second
  7677. LBE09:  .byte $2C           ;A#3
  7678. LBE0A:  .byte $2A           ;A3
  7679. LBE0B:  .byte $1E           ;D#2
  7680. LBE0C:  .byte $1C           ;D2
  7681.  
  7682. PowerUpSQ2IndexData:
  7683. LBE0D:  .byte $B2           ;1/4 seconds
  7684. LBE0E:  .byte $22           ;F2
  7685. LBE0F:  .byte $2C           ;A#3
  7686. LBE10:  .byte $30           ;C3
  7687. LBE11:  .byte $34           ;D3
  7688. LBE12:  .byte $38           ;E3
  7689. LBE13:  .byte $30           ;C3
  7690. LBE14:  .byte $26           ;G2
  7691. LBE15:  .byte $30           ;C3
  7692. LBE16:  .byte $3A           ;F3
  7693. LBE17:  .byte $34           ;D3
  7694. LBE18:  .byte $2C           ;A#3
  7695. LBE19:  .byte $26           ;G2
  7696. LBE1A:  .byte $B4           ;1 second
  7697. LBE1B:  .byte $2A           ;A3
  7698. LBE1C:  .byte $00           ;End power up music.
  7699.  
  7700. FadeInSQ2IndexData:
  7701. LBE1D:  .byte $C4
  7702. LBE1E:  .byte $B0           ;3/32 seconds   +
  7703. LBE1F:  .byte $3E           ;G3     | Repeat 4 times
  7704. LBE20:  .byte $30           ;C3     +
  7705. LBE21:  .byte $FF           ;
  7706. LBE22:  .byte $C4           ;
  7707. LBE23:  .byte $42           ;A4     + Repeat 4 times
  7708. LBE24:  .byte $30           ;C3     +
  7709. LBE25:  .byte $FF           ;
  7710. LBE26:  .byte $C4           ;
  7711. LBE27:  .byte $3A           ;F3     + Repeat 4 times
  7712. LBE28:  .byte $2C           ;A#3        +
  7713. LBE29:  .byte $FF           ;
  7714. LBE2A:  .byte $C4           ;
  7715. LBE2B:  .byte $38           ;E3     + Repeat 4 times
  7716. LBE2C:  .byte $26           ;G2     +
  7717. LBE2D:  .byte $FF           ;
  7718. LBE2E:  .byte $C4           ;
  7719. LBE2F:  .byte $34           ;D3     + Repeat 4 times
  7720. LBE30:  .byte $20           ;E2     +
  7721. LBE31:  .byte $FF           ;
  7722. LBE32:  .byte $E0           ;
  7723. LBE33:  .byte $34           ;D3     + Repeat 32 times
  7724. LBE34:  .byte $24           ;F#2        +
  7725. LBE35:  .byte $FF           ;
  7726.  
  7727. FadeInTriangleIndexData:
  7728. LBE36:  .byte $B3           ;3/4 seconds
  7729. LBE37:  .byte $36           ;D#3
  7730. LBE38:  .byte $34           ;D3
  7731. LBE39:  .byte $30           ;C3
  7732. LBE3A:  .byte $2A           ;A3
  7733. LBE3B:  .byte $B4           ;1 1/2 seconds
  7734. LBE3C:  .byte $1C           ;D2
  7735. LBE3D:  .byte $1C           ;D2
  7736.  
  7737. FadeInSQ1IndexData:
  7738. LBE3E:  .byte $B3           ;3/4 seconds
  7739. LBE3F:  .byte $34           ;D3
  7740. LBE40:  .byte $3A           ;F3
  7741. LBE41:  .byte $34           ;D3
  7742. LBE42:  .byte $30           ;C3
  7743. LBE43:  .byte $B4           ;1 1/2 seconds
  7744. LBE44:  .byte $2A           ;A3
  7745. LBE45:  .byte $2A           ;A3
  7746. LBE46:  .byte $00           ;End fade in music.
  7747.  
  7748. TourianSQ2IndexData:
  7749. LBE47:  .byte $B4           ;1 1/2 seconds
  7750. LBE48:  .byte $12           ;A2
  7751. LBE49:  .byte $B3           ;3/4 seconds
  7752. LBE4A:  .byte $10           ;Ab1
  7753. LBE4B:  .byte $18           ;C2
  7754. LBE4C:  .byte $16           ;B2
  7755. LBE4D:  .byte $0A           ;F1
  7756. LBE4E:  .byte $B4           ;1 1/2 seconds
  7757. LBE4F:  .byte $14           ;A#2
  7758. LBE50:  .byte $12           ;A2
  7759. LBE51:  .byte $B3           ;3/4 seconds
  7760. LBE52:  .byte $10           ;Ab1
  7761. LBE53:  .byte $06           ;D1
  7762. LBE54:  .byte $0E           ;G1
  7763. LBE55:  .byte $04           ;C#1
  7764. LBE56:  .byte $B4           ;1 1/2 seconds
  7765. LBE57:  .byte $0C           ;F#1
  7766. LBE58:  .byte $00           ;End Tourian music.
  7767.  
  7768. TourianSQ1IndexData:
  7769. LBE59:  .byte $E0           ;
  7770. LBE5A:  .byte $B0           ;3/32 seconds   +
  7771. LBE5B:  .byte $54           ;F#4        |
  7772. LBE5C:  .byte $4E           ;D#4        |
  7773. LBE5D:  .byte $48           ;C4     | Repeat 32 times
  7774. LBE5E:  .byte $42           ;A4     |
  7775. LBE5F:  .byte $48           ;C4     |
  7776. LBE60:  .byte $4E           ;D#4        +
  7777. LBE61:  .byte $FF           ;
  7778.  
  7779. TourianTriangleIndexData:
  7780. LBE62:  .byte $E0           ;
  7781. LBE63:  .byte $B3           ;3/4 seconds    +
  7782. LBE64:  .byte $02           ;No sound   |
  7783. LBE65:  .byte $B0           ;3/32 seconds   |
  7784. LBE66:  .byte $3C           ;F#3        |
  7785. LBE67:  .byte $40           ;Ab3        |
  7786. LBE68:  .byte $44           ;A#4        |
  7787. LBE69:  .byte $4A           ;C#4        |
  7788. LBE6A:  .byte $4E           ;D#4        |
  7789. LBE6B:  .byte $54           ;F#4        |
  7790. LBE6C:  .byte $58           ;Ab4        | Repeat 32 times
  7791. LBE6D:  .byte $5C           ;A#5        |
  7792. LBE6E:  .byte $62           ;C#5        |
  7793. LBE6F:  .byte $66           ;D#5        |
  7794. LBE70:  .byte $6C           ;F#5        |
  7795. LBE71:  .byte $70           ;Ab5        |
  7796. LBE72:  .byte $74           ;A#6        |
  7797. LBE73:  .byte $7A           ;C#6        |
  7798. LBE74:  .byte $B3           ;3/4 seconds    |
  7799. LBE75:  .byte $02           ;No sound   +
  7800. LBE76:  .byte $FF
  7801.  
  7802. ;The following table contains the musical notes used by the music player.  The first byte is
  7803. ;the period high information(3 bits) and the second byte is the period low information(8 bits).
  7804. ;The formula for figuring out the frequency is as follows: 1790000/16/(hhhllllllll + 1)
  7805.  
  7806. MusicNotesTbl:
  7807. LBE77:  .byte $07           ;55.0Hz (A1)    Index #$00 (Not used)
  7808. LBE78:  .byte $F0           ;
  7809.  
  7810. LBE79:  .byte $00           ;No sound   Index #$02
  7811. LBE7A:  .byte $00           ;
  7812.  
  7813. LBE7B:  .byte $06           ;69.3Hz (C#2)   Index #$04
  7814. LBE7C:  .byte $4E           ;
  7815.  
  7816. LBE7D:  .byte $05           ;73.4Hz (D2)    Index #$06
  7817. LBE7E:  .byte $F3           ;
  7818.  
  7819. LBE7F:  .byte $05           ;82.4Hz (E2)    Index #$08
  7820. LBE80:  .byte $4D           ;
  7821.  
  7822. LBE81:  .byte $05           ;87.3Hz (F2)    Index #$0A
  7823. LBE82:  .byte $01           ;
  7824.  
  7825. LBE83:  .byte $04           ;92.5Hz (F#2)   Index #$0C
  7826. LBE84:  .byte $B9           ;
  7827.  
  7828. LBE85:  .byte $04           ;98.0Hz (G2)    Index #$0E
  7829. LBE86:  .byte $75           ;
  7830.  
  7831. LBE87:  .byte $04           ;103.8Hz (Ab2)  Index #$10
  7832. LBE88:  .byte $35           ;
  7833.  
  7834. LBE89:  .byte $03           ;110.0Hz (A2)   Index #$12
  7835. LBE8A:  .byte $F8           ;
  7836.  
  7837. LBE8B:  .byte $03           ;116.5Hz (A#2)  Index #$14
  7838. LBE8C:  .byte $BF           ;
  7839.  
  7840. LBE8D:  .byte $03           ;123.5Hz (B2)   Index #$16
  7841. LBE8E:  .byte $89           ;
  7842.  
  7843. LBE8F:  .byte $03           ;130.7Hz (C3)   Index #$18
  7844. LBE90:  .byte $57           ;
  7845.  
  7846. LBE91:  .byte $03           ;138.5Hz (C#3)  Index #$1A
  7847. LBE92:  .byte $27           ;
  7848.  
  7849. LBE93:  .byte $02           ;146.8Hz (D3)   Index #$1C
  7850. LBE94:  .byte $F9           ;
  7851.  
  7852. LBE95:  .byte $02           ;155.4Hz (D#3)  Index #$1E
  7853. LBE96:  .byte $CF           ;
  7854.  
  7855. LBE97:  .byte $02           ;164.8Hz (E3)   Index #$20
  7856. LBE98:  .byte $A6           ;
  7857.  
  7858. LBE99:  .byte $02           ;174.5Hz (F3)   Index #$22
  7859. LBE9A:  .byte $80           ;
  7860.  
  7861. LBE9B:  .byte $02           ;184.9Hz (F#3)  Index #$24
  7862. LBE9C:  .byte $5C           ;
  7863.  
  7864. LBE9D:  .byte $02           ;196.0Hz (G3)   Index #$26
  7865. LBE9E:  .byte $3A           ;  
  7866.    
  7867. LBE9F:  .byte $02           ;207.6Hz (Ab3)  Index #$28
  7868. LBEA0:  .byte $1A           ;
  7869.  
  7870. LBEA1:  .byte $01           ;219.8Hz (A3)   Index #$2A
  7871. LBEA2:  .byte $FC           ;
  7872.  
  7873. LBEA3:  .byte $01           ;233.1Hz (A#3)  Index #$2C
  7874. LBEA4:  .byte $DF           ;
  7875.  
  7876. LBEA5:  .byte $01           ;247.0Hz (B3)   Index #$2E
  7877. LBEA6:  .byte $C4           ;
  7878.  
  7879. LBEA7:  .byte $01           ;261.4Hz (C4)   Index #$30
  7880. LBEA8:  .byte $AB           ;
  7881.  
  7882. LBEA9:  .byte $01           ;276.9Hz (C#4)  Index #$32
  7883. LBEAA:  .byte $93           ;
  7884.  
  7885. LBEAB:  .byte $01           ;293.6Hz (D4)   Index #$34
  7886. LBEAC:  .byte $7C           ;
  7887.  
  7888. LBEAD:  .byte $01           ;310.8Hz (D#4)  Index #$36
  7889. LBEAE:  .byte $67           ;
  7890.  
  7891. LBEAF:  .byte $01           ;330.0Hz (E4)   Index #$38
  7892. LBEB0:  .byte $52           ;
  7893.  
  7894. LBEB1:  .byte $01           ;349.6Hz (F4)   Index #$3A
  7895. LBEB2:  .byte $3F           ;
  7896.  
  7897. LBEB3:  .byte $01           ;370.4Hz (F#4)  Index #$3C
  7898. LBEB4:  .byte $2D           ;
  7899.  
  7900. LBEB5:  .byte $01           ;392.5Hz (G4)   Index #$3E
  7901. LBEB6:  .byte $1C           ;
  7902.  
  7903. LBEB7:  .byte $01           ;415.9Hz (Ab4)  Index #$40
  7904. LBEB8:  .byte $0C           ;
  7905.  
  7906. LBEB9:  .byte $00           ;440.4Hz (A4)   Index #$42
  7907. LBEBA:  .byte $FD           ;
  7908.  
  7909. LBEBB:  .byte $00           ;468.1Hz (A#4)  Index #$44
  7910. LBEBC:  .byte $EE           ;
  7911.  
  7912. LBEBD:  .byte $00           ;495.0Hz (B4)   Index #$46
  7913. LBEBE:  .byte $E1           ;
  7914.  
  7915. LBEBF:  .byte $00           ;525.2Hz (C5)   Index #$48
  7916. LBEC0:  .byte $D4           ;
  7917.  
  7918. LBEC1:  .byte $00           ;556.6Hz (C#5)  Index #$4A
  7919. LBEC2:  .byte $C8           ;
  7920.  
  7921. LBEC3:  .byte $00           ;588.8Hz (D5)   Index #$4C
  7922. LBEC4:  .byte $BD           ;
  7923.  
  7924. LBEC5:  .byte $00           ;625.0Hz (D#5)  Index #$4E
  7925. LBEC6:  .byte $B2           ;
  7926.  
  7927. LBEC7:  .byte $00           ;662.0Hz (E5)   Index #$50
  7928. LBEC8:  .byte $A8           ;
  7929.  
  7930. LBEC9:  .byte $00           ;699.2Hz (F5)   Index #$52
  7931. LBECA:  .byte $9F           ;
  7932.  
  7933. LBECB:  .byte $00           ;740.9Hz (F#5)  Index #$54
  7934. LBECC:  .byte $96           ;
  7935.  
  7936. LBECD:  .byte $00           ;787.9Hz (G5)   Index #$56
  7937. LBECE:  .byte $8D           ;
  7938.  
  7939. LBECF:  .byte $00           ;834.9Hz (Ab5)  Index #$58
  7940. LBED0:  .byte $85           ;
  7941.  
  7942. LBED1:  .byte $00           ;880.9HZ (A5)   Index #$5A
  7943. LBED2:  .byte $7E           ;
  7944.  
  7945. LBED3:  .byte $00           ;940.1Hz (A#5)  Index #$5C
  7946. LBED4:  .byte $76           ;
  7947.  
  7948. LBED5:  .byte $00           ;990.0Hz (B5)   Index #$5E
  7949. LBED6:  .byte $70           ;
  7950.  
  7951. LBED7:  .byte $00           ;1055Hz (C6)    Index #$60
  7952. LBED8:  .byte $69           ;
  7953.  
  7954. LBED9:  .byte $00           ;1118Hz (C#6)   Index #$62
  7955. LBEDA:  .byte $63           ;
  7956.  
  7957. LBEDB:  .byte $00           ;1178Hz (D6)    Index #$64
  7958. LBEDC:  .byte $5E           ;
  7959.  
  7960. LBEDD:  .byte $00           ;1257Hz (D#6)   Index #$66
  7961. LBEDE:  .byte $58           ;
  7962.  
  7963. LBEDF:  .byte $00           ;1332Hz (E6)    Index #$68
  7964. LBEE0:  .byte $53           ;
  7965.  
  7966. LBEE1:  .byte $00           ;1398Hz (F6)    Index #$6A
  7967. LBEE2:  .byte $4F           ;
  7968.  
  7969. LBEE3:  .byte $00           ;1492Hz (F#6)   Index #$6C
  7970. LBEE4:  .byte $4A           ;
  7971.  
  7972. LBEE5:  .byte $00           ;1576Hz (G6)    Index #$6E
  7973. LBEE6:  .byte $46           ;
  7974.  
  7975. LBEE7:  .byte $00           ;1670Hz (Ab6)   Index #$70
  7976. LBEE8:  .byte $42           ;
  7977.  
  7978. LBEE9:  .byte $00           ;1776Hz (A6)    Index #$72
  7979. LBEEA:  .byte $3E           ;
  7980.  
  7981. LBEEB:  .byte $00           ;1896Hz (A#6)   Index #$74
  7982. LBEEC:  .byte $3A           ;
  7983.  
  7984. LBEED:  .byte $00           ;1998Hz (B6)    Index #$76
  7985. LBEEE:  .byte $37           ;
  7986.  
  7987. LBEEF:  .byte $00           ;2111Hz (C7)    Index #$78
  7988. LBEF0:  .byte $34           ;
  7989.  
  7990. LBEF1:  .byte $00           ;2238Hz (C#7)   Index #$7A
  7991. LBEF2:  .byte $31           ;
  7992.  
  7993. LBEF3:  .byte $00           ;2380Hz (D7)    Index #$7C
  7994. LBEF4:  .byte $2E           ;
  7995.  
  7996. LBEF5:  .byte $00           ;2796Hz (F7)    Index #$7E
  7997. LBEF6:  .byte $27           ;
  7998.  
  7999. ;The following tables are used to load the music frame count addresses ($0640 thru $0643). The
  8000. ;larger the number, the longer the music will play a solid note.  The number represents how
  8001. ;many frames the note will play.  There is a small discrepancy in time length because the
  8002. ;Nintendo runs at 60 frames pers second and I am using 64 frames per second to make the
  8003. ;numbers below divide more evenly.
  8004.  
  8005. ;Used by power up music and Kraid area music.
  8006.  
  8007. NoteLengths0Tbl:
  8008. LBEF7:  .byte $04           ;About    1/16 seconds ($B0)
  8009. LBEF8:  .byte $08           ;About    1/8  seconds ($B1)
  8010. LBEF9:  .byte $10           ;About    1/4  seconds ($B2)
  8011. LBEFA:  .byte $20           ;About    1/2  seconds ($B3)
  8012. LBEFB:  .byte $40           ;About 1       seconds ($B4)
  8013. LBEFC:  .byte $18           ;About    3/8  seconds ($B5)
  8014. LBEFD:  .byte $30           ;About    3/4  seconds ($B6)
  8015. LBEFE:  .byte $0C           ;About    3/16 seconds ($B7)
  8016. LBEFF:  .byte $0B           ;About   11/64 seconds ($B8)
  8017. LBF00:  .byte $05           ;About    5/64 seconds ($B9)
  8018. LBF01:  .byte $02           ;About    1/32 seconds ($BA)
  8019.  
  8020. ;Used by item room, fade in, Brinstar music, Ridley area music, Mother brain music,
  8021. ;escape music, Norfair music and Tourian music.
  8022.  
  8023. NoteLengths1Tbl:
  8024. LBF02:  .byte $06           ;About    3/32 seconds ($B0)
  8025. LBF03:  .byte $0C           ;About    3/16 seconds ($B1)
  8026. LBF04:  .byte $18           ;About    3/8  seconds ($B2)
  8027. LBF05:  .byte $30           ;About    3/4  seconds ($B3)
  8028. LBF06:  .byte $60           ;About 1  1/2  seconds ($B4)
  8029. LBF07:  .byte $24           ;About    9/16 seconds ($B5)
  8030. LBF08:  .byte $48           ;About 1  3/16 seconds ($B6)
  8031. LBF09:  .byte $12           ;About    9/32 seconds ($B7)
  8032. LBF0A:  .byte $10           ;About    1/4  seconds ($B8)
  8033. LBF0B:  .byte $08           ;About    1/8  seconds ($B9)
  8034. LBF0C:  .byte $03           ;About    3/64 seconds ($BA)
  8035.  
  8036. ;Used by intro and end game music.
  8037.  
  8038. NoteLengths2Tbl:
  8039. LBF0D:  .byte $10           ;About    1/4  seconds ($B0)
  8040. LBF0E:  .byte $07           ;About    7/64 seconds ($B1)
  8041. LBF0F:  .byte $0E           ;About    7/32 seconds ($B2)
  8042. LBF10:  .byte $1C           ;About    7/16 seconds ($B3)
  8043. LBF11:  .byte $38           ;About    7/8  seconds ($B4)
  8044. LBF12:  .byte $70           ;About 1 13/16 seconds ($B5)
  8045. LBF13:  .byte $2A           ;About   21/32 seconds ($B6)
  8046. LBF14:  .byte $54           ;About 1  5/16 seconds ($B7)
  8047. LBF15:  .byte $15           ;About   21/64 seconds ($B8)
  8048. LBF16:  .byte $12           ;About    9/32 seconds ($B9)
  8049. LBF17:  .byte $02           ;About    1/32 seconds ($BA)
  8050. LBF18:  .byte $03           ;About    3/64 seconds ($BB)
  8051.  
  8052. InitializeMusic:                   
  8053. LBF19:  JSR CheckMusicFlags     ;($B3FC)Check to see if restarting current music.
  8054. LBF1C:  LDA CurrentSFXFlags     ;Load current SFX flags and store CurrentMusic address.
  8055. LBF1F:  STA CurrentMusic        ;
  8056. LBF22:  LDA MusicInitIndex      ;
  8057. LBF25:  TAY             ;
  8058. LBF26:  LDA InitMusicIndexTbl,Y     ;($BBFA)Find index for music in InitMusicInitIndexTbl.
  8059. LBF29:  TAY             ;
  8060. LBF2A:  LDX #$00            ;
  8061.  
  8062. LBF2C:* LDA InitMusicTbl,Y      ;Base is $BD31.
  8063. LBF2F:  STA NoteLengthTblOffset,X   ;
  8064. LBF32:  INY                 ;The following loop repeats 13 times to-->
  8065. LBF33:  INX                 ;load the initial music addresses -->
  8066. LBF34:  TXA                 ;(registers $062B thru $0637).
  8067. LBF35:  CMP #$0D            ;
  8068. LBF37:  BNE -               ;
  8069.  
  8070. LBF39:  LDA #$01            ;Resets addresses $0640 thru $0643 to #$01.-->
  8071. LBF3B:  STA SQ1MusicFrameCount      ;These addresses are used for counting the-->
  8072. LBF3E:  STA SQ2MusicFrameCount      ;number of frames music channels have been playing.
  8073. LBF41:  STA TriangleMusicFrameCount ;
  8074. LBF44:  STA NoiseMusicFrameCount    ;
  8075. LBF47:  LDA #$00            ;
  8076. LBF49:  STA SQ1MusicIndexIndex      ;
  8077. LBF4C:  STA SQ2MusicIndexIndex      ;Resets addresses $0638 thru $063B to #$00.-->
  8078. LBF4F:  STA TriangleMusicIndexIndex ;These are the index to find sound channel data index.
  8079. LBF52:  STA NoiseMusicIndexIndex    ;
  8080. LBF55:  RTS             ;
  8081.  
  8082. ;Not used.
  8083. LBF56:  .byte $10, $07, $0E, $1C, $38, $70, $2A, $54, $15, $12, $02, $03, $20, $2C, $B4, $AD
  8084. LBF66:  .byte $4D, $06, $8D, $8D, $06, $AD, $5E, $06, $A8, $B9, $2A, $BC, $A8, $A2, $00, $B9
  8085. LBF76:  .byte $61, $BD, $9D, $2B, $06, $C8, $E8, $8A, $C9, $0D, $D0, $F3, $A9, $01, $8D, $40
  8086. LBF86:  .byte $06, $8D, $41, $06, $8D, $42, $06, $8D, $43, $06, $A9, $00, $8D, $38, $06, $8D
  8087. LBF96:  .byte $39, $06, $8D, $3A, $06, $8D, $3B, $06, $60, $FF, $00, $00, $00, $00, $00, $00
  8088. LBFA6:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  8089.  
  8090. ;----------------------------------------------[ RESET ]--------------------------------------------
  8091.  
  8092. RESET:
  8093. LBFB0:  SEI             ;Disables interrupt.
  8094. LBFB1:  CLD             ;Sets processor to binary mode.
  8095. LBFB2:  LDX #$00            ;
  8096. LBFB4:  STX PPUControl0         ;Clear PPU control registers.
  8097. LBFB7:  STX PPUControl1         ;
  8098. LBFBA:* LDA PPUStatus           ;
  8099. LBFBD:  BPL -               ;Wait for VBlank.
  8100. LBFBF:* LDA PPUStatus           ;
  8101. LBFC2:  BPL -               ;
  8102. LBFC4:  ORA #$FF            ;
  8103. LBFC6:  STA MMC1Reg0            ;Reset MMC1 chip.-->
  8104. LBFC9:  STA MMC1Reg1            ;(MSB is set).
  8105. LBFCC:  STA MMC1Reg2            ;
  8106. LBFCF:  STA MMC1Reg3            ;
  8107. LBFD2:  JMP Startup         ;($C01A)Does preliminry housekeeping.
  8108.  
  8109. ;Not used.
  8110. LBFD5:  .byte $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $00, $00, $00, $00, $00
  8111. LBFE5:  .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  8112. LBFF5:  .byte $00, $00, $00, $00, $00
  8113.  
  8114. ;----------------------------------------[ Interrupt vectors ]--------------------------------------
  8115.  
  8116. LBFFA:  .word NMI           ;($C0D9)NMI vector.
  8117. LBFFC:  .word RESET         ;($FFB0)Reset vector.
  8118. LBFFE:  .word RESET         ;($FFB0)IRQ vector.
Add Comment
Please, Sign In to add comment