User Tools

Site Tools


metroid:disassembly:game_engine_page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
metroid:disassembly:game_engine_page [2015/04/20 23:14] – created gf_kennonmetroid:disassembly:game_engine_page [2016/03/06 17:29] (current) – infos on breakable blocks snarfblam
Line 29: Line 29:
 ;-------------------------------------[ Forward declarations ]-------------------------------------- ;-------------------------------------[ Forward declarations ]--------------------------------------
  
-.alias ObjectAnimIndexTbl $8572 +.alias ObjectAnimIndexTbl       $8572 
-.alias FramePtrTable $860B +.alias FramePtrTable            $860B 
-.alias PlacePtrTable $86DF +.alias PlacePtrTable            $86DF 
-.alias StarPalSwitch $8AC7 +.alias StarPalSwitch            $8AC7 
-.alias SamusEnterDoor $8B13 +.alias SamusEnterDoor           $8B13 
-.alias AreaPointers $9598 +.alias AreaPointers             $9598 
-.alias AreaRoutine $95C3 +.alias AreaRoutine              $95C3 
-.alias EnemyHitPointTbl $962B +.alias EnemyHitPointTbl         $962B 
-.alias EnemyInitDelayTbl $96BB +.alias EnemyInitDelayTbl        $96BB 
-.alias DecSpriteYCoord $988A +.alias DecSpriteYCoord          $988A 
-.alias NMIScreenWrite $9A07 +.alias NMIScreenWrite           $9A07 
-.alias EndGamePalWrite $9F54 +.alias EndGamePalWrite          $9F54 
-.alias SpecItmsTable $9598 +.alias SpecItmsTable            $9598 
-.alias CopyMap $A93E +.alias CopyMap                  $A93E 
-.alias SoundEngine $B3B4+.alias SoundEngine              $B3B4
  
 ;----------------------------------------[ Start of code ]------------------------------------------ ;----------------------------------------[ Start of code ]------------------------------------------
Line 53: Line 53:
  
 RandomNumbers: RandomNumbers:
-LC000: txa ;  +LC000:  txa                                            
-LC001: pha +LC001:  pha                             
-LC002: ldx #$05 +LC002:  ldx #$05                        
-LC004:* lda RandomNumber1 +LC004:* lda RandomNumber1               
-LC006: clc +LC006:  clc                             
-LC007: adc #$05 +LC007:  adc #$05                        
-LC009: sta RandomNumber1 ;2E is increased by #$19 every frame and--> +LC009:  sta RandomNumber1               ;2E is increased by #$19 every frame and--> 
-LC00B: lda RandomNumber2 ;2F is increased by #$5F every frame.  +LC00B:  lda RandomNumber2               ;2F is increased by #$5F every frame.                    
-LC00D: clc +LC00D:  clc                             
-LC00E: adc #$13 +LC00E:  adc #$13                        
-LC010: sta RandomNumber2 +LC010:  sta RandomNumber2               
-LC012: dex +LC012:  dex                             
-LC013: bne - +LC013:  bne -                           
-LC015: pla +LC015:  pla                             
-LC016: tax +LC016:  tax                             
-LC017: lda RandomNumber1 +LC017:  lda RandomNumber1               
-LC019: rts ;+LC019:  rts                             ;
  
 ;------------------------------------------[ Startup ]---------------------------------------------- ;------------------------------------------[ Startup ]----------------------------------------------
  
 Startup: Startup:
-LC01A: lda #$00 +LC01A:  lda #$00                        
-LC01C: sta MMC1Reg1  ;Clear bit 0. MMC1 is serial controlled +LC01C:  sta MMC1Reg1                    ;Clear bit 0. MMC1 is serial controlled 
-LC01F: sta MMC1Reg1 ;Clear bit 1 +LC01F:  sta MMC1Reg1                    ;Clear bit 1 
-LC022: sta MMC1Reg1 ;Clear bit 2 +LC022:  sta MMC1Reg1                    ;Clear bit 2 
-LC024: sta MMC1Reg1 ;Clear bit 3 +LC024:  sta MMC1Reg1                    ;Clear bit 3 
-LC027: sta MMC1Reg1 ;Clear bit 4  +LC027:  sta MMC1Reg1                    ;Clear bit 4  
-LC02B: sta MMC1Reg2 ;Clear bit 0 +LC02B:  sta MMC1Reg2                    ;Clear bit 0 
-LC02E: sta MMC1Reg2 ;Clear bit 1 +LC02E:  sta MMC1Reg2                    ;Clear bit 1 
-LC031: sta MMC1Reg2 ;Clear bit 2 +LC031:  sta MMC1Reg2                    ;Clear bit 2 
-LC034: sta MMC1Reg2 ;Clear bit 3 +LC034:  sta MMC1Reg2                    ;Clear bit 3 
-LC037: sta MMC1Reg2 ;Clear bit 4  +LC037:  sta MMC1Reg2                    ;Clear bit 4  
-LC03A: jsr MMCWriteReg3 ;($C4FA)Swap to PRG bank #0 at $8000 +LC03A:  jsr MMCWriteReg3                ;($C4FA)Swap to PRG bank #0 at $8000 
-LC03D: dex ;X = $FF +LC03D:  dex                             ;X = $FF 
-LC03E: txs ;S points to end of stack page+LC03E:  txs                             ;S points to end of stack page
  
 ;Clear RAM at $000-$7FF. ;Clear RAM at $000-$7FF.
-LC03F: ldy #$07 ;High byte of start address. +LC03F:  ldy #$07                        ;High byte of start address. 
-LC041: sty $01 +LC041:  sty $01                         
-LC043: ldy #$00       ;Low byte of start address. +LC043:  ldy #$00                        ;Low byte of start address. 
-LC045: sty $00       ;$0000 = #$0700 +LC045:  sty $00                         ;$0000 = #$0700 
-LC047: tya     ;A = 0 +LC047:  tya                             ;A = 0 
-LC048:* sta ($00),    ;clear address +LC048:* sta ($00),                    ;clear address 
-LC04A: iny +LC04A:  iny                             
-LC04B: bne -   ;Repeat for entire page. +LC04B:  bne -                           ;Repeat for entire page. 
-LC04D: dec $01       ;Decrement high byte of address. +LC04D:  dec $01                         ;Decrement high byte of address. 
-LC04F: bmi +   ;If $01 < 0, all pages are cleared. +LC04F:  bmi +                           ;If $01 < 0, all pages are cleared. 
-LC051: ldx $01 +LC051:  ldx $01                         
-LC053: cpx #$01 ;Keep looping until ram is cleared. +LC053:  cpx #$01                        ;Keep looping until ram is cleared. 
-LC055: bne - ;+LC055:  bne -                           ;
  
 ;Clear cartridge RAM at $6000-$7FFF. ;Clear cartridge RAM at $6000-$7FFF.
-LC057:* ldy #$7F ;High byte of start address. +LC057:* ldy #$7F                        ;High byte of start address. 
-LC059: sty $01 +LC059:  sty $01                         
-LC05B: ldy #$00 ;Low byte of start address. +LC05B:  ldy #$00                        ;Low byte of start address. 
-LC05D: sty $00 ;$0000 points to $7F00 +LC05D:  sty $00                         ;$0000 points to $7F00 
-LC05F: tya     ;A = 0 +LC05F:  tya                             ;A = 0 
-LC060:* sta ($00),y +LC060:* sta ($00),                    
-LC062: iny ;Clears 256 bytes of memory before decrementing to next--> +LC062:  iny                             ;Clears 256 bytes of memory before decrementing to next--> 
-LC063: bne - ;256 bytes. +LC063:  bne -                           ;256 bytes. 
-LC065: dec $01 +LC065:  dec $01                         
-LC067: ldx $01 ;Is address < $6000?--> +LC067:  ldx $01                         ;Is address < $6000?--> 
-LC069: cpx #$60     ;If not, do another page. +LC069:  cpx #$60                        ;If not, do another page. 
-LC06B: bcs -       +LC06B:  bcs -                           
  
-LC06D: lda #%00001110 ;Verticle mirroring. +LC06D:  lda #%00001110                  ;Verticle mirroring. 
- ;H/V mirroring (As opposed to one-screen mirroring). +                                        ;H/V mirroring (As opposed to one-screen mirroring). 
- ;Switch low PRGROM area during a page switch. +                                        ;Switch low PRGROM area during a page switch. 
- ;16KB PRGROM switching enabled. +                                        ;16KB PRGROM switching enabled. 
- ;8KB CHRROM switching enabled. +                                        ;8KB CHRROM switching enabled. 
-LC06F: sta MMCReg0Cntrl ;+LC06F:  sta MMCReg0Cntrl                ;
  
-LC071: lda #$00 ;Clear bits 3 and 4 of MMC1 register 3. +LC071:  lda #$00                        ;Clear bits 3 and 4 of MMC1 register 3. 
-LC073: sta SwitchUpperBits ;+LC073:  sta SwitchUpperBits             ;
  
-LC075: ldy #$00 +LC075:  ldy #$00                        
-LC077: sty ScrollX ;ScrollX = 0 +LC077:  sty ScrollX                     ;ScrollX = 0 
-LC079: sty ScrollY     ;ScrollY = 0 +LC079:  sty ScrollY                     ;ScrollY = 0 
-LC07B: sty PPUScroll ;Clear hardware scroll x +LC07B:  sty PPUScroll                   ;Clear hardware scroll x 
-LC07E: sty PPUScroll ;Clear hardware scroll y +LC07E:  sty PPUScroll                   ;Clear hardware scroll y 
-LC081: iny ;Y = #$01 +LC081:  iny                             ;Y = #$01 
-LC082: sty GameMode ;Title screen mode +LC082:  sty GameMode                    ;Title screen mode 
-LC084: jsr ClearNameTables ;($C158) +LC084:  jsr ClearNameTables             ;($C158) 
-LC087: jsr EraseAllSprites ;($C1A3)+LC087:  jsr EraseAllSprites             ;($C1A3)
  
-LC08A: lda #%10010000 ;NMI = enabled +LC08A:  lda #%10010000                  ;NMI = enabled 
- ;Sprite size = 8x8 +                                        ;Sprite size = 8x8 
- ;BG pattern table address = $1000 +                                        ;BG pattern table address = $1000 
- ;SPR pattern table address = $0000 +                                        ;SPR pattern table address = $0000 
- ;PPU address increment = 1 +                                        ;PPU address increment = 1 
- ;Name table address = $2000 +                                        ;Name table address = $2000 
-LC08C: sta PPUControl0 +LC08C:  sta PPUControl0                 
-LC08F: sta PPUCNT0ZP ;+LC08F:  sta PPUCNT0ZP                   ;
  
-LC091: lda #%00000010 ;Sprites visible = no +LC091:  lda #%00000010                  ;Sprites visible = no 
- ;Background visible = no +                                        ;Background visible = no 
- ;Sprite clipping = yes +                                        ;Sprite clipping = yes 
- ;Background clipping = no +                                        ;Background clipping = no 
- ;Display type = color +                                        ;Display type = color 
-LC093: sta PPUCNT1ZP ;+LC093:  sta PPUCNT1ZP                   ;
  
-LC095: lda #$47 +LC095:  lda #$47                        
-LC097: sta MirrorCntrl ;Prepare to set PPU to vertical mirroring. +LC097:  sta MirrorCntrl                 ;Prepare to set PPU to vertical mirroring. 
-LC099: jsr PrepVertMirror ;($C4B2)+LC099:  jsr PrepVertMirror              ;($C4B2)
  
-LC09C: lda #$00 +LC09C:  lda #$00                        
-LC09E: sta DMCCntrl1 ;PCM volume = 0 - disables DMC channel +LC09E:  sta DMCCntrl1                   ;PCM volume = 0 - disables DMC channel 
-LC0A1: lda #$0F +LC0A1:  lda #$0F                        
-LC0A3: sta APUCommonCntrl0 ;Enable sound channel 0,1,2,3+LC0A3:  sta APUCommonCntrl0             ;Enable sound channel 0,1,2,3
  
-LC0A6: ldy #$00 +LC0A6:  ldy #$00                        
-LC0A8: sty TitleRoutine ;Set title routine and and main routine function--> +LC0A8:  sty TitleRoutine                ;Set title routine and and main routine function--> 
-LC0AA: sty MainRoutine ;pointers equal to 0. +LC0AA:  sty MainRoutine                 ;pointers equal to 0. 
-LC0AC: lda #$11 +LC0AC:  lda #$11                        
-LC0AE: sta RandomNumber1 ;Initialize RandomNumber1 to #$11 +LC0AE:  sta RandomNumber1               ;Initialize RandomNumber1 to #$11 
-LC0B0: lda #$FF +LC0B0:  lda #$FF                        
-LC0B2: sta RandomNumber2 ;Initialize RandomNumber2 to #$FF+LC0B2:  sta RandomNumber2               ;Initialize RandomNumber2 to #$FF
  
-LC0B4: iny ;Y = 1 +LC0B4:  iny                             ;Y = 1 
-LC0B5: sty SwitchPending ;Prepare to switch page 0 into lower PRGROM. +LC0B5:  sty SwitchPending               ;Prepare to switch page 0 into lower PRGROM. 
-LC0B7: jsr CheckSwitch ;($C4DE) +LC0B7:  jsr CheckSwitch                 ;($C4DE) 
-LC0BA: bne WaitNMIEnd ;Branch always+LC0BA:  bne WaitNMIEnd                  ;Branch always
  
 ;-----------------------------------------[ Main loop ]---------------------------------------------- ;-----------------------------------------[ Main loop ]----------------------------------------------
Line 181: Line 181:
  
 MainLoop: MainLoop:
-LC0BC: jsr CheckSwitch ;($C4DE)Check to see if memory page needs to be switched. +LC0BC:  jsr CheckSwitch                 ;($C4DE)Check to see if memory page needs to be switched. 
-LC0BF: jsr UpdateTimer ;($C266)Update Timers 1, 2 and 3. +LC0BF:  jsr UpdateTimer                 ;($C266)Update Timers 1, 2 and 3. 
-LC0C2: jsr GoMainRoutine ;($C114)Go to main routine for updating game. +LC0C2:  jsr GoMainRoutine               ;($C114)Go to main routine for updating game. 
-LC0C5: inc FrameCount ;Increment frame counter. +LC0C5:  inc FrameCount                  ;Increment frame counter. 
-LC0C7: lda #$00 +LC0C7:  lda #$00                        
-LC0C9: sta NMIStatus ;Wait for next NMI to end.+LC0C9:  sta NMIStatus                   ;Wait for next NMI to end.
  
 WaitNMIEnd: WaitNMIEnd:
-LC0CB: tay +LC0CB:  tay                             
-LC0CC: lda NMIStatus +LC0CC:  lda NMIStatus                   
-LC0CE: bne + ;If nonzero, NMI has ended. Else keep waiting. +LC0CE:  bne +                           ;If nonzero, NMI has ended. Else keep waiting. 
-LC0D0: jmp WaitNMIEnd ;+LC0D0:  jmp WaitNMIEnd                  ;
  
-LC0D3:* jsr RandomNumbers ;($C000)Update pseudo random numbers. +LC0D3:* jsr RandomNumbers               ;($C000)Update pseudo random numbers. 
-LC0D6: jmp MainLoop ;($C0BC)Jump to top of subroutine.+LC0D6:  jmp MainLoop                    ;($C0BC)Jump to top of subroutine.
  
 ;-------------------------------------[ Non-Maskable Interrupt ]------------------------------------- ;-------------------------------------[ Non-Maskable Interrupt ]-------------------------------------
Line 206: Line 206:
  
 NMI: NMI:
-LC0D9: php ;Save processor status, A, X and Y on stack. +LC0D9:  php                             ;Save processor status, A, X and Y on stack. 
-LC0DA: pha ;Save A. +LC0DA:  pha                             ;Save A. 
-LC0DB: txa +LC0DB:  txa                             
-LC0DC: pha ;Save X. +LC0DC:  pha                             ;Save X. 
-LC0DD: tya +LC0DD:  tya                             
-LC0DE: pha ;Save Y. +LC0DE:  pha                             ;Save Y. 
-LC0DF: lda #$00 +LC0DF:  lda #$00                        
-LC0E1: sta SPRAddress ;Sprite RAM address = 0. +LC0E1:  sta SPRAddress                  ;Sprite RAM address = 0. 
-LC0E4: lda #$02 +LC0E4:  lda #$02                        
-LC0E6: sta SPRDMAReg ;Transfer page 2 ($200-$2FF) to Sprite RAM. +LC0E6:  sta SPRDMAReg                   ;Transfer page 2 ($200-$2FF) to Sprite RAM. 
-LC0E9: lda NMIStatus +LC0E9:  lda NMIStatus                   
-LC0EB: bne ++ ;Skip if the frame couldn't finish in time. +LC0EB:  bne ++                          ;Skip if the frame couldn't finish in time. 
-LC0ED: lda GameMode +LC0ED:  lda GameMode                    
-LC0EF: beq + ;Branch if mode=Play. +LC0EF:  beq +                           ;Branch if mode=Play. 
-LC0F1: jsr NMIScreenWrite ;($9A07)Write end message on screen(If appropriate). +LC0F1:  jsr NMIScreenWrite              ;($9A07)Write end message on screen(If appropriate). 
-LC0F4:* jsr CheckPalWrite ;($C1E0)Check if palette data pending. +LC0F4:* jsr CheckPalWrite               ;($C1E0)Check if palette data pending. 
-LC0F7: jsr CheckPPUWrite ;($C2CA)check if data needs to be written to PPU. +LC0F7:  jsr CheckPPUWrite               ;($C2CA)check if data needs to be written to PPU. 
-LC0FA: jsr WritePPUCtrl ;($C44D)Update $2000 & $2001. +LC0FA:  jsr WritePPUCtrl                ;($C44D)Update $2000 & $2001. 
-LC0FD: jsr WriteScroll ;($C29A)Update h/v scroll reg. +LC0FD:  jsr WriteScroll                 ;($C29A)Update h/v scroll reg. 
-LC100: jsr ReadJoyPads ;($C215)Read both joypads. +LC100:  jsr ReadJoyPads                 ;($C215)Read both joypads. 
-LC103:* jsr SoundEngine ;($B3B4)Update music and SFX. +LC103:* jsr SoundEngine                 ;($B3B4)Update music and SFX. 
-LC106: jsr UpdateAge ;($C97E)Update Samus' age. +LC106:  jsr UpdateAge                   ;($C97E)Update Samus' age. 
-LC109: ldy #$01 ; NMI = finished. +LC109:  ldy #$01                        ; NMI = finished. 
-LC10B: sty NMIStatus +LC10B:  sty NMIStatus                   
-LC10D: pla ;Restore Y. +LC10D:  pla                             ;Restore Y. 
-LC10E: tay +LC10E:  tay                             
-LC10F: pla ;Restore X. +LC10F:  pla                             ;Restore X. 
-LC110: tax +LC110:  tax                             
-LC111: pla ;restore A. +LC111:  pla                             ;restore A. 
-LC112: plp ;Restore processor status flags. +LC112:  plp                             ;Restore processor status flags. 
-LC113: rti ;Return from NMI.+LC113:  rti                             ;Return from NMI.
  
 ;----------------------------------------[ GoMainRoutine ]------------------------------------------- ;----------------------------------------[ GoMainRoutine ]-------------------------------------------
Line 246: Line 246:
  
 GoMainRoutine: GoMainRoutine:
-LC114: lda GameMode ;0 if game is running, 1 if at intro screen. +LC114:  lda GameMode                    ;0 if game is running, 1 if at intro screen. 
-LC116: beq + ;Branch if mode=Play. +LC116:  beq +                           ;Branch if mode=Play. 
-LC118: jmp $8000 ;Jump to $8000, where a routine similar to the one--> +LC118:  jmp $8000                       ;Jump to $8000, where a routine similar to the one--> 
- ;below is executed, only using TitleRoutine instead +                                        ;below is executed, only using TitleRoutine instead 
- ;of MainRoutine as index into a jump table. +                                        ;of MainRoutine as index into a jump table. 
-LC11B:* lda Joy1Change +LC11B:* lda Joy1Change                  
-LC11D: and #$10 ;Has START been pressed?--> +LC11D:  and #$10                        ;Has START been pressed?--> 
-LC11F: beq +++ ;if not, execute current routine as normal.+LC11F:  beq +++                         ;if not, execute current routine as normal.
  
-LC121: lda MainRoutine +LC121:  lda MainRoutine                 
-LC123: cmp #$03 ;Is game engine running?--> +LC123:  cmp #$03                        ;Is game engine running?--> 
-LC125: beq + ;If yes, check for routine #5 (pause game). +LC125:  beq +                           ;If yes, check for routine #5 (pause game). 
-LC127: cmp #$05 ;Is game paused?--> +LC127:  cmp #$05                        ;Is game paused?--> 
-LC129: bne +++ ;If not routine #5 either, don't care about START being pressed. +LC129:  bne +++                         ;If not routine #5 either, don't care about START being pressed. 
-LC12B: lda #$03 ;Otherwise, switch to routine #3 (game engine). +LC12B:  lda #$03                        ;Otherwise, switch to routine #3 (game engine). 
-LC12D: bne ++ ;Branch always. +LC12D:  bne ++                          ;Branch always. 
-LC12F:* lda #$05 ;Switch to pause routine. +LC12F:* lda #$05                        ;Switch to pause routine. 
-LC131:* sta MainRoutine ;(MainRoutine = 5 if game paused, 3 if game engine running). +LC131:* sta MainRoutine                 ;(MainRoutine = 5 if game paused, 3 if game engine running). 
-LC133: lda GamePaused +LC133:  lda GamePaused                  
-LC135: eor #$01 ;Toggle game paused. +LC135:  eor #$01                        ;Toggle game paused. 
-LC137: sta GamePaused +LC137:  sta GamePaused                  
-LC139: jsr PauseMusic ;($CB92)Silences music while game paused.+LC139:  jsr PauseMusic                  ;($CB92)Silences music while game paused.
  
-LC13c:* lda MainRoutine +LC13c:* lda MainRoutine                 
-LC13E: jsr ChooseRoutine ;($C27C)Use MainRoutine as index into routine table below.+LC13E:  jsr ChooseRoutine               ;($C27C)Use MainRoutine as index into routine table below.
  
 ;Pointer table to code. ;Pointer table to code.
  
-LC141: .word AreaInit ;($C801)Area init. +LC141:  .word AreaInit                  ;($C801)Area init. 
-LC143: .word MoreInit ;($C81D)More area init. +LC143:  .word MoreInit                  ;($C81D)More area init. 
-LC145: .word SamusInit ;($C8D1)Samus init. +LC145:  .word SamusInit                 ;($C8D1)Samus init. 
-LC147: .word GameEngine   ;($C92B)Game engine. +LC147:  .word GameEngine                ;($C92B)Game engine. 
-LC149: .word GameOver ;($C9A6)Display GAME OVER. +LC149:  .word GameOver                  ;($C9A6)Display GAME OVER. 
-LC14B: .word PauseMode   ;($C9B1)Pause game. +LC14B:  .word PauseMode                 ;($C9B1)Pause game. 
-LC14D: .word GoPassword ;($C9C4)Display password. +LC14D:  .word GoPassword                ;($C9C4)Display password. 
-LC14F: .word IncrementRoutine ;($C155)Just advances to next routine in table. +LC14F:  .word IncrementRoutine          ;($C155)Just advances to next routine in table. 
-LC151: .word SamusIntro   ;($C9D7)Intro. +LC151:  .word SamusIntro                ;($C9D7)Intro. 
-LC153: .word WaitTimer   ;($C494)Delay.+LC153:  .word WaitTimer                 ;($C494)Delay.
  
 IncrementRoutine: IncrementRoutine:
-LC155: inc MainRoutine ;Increment to next routine in above table. +LC155:  inc MainRoutine                 ;Increment to next routine in above table. 
-LC157: rts ;+LC157:  rts                             ;
  
 ;-------------------------------------[ Clear name tables ]------------------------------------------ ;-------------------------------------[ Clear name tables ]------------------------------------------
  
 ClearNameTables: ClearNameTables:
-LC158: jsr ClearNameTable0 ;($C16D)Always clear name table 0 first. +LC158:  jsr ClearNameTable0             ;($C16D)Always clear name table 0 first. 
-LC15B: lda GameMode +LC15B:  lda GameMode                    
-LC15D: beq + ;Branch if mode = Play. +LC15D:  beq +                           ;Branch if mode = Play. 
-LC15F: lda TitleRoutine +LC15F:  lda TitleRoutine                
-LC161: cmp #$1D ;If running the end game routine, clear--> +LC161:  cmp #$1D                        ;If running the end game routine, clear--> 
-LC163: beq ++ ;name table 2, else clear name table 1. +LC163:  beq ++                          ;name table 2, else clear name table 1. 
-LC165:* lda #$02 ;Name table to clear + 1 (name table 1). +LC165:* lda #$02                        ;Name table to clear + 1 (name table 1). 
-LC167: bne +++ ;Branch always. +LC167:  bne +++                         ;Branch always. 
-LC169:* lda #$03 ;Name table to clear + 1 (name table 2). +LC169:* lda #$03                        ;Name table to clear + 1 (name table 2). 
-LC16B: bne ++ ;Branch always.+LC16B:  bne ++                          ;Branch always.
  
 ClearNameTable0: ClearNameTable0:
-LC16D:* lda #$01 ;Name table to clear + 1 (name table 0). +LC16D:* lda #$01                        ;Name table to clear + 1 (name table 0). 
-LC16F:* sta $01 ;Stores name table to clear. +LC16F:* sta $01                         ;Stores name table to clear. 
-LC171: lda #$FF +LC171:  lda #$FF                        
-LC173: sta $00 ;Value to fill with.+LC173:  sta $00                         ;Value to fill with.
  
 ClearNameTable: ClearNameTable:
-LC175: ldx PPUStatus ;Reset PPU address latch. +LC175:  ldx PPUStatus                   ;Reset PPU address latch. 
-LC178: lda PPUCNT0ZP +LC178:  lda PPUCNT0ZP                   
-LC17A: and #$FB ;PPU increment = 1. +LC17A:  and #$FB                        ;PPU increment = 1. 
-LC17C: sta PPUCNT0ZP +LC17C:  sta PPUCNT0ZP                   
-LC17E: sta PPUControl0 ;Store control bits in PPU. +LC17E:  sta PPUControl0                 ;Store control bits in PPU. 
-LC181: ldx $01 +LC181:  ldx $01                         
-LC183: dex ;Name table = X - 1. +LC183:  dex                             ;Name table = X - 1. 
-LC184: lda HiPPUTable,x ;get high PPU address.  pointer table at $C19F. +LC184:  lda HiPPUTable,               ;get high PPU address.  pointer table at $C19F. 
-LC187: sta PPUAddress +LC187:  sta PPUAddress                  
-LC18A: lda #$00 ;Set PPU start address (High byte first). +LC18A:  lda #$00                        ;Set PPU start address (High byte first). 
-LC18C: sta PPUAddress +LC18C:  sta PPUAddress                  
-LC18F: ldx #$04 ;Prepare to loop 4 times. +LC18F:  ldx #$04                        ;Prepare to loop 4 times. 
-LC191: ldy #$00 ;Inner loop value. +LC191:  ldy #$00                        ;Inner loop value. 
-LC193: lda $00 ;Fill-value. +LC193:  lda $00                         ;Fill-value. 
-LC195:* sta PPUIOReg +LC195:* sta PPUIOReg                    
-LC198: dey +LC198:  dey                             
-LC199: bne - ;Loops until the desired name table is cleared.--> +LC199:  bne -                           ;Loops until the desired name table is cleared.--> 
-LC19B: dex ;It also clears the associated attribute table. +LC19B:  dex                             ;It also clears the associated attribute table. 
-LC19C: bne - +LC19C:  bne -                           
-LC19E: rts ;+LC19E:  rts                             ;
  
 ;The following table is used by the above routine for finding ;The following table is used by the above routine for finding
Line 335: Line 335:
  
 HiPPUTable: HiPPUTable:
-LC19F:  .byte $20 ;Name table 0. +LC19F:  .byte $20                       ;Name table 0. 
-LC1A0: .byte $24 ;Name table 1. +LC1A0:  .byte $24                       ;Name table 1. 
-LC1A1: .byte $28 ;Name table 2. +LC1A1:  .byte $28                       ;Name table 2. 
-LC1A2: .byte $2C ;Name table 3.+LC1A2:  .byte $2C                       ;Name table 3.
  
 ;-------------------------------------[ Erase all sprites ]------------------------------------------ ;-------------------------------------[ Erase all sprites ]------------------------------------------
  
 EraseAllSprites: EraseAllSprites:
-LC1A3: ldy #$02 +LC1A3:  ldy #$02                        
-LC1A5: sty $01 ;Loads locations $00 and $01 with --> +LC1A5:  sty $01                         ;Loads locations $00 and $01 with --> 
-LC1A7: ldy #$00 ;#$00 and #$02 respectively +LC1A7:  ldy #$00                        ;#$00 and #$02 respectively 
-LC1A9: sty $00 +LC1A9:  sty $00                         
-LC1AB: ldy #$00 +LC1AB:  ldy #$00                        
-LC1AD: lda #$F0 +LC1AD:  lda #$F0                        
-LC1AF:* sta ($00),y ;Stores #$F0 in memory addresses $0200 thru $02FF. +LC1AF:* sta ($00),                    ;Stores #$F0 in memory addresses $0200 thru $02FF. 
-LC1B1: iny ;  +LC1B1:  iny                             ;  
-LC1B2: bne - ;Loop while more sprite RAM to clear. +LC1B2:  bne -                           ;Loop while more sprite RAM to clear. 
-LC1B4: lda GameMode +LC1B4:  lda GameMode                    
-LC1B6: beq Exit101 ;Exit subroutine if GameMode=Play(#$00) +LC1B6:  beq Exit101                     ;Exit subroutine if GameMode=Play(#$00) 
-LC1B8: jmp DecSpriteYCoord ;($988A)Find proper y coord of sprites.+LC1B8:  jmp DecSpriteYCoord             ;($988A)Find proper y coord of sprites.
  
 Exit101: Exit101:
-LC1BB: rts ;Return used by subroutines above and below.+LC1BB:  rts                             ;Return used by subroutines above and below.
  
 ;---------------------------------------[ Remove intro sprites ]------------------------------------- ;---------------------------------------[ Remove intro sprites ]-------------------------------------
Line 366: Line 366:
  
 RemoveIntroSprites: RemoveIntroSprites:
-LC1BC: ldy #$02 ;Start at address $200. +LC1BC:  ldy #$02                        ;Start at address $200. 
-LC1BE: sty $01 +LC1BE:  sty $01                         
-LC1C0: ldy #$00 +LC1C0:  ldy #$00                        
-LC1C2: sty $00 ;($00) = $0200 (sprite page) +LC1C2:  sty $00                         ;($00) = $0200 (sprite page) 
-LC1C4: ldy #$5F ;Prepare to clear RAM $0200-$025F +LC1C4:  ldy #$5F                        ;Prepare to clear RAM $0200-$025F 
-LC1C6: lda #$F4 +LC1C6:  lda #$F4                        
-LC1C8:* sta ($00),y +LC1C8:* sta ($00),                    
-LC1CA: dey ;Loop unitl $200 thru $25F is filled with #$F4. +LC1CA:  dey                             ;Loop unitl $200 thru $25F is filled with #$F4. 
-LC1CB: bpl - +LC1CB:  bpl -                           
-LC1CD: lda GameMode +LC1CD:  lda GameMode                    
-LC1CF: beq Exit101 ; branch if mode = Play. +LC1CF:  beq Exit101                     ; branch if mode = Play. 
-LC1D1: jmp DecSpriteYCoord ;($988A)Find proper y coord of sprites.+LC1D1:  jmp DecSpriteYCoord             ;($988A)Find proper y coord of sprites.
  
 ;-------------------------------------[Clear RAM $33 thru $DF]--------------------------------------- ;-------------------------------------[Clear RAM $33 thru $DF]---------------------------------------
Line 384: Line 384:
  
 ClearRAM_33_DF: ClearRAM_33_DF:
-LC1D4: ldx #$33 +LC1D4:  ldx #$33                        
-LC1D6: lda #$00 +LC1D6:  lda #$00                        
-LC1D8:* sta $00,x ;Clear RAM addresses $33 through $DF. +LC1D8:* sta $00,x                       ;Clear RAM addresses $33 through $DF. 
-LC1DA: inx +LC1DA:  inx                             
-LC1DB: cpx #$E0 +LC1DB:  cpx #$E0                        
-LC1DD: bcc - ;Loop until all desired addresses are cleared. +LC1DD:  bcc -                           ;Loop until all desired addresses are cleared. 
-LC1DF: rts ;+LC1DF:  rts                             ;
  
 ;--------------------------------[ Check and prepare palette write ]--------------------------------- ;--------------------------------[ Check and prepare palette write ]---------------------------------
  
 CheckPalWrite: CheckPalWrite:
-LC1E0: lda GameMode +LC1E0:  lda GameMode                    
-LC1E2: beq + ;Is game being played? If so, branch to exit. +LC1E2:  beq +                           ;Is game being played? If so, branch to exit. 
-LC1E4: lda TitleRoutine +LC1E4:  lda TitleRoutine                
-LC1E6: cmp #$1D ;Is Game at ending sequence? If not, branch +LC1E6:  cmp #$1D                        ;Is Game at ending sequence? If not, branch 
-LC1E8: bcc + +LC1E8:  bcc +                           
-LC1EA: jmp EndGamePalWrite ;($9F54)Write palette data for ending. +LC1EA:  jmp EndGamePalWrite             ;($9F54)Write palette data for ending. 
-LC1ED:* ldy PalDataPending +LC1ED:* ldy PalDataPending              
-LC1EF: bne ++ ;Is palette data pending? If so, branch. +LC1EF:  bne ++                          ;Is palette data pending? If so, branch. 
-LC1F1: lda GameMode +LC1F1:  lda GameMode                    
-LC1F3: beq +     ;Is game being played? If so, branch to exit. +LC1F3:  beq +                           ;Is game being played? If so, branch to exit. 
-LC1F5: lda TitleRoutine +LC1F5:  lda TitleRoutine                
-LC1F7: cmp #$15 ;Is intro playing? If not, branch. +LC1F7:  cmp #$15                        ;Is intro playing? If not, branch. 
-LC1F9: bcs + +LC1F9:  bcs +                           
-LC1FB: jmp StarPalSwitch ;($8AC7)Cycles palettes for intro stars twinkle. +LC1FB:  jmp StarPalSwitch               ;($8AC7)Cycles palettes for intro stars twinkle. 
-LC1FE:* rts ;Exit when no palette data pending.+LC1FE:* rts                             ;Exit when no palette data pending.
  
 ;Prepare to write palette data to PPU. ;Prepare to write palette data to PPU.
  
-LC1FF:* dey ;Palette # = PalDataPending - 1. +LC1FF:* dey                             ;Palette # = PalDataPending - 1. 
-LC200: tya +LC200:  tya                             
-LC201: asl ;* 2, each pal data ptr is 2 bytes (16-bit). +LC201:  asl                             ;* 2, each pal data ptr is 2 bytes (16-bit). 
-LC202: tay +LC202:  tay                             
-LC203: ldx $9560,y ;X = low byte of PPU data pointer. +LC203:  ldx $9560,                    ;X = low byte of PPU data pointer. 
-LC206: lda $9561,y +LC206:  lda $9561,                    
-LC209: tay ;Y = high byte of PPU data pointer. +LC209:  tay                             ;Y = high byte of PPU data pointer. 
-LC20A: lda #$00 ;Clear A. +LC20A:  lda #$00                        ;Clear A. 
-LC20C: sta PalDataPending ;Reset palette data pending byte.+LC20C:  sta PalDataPending              ;Reset palette data pending byte.
  
 PreparePPUProcess_: PreparePPUProcess_:
-LC20E: stx $00 ;Lower byte of pointer to PPU string. +LC20E:  stx $00                         ;Lower byte of pointer to PPU string. 
-LC210: sty $01 ;Upper byte of pointer to PPU string. +LC210:  sty $01                         ;Upper byte of pointer to PPU string. 
-LC212: jmp ProcessPPUString ;($C30C)Write data string to PPU.+LC212:  jmp ProcessPPUString            ;($C30C)Write data string to PPU.
  
 ;----------------------------------------[Read joy pad status ]-------------------------------------- ;----------------------------------------[Read joy pad status ]--------------------------------------
Line 433: Line 433:
  
 ReadJoyPads: ReadJoyPads:
-LC215: ldx #$00 ;Load x with #$00. Used to read status of joypad 1. +LC215:  ldx #$00                        ;Load x with #$00. Used to read status of joypad 1. 
-LC217: stx $01 +LC217:  stx $01                         
-LC219: jsr ReadOnePad +LC219:  jsr ReadOnePad                  
-LC21C: inx ;Load x with #$01. Used to read status of joypad 2. +LC21C:  inx                             ;Load x with #$01. Used to read status of joypad 2. 
-LC21D: inc $01 ;+LC21D:  inc $01                         ;
  
 ReadOnePad: ReadOnePad:
-LC21F: ldy #$01 ;These lines strobe the -->        +LC21F:  ldy #$01                        ;These lines strobe the -->        
-LC221: sty CPUJoyPad1   ;joystick to enable the --> +LC221:  sty CPUJoyPad1                  ;joystick to enable the --> 
-LC224: dey ;program to read the --> +LC224:  dey                             ;program to read the --> 
-LC225: sty CPUJoyPad1   ;buttons pressed. +LC225:  sty CPUJoyPad1                  ;buttons pressed. 
-  +         
-LC228: ldy #$08 ;Do 8 buttons. +LC228:  ldy #$08                        ;Do 8 buttons. 
-LC22A:* pha ;Store A. +LC22A:* pha                             ;Store A. 
-LC22B: lda CPUJoyPad1,x ;Read button status. Joypad 1 or 2. +LC22B:  lda CPUJoyPad1,               ;Read button status. Joypad 1 or 2. 
-LC22E: sta $00 ;Store button press at location $00. +LC22E:  sta $00                         ;Store button press at location $00. 
-LC230: lsr ;Move button push to carry bit. +LC230:  lsr                             ;Move button push to carry bit. 
-LC231: ora $00 ;If joystick not connected, --> +LC231:  ora $00                         ;If joystick not connected, --> 
-LC233: lsr ;fills Joy1Status with all 1s. +LC233:  lsr                             ;fills Joy1Status with all 1s. 
-LC234: pla ;Restore A. +LC234:  pla                             ;Restore A. 
-LC235: rol ;Add button press status to A. +LC235:  rol                             ;Add button press status to A. 
-LC236: dey     ;Loop 8 times to get --> +LC236:  dey                             ;Loop 8 times to get --> 
-LC237: bne - ;status of all 8 buttons.+LC237:  bne -                           ;status of all 8 buttons.
  
-LC239: ldx $01 ;Joypad #(0 or 1). +LC239:  ldx $01                         ;Joypad #(0 or 1). 
-LC23B: ldy Joy1Status,x ;Get joypad status of previous refresh. +LC23B:  ldy Joy1Status,               ;Get joypad status of previous refresh. 
-LC23D: sty $00 ;Store at $00. +LC23D:  sty $00                         ;Store at $00. 
-LC23F: sta Joy1Status,x ;Store current joypad status. +LC23F:  sta Joy1Status,               ;Store current joypad status. 
-LC241: eor $00 +LC241:  eor $00                         
-LC243: beq +     ;Branch if no buttons changed. +LC243:  beq +                           ;Branch if no buttons changed. 
-LC245: lda $00 ;  +LC245:  lda $00                                                
-LC247: and #$BF ;Remove the previous status of the B button. +LC247:  and #$BF                        ;Remove the previous status of the B button. 
-LC249: sta $00 +LC249:  sta $00                         
-LC24B: eor Joy1Status,x +LC24B:  eor Joy1Status,               
-LC24D:* and Joy1Status,x ;Save any button changes from the current frame--> +LC24D:* and Joy1Status,               ;Save any button changes from the current frame--> 
-LC24F: sta Joy1Change,x ;and the last frame to the joy change addresses. +LC24F:  sta Joy1Change,               ;and the last frame to the joy change addresses. 
-LC251: sta Joy1Retrig,x ;Store any changed buttons in JoyRetrig address. +LC251:  sta Joy1Retrig,               ;Store any changed buttons in JoyRetrig address. 
-LC253: ldy #$20 +LC253:  ldy #$20                        
-LC255: lda Joy1Status,x ;Checks to see if same buttons are being--> +LC255:  lda Joy1Status,               ;Checks to see if same buttons are being--> 
-LC257: cmp $00 ;pressed this frame as last frame.--> +LC257:  cmp $00                         ;pressed this frame as last frame.--> 
-LC259: bne + ;If none, branch. +LC259:  bne +                           ;If none, branch. 
-LC25B: dec RetrigDelay1,x ;Decrement RetrigDelay if same buttons pressed. +LC25B:  dec RetrigDelay1,             ;Decrement RetrigDelay if same buttons pressed. 
-LC25D: bne ++ ;  +LC25D:  bne ++                                         
-LC25F: sta Joy1Retrig,x ;Once RetrigDelay=#$00, store buttons to retrigger. +LC25F:  sta Joy1Retrig,               ;Once RetrigDelay=#$00, store buttons to retrigger. 
-LC261: ldy #$08 +LC261:  ldy #$08                        
-LC263:* sty RetrigDelay1,x ;Reset retrigger delay to #$20(32 frames)--> +LC263:* sty RetrigDelay1,             ;Reset retrigger delay to #$20(32 frames)--> 
-LC265:* rts ;or #$08(8 frames) if already retriggering.+LC265:* rts                             ;or #$08(8 frames) if already retriggering.
  
 ;-------------------------------------------[ Update timer ]----------------------------------------- ;-------------------------------------------[ Update timer ]-----------------------------------------
Line 492: Line 492:
  
 UpdateTimer: UpdateTimer:
-LC266: ldx #$01 ;First timer to decrement is Timer2. +LC266:  ldx #$01                        ;First timer to decrement is Timer2. 
-LC268: dec TimerDelay +LC268:  dec TimerDelay                  
-LC26A: bpl DecTimer +LC26A:  bpl DecTimer                    
-LC26C: lda #$09 ;TimerDelay hits #$00 every 10th frame. +LC26C:  lda #$09                        ;TimerDelay hits #$00 every 10th frame. 
-LC26E: sta TimerDelay ;Reset TimerDelay after it hits #$00. +LC26E:  sta TimerDelay                  ;Reset TimerDelay after it hits #$00. 
-LC270: ldx #$02 ;Decrement Timer3 every 10 frames.+LC270:  ldx #$02                        ;Decrement Timer3 every 10 frames.
  
 DecTimer: DecTimer:
-LC272: lda Timer1,x +LC272:  lda Timer1,                   
-LC274: beq + ;Don't decrease if timer is already zero. +LC274:  beq +                           ;Don't decrease if timer is already zero. 
-LC276: dec Timer1,x +LC276:  dec Timer1,                   
-LC278:* dex ;Timer1 and Timer2 decremented every frame. +LC278:* dex                             ;Timer1 and Timer2 decremented every frame. 
-LC279: bpl DecTimer +LC279:  bpl DecTimer                    
-LC27B: rts ;+LC27B:  rts                             ;
  
 ;-----------------------------------------[ Choose routine ]----------------------------------------- ;-----------------------------------------[ Choose routine ]-----------------------------------------
Line 515: Line 515:
  
 ChooseRoutine: ChooseRoutine:
-LC27C: asl ;* 2, each ptr is 2 bytes (16-bit). +LC27C:  asl                             ;* 2, each ptr is 2 bytes (16-bit). 
-LC27D: sty TempY ;Temp storage. +LC27D:  sty TempY                       ;Temp storage. 
-LC27F: stx TempX ;Temp storage. +LC27F:  stx TempX                       ;Temp storage. 
-LC281: tay +LC281:  tay                             
-LC282: iny +LC282:  iny                             
-LC283: pla ;Low byte of ptr table address. +LC283:  pla                             ;Low byte of ptr table address. 
-LC284: sta CodePtr +LC284:  sta CodePtr                     
-LC286: pla ;High byte of ptr table address. +LC286:  pla                             ;High byte of ptr table address. 
-LC287: sta CodePtr+1 +LC287:  sta CodePtr+1                   
-LC289: lda (CodePtr),y ;Low byte of code ptr. +LC289:  lda (CodePtr),                ;Low byte of code ptr. 
-LC28B: tax +LC28B:  tax                             
-LC28C: iny +LC28C:  iny                             
-LC28D: lda (CodePtr),y ;High byte of code ptr. +LC28D:  lda (CodePtr),                ;High byte of code ptr. 
-LC28F: sta CodePtr+1 +LC28F:  sta CodePtr+1                   
-LC291: stx CodePtr +LC291:  stx CodePtr                     
-LC293: ldx TempX ;Restore X. +LC293:  ldx TempX                       ;Restore X. 
-LC295: ldy TempY ;Restore Y. +LC295:  ldy TempY                       ;Restore Y. 
-LC297: jmp (CodePtr) ;+LC297:  jmp (CodePtr)                   ;
  
 ;--------------------------------------[ Write to scroll registers ]--------------------------------- ;--------------------------------------[ Write to scroll registers ]---------------------------------
  
 WriteScroll: WriteScroll:
-LC29A: lda PPUStatus ;Reset scroll register flip/flop +LC29A:  lda PPUStatus                   ;Reset scroll register flip/flop 
-LC29D: lda ScrollX +LC29D:  lda ScrollX                     
-LC29F: sta PPUScroll +LC29F:  sta PPUScroll                   
-LC2A2: lda ScrollY ;X and Y scroll offsets are loaded serially. +LC2A2:  lda ScrollY                     ;X and Y scroll offsets are loaded serially. 
-LC2A4: sta PPUScroll +LC2A4:  sta PPUScroll                   
-LC2A7: rts ;+LC2A7:  rts                             ;
  
 ;----------------------------------[ Add y index to stored addresses ]------------------------------- ;----------------------------------[ Add y index to stored addresses ]-------------------------------
Line 549: Line 549:
  
 AddYToPtr00: AddYToPtr00:
-LC2A8: tya +LC2A8:  tya                             
-LC2A9: clc ;Add value stored in Y to lower address--> +LC2A9:  clc                             ;Add value stored in Y to lower address--> 
-LC2AA: adc $00 ;byte stored in $00. +LC2AA:  adc $00                         ;byte stored in $00. 
-LC2AC: sta $00 +LC2AC:  sta $00                         
-LC2AE: bcc + ;Increment $01(upper address byte) if carry--> +LC2AE:  bcc +                           ;Increment $01(upper address byte) if carry--> 
-LC2B0: inc $01 ;has occurred. +LC2B0:  inc $01                         ;has occurred. 
-LC2B2:* rts ;+LC2B2:* rts                             ;
  
 ;Add Y to pointer at $0002 ;Add Y to pointer at $0002
  
 AddYToPtr02: AddYToPtr02:
-LC2B3: tya +LC2B3:  tya                             
-LC2B4: clc ;Add value stored in Y to lower address--> +LC2B4:  clc                             ;Add value stored in Y to lower address--> 
-LC2B5: adc $02 ;byte stored in $02. +LC2B5:  adc $02                         ;byte stored in $02. 
-LC2B7: sta $02 +LC2B7:  sta $02                         
-LC2B9: bcc + ;Increment $01(upper address byte) if carry--> +LC2B9:  bcc +                           ;Increment $01(upper address byte) if carry--> 
-LC2BB: inc $03 ;has occurred. +LC2BB:  inc $03                         ;has occurred. 
-LC2BD:* rts ;+LC2BD:* rts                             ;
  
 ;--------------------------------[ Simple divide and multiply routines ]----------------------------- ;--------------------------------[ Simple divide and multiply routines ]-----------------------------
  
 Adiv32:  Adiv32: 
-LC2BE: lsr ;Divide by 32.+LC2BE:  lsr                             ;Divide by 32.
  
 Adiv16:  Adiv16: 
-LC2BF: lsr ;Divide by 16.+LC2BF:  lsr                             ;Divide by 16.
  
 Adiv8:   Adiv8:  
-LC2C0: lsr ;Divide by 8. +LC2C0:  lsr                             ;Divide by 8. 
-LC2C1: lsr +LC2C1:  lsr                             
-LC2C2: lsr ;Divide by shifting A right. +LC2C2:  lsr                             ;Divide by shifting A right. 
-LC2C3: rts ;+LC2C3:  rts                             ;
  
 Amul32:  Amul32: 
-LC2C4: asl ;Multiply by 32.+LC2C4:  asl                             ;Multiply by 32.
  
 Amul16:  Amul16: 
-LC2C5: asl ;Multiply by 16.+LC2C5:  asl                             ;Multiply by 16.
  
 Amul8: Amul8:
-LC2C6: asl ;Multiply by 8. +LC2C6:  asl                             ;Multiply by 8. 
-LC2C7: asl +LC2C7:  asl                             
-LC2C8: asl ;Multiply by shifting A left. +LC2C8:  asl                             ;Multiply by shifting A left. 
-LC2C9: rts ;+LC2C9:  rts                             ;
  
 ;-------------------------------------[ PPU writing routines ]--------------------------------------- ;-------------------------------------[ PPU writing routines ]---------------------------------------
Line 600: Line 600:
  
 CheckPPUWrite: CheckPPUWrite:
-LC2CA: lda PPUDataPending +LC2CA:  lda PPUDataPending              
-LC2CC: beq +     ;If zero no PPU data to write, branch to exit. +LC2CC:  beq +                           ;If zero no PPU data to write, branch to exit. 
-LC2CE: lda #$A1 ;  +LC2CE:  lda #$A1                                               
-LC2D0: sta $00 ;Sets up PPU writer to start at address $07A1. +LC2D0:  sta $00                         ;Sets up PPU writer to start at address $07A1. 
-LC2D2: lda #$07 +LC2D2:  lda #$07                        
-LC2D4: sta $01   ;$0000 = ptr to PPU data string ($07A1). +LC2D4:  sta $01                         ;$0000 = ptr to PPU data string ($07A1). 
-LC2D6: jsr ProcessPPUString     ;($C30C)write it to PPU. +LC2D6:  jsr ProcessPPUString            ;($C30C)write it to PPU. 
-LC2D9: lda #$00 +LC2D9:  lda #$00                        
-LC2DB: sta PPUStrIndex ;PPU data string has been written so the data--> +LC2DB:  sta PPUStrIndex                 ;PPU data string has been written so the data--> 
-LC2DE: sta PPUDataString ;stored for the write is now erased. +LC2DE:  sta PPUDataString               ;stored for the write is now erased. 
-LC2E1: sta PPUDataPending +LC2E1:  sta PPUDataPending              
-LC2E3:* rts ;+LC2E3:* rts                             ;
  
 PPUWrite: PPUWrite:
-LC2E4: sta PPUAddress ;Set high PPU address. +LC2E4:  sta PPUAddress                  ;Set high PPU address. 
-LC2E7: iny +LC2E7:  iny                             
-LC2E8: lda ($00),y +LC2E8:  lda ($00),                    
-LC2EA: sta PPUAddress ;Set low PPU address. +LC2EA:  sta PPUAddress                  ;Set low PPU address. 
-LC2ED: iny +LC2ED:  iny                             
-LC2EE: lda ($00),y ;Get data byte containing rep length & RLE status. +LC2EE:  lda ($00),                    ;Get data byte containing rep length & RLE status. 
-LC2F0: asl ;Carry Flag = PPU address increment (0 = 1, 1 = 32). +LC2F0:  asl                             ;Carry Flag = PPU address increment (0 = 1, 1 = 32). 
-LC2F1: jsr SetPPUInc ;($C318)Update PPUCtrl0 according to Carry Flag. +LC2F1:  jsr SetPPUInc                   ;($C318)Update PPUCtrl0 according to Carry Flag. 
-LC2F4: asl ;Carry Flag = bit 6 of byte at ($00),y (1 = RLE). +LC2F4:  asl                             ;Carry Flag = bit 6 of byte at ($00),y (1 = RLE). 
-LC2F5: lda ($00),y ;Get data byte again. +LC2F5:  lda ($00),                    ;Get data byte again. 
-LC2F7: and #$3F ;Keep lower 6 bits as loop counter. +LC2F7:  and #$3F                        ;Keep lower 6 bits as loop counter. 
-LC2F9: tax +LC2F9:  tax                             
-LC2FA: bcc PPUWriteLoop ;If Carry Flag not set, the data is not RLE. +LC2FA:  bcc PPUWriteLoop                ;If Carry Flag not set, the data is not RLE. 
-LC2FC: iny ;Data is RLE, advance to data byte.+LC2FC:  iny                             ;Data is RLE, advance to data byte.
  
 PPUWriteLoop: PPUWriteLoop:
-LC2FD: bcs + +LC2FD:  bcs +                           
-LC2FF: iny ;Only inc Y if data is not RLE. +LC2FF:  iny                             ;Only inc Y if data is not RLE. 
-LC300:* lda ($00),y ;Get data byte. +LC300:* lda ($00),                    ;Get data byte. 
-LC302: sta PPUIOReg ;Write to PPU. +LC302:  sta PPUIOReg                    ;Write to PPU. 
-LC305: dex ;Decrease loop counter. +LC305:  dex                             ;Decrease loop counter. 
-LC306: bne PPUWriteLoop ;Keep going until X=0. +LC306:  bne PPUWriteLoop                ;Keep going until X=0. 
-LC308: iny +LC308:  iny                             
-LC309: jsr AddYToPtr00 ;($C2A8)Point to next data chunk.+LC309:  jsr AddYToPtr00                 ;($C2A8)Point to next data chunk.
  
 ;Write data string at ($00) to PPU. ;Write data string at ($00) to PPU.
  
 ProcessPPUString: ProcessPPUString:
-LC30C: ldx PPUStatus ;Reset PPU address flip/flop. +LC30C:  ldx PPUStatus                   ;Reset PPU address flip/flop. 
-LC30F: ldy #$00 +LC30F:  ldy #$00                        
-LC311: lda ($00),y +LC311:  lda ($00),                    
-LC313: bne PPUWrite ;If A is non-zero, PPU data string follows,--> +LC313:  bne PPUWrite                    ;If A is non-zero, PPU data string follows,--> 
-LC315: jmp WriteScroll ;($C29A)Otherwise we're done.+LC315:  jmp WriteScroll                 ;($C29A)Otherwise we're done.
  
 ;In: CF = desired PPU address increment (0 = 1, 1 = 32). ;In: CF = desired PPU address increment (0 = 1, 1 = 32).
Line 652: Line 652:
  
 SetPPUInc: SetPPUInc:
-LC318: pha ;Preserve A. +LC318:  pha                             ;Preserve A. 
-LC319: lda PPUCNT0ZP +LC319:  lda PPUCNT0ZP                   
-LC31B: ora #$04 +LC31B:  ora #$04                        
-LC31D: bcs + ;PPU increment = 32 only if Carry Flag set,--> +LC31D:  bcs +                           ;PPU increment = 32 only if Carry Flag set,--> 
-LC31F: and #$FB ;else PPU increment = 1. +LC31F:  and #$FB                        ;else PPU increment = 1. 
-LC321:* sta PPUControl0 +LC321:* sta PPUControl0                 
-LC323: sta PPUCNT0ZP +LC323:  sta PPUCNT0ZP                   
-LC326: pla ;Restore A. +LC326:  pla                             ;Restore A. 
-LC327: rts ;+LC327:  rts                             ;
  
 ;Erase blasted tile on nametable.  Each screen is 16 tiles across and 15 tiles down. ;Erase blasted tile on nametable.  Each screen is 16 tiles across and 15 tiles down.
 EraseTile: EraseTile:
-LC328: ldy #$01 +LC328:  ldy #$01                        
-LC32A: sty PPUDataPending ;data pending = YES. +LC32A:  sty PPUDataPending              ;data pending = YES. 
-LC32C: dey +LC32C:  dey                             
-LC32D: lda ($02),y +LC32D:  lda ($02),                    
-LC32F: and #$0F +LC32F:  and #$0F                        
-LC331: sta $05 ;# of tiles horizontally. +LC331:  sta $05                         ;# of tiles horizontally. 
-LC333: lda ($02),y +LC333:  lda ($02),                    
-LC335: jsr Adiv16 ;($C2BF)/ 16. +LC335:  jsr Adiv16                      ;($C2BF)/ 16. 
-LC338: sta $04 ;# of tiles vertically. +LC338:  sta $04                         ;# of tiles vertically. 
-LC33A: ldx PPUStrIndex +LC33A:  ldx PPUStrIndex                 
-LC33D:* lda $01 +LC33D:* lda $01                         
-LC33F: jsr WritePPUByte ;($C36B)write PPU high address to $07A1,PPUStrIndex. +LC33F:  jsr WritePPUByte                ;($C36B)write PPU high address to $07A1,PPUStrIndex. 
-LC342: lda $00 +LC342:  lda $00                         
-LC344: jsr WritePPUByte ;($C36B)write PPU low address to $07A1,PPUStrIndex. +LC344:  jsr WritePPUByte                ;($C36B)write PPU low address to $07A1,PPUStrIndex. 
-LC347: lda $05 ;data length. +LC347:  lda $05                         ;data length. 
-LC349: sta $06 +LC349:  sta $06                         
-LC34B: jsr WritePPUByte ;($C36B)write PPU string length to $07A1,PPUStrIndex. +LC34B:  jsr WritePPUByte                ;($C36B)write PPU string length to $07A1,PPUStrIndex. 
-LC34E:* iny +LC34E:* iny                             
-LC34F: lda ($02),y ;Get new tile to replace old tile. +LC34F:  lda ($02),                    ;Get new tile to replace old tile. 
-LC351: jsr WritePPUByte ;($C36B)Write it to $07A1,PPUStrIndex, inc x. +LC351:  jsr WritePPUByte                ;($C36B)Write it to $07A1,PPUStrIndex, inc x. 
-LC354: dec $06 +LC354:  dec $06                         
-LC356: bne - ;Branch if more horizontal tiles to replace. +LC356:  bne -                           ;Branch if more horizontal tiles to replace. 
-LC358: stx PPUStrIndex +LC358:  stx PPUStrIndex                 
-LC35B: sty $06 +LC35B:  sty $06                         
-LC35D: ldy #$20 +LC35D:  ldy #$20                        
-LC35F: jsr AddYToPtr00 ;($C2A8)Move to next name table line. +LC35F:  jsr AddYToPtr00                 ;($C2A8)Move to next name table line. 
-LC362: ldy $06 ;Store index to find next tile info. +LC362:  ldy $06                         ;Store index to find next tile info. 
-LC364: dec $04 +LC364:  dec $04                         
-LC366: bne -- ;Branch if more lines need to be changed on name table. +LC366:  bne --                          ;Branch if more lines need to be changed on name table. 
-LC368: jsr EndPPUString ;($c376)Finish writing PPU string and exit.+LC368:  jsr EndPPUString                ;($c376)Finish writing PPU string and exit.
  
 WritePPUByte: WritePPUByte:
-LC36B: sta PPUDataString,x ;Store data byte at end of PPUDataString.+LC36B:  sta PPUDataString,            ;Store data byte at end of PPUDataString.
  
 NextPPUByte: NextPPUByte:
-LC36E: inx ;PPUDataString has increased in size by 1 byte. +LC36E:  inx                             ;PPUDataString has increased in size by 1 byte. 
-LC36F: cpx #$4F ;PPU byte writer can only write a maximum of #$4F bytes +LC36F:  cpx #$4F                        ;PPU byte writer can only write a maximum of #$4F bytes 
-LC371: bcc + ;If PPU string not full, branch to get more data. +LC371:  bcc +                           ;If PPU string not full, branch to get more data. 
-LC373: ldx PPUStrIndex ;+LC373:  ldx PPUStrIndex                 ;
  
 EndPPUString: EndPPUString:
-LC376: lda #$00 ;If PPU string is already full, or all PPU bytes loaded,--> +LC376:  lda #$00                        ;If PPU string is already full, or all PPU bytes loaded,--> 
-LC378: sta PPUDataString,x ;add #$00 as last byte to the PPU byte string. +LC378:  sta PPUDataString,            ;add #$00 as last byte to the PPU byte string. 
-LC37B: pla +LC37B:  pla                             
-LC37C: pla ;Remove last return address from stack and jump out of--> +LC37C:  pla                             ;Remove last return address from stack and jump out of--> 
-LC37D:* rts ;PPU writing routines.+LC37D:* rts                             ;PPU writing routines.
  
 ;The following routine is only used by the intro routine to load the sprite  ;The following routine is only used by the intro routine to load the sprite 
Line 718: Line 718:
  
 PrepPPUPaletteString: PrepPPUPaletteString:
-LC37E: ldy #$01 +LC37E:  ldy #$01                        
-LC380: sty PPUDataPending ;Indicate data waiting to be written to PPU. +LC380:  sty PPUDataPending              ;Indicate data waiting to be written to PPU. 
-LC382: dey +LC382:  dey                             
-LC383: beq ++++ ;Branch always+LC383:  beq ++++                        ;Branch always
  
-LC385:* sta $04 ;$04 now contains next data byte to be put into the PPU string. +LC385:* sta $04                         ;$04 now contains next data byte to be put into the PPU string. 
-LC387: lda $01 ;High byte of staring address to write PPU data  +LC387:  lda $01                         ;High byte of staring address to write PPU data  
-LC389: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +LC389:  jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
-LC38c: lda $00 ;Low byte of starting address to write PPU data. +LC38c:  lda $00                         ;Low byte of starting address to write PPU data. 
-LC38E: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +LC38E:  jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
-LC391: lda $04 ;A now contains next data byte to be put into the PPU string. +LC391:  lda $04                         ;A now contains next data byte to be put into the PPU string. 
-LC393: jsr SeparateControlBits ;($C3C6)Break control byte into two bytes.+LC393:  jsr SeparateControlBits         ;($C3C6)Break control byte into two bytes.
  
-LC396: bit $04 ;Check to see if RLE bit is set in control byte.--> +LC396:  bit $04                         ;Check to see if RLE bit is set in control byte.--> 
-LC398: bvc WritePaletteStringByte ;If not set, branch to load byte. Else increment index--> +LC398:  bvc WritePaletteStringByte      ;If not set, branch to load byte. Else increment index--> 
-LC39A: iny ;to find repeating data byte.+LC39A:  iny                             ;to find repeating data byte.
  
 WritePaletteStringByte: WritePaletteStringByte:
-LC39B: bit $04 ;Check if RLE bit is set (again). if set, load same--> +LC39B:  bit $04                         ;Check if RLE bit is set (again). if set, load same--> 
-LC39D: bvs + ;byte over and over again until counter = #$00. +LC39D:  bvs +                           ;byte over and over again until counter = #$00. 
-LC39F: iny ;Non-repeating data byte. Increment for next byte. +LC39F:  iny                             ;Non-repeating data byte. Increment for next byte. 
-LC3A0:* lda ($02),y +LC3A0:* lda ($02),                    
-LC3A2: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +LC3A2:  jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
-LC3A5: sty $06 ;Temporarily store data index. +LC3A5:  sty $06                         ;Temporarily store data index. 
-LC3A7: ldy #$01 ;PPU address increment = 1. +LC3A7:  ldy #$01                        ;PPU address increment = 1. 
-LC3A9: bit $04 ;If MSB set in control bit, it looks like this routine might--> +LC3A9:  bit $04                         ;If MSB set in control bit, it looks like this routine might--> 
-LC3AB: bpl + ;have been used for a software control verticle mirror, but--> +LC3AB:  bpl +                           ;have been used for a software control verticle mirror, but--> 
- ;the starting address has already been written to the PPU--> +                                        ;the starting address has already been written to the PPU--> 
- ;string so this section has no effect whether the MSB is set--> +                                        ;string so this section has no effect whether the MSB is set--> 
- ;or not. The PPU is always incremented by 1. +                                        ;or not. The PPU is always incremented by 1. 
-LC3AD: ldy #$20 ;PPU address increment = 32. +LC3AD:  ldy #$20                        ;PPU address increment = 32. 
-LC3AF:* jsr AddYToPtr00 ;($C2A8)Set next PPU write address.(Does nothing, already set). +LC3AF:* jsr AddYToPtr00                 ;($C2A8)Set next PPU write address.(Does nothing, already set). 
-LC3B2: ldy $06 ;Restore data index to Y. +LC3B2:  ldy $06                         ;Restore data index to Y. 
-LC3B4: dec $05 ;Decrement counter byte. +LC3B4:  dec $05                         ;Decrement counter byte. 
-LC3B6: bne WritePaletteStringByte ;If more bytes to write, branch to write another byte. +LC3B6:  bne WritePaletteStringByte      ;If more bytes to write, branch to write another byte. 
-LC3B8: stx PPUStrIndex ;Store total length, in bytes, of PPUDataString. +LC3B8:  stx PPUStrIndex                 ;Store total length, in bytes, of PPUDataString. 
-LC3BB: iny ;Move to next data byte(should be #$00).+LC3BB:  iny                             ;Move to next data byte(should be #$00).
  
-LC3BC:* ldx PPUStrIndex ;X now contains current length of PPU data string. +LC3BC:* ldx PPUStrIndex                 ;X now contains current length of PPU data string. 
-LC3BF: lda ($02),y +LC3BF:  lda ($02),                    
-LC3C1: bne ---- ;Is PPU string done loading (#$00)? If so exit,--> +LC3C1:  bne ----                        ;Is PPU string done loading (#$00)? If so exit,--> 
-LC3C3: jsr EndPPUString ;($C376)else branch to process PPU byte.+LC3C3:  jsr EndPPUString                ;($C376)else branch to process PPU byte.
  
 SeparateControlBits: SeparateControlBits:
-LC3C6: sta $04 ;Store current byte  +LC3C6:  sta $04                         ;Store current byte  
-LC3C8: and #$BF +LC3C8:  and #$BF                        
-LC3CA: sta PPUDataString,x ;Remove RLE bit and save control bit in PPUDataString. +LC3CA:  sta PPUDataString,            ;Remove RLE bit and save control bit in PPUDataString. 
-LC3CD: and #$3F +LC3CD:  and #$3F                        
-LC3CF: sta $05 ;Extract counter bits and save them for use above. +LC3CF:  sta $05                         ;Extract counter bits and save them for use above. 
-LC3D1: jmp NextPPUByte ;($C36E)+LC3D1:  jmp NextPPUByte                 ;($C36E)
  
 ;----------------------------------------[ Math routines ]------------------------------------------- ;----------------------------------------[ Math routines ]-------------------------------------------
  
 TwosCompliment: TwosCompliment:
-LC3D4: eor #$FF +LC3D4:  eor #$FF                        
-LC3D6: clc ;Generate twos compliment of value stored in A. +LC3D6:  clc                             ;Generate twos compliment of value stored in A. 
-LC3D7: adc #$01 +LC3D7:  adc #$01                        
-LC3D9: rts ;+LC3D9:  rts                             ;
  
 ;The following two routines add a Binary coded decimal (BCD) number to another BCD number. ;The following two routines add a Binary coded decimal (BCD) number to another BCD number.
Line 783: Line 783:
  
 Base10Add: Base10Add:
-LC3DA: jsr ExtractNibbles ;($C41D)Separate upper 4 bits and lower 4 bits. +LC3DA:  jsr ExtractNibbles              ;($C41D)Separate upper 4 bits and lower 4 bits. 
-LC3DD: adc $01 ;Add lower nibble to number. +LC3DD:  adc $01                         ;Add lower nibble to number. 
-LC3DF: cmp #$0A +LC3DF:  cmp #$0A                        
-LC3E1: bcc + ;If result is greater than 9, add 5 to create--> +LC3E1:  bcc +                           ;If result is greater than 9, add 5 to create--> 
-LC3E3: adc #$05 ;valid result(skip #$0A thru #$0F). +LC3E3:  adc #$05                        ;valid result(skip #$0A thru #$0F). 
-LC3E5:* clc +LC3E5:* clc                             
-LC3E6: adc $02 ;Add upper nibble to number. +LC3E6:  adc $02                         ;Add upper nibble to number. 
-LC3E8: sta $02 +LC3E8:  sta $02                         
-LC3EA: lda $03 +LC3EA:  lda $03                         
-LC3EC: and #$F0 ;Keep upper 4 bits of HealthLo/HealthHi in A. +LC3EC:  and #$F0                        ;Keep upper 4 bits of HealthLo/HealthHi in A. 
-LC3EE: adc $02 +LC3EE:  adc $02                         
-LC3F0: bcc ++ +LC3F0:  bcc ++                          
-LC3F2:* adc #$5F ;If upper result caused a carry, add #$5F to create--> +LC3F2:* adc #$5F                        ;If upper result caused a carry, add #$5F to create--> 
-LC3F4: sec ;valid result. Set carry indicating carry to next digit. +LC3F4:  sec                             ;valid result. Set carry indicating carry to next digit. 
-LC3F5: rts +LC3F5:  rts                             
-LC3F6:* cmp #$A0 ;If result of upper nibble add is greater than #$90,--> +LC3F6:* cmp #$A0                        ;If result of upper nibble add is greater than #$90,--> 
-LC3F8: bcs -- ;Branch to add #$5F to create valid result. +LC3F8:  bcs --                          ;Branch to add #$5F to create valid result. 
-LC3FA: rts ;+LC3FA:  rts                             ;
  
 Base10Subtract: Base10Subtract:
-LC3FB: jsr ExtractNibbles ;($C41D)Separate upper 4 bits and lower 4 bits. +LC3FB:  jsr ExtractNibbles              ;($C41D)Separate upper 4 bits and lower 4 bits. 
-LC3FE: sbc $01 ;Subtract lower nibble from number. +LC3FE:  sbc $01                         ;Subtract lower nibble from number. 
-LC400: sta $01 +LC400:  sta $01                         
-LC402: bcs + ;If result is less than zero, add 10 to create--> +LC402:  bcs +                           ;If result is less than zero, add 10 to create--> 
-LC404: adc #$0A ;valid result. +LC404:  adc #$0A                        ;valid result. 
-LC406: sta $01 +LC406:  sta $01                         
-LC408: lda $02 +LC408:  lda $02                         
-LC40A: adc #$0F ;Adjust $02 to account for borrowing. +LC40A:  adc #$0F                        ;Adjust $02 to account for borrowing. 
-LC40C: sta $02 +LC40C:  sta $02                         
-LC40E:* lda $03 ;Keep upper 4 bits of HealthLo/HealthHi in A. +LC40E:* lda $03                         ;Keep upper 4 bits of HealthLo/HealthHi in A. 
-LC410: and #$F0 +LC410:  and #$F0                        
-LC412: sec +LC412:  sec                             
-LC413: sbc $02 ;If result is greater than zero, branch to finish. +LC413:  sbc $02                         ;If result is greater than zero, branch to finish. 
-LC415: bcs + +LC415:  bcs +                           
-LC417: adc #$A0 ;Add 10 to create valid result. +LC417:  adc #$A0                        ;Add 10 to create valid result. 
-LC419: clc +LC419:  clc                             
-LC41A:* ora $01 ;Combine A and $01 to create final value. +LC41A:* ora $01                         ;Combine A and $01 to create final value. 
-LC41C: rts ;+LC41C:  rts                             ;
  
 ExtractNibbles: ExtractNibbles:
-LC41D: pha +LC41D:  pha                             
-LC41E: and #$0F ;Lower 4 bits of value to change HealthLo/HealthHi by. +LC41E:  and #$0F                        ;Lower 4 bits of value to change HealthLo/HealthHi by. 
-LC420: sta $01 +LC420:  sta $01                         
-LC422: pla +LC422:  pla                             
-LC423: and #$F0 ;Upper 4 bits of value to change HealthLo/HealthHi by. +LC423:  and #$F0                        ;Upper 4 bits of value to change HealthLo/HealthHi by. 
-LC425: sta $02 +LC425:  sta $02                         
-LC427: lda $03 +LC427:  lda $03                         
-LC429: and #$0F ;Keep lower 4 bits of HealthLo/HealthHi in A. +LC429:  and #$0F                        ;Keep lower 4 bits of HealthLo/HealthHi in A. 
-LC42B: rts ;+LC42B:  rts                             ;
  
 ;---------------------------[ NMI and PPU control routines ]-------------------------------- ;---------------------------[ NMI and PPU control routines ]--------------------------------
Line 838: Line 838:
  
 WaitNMIPass:     WaitNMIPass:    
-LC42C: jsr ClearNMIStat ;($C434)Indicate currently in NMI. +LC42C:  jsr ClearNMIStat                ;($C434)Indicate currently in NMI. 
-LC42F:* lda NMIStatus +LC42F:* lda NMIStatus                   
-LC431: beq - ;Wait for NMI to end. +LC431:  beq -                           ;Wait for NMI to end. 
-LC433: rts ;+LC433:  rts                             ;
  
 ClearNMIStat: ClearNMIStat:
-LC434: lda #$00 ;Clear NMI byte to indicate the game is--> +LC434:  lda #$00                        ;Clear NMI byte to indicate the game is--> 
-LC436: sta NMIStatus ;currently running NMI routines. +LC436:  sta NMIStatus                   ;currently running NMI routines. 
-LC438: rts ;+LC438:  rts                             ;
  
 ScreenOff: ScreenOff:
-LC439: lda PPUCNT1ZP +LC439:  lda PPUCNT1ZP                   
-LC43B: and #$E7 ; BG & SPR visibility = off+LC43B:  and #$E7                        ; BG & SPR visibility = off
  
 WriteAndWait: WriteAndWait:
-LC43D:* sta PPUCNT1ZP ;Update value to be loaded into PPU control register.+LC43D:* sta PPUCNT1ZP                   ;Update value to be loaded into PPU control register.
  
 WaitNMIPass_: WaitNMIPass_:
-LC43F: jsr ClearNMIStat ;($C434)Indicate currently in NMI. +LC43F:  jsr ClearNMIStat                ;($C434)Indicate currently in NMI. 
-LC442:* lda NMIStatus +LC442:* lda NMIStatus                   
-LC444: beq - ;Wait for NMI to end before continuing. +LC444:  beq -                           ;Wait for NMI to end before continuing. 
-LC446: rts ;+LC446:  rts                             ;
  
 ScreenOn: ScreenOn:
-LC447: lda PPUCNT1ZP +LC447:  lda PPUCNT1ZP                   
-LC449: ora #$1E ;BG & SPR visibility = on +LC449:  ora #$1E                        ;BG & SPR visibility = on 
-LC44B: bne -- ;Branch always+LC44B:  bne --                          ;Branch always
  
 ;Update the actual PPU control registers. ;Update the actual PPU control registers.
  
 WritePPUCtrl: WritePPUCtrl:
-LC44D: lda PPUCNT0ZP +LC44D:  lda PPUCNT0ZP                   
-LC44F: sta PPUControl0 +LC44F:  sta PPUControl0                 
-LC452: lda PPUCNT1ZP ;Update PPU control registers. +LC452:  lda PPUCNT1ZP                   ;Update PPU control registers. 
-LC454: sta PPUControl1 +LC454:  sta PPUControl1                 
-LC457: lda MirrorCntrl +LC457:  lda MirrorCntrl                 
-LC459: jsr PrepPPUMirror ;($C4D9)Setup vertical or horizontal mirroring.+LC459:  jsr PrepPPUMirror               ;($C4D9)Setup vertical or horizontal mirroring.
  
 ExitSub: ExitSub:
-LC45C: rts ;Exit subroutines.+LC45C:  rts                             ;Exit subroutines.
  
 ;Turn off both screen and NMI. ;Turn off both screen and NMI.
  
 ScreenNmiOff: ScreenNmiOff:
-LC45D: lda PPUCNT1ZP +LC45D:  lda PPUCNT1ZP                   
-LC45F: and #$E7 ;BG & SPR visibility = off +LC45F:  and #$E7                        ;BG & SPR visibility = off 
-LC461: jsr WriteAndWait ;($C43D)Wait for end of NMI. +LC461:  jsr WriteAndWait                ;($C43D)Wait for end of NMI. 
-LC464: lda PPUCNT0ZP ;Prepare to turn off NMI in PPU. +LC464:  lda PPUCNT0ZP                   ;Prepare to turn off NMI in PPU. 
-LC466: and #$7F ;NMI = off +LC466:  and #$7F                        ;NMI = off 
-LC468: sta PPUCNT0ZP +LC468:  sta PPUCNT0ZP                   
-LC46A: sta PPUControl0 ;Actually load PPU register with NMI off value. +LC46A:  sta PPUControl0                 ;Actually load PPU register with NMI off value. 
-LC46D: rts ;+LC46D:  rts                             ;
  
 ;The following routine does not appear to be used. ;The following routine does not appear to be used.
  
-LC46E: lda PPUCNT0ZP ;Enable VBlank. +LC46E:  lda PPUCNT0ZP                   ;Enable VBlank. 
-LC470: ora #$80 +LC470:  ora #$80                        
-LC472: sta PPUCNT0ZP ;Write PPU control register 0 and PPU status byte. +LC472:  sta PPUCNT0ZP                   ;Write PPU control register 0 and PPU status byte. 
-LC474: sta PPUControl0 +LC474:  sta PPUControl0                 
-LC477: lda PPUCNT1ZP ;Turn sprites and screen on. +LC477:  lda PPUCNT1ZP                   ;Turn sprites and screen on. 
-LC479: ora #$1E +LC479:  ora #$1E                        
-LC47B: bne -- ;Branch always.+LC47B:  bne --                          ;Branch always.
  
 VBOffAndHorzWrite:  VBOffAndHorzWrite: 
-LC47D: lda PPUCNT0ZP +LC47D:  lda PPUCNT0ZP                   
-LC47F: and #$7B ;Horizontal write, disable VBlank.  +LC47F:  and #$7B                        ;Horizontal write, disable VBlank.  
-LC481:* sta PPUControl0 ;Save new values in the PPU control register--> +LC481:* sta PPUControl0                 ;Save new values in the PPU control register--> 
-LC484: sta PPUCNT0ZP ;and PPU status byte. +LC484:  sta PPUCNT0ZP                   ;and PPU status byte. 
-LC486: rts ;+LC486:  rts                             ;
  
 NmiOn: NmiOn:
-LC487:* lda PPUStatus +LC487:* lda PPUStatus                   
-LC48A: and #$80 ;Wait for end of VBlank. +LC48A:  and #$80                        ;Wait for end of VBlank. 
-LC48C: bne - +LC48C:  bne -                           
-LC48E: lda PPUCNT0ZP +LC48E:  lda PPUCNT0ZP                   
-LC490: ora #$80 ;Enable VBlank interrupts. +LC490:  ora #$80                        ;Enable VBlank interrupts. 
-LC492: bne -- ;Branch always.+LC492:  bne --                          ;Branch always.
  
 ;--------------------------------------[ Timer routines ]-------------------------------------------- ;--------------------------------------[ Timer routines ]--------------------------------------------
Line 923: Line 923:
  
 WaitTimer: WaitTimer:
-LC494: lda Timer3 ;Exit if timer hasn't hit zero yet +LC494:  lda Timer3                      ;Exit if timer hasn't hit zero yet 
-LC496: bne + +LC496:  bne +                           
-LC498: lda NextRoutine ;Set GameOver as next routine. +LC498:  lda NextRoutine                 ;Set GameOver as next routine. 
-LC49A: cmp #$04 +LC49A:  cmp #$04                        
-LC49C: beq SetMainRoutine ;Set GoPassword as main routine. +LC49C:  beq SetMainRoutine              ;Set GoPassword as main routine. 
-LC49E: cmp #$06 +LC49E:  cmp #$06                        
-LC4A0: beq SetMainRoutine +LC4A0:  beq SetMainRoutine              
-LC4A2: jsr StartMusic ;($D92C)Assume power up was picked up and GameEngine--> +LC4A2:  jsr StartMusic                  ;($D92C)Assume power up was picked up and GameEngine--> 
-LC4A5: lda NextRoutine ;is next routine. Start area music before exiting.+LC4A5:  lda NextRoutine                 ;is next routine. Start area music before exiting.
  
 SetMainRoutine: SetMainRoutine:
-LC4A7: sta MainRoutine ;Set next routine to run. +LC4A7:  sta MainRoutine                 ;Set next routine to run. 
-LC4A9:* rts ;+LC4A9:* rts                             ;
  
 SetTimer: SetTimer:
-LC4AA: sta Timer3 ;Set Timer3. Frames to wait is value stored in A*10. +LC4AA:  sta Timer3                      ;Set Timer3. Frames to wait is value stored in A*10. 
-LC4AC: stx NextRoutine ;Save routine to jump to after Timer3 expires. +LC4AC:  stx NextRoutine                 ;Save routine to jump to after Timer3 expires. 
-LC4AE: lda #$09 ;Next routine to run is WaitTimer. +LC4AE:  lda #$09                        ;Next routine to run is WaitTimer. 
-LC4B0: bne SetMainRoutine ;Branch always.+LC4B0:  bne SetMainRoutine              ;Branch always.
  
 ;-----------------------------------[ PPU mirroring routines ]--------------------------------------- ;-----------------------------------[ PPU mirroring routines ]---------------------------------------
  
 PrepVertMirror: PrepVertMirror:
-LC4B2: nop +LC4B2:  nop                             
-LC4B3: nop ;Prepare to set PPU for vertical mirroring (again). +LC4B3:  nop                             ;Prepare to set PPU for vertical mirroring (again). 
-LC4B4: lda #$47 ;+LC4B4:  lda #$47                        ;
  
 SetPPUMirror: SetPPUMirror:
-LC4B6: lsr +LC4B6:  lsr                             
-LC4B7: lsr ;Move bit 3 to bit 0 position. +LC4B7:  lsr                             ;Move bit 3 to bit 0 position. 
-LC4B8: lsr +LC4B8:  lsr                             
-LC4B9: and #$01 ;Remove all other bits. +LC4B9:  and #$01                        ;Remove all other bits. 
-LC4BB: sta $00 ;Store at address $00. +LC4BB:  sta $00                         ;Store at address $00. 
-LC4BD: lda MMCReg0Cntrl +LC4BD:  lda MMCReg0Cntrl                
-LC4BF: and #$FE ;Load MMCReg0Cntrl and remove bit 0. +LC4BF:  and #$FE                        ;Load MMCReg0Cntrl and remove bit 0. 
-LC4C1: ora $00 ;Replace bit 0 with stored bit at $00. +LC4C1:  ora $00                         ;Replace bit 0 with stored bit at $00. 
-LC4C3: sta MMCReg0Cntrl +LC4C3:  sta MMCReg0Cntrl                
-LC4C5: sta MMC1Reg0 +LC4C5:  sta MMC1Reg0                    
-LC4C8: lsr +LC4C8:  lsr                             
-LC4C9: sta MMC1Reg0 +LC4C9:  sta MMC1Reg0                    
-LC4Cc: lsr +LC4Cc:  lsr                             
-LC4CD: sta MMC1Reg0 +LC4CD:  sta MMC1Reg0                    
-LC4D0: lsr ;Load new configuration data serially--> +LC4D0:  lsr                             ;Load new configuration data serially--> 
-LC4D1: sta MMC1Reg0 ;into MMC1Reg0. +LC4D1:  sta MMC1Reg0                    ;into MMC1Reg0. 
-LC4D4: lsr +LC4D4:  lsr                             
-LC4D5: sta MMC1Reg0 +LC4D5:  sta MMC1Reg0                    
-LC4D8: rts ;+LC4D8:  rts                             ;
  
 PrepPPUMirror: PrepPPUMirror:
-LC4D9: lda MirrorCntrl ;Load MirrorCntrl into A. +LC4D9:  lda MirrorCntrl                 ;Load MirrorCntrl into A. 
-LC4DB: jmp SetPPUMirror ;($C4B6)Set mirroring through MMC1 chip.+LC4DB:  jmp SetPPUMirror                ;($C4B6)Set mirroring through MMC1 chip.
  
 ;-----------------------------[ Switch bank and init bank routines ]--------------------------------- ;-----------------------------[ Switch bank and init bank routines ]---------------------------------
Line 984: Line 984:
  
 CheckSwitch: CheckSwitch:
-LC4DE: ldy SwitchPending +LC4DE:  ldy SwitchPending               
-LC4E0: beq + ;Exit if zero(no bank switch issued). else Y contains bank#+1. +LC4E0:  beq +                           ;Exit if zero(no bank switch issued). else Y contains bank#+1. 
-LC4E2: jsr SwitchOK ;($C4E8)Perform bank switch. +LC4E2:  jsr SwitchOK                    ;($C4E8)Perform bank switch. 
-LC4E5: jmp GoBankInit ;($C510)Initialize bank switch data.+LC4E5:  jmp GoBankInit                  ;($C510)Initialize bank switch data.
  
 SwitchOK: SwitchOK:
-LC4E8: lda #$00 ;Reset(so that the bank switch won't be performed--> +LC4E8:  lda #$00                        ;Reset(so that the bank switch won't be performed--> 
-LC4EA: sta SwitchPending ;every succeeding frame too). +LC4EA:  sta SwitchPending               ;every succeeding frame too). 
-LC4EC: dey ;Y now contains the bank to switch to. +LC4EC:  dey                             ;Y now contains the bank to switch to. 
-LC4ED: sty CurrentBank ;+LC4ED:  sty CurrentBank                 ;
  
 ROMSwitch: ROMSwitch:
-LC4EF: tya +LC4EF:  tya                             
-LC4F0: sta $00 ;Bank to switch to is stored at location $00. +LC4F0:  sta $00                         ;Bank to switch to is stored at location $00. 
-LC4F2: lda SwitchUpperBits ;Load upper two bits for Reg 3 (they should always be 0). +LC4F2:  lda SwitchUpperBits             ;Load upper two bits for Reg 3 (they should always be 0). 
-LC4F4: and #$18 ;Extract bits 3 and 4 and add them to the current--> +LC4F4:  and #$18                        ;Extract bits 3 and 4 and add them to the current--> 
-LC4F6: ora $00 ;bank to switch to. +LC4F6:  ora $00                         ;bank to switch to. 
-LC4F8: sta SwitchUpperBits ;Store any new bits set in 3 or 4(there should be none).+LC4F8:  sta SwitchUpperBits             ;Store any new bits set in 3 or 4(there should be none).
  
 ;Loads the lower memory page with the bank specified in A. ;Loads the lower memory page with the bank specified in A.
  
 MMCWriteReg3: MMCWriteReg3:
-LC4FA: sta MMC1Reg3 ;Write bit 0 of ROM bank #. +LC4FA:  sta MMC1Reg3                    ;Write bit 0 of ROM bank #. 
-LC4FD: lsr +LC4FD:  lsr                             
-LC4FE: sta MMC1Reg3 ;Write bit 1 of ROM bank #. +LC4FE:  sta MMC1Reg3                    ;Write bit 1 of ROM bank #. 
-LC501: lsr +LC501:  lsr                             
-LC502: sta MMC1Reg3 ;Write bit 2 of ROM bank #. +LC502:  sta MMC1Reg3                    ;Write bit 2 of ROM bank #. 
-LC505: lsr +LC505:  lsr                             
-LC506: sta MMC1Reg3 ;Write bit 3 of ROM bank #. +LC506:  sta MMC1Reg3                    ;Write bit 3 of ROM bank #. 
-LC509: lsr +LC509:  lsr                             
-LC50A: sta MMC1Reg3 ;Write bit 4 of ROM bank #. +LC50A:  sta MMC1Reg3                    ;Write bit 4 of ROM bank #. 
-LC50D: lda $00 ;Restore A with current bank number before exiting. +LC50D:  lda $00                         ;Restore A with current bank number before exiting. 
-LC50F:* rts ;+LC50F:* rts                             ;
  
 ;Calls the proper routine according to the bank number in A. ;Calls the proper routine according to the bank number in A.
  
 GoBankInit: GoBankInit:
-LC510: asl ;*2 For proper table offset below. +LC510:  asl                             ;*2 For proper table offset below. 
-LC511: tay +LC511:  tay                             
-LC512: lda BankInitTable,y +LC512:  lda BankInitTable,            
-LC515: sta $0A ;Load appropriate subroutine address into $0A and $0B. +LC515:  sta $0A                         ;Load appropriate subroutine address into $0A and $0B. 
-LC517: lda BankInitTable+1,y +LC517:  lda BankInitTable+1,          
-LC51A: sta $0B +LC51A:  sta $0B                         
-LC51C: jmp ($000A) ;Jump to appropriate initialization routine.+LC51C:  jmp ($000A)                     ;Jump to appropriate initialization routine.
  
 BankInitTable: BankInitTable:
-LC51F: .word InitBank0 ;($C531)Initialize bank 0. +LC51F:  .word InitBank0                 ;($C531)Initialize bank 0. 
-LC521: .word InitBank1 ;($C552)Initialize bank 1. +LC521:  .word InitBank1                 ;($C552)Initialize bank 1. 
-LC523: .word InitBank2 ;($C583)Initialize bank 2. +LC523:  .word InitBank2                 ;($C583)Initialize bank 2. 
-LC525: .word InitBank3 ;($C590)Initialize bank 3. +LC525:  .word InitBank3                 ;($C590)Initialize bank 3. 
-LC527: .word InitBank4 ;($C5B6)Initialize bank 4. +LC527:  .word InitBank4                 ;($C5B6)Initialize bank 4. 
-LC529: .word InitBank5 ;($C5C3)Initialize bank 5. +LC529:  .word InitBank5                 ;($C5C3)Initialize bank 5. 
-LC52B: .word ExitSub ;($C45C)Rts +LC52B:  .word ExitSub                   ;($C45C)Rts 
-LC52D: .word ExitSub ;($C45C)Rts +LC52D:  .word ExitSub                   ;($C45C)Rts 
-LC52F: .word ExitSub ;($C45C)Rts+LC52F:  .word ExitSub                   ;($C45C)Rts
  
 ;Title screen memory page. ;Title screen memory page.
  
 InitBank0: InitBank0:
-LC531: ldy #$00 +LC531:  ldy #$00                        
-LC533: sty GamePaused ;Ensure game is not paused. +LC533:  sty GamePaused                  ;Ensure game is not paused. 
-LC535: iny ;Y=1. +LC535:  iny                             ;Y=1. 
-LC536: sty GameMode ;Game is at title routines. +LC536:  sty GameMode                    ;Game is at title routines. 
-LC538: jsr ScreenNmiOff ;($C45D)Waits for NMI to end then turns it off. +LC538:  jsr ScreenNmiOff                ;($C45D)Waits for NMI to end then turns it off. 
-LC53B: jsr CopyMap ;($A93E)Copy game map from ROM to cartridge RAM $7000-$73FF +LC53B:  jsr CopyMap                     ;($A93E)Copy game map from ROM to cartridge RAM $7000-$73FF 
-LC53E: jsr ClearNameTables ;($C158)Erase name table data.+LC53E:  jsr ClearNameTables             ;($C158)Erase name table data.
  
-LC541: ldy #$A0 +LC541:  ldy #$A0                        
-LC543:* lda $98BF,y +LC543:* lda $98BF,                    
-LC546: sta $6DFF,y ;Loads sprite info for stars into RAM $6E00 thru 6E9F. +LC546:  sta $6DFF,                    ;Loads sprite info for stars into RAM $6E00 thru 6E9F. 
-LC549: dey +LC549:  dey                             
-LC54A: bne - ;+LC54A:  bne -                           ;
  
-LC54C: jsr InitTitleGFX ;($C5D7)Load title GFX. +LC54C:  jsr InitTitleGFX                ;($C5D7)Load title GFX. 
-LC54F: jmp NmiOn ;($C487)Turn on VBlank interrupts.+LC54F:  jmp NmiOn                       ;($C487)Turn on VBlank interrupts.
  
 ;Brinstar memory page. ;Brinstar memory page.
  
 InitBank1: InitBank1:
-LC552: lda #$00 +LC552:  lda #$00                        
-LC554: sta GameMode ;GameMode = play. +LC554:  sta GameMode                    ;GameMode = play. 
-LC556: jsr ScreenNmiOff ;($C45D)Disable screen and Vblank. +LC556:  jsr ScreenNmiOff                ;($C45D)Disable screen and Vblank. 
-LC559: lda MainRoutine +LC559:  lda MainRoutine                 
-LC55B: cmp #$03 ;Is game engine running? if so, branch.--> +LC55B:  cmp #$03                        ;Is game engine running? if so, branch.--> 
-LC55D: beq + ;Else do some housekeeping first. +LC55D:  beq +                           ;Else do some housekeeping first. 
-LC55F: lda #$00 +LC55F:  lda #$00                        
-LC561: sta MainRoutine ;Run InitArea routine next. +LC561:  sta MainRoutine                 ;Run InitArea routine next. 
-LC563: sta InArea ;Start in Brinstar. +LC563:  sta InArea                      ;Start in Brinstar. 
-LC565: sta GamePaused ;Make sure game is not paused. +LC565:  sta GamePaused                  ;Make sure game is not paused. 
-LC567: jsr ClearRAM_33_DF ;($C1D4)Clear game engine memory addresses. +LC567:  jsr ClearRAM_33_DF              ;($C1D4)Clear game engine memory addresses. 
-LC56A: jsr ClearSamusStats ;($C578)Clear Samus' stats memory addresses. +LC56A:  jsr ClearSamusStats             ;($C578)Clear Samus' stats memory addresses. 
-LC56D:* ldy #$00 +LC56D:* ldy #$00                        
-LC56F: jsr ROMSwitch ;($C4EF)Load Brinstar memory page into lower 16Kb memory. +LC56F:  jsr ROMSwitch                   ;($C4EF)Load Brinstar memory page into lower 16Kb memory. 
-LC572: jsr InitBrinstarGFX ;($C604)Load Brinstar GFX. +LC572:  jsr InitBrinstarGFX             ;($C604)Load Brinstar GFX. 
-LC575: jmp NmiOn ;($C487)Turn on VBlank interrupts.+LC575:  jmp NmiOn                       ;($C487)Turn on VBlank interrupts.
  
 ClearSamusStats: ClearSamusStats:
-LC578: ldy #$0F +LC578:  ldy #$0F                        
-LC57A: lda #$00 ;Clears Samus stats(Health, full tanks, game timer, etc.). +LC57A:  lda #$00                        ;Clears Samus stats(Health, full tanks, game timer, etc.). 
-LC57C:* sta $0100,y ;Load $100 thru $10F with #$00. +LC57C:* sta $0100,                    ;Load $100 thru $10F with #$00. 
-LC57F: dey +LC57F:  dey                             
-LC580: bpl - ;Loop 16 times. +LC580:  bpl -                           ;Loop 16 times. 
-LC582: rts ;+LC582:  rts                             ;
  
 ;Norfair memory page. ;Norfair memory page.
  
 InitBank2: InitBank2:
-LC583: lda #$00 ;GameMode = play. +LC583:  lda #$00                        ;GameMode = play. 
-LC585: sta GameMode +LC585:  sta GameMode                    
-LC587: jsr ScreenNmiOff ;($C45D)Disable screen and Vblank. +LC587:  jsr ScreenNmiOff                ;($C45D)Disable screen and Vblank. 
-LC58A: jsr InitNorfairGFX ;($C622)Load Norfair GFX. +LC58A:  jsr InitNorfairGFX              ;($C622)Load Norfair GFX. 
-LC58D: jmp NmiOn ;($C487)Turn on VBlank interrupts.+LC58D:  jmp NmiOn                       ;($C487)Turn on VBlank interrupts.
  
 ;Tourian memory page. ;Tourian memory page.
  
 InitBank3: InitBank3:
-LC590: lda #$00 ;GameMode = play. +LC590:  lda #$00                        ;GameMode = play. 
-LC592: sta GameMode +LC592:  sta GameMode                    
-LC594: jsr ScreenNmiOff ;($C45D)Disable screen and Vblank. +LC594:  jsr ScreenNmiOff                ;($C45D)Disable screen and Vblank. 
-LC597: ldy #$0D +LC597:  ldy #$0D                        
-LC599:* lda MetroidData,y ;Load info from table below into--> +LC599:* lda MetroidData,              ;Load info from table below into--> 
-LC59C: sta $77F0,y ;$77F0 thru $77FD. +LC59C:  sta $77F0,                    ;$77F0 thru $77FD. 
-LC59F: dey +LC59F:  dey                             
-LC5A0: bpl - +LC5A0:  bpl -                           
-LC5A2: jsr InitTourianGFX ;($C645)Load Tourian GFX. +LC5A2:  jsr InitTourianGFX              ;($C645)Load Tourian GFX. 
-LC5A5: jmp NmiOn ;($C487)Turn on VBlank interrupts.+LC5A5:  jmp NmiOn                       ;($C487)Turn on VBlank interrupts.
  
 ;Table used by above subroutine and loads the initial data used to describe ;Table used by above subroutine and loads the initial data used to describe
Line 1115: Line 1115:
  
 MetroidData: MetroidData:
-LC5A8: .byte $F8, $08, $30, $D0, $60, $A0, $02, $04, $00, $00, $00, $00, $00, $00+LC5A8:  .byte $F8, $08, $30, $D0, $60, $A0, $02, $04, $00, $00, $00, $00, $00, $00
  
 ;Kraid memory page. ;Kraid memory page.
  
 InitBank4: InitBank4:
-LC5B6: lda #$00 ;GameMode = play. +LC5B6:  lda #$00                        ;GameMode = play. 
-LC5B8: sta GameMode +LC5B8:  sta GameMode                    
-LC5BA: jsr ScreenNmiOff ;($C45D)Disable screen and Vblank. +LC5BA:  jsr ScreenNmiOff                ;($C45D)Disable screen and Vblank. 
-LC5BD: jsr InitKraidGFX ;($C677)Load Kraid GFX. +LC5BD:  jsr InitKraidGFX                ;($C677)Load Kraid GFX. 
-LC5C0: jmp NmiOn ;($C487)Turn on VBlank interrupts.+LC5C0:  jmp NmiOn                       ;($C487)Turn on VBlank interrupts.
  
 ;Ridley memory page. ;Ridley memory page.
  
 InitBank5: InitBank5:
-LC5C3: lda #$00 ;GameMode = play. +LC5C3:  lda #$00                        ;GameMode = play. 
-LC5C5: sta GameMode +LC5C5:  sta GameMode                    
-LC5C7: jsr ScreenNmiOff ;($C45D)Disable screen and Vblank. +LC5C7:  jsr ScreenNmiOff                ;($C45D)Disable screen and Vblank. 
-LC5CA: jsr InitRidleyGFX ;($C69F)Loag Ridley GFX. +LC5CA:  jsr InitRidleyGFX               ;($C69F)Loag Ridley GFX. 
-LC5CD: jmp NmiOn ;($C487)Turn on VBlank interrupts.+LC5CD:  jmp NmiOn                       ;($C487)Turn on VBlank interrupts.
  
 InitEndGFX: InitEndGFX:
-LC5D0: lda #$01 +LC5D0:  lda #$01                        
-LC5D2: sta GameMode ;Game is at title/end game. +LC5D2:  sta GameMode                    ;Game is at title/end game. 
-LC5D4: jmp InitGFX6 ;($C6C2)Load end game GFX.+LC5D4:  jmp InitGFX6                    ;($C6C2)Load end game GFX.
  
 InitTitleGFX: InitTitleGFX:
-LC5D7: ldy #$15 ;Entry 21 in GFXInfo table. +LC5D7:  ldy #$15                        ;Entry 21 in GFXInfo table. 
-LC5D9: jsr LoadGFX ;($C7AB)Load pattern table GFX.+LC5D9:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 LoadSamusGFX: LoadSamusGFX:
-LC5DC: ldy #$00 ;Entry 0 in GFXInfo table. +LC5DC:  ldy #$00                        ;Entry 0 in GFXInfo table. 
-LC5DE: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC5DE:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC5E1: lda JustInBailey +LC5E1:  lda JustInBailey                
-LC5E4: beq + ;Branch if wearing suit +LC5E4:  beq +                           ;Branch if wearing suit 
-LC5E6: ldy #$1B ;Entry 27 in GFXInfo table. +LC5E6:  ldy #$1B                        ;Entry 27 in GFXInfo table. 
-LC5E8: jsr LoadGFX ;($C7AB)Switch to girl gfx +LC5E8:  jsr LoadGFX                     ;($C7AB)Switch to girl gfx 
-LC5EB:* ldy #$14 ;Entry 20 in GFXInfo table. +LC5EB:* ldy #$14                        ;Entry 20 in GFXInfo table. 
-LC5ED: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC5ED:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC5F0: ldy #$17 ;Entry 23 in GFXInfo table. +LC5F0:  ldy #$17                        ;Entry 23 in GFXInfo table. 
-LC5F2: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC5F2:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC5F5: ldy #$18 ;Entry 24 in GFXInfo table. +LC5F5:  ldy #$18                        ;Entry 24 in GFXInfo table. 
-LC5F7: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC5F7:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC5FA: ldy #$19 ;Entry 25 in GFXInfo table. +LC5FA:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC5FC: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC5FC:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC5FF: ldy #$16 ;Entry 22 in GFXInfo table. +LC5FF:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC601: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC601:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitBrinstarGFX: InitBrinstarGFX:
-LC604: ldy #$03 ;Entry 3 in GFXInfo table. +LC604:  ldy #$03                        ;Entry 3 in GFXInfo table. 
-LC606: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC606:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-Lc609: ldy #$04 ;Entry 4 in GFXInfo table. +Lc609:  ldy #$04                        ;Entry 4 in GFXInfo table. 
-LC60B: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC60B:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC60E: ldy #$05 ;Entry 5 in GFXInfo table. +LC60E:  ldy #$05                        ;Entry 5 in GFXInfo table. 
-LC610: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC610:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC613: ldy #$06 ;Entry 6 in GFXInfo table. +LC613:  ldy #$06                        ;Entry 6 in GFXInfo table. 
-LC615: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC615:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC618: ldy #$19 ;Entry 25 in GFXInfo table. +LC618:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC61A: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC61A:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC61D: ldy #$16 ;Entry 22 in GFXInfo table. +LC61D:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC61F: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC61F:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitNorfairGFX: InitNorfairGFX:
-LC622: ldy #$04 ;Entry 4 in GFXInfo table. +LC622:  ldy #$04                        ;Entry 4 in GFXInfo table. 
-LC624: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC624:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC627: ldy #$05 ;Entry 5 in GFXInfo table. +LC627:  ldy #$05                        ;Entry 5 in GFXInfo table. 
-LC629: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC629:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC62C: ldy #$07 ;Entry 7 in GFXInfo table. +LC62C:  ldy #$07                        ;Entry 7 in GFXInfo table. 
-LC62E: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC62E:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC631: ldy #$08 ;Entry 8 in GFXInfo table. +LC631:  ldy #$08                        ;Entry 8 in GFXInfo table. 
-LC633: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC633:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC636: ldy #$09 ;Entry 9 in GFXInfo table. +LC636:  ldy #$09                        ;Entry 9 in GFXInfo table. 
-LC638: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC638:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC63B: ldy #$19 ;Entry 25 in GFXInfo table. +LC63B:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC63D: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC63D:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC640: ldy #$16 ;Entry 22 in GFXInfo table. +LC640:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC642: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC642:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitTourianGFX: InitTourianGFX:
-LC645: ldy #$05 ;Entry 5 in GFXInfo table. +LC645:  ldy #$05                        ;Entry 5 in GFXInfo table. 
-LC647: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC647:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC64A: ldy #$0A ;Entry 10 in GFXInfo table. +LC64A:  ldy #$0A                        ;Entry 10 in GFXInfo table. 
-LC64C: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC64C:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC64F: ldy #$0B ;Entry 11 in GFXInfo table. +LC64F:  ldy #$0B                        ;Entry 11 in GFXInfo table. 
-LC651: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC651:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC654: ldy #$0C ;Entry 12 in GFXInfo table. +LC654:  ldy #$0C                        ;Entry 12 in GFXInfo table. 
-LC656: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC656:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC659: ldy #$0D ;Entry 13 in GFXInfo table. +LC659:  ldy #$0D                        ;Entry 13 in GFXInfo table. 
-LC65B: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC65B:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC65E: ldy #$0E ;Entry 14 in GFXInfo table. +LC65E:  ldy #$0E                        ;Entry 14 in GFXInfo table. 
-LC660: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC660:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC663: ldy #$1A ;Entry 26 in GFXInfo table. +LC663:  ldy #$1A                        ;Entry 26 in GFXInfo table. 
-LC665: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC665:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC668: ldy #$1C ;Entry 28 in GFXInfo table. +LC668:  ldy #$1C                        ;Entry 28 in GFXInfo table. 
-LC66A: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC66A:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC66D: ldy #$19 ;Entry 25 in GFXInfo table. +LC66D:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC66F: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC66F:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC672: ldy #$16 ;Entry 22 in GFXInfo table. +LC672:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC674: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC674:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitKraidGFX: InitKraidGFX:
-LC677: ldy #$04 ;Entry 4 in GFXInfo table. +LC677:  ldy #$04                        ;Entry 4 in GFXInfo table. 
-LC679: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC679:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC67C: ldy #$05 ;Entry 5 in GFXInfo table. +LC67C:  ldy #$05                        ;Entry 5 in GFXInfo table. 
-LC67E: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC67E:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC681: ldy #$0A ;Entry 10 in GFXInfo table. +LC681:  ldy #$0A                        ;Entry 10 in GFXInfo table. 
-LC683: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC683:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC686: ldy #$0F ;Entry 15 in GFXInfo table. +LC686:  ldy #$0F                        ;Entry 15 in GFXInfo table. 
-LC688: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC688:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC68B: ldy #$10 ;Entry 16 in GFXInfo table. +LC68B:  ldy #$10                        ;Entry 16 in GFXInfo table. 
-LC68D: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC68D:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC690: ldy #$11 ;Entry 17 in GFXInfo table. +LC690:  ldy #$11                        ;Entry 17 in GFXInfo table. 
-LC692: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC692:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC695: ldy #$19 ;Entry 25 in GFXInfo table. +LC695:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC697: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC697:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC69A: ldy #$16 ;Entry 22 in GFXInfo table. +LC69A:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC69C: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC69C:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitRidleyGFX: InitRidleyGFX:
-LC69F: ldy #$04 ;Entry 4 in GFXInfo table. +LC69F:  ldy #$04                        ;Entry 4 in GFXInfo table. 
-LC6A1: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6A1:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6A4: ldy #$05 ;Entry 5 in GFXInfo table. +LC6A4:  ldy #$05                        ;Entry 5 in GFXInfo table. 
-LC6A6: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6A6:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6A9: ldy #$0A ;Entry 10 in GFXInfo table. +LC6A9:  ldy #$0A                        ;Entry 10 in GFXInfo table. 
-LC6AB: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6AB:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6AE: ldy #$12 ;Entry 18 in GFXInfo table. +LC6AE:  ldy #$12                        ;Entry 18 in GFXInfo table. 
-LC6B0: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6B0:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6B3: ldy #$13 ;Entry 19 in GFXInfo table. +LC6B3:  ldy #$13                        ;Entry 19 in GFXInfo table. 
-LC6B5: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6B5:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6B8: ldy #$19 ;Entry 25 in GFXInfo table. +LC6B8:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC6BA: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6BA:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6BD: ldy #$16 ;Entry 22 in GFXInfo table. +LC6BD:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC6BF: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC6BF:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitGFX6: InitGFX6:
-LC6C2: ldy #$01 ;Entry 1 in GFXInfo table. +LC6C2:  ldy #$01                        ;Entry 1 in GFXInfo table. 
-LC6C4: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6C4:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6C7: ldy #$02 ;Entry 2 in GFXInfo table. +LC6C7:  ldy #$02                        ;Entry 2 in GFXInfo table. 
-LC6C9: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6C9:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6CC: ldy #$19 ;Entry 25 in GFXInfo table. +LC6CC:  ldy #$19                        ;Entry 25 in GFXInfo table. 
-LC6CE: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6CE:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6D1: ldy #$16 ;Entry 22 in GFXInfo table. +LC6D1:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC6D3: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC6D3:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 InitGFX7: InitGFX7:
-LC6D6: ldy #$17 ;Entry 23 in GFXInfo table. +LC6D6:  ldy #$17                        ;Entry 23 in GFXInfo table. 
-LC6D8: jsr LoadGFX ;($C7AB)Load pattern table GFX. +LC6D8:  jsr LoadGFX                     ;($C7AB)Load pattern table GFX. 
-LC6DB: ldy #$16 ;Entry 22 in GFXInfo table. +LC6DB:  ldy #$16                        ;Entry 22 in GFXInfo table. 
-LC6DD: jmp LoadGFX ;($C7AB)Load pattern table GFX.+LC6DD:  jmp LoadGFX                     ;($C7AB)Load pattern table GFX.
  
 ;The table below contains info for each tile data block in the ROM. ;The table below contains info for each tile data block in the ROM.
Line 1272: Line 1272:
  
 GFXInfo: GFXInfo:
-LC6E0: .byte $06 ;[SPR]Samus, items. Entry 0. +LC6E0:  .byte $06                       ;[SPR]Samus, items.             Entry 0. 
-LC6E1: .word $8000, $0000, $09A0 +LC6E1:  .word $8000, $0000, $09A0 
-LC6E7: .byte $04 ;[SPR]Samus in ending. Entry 1. +LC6E7:  .byte $04                       ;[SPR]Samus in ending.          Entry 1. 
-LC6E8: .word $8D60, $0000, $0520 +LC6E8:  .word $8D60, $0000, $0520 
-LC6EE: .byte $01 ;[BGR]Partial font, "The End". Entry 2. +LC6EE:  .byte $01                       ;[BGR]Partial font, "The End" Entry 2. 
-LC6EF: .word $8D60, $1000, $0400 +LC6EF:  .word $8D60, $1000, $0400 
-LC6F5: .byte $06 ;[BGR]Brinstar rooms. Entry 3. +LC6F5:  .byte $06                       ;[BGR]Brinstar rooms.           Entry 3. 
-LC6F6: .word $9DA0, $1000, $0150 +LC6F6:  .word $9DA0, $1000, $0150 
-LC6FC: .byte $05 ;[BGR]Misc. objects. Entry 4. +LC6FC:  .byte $05                       ;[BGR]Misc. objects.            Entry 4. 
-LC6FD: .word $8D60, $1200, $0450 +LC6FD:  .word $8D60, $1200, $0450 
-LC703: .byte $06 ;[BGR]More Brinstar rooms. Entry 5. +LC703:  .byte $06                       ;[BGR]More Brinstar rooms.      Entry 5. 
-LC704: .word $9EF0, $1800, $0800 +LC704:  .word $9EF0, $1800, $0800 
-LC70A: .byte $01 ;[SPR]Brinstar enemies. Entry 6. +LC70A:  .byte $01                       ;[SPR]Brinstar enemies.         Entry 6. 
-LC70B: .word $9160, $0C00, $0400 +LC70B:  .word $9160, $0C00, $0400 
-LC711: .byte $06 ;[BGR]Norfair rooms. Entry 7. +LC711:  .byte $06                       ;[BGR]Norfair rooms.            Entry 7. 
-LC712: .word $A6F0, $1000, $0260 +LC712:  .word $A6F0, $1000, $0260 
-LC718: .byte $06 ;[BGR]More Norfair rooms. Entry 8. +LC718:  .byte $06                       ;[BGR]More Norfair rooms.       Entry 8. 
-LC719: .word $A950, $1700, $0070 +LC719:  .word $A950, $1700, $0070 
-LC71F: .byte $02 ;[SPR]Norfair enemies. Entry 9. +LC71F:  .byte $02                       ;[SPR]Norfair enemies.          Entry 9. 
-LC720: .word $8D60, $0C00, $0400 +LC720:  .word $8D60, $0C00, $0400 
-LC726: .byte $06 ;[BGR]Tourian rooms. Entry 10. +LC726:  .byte $06                       ;[BGR]Tourian rooms.            Entry 10. 
-LC727: .word $A9C0, $1000, $02E0 +LC727:  .word $A9C0, $1000, $02E0 
-LC72D: .byte $06 ;[BGR]More Tourian rooms. Entry 11. +LC72D:  .byte $06                       ;[BGR]More Tourian rooms.       Entry 11. 
-LC72E: .word $ACA0, $1200, $0600 +LC72E:  .word $ACA0, $1200, $0600 
-LC734: .byte $06 ;[BGR]Mother Brain room. Entry 12. +LC734:  .byte $06                       ;[BGR]Mother Brain room.        Entry 12. 
-LC735: .word $B2A0, $1900, $0090 +LC735:  .word $B2A0, $1900, $0090 
-LC73B: .byte $05 ;[BGR]Misc. object. Entry 13. +LC73B:  .byte $05                       ;[BGR]Misc. object.             Entry 13. 
-LC73C: .word $91B0, $1D00, $0300 +LC73C:  .word $91B0, $1D00, $0300 
-LC742: .byte $02 ;[SPR]Tourian enemies. Entry 14. +LC742:  .byte $02                       ;[SPR]Tourian enemies.          Entry 14. 
-LC743: .word $9160, $0C00, $0400 +LC743:  .word $9160, $0C00, $0400 
-LC749: .byte $06 ;[BGR]More Tourian rooms. Entry 15. +LC749:  .byte $06                       ;[BGR]More Tourian rooms.       Entry 15. 
-LC74A: .word $B330, $1700, $00C0 +LC74A:  .word $B330, $1700, $00C0 
-LC750: .byte $04 ;[BGR]Misc. object and fonts. Entry 16. +LC750:  .byte $04                       ;[BGR]Misc. object and fonts.   Entry 16. 
-LC751: .word $9360, $1E00, $0200 +LC751:  .word $9360, $1E00, $0200 
-LC757: .byte $03 ;[SPR]Miniboss I enemies. Entry 17. +LC757:  .byte $03                       ;[SPR]Miniboss I enemies.       Entry 17. 
-LC758: .word $8D60, $0C00, $0400 +LC758:  .word $8D60, $0C00, $0400 
-LC75E: .byte $06 ;[BGR]More Tourian Rooms. Entry 18. +LC75E:  .byte $06                       ;[BGR]More Tourian Rooms.       Entry 18. 
-LC75F: .word $B3F0, $1700, $00C0 +LC75F:  .word $B3F0, $1700, $00C0 
-LC765: .byte $03 ;[SPR]Miniboss II enemies. Entry 19. +LC765:  .byte $03                       ;[SPR]Miniboss II enemies.      Entry 19. 
-LC766: .word $9160, $0C00, $0400 +LC766:  .word $9160, $0C00, $0400 
-LC76C: .byte $06 ;[SPR]Inrto/End sprites. Entry 20. +LC76C:  .byte $06                       ;[SPR]Inrto/End sprites.        Entry 20. 
-LC76D: .word $89A0, $0C00, $0100 +LC76D:  .word $89A0, $0C00, $0100 
-LC773: .byte $06 ;[BGR]Title. Entry 21. +LC773:  .byte $06                       ;[BGR]Title.                    Entry 21. 
-LC774: .word $8BE0, $1400, $0500 +LC774:  .word $8BE0, $1400, $0500 
-LC77A: .byte $06 ;[BGR]Solid tiles. Entry 22. +LC77A:  .byte $06                       ;[BGR]Solid tiles.              Entry 22. 
-LC77B: .word $9980, $1FC0, $0040 +LC77B:  .word $9980, $1FC0, $0040 
-LC781: .byte $06 ;[BGR]Complete font. Entry 23. +LC781:  .byte $06                       ;[BGR]Complete font.            Entry 23. 
-LC782: .word $B4C0, $1000, $0400 +LC782:  .word $B4C0, $1000, $0400 
-LC788: .byte $06 ;[BGR]Complete font. Entry 24. +LC788:  .byte $06                       ;[BGR]Complete font.            Entry 24. 
-LC789: .word $B4C0, $0A00, $00A0 +LC789:  .word $B4C0, $0A00, $00A0 
-LC78F: .byte $06 ;[BGR]Solid tiles. Entry 25. +LC78F:  .byte $06                       ;[BGR]Solid tiles.              Entry 25. 
-LC790: .word $9980, $0FC0, $0040 +LC790:  .word $9980, $0FC0, $0040 
-LC796: .byte $06 ;[BGR]Complete font. Entry 26. +LC796:  .byte $06                       ;[BGR]Complete font.            Entry 26. 
-LC797: .word $B4C0, $1D00, $02A0 +LC797:  .word $B4C0, $1D00, $02A0 
-LC79D: .byte $06 ;[SPR]Suitless Samus. Entry 27. +LC79D:  .byte $06                       ;[SPR]Suitless Samus.           Entry 27. 
-LC79E: .word $90E0, $0000, $07B0 +LC79E:  .word $90E0, $0000, $07B0 
-LC7A4: .byte $06 ;[BGR]Exclaimation point. Entry 28. +LC7A4:  .byte $06                       ;[BGR]Exclaimation point.       Entry 28. 
-LC7A5: .word $9890, $1F40, $0010+LC7A5:  .word $9890, $1F40, $0010
  
 ;--------------------------------[ Pattern table loading routines ]--------------------------------- ;--------------------------------[ Pattern table loading routines ]---------------------------------
Line 1336: Line 1336:
  
 LoadGFX: LoadGFX:
-LC7AB: lda #$FF +LC7AB:  lda #$FF                        
-LC7AD:* clc ;Every time y decrements, the entry into the table--> +LC7AD:* clc                             ;Every time y decrements, the entry into the table--> 
-LC7AE: adc #$07 ;is increased by 7.  When y is less than 0, A points--> +LC7AE:  adc #$07                        ;is increased by 7.  When y is less than 0, A points--> 
-LC7B0: dey ;to the last byte of the entry in the table. +LC7B0:  dey                             ;to the last byte of the entry in the table. 
-LC7B1: bpl - +LC7B1:  bpl -                           
-LC7B3: tay ;Transfer offset into table to Y.+LC7B3:  tay                             ;Transfer offset into table to Y.
  
-LC7B4: ldx #$06 +LC7B4:  ldx #$06                        
-LC7B6:* lda GFXInfo,y +LC7B6:* lda GFXInfo,                  
-LC7B9: sta $00,x ;Copy entries from GFXInfo to $00-$06. +LC7B9:  sta $00,x                       ;Copy entries from GFXInfo to $00-$06. 
-LC7BB: dey +LC7BB:  dey                             
-LC7BC: dex +LC7BC:  dex                             
-LC7BD: bpl - ;+LC7BD:  bpl -                           ;
  
-LC7BF: ldy $00 ;ROM bank containing the GFX data. +LC7BF:  ldy $00                         ;ROM bank containing the GFX data. 
-LC7C1: jsr ROMSwitch ;($C4EF)Switch to that bank. +LC7C1:  jsr ROMSwitch                   ;($C4EF)Switch to that bank. 
-LC7C4: lda PPUCNT0ZP +LC7C4:  lda PPUCNT0ZP                   
-LC7C6: and #$FB +LC7C6:  and #$FB                        
-LC7C8: sta PPUCNT0ZP ;Set the PPU to increment by 1. +LC7C8:  sta PPUCNT0ZP                   ;Set the PPU to increment by 1. 
-LC7CA: sta PPUControl0 +LC7CA:  sta PPUControl0                 
-LC7CD: jsr CopyGFXBlock ;($C7D5)Copy graphics into pattern tables. +LC7CD:  jsr CopyGFXBlock                ;($C7D5)Copy graphics into pattern tables. 
-LC7D0: ldy CurrentBank +LC7D0:  ldy CurrentBank                 
-LC7D2: jmp ROMSwitch ;($C4FE)Switch back to the "old" bank.+LC7D2:  jmp ROMSwitch                   ;($C4FE)Switch back to the "old" bank.
  
 ;Writes tile data from ROM to VRAM, according to the gfx header data ;Writes tile data from ROM to VRAM, according to the gfx header data
Line 1364: Line 1364:
  
 CopyGFXBlock: CopyGFXBlock:
-LC7D5: lda $05 +LC7D5:  lda $05                         
-LC7D7: bne GFXCopyLoop ;If $05 is #$00, decrement $06 before beginning. +LC7D7:  bne GFXCopyLoop                 ;If $05 is #$00, decrement $06 before beginning. 
-LC7D9: dec $06 ;+LC7D9:  dec $06                         ;
  
 GFXCopyLoop: GFXCopyLoop:
-LC7DB: lda $04 +LC7DB:  lda $04                         
-LC7DD: sta PPUAddress ;Set PPU to proper address for GFX block write. +LC7DD:  sta PPUAddress                  ;Set PPU to proper address for GFX block write. 
-LC7E0: lda $03 +LC7E0:  lda $03                         
-LC7E2: sta PPUAddress +LC7E2:  sta PPUAddress                  
-LC7E5: ldy #$00 ;Set offset for GFX data to 0. +LC7E5:  ldy #$00                        ;Set offset for GFX data to 0. 
-LC7E7:* lda ($01),y +LC7E7:* lda ($01),                    
-LC7E9: sta PPUIOReg ;Copy GFX data byte from ROM to Pattern table. +LC7E9:  sta PPUIOReg                    ;Copy GFX data byte from ROM to Pattern table. 
-LC7EC: dec $05 ;Decrement low byte of data length. +LC7EC:  dec $05                         ;Decrement low byte of data length. 
-LC7EE: bne + ;Branch if high byte does not need decrementing. +LC7EE:  bne +                           ;Branch if high byte does not need decrementing. 
-LC7F0: lda $06 +LC7F0:  lda $06                         
-LC7F2: beq ++ ;If copying complete, branch to exit. +LC7F2:  beq ++                          ;If copying complete, branch to exit. 
-LC7F4: dec $06 ;Decrement when low byte has reached 0. +LC7F4:  dec $06                         ;Decrement when low byte has reached 0. 
-LC7F6:* iny ;Increment to next byte to copy. +LC7F6:* iny                             ;Increment to next byte to copy. 
-LC7F7: bne -- +LC7F7:  bne --                          
-LC7F9: inc $02 ;After 256 bytes loaded, increment upper bits of--> +LC7F9:  inc $02                         ;After 256 bytes loaded, increment upper bits of--> 
-LC7FB: inc $04 ;Source and destination addresses. +LC7FB:  inc $04                         ;Source and destination addresses. 
-LC7FD: jmp GFXCopyLoop ;(&C7DB)Repeat copy routine. +LC7FD:  jmp GFXCopyLoop                 ;(&C7DB)Repeat copy routine. 
-LC800:* rts ;+LC800:* rts                             ;
  
 ;-------------------------------------------[ AreaInit ]--------------------------------------------- ;-------------------------------------------[ AreaInit ]---------------------------------------------
  
 AreaInit: AreaInit:
-LC801: lda #$00 +LC801:  lda #$00                        
-LC803: sta ScrollX     ;Clear ScrollX. +LC803:  sta ScrollX                     ;Clear ScrollX. 
-LC805: sta ScrollY     ;Clear ScrollY. +LC805:  sta ScrollY                     ;Clear ScrollY. 
-LC807: lda PPUCNT0ZP ;  +LC807:  lda PPUCNT0ZP                          
-LC809: and #$FC ;Sets nametable address = $2000. +LC809:  and #$FC                        ;Sets nametable address = $2000. 
-LC80B: sta PPUCNT0ZP +LC80B:  sta PPUCNT0ZP                   
-LC80D: inc MainRoutine ;Increment MainRoutine to MoreInit. +LC80D:  inc MainRoutine                 ;Increment MainRoutine to MoreInit. 
-LC80F: lda Joy1Status +LC80F:  lda Joy1Status                  
-LC811: and #$C0 ;Stores status of both the A and B buttons. +LC811:  and #$C0                        ;Stores status of both the A and B buttons. 
-LC813: sta ABStatus   ;Appears to never be accessed. +LC813:  sta ABStatus                    ;Appears to never be accessed. 
-LC815: jsr EraseAllSprites ;($C1A3)Clear all sprite info. +LC815:  jsr EraseAllSprites             ;($C1A3)Clear all sprite info. 
-LC818: lda #$10 ;Prepare to load Brinstar memory page. +LC818:  lda #$10                        ;Prepare to load Brinstar memory page. 
-LC81A: jsr IsEngineRunning ;($CA18)Check to see if ok to switch lower memory page.+LC81A:  jsr IsEngineRunning             ;($CA18)Check to see if ok to switch lower memory page.
  
 ;------------------------------------------[ MoreInit ]--------------------------------------------- ;------------------------------------------[ MoreInit ]---------------------------------------------
  
 MoreInit: MoreInit:
-LC81D: ldy #$01 +LC81D:  ldy #$01                        
-LC81F: sty PalDataPending ;Palette data pending = yes. +LC81F:  sty PalDataPending              ;Palette data pending = yes. 
-LC821: ldx #$FF +LC821:  ldx #$FF                        
-LC823: stx SpareMem75 ;$75 Not referenced ever again in the game. +LC823:  stx SpareMem75                  ;$75 Not referenced ever again in the game. 
-LC825: inx ;X=0. +LC825:  inx                             ;X=0. 
-LC826: stx AtEnding ;Not playing ending scenes. +LC826:  stx AtEnding                    ;Not playing ending scenes. 
-LC829: stx DoorStatus ;Samus not in door. +LC829:  stx DoorStatus                  ;Samus not in door. 
-LC82B: stx SamusDoorData ;Samus is not inside a door. +LC82B:  stx SamusDoorData               ;Samus is not inside a door. 
-LC82D: stx UpdatingProjectile ;No projectiles need to be updated. +LC82D:  stx UpdatingProjectile          ;No projectiles need to be updated. 
-LC82F: txa ;A=0.+LC82F:  txa                             ;A=0.
  
-LC830:* cpx #$65 ;Check to see if more RAM to clear in $7A thru $DE. +LC830:* cpx #$65                        ;Check to see if more RAM to clear in $7A thru $DE. 
-LC832: bcs + +LC832:  bcs +                           
-LC834: sta $7A,x ;Clear RAM $7A thru $DE. +LC834:  sta $7A,x                       ;Clear RAM $7A thru $DE. 
-LC836:* cpx #$FF ;Check to see if more RAM to clear in $300 thru $3FE. +LC836:* cpx #$FF                        ;Check to see if more RAM to clear in $300 thru $3FE. 
-LC838: bcs + +LC838:  bcs +                           
-LC83A: sta ObjAction,x ;Clear RAM $300 thru $3FE. +LC83A:  sta ObjAction,                ;Clear RAM $300 thru $3FE. 
-LC83D:* inx +LC83D:* inx                             
-LC83E: bne --- ;Loop until all required RAM is cleared.+LC83E:  bne ---                         ;Loop until all required RAM is cleared.
  
-LC840: jsr ScreenOff ;($C439)Turn off Background and visibility. +LC840:  jsr ScreenOff                   ;($C439)Turn off Background and visibility. 
-LC843: jsr ClearNameTables ;($C158)Clear screen data. +LC843:  jsr ClearNameTables             ;($C158)Clear screen data. 
-LC846: jsr EraseAllSprites ;($C1A3)Erase all sprites from sprite RAM. +LC846:  jsr EraseAllSprites             ;($C1A3)Erase all sprites from sprite RAM. 
-LC849: jsr DestroyEnemies ;($C8BB)+LC849:  jsr DestroyEnemies              ;($C8BB)
  
- stx DoorOnNameTable3 ;Clear data about doors on the name tables. +        stx DoorOnNameTable3            ;Clear data about doors on the name tables. 
- stx DoorOnNameTable0 +        stx DoorOnNameTable0            
- inx ;X=1. +        inx                             ;X=1. 
- stx SpareMem30 ;Not accessed by game. +        stx SpareMem30                  ;Not accessed by game. 
- inx ;X=2. +        inx                             ;X=2. 
-LC854: stx ScrollDir ;Set initial scroll direction as left.+LC854:  stx ScrollDir                   ;Set initial scroll direction as left.
  
- lda $95D7 ;Get Samus start x pos on map. +        lda $95D7                       ;Get Samus start x pos on map. 
- sta MapPosX +        sta MapPosX                     
- lda $95D8 ;Get Samus start y pos on map. +        lda $95D8                       ;Get Samus start y pos on map. 
- sta MapPosY ;+        sta MapPosY                     ;
  
-LC860: lda $95DA       ; Get ??? Something to do with palette switch +LC860:  lda $95DA       ; Get ??? Something to do with palette switch 
- sta PalToggle +        sta PalToggle 
- lda #$FF +        lda #$FF 
- sta RoomNumber ;Room number = $FF(undefined room). +        sta RoomNumber                  ;Room number = $FF(undefined room). 
-LC869: jsr CopyPtrs    ; copy pointers from ROM to RAM  +LC869:  jsr CopyPtrs    ; copy pointers from ROM to RAM  
-LC86C: jsr GetRoomNum ;($E720)Put room number at current map pos in $5A. +LC86C:  jsr GetRoomNum                  ;($E720)Put room number at current map pos in $5A. 
-*       jsr SetupRoom ;($EA2B) +*       jsr SetupRoom                   ;($EA2B) 
- ldy RoomNumber  ; load room number +        ldy RoomNumber  ; load room number 
- iny +        iny 
- bne -+        bne -
  
- ldy CartRAMPtr+1 +        ldy CartRAMPtr+1 
- sty $01 +        sty $01 
- ldy CartRAMPtr +        ldy CartRAMPtr 
- sty $00 +        sty $00 
- lda PPUCNT0ZP +        lda PPUCNT0ZP 
- and #$FB ; PPU increment = 1 +        and #$FB        ; PPU increment = 1 
- sta PPUCNT0ZP +        sta PPUCNT0ZP 
- sta PPUControl0 +        sta PPUControl0 
- ldy PPUStatus   ; reset PPU addr flip/flop+        ldy PPUStatus   ; reset PPU addr flip/flop
  
 ; Copy room RAM #0 ($6000) to PPU Name Table #0 ($2000) ; Copy room RAM #0 ($6000) to PPU Name Table #0 ($2000)
  
- ldy #$20 +        ldy #$20 
- sty PPUAddress +        sty PPUAddress 
- ldy #$00 +        ldy #$00 
- sty PPUAddress +        sty PPUAddress 
- ldx #$04 ; prepare to write 4 pages+        ldx #$04        ; prepare to write 4 pages
 *       lda ($00),y *       lda ($00),y
- sta PPUIOReg +        sta PPUIOReg 
- iny +        iny 
- bne - +        bne - 
- inc $01 +        inc $01 
- dex +        dex 
- bne -+        bne -
  
- stx $91 +        stx $91 
- inx      ; X = 1 +        inx          ; X = 1 
- stx PalDataPending +        stx PalDataPending 
- stx SpareMem30 ;Not accessed by game. +        stx SpareMem30                  ;Not accessed by game. 
- inc MainRoutine ;SamusInit is next routine to run. +        inc MainRoutine                 ;SamusInit is next routine to run. 
- jmp ScreenOn+        jmp ScreenOn
  
 ; CopyPtrs ; CopyPtrs
Line 1493: Line 1493:
  
 CopyPtrs: CopyPtrs:
- ldx #$0D+        ldx #$0D
 *       lda AreaPointers+2,x *       lda AreaPointers+2,x
- sta RoomPtrTable,+        sta RoomPtrTable,
- dex +        dex 
- bpl - +        bpl - 
- rts+        rts
  
 ; DestroyEnemies ; DestroyEnemies
Line 1504: Line 1504:
  
 DestroyEnemies: DestroyEnemies:
-LC8BB: lda #$00 +LC8BB:  lda #$00 
- tax+        tax
 *       cpx #$48 *       cpx #$48
- bcs + +        bcs + 
- sta $97,x+        sta $97,x
 *       sta EnStatus,x *       sta EnStatus,x
- pha +        pha 
- pla +        pla 
- inx +        inx 
- bne -- +        bne -- 
- stx MetroidOnSamus ;Samus had no Metroid stuck to her. +        stx MetroidOnSamus              ;Samus had no Metroid stuck to her. 
- jmp $95AB+        jmp $95AB
  
 ; SamusInit ; SamusInit
Line 1522: Line 1522:
  
 SamusInit: SamusInit:
-LC8D1: lda #$08 +LC8D1:  lda #$08                        
-LC8D3:  sta MainRoutine ;SamusIntro will be executed next frame. +LC8D3:  sta MainRoutine                 ;SamusIntro will be executed next frame. 
-LC8D5: lda #$2C ;440 frames to fade in Samus(7.3 seconds). +LC8D5:  lda #$2C                        ;440 frames to fade in Samus(7.3 seconds). 
-LC8D7: sta Timer3 +LC8D7:  sta Timer3                      
-LC8D9: jsr IntroMusic ;($CBFD)Start the intro music. +LC8D9:  jsr IntroMusic                  ;($CBFD)Start the intro music. 
-LC8DC: ldy #sa_FadeIn0 +LC8DC:  ldy #sa_FadeIn0                 
- sty ObjAction ;Set Samus status as fading onto screen. +        sty ObjAction                   ;Set Samus status as fading onto screen. 
- ldx #$00 +        ldx #$00 
- stx SamusBlink +        stx SamusBlink 
- dex ;X = $FF +        dex                             ;X = $FF 
- stx $0728 +        stx $0728 
- stx $0730 +        stx $0730 
- stx $0732 +        stx $0732 
- stx $0738 +        stx $0738 
- stx EndTimerLo ;Set end timer bytes to #$FF as--> +        stx EndTimerLo                  ;Set end timer bytes to #$FF as--> 
- stx EndTimerHi ;escape timer not currently active. +        stx EndTimerHi                  ;escape timer not currently active. 
- stx $8B +        stx $8B 
- stx $8E +        stx $8E 
- ldy #$27 +        ldy #$27 
- lda InArea +        lda InArea 
- and #$0F +        and #$0F 
- beq + ;Branch if Samus starting in Brinstar. +        beq +                           ;Branch if Samus starting in Brinstar. 
- lsr ScrollDir ;If not in Brinstar, change scroll direction from left--> +        lsr ScrollDir                   ;If not in Brinstar, change scroll direction from left--> 
- ldy #$2F ;to down. and set PPU for horizontal mirroring. +        ldy #$2F                        ;to down. and set PPU for horizontal mirroring. 
-*       sty MirrorCntrl +*       sty MirrorCntrl                 
- sty MaxMissilePickup +        sty MaxMissilePickup 
- sty MaxEnergyPickup +        sty MaxEnergyPickup 
- lda $95D9 ;Samus' initial vertical position +        lda $95D9                       ;Samus' initial vertical position 
- sta ObjectY +        sta ObjectY                     
- lda #$80 ;Samus' initial horizontal position +        lda #$80                        ;Samus' initial horizontal position 
- sta ObjectX +        sta ObjectX                     
- lda PPUCNT0ZP +        lda PPUCNT0ZP                   
- and #$01 ;Set Samus' name table position to current name table--> +        and #$01                        ;Set Samus' name table position to current name table--> 
- sta ObjectHi ;active in PPU. +        sta ObjectHi                    ;active in PPU. 
- lda #$00 +        lda #$00                        
- sta HealthLo ;Starting health is--> +        sta HealthLo                    ;Starting health is--> 
- lda #$03 ;set to 30 units. +        lda #$03                        ;set to 30 units. 
- sta HealthHi +        sta HealthHi                    
-*       rts ;+*       rts                             ;
  
 ;------------------------------------[ Main game engine ]-------------------------------------------- ;------------------------------------[ Main game engine ]--------------------------------------------
  
 GameEngine: GameEngine:
-LC92B: jsr ScrollDoor ;($E1F1)Scroll doors, if needed. 2 routine calls scrolls--> +LC92B:  jsr ScrollDoor                  ;($E1F1)Scroll doors, if needed. 2 routine calls scrolls--> 
-LC92E: jsr ScrollDoor ;($E1F1)twice as fast as 1 routine call.+LC92E:  jsr ScrollDoor                  ;($E1F1)twice as fast as 1 routine call.
  
-LC931: lda NARPASSWORD +LC931:  lda NARPASSWORD                 
-LC934: beq + +LC934:  beq +                           
-LC936: lda #$03 ;The following code is only accessed if --> +LC936:  lda #$03                        ;The following code is only accessed if --> 
-LC938: sta HealthHi ;NARPASSWORD has been entered at the --> +LC938:  sta HealthHi                    ;NARPASSWORD has been entered at the --> 
-LC93B: lda #$FF ;password screen. Gives you new health,--> +LC93B:  lda #$FF                        ;password screen. Gives you new health,--> 
-LC93D: sta SamusGear ;missiles and every power-up every frame. +LC93D:  sta SamusGear                   ;missiles and every power-up every frame. 
-LC940: lda #$05 +LC940:  lda #$05                        
-LC942: sta MissileCount ;+LC942:  sta MissileCount                ;
  
-LC945:* jsr UpdateWorld ;($CB29)Update Samus, enemies and room tiles. +LC945:* jsr UpdateWorld                 ;($CB29)Update Samus, enemies and room tiles. 
-LC948: lda MiniBossKillDelay +LC948:  lda MiniBossKillDelay           
-LC94B: ora PowerUpDelay ;Check if mini boss was just killed or powerup aquired.--> +LC94B:  ora PowerUpDelay                ;Check if mini boss was just killed or powerup aquired.--> 
-LC94E: beq + ;If not, branch.+LC94E:  beq +                           ;If not, branch.
  
-LC950: lda #$00 +LC950:  lda #$00                        
-LC952: sta MiniBossKillDelay ;Reset delay indicators. +LC952:  sta MiniBossKillDelay           ;Reset delay indicators. 
-LC955: sta PowerUpDelay +LC955:  sta PowerUpDelay                
-LC958: lda #$18 ;Set timer for 240 frames(4 seconds). +LC958:  lda #$18                        ;Set timer for 240 frames(4 seconds). 
-LC95A: ldx #$03 ;GameEngine routine to run after delay expires +LC95A:  ldx #$03                        ;GameEngine routine to run after delay expires 
-LC95C: jsr SetTimer ;($C4AA)Set delay timer and game engine routine.+LC95C:  jsr SetTimer                    ;($C4AA)Set delay timer and game engine routine.
  
-LC95F:* lda ObjAction ;Check is Samus is dead. +LC95F:* lda ObjAction                   ;Check is Samus is dead. 
-LC962: cmp #sa_Dead2   ;Is Samus dead?--> +LC962:  cmp #sa_Dead2                   ;Is Samus dead?--> 
-LC964: bne ---     ;exit if not. +LC964:  bne ---                         ;exit if not. 
-LC966: lda AnimDelay ;Is Samus still exploding?--> +LC966:  lda AnimDelay                   ;Is Samus still exploding?--> 
-LC969: bne --- ;Exit if still exploding. +LC969:  bne ---                         ;Exit if still exploding. 
-LC96B: jsr SilenceMusic ;Turn off music. +LC96B:  jsr SilenceMusic                ;Turn off music. 
-LC96E: lda MotherBrainStatus +LC96E:  lda MotherBrainStatus           
-LC970: cmp #$0A ;Is mother brain already dead? If so, branch. +LC970:  cmp #$0A                        ;Is mother brain already dead? If so, branch. 
-LC972: beq + +LC972:  beq +                           
-LC974: lda #$04 ;Set timer for 40 frames (.667 seconds). +LC974:  lda #$04                        ;Set timer for 40 frames (.667 seconds). 
-LC976: ldx #$04 ;GameOver routine to run after delay expires. +LC976:  ldx #$04                        ;GameOver routine to run after delay expires. 
-LC978: jmp SetTimer ;($C4AA)Set delay timer and run game over routine.+LC978:  jmp SetTimer                    ;($C4AA)Set delay timer and run game over routine.
  
-LC97B:* inc MainRoutine ;Next routine to run is GameOver. +LC97B:* inc MainRoutine                 ;Next routine to run is GameOver. 
-LC97D: rts ;+LC97D:  rts                             ;
  
 ;----------------------------------------[ Update age ]---------------------------------------------- ;----------------------------------------[ Update age ]----------------------------------------------
Line 1613: Line 1613:
  
 UpdateAge: UpdateAge:
-LC97E: lda GameMode +LC97E:  lda GameMode                    
-LC980: bne ++ ;Exit if at title/password screen. +LC980:  bne ++                          ;Exit if at title/password screen. 
-LC982: lda MainRoutine +LC982:  lda MainRoutine                 
-LC984: cmp #$03 ;Is game engine running? +LC984:  cmp #$03                        ;Is game engine running? 
-LC986: bne ++ ;If not, don't update age. +LC986:  bne ++                          ;If not, don't update age. 
-LC988: ldx FrameCount ;Only update age when FrameCount is zero--> +LC988:  ldx FrameCount                  ;Only update age when FrameCount is zero--> 
-LC98A: bne ++ ;(which is approx. every 4.266666666667 seconds). +LC98A:  bne ++                          ;(which is approx. every 4.266666666667 seconds). 
-LC98C: inc SamusAge,x ;Minor Age = Minor Age + 1. +LC98C:  inc SamusAge,                 ;Minor Age = Minor Age + 1. 
-LC98F: lda SamusAge +LC98F:  lda SamusAge                    
-LC992: cmp #$D0 ;Has Minor Age reached $D0?--> +LC992:  cmp #$D0                        ;Has Minor Age reached $D0?--> 
-LC994: bcc ++ ;If not, we're done.--> +LC994:  bcc ++                          ;If not, we're done.--> 
-LC996: lda #$00 ;Else reset minor age. +LC996:  lda #$00                        ;Else reset minor age. 
-LC998: sta SamusAge +LC998:  sta SamusAge                    
-LC99B:* cpx #$03 +LC99B:* cpx #$03                        
-LC99D: bcs + ;Loop to update middle age and possibly major age. +LC99D:  bcs +                           ;Loop to update middle age and possibly major age. 
-LC99F: inx +LC99F:  inx                             
-LC9A0: inc SamusAge,x +LC9A0:  inc SamusAge,                 
-LC9A3: beq -     ;Branch if middle age overflowed, need to increment-->  +LC9A3:  beq -                           ;Branch if middle age overflowed, need to increment-->  
-LC9A5:* rts ;major age too. Else exit.+LC9A5:* rts                             ;major age too. Else exit.
  
 ;-------------------------------------------[ Game over ]-------------------------------------------- ;-------------------------------------------[ Game over ]--------------------------------------------
  
 GameOver: GameOver:
-LC9A6: lda #$1C ;GameOver is the next routine to run. +LC9A6:  lda #$1C                        ;GameOver is the next routine to run. 
-LC9A8: sta TitleRoutine +LC9A8:  sta TitleRoutine                
-LC9AA: lda #$01 +LC9AA:  lda #$01                        
-LC9AC: sta SwitchPending ;Prepare to switch to title memory page. +LC9AC:  sta SwitchPending               ;Prepare to switch to title memory page. 
-LC9AE: jmp ScreenOff ;($C439)Turn screen off.+LC9AE:  jmp ScreenOff                   ;($C439)Turn screen off.
  
 ;------------------------------------------[ Pause mode ]-------------------------------------------- ;------------------------------------------[ Pause mode ]--------------------------------------------
  
 PauseMode: PauseMode:
-LC9B1: lda Joy2Status ;Load buttons currently being pressed on joypad 2. +LC9B1:  lda Joy2Status                  ;Load buttons currently being pressed on joypad 2. 
-LC9B3: and #$88 +LC9B3:  and #$88                        
-LC9B5: eor #$88 ;both A & UP pressed?--> +LC9B5:  eor #$88                        ;both A & UP pressed?--> 
-LC9B7: bne Exit14 ;Exit if not. +LC9B7:  bne Exit14                      ;Exit if not. 
-LC9B9: ldy EndTimerHi +LC9B9:  ldy EndTimerHi                  
-LC9BC: iny ;Is escape timer active?--> +LC9BC:  iny                             ;Is escape timer active?--> 
-LC9BD: bne Exit14 ;Sorry, can't quit if this is during escape scence. +LC9BD:  bne Exit14                      ;Sorry, can't quit if this is during escape scence. 
-LC9BF: sta GamePaused ;Clear pause game indicator. +LC9BF:  sta GamePaused                  ;Clear pause game indicator. 
-LC9C1: inc MainRoutine ;Display password is the next routine to run.+LC9C1:  inc MainRoutine                 ;Display password is the next routine to run.
  
 Exit14: Exit14:
-LC9C3: rts ;Exit for routines above and below.+LC9C3:  rts                             ;Exit for routines above and below.
  
 ;------------------------------------------[ GoPassword ]-------------------------------------------- ;------------------------------------------[ GoPassword ]--------------------------------------------
  
 GoPassword: GoPassword:
-LC9C4: lda #$19 ;DisplayPassword is next routine to run. +LC9C4:  lda #$19                        ;DisplayPassword is next routine to run. 
-LC9C6: sta TitleRoutine +LC9C6:  sta TitleRoutine                
-LC9C8: lda #$01 +LC9C8:  lda #$01                        
-LC9CA: sta SwitchPending ;Prepare to switch to intro memory page. +LC9CA:  sta SwitchPending               ;Prepare to switch to intro memory page. 
-LC9CC: lda NoiseSFXFlag +LC9CC:  lda NoiseSFXFlag                
-LC9CF: ora #$01 ;Silence music. +LC9CF:  ora #$01                        ;Silence music. 
-LC9D1: sta NoiseSFXFlag +LC9D1:  sta NoiseSFXFlag                
-LC9D4: jmp ScreenOff ;($C439)Turn off screen.+LC9D4:  jmp ScreenOff                   ;($C439)Turn off screen.
  
 ;-----------------------------------------[ Samus intro ]-------------------------------------------- ;-----------------------------------------[ Samus intro ]--------------------------------------------
  
 SamusIntro: SamusIntro:
-LC9D7: jsr EraseAllSprites ;($C1A3)Clear all sprites off screen. +LC9D7:  jsr EraseAllSprites             ;($C1A3)Clear all sprites off screen. 
-LC9DA: ldy ObjAction ;Load Samus' fade in status. +LC9DA:  ldy ObjAction                   ;Load Samus' fade in status. 
-LC9DD: lda Timer3 +LC9DD:  lda Timer3                      
-LC9E0: bne + ;Branch if Intro still playing. +LC9E0:  bne +                           ;Branch if Intro still playing. 
- +        
 ;Fade in complete. ;Fade in complete.
-LC9E2: sta ItemRoomMusicStatus ;Make sure item room music is not playing. +LC9E2:  sta ItemRoomMusicStatus         ;Make sure item room music is not playing. 
-LC9E4: lda #sa_Begin ;Samus facing forward and can't be hurt. +LC9E4:  lda #sa_Begin                   ;Samus facing forward and can't be hurt. 
-LC9E6: sta ObjAction +LC9E6:  sta ObjAction                   
-LC9E8: jsr StartMusic ;($D92C)Start main music. +LC9E8:  jsr StartMusic                  ;($D92C)Start main music. 
-LC9EB: jsr SelectSamusPal ;($CB73)Select proper Samus palette. +LC9EB:  jsr SelectSamusPal              ;($CB73)Select proper Samus palette. 
-LC9EE: lda #$03 +LC9EE:  lda #$03                        
-LC9F0: sta MainRoutine ;Game engine will be called next frame.+LC9F0:  sta MainRoutine                 ;Game engine will be called next frame.
  
 ;Still fading in. ;Still fading in.
-LC9F2:* cmp #$1F ;When 310 frames left of intro, display Samus. +LC9F2:* cmp #$1F                        ;When 310 frames left of intro, display Samus. 
-LC9F4: bcs Exit14 ;Branch if not time to start drawing Samus. +LC9F4:  bcs Exit14                      ;Branch if not time to start drawing Samus. 
-LC9F6: cmp SamusFadeInTimeTbl-20,y ;sa_FadeIn0 is beginning of table. +LC9F6:  cmp SamusFadeInTimeTbl-20,    ;sa_FadeIn0 is beginning of table. 
-LC9F9: bne + ;Every time Timer3 equals one of the entries in the table--> +LC9F9:  bne +                           ;Every time Timer3 equals one of the entries in the table--> 
-LC9FB: inc ObjAction ;below, change the palette used to color Samus. +LC9FB:  inc ObjAction                   ;below, change the palette used to color Samus. 
-LC9FE: sty PalDataPending +LC9FE:  sty PalDataPending              
-LCA00:* lda FrameCount ;Is game currently on an odd frame?--> +LCA00:* lda FrameCount                  ;Is game currently on an odd frame?--> 
-LCA02: lsr ;If not, branch to exit. +LCA02:  lsr                             ;If not, branch to exit. 
-LCA03: bcc Exit14 ;Only display Samus on odd frames [the blink effect]. +LCA03:  bcc Exit14                      ;Only display Samus on odd frames [the blink effect]. 
-LCA05: lda #an_SamusFront ;Samus front animation is animation to display.--> +LCA05:  lda #an_SamusFront              ;Samus front animation is animation to display.--> 
-LCA07: jsr SetSamusAnim ;($CF6B)while fading in. +LCA07:  jsr SetSamusAnim                ;($CF6B)while fading in. 
-LCA0A: lda #$00 +LCA0A:  lda #$00                        
-LCA0C: sta SpritePagePos ;Samus sprites start at Sprite00RAM. +LCA0C:  sta SpritePagePos               ;Samus sprites start at Sprite00RAM. 
-LCA0E: sta PageIndex ;Samus RAM is first set of RAM. +LCA0E:  sta PageIndex                   ;Samus RAM is first set of RAM. 
-LCA10: jmp AnimDrawObject ;($DE47)Draw Samus on screen.+LCA10:  jmp AnimDrawObject              ;($DE47)Draw Samus on screen.
  
 ;The following table marks the time remaining in Timer3 when a palette change should occur during ;The following table marks the time remaining in Timer3 when a palette change should occur during
Line 1708: Line 1708:
  
 SamusFadeInTimeTbl: SamusFadeInTimeTbl:
-LCA13: .byte $1E,$14,$0B,$04,$FF+LCA13:  .byte $1E,$14,$0B,$04,$FF
  
 ;---------------------------------[ Check if game engine running ]----------------------------------- ;---------------------------------[ Check if game engine running ]-----------------------------------
  
 IsEngineRunning: IsEngineRunning:
-LCA18: ldy MainRoutine ;If Samus is fading in or the wait timer is--> +LCA18:  ldy MainRoutine                 ;If Samus is fading in or the wait timer is--> 
-LCA1A: cpy #$07 ;active, return from routine. +LCA1A:  cpy #$07                        ;active, return from routine. 
-LCA1C: beq + +LCA1C:  beq +                           
-LCA1E: cpy #$03 ;Is game engine running? +LCA1E:  cpy #$03                        ;Is game engine running? 
-LCA20: beq ++ ;If yes, branch to SwitchBank. +LCA20:  beq ++                          ;If yes, branch to SwitchBank. 
-LCA22:* rts ;Exit if can't switch bank.+LCA22:* rts                             ;Exit if can't switch bank.
  
 ;-----------------------------------------[ Switch bank ]-------------------------------------------- ;-----------------------------------------[ Switch bank ]--------------------------------------------
Line 1725: Line 1725:
  
 SwitchBank: SwitchBank:
-LCA23:* sta InArea ;Save current area Samus is in. +LCA23:* sta InArea                      ;Save current area Samus is in. 
-LCA25: and #$0F +LCA25:  and #$0F                        
-LCA27: tay ;Use 4 LSB to load switch pending offset from BankTable table. +LCA27:  tay                             ;Use 4 LSB to load switch pending offset from BankTable table. 
-LCA28: lda BankTable,y ;Base is $CA30. +LCA28:  lda BankTable,                ;Base is $CA30. 
-LCA2B: sta SwitchPending ;Store switch data. +LCA2B:  sta SwitchPending               ;Store switch data. 
-LCA2D: jmp CheckSwitch ;($C4DE)Switch lower 16KB to appropriate memory page.+LCA2D:  jmp CheckSwitch                 ;($C4DE)Switch lower 16KB to appropriate memory page.
  
 ;Table used by above subroutine. ;Table used by above subroutine.
Line 1736: Line 1736:
  
 BankTable: BankTable:
-LCA30: .byte $02 ;Brinstar. +LCA30:  .byte $02                       ;Brinstar. 
-LCA31: .byte $03 ;Norfair. +LCA31:  .byte $03                       ;Norfair. 
-LCA32: .byte $05 ;Kraid hideout. +LCA32:  .byte $05                       ;Kraid hideout. 
-LCA33: .byte $04 ;Tourian. +LCA33:  .byte $04                       ;Tourian. 
-LCA34: .byte $06 ;Ridley hideout.+LCA34:  .byte $06                       ;Ridley hideout.
  
 ;----------------------------------[ Saved game routines (not used) ]-------------------------------- ;----------------------------------[ Saved game routines (not used) ]--------------------------------
  
 AccessSavedGame: AccessSavedGame:
-LCA35: pha ;Save two copies of A. Why? Who knows. This code is--> +LCA35:  pha                             ;Save two copies of A. Why? Who knows. This code is--> 
-LCA36: pha ;Never implemented. A contains data slot to work on. +LCA36:  pha                             ;Never implemented. A contains data slot to work on. 
-LCA37: jsr GetGameDataIndex ;($CA96)Get index to this save game Samus data info. +LCA37:  jsr GetGameDataIndex            ;($CA96)Get index to this save game Samus data info. 
-LCA3A: lda EraseGame +LCA3A:  lda EraseGame                   
-LCA3D: bpl + ;Is MSB set? If so, erase saved game data. Else branch. +LCA3D:  bpl +                           ;Is MSB set? If so, erase saved game data. Else branch. 
-LCA3F: and #$01 +LCA3F:  and #$01                        
-LCA41: sta EraseGame ;Clear MSB so saved game data is not erased again. +LCA41:  sta EraseGame                   ;Clear MSB so saved game data is not erased again. 
-LCA44: jsr EraseAllGameData ;($CAA1)Erase selected saved game data. +LCA44:  jsr EraseAllGameData            ;($CAA1)Erase selected saved game data. 
-LCA47: lda #$01 ;Indicate this saved game has been erased.--> +LCA47:  lda #$01                        ;Indicate this saved game has been erased.--> 
-LCA49: sta $7800,y ;Saved game 0=$780C, saved game 1=$781C, saved game 2=$782C.  +LCA49:  sta $7800,                    ;Saved game 0=$780C, saved game 1=$781C, saved game 2=$782C.  
-LCA4C:* lda MainRoutine +LCA4C:* lda MainRoutine                 
-LCA4E: cmp #$01 ;If initializing the area at the start of the game, branch--> +LCA4E:  cmp #$01                        ;If initializing the area at the start of the game, branch--> 
-LCA50: beq +++ ;to load Samus' saved game info.+LCA50:  beq +++                         ;to load Samus' saved game info.
  
 SaveGameData: SaveGameData:
-LCA52: lda InArea ;Save game based on current area Samus is in. Don't know why. +LCA52:  lda InArea                      ;Save game based on current area Samus is in. Don't know why. 
-LCA54: jsr SavedDataBaseAddr ;($CAC6)Find index to unique item history for this saved game. +LCA54:  jsr SavedDataBaseAddr           ;($CAC6)Find index to unique item history for this saved game. 
-LCA57: ldy #$3F ;Prepare to save unique item history which is 64 bytes--> +LCA57:  ldy #$3F                        ;Prepare to save unique item history which is 64 bytes--> 
-LCA59:* lda NumberOfUniqueItems,y ;in length. +LCA59:* lda NumberOfUniqueItems,      ;in length. 
-LCA5C: sta ($00),y ;Save unique item history in appropriate saved game slot. +LCA5C:  sta ($00),                    ;Save unique item history in appropriate saved game slot. 
-LCA5E: dey +LCA5E:  dey                             
-LCA5F: bpl - ;Loop until unique item history transfer complete. +LCA5F:  bpl -                           ;Loop until unique item history transfer complete. 
-LCA61: ldy SamusDataIndex ;Prepare to save Samus' data. +LCA61:  ldy SamusDataIndex              ;Prepare to save Samus' data. 
-LCA64: ldx #$00 +LCA64:  ldx #$00                        
-LCA66:* lda SamusStat00,x +LCA66:* lda SamusStat00,              
-LCA69: sta SamusData,y ;Save Samus' data in appropriate saved game slot. +LCA69:  sta SamusData,                ;Save Samus' data in appropriate saved game slot. 
-LCA6C: iny +LCA6C:  iny                             
-LCA6D: inx +LCA6D:  inx                             
-LCA6E: cpx #$10 +LCA6E:  cpx #$10                        
-LCA70: bne - ;Loop until Samus' data transfer complete.+LCA70:  bne -                           ;Loop until Samus' data transfer complete.
  
 LoadGameData: LoadGameData:
-LCA72:* pla ;Restore A to find appropriate saved game to load. +LCA72:* pla                             ;Restore A to find appropriate saved game to load. 
-LCA73: jsr SavedDataBaseAddr ;($CAC6)Find index to unique item history for this saved game. +LCA73:  jsr SavedDataBaseAddr           ;($CAC6)Find index to unique item history for this saved game. 
-LCA76: ldy #$3F ;Prepare to load unique item history which is 64 bytes--> +LCA76:  ldy #$3F                        ;Prepare to load unique item history which is 64 bytes--> 
-LCA78:* lda ($00),y ;in length. +LCA78:* lda ($00),                    ;in length. 
-LCA7A: sta NumberOfUniqueItems,y ;Loop until unique item history is loaded. +LCA7A:  sta NumberOfUniqueItems,      ;Loop until unique item history is loaded. 
-LCA7D: dey +LCA7D:  dey                             
-LCA7E: bpl - +LCA7E:  bpl -                           
-LCA80: bmi + ;Branch always. +LCA80:  bmi +                           ;Branch always. 
-LCA82: pha +LCA82:  pha                             
-LCA83:* ldy SamusDataIndex ;Prepare to load Samus' data. +LCA83:* ldy SamusDataIndex              ;Prepare to load Samus' data. 
-LCA86: ldx #$00 +LCA86:  ldx #$00                        
-LCA88:* lda SamusData,y +LCA88:* lda SamusData,                
-LCA8B: sta SamusStat00,x ;Load Samus' data from appropriate saved game slot. +LCA8B:  sta SamusStat00,              ;Load Samus' data from appropriate saved game slot. 
-LCA8E: iny +LCA8E:  iny                             
-LCA8F: inx +LCA8F:  inx                             
-LCA90: cpx #$10 +LCA90:  cpx #$10                        
-LCA92: bne - ;Loop until Samus' data transfer complete. +LCA92:  bne -                           ;Loop until Samus' data transfer complete. 
-LCA94: pla +LCA94:  pla                             
-LCA95: rts ;+LCA95:  rts                             ;
  
 GetGameDataIndex: GetGameDataIndex:
-LCA96: lda DataSlot +LCA96:  lda DataSlot                    
-LCA99: asl ;A contains the save game slot to work on (0 1 or 2).--> +LCA99:  asl                             ;A contains the save game slot to work on (0 1 or 2).--> 
-LCA9A: asl ;This number is transferred to the upper four bits to--> +LCA9A:  asl                             ;This number is transferred to the upper four bits to--> 
-LCA9B: asl ;find the offset for Samus' data for this particular--> +LCA9B:  asl                             ;find the offset for Samus' data for this particular--> 
-LCA9C: asl ;saved game (#$00, #$10 or #$20). +LCA9C:  asl                             ;saved game (#$00, #$10 or #$20). 
-LCA9D: sta SamusDataIndex +LCA9D:  sta SamusDataIndex              
-LCAA0: rts ;+LCAA0:  rts                             ;
  
 EraseAllGameData: EraseAllGameData:
-LCAA1: lda #$00 ;Always start at saved game 0. Erase all 3 saved games. +LCAA1:  lda #$00                        ;Always start at saved game 0. Erase all 3 saved games. 
-LCAA3: jsr SavedDataBaseAddr ;($CAC6)Find index to unique item history for this saved game. +LCAA3:  jsr SavedDataBaseAddr           ;($CAC6)Find index to unique item history for this saved game. 
-LCAA6: inc $03 ;Prepare to erase saved game info at $6A00 and above. +LCAA6:  inc $03                         ;Prepare to erase saved game info at $6A00 and above. 
-LCAA8: ldy #$00 ;Fill saved game data with #$00. +LCAA8:  ldy #$00                        ;Fill saved game data with #$00. 
-LCAAA: tya +LCAAA:  tya                             
-LCAAB:* sta ($00),y ;Erase unique item histories from $69B4 to $69FF.  +LCAAB:* sta ($00),                    ;Erase unique item histories from $69B4 to $69FF.  
-LCAAD: cpy #$40 +LCAAD:  cpy #$40                        
-LCAAF: bcs + ;IF 64 bytes alrady erased, no need to erase any more--> +LCAAF:  bcs +                           ;IF 64 bytes alrady erased, no need to erase any more--> 
-LCAB1: sta ($02),y ;in the $6A00 and above range. +LCAB1:  sta ($02),                    ;in the $6A00 and above range. 
-LCAB3:* iny +LCAB3:* iny                             
-LCAB4: bne -- ;Lop until all saved game data is erased. +LCAB4:  bne --                          ;Lop until all saved game data is erased. 
-LCAB6: ldy SamusDataIndex ;Load proper index to desired Samus data to erase. +LCAB6:  ldy SamusDataIndex              ;Load proper index to desired Samus data to erase. 
-LCAB9: ldx #$00 +LCAB9:  ldx #$00                        
-LCABB: txa +LCABB:  txa                             
-LCABC:* sta SamusData,y ;Erase Samus' data. +LCABC:* sta SamusData,                ;Erase Samus' data. 
-LCABF: iny +LCABF:  iny                             
-LCAC0: inx +LCAC0:  inx                             
-LCAC1: cpx #$0C +LCAC1:  cpx #$0C                        
-LCAC3: bne - ;Loop until all data is erased. +LCAC3:  bne -                           ;Loop until all data is erased. 
-LCAC5: rts ;+LCAC5:  rts                             ;
  
 ;This routine finds the base address of the unique item history for the desired saved game (0, 1 or 2). ;This routine finds the base address of the unique item history for the desired saved game (0, 1 or 2).
Line 1833: Line 1833:
  
 SavedDataBaseAddr: SavedDataBaseAddr:
-LCAC6: pha ;Save contents of A. +LCAC6:  pha                             ;Save contents of A. 
-LCAC7: lda DataSlot ;Load saved game data slot to load. +LCAC7:  lda DataSlot                    ;Load saved game data slot to load. 
-LCACA: asl ;*2. Table values below are two bytes. +LCACA:  asl                             ;*2. Table values below are two bytes. 
-LCACB: tax +LCACB:  tax                             
-LCACC: lda SavedDataTable,x +LCACC:  lda SavedDataTable,           
-LCACF: sta $00 ;Load $0000 and $0002 with base addresses from--> +LCACF:  sta $00                         ;Load $0000 and $0002 with base addresses from--> 
-LCAD1: sta $02 ;table below($69B4). +LCAD1:  sta $02                         ;table below($69B4). 
-LCAD3: lda SavedDataTable+1,x +LCAD3:  lda SavedDataTable+1,         
-LCAD6: sta $01 +LCAD6:  sta $01                         
-LCAD8: sta $03 +LCAD8:  sta $03                         
-LCADA: pla ;Restore A. +LCADA:  pla                             ;Restore A. 
-LCADB: and #$0F ;Discard upper four bits in A. +LCADB:  and #$0F                        ;Discard upper four bits in A. 
-LCADD: tax ;X used for counting loop. +LCADD:  tax                             ;X used for counting loop. 
-LCADE: beq +++ ;Exit if at saved game 0.  No further calculations required. +LCADE:  beq +++                         ;Exit if at saved game 0.  No further calculations required. 
-LCAE0:* lda $00 +LCAE0:* lda $00                         
-LCAE2: clc +LCAE2:  clc                             
-LCAE3: adc #$40 +LCAE3:  adc #$40                        
-LCAE5: sta $00 ;Loop to add #$40 to base address of $69B4 in order to find--> +LCAE5:  sta $00                         ;Loop to add #$40 to base address of $69B4 in order to find--> 
-LCAE7: bcc + ;the proper base address for this saved game data. (save--> +LCAE7:  bcc +                           ;the proper base address for this saved game data. (save--> 
-LCAE9: inc $01 ;slot 0 = $69B4, save slot 1 = $69F4, save slot 2 = $6A34). +LCAE9:  inc $01                         ;slot 0 = $69B4, save slot 1 = $69F4, save slot 2 = $6A34). 
-LCAEB:* dex +LCAEB:* dex                             
-LCAEC: bne -- +LCAEC:  bne --                          
-LCAEE:* rts ;+LCAEE:* rts                             ;
  
 ;Table used by above subroutine to find base address to load saved game data from. The slot 0 ;Table used by above subroutine to find base address to load saved game data from. The slot 0
Line 1861: Line 1861:
  
 SavedDataTable: SavedDataTable:
-LCAEF: .word ItmeHistory ;($69B4)Base for save game slot 0. +LCAEF:  .word ItmeHistory               ;($69B4)Base for save game slot 0. 
-LCAF1: .word ItmeHistory ;($69B4)Base for save game slot 1. +LCAF1:  .word ItmeHistory               ;($69B4)Base for save game slot 1. 
-LCAF3: .word ItmeHistory ;($69B4)Base for save game slot 2.+LCAF3:  .word ItmeHistory               ;($69B4)Base for save game slot 2.
  
 ;----------------------------------------[ Choose ending ]------------------------------------------- ;----------------------------------------[ Choose ending ]-------------------------------------------
Line 1869: Line 1869:
 ;Determine what type of ending is to be shown, based on Samus' age. ;Determine what type of ending is to be shown, based on Samus' age.
 ChooseEnding: ChooseEnding:
-LCAF5: ldy #$01 +LCAF5:  ldy #$01                        
-LCAF7:* lda SamusAge+2 ;If SamusAge+2 anything but #$00, load worst--> +LCAF7:* lda SamusAge+2                  ;If SamusAge+2 anything but #$00, load worst--> 
-LCAFA: bne + ;ending(more than 37 hours of gameplay). +LCAFA:  bne +                           ;ending(more than 37 hours of gameplay). 
-LCAFC: lda SamusAge+1 +LCAFC:  lda SamusAge+1                  
-LCAFF: cmp AgeTable-1,y ;Loop four times to determine--> +LCAFF:  cmp AgeTable-1,               ;Loop four times to determine--> 
-LCB02: bcs + ;ending type from table below. +LCB02:  bcs +                           ;ending type from table below. 
-LCB04: iny +LCB04:  iny                             
-LCB05: cpy #$05 +LCB05:  cpy #$05                        
-LCB07: bne - +LCB07:  bne -                           
-LCB09:* sty EndingType ;Store the ending # (1..5), 5=best ending +LCB09:* sty EndingType                  ;Store the ending # (1..5), 5=best ending 
-LCB0C: lda #$00 +LCB0C:  lda #$00                        
-LCB0E: cpy #$04 ;Was the best or 2nd best ending achieved? +LCB0E:  cpy #$04                        ;Was the best or 2nd best ending achieved? 
-LCB10: bcc + ;Branch if not (suit stays on) +LCB10:  bcc +                           ;Branch if not (suit stays on) 
-LCB12: lda #$01 +LCB12:  lda #$01                        
-LCB14:* sta JustInBailey ;Suit OFF, baby! +LCB14:* sta JustInBailey                ;Suit OFF, baby! 
-LCB17: rts ;+LCB17:  rts                             ;
  
 ;Table used by above subroutine to determine ending type. ;Table used by above subroutine to determine ending type.
 AgeTable: AgeTable:
-LCB18: .byte $7A ;Max. 37 hours +LCB18:  .byte $7A                       ;Max. 37 hours 
-LCB19: .byte $16 ;Max. 6.7 hours +LCB19:  .byte $16                       ;Max. 6.7 hours 
-LCB1A: .byte $0A ;Max. 3.0 hours +LCB1A:  .byte $0A                       ;Max. 3.0 hours 
-LCB1B: .byte $04 ;Best ending. Max. 1.2 hours+LCB1B:  .byte $04                       ;Best ending. Max. 1.2 hours
  
 ;--------------------------------[ Clear screen data (not used) ]------------------------------------ ;--------------------------------[ Clear screen data (not used) ]------------------------------------
  
 ClearScreenData: ClearScreenData:
-LCB1C: jsr ScreenOff ;($C439)Turn off screen. +LCB1C:  jsr ScreenOff                   ;($C439)Turn off screen. 
-LCB1F: lda #$FF +LCB1F:  lda #$FF                        
-LCB21: sta $00 ;Prepare to fill nametable with #$FF. +LCB21:  sta $00                         ;Prepare to fill nametable with #$FF. 
-LCB23: jsr ClearNameTable ;($C175)Clear selected nametable. +LCB23:  jsr ClearNameTable              ;($C175)Clear selected nametable. 
-LCD26: jmp EraseAllSprites ;($C1A3)Clear sprite data.+LCD26:  jmp EraseAllSprites             ;($C1A3)Clear sprite data.
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 1907: Line 1907:
  
 UpdateWorld: UpdateWorld:
-LCB29: ldx #$00 ;Set start of sprite RAM to $0200. +LCB29:  ldx #$00                        ;Set start of sprite RAM to $0200. 
-LCB2B: stx SpritePagePos ;+LCB2B:  stx SpritePagePos               ;
  
-LCB2D: jsr UpdateEnemies ;($F345)Display of enemies. +LCB2D:  jsr UpdateEnemies               ;($F345)Display of enemies. 
-LCB30: jsr UpdateProjectiles ;($D4BF)Display of bullets/missiles/bombs. +LCB30:  jsr UpdateProjectiles           ;($D4BF)Display of bullets/missiles/bombs. 
-LCB33: jsr UpdateSamus ;($CC0D)Display/movement of Samus. +LCB33:  jsr UpdateSamus                 ;($CC0D)Display/movement of Samus. 
-LCB36: jsr AreaRoutine ;($95C3)Area specific routine. +LCB36:  jsr AreaRoutine                 ;($95C3)Area specific routine. 
-LCB39: jsr UpdateElevator ;($D7B3)Display of elevators. +LCB39:  jsr UpdateElevator              ;($D7B3)Display of elevators. 
-LCB3C: jsr UpdateStatues ;($D9D4)Display of Ridley & Kraid statues. +LCB3C:  jsr UpdateStatues               ;($D9D4)Display of Ridley & Kraid statues. 
-LCB3F: jsr $FA9D       ; destruction of enemies +LCB3F:  jsr $FA9D       ; destruction of enemies 
-LCB42: jsr LFC65       ; update of Mellow/Memu enemies +LCB42:  jsr LFC65       ; update of Mellow/Memu enemies 
-LCB45: jsr LF93B +LCB45:  jsr LF93B 
-LCB48: jsr LFBDD       ; destruction of green spinners +LCB48:  jsr LFBDD       ; destruction of green spinners 
-LCB4B: jsr SamusEnterDoor ;($8B13)Check if Samus entered a door. +LCB4B:  jsr SamusEnterDoor              ;($8B13)Check if Samus entered a door. 
-LCB4E: jsr $8B79       ; display of doors +LCB4E:  jsr $8B79       ; display of doors 
-LCB51: jsr UpdateTiles ; tile de/regeneration +LCB51:  jsr UpdateTiles ; tile de/regeneration 
-LCB54: jsr LF034       ; Samus <--> enemies crash detection +LCB54:  jsr LF034       ; Samus <--> enemies crash detection 
-LCB57: jsr DisplayBar ;($E0C1)Display of status bar. +LCB57:  jsr DisplayBar                  ;($E0C1)Display of status bar. 
- jsr LFAF2 +        jsr LFAF2 
- jsr CheckMissileToggle +        jsr CheckMissileToggle 
- jsr UpdateItems ;($DB37)Display of power-up items. +        jsr UpdateItems                 ;($DB37)Display of power-up items. 
- jsr LFDE3+        jsr UpdateTourianItems          ;($FDE3)
  
 ;Clear remaining sprite RAM ;Clear remaining sprite RAM
- ldx SpritePagePos +        ldx SpritePagePos 
- lda #$F4+        lda #$F4
 *       sta Sprite00RAM,x *       sta Sprite00RAM,x
- jsr Xplus4       ; X = X + 4 +        jsr Xplus4       ; X = X + 4 
- bne - +        bne - 
- rts+        rts
  
 ;------------------------------------[ Select Samus palette ]---------------------------------------- ;------------------------------------[ Select Samus palette ]----------------------------------------
Line 1946: Line 1946:
  
 SelectSamusPal: SelectSamusPal:
-LCB73: tya +LCB73:  tya                             
- pha ;Temp storage of Y on the stack. +        pha                             ;Temp storage of Y on the stack. 
- lda SamusGear +        lda SamusGear 
- asl +        asl 
- asl +        asl 
- asl ;CF contains Varia status (1 = Samus has it) +        asl                             ;CF contains Varia status (1 = Samus has it) 
- lda MissileToggle ;A = 1 if Samus is firing missiles, else 0 +        lda MissileToggle               ;A = 1 if Samus is firing missiles, else 0 
- rol ;Bit 0 of A = 1 if Samus is wearing Varia +        rol                             ;Bit 0 of A = 1 if Samus is wearing Varia 
- adc #$02 +        adc #$02 
- ldy JustInBailey ;In suit?--> +        ldy JustInBailey                ;In suit?--> 
- beq + ;If so, Branch. +        beq +                           ;If so, Branch. 
- clc +        clc 
- adc #$17 ;Add #$17 to the pal # to reach "no suit"-palettes. +        adc #$17                        ;Add #$17 to the pal # to reach "no suit"-palettes. 
-*       sta PalDataPending ;Palette will be written next NMI. +*       sta PalDataPending              ;Palette will be written next NMI. 
- pla +        pla                             
- tay ;Restore the contents of y. +        tay                             ;Restore the contents of y. 
- rts ;+        rts                             ;
  
 ;----------------------------------[ Initiate SFX and music routines ]------------------------------- ;----------------------------------[ Initiate SFX and music routines ]-------------------------------
Line 1968: Line 1968:
 ;Initiate sound effects. ;Initiate sound effects.
  
-SilenceMusic: ;The sound flags are stored in memory--> +SilenceMusic:                           ;The sound flags are stored in memory--> 
-LCB8E: lda #$01 ;starting at $0680. The following is a--> +LCB8E:  lda #$01                        ;starting at $0680. The following is a--> 
-LCB90: bne SFX_SetX0 ;list of sound effects played when the--> +LCB90:  bne SFX_SetX0                   ;list of sound effects played when the--> 
- ;flags are set: +                                        ;flags are set: 
-PauseMusic: +PauseMusic:                             
-LCB92: lda #$02         ;$0680: These SFX use noise channel. +LCB92:  lda #$02                        ;$0680: These SFX use noise channel. 
-LCB94: bne SFX_SetX0 ;Bit 7 - No sound. +LCB94:  bne SFX_SetX0                   ;Bit 7 - No sound. 
- ;Bit 6 - ScrewAttack. +                                        ;Bit 6 - ScrewAttack. 
-SFX_SamusWalk: ;Bit 5 - MissileLaunch. +SFX_SamusWalk:                          ;Bit 5 - MissileLaunch. 
-LCB96: lda #$08 ;Bit 4 - BombExplode. +LCB96:  lda #$08                        ;Bit 4 - BombExplode. 
-LCB98: bne SFX_SetX0 ;Bit 3 - SamusWalk. +LCB98:  bne SFX_SetX0                   ;Bit 3 - SamusWalk. 
- ;Bit 2 - SpitFlame. +                                        ;Bit 2 - SpitFlame. 
-SFX_BombExplode: ;Bit 1 - No sound. +SFX_BombExplode:                        ;Bit 1 - No sound. 
-LCB9A: lda #$10 ;Bit 0 - No sound. +LCB9A:  lda #$10                        ;Bit 0 - No sound. 
-LCB9C: bne SFX_SetX0 +LCB9C:  bne SFX_SetX0                   
- ;$0681: These SFX use sq1 channel. +                                        ;$0681: These SFX use sq1 channel. 
-SFX_MissileLaunch: ;Bit 7 - MissilePickup. +SFX_MissileLaunch:                      ;Bit 7 - MissilePickup. 
-LCB9E: lda #$20 ;Bit 6 - EnergyPickup. +LCB9E:  lda #$20                        ;Bit 6 - EnergyPickup. 
- ;Bit 5 - Metal. +                                        ;Bit 5 - Metal. 
-SFX_SetX0: ;Bit 4 - BulletFire. +SFX_SetX0:                              ;Bit 4 - BulletFire. 
-LCBA0: ldx #$00 ;Bit 3 - OutOfHole. +LCBA0:  ldx #$00                        ;Bit 3 - OutOfHole. 
-LCBA2: beq SFX_SetSoundFlag ;Bit 2 - EnemyHit. +LCBA2:  beq SFX_SetSoundFlag            ;Bit 2 - EnemyHit. 
- ;Bit 1 - SamusJump. +                                        ;Bit 1 - SamusJump. 
-SFX_OutOfHole: ;Bit 0 - WaveFire. +SFX_OutOfHole:                          ;Bit 0 - WaveFire. 
-LCBA4: lda #$08 +LCBA4:  lda #$08                        
-LCBA6: bne SFX_SetX1 ;$0682: Not used. +LCBA6:  bne SFX_SetX1                   ;$0682: Not used. 
- +                                        
-SFX_BombLaunch: ;$0683: These SFX use tri channel. +SFX_BombLaunch:                         ;$0683: These SFX use tri channel. 
-LCBA8: lda #$01 ;Bit 7 - SamusDie. +LCBA8:  lda #$01                        ;Bit 7 - SamusDie. 
-LCBAA: bne SFX_SetX3 ;Bit 6 - DoorOpenClose. +LCBAA:  bne SFX_SetX3                   ;Bit 6 - DoorOpenClose. 
- ;Bit 5 - MetroidHit. +                                        ;Bit 5 - MetroidHit. 
-SFX_SamusJump: ;Bit 4 - StatueRaise. +SFX_SamusJump:                          ;Bit 4 - StatueRaise. 
-LCBAC: lda #$02 ;Bit 3 - Beep. +LCBAC:  lda #$02                        ;Bit 3 - Beep. 
-LCBAE: bne SFX_SetX1 ;Bit 2 - BigEnemyHit. +LCBAE:  bne SFX_SetX1                   ;Bit 2 - BigEnemyHit. 
- ;Bit 1 - SamusBall. +                                        ;Bit 1 - SamusBall. 
-SFX_EnemyHit: ;Bit 0 - BombLaunch. +SFX_EnemyHit:                           ;Bit 0 - BombLaunch. 
-LCBB0: lda #$04 +LCBB0:  lda #$04                        
-LCBB2: bne SFX_SetX1 ;$0684: These SFX use multi channels. +LCBB2:  bne SFX_SetX1                   ;$0684: These SFX use multi channels. 
- ;Bit 7 - FadeInMusic (music). +                                        ;Bit 7 - FadeInMusic            (music). 
-SFX_BulletFire: ;Bit 6 - PowerUpMusic (music). +SFX_BulletFire:                         ;Bit 6 - PowerUpMusic           (music). 
-LCBB4: lda #$10 ;Bit 5 - EndMusic  (Page 0 only)(music). +LCBB4:  lda #$10                        ;Bit 5 - EndMusic  (Page 0 only)(music). 
-LCBB6: bne SFX_SetX1 ;Bit 4 - IntroMusic(Page 0 only)(music). +LCBB6:  bne SFX_SetX1                   ;Bit 4 - IntroMusic(Page 0 only)(music). 
- ;Bit 3 - not used (SFX). +                                        ;Bit 3 - not used               (SFX). 
-SFX_Metal: ;Bit 2 - SamusHit (SFX). +SFX_Metal:                              ;Bit 2 - SamusHit               (SFX). 
-LCBB8: lda #$20 ;Bit 1 - BossHit (SFX). +LCBB8:  lda #$20                        ;Bit 1 - BossHit                (SFX). 
-LCBBA: bne SFX_SetX1 ;Bit 0 - IncorrectPassword (SFX). +LCBBA:  bne SFX_SetX1                   ;Bit 0 - IncorrectPassword      (SFX). 
- +                                        
-SFX_EnergyPickup: ;$0685: Music flags. The music flags start different--> +SFX_EnergyPickup:                       ;$0685: Music flags. The music flags start different--> 
-LCBBC: lda #$40 ;music depending on what memory page is loaded. The--> +LCBBC:  lda #$40                        ;music depending on what memory page is loaded. The--> 
-LCBBD: bne SFX_SetX1 ;following lists what bits start what music for each--> +LCBBD:  bne SFX_SetX1                   ;following lists what bits start what music for each--> 
- ;memory page. +                                        ;memory page. 
-SFX_MissilePickup: +SFX_MissilePickup:                      
-LCBC0: lda #$80 ;Page 0: Intro/ending. +LCBC0:  lda #$80                        ;Page 0: Intro/ending. 
- ;Bit 7 - Not used. +                                        ;Bit 7 - Not used. 
-SFX_SetX1: ;Bit 6 - TourianMusic. +SFX_SetX1:                              ;Bit 6 - TourianMusic. 
-LCBC2: ldx #$01 ;Bit 5 - ItemRoomMusic. +LCBC2:  ldx #$01                        ;Bit 5 - ItemRoomMusic. 
-LCBC4: bne SFX_SetSoundFlag ;Bit 4 - Not used. +LCBC4:  bne SFX_SetSoundFlag            ;Bit 4 - Not used. 
- ;Bit 3 - Not used. +                                        ;Bit 3 - Not used. 
-SFX_WaveFire: ;Bit 2 - Not used. +SFX_WaveFire:                           ;Bit 2 - Not used. 
-LCBC6: lda #$01 ;Bit 1 - Not used. +LCBC6:  lda #$01                        ;Bit 1 - Not used. 
-LCBC8: bne SFX_SetX1 ;Bit 0 - Not used. +LCBC8:  bne SFX_SetX1                   ;Bit 0 - Not used. 
- +                                        
-SFX_ScrewAttack: ;Page 1: Brinstar. +SFX_ScrewAttack:                        ;Page 1: Brinstar. 
-LCBCA: lda #$40 ;Bit 7 - Not used. +LCBCA:  lda #$40                        ;Bit 7 - Not used. 
-LCBCC: bne SFX_SetX0 ;Bit 6 - TourianMusic. +LCBCC:  bne SFX_SetX0                   ;Bit 6 - TourianMusic. 
- ;Bit 5 - ItemRoomMusic. +                                        ;Bit 5 - ItemRoomMusic. 
-SFX_BigEnemyHit: ;Bit 4 - Not used. +SFX_BigEnemyHit:                        ;Bit 4 - Not used. 
-LCBCE: lda #$04 ;Bit 3 - Not used. +LCBCE:  lda #$04                        ;Bit 3 - Not used. 
-LCBD0: bne SFX_SetX3 ;Bit 2 - Not used. +LCBD0:  bne SFX_SetX3                   ;Bit 2 - Not used. 
- ;Bit 1 - Not used. +                                        ;Bit 1 - Not used. 
-SFX_MetroidHit: ;Bit 0 - BrinstarMusic. +SFX_MetroidHit:                         ;Bit 0 - BrinstarMusic. 
-LCBD2: lda #$20 +LCBD2:  lda #$20                        
-LCBD4: bne SFX_SetX3 ;Page 2: Norfair. +LCBD4:  bne SFX_SetX3                   ;Page 2: Norfair. 
- ;Bit 7 - Not used. +                                        ;Bit 7 - Not used. 
-SFX_BossHit: ;Bit 6 - TourianMusic. +SFX_BossHit:                            ;Bit 6 - TourianMusic. 
-LCBD6: lda #$02 ;Bit 5 - ItemRoomMusic. +LCBD6:  lda #$02                        ;Bit 5 - ItemRoomMusic. 
-LCBD8: bne SFX_SetX4 ;Bit 4 - Not used. +LCBD8:  bne SFX_SetX4                   ;Bit 4 - Not used. 
- ;Bit 3 - NorfairMusic. +                                        ;Bit 3 - NorfairMusic. 
-SFX_Door: ;Bit 2 - Not used. +SFX_Door:                               ;Bit 2 - Not used. 
-LCBDA: lda #$40 ;Bit 1 - Not used. +LCBDA:  lda #$40                        ;Bit 1 - Not used. 
-LCBDC: bne SFX_SetX3 ;Bit 0 - Not used. +LCBDC:  bne SFX_SetX3                   ;Bit 0 - Not used. 
- +                                        
-SFX_SamusHit: ;Page 3: Tourian. +SFX_SamusHit:                           ;Page 3: Tourian. 
-LCBDE: lda #$04 ;Bit 7 - Not used. +LCBDE:  lda #$04                        ;Bit 7 - Not used. 
-LCBE0: bne SFX_SetX4 ;Bit 6 - TourianMusic +LCBE0:  bne SFX_SetX4                   ;Bit 6 - TourianMusic 
- ;Bit 5 - ItemRoomMusic. +                                        ;Bit 5 - ItemRoomMusic. 
-SFX_SamusDie: ;Bit 4 - Not used. +SFX_SamusDie:                           ;Bit 4 - Not used. 
-LCBE2: lda #$80 ;Bit 3 - Not used. +LCBE2:  lda #$80                        ;Bit 3 - Not used. 
-LCBE4: bne SFX_SetX3 ;Bit 2 - EscapeMusic. +LCBE4:  bne SFX_SetX3                   ;Bit 2 - EscapeMusic. 
- ;Bit 1 - MotherBrainMusic +                                        ;Bit 1 - MotherBrainMusic 
-SFX_SetX2: ;Bit 0 - Not used. +SFX_SetX2:                              ;Bit 0 - Not used. 
-LCBE6: ldx #$02 +LCBE6:  ldx #$02                        
- ;Page 4: Kraid. +                                        ;Page 4: Kraid. 
-SFX_SetSoundFlag: ;Bit 7 - RidleyAreaMusic. +SFX_SetSoundFlag:                       ;Bit 7 - RidleyAreaMusic. 
-LCBE8: ora $0680,x ;Bit 6 - TourianMusic. +LCBE8:  ora $0680,                    ;Bit 6 - TourianMusic. 
-LCBEB: sta $0680,x ;Bit 5 - ItemRoomMusic. +LCBEB:  sta $0680,                    ;Bit 5 - ItemRoomMusic. 
-LCBEE: rts ;Bit 4 - KraidAreaMusic. +LCBEE:  rts                             ;Bit 4 - KraidAreaMusic. 
- ;Bit 3 - Not used. +                                        ;Bit 3 - Not used. 
-SFX_SamusBall: ;Bit 2 - Not used. +SFX_SamusBall:                          ;Bit 2 - Not used. 
-LCBEF: lda #$02 ;Bit 1 - Not used. +LCBEF:  lda #$02                        ;Bit 1 - Not used. 
-LCBF1: bne SFX_SetX3 ;Bit 0 - Not used. +LCBF1:  bne SFX_SetX3                   ;Bit 0 - Not used. 
- +                                        
-SFX_Beep: ;Page 5: Ridley. +SFX_Beep:                               ;Page 5: Ridley. 
-LCBF3: lda #$08 ;Bit 7 - RidleyAreaMusic. +LCBF3:  lda #$08                        ;Bit 7 - RidleyAreaMusic. 
- ;Bit 6 - TourianMusic. +                                        ;Bit 6 - TourianMusic. 
-SFX_SetX3: ;Bit 5 - ItemRoomMusic. +SFX_SetX3:                              ;Bit 5 - ItemRoomMusic. 
-LCBF5: ldx #$03 ;Bit 4 - KraidAreaMusic. +LCBF5:  ldx #$03                        ;Bit 4 - KraidAreaMusic. 
-LCBF7: bne SFX_SetSoundFlag ;Bit 3 - Not used. +LCBF7:  bne SFX_SetSoundFlag            ;Bit 3 - Not used. 
- ;Bit 2 - Not used. +                                        ;Bit 2 - Not used. 
-;Initiate music ;Bit 1 - Not used. +;Initiate music                         ;Bit 1 - Not used. 
- ;Bit 0 - Not used. +                                        ;Bit 0 - Not used. 
-PowerUpMusic: +PowerUpMusic:                           
-LCBF9: lda #$40 +LCBF9:  lda #$40                        
-LCBFB: bne SFX_SetX4 +LCBFB:  bne SFX_SetX4                   
- +                                        
-IntroMusic: +IntroMusic:                             
-LCBFD: lda #$80 +LCBFD:  lda #$80                        
- +                                        
-SFX_SetX4: +SFX_SetX4:                              
-LCBFF: ldx #$04 +LCBFF:  ldx #$04                        
-LCC01: bne SFX_SetSoundFlag +LCC01:  bne SFX_SetSoundFlag            
- +                                        
-MotherBrainMusic: +MotherBrainMusic:                       
-LCC03: lda #$02 +LCC03:  lda #$02                        
-LCC05: bne SFX_SetX5 +LCC05:  bne SFX_SetX5                   
- +                                        
-TourianMusic: +TourianMusic:                           
-LCC07: lda #$40 +LCC07:  lda #$40                        
- +                                        
-SFX_SetX5: +SFX_SetX5:                              
-LCC09: ldx #$05 +LCC09:  ldx #$05                        
-LCC0B: bne SFX_SetSoundFlag ;+LCC0B:  bne SFX_SetSoundFlag            ;
  
 ;--------------------------------------[ Update Samus ]---------------------------------------------- ;--------------------------------------[ Update Samus ]----------------------------------------------
  
 UpdateSamus: UpdateSamus:
-LCC0D: ldx #$00 ;Samus data is located at index #$00. +LCC0D:  ldx #$00                        ;Samus data is located at index #$00. 
-LCC0F: stx PageIndex +LCC0F:  stx PageIndex                   
-LCC11: inx ;x=1. +LCC11:  inx                             ;x=1. 
-LCC12: stx IsSamus ;Indicate Samus is the object being updated. +LCC12:  stx IsSamus                     ;Indicate Samus is the object being updated. 
-LCC14: jsr GoSamusHandler ;($CC1A)Find proper Samus handler routine. +LCC14:  jsr GoSamusHandler              ;($CC1A)Find proper Samus handler routine. 
-LCC17: dec IsSamus ;Update of Samus complete. +LCC17:  dec IsSamus                     ;Update of Samus complete. 
-LCC19: rts ;+LCC19:  rts                             ;
  
 GoSamusHandler: GoSamusHandler:
-LCC1A: lda ObjAction +LCC1A:  lda ObjAction                   
-LCC1D: bmi SamusStand ;Branch if Samus is standing. +LCC1D:  bmi SamusStand                  ;Branch if Samus is standing. 
-LCC1F: jsr ChooseRoutine ;($C27C)Goto proper Samus handler routine.+LCC1F:  jsr ChooseRoutine               ;($C27C)Goto proper Samus handler routine.
  
 ;Pointer table for Samus' action handlers. ;Pointer table for Samus' action handlers.
  
-LCC22: .word SamusStand ;($CC36)Standing. +LCC22:  .word SamusStand                ;($CC36)Standing. 
-LCC24: .word SamusRun ;($CCC2)Running. +LCC24:  .word SamusRun                  ;($CCC2)Running. 
-LCC26: .word SamusJump ;($D002)Jumping. +LCC26:  .word SamusJump                 ;($D002)Jumping. 
-LCC28: .word SamusRoll ;($D0E1)Rolling. +LCC28:  .word SamusRoll                 ;($D0E1)Rolling. 
-LCC2A: .word SamusPntUp ;($D198)Pointing up. +LCC2A:  .word SamusPntUp                ;($D198)Pointing up. 
-LCC2C: .word SamusDoor ;($D3A8)Inside door while screen scrolling. +LCC2C:  .word SamusDoor                 ;($D3A8)Inside door while screen scrolling. 
-LCC2E: .word SamusJump ;($D002)Jumping while pointing up. +LCC2E:  .word SamusJump                 ;($D002)Jumping while pointing up. 
-LCC30: .word SamusDead ;($D41A)Dead. +LCC30:  .word SamusDead                 ;($D41A)Dead. 
-LCC32: .word SamusDead2 ;($D41F)More dead. +LCC32:  .word SamusDead2                ;($D41F)More dead. 
-LCC34: .word SamusElevator ;($D423)Samus on elevator.+LCC34:  .word SamusElevator             ;($D423)Samus on elevator.
  
 ;---------------------------------------[ Samus standing ]------------------------------------------- ;---------------------------------------[ Samus standing ]-------------------------------------------
  
 SamusStand: SamusStand:
-LCC36: lda Joy1Status ;Status of joypad 1. +LCC36:  lda Joy1Status                  ;Status of joypad 1. 
-LCC38: and #$CF ;Remove SELECT & START status bits. +LCC38:  and #$CF                        ;Remove SELECT & START status bits. 
-LCC3A: beq + ;Branch if no buttons pressed. +LCC3A:  beq +                           ;Branch if no buttons pressed. 
-LCC3C: jsr ClearHorzMvmtAnimData ;($CF5D)Set no horiontal movement and single frame animation. +LCC3C:  jsr ClearHorzMvmtAnimData       ;($CF5D)Set no horiontal movement and single frame animation. 
-LCC3F: lda Joy1Status +LCC3F:  lda Joy1Status                  
-LCC41:* and #$07 ;Keep status of DOWN/LEFT/RIGHT. +LCC41:* and #$07                        ;Keep status of DOWN/LEFT/RIGHT. 
-LCC43: bne + ;Branch if any are pressed. +LCC43:  bne +                           ;Branch if any are pressed. 
-LCC45: lda Joy1Change +LCC45:  lda Joy1Change                  
-LCC47: and #$08     ;Check if UP was pressed last frame.--> +LCC47:  and #$08                        ;Check if UP was pressed last frame.--> 
-LCC49: beq +++ ;If not, branch. +LCC49:  beq +++                         ;If not, branch. 
-LCC4B:* jsr BitScan ;($E1E1)Find which directional button is pressed. +LCC4B:* jsr BitScan                     ;($E1E1)Find which directional button is pressed. 
-LCC4E: cmp #$02 ;Is down pressed?--> +LCC4E:  cmp #$02                        ;Is down pressed?--> 
-LCC50: bcs + ;If so, branch. +LCC50:  bcs +                           ;If so, branch. 
-LCC52: sta SamusDir ;1=left, 0=right. +LCC52:  sta SamusDir                    ;1=left, 0=right. 
-LCC54:* tax +LCC54:* tax                             
-LCC55: lda ActionTable,x ;Load proper Samus status from table below. +LCC55:  lda ActionTable,              ;Load proper Samus status from table below. 
-LCC58: sta ObjAction ;Save Samus status. +LCC58:  sta ObjAction                   ;Save Samus status. 
-LCC5B:* lda Joy1Change +LCC5B:* lda Joy1Change                  
-LCC5D: ora Joy1Retrig ;Check if fire was just pressed or needs to retrigger. +LCC5D:  ora Joy1Retrig                  ;Check if fire was just pressed or needs to retrigger. 
-LCC5F: asl +LCC5F:  asl                             
-LCC60: bpl + ;Branch if FIRE not pressed. +LCC60:  bpl +                           ;Branch if FIRE not pressed. 
-LCC62: jsr FireWeapon ;($D1EE)Shoot left/right. +LCC62:  jsr FireWeapon                  ;($D1EE)Shoot left/right. 
-LCC65:* bit Joy1Change ;Check if jump was just pressed. +LCC65:* bit Joy1Change                  ;Check if jump was just pressed. 
-LCC67: bpl + ;Branch if JUMP not pressed. +LCC67:  bpl +                           ;Branch if JUMP not pressed. 
-LCC69: lda #sa_Jump +LCC69:  lda #sa_Jump                    
-LCC6B: sta ObjAction ;Set Samus status as jumping. +LCC6B:  sta ObjAction                   ;Set Samus status as jumping. 
-LCC6E:* lda #$04 ;Prepare to set animation delay to 4 frames. +LCC6E:* lda #$04                        ;Prepare to set animation delay to 4 frames. 
-LCC70: jsr SetSamusData ;($CD6D)Set Samus control data and animation. +LCC70:  jsr SetSamusData                ;($CD6D)Set Samus control data and animation. 
-LCC73: lda ObjAction +LCC73:  lda ObjAction                   
-LCC76: cmp #sa_Door ;Is Samus inside a door, dead or pointing up and jumping?--> +LCC76:  cmp #sa_Door                    ;Is Samus inside a door, dead or pointing up and jumping?--> 
-LCC78: bcs + ;If so, branch to exit. +LCC78:  bcs +                           ;If so, branch to exit. 
-LCC7A: jsr ChooseRoutine ;Select routine below.+LCC7A:  jsr ChooseRoutine               ;Select routine below.
  
 ;Pointer table to code. ;Pointer table to code.
  
-LCC7D: .word ExitSub ;($C45C)Rts. +LCC7D:  .word ExitSub                   ;($C45C)Rts. 
-LCC7F: .word SetSamusRun ;($CC98)Samus is running. +LCC7F:  .word SetSamusRun               ;($CC98)Samus is running. 
-LCC81: .word SetSamusJump ;($CFC3)Samus is jumping. +LCC81:  .word SetSamusJump              ;($CFC3)Samus is jumping. 
-LCC83: .word SetSamusRoll ;($D0B5)Samus is in a ball. +LCC83:  .word SetSamusRoll              ;($D0B5)Samus is in a ball. 
-LCC85: .word SetSamusPntUp ;($CF77)Samus is pointing up.+LCC85:  .word SetSamusPntUp             ;($CF77)Samus is pointing up.
  
 ;Table used by above subroutine. ;Table used by above subroutine.
  
 ActionTable: ActionTable:
-LCC87: .byte sa_Run ;Run right. +LCC87:  .byte sa_Run                    ;Run right. 
-LCC88: .byte sa_Run ;Run left. +LCC88:  .byte sa_Run                    ;Run left. 
-LCC89: .byte sa_Roll +LCC89:  .byte sa_Roll 
-LCC8A: .byte sa_PntUp+LCC8A:  .byte sa_PntUp
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 2186: Line 2186:
 SetSamusExplode: SetSamusExplode:
 LCC8B:  lda #$50 LCC8B:  lda #$50
- sta SamusJumpDsplcmnt +        sta SamusJumpDsplcmnt 
- lda #an_Explode +        lda #an_Explode 
- jsr SetSamusAnim +        jsr SetSamusAnim 
- sta ObjectCounter+        sta ObjectCounter
 *       rts *       rts
  
 SetSamusRun: SetSamusRun:
 LCC98:  lda #$09 LCC98:  lda #$09
- sta WalkSoundDelay +        sta WalkSoundDelay 
- ldx #$00 +        ldx #$00 
- lda AnimResetIndex +        lda AnimResetIndex 
- cmp #an_SamusStand +        cmp #an_SamusStand 
- beq + +        beq + 
- inx +        inx 
- cmp #$27 +        cmp #$27 
- beq + +        beq + 
- lda #$04 +        lda #$04 
- jsr SetSamusNextAnim+        jsr SetSamusNextAnim
 *       lda RunAnimationTbl,x *       lda RunAnimationTbl,x
- sta AnimResetIndex +        sta AnimResetIndex 
- ldx SamusDir+        ldx SamusDir
 LCCB7:  lda RunAccelerationTbl,x LCCB7:  lda RunAccelerationTbl,x
- sta SamusHorzAccel +        sta SamusHorzAccel 
- rts+        rts
  
 RunAnimationTbl: RunAnimationTbl:
 LCCBE:  .byte an_SamusRun LCCBE:  .byte an_SamusRun
- .byte an_SamusRunPntUp+        .byte an_SamusRunPntUp
  
 RunAccelerationTbl: RunAccelerationTbl:
-LCCC0:  .byte $30 ;Accelerate right. +LCCC0:  .byte $30                       ;Accelerate right. 
- .byte $D0 ;Accelerate left.+        .byte $D0                       ;Accelerate left.
  
 ; SamusRun ; SamusRun
Line 2223: Line 2223:
  
 SamusRun: SamusRun:
-LCCC2: ldx SamusDir +LCCC2:  ldx SamusDir 
- lda SamusGravity +        lda SamusGravity 
- beq +++++++ +        beq +++++++ 
- ldy SamusJumpDsplcmnt +        ldy SamusJumpDsplcmnt 
- bit ObjVertSpeed +        bit ObjVertSpeed 
- bmi + +        bmi + 
- cpy #$18 +        cpy #$18 
- bcs ++++ +        bcs ++++ 
- lda #an_SamusJump +        lda #an_SamusJump 
- sta AnimResetIndex +        sta AnimResetIndex 
- bcc ++++   ; branch always+        bcc ++++          ; branch always
 *       cpy #$18 *       cpy #$18
- bcc +++ +        bcc +++ 
- lda AnimResetIndex +        lda AnimResetIndex 
- cmp #an_SamusFireJump +        cmp #an_SamusFireJump 
- beq + +        beq + 
- lda #an_SamusSalto +        lda #an_SamusSalto 
- sta AnimResetIndex+        sta AnimResetIndex
 *       cpy #$20 *       cpy #$20
- bcc ++ +        bcc ++ 
- lda Joy1Status +        lda Joy1Status 
- and #$08 +        and #$08 
- beq + +        beq + 
- lda #an_SamusJumpPntUp +        lda #an_SamusJumpPntUp 
- sta AnimResetIndex+        sta AnimResetIndex
 *       bit Joy1Status *       bit Joy1Status
- bmi + +        bmi + 
- jsr StopVertMovement ;($D147) +        jsr StopVertMovement            ;($D147) 
-* lda #an_SamusRun +      lda #an_SamusRun 
- cmp AnimResetIndex +        cmp AnimResetIndex 
- bne + +        bne + 
- lda #an_SamusJump +        lda #an_SamusJump 
- sta AnimResetIndex+        sta AnimResetIndex
 *       lda SamusInLava *       lda SamusInLava
- beq + +        beq + 
- lda Joy1Change +        lda Joy1Change 
- bmi LCD40       ; branch if JUMP pressed+        bmi LCD40       ; branch if JUMP pressed
 *       jsr LCF88 *       jsr LCF88
- jsr LD09C +        jsr LD09C 
- jsr LCF2E +        jsr LCF2E 
- lda #$02 +        lda #$02 
- bne SetSamusData       ; branch always +        bne SetSamusData       ; branch always 
-* lda SamusOnElevator +      lda SamusOnElevator 
- bne + +        bne + 
- jsr LCCB7+        jsr LCCB7
 *       jsr LCDBF *       jsr LCDBF
- dec WalkSoundDelay  ; time to play walk sound? +        dec WalkSoundDelay  ; time to play walk sound? 
- bne +        ; branch if not +        bne +          ; branch if not 
- lda #$09 +        lda #$09 
- sta WalkSoundDelay  ; # of frames till next walk sound trigger +        sta WalkSoundDelay  ; # of frames till next walk sound trigger 
- jsr SFX_SamusWalk+        jsr SFX_SamusWalk
 *       jsr LCF2E *       jsr LCF2E
- lda Joy1Change +        lda Joy1Change 
- bpl +    ; branch if JUMP not pressed+        bpl +      ; branch if JUMP not pressed
 LCD40:  jsr LCFC3 LCD40:  jsr LCFC3
- lda #$12 +        lda #$12 
- sta SamusHorzSpeedMax +        sta SamusHorzSpeedMax 
- jmp LCD6B+        jmp LCD6B
  
 *       ora Joy1Retrig *       ora Joy1Retrig
- asl +        asl 
- bpl +    ; branch if FIRE not pressed +        bpl +      ; branch if FIRE not pressed 
- jsr LCDD7+        jsr LCDD7
 *       lda Joy1Status *       lda Joy1Status
- and #$03 +        and #$03 
- bne + +        bne + 
- jsr LCF55 +        jsr LCF55 
- jmp LCD6B+        jmp LCD6B
  
-*       jsr BitScan ;($E1E1) +*       jsr BitScan                     ;($E1E1) 
- cmp SamusDir +        cmp SamusDir 
- beq LCD6B +        beq LCD6B 
- sta SamusDir +        sta SamusDir 
- jsr LCC98+        jsr LCC98
 LCD6B:  lda #$03 LCD6B:  lda #$03
  
Line 2304: Line 2304:
  
 SetSamusData: SetSamusData:
-LCD6D:  jsr UpdateObjAnim ;($DC8F)Update animation if needed. +LCD6D:  jsr UpdateObjAnim               ;($DC8F)Update animation if needed. 
-LCD70: jsr IsScrewAttackActive ;($CD9C)Check if screw attack active to change palette. +LCD70:  jsr IsScrewAttackActive         ;($CD9C)Check if screw attack active to change palette. 
-LCD73: bcs + ;If screw attack not active, branch to skip palette change. +LCD73:  bcs +                           ;If screw attack not active, branch to skip palette change. 
-LCD75: lda FrameCount +LCD75:  lda FrameCount                  
-LCD77: lsr +LCD77:  lsr                             
-LCD78: and #$03 ;Every other frame, change Samus palette while screw--> +LCD78:  and #$03                        ;Every other frame, change Samus palette while screw--> 
-LCD7A: ora #$A0 ;Attack is active. +LCD7A:  ora #$A0                        ;Attack is active. 
-LCD7C: sta ObjectCntrl +LCD7C:  sta ObjectCntrl                 
-LCD7E:* jsr CheckHealthStatus ;($CDFA)Check if Samus hit, blinking or Health low. +LCD7E:* jsr CheckHealthStatus           ;($CDFA)Check if Samus hit, blinking or Health low. 
-LCD81: jsr LavaAndMoveCheck ;($E269)Check if Samus is in lava or moving. +LCD81:  jsr LavaAndMoveCheck            ;($E269)Check if Samus is in lava or moving. 
-LCD84: lda MetroidOnSamus ;Is a Metroid stuck to Samus?--> +LCD84:  lda MetroidOnSamus              ;Is a Metroid stuck to Samus?--> 
-LCD86: beq + ;If not, branch. +LCD86:  beq +                           ;If not, branch. 
-LCD88: lda #$A1 ;Metroid on Samus. Turn Samus blue. +LCD88:  lda #$A1                        ;Metroid on Samus. Turn Samus blue. 
-LCD8A: sta ObjectCntrl +LCD8A:  sta ObjectCntrl                 
-LCD8C:* jsr SetmirrorCntrlBit ;($CD92)Mirror Samus, if necessary. +LCD8C:* jsr SetmirrorCntrlBit           ;($CD92)Mirror Samus, if necessary. 
-LCD8F: jmp DrawFrame ;($DE4A)Display Samus.+LCD8F:  jmp DrawFrame                   ;($DE4A)Display Samus.
  
 ;---------------------------------[ Set mirror control bit ]----------------------------------------- ;---------------------------------[ Set mirror control bit ]-----------------------------------------
  
 SetmirrorCntrlBit: SetmirrorCntrlBit:
-LCD92:  lda SamusDir ;Facing left=#$01, facing right=#$00. +LCD92:  lda SamusDir                    ;Facing left=#$01, facing right=#$00. 
-LCD94: jsr Amul16 ;($C2C5)*16. Move bit 0 to bit 4 position. +LCD94:  jsr Amul16                      ;($C2C5)*16. Move bit 0 to bit 4 position. 
-LCD97: ora ObjectCntrl +LCD97:  ora ObjectCntrl                 
-LCD99: sta ObjectCntrl ;Use SamusDir bit to set mirror bit. +LCD99:  sta ObjectCntrl                 ;Use SamusDir bit to set mirror bit. 
-LCD9B: rts ;+LCD9B:  rts                             ;
  
 ;------------------------------[ Check if screw attack is active ]----------------------------------- ;------------------------------[ Check if screw attack is active ]-----------------------------------
  
 IsScrewAttackActive: IsScrewAttackActive:
-LCD9C:  sec ;Assume screw attack is not active. +LCD9C:  sec                             ;Assume screw attack is not active. 
-LCD9D: ldy ObjAction +LCD9D:  ldy ObjAction                   
-LCDA0: dey ;Is Samus running?--> +LCDA0:  dey                             ;Is Samus running?--> 
-LCDA1: bne ++ ;If not, branch to exit. +LCDA1:  bne ++                          ;If not, branch to exit. 
-LCDA3: lda SamusGear +LCDA3:  lda SamusGear                   
-LCDA6: and #gr_SCREWATTACK ;Does Samus have screw attack?--> +LCDA6:  and #gr_SCREWATTACK             ;Does Samus have screw attack?--> 
-LCDA8: beq ++ ;If not, branch to exit. +LCDA8:  beq ++                          ;If not, branch to exit. 
-LCDAA: lda AnimResetIndex +LCDAA:  lda AnimResetIndex              
-LCDAD: cmp #an_SamusSalto ;Is Samus summersaulting?--> +LCDAD:  cmp #an_SamusSalto              ;Is Samus summersaulting?--> 
-LCDAF: beq + ;If so, branch to clear carry(screw attack active). +LCDAF:  beq +                           ;If so, branch to clear carry(screw attack active). 
-LCDB1: cmp #an_SamusJump +LCDB1:  cmp #an_SamusJump               
-LCDB3: sec ;Is Samus jumping?--> +LCDB3:  sec                             ;Is Samus jumping?--> 
-LCDB4: bne ++ ;If not, branch to exit. +LCDB4:  bne ++                          ;If not, branch to exit. 
-LCDB6: bit ObjVertSpeed ;If Samus is jumping and still moving upwards, screw-->  +LCDB6:  bit ObjVertSpeed                ;If Samus is jumping and still moving upwards, screw-->  
-LCDB9: bpl ++ ;attack is active. +LCDB9:  bpl ++                          ;attack is active. 
-LCDBB:* cmp AnimIndex ;Screw attack will still be active if not spinning, but--> +LCDBB:* cmp AnimIndex                   ;Screw attack will still be active if not spinning, but--> 
-LCDBE:* rts ;jumping while running and still moving upwards.+LCDBE:* rts                             ;jumping while running and still moving upwards.
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
  
 LCDBF:  lda Joy1Status LCDBF:  lda Joy1Status
- and #$08 +        and #$08 
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- tax +        tax 
- lda LCCBE,x +        lda LCCBE,x 
- cmp AnimResetIndex +        cmp AnimResetIndex 
- beq - +        beq - 
- jsr SetSamusAnim +        jsr SetSamusAnim 
- pla +        pla 
- pla +        pla 
- jmp LCD6B+        jmp LCD6B
  
-LCDD7:  jsr FireWeapon ;($D1EE)Shoot left/right. +LCDD7:  jsr FireWeapon                  ;($D1EE)Shoot left/right. 
- lda Joy1Status +        lda Joy1Status 
- and #$08 +        and #$08 
- bne + +        bne + 
- lda #an_SamusFireRun +        lda #an_SamusFireRun 
- sta AnimIndex +        sta AnimIndex 
- rts+        rts
  
 *       lda AnimIndex *       lda AnimIndex
- sec +        sec 
- sbc AnimResetIndex +        sbc AnimResetIndex 
- and #$03 +        and #$03 
- tax +        tax 
- lda Table05,x +        lda Table05,x 
- jmp SetSamusNextAnim+        jmp SetSamusNextAnim
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table05: Table05:
- .byte $3F +        .byte $3F 
- .byte $3B +        .byte $3B 
- .byte $3D +        .byte $3D 
- .byte $3F+        .byte $3F
  
 CheckHealthStatus: CheckHealthStatus:
-LCDFA:  lda SamusHit +LCDFA:  lda SamusHit                    
- and #$20 ;Has Samus been hit?--> +        and #$20                        ;Has Samus been hit?--> 
- beq +++ ;If not, branch to check if still blinking from recent hit. +        beq +++                         ;If not, branch to check if still blinking from recent hit. 
- lda #$32 +        lda #$32                        
- sta SamusBlink ;Samus has been hit. Set blink for 32 frames. +        sta SamusBlink                  ;Samus has been hit. Set blink for 32 frames. 
- lda #$FF +        lda #$FF 
- sta DamagePushDirection +        sta DamagePushDirection 
- lda $73 +        lda $73 
- sta $77 +        sta $77 
- beq ++ +        beq ++ 
- bpl + +        bpl + 
- jsr SFX_SamusHit+        jsr SFX_SamusHit
 *       lda SamusHit *       lda SamusHit
- and #$08 +        and #$08 
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- sta DamagePushDirection +        sta DamagePushDirection 
-* lda #$FD +      lda #$FD 
- sta ObjVertSpeed +        sta ObjVertSpeed 
- lda #$38 ;Samus is hit. Store Samus hit gravity. +        lda #$38                        ;Samus is hit. Store Samus hit gravity. 
- sta SamusGravity +        sta SamusGravity                
- jsr IsSamusDead +        jsr IsSamusDead 
- bne + +        bne + 
- jmp CheckHealthBeep+        jmp CheckHealthBeep
  
-* lda SamusBlink +      lda SamusBlink 
- beq CheckHealthBeep +        beq CheckHealthBeep 
- dec SamusBlink +        dec SamusBlink 
- ldx DamagePushDirection +        ldx DamagePushDirection 
- inx +        inx 
- beq +++ +        beq +++ 
- jsr Adiv16       ; / 16 +        jsr Adiv16       ; / 16 
- cmp #$03 +        cmp #$03 
- bcs + +        bcs + 
- ldy SamusHorzAccel +        ldy SamusHorzAccel 
- bne +++ +        bne +++ 
- jsr LCF4E+        jsr LCF4E
 *       dex *       dex
- bne + +        bne + 
- jsr TwosCompliment ;($C3D4)+        jsr TwosCompliment              ;($C3D4)
 *       sta ObjHorzSpeed *       sta ObjHorzSpeed
-* lda $77 +      lda $77 
- bpl CheckHealthBeep +        bpl CheckHealthBeep 
- lda FrameCount +        lda FrameCount 
- and #$01 +        and #$01 
- bne CheckHealthBeep +        bne CheckHealthBeep 
- tay +        tay 
- sty AnimDelay +        sty AnimDelay 
- ldy #$F7 +        ldy #$F7 
- sty AnimFrame+        sty AnimFrame
  
 CheckHealthBeep: CheckHealthBeep:
- ldy HealthHi +        ldy HealthHi 
- dey +        dey 
- bmi + +        bmi + 
- bne ++ +        bne ++ 
- lda HealthLo +        lda HealthLo 
- cmp #$70 +        cmp #$70 
- bcs +++        bcs ++
 ; health < 17 ; health < 17
 *       lda FrameCount *       lda FrameCount
- and #$0F +        and #$0F 
- bne + ;Only beep every 16th frame. +        bne +                           ;Only beep every 16th frame. 
- jsr SFX_Beep +        jsr SFX_Beep 
-* lda #$00 +      lda #$00 
- sta SamusHit +        sta SamusHit 
-LCE83: rts+LCE83:  rts
  
 ;----------------------------------------[ Is Samus dead ]------------------------------------------- ;----------------------------------------[ Is Samus dead ]-------------------------------------------
  
 IsSamusDead: IsSamusDead:
-LCE84: lda ObjAction +LCE84:  lda ObjAction                   
-LCE87: cmp #sa_Dead +LCE87:  cmp #sa_Dead                    
-LCE89: beq Exit3 ;Samus is dead. Zero flag is set. +LCE89:  beq Exit3                       ;Samus is dead. Zero flag is set. 
-LCE8B: cmp #sa_Dead2 +LCE8B:  cmp #sa_Dead2                   
-LCE8D: beq Exit3 +LCE8D:  beq Exit3                       
-LCE8F: cmp #$FF ;Samus not dead. Clear zero flag.+LCE8F:  cmp #$FF                        ;Samus not dead. Clear zero flag.
  
 Exit3:   Exit3:  
-LCE91: rts ;Exit for routines above and below.+LCE91:  rts                             ;Exit for routines above and below.
  
 ;----------------------------------------[ Subtract health ]----------------------------------------- ;----------------------------------------[ Subtract health ]-----------------------------------------
  
 SubtractHealth: SubtractHealth:
-LCE92: lda HealthLoChange ;Check to see if health needs to be changed.--> +LCE92:  lda HealthLoChange              ;Check to see if health needs to be changed.--> 
-LCE94: ora HealthHiChange ;If not, branch to exit. +LCE94:  ora HealthHiChange              ;If not, branch to exit. 
-LCE96: beq Exit3 +LCE96:  beq Exit3                       
-LCE98: jsr IsSamusDead ;($CE84)Check if Samus is already dead. +LCE98:  jsr IsSamusDead                 ;($CE84)Check if Samus is already dead. 
-LCE9B: beq ClearDamage ;Samus is dead. Branch to clear damage values. +LCE9B:  beq ClearDamage                 ;Samus is dead. Branch to clear damage values. 
-LCE9D: ldy EndTimerHi ;If end escape timer is running, Samus cannot be hurt. +LCE9D:  ldy EndTimerHi                  ;If end escape timer is running, Samus cannot be hurt. 
-LCEA0: iny +LCEA0:  iny                             
-LCEA1: beq + ;Branch if end escape timer not active.+LCEA1:  beq +                           ;Branch if end escape timer not active.
  
 ClearDamage: ClearDamage:
-LCEA3: jmp ClearHealthChange ;($F323)Clear health change values.+LCEA3:  jmp ClearHealthChange           ;($F323)Clear health change values.
  
-LCEA6:* lda MotherBrainStatus ;If mother brain is in the process of dying, receive--> +LCEA6:* lda MotherBrainStatus           ;If mother brain is in the process of dying, receive--> 
-LCEA8: cmp #$03 ;no damage. +LCEA8:  cmp #$03                        ;no damage. 
-LCEAA: bcs ClearDamage ;+LCEAA:  bcs ClearDamage                 ;
  
-LCEAC: lda SamusGear +LCEAC:  lda SamusGear                   
-LCEAF: and #gr_VARIA ;Check is Samus has Varia. +LCEAF:  and #gr_VARIA                   ;Check is Samus has Varia. 
-LCEB1: beq + +LCEB1:  beq +                           
-LCEB3: lsr HealthLoChange ;If Samus has Varia, divide damage by 2. +LCEB3:  lsr HealthLoChange              ;If Samus has Varia, divide damage by 2. 
-LCEB5: lsr HealthHiChange +LCEB5:  lsr HealthHiChange              
-LCEB7: bcc + ;If HealthHi moved a bit into the carry flag while--> +LCEB7:  bcc +                           ;If HealthHi moved a bit into the carry flag while--> 
-LCEB9: lda #$4F ;dividing, add #$4F to HealthLo for proper--> +LCEB9:  lda #$4F                        ;dividing, add #$4F to HealthLo for proper--> 
-LCEBB: adc HealthLoChange ;division results. +LCEBB:  adc HealthLoChange              ;division results. 
-LCEBD: sta HealthLoChange ;+LCEBD:  sta HealthLoChange              ;
  
-LCEBF:* lda HealthLo ;Prepare to subtract from HealthLo. +LCEBF:* lda HealthLo                    ;Prepare to subtract from HealthLo. 
-LCEC2: sta $03 +LCEC2:  sta $03                         
-LCEC4: lda HealthLoChange ;Amount to subtract from HealthLo. +LCEC4:  lda HealthLoChange              ;Amount to subtract from HealthLo. 
-LCEC6: sec +LCEC6:  sec                             
-LCEC7: jsr Base10Subtract ;($C3FB)Perform base 10 subtraction. +LCEC7:  jsr Base10Subtract              ;($C3FB)Perform base 10 subtraction. 
-LCECA: sta HealthLo ;Save results.+LCECA:  sta HealthLo                    ;Save results.
  
-LCECD:   lda HealthHi ;Prepare to subtract from HealthHi. +LCECD:   lda HealthHi                   ;Prepare to subtract from HealthHi. 
-LCED0: sta $03 +LCED0:  sta $03                         
-LCED2: lda HealthHiChange ;Amount to subtract from HealthHi. +LCED2:  lda HealthHiChange              ;Amount to subtract from HealthHi. 
-LCED4: jsr Base10Subtract ;($C3FB)Perform base 10 subtraction. +LCED4:  jsr Base10Subtract              ;($C3FB)Perform base 10 subtraction. 
-LCED7: sta HealthHi ;Save Results.+LCED7:  sta HealthHi                    ;Save Results.
  
-LCEDA: lda HealthLo +LCEDA:  lda HealthLo                    
-LCEDD: and #$F0 ;Is Samus health at 0?  If so, branch to--> +LCEDD:  and #$F0                        ;Is Samus health at 0?  If so, branch to--> 
-LCEDF: ora HealthHi ;begin death routine. +LCEDF:  ora HealthHi                    ;begin death routine. 
-LCEE2: beq + +LCEE2:  beq +                           
-LCEE4: bcs ++ ;Samus not dead. Branch to exit.+LCEE4:  bcs ++                          ;Samus not dead. Branch to exit.
  
-LCEE6:* lda #$00 ;Samus is dead. +LCEE6:* lda #$00                        ;Samus is dead. 
-LCEE8: sta HealthLo +LCEE8:  sta HealthLo                    
-LCEEB: sta HealthHi ;Set health to #$00. +LCEEB:  sta HealthHi                    ;Set health to #$00. 
-LCEEE: lda #sa_Dead +LCEEE:  lda #sa_Dead                    
-LCEF0: sta ObjAction ;Death handler. +LCEF0:  sta ObjAction                   ;Death handler. 
-LCEF3: jsr SFX_SamusDie ;($CBE2)Start Samus die SFX. +LCEF3:  jsr SFX_SamusDie                ;($CBE2)Start Samus die SFX. 
-LCEF6: jmp SetSamusExplode ;($CC8B)Set Samus exlpode routine.+LCEF6:  jmp SetSamusExplode             ;($CC8B)Set Samus exlpode routine.
  
 ;----------------------------------------[ Add health ]---------------------------------------------- ;----------------------------------------[ Add health ]----------------------------------------------
  
 AddHealth: AddHealth:
-LCEF9: lda HealthLo ;Prepare to add to HealthLo. +LCEF9:  lda HealthLo                    ;Prepare to add to HealthLo. 
-LCEFC: sta $03 +LCEFC:  sta $03                         
-LCEFE: lda HealthLoChange ;Amount to add to HealthLo. +LCEFE:  lda HealthLoChange              ;Amount to add to HealthLo. 
-LCF00: clc +LCF00:  clc                             
-LCF01: jsr Base10Add ;($C3DA)Perform base 10 addition. +LCF01:  jsr Base10Add                   ;($C3DA)Perform base 10 addition. 
-LCF04: sta HealthLo ;Save results.+LCF04:  sta HealthLo                    ;Save results.
  
-LCF07: lda HealthHi ;Prepare to add to HealthHi. +LCF07:  lda HealthHi                    ;Prepare to add to HealthHi. 
-LCF0A: sta $03 +LCF0A:  sta $03                         
-LCF0C: lda HealthHiChange ;Amount to add to HealthHi. +LCF0C:  lda HealthHiChange              ;Amount to add to HealthHi. 
-LCF0E: jsr Base10Add ;($C3DA)Perform base 10 addition. +LCF0E:  jsr Base10Add                   ;($C3DA)Perform base 10 addition. 
-LCF11: sta HealthHi ;Save results.+LCF11:  sta HealthHi                    ;Save results.
  
-LCF14: lda TankCount +LCF14:  lda TankCount                   
-LCF17: jsr Amul16 ;($C2C5)*16. Move tank count to upper 4 bits. +LCF17:  jsr Amul16                      ;($C2C5)*16. Move tank count to upper 4 bits. 
-LCF1A: ora #$0F ;Set lower 4 bits. +LCF1A:  ora #$0F                        ;Set lower 4 bits. 
-LCF1C: cmp HealthHi +LCF1C:  cmp HealthHi                    
-LCF1F: bcs + ;Is life less than max? if so, branch. +LCF1F:  bcs +                           ;Is life less than max? if so, branch. 
-LCF21: and #$F9 ;Life is more than max amount.  +LCF21:  and #$F9                        ;Life is more than max amount.  
-LCF23: sta HealthHi +LCF23:  sta HealthHi                    
-LCF26: lda #$99 ;Set life to max amount. +LCF26:  lda #$99                        ;Set life to max amount. 
-LCF28: sta HealthLo +LCF28:  sta HealthLo                    
-LCF2B:* jmp ClearHealthChange ;($F323)+LCF2B:* jmp ClearHealthChange           ;($F323)
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
  
-LCF2E: lda SamusHit +LCF2E:  lda SamusHit 
-LCF31: lsr +LCF31:  lsr 
- and #$02 +        and #$02 
- beq +++ +        beq +++ 
- bcs + +        bcs + 
- lda SamusHorzAccel +        lda SamusHorzAccel 
- bmi +++ +        bmi +++ 
- bpl +++        bpl ++
 *       lda SamusHorzAccel *       lda SamusHorzAccel
- bmi + +        bmi + 
- bne ++ +        bne ++ 
-* jsr TwosCompliment ;($C3D4) +      jsr TwosCompliment              ;($C3D4) 
- sta SamusHorzAccel+        sta SamusHorzAccel
  
 ClearHorzMvmntData: ClearHorzMvmntData:
-LCF4C:  ldy #$00 +LCF4C:  ldy #$00                        
-LCF4E:  sty ObjHorzSpeed ;Set Samus Horizontal speed and horizontal--> +LCF4E:  sty ObjHorzSpeed                ;Set Samus Horizontal speed and horizontal--> 
- sty HorzCntrLinear ;linear counter to #$00. +        sty HorzCntrLinear              ;linear counter to #$00. 
-* rts ;+      rts                             ;
  
 StopHorzMovement: StopHorzMovement:
-LCF55:  lda SamusHorzAccel ;Is Samus moving horizontally?--> +LCF55:  lda SamusHorzAccel              ;Is Samus moving horizontally?--> 
- bne ClearHorzMvmtAnimData ;If so, branch to stop movement. +        bne ClearHorzMvmtAnimData       ;If so, branch to stop movement. 
- jsr SFX_SamusWalk ;($CB96)Play walk SFX.+        jsr SFX_SamusWalk               ;($CB96)Play walk SFX.
  
 ClearHorzMvmtAnimData: ClearHorzMvmtAnimData:
-LCF5D:  jsr NoHorzMoveNoDelay ;($CF81)Clear horizontal movement and animation delay data. +LCF5D:  jsr NoHorzMoveNoDelay           ;($CF81)Clear horizontal movement and animation delay data. 
- sty ObjAction ;Samus is standing. +        sty ObjAction                   ;Samus is standing. 
- lda Joy1Status +        lda Joy1Status                  
- and #$08 ;Is The up button being pressed?--> +        and #$08                        ;Is The up button being pressed?--> 
- bne + ;If so, branch. +        bne +                           ;If so, branch. 
- lda #an_SamusStand ;Set Samus animation for standing.+        lda #an_SamusStand              ;Set Samus animation for standing.
  
 SetSamusAnim: SetSamusAnim:
-LCF6B: sta AnimResetIndex ;Set new animation reset index.+LCF6B:  sta AnimResetIndex              ;Set new animation reset index.
  
 SetSamusNextAnim: SetSamusNextAnim:
- sta AnimIndex ;Set new animation data index. +        sta AnimIndex                   ;Set new animation data index. 
- lda #$00 +        lda #$00                        
- sta AnimDelay ;New animation to take effect immediately. +        sta AnimDelay                   ;New animation to take effect immediately. 
- rts ;+        rts                             ;
  
 SetSamusPntUp: SetSamusPntUp:
-LCF77:* lda #sa_PntUp +LCF77:* lda #sa_PntUp                   
- sta ObjAction ;Samus is pointing up. +        sta ObjAction                   ;Samus is pointing up. 
- lda #an_SamusPntUp +        lda #an_SamusPntUp              
- jsr SetSamusAnim ;($CF6B)Set new animation values.+        jsr SetSamusAnim                ;($CF6B)Set new animation values.
  
 NoHorzMoveNoDelay: NoHorzMoveNoDelay:
-LCF81:  jsr ClearHorzData ;($CFB7)Clear all horizontal movement data. +LCF81:  jsr ClearHorzData               ;($CFB7)Clear all horizontal movement data. 
- sty AnimDelay ;Clear animation delay data. +        sty AnimDelay                   ;Clear animation delay data. 
- rts ;+        rts                             ;
  
 LCF88:  lda Joy1Status LCF88:  lda Joy1Status
- and #$03 +        and #$03 
- beq + +        beq + 
- jsr BitScan ;($E1E1) +        jsr BitScan                     ;($E1E1) 
- tax +        tax 
- jsr LCCB7 +        jsr LCCB7 
- lda SamusGravity +        lda SamusGravity 
- bmi ++ +        bmi ++ 
- lda AnimResetIndex +        lda AnimResetIndex 
- cmp #an_SamusSalto +        cmp #an_SamusSalto 
- beq ++ +        beq ++ 
- stx SamusDir +        stx SamusDir 
- lda Table06+1,+        lda Table06+1,
- jmp SetSamusAnim+        jmp SetSamusAnim
  
 *       lda SamusGravity *       lda SamusGravity
- bmi + +        bmi + 
- beq + +        beq + 
- lda AnimResetIndex +        lda AnimResetIndex 
- cmp #an_SamusJump +        cmp #an_SamusJump 
- bne ++        bne +
  
 ClearHorzData: ClearHorzData:
-LCFB7:  jsr ClearHorzMvmntData ;($CF4C)Clear horizontal speed and linear counter. +LCFB7:  jsr ClearHorzMvmntData          ;($CF4C)Clear horizontal speed and linear counter. 
- sty SamusHorzAccel ;Clear horizontal acceleration data. +        sty SamusHorzAccel              ;Clear horizontal acceleration data. 
-* rts ;+      rts                             ;
  
 LCFBE:  ldy #an_SamusJumpPntUp LCFBE:  ldy #an_SamusJumpPntUp
- jmp ++        jmp +
  
 SetSamusJump: SetSamusJump:
 LCFC3:  ldy #an_SamusJump LCFC3:  ldy #an_SamusJump
 *       sty AnimResetIndex *       sty AnimResetIndex
- dey +        dey 
- sty AnimIndex +        sty AnimIndex 
- lda #$04 +        lda #$04 
- sta AnimDelay +        sta AnimDelay 
- lda #$00 +        lda #$00 
- sta SamusJumpDsplcmnt +        sta SamusJumpDsplcmnt 
- lda #$FC +        lda #$FC 
- sta ObjVertSpeed +        sta ObjVertSpeed 
- ldx ObjAction +        ldx ObjAction 
- dex +        dex 
- bne +    ; branch if Samus is standing still +        bne +      ; branch if Samus is standing still 
- lda SamusGear +        lda SamusGear 
- and #gr_SCREWATTACK +        and #gr_SCREWATTACK 
- beq +    ; branch if Samus doesn't have Screw Attack +        beq +      ; branch if Samus doesn't have Screw Attack 
- lda #$00 +        lda #$00 
- sta $0686 +        sta $0686 
- jsr SFX_ScrewAttack+        jsr SFX_ScrewAttack
 *       jsr SFX_SamusJump *       jsr SFX_SamusJump
-LCFF3:  ldy #$18 ; gravity (high value -> low jump) +LCFF3:  ldy #$18        ; gravity (high value -> low jump) 
- lda SamusGear +        lda SamusGear 
- and #gr_HIGHJUMP +        and #gr_HIGHJUMP 
- beq +    ; branch if Samus doesn't have High Jump +        beq +      ; branch if Samus doesn't have High Jump 
- ldy #$12 ; lower gravity value -> high jump!+        ldy #$12        ; lower gravity value -> high jump!
 *       sty SamusGravity *       sty SamusGravity
- rts+        rts
  
 SamusJump: SamusJump:
- lda SamusJumpDsplcmnt +        lda SamusJumpDsplcmnt 
- bit ObjVertSpeed +        bit ObjVertSpeed 
- bpl +    ; branch if falling down +        bpl +      ; branch if falling down 
- cmp #$20 +        cmp #$20 
- bcc +    ; branch if jumped less than 32 pixels upwards +        bcc +      ; branch if jumped less than 32 pixels upwards 
- bit Joy1Status +        bit Joy1Status 
- bmi +    ; branch if JUMP button still pressed +        bmi +      ; branch if JUMP button still pressed 
- jsr StopVertMovement ;($D147)Stop jump (start falling).+        jsr StopVertMovement            ;($D147)Stop jump (start falling).
 *       jsr LD055 *       jsr LD055
- jsr LCF2E +        jsr LCF2E 
- lda Joy1Status +        lda Joy1Status 
- and #$08     ; UP pressed? +        and #$08     ; UP pressed? 
- beq +    ; branch if not +        beq +      ; branch if not 
- lda #an_SamusJumpPntUp +        lda #an_SamusJumpPntUp 
- sta AnimResetIndex +        sta AnimResetIndex 
- lda #sa_PntJump      ; "jumping & pointing up" handler +        lda #sa_PntJump      ; "jumping & pointing up" handler 
- sta ObjAction+        sta ObjAction
 *       jsr LD09C *       jsr LD09C
- lda SamusInLava +        lda SamusInLava 
- beq + +        beq + 
- lda Joy1Change +        lda Joy1Change 
- bpl +    ; branch if JUMP not pressed +        bpl +      ; branch if JUMP not pressed 
- jsr LCFC3 +        jsr LCFC3 
- jmp LCD6B+        jmp LCD6B
  
 *       lda SamusGravity *       lda SamusGravity
- bne ++ +        bne ++ 
- lda ObjAction +        lda ObjAction 
- cmp #sa_PntJump +        cmp #sa_PntJump 
- bne + +        bne + 
- jsr LCF77 +        jsr LCF77 
- bne +++        bne ++
 *       jsr LCF55 *       jsr LCF55
-* lda #$03 +      lda #$03 
- jmp SetSamusData ;($CD6D)Set Samus control data and animation.+        jmp SetSamusData                ;($CD6D)Set Samus control data and animation.
  
 LD055:  ldx #$01 LD055:  ldx #$01
- ldy #$00 +        ldy #$00 
- lda Joy1Status +        lda Joy1Status 
- lsr +        lsr 
- bcs +    ; branch if RIGHT pressed +        bcs +      ; branch if RIGHT pressed 
- dex +        dex 
- lsr +        lsr 
- bcc ++++       ; branch if LEFT not pressed +        bcc ++++       ; branch if LEFT not pressed 
- dex +        dex 
- iny+        iny
 *       cpy SamusDir *       cpy SamusDir
- beq +++ +        beq +++ 
- lda ObjAction +        lda ObjAction 
- cmp #sa_PntJump +        cmp #sa_PntJump 
- bne + +        bne + 
- lda AnimResetIndex +        lda AnimResetIndex 
- cmp Table04,y +        cmp Table04,y 
- bne ++ +        bne ++ 
- lda Table04+1,+        lda Table04+1,
- jmp +++        jmp ++
  
 *       lda AnimResetIndex *       lda AnimResetIndex
- cmp Table06,y +        cmp Table06,y 
- bne + +        bne + 
- lda Table06+1,+        lda Table06+1,
-* jsr SetSamusAnim +      jsr SetSamusAnim 
- lda #$08 +        lda #$08 
- sta AnimDelay +        sta AnimDelay 
- sty SamusDir +        sty SamusDir 
-* stx ObjHorzSpeed+      stx ObjHorzSpeed
 *       rts *       rts
  
Line 2743: Line 2743:
  
 Table06: Table06:
- .byte $0C +        .byte $0C 
- .byte $0C +        .byte $0C 
- .byte $0C+        .byte $0C
 Table04: Table04:
- .byte $35 +        .byte $35 
- .byte $35 +        .byte $35 
- .byte $35+        .byte $35
  
 LD09C:  lda Joy1Change LD09C:  lda Joy1Change
- ora Joy1Retrig +        ora Joy1Retrig 
- asl +        asl 
- bpl -    ; exit if FIRE not pressed +        bpl -      ; exit if FIRE not pressed 
- lda AnimResetIndex +        lda AnimResetIndex 
- cmp #an_SamusJumpPntUp +        cmp #an_SamusJumpPntUp 
- bne + +        bne + 
- jmp LD275+        jmp LD275
  
 *       jsr LD210 *       jsr LD210
- lda #an_SamusFireJump +        lda #an_SamusFireJump 
- jmp SetSamusAnim+        jmp SetSamusAnim
  
 SetSamusRoll: SetSamusRoll:
 LD0B5:  lda SamusGear LD0B5:  lda SamusGear
- and #gr_MARUMARI +        and #gr_MARUMARI 
- beq +    ; branch if Samus doesn't have Maru Mari +        beq +      ; branch if Samus doesn't have Maru Mari 
- lda SamusGravity +        lda SamusGravity 
- bne ++        bne +
  
 ;Turn Samus into ball ;Turn Samus into ball
- ldx SamusDir +        ldx SamusDir 
- lda #an_SamusRoll +        lda #an_SamusRoll 
- sta AnimResetIndex +        sta AnimResetIndex 
- lda #an_SamusRunJump +        lda #an_SamusRunJump 
- sta AnimIndex +        sta AnimIndex 
- lda LCCC0,x +        lda LCCC0,x 
- sta SamusHorzAccel +        sta SamusHorzAccel 
- lda #$01 +        lda #$01 
- sta $0686 +        sta $0686 
- jmp SFX_SamusBall+        jmp SFX_SamusBall
  
 *       lda #sa_Stand *       lda #sa_Stand
- sta ObjAction +        sta ObjAction 
- rts+        rts
  
 ; SamusRoll ; SamusRoll
 ; ========= ; =========
  
- SamusRoll: +        SamusRoll: 
- lda Joy1Change +        lda Joy1Change 
- and #$08     ; UP pressed? +        and #$08     ; UP pressed? 
- bne +    ; branch if yes +        bne +      ; branch if yes 
- bit Joy1Change ; JUMP pressed? +        bit Joy1Change  ; JUMP pressed? 
- bpl ++   ; branch if no+        bpl ++    ; branch if no
 *       lda Joy1Status *       lda Joy1Status
- and #$04    ; DOWN pressed? +        and #$04           ; DOWN pressed? 
- bne +   ; branch if yes+        bne +     ; branch if yes
 ;break out of "ball mode" ;break out of "ball mode"
- lda ObjRadY +        lda ObjRadY 
- clc +        clc 
- adc #$08 +        adc #$08 
- sta ObjRadY +        sta ObjRadY 
- jsr CheckMoveUp +        jsr CheckMoveUp 
- bcc +   ; branch if not possible to stand up +        bcc +     ; branch if not possible to stand up 
- ldx #$00 +        ldx #$00 
- jsr LE8BE +        jsr LE8BE 
- stx $05 +        stx $05 
- lda #$F5 +        lda #$F5 
- sta $04 +        sta $04 
- jsr LFD8F +        jsr LFD8F 
- jsr LD638 +        jsr LD638 
- jsr LCF55 +        jsr LCF55 
- dec AnimIndex +        dec AnimIndex 
- jsr StopVertMovement ;($D147) +        jsr StopVertMovement            ;($D147) 
- lda #$04 +        lda #$04 
- jmp LD144+        jmp LD144
  
-* lda Joy1Change +      lda Joy1Change 
- jsr BitScan ;($E1E1) +        jsr BitScan                     ;($E1E1) 
- cmp #$02 +        cmp #$02 
- bcs + +        bcs + 
- sta SamusDir +        sta SamusDir 
- lda #an_SamusRoll +        lda #an_SamusRoll 
- jsr SetSamusAnim+        jsr SetSamusAnim
 *       ldx SamusDir *       ldx SamusDir
- jsr LCCB7 +        jsr LCCB7 
- jsr LCF2E +        jsr LCF2E 
- jsr CheckBombLaunch +        jsr CheckBombLaunch 
- lda Joy1Status +        lda Joy1Status 
- and #$03 +        and #$03 
- bne + +        bne + 
- jsr LCFB7+        jsr LCFB7
 *       lda #$02 *       lda #$02
-LD144:  jmp SetSamusData ;($CD6D)Set Samus control data and animation.+LD144:  jmp SetSamusData                ;($CD6D)Set Samus control data and animation.
  
 StopVertMovement: StopVertMovement:
 LD147:  ldy #$00 LD147:  ldy #$00
- sty ObjVertSpeed +        sty ObjVertSpeed 
- sty VertCntrLinear +        sty VertCntrLinear 
- rts+        rts
  
 ; CheckBombLaunch ; CheckBombLaunch
Line 2853: Line 2853:
 ; - If so, a bomb is launched. ; - If so, a bomb is launched.
  
- CheckBombLaunch: +        CheckBombLaunch: 
- lda SamusGear +        lda SamusGear 
- lsr +        lsr 
- bcc ++   ; exit if Samus doesn't have Bombs +        bcc ++    ; exit if Samus doesn't have Bombs 
- lda Joy1Change +        lda Joy1Change 
- ora Joy1Retrig +        ora Joy1Retrig 
- asl ; bit 7 = status of FIRE button +        asl             ; bit 7 = status of FIRE button 
- bpl ++   ; exit if FIRE not pressed +        bpl ++    ; exit if FIRE not pressed 
- lda ObjVertSpeed +        lda ObjVertSpeed 
- ora SamusOnElevator +        ora SamusOnElevator 
- bne ++ +        bne ++ 
- ldx #$D0 ; try object slot D +        ldx #$D0        ; try object slot D 
- lda ObjAction,+        lda ObjAction,
- beq +    ; launch bomb if slot available +        beq +      ; launch bomb if slot available 
- ldx #$E0 ; try object slot E +        ldx #$E0        ; try object slot E 
- lda ObjAction,+        lda ObjAction,
- beq +    ; launch bomb if slot available +        beq +      ; launch bomb if slot available 
- ldx #$F0 ; try object slot F +        ldx #$F0        ; try object slot F 
- lda ObjAction,+        lda ObjAction,
- bne ++   ; no bomb slots available, exit+        bne ++    ; no bomb slots available, exit
 ; launch bomb... give it same coords as Samus ; launch bomb... give it same coords as Samus
 *       lda ObjectHi *       lda ObjectHi
- sta ObjectHi,+        sta ObjectHi,
- lda ObjectX +        lda ObjectX 
- sta ObjectX,x +        sta ObjectX,x 
- lda ObjectY +        lda ObjectY 
- clc +        clc 
- adc #$04 ; 4 pixels further down than Samus' center +        adc #$04        ; 4 pixels further down than Samus' center 
- sta ObjectY,x +        sta ObjectY,x 
- lda #wa_LayBomb +        lda #wa_LayBomb 
- sta ObjAction,+        sta ObjAction,
- jsr SFX_BombLaunch +        jsr SFX_BombLaunch 
-* rts+      rts
  
- SamusPntUp: +        SamusPntUp: 
- lda Joy1Status +        lda Joy1Status 
- and #$08     ; UP still pressed? +        and #$08     ; UP still pressed? 
- bne +    ; branch if yes +        bne +      ; branch if yes 
- lda #sa_Stand   ; stand handler +        lda #sa_Stand   ; stand handler 
- sta ObjAction+        sta ObjAction
 *       lda Joy1Status *       lda Joy1Status
- and #$07 ; DOWN, LEFT, RIGHT pressed? +        and #$07        ; DOWN, LEFT, RIGHT pressed? 
- beq ++   ; branch if no +        beq ++    ; branch if no 
- jsr BitScan ;($E1E1) +        jsr BitScan                     ;($E1E1) 
- cmp #$02 +        cmp #$02 
- bcs + +        bcs + 
- sta SamusDir+        sta SamusDir
 *       tax *       tax
- lda Table07,x +        lda Table07,x 
- sta ObjAction +        sta ObjAction 
-* lda Joy1Change +      lda Joy1Change 
- ora Joy1Retrig +        ora Joy1Retrig 
- asl +        asl 
- bpl +    ; branch if FIRE not pressed +        bpl +      ; branch if FIRE not pressed 
- jsr FireWeapon ;($D1EE)Shoot up.+        jsr FireWeapon                  ;($D1EE)Shoot up.
 *       bit Joy1Change *       bit Joy1Change
- bpl +    ; branch if JUMP not pressed +        bpl +      ; branch if JUMP not pressed 
- lda #sa_PntJump +        lda #sa_PntJump 
- sta ObjAction+        sta ObjAction
 *       lda #$04 *       lda #$04
- jsr SetSamusData ;($CD6D)Set Samus control data and animation. +        jsr SetSamusData                ;($CD6D)Set Samus control data and animation. 
- lda ObjAction +        lda ObjAction 
- jsr ChooseRoutine+        jsr ChooseRoutine
  
 ; Pointer table to code ; Pointer table to code
  
- .word $CF55 +        .word $CF55 
- .word $CC98 +        .word $CC98 
- .word ExitSub       ;($C45C)rts +        .word ExitSub       ;($C45C)rts 
- .word $D0B5 +        .word $D0B5 
- .word ExitSub       ;($C45C)rts +        .word ExitSub       ;($C45C)rts 
- .word ExitSub       ;($C45C)rts +        .word ExitSub       ;($C45C)rts 
- .word $CFBE +        .word $CFBE 
- .word ExitSub       ;($C45C)rts +        .word ExitSub       ;($C45C)rts 
- .word ExitSub       ;($C45C)rts +        .word ExitSub       ;($C45C)rts 
- .word ExitSub       ;($C45C)rts+        .word ExitSub       ;($C45C)rts
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table07: Table07:
- .byte sa_Run +        .byte sa_Run 
- .byte sa_Run +        .byte sa_Run 
- .byte sa_Roll+        .byte sa_Roll
  
 FireWeapon: FireWeapon:
 LD1EE:  lda Joy1Status LD1EE:  lda Joy1Status
- and #$08 +        and #$08 
- beq LD210 +        beq LD210 
- jmp LD275+        jmp LD275
  
 LD1F7:  ldy #$D0 LD1F7:  ldy #$D0
 *       lda ObjAction,y *       lda ObjAction,y
- beq + +        beq + 
- jsr Yplus16 +        jsr Yplus16 
- bne - +        bne - 
- iny +        iny 
- rts+        rts
  
 *       sta $030A,y *       sta $030A,y
- lda MissileToggle +        lda MissileToggle 
- beq + +        beq + 
- cpy #$D0+        cpy #$D0
 *       rts *       rts
  
 LD210:  lda MetroidOnSamus LD210:  lda MetroidOnSamus
- bne + +        bne + 
- jsr LD1F7 +        jsr LD1F7 
- bne + +        bne + 
- jsr LD2EB +        jsr LD2EB 
- jsr LD359 +        jsr LD359 
- jsr LD38E +        jsr LD38E 
- lda #$0C +        lda #$0C 
- sta $030F,y +        sta $030F,y 
- ldx SamusDir +        ldx SamusDir 
- lda Table99,  ; get bullet speed +        lda Table99,  ; get bullet speed 
- sta ObjHorzSpeed,    ; -4 or 4, depending on Samus' direction +        sta ObjHorzSpeed,    ; -4 or 4, depending on Samus' direction 
- lda #$00 +        lda #$00 
- sta ObjVertSpeed,+        sta ObjVertSpeed,
- lda #$01 +        lda #$01 
- sta ObjectOnScreen,+        sta ObjectOnScreen,
- jsr CheckMissileLaunch +        jsr CheckMissileLaunch 
- lda ObjAction,+        lda ObjAction,
- asl +        asl 
- ora SamusDir +        ora SamusDir 
- and #$03 +        and #$03 
- tax +        tax 
- lda Table08,x +        lda Table08,x 
- sta $05 +        sta $05 
- lda #$FA +        lda #$FA 
- sta $04 +        sta $04 
- jsr LD306 +        jsr LD306 
- lda SamusGear +        lda SamusGear 
- and #gr_LONGBEAM +        and #gr_LONGBEAM 
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- ror +        ror 
- ora $061F +        ora $061F 
- sta $061F +        sta $061F 
- ldx ObjAction,+        ldx ObjAction,
- dex +        dex 
- bne + +        bne + 
- jsr SFX_BulletFire+        jsr SFX_BulletFire
 *       ldy #$09 *       ldy #$09
 LD26B:  tya LD26B:  tya
- jmp SetSamusNextAnim+        jmp SetSamusNextAnim
  
 Table08: Table08:
- .byte $0C +        .byte $0C 
- .byte $F4 +        .byte $F4 
- .byte $08 +        .byte $08 
- .byte $F8+        .byte $F8
  
 Table99: Table99:
- .byte $04 +        .byte $04 
- .byte $FC+        .byte $FC
  
 LD275:  lda MetroidOnSamus LD275:  lda MetroidOnSamus
- bne + +        bne + 
- jsr LD1F7 +        jsr LD1F7 
- bne + +        bne + 
- jsr LD2EB +        jsr LD2EB 
- jsr LD38A +        jsr LD38A 
- jsr LD38E +        jsr LD38E 
- lda #$0C +        lda #$0C 
- sta $030F,y +        sta $030F,y 
- lda #$FC +        lda #$FC 
- sta ObjVertSpeed,+        sta ObjVertSpeed,
- lda #$00 +        lda #$00 
- sta ObjHorzSpeed,+        sta ObjHorzSpeed,
- lda #$01 +        lda #$01 
- sta ObjectOnScreen,+        sta ObjectOnScreen,
- jsr LD340 +        jsr LD340 
- ldx SamusDir +        ldx SamusDir 
- lda Table09+4,+        lda Table09+4,
- sta $05 +        sta $05 
- lda ObjAction,+        lda ObjAction,
- and #$01 +        and #$01 
- tax +        tax 
- lda Table09+6,+        lda Table09+6,
- sta $04 +        sta $04 
- jsr LD306 +        jsr LD306 
- lda SamusGear +        lda SamusGear 
- and #gr_LONGBEAM +        and #gr_LONGBEAM 
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- ror +        ror 
- ora $061F +        ora $061F 
- sta $061F +        sta $061F 
- lda ObjAction,+        lda ObjAction,
- cmp #$01 +        cmp #$01 
- bne + +        bne + 
- jsr SFX_BulletFire+        jsr SFX_BulletFire
 *       ldx SamusDir *       ldx SamusDir
- ldy Table09,x +        ldy Table09,x 
- lda SamusGravity +        lda SamusGravity 
- beq + +        beq + 
- ldy Table09+2,x+        ldy Table09+2,x
 *       lda ObjAction *       lda ObjAction
- cmp #$01 +        cmp #$01 
- beq + +        beq + 
- jmp LD26B+        jmp LD26B
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table09: Table09:
- .byte $26 +        .byte $26 
- .byte $26 +        .byte $26 
- .byte $34 +        .byte $34 
- .byte $34 +        .byte $34 
- .byte $01 +        .byte $01 
- .byte $FF +        .byte $FF 
- .byte $EC +        .byte $EC 
- .byte $F0+        .byte $F0
  
 LD2EB:  tya LD2EB:  tya
- tax +        tax 
- inc ObjAction,+        inc ObjAction,
- lda #$02 +        lda #$02 
- sta ObjRadY,y +        sta ObjRadY,y 
- sta ObjRadX,y +        sta ObjRadX,y 
- lda #an_Bullet+        lda #an_Bullet
  
 SetProjectileAnim: SetProjectileAnim:
-LD2FA: sta AnimResetIndex,+LD2FA:  sta AnimResetIndex,
- sta AnimIndex,+        sta AnimIndex,
- lda #$00 +        lda #$00 
- sta AnimDelay,x+        sta AnimDelay,x
 *       rts *       rts
  
 LD306:  ldx #$00 LD306:  ldx #$00
- jsr LE8BE +        jsr LE8BE 
- tya +        tya 
- tax +        tax 
- jsr LFD8F +        jsr LFD8F 
- txa +        txa 
- tay +        tay 
- jmp LD638+        jmp LD638
  
 CheckMissileLaunch: CheckMissileLaunch:
- lda MissileToggle +        lda MissileToggle 
- beq Exit4       ; exit if Samus not in "missile fire" mode +        beq Exit4       ; exit if Samus not in "missile fire" mode 
- cpy #$D0 +        cpy #$D0 
- bne Exit4 +        bne Exit4 
- ldx SamusDir +        ldx SamusDir 
- lda MissileAnims,x+        lda MissileAnims,x
 *       jsr SetBulletAnim *       jsr SetBulletAnim
- jsr SFX_MissileLaunch +        jsr SFX_MissileLaunch 
- lda #wa_Missile ; missile handler +        lda #wa_Missile ; missile handler 
- sta ObjAction,+        sta ObjAction,
- lda #$FF +        lda #$FF 
- sta $030F,    ; # of frames projectile should last +        sta $030F,    ; # of frames projectile should last 
- dec MissileCount +        dec MissileCount 
- bne Exit4       ; exit if not the last missile+        bne Exit4       ; exit if not the last missile
 ; Samus has no more missiles left ; Samus has no more missiles left
- dec MissileToggle       ; put Samus in "regular fire" mode +        dec MissileToggle       ; put Samus in "regular fire" mode 
- jmp SelectSamusPal      ; update Samus' palette to reflect this+        jmp SelectSamusPal      ; update Samus' palette to reflect this
  
 MissileAnims: MissileAnims:
- .byte an_MissileRight +        .byte an_MissileRight 
- .byte an_MissileLeft+        .byte an_MissileLeft
  
 LD340:  lda MissileToggle LD340:  lda MissileToggle
- beq Exit4 +        beq Exit4 
- cpy #$D0 +        cpy #$D0 
- bne Exit4 +        bne Exit4 
- lda #$8F +        lda #$8F 
- bne -+        bne -
  
 SetBulletAnim: SetBulletAnim:
- sta AnimIndex,+        sta AnimIndex,
- sta AnimResetIndex,+        sta AnimResetIndex,
- lda #$00 +        lda #$00 
- sta AnimDelay,y+        sta AnimDelay,y
 Exit4:  rts Exit4:  rts
  
 LD359:  lda SamusDir LD359:  lda SamusDir
 *       sta $0502,y *       sta $0502,y
- bit SamusGear +        bit SamusGear 
- bvc Exit4       ; branch if Samus doesn't have Wave Beam +        bvc Exit4       ; branch if Samus doesn't have Wave Beam 
- lda MissileToggle +        lda MissileToggle 
- bne Exit4 +        bne Exit4 
- lda #$00 +        lda #$00 
- sta $0501,y +        sta $0501,y 
- sta $0304,y +        sta $0304,y 
- tya +        tya 
- jsr Adiv32      ; / 32 +        jsr Adiv32      ; / 32 
- lda #$00 +        lda #$00 
- bcs + +        bcs + 
- lda #$0C+        lda #$0C
 *       sta $0500,y *       sta $0500,y
- lda #wa_WaveBeam +        lda #wa_WaveBeam 
- sta ObjAction,+        sta ObjAction,
- lda #an_WaveBeam +        lda #an_WaveBeam 
- jsr SetBulletAnim +        jsr SetBulletAnim 
- jmp SFX_WaveFire+        jmp SFX_WaveFire
  
 LD38A:  lda #$02 LD38A:  lda #$02
- bne --+        bne --
 LD38E:  lda MissileToggle LD38E:  lda MissileToggle
- bne Exit4 +        bne Exit4 
- lda SamusGear +        lda SamusGear 
- bpl Exit4       ; branch if Samus doesn't have Ice Beam +        bpl Exit4       ; branch if Samus doesn't have Ice Beam 
- lda #wa_IceBeam +        lda #wa_IceBeam 
- sta ObjAction,+        sta ObjAction,
- lda $061F +        lda $061F 
- ora #$01 +        ora #$01 
- sta $061F +        sta $061F 
- jmp SFX_BulletFire+        jmp SFX_BulletFire
  
 ; SamusDoor ; SamusDoor
Line 3168: Line 3168:
  
 SamusDoor: SamusDoor:
- lda DoorStatus +        lda DoorStatus 
- cmp #$05 +        cmp #$05 
- bcc ++++++++        bcc +++++++
     ; move Samus out of door, how far depends on initial value of DoorDelay     ; move Samus out of door, how far depends on initial value of DoorDelay
- dec DoorDelay +        dec DoorDelay 
- bne MoveOutDoor+        bne MoveOutDoor
     ; done moving     ; done moving
- asl +        asl 
- bcc + +        bcc + 
- lsr +        lsr 
- sta DoorStatus +        sta DoorStatus 
- bne ++++++++        bne +++++++
 *       jsr LD48C *       jsr LD48C
- jsr LED65 +        jsr LED65 
- jsr $95AB +        jsr $95AB 
- lda ItemRoomMusicStatus +        lda ItemRoomMusicStatus 
- beq ++ +        beq ++ 
- pha +        pha 
- jsr LD92C       ; start music +        jsr LD92C       ; start music 
- pla +        pla 
- bpl ++ +        bpl ++ 
- lda #$00 +        lda #$00 
- sta ItemRoomMusicStatus +        sta ItemRoomMusicStatus 
- beq +++        beq ++
 *       lda #$80 *       lda #$80
- sta ItemRoomMusicStatus+        sta ItemRoomMusicStatus
 *       lda KraidRidleyPresent *       lda KraidRidleyPresent
- beq + +        beq + 
- jsr LCC07 +        jsr LCC07 
- lda #$00 +        lda #$00 
- sta KraidRidleyPresent +        sta KraidRidleyPresent 
- beq --    ; branch always+        beq --     ; branch always
 *       lda SamusDoorData *       lda SamusDoorData
- and #$0F +        and #$0F 
- sta ObjAction +        sta ObjAction 
- lda #$00 +        lda #$00 
- sta SamusDoorData +        sta SamusDoorData 
- sta DoorStatus +        sta DoorStatus 
- jsr StopVertMovement ;($D147)+        jsr StopVertMovement            ;($D147)
  
 MoveOutDoor: MoveOutDoor:
- lda SamusDoorDir +        lda SamusDoorDir 
- beq ++   ; branch if door leads to the right +        beq ++    ; branch if door leads to the right 
- ldy ObjectX +        ldy ObjectX 
- bne + +        bne + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord+        jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord
 *       dec ObjectX *       dec ObjectX
- jmp +++        jmp ++
  
-* inc ObjectX +      inc ObjectX 
- bne + +        bne + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord +        jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord 
-* jsr CheckHealthStatus ;($CDFA)Check if Samus hit, blinking or Health low. +      jsr CheckHealthStatus           ;($CDFA)Check if Samus hit, blinking or Health low. 
- jsr SetmirrorCntrlBit +        jsr SetmirrorCntrlBit 
- jmp DrawFrame       ; display Samus+        jmp DrawFrame       ; display Samus
  
 SamusDead: SamusDead:
-D41A: lda #$01 +D41A:   lda #$01 
- jmp SetSamusData ;($CD6D)Set Samus control data and animation.+        jmp SetSamusData                ;($CD6D)Set Samus control data and animation.
  
 SamusDead2: SamusDead2:
- dec AnimDelay +        dec AnimDelay 
- rts+        rts
  
 ; SamusElevator ; SamusElevator
Line 3236: Line 3236:
  
 SamusElevator: SamusElevator:
- lda ElevatorStatus +        lda ElevatorStatus 
- cmp #$03 +        cmp #$03 
- beq + +        beq + 
- cmp #$08 +        cmp #$08 
- bne ++++++++        bne +++++++
 *       lda $032F *       lda $032F
- bmi +++ +        bmi +++ 
- lda ObjectY +        lda ObjectY 
- sec +        sec 
- sbc ScrollY     ; A = Samus' Y position on the visual screen +        sbc ScrollY     ; A = Samus' Y position on the visual screen 
- cmp #$84 +        cmp #$84 
- bcc +    ; if ScreenY < $84, don't scroll +        bcc +      ; if ScreenY < $84, don't scroll 
- jsr ScrollDown  ; otherwise, attempt to scroll+        jsr ScrollDown  ; otherwise, attempt to scroll
 *       ldy ObjectY *       ldy ObjectY
- cpy #239 ; wrap-around required? +        cpy #239        ; wrap-around required? 
- bne + +        bne + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord +        jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord 
- ldy #$FF ; ObjectY will now be 0+        ldy #$FF        ; ObjectY will now be 0
 *       iny *       iny
- sty ObjectY +        sty ObjectY 
- jmp LD47E+        jmp LD47E
  
-* lda ObjectY +      lda ObjectY 
- sec +        sec 
- sbc ScrollY     ; A = Samus' Y position on the visual screen +        sbc ScrollY     ; A = Samus' Y position on the visual screen 
- cmp #$64 +        cmp #$64 
- bcs +    ; if ScreenY >= $64, don't scroll +        bcs +      ; if ScreenY >= $64, don't scroll 
- jsr ScrollUp    ; otherwise, attempt to scroll+        jsr ScrollUp    ; otherwise, attempt to scroll
 *       ldy ObjectY *       ldy ObjectY
- bne +    ; wraparound required? (branch if not) +        bne +      ; wraparound required? (branch if not) 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord +        jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord 
- ldy #240 ; ObjectY will now be 239+        ldy #240        ; ObjectY will now be 239
 *       dey *       dey
- sty ObjectY +        sty ObjectY 
- jmp LD47E+        jmp LD47E
  
-* ldy #$00 +      ldy #$00 
- sty ObjVertSpeed +        sty ObjVertSpeed 
- cmp #$05 +        cmp #$05 
- beq + +        beq + 
- cmp #$07 +        cmp #$07 
- beq ++        beq +
 LD47E:  lda FrameCount LD47E:  lda FrameCount
- lsr +        lsr 
- bcc ++ +        bcc ++ 
-*       jsr SetmirrorCntrlBit ;($CD92)Mirror Samus, if necessary. +*       jsr SetmirrorCntrlBit           ;($CD92)Mirror Samus, if necessary. 
- lda #$01 +        lda #$01 
- jmp AnimDrawObject +        jmp AnimDrawObject 
-* rts+      rts
  
 LD48C:  ldx #$60 LD48C:  ldx #$60
- sec+        sec
 *       jsr LD4B4 *       jsr LD4B4
- txa +        txa 
- sbc #$20 +        sbc #$20 
- tax +        tax 
- bpl - +        bpl - 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- tay +        tay 
- ldx #$18+        ldx #$18
 *       jsr LD4A8 *       jsr LD4A8
- txa +        txa 
- sec +        sec 
- sbc #$08 +        sbc #$08 
- tax +        tax 
- bne -+        bne -
 LD4A8:  tya LD4A8:  tya
- cmp $072C,x +        cmp $072C,x 
- bne + +        bne + 
- lda #$FF +        lda #$FF 
- sta $0728,x+        sta $0728,x
 *       rts *       rts
  
-LD4B4: lda $0405,x +LD4B4:  lda $0405,x 
-LD4B7: and #$02 +LD4B7:  and #$02 
-LD4B9: bne + +LD4B9:  bne + 
-LD4BB: sta EnStatus,+LD4BB:  sta EnStatus,
-LD4BE:* rts+LD4BE:* rts
  
 ; UpdateProjectiles ; UpdateProjectiles
Line 3319: Line 3319:
  
 UpdateProjectiles: UpdateProjectiles:
- ldx #$D0+        ldx #$D0
 jsr DoOneProjectile jsr DoOneProjectile
- ldx #$E0+        ldx #$E0
 jsr DoOneProjectile jsr DoOneProjectile
- ldx #$F0+        ldx #$F0
 DoOneProjectile: DoOneProjectile:
- stx PageIndex +        stx PageIndex 
- lda ObjAction,+        lda ObjAction,
-LD4D0: jsr ChooseRoutine+LD4D0:  jsr ChooseRoutine
  
-LD4D3: .word ExitSub     ;($C45C) rts +LD4D3:  .word ExitSub     ;($C45C) rts 
-LD4D5: .word UpdateBullet ; regular beam +LD4D5:  .word UpdateBullet ; regular beam 
- .word UpdateWaveBullet      ; wave beam +        .word UpdateWaveBullet      ; wave beam 
- .word UpdateIceBullet       ; ice beam +        .word UpdateIceBullet       ; ice beam 
- .word BulletExplode    ; bullet/missile explode +        .word BulletExplode    ; bullet/missile explode 
- .word $D65E       ; lay bomb +        .word $D65E       ; lay bomb 
- .word $D670       ; lay bomb +        .word $D670       ; lay bomb 
- .word $D691       ; lay bomb +        .word $D691       ; lay bomb 
- .word $D65E       ; lay bomb +        .word $D65E       ; lay bomb 
- .word $D670       ; bomb countdown +        .word $D670       ; bomb countdown 
- .word $D691       ; bomb explode +        .word $D691       ; bomb explode 
- .word UpdateBullet  ; missile+        .word UpdateBullet  ; missile
  
 UpdateBullet: UpdateBullet:
- lda #$01 +        lda #$01 
- sta UpdatingProjectile +        sta UpdatingProjectile 
- jsr LD5FC +        jsr LD5FC 
- jsr LD5DA +        jsr LD5DA 
- jsr LD609+        jsr LD609
 CheckBulletStat: CheckBulletStat:
- ldx PageIndex +        ldx PageIndex 
- bcc + +        bcc + 
- lda SamusGear +        lda SamusGear 
- and #gr_LONGBEAM +        and #gr_LONGBEAM 
- bne DrawBullet  ; branch if Samus has Long Beam +        bne DrawBullet  ; branch if Samus has Long Beam 
- dec $030F,    ; decrement bullet timer +        dec $030F,    ; decrement bullet timer 
- bne DrawBullet +        bne DrawBullet 
- lda #$00 ; timer hit 0, kill bullet +        lda #$00        ; timer hit 0, kill bullet 
- sta ObjAction,+        sta ObjAction,
- beq DrawBullet  ; branch always+        beq DrawBullet  ; branch always
 *       lda ObjAction,x *       lda ObjAction,x
- beq + +        beq + 
- jsr LD5E4+        jsr LD5E4
 DrawBullet: DrawBullet:
- lda #$01 +        lda #$01 
- jsr AnimDrawObject+        jsr AnimDrawObject
 *       dec UpdatingProjectile *       dec UpdatingProjectile
- rts+        rts
  
 *       inc $0500,x *       inc $0500,x
 LD522:  inc $0500,x LD522:  inc $0500,x
- lda #$00 +        lda #$00 
- sta $0501,x +        sta $0501,x 
- beq +    ; branch always+        beq +      ; branch always
  
 UpdateWaveBullet: UpdateWaveBullet:
- lda #$01 +        lda #$01 
- sta UpdatingProjectile +        sta UpdatingProjectile 
- jsr LD5FC +        jsr LD5FC 
- jsr LD5DA +        jsr LD5DA 
- lda $0502,x +        lda $0502,x 
- and #$FE +        and #$FE 
- tay +        tay 
- lda Table0A,y +        lda Table0A,y 
- sta $0A +        sta $0A 
- lda Table0A+1,+        lda Table0A+1,
- sta $0B+        sta $0B
 *       ldy $0500,x *       ldy $0500,x
- lda ($0A),y +        lda ($0A),y 
- cmp #$FF +        cmp #$FF 
- bne + +        bne + 
- sta $0500,x +        sta $0500,x 
- jmp LD522+        jmp LD522
  
 *       cmp $0501,x *       cmp $0501,x
- beq --- +        beq --- 
- inc $0501,x +        inc $0501,x 
- iny +        iny 
- lda ($0A),y +        lda ($0A),y 
- jsr $8296 +        jsr $8296 
- ldx PageIndex +        ldx PageIndex 
- sta ObjVertSpeed,+        sta ObjVertSpeed,
- lda ($0A),y +        lda ($0A),y 
- jsr $832F +        jsr $832F 
- ldx PageIndex +        ldx PageIndex 
- sta ObjHorzSpeed,+        sta ObjHorzSpeed,
- tay +        tay 
- lda $0502,x +        lda $0502,x 
- lsr +        lsr 
- bcc + +        bcc + 
- tya +        tya 
- jsr TwosCompliment ;($C3D4) +        jsr TwosCompliment              ;($C3D4) 
- sta ObjHorzSpeed,x+        sta ObjHorzSpeed,x
 *       jsr LD609 *       jsr LD609
- bcs + +        bcs + 
- jsr LD624+        jsr LD624
 *       jmp CheckBulletStat *       jmp CheckBulletStat
  
 Table0A: Table0A:
- .word Table0C     ; pointer to table #1 below +        .word Table0C     ; pointer to table #1 below 
- .word Table0D     ; pointer to table #2 below+        .word Table0D     ; pointer to table #2 below
  
 ; Table #1 (size: 25 bytes) ; Table #1 (size: 25 bytes)
  
 Table0C: Table0C:
- .byte $01 +        .byte $01 
- .byte $F3 +        .byte $F3 
- .byte $01 +        .byte $01 
- .byte $D3 +        .byte $D3 
- .byte $01 +        .byte $01 
- .byte $93 +        .byte $93 
- .byte $01 +        .byte $01 
- .byte $13 +        .byte $13 
- .byte $01 +        .byte $01 
- .byte $53 +        .byte $53 
- .byte $01 +        .byte $01 
- .byte $73 +        .byte $73 
- .byte $01 +        .byte $01 
- .byte $73 +        .byte $73 
- .byte $01 +        .byte $01 
- .byte $53 +        .byte $53 
- .byte $01 +        .byte $01 
- .byte $13 +        .byte $13 
- .byte $01 +        .byte $01 
- .byte $93 +        .byte $93 
- .byte $01 +        .byte $01 
- .byte $D3 +        .byte $D3 
- .byte $01 +        .byte $01 
- .byte $F3 +        .byte $F3 
- .byte $FF+        .byte $FF
  
 ; Table #2 (size: 25 bytes) ; Table #2 (size: 25 bytes)
  
 Table0D: Table0D:
- .byte $01 +        .byte $01 
- .byte $B7 +        .byte $B7 
- .byte $01 +        .byte $01 
- .byte $B5 +        .byte $B5 
- .byte $01 +        .byte $01 
- .byte $B1 +        .byte $B1 
- .byte $01 +        .byte $01 
- .byte $B9 +        .byte $B9 
- .byte $01 +        .byte $01 
- .byte $BD +        .byte $BD 
- .byte $01 +        .byte $01 
- .byte $BF +        .byte $BF 
- .byte $01 +        .byte $01 
- .byte $BF +        .byte $BF 
- .byte $01 +        .byte $01 
- .byte $BD +        .byte $BD 
- .byte $01 +        .byte $01 
- .byte $B9 +        .byte $B9 
- .byte $01 +        .byte $01 
- .byte $B1 +        .byte $B1 
- .byte $01 +        .byte $01 
- .byte $B5 +        .byte $B5 
- .byte $01 +        .byte $01 
- .byte $B7 +        .byte $B7 
- .byte $FF+        .byte $FF
  
 ; UpdateIceBullet ; UpdateIceBullet
 ; =============== ; ===============
  
- UpdateIceBullet: +        UpdateIceBullet: 
- lda #$81 +        lda #$81 
- sta ObjectCntrl +        sta ObjectCntrl 
- jmp UpdateBullet+        jmp UpdateBullet
  
 ; BulletExplode ; BulletExplode
Line 3491: Line 3491:
 ; bullet/missile explode ; bullet/missile explode
  
- BulletExplode: +        BulletExplode: 
- lda #$01 +        lda #$01 
- sta UpdatingProjectile +        sta UpdatingProjectile 
- lda $0303,x +        lda $0303,x 
- sec +        sec 
- sbc #$F7 +        sbc #$F7 
- bne + +        bne + 
- sta ObjAction,x ; kill bullet+        sta ObjAction, ; kill bullet
 *       jmp DrawBullet *       jmp DrawBullet
  
 LD5DA:  lda $030A,x LD5DA:  lda $030A,x
- beq Exit5 +        beq Exit5 
- lda #$00 +        lda #$00 
- sta $030A,x+        sta $030A,x
 LD5E4:  lda #$1D LD5E4:  lda #$1D
- ldy ObjAction,+        ldy ObjAction,
- cpy #wa_BulletExplode +        cpy #wa_BulletExplode 
- beq Exit5 +        beq Exit5 
- cpy #wa_Missile +        cpy #wa_Missile 
- bne + +        bne + 
- lda #an_MissileExplode+        lda #an_MissileExplode
 *       jsr SetProjectileAnim *       jsr SetProjectileAnim
- lda #wa_BulletExplode+        lda #wa_BulletExplode
 *       sta ObjAction,x *       sta ObjAction,x
 Exit5:  rts Exit5:  rts
  
 LD5FC:  lda ObjectOnScreen,x LD5FC:  lda ObjectOnScreen,x
- lsr +        lsr 
- bcs Exit5 +        bcs Exit5 
-* lda #$00 +      lda #$00 
- beq --  ; branch always+        beq --   ; branch always
 *       jmp LE81E *       jmp LE81E
  
Line 3527: Line 3527:
  
 LD609:  jsr GetObjCoords LD609:  jsr GetObjCoords
- ldy #$00 +        ldy #$00 
- lda ($04),    ; get tile # that bullet touches +        lda ($04),    ; get tile # that bullet touches 
- cmp #$A0 +        cmp #$A0 
- bcs LD624 +        bcs LD624 
- jsr $95C0 +        jsr $95C0 
- cmp #$4E +        cmp #$4E 
- beq - +        beq - 
- jsr LD651 +        jsr LD651 
- bcc ++ +        bcc ++ 
- clc +        clc 
- jmp IsBlastTile+        jmp IsBlastTile
  
 LD624:  ldx PageIndex LD624:  ldx PageIndex
- lda ObjHorzSpeed,+        lda ObjHorzSpeed,
- sta $05 +        sta $05 
- lda ObjVertSpeed,+        lda ObjVertSpeed,
- sta $04 +        sta $04 
- jsr LE8BE +        jsr LE8BE 
- jsr LFD8F +        jsr LFD8F 
- bcc --+        bcc --
 LD638:  lda $08 LD638:  lda $08
- sta ObjectY,x +        sta ObjectY,x 
- lda $09 +        lda $09 
- sta ObjectX,x +        sta ObjectX,x 
- lda $0B +        lda $0B 
- and #$01 +        and #$01 
- bpl +    ; branch always +        bpl +      ; branch always 
- ToggleObjectHi: +        ToggleObjectHi: 
- lda ObjectHi,+        lda ObjectHi,
- eor #$01+        eor #$01
 *       sta ObjectHi,x *       sta ObjectHi,x
-* rts+      rts
  
 LD651:  ldy InArea LD651:  ldy InArea
- cpy #$10 +        cpy #$10 
- beq + +        beq + 
- cmp #$70 +        cmp #$70 
- bcs +++        bcs ++
 *       cmp #$80 *       cmp #$80
-* rts+      rts
  
 LD65E:  lda #an_BombTick LD65E:  lda #an_BombTick
- jsr SetProjectileAnim +        jsr SetProjectileAnim 
- lda #$18 ; fuse length :-) +        lda #$18        ; fuse length :-) 
- sta $030F,x +        sta $030F,x 
- inc ObjAction,      ; bomb update handler +        inc ObjAction,      ; bomb update handler 
- DrawBomb: +        DrawBomb: 
- lda #$03 +        lda #$03 
- jmp AnimDrawObject+        jmp AnimDrawObject
  
 LD670:  lda FrameCount LD670:  lda FrameCount
- lsr +        lsr 
- bcc ++   ; only update counter on odd frames +        bcc ++    ; only update counter on odd frames 
- dec $030F,x +        dec $030F,x 
- bne ++ +        bne ++ 
- lda #$37 +        lda #$37 
- ldy ObjAction,+        ldy ObjAction,
- cpy #$09 +        cpy #$09 
- bne + +        bne + 
- lda #an_BombExplode+        lda #an_BombExplode
 *       jsr SetProjectileAnim *       jsr SetProjectileAnim
- inc ObjAction,+        inc ObjAction,
- jsr SFX_BombExplode +        jsr SFX_BombExplode 
-* jmp DrawBomb+      jmp DrawBomb
  
 LD691:  inc $030F,x LD691:  inc $030F,x
- jsr LD6A7 +        jsr LD6A7 
- ldx PageIndex +        ldx PageIndex 
- lda $0303,x +        lda $0303,x 
- sec +        sec 
- sbc #$F7 +        sbc #$F7 
- bne + +        bne + 
- sta ObjAction,    ; kill bomb+        sta ObjAction,    ; kill bomb
 *       jmp DrawBomb *       jmp DrawBomb
  
 LD6A7:  jsr GetObjCoords LD6A7:  jsr GetObjCoords
- lda $04 +        lda $04 
- sta $0A +        sta $0A 
- lda $05 +        lda $05 
- sta $0B +        sta $0B 
- ldx PageIndex +        ldx PageIndex 
- ldy $030F,x +        ldy $030F,x 
- dey +        dey 
- beq ++ +        beq ++ 
- dey +        dey 
- bne +++ +        bne +++ 
- lda #$40 +        lda #$40 
- jsr LD78B +        jsr LD78B 
- txa +        txa 
- bne + +        bne + 
- lda $04 +        lda $04 
- and #$20 +        and #$20 
- beq Exit6+        beq Exit6
 *       lda $05 *       lda $05
- and #$03 +        and #$03 
- cmp #$03 +        cmp #$03 
- bne + +        bne + 
- lda $04 +        lda $04 
- cmp #$C0 +        cmp #$C0 
- bcc + +        bcc + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne Exit6 +        bne Exit6 
- lda #$80 +        lda #$80 
- jsr LD78B +        jsr LD78B 
-* jsr LD76A+      jsr LD76A
 Exit6:  rts Exit6:  rts
  
-* dey +      dey 
- bne +++ +        bne +++ 
- lda #$40 +        lda #$40 
- jsr LD77F +        jsr LD77F 
- txa +        txa 
- bne + +        bne + 
- lda $04 +        lda $04 
- and #$20 +        and #$20 
- bne Exit6+        bne Exit6
 *       lda $05 *       lda $05
- and #$03 +        and #$03 
- cmp #$03 +        cmp #$03 
- bne + +        bne + 
- lda $04 +        lda $04 
- cmp #$C0 +        cmp #$C0 
- bcc + +        bcc + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne Exit6 +        bne Exit6 
- lda #$80 +        lda #$80 
- jsr LD77F+        jsr LD77F
 *       jmp LD76A *       jmp LD76A
  
-* dey +      dey 
- bne +++ +        bne +++ 
- lda #$02 +        lda #$02 
- jsr LD78B +        jsr LD78B 
- txa +        txa 
- bne + +        bne + 
- lda $04 +        lda $04 
- lsr +        lsr 
- bcc Exit7+        bcc Exit7
 *       lda $04 *       lda $04
- and #$1F +        and #$1F 
- cmp #$1E +        cmp #$1E 
- bcc + +        bcc + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- beq Exit7 +        beq Exit7 
- lda #$1E +        lda #$1E 
- jsr LD77F +        jsr LD77F 
- lda $05 +        lda $05 
- eor #$04 +        eor #$04 
- sta $05+        sta $05
 *       jmp LD76A *       jmp LD76A
  
-* dey +      dey 
- bne Exit7 +        bne Exit7 
- lda #$02 +        lda #$02 
- jsr LD77F +        jsr LD77F 
- txa +        txa 
- bne + +        bne + 
- lda $04 +        lda $04 
- lsr +        lsr 
- bcs Exit7+        bcs Exit7
 *       lda $04 *       lda $04
- and #$1F +        and #$1F 
- cmp #$02 +        cmp #$02 
- bcs LD76A +        bcs LD76A 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- beq Exit7 +        beq Exit7 
- lda #$1E +        lda #$1E 
- jsr LD78B +        jsr LD78B 
- lda $05 +        lda $05 
- eor #$04 +        eor #$04 
- sta $05+        sta $05
 LD76A:  txa LD76A:  txa
- pha +        pha 
- ldy #$00 +        ldy #$00 
- lda ($04),y +        lda ($04),y 
- jsr LD651 +        jsr LD651 
- bcc + +        bcc + 
- cmp #$A0 +        cmp #$A0 
- bcs + +        bcs + 
- jsr LE9C2+        jsr LE9C2
 *       pla *       pla
- tax+        tax
 Exit7:  rts Exit7:  rts
  
 LD77F:  clc LD77F:  clc
- adc $0A +        adc $0A 
- sta $04 +        sta $04 
- lda $0B +        lda $0B 
- adc #$00 +        adc #$00 
- jmp LD798+        jmp LD798
  
 LD78B:  sta $00 LD78B:  sta $00
- lda $0A +        lda $0A 
- sec +        sec 
- sbc $00 +        sbc $00 
- sta $04 +        sta $04 
- lda $0B +        lda $0B 
- sbc #$00+        sbc #$00
 LD798:  and #$07 LD798:  and #$07
- ora #$60 +        ora #$60 
- sta $05+        sta $05
 *       rts *       rts
  
Line 3737: Line 3737:
  
 GetObjCoords: GetObjCoords:
-LD79F: ldx PageIndex ;Load index into object RAM to find proper object. +LD79F:  ldx PageIndex                   ;Load index into object RAM to find proper object. 
-LD7A1: lda ObjectY,x +LD7A1:  lda ObjectY,                  
-LD7A4: sta $02 ;Load and save temp copy of object y coord. +LD7A4:  sta $02                         ;Load and save temp copy of object y coord. 
-LD7A6: lda ObjectX,x +LD7A6:  lda ObjectX,                  
-LD7A9: sta $03 ;Load and save temp copy of object x coord. +LD7A9:  sta $03                         ;Load and save temp copy of object x coord. 
-LD7AB: lda ObjectHi,x +LD7AB:  lda ObjectHi,                 
-LD7AE: sta $0B ;Load and save temp copy of object nametable. +LD7AE:  sta $0B                         ;Load and save temp copy of object nametable. 
-LD7B0: jmp MakeCartRAMPtr ;($E96A)Find object position in room RAM.+LD7B0:  jmp MakeCartRAMPtr              ;($E96A)Find object position in room RAM.
  
 ;--------------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------
  
 UpdateElevator: UpdateElevator:
- ldx #$20 +        ldx #$20 
- stx PageIndex +        stx PageIndex 
- lda ObjAction,+        lda ObjAction,
- jsr ChooseRoutine+        jsr ChooseRoutine
  
 ; Pointer table to elevator handlers ; Pointer table to elevator handlers
  
- .word ExitSub       ;($C45C) rts +        .word ExitSub       ;($C45C) rts 
- .word ElevatorIdle +        .word ElevatorIdle 
- .word $D80E +        .word $D80E 
- .word ElevatorMove +        .word ElevatorMove 
- .word ElevatorScroll +        .word ElevatorScroll 
- .word $D8A3 +        .word $D8A3 
- .word $D8BF +        .word $D8BF 
- .word $D8A3 +        .word $D8A3 
- .word ElevatorMove +        .word ElevatorMove 
- .word ElevatorStop+        .word ElevatorStop
  
- ElevatorIdle: +        ElevatorIdle: 
- lda SamusOnElevator +        lda SamusOnElevator 
- beq ShowElevator +        beq ShowElevator 
- lda #$04 +        lda #$04 
- bit $032F       ; elevator direction in bit 7 (1 = up) +        bit $032F       ; elevator direction in bit 7 (1 = up) 
- bpl + +        bpl + 
- asl ; btn_UP+        asl             ; btn_UP
 *       and Joy1Status *       and Joy1Status
- beq ShowElevator+        beq ShowElevator
     ; start elevator!     ; start elevator!
- jsr StopVertMovement ;($D147) +        jsr StopVertMovement            ;($D147) 
- sty AnimDelay +        sty AnimDelay 
- sty SamusGravity +        sty SamusGravity 
- tya +        tya 
- sta ObjVertSpeed,+        sta ObjVertSpeed,
- inc ObjAction,+        inc ObjAction,
- lda #sa_Elevator +        lda #sa_Elevator 
- sta ObjAction +        sta ObjAction 
- lda #an_SamusFront +        lda #an_SamusFront 
- jsr SetSamusAnim +        jsr SetSamusAnim 
- lda #128 +        lda #128 
- sta ObjectX     ; center +        sta ObjectX     ; center 
- lda #112 +        lda #112 
- sta ObjectY     ; center +        sta ObjectY     ; center 
- ShowElevator: +        ShowElevator: 
- lda FrameCount +        lda FrameCount 
- lsr +        lsr 
- bcc --   ; only display elevator at odd frames +        bcc --    ; only display elevator at odd frames 
- jmp DrawFrame       ; display elevator+        jmp DrawFrame       ; display elevator
  
 LD80E:  lda ScrollX LD80E:  lda ScrollX
- bne + +        bne + 
- lda MirrorCntrl +        lda MirrorCntrl 
- ora #$08 +        ora #$08 
- sta MirrorCntrl +        sta MirrorCntrl 
- lda ScrollDir +        lda ScrollDir 
- and #$01 +        and #$01 
- sta ScrollDir +        sta ScrollDir 
- inc ObjAction,+        inc ObjAction,
- jmp ShowElevator+        jmp ShowElevator
  
 *       lda #$80 *       lda #$80
- sta ObjectX +        sta ObjectX 
- lda ObjectX,x +        lda ObjectX,x 
- sec +        sec 
- sbc ScrollX +        sbc ScrollX 
- bmi + +        bmi + 
- jsr ScrollLeft +        jsr ScrollLeft 
- jmp ShowElevator+        jmp ShowElevator
  
 *       jsr ScrollRight *       jsr ScrollRight
- jmp ShowElevator+        jmp ShowElevator
  
- ElevatorMove: +        ElevatorMove: 
- lda $030F,x +        lda $030F,x 
- bpl ++   ; branch if elevator going down+        bpl ++    ; branch if elevator going down
     ; move elevator up one pixel     ; move elevator up one pixel
- ldy ObjectY,x +        ldy ObjectY,x 
- bne + +        bne + 
- jsr ToggleObjectHi +        jsr ToggleObjectHi 
- ldy #240+        ldy #240
 *       dey *       dey
- tya +        tya 
- sta ObjectY,x +        sta ObjectY,x 
- jmp +++        jmp ++
  
     ; move elevator down one pixel     ; move elevator down one pixel
-* inc ObjectY,x +      inc ObjectY,x 
- lda ObjectY,x +        lda ObjectY,x 
- cmp #240 +        cmp #240 
- bne + +        bne + 
- jsr ToggleObjectHi +        jsr ToggleObjectHi 
- lda #$00 +        lda #$00 
- sta ObjectY,x +        sta ObjectY,x 
-* cmp #$83 +      cmp #$83 
- bne +    ; move until Y coord = $83 +        bne +      ; move until Y coord = $83 
- inc ObjAction,x+        inc ObjAction,x
 *       jmp ShowElevator *       jmp ShowElevator
  
- ElevatorScroll: +        ElevatorScroll: 
- lda ScrollY +        lda ScrollY 
- bne ElevScrollRoom  ; scroll until ScrollY = 0 +        bne ElevScrollRoom  ; scroll until ScrollY = 0 
- lda #$4E +        lda #$4E 
- sta AnimResetIndex +        sta AnimResetIndex 
- lda #$41 +        lda #$41 
- sta AnimIndex +        sta AnimIndex 
- lda #$5D +        lda #$5D 
- sta AnimResetIndex,+        sta AnimResetIndex,
- lda #$50 +        lda #$50 
- sta AnimIndex,+        sta AnimIndex,
- inc ObjAction,+        inc ObjAction,
- lda #$40 +        lda #$40 
- sta Timer1 +        sta Timer1 
- jmp ShowElevator+        jmp ShowElevator
  
- ElevScrollRoom: +        ElevScrollRoom: 
- lda $030F,x +        lda $030F,x 
- bpl +    ; branch if elevator going down +        bpl +      ; branch if elevator going down 
- jsr ScrollUp +        jsr ScrollUp 
- jmp ShowElevator+        jmp ShowElevator
  
 *       jsr ScrollDown *       jsr ScrollDown
- jmp ShowElevator+        jmp ShowElevator
  
 LD8A3:  inc ObjAction,x LD8A3:  inc ObjAction,x
- lda ObjAction,+        lda ObjAction,
- cmp #$08 ; ElevatorMove +        cmp #$08        ; ElevatorMove 
- bne + +        bne + 
- lda #$23 +        lda #$23 
- sta $0303,x +        sta $0303,x 
- lda #an_SamusFront +        lda #an_SamusFront 
- jsr SetSamusAnim +        jsr SetSamusAnim 
- jmp ShowElevator+        jmp ShowElevator
  
 *       lda #$01 *       lda #$01
- jmp AnimDrawObject+        jmp AnimDrawObject
  
 LD8BF:  lda $030F,x LD8BF:  lda $030F,x
- tay +        tay 
- cmp #$8F ; Leads-To-Ending elevator? +        cmp #$8F        ; Leads-To-Ending elevator? 
- bne ++        bne +
     ; Samus made it! YAY!     ; Samus made it! YAY!
- lda #$07 +        lda #$07 
- sta MainRoutine +        sta MainRoutine 
- inc AtEnding +        inc AtEnding 
- ldy #$00 +        ldy #$00 
- sty $33 +        sty $33 
- iny +        iny 
- sty SwitchPending   ; switch to bank 0 +        sty SwitchPending   ; switch to bank 0 
- lda #$1D ; ending +        lda #$1D        ; ending 
- sta TitleRoutine +        sta TitleRoutine 
- rts+        rts
  
 *       tya *       tya
- bpl ++ +        bpl ++ 
- ldy #$00 +        ldy #$00 
- cmp #$84 +        cmp #$84 
- bne + +        bne + 
- iny+        iny
 *       tya *       tya
-* ora #$10 +      ora #$10 
- jsr LCA18 +        jsr LCA18 
- lda PalToggle +        lda PalToggle 
- eor #$07 +        eor #$07 
- sta PalToggle +        sta PalToggle 
- ldy InArea +        ldy InArea 
- cpy #$12 +        cpy #$12 
- bcc + +        bcc + 
- lda #$01+        lda #$01
 *       sta PalDataPending *       sta PalDataPending
- jsr WaitNMIPass_ +        jsr WaitNMIPass_ 
- jsr SelectSamusPal +        jsr SelectSamusPal 
- jsr StartMusic ;($LD92C)Start music. +        jsr StartMusic                  ;($LD92C)Start music. 
- jsr ScreenOn +        jsr ScreenOn 
- jsr CopyPtrs +        jsr CopyPtrs 
- jsr DestroyEnemies +        jsr DestroyEnemies 
- ldx #$20 +        ldx #$20 
- stx PageIndex +        stx PageIndex 
- lda #$6B +        lda #$6B 
- sta AnimResetIndex +        sta AnimResetIndex 
- lda #$5F +        lda #$5F 
- sta AnimIndex +        sta AnimIndex 
- lda #$7A +        lda #$7A 
- sta AnimResetIndex,+        sta AnimResetIndex,
- lda #$6E +        lda #$6E 
- sta AnimIndex,+        sta AnimIndex,
- inc ObjAction,+        inc ObjAction,
- lda #$40 +        lda #$40 
- sta Timer1 +        sta Timer1 
- rts+        rts
  
 StartMusic: StartMusic:
-LD92C: lda ElevatorStatus +LD92C:  lda ElevatorStatus 
- cmp #$06 +        cmp #$06 
- bne + +        bne + 
- lda $032F +        lda $032F 
- bmi ++ +        bmi ++ 
-*       lda $95CD ;Load proper bit flag for area music. +*       lda $95CD                       ;Load proper bit flag for area music. 
- ldy ItemRoomMusicStatus +        ldy ItemRoomMusicStatus 
- bmi ++ +        bmi ++ 
- beq ++ +        beq ++ 
-* lda #$81 +      lda #$81 
- sta ItemRoomMusicStatus +        sta ItemRoomMusicStatus 
- lda #$20 ;Set flag to play item room music.+        lda #$20                        ;Set flag to play item room music.
  
-* ora MusicInitFlag +      ora MusicInitFlag               
- sta MusicInitFlag ;Store music flag info. +        sta MusicInitFlag               ;Store music flag info. 
- rts ;+        rts                             ;
  
 ElevatorStop: ElevatorStop:
- lda ScrollY +        lda ScrollY 
- bne ++   ; scroll until ScrollY = 0 +        bne ++    ; scroll until ScrollY = 0 
- lda #sa_Stand +        lda #sa_Stand 
- sta ObjAction +        sta ObjAction 
- jsr LCF55 +        jsr LCF55 
- ldx PageIndex   ; #$20 +        ldx PageIndex   ; #$20 
- lda #$01 ; ElevatorIdle +        lda #$01        ; ElevatorIdle 
- sta ObjAction,+        sta ObjAction,
- lda $030F,x +        lda $030F,x 
- eor #$80 ; switch elevator direction +        eor #$80        ; switch elevator direction 
- sta $030F,x +        sta $030F,x 
- bmi + +        bmi + 
- jsr ToggleScroll +        jsr ToggleScroll 
- sta MirrorCntrl+        sta MirrorCntrl
 *       jmp ShowElevator *       jmp ShowElevator
-* jmp ElevScrollRoom+      jmp ElevScrollRoom
  
 SamusOnElevatorOrEnemy: SamusOnElevatorOrEnemy:
-LD976:  lda #$00 +LD976:  lda #$00                        
- sta SamusOnElevator ;Assume Samus is not on an elevator or on a frozen enemy. +        sta SamusOnElevator             ;Assume Samus is not on an elevator or on a frozen enemy. 
- sta OnFrozenEnemy +        sta OnFrozenEnemy               
- tay +        tay 
- ldx #$50 +        ldx #$50 
- jsr LF186+        jsr LF186
 *       lda EnStatus,x *       lda EnStatus,x
- cmp #$04 +        cmp #$04 
- bne + +        bne + 
- jsr LF152 +        jsr LF152 
- jsr LF1BF +        jsr LF1BF 
- jsr LF1FA +        jsr LF1FA 
- bcs + +        bcs + 
- jsr LD9BA +        jsr LD9BA 
- bne + +        bne + 
-D99A: inc OnFrozenEnemy ;Samus is standing on a frozen enemy. +D99A:   inc OnFrozenEnemy               ;Samus is standing on a frozen enemy. 
- bne +++        bne ++
 *       jsr Xminus16 *       jsr Xminus16
- bpl -- +        bpl -- 
-* lda ElevatorStatus +      lda ElevatorStatus 
- beq + +        beq + 
- ldy #$00 +        ldy #$00 
- ldx #$20 +        ldx #$20 
- jsr LDC82 +        jsr LDC82 
- bcs + +        bcs + 
- jsr LD9BA +        jsr LD9BA 
- bne + +        bne + 
- inc SamusOnElevator ;Samus is standing on elevator.+        inc SamusOnElevator             ;Samus is standing on elevator.
 *       rts *       rts
  
 LD9BA:  lda $10 LD9BA:  lda $10
- and #$02 +        and #$02 
- bne + +        bne + 
- ldy $11 +        ldy $11 
- iny +        iny 
- cpy $04 +        cpy $04 
- beq Exit8+        beq Exit8
 *       lda SamusHit *       lda SamusHit
- and #$38 +        and #$38 
- ora $10 +        ora $10 
- ora #$40 +        ora #$40 
- sta SamusHit+        sta SamusHit
 Exit8:  rts Exit8:  rts
  
Line 4022: Line 4022:
 ; ============= ; =============
  
- UpdateStatues: +        UpdateStatues: 
- lda #$60 +        lda #$60 
- sta PageIndex +        sta PageIndex 
- ldy $0360 +        ldy $0360 
- beq Exit8    ; exit if no statue present +        beq Exit8          ; exit if no statue present 
- dey +        dey 
- bne + +        bne + 
- jsr LDAB0 +        jsr LDAB0 
- ldy #$01 +        ldy #$01 
- jsr LDAB0 +        jsr LDAB0 
- bcs + +        bcs + 
- inc $0360+        inc $0360
 *       ldy $0360 *       ldy $0360
- cpy #$02 +        cpy #$02 
- bne +++ +        bne +++ 
- lda KraidStatueStatus +        lda KraidStatueStatus 
- bpl + +        bpl + 
- ldy #$02 +        ldy #$02 
- jsr LDAB0+        jsr LDAB0
 *       lda $687C *       lda $687C
- bpl + +        bpl + 
- ldy #$03 +        ldy #$03 
- jsr LDAB0+        jsr LDAB0
 *       bcs + *       bcs +
- inc $0360 +        inc $0360 
-* ldx #$60 +      ldx #$60 
- jsr LDA1A +        jsr LDA1A 
- ldx #$61 +        ldx #$61 
- jsr LDA1A +        jsr LDA1A 
- jmp LDADA+        jmp LDADA
  
 LDA1A:  jsr LDA3D LDA1A:  jsr LDA3D
- jsr LDA7C +        jsr LDA7C 
- txa +        txa 
- and #$01 +        and #$01 
- tay +        tay 
- lda LDA3B,y +        lda LDA3B,y 
- sta $0363 +        sta $0363 
- lda $681B,x +        lda $681B,x 
- beq + +        beq + 
- bmi + +        bmi + 
- lda FrameCount +        lda FrameCount 
- lsr +        lsr 
- bcc ++   ; only display statue at odd frames+        bcc ++    ; only display statue at odd frames
 *       jmp DrawFrame       ; display statue *       jmp DrawFrame       ; display statue
  
 LDA39:  .byte $88 LDA39:  .byte $88
- .byte $68+        .byte $68
 LDA3B:  .byte $65 LDA3B:  .byte $65
- .byte $66+        .byte $66
  
 LDA3D:  lda $0304,x LDA3D:  lda $0304,x
- bmi + +        bmi + 
- lda #$01 +        lda #$01 
- sta $0304,x +        sta $0304,x 
- lda $030F,x +        lda $030F,x 
- and #$0F +        and #$0F 
- beq + +        beq + 
- inc $0304,x +        inc $0304,x 
- dec $030F,x +        dec $030F,x 
- lda $030F,x +        lda $030F,x 
- and #$0F +        and #$0F 
- bne + +        bne + 
- lda $0304,x +        lda $0304,x 
- ora #$80 +        ora #$80 
- sta $0304,x +        sta $0304,x 
- sta $681B,x +        sta $681B,x 
- inc $0304,x +        inc $0304,x 
- txa +        txa 
- pha +        pha 
- and #$01 +        and #$01 
- pha +        pha 
- tay +        tay 
- jsr LDAB0 +        jsr LDAB0 
- pla +        pla 
- tay +        tay 
- iny +        iny 
- iny +        iny 
- jsr LDAB0 +        jsr LDAB0 
- pla +        pla 
- tax +        tax 
-* rts+      rts
  
 LDA7C:  lda $030F,x LDA7C:  lda $030F,x
- sta $036D +        sta $036D 
- txa +        txa 
- and #$01 +        and #$01 
- tay +        tay 
- lda LDA39,y +        lda LDA39,y 
- sta $036E +        sta $036E 
- lda $681B,x +        lda $681B,x 
- beq + +        beq + 
- bmi + +        bmi + 
- lda $0304,x +        lda $0304,x 
- cmp #$01 +        cmp #$01 
- bne + +        bne + 
- lda $0306,x +        lda $0306,x 
- beq + +        beq + 
- dec $030F,x +        dec $030F,x 
- lda $0683 +        lda $0683 
- ora #$10 +        ora #$10 
- sta $0683+        sta $0683
 *       lda #$00 *       lda #$00
- sta $0306,x +        sta $0306,x 
- rts+        rts
  
 LDAB0:  lda Table0E,y LDAB0:  lda Table0E,y
- sta $05C8 +        sta $05C8 
- lda $036C +        lda $036C 
- asl +        asl 
- asl +        asl 
- ora Table1B,y +        ora Table1B,y 
- sta $05C9 +        sta $05C9 
- lda #$09 +        lda #$09 
- sta $05C3 +        sta $05C3 
- lda #$C0 +        lda #$C0 
- sta PageIndex +        sta PageIndex 
- jsr DrawTileBlast +        jsr DrawTileBlast 
- lda #$60 +        lda #$60 
- sta PageIndex +        sta PageIndex 
- rts+        rts
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table0E: Table0E:
- .byte $30 +        .byte $30 
- .byte $AC +        .byte $AC 
- .byte $F0 +        .byte $F0 
- .byte $6C+        .byte $6C
 Table1B: Table1B:
- .byte $61 +        .byte $61 
- .byte $60 +        .byte $60 
- .byte $60 +        .byte $60 
- .byte $60+        .byte $60
  
 LDADA:  lda $54 LDADA:  lda $54
- bmi Exit0 +        bmi Exit0 
- lda DoorStatus +        lda DoorStatus 
- bne Exit0 +        bne Exit0 
- lda KraidStatueStatus +        lda KraidStatueStatus 
- and $687C +        and $687C 
- bpl Exit0 +        bpl Exit0 
- sta $54 +        sta $54 
- ldx #$70 +        ldx #$70 
- ldy #$08+        ldy #$08
 *       lda #$03 *       lda #$03
- sta $0500,x +        sta $0500,x 
- tya +        tya 
- asl +        asl 
- sta $0507,x +        sta $0507,x 
- lda #$04 +        lda #$04 
- sta TileType,+        sta TileType,
- lda $036C +        lda $036C 
- asl +        asl 
- asl +        asl 
- ora #$62 +        ora #$62 
- sta TileWRAMHi,+        sta TileWRAMHi,
- tya +        tya 
- asl +        asl 
- adc #$08 +        adc #$08 
- sta TileWRAMLo,+        sta TileWRAMLo,
- jsr Xminus16 +        jsr Xminus16 
- dey +        dey 
- bne -+        bne -
 Exit0:  rts Exit0:  rts
  
Line 4193: Line 4193:
  
 CheckMissileToggle: CheckMissileToggle:
- lda MissileCount +        lda MissileCount 
- beq Exit0       ; exit if Samus has no missiles +        beq Exit0       ; exit if Samus has no missiles 
- lda Joy1Change +        lda Joy1Change 
- ora Joy1Retrig +        ora Joy1Retrig 
- and #$20  +        and #$20         
- beq Exit0       ; exit if SELECT not pressed +        beq Exit0       ; exit if SELECT not pressed 
- lda MissileToggle +        lda MissileToggle 
- eor #$01 ; 0 = fire bullets, 1 = fire missiles +        eor #$01        ; 0 = fire bullets, 1 = fire missiles 
- sta MissileToggle +        sta MissileToggle 
- jmp SelectSamusPal+        jmp SelectSamusPal
  
 ; MakeBitMask ; MakeBitMask
Line 4209: Line 4209:
  
 MakeBitMask: MakeBitMask:
-LDB2F: sec +LDB2F:  sec 
-LDB30: lda #$00 +LDB30:  lda #$00 
-LDB32:* rol +LDB32:* rol 
-LDB33: dey +LDB33:  dey 
-LDB34: bpl - +LDB34:  bpl - 
-LDB36:* rts+LDB36:* rts
  
 ;------------------------------------------[ Update items ]----------------------------------------- ;------------------------------------------[ Update items ]-----------------------------------------
  
 UpdateItems: UpdateItems:
-LDB37: lda #$40 ;PowerUp RAM starts at $0340. +LDB37:  lda #$40                        ;PowerUp RAM starts at $0340. 
-LDB39: sta PageIndex +LDB39:  sta PageIndex                   
-LDB3B: ldx #$00 ;Check first item slot. +LDB3B:  ldx #$00                        ;Check first item slot. 
-LDB3D: jsr CheckOneItem ;($DB42)Check current item slot. +LDB3D:  jsr CheckOneItem                ;($DB42)Check current item slot. 
-LDB40: ldx #$08 ;Check second item slot.+LDB40:  ldx #$08                        ;Check second item slot.
  
 CheckOneItem: CheckOneItem:
-LDB42: stx ItemIndex ;First or second item slot index(#$00 or #$08). +LDB42:  stx ItemIndex                   ;First or second item slot index(#$00 or #$08). 
-LDB44: ldy PowerUpType,x +LDB44:  ldy PowerUpType,              
-LDB47: iny ;Is no item present in item slot(#$FF)?--> +LDB47:  iny                             ;Is no item present in item slot(#$FF)?--> 
-LDB48: beq - ;If so, branch to exit.+LDB48:  beq -                           ;If so, branch to exit.
  
-LDB4A: lda PowerUpYCoord,x +LDB4A:  lda PowerUpYCoord,            
-LDB4D: sta PowerUpY +LDB4D:  sta PowerUpY                    
-LDB50: lda PowerUpXCoord,x ;Store y, x and name table coordinates of power up item. +LDB50:  lda PowerUpXCoord,            ;Store y, x and name table coordinates of power up item. 
-LDB53: sta PowerUpX +LDB53:  sta PowerUpX                    
-LDB56: lda PowerUpNameTable,x +LDB56:  lda PowerUpNameTable,         
-LDB59: sta PowerUpHi +LDB59:  sta PowerUpHi                   
-LDB5C: jsr GetObjCoords ;($D79F)Find object position in room RAM. +LDB5C:  jsr GetObjCoords                ;($D79F)Find object position in room RAM. 
-LDB5F: ldx ItemIndex ;Index to proper power up item. +LDB5F:  ldx ItemIndex                   ;Index to proper power up item. 
-LDB61: ldy #$00 ;Reset index. +LDB61:  ldy #$00                        ;Reset index. 
-LDB63: lda ($04),y ;Load pointer into room RAM. +LDB63:  lda ($04),                    ;Load pointer into room RAM. 
-LDB65: cmp #$A0 ;Is object being placed on top of a solid tile?--> +LDB65:  cmp #$A0                        ;Is object being placed on top of a solid tile?--> 
-LDB67: bcc - ;If so, branch to exit. +LDB67:  bcc -                           ;If so, branch to exit. 
-LDB69: lda PowerUpType,x +LDB69:  lda PowerUpType,              
-LDB6C: and #$0F ;Load power up type byte and keep only bits 0 thru 3. +LDB6C:  and #$0F                        ;Load power up type byte and keep only bits 0 thru 3. 
-LDB6E: ora #$50 ;Set bits 4 and 6. +LDB6E:  ora #$50                        ;Set bits 4 and 6. 
-LDB70: sta PowerUpAnimFrame ;Save index to find object animation. +LDB70:  sta PowerUpAnimFrame            ;Save index to find object animation. 
-LDB73: lda FrameCount +LDB73:  lda FrameCount                  
-LDB75: lsr ;Color affected every other frame. +LDB75:  lsr                             ;Color affected every other frame. 
-LDB76: and #$03 ;the 2 LSBs of object control byte change palette of object. +LDB76:  and #$03                        ;the 2 LSBs of object control byte change palette of object. 
-LDB78: ora #$80 ;Indicate ObjectCntrl contains valid data by setting MSB. +LDB78:  ora #$80                        ;Indicate ObjectCntrl contains valid data by setting MSB. 
-LDB7A: sta ObjectCntrl ;Change color of item every other frame. +LDB7A:  sta ObjectCntrl                 ;Change color of item every other frame. 
-LDB7C: lda SpritePagePos ;Load current index into sprite RAM. +LDB7C:  lda SpritePagePos               ;Load current index into sprite RAM. 
-LDB7E: pha ;Temp save sprite RAM position. +LDB7E:  pha                             ;Temp save sprite RAM position. 
-LDB7F: lda PowerUpAnimIndex,x ;Load entry into FramePtrTable for item animation. +LDB7F:  lda PowerUpAnimIndex,         ;Load entry into FramePtrTable for item animation. 
-LDB82: jsr DrawFrame ;($DE4A)Display special item.+LDB82:  jsr DrawFrame                   ;($DE4A)Display special item.
  
-LDB85: pla ;Restore sprite page position byte. +LDB85:  pla                             ;Restore sprite page position byte. 
-LDB86: cmp SpritePagePos ;Was power up item successfully drawn?--> +LDB86:  cmp SpritePagePos               ;Was power up item successfully drawn?--> 
-LDB88: beq Exit9 ;If not, branch to exit. +LDB88:  beq Exit9                       ;If not, branch to exit. 
-LDB8A: tax ;Store sprite page position in x. +LDB8A:  tax                             ;Store sprite page position in x. 
-LDB8B: ldy ItemIndex ;Load index to proper power up data slot. +LDB8B:  ldy ItemIndex                   ;Load index to proper power up data slot. 
-LDB8D: lda PowerUpType,y ;Reload power up type data. +LDB8D:  lda PowerUpType,              ;Reload power up type data. 
-LDB90: ldy #$01 ;Set power up color for ice beam orb. +LDB90:  ldy #$01                        ;Set power up color for ice beam orb. 
-LDB92: cmp #$07 ;Is power up item the ice beam?--> +LDB92:  cmp #$07                        ;Is power up item the ice beam?--> 
-LDB94: beq + ;If so, branch.+LDB94:  beq +                           ;If so, branch.
  
-LDB96: dey ;Set power up color for long/wave beam orb. +LDB96:  dey                             ;Set power up color for long/wave beam orb. 
-LDB97: cmp #$06 ;Is power up item the wave beam?--> +LDB97:  cmp #$06                        ;Is power up item the wave beam?--> 
-LDB99: beq + ;If so, branch. +LDB99:  beq +                           ;If so, branch. 
-LDB9B: cmp #$02 ;Is power up item the long beam?--> +LDB9B:  cmp #$02                        ;Is power up item the long beam?--> 
-LDB9D: bne ++ ;If not, branch. +LDB9D:  bne ++                          ;If not, branch. 
-LDB9F:* tya ;Transfer color data to A. +LDB9F:* tya                             ;Transfer color data to A. 
-LDBA0: sta Sprite01RAM+2,x ;Store power up color for beam weapon. +LDBA0:  sta Sprite01RAM+2,            ;Store power up color for beam weapon. 
-LDBA3: lda #$FF ;Indicate power up obtained is a beam weapon.+LDBA3:  lda #$FF                        ;Indicate power up obtained is a beam weapon.
  
-LDBA5:* pha ;Temporarily store power up type. +LDBA5:* pha                             ;Temporarily store power up type. 
-LDBA6: ldx #$00 ;Index to object 0(Samus). +LDBA6:  ldx #$00                        ;Index to object 0(Samus). 
-LDBA8: ldy #$40 ;Index to object 1(power up). +LDBA8:  ldy #$40                        ;Index to object 1(power up). 
-LDBAA: jsr AreObjectsTouching ;($DC7F)Determine if Samus is touching power up. +LDBAA:  jsr AreObjectsTouching          ;($DC7F)Determine if Samus is touching power up. 
-LDBAD: pla ;Restore power up type byte. +LDBAD:  pla                             ;Restore power up type byte. 
-LDBAE: bcs Exit9 ;Carry clear=Samus touching power up. Carry set=not touching.+LDBAE:  bcs Exit9                       ;Carry clear=Samus touching power up. Carry set=not touching.
  
-LDBB0: tay ;Store power-up type byte in Y. +LDBB0:  tay                             ;Store power-up type byte in Y. 
-LDBB1: jsr PowerUpMusic ;($CBF9)Power up obtained! Play power up music. +LDBB1:  jsr PowerUpMusic                ;($CBF9)Power up obtained! Play power up music. 
-LDBB4: ldx ItemIndex ;X=index to power up item slot. +LDBB4:  ldx ItemIndex                   ;X=index to power up item slot. 
-LDBB6: iny ;Is item obtained a beam weapon?--> +LDBB6:  iny                             ;Is item obtained a beam weapon?--> 
-LDBB7: beq + ;If so, branch. +LDBB7:  beq +                           ;If so, branch. 
-LDBB9: lda PowerUpNameTable,x +LDBB9:  lda PowerUpNameTable,         
-LDBBC: sta $08 ;Temp storage of nametable and power-up type in $08--> +LDBBC:  sta $08                         ;Temp storage of nametable and power-up type in $08--> 
-LDBBE: lda PowerUpType,x ;and $09 respectively. +LDBBE:  lda PowerUpType,              ;and $09 respectively. 
-LDBC1: sta $09 +LDBC1:  sta $09                         
-LDBC3: jsr GetItemXYPos ;($DC1C)Get proper X and Y coords of item, save in history. +LDBC3:  jsr GetItemXYPos                ;($DC1C)Get proper X and Y coords of item, save in history. 
-LDBC6:* lda PowerUpType,x ;Get power-up type byte again. +LDBC6:* lda PowerUpType,              ;Get power-up type byte again. 
-LDBC9: tay +LDBC9:  tay                             
-LDBCA: cpy #$08 ;Is power-up item a missile or energy tank?--> +LDBCA:  cpy #$08                        ;Is power-up item a missile or energy tank?--> 
-LDBCC: bcs ++++ ;If so, branch. +LDBCC:  bcs ++++                        ;If so, branch. 
-LDBCE: cpy #$06 ;Is item the wave beam or ice beam?--> +LDBCE:  cpy #$06                        ;Is item the wave beam or ice beam?--> 
-LDBD0: bcc + ;If not, branch. +LDBD0:  bcc +                           ;If not, branch. 
-LDBD2: lda SamusGear ;Clear status of wave beam and ice beam power ups. +LDBD2:  lda SamusGear                   ;Clear status of wave beam and ice beam power ups. 
-LDBD5: and #$3F +LDBD5:  and #$3F                        
-LDBD7: sta SamusGear ;Remove beam weapon data from Samus gear byte. +LDBD7:  sta SamusGear                   ;Remove beam weapon data from Samus gear byte. 
-LDBDA:* jsr MakeBitMask ;($DB2F)Create a bit mask for beam weapon just obtained. +LDBDA:* jsr MakeBitMask                 ;($DB2F)Create a bit mask for beam weapon just obtained. 
-LDBDD: ora SamusGear +LDBDD:  ora SamusGear                   
-LDBE0: sta SamusGear ;Update Samus gear with new beam weapon. +LDBE0:  sta SamusGear                   ;Update Samus gear with new beam weapon. 
-LDBE3:* lda #$FF +LDBE3:* lda #$FF                        
-LDBE5: sta PowerUpDelay ;Initiate delay while power up music plays. +LDBE5:  sta PowerUpDelay                ;Initiate delay while power up music plays. 
-LDBE8: sta PowerUpType,x ;Clear out item data from RAM. +LDBE8:  sta PowerUpType,              ;Clear out item data from RAM. 
-LDBEB: ldy ItemRoomMusicStatus ;Is Samus not in an item room?--> +LDBEB:  ldy ItemRoomMusicStatus         ;Is Samus not in an item room?--> 
-LDBED: beq + ;If not, branch. +LDBED:  beq +                           ;If not, branch. 
-LDBEF: ldy #$01 ;Restart item room music after special item music is done. +LDBEF:  ldy #$01                        ;Restart item room music after special item music is done. 
-LDBF1:* sty ItemRoomMusicStatus +LDBF1:* sty ItemRoomMusicStatus         
-LDBF3: jmp SelectSamusPal ;($CB73)Set Samus new palette.+LDBF3:  jmp SelectSamusPal              ;($CB73)Set Samus new palette.
  
 Exit9: Exit9:
-LDBF6: rts ;Exit for multiple routines above.+LDBF6:  rts                             ;Exit for multiple routines above.
  
 MissileEnergyPickup: MissileEnergyPickup:
-LDBF7:* beq + ;Branch if item is an energy tank. +LDBF7:* beq +                           ;Branch if item is an energy tank. 
-LDBF9: lda #$05 +LDBF9:  lda #$05                        
-LDBFB: jsr AddToMaxMissiles ;($DD97)Increase missile capacity by 5. +LDBFB:  jsr AddToMaxMissiles            ;($DD97)Increase missile capacity by 5. 
-LDBFE: bne --- ;Branch always.+LDBFE:  bne ---                         ;Branch always.
  
-LDC00:* lda TankCount +LDC00:* lda TankCount                   
-LDC03: cmp #$06 ;Has Samus got 6 energy tanks?--> +LDC03:  cmp #$06                        ;Has Samus got 6 energy tanks?--> 
-LDC05: beq + ;If so, she can't have any more.--> +LDC05:  beq +                           ;If so, she can't have any more.--> 
-LDC07: inc TankCount ;Otherwise give her a new tank. +LDC07:  inc TankCount                   ;Otherwise give her a new tank. 
-LDC0A:* lda TankCount +LDC0A:* lda TankCount                   
-LDC0D: jsr Amul16 ;Get tank count and shift into upper nibble. +LDC0D:  jsr Amul16                      ;Get tank count and shift into upper nibble. 
-LDC10: ora #$09 +LDC10:  ora #$09                        
-LDC12: sta HealthHi ;Set new tank count. Upper health digit set to 9. +LDC12:  sta HealthHi                    ;Set new tank count. Upper health digit set to 9. 
-LDC15: lda #$99 ;Max out low health digit. +LDC15:  lda #$99                        ;Max out low health digit. 
-LDC17: sta HealthLo ;Health is now FULL! +LDC17:  sta HealthLo                    ;Health is now FULL! 
-LDC1A: bne ----- ;Branch always.+LDC1A:  bne -----                       ;Branch always.
  
 ;It is possible for the current nametable in the PPU to not be the actual nametable the special item ;It is possible for the current nametable in the PPU to not be the actual nametable the special item
Line 4340: Line 4340:
  
 GetItemXYPos: GetItemXYPos:
-LDC1C:  lda MapPosX +LDC1C:  lda MapPosX                     
-LDC1E: sta $07 ;Temp storage of Samus map position x and y in $07--> +LDC1E:  sta $07                         ;Temp storage of Samus map position x and y in $07--> 
-LDC20: lda MapPosY ;and $06 respectively. +LDC20:  lda MapPosY                     ;and $06 respectively. 
-LDC22: sta $06 +LDC22:  sta $06                         
-LDC24: lda ScrollDir ;Load scroll direction and shift LSB into carry bit. +LDC24:  lda ScrollDir                   ;Load scroll direction and shift LSB into carry bit. 
-LDC26: lsr +LDC26:  lsr                             
-LDC27: php ;Temp storage of processor status. +LDC27:  php                             ;Temp storage of processor status. 
-LDC28: beq + ;Branch if scrolling up/down. +LDC28:  beq +                           ;Branch if scrolling up/down. 
-LDC2A: bcc ++ ;Branch if scrolling right.+LDC2A:  bcc ++                          ;Branch if scrolling right.
  
 ;Scrolling left. ;Scrolling left.
-LDC2C: lda ScrollX ;Unless the scroll x offset is 0, the actual room x pos--> +LDC2C:  lda ScrollX                     ;Unless the scroll x offset is 0, the actual room x pos--> 
-LDC2E: beq ++ ;needs to be decremented in order to be correct. +LDC2E:  beq ++                          ;needs to be decremented in order to be correct. 
-LDC30: dec $07 +LDC30:  dec $07                         
-LDC32: bcs ++ ;Branch always.+LDC32:  bcs ++                          ;Branch always.
  
-LDC34:* bcc + ;Branch if scrolling up.+LDC34:* bcc +                           ;Branch if scrolling up.
  
 ;Scrolling down. ;Scrolling down.
-LDC36: lda ScrollY ;Unless the scroll y offset is 0, the actual room y pos--> +LDC36:  lda ScrollY                     ;Unless the scroll y offset is 0, the actual room y pos--> 
-LDC38: beq + ;needs to be decremented in order to be correct. +LDC38:  beq +                           ;needs to be decremented in order to be correct. 
-LDC3A: dec $06 ;+LDC3A:  dec $06                         ;
  
-LDC3C:* lda PPUCNT0ZP ;If item is on the same nametable as current nametable,--> +LDC3C:* lda PPUCNT0ZP                   ;If item is on the same nametable as current nametable,--> 
-LDC3E: eor $08 ;then no further adjustment to item x and y position needed. +LDC3E:  eor $08                         ;then no further adjustment to item x and y position needed. 
-LDC40: and #$01 +LDC40:  and #$01                        
-LDC42: plp ;Restore the processor status and clear the carry bit. +LDC42:  plp                             ;Restore the processor status and clear the carry bit. 
-LDC43: clc +LDC43:  clc                             
-LDC44: beq + ;If Scrolling up/down, branch to adjust item y position.+LDC44:  beq +                           ;If Scrolling up/down, branch to adjust item y position.
  
-LDC46: adc $07 ;Scrolling left/right. Make any necessary adjustments to--> +LDC46:  adc $07                         ;Scrolling left/right. Make any necessary adjustments to--> 
-LDC48: sta $07 ;item x position before writing to unique item history.+LDC48:  sta $07                         ;item x position before writing to unique item history.
  
-LDC4A: jmp AddItemToHistory ;($DC51)Add unique item to unique item history.+LDC4A:  jmp AddItemToHistory            ;($DC51)Add unique item to unique item history.
  
-LDC4D:* adc $06 ;Scrolling up/down. Make any necessary adjustments to--> +LDC4D:* adc $06                         ;Scrolling up/down. Make any necessary adjustments to--> 
-LDC4F: sta $06 ;item y position before writing to unique item history.+LDC4F:  sta $06                         ;item y position before writing to unique item history.
  
 AddItemToHistory: AddItemToHistory:
-LDC51:  jsr CreateItemID ;($DC67)Create an item ID to put into unique item history. +LDC51:  jsr CreateItemID                ;($DC67)Create an item ID to put into unique item history. 
-LDC54:  ldy NumberOfUniqueItems ;Store number of uniqie items in Y. +LDC54:  ldy NumberOfUniqueItems         ;Store number of uniqie items in Y. 
-LDC57: lda $06 +LDC57:  lda $06                         
-LDC59: sta UniqueItemHistory,y ;Store item ID in inuque item history. +LDC59:  sta UniqueItemHistory,        ;Store item ID in inuque item history. 
-LDC5C: lda $07 +LDC5C:  lda $07                         
-LDC5E: sta UniqueItemHistory+1,y ; +LDC5E:  sta UniqueItemHistory+1,      
-LDC61: iny ;Add 2 to Y. 2 bytes ber unique item. +LDC61:  iny                             ;Add 2 to Y. 2 bytes ber unique item. 
-LDC62: iny +LDC62:  iny                             
-LDC63: sty NumberOfUniqueItems ;Store new number of unique items. +LDC63:  sty NumberOfUniqueItems         ;Store new number of unique items. 
-LDC66: rts ;+LDC66:  rts                             ;
  
 ;------------------------------------------[ Create item ID ]----------------------------------------- ;------------------------------------------[ Create item ID ]-----------------------------------------
Line 4418: Line 4418:
  
 CreateItemID: CreateItemID:
-LDC67: lda $07 ;Load x map position of item. +LDC67:  lda $07                         ;Load x map position of item. 
-LDC69: jsr Amul32 ;($C2C$)*32. Move lower 3 bytes to upper 3 bytes. +LDC69:  jsr Amul32                      ;($C2C$)*32. Move lower 3 bytes to upper 3 bytes. 
-LDC6C: ora $06 ;combine Y coordinates into data byte. +LDC6C:  ora $06                         ;combine Y coordinates into data byte. 
-LDC6E: sta $06 ;Lower data byte complete. Save in $06. +LDC6E:  sta $06                         ;Lower data byte complete. Save in $06. 
-LDC70: lsr $07 +LDC70:  lsr $07                         
-LDC72: lsr $07 ;Move upper two bits of X coordinate to LSBs. +LDC72:  lsr $07                         ;Move upper two bits of X coordinate to LSBs. 
-LDC74: lsr $07 +LDC74:  lsr $07                         
-LDC76: lda $09 ;Load item type bits. +LDC76:  lda $09                         ;Load item type bits. 
-LDC78: asl ;Move the 6 bits of item type to upper 6 bits of byte. +LDC78:  asl                             ;Move the 6 bits of item type to upper 6 bits of byte. 
-LDC79: asl +LDC79:  asl                             
-LDC7A: ora $07 ;Add upper two bits of X coordinate to byte. +LDC7A:  ora $07                         ;Add upper two bits of X coordinate to byte. 
-LDC7C: sta $07 ;Upper data byte complete. Save in #$06. +LDC7C:  sta $07                         ;Upper data byte complete. Save in #$06. 
-LDC7E: rts ;+LDC7E:  rts                             ;
  
 ;----------------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------------
Line 4437: Line 4437:
 LDC7F:  jsr LF186 LDC7F:  jsr LF186
 LDC82:  jsr LF172 LDC82:  jsr LF172
-LDC85: jsr LF1A7 +LDC85:  jsr LF1A7 
-LDC88: jmp LF1FA+LDC88:  jmp LF1FA
  
 ;The following table is used to rotate the sprites of both Samus and enemies when they explode. ;The following table is used to rotate the sprites of both Samus and enemies when they explode.
  
 ExplodeRotationTbl: ExplodeRotationTbl:
-LDC8B: .byte $00 ;No sprite flipping. +LDC8B:  .byte $00                       ;No sprite flipping. 
-LDC8C: .byte $80 ;Flip sprite vertically. +LDC8C:  .byte $80                       ;Flip sprite vertically. 
-LDC8D: .byte $C0 ;Flip sprite vertically and horizontally. +LDC8D:  .byte $C0                       ;Flip sprite vertically and horizontally. 
-LDC8E: .byte $40 ;Flip sprite horizontally.+LDC8E:  .byte $40                       ;Flip sprite horizontally.
  
 ; UpdateObjAnim ; UpdateObjAnim
Line 4453: Line 4453:
  
 UpdateObjAnim: UpdateObjAnim:
-LDC8F: ldx PageIndex +LDC8F:  ldx PageIndex 
- ldy AnimDelay,+        ldy AnimDelay,
- beq +    ; is it time to advance to the next anim frame? +        beq +      ; is it time to advance to the next anim frame? 
- dec AnimDelay,    ; nope +        dec AnimDelay,    ; nope 
- bne +++   ; exit if still not zero (don't update animation)+        bne +++   ; exit if still not zero (don't update animation)
 *       sta AnimDelay,    ; set initial anim countdown value *       sta AnimDelay,    ; set initial anim countdown value
- ldy AnimIndex,+        ldy AnimIndex,
-*       lda ObjectAnimIndexTbl,y ;($8572)Load frame number. +*       lda ObjectAnimIndexTbl,               ;($8572)Load frame number. 
- cmp #$FF ; has end of anim been reached? +        cmp #$FF        ; has end of anim been reached? 
- beq ++ +        beq ++ 
- sta AnimFrame,    ; store frame number +        sta AnimFrame,    ; store frame number 
- iny      ; inc anim index +        iny          ; inc anim index 
- tya +        tya 
- sta AnimIndex,    ; store anim index +        sta AnimIndex,    ; store anim index 
-* rts+      rts
  
 *       ldy AnimResetIndex,    ; reset anim frame index *       ldy AnimResetIndex,    ; reset anim frame index
- jmp ---    ; do first frame of animation+        jmp ---    ; do first frame of animation
  
 LDCB7:  pha LDCB7:  pha
- lda #$00 +        lda #$00 
- sta $06 +        sta $06 
- pla +        pla 
- bpl + +        bpl + 
- dec $06+        dec $06
 *       clc *       clc
- rts+        rts
  
 ;--------------------------------[ Get sprite control byte ]----------------------------------------- ;--------------------------------[ Get sprite control byte ]-----------------------------------------
Line 4489: Line 4489:
  
 GetSpriteCntrlData: GetSpriteCntrlData:
-LDCC3:  ldy #$00 +LDCC3:  ldy #$00                        
-LDCC5: sty $0F ;Clear index into placement data. +LDCC5:  sty $0F                         ;Clear index into placement data. 
-LDCC7: lda ($00),y ;Load control byte from frame pointer data. +LDCC7:  lda ($00),                    ;Load control byte from frame pointer data. 
-LDCC9: sta $04 ;Store value in $04 for processing below. +LDCC9:  sta $04                         ;Store value in $04 for processing below. 
-LDCCB: tax ;Keep a copy of the value in x as well. +LDCCB:  tax                             ;Keep a copy of the value in x as well. 
-LDCCC: jsr Adiv16 ;($C2BF)Move upper 4 bits to lower 4 bits. +LDCCC:  jsr Adiv16                      ;($C2BF)Move upper 4 bits to lower 4 bits. 
-LDCCF: and #$03 +LDCCF:  and #$03                        
-LDCD1: sta $05 ;The following lines take the upper 4 bits in the--> +LDCD1:  sta $05                         ;The following lines take the upper 4 bits in the--> 
-LDCD3: txa ;control byte and transfer bits 4 and 5 into $05 bits 0--> +LDCD3:  txa                             ;control byte and transfer bits 4 and 5 into $05 bits 0--> 
-LDCD4: and #$C0 ;and 1(sprite color bits).  Bits 6 and 7 are--> +LDCD4:  and #$C0                        ;and 1(sprite color bits).  Bits 6 and 7 are--> 
-LDCD6: ora #$20 ;transferred into $05 bits 6 and 7(sprite flip bits).--> +LDCD6:  ora #$20                        ;transferred into $05 bits 6 and 7(sprite flip bits).--> 
-LDCD8: ora $05 ;bit 5 is then set(sprite always drawn behind background). +LDCD8:  ora $05                         ;bit 5 is then set(sprite always drawn behind background). 
-LDCDA: sta $05 +LDCDA:  sta $05                         
-LDCDC: lda ObjectCntrl ;Extract bit from control byte that controls the +LDCDC:  lda ObjectCntrl                 ;Extract bit from control byte that controls the 
-LDCDE: and #$10 ;object mirroring. +LDCDE:  and #$10                        ;object mirroring. 
-LDCE0: asl +LDCE0:  asl                             
-LDCE1: asl +LDCE1:  asl                             
-LDCE2: eor $04 ;Move it to the bit 6 position and use it to flip the--> +LDCE2:  eor $04                         ;Move it to the bit 6 position and use it to flip the--> 
-LDCE4: sta $04 ;horizontal mirroring of the sprite if set. +LDCE4:  sta $04                         ;horizontal mirroring of the sprite if set. 
-LDCE6: lda ObjectCntrl +LDCE6:  lda ObjectCntrl                 
-LDCE8: bpl + ;If MSB is set in ObjectCntrl, use its flip bits(6 and 7). +LDCE8:  bpl +                           ;If MSB is set in ObjectCntrl, use its flip bits(6 and 7). 
-LDCEA: asl ObjectCntrl +LDCEA:  asl ObjectCntrl                 
-LDCEC: jsr SpriteFlipBitsOveride ;($E038)Use object flip bits as priority over sprite flip bits.  +LDCEC:  jsr SpriteFlipBitsOveride       ;($E038)Use object flip bits as priority over sprite flip bits.  
-LDCEF:* txa ;Discard upper nibble so only entry number into--> +LDCEF:* txa                             ;Discard upper nibble so only entry number into--> 
-LDCF0: and #$0F ;PlacePtrTbl remains. +LDCF0:  and #$0F                        ;PlacePtrTbl remains. 
-LDCF2: asl ;*2. pointers in PlacePntrTbl are 2 bytes in size. +LDCF2:  asl                             ;*2. pointers in PlacePntrTbl are 2 bytes in size. 
-LDCF3: tax ;Transfer to X to use as an index to find proper--> +LDCF3:  tax                             ;Transfer to X to use as an index to find proper--> 
-LDCF4: rts ;placement data segment.+LDCF4:  rts                             ;placement data segment.
  
 ;----------------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------------
  
-LDCF5:  jsr ClearObjectCntrl ;($DF2D)Clear object control byte. +LDCF5:  jsr ClearObjectCntrl            ;($DF2D)Clear object control byte. 
- pla +        pla 
- pla +        pla 
- ldx PageIndex+        ldx PageIndex
 LDCFC:  lda InArea LDCFC:  lda InArea
- cmp #$13 +        cmp #$13 
- bne + +        bne + 
- lda EnDataIndex,+        lda EnDataIndex,
- cmp #$04 +        cmp #$04 
- beq +++++ +        beq +++++ 
- cmp #$02 +        cmp #$02 
- beq ++++++        beq +++++
 *       lda $040C,x *       lda $040C,x
- asl +        asl 
- bmi LDD75 +        bmi LDD75 
- jsr LF74B +        jsr LF74B 
- sta $00 +        sta $00 
- jsr $80B0 +        jsr $80B0 
- and #$20 +        and #$20 
- sta EnDataIndex,+        sta EnDataIndex,
- lda #$05 +        lda #$05 
- sta EnStatus,+        sta EnStatus,
- lda #$60 +        lda #$60 
- sta $040D,x +        sta $040D,x 
- lda RandomNumber1 +        lda RandomNumber1 
- cmp #$10 +        cmp #$10 
- bcc LDD5B +        bcc LDD5B 
-* and #$07 +      and #$07 
- tay +        tay 
- lda ItemDropTbl,+        lda ItemDropTbl,
- sta EnAnimFrame,+        sta EnAnimFrame,
- cmp #$80 +        cmp #$80 
- bne ++ +        bne ++ 
- ldy MaxMissilePickup +        ldy MaxMissilePickup 
- cpy CurrentMissilePickups +        cpy CurrentMissilePickups 
- beq LDD5B +        beq LDD5B 
- lda MaxMissiles +        lda MaxMissiles 
- beq LDD5B +        beq LDD5B 
- inc CurrentMissilePickups+        inc CurrentMissilePickups
 *       rts *       rts
  
 *       ldy MaxEnergyPickup *       ldy MaxEnergyPickup
- cpy CurrentEnergyPickups +        cpy CurrentEnergyPickups 
- beq LDD5B +        beq LDD5B 
- inc CurrentEnergyPickups +        inc CurrentEnergyPickups 
- cmp #$89 +        cmp #$89 
- bne -- +        bne -- 
- lsr $00 +        lsr $00 
- bcs --+        bcs --
  
 LDD5B:  ldx PageIndex LDD5B:  ldx PageIndex
- lda InArea +        lda InArea 
- cmp #$13 +        cmp #$13 
- beq ++ +        beq ++ 
-* jmp KillObject ;($FA18)Free enemy data slot.+      jmp KillObject                  ;($FA18)Free enemy data slot.
  
 *       lda RandomNumber1 *       lda RandomNumber1
- ldy #$00 +        ldy #$00 
- sty CurrentEnergyPickups +        sty CurrentEnergyPickups 
- sty CurrentMissilePickups +        sty CurrentMissilePickups 
- iny +        iny 
- sty MaxMissilePickup +        sty MaxMissilePickup 
- sty MaxEnergyPickup +        sty MaxEnergyPickup 
- bne -----+        bne -----
  
 LDD75:  jsr PowerUpMusic LDD75:  jsr PowerUpMusic
- lda InArea +        lda InArea 
- and #$0F +        and #$0F 
- sta MiniBossKillDelay +        sta MiniBossKillDelay 
- lsr +        lsr 
- tay +        tay 
- sta MaxMissiles,+        sta MaxMissiles,
- lda #75 +        lda #75 
- jsr AddToMaxMissiles +        jsr AddToMaxMissiles 
- bne LDD5B+        bne LDD5B
  
 LDD8B:  ldx PageIndex LDD8B:  ldx PageIndex
- lda EnAnimFrame,+        lda EnAnimFrame,
- cmp #$F7 +        cmp #$F7 
- bne +++ +        bne +++ 
- jmp ClearObjectCntrl ;($DF2D)Clear object control byte.+        jmp ClearObjectCntrl            ;($DF2D)Clear object control byte.
  
 ; AddToMaxMissiles ; AddToMaxMissiles
Line 4608: Line 4608:
  
 AddToMaxMissiles: AddToMaxMissiles:
- pha ;Temp storage of # of missiles to add. +        pha                             ;Temp storage of # of missiles to add. 
- clc +        clc 
- adc MissileCount +        adc MissileCount 
- bcc + +        bcc + 
- lda #$FF+        lda #$FF
 *       sta MissileCount *       sta MissileCount
- pla +        pla 
- clc +        clc 
- adc MaxMissiles +        adc MaxMissiles 
- bcc + +        bcc + 
- lda #$FF+        lda #$FF
 *       sta MaxMissiles *       sta MaxMissiles
- rts+        rts
  
-* lda EnYRoomPos,+      lda EnYRoomPos,
- sta $0A ; Y coord +        sta $0A  ; Y coord 
- lda EnXRoomPos,+        lda EnXRoomPos,
- sta $0B ; X coord +        sta $0B  ; X coord 
- lda EnNameTable,+        lda EnNameTable,
- sta $06 ; hi coord +        sta $06  ; hi coord 
- lda EnAnimFrame,+        lda EnAnimFrame,
- asl +        asl 
- tay +        tay 
- lda ($41),y +        lda ($41),y 
- bcc + +        bcc + 
- lda ($43),y+        lda ($43),y
 *       sta $00 *       sta $00
- iny +        iny 
- lda ($41),y +        lda ($41),y 
- bcc + +        bcc + 
- lda ($43),y+        lda ($43),y
 *       sta $01 *       sta $01
- jsr GetSpriteCntrlData ;($DCC3)Get place pointer index and sprite control data. +        jsr GetSpriteCntrlData          ;($DCC3)Get place pointer index and sprite control data. 
- tay +        tay 
- lda ($45),y +        lda ($45),y 
- sta $02 +        sta $02 
- iny +        iny 
- lda ($45),y +        lda ($45),y 
- sta $03 +        sta $03 
- ldy #$00 +        ldy #$00 
- cpx #$02 +        cpx #$02 
- bne + +        bne + 
- ldx PageIndex +        ldx PageIndex 
- inc EnCounter,+        inc EnCounter,
- lda EnCounter,+        lda EnCounter,
- pha +        pha 
- and #$03 +        and #$03 
- tax +        tax 
- lda $05 +        lda $05 
- and #$3F +        and #$3F 
- ora ExplodeRotationTbl,+        ora ExplodeRotationTbl,
- sta $05 +        sta $05 
- pla +        pla 
- cmp #$19 +        cmp #$19 
- bne + +        bne + 
- jmp LDCF5+        jmp LDCF5
  
 *       ldx PageIndex *       ldx PageIndex
- iny +        iny 
- lda ($00),y +        lda ($00),y 
- sta EnRadY,x +        sta EnRadY,x 
- jsr ReduceYRadius ;($DE3D)Reduce temp y radius by #$10. +        jsr ReduceYRadius               ;($DE3D)Reduce temp y radius by #$10. 
- iny +        iny 
- lda ($00),y +        lda ($00),y 
- sta EnRadX,x +        sta EnRadX,x 
- sta $09 +        sta $09 
- iny +        iny 
- sty $11 +        sty $11 
- jsr IsObjectVisible ;($DFDF)Determine if object is within screen boundaries. +        jsr IsObjectVisible             ;($DFDF)Determine if object is within screen boundaries. 
- txa +        txa 
- asl +        asl 
- sta $08 +        sta $08 
- ldx PageIndex +        ldx PageIndex 
- lda $0405,x +        lda $0405,x 
- and #$FD +        and #$FD 
- ora $08 +        ora $08 
- sta $0405,x +        sta $0405,x 
- lda $08 +        lda $08 
- beq ++ +        beq ++ 
- jmp LDEDE+        jmp LDEDE
  
 ;----------------------------------------[ Item drop table ]----------------------------------------- ;----------------------------------------[ Item drop table ]-----------------------------------------
Line 4694: Line 4694:
  
 ItemDropTbl: ItemDropTbl:
-LDE35: .byte $80 ;Missile. +LDE35:  .byte $80                       ;Missile. 
-LDE36: .byte $81 ;Energy. +LDE36:  .byte $81                       ;Energy. 
-LDE37: .byte $89 ;No item. +LDE37:  .byte $89                       ;No item. 
-LDE38: .byte $80 ;Missile. +LDE38:  .byte $80                       ;Missile. 
-LDE39: .byte $81 ;Energy. +LDE39:  .byte $81                       ;Energy. 
-LDE3A: .byte $89 ;No item. +LDE3A:  .byte $89                       ;No item. 
-LDE3B: .byte $81 ;Energy. +LDE3B:  .byte $81                       ;Energy. 
-LDE3C: .byte $89 ;No item.+LDE3C:  .byte $89                       ;No item.
  
 ;------------------------------------[ Object drawing routines ]------------------------------------- ;------------------------------------[ Object drawing routines ]-------------------------------------
Line 4709: Line 4709:
  
 ReduceYRadius: ReduceYRadius:
-LDE3D: sec +LDE3D:  sec                             
-LDE3E: sbc #$10 ;Subtract #$10 from object y radius. +LDE3E:  sbc #$10                        ;Subtract #$10 from object y radius. 
-LDE40: bcs + ;If number is still a positive number, branch to store value. +LDE40:  bcs +                           ;If number is still a positive number, branch to store value. 
-LDE42: lda #$00 ;Number is negative.  Set Y radius to #$00. +LDE42:  lda #$00                        ;Number is negative.  Set Y radius to #$00. 
-LDE44:* sta $08 ;Store result and return. +LDE44:* sta $08                         ;Store result and return. 
-LDE46: rts ;+LDE46:  rts                             ;
  
 AnimDrawObject: AnimDrawObject:
-LDE47: jsr UpdateObjAnim ;($DC8F)Update animation if needed.+LDE47:  jsr UpdateObjAnim               ;($DC8F)Update animation if needed.
  
 DrawFrame: DrawFrame:
-LDE4A: ldx PageIndex ;Get index to proper object to work with. +LDE4A:  ldx PageIndex                   ;Get index to proper object to work with. 
-LDE4C: lda AnimFrame,x +LDE4C:  lda AnimFrame,                
-LDE4F: cmp #$F7 ;Is the frame valid?--> +LDE4F:  cmp #$F7                        ;Is the frame valid?--> 
-LDE51: bne ++ ;Branch if yes. +LDE51:  bne ++                          ;Branch if yes. 
-LDE53:* jmp ClearObjectCntrl ;($DF2D)Clear object control byte. +LDE53:* jmp ClearObjectCntrl            ;($DF2D)Clear object control byte. 
-LDE56:* cmp #$07 ;Is the animation of Samus facing forward?--> +LDE56:* cmp #$07                        ;Is the animation of Samus facing forward?--> 
-LDE58: bne + ;If not, branch.+LDE58:  bne +                           ;If not, branch.
  
-LDE5A: lda ObjectCntrl ;Ensure object mirroring bit is clear so Samus'--> +LDE5A:  lda ObjectCntrl                 ;Ensure object mirroring bit is clear so Samus'--> 
-LDE5C: and #$EF ;sprite appears properly when going up and down--> +LDE5C:  and #$EF                        ;sprite appears properly when going up and down--> 
-LDE5E: sta ObjectCntrl ;elevators.+LDE5E:  sta ObjectCntrl                 ;elevators.
  
-LDE60:* lda ObjectY,x +LDE60:* lda ObjectY,                  
-LDE63: sta $0A +LDE63:  sta $0A                         
-LDE65: lda ObjectX,x ;Copy object y and x room position and name table--> +LDE65:  lda ObjectX,                  ;Copy object y and x room position and name table--> 
-LDE68: sta $0B ;data into $0A, $0B and $06 respectively. +LDE68:  sta $0B                         ;data into $0A, $0B and $06 respectively. 
-LDE6A: lda ObjectHi,x +LDE6A:  lda ObjectHi,                 
-LDE6D: sta $06 +LDE6D:  sta $06                         
-LDE6F: lda AnimFrame,x ;Load A with index into FramePtrTable. +LDE6F:  lda AnimFrame,                ;Load A with index into FramePtrTable. 
-LDE72: asl ;*2. Frame pointers are two bytes. +LDE72:  asl                             ;*2. Frame pointers are two bytes. 
-LDE73: tax ;X is now the index into the FramePtrTable. +LDE73:  tax                             ;X is now the index into the FramePtrTable. 
-LDE74: lda FramePtrTable,x +LDE74:  lda FramePtrTable,            
-LDE77: sta $00 +LDE77:  sta $00                         
-LDE79: lda FramePtrTable+1,x ;Entry from FramePtrTable is stored in $0000. +LDE79:  lda FramePtrTable+1,          ;Entry from FramePtrTable is stored in $0000. 
-LDE7C: sta $01 +LDE7C:  sta $01                         
-LDE7E: jsr GetSpriteCntrlData ;($DCC3)Get place pointer index and sprite control data. +LDE7E:  jsr GetSpriteCntrlData          ;($DCC3)Get place pointer index and sprite control data. 
-LDE81: lda PlacePtrTable,x +LDE81:  lda PlacePtrTable,            
-LDE84: sta $02 +LDE84:  sta $02                         
-LDE86: lda PlacePtrTable+1,x ;Store pointer from PlacePtrTbl in $0002. +LDE86:  lda PlacePtrTable+1,          ;Store pointer from PlacePtrTbl in $0002. 
-LDE89: sta $03 +LDE89:  sta $03                         
-LDE8B: lda IsSamus ;Is Samus the object being drawn?--> +LDE8B:  lda IsSamus                     ;Is Samus the object being drawn?--> 
-LDE8D: beq + ;If not, branch.+LDE8D:  beq +                           ;If not, branch.
  
 ;Special case for Samus exploding. ;Special case for Samus exploding.
-LDE8F: cpx #$0E ;Is Samus exploding?--> +LDE8F:  cpx #$0E                        ;Is Samus exploding?--> 
-LDE91: bne + ;If not, branch to skip this section of code. +LDE91:  bne +                           ;If not, branch to skip this section of code. 
-LDE93: ldx PageIndex ;X=0. +LDE93:  ldx PageIndex                   ;X=0. 
-LDE95: inc ObjectCounter ;Incremented every frame during explode sequence.--> +LDE95:  inc ObjectCounter               ;Incremented every frame during explode sequence.--> 
-LDE97: lda ObjectCounter ;Bottom two bits used for index into ExplodeRotationTbl. +LDE97:  lda ObjectCounter               ;Bottom two bits used for index into ExplodeRotationTbl. 
-LDE99: pha ;Save value of A. +LDE99:  pha                             ;Save value of A. 
-LDE9A: and #$03 ;Use 2 LSBs for index into ExplodeRotationTbl. +LDE9A:  and #$03                        ;Use 2 LSBs for index into ExplodeRotationTbl. 
-LDE9C: tax +LDE9C:  tax                             
-LDE9D: lda $05 ;Drop mirror control bits from sprite control byte. +LDE9D:  lda $05                         ;Drop mirror control bits from sprite control byte. 
-LDE9F: and #$3F +LDE9F:  and #$3F                        
-LDEA1: ora ExplodeRotationTbl,x ;Use mirror control bytes from table(Base is $DC8B). +LDEA1:  ora ExplodeRotationTbl,       ;Use mirror control bytes from table(Base is $DC8B). 
-LDEA4: sta $05 ;Save modified sprite control byte. +LDEA4:  sta $05                         ;Save modified sprite control byte. 
-LDEA6: pla ;Restore A +LDEA6:  pla                             ;Restore A 
-LDEA7: cmp #$19 ;After 25 frames, Move on to second part of death-->  +LDEA7:  cmp #$19                        ;After 25 frames, Move on to second part of death-->  
-LDEA9: bne + ;handler, else branch to skip the rest of this code. +LDEA9:  bne +                           ;handler, else branch to skip the rest of this code. 
-LDEAB: ldx PageIndex ;X=0. +LDEAB:  ldx PageIndex                   ;X=0. 
-LDEAD: lda #sa_Dead2 +LDEAD:  lda #sa_Dead2                   
-LDEAF: sta ObjAction,x ;Move to next part of the death handler. +LDEAF:  sta ObjAction,                ;Move to next part of the death handler. 
-LDEB2: lda #$28 +LDEB2:  lda #$28                        
-LDEB4: sta AnimDelay,x ;Set animation delay for 40 frames(.667 seconds). +LDEB4:  sta AnimDelay,                ;Set animation delay for 40 frames(.667 seconds). 
-LDEB7: pla ;Pull last return address off of the stack. +LDEB7:  pla                             ;Pull last return address off of the stack. 
-LDEB8: pla +LDEB8:  pla                             
-LDEB9: jmp ClearObjectCntrl ;($DF2D)Clear object control byte.+LDEB9:  jmp ClearObjectCntrl            ;($DF2D)Clear object control byte.
  
-LDEBC:* ldx PageIndex +LDEBC:* ldx PageIndex                   
-LDEBE: iny ;Increment to second frame data byte. +LDEBE:  iny                             ;Increment to second frame data byte. 
-LDEBF: lda ($00),y +LDEBF:  lda ($00),                    
-LDEC1: sta ObjRadY,x ;Get verticle radius in pixles of object. +LDEC1:  sta ObjRadY,                  ;Get verticle radius in pixles of object. 
-LDEC3: jsr ReduceYRadius ;($DE3D)Reduce temp y radius by #$10. +LDEC3:  jsr ReduceYRadius               ;($DE3D)Reduce temp y radius by #$10. 
-LDEC6: iny ;Increment to third frame data byte. +LDEC6:  iny                             ;Increment to third frame data byte. 
-LDEC7: lda ($00),y ;Get horizontal radius in pixels of object. +LDEC7:  lda ($00),                    ;Get horizontal radius in pixels of object. 
-LDEC9: sta ObjRadX,x +LDEC9:  sta ObjRadX,                  
-LDECB: sta $09 ;Temp storage for object x radius. +LDECB:  sta $09                         ;Temp storage for object x radius. 
-LDECD: iny ;Set index to 4th byte of frame data. +LDECD:  iny                             ;Set index to 4th byte of frame data. 
-LDECE: sty $11 ;Store current index into frame data. +LDECE:  sty $11                         ;Store current index into frame data. 
-LDED0: jsr IsObjectVisible ;($DFDF)Determine if object is within the screen boundaries. +LDED0:  jsr IsObjectVisible             ;($DFDF)Determine if object is within the screen boundaries. 
-LDED3: txa +LDED3:  txa                             
-LDED4: ldx PageIndex ;Get index to object. +LDED4:  ldx PageIndex                   ;Get index to object. 
-LDED6: sta ObjectOnScreen,x ;Store visibility status of object. +LDED6:  sta ObjectOnScreen,           ;Store visibility status of object. 
-LDEDB: tax +LDEDB:  tax                             
-LDEDC: beq + ;Branch if object is not within the screen boundaries. +LDEDC:  beq +                           ;Branch if object is not within the screen boundaries. 
-LDEDE:  ldx SpritePagePos ;Load index into next unused sprite RAM segment. +LDEDE:  ldx SpritePagePos               ;Load index into next unused sprite RAM segment. 
-LDEE0: jmp DrawSpriteObject ;($DF19)Start drawing object.+LDEE0:  jmp DrawSpriteObject            ;($DF19)Start drawing object.
  
-LDEE3:* jmp ClearObjectCntrl ;($DF2D)Clear object control byte then exit.+LDEE3:* jmp ClearObjectCntrl            ;($DF2D)Clear object control byte then exit.
  
 WriteSpriteRAM: WriteSpriteRAM:
-LDEE6:* ldy $0F ;Load index for placement data. +LDEE6:* ldy $0F                         ;Load index for placement data. 
-LDEE8: jsr YDisplacement ;($DF6B)Get displacement for y direction. +LDEE8:  jsr YDisplacement               ;($DF6B)Get displacement for y direction. 
-LDEEB: adc $10 ;Add initial Y position. +LDEEB:  adc $10                         ;Add initial Y position. 
-LDEED: sta Sprite00RAM,x ;Store sprite Y coord. +LDEED:  sta Sprite00RAM,              ;Store sprite Y coord. 
-LDEF0: dec Sprite00RAM,x ;Because PPU uses Y + 1 as real Y coord. +LDEF0:  dec Sprite00RAM,              ;Because PPU uses Y + 1 as real Y coord. 
-LDEF3: inc $0F ;Increment index to next byte of placement data. +LDEF3:  inc $0F                         ;Increment index to next byte of placement data. 
-LDEF5: ldy $11 ;Get index to frame data. +LDEF5:  ldy $11                         ;Get index to frame data. 
-LDEF7: lda ($00),y ;Tile value. +LDEF7:  lda ($00),                    ;Tile value. 
-LDEF9: sta Sprite00RAM+1,x ;Store tile value in sprite RAM. +LDEF9:  sta Sprite00RAM+1,            ;Store tile value in sprite RAM. 
-LDEFC: lda ObjectCntrl +LDEFC:  lda ObjectCntrl                 
-LDEFE: asl ;Move horizontal mirror control byte to bit 6 and--> +LDEFE:  asl                             ;Move horizontal mirror control byte to bit 6 and--> 
-LDEFF: asl ;discard all other bits. +LDEFF:  asl                             ;discard all other bits. 
-LDF00: and #$40 +LDF00:  and #$40                        
-LDF02: eor $05 ;Use it to override sprite horz mirror bit. +LDF02:  eor $05                         ;Use it to override sprite horz mirror bit. 
-LDF04: sta Sprite00RAM+2,x ;Store sprite control byte in sprite RAM. +LDF04:  sta Sprite00RAM+2,            ;Store sprite control byte in sprite RAM. 
-LDF07: inc $11 ;Increment to next byte of frame data. +LDF07:  inc $11                         ;Increment to next byte of frame data. 
-LDF09: ldy $0F ;Load index for placement data. +LDF09:  ldy $0F                         ;Load index for placement data. 
-LDF0B: jsr XDisplacement ;($DFA3)Get displacement for x direction. +LDF0B:  jsr XDisplacement               ;($DFA3)Get displacement for x direction. 
-LDF0E: adc $0E ;Add initial X pos +LDF0E:  adc $0E                         ;Add initial X pos 
-LDF10: sta Sprite00RAM+3,x ;Store sprite X coord +LDF10:  sta Sprite00RAM+3,            ;Store sprite X coord 
-LDF13: inc $0F ;Increment to next placement data byte. +LDF13:  inc $0F                         ;Increment to next placement data byte. 
-LDF15: inx +LDF15:  inx                             
-LDF16: inx +LDF16:  inx                             
-LDF17: inx ;Advance to next sprite. +LDF17:  inx                             ;Advance to next sprite. 
-LDF18: inx ;+LDF18:  inx                             ;
  
 DrawSpriteObject: DrawSpriteObject:
-LDF19:  ldy $11 ;Get index into frame data.+LDF19:  ldy $11                         ;Get index into frame data.
  
 GetNextFrameByte: GetNextFrameByte:
-LDF1B:  lda ($00),y ;Get next frame data byte. +LDF1B:  lda ($00),                    ;Get next frame data byte. 
-LDF1D: cmp #$FC ;If byte < #$FC, byte is tile data. If >= #$FC, byte is-->  +LDF1D:  cmp #$FC                        ;If byte < #$FC, byte is tile data. If >= #$FC, byte is-->  
-LDF1F: bcc WriteSpriteRAM ;frame data control info. Branch to draw sprite. +LDF1F:  bcc WriteSpriteRAM              ;frame data control info. Branch to draw sprite. 
-LDF21: beq OffsetObjectPosition ;#$FC changes object's x and y position. +LDF21:  beq OffsetObjectPosition        ;#$FC changes object's x and y position. 
-LDF23: cmp #$FD +LDF23:  cmp #$FD                        
-LDF25: beq GetNewControlByte ;#$FD sets new control byte information for the next sprites. +LDF25:  beq GetNewControlByte           ;#$FD sets new control byte information for the next sprites. 
-LDF27: cmp #$FE ;#$FE skips next sprite placement x and y bytes. +LDF27:  cmp #$FE                        ;#$FE skips next sprite placement x and y bytes. 
-LDF29: beq SkipPlacementData +LDF29:  beq SkipPlacementData           
-LDF2B: stx SpritePagePos ;Keep track of current position in sprite RAM.+LDF2B:  stx SpritePagePos               ;Keep track of current position in sprite RAM.
  
 ClearObjectCntrl: ClearObjectCntrl:
-LDF2D:  lda #$00 +LDF2D:  lda #$00                        
-LDF2F: sta ObjectCntrl ;Clear object control byte. +LDF2F:  sta ObjectCntrl                 ;Clear object control byte. 
-LDF31: rts ;+LDF31:  rts                             ;
  
 SkipPlacementData: SkipPlacementData:
-LDF32:* inc $0F ;Skip next y and x placement data bytes. +LDF32:* inc $0F                         ;Skip next y and x placement data bytes. 
-LDF34: inc $0F +LDF34:  inc $0F                         
-LDF36: inc $11 ;Increment to next data item in frame data. +LDF36:  inc $11                         ;Increment to next data item in frame data. 
-LDF38: jmp DrawSpriteObject ;($DF19)Draw next sprite.+LDF38:  jmp DrawSpriteObject            ;($DF19)Draw next sprite.
  
 GetNewControlByte: GetNewControlByte:
-LDF3B:* iny ;Increment index to next byte of frame data. +LDF3B:* iny                             ;Increment index to next byte of frame data. 
-LDF3C: asl ObjectCntrl ;If MSB of ObjectCntrl is not set, no overriding of--> +LDF3C:  asl ObjectCntrl                 ;If MSB of ObjectCntrl is not set, no overriding of--> 
-LDF3E: bcc + ;flip bits needs to be performed. +LDF3E:  bcc +                           ;flip bits needs to be performed. 
-LDF40: jsr SpriteFlipBitsOveride ;($E038)Use object flip bits as priority over sprite flip bits. +LDF40:  jsr SpriteFlipBitsOveride       ;($E038)Use object flip bits as priority over sprite flip bits. 
-LDF43: bne ++ ;Branch always. +LDF43:  bne ++                          ;Branch always. 
-LDF45:* lsr ObjectCntrl ;Restore MSB of ObjectCntrl. +LDF45:* lsr ObjectCntrl                 ;Restore MSB of ObjectCntrl. 
-LDF47: lda ($00),y +LDF47:  lda ($00),                    
-LDF49: sta $05 ;Save new sprite control byte. +LDF49:  sta $05                         ;Save new sprite control byte. 
-LDF4B:* iny ;Increment past sprite control byte. +LDF4B:* iny                             ;Increment past sprite control byte. 
-LDF4C: sty $11 ;Save index of frame data. +LDF4C:  sty $11                         ;Save index of frame data. 
-LDF4E: jmp GetNextFrameByte ;($DF1B)Load next frame data byte.+LDF4E:  jmp GetNextFrameByte            ;($DF1B)Load next frame data byte.
  
 OffsetObjectPosition: OffsetObjectPosition:
-LDF51:* iny ;Increment index to next byte of frame data. +LDF51:* iny                             ;Increment index to next byte of frame data. 
-LDF52: lda ($00),y ;This data byte is used to offset the object from--> +LDF52:  lda ($00),                    ;This data byte is used to offset the object from--> 
-LDF54: clc ;its current y positon. +LDF54:  clc                             ;its current y positon. 
-LDF55: adc $10 +LDF55:  adc $10                         
-LDF57: sta $10 ;Add offset amount to object y screen position. +LDF57:  sta $10                         ;Add offset amount to object y screen position. 
-LDF59: inc $11 +LDF59:  inc $11                         
-LDF5B: inc $11 ;Increment past control byte and y offset byte. +LDF5B:  inc $11                         ;Increment past control byte and y offset byte. 
-LDF5D: ldy $11 +LDF5D:  ldy $11                         
-LDF5F: lda ($00),y ;Load x offset data byte. +LDF5F:  lda ($00),                    ;Load x offset data byte. 
-LDF61: clc +LDF61:  clc                             
-LDF62: adc $0E ;Add offset amount to object x screen position. +LDF62:  adc $0E                         ;Add offset amount to object x screen position. 
-LDF64: sta $0E +LDF64:  sta $0E                         
-LDF66: inc $11 ;Increment past x offset byte. +LDF66:  inc $11                         ;Increment past x offset byte. 
-LDF68: jmp DrawSpriteObject ;($DF19)Draw next sprite.+LDF68:  jmp DrawSpriteObject            ;($DF19)Draw next sprite.
  
 ;----------------------------------[ Sprite placement routines ]------------------------------------- ;----------------------------------[ Sprite placement routines ]-------------------------------------
  
 YDisplacement: YDisplacement:
-LDF6B:  lda ($02),y ;Load placement data byte. +LDF6B:  lda ($02),                    ;Load placement data byte. 
-LDF6D: tay +LDF6D:  tay                             
-LDF6E: and #$F0 ;Check to see if this is placement data for the object--> +LDF6E:  and #$F0                        ;Check to see if this is placement data for the object--> 
-LDF70: cmp #$80 ;exploding.  If so, branch. +LDF70:  cmp #$80                        ;exploding.  If so, branch. 
-LDF72: beq ++ +LDF72:  beq ++                          
-LDF74: tya ;Restore placement data byte to A. +LDF74:  tya                             ;Restore placement data byte to A. 
-LDF75:* bit $04 +LDF75:* bit $04                         
-LDF77: bmi NegativeDisplacement ;Branch if MSB in $04 is set(Flips object). +LDF77:  bmi NegativeDisplacement        ;Branch if MSB in $04 is set(Flips object). 
-LDF79: clc ;Clear carry before returning. +LDF79:  clc                             ;Clear carry before returning. 
-LDF7A: rts ;+LDF7A:  rts                             ;
  
 ExplodeYDisplace: ExplodeYDisplace:
-LDF7B:* tya ;Transfer placement byte back into A. +LDF7B:* tya                             ;Transfer placement byte back into A. 
-LDF7C: and #$0E ;Discard bits 7,6,5,4 and 0. +LDF7C:  and #$0E                        ;Discard bits 7,6,5,4 and 0. 
-LDF7E: lsr ;/2. +LDF7E:  lsr                             ;/2. 
-LDF7F: tay +LDF7F:  tay                             
-LDF80: lda ExplodeIndexTbl,y ;Index into ExplodePlacementTbl. +LDF80:  lda ExplodeIndexTbl,          ;Index into ExplodePlacementTbl. 
-LDF83: ldy IsSamus +LDF83:  ldy IsSamus                     
-LDF85: bne + ;Is Samus the object exploding? if so, branch. +LDF85:  bne +                           ;Is Samus the object exploding? if so, branch. 
-LDF87: ldy PageIndex ;Load index to proper enemy data. +LDF87:  ldy PageIndex                   ;Load index to proper enemy data. 
-LDF89: adc EnCounter,y ;Increment every frame enemy is exploding. Initial=#$01. +LDF89:  adc EnCounter,                ;Increment every frame enemy is exploding. Initial=#$01. 
-LDF8C: jmp ++ ;Jump to load explode placement data.+LDF8C:  jmp ++                          ;Jump to load explode placement data.
  
  
 ;Special case for Samus exploding. ;Special case for Samus exploding.
-LDF8F:* adc ObjectCounter ;Increments every frame Samus is exploding. Initial=#$01. +LDF8F:* adc ObjectCounter               ;Increments every frame Samus is exploding. Initial=#$01. 
-LDF91:* tay +LDF91:* tay                             
-LDF92: lda ExplodeIndexTbl+2,y ;Get data from ExplodePlacementTbl. +LDF92:  lda ExplodeIndexTbl+2,        ;Get data from ExplodePlacementTbl. 
-LDF95: pha ;Save data on stack. +LDF95:  pha                             ;Save data on stack. 
-LDF96: lda $0F ;Load placement data index. +LDF96:  lda $0F                         ;Load placement data index. 
-LDF98: clc +LDF98:  clc                             
-LDF99: adc #$0C ;Move index forward by 12 bytes. to find y--> +LDF99:  adc #$0C                        ;Move index forward by 12 bytes. to find y--> 
-LDF9B: tay ;placement data. +LDF9B:  tay                             ;placement data. 
-LDF9C: pla ;Restore A with ExplodePlacementTbl data. +LDF9C:  pla                             ;Restore A with ExplodePlacementTbl data. 
-LDF9D: clc +LDF9D:  clc                             
-LDF9E: adc ($02),y ;Add table displacements with sprite placement data. +LDF9E:  adc ($02),                    ;Add table displacements with sprite placement data. 
-LDFA0: jmp ---- ;Branch to add y placement values to sprite coords.+LDFA0:  jmp ----                        ;Branch to add y placement values to sprite coords.
  
 XDisplacement: XDisplacement:
-LDFA3:  lda ($02),y ;Load placement data byte. +LDFA3:  lda ($02),                    ;Load placement data byte. 
-LDFA5: tay +LDFA5:  tay                             
-LDFA6: and #$F0 ;Check to see if this is placement data for the object--> +LDFA6:  and #$F0                        ;Check to see if this is placement data for the object--> 
-LDFA8: cmp #$80 ;exploding.  If so, branch. +LDFA8:  cmp #$80                        ;exploding.  If so, branch. 
-LDFAA: beq +++ +LDFAA:  beq +++                         
-LDFAC: tya ;Restore placement data byte to A. +LDFAC:  tya                             ;Restore placement data byte to A. 
-LDFAD:* bit $04 +LDFAD:* bit $04                         
-LDFAF: bvc + ;Branch if bit 6 cleared, else data is negative displacement.+LDFAF:  bvc +                           ;Branch if bit 6 cleared, else data is negative displacement.
  
 NegativeDisplacement: NegativeDisplacement:
-LDFB1:  eor #$FF +LDFB1:  eor #$FF                        
-LDFB3: sec ;NOTE:Setting carry makes solution 1 higher than expected. +LDFB3:  sec                             ;NOTE:Setting carry makes solution 1 higher than expected. 
-LDFB4: adc #$F8 ;If flip bit is set in $04, this function flips the--> +LDFB4:  adc #$F8                        ;If flip bit is set in $04, this function flips the--> 
-LDFB6:* clc ;object by using two compliment minus 8(Each sprite is--> +LDFB6:* clc                             ;object by using two compliment minus 8(Each sprite is--> 
-LDFB7: rts ;8x8 pixels).+LDFB7:  rts                             ;8x8 pixels).
  
 ExplodeXDisplace: ExplodeXDisplace:
-LDFB8:* ldy PageIndex ;Load index to proper enemy slot. +LDFB8:* ldy PageIndex                   ;Load index to proper enemy slot. 
-LDFBA: lda EnCounter,y ;Load counter value. +LDFBA:  lda EnCounter,                ;Load counter value. 
-LDFBD: ldy IsSamus ;Is Samus the one exploding?--> +LDFBD:  ldy IsSamus                     ;Is Samus the one exploding?--> 
-LDFBF: beq + ;If not, branch. +LDFBF:  beq +                           ;If not, branch. 
-LDFC1: lda ObjectCounter ;Load object counter if it is Samus who is exploding. +LDFC1:  lda ObjectCounter               ;Load object counter if it is Samus who is exploding. 
-LDFC3:* asl ;*2. Move sprite in x direction 2 pixels every frame. +LDFC3:* asl                             ;*2. Move sprite in x direction 2 pixels every frame. 
-LDFC4: pha ;Store value on stack. +LDFC4:  pha                             ;Store value on stack. 
-LDFC5: ldy $0F +LDFC5:  ldy $0F                         
-LDFC7: lda ($02),y ;Load placement data byte. +LDFC7:  lda ($02),                    ;Load placement data byte. 
-LDFC9: lsr +LDFC9:  lsr                             
-LDFCA: bcs + ;Check if LSB is set. If not, the byte stored on stack--> +LDFCA:  bcs +                           ;Check if LSB is set. If not, the byte stored on stack--> 
-LDFCC: pla ;Will be twos complimented and used to move sprite in--> +LDFCC:  pla                             ;Will be twos complimented and used to move sprite in--> 
-LDFCD: eor #$FF ;the negative x direction. +LDFCD:  eor #$FF                        ;the negative x direction. 
-LDFCF: adc #$01 +LDFCF:  adc #$01                        
-LDFD1: pha +LDFD1:  pha                             
-LDFD2:* lda $0F ;Load placement data index. +LDFD2:* lda $0F                         ;Load placement data index. 
-LDFD4: clc +LDFD4:  clc                             
-LDFD5: adc #$0C ;Move index forward by 12 bytes. to find x--> +LDFD5:  adc #$0C                        ;Move index forward by 12 bytes. to find x--> 
-LDFD7: tay ;placement data. +LDFD7:  tay                             ;placement data. 
-LDFD8: pla ;Restore A with x displacement data. +LDFD8:  pla                             ;Restore A with x displacement data. 
-LDFD9: clc +LDFD9:  clc                             
-LDFDA: adc ($02),y ;Add x displacement with sprite placement data. +LDFDA:  adc ($02),                    ;Add x displacement with sprite placement data. 
-LDFDC: jmp ----- ;Branch to add x placement values to sprite coords.+LDFDC:  jmp -----                       ;Branch to add x placement values to sprite coords.
  
 ;---------------------------------[ Check if object is on screen ]---------------------------------- ;---------------------------------[ Check if object is on screen ]----------------------------------
Line 4972: Line 4972:
  
 IsObjectVisible: IsObjectVisible:
-LDFDF:  ldx #$01 ;Assume object is visible on screen. +LDFDF:  ldx #$01                        ;Assume object is visible on screen. 
-LDFE1: lda $0A ;Object Y position in room. +LDFE1:  lda $0A                         ;Object Y position in room. 
-LDFE3: tay +LDFE3:  tay                             
-LDFE4: sec ;Subtract y scroll to find sprite's y position on screen. +LDFE4:  sec                             ;Subtract y scroll to find sprite's y position on screen. 
-LDFE5: sbc ScrollY +LDFE5:  sbc ScrollY                     
-LDFE7: sta $10 ;Store result in $10. +LDFE7:  sta $10                         ;Store result in $10. 
-LDFE9: lda $0B ;Object X position in room. +LDFE9:  lda $0B                         ;Object X position in room. 
-LDFEB: sec +LDFEB:  sec                             
-LDFEC: sbc ScrollX ;Subtract x scroll to find sprite's x position on screen. +LDFEC:  sbc ScrollX                     ;Subtract x scroll to find sprite's x position on screen. 
-LDFEE: sta $0E ;Store result in $0E. +LDFEE:  sta $0E                         ;Store result in $0E. 
-LDFF0: lda ScrollDir +LDFF0:  lda ScrollDir                   
-LDFF2: and #$02 ;Is Samus scrolling left or right?--> +LDFF2:  and #$02                        ;Is Samus scrolling left or right?--> 
-LDFF4: bne HorzScrollCheck ;($E01C)If so, branch.+LDFF4:  bne HorzScrollCheck             ;($E01C)If so, branch.
  
 VertScrollCheck: VertScrollCheck:
-LDFF6: cpy ScrollY ;If object room pos is >= scrollY, set carry. +LDFF6:  cpy ScrollY                     ;If object room pos is >= scrollY, set carry. 
-LDFF8: lda $06 ;Check if object is on different name table as current--> +LDFF8:  lda $06                         ;Check if object is on different name table as current--> 
-LDFFA: eor PPUCNT0ZP ;name table active in PPU.--> +LDFFA:  eor PPUCNT0ZP                   ;name table active in PPU.--> 
-LDFFC: and #$01 ;If not, branch. +LDFFC:  and #$01                        ;If not, branch. 
-LDFFE: beq + +LDFFE:  beq +                           
-LE000: bcs ++ ;If carry is still set, sprite is not in screen boundaries. +LE000:  bcs ++                          ;If carry is still set, sprite is not in screen boundaries. 
-LE002: lda $10 +LE002:  lda $10                         
-LE004: sbc #$0F ;Move sprite y position up 15 pixles. +LE004:  sbc #$0F                        ;Move sprite y position up 15 pixles. 
-LE006: sta $10 +LE006:  sta $10                         
-LE008: lda $09 +LE008:  lda $09                         
-LE00A: clc ;If a portion of the object is outside the sceen--> +LE00A:  clc                             ;If a portion of the object is outside the sceen--> 
-LE00B: adc $10 ;boundaries, treat object as if the whole thing is--> +LE00B:  adc $10                         ;boundaries, treat object as if the whole thing is--> 
-LE00D: cmp #$F0 ;not visible. +LE00D:  cmp #$F0                        ;not visible. 
-LE00F: bcc +++ +LE00F:  bcc +++                         
-LE011: clc ;Causes next statement to branch always. +LE011:  clc                             ;Causes next statement to branch always. 
-LE012:* bcc + +LE012:* bcc +                           
-LE014: lda $09 ;If object is on same name table as the current one in--> +LE014:  lda $09                         ;If object is on same name table as the current one in--> 
-LE016: cmp $10 ;the PPU, check if part of object is out of screen-->  +LE016:  cmp $10                         ;the PPU, check if part of object is out of screen-->  
-LE018: bcc ++ ;boundaries.  If so, branch. +LE018:  bcc ++                          ;boundaries.  If so, branch. 
-LE01A:* dex ;Sprite is not within screen boundaries. Decrement X. +LE01A:* dex                             ;Sprite is not within screen boundaries. Decrement X. 
-LE01B:* rts ;+LE01B:* rts                             ;
  
 HorzScrollCheck: HorzScrollCheck:
-LE01C:  lda $06 +LE01C:  lda $06                         
-LE01E: eor PPUCNT0ZP ;Check if object is on different name table as current--> +LE01E:  eor PPUCNT0ZP                   ;Check if object is on different name table as current--> 
-LE020: and #$01 ;name table active in PPU.--> +LE020:  and #$01                        ;name table active in PPU.--> 
-LE022: beq + ;If not, branch. +LE022:  beq +                           ;If not, branch. 
-LE024: bcs ++ ;If carry is still set, sprite is not in screen boundaries. +LE024:  bcs ++                          ;If carry is still set, sprite is not in screen boundaries. 
-LE026: lda $09 +LE026:  lda $09                         
-LE028: clc ;If a portion of the object is outside the sceen--> +LE028:  clc                             ;If a portion of the object is outside the sceen--> 
-LE029: adc $0E ;boundaries, treat object as if the whole thing is--> +LE029:  adc $0E                         ;boundaries, treat object as if the whole thing is--> 
-LE02B: bcc +++ ;not visible. +LE02B:  bcc +++                         ;not visible. 
-LE02D: clc ;Causes next statement to branch always. +LE02D:  clc                             ;Causes next statement to branch always. 
-LE02E:* bcc + +LE02E:* bcc +                           
-LE030: lda $09 ;If object is on same name table as the current one in--> +LE030:  lda $09                         ;If object is on same name table as the current one in--> 
-LE032: cmp $0E ;the PPU, check if part of object is out of screen-->  +LE032:  cmp $0E                         ;the PPU, check if part of object is out of screen-->  
-LE034: bcc ++ ;boundaries.  If so, branch. +LE034:  bcc ++                          ;boundaries.  If so, branch. 
-LE036:* dex ;Sprite is not within screen boundaries. Decrement X. +LE036:* dex                             ;Sprite is not within screen boundaries. Decrement X. 
-LE037:* rts ;+LE037:* rts                             ;
  
 ;------------------------[ Override sprite flip bits with object flip bits ]------------------------- ;------------------------[ Override sprite flip bits with object flip bits ]-------------------------
Line 5034: Line 5034:
  
 SpriteFlipBitsOveride: SpriteFlipBitsOveride:
-LE038: lsr ObjectCntrl ;Restore MSB. +LE038:  lsr ObjectCntrl                 ;Restore MSB. 
-LE03A: lda ($00),y ;Reload frame data control byte into A. +LE03A:  lda ($00),                    ;Reload frame data control byte into A. 
-LE03C: and #$C0 ;Extract the two sprite flip bytes from theoriginal--> +LE03C:  and #$C0                        ;Extract the two sprite flip bytes from theoriginal--> 
-LE03E: ora ObjectCntrl ;control byte and set any additional bits from ObjectCntrl. +LE03E:  ora ObjectCntrl                 ;control byte and set any additional bits from ObjectCntrl. 
-LE040: sta $05 ;Store modified byte to load in sprite control byte later. +LE040:  sta $05                         ;Store modified byte to load in sprite control byte later. 
-LE042: lda ObjectCntrl +LE042:  lda ObjectCntrl                 
-LE044: ora #$80 +LE044:  ora #$80                        
-LE046: sta ObjectCntrl ;Ensure MSB of object control byte remains set. +LE046:  sta ObjectCntrl                 ;Ensure MSB of object control byte remains set. 
-LE048: rts ;+LE048:  rts                             ;
  
 ;--------------------------------[ Explosion placement data ]--------------------------------------- ;--------------------------------[ Explosion placement data ]---------------------------------------
Line 5050: Line 5050:
  
 ExplodeIndexTbl: ExplodeIndexTbl:
-LE049: .byte $00, $18, $30+LE049:  .byte $00, $18, $30
  
 ;The following table is used to produce the arcing motion of exploding objects.  It is displacement ;The following table is used to produce the arcing motion of exploding objects.  It is displacement
Line 5058: Line 5058:
  
 ;Bottom sprites. ;Bottom sprites.
-LE04C: .byte $FC, $F8, $F4, $F0, $EE, $EC, $EA, $E8, $E7, $E6, $E6, $E5, $E5, $E4, $E4, $E3 +LE04C:  .byte $FC, $F8, $F4, $F0, $EE, $EC, $EA, $E8, $E7, $E6, $E6, $E5, $E5, $E4, $E4, $E3 
-LE05C: .byte $E5, $E7, $E9, $EB, $EF, $F3, $F7, $FB+LE05C:  .byte $E5, $E7, $E9, $EB, $EF, $F3, $F7, $FB
  
 ;Middle sprites. ;Middle sprites.
-LE064: .byte $FE, $FC, $FA, $F8, $F6, $F4, $F2, $F0, $EE, $ED, $EB, $EA, $E9, $E8, $E7, $E6 +LE064:  .byte $FE, $FC, $FA, $F8, $F6, $F4, $F2, $F0, $EE, $ED, $EB, $EA, $E9, $E8, $E7, $E6 
-LE074: .byte $E6, $E6, $E6, $E6, $E8, $EA, $EC, $EE+LE074:  .byte $E6, $E6, $E6, $E6, $E8, $EA, $EC, $EE
  
 ;Top sprites. ;Top sprites.
-LE07C: .byte $FE, $FC, $FA, $F8, $F7, $F6, $F5, $F4, $F3, $F2, $F1, $F1, $F0, $F0, $EF, $EF +LE07C:  .byte $FE, $FC, $FA, $F8, $F7, $F6, $F5, $F4, $F3, $F2, $F1, $F1, $F0, $F0, $EF, $EF 
-LE08C: .byte $EF, $EF, $EF, $EF, $F0, $F0, $F1, $F2+LE08C:  .byte $EF, $EF, $EF, $EF, $F0, $F0, $F1, $F2
  
 ;--------------------------------------[ Update enemy animation ]----------------------------------- ;--------------------------------------[ Update enemy animation ]-----------------------------------
Line 5074: Line 5074:
  
 UpdateEnemyAnim: UpdateEnemyAnim:
-LE094: ldx PageIndex ;Load index to desired enemy. +LE094:  ldx PageIndex                   ;Load index to desired enemy. 
-LE096: ldy EnStatus,x +LE096:  ldy EnStatus,                 
-LE099: cpy #$05 ;Is enemy in the process of dying?--> +LE099:  cpy #$05                        ;Is enemy in the process of dying?--> 
-LE09B: beq +++ ;If so, branch to exit. +LE09B:  beq +++                         ;If so, branch to exit. 
-LE09D: ldy EnAnimDelay,x +LE09D:  ldy EnAnimDelay,              
-LE0A0: beq + ;Check if current anumation frame is ready to be updated. +LE0A0:  beq +                           ;Check if current anumation frame is ready to be updated. 
-LE0A2: dec EnAnimDelay,x ;Not ready to update. decrement delay timer and--> +LE0A2:  dec EnAnimDelay,              ;Not ready to update. decrement delay timer and--> 
-LE0A5: bne +++ ;branch to exit. +LE0A5:  bne +++                         ;branch to exit. 
-LE0A7:* sta EnAnimDelay,x ;Save new animation delay value. +LE0A7:* sta EnAnimDelay,              ;Save new animation delay value. 
-LE0AA: ldy EnAnimIndex,x ;Load enemy animation index. +LE0AA:  ldy EnAnimIndex,              ;Load enemy animation index. 
-LE0AD:* lda (EnemyAnimPtr),y ;Get animation data. +LE0AD:* lda (EnemyAnimPtr),           ;Get animation data. 
-LE0AF: cmp #$FF ;End of animation? +LE0AF:  cmp #$FF                        ;End of animation? 
-LE0B1: beq ++ ;If so, branch to reset animation. +LE0B1:  beq ++                          ;If so, branch to reset animation. 
-LE0B3: sta EnAnimFrame,x ;Store current animation frame data. +LE0B3:  sta EnAnimFrame,              ;Store current animation frame data. 
-LE0B6: iny ;Increment to next animation data index. +LE0B6:  iny                             ;Increment to next animation data index. 
-LE0B7: tya +LE0B7:  tya                             
-LE0B8: sta EnAnimIndex,x ;Save new animation index. +LE0B8:  sta EnAnimIndex,              ;Save new animation index. 
-LE0BB:* rts ;+LE0BB:* rts                             ;
  
-LE0BC:* ldy EnResetAnimIndex,x ;reset animation index. +LE0BC:* ldy EnResetAnimIndex,         ;reset animation index. 
-LE0BF: bcs --- ;Branch always.+LE0BF:  bcs ---                         ;Branch always.
  
 ;---------------------------------------[ Display status bar ]--------------------------------------- ;---------------------------------------[ Display status bar ]---------------------------------------
Line 5101: Line 5101:
  
 DisplayBar: DisplayBar:
-LE0C1: ldy #$00 ;Reset data index. +LE0C1:  ldy #$00                        ;Reset data index. 
-LE0C3: lda SpritePagePos ;Load current sprite index. +LE0C3:  lda SpritePagePos               ;Load current sprite index. 
-LE0C5: pha ;save sprite page pos. +LE0C5:  pha                             ;save sprite page pos. 
-LE0C6: tax +LE0C6:  tax                             
-LE0C7:* lda DataDisplayTbl,y +LE0C7:* lda DataDisplayTbl,           
-LE0CA: sta Sprite00RAM,x ;Stor contents of DataDisplayTbl in sprite RAM. +LE0CA:  sta Sprite00RAM,              ;Stor contents of DataDisplayTbl in sprite RAM. 
-LE0CD: inx +LE0CD:  inx                             
-LE0CE: iny +LE0CE:  iny                             
-LE0CF: cpy #$28 ;10*4. At end of DataDisplayTbl? If not, loop to--> +LE0CF:  cpy #$28                        ;10*4. At end of DataDisplayTbl? If not, loop to--> 
-LE0D1: bne - ;load next byte from table.+LE0D1:  bne -                           ;load next byte from table.
  
 ;Display 2-digit health count. ;Display 2-digit health count.
-LE0D3: stx SpritePagePos ;Save new location in sprite RAM. +LE0D3:  stx SpritePagePos               ;Save new location in sprite RAM. 
-LE0D5: pla ;Restore initial sprite page pos. +LE0D5:  pla                             ;Restore initial sprite page pos. 
-LE0D6: tax +LE0D6:  tax                             
-LE0D7: lda HealthHi +LE0D7:  lda HealthHi                    
-LE0DA: and #$0F ;Extract upper health digit. +LE0DA:  and #$0F                        ;Extract upper health digit. 
-LE0DC: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE0DC:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE0DF: lda HealthLo +LE0DF:  lda HealthLo                    
-LE0E2: jsr Adiv16 ;($C2BF)Move lower health digit to 4 LSBs. +LE0E2:  jsr Adiv16                      ;($C2BF)Move lower health digit to 4 LSBs. 
-LE0E5: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE0E5:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE0E8: ldy EndTimerHi +LE0E8:  ldy EndTimerHi                  
-LE0EB: iny ;Is Samus in escape sequence?--> +LE0EB:  iny                             ;Is Samus in escape sequence?--> 
-LE0EC: bne ++ ;If so, branch. +LE0EC:  bne ++                          ;If so, branch. 
-LE0EE: ldy MaxMissiles +LE0EE:  ldy MaxMissiles                 
-LE0F1: beq + ;Don't show missile count if Samus has no missile containers.+LE0F1:  beq +                           ;Don't show missile count if Samus has no missile containers.
  
 ;Display 3-digit missile count. ;Display 3-digit missile count.
-LE0F3: lda MissileCount +LE0F3:  lda MissileCount                
-LE0F6: jsr HexToDec ;($E198)Convert missile hex count to decimal cout. +LE0F6:  jsr HexToDec                    ;($E198)Convert missile hex count to decimal cout. 
-LE0F9: lda $02 ;Upper digit. +LE0F9:  lda $02                         ;Upper digit. 
-LE0FB: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE0FB:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE0FE: lda $01 ;Middle digit. +LE0FE:  lda $01                         ;Middle digit. 
-LE100: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE100:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE103: lda $00 ;Lower digit. +LE103:  lda $00                         ;Lower digit. 
-LE105: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE105:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE108: bne +++ ;Branch always.+LE108:  bne +++                         ;Branch always.
  
 ;Samus has no missiles, erase missile sprite. ;Samus has no missiles, erase missile sprite.
-LE10A:* lda #$FF ;"Blank" tile. +LE10A:* lda #$FF                        ;"Blank" tile. 
-LE10C: cpx #$F4 ;If at last 3 sprites, branch to skip. +LE10C:  cpx #$F4                        ;If at last 3 sprites, branch to skip. 
-LE10E: bcs ++ +LE10E:  bcs ++                          
-LE110: sta Sprite03RAM+1,x ;Erase left half of missile. +LE110:  sta Sprite03RAM+1,            ;Erase left half of missile. 
-LE113: cpx #$F0 ;If at last 4 sprites, branch to skip. +LE113:  cpx #$F0                        ;If at last 4 sprites, branch to skip. 
-LE115: bcs ++ +LE115:  bcs ++                          
-LE117: sta Sprite04RAM+1,x ;Erase right half of missile. +LE117:  sta Sprite04RAM+1,            ;Erase right half of missile. 
-LE11A: bne ++ ;Branch always.+LE11A:  bne ++                          ;Branch always.
  
 ;Display 3-digit end sequence timer. ;Display 3-digit end sequence timer.
-LE11C:* lda EndTimerHi +LE11C:* lda EndTimerHi                  
-LE11F: jsr Adiv16 ;($C2BF)Upper timer digit. +LE11F:  jsr Adiv16                      ;($C2BF)Upper timer digit. 
-LE122: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE122:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE125: lda EndTimerHi +LE125:  lda EndTimerHi                  
-LE128: and #$0F ;Middle timer digit. +LE128:  and #$0F                        ;Middle timer digit. 
-LE12A: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE12A:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE12D: lda EndTimerLo +LE12D:  lda EndTimerLo                  
-LE130: jsr Adiv16 ;($C2BF)Lower timer digit. +LE130:  jsr Adiv16                      ;($C2BF)Lower timer digit. 
-LE133: jsr SPRWriteDigit ;($E173)Display digit on screen. +LE133:  jsr SPRWriteDigit               ;($E173)Display digit on screen. 
-LE136: lda #$58 ;"TI" sprite(left half of "TIME"). +LE136:  lda #$58                        ;"TI" sprite(left half of "TIME"). 
-LE138: sta Sprite00RAM+1,x +LE138:  sta Sprite00RAM+1,            
-LE13B: inc Sprite00RAM+2,x ;Change color of sprite. +LE13B:  inc Sprite00RAM+2,            ;Change color of sprite. 
-LE13E: cpx #$FC ;If at last sprite, branch to skip. +LE13E:  cpx #$FC                        ;If at last sprite, branch to skip. 
-LE140: bcs + +LE140:  bcs +                           
-LE142: lda #$59 ;"ME" sprite(right half of "TIME"). +LE142:  lda #$59                        ;"ME" sprite(right half of "TIME"). 
-LE144: sta Sprite01RAM+1,x +LE144:  sta Sprite01RAM+1,            
-LE147: inc Sprite01RAM+2,x ;Change color of sprite.+LE147:  inc Sprite01RAM+2,            ;Change color of sprite.
  
-LE14A:* ldx SpritePagePos ;Restore initial sprite page pos. +LE14A:* ldx SpritePagePos               ;Restore initial sprite page pos. 
-LE14C: lda TankCount +LE14C:  lda TankCount                   
-LE14F: beq ++ ;Branch to exit if Samus has no energy tanks.+LE14F:  beq ++                          ;Branch to exit if Samus has no energy tanks.
  
 ;Display full/empty energy tanks. ;Display full/empty energy tanks.
-LE151: sta $03 ;Temp store tank count. +LE151:  sta $03                         ;Temp store tank count. 
-LE153: lda #$40 ;X coord of right-most energy tank. +LE153:  lda #$40                        ;X coord of right-most energy tank. 
-LE155: sta $00 ;Energy tanks are drawn from right to left. +LE155:  sta $00                         ;Energy tanks are drawn from right to left. 
-LE157: ldy #$6F ;"Full energy tank" tile. +LE157:  ldy #$6F                        ;"Full energy tank" tile. 
-LE159: lda HealthHi +LE159:  lda HealthHi                    
-LE15C: jsr Adiv16 ;($C2BF)/16. A contains # of full energy tanks. +LE15C:  jsr Adiv16                      ;($C2BF)/16. A contains # of full energy tanks. 
-LE15F: sta $01 ;Storage of full tanks. +LE15F:  sta $01                         ;Storage of full tanks. 
-LE161: bne AddTanks ;Branch if at least 1 tank is full. +LE161:  bne AddTanks                    ;Branch if at least 1 tank is full. 
-LE163: dey ;Else switch to "empty energy tank" tile.+LE163:  dey                             ;Else switch to "empty energy tank" tile.
  
 AddTanks: AddTanks:
-LE164: jsr AddOneTank ;($E17B)Add energy tank to display. +LE164:  jsr AddOneTank                  ;($E17B)Add energy tank to display. 
-LE167: dec $01 ;Any more full energy tanks left?--> +LE167:  dec $01                         ;Any more full energy tanks left?--> 
-LE169: bne + ;If so, then branch.--> +LE169:  bne +                           ;If so, then branch.--> 
-LE16B: dey ;Otherwise, switch to "empty energy tank" tile. +LE16B:  dey                             ;Otherwise, switch to "empty energy tank" tile. 
-LE16C:* dec $03 ;done all tanks?--> +LE16C:* dec $03                         ;done all tanks?--> 
-LE16E: bne AddTanks ;if not, loop to do another.+LE16E:  bne AddTanks                    ;if not, loop to do another.
  
-LE170: stx SpritePagePos ;Store new sprite page position. +LE170:  stx SpritePagePos               ;Store new sprite page position. 
-LE172:* rts ;+LE172:* rts                             ;
  
 ;----------------------------------------[Sprite write digit ]--------------------------------------- ;----------------------------------------[Sprite write digit ]---------------------------------------
Line 5200: Line 5200:
  
 SPRWriteDigit: SPRWriteDigit:
-LE173: ora #$A0 ;#$A0 is index into pattern table for numbers. +LE173:  ora #$A0                        ;#$A0 is index into pattern table for numbers. 
-LE175: sta Sprite00RAM+1,x ;Store proper nametable pattern in sprite RAM. +LE175:  sta Sprite00RAM+1,            ;Store proper nametable pattern in sprite RAM. 
-LE178: jmp Xplus4 ;Find next sprite pattern table byte.+LE178:  jmp Xplus4                      ;Find next sprite pattern table byte.
  
 ;----------------------------------[ Add energy tank to display ]------------------------------------ ;----------------------------------[ Add energy tank to display ]------------------------------------
Line 5209: Line 5209:
  
 AddOneTank: AddOneTank:
-LE17B: lda #$17 ;Y coord-1. +LE17B:  lda #$17                        ;Y coord-1. 
-LE17D: sta Sprite00RAM,x +LE17D:  sta Sprite00RAM,              
-LE180: tya ;Tile value. +LE180:  tya                             ;Tile value. 
-LE181: sta Sprite00RAM+1,x +LE181:  sta Sprite00RAM+1,            
-LE184: lda #$01 ;Palette #. +LE184:  lda #$01                        ;Palette #. 
-LE186: sta Sprite00RAM+2,x +LE186:  sta Sprite00RAM+2,            
-LE189: lda $00 ;X coord. +LE189:  lda $00                         ;X coord. 
-LE18B: sta Sprite00RAM+3,x +LE18B:  sta Sprite00RAM+3,            
-LE18E: sec +LE18E:  sec                             
-LE18F: sbc #$0A ;Find x coord of next energy tank. +LE18F:  sbc #$0A                        ;Find x coord of next energy tank. 
-LE191: sta $00 ;+LE191:  sta $00                         ;
  
 ;-----------------------------------------[ Add 4 to x ]--------------------------------------------- ;-----------------------------------------[ Add 4 to x ]---------------------------------------------
  
 Xplus4: Xplus4:
-LE193: inx +LE193:  inx                             
-LE194: inx +LE194:  inx                             
-LE195: inx ;Add 4 to value stored in X. +LE195:  inx                             ;Add 4 to value stored in X. 
-LE196: inx +LE196:  inx                             
-LE197: rts ;+LE197:  rts                             ;
  
 ;------------------------------------[ Convert hex to decimal ]-------------------------------------- ;------------------------------------[ Convert hex to decimal ]--------------------------------------
Line 5235: Line 5235:
  
 HexToDec: HexToDec:
-LE198: ldy #100 ;Find upper digit. +LE198:  ldy #100                        ;Find upper digit. 
-LE19A: sty $0A +LE19A:  sty $0A                         
-LE19C: jsr GetDigit ;($E1AD)Extract hundreds digit. +LE19C:  jsr GetDigit                    ;($E1AD)Extract hundreds digit. 
-LE19F: sty $02 ;Store upper digit in $02. +LE19F:  sty $02                         ;Store upper digit in $02. 
-LE1A1: ldy #10 ;Find middle digit. +LE1A1:  ldy #10                         ;Find middle digit. 
-LE1A3: sty $0A +LE1A3:  sty $0A                         
-LE1A5: jsr GetDigit ;($E1AD)Extract tens digit. +LE1A5:  jsr GetDigit                    ;($E1AD)Extract tens digit. 
-LE1A8: sty $01 ;Store middle digit in $01. +LE1A8:  sty $01                         ;Store middle digit in $01. 
-LE1AA: sta $00 ;Store lower digit in $00 +LE1AA:  sta $00                         ;Store lower digit in $00 
-LE1AC: rts ;+LE1AC:  rts                             ;
  
 GetDigit: GetDigit:
-LE1AD: ldy #$00 +LE1AD:  ldy #$00                        
-LE1AF: sec +LE1AF:  sec                             
-LE1B0:* iny +LE1B0:* iny                             
-LE1B1: sbc $0A ;Loop and subtract value in $0A from A until carry flag--> +LE1B1:  sbc $0A                         ;Loop and subtract value in $0A from A until carry flag--> 
-LE1B3: bcs - ;is not set.  The resulting number of loops is the decimal--> +LE1B3:  bcs -                           ;is not set.  The resulting number of loops is the decimal--> 
-LE1B5: dey ;number extracted and A is the remainder. +LE1B5:  dey                             ;number extracted and A is the remainder. 
-LE1B6: adc $0A +LE1B6:  adc $0A                         
-LE1B8: rts ;+LE1B8:  rts                             ;
  
 ;-------------------------------------[ Status bar sprite data ]------------------------------------- ;-------------------------------------[ Status bar sprite data ]-------------------------------------
Line 5261: Line 5261:
  
 DataDisplayTbl: DataDisplayTbl:
-LE1B9: .byte $21,$A0,$01,$30 ;Upper health digit. +LE1B9:  .byte $21,$A0,$01,$30           ;Upper health digit. 
-LE1BD: .byte $21,$A0,$01,$38 ;Lower health digit. +LE1BD:  .byte $21,$A0,$01,$38           ;Lower health digit. 
-LE1C1: .byte $2B,$FF,$01,$28 ;Upper missile digit. +LE1C1:  .byte $2B,$FF,$01,$28           ;Upper missile digit. 
-LE1C5: .byte $2B,$FF,$01,$30 ;Middle missile digit. +LE1C5:  .byte $2B,$FF,$01,$30           ;Middle missile digit. 
-LE1C9: .byte $2B,$FF,$01,$38 ;Lower missile digit. +LE1C9:  .byte $2B,$FF,$01,$38           ;Lower missile digit. 
-LE1CD: .byte $2B,$5E,$00,$18 ;Left half of missile. +LE1CD:  .byte $2B,$5E,$00,$18           ;Left half of missile. 
-LE1D1: .byte $2B,$5F,$00,$20 ;Right half of missile. +LE1D1:  .byte $2B,$5F,$00,$20           ;Right half of missile. 
-LE1D5: .byte $21,$76,$01,$18 ;E +LE1D5:  .byte $21,$76,$01,$18           ;E 
-LE1D9: .byte $21,$7F,$01,$20 ;N +LE1D9:  .byte $21,$7F,$01,$20           ;N 
-LE1DD: .byte $21,$3A,$00,$28 ;..+LE1DD:  .byte $21,$3A,$00,$28           ;..
  
 ;-------------------------------------------[ Bit scan ]--------------------------------------------- ;-------------------------------------------[ Bit scan ]---------------------------------------------
Line 5279: Line 5279:
  
 BitScan: BitScan:
-LE1E1: stx $0E ;Save X. +LE1E1:  stx $0E                         ;Save X. 
-LE1E3: ldx #$00 ;First bit is bit 0. +LE1E3:  ldx #$00                        ;First bit is bit 0. 
-LE1E5:* lsr ;Transfer bit to carry flag. +LE1E5:* lsr                             ;Transfer bit to carry flag. 
-LE1E6: bcs + ;If the shifted bit was 1, Branch out of loop. +LE1E6:  bcs +                           ;If the shifted bit was 1, Branch out of loop. 
-LE1E8: inx ;Increment X to keep of # of bits checked. +LE1E8:  inx                             ;Increment X to keep of # of bits checked. 
-LE1E9: cpx #$08 ;Have all 8 bit been tested?--> +LE1E9:  cpx #$08                        ;Have all 8 bit been tested?--> 
-LE1EB: bne - ;If not, branch to check the next bit. +LE1EB:  bne -                           ;If not, branch to check the next bit. 
-LE1ED:* txa ;Return which bit number was set. +LE1ED:* txa                             ;Return which bit number was set. 
-LE1EE: ldx $0E ;Restore X. +LE1EE:  ldx $0E                         ;Restore X. 
-LE1F0:* rts ;+LE1F0:* rts                             ;
  
 ;------------------------------------------[ Scroll door ]------------------------------------------- ;------------------------------------------[ Scroll door ]-------------------------------------------
Line 5295: Line 5295:
  
 ScrollDoor: ScrollDoor:
-LE1F1: ldx DoorStatus +LE1F1:  ldx DoorStatus                  
-LE1F3: beq - ;Exit if Samus isn't in a door. +LE1F3:  beq -                           ;Exit if Samus isn't in a door. 
-LE1F5: dex +LE1F5:  dex                             
-LE1F6: bne + ;Not in right door. branch to check left door. +LE1F6:  bne +                           ;Not in right door. branch to check left door. 
-LE1F8: jsr ScrollRight ;($E6D2)DoorStatus=1, scroll 1 pixel right. +LE1F8:  jsr ScrollRight                 ;($E6D2)DoorStatus=1, scroll 1 pixel right. 
-LE1FB: jmp ++ ;Jump to check if door scroll is finished.+LE1FB:  jmp ++                          ;Jump to check if door scroll is finished.
  
-LE1FE:* dex ;Check if in left door. +LE1FE:* dex                             ;Check if in left door. 
-LE1FF: bne ++ +LE1FF:  bne ++                          
-LE201: jsr ScrollLeft ;($E6A7)DoorStatus=2, scroll 1 pixel left. +LE201:  jsr ScrollLeft                  ;($E6A7)DoorStatus=2, scroll 1 pixel left. 
-LE204:* ldx ScrollX ;Has x scroll offset reached 0?--> +LE204:* ldx ScrollX                     ;Has x scroll offset reached 0?--> 
-LE206: bne Exit15 ;If not, branch to exit.+LE206:  bne Exit15                      ;If not, branch to exit.
  
 ;Scrolled one full screen, time to exit door. ;Scrolled one full screen, time to exit door.
-LE208: ldx #$05 ;Samus is exiting the door. +LE208:  ldx #$05                        ;Samus is exiting the door. 
-LE20A: bne DoOneDoorScroll ;Branch always.+LE20A:  bne DoOneDoorScroll             ;Branch always.
  
-LE20C:* dex +LE20C:* dex                             
-LE20D: bne + ;Check if need to scroll down to center door. +LE20D:  bne +                           ;Check if need to scroll down to center door. 
-LE20F: jsr ScrollDown ;($E519)DoorStatus=3, scroll 1 pixel down. +LE20F:  jsr ScrollDown                  ;($E519)DoorStatus=3, scroll 1 pixel down. 
-LE212: jmp ++ ;Jump to check y scrolling value. +LE212:  jmp ++                          ;Jump to check y scrolling value. 
-LE215:* dex +LE215:* dex                             
-LE216: bne Exit15 ;Check if need to scroll up to center door. +LE216:  bne Exit15                      ;Check if need to scroll up to center door. 
-LE218: jsr ScrollUp ;($E4F1)DoorStatus=4, scroll 1 pixel up.+LE218:  jsr ScrollUp                    ;($E4F1)DoorStatus=4, scroll 1 pixel up.
  
 VerticalRoomCentered: VerticalRoomCentered:
-LE21B:* ldx ScrollY ;Has room been centered on screen?--> +LE21B:* ldx ScrollY                     ;Has room been centered on screen?--> 
-LE21D: bne Exit15 ;If not, branch to exit. +LE21D:  bne Exit15                      ;If not, branch to exit. 
-LE21F: stx DoorOnNameTable3 +LE21F:  stx DoorOnNameTable3            
-LE221: stx DoorOnNameTable0 ;Erase door nametable data. +LE221:  stx DoorOnNameTable0            ;Erase door nametable data. 
-LE223: inx ;X=1. +LE223:  inx                             ;X=1. 
-LE224: lda ObjectX ;Did Samus enter in the right hand door?--> +LE224:  lda ObjectX                     ;Did Samus enter in the right hand door?--> 
-LE227: bmi ++ ;If so, branch. +LE227:  bmi ++                          ;If so, branch. 
-LE229: inx ;X=2. Samus is in left door. +LE229:  inx                             ;X=2. Samus is in left door. 
-LE22A: bne ++ ;Branch always.+LE22A:  bne ++                          ;Branch always.
  
 ;This function is called once after door scrolling is complete. ;This function is called once after door scrolling is complete.
  
 DoOneDoorScroll: DoOneDoorScroll:
-LE22C: lda #$20 ;Set DoorDelay to 32 frames(comming out of door). +LE22C:  lda #$20                        ;Set DoorDelay to 32 frames(comming out of door). 
-LE22E: sta DoorDelay +LE22E:  sta DoorDelay                   
-LE230: lda SamusDoorData ;Check if scrolling should be toggled. +LE230:  lda SamusDoorData               ;Check if scrolling should be toggled. 
-LE232: jsr Amul8 ;($C2C6)*8. Is door not to toggle scrolling(item room,--> +LE232:  jsr Amul8                       ;($C2C6)*8. Is door not to toggle scrolling(item room,--> 
-LE235: bcs + ;bridge room, etc.)? If so, branch to NOT toggle scrolling. +LE235:  bcs +                           ;bridge room, etc.)? If so, branch to NOT toggle scrolling. 
-LE237: ldy DoorScrollStatus ;If comming from vertical shaft, skip ToggleScroll because--> +LE237:  ldy DoorScrollStatus            ;If comming from vertical shaft, skip ToggleScroll because--> 
-LE239: cpy #$03 ;the scroll was already toggled after room was centered--> +LE239:  cpy #$03                        ;the scroll was already toggled after room was centered--> 
-LE23B: bcc ++ ;by the routine just above. +LE23B:  bcc ++                          ;by the routine just above. 
-LE23D:* lda #$47 ;Set mirroring for vertical mirroring(horz scrolling). +LE23D:* lda #$47                        ;Set mirroring for vertical mirroring(horz scrolling). 
-LE23F: bne ++ ;Branch always.+LE23F:  bne ++                          ;Branch always.
  
-LE241:* jsr ToggleScroll ;($E252)Toggle scrolling and mirroring. +LE241:* jsr ToggleScroll                ;($E252)Toggle scrolling and mirroring. 
-LE244:* sta MirrorCntrl ;Store new mirror control data. +LE244:* sta MirrorCntrl                 ;Store new mirror control data. 
-LE246: stx DoorStatus ;DoorStatus=5. Done with door scrolling.+LE246:  stx DoorStatus                  ;DoorStatus=5. Done with door scrolling.
  
 Exit15: Exit15:
-LE248: rts ;Exit for several routines above.+LE248:  rts                             ;Exit for several routines above.
  
 ;------------------------------------[ Toggle Samus nametable ]-------------------------------------- ;------------------------------------[ Toggle Samus nametable ]--------------------------------------
  
 ToggleSamusHi: ToggleSamusHi:
-LE249: lda ObjectHi +LE249:  lda ObjectHi                    
-LE24C: eor #$01 ;Change Samus' current nametable from one to the other. +LE24C:  eor #$01                        ;Change Samus' current nametable from one to the other. 
-LE24E: sta ObjectHi +LE24E:  sta ObjectHi                    
-LE251: rts ;+LE251:  rts                             ;
  
 ;-------------------------------------------[ Toggle scroll ]---------------------------------------- ;-------------------------------------------[ Toggle scroll ]----------------------------------------
Line 5366: Line 5366:
  
 ToggleScroll: ToggleScroll:
-LE252: lda ScrollDir +LE252:  lda ScrollDir                   
-LE254: eor #$03 ;Toggle scroll direction. +LE254:  eor #$03                        ;Toggle scroll direction. 
-LE256: sta ScrollDir +LE256:  sta ScrollDir                   
-LE258: lda MirrorCntrl ;Toggle mirroring. +LE258:  lda MirrorCntrl                 ;Toggle mirroring. 
-LE25A: eor #$08 +LE25A:  eor #$08                        
-LE25C: rts ;+LE25C:  rts                             ;
  
 ;----------------------------------------[ Is Samus in lava ]---------------------------------------- ;----------------------------------------[ Is Samus in lava ]----------------------------------------
Line 5381: Line 5381:
  
 IsSamusInLava: IsSamusInLava:
-LE25D:  lda #$01 +LE25D:  lda #$01                        
-LE25F: cmp ScrollDir ;Set carry bit(and exit) if scrolling up or down. +LE25F:  cmp ScrollDir                   ;Set carry bit(and exit) if scrolling up or down. 
-LE261: bcs + +LE261:  bcs +                           
-LE263: lda #$D8 ;If Samus is Scrolling left or right and within 24 pixels--> +LE263:  lda #$D8                        ;If Samus is Scrolling left or right and within 24 pixels--> 
-LE265: cmp ObjectY ;of the bottom of the screen, she is in lava. Clear carry bit. +LE265:  cmp ObjectY                     ;of the bottom of the screen, she is in lava. Clear carry bit. 
-LE268:* rts ;+LE268:* rts                             ;
  
 ;----------------------------------[ Check lava and movement routines ]------------------------------ ;----------------------------------[ Check lava and movement routines ]------------------------------
  
 LavaAndMoveCheck: LavaAndMoveCheck:
-LE269:  lda ObjAction +LE269:  lda ObjAction                   
-LE26C: cmp #sa_Elevator ;Is Samus on elevator?--> +LE26C:  cmp #sa_Elevator                ;Is Samus on elevator?--> 
-LE26E: beq + ;If so, branch. +LE26E:  beq +                           ;If so, branch. 
-LE270: cmp #sa_Dead ;Is Samus Dead--> +LE270:  cmp #sa_Dead                    ;Is Samus Dead--> 
-LE272: bcs - ;If so, branch to exit. +LE272:  bcs -                           ;If so, branch to exit. 
-LE274:* jsr IsSamusInLava ;($E25D)Clear carry flag if Samus is in lava. +LE274:* jsr IsSamusInLava               ;($E25D)Clear carry flag if Samus is in lava. 
-LE277: ldy #$FF ;Assume Samus not in lava. +LE277:  ldy #$FF                        ;Assume Samus not in lava. 
-LE279: bcs ++++ ;Samus not in lava so branch.+LE279:  bcs ++++                        ;Samus not in lava so branch.
  
 ;Samus is in lava. ;Samus is in lava.
-LE27B: sty DamagePushDirection ;Don't push Samus from lava damage. +LE27B:  sty DamagePushDirection         ;Don't push Samus from lava damage. 
-LE27D: jsr ClearHealthChange ;($F323)Clear any pending health changes to Samus. +LE27D:  jsr ClearHealthChange           ;($F323)Clear any pending health changes to Samus. 
-LE280: lda #$32 +LE280:  lda #$32                        
-LE282: sta SamusBlink ;Make Samus blink. +LE282:  sta SamusBlink                  ;Make Samus blink. 
-LE284: lda FrameCount +LE284:  lda FrameCount                  
-LE286: and #$03 ;Start the jump SFX every 4th frame while in lava. +LE286:  and #$03                        ;Start the jump SFX every 4th frame while in lava. 
-LE288: bne + +LE288:  bne +                           
-LE28A: jsr SFX_SamusJump ;($CBAC)Initiate jump SFX. +LE28A:  jsr SFX_SamusJump               ;($CBAC)Initiate jump SFX. 
-LE28D:* lda FrameCount +LE28D:* lda FrameCount                  
-LE28F: lsr ;This portion of the code causes Samus to be damaged by--> +LE28F:  lsr                             ;This portion of the code causes Samus to be damaged by--> 
-LE290: and #$03 ;lava twice every 8 frames if she does not have the varia--> +LE290:  and #$03                        ;lava twice every 8 frames if she does not have the varia--> 
-LE292: bne ++ ;but only once every 8 frames if she does. +LE292:  bne ++                          ;but only once every 8 frames if she does. 
-LE294: lda SamusGear +LE294:  lda SamusGear                   
-LE297: and #gr_VARIA ;Does Samus have the Varia?--> +LE297:  and #gr_VARIA                   ;Does Samus have the Varia?--> 
-LE299: beq + ;If not, branch. +LE299:  beq +                           ;If not, branch. 
-LE29B: bcc ++ ;Samus has varia. Carry set every other frame. Half damage. +LE29B:  bcc ++                          ;Samus has varia. Carry set every other frame. Half damage. 
-LE29D:* lda #$07 +LE29D:* lda #$07                        
-LE29F: sta HealthLoChange ;Samus takes lava damage. +LE29F:  sta HealthLoChange              ;Samus takes lava damage. 
-LE2A1: jsr SubtractHealth ;($CE92) +LE2A1:  jsr SubtractHealth              ;($CE92) 
-LE2A4:* ldy #$00 ;Prepare to indicate Samus is in lava. +LE2A4:* ldy #$00                        ;Prepare to indicate Samus is in lava. 
-LE2A6:* iny ;Set Samus lava status. +LE2A6:* iny                             ;Set Samus lava status. 
-LE2A7: sty SamusInLava ;+LE2A7:  sty SamusInLava                 ;
  
 SamusMoveVertically: SamusMoveVertically:
-LE2A9: jsr VertAccelerate ;($E37A)Calculate vertical acceleration. +LE2A9:  jsr VertAccelerate              ;($E37A)Calculate vertical acceleration. 
-LE2AC: lda ObjectY +LE2AC:  lda ObjectY                     
-LE2AF: sec +LE2AF:  sec                             
-LE2B0: sbc ScrollY ;Calculate Samus' screen y position. +LE2B0:  sbc ScrollY                     ;Calculate Samus' screen y position. 
-LE2B2: sta SamusScrY +LE2B2:  sta SamusScrY                   
-LE2B4: lda $00 ;Load temp copy of vertical speed. +LE2B4:  lda $00                         ;Load temp copy of vertical speed. 
-LE2B6: bpl ++++ ;If Samus is moving downwards, branch.+LE2B6:  bpl ++++                        ;If Samus is moving downwards, branch.
  
-LE2B8: jsr TwosCompliment ;($C3D4)Get twos compliment of vertical speed. +LE2B8:  jsr TwosCompliment              ;($C3D4)Get twos compliment of vertical speed. 
-LE2BB: ldy SamusInLava ;Is Samus in lava? +LE2BB:  ldy SamusInLava                 ;Is Samus in lava? 
-LE2BD: beq + ;If not, branch,--> +LE2BD:  beq +                           ;If not, branch,--> 
-LE2BF: lsr ;else cut vertical speed in half. +LE2BF:  lsr                             ;else cut vertical speed in half. 
-LE2C0: beq SamusMoveHorizontally ;($E31A)Branch if no vertical mvmnt to Check left/right mvmnt.+LE2C0:  beq SamusMoveHorizontally       ;($E31A)Branch if no vertical mvmnt to Check left/right mvmnt.
  
 ;Samus is moving upwards. ;Samus is moving upwards.
-LE2C2:* sta ObjectCounter ;Store number of pixels to move Samus this frame. +LE2C2:* sta ObjectCounter               ;Store number of pixels to move Samus this frame. 
-LE2C4:* jsr MoveSamusUp ;($E457)Attempt to move Samus up 1 pixel. +LE2C4:* jsr MoveSamusUp                 ;($E457)Attempt to move Samus up 1 pixel. 
-LE2C7: bcs + ;Branch if Samus successfully moved up 1 pixel.+LE2C7:  bcs +                           ;Branch if Samus successfully moved up 1 pixel.
  
-LE2C9: sec ;Samus blocked upwards. Divide her speed by 2 and set the +LE2C9:  sec                             ;Samus blocked upwards. Divide her speed by 2 and set the 
-LE2CA: ror ObjVertSpeed ;MSB to reverse her direction of travel. +LE2CA:  ror ObjVertSpeed                ;MSB to reverse her direction of travel. 
-LE2CD: ror VertCntrLinear +LE2CD:  ror VertCntrLinear              
-LE2D0: jmp SamusMoveHorizontally ;($E31A)Attempt to move Samus left/right.+LE2D0:  jmp SamusMoveHorizontally       ;($E31A)Attempt to move Samus left/right.
  
-LE2D3:* dec ObjectCounter ;1 pixel movement is complete. +LE2D3:* dec ObjectCounter               ;1 pixel movement is complete. 
-LE2D5: bne -- ;Branch if Samus needs to be moved another pixel.+LE2D5:  bne --                          ;Branch if Samus needs to be moved another pixel.
  
 ;Samus is moving downwards. ;Samus is moving downwards.
-LE2D7:* beq SamusMoveHorizontally ;($E31A)Branch if no vertical mvmnt to Check left/right mvmnt. +LE2D7:* beq SamusMoveHorizontally       ;($E31A)Branch if no vertical mvmnt to Check left/right mvmnt. 
-LE2D9: ldy SamusInLava ;Is Samus in lava? +LE2D9:  ldy SamusInLava                 ;Is Samus in lava? 
-LE2DB: beq + ;If not, branch,--> +LE2DB:  beq +                           ;If not, branch,--> 
-LE2DD: lsr ;Else reduce Samus speed by 75%(divide by 4). +LE2DD:  lsr                             ;Else reduce Samus speed by 75%(divide by 4). 
-LE2DE: lsr +LE2DE:  lsr                             
-LE2DF: beq SamusMoveHorizontally ;($E31A)Attempt to move Samus left/right.+LE2DF:  beq SamusMoveHorizontally       ;($E31A)Attempt to move Samus left/right.
  
-LE2E1:* sta ObjectCounter ;Store number of pixels to move Samus this frame. +LE2E1:* sta ObjectCounter               ;Store number of pixels to move Samus this frame. 
-LE2E3:* jsr MoveSamusDown ;($E4A3)Attempt to move Samus 1 pixel down. +LE2E3:* jsr MoveSamusDown               ;($E4A3)Attempt to move Samus 1 pixel down. 
-LE2E6: bcs +++ ;Branch if Samus successfully moved down 1 pixel.+LE2E6:  bcs +++                         ;Branch if Samus successfully moved down 1 pixel.
  
 ;Samus bounce after hitting the ground in ball form. ;Samus bounce after hitting the ground in ball form.
-LE2E8: lda ObjAction +LE2E8:  lda ObjAction                   
-LE2EB: cmp #sa_Roll ;Is Samus rolled into a ball?--> +LE2EB:  cmp #sa_Roll                    ;Is Samus rolled into a ball?--> 
-LE2ED: bne + ;If not, branch. +LE2ED:  bne +                           ;If not, branch. 
-LE2EF: lsr ObjVertSpeed ;Divide verticle speed by 2. +LE2EF:  lsr ObjVertSpeed                ;Divide verticle speed by 2. 
-LE2F2: beq ++ ;Speed not fast enough to bounce. branch to skip. +LE2F2:  beq ++                          ;Speed not fast enough to bounce. branch to skip. 
-LE2F4: ror VertCntrLinear ;Move carry bit into MSB to reverse Linear counter. +LE2F4:  ror VertCntrLinear              ;Move carry bit into MSB to reverse Linear counter. 
-LE2F7: lda #$00 +LE2F7:  lda #$00                        
-LE2F9: sec +LE2F9:  sec                             
-LE2FA: sbc VertCntrLinear ;Subtract linear counter from 0 and save the results.--> +LE2FA:  sbc VertCntrLinear              ;Subtract linear counter from 0 and save the results.--> 
-LE2FD: sta VertCntrLinear ;Carry will be cleared. +LE2FD:  sta VertCntrLinear              ;Carry will be cleared. 
-LE300: lda #$00 +LE300:  lda #$00                        
-LE302: sbc ObjVertSpeed ;Subtract vertical speed from 0. this will reverse the--> +LE302:  sbc ObjVertSpeed                ;Subtract vertical speed from 0. this will reverse the--> 
-LE305: sta ObjVertSpeed ;vertical direction of travel(bounce up). +LE305:  sta ObjVertSpeed                ;vertical direction of travel(bounce up). 
-LE308: jmp SamusMoveHorizontally ;($E31A)Attempt to move Samus left/right.+LE308:  jmp SamusMoveHorizontally       ;($E31A)Attempt to move Samus left/right.
  
 ;Samus has hit the ground after moving downwards.  ;Samus has hit the ground after moving downwards. 
-LE30B:* jsr SFX_SamusWalk ;($CB96)Play walk SFX. +LE30B:* jsr SFX_SamusWalk               ;($CB96)Play walk SFX. 
-LE30E:* jsr StopVertMovement ;($D147)Clear vertical movement data. +LE30E:* jsr StopVertMovement            ;($D147)Clear vertical movement data. 
-LE311: sty SamusGravity ;Clear Samus gravity value. +LE311:  sty SamusGravity                ;Clear Samus gravity value. 
-LE314: beq SamusMoveHorizontally ;($E31A)Attempt to move Samus left/right.+LE314:  beq SamusMoveHorizontally       ;($E31A)Attempt to move Samus left/right.
  
-LE316:* dec ObjectCounter ;1 pixel movement is complete. +LE316:* dec ObjectCounter               ;1 pixel movement is complete. 
-LE318: bne ---- ;Branch if Samus needs to be moved another pixel.+LE318:  bne ----                        ;Branch if Samus needs to be moved another pixel.
  
 SamusMoveHorizontally: SamusMoveHorizontally:
-LE31A:  jsr HorzAccelerate ;($E3E5)Horizontally accelerate Samus. +LE31A:  jsr HorzAccelerate              ;($E3E5)Horizontally accelerate Samus. 
-LE31D: lda ObjectX +LE31D:  lda ObjectX                     
-LE320: sec ;Calculate Samus' x position on screen. +LE320:  sec                             ;Calculate Samus' x position on screen. 
-LE321: sbc ScrollX +LE321:  sbc ScrollX                     
-LE323: sta SamusScrX ;Save Samus' x position. +LE323:  sta SamusScrX                   ;Save Samus' x position. 
-LE325: lda $00 ;Load Samus' current horizontal speed. +LE325:  lda $00                         ;Load Samus' current horizontal speed. 
-LE327: bpl +++ ;Branch if moving right.+LE327:  bpl +++                         ;Branch if moving right.
  
 ;Samus is moving left. ;Samus is moving left.
-LE329: jsr TwosCompliment ;($C3D4)Get twos compliment of horizontal speed. +LE329:  jsr TwosCompliment              ;($C3D4)Get twos compliment of horizontal speed. 
-LE32C: ldy SamusInLava ;Is Samus in lava?--> +LE32C:  ldy SamusInLava                 ;Is Samus in lava?--> 
-LE32E: beq + ;If not, branch,--> +LE32E:  beq +                           ;If not, branch,--> 
-LE330: lsr ;else cut horizontal speed in half. +LE330:  lsr                             ;else cut horizontal speed in half. 
-LE331: beq Exit10 ;Branch to exit if Samus not going to move this frame.+LE331:  beq Exit10                      ;Branch to exit if Samus not going to move this frame.
  
-LE333:* sta ObjectCounter ;Store number of pixels to move Samus this frame. +LE333:* sta ObjectCounter               ;Store number of pixels to move Samus this frame. 
-LE335:* jsr MoveSamusLeft ;($E626)Attempt to move Samus 1 pixel to the left. +LE335:* jsr MoveSamusLeft               ;($E626)Attempt to move Samus 1 pixel to the left. 
-LE338: jsr CheckStopHorzMvmt ;($E365)Check if horizontal movement needs to be stopped. +LE338:  jsr CheckStopHorzMvmt           ;($E365)Check if horizontal movement needs to be stopped. 
-LE33B: dec ObjectCounter ;1 pixel movement is complete. +LE33B:  dec ObjectCounter               ;1 pixel movement is complete. 
-LE33D: bne - ;Branch if Samus needs to be moved another pixel.+LE33D:  bne -                           ;Branch if Samus needs to be moved another pixel.
  
-LE33F: lda SamusDoorData ;Has Samus entered a door?--> +LE33F:  lda SamusDoorData               ;Has Samus entered a door?--> 
-LE341: beq Exit10 ;If not, branch to exit. +LE341:  beq Exit10                      ;If not, branch to exit. 
-LE343: lda #$01 ;Door leads to the left. +LE343:  lda #$01                        ;Door leads to the left. 
-LE345: bne ++++ ;Branch always.+LE345:  bne ++++                        ;Branch always.
  
 ;Samus is moving right. ;Samus is moving right.
-LE347:* beq Exit10 ;Branch to exit if Samus not moving horizontally. +LE347:* beq Exit10                      ;Branch to exit if Samus not moving horizontally. 
-LE349: ldy SamusInLava ;Is Samus in lava?--> +LE349:  ldy SamusInLava                 ;Is Samus in lava?--> 
-LE34B: beq + ;If not, branch,--> +LE34B:  beq +                           ;If not, branch,--> 
-LE34D: lsr ;else cut horizontal speed in half. +LE34D:  lsr                             ;else cut horizontal speed in half. 
-LE34E: beq Exit10 ;Branch to exit if Samus not going to move this frame.+LE34E:  beq Exit10                      ;Branch to exit if Samus not going to move this frame.
  
-LE350:* sta ObjectCounter ;Store number of pixels to move Samus this frame. +LE350:* sta ObjectCounter               ;Store number of pixels to move Samus this frame. 
-LE352:* jsr MoveSamusRight ;($E668)Attempt to move Samus 1 pixel to the right. +LE352:* jsr MoveSamusRight              ;($E668)Attempt to move Samus 1 pixel to the right. 
-LE355: jsr CheckStopHorzMvmt ;($E365)Check if horizontal movement needs to be stopped. +LE355:  jsr CheckStopHorzMvmt           ;($E365)Check if horizontal movement needs to be stopped. 
-LE358: dec ObjectCounter ;1 pixel movement is complete. +LE358:  dec ObjectCounter               ;1 pixel movement is complete. 
-LE35A: bne - ;Branch if Samus needs to be moved another pixel.+LE35A:  bne -                           ;Branch if Samus needs to be moved another pixel.
  
-LE35C: lda SamusDoorData ;Has Samus entered a door?--> +LE35C:  lda SamusDoorData               ;Has Samus entered a door?--> 
-LE35E: beq Exit10 ;If not, branch to exit. +LE35E:  beq Exit10                      ;If not, branch to exit. 
-LE360: lda #$00 +LE360:  lda #$00                        
-LE362:* sta SamusDoorDir ;Door leads to the right.+LE362:* sta SamusDoorDir                ;Door leads to the right.
  
 Exit10: Exit10:
-LE364: rts ;Exit for routines above and below.+LE364:  rts                             ;Exit for routines above and below.
  
 CheckStopHorzMvmt: CheckStopHorzMvmt:
-LE365:  bcs Exit10 ;Samus moved successfully. Branch to exit. +LE365:  bcs Exit10                      ;Samus moved successfully. Branch to exit. 
-LE367: lda #$01 ;Load counter with #$01 so this function will not be--> +LE367:  lda #$01                        ;Load counter with #$01 so this function will not be--> 
-LE369: sta ObjectCounter ;called again. +LE369:  sta ObjectCounter               ;called again. 
-LE36C: lda SamusGravity ;Is Samus on the ground?--> +LE36C:  lda SamusGravity                ;Is Samus on the ground?--> 
-LE36E: bne Exit10 ;If not, branch to exit. +LE36E:  bne Exit10                      ;If not, branch to exit. 
-LE370: lda ObjAction +LE370:  lda ObjAction                   
-LE373: cmp #sa_Roll ;Is Samus rolled into a ball?--> +LE373:  cmp #sa_Roll                    ;Is Samus rolled into a ball?--> 
-LE375: beq Exit10 ;If so, branch to exit. +LE375:  beq Exit10                      ;If so, branch to exit. 
-LE377: jmp StopHorzMovement ;($CF55)Stop horizontal movement or play walk SFX if stopped.+LE377:  jmp StopHorzMovement            ;($CF55)Stop horizontal movement or play walk SFX if stopped.
  
 ;-------------------------------------[ Samus vertical acceleration ]-------------------------------- ;-------------------------------------[ Samus vertical acceleration ]--------------------------------
Line 5559: Line 5559:
  
 VertAccelerate: VertAccelerate:
-LE37A:  lda SamusGravity ;Is Samus rising or falling?--> +LE37A:  lda SamusGravity                ;Is Samus rising or falling?--> 
-LE37D: bne ++ ;Branch if yes. +LE37D:  bne ++                          ;Branch if yes. 
-LE37F: lda #$18 +LE37F:  lda #$18                        
-LE381: sta SamusHorzSpeedMax ;Set Samus maximum running speed. +LE381:  sta SamusHorzSpeedMax           ;Set Samus maximum running speed. 
-LE384: lda ObjectY +LE384:  lda ObjectY                     
-LE387: clc +LE387:  clc                             
-LE388: adc ObjRadY ;Check is Samus is obstructed downwards on y room--> +LE388:  adc ObjRadY                     ;Check is Samus is obstructed downwards on y room--> 
-LE38B: and #$07 ;positions divisible by 8(every 8th pixel). +LE38B:  and #$07                        ;positions divisible by 8(every 8th pixel). 
-LE38D: bne + +LE38D:  bne +                           
-LE38F: jsr CheckMoveDown ;($E7AD)Is Samus obstructed downwards?--> +LE38F:  jsr CheckMoveDown               ;($E7AD)Is Samus obstructed downwards?--> 
-LE392: bcc ++ ;Branch if yes. +LE392:  bcc ++                          ;Branch if yes. 
-LE394:* jsr SamusOnElevatorOrEnemy ;($D976)Calculate if Samus standing on elevator or enemy. +LE394:* jsr SamusOnElevatorOrEnemy      ;($D976)Calculate if Samus standing on elevator or enemy. 
-LE397: lda SamusOnElevator ;Is Samus on an elevator?--> +LE397:  lda SamusOnElevator             ;Is Samus on an elevator?--> 
-LE39A: bne + ;Branch if yes. +LE39A:  bne +                           ;Branch if yes. 
-LE39C: lda OnFrozenEnemy ;Is Samus standing on a frozen enemy?--> +LE39C:  lda OnFrozenEnemy               ;Is Samus standing on a frozen enemy?--> 
-LE39E: bne + ;Branch if yes. +LE39E:  bne +                           ;Branch if yes. 
-LE3A0: lda #$1A ;Samus is falling. Store falling gravity value. +LE3A0:  lda #$1A                        ;Samus is falling. Store falling gravity value. 
-LE3A2: sta SamusGravity ;+LE3A2:  sta SamusGravity                ;
  
-LE3A5:* ldx #$05 ;Load X with maximum downward speed. +LE3A5:* ldx #$05                        ;Load X with maximum downward speed. 
-LE3A7: lda VertCntrLinear +LE3A7:  lda VertCntrLinear              
-LE3AA: clc ;The higher the gravity, the faster this addition overflows--> +LE3AA:  clc                             ;The higher the gravity, the faster this addition overflows--> 
-LE3AB: adc SamusGravity ;and the faster ObjVertSpeed is incremented. +LE3AB:  adc SamusGravity                ;and the faster ObjVertSpeed is incremented. 
-LE3AE: sta VertCntrLinear +LE3AE:  sta VertCntrLinear              
-LE3B1: lda ObjVertSpeed ;Every time above addition sets carry bit, ObjVertSpeed is--> +LE3B1:  lda ObjVertSpeed                ;Every time above addition sets carry bit, ObjVertSpeed is--> 
-LE3B4: adc #$00 ;incremented. This has the effect of speeding up a fall--> +LE3B4:  adc #$00                        ;incremented. This has the effect of speeding up a fall--> 
-LE3B6: sta ObjVertSpeed ;and slowing down a jump. +LE3B6:  sta ObjVertSpeed                ;and slowing down a jump. 
-LE3B9: bpl + ;Branch if Samus is moving downwards.+LE3B9:  bpl +                           ;Branch if Samus is moving downwards.
  
 ;Check if maximum upward speed has been exceeded. If so, prepare to set maximum speed. ;Check if maximum upward speed has been exceeded. If so, prepare to set maximum speed.
-LE3BB: lda #$00 +LE3BB:  lda #$00                        
-LE3BD: cmp VertCntrLinear ;Sets carry bit. +LE3BD:  cmp VertCntrLinear              ;Sets carry bit. 
-LE3C0: sbc ObjVertSpeed ;Subtract ObjVertSpeed to see if maximum speed has--> +LE3C0:  sbc ObjVertSpeed                ;Subtract ObjVertSpeed to see if maximum speed has--> 
-LE3C3: cmp #$06 ;been exceeded. +LE3C3:  cmp #$06                        ;been exceeded. 
-LE3C5: ldx #$FA ;Load X with maximum upward speed. +LE3C5:  ldx #$FA                        ;Load X with maximum upward speed. 
-LE3C7: bne ++ ;Branch always.+LE3C7:  bne ++                          ;Branch always.
  
 ;Check if maximum downward speed has been reached. If so, prepare to set maximum speed. ;Check if maximum downward speed has been reached. If so, prepare to set maximum speed.
-LE3C9:* cmp #$05 ;Has maximum downward speed been reached?--> +LE3C9:* cmp #$05                        ;Has maximum downward speed been reached?--> 
-LE3CB:* bcc + ;If not, branch.+LE3CB:* bcc +                           ;If not, branch.
  
 ;Max verticle speed reached or exceeded. Adjust Samus verticle speed to max. ;Max verticle speed reached or exceeded. Adjust Samus verticle speed to max.
-LE3CD: jsr StopVertMovement ;($D147)Clear verticle movement data. +LE3CD:  jsr StopVertMovement            ;($D147)Clear verticle movement data. 
-LE3D0: stx ObjVertSpeed ;Set Samus vertical speed to max.+LE3D0:  stx ObjVertSpeed                ;Set Samus vertical speed to max.
  
 ;This portion of the function creates an exponential increase/decrease in verticle speed. This is the ;This portion of the function creates an exponential increase/decrease in verticle speed. This is the
 ;part of the function that does all the work to make Samus' jump seem natural. ;part of the function that does all the work to make Samus' jump seem natural.
-LE3D3:* lda VertCntrNonLinear +LE3D3:* lda VertCntrNonLinear           
-LE3D6: clc ;This function adds itself plus the linear verticle counter--> +LE3D6:  clc                             ;This function adds itself plus the linear verticle counter--> 
-LE3D7: adc VertCntrLinear ;onto itself every frame.  This causes the non-linear--> +LE3D7:  adc VertCntrLinear              ;onto itself every frame.  This causes the non-linear--> 
-LE3DA: sta VertCntrNonLinear ;counter to increase exponentially.  This function will--> +LE3DA:  sta VertCntrNonLinear           ;counter to increase exponentially.  This function will--> 
-LE3DD: lda #$00 ;cause Samus to reach maximum speed first in most--> +LE3DD:  lda #$00                        ;cause Samus to reach maximum speed first in most--> 
-LE3DF: adc ObjVertSpeed ;situations before the linear counter. +LE3DF:  adc ObjVertSpeed                ;situations before the linear counter. 
-LE3E2: sta $00 ;$00 stores temp copy of current verticle speed. +LE3E2:  sta $00                         ;$00 stores temp copy of current verticle speed. 
-LE3E4: rts ;+LE3E4:  rts                             ;
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 5619: Line 5619:
 HorzAccelerate: HorzAccelerate:
 LE3E5:  lda SamusHorzSpeedMax LE3E5:  lda SamusHorzSpeedMax
- jsr Amul16       ; * 16 +        jsr Amul16       ; * 16 
- sta $00 +        sta $00 
- sta $02 +        sta $02 
- lda SamusHorzSpeedMax +        lda SamusHorzSpeedMax 
- jsr Adiv16       ; / 16 +        jsr Adiv16       ; / 16 
- sta $01 +        sta $01 
- sta $03+        sta $03
  
- lda HorzCntrLinear +        lda HorzCntrLinear 
- clc +        clc 
- adc SamusHorzAccel +        adc SamusHorzAccel 
- sta HorzCntrLinear +        sta HorzCntrLinear 
- tax +        tax 
- lda #$00 +        lda #$00 
- bit SamusHorzAccel +        bit SamusHorzAccel 
- bpl + ;Branch if Samus accelerating to the right.+        bpl +                           ;Branch if Samus accelerating to the right.
  
- lda #$FF+        lda #$FF
  
 *       adc ObjHorzSpeed *       adc ObjHorzSpeed
- sta ObjHorzSpeed +        sta ObjHorzSpeed 
- tay +        tay 
- bpl + ;Branch if Samus accelerating to the right.+        bpl +                           ;Branch if Samus accelerating to the right.
  
- lda #$00 +        lda #$00 
- sec +        sec 
- sbc HorzCntrLinear +        sbc HorzCntrLinear 
- tax +        tax 
- lda #$00 +        lda #$00 
- sbc ObjHorzSpeed +        sbc ObjHorzSpeed 
- tay +        tay 
- jsr LE449+        jsr LE449
  
 *       cpx $02 *       cpx $02
- tya +        tya 
- sbc $03 +        sbc $03 
- bcc + +        bcc + 
- lda $00 +        lda $00 
- sta HorzCntrLinear +        sta HorzCntrLinear 
- lda $01 +        lda $01 
- sta ObjHorzSpeed+        sta ObjHorzSpeed
 *       lda HorzCntrNonLinear *       lda HorzCntrNonLinear
- clc +        clc 
- adc HorzCntrLinear +        adc HorzCntrLinear 
- sta HorzCntrNonLinear +        sta HorzCntrNonLinear 
- lda #$00 +        lda #$00 
- adc ObjHorzSpeed +        adc ObjHorzSpeed 
- sta $00 ;$00 stores temp copy of current horizontal speed. +        sta $00                         ;$00 stores temp copy of current horizontal speed. 
- rts ;+        rts                             ;
  
 LE449:  lda #$00 LE449:  lda #$00
- sec +        sec 
- sbc $00 +        sbc $00 
- sta $00 +        sta $00 
- lda #$00 +        lda #$00 
- sbc $01 +        sbc $01 
- sta $01 +        sta $01 
- rts+        rts
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 5683: Line 5683:
  
 MoveSamusUp: MoveSamusUp:
-LE457: lda ObjectY ;Get Samus' y position in room. +LE457:  lda ObjectY                     ;Get Samus' y position in room. 
- sec +        sec                             
- sbc ObjRadY ;Subtract Samus' vertical radius. +        sbc ObjRadY                     ;Subtract Samus' vertical radius. 
-LE45E: and #$07 ;Check if result is a multiple of 8. If so, branch to--> +LE45E:  and #$07                        ;Check if result is a multiple of 8. If so, branch to--> 
-LE460: bne + ;Only call crash detection every 8th pixel. +LE460:  bne +                           ;Only call crash detection every 8th pixel. 
-LE462: jsr CheckMoveUp ;($E7A2)Check if Samus obstructed UPWARDS.--> +LE462:  jsr CheckMoveUp                 ;($E7A2)Check if Samus obstructed UPWARDS.--> 
- bcc +++++++ ;If so, branch to exit(can't move any further). +        bcc +++++++                     ;If so, branch to exit(can't move any further). 
-*       lda ObjAction +*       lda ObjAction                   
- cmp #sa_Elevator ;Is Samus riding elevator?--> +        cmp #sa_Elevator                ;Is Samus riding elevator?--> 
- beq + ;If so, branch. +        beq +                           ;If so, branch. 
- jsr SamusOnElevatorOrEnemy ;($D976)Calculate if Samus standing on elevator or enemy. +        jsr SamusOnElevatorOrEnemy      ;($D976)Calculate if Samus standing on elevator or enemy. 
- lda SamusHit +        lda SamusHit 
- and #$42 +        and #$42 
- cmp #$42 +        cmp #$42 
- clc +        clc 
- beq +++++++        beq ++++++
 *       lda SamusScrY *       lda SamusScrY
- cmp #$66 ; reached up scroll limit? +        cmp #$66        ; reached up scroll limit? 
- bcs +    ; branch if not +        bcs +      ; branch if not 
- jsr ScrollUp +        jsr ScrollUp 
- bcc +++        bcc ++
 *       dec SamusScrY *       dec SamusScrY
-* lda ObjectY +      lda ObjectY 
- bne ++ +        bne ++ 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne + +        bne + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord+        jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord
 *       lda #240 *       lda #240
- sta ObjectY +        sta ObjectY 
-* dec ObjectY +      dec ObjectY 
- inc SamusJumpDsplcmnt +        inc SamusJumpDsplcmnt 
- sec +        sec 
-* rts+      rts
  
 ; attempt to move Samus one pixel down ; attempt to move Samus one pixel down
  
 MoveSamusDown: MoveSamusDown:
- lda ObjectY +        lda ObjectY 
- clc +        clc 
- adc ObjRadY +        adc ObjRadY 
- and #$07 +        and #$07 
- bne +    ; only call crash detection every 8th pixel +        bne +              ; only call crash detection every 8th pixel 
- jsr CheckMoveDown       ; check if Samus obstructed DOWNWARDS +        jsr CheckMoveDown       ; check if Samus obstructed DOWNWARDS 
- bcc +++++++  ; exit if yes+        bcc +++++++      ; exit if yes
 *       lda ObjAction *       lda ObjAction
- cmp #sa_Elevator ; is Samus in elevator? +        cmp #sa_Elevator        ; is Samus in elevator? 
- beq + +        beq + 
- jsr LD976 +        jsr LD976 
- lda SamusOnElevator +        lda SamusOnElevator 
- clc +        clc 
- bne ++++++ +        bne ++++++ 
- lda OnFrozenEnemy +        lda OnFrozenEnemy 
- bne +++++++        bne ++++++
 *       lda SamusScrY *       lda SamusScrY
- cmp #$84 ; reached down scroll limit? +        cmp #$84        ; reached down scroll limit? 
- bcc +    ; branch if not +        bcc +      ; branch if not 
- jsr ScrollDown +        jsr ScrollDown 
- bcc +++        bcc ++
 *       inc SamusScrY *       inc SamusScrY
-* lda ObjectY +      lda ObjectY 
- cmp #239 +        cmp #239 
- bne ++ +        bne ++ 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne + +        bne + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord+        jsr ToggleSamusHi       ; toggle 9th bit of Samus' Y coord
 *       lda #$FF *       lda #$FF
- sta ObjectY +        sta ObjectY 
-* inc ObjectY +      inc ObjectY 
- dec SamusJumpDsplcmnt +        dec SamusJumpDsplcmnt 
- sec +        sec 
-* rts+      rts
  
 ; Attempt to scroll UP ; Attempt to scroll UP
  
- ScrollUp: +        ScrollUp: 
- lda ScrollDir +        lda ScrollDir 
- beq + +        beq + 
- cmp #$01 +        cmp #$01 
- bne ++++ +        bne ++++ 
- dec ScrollDir +        dec ScrollDir 
- lda ScrollY +        lda ScrollY 
- beq + +        beq + 
- dec MapPosY+        dec MapPosY
 *       ldx ScrollY *       ldx ScrollY
- bne + +        bne + 
- dec MapPosY     ; decrement MapY +        dec MapPosY     ; decrement MapY 
- jsr GetRoomNum  ; put room # at current map pos in $5A +        jsr GetRoomNum  ; put room # at current map pos in $5A 
- bcs ++   ; if function returns CF = 1, moving up is not possible +        bcs ++   ; if function returns CF = 1, moving up is not possible 
- jsr LE9B7       ; switch to the opposite Name Table +        jsr LE9B7       ; switch to the opposite Name Table 
- ldx #240 ; new Y coord +        ldx #240        ; new Y coord 
-* dex +      dex 
- jmp LE53F+        jmp LE53F
  
-* inc MapPosY +      inc MapPosY 
-* sec +      sec 
- rts+        rts
  
 ; Attempt to scroll DOWN ; Attempt to scroll DOWN
  
- ScrollDown: +        ScrollDown: 
- ldx ScrollDir +        ldx ScrollDir 
- dex +        dex 
- beq + +        beq + 
- bpl +++++ +        bpl +++++ 
- inc ScrollDir +        inc ScrollDir 
- lda ScrollY +        lda ScrollY 
- beq + +        beq + 
- inc MapPosY+        inc MapPosY
 *       lda ScrollY *       lda ScrollY
- bne + +        bne + 
- inc MapPosY     ; increment MapY +        inc MapPosY     ; increment MapY 
- jsr GetRoomNum  ; put room # at current map pos in $5A +        jsr GetRoomNum  ; put room # at current map pos in $5A 
- bcs +++   ; if function returns CF = 1, moving down is not possible+        bcs +++   ; if function returns CF = 1, moving down is not possible
 *       ldx ScrollY *       ldx ScrollY
- cpx #239 +        cpx #239 
- bne + +        bne + 
- jsr LE9B7       ; switch to the opposite Name Table +        jsr LE9B7       ; switch to the opposite Name Table 
- ldx #$FF+        ldx #$FF
 *       inx *       inx
 LE53F:  stx ScrollY LE53F:  stx ScrollY
- jsr LE54A       ; check if it's time to update Name Table +        jsr LE54A       ; check if it's time to update Name Table 
- clc +        clc 
- rts+        rts
  
-* dec MapPosY +      dec MapPosY 
-* sec+      sec
 *       rts *       rts
  
 LE54A:  jsr SetupRoom LE54A:  jsr SetupRoom
- ldx RoomNumber +        ldx RoomNumber 
- inx +        inx 
- bne - +        bne - 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne + +        bne + 
- jmp LE571+        jmp LE571
 *       jmp LE701 *       jmp LE701
  
Line 5826: Line 5826:
  
 Table11: Table11:
- .byte $07 +        .byte $07 
- .byte $00+        .byte $00
  
 ;---------------------------------[ Get PPU and RoomRAM addresses ]---------------------------------- ;---------------------------------[ Get PPU and RoomRAM addresses ]----------------------------------
  
 PPUAddrs: PPUAddrs:
-LE560: .byte $20 ;High byte of nametable #0(PPU). +LE560:  .byte $20                       ;High byte of nametable #0(PPU). 
-LE561: .byte $2C ;High byte of nametable #3(PPU)+LE561:  .byte $2C                       ;High byte of nametable #3(PPU)
  
 WRAMAddrs: WRAMAddrs:
-LE562: .byte $60 ;High byte of RoomRAMA(cart RAM). +LE562:  .byte $60                       ;High byte of RoomRAMA(cart RAM). 
-LE563: .byte $64 ;High byte of RoomRAMB(cart RAM).+LE563:  .byte $64                       ;High byte of RoomRAMB(cart RAM).
  
 GetNameAddrs: GetNameAddrs:
-LE564: jsr GetNameTable ;($EB85)Get current name table number. +LE564:  jsr GetNameTable                ;($EB85)Get current name table number. 
-LE567: and #$01 ;Update name table 0 or 3. +LE567:  and #$01                        ;Update name table 0 or 3. 
-LE569: tay +LE569:  tay                             
-LE56A: lda PPUAddrs,y ;Get high PPU addr of nametable(dest). +LE56A:  lda PPUAddrs,                 ;Get high PPU addr of nametable(dest). 
-LE56D: ldx WRAMAddrs,y ;Get high cart RAM addr of nametable(src). +LE56D:  ldx WRAMAddrs,                ;Get high cart RAM addr of nametable(src). 
-LE570: rts ;+LE570:  rts                             ;
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 5852: Line 5852:
  
 LE571:  ldx ScrollDir LE571:  ldx ScrollDir
- lda ScrollY +        lda ScrollY 
- and #$07 ; compare value = 0 if ScrollDir = down, else 7 +        and #$07        ; compare value = 0 if ScrollDir = down, else 7 
- cmp Table11,x +        cmp Table11,x 
- bne --    ; exit if not equal (no nametable update)+        bne --     ; exit if not equal (no nametable update)
  
-LE57C:  ldx ScrollDir +LE57C:  ldx ScrollDir                   
- cpx TempScrollDir ;Still scrolling same direction when room was loaded?--> +        cpx TempScrollDir               ;Still scrolling same direction when room was loaded?--> 
- bne -- ;If not, branch to exit. +        bne --                          ;If not, branch to exit. 
- lda ScrollY +        lda ScrollY 
- and #$F8 ; keep upper 5 bits +        and #$F8        ; keep upper 5 bits 
- sta $00 +        sta $00 
- lda #$00 +        lda #$00 
- asl $00 +        asl $00 
- rol +        rol 
- asl $00 +        asl $00 
- rol+        rol
  
-LE590:  sta $01 ; $0001 = (ScrollY & 0xF8) << 2 = row offset +LE590:  sta $01  ; $0001 = (ScrollY & 0xF8) << 2 = row offset 
- jsr GetNameAddrs +        jsr GetNameAddrs 
- ora $01 +        ora $01 
- sta $03 +        sta $03 
- txa +        txa 
- ora $01 +        ora $01 
- sta $01 +        sta $01 
- lda $00 +        lda $00 
- sta $02 +        sta $02 
- lda ScrollDir +        lda ScrollDir 
- lsr ; A = 0 if vertical scrolling, 1 if horizontal +        lsr             ; A = 0 if vertical scrolling, 1 if horizontal 
- tax +        tax 
- lda Table01,x +        lda Table01,x 
- sta $04 +        sta $04 
- ldy #$01 +        ldy #$01 
- sty PPUDataPending      ; data pending = YES +        sty PPUDataPending      ; data pending = YES 
- dey +        dey 
- ldx PPUStrIndex +        ldx PPUStrIndex 
- lda $03 +        lda $03 
- jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +        jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
- lda $02 +        lda $02 
- jsr WritePPUByte +        jsr WritePPUByte 
- lda $04 +        lda $04 
- jsr SeparateControlBits ;($C3C6)+        jsr SeparateControlBits         ;($C3C6)
 *       lda ($00),y *       lda ($00),y
- jsr WritePPUByte +        jsr WritePPUByte 
- sty $06 +        sty $06 
- ldy #$01 ; WRAM pointer increment = 1... +        ldy #$01        ; WRAM pointer increment = 1... 
- bit $04 ; ... if bit 7 (PPU inc) of $04 clear +        bit $04  ; ... if bit 7 (PPU inc) of $04 clear 
- bpl + +        bpl + 
- ldy #$20 ; else ptr inc = 32 +        ldy #$20        ; else ptr inc = 32 
-*       jsr AddYToPtr00 ;($C2A8) +*       jsr AddYToPtr00                 ;($C2A8) 
- ldy $06 +        ldy $06 
- dec $05 +        dec $05 
- bne -- +        bne -- 
- stx PPUStrIndex +        stx PPUStrIndex 
- jsr EndPPUString+        jsr EndPPUString
  
 Table01: Table01:
- .byte $20 ;Horizontal write. PPU inc = 1, length = 32 tiles. +        .byte $20                       ;Horizontal write. PPU inc = 1, length = 32 tiles. 
- .byte $9E ;Vertical write... PPU inc = 32, length = 30 tiles.+        .byte $9E                       ;Vertical write... PPU inc = 32, length = 30 tiles.
  
 ;---------------------------------[Write PPU attribute table data ]---------------------------------- ;---------------------------------[Write PPU attribute table data ]----------------------------------
  
 WritePPUAttribTbl: WritePPUAttribTbl:
-LE5E2:  ldx #$C0 ;Low byte of First row of attribute table. +LE5E2:  ldx #$C0                        ;Low byte of First row of attribute table. 
-LE5E4: lda RoomNumber +LE5E4:  lda RoomNumber                  
-LE5E6: cmp #$F2 ;Is this the second pass through the routine?--> +LE5E6:  cmp #$F2                        ;Is this the second pass through the routine?--> 
-LE5E8: beq + ;If so, branch. +LE5E8:  beq +                           ;If so, branch. 
-LE5EA: ldx #$E0 ;Low byte of second row of attribute table. +LE5EA:  ldx #$E0                        ;Low byte of second row of attribute table. 
-LE5EC:* stx $00 ;$0000=RoomRAM atrrib table starting address. +LE5EC:* stx $00                         ;$0000=RoomRAM atrrib table starting address. 
-LE5EE: stx $02 ;$0002=PPU attrib table starting address. +LE5EE:  stx $02                         ;$0002=PPU attrib table starting address. 
-LE5F0: jsr GetNameAddrs ;($E564)Get name table addr and corresponding RoomRAM addr. +LE5F0:  jsr GetNameAddrs                ;($E564)Get name table addr and corresponding RoomRAM addr. 
-LE5F3: ora #$03 ;#$23 for attrib table 0, #$2F for attrib table 3. +LE5F3:  ora #$03                        ;#$23 for attrib table 0, #$2F for attrib table 3. 
-LE5F5: sta $03 ;Store results. +LE5F5:  sta $03                         ;Store results. 
-LE5F7: txa ;move high byte of RoomRAM to A. +LE5F7:  txa                             ;move high byte of RoomRAM to A. 
-LE5F8: ora #$03 ;#$63 for RoomRAMA, #$67 for RoomRAMB(Attrib tables). +LE5F8:  ora #$03                        ;#$63 for RoomRAMA, #$67 for RoomRAMB(Attrib tables). 
-LE5FA: sta $01 ;Store results. +LE5FA:  sta $01                         ;Store results. 
-LE5FC: lda #$01 +LE5FC:  lda #$01                        
-LE5FE: sta PPUDataPending ;Data pending = YES. +LE5FE:  sta PPUDataPending              ;Data pending = YES. 
-LE600: ldx PPUStrIndex ;Load current index into PPU strng to append data. +LE600:  ldx PPUStrIndex                 ;Load current index into PPU strng to append data. 
-LE603: lda $03 ;Store high byte of starting address(attrib table). +LE603:  lda $03                         ;Store high byte of starting address(attrib table). 
-LE605: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +LE605:  jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
-LE608: lda $02 ;Store low byte of starting address(attrib table). +LE608:  lda $02                         ;Store low byte of starting address(attrib table). 
-LE60A: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +LE60A:  jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
-LE60D: lda #$20 ;Length of data to write(1 row of attrib data). +LE60D:  lda #$20                        ;Length of data to write(1 row of attrib data). 
-LE60F: sta $04 +LE60F:  sta $04                         
-LE611: jsr WritePPUByte ;($C36B)Write control byte. Horizontal write. +LE611:  jsr WritePPUByte                ;($C36B)Write control byte. Horizontal write. 
-LE614: ldy #$00 ;Reset index into data string. +LE614:  ldy #$00                        ;Reset index into data string. 
-LE616:* lda ($00),y ;Get data byte. +LE616:* lda ($00),                    ;Get data byte. 
-LE618: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. +LE618:  jsr WritePPUByte                ;($C36B)Put data byte into PPUDataString. 
-LE61B: iny ;Increment to next attrib data byte. +LE61B:  iny                             ;Increment to next attrib data byte. 
-LE61C: dec $04 +LE61C:  dec $04                         
-LE61E: bne - ;Loop until all attrib data loaded into PPU. +LE61E:  bne -                           ;Loop until all attrib data loaded into PPU. 
-LE620: stx PPUStrIndex ;Store updated PPU string index. +LE620:  stx PPUStrIndex                 ;Store updated PPU string index. 
-LE623: jsr EndPPUString ;($C376)Append end marker(#$00) and exit writing routines.+LE623:  jsr EndPPUString                ;($C376)Append end marker(#$00) and exit writing routines.
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 5951: Line 5951:
  
 MoveSamusLeft: MoveSamusLeft:
-LE626: lda ObjectX +LE626:  lda ObjectX 
- sec +        sec 
- sbc ObjRadX +        sbc ObjRadX 
- and #$07 +        and #$07 
- bne +    ; only call crash detection every 8th pixel +        bne +              ; only call crash detection every 8th pixel 
- jsr CheckMoveLeft       ; check if player is obstructed to the LEFT +        jsr CheckMoveLeft       ; check if player is obstructed to the LEFT 
- bcc +++++  ; branch if yes! (CF = 0)+        bcc +++++        ; branch if yes! (CF = 0)
 *       jsr LD976 *       jsr LD976
- lda SamusHit +        lda SamusHit 
- and #$41 +        and #$41 
- cmp #$41 +        cmp #$41 
- clc +        clc 
- beq ++++ +        beq ++++ 
- lda SamusScrX +        lda SamusScrX 
- cmp #$71 ; reached left scroll limit? +        cmp #$71        ; reached left scroll limit? 
- bcs +    ; branch if not +        bcs +      ; branch if not 
- jsr ScrollLeft +        jsr ScrollLeft 
- bcc +++        bcc ++
 *       dec SamusScrX *       dec SamusScrX
-* lda ObjectX +      lda ObjectX 
- bne + +        bne + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- beq + +        beq + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord+        jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord
 *       dec ObjectX *       dec ObjectX
- sec +        sec 
- rts+        rts
  
 ; crash with object on the left ; crash with object on the left
  
-* lda #$00 +      lda #$00 
- sta SamusDoorData +        sta SamusDoorData 
- rts+        rts
  
 ; attempt to move Samus one pixel right ; attempt to move Samus one pixel right
  
 MoveSamusRight: MoveSamusRight:
- lda ObjectX +        lda ObjectX 
- clc +        clc 
- adc ObjRadX +        adc ObjRadX 
- and #$07 +        and #$07 
- bne +    ; only call crash detection every 8th pixel +        bne +              ; only call crash detection every 8th pixel 
- jsr CheckMoveRight      ; check if Samus is obstructed to the RIGHT +        jsr CheckMoveRight      ; check if Samus is obstructed to the RIGHT 
- bcc +++++       ; branch if yes! (CF = 0)+        bcc +++++       ; branch if yes! (CF = 0)
 *       jsr LD976 *       jsr LD976
- lda SamusHit +        lda SamusHit 
- and #$41 +        and #$41 
- cmp #$40 +        cmp #$40 
- clc +        clc 
- beq ++++ +        beq ++++ 
- lda SamusScrX +        lda SamusScrX 
- cmp #$8F ; reached right scroll limit? +        cmp #$8F        ; reached right scroll limit? 
- bcc +    ; branch if not +        bcc +      ; branch if not 
- jsr ScrollRight +        jsr ScrollRight 
- bcc +++        bcc ++
 *       inc SamusScrX *       inc SamusScrX
-* inc ObjectX      ; go right, Samus! +      inc ObjectX      ; go right, Samus! 
- bne + +        bne + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- beq + +        beq + 
- jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord+        jsr ToggleSamusHi       ; toggle 9th bit of Samus' X coord
 *       sec *       sec
- rts+        rts
  
 ; crash with object on the right ; crash with object on the right
  
-* lda #$00 +      lda #$00 
- sta SamusDoorData +        sta SamusDoorData 
- rts+        rts
  
 ; Attempt to scroll LEFT ; Attempt to scroll LEFT
  
- ScrollLeft: +        ScrollLeft: 
- lda ScrollDir +        lda ScrollDir 
- cmp #$02 +        cmp #$02 
- beq + +        beq + 
- cmp #$03 +        cmp #$03 
- bne ++++ +        bne ++++ 
- dec ScrollDir +        dec ScrollDir 
- lda ScrollX +        lda ScrollX 
- beq + +        beq + 
- dec MapPosX+        dec MapPosX
 *       lda ScrollX *       lda ScrollX
- bne + +        bne + 
- dec MapPosX     ; decrement MapX +        dec MapPosX     ; decrement MapX 
- jsr GetRoomNum  ; put room # at current map pos in $5A +        jsr GetRoomNum  ; put room # at current map pos in $5A 
- bcs ++  ; if function returns CF=1, scrolling left is not possible +        bcs ++  ; if function returns CF=1, scrolling left is not possible 
- jsr LE9B7       ; switch to the opposite Name Table+        jsr LE9B7       ; switch to the opposite Name Table
 *       dec ScrollX *       dec ScrollX
- jsr LE54A       ; check if it's time to update Name Table +        jsr LE54A       ; check if it's time to update Name Table 
- clc +        clc 
- rts+        rts
  
-* inc MapPosX +      inc MapPosX 
-* sec +      sec 
- rts+        rts
  
 ; Attempt to scroll RIGHT ; Attempt to scroll RIGHT
  
 ScrollRight: ScrollRight:
- lda ScrollDir +        lda ScrollDir 
- cmp #$03 +        cmp #$03 
- beq + +        beq + 
- cmp #$02 +        cmp #$02 
- bne +++++ +        bne +++++ 
- inc ScrollDir +        inc ScrollDir 
- lda ScrollX +        lda ScrollX 
- beq + +        beq + 
- inc MapPosX+        inc MapPosX
 *       lda ScrollX *       lda ScrollX
- bne + +        bne + 
- inc MapPosX +        inc MapPosX 
- jsr GetRoomNum  ; put room # at current map pos in $5A +        jsr GetRoomNum  ; put room # at current map pos in $5A 
- bcs +++   ; if function returns CF=1, scrolling right is not possible+        bcs +++   ; if function returns CF=1, scrolling right is not possible
 *       inc ScrollX *       inc ScrollX
- bne + +        bne + 
- jsr LE9B7       ; switch to the opposite Name Table+        jsr LE9B7       ; switch to the opposite Name Table
 *       jsr LE54A       ; check if it's time to update Name Table *       jsr LE54A       ; check if it's time to update Name Table
- clc +        clc 
- rts+        rts
  
-* dec MapPosX +      dec MapPosX 
-* sec+      sec
 *       rts *       rts
  
 Table02: Table02:
- .byte $07,$00+        .byte $07,$00
  
 ; check if it's time to update nametable (when scrolling is HORIZONTAL) ; check if it's time to update nametable (when scrolling is HORIZONTAL)
  
 LE701:  ldx ScrollDir LE701:  ldx ScrollDir
- lda ScrollX +        lda ScrollX 
- and #$07 ; keep lower 3 bits +        and #$07        ; keep lower 3 bits 
- cmp Table02-2,x ; compare value = 0 if ScrollDir = right, else 7 +        cmp Table02-2,x ; compare value = 0 if ScrollDir = right, else 7 
- bne -    ; exit if not equal (no nametable update)+        bne -      ; exit if not equal (no nametable update)
  
 LE70C:  ldx ScrollDir LE70C:  ldx ScrollDir
- cpx TempScrollDir +        cpx TempScrollDir 
- bne - +        bne - 
- lda ScrollX +        lda ScrollX 
- and #$F8 ; keep upper five bits +        and #$F8        ; keep upper five bits 
- jsr Adiv8       ; / 8 (make 'em lower five) +        jsr Adiv8       ; / 8 (make 'em lower five) 
- sta $00 +        sta $00 
- lda #$00 +        lda #$00 
- jmp LE590+        jmp LE590
  
 ;---------------------------------------[ Get room number ]------------------------------------------- ;---------------------------------------[ Get room number ]-------------------------------------------
Line 6105: Line 6105:
  
 GetRoomNum: GetRoomNum:
-LE720: lda ScrollDir +LE720:  lda ScrollDir                   
-LE722: lsr ;Branch if scrolling vertical. +LE722:  lsr                             ;Branch if scrolling vertical. 
-LE723: beq + ;+LE723:  beq +                           ;
  
-LE725: rol ;Restore value of a +LE725:  rol                             ;Restore value of a 
-LE726: adc #$FF ;A=#$01 if scrolling left, A=#$02 if scrolling right. +LE726:  adc #$FF                        ;A=#$01 if scrolling left, A=#$02 if scrolling right. 
-LE728: pha ;Save A. +LE728:  pha                             ;Save A. 
-LE729: jsr OnNameTable0 ;($EC93)Y=1 if name table=0, Y=0 if name table=3. +LE729:  jsr OnNameTable0                ;($EC93)Y=1 if name table=0, Y=0 if name table=3. 
-LE72C: pla ;Restore A. +LE72C:  pla                             ;Restore A. 
-LE72D: and $006C,y +LE72D:  and $006C,                    
-LE730: sec +LE730:  sec                             
-LE731: bne +++++ ;Can't load room, a door is in the way. This has the--> +LE731:  bne +++++                       ;Can't load room, a door is in the way. This has the--> 
- ;effect of stopping the scrolling until Samus walks--> +                                        ;effect of stopping the scrolling until Samus walks--> 
- ;through the door(horizontal scrolling only).+                                        ;through the door(horizontal scrolling only).
  
-LE733:* lda MapPosY ;Map pos y. +LE733:* lda MapPosY                     ;Map pos y. 
-LE735: jsr Amul16 ;($C2C5)Multiply by 16. +LE735:  jsr Amul16                      ;($C2C5)Multiply by 16. 
-LE738: sta $00 ;Store multiplied value in $00. +LE738:  sta $00                         ;Store multiplied value in $00. 
-LE73A: lda #$00 +LE73A:  lda #$00                        
-LE73C: rol ;Save carry, if any. +LE73C:  rol                             ;Save carry, if any. 
-LE73D: rol $00 ;Multiply value in $00 by 2. +LE73D:  rol $00                         ;Multiply value in $00 by 2. 
-LE73F: rol ;Save carry, if any. +LE73F:  rol                             ;Save carry, if any. 
-LE740: sta $01 +LE740:  sta $01                         
-LE742: lda $00 +LE742:  lda $00                         
-LE744: adc MapPosX ;Add map pos X to A. +LE744:  adc MapPosX                     ;Add map pos X to A. 
-LE746: sta $00 ;Store result. +LE746:  sta $00                         ;Store result. 
-LE748: lda $01 +LE748:  lda $01                         
-LE74A: adc #$70 ;Add #$7000 to result. +LE74A:  adc #$70                        ;Add #$7000 to result. 
-LE74C: sta $01 ;$0000 = (MapY*32)+MapX+#$7000. +LE74C:  sta $01                         ;$0000 = (MapY*32)+MapX+#$7000. 
-LE74E: ldy #$00 +LE74E:  ldy #$00                        
-LE750: lda ($00),y ;Load room number. +LE750:  lda ($00),                    ;Load room number. 
-LE752: cmp #$FF ;Is it unused?--> +LE752:  cmp #$FF                        ;Is it unused?--> 
-LE754: beq ++++ ;If so, branch to exit with carry flag set.+LE754:  beq ++++                        ;If so, branch to exit with carry flag set.
  
-LE756: sta RoomNumber ;Store room number.+LE756:  sta RoomNumber                  ;Store room number.
  
-LE758:* cmp $95D0,y ;Is it a special room?--> +LE758:* cmp $95D0,                    ;Is it a special room?--> 
-LE75B: beq + ;If so, branch to set flag to play item room music. +LE75B:  beq +                           ;If so, branch to set flag to play item room music. 
-LE75D: iny +LE75D:  iny                             
-LE75E: cpy #$07 +LE75E:  cpy #$07                        
-LE760: bne - ;Loop until all special room numbers are checked.+LE760:  bne -                           ;Loop until all special room numbers are checked.
  
-LE762: lda ItemRoomMusicStatus ;Load item room music status. +LE762:  lda ItemRoomMusicStatus         ;Load item room music status. 
-LE764: beq ++ ;Branch if not in special room. +LE764:  beq ++                          ;Branch if not in special room. 
-LE766: lda #$80 ;Ptop playing item room music after next music start. +LE766:  lda #$80                        ;Ptop playing item room music after next music start. 
-LE768: bne ++ ;Branch always.+LE768:  bne ++                          ;Branch always.
  
-LE76A:* lda #$01 ;Start item room music on next music start. +LE76A:* lda #$01                        ;Start item room music on next music start. 
-LE76C:* sta ItemRoomMusicStatus +LE76C:* sta ItemRoomMusicStatus         
-LE76E: clc ;Clear carry flag. was able to get room number. +LE76E:  clc                             ;Clear carry flag. was able to get room number. 
-LE76F:* rts ;+LE76F:* rts                             ;
  
 ;----------------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------------
  
-LE770: ldx PageIndex +LE770:  ldx PageIndex 
- lda EnRadY,x +        lda EnRadY,x 
- clc +        clc 
- adc #$08 +        adc #$08 
- jmp LE783+        jmp LE783
  
 LE77B:  ldx PageIndex LE77B:  ldx PageIndex
- lda #$00 +        lda #$00 
- sec +        sec 
- sbc EnRadY,x+        sbc EnRadY,x
 LE783:  sta $02 LE783:  sta $02
- lda #$08 +        lda #$08 
- sta $04 +        sta $04 
- jsr LE792 +        jsr LE792 
- lda EnRadX,x +        lda EnRadX,x 
- jmp LE7BD+        jmp LE7BD
  
 LE792:  lda EnXRoomPos,x LE792:  lda EnXRoomPos,x
- sta $09     ; X coord +        sta $09     ; X coord 
- lda EnYRoomPos,+        lda EnYRoomPos,
- sta $08     ; Y coord +        sta $08     ; Y coord 
- lda EnNameTable,+        lda EnNameTable,
- sta $0B     ; hi coord +        sta $0B     ; hi coord 
- rts+        rts
  
 CheckMoveUp: CheckMoveUp:
-LE7A2: ldx PageIndex +LE7A2:  ldx PageIndex 
- lda ObjRadY,x +        lda ObjRadY,x 
- clc +        clc 
- adc #$08 +        adc #$08 
- jmp ++        jmp +
  
 CheckMoveDown: CheckMoveDown:
- ldx PageIndex +        ldx PageIndex 
- lda #$00 +        lda #$00 
- sec +        sec 
- sbc ObjRadY,x+        sbc ObjRadY,x
 *       sta $02 *       sta $02
- jsr LE8BE +        jsr LE8BE 
- lda ObjRadX,x+        lda ObjRadX,x
 LE7BD:  bne + LE7BD:  bne +
- sec +        sec 
- rts+        rts
  
 *       sta $03 *       sta $03
- tay +        tay 
- ldx #$00 +        ldx #$00 
- lda $09 +        lda $09 
- sec +        sec 
- sbc $03 +        sbc $03 
- and #$07 +        and #$07 
- beq + +        beq + 
- inx+        inx
 *       jsr LE8CE *       jsr LE8CE
- sta $04 +        sta $04 
- jsr LE90F +        jsr LE90F 
- ldx #$00 +        ldx #$00 
- ldy #$08 +        ldy #$08 
- lda $00+        lda $00
 LE7DE:  bne +++ LE7DE:  bne +++
- stx $06 +        stx $06 
- sty $07 +        sty $07 
- ldx $04+        ldx $04
  
 ; object<-->background crash detection ; object<-->background crash detection
  
-LE7E6:  jsr MakeCartRAMPtr ;($E96A)Find object position in room RAM. +LE7E6:  jsr MakeCartRAMPtr              ;($E96A)Find object position in room RAM. 
- ldy #$00 +        ldy #$00 
- lda ($04),    ; get tile value +        lda ($04),    ; get tile value 
- cmp #$4E +        cmp #$4E 
- beq LE81E +        beq LE81E 
- jsr $95C0 +        jsr $95C0 
- jsr LD651 +        jsr LD651 
- bcc Exit16      ; CF = 0 if tile # < $80 (solid tile)... CRASH!!! +        bcc Exit16      ; CF = 0 if tile # < $80 (solid tile)... CRASH!!! 
- cmp #$A0 ; is tile >= A0h? (walkable tile) +        cmp #$A0        ; is tile >= A0h? (walkable tile) 
- bcs IsWalkableTile +        bcs IsWalkableTile 
- jmp IsBlastTile  ; tile is $80-$9F (blastable tiles)+        jmp IsBlastTile  ; tile is $80-$9F (blastable tiles)
  
 IsWalkableTile: IsWalkableTile:
- ldy IsSamus +        ldy IsSamus 
- beq +++        beq ++
     ; special case for Samus     ; special case for Samus
- dey      ; = 0 +        dey          ; = 0 
- sty SamusDoorData +        sty SamusDoorData 
- cmp #$A0 ; crash with tile #$A0? (scroll toggling door) +        cmp #$A0        ; crash with tile #$A0? (scroll toggling door) 
- beq + +        beq + 
- cmp #$A1 ; crash with tile #$A1? (horizontal scrolling door) +        cmp #$A1        ; crash with tile #$A1? (horizontal scrolling door) 
- bne ++ +        bne ++ 
- inc SamusDoorData+        inc SamusDoorData
 *       inc SamusDoorData *       inc SamusDoorData
-* dex +      dex 
- beq + +        beq + 
- jsr LE98E +        jsr LE98E 
- jmp LE7E6+        jmp LE7E6
  
-* sec      ; no crash +      sec          ; no crash 
- Exit16: +        Exit16: 
- rts+        rts
  
 LE81E:  ldx UpdatingProjectile LE81E:  ldx UpdatingProjectile
- beq ClcExit +        beq ClcExit 
- ldx #$06+        ldx #$06
 *       lda $05 *       lda $05
- eor $5D,x +        eor $5D,x 
- and #$04 +        and #$04 
- bne +++ +        bne +++ 
- lda $04 +        lda $04 
- eor $5C,x +        eor $5C,x 
- and #$1F +        and #$1F 
- bne +++ +        bne +++ 
- txa +        txa 
- jsr Amul8       ; * 8 +        jsr Amul8       ; * 8 
- ora #$80 +        ora #$80 
- tay +        tay 
- lda ObjAction,+        lda ObjAction,
- beq +++ +        beq +++ 
- lda $0307,y +        lda $0307,y 
- lsr +        lsr 
- bcs ++ +        bcs ++ 
- ldx PageIndex +        ldx PageIndex 
- lda ObjAction,+        lda ObjAction,
- eor #$0B +        eor #$0B 
- beq + +        beq + 
- lda ObjAction,+        lda ObjAction,
- eor #$04 +        eor #$04 
- bne PlaySnd4 +        bne PlaySnd4 
- lda AnimResetIndex,+        lda AnimResetIndex,
- eor #$91 +        eor #$91 
- bne PlaySnd4+        bne PlaySnd4
 *       lda $0683 *       lda $0683
- ora #$02 +        ora #$02 
- sta $0683 +        sta $0683 
-* lda #$04 +      lda #$04 
- sta $030A,y +        sta $030A,y 
- bne ClcExit +        bne ClcExit 
-* dex +      dex 
- dex +        dex 
- bpl ---- +        bpl ---- 
- lda $04 +        lda $04 
- jsr Adiv8       ; / 8 +        jsr Adiv8       ; / 8 
- and #$01 +        and #$01 
- tax +        tax 
- inc $0366,x+        inc $0366,x
  
 ClcExit: ClcExit:
- clc +        clc 
- rts+        rts
  
 PlaySnd4: PlaySnd4:
- jmp SFX_Metal+        jmp SFX_Metal
  
 CheckMoveLeft: CheckMoveLeft:
- ldx PageIndex +        ldx PageIndex 
- lda ObjRadX,x +        lda ObjRadX,x 
- clc +        clc 
- adc #$08 +        adc #$08 
- jmp ++        jmp +
  
 CheckMoveRight: CheckMoveRight:
- ldx PageIndex +        ldx PageIndex 
- lda #$00 +        lda #$00 
- sec +        sec 
- sbc ObjRadX,x+        sbc ObjRadX,x
 *       sta $03 *       sta $03
- jsr LE8BE +        jsr LE8BE 
- ldy ObjRadY,x+        ldy ObjRadY,x
 LE89B:  bne + LE89B:  bne +
- sec +        sec 
- rts+        rts
  
 *       sty $02 *       sty $02
- ldx #$00 +        ldx #$00 
- lda $08 +        lda $08 
- sec +        sec 
- sbc $02 +        sbc $02 
- and #$07 +        and #$07 
- beq + +        beq + 
- inx+        inx
 *       jsr LE8CE *       jsr LE8CE
- sta $04 +        sta $04 
- jsr LE90F +        jsr LE90F 
- ldx #$08 +        ldx #$08 
- ldy #$00 +        ldy #$00 
- lda $01 +        lda $01 
- jmp LE7DE+        jmp LE7DE
  
 LE8BE:  lda ObjectHi,x LE8BE:  lda ObjectHi,x
- sta $0B +        sta $0B 
- lda ObjectY,x +        lda ObjectY,x 
- sta $08 +        sta $08 
- lda ObjectX,x +        lda ObjectX,x 
- sta $09 +        sta $09 
- rts+        rts
  
 LE8CE:  eor #$FF LE8CE:  eor #$FF
- clc +        clc 
- adc #$01 +        adc #$01 
- and #$07 +        and #$07 
- sta $04 +        sta $04 
- tya +        tya 
- asl +        asl 
- sec +        sec 
- sbc $04 +        sbc $04 
- bcs + +        bcs + 
- adc #$08+        adc #$08
 *       tay *       tay
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- sta $04 +        sta $04 
- tya +        tya 
- and #$07 +        and #$07 
- beq + +        beq + 
- inx+        inx
 *       txa *       txa
- clc +        clc 
- adc $04 +        adc $04 
- rts+        rts
  
 LE8F1:  ldx PageIndex LE8F1:  ldx PageIndex
- lda EnRadX,x +        lda EnRadX,x 
- clc +        clc 
- adc #$08 +        adc #$08 
- jmp LE904+        jmp LE904
  
 LE8FC:  ldx PageIndex LE8FC:  ldx PageIndex
- lda #$00 +        lda #$00 
- sec +        sec 
- sbc EnRadX,x+        sbc EnRadX,x
 LE904:  sta $03 LE904:  sta $03
- jsr LE792 +        jsr LE792 
- ldy EnRadY,x +        ldy EnRadY,x 
- jmp LE89B+        jmp LE89B
  
 LE90F:  lda $02 LE90F:  lda $02
- bpl ++ +        bpl ++ 
- jsr LE95F +        jsr LE95F 
- bcs + +        bcs + 
- cpx #$F0 +        cpx #$F0 
- bcc ++++        bcc +++
 *       txa *       txa
- adc #$0F +        adc #$0F 
- jmp LE934+        jmp LE934
  
-* jsr LE95F +      jsr LE95F 
- lda $08 +        lda $08 
- sec +        sec 
- sbc $02 +        sbc $02 
- tax +        tax 
- and #$07 +        and #$07 
- sta $00 +        sta $00 
- bcs + +        bcs + 
- txa +        txa 
- sbc #$0F+        sbc #$0F
 LE934:  tax LE934:  tax
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne + +        bne + 
- inc $0B +        inc $0B 
-* stx $02 +      stx $02 
- ldx #$00 +        ldx #$00 
- lda $03 +        lda $03 
- bmi + +        bmi + 
- dex+        dex
 *       lda $09 *       lda $09
- sec +        sec 
- sbc $03 +        sbc $03 
- sta $03 +        sta $03 
- and #$07 +        and #$07 
- sta $01 +        sta $01 
- txa +        txa 
- adc #$00 +        adc #$00 
- beq + +        beq + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- beq + +        beq + 
- inc $0B+        inc $0B
 *       rts *       rts
  
 LE95F:  lda $08 LE95F:  lda $08
- sec +        sec 
- sbc $02 +        sbc $02 
- tax +        tax 
- and #$07 +        and #$07 
- sta $00 +        sta $00 
- rts+        rts
  
 ;------------------------------------[ Object pointer into cart RAM ]------------------------------- ;------------------------------------[ Object pointer into cart RAM ]-------------------------------
Line 6452: Line 6452:
  
 MakeCartRAMPtr: MakeCartRAMPtr:
-LE96A: lda #$18 ;Set pointer to $6xxx(cart RAM). +LE96A:  lda #$18                        ;Set pointer to $6xxx(cart RAM). 
-LE96C: sta $05 +LE96C:  sta $05                         
-LE96E: lda $02 ;Object Y room position. +LE96E:  lda $02                         ;Object Y room position. 
-LE970: and #$F8 ;Drop 3 LSBs. Only use multiples of 8. +LE970:  and #$F8                        ;Drop 3 LSBs. Only use multiples of 8. 
-LE972: asl +LE972:  asl                             
-LE973: rol $05 +LE973:  rol $05                         
-LE975: asl ;Move upper 2 bits to lower 2 bits of $05 and move y bits--> +LE975:  asl                             ;Move upper 2 bits to lower 2 bits of $05 and move y bits--> 
-LE976: rol $05 ;3, 4, 5 to upper 3 bits of $04. +LE976:  rol $05                         ;3, 4, 5 to upper 3 bits of $04. 
-LR978: sta $04 +LR978:  sta $04                         
-LE97A: lda $03 ;Object X room position. +LE97A:  lda $03                         ;Object X room position. 
-LE97C: lsr +LE97C:  lsr                             
-LE97D: lsr +LE97D:  lsr                             
-LE97E: lsr     ;A=ObjectX/8. +LE97E:  lsr                             ;A=ObjectX/8. 
-LE97F: ora $04 +LE97F:  ora $04                         
-LE981: sta $04 ;Put bits 0 thru 4 into $04. +LE981:  sta $04                         ;Put bits 0 thru 4 into $04. 
-LE983: lda $0B ;Object nametable. +LE983:  lda $0B                         ;Object nametable. 
-LE985: asl +LE985:  asl                             
-LE986: asl ; A=ObjectHi*4. +LE986:  asl                             ; A=ObjectHi*4. 
-LE987: and #$04 ;Set bit 2 if object is on nametable 3. +LE987:  and #$04                        ;Set bit 2 if object is on nametable 3. 
-LE989: ora $05 +LE989:  ora $05                         
-LE98B: sta $05 ;Include nametable bit in $05. +LE98B:  sta $05                         ;Include nametable bit in $05. 
-LE98D: rts ;Return pointer in $04 = 01100HYY YYYXXXXX.+LE98D:  rts                             ;Return pointer in $04 = 01100HYY YYYXXXXX.
  
 ;--------------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------
  
 LE98E:  lda $02 LE98E:  lda $02
- clc +        clc 
- adc $06 +        adc $06 
- sta $02 +        sta $02 
- cmp #$F0 +        cmp #$F0 
- bcc + +        bcc + 
- adc #$0F +        adc #$0F 
- sta $02 +        sta $02 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- bne + +        bne + 
- inc $0B+        inc $0B
 *       lda $03 *       lda $03
- clc +        clc 
- adc $07 +        adc $07 
- sta $03 +        sta $03 
- bcc + +        bcc + 
- lda ScrollDir +        lda ScrollDir 
- and #$02 +        and #$02 
- beq + +        beq + 
- inc $0B+        inc $0B
 *       rts *       rts
  
 LE9B7:  lda PPUCNT0ZP LE9B7:  lda PPUCNT0ZP
- eor #$03 +        eor #$03 
- sta PPUCNT0ZP +        sta PPUCNT0ZP 
- rts+        rts
  
 IsBlastTile: IsBlastTile:
- ldy UpdatingProjectile +        ldy UpdatingProjectile 
- beq Exit18+        beq Exit18
 LE9C2:  tay LE9C2:  tay
- jsr $95BD +        jsr $95BD 
- cpy #$98 +        cpy #$98 
- bcs ++++++        bcs +++++
 ; attempt to find a vacant tile slot ; attempt to find a vacant tile slot
- ldx #$C0+        ldx #$C0
 *       lda TileRoutine,x *       lda TileRoutine,x
- beq +    ; 0 = free slot +        beq +                           ; 0 = free slot 
- jsr Xminus16 +        jsr Xminus16 
- bne - +        bne - 
- lda TileRoutine,+        lda TileRoutine,
- bne ++++  ; no more slots, can't blast tile+        bne ++++                        ; no more slots, can't blast tile
 *       inc TileRoutine,x *       inc TileRoutine,x
- lda $04 +        lda $04 
- and #$DE +        and #$DE 
- sta TileWRAMLo,+        sta TileWRAMLo,
- lda $05 +        lda $05 
- sta TileWRAMHi,+        sta TileWRAMHi,
- lda InArea +        lda InArea 
- cmp #$11 +        cmp #$11                        ; In Norfair? 
- bne + +        bne + 
- cpy #$76 +        cpy #$76                        ; Special case for the four-small-bubbles breakable block 
- bne + +        bne + 
- lda #$04 +        lda #$04 
- bne ++ +        bne ++ 
-*       tya +*       tya                             ; Destroyed block ID 
- clc +        clc 
- adc #$10 +        adc #$10 
- and #$3C +        and #$3C 
- lsr +        lsr 
-* lsr +      lsr 
- sta TileType,+        sta TileType,
-* clc+      clc
 Exit18: rts Exit18: rts
  
Line 6546: Line 6546:
  
 SelectRoomRAM: SelectRoomRAM:
-LEA05: jsr GetNameTable ;($EB85)Find name table to draw room on. +LEA05:  jsr GetNameTable                ;($EB85)Find name table to draw room on. 
-LEA08: asl +LEA08:  asl                             
-LEA09: asl +LEA09:  asl                             
-LEA0A: ora #$60 ;A=#$64 for name table 3, A=#$60 for name table 0. +LEA0A:  ora #$60                        ;A=#$64 for name table 3, A=#$60 for name table 0. 
-LEA0C: sta CartRAMPtr+1 +LEA0C:  sta CartRAMPtr+1                
-LEA0E: lda #$00 +LEA0E:  lda #$00                        
-LEA10: sta CartRAMPtr ;Save two byte pointer to start of proper room RAM. +LEA10:  sta CartRAMPtr                  ;Save two byte pointer to start of proper room RAM. 
-LEA12: rts ;+LEA12:  rts                             ;
  
 ;------------------------------------[ write attribute table data ]---------------------------------- ;------------------------------------[ write attribute table data ]----------------------------------
  
 AttribTableWrite: AttribTableWrite:
-LEA13:* lda RoomNumber +LEA13:* lda RoomNumber                  
-LEA15: and #$0F ;Determine what row of PPU attribute table data, if any,--> +LEA15:  and #$0F                        ;Determine what row of PPU attribute table data, if any,--> 
-LEA17: inc RoomNumber ;to load from RoomRAM into PPU. +LEA17:  inc RoomNumber                  ;to load from RoomRAM into PPU. 
-LEA19: jsr ChooseRoutine ;+LEA19:  jsr ChooseRoutine               ;
  
 ;The following table is used by the code above to determine when to write to the PPU attribute table. ;The following table is used by the code above to determine when to write to the PPU attribute table.
  
-LEA1c: .word ExitSub ;($C45C)Rts. +LEA1c:  .word ExitSub                   ;($C45C)Rts. 
-LEA1E: .word WritePPUAttribTbl ;($E5E2)Write first row of PPU attrib data. +LEA1E:  .word WritePPUAttribTbl         ;($E5E2)Write first row of PPU attrib data. 
-LEA20: .word ExitSub ;($C45C)Rts. +LEA20:  .word ExitSub                   ;($C45C)Rts. 
-LEA22: .word WritePPUAttribTbl ;($E5E2)Write second row of PPU attrib data. +LEA22:  .word WritePPUAttribTbl         ;($E5E2)Write second row of PPU attrib data. 
-LEA24: .word RoomFinished ;($EA26)Finished writing attribute table data.+LEA24:  .word RoomFinished              ;($EA26)Finished writing attribute table data.
  
 ;-----------------------------------[ Finished writing room data ]----------------------------------- ;-----------------------------------[ Finished writing room data ]-----------------------------------
  
 RoomFinished: RoomFinished:
-LEA26:  lda #$FF ;No more tasks to perform on current room.--> +LEA26:  lda #$FF                        ;No more tasks to perform on current room.--> 
-LEA28: sta RoomNumber ;Set RoomNumber to #$FF. +LEA28:  sta RoomNumber                  ;Set RoomNumber to #$FF. 
-LEA2A:* rts ;+LEA2A:* rts                             ;
  
 ;------------------------------------------[ Setup room ]-------------------------------------------- ;------------------------------------------[ Setup room ]--------------------------------------------
  
 SetupRoom: SetupRoom:
-LEA2B: lda RoomNumber ;Room number. +LEA2B:  lda RoomNumber                  ;Room number. 
-LEA2D: cmp #$FF +LEA2D:  cmp #$FF                        
-LEA2F: beq - ;Branch to exit if room is undefined. +LEA2F:  beq -                           ;Branch to exit if room is undefined. 
-LEA31: cmp #$FE +LEA31:  cmp #$FE                        
-LEA33: beq + ;Branch if empty place holder byte found in room data. +LEA33:  beq +                           ;Branch if empty place holder byte found in room data. 
-LEA35: cmp #$F0 +LEA35:  cmp #$F0                        
-LEA37: bcs -- ;Branch if time to write PPU attribute table data. +LEA37:  bcs --                          ;Branch if time to write PPU attribute table data. 
-LEA39: jsr UpdateRoomSpriteInfo ;($EC9B)Update which sprite belongs on which name table.+LEA39:  jsr UpdateRoomSpriteInfo        ;($EC9B)Update which sprite belongs on which name table.
  
-LEA3C: jsr ScanForItems ;($ED98)Set up any special items. +LEA3C:  jsr ScanForItems                ;($ED98)Set up any special items. 
-LEA3F: lda RoomNumber ;Room number to load. +LEA3F:  lda RoomNumber                  ;Room number to load. 
-LEA41: asl ;*2(for loading address of room pointer). +LEA41:  asl                             ;*2(for loading address of room pointer). 
-LEA42: tay +LEA42:  tay                             
-LEA43: lda (RoomPtrTable),y ;Low byte of 16-bit room pointer.--> +LEA43:  lda (RoomPtrTable),           ;Low byte of 16-bit room pointer.--> 
-LEA45: sta RoomPtr ;Base copied from $959A to $3B. +LEA45:  sta RoomPtr                     ;Base copied from $959A to $3B. 
-LEA47: iny +LEA47:  iny                             
-LEA48: lda (RoomPtrTable),y ;High byte of 16-bit room pointer.--> +LEA48:  lda (RoomPtrTable),           ;High byte of 16-bit room pointer.--> 
-LEA4A: sta RoomPtr+1 ;Base copied from $959B to $3C. +LEA4A:  sta RoomPtr+1                   ;Base copied from $959B to $3C. 
-LEA4C: ldy #$00 +LEA4C:  ldy #$00                        
-LEA4E: lda (RoomPtr),y ;First byte of room data. +LEA4E:  lda (RoomPtr),                ;First byte of room data. 
-LEA50: sta RoomPal ;store initial palette # to fill attrib table with. +LEA50:  sta RoomPal                     ;store initial palette # to fill attrib table with. 
-LEA52: lda #$01 +LEA52:  lda #$01                        
-LEA54: jsr AddToRoomPtr ;($EAC0)Increment room data pointer. +LEA54:  jsr AddToRoomPtr                ;($EAC0)Increment room data pointer. 
-LEA57: jsr SelectRoomRAM ;($EA05)Determine where to draw room in RAM, $6000 or $6400. +LEA57:  jsr SelectRoomRAM               ;($EA05)Determine where to draw room in RAM, $6000 or $6400. 
-LEA5A: jsr InitTables ;($EFF8)clear Name Table & do initial Attrib table setup. +LEA5A:  jsr InitTables                  ;($EFF8)clear Name Table & do initial Attrib table setup. 
-LEA5D:* jmp DrawRoom ;($EAAA)Load room contents into room RAM.+LEA5D:* jmp DrawRoom                    ;($EAAA)Load room contents into room RAM.
  
 ;---------------------------------------[ Draw room object ]----------------------------------------- ;---------------------------------------[ Draw room object ]-----------------------------------------
  
 DrawObject: DrawObject:
-LEA60: sta $0E ;Store object position byte(%yyyyxxxx). +LEA60:  sta $0E                         ;Store object position byte(%yyyyxxxx). 
-LEA62: lda CartRAMPtr +LEA62:  lda CartRAMPtr                  
-LEA64: sta CartRAMWorkPtr ;Set the working pointer equal to the room pointer--> +LEA64:  sta CartRAMWorkPtr              ;Set the working pointer equal to the room pointer--> 
-LEA66: lda CartRAMPtr+1 ;(start at beginning of the room). +LEA66:  lda CartRAMPtr+1                ;(start at beginning of the room). 
-LEA68: sta CartRAMWorkPtr+1 +LEA68:  sta CartRAMWorkPtr+1            
-LEA6A: lda $0E ;Reload object position byte. +LEA6A:  lda $0E                         ;Reload object position byte. 
-LEA6C: jsr Adiv16 ;($C2BF)/16. Lower nibble contains object y position.--> +LEA6C:  jsr Adiv16                      ;($C2BF)/16. Lower nibble contains object y position.--> 
-LEA6F: tax ;Transfer it to X, prepare for loop. +LEA6F:  tax                             ;Transfer it to X, prepare for loop. 
-LEA70: beq +++ ;Skip y position calculation loop as y position=0 and--> +LEA70:  beq +++                         ;Skip y position calculation loop as y position=0 and--> 
- ;does not need to be calculated. +                                        ;does not need to be calculated. 
-LEA72:* lda CartRAMWorkPtr ;LoW byte of pointer working in room RAM. +LEA72:* lda CartRAMWorkPtr              ;LoW byte of pointer working in room RAM. 
-LEA74: clc +LEA74:  clc                             
-LEA75: adc #$40 ;Advance two rows in room RAM(one y unit). +LEA75:  adc #$40                        ;Advance two rows in room RAM(one y unit). 
-LEA77: sta CartRAMWorkPtr +LEA77:  sta CartRAMWorkPtr              
-LEA79: bcc + ;If carry occurred, increment high byte of pointer--> +LEA79:  bcc +                           ;If carry occurred, increment high byte of pointer--> 
-LEA7B: inc CartRAMWorkPtr+1 ;in room RAM. +LEA7B:  inc CartRAMWorkPtr+1            ;in room RAM. 
-LEA7D:* dex +LEA7D:* dex                             
-LEA7E: bne -- ;Repeat until at desired y position(X=0).+LEA7E:  bne --                          ;Repeat until at desired y position(X=0).
  
-LEA80:* lda $0E ;Reload object position byte. +LEA80:* lda $0E                         ;Reload object position byte. 
-LEA82: and #$0F ;Remove y position upper nibble. +LEA82:  and #$0F                        ;Remove y position upper nibble. 
-LEA84: asl ;Each x unit is 2 tiles. +LEA84:  asl                             ;Each x unit is 2 tiles. 
-LEA85: adc CartRAMWorkPtr +LEA85:  adc CartRAMWorkPtr              
-LEA87: sta CartRAMWorkPtr ;Add x position to room RAM work pointer. +LEA87:  sta CartRAMWorkPtr              ;Add x position to room RAM work pointer. 
-LEA89: bcc + ;If carry occurred, increment high byte of room RAM work--> +LEA89:  bcc +                           ;If carry occurred, increment high byte of room RAM work--> 
-LEA8B: inc CartRAMWorkPtr+1 ;pointer, else branch to draw object.+LEA8B:  inc CartRAMWorkPtr+1            ;pointer, else branch to draw object.
  
 ;CartRAMWorkPtr now points to the object's starting location (upper left corner) ;CartRAMWorkPtr now points to the object's starting location (upper left corner)
 ;on the room RAM which will eventually be loaded into a name table. ;on the room RAM which will eventually be loaded into a name table.
  
-LEA8D:* iny ;Move to the next byte of room data which is--> +LEA8D:* iny                             ;Move to the next byte of room data which is--> 
-LEA8E: lda (RoomPtr),y ;the index into the structure pointer table. +LEA8E:  lda (RoomPtr),                ;the index into the structure pointer table. 
-LEA90: tax ;Transfer structure pointer index into X. +LEA90:  tax                             ;Transfer structure pointer index into X. 
-LEA91: iny ;Move to the next byte of room data which is--> +LEA91:  iny                             ;Move to the next byte of room data which is--> 
-LEA92: lda (RoomPtr),y ;the attrib table info for the structure. +LEA92:  lda (RoomPtr),                ;the attrib table info for the structure. 
-LEA94: sta ObjectPal ;Save attribute table info. +LEA94:  sta ObjectPal                   ;Save attribute table info. 
-LEA96: txa ;Restore structure pointer to A. +LEA96:  txa                             ;Restore structure pointer to A. 
-LEA97: asl ;*2. Structure pointers are two bytes in size. +LEA97:  asl                             ;*2. Structure pointers are two bytes in size. 
-LEA98: tay +LEA98:  tay                             
-LEA99: lda (StructPtrTable),y ;Low byte of 16-bit structure ptr. +LEA99:  lda (StructPtrTable),         ;Low byte of 16-bit structure ptr. 
-LEA9B: sta StructPtr +LEA9B:  sta StructPtr                   
-LEA9D: iny +LEA9D:  iny                             
-LEA9E: lda (StructPtrTable),y ;High byte of 16-bit structure ptr. +LEA9E:  lda (StructPtrTable),         ;High byte of 16-bit structure ptr. 
-LEAA0: sta StructPtr+1 +LEAA0:  sta StructPtr+1                 
-LEAA2: jsr DrawStruct ;($EF8C)Draw one structure. +LEAA2:  jsr DrawStruct                  ;($EF8C)Draw one structure. 
-LEAA5: lda #$03 ;Move to next set of structure data. +LEAA5:  lda #$03                        ;Move to next set of structure data. 
-LEAA7: jsr AddToRoomPtr ;($EAC0)Add A to room data pointer.+LEAA7:  jsr AddToRoomPtr                ;($EAC0)Add A to room data pointer.
  
 ;-------------------------------------------[ Draw room ]-------------------------------------------- ;-------------------------------------------[ Draw room ]--------------------------------------------
Line 6664: Line 6664:
  
 DrawRoom: DrawRoom:
-LEAAA: ldy #$00 ;Zero index. +LEAAA:  ldy #$00                        ;Zero index. 
-LEAAC: lda (RoomPtr),y ;Load byte of room data.--> +LEAAC:  lda (RoomPtr),                ;Load byte of room data.--> 
-LEAAE: cmp #$FF ;Is it #$FF(end-of-room)?--> +LEAAE:  cmp #$FF                        ;Is it #$FF(end-of-room)?--> 
-LEAB0: beq EndOfRoom ;If so, branch to exit. +LEAB0:  beq EndOfRoom                   ;If so, branch to exit. 
-LEAB2: cmp #$FE ;Place holder for empty room objects(not used). +LEAB2:  cmp #$FE                        ;Place holder for empty room objects(not used). 
-LEAB4: beq + +LEAB4:  beq +                           
-LEAB6: cmp #$FD ;is A=#$FD(end-of-objects)?--> +LEAB6:  cmp #$FD                        ;is A=#$FD(end-of-objects)?--> 
-LEAB8: bne DrawObject ;If not, branch to draw room object.--> +LEAB8:  bne DrawObject                  ;If not, branch to draw room object.--> 
-LEABA: beq EndOfObjs ;Else branch to set up enemies/doors. +LEABA:  beq EndOfObjs                   ;Else branch to set up enemies/doors. 
-LEABC:* sta RoomNumber ;Store #$FE if room object is empty. +LEABC:* sta RoomNumber                  ;Store #$FE if room object is empty. 
-LEABE: lda #$01 ;Prepare to increment RoomPtr.+LEABE:  lda #$01                        ;Prepare to increment RoomPtr.
  
 ;-------------------------------------[ Add A to room pointer ]-------------------------------------- ;-------------------------------------[ Add A to room pointer ]--------------------------------------
  
 AddToRoomPtr: AddToRoomPtr:
-LEAC0: clc ;Prepare to add index in A to room pointer. +LEAC0:  clc                             ;Prepare to add index in A to room pointer. 
-LEAC1: adc RoomPtr +LEAC1:  adc RoomPtr                     
-LEAC3: sta RoomPtr +LEAC3:  sta RoomPtr                     
-LEAC5: bcc + ;Did carry occur? If not branch to exit. +LEAC5:  bcc +                           ;Did carry occur? If not branch to exit. 
-LEAC7: inc RoomPtr+1 ;Increment high byte of room pointer if carry occured. +LEAC7:  inc RoomPtr+1                   ;Increment high byte of room pointer if carry occured. 
-LEAC9:* rts ;+LEAC9:* rts                             ;
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
  
 EndOfObjs: EndOfObjs:
-LEACA: lda RoomPtr +LEACA:  lda RoomPtr                     
-LEACC: sta $00 ;Store room pointer in $0000. +LEACC:  sta $00                         ;Store room pointer in $0000. 
-LEACE: lda RoomPtr+1 +LEACE:  lda RoomPtr+1                   
-LEAD0: sta $01 +LEAD0:  sta $01                         
-LEAD2: lda #$01 ;Prepare to increment to enemy/door data.+LEAD2:  lda #$01                        ;Prepare to increment to enemy/door data.
  
 EnemyLoop: EnemyLoop:
-LEAD4: jsr AddToPtr00 ;($EF09)Add A to pointer at $0000. +LEAD4:  jsr AddToPtr00                  ;($EF09)Add A to pointer at $0000. 
-LEAD7: ldy #$00 +LEAD7:  ldy #$00                        
-LEAD9: lda ($00),y ;Get first byte of enemy/door data. +LEAD9:  lda ($00),                    ;Get first byte of enemy/door data. 
-LEADB: cmp #$FF ;End of enemy/door data?--> +LEADB:  cmp #$FF                        ;End of enemy/door data?--> 
-LEADD: beq EndOfRoom ;If so, branch to finish room setup. +LEADD:  beq EndOfRoom                   ;If so, branch to finish room setup. 
-LEADF: and #$0F ;Discard upper four bits of data. +LEADF:  and #$0F                        ;Discard upper four bits of data. 
-LEAE1: jsr ChooseRoutine ;Jump to proper enemy/door handling routine.+LEAE1:  jsr ChooseRoutine               ;Jump to proper enemy/door handling routine.
  
 ;Pointer table to code. ;Pointer table to code.
  
-LEAE4: .word ExitSub ;($C45C)Rts. +LEAE4:  .word ExitSub                   ;($C45C)Rts. 
-LEAE6: .word LoadEnemy ;($EB06)Room enemies. +LEAE6:  .word LoadEnemy                 ;($EB06)Room enemies. 
-LEAE8: .word LoadDoor ;($EB8C)Room doors. +LEAE8:  .word LoadDoor                  ;($EB8C)Room doors. 
-LEAEA: .word ExitSub ;($C45C)Rts. +LEAEA:  .word ExitSub                   ;($C45C)Rts. 
-LEAEC: .word LoadElevator ;($EC04)Elevator. +LEAEC:  .word LoadElevator              ;($EC04)Elevator. 
-LEAEE: .word ExitSub ;($C45C)Rts. +LEAEE:  .word ExitSub                   ;($C45C)Rts. 
-LEAF0: .word LoadStatues ;($EC2F)Kraid & Ridley statues. +LEAF0:  .word LoadStatues               ;($EC2F)Kraid & Ridley statues. 
-LEAF2: .word ZebHole ;($EC57)Regenerating enemies(such as Zeb).+LEAF2:  .word ZebHole                   ;($EC57)Regenerating enemies(such as Zeb).
  
 EndOfRoom: EndOfRoom:
-LEAF4: ldx #$F0 ;Prepare for PPU attribute table write. +LEAF4:  ldx #$F0                        ;Prepare for PPU attribute table write. 
- stx RoomNumber +        stx RoomNumber                  
- lda ScrollDir +        lda ScrollDir                   
- sta TempScrollDir ;Make temp copy of ScrollDir. +        sta TempScrollDir               ;Make temp copy of ScrollDir. 
- and #$02 ;Check if scrolling left or right. +        and #$02                        ;Check if scrolling left or right. 
- bne + +        bne +                           
- jmp LE57C+        jmp LE57C
 *       jmp LE70C *       jmp LE70C
  
 LoadEnemy: LoadEnemy:
-LEB06: jsr GetEnemyData ;($EB0C)Get enemy data from room data. +LEB06:  jsr GetEnemyData                ;($EB0C)Get enemy data from room data. 
-LEB09: jmp EnemyLoop ;($EAD4)Do next room object.+LEB09:  jmp EnemyLoop                   ;($EAD4)Do next room object.
  
 GetEnemyData: GetEnemyData:
-LEB0C: lda ($00),y ;Get 1st byte again. +LEB0C:  lda ($00),                    ;Get 1st byte again. 
- and #$F0 ;Get object slot that enemy will occupy. +        and #$F0                        ;Get object slot that enemy will occupy. 
- tax +        tax                             
- jsr IsSlotTaken ;($EB7A)Check if object slot is already in use. +        jsr IsSlotTaken                 ;($EB7A)Check if object slot is already in use. 
- bne ++ ;Exit if object slot taken. +        bne ++                          ;Exit if object slot taken. 
- iny +        iny                             
- lda ($00),y ;Get enemy type. +        lda ($00),                    ;Get enemy type. 
- jsr GetEnemyType ;($EB28)Load data about enemy. +        jsr GetEnemyType                ;($EB28)Load data about enemy. 
- ldy #$02 +        ldy #$02                        
- lda ($00),y ;Get enemy initial position(%yyyyxxxx). +        lda ($00),                    ;Get enemy initial position(%yyyyxxxx). 
- jsr LEB4D +        jsr LEB4D 
- pha+        pha
 *       pla *       pla
-*       lda #$03 ;Number of bytes to add to ptr to find next room item. +*       lda #$03                        ;Number of bytes to add to ptr to find next room item. 
- rts ;+        rts                             ;
  
 GetEnemyType: GetEnemyType:
-LEB28: pha ;Store enemy type. +LEB28:  pha                             ;Store enemy type. 
- and #$C0 ;If MSB is set, the "tough" version of the enemy   +        and #$C0                        ;If MSB is set, the "tough" version of the enemy   
- sta EnSpecialAttribs,x ;is to be loaded(more hit points, except rippers). +        sta EnSpecialAttribs,         ;is to be loaded(more hit points, except rippers). 
- asl +        asl                             
- bpl ++ ;If bit 6 is set, the enemy is either Kraid or Ridley. +        bpl ++                          ;If bit 6 is set, the enemy is either Kraid or Ridley. 
- lda InArea ;Load current area Samus is in(to check if Kraid or--> +        lda InArea                      ;Load current area Samus is in(to check if Kraid or--> 
- and #$06 ;Ridley is alive or dead). +        and #$06                        ;Ridley is alive or dead). 
- lsr ;Use InArea to find status of Kraid/Ridley statue. +        lsr                             ;Use InArea to find status of Kraid/Ridley statue. 
- tay +        tay                             
- lda MaxMissiles,y ;Load status of Kraid/Ridley statue. +        lda MaxMissiles,              ;Load status of Kraid/Ridley statue. 
- beq + ;Branch if Kraid or Ridley needs to be loaded. +        beq +                           ;Branch if Kraid or Ridley needs to be loaded. 
- pla +        pla                             
- pla ;Mini boss is dead so pull enemy info and last address off--> +        pla                             ;Mini boss is dead so pull enemy info and last address off--> 
- jmp -- ;stack so next enemy/door item can be loaded.+        jmp --                          ;stack so next enemy/door item can be loaded.
  
-*       lda #$01 ;Samus is in Kraid or Ridley's room and the--> +*       lda #$01                        ;Samus is in Kraid or Ridley's room and the--> 
- sta KraidRidleyPresent ;mini boss is alive and needs to be loaded.+        sta KraidRidleyPresent          ;mini boss is alive and needs to be loaded.
  
-* pla ;Restore enemy type data. +      pla                             ;Restore enemy type data. 
- and #$3F ;Keep 6 lower bits to use as index for enemy data tables. +        and #$3F                        ;Keep 6 lower bits to use as index for enemy data tables. 
- sta EnDataIndex,x ;Store index byte. +        sta EnDataIndex,              ;Store index byte. 
- rts ;+        rts                             ;
  
-LEB4D:  tay ;Save enemy position data in Y. +LEB4D:  tay                             ;Save enemy position data in Y. 
- and #$F0 ;Extract Enemy y position. +        and #$F0                        ;Extract Enemy y position. 
- ora #$08 ;Add 8 pixels to y position so enemy is always on screen.  +        ora #$08                        ;Add 8 pixels to y position so enemy is always on screen.  
- sta EnYRoomPos,x ;Store enemy y position. +        sta EnYRoomPos,               ;Store enemy y position. 
- tya ;Restore enemy position data. +        tya                             ;Restore enemy position data. 
- jsr Amul16 ;*16 to extract enemy x position. +        jsr Amul16                      ;*16 to extract enemy x position. 
- ora #$0C ;Add 12 pixels to x position so enemy is always on screen. +        ora #$0C                        ;Add 12 pixels to x position so enemy is always on screen. 
- sta EnXRoomPos,x ;Store enemy x position. +        sta EnXRoomPos,               ;Store enemy x position. 
- lda #$01 +        lda #$01                        
- sta EnStatus,x ;Indicate object slot is taken. +        sta EnStatus,                 ;Indicate object slot is taken. 
- lda #$00 +        lda #$00 
- sta $0404,x +        sta $0404,x 
- jsr GetNameTable ;($EB85)Get name table to place enemy on. +        jsr GetNameTable                ;($EB85)Get name table to place enemy on. 
- sta EnNameTable,x ;Store name table. +        sta EnNameTable,              ;Store name table. 
- ldy EnDataIndex,x ;Load A with index to enemy data. +        ldy EnDataIndex,              ;Load A with index to enemy data. 
- asl $0405,x ;*2 +        asl $0405,                    ;*2 
- jsr LFB7B +        jsr LFB7B 
- jmp LF85A+        jmp LF85A
  
 IsSlotTaken: IsSlotTaken:
-LEB7A: lda EnStatus,+LEB7A:  lda EnStatus,
- beq + +        beq + 
- lda $0405,x +        lda $0405,x 
- and #$02+        and #$02
 *       rts *       rts
  
Line 6805: Line 6805:
 ;like so: ;like so:
 ; ;
-; +-----+-----+  +-----+-----+ +; +-----+-----+                                                  +-----+-----+ 
-; |         | The following is an incorrect example of how  |         |+; |         | The following is an incorrect example of how     |         |
 ; |  2  |  3  | Samus goes from one name table to the next-----> |  2  |  3  | ; |  2  |  3  | Samus goes from one name table to the next-----> |  2  |  3  |
-; |         |  |         | +; |                                                          |         | 
-; +-----+-----+  +-----+-----+ +; +-----+-----+                                                  +-----+-----+ 
-; |         |  |         | +; |                                                          |         | 
-; |  0  |  1  |       INCORRECT!------>  |  0<-|->+; |  0  |  1  |                               INCORRECT!------>  |  0<-|->
-; |         |  |         | +; |                                                          |         | 
-; +-----+-----+  +-----+-----++; +-----+-----+                                                  +-----+-----+
 ; ;
 ;The following are examples of how the name tables are properly traversed while walking through rooms: ;The following are examples of how the name tables are properly traversed while walking through rooms:
 ; ;
-;    +-----+-----+      +-----+-----+ +         +-----+-----+                                     +-----+-----+ 
-;    |         |      |         | +         |                                             |         | 
-;    |  2  | ->3 |      |  2  |  3<-|-+ +         |  2  | ->3 |                                     |  2  |  3<-|-+ 
-;    |     |/    |      |         | | +         |     |/    |                                     |         | | 
-;    +-----+-----+     <--------CORRECT!-------->      +-----+-----+ | +         +-----+-----+     <--------CORRECT!-------->      +-----+-----+ | 
-;    |    /|     |      |         | | +         |    /|                                         |         | | 
-;    | 0<- |  1  |    +-|-> |  1  | | +         | 0<- |  1  |                                   +-|-> |  1  | | 
-;    |         |    | |         | | +         |                                           | |         | | 
-;    +-----+-----+    | +-----+-----+ | +         +-----+-----+                                   | +-----+-----+ | 
-;    +---------------++                                                         +---------------+
 ; ;
 ;The same diagonal traversal of the name tables illustrated above applies to vetricle traversal as ;The same diagonal traversal of the name tables illustrated above applies to vetricle traversal as
Line 6833: Line 6833:
  
 GetNameTable: GetNameTable:
-LEB85: lda PPUCNT0ZP +LEB85:  lda PPUCNT0ZP                   
-LEB87: eor ScrollDir ;Store #$01 if object should be loaded onto name table 3--> +LEB87:  eor ScrollDir                   ;Store #$01 if object should be loaded onto name table 3--> 
-LEB89: and #$01 ;store #$00 if it should be loaded onto name table 0. +LEB89:  and #$01                        ;store #$00 if it should be loaded onto name table 0. 
-LEB8B: rts ;+LEB8B:  rts                             ;
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 6843: Line 6843:
 ; ======== ; ========
  
- LoadDoor: +        LoadDoor: 
- jsr LEB92+        jsr LEB92
 *       jmp EnemyLoop    ; do next room object *       jmp EnemyLoop    ; do next room object
  
 LEB92:  iny LEB92:  iny
- lda ($00),    ; door info byte +        lda ($00),    ; door info byte 
- pha +        pha 
- jsr Amul16      ; CF = door side (0=right, 1=left) +        jsr Amul16      ; CF = door side (0=right, 1=left) 
- php +        php 
- lda MapPosX +        lda MapPosX 
- clc +        clc 
- adc MapPosY +        adc MapPosY 
- plp +        plp 
- rol +        rol 
- and #$03 +        and #$03 
- tay +        tay 
- ldx $EC00,y +        ldx $EC00,y 
- pla      ; retrieve door info +        pla          ; retrieve door info 
- and #$03 +        and #$03 
- sta $0307,    ; door palette +        sta $0307,    ; door palette 
- tya +        tya 
- pha +        pha 
- lda $0307,x +        lda $0307,x 
- cmp #$01 +        cmp #$01 
- beq ++ +        beq ++ 
- cmp #$03 +        cmp #$03 
- beq ++ +        beq ++ 
- lda #$0A +        lda #$0A 
- sta $09 +        sta $09 
- ldy MapPosX +        ldy MapPosX 
- txa +        txa 
- jsr Amul16       ; * 16 +        jsr Amul16       ; * 16 
- bcc + +        bcc + 
- dey+        dey
 *       tya *       tya
- jsr LEE41 +        jsr LEE41 
- jsr LEE4A +        jsr LEE4A 
- bcs ++ +        bcs ++ 
-* lda #$01 +      lda #$01 
- sta ObjAction,x+        sta ObjAction,x
 *       pla *       pla
- and #$01 ; A = door side (0=right, 1=left) +        and #$01        ; A = door side (0=right, 1=left) 
- tay +        tay 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- sta ObjectHi,+        sta ObjectHi,
- lda DoorXs,   ; get door's X coordinate +        lda DoorXs,   ; get door's X coordinate 
- sta ObjectX,x +        sta ObjectX,x 
- lda #$68 ; door Y coord is always #$68 +        lda #$68        ; door Y coord is always #$68 
- sta ObjectY,x +        sta ObjectY,x 
- lda LEBFE,y +        lda LEBFE,y 
- tay +        tay 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- eor #$01 +        eor #$01 
- tax +        tax 
- tya +        tya 
- ora DoorOnNameTable3,+        ora DoorOnNameTable3,
- sta DoorOnNameTable3,+        sta DoorOnNameTable3,
- lda #$02 +        lda #$02 
- rts+        rts
  
 DoorXs: DoorXs:
- .byte $F0  ; X coord of RIGHT door +        .byte $F0        ; X coord of RIGHT door 
- .byte $10  ; X coord of LEFT door+        .byte $10        ; X coord of LEFT door
 LEBFE:  .byte $02 LEBFE:  .byte $02
- .byte $01+        .byte $01
 LEC00:  .byte $80 LEC00:  .byte $80
- .byte $B0 +        .byte $B0 
- .byte $A0 +        .byte $A0 
- .byte $90+        .byte $90
  
 ; LoadElevator ; LoadElevator
 ; ============ ; ============
  
- LoadElevator: +        LoadElevator: 
- jsr LEC09 +        jsr LEC09 
- bne ----    ; branch always+        bne ----           ; branch always
  
 LEC09:  lda ElevatorStatus LEC09:  lda ElevatorStatus
- bne +    ; exit if elevator already present +        bne +      ; exit if elevator already present 
- iny +        iny 
- lda ($00),y +        lda ($00),y 
- sta $032F +        sta $032F 
- ldy #$83 +        ldy #$83 
- sty $032D       ; elevator Y coord +        sty $032D       ; elevator Y coord 
- lda #$80 +        lda #$80 
- sta $032E       ; elevator X coord +        sta $032E       ; elevator X coord 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- sta $032C       ; high Y coord +        sta $032C       ; high Y coord 
- lda #$23 +        lda #$23 
- sta $0323       ; elevator frame +        sta $0323       ; elevator frame 
- inc ElevatorStatus ;1+        inc ElevatorStatus              ;1
 *       lda #$02 *       lda #$02
- rts+        rts
  
 ; LoadStatues ; LoadStatues
 ; =========== ; ===========
  
- LoadStatues: +        LoadStatues: 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- sta $036C +        sta $036C 
- lda #$40 +        lda #$40 
- ldx RidleyStatueStatus +        ldx RidleyStatueStatus 
- bpl +    ; branch if Ridley statue not hit +        bpl +      ; branch if Ridley statue not hit 
- lda #$30+        lda #$30
 *       sta $0370 *       sta $0370
- lda #$60 +        lda #$60 
- ldx KraidStatueStatus +        ldx KraidStatueStatus 
- bpl +    ; branch if Kraid statue not hit +        bpl +      ; branch if Kraid statue not hit 
- lda #$50+        lda #$50
 *       sta $036F *       sta $036F
- sty $54 +        sty $54 
- lda #$01 +        lda #$01 
- sta $0360 +        sta $0360 
-* jmp EnemyLoop   ; do next room object+      jmp EnemyLoop   ; do next room object
  
 ZebHole: ZebHole:
 LEC57:  ldx #$20 LEC57:  ldx #$20
 *       txa *       txa
- sec +        sec 
- sbc #$08 +        sbc #$08 
- bmi + +        bmi + 
- tax +        tax 
- ldy $0728,x +        ldy $0728,x 
- iny +        iny 
- bne - +        bne - 
- ldy #$00 +        ldy #$00 
- lda ($00),y +        lda ($00),y 
- and #$F0 +        and #$F0 
- sta $0729,x +        sta $0729,x 
- iny +        iny 
- lda ($00),y +        lda ($00),y 
- sta $0728,x +        sta $0728,x 
- iny +        iny 
- lda ($00),y +        lda ($00),y 
- tay +        tay 
- and #$F0 +        and #$F0 
- ora #$08 +        ora #$08 
- sta $072A,x +        sta $072A,x 
- tya +        tya 
- jsr Amul16       ; * 16 +        jsr Amul16       ; * 16 
- ora #$00 +        ora #$00 
- sta $072B,x +        sta $072B,x 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- sta $072C,x+        sta $072C,x
 *       lda #$03 *       lda #$03
- bne ---+        bne ---
  
 OnNameTable0: OnNameTable0:
-LEC93: lda PPUCNT0ZP +LEC93:  lda PPUCNT0ZP                   
- eor #$01 ;If currently on name table 0,--> +        eor #$01                        ;If currently on name table 0,--> 
- and #$01 ;return #$01. Else return #$00. +        and #$01                        ;return #$01. Else return #$00. 
- tay +        tay                             
- rts ;+        rts                             ;
  
 UpdateRoomSpriteInfo: UpdateRoomSpriteInfo:
-LEC9B: ldx ScrollDir +LEC9B:  ldx ScrollDir 
- dex +        dex 
- ldy #$00 +        ldy #$00 
- jsr UpdateDoorData ;($ED51)Update name table 0 door data. +        jsr UpdateDoorData              ;($ED51)Update name table 0 door data. 
- iny +        iny 
- jsr UpdateDoorData ;($ED51)Update name table 3 door data. +        jsr UpdateDoorData              ;($ED51)Update name table 3 door data. 
- ldx #$50 +        ldx #$50 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- tay+        tay
 *       tya *       tya
- eor EnNameTable,+        eor EnNameTable,
- lsr +        lsr 
- bcs + +        bcs + 
- lda $0405,x +        lda $0405,x 
- and #$02 +        and #$02 
- bne + +        bne + 
- sta EnStatus,x+        sta EnStatus,x
 *       jsr Xminus16 *       jsr Xminus16
- bpl -- +        bpl -- 
- ldx #$18+        ldx #$18
 *       tya *       tya
- eor $B3,x +        eor $B3,x 
- lsr +        lsr 
- bcs + +        bcs + 
- lda #$00 +        lda #$00 
- sta $B0,x+        sta $B0,x
 *       txa *       txa
- sec +        sec 
- sbc #$08 +        sbc #$08 
- tax +        tax 
- bpl -- +        bpl -- 
- jsr LED65 +        jsr LED65 
- jsr LED5B +        jsr LED5B 
- jsr GetNameTable ;(EB85) +        jsr GetNameTable                ;(EB85) 
- asl +        asl 
- asl +        asl 
- tay +        tay 
- ldx #$C0+        ldx #$C0
 *       tya *       tya
- eor TileWRAMHi,+        eor TileWRAMHi,
- and #$04 +        and #$04 
- bne + +        bne + 
- sta $0500,x+        sta $0500,x
 *       jsr Xminus16 *       jsr Xminus16
- cmp #$F0 +        cmp #$F0 
- bne -- +        bne -- 
- tya +        tya 
- lsr +        lsr 
- lsr +        lsr 
- tay +        tay 
- ldx #$D0 +        ldx #$D0 
- jsr LED7A +        jsr LED7A 
- ldx #$E0 +        ldx #$E0 
- jsr LED7A +        jsr LED7A 
- ldx #$F0 +        ldx #$F0 
- jsr LED7A +        jsr LED7A 
- tya +        tya 
- sec +        sec 
- sbc $032C +        sbc $032C 
- bne + +        bne + 
- sta ElevatorStatus+        sta ElevatorStatus
 *       ldx #$1E *       ldx #$1E
 *       lda $0704,x *       lda $0704,x
- bne + +        bne + 
- lda #$FF +        lda #$FF 
- sta $0700,x+        sta $0700,x
 *       txa *       txa
- sec +        sec 
- sbc #$06 +        sbc #$06 
- tax +        tax 
- bpl -- +        bpl -- 
- cpy $036C +        cpy $036C 
- bne + +        bne + 
- lda #$00 +        lda #$00 
- sta $0360+        sta $0360
 *       ldx #$18 *       ldx #$18
 *       tya *       tya
- cmp $072C,x +        cmp $072C,x 
- bne + +        bne + 
- lda #$FF +        lda #$FF 
- sta $0728,x+        sta $0728,x
 *       txa *       txa
- sec +        sec 
- sbc #$08 +        sbc #$08 
- tax +        tax 
- bpl -- +        bpl -- 
- ldx #$00 +        ldx #$00 
- jsr LED8C +        jsr LED8C 
- ldx #$08 +        ldx #$08 
- jsr LED8C +        jsr LED8C 
- jmp $95AE+        jmp $95AE
  
 UpdateDoorData: UpdateDoorData:
-LED51: txa +LED51:  txa                             
-LED52: eor #$03 +LED52:  eor #$03                        
-LED54: and $006C,y ;Moves door info from one name table to the next--> +LED54:  and $006C,                    ;Moves door info from one name table to the next--> 
-LED57:* sta $006C,y ;when the room is transferred across name tables. +LED57:* sta $006C,                    ;when the room is transferred across name tables. 
-LED5A: rts ;+LED5A:  rts                             ;
  
-LED5B:  jsr GetNameTable ;($EB85) +LED5B:  jsr GetNameTable                ;($EB85) 
- eor #$01 +        eor #$01 
- tay +        tay 
- lda #$00 +        lda #$00 
- beq -+        beq -
 LED65:  ldx #$B0 LED65:  ldx #$B0
 *       lda ObjAction,x *       lda ObjAction,x
- beq + +        beq + 
- lda ObjectOnScreen,+        lda ObjectOnScreen,
- bne + +        bne + 
- sta ObjAction,x+        sta ObjAction,x
 *       jsr Xminus16 *       jsr Xminus16
- bmi -- +        bmi -- 
- rts+        rts
  
 LED7A:  lda ObjAction,x LED7A:  lda ObjAction,x
- cmp #$05 +        cmp #$05 
- bcc + +        bcc + 
- tya +        tya 
- eor ObjectHi,+        eor ObjectHi,
- lsr +        lsr 
- bcs + +        bcs + 
- sta ObjAction,x+        sta ObjAction,x
 *       rts *       rts
  
 LED8C:  tya LED8C:  tya
- cmp PowerUpNameTable,+        cmp PowerUpNameTable,
- bne Exit11 +        bne Exit11 
- lda #$FF +        lda #$FF 
- sta PowerUpType,x+        sta PowerUpType,x
 Exit11: rts Exit11: rts
  
Line 7135: Line 7135:
  
 ScanForItems: ScanForItems:
-LED98: lda SpecItmsTable ;Low byte of ptr to 1st item data. +LED98:  lda SpecItmsTable               ;Low byte of ptr to 1st item data. 
-LED9B: sta $00 +LED9B:  sta $00                         
-LED9D: lda SpecItmsTable+1 ;High byte of ptr to 1st item data.+LED9D:  lda SpecItmsTable+1             ;High byte of ptr to 1st item data.
  
 ScanOneItem: ScanOneItem:
-LEDA0: sta $01 +LEDA0:  sta $01                         
-LEDA2: ldy #$00 ;Index starts at #$00. +LEDA2:  ldy #$00                        ;Index starts at #$00. 
-LEDA4: lda ($00),y ;Load map Ypos of item.--> +LEDA4:  lda ($00),                    ;Load map Ypos of item.--> 
-LEDA6: cmp MapPosY ;Does it equal Samus' Ypos on map?--> +LEDA6:  cmp MapPosY                     ;Does it equal Samus' Ypos on map?--> 
-LEDA8: beq + ;If yes, check Xpos too.+LEDA8:  beq +                           ;If yes, check Xpos too.
  
-LEDAA: bcs Exit11 ;Exit if item Y pos >  Samus Y Pos. +LEDAA:  bcs Exit11                      ;Exit if item Y pos >  Samus Y Pos. 
-LEDAC: iny +LEDAC:  iny                             
-LEDAD: lda ($00),y ;Low byte of ptr to next item data. +LEDAD:  lda ($00),                    ;Low byte of ptr to next item data. 
-LEDAF: tax +LEDAF:  tax                             
-LEDB0: iny +LEDB0:  iny                             
-LEDB1: and ($00),y ;AND with hi byte of item ptr. +LEDB1:  and ($00),                    ;AND with hi byte of item ptr. 
-LEDB3: cmp #$FF ;if result is FFh, then this was the last item--> +LEDB3:  cmp #$FF                        ;if result is FFh, then this was the last item--> 
-LEDB5: beq Exit11 ;(item ptr = FFFF). Branch to exit.+LEDB5:  beq Exit11                      ;(item ptr = FFFF). Branch to exit.
  
-LEDB7: lda ($00),y ;High byte of ptr to next item data. +LEDB7:  lda ($00),                    ;High byte of ptr to next item data. 
-LEDB9: stx $00 ;Write low byte for next item. +LEDB9:  stx $00                         ;Write low byte for next item. 
-LEDBB: jmp ScanOneItem ;Process next item.+LEDBB:  jmp ScanOneItem                 ;Process next item.
  
-LEDBE:* lda #$03 ;Get ready to look at byte containing X pos. +LEDBE:* lda #$03                        ;Get ready to look at byte containing X pos. 
-LEDC0: jsr AddToPtr00 ;($EF09)Add 3 to pointer at $0000.+LEDC0:  jsr AddToPtr00                  ;($EF09)Add 3 to pointer at $0000.
  
 ScanItemX: ScanItemX:
-LEDC3: ldy #$00 +LEDC3:  ldy #$00                        
-LEDC5: lda ($00),y ;Load map Xpos of object.--> +LEDC5:  lda ($00),                    ;Load map Xpos of object.--> 
-LEDC7: cmp MapPosX ;Does it equal Samus' Xpos on map?--> +LEDC7:  cmp MapPosX                     ;Does it equal Samus' Xpos on map?--> 
-LEDC9: beq + ;If so, then load object. +LEDC9:  beq +                           ;If so, then load object. 
-LEDCB: bcs Exit11 ;Exit if item pos X > Samus Pos X.+LEDCB:  bcs Exit11                      ;Exit if item pos X > Samus Pos X.
  
-LEDCD: iny +LEDCD:  iny                             
-LEDCE: jsr AnotherItem ;($EF00)Check for another item on same Y pos. +LEDCE:  jsr AnotherItem                 ;($EF00)Check for another item on same Y pos. 
-LEDD1: jmp ScanItemX ;Try next X coord.+LEDD1:  jmp ScanItemX                   ;Try next X coord.
  
-LEDD4:* lda #$02 ;Move ahead two bytes to find item data.+LEDD4:* lda #$02                        ;Move ahead two bytes to find item data.
  
 ChooseHandlerRoutine: ChooseHandlerRoutine:
-LEDD6: jsr AddToPtr00 ;($EF09)Add A to pointer at $0000. +LEDD6:  jsr AddToPtr00                  ;($EF09)Add A to pointer at $0000. 
-LEDD9: ldy #$00 +LEDD9:  ldy #$00                        
-LEDDB: lda ($00),y ;Object type +LEDDB:  lda ($00),                    ;Object type 
-LEDDD: and #$0F ;Object handling routine index stored in 4 LSBs. +LEDDD:  and #$0F                        ;Object handling routine index stored in 4 LSBs. 
-LEDDF: jsr ChooseRoutine ;($C27C)Load proper handling routine from table below.+LEDDF:  jsr ChooseRoutine               ;($C27C)Load proper handling routine from table below.
  
 ;Handler routines jumped to by above code. ;Handler routines jumped to by above code.
  
-LEDE2: .word ExitSub ;($C45C)rts. +LEDE2:  .word ExitSub                   ;($C45C)rts. 
-LEDE4: .word SqueeptHandler ;($EDF8)Some squeepts. +LEDE4:  .word SqueeptHandler            ;($EDF8)Some squeepts. 
-LEDE6: .word PowerUpHandler ;($EDFE)power-ups. +LEDE6:  .word PowerUpHandler            ;($EDFE)power-ups. 
-LEDE8: .word SpecEnemyHandler ;($EE63)Special enemies(Mellows, Melias and Memus). +LEDE8:  .word SpecEnemyHandler          ;($EE63)Special enemies(Mellows, Melias and Memus). 
-LEDEA: .word ElevatorHandler ;($EEA1)Elevators. +LEDEA:  .word ElevatorHandler           ;($EEA1)Elevators. 
-LEDEC: .word CannonHandler ;($EEA6)Mother brain room cannons. +LEDEC:  .word CannonHandler             ;($EEA6)Mother brain room cannons. 
-LEDEE: .word MotherBrainHandler ;($EEAE)Mother brain. +LEDEE:  .word MotherBrainHandler        ;($EEAE)Mother brain. 
-LEDF0: .word ZeebetiteHandler ;($EECA)Zeebetites. +LEDF0:  .word ZeebetiteHandler          ;($EECA)Zeebetites. 
-LEDF2: .word RinkaHandler ;($EEEE)Rinkas. +LEDF2:  .word RinkaHandler              ;($EEEE)Rinkas. 
-LEDF4: .word DoorHandler ;($EEF4)Some doors. +LEDF4:  .word DoorHandler               ;($EEF4)Some doors. 
-LEDF6: .word PaletteHandler ;($EEFA)Background palette change.+LEDF6:  .word PaletteHandler            ;($EEFA)Background palette change.
  
 ;---------------------------------------[ Squeept handler ]------------------------------------------ ;---------------------------------------[ Squeept handler ]------------------------------------------
  
 SqueeptHandler: SqueeptHandler:
-LEDF8: jsr GetEnemyData ;($EB0C)Load Squeept data. +LEDF8:  jsr GetEnemyData                ;($EB0C)Load Squeept data. 
-LEDFB:* jmp ChooseHandlerRoutine ;($EDD6)Exit handler routines.+LEDFB:* jmp ChooseHandlerRoutine        ;($EDD6)Exit handler routines.
  
 ;--------------------------------------[ Power-up Handler ]------------------------------------------ ;--------------------------------------[ Power-up Handler ]------------------------------------------
  
 PowerUpHandler: PowerUpHandler:
-LEDFE: iny ;Prepare to store item type. +LEDFE:  iny                             ;Prepare to store item type. 
-LEDFF: ldx #$00 +LEDFF:  ldx #$00                        
-LEE01: lda #$FF +LEE01:  lda #$FF                        
-LEE03: cmp PowerUpType ;Is first power-up item slot available?--> +LEE03:  cmp PowerUpType                 ;Is first power-up item slot available?--> 
-LEE06: beq + ;if yes, branch to load item.+LEE06:  beq +                           ;if yes, branch to load item.
  
-LEE08: ldx #$08 ;Prepare to check second power-up item slot. +LEE08:  ldx #$08                        ;Prepare to check second power-up item slot. 
-LEE0A: cmp PowerUpBType ;Is second power-up item slot available?-->  +LEE0A:  cmp PowerUpBType                ;Is second power-up item slot available?-->                      
-LEE0D: bne ++ ;If not, branch to exit. +LEE0D:  bne ++                          ;If not, branch to exit. 
-LEE0F:* lda ($00),y ;Power-up item type. +LEE0F:* lda ($00),                    ;Power-up item type. 
-LEE11: jsr PrepareItemID ;($EE3D)Get unique item ID. +LEE11:  jsr PrepareItemID               ;($EE3D)Get unique item ID. 
-LEE14: jsr CheckForItem ;($EE4A)Check if Samus already has item. +LEE14:  jsr CheckForItem                ;($EE4A)Check if Samus already has item. 
-LEE17: bcs + ;Samus already has item. do not load it.+LEE17:  bcs +                           ;Samus already has item. do not load it.
  
-LEE19: ldy #$02 ;Prepare to load item coordinates. +LEE19:  ldy #$02                        ;Prepare to load item coordinates. 
-LEE1B: lda $09 +LEE1B:  lda $09                         
-LEE1D: sta PowerUpType,x ;Store power-up type in available item slot. +LEE1D:  sta PowerUpType,              ;Store power-up type in available item slot. 
-LEE20: lda ($00),y ;Load x and y screen positions of item. +LEE20:  lda ($00),                    ;Load x and y screen positions of item. 
-LEE22: tay ;Save position data for later processing. +LEE22:  tay                             ;Save position data for later processing. 
-LEE23: and #$F0 ;Extract Y coordinate. +LEE23:  and #$F0                        ;Extract Y coordinate. 
-LEE25: ora #$08 ;+ 8 to find  Y coordinate center. +LEE25:  ora #$08                        ;+ 8 to find  Y coordinate center. 
-LEE27: sta PowerUpYCoord,x ;Store center Y coord +LEE27:  sta PowerUpYCoord,            ;Store center Y coord 
-LEE2A: tya ;Reload position data. +LEE2A:  tya                             ;Reload position data. 
-LEE2B: jsr Amul16 ;($C2C5)*16. Move lower 4 bits to upper 4 bits. +LEE2B:  jsr Amul16                      ;($C2C5)*16. Move lower 4 bits to upper 4 bits. 
-LEE2E: ora #$08 ;+ 8 to find X coordinate center. +LEE2E:  ora #$08                        ;+ 8 to find X coordinate center. 
-LEE30: sta PowerUpXCoord,x ;Store center X coord +LEE30:  sta PowerUpXCoord,            ;Store center X coord 
-LEE33: jsr GetNameTable ;($EB85)Get name table to place item on. +LEE33:  jsr GetNameTable                ;($EB85)Get name table to place item on. 
-LEE36: sta PowerUpNameTable,x ;Store name table Item is located on.+LEE36:  sta PowerUpNameTable,         ;Store name table Item is located on.
  
-LEE39:* lda #$03 ;Get next data byte(Always #$00). +LEE39:* lda #$03                        ;Get next data byte(Always #$00). 
-LEE3B: bne --- ;Branch always to exit handler routines. +LEE3B:  bne ---                         ;Branch always to exit handler routines. 
- +        
 PrepareItemID: PrepareItemID:
-LEE3D: sta $09 ;Store item type. +LEE3D:  sta $09                         ;Store item type. 
-LEE3E: lda MapPosX ;+LEE3E:  lda MapPosX                     ;
  
-LEE41: sta $07 ;Store item X coordinate. +LEE41:  sta $07                         ;Store item X coordinate. 
-LEE42: lda MapPosY +LEE42:  lda MapPosY                     
-LEE45: sta $06 ;Store item Y coordinate. +LEE45:  sta $06                         ;Store item Y coordinate. 
-LEE47: jmp CreateItemID ;($DC67)Get unique item ID.+LEE47:  jmp CreateItemID                ;($DC67)Get unique item ID.
  
 CheckForItem: CheckForItem:
-LEE4A: ldy NumberOfUniqueItems +LEE4A:  ldy NumberOfUniqueItems         
-LEE4D: beq +++ ;Samus has no unique items. Load item and exit. +LEE4D:  beq +++                         ;Samus has no unique items. Load item and exit. 
-LEE4F:* lda $07 +LEE4F:* lda $07                         
-LEE51: cmp NumberOfUniqueItems,y ;Look for lower byte of unique item. +LEE51:  cmp NumberOfUniqueItems,      ;Look for lower byte of unique item. 
-LEE54: bne + +LEE54:  bne +                           
-LEE56: lda $06 ;Look for upper byte of unique item. +LEE56:  lda $06                         ;Look for upper byte of unique item. 
-LEE58: cmp DataSlot,y +LEE58:  cmp DataSlot,                 
-LEE5B: beq +++ ;Samus already has item. Branch to exit. +LEE5B:  beq +++                         ;Samus already has item. Branch to exit. 
-LEE5D:* dey +LEE5D:* dey                             
-LEE5E: dey +LEE5E:  dey                             
-LEE5F: bne -- ;Loop until all Samus' unique items are checked. +LEE5F:  bne --                          ;Loop until all Samus' unique items are checked. 
-LEE61:* clc ;Samus does not have the item. It will be placed on screen. +LEE61:* clc                             ;Samus does not have the item. It will be placed on screen. 
-LEE62:* rts ;+LEE62:* rts                             ;
  
 ;----------------------------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------------------------
Line 7265: Line 7265:
 SpecEnemyHandler: SpecEnemyHandler:
 LEE63:  ldx #$18 LEE63:  ldx #$18
- lda RandomNumber1 +        lda RandomNumber1 
- adc FrameCount +        adc FrameCount 
- sta $8A+        sta $8A
 *       jsr LEE86 *       jsr LEE86
- txa +        txa 
- sec +        sec 
- sbc #$08 +        sbc #$08 
- tax +        tax 
- bpl - +        bpl - 
- lda $95E4 +        lda $95E4 
- sta $6BE9 +        sta $6BE9 
- sta $6BEA +        sta $6BEA 
- lda #$01 +        lda #$01 
- sta $6BE4 +        sta $6BE4 
-*       jmp ChooseHandlerRoutine ;($EDD6)Exit handler routines.+*       jmp ChooseHandlerRoutine        ;($EDD6)Exit handler routines.
  
 LEE86:  lda $B0,x LEE86:  lda $B0,x
- bne + +        bne + 
- txa +        txa 
- adc $8A +        adc $8A 
- and #$7F +        and #$7F 
- sta $B1,x +        sta $B1,x 
- adc RandomNumber2 +        adc RandomNumber2 
- sta $B2,x +        sta $B2,x 
- jsr GetNameTable ;($EB85) +        jsr GetNameTable                ;($EB85) 
- sta $B3,x +        sta $B3,x 
- lda #$01 +        lda #$01 
- sta $B0,x +        sta $B0,x 
- rol $8A+        rol $8A
 *       rts *       rts
  
 ElevatorHandler: ElevatorHandler:
 LEEA1:  jsr LEC09 LEEA1:  jsr LEC09
- bne -- ;Branch always.+        bne --                          ;Branch always.
  
 CannonHandler: CannonHandler:
 LEEA6:  jsr $95B1 LEEA6:  jsr $95B1
- lda #$02 +        lda #$02 
-*       jmp ChooseHandlerRoutine ;($EDD6)Exit handler routines.+*       jmp ChooseHandlerRoutine        ;($EDD6)Exit handler routines.
  
 MotherBrainHandler: MotherBrainHandler:
 LEEAE:  jsr $95B4 LEEAE:  jsr $95B4
- lda #$38 +        lda #$38 
- sta $07 +        sta $07 
- lda #$00 +        lda #$00 
- sta $06 +        sta $06 
- jsr LEE4A +        jsr LEE4A 
- bcc LEEC6 +        bcc LEEC6 
- lda #$08 +        lda #$08 
- sta MotherBrainStatus +        sta MotherBrainStatus 
- lda #$00 +        lda #$00 
- sta MotherBrainHits+        sta MotherBrainHits
 LEEC6:  lda #$01 LEEC6:  lda #$01
- bne -+        bne -
  
 ZeebetiteHandler: ZeebetiteHandler:
 LEECA:  jsr $95B7 LEECA:  jsr $95B7
- txa +        txa 
- lsr +        lsr 
- adc #$3C +        adc #$3C 
- sta $07 +        sta $07 
- lda #$00 +        lda #$00 
- sta $06 +        sta $06 
- jsr LEE4A +        jsr LEE4A 
- bcc + +        bcc + 
- lda #$81 +        lda #$81 
- sta $0758,x +        sta $0758,x 
- lda #$01 +        lda #$01 
- sta $075D,x +        sta $075D,x 
- lda #$07 +        lda #$07 
- sta $075B,x+        sta $075B,x
 *       jmp LEEC6 *       jmp LEEC6
  
 RinkaHandler: RinkaHandler:
 LEEEE:  jsr $95BA LEEEE:  jsr $95BA
- jmp LEEC6+        jmp LEEC6
  
 DoorHandler: DoorHandler:
 LEEF4:  jsr LEB92 LEEF4:  jsr LEB92
- jmp ChooseHandlerRoutine ;($EDD6)Exit handler routines.+        jmp ChooseHandlerRoutine        ;($EDD6)Exit handler routines.
  
 PaletteHandler: PaletteHandler:
 LEEFA:  lda ScrollDir LEEFA:  lda ScrollDir
- sta $91 +        sta $91 
- bne LEEC6+        bne LEEC6
  
 AnotherItem: AnotherItem:
-LEF00: lda ($00),y ;Is there another item with same Y pos?--> +LEF00:  lda ($00),                    ;Is there another item with same Y pos?--> 
- cmp #$FF ;If so, A is amount to add to ptr. to find X pos. +        cmp #$FF                        ;If so, A is amount to add to ptr. to find X pos. 
- bne AddToPtr00 ;($EF09) +        bne AddToPtr00                  ;($EF09) 
- pla +        pla                             
- pla ;No more items to check. Pull last subroutine--> +        pla                             ;No more items to check. Pull last subroutine--> 
- rts ;off stack and exit.+        rts                             ;off stack and exit.
  
 AddToPtr00: AddToPtr00:
-LEF09: clc +LEF09:  clc                             
- adc $00 +        adc $00                         
- sta $00 ;A is added to the 16 bit address stored in $0000. +        sta $00                         ;A is added to the 16 bit address stored in $0000. 
- bcc + +        bcc +                           
- inc $01 +        inc $01                         
-*       rts ;+*       rts                             ;
  
 ;----------------------------------[ Draw structure routines ]---------------------------------------- ;----------------------------------[ Draw structure routines ]----------------------------------------
Line 7373: Line 7373:
  
 DrawStructRow: DrawStructRow:
-LEF13: and #$0F ;Row length(in macros). Range #$00 thru #$0F. +LEF13:  and #$0F                        ;Row length(in macros). Range #$00 thru #$0F. 
-LEF15: bne + +LEF15:  bne +                           
-LEF17: lda #$10 ;#$00 in row length=16. +LEF17:  lda #$10                        ;#$00 in row length=16. 
-LEF19:* sta $0E ;Store horizontal macro count. +LEF19:* sta $0E                         ;Store horizontal macro count. 
-LEF1B: lda (StructPtr),y ;Get length byte again. +LEF1B:  lda (StructPtr),              ;Get length byte again. 
-LEF1D: jsr Adiv16 ;($C2BF)/16. Upper nibble contains x coord offset(if any). +LEF1D:  jsr Adiv16                      ;($C2BF)/16. Upper nibble contains x coord offset(if any). 
-LEF20: asl ;*2, because a macro is 2 tiles wide. +LEF20:  asl                             ;*2, because a macro is 2 tiles wide. 
-LEF21: adc CartRAMWorkPtr ;Add x coord offset to CartRAMWorkPtr and save in $00. +LEF21:  adc CartRAMWorkPtr              ;Add x coord offset to CartRAMWorkPtr and save in $00. 
-LEF23: sta $00 +LEF23:  sta $00                         
-LEF25: lda #$00 +LEF25:  lda #$00                        
-LEF27: adc CartRAMWorkPtr+1 ;Save high byte of work pointer in $01. +LEF27:  adc CartRAMWorkPtr+1            ;Save high byte of work pointer in $01. 
-LEF29: sta $01 ;$0000 = work pointer.+LEF29:  sta $01                         ;$0000 = work pointer.
  
 DrawMacro: DrawMacro:
-LEF2B: lda $01 ;High byte of current location in room RAM. +LEF2B:  lda $01                         ;High byte of current location in room RAM. 
-LEF2D: cmp #$63 ;Check high byte of room RAM address for both room RAMs--> +LEF2D:  cmp #$63                        ;Check high byte of room RAM address for both room RAMs--> 
-LEF2F: beq + ;to see if the attribute table data for the room RAM has--> +LEF2F:  beq +                           ;to see if the attribute table data for the room RAM has--> 
-LEF31: cmp #$67 ;been reached.  If so, branch to check lower byte as well. +LEF31:  cmp #$67                        ;been reached.  If so, branch to check lower byte as well. 
-LEF33: bcc ++ ;If not at end of room RAM, branch to draw macro. +LEF33:  bcc ++                          ;If not at end of room RAM, branch to draw macro. 
-LEF35: beq + +LEF35:  beq +                           
-LEF37: rts ;Return if have gone past room RAM(should never happen).+LEF37:  rts                             ;Return if have gone past room RAM(should never happen).
  
-LEF38:* lda $00 ;Low byte of current nametable address. +LEF38:* lda $00                         ;Low byte of current nametable address. 
-LEF3A: cmp #$A0 ;Reached attrib table?--> +LEF3A:  cmp #$A0                        ;Reached attrib table?--> 
-LEF3C: bcc + ;If not, branch to draw the macro. +LEF3C:  bcc +                           ;If not, branch to draw the macro. 
-LEF3E: rts ;Can't draw any more of the structure, exit.+LEF3E:  rts                             ;Can't draw any more of the structure, exit.
  
-LEF3F:* inc $10 ;Increase struct data index. +LEF3F:* inc $10                         ;Increase struct data index. 
-LEF41: ldy $10 ;Load struct data index into Y. +LEF41:  ldy $10                         ;Load struct data index into Y. 
-LEF43: lda (StructPtr),y ;Get macro number. +LEF43:  lda (StructPtr),              ;Get macro number. 
-LEF45: asl +LEF45:  asl                             
-LEF46: asl ;A=macro number * 4. Each macro is 4 bytes long. +LEF46:  asl                             ;A=macro number * 4. Each macro is 4 bytes long. 
-LEF47: sta $11 ;Store macro index. +LEF47:  sta $11                         ;Store macro index. 
-LEF49: ldx #$03 ;Prepare to copy four tile numbers. +LEF49:  ldx #$03                        ;Prepare to copy four tile numbers. 
-LEF4B:* ldy $11 ;Macro index loaded into Y. +LEF4B:* ldy $11                         ;Macro index loaded into Y. 
-LEF4D: lda (MacroPtr),y ;Get tile number. +LEF4D:  lda (MacroPtr),               ;Get tile number. 
-LEF4F: inc $11 ;Increase macro index +LEF4F:  inc $11                         ;Increase macro index 
-LEF51: ldy TilePosTable,x ;get tile position in macro. +LEF51:  ldy TilePosTable,             ;get tile position in macro. 
-LEF54: sta ($00),y ;Write tile number to room RAM. +LEF54:  sta ($00),                    ;Write tile number to room RAM. 
-LEF56: dex ;Done four tiles yet?--> +LEF56:  dex                             ;Done four tiles yet?--> 
-LEF57: bpl - ;If not, loop to do another. +LEF57:  bpl -                           ;If not, loop to do another. 
-LEF59: jsr UpdateAttrib ;($EF9E)Update attribute table if necessary +LEF59:  jsr UpdateAttrib                ;($EF9E)Update attribute table if necessary 
-LEF5C: ldy #$02 ;Macro width(in tiles). +LEF5C:  ldy #$02                        ;Macro width(in tiles). 
-LEF5E: jsr AddYToPtr00 ;($C2A8)Add 2 to pointer to move to next macro. +LEF5E:  jsr AddYToPtr00                 ;($C2A8)Add 2 to pointer to move to next macro. 
-LEF61: lda $00 ;Low byte of current room RAM work pointer. +LEF61:  lda $00                         ;Low byte of current room RAM work pointer. 
-LEF63: and #$1F ;Still room left in current row?--> +LEF63:  and #$1F                        ;Still room left in current row?--> 
-LEF65: bne + ;If yes, branch to do another macro.+LEF65:  bne +                           ;If yes, branch to do another macro.
  
 ;End structure row early to prevent it from wrapping on to the next row.. ;End structure row early to prevent it from wrapping on to the next row..
-LEF67: lda $10 ;Struct index. +LEF67:  lda $10                         ;Struct index. 
-LEF69: clc +LEF69:  clc                             
-LEF6A: adc $0E ;Add number of macros remaining in current row. +LEF6A:  adc $0E                         ;Add number of macros remaining in current row. 
-LEF6C: sec +LEF6C:  sec                             
-LEF6D: sbc #$01 ;-1 from macros remaining in current row. +LEF6D:  sbc #$01                        ;-1 from macros remaining in current row. 
-LEF6F: jmp AdvanceRow ;($EF78)Move to next row of structure.+LEF6F:  jmp AdvanceRow                  ;($EF78)Move to next row of structure.
  
-LEF72:* dec $0E ;Have all macros been drawn on this row?--> +LEF72:* dec $0E                         ;Have all macros been drawn on this row?--> 
-LEF74: bne DrawMacro ;If not, branch to draw another macro. +LEF74:  bne DrawMacro                   ;If not, branch to draw another macro. 
-LEF76: lda $10 ;Load struct index.+LEF76:  lda $10                         ;Load struct index.
  
 AdvanceRow: AdvanceRow:
-LEF78: sec ;Since carry bit is set,--> +LEF78:  sec                             ;Since carry bit is set,--> 
-LEF79: adc StructPtr ;addition will be one more than expected. +LEF79:  adc StructPtr                   ;addition will be one more than expected. 
-LEF7B: sta StructPtr ;Update the struct pointer. +LEF7B:  sta StructPtr                   ;Update the struct pointer. 
-LEF7D: bcc + +LEF7D:  bcc +                           
-LEF7F: inc StructPtr+1 ;Update high byte of struct pointer if carry occured. +LEF7F:  inc StructPtr+1                 ;Update high byte of struct pointer if carry occured. 
-LEF81:* lda #$40 +LEF81:* lda #$40                        
-LEF83: clc +LEF83:  clc                             
-LEF84: adc CartRAMWorkPtr ;Advance to next macro row in room RAM(two tile rows). +LEF84:  adc CartRAMWorkPtr              ;Advance to next macro row in room RAM(two tile rows). 
-LEF86: sta CartRAMWorkPtr +LEF86:  sta CartRAMWorkPtr              
-LEF88: bcc DrawStruct ;Begin drawing next structure row. +LEF88:  bcc DrawStruct                  ;Begin drawing next structure row. 
-LEF8A: inc CartRAMWorkPtr+1 ;Increment high byte of pointer if necessary.+LEF8A:  inc CartRAMWorkPtr+1            ;Increment high byte of pointer if necessary.
  
 DrawStruct: DrawStruct:
-LEF8C: ldy #$00 ;Reset struct index. +LEF8C:  ldy #$00                        ;Reset struct index. 
-LEF8E: sty $10 +LEF8E:  sty $10                         
-LEF90: lda (StructPtr),y ;Load data byte. +LEF90:  lda (StructPtr),              ;Load data byte. 
-LEF92: cmp #$FF ;End-of-struct?--> +LEF92:  cmp #$FF                        ;End-of-struct?--> 
-LEF94: beq + ;If so, branch to exit. +LEF94:  beq +                           ;If so, branch to exit. 
-LEF96: jmp DrawStructRow ;($EF13)Draw a row of macros. +LEF96:  jmp DrawStructRow               ;($EF13)Draw a row of macros. 
-LEF99:* rts ;+LEF99:* rts                             ;
  
 ;The following table is used to draw macros in room RAM. Each macro is 2 x 2 tiles. ;The following table is used to draw macros in room RAM. Each macro is 2 x 2 tiles.
Line 7459: Line 7459:
  
 TilePosTable: TilePosTable:
-LEF9A: .byte $21 ;Lower right tile. +LEF9A:  .byte $21                       ;Lower right tile. 
-LEF9B: .byte $20 ;Lower left tile. +LEF9B:  .byte $20                       ;Lower left tile. 
-LEF9C: .byte $01 ;Upper right tile. +LEF9C:  .byte $01                       ;Upper right tile. 
-LEF9D: .byte $00 ;Upper left tile.+LEF9D:  .byte $00                       ;Upper left tile.
  
 ;---------------------------------[ Update attribute table bits ]------------------------------------ ;---------------------------------[ Update attribute table bits ]------------------------------------
Line 7469: Line 7469:
  
 UpdateAttrib: UpdateAttrib:
-LEF9E: lda ObjectPal ;Load attribute data of structure. +LEF9E:  lda ObjectPal                   ;Load attribute data of structure. 
-LEFA0: cmp RoomPal ;Is it the same as the room's default attribute data?--> +LEFA0:  cmp RoomPal                     ;Is it the same as the room's default attribute data?--> 
-LEFA2: beq +++++ ;If so, no need to modify the attribute table, exit.+LEFA2:  beq +++++                       ;If so, no need to modify the attribute table, exit.
  
 ;Figure out cart RAM address of the byte containing the relevant bits. ;Figure out cart RAM address of the byte containing the relevant bits.
  
-LEFA4: lda $00 +LEFA4:  lda $00                         
-LEFA6: sta $02 +LEFA6:  sta $02                         
-LEFA8: lda $01 +LEFA8:  lda $01                         
-LEFAA: lsr +LEFAA:  lsr                             
-LEFAB: ror $02 +LEFAB:  ror $02                         
-LEFAD: lsr +LEFAD:  lsr                             
-LEFAE: ror $02 +LEFAE:  ror $02                         
-LEFB0: lda $02 ;The following section of code calculates the--> +LEFB0:  lda $02                         ;The following section of code calculates the--> 
-LEFB2: and #$07 ;proper attribute byte that corresponds to the--> +LEFB2:  and #$07                        ;proper attribute byte that corresponds to the--> 
-LEFB4: sta $03 ;macro that has just been placed in the room RAM. +LEFB4:  sta $03                         ;macro that has just been placed in the room RAM. 
-LEFB6: lda $02 +LEFB6:  lda $02                         
-LEFB8: lsr +LEFB8:  lsr                             
-LEFB9: lsr +LEFB9:  lsr                             
-LEFBA: and #$38 +LEFBA:  and #$38                        
-LEFBC: ora $03 +LEFBC:  ora $03                         
-LEFBE: ora #$C0 +LEFBE:  ora #$C0                        
-LEFC0: sta $02 +LEFC0:  sta $02                         
-LEFC2: lda #$63 +LEFC2:  lda #$63                        
-LEFC4: sta $03 ;$0002 contains pointer to attribute byte.+LEFC4:  sta $03                         ;$0002 contains pointer to attribute byte.
  
-LEFC6: ldx #$00 +LEFC6:  ldx #$00                        
-LEFC8: bit $00 +LEFC8:  bit $00                         
-LEFCA: bvc + +LEFCA:  bvc +                           
-LEFCC: ldx #$02 ;The following section of code figures out which--> +LEFCC:  ldx #$02                        ;The following section of code figures out which--> 
-LEFCE:* lda $00 ;pair of bits to modify in the attribute table byte--> +LEFCE:* lda $00                         ;pair of bits to modify in the attribute table byte--> 
-LEFD0: and #$02 ;for the macro that has just been placed in the--> +LEFD0:  and #$02                        ;for the macro that has just been placed in the--> 
-LEFD2: beq + ;room RAM. +LEFD2:  beq +                           ;room RAM. 
-LEFD4: inx ;+LEFD4:  inx                             ;
  
 ;X now contains which macro attribute table bits to modify: ;X now contains which macro attribute table bits to modify:
Line 7513: Line 7513:
  
 ;The following code clears the old attribute table bits and sets the new ones. ;The following code clears the old attribute table bits and sets the new ones.
-LEFD5:* lda $01 ;Load high byte of work pointer in room RAM. +LEFD5:* lda $01                         ;Load high byte of work pointer in room RAM. 
-LEFD7: and #$04 +LEFD7:  and #$04                        
-LEFD9: ora $03 ;Choose proper attribute table associated with the--> +LEFD9:  ora $03                         ;Choose proper attribute table associated with the--> 
-LEFDB: sta $03 ;current room RAM. +LEFDB:  sta $03                         ;current room RAM. 
-LEFDD: lda AttribMaskTable,x ;Choose appropriate attribute table bit mask from table below. +LEFDD:  lda AttribMaskTable,          ;Choose appropriate attribute table bit mask from table below. 
-LEFE0: ldy #$00 +LEFE0:  ldy #$00                        
-LEFE2: and ($02),y ;clear the old attribute table bits. +LEFE2:  and ($02),                    ;clear the old attribute table bits. 
-LEFE4: sta ($02),y +LEFE4:  sta ($02),                    
-LEFE6: lda ObjectPal ;Load new attribute table data(#$00 thru #$03). +LEFE6:  lda ObjectPal                   ;Load new attribute table data(#$00 thru #$03). 
-LEFE8:* dex +LEFE8:* dex                             
-LEFE9: bmi + +LEFE9:  bmi +                           
-LEFEB: asl +LEFEB:  asl                             
-LEFEC: asl ;Attribute table bits shifted one step left +LEFEC:  asl                             ;Attribute table bits shifted one step left 
-LEFED: bcc - ;Loop until attribute table bits are in the proper location. +LEFED:  bcc -                           ;Loop until attribute table bits are in the proper location. 
-LEFEF:* ora ($02),y +LEFEF:* ora ($02),                    
-LEFF1: sta ($02),y ;Set attribute table bits. +LEFF1:  sta ($02),                    ;Set attribute table bits. 
-LEFF3:* rts ;+LEFF3:* rts                             ;
  
 AttribMaskTable: AttribMaskTable:
-LEFF4: .byte %11111100 ;Upper left macro. +LEFF4:  .byte %11111100                 ;Upper left macro. 
-LEFF5: .byte %11110011 ;Upper right macro. +LEFF5:  .byte %11110011                 ;Upper right macro. 
-LEFF6: .byte %11001111 ;Lower left macro. +LEFF6:  .byte %11001111                 ;Lower left macro. 
-LEFF7: .byte %00111111 ;Lower right macro.+LEFF7:  .byte %00111111                 ;Lower right macro.
  
 ;------------------------[ Initialize room RAM and associated attribute table ]----------------------- ;------------------------[ Initialize room RAM and associated attribute table ]-----------------------
  
 InitTables: InitTables:
-LEFF8: lda CartRAMPtr+1 ;#$60 or #$64. +LEFF8:  lda CartRAMPtr+1                ;#$60 or #$64. 
-LEFFA: tay +LEFFA:  tay                             
-LEFFB: tax ;Save value to create counter later. +LEFFB:  tax                             ;Save value to create counter later. 
-LEFFC: iny +LEFFC:  iny                             
-LEFFD: iny ;High byte of address to fill to ($63 or $67). +LEFFD:  iny                             ;High byte of address to fill to ($63 or $67). 
-LEFFE: iny +LEFFE:  iny                             
-LEFFF: lda #$FF ;Value to fill room RAM with. +LEFFF:  lda #$FF                        ;Value to fill room RAM with. 
-LF001: jsr FillRoomRAM ;($F01C)Fill entire RAM for designated room with #$FF.+LF001:  jsr FillRoomRAM                 ;($F01C)Fill entire RAM for designated room with #$FF.
  
-LF004: ldx $01 ;#$5F or #$63 depening on which room RAM was initialized. +LF004:  ldx $01                         ;#$5F or #$63 depening on which room RAM was initialized. 
-LF006: jsr Xplus4 ;($E193)X = X + 4. +LF006:  jsr Xplus4                      ;($E193)X = X + 4. 
-LF009: stx $01 ;Set high byte for attribute table write(#$63 or #$67). +LF009:  stx $01                         ;Set high byte for attribute table write(#$63 or #$67). 
-LF00B: ldx RoomPal ;Index into table below (Lowest 2 bits). +LF00B:  ldx RoomPal                     ;Index into table below (Lowest 2 bits). 
-LF00D: lda ATDataTable,x ;Load attribute table data from table below. +LF00D:  lda ATDataTable,              ;Load attribute table data from table below. 
-LF010: ldy #$C0 ;Low byte of start of all attribute tables. +LF010:  ldy #$C0                        ;Low byte of start of all attribute tables. 
-LF012:* sta ($00),y ;Fill attribute table. +LF012:* sta ($00),                    ;Fill attribute table. 
-LF014: iny +LF014:  iny                             
-LF015: bne - ;Loop until entire attribute table is filled. +LF015:  bne -                           ;Loop until entire attribute table is filled. 
-LF017: rts ;+LF017:  rts                             ;
  
 ATDataTable:        ATDataTable:       
-LF018: .byte %00000000 +LF018:  .byte %00000000                 
-LF019: .byte %01010101 ;Data to fill attribute tables with. +LF019:  .byte %01010101                 ;Data to fill attribute tables with. 
-LF01A: .byte %10101010 +LF01A:  .byte %10101010                 
-LF01B: .byte %11111111 ;+LF01B:  .byte %11111111                 ;
  
 FillRoomRAM: FillRoomRAM:
-LF01C: pha ;Temporarily store A. +LF01C:  pha                             ;Temporarily store A. 
-LF01D: txa +LF01D:  txa                             
-LF01E: sty $01 ;Calculate value to store in X to use as upper byte--> +LF01E:  sty $01                         ;Calculate value to store in X to use as upper byte--> 
-LF020: clc ;counter for initilaizing room RAM(X=#$FC).--> +LF020:  clc                             ;counter for initilaizing room RAM(X=#$FC).--> 
-LF021: sbc $01 ;Since carry bit is cleared, result is one less than expected. +LF021:  sbc $01                         ;Since carry bit is cleared, result is one less than expected. 
-LF023: tax +LF023:  tax                             
-LF024: pla ;Restore value to fill room RAM with(#$FF). +LF024:  pla                             ;Restore value to fill room RAM with(#$FF). 
-LF025: ldy #$00 ;Lower address byte to start at. +LF025:  ldy #$00                        ;Lower address byte to start at. 
-LF027: sty $00 +LF027:  sty $00                         
-LF029:* sta ($00),y +LF029:* sta ($00),                    
-LF02B: dey +LF02B:  dey                             
-LF02C: bne - +LF02C:  bne -                           
-LF02E: dec $01 ;Loop until all the room RAM is filled with #$FF(black). +LF02E:  dec $01                         ;Loop until all the room RAM is filled with #$FF(black). 
-LF030: inx +LF030:  inx                             
-LF031: bne - +LF031:  bne -                           
-LF033: rts ;+LF033:  rts                             ;
  
 ;---------------------------------------------------------------------------------------------------- ;----------------------------------------------------------------------------------------------------
Line 7590: Line 7590:
  
 LF034:  lda #$FF LF034:  lda #$FF
- sta $73 +        sta $73 
- sta $010F+        sta $010F
 ; check for crash with Memus ; check for crash with Memus
- ldx #$18+        ldx #$18
 *      lda $B0,x *      lda $B0,x
- beq +++++     ; branch if no Memu in slot +        beq +++++           ; branch if no Memu in slot 
- cmp #$03 +        cmp #$03 
- beq +++++ +        beq +++++ 
- jsr LF19A +        jsr LF19A 
- jsr IsSamusDead +        jsr IsSamusDead 
- beq + +        beq + 
- lda SamusBlink +        lda SamusBlink 
- bne + +        bne + 
- ldy #$00 +        ldy #$00 
- jsr LF149 +        jsr LF149 
- jsr LF2B4+        jsr LF2B4
     ; check for crash with bullets     ; check for crash with bullets
 *       ldy #$D0 *       ldy #$D0
 *       lda ObjAction,      ; projectile active? *       lda ObjAction,      ; projectile active?
- beq ++   ; try next one if not +        beq ++            ; try next one if not 
- cmp #wa_BulletExplode +        cmp #wa_BulletExplode 
- bcc + +        bcc + 
- cmp #$07 +        cmp #$07 
- beq + +        beq + 
- cmp #wa_BombExplode +        cmp #wa_BombExplode 
- beq + +        beq + 
- cmp #wa_Missile +        cmp #wa_Missile 
- bne +++        bne ++
 *       jsr LF149 *       jsr LF149
- jsr LF32A+        jsr LF32A
 *      jsr Yplus16 *      jsr Yplus16
- bne --- +        bne --- 
-* txa +      txa 
- sec +        sec 
- sbc #$08 ; each Memu occupies 8 bytes +        sbc #$08                ; each Memu occupies 8 bytes 
- tax +        tax 
- bpl ------+        bpl ------
  
- ldx #$B0+        ldx #$B0
 *       lda ObjAction,x *       lda ObjAction,x
- cmp #$02 +        cmp #$02 
- bne + +        bne + 
- ldy #$00 +        ldy #$00 
- jsr IsSamusDead +        jsr IsSamusDead 
- beq ++ +        beq ++ 
- jsr AreObjectsTouching ;($DC7F) +        jsr AreObjectsTouching          ;($DC7F) 
- jsr LF277+        jsr LF277
 *       jsr Xminus16 *       jsr Xminus16
- bmi --+        bmi --
 ; enemy <--> bullet/missile/bomb detection ; enemy <--> bullet/missile/bomb detection
-* ldx #$50 ; start with enemy slot #5 +      ldx #$50                ; start with enemy slot #5 
-LF09F:  lda EnStatus,x      ; slot active? +LF09F:  lda EnStatus,      ; slot active? 
- beq +    ; branch if not +        beq +              ; branch if not 
- cmp #$03 +        cmp #$03 
-*       beq NextEnemy    ; next slot +*       beq NextEnemy      ; next slot 
- jsr LF152 +        jsr LF152 
- lda EnStatus,+        lda EnStatus,
- cmp #$05 +        cmp #$05 
- beq ++++ +        beq ++++ 
- ldy #$D0 ; first projectile slot +        ldy #$D0                ; first projectile slot 
-*       lda ObjAction,y ; is it active? +*       lda ObjAction, ; is it active? 
- beq ++   ; branch if not +        beq ++            ; branch if not 
- cmp #wa_BulletExplode +        cmp #wa_BulletExplode 
- bcc + +        bcc + 
- cmp #$07 +        cmp #$07 
- beq + +        beq + 
- cmp #wa_BombExplode +        cmp #wa_BombExplode 
- beq + +        beq + 
- cmp #wa_Missile +        cmp #wa_Missile 
- bne +++        bne ++
 ; check if enemy is actually hit ; check if enemy is actually hit
 *       jsr LF140 *       jsr LF140
- jsr LF2CA +        jsr LF2CA 
-* jsr Yplus16      ; next projectile slot +      jsr Yplus16          ; next projectile slot 
- bne --- +        bne --- 
-* ldy #$00 +      ldy #$00 
- lda SamusBlink +        lda SamusBlink 
- bne NextEnemy +        bne NextEnemy 
- jsr IsSamusDead +        jsr IsSamusDead 
- beq NextEnemy +        beq NextEnemy 
- jsr LF140 +        jsr LF140 
- jsr LF282 +        jsr LF282 
- NextEnemy: +        NextEnemy: 
- jsr Xminus16 +        jsr Xminus16 
- bmi + +        bmi + 
- jmp LF09F+        jmp LF09F
  
 *       ldx #$00 *       ldx #$00
- jsr LF172 +        jsr LF172 
- ldy #$60+        ldy #$60
 *       lda EnStatus,y *       lda EnStatus,y
- beq + +        beq + 
- cmp #$05 +        cmp #$05 
- beq + +        beq + 
- lda SamusBlink +        lda SamusBlink 
- bne + +        bne + 
- jsr IsSamusDead +        jsr IsSamusDead 
- beq + +        beq + 
- jsr LF1B3 +        jsr LF1B3 
- jsr LF162 +        jsr LF162 
- jsr LF1FA +        jsr LF1FA 
- jsr LF2ED+        jsr LF2ED
 *       jsr Yplus16 *       jsr Yplus16
- cmp #$C0 +        cmp #$C0 
- bne -- +        bne -- 
- ldy #$00 +        ldy #$00 
- jsr IsSamusDead +        jsr IsSamusDead 
- beq ++++ +        beq ++++ 
- jsr LF186 +        jsr LF186 
- ldx #$F0+        ldx #$F0
 *       lda ObjAction,x *       lda ObjAction,x
- cmp #$07 +        cmp #$07 
- beq + +        beq + 
- cmp #$0A +        cmp #$0A 
- bne +++        bne ++
 *       jsr LDC82 *       jsr LDC82
- jsr LF311 +        jsr LF311 
-* jsr Xminus16 +      jsr Xminus16 
- cmp #$C0 +        cmp #$C0 
- bne ---  +        bne ---                  
-* jmp SubtractHealth ;($CE92)+      jmp SubtractHealth              ;($CE92)
  
 LF140:  jsr LF1BF LF140:  jsr LF1BF
- jsr LF186 +        jsr LF186 
- jmp LF1FA+        jmp LF1FA
  
 LF149:  jsr LF186 LF149:  jsr LF186
- jsr LF1D2 +        jsr LF1D2 
- jmp LF1FA+        jmp LF1FA
  
 LF152:  lda EnYRoomPos,x LF152:  lda EnYRoomPos,x
- sta $07 ; Y coord +        sta $07  ; Y coord 
- lda EnXRoomPos,+        lda EnXRoomPos,
- sta $09 ; X coord +        sta $09  ; X coord 
- lda EnNameTable,    ; hi coord +        lda EnNameTable,    ; hi coord 
- jmp LF17F+        jmp LF17F
  
 LF162:  lda EnYRoomPos,    ; Y coord LF162:  lda EnYRoomPos,    ; Y coord
- sta $06 +        sta $06 
- lda EnXRoomPos,    ; X coord +        lda EnXRoomPos,    ; X coord 
- sta $08 +        sta $08 
- lda EnNameTable,    ; hi coord +        lda EnNameTable,    ; hi coord 
- jmp LF193+        jmp LF193
  
 GetObject0CoordData: GetObject0CoordData:
 LF172:  lda ObjectY,x LF172:  lda ObjectY,x
- sta $07 +        sta $07 
- lda ObjectX,x +        lda ObjectX,x 
- sta $09 +        sta $09 
- lda ObjectHi,x+        lda ObjectHi,x
  
 LF17F:  eor PPUCNT0ZP LF17F:  eor PPUCNT0ZP
- and #$01 +        and #$01 
- sta $0B +        sta $0B 
- rts+        rts
  
 GetObject1CoordData: GetObject1CoordData:
 LF186:  lda ObjectY,y LF186:  lda ObjectY,y
- sta $06 +        sta $06 
- lda ObjectX,y +        lda ObjectX,y 
- sta $08 +        sta $08 
- lda ObjectHi,y+        lda ObjectHi,y
  
 LF193:  eor PPUCNT0ZP LF193:  eor PPUCNT0ZP
- and #$01 +        and #$01 
- sta $0A +        sta $0A 
- rts+        rts
  
 LF19A:  lda $B1,x LF19A:  lda $B1,x
- sta $07 +        sta $07 
- lda $B2,x +        lda $B2,x 
- sta $09 +        sta $09 
- lda $B3,x +        lda $B3,x 
- jmp LF17F+        jmp LF17F
  
 DistFromObj0ToObj1: DistFromObj0ToObj1:
 LF1A7:  lda ObjRadY,x LF1A7:  lda ObjRadY,x
- jsr LF1E0 +        jsr LF1E0 
- lda ObjRadX,x +        lda ObjRadX,x 
- jmp LF1D9+        jmp LF1D9
  
 DistFromObj0ToEn1: DistFromObj0ToEn1:
 LF1B3:  lda ObjRadY,x LF1B3:  lda ObjRadY,x
- jsr LF1E7 +        jsr LF1E7 
- lda ObjRadX,x +        lda ObjRadX,x 
- jmp LF1CB+        jmp LF1CB
  
 DistFromEn0ToObj1: DistFromEn0ToObj1:
 LF1BF:  lda EnRadY,x LF1BF:  lda EnRadY,x
- jsr LF1E0 +        jsr LF1E0 
- lda EnRadX,x +        lda EnRadX,x 
- jmp LF1D9+        jmp LF1D9
  
 AddEnemy1XRadius: AddEnemy1XRadius:
 LF1CB:  clc LF1CB:  clc
- adc EnRadX,y +        adc EnRadX,y 
- sta $05 +        sta $05 
- rts+        rts
  
 LF1D2:  lda #$04 LF1D2:  lda #$04
- jsr LF1E0 +        jsr LF1E0 
- lda #$08+        lda #$08
  
 AddObject1XRadius: AddObject1XRadius:
 LF1D9:  clc LF1D9:  clc
- adc ObjRadX,y +        adc ObjRadX,y 
- sta $05 +        sta $05 
- rts+        rts
  
 AddObject1YRadius: AddObject1YRadius:
 LF1E0:  clc LF1E0:  clc
- adc ObjRadY,y +        adc ObjRadY,y 
- sta $04 +        sta $04 
- rts+        rts
  
 LF1E7:  clc LF1E7:  clc
- adc EnRadY,y +        adc EnRadY,y 
- sta $04 +        sta $04 
- rts+        rts
  
 ; Y = Y + 16 ; Y = Y + 16
  
 Yplus16: Yplus16:
- tya +        tya 
- clc +        clc 
- adc #$10 +        adc #$10 
- tay +        tay 
- rts+        rts
  
 ; X = X - 16 ; X = X - 16
  
 Xminus16: Xminus16:
- txa +        txa 
- sec +        sec 
- sbc #$10 +        sbc #$10 
- tax +        tax 
- rts+        rts
  
 LF1FA:  lda #$02 LF1FA:  lda #$02
- sta $10 +        sta $10 
- and ScrollDir +        and ScrollDir 
- sta $03 +        sta $03 
- lda $07 ;Load object 0 y coord. +        lda $07                         ;Load object 0 y coord. 
- sec +        sec                             
- sbc $06 ;Subtract object 1 y coord. +        sbc $06                         ;Subtract object 1 y coord. 
- sta $00 ;Store difference in $00. +        sta $00                         ;Store difference in $00. 
- lda $03 +        lda $03 
- bne ++ +        bne ++ 
- lda $0B +        lda $0B 
- eor $0A +        eor $0A 
- beq ++ +        beq ++ 
- jsr LF262 +        jsr LF262 
- lda $00 +        lda $00 
- sec +        sec 
- sbc #$10 +        sbc #$10 
- sta $00 +        sta $00 
- bcs + +        bcs + 
- dec $01+        dec $01
 *       jmp LF22B *       jmp LF22B
  
-* lda #$00 +      lda #$00 
- sbc #$00 +        sbc #$00 
- jsr LF266+        jsr LF266
  
 LF22B:  sec LF22B:  sec
- lda $01 +        lda $01 
- bne ++ +        bne ++ 
- lda $00 +        lda $00 
- sta $11 +        sta $11 
- cmp $04 +        cmp $04 
- bcs ++ +        bcs ++ 
- asl $10 +        asl $10 
- lda $09 +        lda $09 
- sec +        sec 
- sbc $08 +        sbc $08 
- sta $00 +        sta $00 
- lda $03 +        lda $03 
- beq + +        beq + 
- lda $0B +        lda $0B 
- eor $0A +        eor $0A 
- beq + +        beq + 
- jsr LF262 +        jsr LF262 
- jmp LF256+        jmp LF256
  
 *       sbc #$00 *       sbc #$00
- jsr LF266+        jsr LF266
 LF256:  sec LF256:  sec
- lda $01 +        lda $01 
- bne + +        bne + 
- lda $00 +        lda $00 
- sta $0F +        sta $0F 
- cmp $05 +        cmp $05 
-* rts+      rts
  
 LF262:  lda $0B LF262:  lda $0B
- sbc $0A+        sbc $0A
  
 LF266:  sta $01 LF266:  sta $01
- bpl + +        bpl + 
- jsr LE449 +        jsr LE449 
- inc $10+        inc $10
 *       rts *       rts
  
 LF270:  ora $030A,x LF270:  ora $030A,x
- sta $030A,x +        sta $030A,x 
- rts+        rts
  
 LF277:  bcs Exit17 LF277:  bcs Exit17
 LF279:  lda $10 LF279:  lda $10
 LF27B:  ora $030A,y LF27B:  ora $030A,y
- sta $030A,y +        sta $030A,y 
- Exit17: +        Exit17: 
- rts+        rts
  
 LF282:  bcs Exit17 LF282:  bcs Exit17
- jsr LF2E8 +        jsr LF2E8 
- jsr IsScrewAttackActive ;($CD9C)Check if screw attack active. +        jsr IsScrewAttackActive         ;($CD9C)Check if screw attack active. 
- ldy #$00 +        ldy #$00 
- bcc +++ +        bcc +++ 
- lda EnStatus,+        lda EnStatus,
- cmp #$04 +        cmp #$04 
- bcs Exit17 +        bcs Exit17 
- lda EnDataIndex,x+        lda EnDataIndex,x
 *       sta $010F *       sta $010F
- tay +        tay 
- bmi + +        bmi + 
- lda $968B,y +        lda $968B,y 
- and #$10 +        and #$10 
- bne Exit17+        bne Exit17
 *       ldy #$00 *       ldy #$00
- jsr LF338 +        jsr LF338 
- jmp LF306+        jmp LF306
  
-* lda #$81 +      lda #$81 
- sta $040E,x +        sta $040E,x 
- bne +++        bne ++
 LF2B4:  bcs + LF2B4:  bcs +
- jsr IsScrewAttackActive ;($CD9C)Check if screw attack active. +        jsr IsScrewAttackActive         ;($CD9C)Check if screw attack active. 
- ldy #$00 +        ldy #$00 
- lda #$C0 +        lda #$C0 
- bcs ---+        bcs ---
 LF2BF:  lda $B6,x LF2BF:  lda $B6,x
- and #$F8 +        and #$F8 
- ora $10 +        ora $10 
- eor #$03 +        eor #$03 
- sta $B6,x+        sta $B6,x
 *       rts *       rts
  
 LF2CA:  bcs +++ LF2CA:  bcs +++
- lda ObjAction,+        lda ObjAction,
- sta $040E,x +        sta $040E,x 
- jsr LF279 +        jsr LF279 
-* jsr LF332+      jsr LF332
 *       ora $0404,x *       ora $0404,x
- sta $0404,x+        sta $0404,x
 *       rts *       rts
  
 LF2DF:  lda $10 LF2DF:  lda $10
- ora $0404,y +        ora $0404,y 
- sta $0404,y +        sta $0404,y 
- rts+        rts
  
 LF2E8:  jsr LF340 LF2E8:  jsr LF340
- bne --+        bne --
 LF2ED:  bcs + LF2ED:  bcs +
- jsr LF2DF +        jsr LF2DF 
- tya +        tya 
- pha +        pha 
- jsr IsScrewAttackActive ;($CD9C)Check if screw attack active. +        jsr IsScrewAttackActive         ;($CD9C)Check if screw attack active. 
- pla +        pla 
- tay +        tay 
- bcc + +        bcc + 
- lda #$80 +        lda #$80 
- sta $010F +        sta $010F 
- jsr LF332 +        jsr LF332 
- jsr LF270+        jsr LF270
 LF306:  lda $95CE LF306:  lda $95CE
- sta HealthLoChange +        sta HealthLoChange 
- lda $95CF +        lda $95CF 
- sta HealthHiChange+        sta HealthHiChange
 *       rts *       rts
  
 LF311:  bcs Exit22 LF311:  bcs Exit22
- lda #$E0 +        lda #$E0 
- sta $010F +        sta $010F 
- jsr LF338 +        jsr LF338 
- lda $0F +        lda $0F 
- beq + +        beq + 
- lda #$01+        lda #$01
 *       sta $73 *       sta $73
  
 ClearHealthChange: ClearHealthChange:
-LF323: lda #$00 +LF323:  lda #$00 
-LF325: sta HealthLoChange +LF325:  sta HealthLoChange 
-LF327: sta HealthHiChange+LF327:  sta HealthHiChange
  
 Exit22:  Exit22: 
-LF329: rts ;Return for routine above and below.+LF329:  rts                             ;Return for routine above and below.
  
 LF32A:  bcs Exit22 LF32A:  bcs Exit22
- jsr LF279 +        jsr LF279 
- jmp LF2BF+        jmp LF2BF
  
 LF332:  jsr LF340 LF332:  jsr LF340
- jmp Amul8       ; * 8+        jmp Amul8       ; * 8
  
 LF338:  lda $10 LF338:  lda $10
- asl +        asl 
- asl +        asl 
- asl +        asl 
- jmp LF27B+        jmp LF27B
  
 LF340:  lda $10 LF340:  lda $10
- eor #$03 +        eor #$03 
- rts+        rts
  
 ; UpdateEnemies ; UpdateEnemies
Line 8010: Line 8010:
  
 UpdateEnemies: UpdateEnemies:
-LF345: ldx #$50 ;Load x with #$50 +LF345:  ldx #$50                ;Load x with #$50 
-*       jsr DoOneEnemy ;($F351) +*       jsr DoOneEnemy                  ;($F351) 
- ldx PageIndex +        ldx PageIndex 
- jsr Xminus16 +        jsr Xminus16 
- bne -+        bne -
 DoOneEnemy: DoOneEnemy:
-LF351: stx PageIndex ;PageIndex starts at $50 and is subtracted by #$0F each--> +LF351:  stx PageIndex                   ;PageIndex starts at $50 and is subtracted by #$0F each--> 
- ;iteration. There is a max of 6 enemies at a time. +                                        ;iteration. There is a max of 6 enemies at a time. 
- ldy EnStatus,+        ldy EnStatus,
- beq + +        beq + 
- cpy #$03 +        cpy #$03 
- bcs + +        bcs + 
- jsr LF37F+        jsr LF37F
 *       jsr LF3AA *       jsr LF3AA
- lda EnStatus,+        lda EnStatus,
- sta $81 +        sta $81 
- cmp #$07 +        cmp #$07 
- bcs + +        bcs + 
- jsr ChooseRoutine+        jsr ChooseRoutine
  
 ; Pointer table to code ; Pointer table to code
  
- .word ExitSub       ;($C45C) rts +        .word ExitSub       ;($C45C) rts 
- .word $F3BE +        .word $F3BE 
- .word $F3E6 +        .word $F3E6 
- .word $F40D +        .word $F40D 
- .word $F43E +        .word $F43E 
- .word $F483 +        .word $F483 
- .word $F4EE+        .word $F4EE
  
-*       jmp KillObject ;($FA18)Free enemy data slot.+*       jmp KillObject                  ;($FA18)Free enemy data slot.
  
 LF37F:  lda $0405,x LF37F:  lda $0405,x
- and #$02 +        and #$02 
- bne + +        bne + 
- lda EnYRoomPos,    ; Y coord +        lda EnYRoomPos,    ; Y coord 
- sta $0A +        sta $0A 
- lda EnXRoomPos,    ; X coord +        lda EnXRoomPos,    ; X coord 
- sta $0B +        sta $0B 
- lda EnNameTable,    ; hi coord +        lda EnNameTable,    ; hi coord 
- sta $06 +        sta $06 
- lda EnRadY,x +        lda EnRadY,x 
- sta $08 +        sta $08 
- lda EnRadX,x +        lda EnRadX,x 
- sta $09 +        sta $09 
- jsr IsObjectVisible ;($DFDF)Determine if object is within the screen boundaries. +        jsr IsObjectVisible             ;($DFDF)Determine if object is within the screen boundaries. 
- txa +        txa 
- bne + +        bne + 
- pla +        pla 
- pla+        pla
 *       ldx PageIndex *       ldx PageIndex
- rts+        rts
  
 LF3AA:  lda $0405,x LF3AA:  lda $0405,x
- asl +        asl 
- rol +        rol 
- tay +        tay 
- txa +        txa 
- jsr Adiv16 ;($C2BF)/16. +        jsr Adiv16                      ;($C2BF)/16. 
- eor FrameCount +        eor FrameCount 
- lsr +        lsr 
- tya +        tya 
- ror +        ror 
- ror +        ror 
- sta $0405,x +        sta $0405,x 
- rts+        rts
  
 LF3BE:  lda $0405,x LF3BE:  lda $0405,x
- asl +        asl 
- bmi + +        bmi + 
- lda #$00 +        lda #$00 
- sta $6B01,x +        sta $6B01,x 
- sta EnCounter,+        sta EnCounter,
- sta $040A,x +        sta $040A,x 
- jsr LF6B9 +        jsr LF6B9 
- jsr LF75B +        jsr LF75B 
- jsr LF682 +        jsr LF682 
- jsr LF676 +        jsr LF676 
- lda EnDelay,x +        lda EnDelay,x 
- beq + +        beq + 
- jsr LF7BA+        jsr LF7BA
 *       jmp ++ *       jmp ++
  
 LF3E6:  lda $0405,x LF3E6:  lda $0405,x
- asl +        asl 
- bmi ++ +        bmi ++ 
- lda $0405,x +        lda $0405,x 
- and #$20 +        and #$20 
- beq + +        beq + 
- ldy EnDataIndex,+        ldy EnDataIndex,
- lda EnemyInitDelayTbl,y ;($96BB) +        lda EnemyInitDelayTbl,        ;($96BB) 
- sta EnDelay,x +        sta EnDelay,x 
- dec EnStatus,+        dec EnStatus,
- bne +++        bne ++
 *       jsr LF6B9 *       jsr LF6B9
- jsr LF75B +        jsr LF75B 
- jsr LF51E +        jsr LF51E 
-LF40A:* jsr LF536 +LF40A:* jsr LF536 
- jmp $95E5+        jmp $95E5
  
-LF410: jsr UpdateEnemyAnim +LF410:  jsr UpdateEnemyAnim 
- jsr $8058+        jsr $8058
 LF416:  ldx PageIndex LF416:  ldx PageIndex
- lda EnSpecialAttribs,+        lda EnSpecialAttribs,
- bpl + +        bpl + 
- lda ObjectCntrl +        lda ObjectCntrl 
- bmi + +        bmi + 
- lda #$A3+        lda #$A3
 LF423:  sta ObjectCntrl LF423:  sta ObjectCntrl
 *       lda EnStatus,x *       lda EnStatus,x
- beq LF42D +        beq LF42D 
- jsr LDD8B+        jsr LDD8B
 LF42D:  ldx PageIndex LF42D:  ldx PageIndex
- lda #$00 +        lda #$00 
- sta $0404,x +        sta $0404,x 
- sta $040E,x +        sta $040E,x 
- rts+        rts
  
 LF438:  jsr UpdateEnemyAnim LF438:  jsr UpdateEnemyAnim
Line 8132: Line 8132:
  
 LF43E:  jsr LF536 LF43E:  jsr LF536
- lda EnStatus,+        lda EnStatus,
- cmp #$03 +        cmp #$03 
- beq LF410 +        beq LF410 
- bit ObjectCntrl +        bit ObjectCntrl 
- bmi + +        bmi + 
- lda #$A1 +        lda #$A1 
- sta ObjectCntrl+        sta ObjectCntrl
 *       lda FrameCount *       lda FrameCount
- and #$07 +        and #$07 
- bne + +        bne + 
- dec $040D,x +        dec $040D,x 
- bne + +        bne + 
- lda EnStatus,+        lda EnStatus,
- cmp #$03 +        cmp #$03 
- beq + +        beq + 
- lda $040C,x +        lda $040C,x 
- sta EnStatus,+        sta EnStatus,
- ldy EnDataIndex,+        ldy EnDataIndex,
- lda $969B,y +        lda $969B,y 
- sta $040D,x+        sta $040D,x
 *       lda $040D,x *       lda $040D,x
- cmp #$0B +        cmp #$0B 
- bcs + +        bcs + 
- lda FrameCount +        lda FrameCount 
- and #$02 +        and #$02 
- beq + +        beq + 
- asl ObjectCntrl+        asl ObjectCntrl
 *       jmp LF416 *       jmp LF416
  
 LF483:  lda $0404,x LF483:  lda $0404,x
- and #$24 +        and #$24 
- beq ++++++ +        beq ++++++ 
- jsr KillObject ;($FA18)Free enemy data slot. +        jsr KillObject                  ;($FA18)Free enemy data slot. 
- ldy EnAnimFrame,+        ldy EnAnimFrame,
- cpy #$80 +        cpy #$80 
- beq PickupMissile +        beq PickupMissile 
- tya +        tya 
- pha +        pha 
- lda EnDataIndex,+        lda EnDataIndex,
- pha +        pha 
- ldy #$00 +        ldy #$00 
- ldx #$03 +        ldx #$03 
- pla +        pla 
- bne ++ +        bne ++ 
- dex +        dex 
- pla +        pla 
- cmp #$81 +        cmp #$81 
- bne + +        bne + 
- ldx #$00 ;Increase HealthHi by 0. +        ldx #$00                        ;Increase HealthHi by 0. 
- ldy #$50 ;Increase HealthLo by 5.+        ldy #$50                        ;Increase HealthLo by 5.
 *       pha *       pha
-* pla  +      pla                              
- sty HealthLoChange +        sty HealthLoChange 
- stx HealthHiChange +        stx HealthHiChange 
- jsr AddHealth ;($CEF9)Add health to Samus. +        jsr AddHealth                   ;($CEF9)Add health to Samus. 
- jmp SFX_EnergyPickup+        jmp SFX_EnergyPickup
  
 PickupMissile: PickupMissile:
- lda #$02 +        lda #$02 
- ldy EnDataIndex,+        ldy EnDataIndex,
- beq + +        beq + 
- lda #$1E+        lda #$1E
 *       clc *       clc
- adc MissileCount +        adc MissileCount 
- bcs +    ; can't have more than 255 missiles +        bcs +              ; can't have more than 255 missiles 
- cmp MaxMissiles ; can Samus hold this many missiles? +        cmp MaxMissiles  ; can Samus hold this many missiles? 
- bcc ++   ; branch if yes +        bcc ++            ; branch if yes 
-*       lda MaxMissiles ; set to max. # of missiles allowed +*       lda MaxMissiles  ; set to max. # of missiles allowed 
-* sta MissileCount +      sta MissileCount 
- jmp SFX_MissilePickup+        jmp SFX_MissilePickup
  
-* lda FrameCount +      lda FrameCount 
- and #$03 +        and #$03 
- bne + +        bne + 
- dec $040D,x +        dec $040D,x 
- bne + +        bne + 
- jsr KillObject ;($FA18)Free enemy data slot. +        jsr KillObject                  ;($FA18)Free enemy data slot. 
-* lda FrameCount +      lda FrameCount 
- and #$02 +        and #$02 
- lsr +        lsr 
- ora #$A0 +        ora #$A0 
- sta ObjectCntrl +        sta ObjectCntrl 
- jmp LF416+        jmp LF416
  
 LF4EE:  dec EnSpecialAttribs,x LF4EE:  dec EnSpecialAttribs,x
- bne ++ +        bne ++ 
- lda $040C,x +        lda $040C,x 
- tay +        tay 
- and #$C0 +        and #$C0 
- sta EnSpecialAttribs,+        sta EnSpecialAttribs,
- tya +        tya 
- and #$3F +        and #$3F 
- sta EnStatus,+        sta EnStatus,
- pha +        pha 
- jsr $80B0 +        jsr $80B0 
- and #$20 +        and #$20 
- beq + +        beq + 
- pla +        pla 
- jsr LF515 +        jsr LF515 
- pha+        pha
 *       pla *       pla
-* lda #$A0 +      lda #$A0 
- jmp LF423+        jmp LF423
  
 LF515:  sta $040C,x LF515:  sta $040C,x
 LF518:  lda #$04 LF518:  lda #$04
- sta EnStatus,+        sta EnStatus,
- rts+        rts
  
 LF51E:  lda ScrollDir LF51E:  lda ScrollDir
- ldx PageIndex +        ldx PageIndex 
- cmp #$02 +        cmp #$02 
- bcc ++ +        bcc ++ 
- lda EnYRoomPos,    ; Y coord +        lda EnYRoomPos,    ; Y coord 
- cmp #$EC +        cmp #$EC 
- bcc ++ +        bcc ++ 
- jmp KillObject ;($FA18)Free enemy data slot.+        jmp KillObject                  ;($FA18)Free enemy data slot.
  
 *       jsr SFX_MetroidHit *       jsr SFX_MetroidHit
- jmp GetPageIndex+        jmp GetPageIndex
  
 LF536:  lda EnSpecialAttribs,x LF536:  lda EnSpecialAttribs,x
- sta $0A +        sta $0A 
- lda $0404,x +        lda $0404,x 
- and #$20 +        and #$20 
- beq + +        beq + 
- lda $040E,x +        lda $040E,x 
- cmp #$03 +        cmp #$03 
- bne +++ +        bne +++ 
- bit $0A +        bit $0A 
- bvs +++ +        bvs +++ 
- lda EnStatus,+        lda EnStatus,
- cmp #$04 +        cmp #$04 
- beq +++ +        beq +++ 
- jsr LF515 +        jsr LF515 
- lda #$40 +        lda #$40 
- sta $040D,x +        sta $040D,x 
- jsr $80B0 +        jsr $80B0 
- and #$20 +        and #$20 
- beq + +        beq + 
- lda #$05 +        lda #$05 
- sta EnHitPoints,+        sta EnHitPoints,
- jmp $95A8+        jmp $95A8
 *       rts *       rts
  
-* jsr $80B0 +      jsr $80B0 
- and #$20 +        and #$20 
- bne --- +        bne --- 
- jsr SFX_Metal +        jsr SFX_Metal 
- jmp LF42D+        jmp LF42D
  
-* lda EnHitPoints,+      lda EnHitPoints,
- cmp #$FF +        cmp #$FF 
- beq -- +        beq -- 
- bit $0A +        bit $0A 
- bvc + +        bvc + 
- jsr SFX_BossHit +        jsr SFX_BossHit 
- bne ++ +        bne ++ 
-* jsr LF74B +      jsr LF74B 
- and #$0C +        and #$0C 
- beq PlaySnd1 +        beq PlaySnd1 
- cmp #$04 +        cmp #$04 
- beq PlaySnd2 +        beq PlaySnd2 
- cmp #$08 +        cmp #$08 
- beq PlaySnd3 +        beq PlaySnd3 
- jsr SFX_MetroidHit +        jsr SFX_MetroidHit 
- bne +       ; branch always+        bne +       ; branch always
 PlaySnd1: PlaySnd1:
- jsr SFX_EnemyHit +        jsr SFX_EnemyHit 
- bne +       ; branch always+        bne +       ; branch always
 PlaySnd2: PlaySnd2:
- jsr SFX_EnemyHit +        jsr SFX_EnemyHit 
- bne +       ; branch always+        bne +       ; branch always
 PlaySnd3: PlaySnd3:
- jsr SFX_BigEnemyHit ;($CBCE) +        jsr SFX_BigEnemyHit             ;($CBCE) 
-* ldx PageIndex +      ldx PageIndex 
- jsr $80B0 +        jsr $80B0 
- and #$20 +        and #$20 
- beq + +        beq + 
- lda $040E,x +        lda $040E,x 
- cmp #$0B +        cmp #$0B 
- bne ----+        bne ----
 *       lda EnStatus,x *       lda EnStatus,x
- cmp #$04 +        cmp #$04 
- bne + +        bne + 
- lda $040C,x+        lda $040C,x
 *       ora $0A *       ora $0A
- sta $040C,x +        sta $040C,x 
- asl +        asl 
- bmi + +        bmi + 
- jsr $80B0 +        jsr $80B0 
- and #$20 +        and #$20 
- bne + +        bne + 
- ldy $040E,x +        ldy $040E,x 
- cpy #$0B +        cpy #$0B 
- beq +++++ +        beq +++++ 
- cpy #$81 +        cpy #$81 
- beq ++++++        beq +++++
 *       lda #$06 *       lda #$06
- sta EnStatus,+        sta EnStatus,
- lda #$0A +        lda #$0A 
- bit $0A +        bit $0A 
- bvc + +        bvc + 
- lda #$03+        lda #$03
 *       sta EnSpecialAttribs,x *       sta EnSpecialAttribs,x
- cpy #$02 +        cpy #$02 
- beq + +        beq + 
- bit $0A +        bit $0A 
- bvc ++ +        bvc ++ 
- ldy $040E,x +        ldy $040E,x 
- cpy #$0B +        cpy #$0B 
- bne ++ +        bne ++ 
- dec EnHitPoints,+        dec EnHitPoints,
- beq +++ +        beq +++ 
- dec EnHitPoints,+        dec EnHitPoints,
- beq ++++        beq +++
 *       dec EnHitPoints,x *       dec EnHitPoints,x
- beq ++ +        beq ++ 
-* dec EnHitPoints,+      dec EnHitPoints,
- bne GetPageIndex +        bne GetPageIndex 
-* lda #$03 +      lda #$03 
- sta EnStatus,+        sta EnStatus,
- bit $0A +        bit $0A 
- bvs + +        bvs + 
- lda $040E,x +        lda $040E,x 
- cmp #$02 +        cmp #$02 
- bcs + +        bcs + 
- lda #$00 +        lda #$00 
- jsr LDCFC +        jsr LDCFC 
- ldx PageIndex+        ldx PageIndex
 *       jsr LF844 *       jsr LF844
- lda $960B,y +        lda $960B,y 
- jsr LF68D +        jsr LF68D 
- sta EnCounter,+        sta EnCounter,
- ldx #$C0+        ldx #$C0
 *       lda EnStatus,x *       lda EnStatus,x
- beq + +        beq + 
- txa +        txa 
- clc +        clc 
- adc #$08 +        adc #$08 
- tax +        tax 
- cmp #$E0 +        cmp #$E0 
- bne - +        bne - 
- beq GetPageIndex+        beq GetPageIndex
 *       lda $95DD *       lda $95DD
- jsr LF68D +        jsr LF68D 
- lda #$0A +        lda #$0A 
- sta EnCounter,+        sta EnCounter,
- inc EnStatus,+        inc EnStatus,
- lda #$00 +        lda #$00 
- bit $0A +        bit $0A 
- bvc + +        bvc + 
- lda #$03+        lda #$03
 *       sta $0407,x *       sta $0407,x
- ldy PageIndex +        ldy PageIndex 
- lda EnYRoomPos,+        lda EnYRoomPos,
- sta EnYRoomPos,+        sta EnYRoomPos,
- lda EnXRoomPos,+        lda EnXRoomPos,
- sta EnXRoomPos,+        sta EnXRoomPos,
- lda EnNameTable,+        lda EnNameTable,
- sta EnNameTable,+        sta EnNameTable,
- GetPageIndex: +        GetPageIndex: 
- ldx PageIndex +        ldx PageIndex 
- rts+        rts
  
 LF676:  jsr $80B0 LF676:  jsr $80B0
- asl +        asl 
- asl +        asl 
- asl +        asl 
- and #$C0 +        and #$C0 
- sta $6B03,x +        sta $6B03,x 
- rts+        rts
  
 LF682:  jsr LF844 LF682:  jsr LF844
- lda $963B,y +        lda $963B,y 
- cmp EnResetAnimIndex,+        cmp EnResetAnimIndex,
- beq ++        beq +
 LF68D:  sta EnResetAnimIndex,x LF68D:  sta EnResetAnimIndex,x
 LF690:  sta EnAnimIndex,x LF690:  sta EnAnimIndex,x
 LF693:  lda #$00 LF693:  lda #$00
- sta EnAnimDelay,x+        sta EnAnimDelay,x
 *       rts *       rts
  
 LF699:  jsr LF844 LF699:  jsr LF844
- lda $965B,y +        lda $965B,y 
- cmp EnResetAnimIndex,+        cmp EnResetAnimIndex,
- beq Exit12 +        beq Exit12 
- jsr LF68D +        jsr LF68D 
- ldy EnDataIndex,+        ldy EnDataIndex,
- lda $967B,y +        lda $967B,y 
- and #$7F +        and #$7F 
- beq Exit12 +        beq Exit12 
- tay+        tay
 *       dec EnAnimIndex,x *       dec EnAnimIndex,x
- dey +        dey 
- bne -+        bne -
 Exit12: rts Exit12: rts
  
 LF6B9:  lda #$00 LF6B9:  lda #$00
- sta $82 +        sta $82 
- jsr LF74B +        jsr LF74B 
- tay +        tay 
- lda EnStatus,+        lda EnStatus,
- cmp #$02 +        cmp #$02 
- bne + +        bne + 
- tya +        tya 
- and #$02 +        and #$02 
- beq Exit12+        beq Exit12
 *       tya *       tya
- dec $040D,x +        dec $040D,x 
- bne Exit12 +        bne Exit12 
- pha +        pha 
- ldy EnDataIndex,+        ldy EnDataIndex,
- lda $969B,y +        lda $969B,y 
- sta $040D,x +        sta $040D,x 
- pla +        pla 
- bpl ++++ +        bpl ++++ 
- lda #$FE +        lda #$FE 
- jsr LF7B3 +        jsr LF7B3 
- lda ScrollDir +        lda ScrollDir 
- cmp #$02 +        cmp #$02 
- bcc + +        bcc + 
- jsr LF752 +        jsr LF752 
- bcc + +        bcc + 
- tya +        tya 
- eor PPUCNT0ZP +        eor PPUCNT0ZP 
- bcs ++++        bcs +++
 *       lda EnXRoomPos,x *       lda EnXRoomPos,x
- cmp ObjectX +        cmp ObjectX 
- bne + +        bne + 
- inc $82+        inc $82
 *       rol *       rol
-* and #$01 +      and #$01 
- jsr LF744 +        jsr LF744 
- lsr +        lsr 
- ror +        ror 
- eor $0403,x +        eor $0403,x 
- bpl + +        bpl + 
- jsr $81DA +        jsr $81DA 
-* lda #$FB +      lda #$FB 
- jsr LF7B3 +        jsr LF7B3 
- lda ScrollDir +        lda ScrollDir 
- cmp #$02 +        cmp #$02 
- bcs + +        bcs + 
- jsr LF752 +        jsr LF752 
- bcc + +        bcc + 
- tya +        tya 
- eor PPUCNT0ZP +        eor PPUCNT0ZP 
- bcs +++ +        bcs +++ 
-* lda EnYRoomPos,+      lda EnYRoomPos,
- cmp ObjectY +        cmp ObjectY 
- bne + +        bne + 
- inc $82 +        inc $82 
- inc $82 +        inc $82 
-* rol +      rol 
-* and #$01 +      and #$01 
- asl +        asl 
- asl +        asl 
- jsr LF744 +        jsr LF744 
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- ror +        ror 
- eor $0402,x +        eor $0402,x 
- bpl + +        bpl + 
- jmp $820F+        jmp $820F
  
 LF744:  ora $0405,x LF744:  ora $0405,x
- sta $0405,x+        sta $0405,x
 *       rts *       rts
  
 LF74B:  ldy EnDataIndex,x LF74B:  ldy EnDataIndex,x
- lda $968B,y +        lda $968B,y 
- rts+        rts
  
 LF752:  lda EnNameTable,x LF752:  lda EnNameTable,x
- tay +        tay 
- eor ObjectHi +        eor ObjectHi 
- lsr +        lsr 
- rts+        rts
  
 LF75B:  lda #$E7 LF75B:  lda #$E7
- sta $06 +        sta $06 
- lda #$18 +        lda #$18 
- jsr LF744 +        jsr LF744 
- ldy EnDataIndex,+        ldy EnDataIndex,
- lda $96AB,y +        lda $96AB,y 
- beq +++++ +        beq +++++ 
- tay +        tay 
- lda $0405,x +        lda $0405,x 
- and #$02 +        and #$02 
- beq ++++ +        beq ++++ 
- tya +        tya 
- ldy #$F7 +        ldy #$F7 
- asl +        asl 
- bcs + +        bcs + 
- ldy #$EF+        ldy #$EF
 *       lsr *       lsr
- sta $02 +        sta $02 
- sty $06 +        sty $06 
- lda ObjectY +        lda ObjectY 
- sta $00 +        sta $00 
- ldy EnYRoomPos,+        ldy EnYRoomPos,
- lda $0405,x +        lda $0405,x 
- bmi + +        bmi + 
- ldy ObjectX +        ldy ObjectX 
- sty $00 +        sty $00 
- ldy EnXRoomPos,x+        ldy EnXRoomPos,x
 *       lda ObjectHi *       lda ObjectHi
- lsr +        lsr 
- ror $00 +        ror $00 
- lda EnNameTable,+        lda EnNameTable,
- lsr +        lsr 
- tya +        tya 
- ror +        ror 
- sec +        sec 
- sbc $00 +        sbc $00 
- bpl + +        bpl + 
- jsr TwosCompliment ;($C3D4)+        jsr TwosCompliment              ;($C3D4)
 *       lsr *       lsr
- lsr +        lsr 
- lsr +        lsr 
- cmp $02 +        cmp $02 
- bcc ++ +        bcc ++ 
-* lda $06+      lda $06
 LF7B3:  and $0405,x LF7B3:  and $0405,x
- sta $0405,x +        sta $0405,x 
-* rts+      rts
  
 LF7BA:  dec EnDelay,x LF7BA:  dec EnDelay,x
- bne + +        bne + 
- lda $0405,x +        lda $0405,x 
- and #$08 +        and #$08 
- bne ++ +        bne ++ 
- inc EnDelay,x+        inc EnDelay,x
 *       rts *       rts
  
-* lda EnDataIndex,+      lda EnDataIndex,
- cmp #$07 +        cmp #$07 
- bne + +        bne + 
- jsr SFX_OutOfHole +        jsr SFX_OutOfHole 
- ldx PageIndex +        ldx PageIndex 
-* inc EnStatus,+      inc EnStatus,
- jsr LF699 +        jsr LF699 
- ldy EnDataIndex,+        ldy EnDataIndex,
- lda $96CB,y +        lda $96CB,y 
- clc +        clc 
- adc #$D1 +        adc #$D1 
- sta $00 +        sta $00 
- lda #$00 +        lda #$00 
- adc #$97 +        adc #$97 
- sta $01 +        sta $01 
- lda FrameCount +        lda FrameCount 
- eor RandomNumber1 +        eor RandomNumber1 
- ldy #$00 +        ldy #$00 
- and ($00),y +        and ($00),y 
- tay +        tay 
- iny +        iny 
- lda ($00),y +        lda ($00),y 
- sta $0408,x +        sta $0408,x 
- jsr $80B0 +        jsr $80B0 
- bpl ++ +        bpl ++ 
- lda #$00 +        lda #$00 
- sta EnCounter,+        sta EnCounter,
- sta $0407,x +        sta $0407,x 
- ldy $0408,x +        ldy $0408,x 
- lda $972B,y +        lda $972B,y 
- sta $6AFE,x +        sta $6AFE,x 
- lda $973F,y +        lda $973F,y 
- sta $6AFF,x +        sta $6AFF,x 
- lda $9753,y +        lda $9753,y 
- sta $0402,x +        sta $0402,x 
- lda $9767,y +        lda $9767,y 
- sta $0403,x +        sta $0403,x 
- lda $0405,x +        lda $0405,x 
- bmi + +        bmi + 
- lsr +        lsr 
- bcc ++ +        bcc ++ 
- jsr $81D1 +        jsr $81D1 
- jmp +++        jmp ++
  
 *       and #$04 *       and #$04
- beq + +        beq + 
- jsr $8206 +        jsr $8206 
-* lda #$DF +      lda #$DF 
- jmp LF7B3+        jmp LF7B3
  
 LF83E:  lda $0405,x LF83E:  lda $0405,x
Line 8623: Line 8623:
  
 LF844:  lda $0405,x LF844:  lda $0405,x
- bpl + +        bpl + 
- lsr +        lsr 
- lsr +        lsr 
-* lsr +      lsr 
- lda EnDataIndex,+        lda EnDataIndex,
- rol +        rol 
- tay +        tay 
- rts+        rts
  
 LF852:  txa LF852:  txa
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- adc FrameCount +        adc FrameCount 
- lsr +        lsr 
- rts+        rts
  
 LF85A:  ldy EnDataIndex,x LF85A:  ldy EnDataIndex,x
- lda $969B,y +        lda $969B,y 
- sta $040D,x +        sta $040D,x 
- lda EnemyHitPointTbl,y ;($962B) +        lda EnemyHitPointTbl,         ;($962B) 
- ldy EnSpecialAttribs,+        ldy EnSpecialAttribs,
- bpl + +        bpl + 
- asl+        asl
 *       sta EnHitPoints,x *       sta EnHitPoints,x
 *       rts *       rts
  
 LF870:  lda $0405,x LF870:  lda $0405,x
- and #$10 +        and #$10 
- beq - +        beq - 
- lda $87 +        lda $87 
- and EnStatus,+        and EnStatus,
- beq - +        beq - 
- lda $87 +        lda $87 
- bpl + +        bpl + 
- ldy $6B01,x +        ldy $6B01,x 
- bne -+        bne -
 *       jsr LF8E8 *       jsr LF8E8
- bcs ++ +        bcs ++ 
- sta $0404,y +        sta $0404,y 
- jsr LF92C +        jsr LF92C 
- lda $0405,x +        lda $0405,x 
- lsr +        lsr 
- lda $85 +        lda $85 
- pha +        pha 
- rol +        rol 
- tax +        tax 
- lda $978B,x +        lda $978B,x 
- pha +        pha 
- tya +        tya 
- tax +        tax 
- pla +        pla 
- jsr LF68D +        jsr LF68D 
- ldx PageIndex +        ldx PageIndex 
- lda #$01 +        lda #$01 
- sta EnStatus,+        sta EnStatus,
- and $0405,x +        and $0405,x 
- tax +        tax 
- lda Table15,x +        lda Table15,x 
- sta $0403,y +        sta $0403,y 
- lda #$00 +        lda #$00 
- sta $0402,y +        sta $0402,y 
- ldx PageIndex +        ldx PageIndex 
- jsr LF8F8 +        jsr LF8F8 
- lda $0405,x +        lda $0405,x 
- lsr +        lsr 
- pla +        pla 
- tax +        tax 
- lda $97A3,x +        lda $97A3,x 
- sta $04 +        sta $04 
- txa +        txa 
- rol +        rol 
- tax +        tax 
- lda $979B,x +        lda $979B,x 
- sta $05 +        sta $05 
- jsr LF91D +        jsr LF91D 
- ldx PageIndex +        ldx PageIndex 
- bit $87 +        bit $87 
- bvc ++ +        bvc ++ 
- lda $0405,x +        lda $0405,x 
- and #$01 +        and #$01 
- tay +        tay 
- lda $0083,y +        lda $0083,y 
- jmp LF690+        jmp LF690
  
 LF8E8:  ldy #$60 LF8E8:  ldy #$60
- clc+        clc
 *       lda EnStatus,y *       lda EnStatus,y
- beq + +        beq + 
- jsr Yplus16 +        jsr Yplus16 
- cmp #$C0 +        cmp #$C0 
- bne -+        bne -
 *       rts *       rts
  
 LF8F8:  lda $85 LF8F8:  lda $85
- cmp #$02 +        cmp #$02 
- bcc + +        bcc + 
- ldx PageIndex +        ldx PageIndex 
- lda $0405,x +        lda $0405,x 
- lsr +        lsr 
- lda $88 +        lda $88 
- rol +        rol 
- and #$07 +        and #$07 
- sta $040A,y +        sta $040A,y 
- lda #$02 +        lda #$02 
- sta EnStatus,+        sta EnStatus,
- lda #$00 +        lda #$00 
- sta EnDelay,y +        sta EnDelay,y 
- sta EnAnimDelay,+        sta EnAnimDelay,
- sta $0408,y+        sta $0408,y
 *       rts *       rts
  
 LF91D:  ldx PageIndex LF91D:  ldx PageIndex
- jsr LE792 +        jsr LE792 
- tya +        tya 
- tax +        tax 
- jsr LFD8F +        jsr LFD8F 
- jmp LFA49+        jmp LFA49
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table15: Table15:
- .byte $02 +        .byte $02 
- .byte $FE+        .byte $FE
  
 LF92C:  lda #$02 LF92C:  lda #$02
- sta EnRadY,y +        sta EnRadY,y 
- sta EnRadX,y +        sta EnRadX,y 
- ora $0405,y +        ora $0405,y 
- sta $0405,y +        sta $0405,y 
- rts+        rts
  
 LF93B:  ldx #$B0 LF93B:  ldx #$B0
 *       jsr LF949 *       jsr LF949
- ldx PageIndex +        ldx PageIndex 
- jsr Xminus16 +        jsr Xminus16 
- cmp #$60 +        cmp #$60 
- bne -+        bne -
 LF949:  stx PageIndex LF949:  stx PageIndex
- lda $0405,x +        lda $0405,x 
- and #$02 +        and #$02 
- bne + +        bne + 
- jsr KillObject ;($FA18)Free enemy data slot.+        jsr KillObject                  ;($FA18)Free enemy data slot.
 *       lda EnStatus,x *       lda EnStatus,x
- beq Exit19 +        beq Exit19 
- jsr ChooseRoutine+        jsr ChooseRoutine
  
 ; Pointer table to code ; Pointer table to code
  
- .word ExitSub     ;($C45C) rts +        .word ExitSub     ;($C45C) rts 
- .word $F96A +        .word $F96A 
- .word LF991       ; spit dragon's fireball +        .word LF991       ; spit dragon's fireball 
- .word ExitSub     ;($C45C) rts +        .word ExitSub     ;($C45C) rts 
- .word $FA6B +        .word $FA6B 
- .word $FA91+        .word $FA91
  
 Exit19: rts Exit19: rts
  
 LF96A:  jsr LFA5B LF96A:  jsr LFA5B
- jsr LFA1E +        jsr LFA1E 
- ldx PageIndex +        ldx PageIndex 
- bcs LF97C +        bcs LF97C 
- lda EnStatus,+        lda EnStatus,
- beq Exit19 +        beq Exit19 
- jsr LFA60+        jsr LFA60
 LF97C:  lda #$01 LF97C:  lda #$01
 LF97E:  jsr UpdateEnemyAnim LF97E:  jsr UpdateEnemyAnim
- jmp LDD8B+        jmp LDD8B
  
 *       inc $0408,x *       inc $0408,x
 LF987:  inc $0408,x LF987:  inc $0408,x
- lda #$00 +        lda #$00 
- sta EnDelay,x +        sta EnDelay,x 
- beq ++        beq +
 LF991:  jsr LFA5B LF991:  jsr LFA5B
- lda $040A,x +        lda $040A,x 
- and #$FE +        and #$FE 
- tay +        tay 
- lda $97A7,y +        lda $97A7,y 
- sta $0A +        sta $0A 
- lda $97A8,y +        lda $97A8,y 
- sta $0B+        sta $0B
 *       ldy $0408,x *       ldy $0408,x
- lda ($0A),y +        lda ($0A),y 
- cmp #$FF +        cmp #$FF 
- bne + +        bne + 
- sta $0408,x +        sta $0408,x 
- jmp LF987+        jmp LF987
  
 *       cmp EnDelay,x *       cmp EnDelay,x
- beq --- +        beq --- 
- inc EnDelay,x +        inc EnDelay,x 
- iny +        iny 
- lda ($0A),y +        lda ($0A),y 
- jsr $8296 +        jsr $8296 
- ldx PageIndex +        ldx PageIndex 
- sta $0402,x +        sta $0402,x 
- lda ($0A),y +        lda ($0A),y 
- jsr $832F +        jsr $832F 
- ldx PageIndex +        ldx PageIndex 
- sta $0403,x +        sta $0403,x 
- tay +        tay 
- lda $040A,x +        lda $040A,x 
- lsr +        lsr 
- php +        php 
- bcc + +        bcc + 
- tya +        tya 
- jsr TwosCompliment ;($C3D4) +        jsr TwosCompliment              ;($C3D4) 
- sta $0403,x+        sta $0403,x
 *       plp *       plp
- bne + +        bne + 
- lda $0402,x +        lda $0402,x 
- beq + +        beq + 
- bmi + +        bmi + 
- ldy $040A,x +        ldy $040A,x 
- lda $95E0,y +        lda $95E0,y 
- sta EnResetAnimIndex,x+        sta EnResetAnimIndex,x
 *       jsr LFA1E *       jsr LFA1E
- ldx PageIndex +        ldx PageIndex 
- bcs ++ +        bcs ++ 
- lda EnStatus,+        lda EnStatus,
- beq Exit20 +        beq Exit20 
- ldy #$00 +        ldy #$00 
- lda $040A,x +        lda $040A,x 
- lsr +        lsr 
- beq + +        beq + 
- iny+        iny
 *       lda $95E2,y *       lda $95E2,y
- jsr LF68D +        jsr LF68D 
- jsr LF518 +        jsr LF518 
- lda #$0A +        lda #$0A 
- sta EnDelay,x+        sta EnDelay,x
 *       jmp LF97C *       jmp LF97C
  
 KillObject: KillObject:
-LFA18: lda #$00 +LFA18:  lda #$00                        
-LFA1A: sta EnStatus,x ;Store #$00 as enemy status(enemy slot is open). +LFA1A:  sta EnStatus,                 ;Store #$00 as enemy status(enemy slot is open). 
-LFA1D: rts ;+LFA1D:  rts                             ;
  
 ; enemy<-->background crash detection ; enemy<-->background crash detection
  
 LFA1E:  lda InArea LFA1E:  lda InArea
- cmp #$11 +        cmp #$11 
- bne + +        bne + 
- lda EnStatus,+        lda EnStatus,
- lsr +        lsr 
- bcc +++        bcc ++
 *       jsr LFA7D *       jsr LFA7D
- ldy #$00 +        ldy #$00 
- lda ($04),y +        lda ($04),y 
- cmp #$A0 +        cmp #$A0 
- bcc ++ +        bcc ++ 
- ldx PageIndex+        ldx PageIndex
 *       lda $0403,x *       lda $0403,x
- sta $05 +        sta $05 
- lda $0402,x +        lda $0402,x 
- sta $04+        sta $04
 LFA41:  jsr LE792 LFA41:  jsr LE792
- jsr LFD8F +        jsr LFD8F 
- bcc KillObject ;($FA18)Free enemy data slot.+        bcc KillObject                  ;($FA18)Free enemy data slot.
 LFA49:  lda $08 LFA49:  lda $08
- sta EnYRoomPos,+        sta EnYRoomPos,
- lda $09 +        lda $09 
- sta EnXRoomPos,+        sta EnXRoomPos,
- lda $0B +        lda $0B 
- and #$01 +        and #$01 
- sta EnNameTable,x+        sta EnNameTable,x
 *       rts *       rts
  
 LFA5B:  lda $0404,x LFA5B:  lda $0404,x
- beq Exit20+        beq Exit20
 LFA60:  lda #$00 LFA60:  lda #$00
- sta $0404,x +        sta $0404,x 
- lda #$05 +        lda #$05 
- sta EnStatus,x+        sta EnStatus,x
 Exit20: rts Exit20: rts
  
 LFA6B:  lda EnAnimFrame,x LFA6B:  lda EnAnimFrame,x
- cmp #$F7 +        cmp #$F7 
- beq + +        beq + 
- dec EnDelay,x +        dec EnDelay,x 
- bne ++ +        bne ++ 
-*       jsr KillObject ;($FA18)Free enemy data slot.+*       jsr KillObject                  ;($FA18)Free enemy data slot.
 *       jmp LF97C *       jmp LF97C
  
 LFA7D:  ldx PageIndex LFA7D:  ldx PageIndex
- lda EnYRoomPos,+        lda EnYRoomPos,
- sta $02 +        sta $02 
- lda EnXRoomPos,+        lda EnXRoomPos,
- sta $03 +        sta $03 
- lda EnNameTable,+        lda EnNameTable,
- sta $0B +        sta $0B 
- jmp MakeCartRAMPtr ;($E96A)Find enemy position in room RAM.+        jmp MakeCartRAMPtr              ;($E96A)Find enemy position in room RAM.
  
-LFA91:  jsr KillObject ;($FA18)Free enemy data slot. +LFA91:  jsr KillObject                  ;($FA18)Free enemy data slot. 
- lda $95DC +        lda $95DC 
- jsr LF68D +        jsr LF68D 
- jmp LF97C+        jmp LF97C
  
 LFA9D:  ldx #$C0 LFA9D:  ldx #$C0
 *       stx PageIndex *       stx PageIndex
- lda EnStatus,+        lda EnStatus,
- beq + +        beq + 
- jsr LFAB4+        jsr LFAB4
 *       lda PageIndex *       lda PageIndex
- clc +        clc 
- adc #$08 +        adc #$08 
- tax +        tax 
- cmp #$E0 +        cmp #$E0 
- bne --+        bne --
 *      rts *      rts
  
 LFAB4:  dec EnCounter,x LFAB4:  dec EnCounter,x
- bne ++ +        bne ++ 
- lda #$0C +        lda #$0C 
- sta EnCounter,+        sta EnCounter,
- dec $0407,x +        dec $0407,x 
- bmi + +        bmi + 
- bne ++ +        bne ++ 
-*       jsr KillObject ;($FA18)Free enemy data slot. +*       jsr KillObject                  ;($FA18)Free enemy data slot. 
-* lda EnCounter,+      lda EnCounter,
- cmp #$09 +        cmp #$09 
- bne + +        bne + 
- lda $0407,x +        lda $0407,x 
- asl +        asl 
- tay +        tay 
- lda Table16,y +        lda Table16,y 
- sta $04 +        sta $04 
- lda Table16+1,+        lda Table16+1,
- sta $05 +        sta $05 
- jsr LFA41+        jsr LFA41
 *       lda #$80 *       lda #$80
- sta ObjectCntrl +        sta ObjectCntrl 
- lda #$03 +        lda #$03 
- jmp LF97E+        jmp LF97E
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table16: Table16:
- .byte $00 +        .byte $00 
- .byte $00 +        .byte $00 
- .byte $0C +        .byte $0C 
- .byte $1C +        .byte $1C 
- .byte $10 +        .byte $10 
- .byte $F0 +        .byte $F0 
- .byte $F0 +        .byte $F0 
- .byte $08+        .byte $08
  
 LFAF2:  ldy #$18 LFAF2:  ldy #$18
 *       jsr LFAFF *       jsr LFAFF
- lda PageIndex +        lda PageIndex 
- sec +        sec 
- sbc #$08 +        sbc #$08 
- tay +        tay 
- bne -+        bne -
  
 LFAFF:  sty PageIndex LFAFF:  sty PageIndex
- ldx $0728,y +        ldx $0728,y 
- inx +        inx 
- beq ----- +        beq ----- 
- ldx $0729,y +        ldx $0729,y 
- lda EnStatus,+        lda EnStatus,
- beq + +        beq + 
- lda $0405,x +        lda $0405,x 
- and #$02 +        and #$02 
- bne Exit13+        bne Exit13
 *       sta $0404,x *       sta $0404,x
- lda #$FF +        lda #$FF 
- cmp EnDataIndex,+        cmp EnDataIndex,
- bne + +        bne + 
- dec EnDelay,x +        dec EnDelay,x 
- bne Exit13 +        bne Exit13 
- lda $0728,y +        lda $0728,y 
- jsr LEB28 +        jsr LEB28 
- ldy PageIndex +        ldy PageIndex 
- lda $072A,y +        lda $072A,y 
- sta EnYRoomPos,+        sta EnYRoomPos,
- lda $072B,y +        lda $072B,y 
- sta EnXRoomPos,+        sta EnXRoomPos,
- lda $072C,y +        lda $072C,y 
- sta EnNameTable,+        sta EnNameTable,
- lda #$18 +        lda #$18 
- sta EnRadX,x +        sta EnRadX,x 
- lda #$0C +        lda #$0C 
- sta EnRadY,x +        sta EnRadY,x 
- ldy #$00 +        ldy #$00 
- jsr LF186 +        jsr LF186 
- jsr LF152 +        jsr LF152 
- jsr LF1BF +        jsr LF1BF 
- jsr LF1FA +        jsr LF1FA 
- bcc Exit13 +        bcc Exit13 
- lda #$01 +        lda #$01 
- sta EnDelay,x +        sta EnDelay,x 
- sta EnStatus,+        sta EnStatus,
- and ScrollDir +        and ScrollDir 
- asl +        asl 
- sta $0405,x +        sta $0405,x 
- ldy EnDataIndex,+        ldy EnDataIndex,
- jsr LFB7B +        jsr LFB7B 
- jmp LF85A+        jmp LF85A
  
 *       sta EnDataIndex,x *       sta EnDataIndex,x
- lda #$01 +        lda #$01 
- sta EnDelay,x +        sta EnDelay,x 
- jmp KillObject ;($FA18)Free enemy data slot.+        jmp KillObject                  ;($FA18)Free enemy data slot.
  
 LFB7B:  jsr $80B0 LFB7B:  jsr $80B0
- ror $0405,x +        ror $0405,x 
- lda EnemyInitDelayTbl,y ;($96BB)Load initial delay for enemy movement. +        lda EnemyInitDelayTbl,        ;($96BB)Load initial delay for enemy movement. 
- sta EnDelay,x ;+        sta EnDelay,          ;
  
 Exit13:  Exit13: 
- rts ;Exit from multiple routines.+        rts                             ;Exit from multiple routines.
  
 LFB88:  ldx PageIndex LFB88:  ldx PageIndex
- jsr LF844 +        jsr LF844 
- lda $6B01,x +        lda $6B01,x 
- inc $6B03,x +        inc $6B03,x 
- dec $6B03,x +        dec $6B03,x 
- bne + +        bne + 
- pha +        pha 
- pla+        pla
 *       bpl + *       bpl +
- jsr TwosCompliment ;($C3D4)+        jsr TwosCompliment              ;($C3D4)
 *       cmp #$08 *       cmp #$08
- bcc + +        bcc + 
- cmp #$10 +        cmp #$10 
- bcs Exit13 +        bcs Exit13 
- tya +        tya 
- and #$01 +        and #$01 
- tay +        tay 
- lda $0085,y +        lda $0085,y 
- cmp EnResetAnimIndex,+        cmp EnResetAnimIndex,
- beq Exit13 +        beq Exit13 
- sta EnAnimIndex,+        sta EnAnimIndex,
- dec EnAnimIndex,+        dec EnAnimIndex,
- sta EnResetAnimIndex,+        sta EnResetAnimIndex,
- jmp LF693+        jmp LF693
  
 *       lda $963B,y *       lda $963B,y
- cmp EnResetAnimIndex,+        cmp EnResetAnimIndex,
- beq Exit13 +        beq Exit13 
- jmp LF68D+        jmp LF68D
  
 LFBCA:  ldx PageIndex LFBCA:  ldx PageIndex
- jsr LF844 +        jsr LF844 
- lda $965B,y +        lda $965B,y 
- cmp EnResetAnimIndex,+        cmp EnResetAnimIndex,
- beq Exit13 +        beq Exit13 
- sta EnResetAnimIndex,+        sta EnResetAnimIndex,
- jmp LF690+        jmp LF690
  
 LFBDD:  lda #$40 LFBDD:  lda #$40
- sta PageIndex +        sta PageIndex 
- ldx #$0C+        ldx #$0C
 *       jsr LFBEC *       jsr LFBEC
- dex +        dex 
- dex +        dex 
- dex +        dex 
- dex +        dex 
- bne -+        bne -
 LFBEC:  lda $A0,x LFBEC:  lda $A0,x
- beq ++ +        beq ++ 
- dec $A0,x +        dec $A0,x 
- txa +        txa 
- lsr +        lsr 
- tay +        tay 
- lda Table17,y +        lda Table17,y 
- sta $04 +        sta $04 
- lda Table17+1,+        lda Table17+1,
- sta $05 +        sta $05 
- lda $A1,x +        lda $A1,x 
- sta $08 +        sta $08 
- lda $A2,x +        lda $A2,x 
- sta $09 +        sta $09 
- lda $A3,x +        lda $A3,x 
- sta $0B +        sta $0B 
- jsr LFD8F +        jsr LFD8F 
- bcc +++ +        bcc +++ 
- lda $08 +        lda $08 
- sta $A1,x +        sta $A1,x 
- sta $034D +        sta $034D 
- lda $09 +        lda $09 
- sta $A2,x +        sta $A2,x 
- sta $034E +        sta $034E 
- lda $0B +        lda $0B 
- and #$01 +        and #$01 
- sta $A3,x +        sta $A3,x 
- sta $034C +        sta $034C 
- lda $A3,x +        lda $A3,x 
- sta $034C +        sta $034C 
- lda #$5A +        lda #$5A 
- sta PowerUpAnimFrame ;Save index to find object animation. +        sta PowerUpAnimFrame            ;Save index to find object animation. 
- txa +        txa 
- pha +        pha 
- jsr DrawFrame +        jsr DrawFrame 
- lda SamusBlink +        lda SamusBlink 
- bne + +        bne + 
- ldy #$00 +        ldy #$00 
- ldx #$40 +        ldx #$40 
- jsr AreObjectsTouching ;($DC7F) +        jsr AreObjectsTouching          ;($DC7F) 
- bcs + +        bcs + 
- jsr IsScrewAttackActive ;($CD9C)Check if screw attack active. +        jsr IsScrewAttackActive         ;($CD9C)Check if screw attack active. 
- ldy #$00 +        ldy #$00 
- bcc + +        bcc + 
- clc +        clc 
- jsr LF311 +        jsr LF311 
- lda #$50 +        lda #$50 
- sta HealthLoChange +        sta HealthLoChange 
- jsr SubtractHealth ;($CE92)+        jsr SubtractHealth              ;($CE92)
 *       pla *       pla
- tax +        tax 
-* rts+      rts
  
-* lda #$00 +      lda #$00 
- sta $A0,x +        sta $A0,x 
- rts+        rts
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table17: Table17:
- .byte $00 +        .byte $00 
- .byte $FB +        .byte $FB 
- .byte $FB +        .byte $FB 
- .byte $FE +        .byte $FE 
- .byte $FB +        .byte $FB 
- .byte $02 +        .byte $02 
- .byte $00 +        .byte $00 
- .byte $05+        .byte $05
  
 LFC65:  lda $6BE4 LFC65:  lda $6BE4
- beq ++ +        beq ++ 
- ldx #$F0 +        ldx #$F0 
- stx PageIndex +        stx PageIndex 
- lda $6BE9 +        lda $6BE9 
- cmp $95E4 +        cmp $95E4 
- bne +++ +        bne +++ 
- lda #$03 +        lda #$03 
- jsr UpdateEnemyAnim +        jsr UpdateEnemyAnim 
- lda RandomNumber1 +        lda RandomNumber1 
- sta $8A +        sta $8A 
- lda #$18+        lda #$18
 *       pha *       pha
- tax +        tax 
- jsr LFC98 +        jsr LFC98 
- pla +        pla 
- tax +        tax 
- lda $B6,x +        lda $B6,x 
- and #$F8 +        and #$F8 
- sta $B6,x +        sta $B6,x 
- txa +        txa 
- sec +        sec 
- sbc #$08 +        sbc #$08 
- bpl -+        bpl -
 *       rts *       rts
  
-*      jmp KillObject ;($FA18)Free enemy data slot.+*      jmp KillObject                   ;($FA18)Free enemy data slot.
  
 LFC98:  lda $B0,x LFC98:  lda $B0,x
- jsr ChooseRoutine+        jsr ChooseRoutine
  
 ; Pointer table to code ; Pointer table to code
  
- .word ExitSub       ;($C45C) rts +        .word ExitSub       ;($C45C) rts 
- .word $FCA5 +        .word $FCA5 
- .word $FCB1 +        .word $FCB1 
- .word $FCBA+        .word $FCBA
  
 LFCA5:  jsr LFD84 LFCA5:  jsr LFD84
- jsr LFD08 +        jsr LFD08 
- jsr LFD25 +        jsr LFD25 
- jmp LDD8B+        jmp LDD8B
  
 LFCB1:  jsr LFD84 LFCB1:  jsr LFD84
- jsr LFCC1 +        jsr LFCC1 
- jmp LDD8B+        jmp LDD8B
  
 LFCBA:  lda #$00 LFCBA:  lda #$00
- sta $B0,x +        sta $B0,x 
- jmp SFX_EnemyHit+        jmp SFX_EnemyHit
  
 LFCC1:  jsr LFD5F LFCC1:  jsr LFD5F
- lda $B4,x +        lda $B4,x 
- cmp #$02 +        cmp #$02 
- bcs + +        bcs + 
- ldy $08 +        ldy $08 
- cpy ObjectY +        cpy ObjectY 
- bcc + +        bcc + 
- ora #$02 +        ora #$02 
- sta $B4,x+        sta $B4,x
 *       ldy #$01 *       ldy #$01
- lda $B4,x +        lda $B4,x 
- lsr +        lsr 
- bcc + +        bcc + 
- ldy #$FF+        ldy #$FF
 *       sty $05 *       sty $05
- ldy #$04 +        ldy #$04 
- lsr +        lsr 
- lda $B5,x +        lda $B5,x 
- bcc + +        bcc + 
- ldy #$FD+        ldy #$FD
 *       sty $04 *       sty $04
- inc $B5,x +        inc $B5,x 
- jsr LFD8F +        jsr LFD8F 
- bcs + +        bcs + 
- lda $B4,x +        lda $B4,x 
- ora #$02 +        ora #$02 
- sta $B4,x+        sta $B4,x
 *       bcc + *       bcc +
- jsr LFD6C+        jsr LFD6C
 *       lda $B5,x *       lda $B5,x
- cmp #$50 +        cmp #$50 
- bcc + +        bcc + 
- lda #$01 +        lda #$01 
- sta $B0,x+        sta $B0,x
 *       rts *       rts
  
 LFD08:  lda #$00 LFD08:  lda #$00
- sta $B5,x +        sta $B5,x 
- tay +        tay 
- lda ObjectX +        lda ObjectX 
- sec +        sec 
- sbc $B2,x +        sbc $B2,x 
- bpl + +        bpl + 
- iny +        iny 
- jsr TwosCompliment ;($C3D4)+        jsr TwosCompliment              ;($C3D4)
 *       cmp #$10 *       cmp #$10
- bcs + +        bcs + 
- tya +        tya 
- sta $B4,x +        sta $B4,x 
- lda #$02 +        lda #$02 
- sta $B0,x+        sta $B0,x
 *       rts *       rts
  
 LFD25:  txa LFD25:  txa
- lsr +        lsr 
- lsr +        lsr 
- lsr +        lsr 
- adc $8A +        adc $8A 
- sta $8A +        sta $8A 
- lsr $8A +        lsr $8A 
- and #$03 +        and #$03 
- tay +        tay 
- lda Table18,y +        lda Table18,y 
- sta $04 +        sta $04 
- lda Table18+1,+        lda Table18+1,
- sta $05 +        sta $05 
- jsr LFD5F +        jsr LFD5F 
- lda $08 +        lda $08 
- sec +        sec 
- sbc ScrollY +        sbc ScrollY 
- tay +        tay 
- lda #$02 +        lda #$02 
- cpy #$20 +        cpy #$20 
- bcc + +        bcc + 
- jsr TwosCompliment ;($C3D4) +        jsr TwosCompliment              ;($C3D4) 
- cpy #$80 +        cpy #$80 
- bcc +++        bcc ++
 *       sta $04 *       sta $04
 *      jsr LFD8F *      jsr LFD8F
- jmp LFD6C+        jmp LFD6C
  
 ; Table used by above subroutine ; Table used by above subroutine
  
 Table18: Table18:
- .byte $02 +        .byte $02 
- .byte $FE +        .byte $FE 
- .byte $01 +        .byte $01 
- .byte $FF +        .byte $FF 
- .byte $02+        .byte $02
  
 LFD5F:  lda $B3,x LFD5F:  lda $B3,x
- sta $0B +        sta $0B 
- lda $B1,x +        lda $B1,x 
- sta $08 +        sta $08 
- lda $B2,x +        lda $B2,x 
- sta $09 +        sta $09 
- rts+        rts
  
 LFD6C:  lda $08 LFD6C:  lda $08
- sta $B1,x +        sta $B1,x 
- sta $04F0 +        sta $04F0 
- lda $09 +        lda $09 
- sta $B2,x +        sta $B2,x 
- sta $04F1 +        sta $04F1 
- lda $0B +        lda $0B 
- and #$01 +        and #$01 
- sta $B3,x +        sta $B3,x 
- sta $6BEB +        sta $6BEB 
- rts+        rts
  
 LFD84:  lda $B6,x LFD84:  lda $B6,x
- and #$04 +        and #$04 
- beq + +        beq + 
- lda #$03 +        lda #$03 
- sta $B0,x+        sta $B0,x
 *       rts *       rts
  
 LFD8F:  lda ScrollDir LFD8F:  lda ScrollDir
- and #$02 +        and #$02 
- sta $02 +        sta $02 
- lda $04 +        lda $04 
- clc +        clc 
- bmi +++ +        bmi +++ 
- beq LFDBF +        beq LFDBF 
- adc $08 +        adc $08 
- bcs + +        bcs + 
- cmp #$F0 +        cmp #$F0 
- bcc +++        bcc ++
 *       adc #$0F *       adc #$0F
- ldy $02 +        ldy $02 
- bne ClcExit2 +        bne ClcExit2 
- inc $0B+        inc $0B
 *       sta $08 *       sta $08
- jmp LFDBF+        jmp LFDBF
  
-* adc $08 +      adc $08 
- bcs + +        bcs + 
- sbc #$0F +        sbc #$0F 
- ldy $02 +        ldy $02 
- bne ClcExit2 +        bne ClcExit2 
- inc $0B+        inc $0B
 *       sta $08 *       sta $08
 LFDBF:  lda $05 LFDBF:  lda $05
- clc +        clc 
- bmi ++ +        bmi ++ 
- beq SecExit +        beq SecExit 
- adc $09 +        adc $09 
- bcc + +        bcc + 
- ldy $02 +        ldy $02 
- beq ClcExit2 +        beq ClcExit2 
- inc $0B+        inc $0B
 *       jmp ++ *       jmp ++
  
 *       adc $09 *       adc $09
- bcs + +        bcs + 
- ldy $02 +        ldy $02 
- beq ClcExit2 +        beq ClcExit2 
- inc $0B+        inc $0B
 *       sta $09 *       sta $09
- SecExit: +        SecExit: 
- sec +        sec 
- rts+        rts
  
- ClcExit2: +        ClcExit2: 
- clc +        clc 
-* rts +      rts
- +
-LFDE3:  lda EndTimerHi +
- cmp #$99 +
- bne + +
- clc +
- sbc EndTimerLo  ; A = zero if timer just started +
- bne +    ; branch if not +
- sta $06 +
- lda #$38 +
- sta $07 +
- jsr LDC54 +
-*       ldx #$20 +
-*       jsr LFE05 +
- txa +
- sec +
- sbc #$08 +
- tax +
- bne -+
  
-LFE05:  lda $0758,x +UpdateTourianItems: 
- sec +; Adds mother brain and zebetite  
- sbc #$02 +LFDE3:  lda EndTimerHi          ; Determine if this is the first frame the end timer is running 
- bne --- +        cmp #$99                ; (it will have a value of 99.99 the first frame) 
- sta $06 +        bne +                    
- inc $0758,x +        clc                      
- txa +        sbc EndTimerLo           
- lsr +        bne +                   ; On the first frame of the end timer: 
- adc #$3C +                                 
- sta $07 +        sta $06                 ;  
- jmp LDC54+        lda #$38                ; 
 +        sta $07                 ;    Add [mother brain defeated] to item history 
 +        jsr LDC54               ;  
 +                                 
 +*       ldx #$20                ; Loop through zebetites (@ x = 20, 18, 10, 8, 0) 
 +*       jsr CheckZebetite       ;     ($FE05) Update one zebetite 
 +        txa                     ;     (Subtract 8 from x) 
 +        sec                      
 +        sbc #$08                 
 +        tax                      
 +        bne -                    
 +                                 
 +CheckZebetite                    
 +LFE05:  lda $0758,            ;  
 +        sec                      
 +        sbc #$02                ;  
 +        bne ---                 ; Exit if zebetite state != 2 
 +        sta $06                 ; Store 0 to $06 
 +        inc $0758,            ; Set zebetite state to 3 
 +        txa                      
 +        lsr                     ; A =  zebetite index * 4 (10, C, 8, 4, or 0) 
 +        adc #$3C                ;      + $3C 
 +        sta $07                  
 +        jmp LDC54               ; Add zebetite to item history
  
 ; Tile degenerate/regenerate ; Tile degenerate/regenerate
  
 UpdateTiles: UpdateTiles:
- ldx #$C0+        ldx #$C0
 *       jsr DoOneTile *       jsr DoOneTile
- ldx PageIndex +        ldx PageIndex 
- jsr Xminus16 +        jsr Xminus16 
- bne - +        bne - 
- DoOneTile: +        DoOneTile: 
- stx PageIndex +        stx PageIndex 
- lda TileRoutine,+        lda TileRoutine,
- beq +        ; exit if tile not active +        beq +          ; exit if tile not active 
- jsr ChooseRoutine+        jsr ChooseRoutine
  
 ; Pointer table to code ; Pointer table to code
  
- .word ExitSub       ;($C45C) rts +        .word ExitSub       ;($C45C) rts 
- .word $FE3D +        .word $FE3D 
- .word $FE54 +        .word $FE54 
- .word $FE59 +        .word $FE59 
- .word $FE54 +        .word $FE54 
- .word $FE83+        .word $FE83
  
 LFE3D:  inc TileRoutine,x LFE3D:  inc TileRoutine,x
- lda #$00 +        lda #$00 
- jsr SetTileAnim +        jsr SetTileAnim 
- lda #$50 +        lda #$50 
- sta TileDelay,+        sta TileDelay,
- lda TileWRAMLo,    ; low WRAM addr of blasted tile +        lda TileWRAMLo,    ; low WRAM addr of blasted tile 
- sta $00 +        sta $00 
- lda TileWRAMHi,    ; high WRAM addr +        lda TileWRAMHi,    ; high WRAM addr 
- sta $01+        sta $01
  
 LFE54:  lda #$02 LFE54:  lda #$02
- jmp UpdateTileAnim+        jmp UpdateTileAnim
  
 LFE59:  lda FrameCount LFE59:  lda FrameCount
- and #$03 +        and #$03 
- bne +       ; only update tile timer every 4th frame +        bne +       ; only update tile timer every 4th frame 
- dec TileDelay,+        dec TileDelay,
- bne +       ; exit if timer not reached zero +        bne +       ; exit if timer not reached zero 
- inc TileRoutine,+        inc TileRoutine,
- ldy TileType,+        ldy TileType,
- lda Table19,y +        lda Table19,y 
- SetTileAnim: +        SetTileAnim: 
- sta TileAnimIndex,+        sta TileAnimIndex,
- sta $0505,x +        sta $0505,x 
- lda #$00 +        lda #$00 
- sta TileAnimDelay,x+        sta TileAnimDelay,x
 *       rts *       rts
  
Line 9455: Line 9460:
  
 Table19: Table19:
- .byte $18,$1C,$20,$00,$04,$08,$0C,$10,$24,$14+        .byte $18,$1C,$20,$00,$04,$08,$0C,$10,$24,$14
  
 LFE83:  lda #$00 LFE83:  lda #$00
- sta TileRoutine,      ; tile = respawned +        sta TileRoutine,      ; tile = respawned 
- lda TileWRAMLo,+        lda TileWRAMLo,
- clc +        clc 
- adc #$21 +        adc #$21 
- sta $00 +        sta $00 
- lda TileWRAMHi,+        lda TileWRAMHi,
- sta $01 +        sta $01 
- jsr LFF3C +        jsr LFF3C 
- lda $02 +        lda $02 
- sta $07 +        sta $07 
- lda $03 +        lda $03 
- sta $09 +        sta $09 
- lda $01 +        lda $01 
- lsr +        lsr 
- lsr +        lsr 
- and #$01 +        and #$01 
- sta $0B +        sta $0B 
- ldy #$00 +        ldy #$00 
- jsr LF186 +        jsr LF186 
- lda #$04 +        lda #$04 
- clc +        clc 
- adc ObjRadY +        adc ObjRadY 
- sta $04 +        sta $04 
- lda #$04 +        lda #$04 
- clc +        clc 
- adc ObjRadX +        adc ObjRadX 
- sta $05 +        sta $05 
- jsr LF1FA +        jsr LF1FA 
- bcs Exit23 +        bcs Exit23 
- jsr LF311 +        jsr LF311 
- lda #$50 +        lda #$50 
- sta HealthLoChange +        sta HealthLoChange 
- jmp SubtractHealth ;($CE92)+        jmp SubtractHealth              ;($CE92)
  
- GetTileFramePtr: +        GetTileFramePtr: 
- lda TileAnimFrame,+        lda TileAnimFrame,
- asl +        asl 
- tay +        tay 
- lda $97AF,y +        lda $97AF,y 
- sta $02 +        sta $02 
- lda $97B0,y +        lda $97B0,y 
- sta $03+        sta $03
 Exit23: rts Exit23: rts
  
- DrawTileBlast: +        DrawTileBlast: 
- lda PPUStrIndex +        lda PPUStrIndex 
- cmp #$1F +        cmp #$1F 
- bcs Exit23 +        bcs Exit23 
- ldx PageIndex +        ldx PageIndex 
- lda TileWRAMLo,+        lda TileWRAMLo,
- sta $00 +        sta $00 
- lda TileWRAMHi,+        lda TileWRAMHi,
- sta $01 +        sta $01 
- jsr GetTileFramePtr +        jsr GetTileFramePtr 
- ldy #$00 +        ldy #$00 
- sty $11 +        sty $11 
- lda ($02),y +        lda ($02),y 
- tax +        tax 
- jsr Adiv16       ; / 16 +        jsr Adiv16       ; / 16 
- sta $04 +        sta $04 
- txa +        txa 
- and #$0F +        and #$0F 
- sta $05 +        sta $05 
- iny +        iny 
- sty $10+        sty $10
 *       ldx $05 *       ldx $05
 *       ldy $10 *       ldy $10
- lda ($02),y +        lda ($02),y 
- inc $10 +        inc $10 
- ldy $11 +        ldy $11 
- sta ($00),y +        sta ($00),y 
- inc $11 +        inc $11 
- dex +        dex 
- bne - +        bne - 
- lda $11 +        lda $11 
- clc +        clc 
- adc #$20 +        adc #$20 
- sec +        sec 
- sbc $05 +        sbc $05 
- sta $11 +        sta $11 
- dec $04 +        dec $04 
- bne -- +        bne -- 
- lda $01 +        lda $01 
- and #$04 +        and #$04 
- beq + +        beq + 
- lda $01 +        lda $01 
- ora #$0C +        ora #$0C 
- sta $01+        sta $01
 *       lda $01 *       lda $01
- and #$2F +        and #$2F 
- sta $01 +        sta $01 
- jsr LC328 +        jsr LC328 
- clc +        clc 
- rts+        rts
  
 LFF3C:  lda $00 LFF3C:  lda $00
- tay +        tay 
- and #$E0 +        and #$E0 
- sta $02 +        sta $02 
- lda $01 +        lda $01 
- lsr +        lsr 
- ror $02 +        ror $02 
- lsr +        lsr 
- ror $02 +        ror $02 
- tya +        tya 
- and #$1F +        and #$1F 
- jsr Amul8       ; * 8 +        jsr Amul8       ; * 8 
- sta $03 +        sta $03 
- rts+        rts
  
 UpdateTileAnim: UpdateTileAnim:
- ldx PageIndex +        ldx PageIndex 
- ldy TileAnimDelay,+        ldy TileAnimDelay,
- beq + +        beq + 
- dec TileAnimDelay,+        dec TileAnimDelay,
- bne +++        bne ++
 *       sta TileAnimDelay,x *       sta TileAnimDelay,x
- ldy TileAnimIndex,+        ldy TileAnimIndex,
- lda TileBlastAnim,+        lda TileBlastAnim,
- cmp #$FE     ; end of "tile-blast" animation? +        cmp #$FE            ; end of "tile-blast" animation? 
- beq ++ +        beq ++ 
- sta TileAnimFrame,+        sta TileAnimFrame,
- iny +        iny 
- tya +        tya 
- sta TileAnimIndex,+        sta TileAnimIndex,
- jsr DrawTileBlast +        jsr DrawTileBlast 
- bcc + +        bcc + 
- ldx PageIndex +        ldx PageIndex 
- dec TileAnimIndex,+        dec TileAnimIndex,
-* rts+      rts
  
 *       inc TileRoutine,x *       inc TileRoutine,x
- pla +        pla 
- pla +        pla 
- rts+        rts
  
 ; Frame data for tile blasts ; Frame data for tile blasts
  
- TileBlastAnim: +        TileBlastAnim: 
- .byte $06,$07,$00,$FE +        .byte $06,$07,$00,$FE 
- .byte $07,$06,$01,$FE +        .byte $07,$06,$01,$FE 
- .byte $07,$06,$02,$FE +        .byte $07,$06,$02,$FE 
- .byte $07,$06,$03,$FE +        .byte $07,$06,$03,$FE 
- .byte $07,$06,$04,$FE +        .byte $07,$06,$04,$FE 
- .byte $07,$06,$05,$FE +        .byte $07,$06,$05,$FE 
- .byte $07,$06,$09,$FE +        .byte $07,$06,$09,$FE 
- .byte $07,$06,$0A,$FE +        .byte $07,$06,$0A,$FE 
- .byte $07,$06,$0B,$FE +        .byte $07,$06,$0B,$FE 
- .byte $07,$06,$08,$FE+        .byte $07,$06,$08,$FE
  
- .byte $00 +        .byte $00 
- .byte $00+        .byte $00
  
 ;-----------------------------------------------[ RESET ]-------------------------------------------- ;-----------------------------------------------[ RESET ]--------------------------------------------
  
 RESET: RESET:
-LFFB0: SEI ;Disables interrupt +LFFB0:  SEI                             ;Disables interrupt 
-LFFB1: CLD ;Sets processor to binary mode +LFFB1:  CLD                             ;Sets processor to binary mode 
-LFFB2: LDX #$00 +LFFB2:  LDX #$00                        
-LFFB4: STX PPUControl0 ;Clear PPU control registers +LFFB4:  STX PPUControl0                 ;Clear PPU control registers 
-LFFB7: STX PPUControl1 +LFFB7:  STX PPUControl1                 
-LFFBA:* LDA PPUStatus +LFFBA:* LDA PPUStatus                   
-LFFBD: BPL - ;Wait for VBlank +LFFBD:  BPL -                           ;Wait for VBlank 
-LFFBF:* LDA PPUStatus +LFFBF:* LDA PPUStatus                   
-LFFC2: BPL - +LFFC2:  BPL -                           
-LFFC4: ORA #$FF +LFFC4:  ORA #$FF                        
-LFFC6: STA MMC1Reg0 ;Reset MMC1 chip +LFFC6:  STA MMC1Reg0                    ;Reset MMC1 chip 
-LFFC9: STA MMC1Reg1 ;(MSB is set) +LFFC9:  STA MMC1Reg1                    ;(MSB is set) 
-LFFCC: STA MMC1Reg2 +LFFCC:  STA MMC1Reg2                    
-LFFCF: STA MMC1Reg3 +LFFCF:  STA MMC1Reg3                    
-LFFD2: JMP Startup ;($C01A)Do preliminary housekeeping.+LFFD2:  JMP Startup                     ;($C01A)Do preliminary housekeeping.
  
 ;Not used. ;Not used.
-LFFD5: .byte $FF, $FF, $FF, $4C, $E4, $B3, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF +LFFD5:  .byte $FF, $FF, $FF, $4C, $E4, $B3, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF 
-LFFE5: .byte $FF, $FF, $FF, $FF, $4D, $45, $54, $52, $4F, $49, $44, $E4, $8D, $00, $00, $38 +LFFE5:  .byte $FF, $FF, $FF, $FF, $4D, $45, $54, $52, $4F, $49, $44, $E4, $8D, $00, $00, $38 
-LFFF5: .byte $04, $01, $06, $01, $BC+LFFF5:  .byte $04, $01, $06, $01, $BC
  
 ;-----------------------------------------[ Interrupt vectors ]-------------------------------------- ;-----------------------------------------[ Interrupt vectors ]--------------------------------------
  
-LBFFA:  .word NMI ;($C0D9)NMI vector. +LBFFA:  .word NMI                       ;($C0D9)NMI vector. 
-LBFFC: .word RESET ;($FFB0)Reset vector. +LBFFC:  .word RESET                     ;($FFB0)Reset vector. 
-LBFFE:  .word RESET ;($FFB0)IRQ vector.+LBFFE:  .word RESET                     ;($FFB0)IRQ vector.
 </code> </code>
 +
metroid/disassembly/game_engine_page.1429571676.txt.gz · Last modified: 2015/04/20 23:14 by gf_kennon