This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
metroid:disassembly:game_engine_page [2015/04/20 23:14] – created gf_kennon | metroid:disassembly:game_engine_page [2016/03/06 17:29] (current) – infos on breakable blocks snarfblam | ||
---|---|---|---|
Line 29: | Line 29: | ||
; | ; | ||
- | .alias ObjectAnimIndexTbl $8572 | + | .alias ObjectAnimIndexTbl |
- | .alias FramePtrTable $860B | + | .alias FramePtrTable |
- | .alias PlacePtrTable $86DF | + | .alias PlacePtrTable |
- | .alias StarPalSwitch $8AC7 | + | .alias StarPalSwitch |
- | .alias SamusEnterDoor $8B13 | + | .alias SamusEnterDoor |
- | .alias AreaPointers $9598 | + | .alias AreaPointers |
- | .alias AreaRoutine $95C3 | + | .alias AreaRoutine |
- | .alias EnemyHitPointTbl $962B | + | .alias EnemyHitPointTbl |
- | .alias EnemyInitDelayTbl $96BB | + | .alias EnemyInitDelayTbl |
- | .alias DecSpriteYCoord $988A | + | .alias DecSpriteYCoord |
- | .alias NMIScreenWrite $9A07 | + | .alias NMIScreenWrite |
- | .alias EndGamePalWrite $9F54 | + | .alias EndGamePalWrite |
- | .alias SpecItmsTable $9598 | + | .alias SpecItmsTable |
- | .alias CopyMap $A93E | + | .alias CopyMap |
- | .alias SoundEngine $B3B4 | + | .alias SoundEngine |
; | ; | ||
Line 53: | Line 53: | ||
RandomNumbers: | RandomNumbers: | ||
- | LC000: txa ; | + | LC000: |
- | LC001: pha ; | + | LC001: |
- | LC002: ldx #$05 ; | + | LC002: |
- | LC004:* lda RandomNumber1 ; | + | LC004:* lda RandomNumber1 |
- | LC006: clc ; | + | LC006: |
- | LC007: adc #$05 ; | + | LC007: |
- | LC009: sta RandomNumber1 ;2E is increased by #$19 every frame and--> | + | LC009: |
- | LC00B: lda RandomNumber2 ;2F is increased by #$5F every frame. | + | LC00B: |
- | LC00D: clc ; | + | LC00D: |
- | LC00E: adc #$13 ; | + | LC00E: |
- | LC010: sta RandomNumber2 ; | + | LC010: |
- | LC012: dex ; | + | LC012: |
- | LC013: bne - ; | + | LC013: |
- | LC015: pla ; | + | LC015: |
- | LC016: tax ; | + | LC016: |
- | LC017: lda RandomNumber1 ; | + | LC017: |
- | LC019: rts ; | + | LC019: |
; | ; | ||
Startup: | Startup: | ||
- | LC01A: lda #$00 ; | + | LC01A: |
- | LC01C: sta MMC1Reg1 | + | LC01C: |
- | LC01F: sta MMC1Reg1 ;Clear bit 1 | + | LC01F: |
- | LC022: sta MMC1Reg1 ;Clear bit 2 | + | LC022: |
- | LC024: sta MMC1Reg1 ;Clear bit 3 | + | LC024: |
- | LC027: sta MMC1Reg1 ;Clear bit 4 | + | LC027: |
- | LC02B: sta MMC1Reg2 ;Clear bit 0 | + | LC02B: |
- | LC02E: sta MMC1Reg2 ;Clear bit 1 | + | LC02E: |
- | LC031: sta MMC1Reg2 ;Clear bit 2 | + | LC031: |
- | LC034: sta MMC1Reg2 ;Clear bit 3 | + | LC034: |
- | LC037: sta MMC1Reg2 ;Clear bit 4 | + | LC037: |
- | LC03A: jsr MMCWriteReg3 ; | + | LC03A: |
- | LC03D: dex ;X = $FF | + | LC03D: |
- | LC03E: txs ;S points to end of stack page | + | LC03E: |
;Clear RAM at $000-$7FF. | ;Clear RAM at $000-$7FF. | ||
- | LC03F: ldy #$07 ;High byte of start address. | + | LC03F: |
- | LC041: sty $01 ; | + | LC041: |
- | LC043: ldy #$00 ;Low byte of start address. | + | LC043: |
- | LC045: sty $00 ;$0000 = #$0700 | + | LC045: |
- | LC047: tya ;A = 0 | + | LC047: |
- | LC048:* sta ($00), | + | LC048:* sta ($00), |
- | LC04A: iny ; | + | LC04A: |
- | LC04B: bne - ;Repeat for entire page. | + | LC04B: |
- | LC04D: dec $01 ;Decrement high byte of address. | + | LC04D: |
- | LC04F: bmi + ;If $01 < 0, all pages are cleared. | + | LC04F: |
- | LC051: ldx $01 ; | + | LC051: |
- | LC053: cpx #$01 ;Keep looping until ram is cleared. | + | LC053: |
- | LC055: bne - ; | + | LC055: |
;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: |
- | LC05B: ldy #$00 ;Low byte of start address. | + | LC05B: |
- | LC05D: sty $00 ;$0000 points to $7F00 | + | LC05D: |
- | LC05F: tya ;A = 0 | + | LC05F: |
- | LC060:* sta ($00),y ; | + | LC060:* sta ($00), |
- | LC062: iny ;Clears 256 bytes of memory before decrementing to next--> | + | LC062: |
- | LC063: bne - ;256 bytes. | + | LC063: |
- | LC065: dec $01 ; | + | LC065: |
- | LC067: ldx $01 ;Is address < $6000? | + | LC067: |
- | LC069: cpx #$60 ;If not, do another page. | + | LC069: |
- | LC06B: bcs - ; | + | LC06B: |
- | LC06D: lda #%00001110 ;Verticle mirroring. | + | LC06D: |
- | ;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: |
- | LC071: lda #$00 ;Clear bits 3 and 4 of MMC1 register 3. | + | LC071: |
- | LC073: sta SwitchUpperBits ; | + | LC073: |
- | LC075: ldy #$00 ; | + | LC075: |
- | LC077: sty ScrollX ;ScrollX = 0 | + | LC077: |
- | LC079: sty ScrollY | + | LC079: |
- | LC07B: sty PPUScroll ;Clear hardware scroll x | + | LC07B: |
- | LC07E: sty PPUScroll ;Clear hardware scroll y | + | LC07E: |
- | LC081: iny ;Y = #$01 | + | LC081: |
- | LC082: sty GameMode ;Title screen mode | + | LC082: |
- | LC084: jsr ClearNameTables ;($C158) | + | LC084: |
- | LC087: jsr EraseAllSprites ;($C1A3) | + | LC087: |
- | LC08A: lda #%10010000 ;NMI = enabled | + | LC08A: |
- | ;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: |
- | LC08F: sta PPUCNT0ZP ; | + | LC08F: |
- | LC091: lda #%00000010 ;Sprites visible = no | + | LC091: |
- | ;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: |
- | LC095: lda #$47 ; | + | LC095: |
- | LC097: sta MirrorCntrl ;Prepare to set PPU to vertical mirroring. | + | LC097: |
- | LC099: jsr PrepVertMirror ;($C4B2) | + | LC099: |
- | LC09C: lda #$00 ; | + | LC09C: |
- | LC09E: sta DMCCntrl1 ;PCM volume = 0 - disables DMC channel | + | LC09E: |
- | LC0A1: lda #$0F ; | + | LC0A1: |
- | LC0A3: sta APUCommonCntrl0 ;Enable sound channel 0,1,2,3 | + | LC0A3: |
- | LC0A6: ldy #$00 ; | + | LC0A6: |
- | LC0A8: sty TitleRoutine ;Set title routine and and main routine function--> | + | LC0A8: |
- | LC0AA: sty MainRoutine ;pointers equal to 0. | + | LC0AA: |
- | LC0AC: lda #$11 ; | + | LC0AC: |
- | LC0AE: sta RandomNumber1 ;Initialize RandomNumber1 to #$11 | + | LC0AE: |
- | LC0B0: lda #$FF ; | + | LC0B0: |
- | LC0B2: sta RandomNumber2 ;Initialize RandomNumber2 to #$FF | + | LC0B2: |
- | LC0B4: iny ;Y = 1 | + | LC0B4: |
- | LC0B5: sty SwitchPending ;Prepare to switch page 0 into lower PRGROM. | + | LC0B5: |
- | LC0B7: jsr CheckSwitch ;($C4DE) | + | LC0B7: |
- | LC0BA: bne WaitNMIEnd ;Branch always | + | LC0BA: |
; | ; | ||
Line 181: | Line 181: | ||
MainLoop: | MainLoop: | ||
- | LC0BC: jsr CheckSwitch ; | + | LC0BC: |
- | LC0BF: jsr UpdateTimer ; | + | LC0BF: |
- | LC0C2: jsr GoMainRoutine ;($C114)Go to main routine for updating game. | + | LC0C2: |
- | LC0C5: inc FrameCount ;Increment frame counter. | + | LC0C5: |
- | LC0C7: lda #$00 ; | + | LC0C7: |
- | LC0C9: sta NMIStatus ;Wait for next NMI to end. | + | LC0C9: |
WaitNMIEnd: | WaitNMIEnd: | ||
- | LC0CB: tay ; | + | LC0CB: |
- | LC0CC: lda NMIStatus ; | + | LC0CC: |
- | LC0CE: bne + ;If nonzero, NMI has ended. Else keep waiting. | + | LC0CE: |
- | LC0D0: jmp WaitNMIEnd ; | + | LC0D0: |
- | LC0D3:* jsr RandomNumbers ; | + | LC0D3:* jsr RandomNumbers |
- | LC0D6: jmp MainLoop ; | + | LC0D6: |
; | ; | ||
Line 206: | Line 206: | ||
NMI: | NMI: | ||
- | LC0D9: php ;Save processor status, A, X and Y on stack. | + | LC0D9: |
- | LC0DA: pha ;Save A. | + | LC0DA: |
- | LC0DB: txa ; | + | LC0DB: |
- | LC0DC: pha ;Save X. | + | LC0DC: |
- | LC0DD: tya ; | + | LC0DD: |
- | LC0DE: pha ;Save Y. | + | LC0DE: |
- | LC0DF: lda #$00 ; | + | LC0DF: |
- | LC0E1: sta SPRAddress ;Sprite RAM address = 0. | + | LC0E1: |
- | LC0E4: lda #$02 ; | + | LC0E4: |
- | LC0E6: sta SPRDMAReg ;Transfer page 2 ($200-$2FF) to Sprite RAM. | + | LC0E6: |
- | LC0E9: lda NMIStatus ; | + | LC0E9: |
- | LC0EB: bne ++ ;Skip if the frame couldn' | + | LC0EB: |
- | LC0ED: lda GameMode ; | + | LC0ED: |
- | LC0EF: beq + ;Branch if mode=Play. | + | LC0EF: |
- | LC0F1: jsr NMIScreenWrite ; | + | LC0F1: |
- | LC0F4:* jsr CheckPalWrite ; | + | LC0F4:* jsr CheckPalWrite |
- | LC0F7: jsr CheckPPUWrite ; | + | LC0F7: |
- | LC0FA: jsr WritePPUCtrl ; | + | LC0FA: |
- | LC0FD: jsr WriteScroll ; | + | LC0FD: |
- | LC100: jsr ReadJoyPads ; | + | LC100: |
- | LC103:* jsr SoundEngine ; | + | LC103:* jsr SoundEngine |
- | LC106: jsr UpdateAge ; | + | LC106: |
- | LC109: ldy #$01 ; NMI = finished. | + | LC109: |
- | LC10B: sty NMIStatus ; | + | LC10B: |
- | LC10D: pla ;Restore Y. | + | LC10D: |
- | LC10E: tay ; | + | LC10E: |
- | LC10F: pla ;Restore X. | + | LC10F: |
- | LC110: tax ; | + | LC110: |
- | LC111: pla ;restore A. | + | LC111: |
- | LC112: plp ;Restore processor status flags. | + | LC112: |
- | LC113: rti ;Return from NMI. | + | LC113: |
; | ; | ||
Line 246: | Line 246: | ||
GoMainRoutine: | GoMainRoutine: | ||
- | LC114: lda GameMode ;0 if game is running, 1 if at intro screen. | + | LC114: |
- | LC116: beq + ;Branch if mode=Play. | + | LC116: |
- | LC118: jmp $8000 ;Jump to $8000, where a routine similar to the one--> | + | LC118: |
- | ;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: |
- | LC11F: beq +++ ;if not, execute current routine as normal. | + | LC11F: |
- | LC121: lda MainRoutine ; | + | LC121: |
- | LC123: cmp #$03 ;Is game engine running? | + | LC123: |
- | LC125: beq + ;If yes, check for routine #5 (pause game). | + | LC125: |
- | LC127: cmp #$05 ;Is game paused? | + | LC127: |
- | LC129: bne +++ ;If not routine #5 either, don't care about START being pressed. | + | LC129: |
- | LC12B: lda #$03 ;Otherwise, switch to routine #3 (game engine). | + | LC12B: |
- | LC12D: bne ++ ;Branch always. | + | LC12D: |
- | LC12F:* lda #$05 ;Switch to pause routine. | + | LC12F:* lda #$05 ;Switch to pause routine. |
- | LC131:* sta MainRoutine ; | + | LC131:* sta MainRoutine |
- | LC133: lda GamePaused ; | + | LC133: |
- | LC135: eor #$01 ;Toggle game paused. | + | LC135: |
- | LC137: sta GamePaused ; | + | LC137: |
- | LC139: jsr PauseMusic ; | + | LC139: |
- | LC13c:* lda MainRoutine ; | + | LC13c:* lda MainRoutine |
- | LC13E: jsr ChooseRoutine ;($C27C)Use MainRoutine as index into routine table below. | + | LC13E: |
;Pointer table to code. | ;Pointer table to code. | ||
- | LC141: | + | LC141: |
- | LC143: | + | LC143: |
- | LC145: | + | LC145: |
- | LC147: | + | LC147: |
- | LC149: | + | LC149: |
- | LC14B: | + | LC14B: |
- | LC14D: | + | LC14D: |
- | LC14F: | + | LC14F: |
- | LC151: | + | LC151: |
- | LC153: | + | LC153: |
IncrementRoutine: | IncrementRoutine: | ||
- | LC155: inc MainRoutine ;Increment to next routine in above table. | + | LC155: |
- | LC157: rts ; | + | LC157: |
; | ; | ||
ClearNameTables: | ClearNameTables: | ||
- | LC158: jsr ClearNameTable0 ; | + | LC158: |
- | LC15B: lda GameMode ; | + | LC15B: |
- | LC15D: beq + ;Branch if mode = Play. | + | LC15D: |
- | LC15F: lda TitleRoutine ; | + | LC15F: |
- | LC161: cmp #$1D ;If running the end game routine, clear--> | + | LC161: |
- | LC163: beq ++ ;name table 2, else clear name table 1. | + | LC163: |
- | 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: |
- | 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: |
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 |
- | LC171: lda #$FF ; | + | LC171: |
- | LC173: sta $00 ;Value to fill with. | + | LC173: |
ClearNameTable: | ClearNameTable: | ||
- | LC175: ldx PPUStatus ;Reset PPU address latch. | + | LC175: |
- | LC178: lda PPUCNT0ZP ; | + | LC178: |
- | LC17A: and #$FB ;PPU increment = 1. | + | LC17A: |
- | LC17C: sta PPUCNT0ZP ; | + | LC17C: |
- | LC17E: sta PPUControl0 ;Store control bits in PPU. | + | LC17E: |
- | LC181: ldx $01 ; | + | LC181: |
- | LC183: dex ;Name table = X - 1. | + | LC183: |
- | LC184: lda HiPPUTable, | + | LC184: |
- | LC187: sta PPUAddress ; | + | LC187: |
- | LC18A: lda #$00 ;Set PPU start address (High byte first). | + | LC18A: |
- | LC18C: sta PPUAddress ; | + | LC18C: |
- | LC18F: ldx #$04 ;Prepare to loop 4 times. | + | LC18F: |
- | LC191: ldy #$00 ;Inner loop value. | + | LC191: |
- | LC193: lda $00 ; | + | LC193: |
- | LC195:* sta PPUIOReg ; | + | LC195:* sta PPUIOReg |
- | LC198: dey ; | + | LC198: |
- | LC199: bne - ;Loops until the desired name table is cleared.--> | + | LC199: |
- | LC19B: dex ;It also clears the associated attribute table. | + | LC19B: |
- | LC19C: bne - ; | + | LC19C: |
- | LC19E: rts ; | + | LC19E: |
;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: | + | LC19F: |
- | LC1A0: | + | LC1A0: |
- | LC1A1: | + | LC1A1: |
- | LC1A2: | + | LC1A2: |
; | ; | ||
EraseAllSprites: | EraseAllSprites: | ||
- | LC1A3: ldy #$02 ; | + | LC1A3: |
- | LC1A5: sty $01 ;Loads locations $00 and $01 with --> | + | LC1A5: |
- | LC1A7: ldy #$00 ;#$00 and #$02 respectively | + | LC1A7: |
- | LC1A9: sty $00 ; | + | LC1A9: |
- | LC1AB: ldy #$00 ; | + | LC1AB: |
- | LC1AD: lda #$F0 ; | + | LC1AD: |
- | LC1AF:* sta ($00),y ;Stores #$F0 in memory addresses $0200 thru $02FF. | + | LC1AF:* sta ($00), |
- | LC1B1: iny ; | + | LC1B1: |
- | LC1B2: bne - ;Loop while more sprite RAM to clear. | + | LC1B2: |
- | LC1B4: lda GameMode ; | + | LC1B4: |
- | LC1B6: beq Exit101 ;Exit subroutine if GameMode=Play(# | + | LC1B6: |
- | LC1B8: jmp DecSpriteYCoord ; | + | LC1B8: |
Exit101: | Exit101: | ||
- | LC1BB: rts ;Return used by subroutines above and below. | + | LC1BB: |
; | ; | ||
Line 366: | Line 366: | ||
RemoveIntroSprites: | RemoveIntroSprites: | ||
- | LC1BC: ldy #$02 ;Start at address $200. | + | LC1BC: |
- | LC1BE: sty $01 ; | + | LC1BE: |
- | LC1C0: ldy #$00 ; | + | LC1C0: |
- | LC1C2: sty $00 ;($00) = $0200 (sprite page) | + | LC1C2: |
- | LC1C4: ldy #$5F ;Prepare to clear RAM $0200-$025F | + | LC1C4: |
- | LC1C6: lda #$F4 ; | + | LC1C6: |
- | LC1C8:* sta ($00),y ; | + | LC1C8:* sta ($00), |
- | LC1CA: dey ;Loop unitl $200 thru $25F is filled with #$F4. | + | LC1CA: |
- | LC1CB: bpl - ; | + | LC1CB: |
- | LC1CD: lda GameMode ; | + | LC1CD: |
- | LC1CF: beq Exit101 ; branch if mode = Play. | + | LC1CF: |
- | LC1D1: jmp DecSpriteYCoord ; | + | LC1D1: |
; | ; | ||
Line 384: | Line 384: | ||
ClearRAM_33_DF: | ClearRAM_33_DF: | ||
- | LC1D4: ldx #$33 ; | + | LC1D4: |
- | LC1D6: lda #$00 ; | + | LC1D6: |
- | LC1D8:* sta $00,x ;Clear RAM addresses $33 through $DF. | + | LC1D8:* sta $00,x |
- | LC1DA: inx ; | + | LC1DA: |
- | LC1DB: cpx #$E0 ; | + | LC1DB: |
- | LC1DD: bcc - ;Loop until all desired addresses are cleared. | + | LC1DD: |
- | LC1DF: rts ; | + | LC1DF: |
; | ; | ||
CheckPalWrite: | CheckPalWrite: | ||
- | LC1E0: lda GameMode ; | + | LC1E0: |
- | LC1E2: beq + ;Is game being played? If so, branch to exit. | + | LC1E2: |
- | LC1E4: lda TitleRoutine ; | + | LC1E4: |
- | LC1E6: cmp #$1D ;Is Game at ending sequence? If not, branch | + | LC1E6: |
- | LC1E8: bcc + ; | + | LC1E8: |
- | LC1EA: jmp EndGamePalWrite ; | + | LC1EA: |
- | LC1ED:* ldy PalDataPending ; | + | LC1ED:* ldy PalDataPending |
- | LC1EF: bne ++ ;Is palette data pending? If so, branch. | + | LC1EF: |
- | LC1F1: lda GameMode ; | + | LC1F1: |
- | LC1F3: beq + ;Is game being played? If so, branch to exit. | + | LC1F3: |
- | LC1F5: lda TitleRoutine ; | + | LC1F5: |
- | LC1F7: cmp #$15 ;Is intro playing? If not, branch. | + | LC1F7: |
- | LC1F9: bcs + ; | + | LC1F9: |
- | LC1FB: jmp StarPalSwitch ; | + | LC1FB: |
- | LC1FE: | + | LC1FE:* rts |
;Prepare to write palette data to PPU. | ;Prepare to write palette data to PPU. | ||
- | LC1FF: | + | LC1FF:* dey |
- | LC200: tya ; | + | LC200: |
- | LC201: asl ;* 2, each pal data ptr is 2 bytes (16-bit). | + | LC201: |
- | LC202: tay ; | + | LC202: |
- | LC203: ldx $9560,y ;X = low byte of PPU data pointer. | + | LC203: |
- | LC206: lda $9561,y ; | + | LC206: |
- | LC209: tay ;Y = high byte of PPU data pointer. | + | LC209: |
- | LC20A: lda #$00 ;Clear A. | + | LC20A: |
- | LC20C: sta PalDataPending ;Reset palette data pending byte. | + | LC20C: |
PreparePPUProcess_: | PreparePPUProcess_: | ||
- | LC20E: stx $00 ;Lower byte of pointer to PPU string. | + | LC20E: |
- | LC210: sty $01 ;Upper byte of pointer to PPU string. | + | LC210: |
- | LC212: jmp ProcessPPUString ; | + | LC212: |
; | ; | ||
Line 433: | Line 433: | ||
ReadJoyPads: | ReadJoyPads: | ||
- | LC215: ldx #$00 ;Load x with #$00. Used to read status of joypad 1. | + | LC215: |
- | LC217: stx $01 ; | + | LC217: |
- | LC219: jsr ReadOnePad ; | + | LC219: |
- | LC21C: inx ;Load x with #$01. Used to read status of joypad 2. | + | LC21C: |
- | LC21D: inc $01 ; | + | LC21D: |
ReadOnePad: | ReadOnePad: | ||
- | LC21F: ldy #$01 ;These lines strobe the --> | + | LC21F: |
- | LC221: sty CPUJoyPad1 | + | LC221: |
- | LC224: dey ;program to read the --> | + | LC224: |
- | LC225: sty CPUJoyPad1 | + | LC225: |
- | + | ||
- | LC228: ldy #$08 ;Do 8 buttons. | + | LC228: |
- | LC22A: | + | LC22A:* pha |
- | LC22B: lda CPUJoyPad1, | + | LC22B: |
- | LC22E: sta $00 ;Store button press at location $00. | + | LC22E: |
- | LC230: lsr ;Move button push to carry bit. | + | LC230: |
- | LC231: ora $00 ;If joystick not connected, --> | + | LC231: |
- | LC233: lsr ;fills Joy1Status with all 1s. | + | LC233: |
- | LC234: pla ;Restore A. | + | LC234: |
- | LC235: rol ;Add button press status to A. | + | LC235: |
- | LC236: | + | LC236: |
- | LC237: bne - ;status of all 8 buttons. | + | LC237: |
- | LC239: ldx $01 ;Joypad #(0 or 1). | + | LC239: |
- | LC23B: ldy Joy1Status, | + | LC23B: |
- | LC23D: sty $00 ;Store at $00. | + | LC23D: |
- | LC23F: sta Joy1Status, | + | LC23F: |
- | LC241: eor $00 ; | + | LC241: |
- | LC243: beq + ;Branch if no buttons changed. | + | LC243: |
- | LC245: lda $00 ; | + | LC245: |
- | LC247: and #$BF ;Remove the previous status of the B button. | + | LC247: |
- | LC249: sta $00 ; | + | LC249: |
- | LC24B: eor Joy1Status, | + | LC24B: |
- | LC24D:* and Joy1Status, | + | LC24D:* and Joy1Status, |
- | LC24F: sta Joy1Change, | + | LC24F: |
- | LC251: sta Joy1Retrig, | + | LC251: |
- | LC253: ldy #$20 ; | + | LC253: |
- | LC255: lda Joy1Status, | + | LC255: |
- | LC257: cmp $00 ;pressed this frame as last frame.--> | + | LC257: |
- | LC259: bne + ;If none, branch. | + | LC259: |
- | LC25B: dec RetrigDelay1, | + | LC25B: |
- | LC25D: bne ++ ; | + | LC25D: |
- | LC25F: sta Joy1Retrig, | + | LC25F: |
- | LC261: ldy #$08 ; | + | LC261: |
- | LC263:* sty RetrigDelay1, | + | LC263:* sty RetrigDelay1, |
- | LC265: | + | LC265:* rts |
; | ; | ||
Line 492: | Line 492: | ||
UpdateTimer: | UpdateTimer: | ||
- | LC266: ldx #$01 ;First timer to decrement is Timer2. | + | LC266: |
- | LC268: dec TimerDelay ; | + | LC268: |
- | LC26A: bpl DecTimer ; | + | LC26A: |
- | LC26C: lda #$09 ;TimerDelay hits #$00 every 10th frame. | + | LC26C: |
- | LC26E: sta TimerDelay ;Reset TimerDelay after it hits #$00. | + | LC26E: |
- | LC270: ldx #$02 ;Decrement Timer3 every 10 frames. | + | LC270: |
DecTimer: | DecTimer: | ||
- | LC272: lda Timer1,x ; | + | LC272: |
- | LC274: beq + ;Don't decrease if timer is already zero. | + | LC274: |
- | LC276: dec Timer1,x ; | + | LC276: |
- | LC278: | + | LC278:* dex |
- | LC279: bpl DecTimer ; | + | LC279: |
- | LC27B: rts ; | + | LC27B: |
; | ; | ||
Line 515: | Line 515: | ||
ChooseRoutine: | ChooseRoutine: | ||
- | LC27C: asl ;* 2, each ptr is 2 bytes (16-bit). | + | LC27C: |
- | LC27D: sty TempY ;Temp storage. | + | LC27D: |
- | LC27F: stx TempX ;Temp storage. | + | LC27F: |
- | LC281: tay ; | + | LC281: |
- | LC282: iny ; | + | LC282: |
- | LC283: pla ;Low byte of ptr table address. | + | LC283: |
- | LC284: sta CodePtr ; | + | LC284: |
- | LC286: pla ;High byte of ptr table address. | + | LC286: |
- | LC287: sta CodePtr+1 ; | + | LC287: |
- | LC289: lda (CodePtr), | + | LC289: |
- | LC28B: tax ; | + | LC28B: |
- | LC28C: iny ; | + | LC28C: |
- | LC28D: lda (CodePtr), | + | LC28D: |
- | LC28F: sta CodePtr+1 ; | + | LC28F: |
- | LC291: stx CodePtr ; | + | LC291: |
- | LC293: ldx TempX ;Restore X. | + | LC293: |
- | LC295: ldy TempY ;Restore Y. | + | LC295: |
- | LC297: jmp (CodePtr) ; | + | LC297: |
; | ; | ||
WriteScroll: | WriteScroll: | ||
- | LC29A: lda PPUStatus ;Reset scroll register flip/flop | + | LC29A: |
- | LC29D: lda ScrollX ; | + | LC29D: |
- | LC29F: sta PPUScroll ; | + | LC29F: |
- | LC2A2: lda ScrollY ;X and Y scroll offsets are loaded serially. | + | LC2A2: |
- | LC2A4: sta PPUScroll ; | + | LC2A4: |
- | LC2A7: rts ; | + | LC2A7: |
; | ; | ||
Line 549: | Line 549: | ||
AddYToPtr00: | AddYToPtr00: | ||
- | LC2A8: tya ; | + | LC2A8: |
- | LC2A9: clc ;Add value stored in Y to lower address--> | + | LC2A9: |
- | LC2AA: adc $00 ;byte stored in $00. | + | LC2AA: |
- | LC2AC: sta $00 ; | + | LC2AC: |
- | LC2AE: bcc + ;Increment $01(upper address byte) if carry--> | + | LC2AE: |
- | LC2B0: inc $01 ;has occurred. | + | LC2B0: |
- | LC2B2: | + | LC2B2:* rts |
;Add Y to pointer at $0002 | ;Add Y to pointer at $0002 | ||
AddYToPtr02: | AddYToPtr02: | ||
- | LC2B3: tya ; | + | LC2B3: |
- | LC2B4: clc ;Add value stored in Y to lower address--> | + | LC2B4: |
- | LC2B5: adc $02 ;byte stored in $02. | + | LC2B5: |
- | LC2B7: sta $02 ; | + | LC2B7: |
- | LC2B9: bcc + ;Increment $01(upper address byte) if carry--> | + | LC2B9: |
- | LC2BB: inc $03 ;has occurred. | + | LC2BB: |
- | LC2BD: | + | LC2BD:* rts |
; | ; | ||
Adiv32: | Adiv32: | ||
- | LC2BE: lsr ;Divide by 32. | + | LC2BE: |
Adiv16: | Adiv16: | ||
- | LC2BF: lsr ;Divide by 16. | + | LC2BF: |
Adiv8: | Adiv8: | ||
- | LC2C0: lsr ;Divide by 8. | + | LC2C0: |
- | LC2C1: lsr ; | + | LC2C1: |
- | LC2C2: lsr ;Divide by shifting A right. | + | LC2C2: |
- | LC2C3: rts ; | + | LC2C3: |
Amul32: | Amul32: | ||
- | LC2C4: asl ;Multiply by 32. | + | LC2C4: |
Amul16: | Amul16: | ||
- | LC2C5: asl ;Multiply by 16. | + | LC2C5: |
Amul8: | Amul8: | ||
- | LC2C6: asl ;Multiply by 8. | + | LC2C6: |
- | LC2C7: asl ; | + | LC2C7: |
- | LC2C8: asl ;Multiply by shifting A left. | + | LC2C8: |
- | LC2C9: rts ; | + | LC2C9: |
; | ; | ||
Line 600: | Line 600: | ||
CheckPPUWrite: | CheckPPUWrite: | ||
- | LC2CA: lda PPUDataPending ; | + | LC2CA: |
- | LC2CC: beq + ;If zero no PPU data to write, branch to exit. | + | LC2CC: |
- | LC2CE: lda #$A1 ; | + | LC2CE: |
- | LC2D0: sta $00 ;Sets up PPU writer to start at address $07A1. | + | LC2D0: |
- | LC2D2: lda #$07 ; | + | LC2D2: |
- | LC2D4: sta $01 ;$0000 = ptr to PPU data string ($07A1). | + | LC2D4: |
- | LC2D6: jsr ProcessPPUString | + | LC2D6: |
- | LC2D9: lda #$00 ; | + | LC2D9: |
- | LC2DB: sta PPUStrIndex ;PPU data string has been written so the data--> | + | LC2DB: |
- | LC2DE: sta PPUDataString ;stored for the write is now erased. | + | LC2DE: |
- | LC2E1: sta PPUDataPending ; | + | LC2E1: |
- | LC2E3: | + | LC2E3:* rts |
PPUWrite: | PPUWrite: | ||
- | LC2E4: sta PPUAddress ;Set high PPU address. | + | LC2E4: |
- | LC2E7: iny ; | + | LC2E7: |
- | LC2E8: lda ($00),y ; | + | LC2E8: |
- | LC2EA: sta PPUAddress ;Set low PPU address. | + | LC2EA: |
- | LC2ED: iny ; | + | LC2ED: |
- | LC2EE: lda ($00),y ;Get data byte containing rep length & RLE status. | + | LC2EE: |
- | LC2F0: asl ;Carry Flag = PPU address increment (0 = 1, 1 = 32). | + | LC2F0: |
- | LC2F1: jsr SetPPUInc ; | + | LC2F1: |
- | LC2F4: asl ;Carry Flag = bit 6 of byte at ($00),y (1 = RLE). | + | LC2F4: |
- | LC2F5: lda ($00),y ;Get data byte again. | + | LC2F5: |
- | LC2F7: and #$3F ;Keep lower 6 bits as loop counter. | + | LC2F7: |
- | LC2F9: tax ; | + | LC2F9: |
- | LC2FA: bcc PPUWriteLoop ;If Carry Flag not set, the data is not RLE. | + | LC2FA: |
- | LC2FC: iny ;Data is RLE, advance to data byte. | + | LC2FC: |
PPUWriteLoop: | PPUWriteLoop: | ||
- | LC2FD: bcs + ; | + | LC2FD: |
- | LC2FF: iny ;Only inc Y if data is not RLE. | + | LC2FF: |
- | LC300:* lda ($00),y ;Get data byte. | + | LC300:* lda ($00), |
- | LC302: sta PPUIOReg ;Write to PPU. | + | LC302: |
- | LC305: dex ;Decrease loop counter. | + | LC305: |
- | LC306: bne PPUWriteLoop ;Keep going until X=0. | + | LC306: |
- | LC308: iny ; | + | LC308: |
- | LC309: jsr AddYToPtr00 ; | + | LC309: |
;Write data string at ($00) to PPU. | ;Write data string at ($00) to PPU. | ||
ProcessPPUString: | ProcessPPUString: | ||
- | LC30C: ldx PPUStatus ;Reset PPU address flip/ | + | LC30C: |
- | LC30F: ldy #$00 ; | + | LC30F: |
- | LC311: lda ($00),y ; | + | LC311: |
- | LC313: bne PPUWrite ;If A is non-zero, PPU data string follows, | + | LC313: |
- | LC315: jmp WriteScroll ; | + | LC315: |
;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: |
- | LC319: lda PPUCNT0ZP ; | + | LC319: |
- | LC31B: ora #$04 ; | + | LC31B: |
- | LC31D: bcs + ;PPU increment = 32 only if Carry Flag set, | + | LC31D: |
- | LC31F: and #$FB ;else PPU increment = 1. | + | LC31F: |
- | LC321:* sta PPUControl0 ; | + | LC321:* sta PPUControl0 |
- | LC323: sta PPUCNT0ZP ; | + | LC323: |
- | LC326: pla ;Restore A. | + | LC326: |
- | LC327: rts ; | + | LC327: |
;Erase blasted tile on nametable. | ;Erase blasted tile on nametable. | ||
EraseTile: | EraseTile: | ||
- | LC328: ldy #$01 ; | + | LC328: |
- | LC32A: sty PPUDataPending ;data pending = YES. | + | LC32A: |
- | LC32C: dey ; | + | LC32C: |
- | LC32D: lda ($02),y ; | + | LC32D: |
- | LC32F: and #$0F ; | + | LC32F: |
- | LC331: sta $05 ;# of tiles horizontally. | + | LC331: |
- | LC333: lda ($02),y ; | + | LC333: |
- | LC335: jsr Adiv16 ;($C2BF)/ 16. | + | LC335: |
- | LC338: sta $04 ;# of tiles vertically. | + | LC338: |
- | LC33A: ldx PPUStrIndex ; | + | LC33A: |
- | LC33D:* lda $01 ; | + | LC33D:* lda $01 |
- | LC33F: jsr WritePPUByte ; | + | LC33F: |
- | LC342: lda $00 ; | + | LC342: |
- | LC344: jsr WritePPUByte ; | + | LC344: |
- | LC347: lda $05 ;data length. | + | LC347: |
- | LC349: sta $06 ; | + | LC349: |
- | LC34B: jsr WritePPUByte ; | + | LC34B: |
- | LC34E: | + | LC34E:* iny |
- | LC34F: lda ($02),y ;Get new tile to replace old tile. | + | LC34F: |
- | LC351: jsr WritePPUByte ; | + | LC351: |
- | LC354: dec $06 ; | + | LC354: |
- | LC356: bne - ;Branch if more horizontal tiles to replace. | + | LC356: |
- | LC358: stx PPUStrIndex ; | + | LC358: |
- | LC35B: sty $06 ; | + | LC35B: |
- | LC35D: ldy #$20 ; | + | LC35D: |
- | LC35F: jsr AddYToPtr00 ; | + | LC35F: |
- | LC362: ldy $06 ;Store index to find next tile info. | + | LC362: |
- | LC364: dec $04 ; | + | LC364: |
- | LC366: bne -- ;Branch if more lines need to be changed on name table. | + | LC366: |
- | LC368: jsr EndPPUString ; | + | LC368: |
WritePPUByte: | WritePPUByte: | ||
- | LC36B: sta PPUDataString, | + | LC36B: |
NextPPUByte: | NextPPUByte: | ||
- | LC36E: inx ; | + | LC36E: |
- | LC36F: cpx #$4F ;PPU byte writer can only write a maximum of #$4F bytes | + | LC36F: |
- | LC371: bcc + ;If PPU string not full, branch to get more data. | + | LC371: |
- | LC373: ldx PPUStrIndex ; | + | LC373: |
EndPPUString: | EndPPUString: | ||
- | LC376: lda #$00 ;If PPU string is already full, or all PPU bytes loaded, | + | LC376: |
- | LC378: sta PPUDataString, | + | LC378: |
- | LC37B: pla ; | + | LC37B: |
- | LC37C: pla ;Remove last return address from stack and jump out of--> | + | LC37C: |
- | LC37D: | + | LC37D:* rts |
;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: |
- | LC380: sty PPUDataPending ;Indicate data waiting to be written to PPU. | + | LC380: |
- | LC382: dey ; | + | LC382: |
- | LC383: beq ++++ ;Branch always | + | LC383: |
- | LC385:* sta $04 ;$04 now contains next data byte to be put into the PPU string. | + | LC385:* sta $04 |
- | LC387: lda $01 ;High byte of staring address to write PPU data | + | LC387: |
- | LC389: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | LC389: |
- | LC38c: lda $00 ;Low byte of starting address to write PPU data. | + | LC38c: |
- | LC38E: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | LC38E: |
- | LC391: lda $04 ;A now contains next data byte to be put into the PPU string. | + | LC391: |
- | LC393: jsr SeparateControlBits ; | + | LC393: |
- | LC396: bit $04 ;Check to see if RLE bit is set in control byte.--> | + | LC396: |
- | LC398: bvc WritePaletteStringByte ; | + | LC398: |
- | LC39A: iny ;to find repeating data byte. | + | LC39A: |
WritePaletteStringByte: | WritePaletteStringByte: | ||
- | LC39B: bit $04 ;Check if RLE bit is set (again). if set, load same--> | + | LC39B: |
- | LC39D: bvs + ;byte over and over again until counter = #$00. | + | LC39D: |
- | LC39F: iny ; | + | LC39F: |
- | LC3A0:* lda ($02),y ; | + | LC3A0:* lda ($02), |
- | LC3A2: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | LC3A2: |
- | LC3A5: sty $06 ; | + | LC3A5: |
- | LC3A7: ldy #$01 ;PPU address increment = 1. | + | LC3A7: |
- | LC3A9: bit $04 ;If MSB set in control bit, it looks like this routine might--> | + | LC3A9: |
- | LC3AB: bpl + ;have been used for a software control verticle mirror, but--> | + | LC3AB: |
- | ;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: |
- | LC3AF:* jsr AddYToPtr00 ;($C2A8)Set next PPU write address.(Does nothing, already set). | + | LC3AF:* jsr AddYToPtr00 |
- | LC3B2: ldy $06 ;Restore data index to Y. | + | LC3B2: |
- | LC3B4: dec $05 ;Decrement counter byte. | + | LC3B4: |
- | LC3B6: bne WritePaletteStringByte ; | + | LC3B6: |
- | LC3B8: stx PPUStrIndex ;Store total length, in bytes, of PPUDataString. | + | LC3B8: |
- | LC3BB: iny ;Move to next data byte(should be #$00). | + | LC3BB: |
- | LC3BC:* ldx PPUStrIndex ;X now contains current length of PPU data string. | + | LC3BC:* ldx PPUStrIndex |
- | LC3BF: lda ($02),y ; | + | LC3BF: |
- | LC3C1: bne ---- ;Is PPU string done loading (#$00)? If so exit, | + | LC3C1: |
- | LC3C3: jsr EndPPUString ; | + | LC3C3: |
SeparateControlBits: | SeparateControlBits: | ||
- | LC3C6: sta $04 ;Store current byte | + | LC3C6: |
- | LC3C8: and #$BF ; | + | LC3C8: |
- | LC3CA: sta PPUDataString, | + | LC3CA: |
- | LC3CD: and #$3F ; | + | LC3CD: |
- | LC3CF: sta $05 ;Extract counter bits and save them for use above. | + | LC3CF: |
- | LC3D1: jmp NextPPUByte ;($C36E) | + | LC3D1: |
; | ; | ||
TwosCompliment: | TwosCompliment: | ||
- | LC3D4: eor #$FF ; | + | LC3D4: |
- | LC3D6: clc ;Generate twos compliment of value stored in A. | + | LC3D6: |
- | LC3D7: adc #$01 ; | + | LC3D7: |
- | LC3D9: rts ; | + | LC3D9: |
;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 ; | + | LC3DA: |
- | LC3DD: adc $01 ;Add lower nibble to number. | + | LC3DD: |
- | LC3DF: cmp #$0A ; | + | LC3DF: |
- | LC3E1: bcc + ;If result is greater than 9, add 5 to create--> | + | LC3E1: |
- | LC3E3: adc #$05 ;valid result(skip #$0A thru #$0F). | + | LC3E3: |
- | LC3E5: | + | LC3E5:* clc |
- | LC3E6: adc $02 ;Add upper nibble to number. | + | LC3E6: |
- | LC3E8: sta $02 ; | + | LC3E8: |
- | LC3EA: lda $03 ; | + | LC3EA: |
- | LC3EC: and #$F0 ;Keep upper 4 bits of HealthLo/ | + | LC3EC: |
- | LC3EE: adc $02 ; | + | LC3EE: |
- | LC3F0: bcc ++ ; | + | LC3F0: |
- | 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: |
- | LC3F5: rts ; | + | LC3F5: |
- | LC3F6:* cmp #$A0 ;If result of upper nibble add is greater than # | + | LC3F6:* cmp #$A0 ;If result of upper nibble add is greater than # |
- | LC3F8: bcs -- ;Branch to add #$5F to create valid result. | + | LC3F8: |
- | LC3FA: rts ; | + | LC3FA: |
Base10Subtract: | Base10Subtract: | ||
- | LC3FB: jsr ExtractNibbles ; | + | LC3FB: |
- | LC3FE: sbc $01 ;Subtract lower nibble from number. | + | LC3FE: |
- | LC400: sta $01 ; | + | LC400: |
- | LC402: bcs + ;If result is less than zero, add 10 to create--> | + | LC402: |
- | LC404: adc #$0A ;valid result. | + | LC404: |
- | LC406: sta $01 ; | + | LC406: |
- | LC408: lda $02 ; | + | LC408: |
- | LC40A: adc #$0F ;Adjust $02 to account for borrowing. | + | LC40A: |
- | LC40C: sta $02 ; | + | LC40C: |
- | LC40E:* lda $03 ;Keep upper 4 bits of HealthLo/ | + | LC40E:* lda $03 |
- | LC410: and #$F0 ; | + | LC410: |
- | LC412: sec ; | + | LC412: |
- | LC413: sbc $02 ;If result is greater than zero, branch to finish. | + | LC413: |
- | LC415: bcs + ; | + | LC415: |
- | LC417: adc #$A0 ;Add 10 to create valid result. | + | LC417: |
- | LC419: clc ; | + | LC419: |
- | LC41A:* ora $01 ;Combine A and $01 to create final value. | + | LC41A:* ora $01 |
- | LC41C: rts ; | + | LC41C: |
ExtractNibbles: | ExtractNibbles: | ||
- | LC41D: pha ; | + | LC41D: |
- | LC41E: and #$0F ;Lower 4 bits of value to change HealthLo/ | + | LC41E: |
- | LC420: sta $01 ; | + | LC420: |
- | LC422: pla ; | + | LC422: |
- | LC423: and #$F0 ;Upper 4 bits of value to change HealthLo/ | + | LC423: |
- | LC425: sta $02 ; | + | LC425: |
- | LC427: lda $03 ; | + | LC427: |
- | LC429: and #$0F ;Keep lower 4 bits of HealthLo/ | + | LC429: |
- | LC42B: rts ; | + | LC42B: |
; | ; | ||
Line 838: | Line 838: | ||
WaitNMIPass: | WaitNMIPass: | ||
- | LC42C: jsr ClearNMIStat ; | + | LC42C: |
- | LC42F:* lda NMIStatus ; | + | LC42F:* lda NMIStatus |
- | LC431: beq - ;Wait for NMI to end. | + | LC431: |
- | LC433: rts ; | + | LC433: |
ClearNMIStat: | ClearNMIStat: | ||
- | LC434: lda #$00 ;Clear NMI byte to indicate the game is--> | + | LC434: |
- | LC436: sta NMIStatus ;currently running NMI routines. | + | LC436: |
- | LC438: rts ; | + | LC438: |
ScreenOff: | ScreenOff: | ||
- | LC439: lda PPUCNT1ZP ; | + | LC439: |
- | LC43B: and #$E7 ; BG & SPR visibility = off | + | LC43B: |
WriteAndWait: | WriteAndWait: | ||
- | LC43D:* sta PPUCNT1ZP ;Update value to be loaded into PPU control register. | + | LC43D:* sta PPUCNT1ZP |
WaitNMIPass_: | WaitNMIPass_: | ||
- | LC43F: jsr ClearNMIStat ; | + | LC43F: |
- | LC442:* lda NMIStatus ; | + | LC442:* lda NMIStatus |
- | LC444: beq - ;Wait for NMI to end before continuing. | + | LC444: |
- | LC446: rts ; | + | LC446: |
ScreenOn: | ScreenOn: | ||
- | LC447: lda PPUCNT1ZP ; | + | LC447: |
- | LC449: ora #$1E ;BG & SPR visibility = on | + | LC449: |
- | LC44B: bne -- ;Branch always | + | LC44B: |
;Update the actual PPU control registers. | ;Update the actual PPU control registers. | ||
WritePPUCtrl: | WritePPUCtrl: | ||
- | LC44D: lda PPUCNT0ZP ; | + | LC44D: |
- | LC44F: sta PPUControl0 ; | + | LC44F: |
- | LC452: lda PPUCNT1ZP ;Update PPU control registers. | + | LC452: |
- | LC454: sta PPUControl1 ; | + | LC454: |
- | LC457: lda MirrorCntrl ; | + | LC457: |
- | LC459: jsr PrepPPUMirror ; | + | LC459: |
ExitSub: | ExitSub: | ||
- | LC45C: rts ;Exit subroutines. | + | LC45C: |
;Turn off both screen and NMI. | ;Turn off both screen and NMI. | ||
ScreenNmiOff: | ScreenNmiOff: | ||
- | LC45D: lda PPUCNT1ZP ; | + | LC45D: |
- | LC45F: and #$E7 ;BG & SPR visibility = off | + | LC45F: |
- | LC461: jsr WriteAndWait ; | + | LC461: |
- | LC464: lda PPUCNT0ZP ;Prepare to turn off NMI in PPU. | + | LC464: |
- | LC466: and #$7F ;NMI = off | + | LC466: |
- | LC468: sta PPUCNT0ZP ; | + | LC468: |
- | LC46A: sta PPUControl0 ;Actually load PPU register with NMI off value. | + | LC46A: |
- | LC46D: rts ; | + | LC46D: |
;The following routine does not appear to be used. | ;The following routine does not appear to be used. | ||
- | LC46E: lda PPUCNT0ZP ;Enable VBlank. | + | LC46E: |
- | LC470: ora #$80 ; | + | LC470: |
- | LC472: sta PPUCNT0ZP ;Write PPU control register 0 and PPU status byte. | + | LC472: |
- | LC474: sta PPUControl0 ; | + | LC474: |
- | LC477: lda PPUCNT1ZP ;Turn sprites and screen on. | + | LC477: |
- | LC479: ora #$1E ; | + | LC479: |
- | LC47B: bne -- ;Branch always. | + | LC47B: |
VBOffAndHorzWrite: | VBOffAndHorzWrite: | ||
- | LC47D: lda PPUCNT0ZP ; | + | LC47D: |
- | LC47F: and #$7B ;Horizontal write, disable VBlank. | + | LC47F: |
- | LC481:* sta PPUControl0 ;Save new values in the PPU control register--> | + | LC481:* sta PPUControl0 |
- | LC484: sta PPUCNT0ZP ;and PPU status byte. | + | LC484: |
- | LC486: rts ; | + | LC486: |
NmiOn: | NmiOn: | ||
- | LC487:* lda PPUStatus ; | + | LC487:* lda PPUStatus |
- | LC48A: and #$80 ;Wait for end of VBlank. | + | LC48A: |
- | LC48C: bne - ; | + | LC48C: |
- | LC48E: lda PPUCNT0ZP ; | + | LC48E: |
- | LC490: ora #$80 ;Enable VBlank interrupts. | + | LC490: |
- | LC492: bne -- ;Branch always. | + | LC492: |
; | ; | ||
Line 923: | Line 923: | ||
WaitTimer: | WaitTimer: | ||
- | LC494: lda Timer3 ;Exit if timer hasn't hit zero yet | + | LC494: |
- | LC496: bne + ; | + | LC496: |
- | LC498: lda NextRoutine ;Set GameOver as next routine. | + | LC498: |
- | LC49A: cmp #$04 ; | + | LC49A: |
- | LC49C: beq SetMainRoutine ;Set GoPassword as main routine. | + | LC49C: |
- | LC49E: cmp #$06 ; | + | LC49E: |
- | LC4A0: beq SetMainRoutine ; | + | LC4A0: |
- | LC4A2: jsr StartMusic ; | + | LC4A2: |
- | LC4A5: lda NextRoutine ;is next routine. Start area music before exiting. | + | LC4A5: |
SetMainRoutine: | SetMainRoutine: | ||
- | LC4A7: sta MainRoutine ;Set next routine to run. | + | LC4A7: |
- | LC4A9: | + | LC4A9:* rts |
SetTimer: | SetTimer: | ||
- | LC4AA: sta Timer3 ;Set Timer3. Frames to wait is value stored in A*10. | + | LC4AA: |
- | LC4AC: stx NextRoutine ;Save routine to jump to after Timer3 expires. | + | LC4AC: |
- | LC4AE: lda #$09 ;Next routine to run is WaitTimer. | + | LC4AE: |
- | LC4B0: bne SetMainRoutine ;Branch always. | + | LC4B0: |
; | ; | ||
PrepVertMirror: | PrepVertMirror: | ||
- | LC4B2: nop ; | + | LC4B2: |
- | LC4B3: nop ;Prepare to set PPU for vertical mirroring (again). | + | LC4B3: |
- | LC4B4: lda #$47 ; | + | LC4B4: |
SetPPUMirror: | SetPPUMirror: | ||
- | LC4B6: lsr ; | + | LC4B6: |
- | LC4B7: lsr ;Move bit 3 to bit 0 position. | + | LC4B7: |
- | LC4B8: lsr ; | + | LC4B8: |
- | LC4B9: and #$01 ;Remove all other bits. | + | LC4B9: |
- | LC4BB: sta $00 ;Store at address $00. | + | LC4BB: |
- | LC4BD: lda MMCReg0Cntrl ; | + | LC4BD: |
- | LC4BF: and #$FE ;Load MMCReg0Cntrl and remove bit 0. | + | LC4BF: |
- | LC4C1: ora $00 ;Replace bit 0 with stored bit at $00. | + | LC4C1: |
- | LC4C3: sta MMCReg0Cntrl ; | + | LC4C3: |
- | LC4C5: sta MMC1Reg0 ; | + | LC4C5: |
- | LC4C8: lsr ; | + | LC4C8: |
- | LC4C9: sta MMC1Reg0 ; | + | LC4C9: |
- | LC4Cc: lsr ; | + | LC4Cc: |
- | LC4CD: sta MMC1Reg0 ; | + | LC4CD: |
- | LC4D0: lsr ;Load new configuration data serially--> | + | LC4D0: |
- | LC4D1: sta MMC1Reg0 ;into MMC1Reg0. | + | LC4D1: |
- | LC4D4: lsr ; | + | LC4D4: |
- | LC4D5: sta MMC1Reg0 ; | + | LC4D5: |
- | LC4D8: rts ; | + | LC4D8: |
PrepPPUMirror: | PrepPPUMirror: | ||
- | LC4D9: lda MirrorCntrl ;Load MirrorCntrl into A. | + | LC4D9: |
- | LC4DB: jmp SetPPUMirror ;($C4B6)Set mirroring through MMC1 chip. | + | LC4DB: |
; | ; | ||
Line 984: | Line 984: | ||
CheckSwitch: | CheckSwitch: | ||
- | LC4DE: ldy SwitchPending ; | + | LC4DE: |
- | LC4E0: beq + ;Exit if zero(no bank switch issued). else Y contains bank#+1. | + | LC4E0: |
- | LC4E2: jsr SwitchOK ; | + | LC4E2: |
- | LC4E5: jmp GoBankInit ; | + | LC4E5: |
SwitchOK: | SwitchOK: | ||
- | LC4E8: lda #$00 ;Reset(so that the bank switch won't be performed--> | + | LC4E8: |
- | LC4EA: sta SwitchPending ;every succeeding frame too). | + | LC4EA: |
- | LC4EC: dey ;Y now contains the bank to switch to. | + | LC4EC: |
- | LC4ED: sty CurrentBank ; | + | LC4ED: |
ROMSwitch: | ROMSwitch: | ||
- | LC4EF: tya ; | + | LC4EF: |
- | LC4F0: sta $00 ;Bank to switch to is stored at location $00. | + | LC4F0: |
- | LC4F2: lda SwitchUpperBits ;Load upper two bits for Reg 3 (they should always be 0). | + | LC4F2: |
- | LC4F4: and #$18 ;Extract bits 3 and 4 and add them to the current--> | + | LC4F4: |
- | LC4F6: ora $00 ;bank to switch to. | + | LC4F6: |
- | LC4F8: sta SwitchUpperBits ;Store any new bits set in 3 or 4(there should be none). | + | LC4F8: |
;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: |
- | LC4FD: lsr ; | + | LC4FD: |
- | LC4FE: sta MMC1Reg3 ;Write bit 1 of ROM bank #. | + | LC4FE: |
- | LC501: lsr ; | + | LC501: |
- | LC502: sta MMC1Reg3 ;Write bit 2 of ROM bank #. | + | LC502: |
- | LC505: lsr ; | + | LC505: |
- | LC506: sta MMC1Reg3 ;Write bit 3 of ROM bank #. | + | LC506: |
- | LC509: lsr ; | + | LC509: |
- | LC50A: sta MMC1Reg3 ;Write bit 4 of ROM bank #. | + | LC50A: |
- | LC50D: lda $00 ;Restore A with current bank number before exiting. | + | LC50D: |
- | LC50F: | + | 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: |
- | LC511: tay ; | + | LC511: |
- | LC512: lda BankInitTable, | + | LC512: |
- | LC515: sta $0A ;Load appropriate subroutine address into $0A and $0B. | + | LC515: |
- | LC517: lda BankInitTable+1, | + | LC517: |
- | LC51A: sta $0B ; | + | LC51A: |
- | LC51C: jmp ($000A) ;Jump to appropriate initialization routine. | + | LC51C: |
BankInitTable: | BankInitTable: | ||
- | LC51F: | + | LC51F: |
- | LC521: | + | LC521: |
- | LC523: | + | LC523: |
- | LC525: | + | LC525: |
- | LC527: | + | LC527: |
- | LC529: | + | LC529: |
- | LC52B: | + | LC52B: |
- | LC52D: | + | LC52D: |
- | LC52F: | + | LC52F: |
;Title screen memory page. | ;Title screen memory page. | ||
InitBank0: | InitBank0: | ||
- | LC531: ldy #$00 ; | + | LC531: |
- | LC533: sty GamePaused ;Ensure game is not paused. | + | LC533: |
- | LC535: iny ;Y=1. | + | LC535: |
- | LC536: sty GameMode ;Game is at title routines. | + | LC536: |
- | LC538: jsr ScreenNmiOff ; | + | LC538: |
- | LC53B: jsr CopyMap ; | + | LC53B: |
- | LC53E: jsr ClearNameTables ; | + | LC53E: |
- | LC541: ldy #$A0 ; | + | LC541: |
- | LC543:* lda $98BF,y ; | + | LC543:* lda $98BF, |
- | LC546: sta $6DFF,y ;Loads sprite info for stars into RAM $6E00 thru 6E9F. | + | LC546: |
- | LC549: dey ; | + | LC549: |
- | LC54A: bne - ; | + | LC54A: |
- | LC54C: jsr InitTitleGFX ; | + | LC54C: |
- | LC54F: jmp NmiOn ; | + | LC54F: |
;Brinstar memory page. | ;Brinstar memory page. | ||
InitBank1: | InitBank1: | ||
- | LC552: lda #$00 ; | + | LC552: |
- | LC554: sta GameMode ;GameMode = play. | + | LC554: |
- | LC556: jsr ScreenNmiOff ; | + | LC556: |
- | LC559: lda MainRoutine ; | + | LC559: |
- | LC55B: cmp #$03 ;Is game engine running? if so, branch.--> | + | LC55B: |
- | LC55D: beq + ;Else do some housekeeping first. | + | LC55D: |
- | LC55F: lda #$00 ; | + | LC55F: |
- | LC561: sta MainRoutine ;Run InitArea routine next. | + | LC561: |
- | LC563: sta InArea ;Start in Brinstar. | + | LC563: |
- | LC565: sta GamePaused ;Make sure game is not paused. | + | LC565: |
- | LC567: jsr ClearRAM_33_DF ; | + | LC567: |
- | LC56A: jsr ClearSamusStats ; | + | LC56A: |
- | LC56D:* ldy #$00 ; | + | LC56D:* ldy #$00 ; |
- | LC56F: jsr ROMSwitch ; | + | LC56F: |
- | LC572: jsr InitBrinstarGFX ; | + | LC572: |
- | LC575: jmp NmiOn ; | + | LC575: |
ClearSamusStats: | ClearSamusStats: | ||
- | LC578: ldy #$0F ; | + | LC578: |
- | LC57A: lda #$00 ;Clears Samus stats(Health, | + | LC57A: |
- | LC57C:* sta $0100,y ;Load $100 thru $10F with #$00. | + | LC57C:* sta $0100, |
- | LC57F: dey ; | + | LC57F: |
- | LC580: bpl - ;Loop 16 times. | + | LC580: |
- | LC582: rts ; | + | LC582: |
;Norfair memory page. | ;Norfair memory page. | ||
InitBank2: | InitBank2: | ||
- | LC583: lda #$00 ;GameMode = play. | + | LC583: |
- | LC585: sta GameMode ; | + | LC585: |
- | LC587: jsr ScreenNmiOff ; | + | LC587: |
- | LC58A: jsr InitNorfairGFX ; | + | LC58A: |
- | LC58D: jmp NmiOn ; | + | LC58D: |
;Tourian memory page. | ;Tourian memory page. | ||
InitBank3: | InitBank3: | ||
- | LC590: lda #$00 ;GameMode = play. | + | LC590: |
- | LC592: sta GameMode ; | + | LC592: |
- | LC594: jsr ScreenNmiOff ; | + | LC594: |
- | LC597: ldy #$0D ; | + | LC597: |
- | LC599:* lda MetroidData, | + | LC599:* lda MetroidData, |
- | LC59C: sta $77F0,y ;$77F0 thru $77FD. | + | LC59C: |
- | LC59F: dey ; | + | LC59F: |
- | LC5A0: bpl - ; | + | LC5A0: |
- | LC5A2: jsr InitTourianGFX ; | + | LC5A2: |
- | LC5A5: jmp NmiOn ; | + | LC5A5: |
;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: | + | LC5A8: |
;Kraid memory page. | ;Kraid memory page. | ||
InitBank4: | InitBank4: | ||
- | LC5B6: lda #$00 ;GameMode = play. | + | LC5B6: |
- | LC5B8: sta GameMode ; | + | LC5B8: |
- | LC5BA: jsr ScreenNmiOff ; | + | LC5BA: |
- | LC5BD: jsr InitKraidGFX ; | + | LC5BD: |
- | LC5C0: jmp NmiOn ; | + | LC5C0: |
;Ridley memory page. | ;Ridley memory page. | ||
InitBank5: | InitBank5: | ||
- | LC5C3: lda #$00 ;GameMode = play. | + | LC5C3: |
- | LC5C5: sta GameMode ; | + | LC5C5: |
- | LC5C7: jsr ScreenNmiOff ; | + | LC5C7: |
- | LC5CA: jsr InitRidleyGFX ; | + | LC5CA: |
- | LC5CD: jmp NmiOn ; | + | LC5CD: |
InitEndGFX: | InitEndGFX: | ||
- | LC5D0: lda #$01 ; | + | LC5D0: |
- | LC5D2: sta GameMode ;Game is at title/end game. | + | LC5D2: |
- | LC5D4: jmp InitGFX6 ; | + | LC5D4: |
InitTitleGFX: | InitTitleGFX: | ||
- | LC5D7: ldy #$15 ;Entry 21 in GFXInfo table. | + | LC5D7: |
- | LC5D9: jsr LoadGFX ; | + | LC5D9: |
LoadSamusGFX: | LoadSamusGFX: | ||
- | LC5DC: ldy #$00 ;Entry 0 in GFXInfo table. | + | LC5DC: |
- | LC5DE: jsr LoadGFX ; | + | LC5DE: |
- | LC5E1: lda JustInBailey ; | + | LC5E1: |
- | LC5E4: beq + ;Branch if wearing suit | + | LC5E4: |
- | LC5E6: ldy #$1B ;Entry 27 in GFXInfo table. | + | LC5E6: |
- | LC5E8: jsr LoadGFX ; | + | LC5E8: |
- | LC5EB:* ldy #$14 ;Entry 20 in GFXInfo table. | + | LC5EB:* ldy #$14 ;Entry 20 in GFXInfo table. |
- | LC5ED: jsr LoadGFX ; | + | LC5ED: |
- | LC5F0: ldy #$17 ;Entry 23 in GFXInfo table. | + | LC5F0: |
- | LC5F2: jsr LoadGFX ; | + | LC5F2: |
- | LC5F5: ldy #$18 ;Entry 24 in GFXInfo table. | + | LC5F5: |
- | LC5F7: jsr LoadGFX ; | + | LC5F7: |
- | LC5FA: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC5FA: |
- | LC5FC: jsr LoadGFX ; | + | LC5FC: |
- | LC5FF: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC5FF: |
- | LC601: jmp LoadGFX ; | + | LC601: |
InitBrinstarGFX: | InitBrinstarGFX: | ||
- | LC604: ldy #$03 ;Entry 3 in GFXInfo table. | + | LC604: |
- | LC606: jsr LoadGFX ; | + | LC606: |
- | Lc609: ldy #$04 ;Entry 4 in GFXInfo table. | + | Lc609: |
- | LC60B: jsr LoadGFX ; | + | LC60B: |
- | LC60E: ldy #$05 ;Entry 5 in GFXInfo table. | + | LC60E: |
- | LC610: jsr LoadGFX ; | + | LC610: |
- | LC613: ldy #$06 ;Entry 6 in GFXInfo table. | + | LC613: |
- | LC615: jsr LoadGFX ; | + | LC615: |
- | LC618: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC618: |
- | LC61A: jsr LoadGFX ; | + | LC61A: |
- | LC61D: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC61D: |
- | LC61F: jmp LoadGFX ; | + | LC61F: |
InitNorfairGFX: | InitNorfairGFX: | ||
- | LC622: ldy #$04 ;Entry 4 in GFXInfo table. | + | LC622: |
- | LC624: jsr LoadGFX ; | + | LC624: |
- | LC627: ldy #$05 ;Entry 5 in GFXInfo table. | + | LC627: |
- | LC629: jsr LoadGFX ; | + | LC629: |
- | LC62C: ldy #$07 ;Entry 7 in GFXInfo table. | + | LC62C: |
- | LC62E: jsr LoadGFX ; | + | LC62E: |
- | LC631: ldy #$08 ;Entry 8 in GFXInfo table. | + | LC631: |
- | LC633: jsr LoadGFX ; | + | LC633: |
- | LC636: ldy #$09 ;Entry 9 in GFXInfo table. | + | LC636: |
- | LC638: jsr LoadGFX ; | + | LC638: |
- | LC63B: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC63B: |
- | LC63D: jsr LoadGFX ; | + | LC63D: |
- | LC640: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC640: |
- | LC642: jmp LoadGFX ; | + | LC642: |
InitTourianGFX: | InitTourianGFX: | ||
- | LC645: ldy #$05 ;Entry 5 in GFXInfo table. | + | LC645: |
- | LC647: jsr LoadGFX ; | + | LC647: |
- | LC64A: ldy #$0A ;Entry 10 in GFXInfo table. | + | LC64A: |
- | LC64C: jsr LoadGFX ; | + | LC64C: |
- | LC64F: ldy #$0B ;Entry 11 in GFXInfo table. | + | LC64F: |
- | LC651: jsr LoadGFX ; | + | LC651: |
- | LC654: ldy #$0C ;Entry 12 in GFXInfo table. | + | LC654: |
- | LC656: jsr LoadGFX ; | + | LC656: |
- | LC659: ldy #$0D ;Entry 13 in GFXInfo table. | + | LC659: |
- | LC65B: jsr LoadGFX ; | + | LC65B: |
- | LC65E: ldy #$0E ;Entry 14 in GFXInfo table. | + | LC65E: |
- | LC660: jsr LoadGFX ; | + | LC660: |
- | LC663: ldy #$1A ;Entry 26 in GFXInfo table. | + | LC663: |
- | LC665: jsr LoadGFX ; | + | LC665: |
- | LC668: ldy #$1C ;Entry 28 in GFXInfo table. | + | LC668: |
- | LC66A: jsr LoadGFX ; | + | LC66A: |
- | LC66D: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC66D: |
- | LC66F: jsr LoadGFX ; | + | LC66F: |
- | LC672: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC672: |
- | LC674: jmp LoadGFX ; | + | LC674: |
InitKraidGFX: | InitKraidGFX: | ||
- | LC677: ldy #$04 ;Entry 4 in GFXInfo table. | + | LC677: |
- | LC679: jsr LoadGFX ; | + | LC679: |
- | LC67C: ldy #$05 ;Entry 5 in GFXInfo table. | + | LC67C: |
- | LC67E: jsr LoadGFX ; | + | LC67E: |
- | LC681: ldy #$0A ;Entry 10 in GFXInfo table. | + | LC681: |
- | LC683: jsr LoadGFX ; | + | LC683: |
- | LC686: ldy #$0F ;Entry 15 in GFXInfo table. | + | LC686: |
- | LC688: jsr LoadGFX ; | + | LC688: |
- | LC68B: ldy #$10 ;Entry 16 in GFXInfo table. | + | LC68B: |
- | LC68D: jsr LoadGFX ; | + | LC68D: |
- | LC690: ldy #$11 ;Entry 17 in GFXInfo table. | + | LC690: |
- | LC692: jsr LoadGFX ; | + | LC692: |
- | LC695: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC695: |
- | LC697: jsr LoadGFX ; | + | LC697: |
- | LC69A: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC69A: |
- | LC69C: jmp LoadGFX ; | + | LC69C: |
InitRidleyGFX: | InitRidleyGFX: | ||
- | LC69F: ldy #$04 ;Entry 4 in GFXInfo table. | + | LC69F: |
- | LC6A1: jsr LoadGFX ; | + | LC6A1: |
- | LC6A4: ldy #$05 ;Entry 5 in GFXInfo table. | + | LC6A4: |
- | LC6A6: jsr LoadGFX ; | + | LC6A6: |
- | LC6A9: ldy #$0A ;Entry 10 in GFXInfo table. | + | LC6A9: |
- | LC6AB: jsr LoadGFX ; | + | LC6AB: |
- | LC6AE: ldy #$12 ;Entry 18 in GFXInfo table. | + | LC6AE: |
- | LC6B0: jsr LoadGFX ; | + | LC6B0: |
- | LC6B3: ldy #$13 ;Entry 19 in GFXInfo table. | + | LC6B3: |
- | LC6B5: jsr LoadGFX ; | + | LC6B5: |
- | LC6B8: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC6B8: |
- | LC6BA: jsr LoadGFX ; | + | LC6BA: |
- | LC6BD: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC6BD: |
- | LC6BF: jmp LoadGFX ; | + | LC6BF: |
InitGFX6: | InitGFX6: | ||
- | LC6C2: ldy #$01 ;Entry 1 in GFXInfo table. | + | LC6C2: |
- | LC6C4: jsr LoadGFX ; | + | LC6C4: |
- | LC6C7: ldy #$02 ;Entry 2 in GFXInfo table. | + | LC6C7: |
- | LC6C9: jsr LoadGFX ; | + | LC6C9: |
- | LC6CC: ldy #$19 ;Entry 25 in GFXInfo table. | + | LC6CC: |
- | LC6CE: jsr LoadGFX ; | + | LC6CE: |
- | LC6D1: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC6D1: |
- | LC6D3: jmp LoadGFX ; | + | LC6D3: |
InitGFX7: | InitGFX7: | ||
- | LC6D6: ldy #$17 ;Entry 23 in GFXInfo table. | + | LC6D6: |
- | LC6D8: jsr LoadGFX ; | + | LC6D8: |
- | LC6DB: ldy #$16 ;Entry 22 in GFXInfo table. | + | LC6DB: |
- | LC6DD: jmp LoadGFX ; | + | LC6DD: |
;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: | + | LC6E0: |
- | LC6E1: | + | LC6E1: |
- | LC6E7: | + | LC6E7: |
- | LC6E8: | + | LC6E8: |
- | LC6EE: | + | LC6EE: |
- | LC6EF: | + | LC6EF: |
- | LC6F5: | + | LC6F5: |
- | LC6F6: | + | LC6F6: |
- | LC6FC: | + | LC6FC: |
- | LC6FD: | + | LC6FD: |
- | LC703: | + | LC703: |
- | LC704: | + | LC704: |
- | LC70A: | + | LC70A: |
- | LC70B: | + | LC70B: |
- | LC711: | + | LC711: |
- | LC712: | + | LC712: |
- | LC718: | + | LC718: |
- | LC719: | + | LC719: |
- | LC71F: | + | LC71F: |
- | LC720: | + | LC720: |
- | LC726: | + | LC726: |
- | LC727: | + | LC727: |
- | LC72D: | + | LC72D: |
- | LC72E: | + | LC72E: |
- | LC734: | + | LC734: |
- | LC735: | + | LC735: |
- | LC73B: | + | LC73B: |
- | LC73C: | + | LC73C: |
- | LC742: | + | LC742: |
- | LC743: | + | LC743: |
- | LC749: | + | LC749: |
- | LC74A: | + | LC74A: |
- | LC750: | + | LC750: |
- | LC751: | + | LC751: |
- | LC757: | + | LC757: |
- | LC758: | + | LC758: |
- | LC75E: | + | LC75E: |
- | LC75F: | + | LC75F: |
- | LC765: | + | LC765: |
- | LC766: | + | LC766: |
- | LC76C: | + | LC76C: |
- | LC76D: | + | LC76D: |
- | LC773: | + | LC773: |
- | LC774: | + | LC774: |
- | LC77A: | + | LC77A: |
- | LC77B: | + | LC77B: |
- | LC781: | + | LC781: |
- | LC782: | + | LC782: |
- | LC788: | + | LC788: |
- | LC789: | + | LC789: |
- | LC78F: | + | LC78F: |
- | LC790: | + | LC790: |
- | LC796: | + | LC796: |
- | LC797: | + | LC797: |
- | LC79D: | + | LC79D: |
- | LC79E: | + | LC79E: |
- | LC7A4: | + | LC7A4: |
- | LC7A5: | + | LC7A5: |
; | ; | ||
Line 1336: | Line 1336: | ||
LoadGFX: | LoadGFX: | ||
- | LC7AB: lda #$FF ; | + | LC7AB: |
- | LC7AD: | + | LC7AD:* clc |
- | LC7AE: adc #$07 ;is increased by 7. When y is less than 0, A points--> | + | LC7AE: |
- | LC7B0: dey ;to the last byte of the entry in the table. | + | LC7B0: |
- | LC7B1: bpl - ; | + | LC7B1: |
- | LC7B3: tay ;Transfer offset into table to Y. | + | LC7B3: |
- | LC7B4: ldx #$06 ; | + | LC7B4: |
- | LC7B6:* lda GFXInfo,y ; | + | LC7B6:* lda GFXInfo, |
- | LC7B9: sta $00,x ;Copy entries from GFXInfo to $00-$06. | + | LC7B9: |
- | LC7BB: dey ; | + | LC7BB: |
- | LC7BC: dex ; | + | LC7BC: |
- | LC7BD: bpl - ; | + | LC7BD: |
- | LC7BF: ldy $00 ;ROM bank containing the GFX data. | + | LC7BF: |
- | LC7C1: jsr ROMSwitch ; | + | LC7C1: |
- | LC7C4: lda PPUCNT0ZP ; | + | LC7C4: |
- | LC7C6: and #$FB ; | + | LC7C6: |
- | LC7C8: sta PPUCNT0ZP ;Set the PPU to increment by 1. | + | LC7C8: |
- | LC7CA: sta PPUControl0 ; | + | LC7CA: |
- | LC7CD: jsr CopyGFXBlock ; | + | LC7CD: |
- | LC7D0: ldy CurrentBank ; | + | LC7D0: |
- | LC7D2: jmp ROMSwitch ; | + | LC7D2: |
;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: |
- | LC7D7: bne GFXCopyLoop ;If $05 is #$00, decrement $06 before beginning. | + | LC7D7: |
- | LC7D9: dec $06 ; | + | LC7D9: |
GFXCopyLoop: | GFXCopyLoop: | ||
- | LC7DB: lda $04 ; | + | LC7DB: |
- | LC7DD: sta PPUAddress ;Set PPU to proper address for GFX block write. | + | LC7DD: |
- | LC7E0: lda $03 ; | + | LC7E0: |
- | LC7E2: sta PPUAddress ; | + | LC7E2: |
- | LC7E5: ldy #$00 ;Set offset for GFX data to 0. | + | LC7E5: |
- | LC7E7:* lda ($01),y ; | + | LC7E7:* lda ($01), |
- | LC7E9: sta PPUIOReg ;Copy GFX data byte from ROM to Pattern table. | + | LC7E9: |
- | LC7EC: dec $05 ;Decrement low byte of data length. | + | LC7EC: |
- | LC7EE: bne + ;Branch if high byte does not need decrementing. | + | LC7EE: |
- | LC7F0: lda $06 ; | + | LC7F0: |
- | LC7F2: beq ++ ;If copying complete, branch to exit. | + | LC7F2: |
- | LC7F4: dec $06 ;Decrement when low byte has reached 0. | + | LC7F4: |
- | LC7F6: | + | LC7F6:* iny |
- | LC7F7: bne -- ; | + | LC7F7: |
- | LC7F9: inc $02 ;After 256 bytes loaded, increment upper bits of--> | + | LC7F9: |
- | LC7FB: inc $04 ;Source and destination addresses. | + | LC7FB: |
- | LC7FD: jmp GFXCopyLoop ; | + | LC7FD: |
- | LC800: | + | LC800:* rts |
; | ; | ||
AreaInit: | AreaInit: | ||
- | LC801: lda #$00 ; | + | LC801: |
- | LC803: sta ScrollX | + | LC803: |
- | LC805: sta ScrollY | + | LC805: |
- | LC807: lda PPUCNT0ZP ; | + | LC807: |
- | LC809: and #$FC ;Sets nametable address = $2000. | + | LC809: |
- | LC80B: sta PPUCNT0ZP ; | + | LC80B: |
- | LC80D: inc MainRoutine ;Increment MainRoutine to MoreInit. | + | LC80D: |
- | LC80F: lda Joy1Status ; | + | LC80F: |
- | LC811: and #$C0 ;Stores status of both the A and B buttons. | + | LC811: |
- | LC813: sta ABStatus ;Appears to never be accessed. | + | LC813: |
- | LC815: jsr EraseAllSprites ; | + | LC815: |
- | LC818: lda #$10 ;Prepare to load Brinstar memory page. | + | LC818: |
- | LC81A: jsr IsEngineRunning ; | + | LC81A: |
; | ; | ||
MoreInit: | MoreInit: | ||
- | LC81D: ldy #$01 ; | + | LC81D: |
- | LC81F: sty PalDataPending ;Palette data pending = yes. | + | LC81F: |
- | LC821: ldx #$FF ; | + | LC821: |
- | LC823: stx SpareMem75 ;$75 Not referenced ever again in the game. | + | LC823: |
- | LC825: inx ;X=0. | + | LC825: |
- | LC826: stx AtEnding ;Not playing ending scenes. | + | LC826: |
- | LC829: stx DoorStatus ;Samus not in door. | + | LC829: |
- | LC82B: stx SamusDoorData ;Samus is not inside a door. | + | LC82B: |
- | LC82D: stx UpdatingProjectile ;No projectiles need to be updated. | + | LC82D: |
- | LC82F: txa ;A=0. | + | LC82F: |
- | 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: |
- | LC834: sta $7A,x ;Clear RAM $7A thru $DE. | + | LC834: |
- | 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: |
- | LC83A: sta ObjAction, | + | LC83A: |
- | LC83D: | + | LC83D:* inx |
- | LC83E: bne --- ;Loop until all required RAM is cleared. | + | LC83E: |
- | LC840: jsr ScreenOff ; | + | LC840: |
- | LC843: jsr ClearNameTables ; | + | LC843: |
- | LC846: jsr EraseAllSprites ; | + | LC846: |
- | LC849: jsr DestroyEnemies ;($C8BB) | + | LC849: |
- | stx DoorOnNameTable3 ;Clear data about doors on the name tables. | + | |
- | stx DoorOnNameTable0 ; | + | stx DoorOnNameTable0 |
- | inx ;X=1. | + | inx |
- | stx SpareMem30 ;Not accessed by game. | + | stx SpareMem30 |
- | inx ;X=2. | + | inx |
- | LC854: stx ScrollDir ;Set initial scroll direction as left. | + | LC854: |
- | lda $95D7 ;Get Samus start x pos on map. | + | |
- | sta MapPosX ; | + | sta MapPosX |
- | lda $95D8 ;Get Samus start y pos on map. | + | lda $95D8 |
- | sta MapPosY ; | + | sta MapPosY |
- | LC860: lda $95DA ; Get ??? Something to do with palette switch | + | LC860: |
- | sta PalToggle | + | sta PalToggle |
- | lda #$FF | + | lda #$FF |
- | sta RoomNumber ;Room number = $FF(undefined room). | + | sta RoomNumber |
- | LC869: jsr CopyPtrs | + | LC869: |
- | LC86C: jsr GetRoomNum ;($E720)Put room number at current map pos in $5A. | + | LC86C: |
- | * jsr SetupRoom ;($EA2B) | + | * jsr SetupRoom |
- | ldy RoomNumber | + | ldy RoomNumber |
- | iny | + | iny |
- | bne - | + | bne - |
- | 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 | + | ldy PPUStatus |
; Copy room RAM #0 ($6000) to PPU Name Table #0 ($2000) | ; Copy room RAM #0 ($6000) to PPU Name Table #0 ($2000) | ||
- | 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 | + | |
- | iny | + | iny |
- | bne - | + | bne - |
- | inc $01 | + | inc $01 |
- | dex | + | dex |
- | bne - | + | bne - |
- | stx $91 | + | |
- | inx ; X = 1 | + | inx ; X = 1 |
- | stx PalDataPending | + | stx PalDataPending |
- | stx SpareMem30 ;Not accessed by game. | + | stx SpareMem30 |
- | inc MainRoutine ;SamusInit is next routine to run. | + | inc MainRoutine |
- | jmp ScreenOn | + | jmp ScreenOn |
; CopyPtrs | ; CopyPtrs | ||
Line 1493: | Line 1493: | ||
CopyPtrs: | CopyPtrs: | ||
- | ldx #$0D | + | |
* lda AreaPointers+2, | * lda AreaPointers+2, | ||
- | sta RoomPtrTable, | + | |
- | dex | + | dex |
- | bpl - | + | bpl - |
- | rts | + | rts |
; DestroyEnemies | ; DestroyEnemies | ||
Line 1504: | Line 1504: | ||
DestroyEnemies: | DestroyEnemies: | ||
- | LC8BB: lda #$00 | + | LC8BB: |
- | tax | + | tax |
* cpx #$48 | * cpx #$48 | ||
- | bcs + | + | |
- | sta $97,x | + | sta $97,x |
* sta EnStatus,x | * sta EnStatus,x | ||
- | pha | + | |
- | pla | + | pla |
- | inx | + | inx |
- | bne -- | + | bne -- |
- | stx MetroidOnSamus ;Samus had no Metroid stuck to her. | + | stx MetroidOnSamus |
- | jmp $95AB | + | jmp $95AB |
; SamusInit | ; SamusInit | ||
Line 1522: | Line 1522: | ||
SamusInit: | SamusInit: | ||
- | LC8D1: lda #$08 ; | + | LC8D1: |
- | LC8D3: | + | LC8D3: |
- | LC8D5: lda #$2C ;440 frames to fade in Samus(7.3 seconds). | + | LC8D5: |
- | LC8D7: sta Timer3 ; | + | LC8D7: |
- | LC8D9: jsr IntroMusic ; | + | LC8D9: |
- | LC8DC: ldy # | + | LC8DC: |
- | sty ObjAction ;Set Samus status as fading onto screen. | + | sty ObjAction |
- | ldx #$00 | + | ldx #$00 |
- | stx SamusBlink | + | stx SamusBlink |
- | dex ;X = $FF | + | dex |
- | 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 |
- | stx EndTimerHi ;escape timer not currently active. | + | stx EndTimerHi |
- | 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 + |
- | lsr ScrollDir ;If not in Brinstar, change scroll direction from left--> | + | lsr ScrollDir |
- | 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 ; | + | lda $95D9 |
- | sta ObjectY ; | + | sta ObjectY |
- | lda #$80 ; | + | lda #$80 ; |
- | 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 |
- | lda #$00 ; | + | lda #$00 ; |
- | sta HealthLo ;Starting health is--> | + | sta HealthLo |
- | lda #$03 ;set to 30 units. | + | lda #$03 ;set to 30 units. |
- | sta HealthHi ; | + | sta HealthHi |
- | * rts ; | + | * |
; | ; | ||
GameEngine: | GameEngine: | ||
- | LC92B: jsr ScrollDoor ; | + | LC92B: |
- | LC92E: jsr ScrollDoor ; | + | LC92E: |
- | LC931: lda NARPASSWORD ; | + | LC931: |
- | LC934: beq + ; | + | LC934: |
- | LC936: lda #$03 ;The following code is only accessed if --> | + | LC936: |
- | LC938: sta HealthHi ; | + | LC938: |
- | LC93B: lda #$FF ;password screen. Gives you new health, | + | LC93B: |
- | LC93D: sta SamusGear ;missiles and every power-up every frame. | + | LC93D: |
- | LC940: lda #$05 ; | + | LC940: |
- | LC942: sta MissileCount ; | + | LC942: |
- | LC945:* jsr UpdateWorld ; | + | LC945:* jsr UpdateWorld |
- | LC948: lda MiniBossKillDelay ; | + | LC948: |
- | LC94B: ora PowerUpDelay ;Check if mini boss was just killed or powerup aquired.--> | + | LC94B: |
- | LC94E: beq + ;If not, branch. | + | LC94E: |
- | LC950: lda #$00 ; | + | LC950: |
- | LC952: sta MiniBossKillDelay ;Reset delay indicators. | + | LC952: |
- | LC955: sta PowerUpDelay ; | + | LC955: |
- | LC958: lda #$18 ;Set timer for 240 frames(4 seconds). | + | LC958: |
- | LC95A: ldx #$03 ;GameEngine routine to run after delay expires | + | LC95A: |
- | LC95C: jsr SetTimer ;($C4AA)Set delay timer and game engine routine. | + | LC95C: |
- | LC95F:* lda ObjAction ;Check is Samus is dead. | + | LC95F:* lda ObjAction |
- | LC962: cmp # | + | LC962: |
- | LC964: bne --- ;exit if not. | + | LC964: |
- | LC966: lda AnimDelay ;Is Samus still exploding? | + | LC966: |
- | LC969: bne --- ;Exit if still exploding. | + | LC969: |
- | LC96B: jsr SilenceMusic ;Turn off music. | + | LC96B: |
- | LC96E: lda MotherBrainStatus ; | + | LC96E: |
- | LC970: cmp #$0A ;Is mother brain already dead? If so, branch. | + | LC970: |
- | LC972: beq + ; | + | LC972: |
- | LC974: lda #$04 ;Set timer for 40 frames (.667 seconds). | + | LC974: |
- | LC976: ldx #$04 ;GameOver routine to run after delay expires. | + | LC976: |
- | LC978: jmp SetTimer ;($C4AA)Set delay timer and run game over routine. | + | LC978: |
- | LC97B:* inc MainRoutine ;Next routine to run is GameOver. | + | LC97B:* inc MainRoutine |
- | LC97D: rts ; | + | LC97D: |
; | ; | ||
Line 1613: | Line 1613: | ||
UpdateAge: | UpdateAge: | ||
- | LC97E: lda GameMode ; | + | LC97E: |
- | LC980: bne ++ ;Exit if at title/ | + | LC980: |
- | LC982: lda MainRoutine ; | + | LC982: |
- | LC984: cmp #$03 ;Is game engine running? | + | LC984: |
- | LC986: bne ++ ;If not, don't update age. | + | LC986: |
- | LC988: ldx FrameCount ;Only update age when FrameCount is zero--> | + | LC988: |
- | LC98A: bne ++ ;(which is approx. every 4.266666666667 seconds). | + | LC98A: |
- | LC98C: inc SamusAge,x ;Minor Age = Minor Age + 1. | + | LC98C: |
- | LC98F: lda SamusAge ; | + | LC98F: |
- | LC992: cmp #$D0 ;Has Minor Age reached $D0? | + | LC992: |
- | LC994: bcc ++ ;If not, we're done.--> | + | LC994: |
- | LC996: lda #$00 ;Else reset minor age. | + | LC996: |
- | LC998: sta SamusAge ; | + | LC998: |
- | LC99B:* cpx #$03 ; | + | LC99B:* cpx #$03 ; |
- | LC99D: bcs + ;Loop to update middle age and possibly major age. | + | LC99D: |
- | LC99F: inx ; | + | LC99F: |
- | LC9A0: inc SamusAge,x ; | + | LC9A0: |
- | LC9A3: beq - ;Branch if middle age overflowed, need to increment--> | + | LC9A3: |
- | LC9A5: | + | LC9A5:* rts |
; | ; | ||
GameOver: | GameOver: | ||
- | LC9A6: lda #$1C ;GameOver is the next routine to run. | + | LC9A6: |
- | LC9A8: sta TitleRoutine ; | + | LC9A8: |
- | LC9AA: lda #$01 ; | + | LC9AA: |
- | LC9AC: sta SwitchPending ;Prepare to switch to title memory page. | + | LC9AC: |
- | LC9AE: jmp ScreenOff ; | + | LC9AE: |
; | ; | ||
PauseMode: | PauseMode: | ||
- | LC9B1: lda Joy2Status ;Load buttons currently being pressed on joypad 2. | + | LC9B1: |
- | LC9B3: and #$88 ; | + | LC9B3: |
- | LC9B5: eor #$88 ;both A & UP pressed? | + | LC9B5: |
- | LC9B7: bne Exit14 ;Exit if not. | + | LC9B7: |
- | LC9B9: ldy EndTimerHi ; | + | LC9B9: |
- | LC9BC: iny ;Is escape timer active? | + | LC9BC: |
- | LC9BD: bne Exit14 ;Sorry, can't quit if this is during escape scence. | + | LC9BD: |
- | LC9BF: sta GamePaused ;Clear pause game indicator. | + | LC9BF: |
- | LC9C1: inc MainRoutine ;Display password is the next routine to run. | + | LC9C1: |
Exit14: | Exit14: | ||
- | LC9C3: rts ;Exit for routines above and below. | + | LC9C3: |
; | ; | ||
GoPassword: | GoPassword: | ||
- | LC9C4: lda #$19 ; | + | LC9C4: |
- | LC9C6: sta TitleRoutine ; | + | LC9C6: |
- | LC9C8: lda #$01 ; | + | LC9C8: |
- | LC9CA: sta SwitchPending ;Prepare to switch to intro memory page. | + | LC9CA: |
- | LC9CC: lda NoiseSFXFlag ; | + | LC9CC: |
- | LC9CF: ora #$01 ;Silence music. | + | LC9CF: |
- | LC9D1: sta NoiseSFXFlag ; | + | LC9D1: |
- | LC9D4: jmp ScreenOff ; | + | LC9D4: |
; | ; | ||
SamusIntro: | SamusIntro: | ||
- | LC9D7: jsr EraseAllSprites ; | + | LC9D7: |
- | LC9DA: ldy ObjAction ;Load Samus' fade in status. | + | LC9DA: |
- | LC9DD: lda Timer3 ; | + | LC9DD: |
- | LC9E0: bne + ;Branch if Intro still playing. | + | LC9E0: |
- | + | ||
;Fade in complete. | ;Fade in complete. | ||
- | LC9E2: sta ItemRoomMusicStatus ;Make sure item room music is not playing. | + | LC9E2: |
- | LC9E4: lda #sa_Begin ;Samus facing forward and can't be hurt. | + | LC9E4: |
- | LC9E6: sta ObjAction ; | + | LC9E6: |
- | LC9E8: jsr StartMusic ; | + | LC9E8: |
- | LC9EB: jsr SelectSamusPal ; | + | LC9EB: |
- | LC9EE: lda #$03 ; | + | LC9EE: |
- | LC9F0: sta MainRoutine ;Game engine will be called next frame. | + | LC9F0: |
;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: |
- | LC9F6: cmp SamusFadeInTimeTbl-20, | + | LC9F6: |
- | LC9F9: bne + ;Every time Timer3 equals one of the entries in the table--> | + | LC9F9: |
- | LC9FB: inc ObjAction ;below, change the palette used to color Samus. | + | LC9FB: |
- | LC9FE: sty PalDataPending ; | + | LC9FE: |
- | LCA00:* lda FrameCount ;Is game currently on an odd frame? | + | LCA00:* lda FrameCount |
- | LCA02: lsr ;If not, branch to exit. | + | LCA02: |
- | LCA03: bcc Exit14 ;Only display Samus on odd frames [the blink effect]. | + | LCA03: |
- | LCA05: lda # | + | LCA05: |
- | LCA07: jsr SetSamusAnim ; | + | LCA07: |
- | LCA0A: lda #$00 ; | + | LCA0A: |
- | LCA0C: sta SpritePagePos ;Samus sprites start at Sprite00RAM. | + | LCA0C: |
- | LCA0E: sta PageIndex ;Samus RAM is first set of RAM. | + | LCA0E: |
- | LCA10: jmp AnimDrawObject ; | + | LCA10: |
;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: | + | LCA13: |
; | ; | ||
IsEngineRunning: | IsEngineRunning: | ||
- | LCA18: ldy MainRoutine ;If Samus is fading in or the wait timer is--> | + | LCA18: |
- | LCA1A: cpy #$07 ;active, return from routine. | + | LCA1A: |
- | LCA1C: beq + ; | + | LCA1C: |
- | LCA1E: cpy #$03 ;Is game engine running? | + | LCA1E: |
- | LCA20: beq ++ ;If yes, branch to SwitchBank. | + | LCA20: |
- | LCA22: | + | LCA22:* rts |
; | ; | ||
Line 1725: | Line 1725: | ||
SwitchBank: | SwitchBank: | ||
- | LCA23:* sta InArea ;Save current area Samus is in. | + | LCA23:* sta InArea |
- | LCA25: and #$0F ; | + | LCA25: |
- | LCA27: tay ;Use 4 LSB to load switch pending offset from BankTable table. | + | LCA27: |
- | LCA28: lda BankTable, | + | LCA28: |
- | LCA2B: sta SwitchPending ;Store switch data. | + | LCA2B: |
- | LCA2D: jmp CheckSwitch ; | + | LCA2D: |
;Table used by above subroutine. | ;Table used by above subroutine. | ||
Line 1736: | Line 1736: | ||
BankTable: | BankTable: | ||
- | LCA30: | + | LCA30: |
- | LCA31: | + | LCA31: |
- | LCA32: | + | LCA32: |
- | LCA33: | + | LCA33: |
- | LCA34: | + | LCA34: |
; | ; | ||
AccessSavedGame: | AccessSavedGame: | ||
- | LCA35: pha ;Save two copies of A. Why? Who knows. This code is--> | + | LCA35: |
- | LCA36: pha ;Never implemented. A contains data slot to work on. | + | LCA36: |
- | LCA37: jsr GetGameDataIndex ;($CA96)Get index to this save game Samus data info. | + | LCA37: |
- | LCA3A: lda EraseGame ; | + | LCA3A: |
- | LCA3D: bpl + ;Is MSB set? If so, erase saved game data. Else branch. | + | LCA3D: |
- | LCA3F: and #$01 ; | + | LCA3F: |
- | LCA41: sta EraseGame ;Clear MSB so saved game data is not erased again. | + | LCA41: |
- | LCA44: jsr EraseAllGameData ; | + | LCA44: |
- | LCA47: lda #$01 ;Indicate this saved game has been erased.--> | + | LCA47: |
- | LCA49: sta $7800,y ;Saved game 0=$780C, saved game 1=$781C, saved game 2=$782C. | + | LCA49: |
- | LCA4C:* lda MainRoutine ; | + | LCA4C:* lda MainRoutine |
- | LCA4E: cmp #$01 ;If initializing the area at the start of the game, branch--> | + | LCA4E: |
- | LCA50: beq +++ ;to load Samus' saved game info. | + | LCA50: |
SaveGameData: | SaveGameData: | ||
- | LCA52: lda InArea ;Save game based on current area Samus is in. Don't know why. | + | LCA52: |
- | LCA54: jsr SavedDataBaseAddr ; | + | LCA54: |
- | LCA57: ldy #$3F ;Prepare to save unique item history which is 64 bytes--> | + | LCA57: |
- | LCA59:* lda NumberOfUniqueItems, | + | LCA59:* lda NumberOfUniqueItems, |
- | LCA5C: sta ($00),y ;Save unique item history in appropriate saved game slot. | + | LCA5C: |
- | LCA5E: dey ; | + | LCA5E: |
- | LCA5F: bpl - ;Loop until unique item history transfer complete. | + | LCA5F: |
- | LCA61: ldy SamusDataIndex ;Prepare to save Samus' data. | + | LCA61: |
- | LCA64: ldx #$00 ; | + | LCA64: |
- | LCA66:* lda SamusStat00, | + | LCA66:* lda SamusStat00, |
- | LCA69: sta SamusData, | + | LCA69: |
- | LCA6C: iny ; | + | LCA6C: |
- | LCA6D: inx ; | + | LCA6D: |
- | LCA6E: cpx #$10 ; | + | LCA6E: |
- | LCA70: bne - ;Loop until Samus' data transfer complete. | + | LCA70: |
LoadGameData: | LoadGameData: | ||
- | LCA72: | + | LCA72:* pla |
- | LCA73: jsr SavedDataBaseAddr ; | + | LCA73: |
- | LCA76: ldy #$3F ;Prepare to load unique item history which is 64 bytes--> | + | LCA76: |
- | LCA78:* lda ($00),y ;in length. | + | LCA78:* lda ($00), |
- | LCA7A: sta NumberOfUniqueItems, | + | LCA7A: |
- | LCA7D: dey ; | + | LCA7D: |
- | LCA7E: bpl - ; | + | LCA7E: |
- | LCA80: bmi + ;Branch always. | + | LCA80: |
- | LCA82: pha ; | + | LCA82: |
- | LCA83:* ldy SamusDataIndex ;Prepare to load Samus' data. | + | LCA83:* ldy SamusDataIndex |
- | LCA86: ldx #$00 ; | + | LCA86: |
- | LCA88:* lda SamusData, | + | LCA88:* lda SamusData, |
- | LCA8B: sta SamusStat00, | + | LCA8B: |
- | LCA8E: iny ; | + | LCA8E: |
- | LCA8F: inx ; | + | LCA8F: |
- | LCA90: cpx #$10 ; | + | LCA90: |
- | LCA92: bne - ;Loop until Samus' data transfer complete. | + | LCA92: |
- | LCA94: pla ; | + | LCA94: |
- | LCA95: rts ; | + | LCA95: |
GetGameDataIndex: | GetGameDataIndex: | ||
- | LCA96: lda DataSlot ; | + | LCA96: |
- | LCA99: asl ;A contains the save game slot to work on (0 1 or 2).--> | + | LCA99: |
- | LCA9A: asl ;This number is transferred to the upper four bits to--> | + | LCA9A: |
- | LCA9B: asl ;find the offset for Samus' data for this particular--> | + | LCA9B: |
- | LCA9C: asl ;saved game (#$00, #$10 or #$20). | + | LCA9C: |
- | LCA9D: sta SamusDataIndex ; | + | LCA9D: |
- | LCAA0: rts ; | + | LCAA0: |
EraseAllGameData: | EraseAllGameData: | ||
- | LCAA1: lda #$00 ;Always start at saved game 0. Erase all 3 saved games. | + | LCAA1: |
- | LCAA3: jsr SavedDataBaseAddr ; | + | LCAA3: |
- | LCAA6: inc $03 ;Prepare to erase saved game info at $6A00 and above. | + | LCAA6: |
- | LCAA8: ldy #$00 ;Fill saved game data with #$00. | + | LCAA8: |
- | LCAAA: tya ; | + | LCAAA: |
- | LCAAB:* sta ($00),y ;Erase unique item histories from $69B4 to $69FF. | + | LCAAB:* sta ($00), |
- | LCAAD: cpy #$40 ; | + | LCAAD: |
- | LCAAF: bcs + ;IF 64 bytes alrady erased, no need to erase any more--> | + | LCAAF: |
- | LCAB1: sta ($02),y ;in the $6A00 and above range. | + | LCAB1: |
- | LCAB3: | + | LCAB3:* iny |
- | LCAB4: bne -- ;Lop until all saved game data is erased. | + | LCAB4: |
- | LCAB6: ldy SamusDataIndex ;Load proper index to desired Samus data to erase. | + | LCAB6: |
- | LCAB9: ldx #$00 ; | + | LCAB9: |
- | LCABB: txa ; | + | LCABB: |
- | LCABC:* sta SamusData, | + | LCABC:* sta SamusData, |
- | LCABF: iny ; | + | LCABF: |
- | LCAC0: inx ; | + | LCAC0: |
- | LCAC1: cpx #$0C ; | + | LCAC1: |
- | LCAC3: bne - ;Loop until all data is erased. | + | LCAC3: |
- | LCAC5: rts ; | + | LCAC5: |
;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: |
- | LCAC7: lda DataSlot ;Load saved game data slot to load. | + | LCAC7: |
- | LCACA: asl ;*2. Table values below are two bytes. | + | LCACA: |
- | LCACB: tax ; | + | LCACB: |
- | LCACC: lda SavedDataTable, | + | LCACC: |
- | LCACF: sta $00 ;Load $0000 and $0002 with base addresses from--> | + | LCACF: |
- | LCAD1: sta $02 ;table below($69B4). | + | LCAD1: |
- | LCAD3: lda SavedDataTable+1, | + | LCAD3: |
- | LCAD6: sta $01 ; | + | LCAD6: |
- | LCAD8: sta $03 ; | + | LCAD8: |
- | LCADA: pla ;Restore A. | + | LCADA: |
- | LCADB: and #$0F ;Discard upper four bits in A. | + | LCADB: |
- | LCADD: tax ;X used for counting loop. | + | LCADD: |
- | LCADE: beq +++ ;Exit if at saved game 0. No further calculations required. | + | LCADE: |
- | LCAE0:* lda $00 ; | + | LCAE0:* lda $00 |
- | LCAE2: clc ; | + | LCAE2: |
- | LCAE3: adc #$40 ; | + | LCAE3: |
- | LCAE5: sta $00 ;Loop to add #$40 to base address of $69B4 in order to find--> | + | LCAE5: |
- | LCAE7: bcc + ;the proper base address for this saved game data. (save--> | + | LCAE7: |
- | LCAE9: inc $01 ;slot 0 = $69B4, save slot 1 = $69F4, save slot 2 = $6A34). | + | LCAE9: |
- | LCAEB: | + | LCAEB:* dex |
- | LCAEC: bne -- ; | + | LCAEC: |
- | LCAEE: | + | 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: | + | LCAEF: |
- | LCAF1: | + | LCAF1: |
- | LCAF3: | + | LCAF3: |
; | ; | ||
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: |
- | LCAF7:* lda SamusAge+2 ;If SamusAge+2 anything but #$00, load worst--> | + | LCAF7:* lda SamusAge+2 |
- | LCAFA: bne + ; | + | LCAFA: |
- | LCAFC: lda SamusAge+1 ; | + | LCAFC: |
- | LCAFF: cmp AgeTable-1, | + | LCAFF: |
- | LCB02: bcs + ;ending type from table below. | + | LCB02: |
- | LCB04: iny ; | + | LCB04: |
- | LCB05: cpy #$05 ; | + | LCB05: |
- | LCB07: bne - ; | + | LCB07: |
- | LCB09:* sty EndingType ;Store the ending # (1..5), 5=best ending | + | LCB09:* sty EndingType |
- | LCB0C: lda #$00 ; | + | LCB0C: |
- | LCB0E: cpy #$04 ;Was the best or 2nd best ending achieved? | + | LCB0E: |
- | LCB10: bcc + ;Branch if not (suit stays on) | + | LCB10: |
- | LCB12: lda #$01 ; | + | LCB12: |
- | LCB14:* sta JustInBailey ;Suit OFF, baby! | + | LCB14:* sta JustInBailey |
- | LCB17: rts ; | + | LCB17: |
;Table used by above subroutine to determine ending type. | ;Table used by above subroutine to determine ending type. | ||
AgeTable: | AgeTable: | ||
- | LCB18: | + | LCB18: |
- | LCB19: | + | LCB19: |
- | LCB1A: | + | LCB1A: |
- | LCB1B: | + | LCB1B: |
; | ; | ||
ClearScreenData: | ClearScreenData: | ||
- | LCB1C: jsr ScreenOff ; | + | LCB1C: |
- | LCB1F: lda #$FF ; | + | LCB1F: |
- | LCB21: sta $00 ;Prepare to fill nametable with #$FF. | + | LCB21: |
- | LCB23: jsr ClearNameTable ; | + | LCB23: |
- | LCD26: jmp EraseAllSprites ; | + | LCD26: |
; | ; | ||
Line 1907: | Line 1907: | ||
UpdateWorld: | UpdateWorld: | ||
- | LCB29: ldx #$00 ;Set start of sprite RAM to $0200. | + | LCB29: |
- | LCB2B: stx SpritePagePos ; | + | LCB2B: |
- | LCB2D: jsr UpdateEnemies ; | + | LCB2D: |
- | LCB30: jsr UpdateProjectiles ; | + | LCB30: |
- | LCB33: jsr UpdateSamus ; | + | LCB33: |
- | LCB36: jsr AreaRoutine ; | + | LCB36: |
- | LCB39: jsr UpdateElevator ; | + | LCB39: |
- | LCB3C: jsr UpdateStatues ; | + | LCB3C: |
- | LCB3F: jsr $FA9D ; destruction of enemies | + | LCB3F: |
- | LCB42: jsr LFC65 ; update of Mellow/Memu enemies | + | LCB42: |
- | LCB45: jsr LF93B | + | LCB45: |
- | LCB48: jsr LFBDD ; destruction of green spinners | + | LCB48: |
- | LCB4B: jsr SamusEnterDoor ; | + | LCB4B: |
- | LCB4E: jsr $8B79 ; display of doors | + | LCB4E: |
- | LCB51: jsr UpdateTiles ; tile de/ | + | LCB51: |
- | LCB54: jsr LF034 ; Samus <--> enemies crash detection | + | LCB54: |
- | LCB57: jsr DisplayBar ; | + | LCB57: |
- | jsr LFAF2 | + | jsr LFAF2 |
- | jsr CheckMissileToggle | + | jsr CheckMissileToggle |
- | jsr UpdateItems ; | + | jsr UpdateItems |
- | jsr LFDE3 | + | jsr UpdateTourianItems |
;Clear remaining sprite RAM | ;Clear remaining sprite RAM | ||
- | ldx SpritePagePos | + | |
- | lda #$F4 | + | lda #$F4 |
* sta Sprite00RAM, | * sta Sprite00RAM, | ||
- | jsr Xplus4 | + | |
- | bne - | + | bne - |
- | rts | + | rts |
; | ; | ||
Line 1946: | Line 1946: | ||
SelectSamusPal: | SelectSamusPal: | ||
- | LCB73: tya ; | + | LCB73: |
- | pha ;Temp storage of Y on the stack. | + | pha |
- | lda SamusGear | + | lda SamusGear |
- | asl | + | asl |
- | asl | + | asl |
- | asl ;CF contains Varia status (1 = Samus has it) | + | asl |
- | lda MissileToggle ;A = 1 if Samus is firing missiles, else 0 | + | lda MissileToggle |
- | rol ;Bit 0 of A = 1 if Samus is wearing Varia | + | rol |
- | adc #$02 | + | adc #$02 |
- | ldy JustInBailey ;In suit? | + | ldy JustInBailey |
- | beq + ;If so, Branch. | + | beq + |
- | clc | + | clc |
- | adc #$17 ;Add #$17 to the pal # to reach "no suit" | + | adc #$17 ;Add #$17 to the pal # to reach "no suit" |
- | * sta PalDataPending ;Palette will be written next NMI. | + | * sta PalDataPending |
- | pla ; | + | pla |
- | tay ;Restore the contents of y. | + | tay |
- | rts ; | + | rts |
; | ; | ||
Line 1968: | Line 1968: | ||
;Initiate sound effects. | ;Initiate sound effects. | ||
- | SilenceMusic: | + | SilenceMusic: |
- | LCB8E: lda #$01 ;starting at $0680. The following is a--> | + | LCB8E: |
- | LCB90: bne SFX_SetX0 ;list of sound effects played when the--> | + | LCB90: |
- | ;flags are set: | + | ;flags are set: |
- | PauseMusic: | + | PauseMusic: |
- | LCB92: lda #$02 ;$0680: These SFX use noise channel. | + | LCB92: |
- | LCB94: bne SFX_SetX0 ;Bit 7 - No sound. | + | LCB94: |
- | ;Bit 6 - ScrewAttack. | + | ;Bit 6 - ScrewAttack. |
- | SFX_SamusWalk: | + | SFX_SamusWalk: |
- | LCB96: lda #$08 ;Bit 4 - BombExplode. | + | LCB96: |
- | LCB98: bne SFX_SetX0 ;Bit 3 - SamusWalk. | + | LCB98: |
- | ;Bit 2 - SpitFlame. | + | ;Bit 2 - SpitFlame. |
- | SFX_BombExplode: | + | SFX_BombExplode: |
- | LCB9A: lda #$10 ;Bit 0 - No sound. | + | LCB9A: |
- | LCB9C: bne SFX_SetX0 ; | + | LCB9C: |
- | ;$0681: These SFX use sq1 channel. | + | ;$0681: These SFX use sq1 channel. |
- | SFX_MissileLaunch: | + | SFX_MissileLaunch: |
- | LCB9E: lda #$20 ;Bit 6 - EnergyPickup. | + | LCB9E: |
- | ;Bit 5 - Metal. | + | ;Bit 5 - Metal. |
- | SFX_SetX0: ;Bit 4 - BulletFire. | + | SFX_SetX0: |
- | LCBA0: ldx #$00 ;Bit 3 - OutOfHole. | + | LCBA0: |
- | LCBA2: beq SFX_SetSoundFlag ;Bit 2 - EnemyHit. | + | LCBA2: |
- | ;Bit 1 - SamusJump. | + | ;Bit 1 - SamusJump. |
- | SFX_OutOfHole: | + | SFX_OutOfHole: |
- | LCBA4: lda #$08 ; | + | LCBA4: |
- | LCBA6: bne SFX_SetX1 ;$0682: Not used. | + | LCBA6: |
- | ; | + | ; |
- | SFX_BombLaunch: | + | SFX_BombLaunch: |
- | LCBA8: lda #$01 ;Bit 7 - SamusDie. | + | LCBA8: |
- | LCBAA: bne SFX_SetX3 ;Bit 6 - DoorOpenClose. | + | LCBAA: |
- | ;Bit 5 - MetroidHit. | + | ;Bit 5 - MetroidHit. |
- | SFX_SamusJump: | + | SFX_SamusJump: |
- | LCBAC: lda #$02 ;Bit 3 - Beep. | + | LCBAC: |
- | LCBAE: bne SFX_SetX1 ;Bit 2 - BigEnemyHit. | + | LCBAE: |
- | ;Bit 1 - SamusBall. | + | ;Bit 1 - SamusBall. |
- | SFX_EnemyHit: | + | SFX_EnemyHit: |
- | LCBB0: lda #$04 ; | + | LCBB0: |
- | LCBB2: bne SFX_SetX1 ;$0684: These SFX use multi channels. | + | LCBB2: |
- | ;Bit 7 - FadeInMusic (music). | + | ;Bit 7 - FadeInMusic |
- | SFX_BulletFire: | + | SFX_BulletFire: |
- | LCBB4: lda #$10 ;Bit 5 - EndMusic | + | LCBB4: |
- | LCBB6: bne SFX_SetX1 ;Bit 4 - IntroMusic(Page 0 only)(music). | + | LCBB6: |
- | ;Bit 3 - not used (SFX). | + | ;Bit 3 - not used |
- | SFX_Metal: ;Bit 2 - SamusHit (SFX). | + | SFX_Metal: |
- | LCBB8: lda #$20 ;Bit 1 - BossHit (SFX). | + | LCBB8: |
- | LCBBA: bne SFX_SetX1 ;Bit 0 - IncorrectPassword (SFX). | + | LCBBA: |
- | ; | + | ; |
- | SFX_EnergyPickup: | + | SFX_EnergyPickup: |
- | LCBBC: lda #$40 ;music depending on what memory page is loaded. The--> | + | LCBBC: |
- | LCBBD: bne SFX_SetX1 ;following lists what bits start what music for each--> | + | LCBBD: |
- | ;memory page. | + | ;memory page. |
- | SFX_MissilePickup: | + | SFX_MissilePickup: |
- | LCBC0: lda #$80 ;Page 0: Intro/ | + | LCBC0: |
- | ;Bit 7 - Not used. | + | ;Bit 7 - Not used. |
- | SFX_SetX1: ;Bit 6 - TourianMusic. | + | SFX_SetX1: |
- | LCBC2: ldx #$01 ;Bit 5 - ItemRoomMusic. | + | LCBC2: |
- | LCBC4: bne SFX_SetSoundFlag ;Bit 4 - Not used. | + | LCBC4: |
- | ;Bit 3 - Not used. | + | ;Bit 3 - Not used. |
- | SFX_WaveFire: | + | SFX_WaveFire: |
- | LCBC6: lda #$01 ;Bit 1 - Not used. | + | LCBC6: |
- | LCBC8: bne SFX_SetX1 ;Bit 0 - Not used. | + | LCBC8: |
- | ; | + | ; |
- | SFX_ScrewAttack: | + | SFX_ScrewAttack: |
- | LCBCA: lda #$40 ;Bit 7 - Not used. | + | LCBCA: |
- | LCBCC: bne SFX_SetX0 ;Bit 6 - TourianMusic. | + | LCBCC: |
- | ;Bit 5 - ItemRoomMusic. | + | ;Bit 5 - ItemRoomMusic. |
- | SFX_BigEnemyHit: | + | SFX_BigEnemyHit: |
- | LCBCE: lda #$04 ;Bit 3 - Not used. | + | LCBCE: |
- | LCBD0: bne SFX_SetX3 ;Bit 2 - Not used. | + | LCBD0: |
- | ;Bit 1 - Not used. | + | ;Bit 1 - Not used. |
- | SFX_MetroidHit: | + | SFX_MetroidHit: |
- | LCBD2: lda #$20 ; | + | LCBD2: |
- | LCBD4: bne SFX_SetX3 ;Page 2: Norfair. | + | LCBD4: |
- | ;Bit 7 - Not used. | + | ;Bit 7 - Not used. |
- | SFX_BossHit: | + | SFX_BossHit: |
- | LCBD6: lda #$02 ;Bit 5 - ItemRoomMusic. | + | LCBD6: |
- | LCBD8: bne SFX_SetX4 ;Bit 4 - Not used. | + | LCBD8: |
- | ;Bit 3 - NorfairMusic. | + | ;Bit 3 - NorfairMusic. |
- | SFX_Door: ;Bit 2 - Not used. | + | SFX_Door: |
- | LCBDA: lda #$40 ;Bit 1 - Not used. | + | LCBDA: |
- | LCBDC: bne SFX_SetX3 ;Bit 0 - Not used. | + | LCBDC: |
- | ; | + | ; |
- | SFX_SamusHit: | + | SFX_SamusHit: |
- | LCBDE: lda #$04 ;Bit 7 - Not used. | + | LCBDE: |
- | LCBE0: bne SFX_SetX4 ;Bit 6 - TourianMusic | + | LCBE0: |
- | ;Bit 5 - ItemRoomMusic. | + | ;Bit 5 - ItemRoomMusic. |
- | SFX_SamusDie: | + | SFX_SamusDie: |
- | LCBE2: lda #$80 ;Bit 3 - Not used. | + | LCBE2: |
- | LCBE4: bne SFX_SetX3 ;Bit 2 - EscapeMusic. | + | LCBE4: |
- | ;Bit 1 - MotherBrainMusic | + | ;Bit 1 - MotherBrainMusic |
- | SFX_SetX2: ;Bit 0 - Not used. | + | SFX_SetX2: |
- | LCBE6: ldx #$02 ; | + | LCBE6: |
- | ;Page 4: Kraid. | + | ;Page 4: Kraid. |
- | SFX_SetSoundFlag: | + | SFX_SetSoundFlag: |
- | LCBE8: ora $0680,x ;Bit 6 - TourianMusic. | + | LCBE8: |
- | LCBEB: sta $0680,x ;Bit 5 - ItemRoomMusic. | + | LCBEB: |
- | LCBEE: rts ;Bit 4 - KraidAreaMusic. | + | LCBEE: |
- | ;Bit 3 - Not used. | + | ;Bit 3 - Not used. |
- | SFX_SamusBall: | + | SFX_SamusBall: |
- | LCBEF: lda #$02 ;Bit 1 - Not used. | + | LCBEF: |
- | LCBF1: bne SFX_SetX3 ;Bit 0 - Not used. | + | LCBF1: |
- | ; | + | ; |
- | SFX_Beep: ;Page 5: Ridley. | + | SFX_Beep: |
- | LCBF3: lda #$08 ;Bit 7 - RidleyAreaMusic. | + | LCBF3: |
- | ;Bit 6 - TourianMusic. | + | ;Bit 6 - TourianMusic. |
- | SFX_SetX3: ;Bit 5 - ItemRoomMusic. | + | SFX_SetX3: |
- | LCBF5: ldx #$03 ;Bit 4 - KraidAreaMusic. | + | LCBF5: |
- | LCBF7: bne SFX_SetSoundFlag ;Bit 3 - Not used. | + | LCBF7: |
- | ;Bit 2 - Not used. | + | ;Bit 2 - Not used. |
- | ;Initiate music ;Bit 1 - Not used. | + | ;Initiate music |
- | ;Bit 0 - Not used. | + | ;Bit 0 - Not used. |
- | PowerUpMusic: | + | PowerUpMusic: |
- | LCBF9: lda #$40 ; | + | LCBF9: |
- | LCBFB: bne SFX_SetX4 ; | + | LCBFB: |
- | ; | + | ; |
- | IntroMusic: | + | IntroMusic: |
- | LCBFD: lda #$80 ; | + | LCBFD: |
- | ; | + | ; |
- | SFX_SetX4: ; | + | SFX_SetX4: |
- | LCBFF: ldx #$04 ; | + | LCBFF: |
- | LCC01: bne SFX_SetSoundFlag ; | + | LCC01: |
- | ; | + | ; |
- | MotherBrainMusic: | + | MotherBrainMusic: |
- | LCC03: lda #$02 ; | + | LCC03: |
- | LCC05: bne SFX_SetX5 ; | + | LCC05: |
- | ; | + | ; |
- | TourianMusic: | + | TourianMusic: |
- | LCC07: lda #$40 ; | + | LCC07: |
- | ; | + | ; |
- | SFX_SetX5: ; | + | SFX_SetX5: |
- | LCC09: ldx #$05 ; | + | LCC09: |
- | LCC0B: bne SFX_SetSoundFlag ; | + | LCC0B: |
; | ; | ||
UpdateSamus: | UpdateSamus: | ||
- | LCC0D: ldx #$00 ;Samus data is located at index #$00. | + | LCC0D: |
- | LCC0F: stx PageIndex ; | + | LCC0F: |
- | LCC11: inx ;x=1. | + | LCC11: |
- | LCC12: stx IsSamus ;Indicate Samus is the object being updated. | + | LCC12: |
- | LCC14: jsr GoSamusHandler ; | + | LCC14: |
- | LCC17: dec IsSamus ;Update of Samus complete. | + | LCC17: |
- | LCC19: rts ; | + | LCC19: |
GoSamusHandler: | GoSamusHandler: | ||
- | LCC1A: lda ObjAction ; | + | LCC1A: |
- | LCC1D: bmi SamusStand ;Branch if Samus is standing. | + | LCC1D: |
- | LCC1F: jsr ChooseRoutine ; | + | LCC1F: |
;Pointer table for Samus' action handlers. | ;Pointer table for Samus' action handlers. | ||
- | LCC22: | + | LCC22: |
- | LCC24: | + | LCC24: |
- | LCC26: | + | LCC26: |
- | LCC28: | + | LCC28: |
- | LCC2A: | + | LCC2A: |
- | LCC2C: | + | LCC2C: |
- | LCC2E: | + | LCC2E: |
- | LCC30: | + | LCC30: |
- | LCC32: | + | LCC32: |
- | LCC34: | + | LCC34: |
; | ; | ||
SamusStand: | SamusStand: | ||
- | LCC36: lda Joy1Status ;Status of joypad 1. | + | LCC36: |
- | LCC38: and #$CF ;Remove SELECT & START status bits. | + | LCC38: |
- | LCC3A: beq + ;Branch if no buttons pressed. | + | LCC3A: |
- | LCC3C: jsr ClearHorzMvmtAnimData ; | + | LCC3C: |
- | LCC3F: lda Joy1Status ; | + | LCC3F: |
- | LCC41:* and #$07 ;Keep status of DOWN/ | + | LCC41:* and #$07 ;Keep status of DOWN/ |
- | LCC43: bne + ;Branch if any are pressed. | + | LCC43: |
- | LCC45: lda Joy1Change ; | + | LCC45: |
- | LCC47: and #$08 ;Check if UP was pressed last frame.--> | + | LCC47: |
- | LCC49: beq +++ ;If not, branch. | + | LCC49: |
- | LCC4B:* jsr BitScan ; | + | LCC4B:* jsr BitScan |
- | LCC4E: cmp #$02 ;Is down pressed? | + | LCC4E: |
- | LCC50: bcs + ;If so, branch. | + | LCC50: |
- | LCC52: sta SamusDir ;1=left, 0=right. | + | LCC52: |
- | LCC54: | + | LCC54:* tax |
- | LCC55: lda ActionTable, | + | LCC55: |
- | LCC58: sta ObjAction ;Save Samus status. | + | LCC58: |
- | LCC5B:* lda Joy1Change ; | + | LCC5B:* lda Joy1Change |
- | LCC5D: ora Joy1Retrig ;Check if fire was just pressed or needs to retrigger. | + | LCC5D: |
- | LCC5F: asl ; | + | LCC5F: |
- | LCC60: bpl + ;Branch if FIRE not pressed. | + | LCC60: |
- | LCC62: jsr FireWeapon ; | + | LCC62: |
- | LCC65:* bit Joy1Change ;Check if jump was just pressed. | + | LCC65:* bit Joy1Change |
- | LCC67: bpl + ;Branch if JUMP not pressed. | + | LCC67: |
- | LCC69: lda #sa_Jump ; | + | LCC69: |
- | LCC6B: sta ObjAction ;Set Samus status as jumping. | + | LCC6B: |
- | 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: |
- | LCC73: lda ObjAction ; | + | LCC73: |
- | LCC76: cmp #sa_Door ;Is Samus inside a door, dead or pointing up and jumping? | + | LCC76: |
- | LCC78: bcs + ;If so, branch to exit. | + | LCC78: |
- | LCC7A: jsr ChooseRoutine ;Select routine below. | + | LCC7A: |
;Pointer table to code. | ;Pointer table to code. | ||
- | LCC7D: | + | LCC7D: |
- | LCC7F: | + | LCC7F: |
- | LCC81: | + | LCC81: |
- | LCC83: | + | LCC83: |
- | LCC85: | + | LCC85: |
;Table used by above subroutine. | ;Table used by above subroutine. | ||
ActionTable: | ActionTable: | ||
- | LCC87: | + | LCC87: |
- | LCC88: | + | LCC88: |
- | LCC89: | + | LCC89: |
- | LCC8A: | + | LCC8A: |
; | ; | ||
Line 2186: | Line 2186: | ||
SetSamusExplode: | SetSamusExplode: | ||
LCC8B: | LCC8B: | ||
- | sta SamusJumpDsplcmnt | + | |
- | lda # | + | lda # |
- | jsr SetSamusAnim | + | jsr SetSamusAnim |
- | sta ObjectCounter | + | sta ObjectCounter |
* rts | * rts | ||
SetSamusRun: | SetSamusRun: | ||
LCC98: | LCC98: | ||
- | sta WalkSoundDelay | + | |
- | ldx #$00 | + | ldx #$00 |
- | lda AnimResetIndex | + | lda AnimResetIndex |
- | cmp # | + | cmp # |
- | beq + | + | beq + |
- | inx | + | inx |
- | cmp #$27 | + | cmp #$27 |
- | beq + | + | beq + |
- | lda #$04 | + | lda #$04 |
- | jsr SetSamusNextAnim | + | jsr SetSamusNextAnim |
* lda RunAnimationTbl, | * lda RunAnimationTbl, | ||
- | sta AnimResetIndex | + | |
- | ldx SamusDir | + | ldx SamusDir |
LCCB7: | LCCB7: | ||
- | sta SamusHorzAccel | + | |
- | rts | + | rts |
RunAnimationTbl: | RunAnimationTbl: | ||
LCCBE: | LCCBE: | ||
- | .byte an_SamusRunPntUp | + | |
RunAccelerationTbl: | RunAccelerationTbl: | ||
- | LCCC0: | + | LCCC0: |
- | .byte $D0 ;Accelerate left. | + | .byte $D0 |
; SamusRun | ; SamusRun | ||
Line 2223: | Line 2223: | ||
SamusRun: | SamusRun: | ||
- | LCCC2: ldx SamusDir | + | LCCC2: |
- | lda SamusGravity | + | lda SamusGravity |
- | beq +++++++ | + | beq +++++++ |
- | ldy SamusJumpDsplcmnt | + | ldy SamusJumpDsplcmnt |
- | bit ObjVertSpeed | + | bit ObjVertSpeed |
- | bmi + | + | bmi + |
- | cpy #$18 | + | cpy #$18 |
- | bcs ++++ | + | bcs ++++ |
- | lda # | + | lda # |
- | sta AnimResetIndex | + | sta AnimResetIndex |
- | bcc ++++ | + | bcc ++++ ; branch always |
* cpy #$18 | * cpy #$18 | ||
- | bcc +++ | + | |
- | lda AnimResetIndex | + | lda AnimResetIndex |
- | cmp # | + | cmp # |
- | beq + | + | beq + |
- | lda # | + | lda # |
- | sta AnimResetIndex | + | sta AnimResetIndex |
* cpy #$20 | * cpy #$20 | ||
- | bcc ++ | + | |
- | lda Joy1Status | + | lda Joy1Status |
- | and #$08 | + | and #$08 |
- | beq + | + | beq + |
- | lda # | + | lda # |
- | sta AnimResetIndex | + | sta AnimResetIndex |
* bit Joy1Status | * bit Joy1Status | ||
- | bmi + | + | |
- | jsr StopVertMovement ;($D147) | + | jsr StopVertMovement |
- | * lda # | + | * |
- | cmp AnimResetIndex | + | cmp AnimResetIndex |
- | bne + | + | bne + |
- | lda # | + | lda # |
- | sta AnimResetIndex | + | sta AnimResetIndex |
* lda SamusInLava | * lda SamusInLava | ||
- | beq + | + | |
- | lda Joy1Change | + | lda Joy1Change |
- | bmi LCD40 ; branch if JUMP pressed | + | bmi LCD40 ; branch if JUMP pressed |
* jsr LCF88 | * jsr LCF88 | ||
- | jsr LD09C | + | |
- | jsr LCF2E | + | jsr LCF2E |
- | lda #$02 | + | lda #$02 |
- | bne SetSamusData | + | bne SetSamusData |
- | * lda SamusOnElevator | + | * |
- | bne + | + | bne + |
- | jsr LCCB7 | + | jsr LCCB7 |
* jsr LCDBF | * jsr LCDBF | ||
- | dec WalkSoundDelay | + | |
- | bne + ; branch if not | + | bne + ; branch if not |
- | lda #$09 | + | lda #$09 |
- | sta WalkSoundDelay | + | sta WalkSoundDelay |
- | jsr SFX_SamusWalk | + | jsr SFX_SamusWalk |
* jsr LCF2E | * jsr LCF2E | ||
- | lda Joy1Change | + | |
- | bpl + ; branch if JUMP not pressed | + | bpl + ; branch if JUMP not pressed |
LCD40: | LCD40: | ||
- | lda #$12 | + | |
- | sta SamusHorzSpeedMax | + | sta SamusHorzSpeedMax |
- | jmp LCD6B | + | jmp LCD6B |
* ora Joy1Retrig | * ora Joy1Retrig | ||
- | asl | + | |
- | bpl + ; branch if FIRE not pressed | + | bpl + ; branch if FIRE not pressed |
- | jsr LCDD7 | + | jsr LCDD7 |
* lda Joy1Status | * lda Joy1Status | ||
- | and #$03 | + | |
- | bne + | + | bne + |
- | jsr LCF55 | + | jsr LCF55 |
- | jmp LCD6B | + | jmp LCD6B |
- | * jsr BitScan ;($E1E1) | + | * jsr BitScan |
- | cmp SamusDir | + | cmp SamusDir |
- | beq LCD6B | + | beq LCD6B |
- | sta SamusDir | + | sta SamusDir |
- | jsr LCC98 | + | jsr LCC98 |
LCD6B: | LCD6B: | ||
Line 2304: | Line 2304: | ||
SetSamusData: | SetSamusData: | ||
- | LCD6D: | + | LCD6D: |
- | LCD70: jsr IsScrewAttackActive ; | + | LCD70: |
- | LCD73: bcs + ;If screw attack not active, branch to skip palette change. | + | LCD73: |
- | LCD75: lda FrameCount ; | + | LCD75: |
- | LCD77: lsr ; | + | LCD77: |
- | LCD78: and #$03 ;Every other frame, change Samus palette while screw--> | + | LCD78: |
- | LCD7A: ora #$A0 ;Attack is active. | + | LCD7A: |
- | LCD7C: sta ObjectCntrl ; | + | LCD7C: |
- | LCD7E:* jsr CheckHealthStatus ; | + | LCD7E:* jsr CheckHealthStatus |
- | LCD81: jsr LavaAndMoveCheck ; | + | LCD81: |
- | LCD84: lda MetroidOnSamus ;Is a Metroid stuck to Samus? | + | LCD84: |
- | LCD86: beq + ;If not, branch. | + | LCD86: |
- | LCD88: lda #$A1 ;Metroid on Samus. Turn Samus blue. | + | LCD88: |
- | LCD8A: sta ObjectCntrl ; | + | LCD8A: |
- | LCD8C:* jsr SetmirrorCntrlBit ; | + | LCD8C:* jsr SetmirrorCntrlBit |
- | LCD8F: jmp DrawFrame ; | + | LCD8F: |
; | ; | ||
SetmirrorCntrlBit: | SetmirrorCntrlBit: | ||
- | LCD92: | + | LCD92: |
- | LCD94: jsr Amul16 ; | + | LCD94: |
- | LCD97: ora ObjectCntrl ; | + | LCD97: |
- | LCD99: sta ObjectCntrl ;Use SamusDir bit to set mirror bit. | + | LCD99: |
- | LCD9B: rts ; | + | LCD9B: |
; | ; | ||
IsScrewAttackActive: | IsScrewAttackActive: | ||
- | LCD9C: | + | LCD9C: |
- | LCD9D: ldy ObjAction ; | + | LCD9D: |
- | LCDA0: dey ;Is Samus running? | + | LCDA0: |
- | LCDA1: bne ++ ;If not, branch to exit. | + | LCDA1: |
- | LCDA3: lda SamusGear ; | + | LCDA3: |
- | LCDA6: and # | + | LCDA6: |
- | LCDA8: beq ++ ;If not, branch to exit. | + | LCDA8: |
- | LCDAA: lda AnimResetIndex ; | + | LCDAA: |
- | LCDAD: cmp # | + | LCDAD: |
- | LCDAF: beq + ;If so, branch to clear carry(screw attack active). | + | LCDAF: |
- | LCDB1: cmp # | + | LCDB1: |
- | LCDB3: sec ;Is Samus jumping? | + | LCDB3: |
- | LCDB4: bne ++ ;If not, branch to exit. | + | LCDB4: |
- | LCDB6: bit ObjVertSpeed ;If Samus is jumping and still moving upwards, screw--> | + | LCDB6: |
- | LCDB9: bpl ++ ;attack is active. | + | LCDB9: |
- | LCDBB:* cmp AnimIndex ;Screw attack will still be active if not spinning, but--> | + | LCDBB:* cmp AnimIndex |
- | LCDBE: | + | LCDBE:* rts |
; | ; | ||
LCDBF: | LCDBF: | ||
- | 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: | + | LCDD7: |
- | lda Joy1Status | + | lda Joy1Status |
- | and #$08 | + | and #$08 |
- | bne + | + | bne + |
- | lda # | + | lda # |
- | sta AnimIndex | + | sta AnimIndex |
- | rts | + | rts |
* lda AnimIndex | * lda AnimIndex | ||
- | 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 $3B | + | .byte $3B |
- | .byte $3D | + | .byte $3D |
- | .byte $3F | + | .byte $3F |
CheckHealthStatus: | CheckHealthStatus: | ||
- | LCDFA: | + | LCDFA: |
- | 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 +++ |
- | lda #$32 ; | + | lda #$32 ; |
- | sta SamusBlink ;Samus has been hit. Set blink for 32 frames. | + | sta SamusBlink |
- | 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 | + | |
- | lsr | + | lsr |
- | lsr | + | lsr |
- | lsr | + | lsr |
- | sta DamagePushDirection | + | sta DamagePushDirection |
- | * 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 | + | * |
- | beq CheckHealthBeep | + | beq CheckHealthBeep |
- | dec SamusBlink | + | dec SamusBlink |
- | ldx DamagePushDirection | + | ldx DamagePushDirection |
- | inx | + | inx |
- | beq +++ | + | beq +++ |
- | jsr Adiv16 | + | jsr Adiv16 |
- | cmp #$03 | + | cmp #$03 |
- | bcs + | + | bcs + |
- | ldy SamusHorzAccel | + | ldy SamusHorzAccel |
- | bne +++ | + | bne +++ |
- | jsr LCF4E | + | jsr LCF4E |
* dex | * dex | ||
- | bne + | + | |
- | jsr TwosCompliment ;($C3D4) | + | jsr TwosCompliment |
* sta ObjHorzSpeed | * sta ObjHorzSpeed | ||
- | * 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 | + | |
- | 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 | + | |
- | bne + ;Only beep every 16th frame. | + | bne + |
- | jsr SFX_Beep | + | jsr SFX_Beep |
- | * lda #$00 | + | * |
- | sta SamusHit | + | sta SamusHit |
- | LCE83: rts | + | LCE83: |
; | ; | ||
IsSamusDead: | IsSamusDead: | ||
- | LCE84: lda ObjAction ; | + | LCE84: |
- | LCE87: cmp #sa_Dead ; | + | LCE87: |
- | LCE89: beq Exit3 ;Samus is dead. Zero flag is set. | + | LCE89: |
- | LCE8B: cmp #sa_Dead2 ; | + | LCE8B: |
- | LCE8D: beq Exit3 ; | + | LCE8D: |
- | LCE8F: cmp #$FF ;Samus not dead. Clear zero flag. | + | LCE8F: |
Exit3: | Exit3: | ||
- | LCE91: rts ;Exit for routines above and below. | + | LCE91: |
; | ; | ||
SubtractHealth: | SubtractHealth: | ||
- | LCE92: lda HealthLoChange ;Check to see if health needs to be changed.--> | + | LCE92: |
- | LCE94: ora HealthHiChange ;If not, branch to exit. | + | LCE94: |
- | LCE96: beq Exit3 ; | + | LCE96: |
- | LCE98: jsr IsSamusDead ; | + | LCE98: |
- | LCE9B: beq ClearDamage ;Samus is dead. Branch to clear damage values. | + | LCE9B: |
- | LCE9D: ldy EndTimerHi ;If end escape timer is running, Samus cannot be hurt. | + | LCE9D: |
- | LCEA0: iny ; | + | LCEA0: |
- | LCEA1: beq + ;Branch if end escape timer not active. | + | LCEA1: |
ClearDamage: | ClearDamage: | ||
- | LCEA3: jmp ClearHealthChange ; | + | LCEA3: |
- | LCEA6:* lda MotherBrainStatus ;If mother brain is in the process of dying, receive--> | + | LCEA6:* lda MotherBrainStatus |
- | LCEA8: cmp #$03 ;no damage. | + | LCEA8: |
- | LCEAA: bcs ClearDamage ; | + | LCEAA: |
- | LCEAC: lda SamusGear ; | + | LCEAC: |
- | LCEAF: and #gr_VARIA ;Check is Samus has Varia. | + | LCEAF: |
- | LCEB1: beq + ; | + | LCEB1: |
- | LCEB3: lsr HealthLoChange ;If Samus has Varia, divide damage by 2. | + | LCEB3: |
- | LCEB5: lsr HealthHiChange ; | + | LCEB5: |
- | LCEB7: bcc + ;If HealthHi moved a bit into the carry flag while--> | + | LCEB7: |
- | LCEB9: lda #$4F ;dividing, add #$4F to HealthLo for proper--> | + | LCEB9: |
- | LCEBB: adc HealthLoChange ;division results. | + | LCEBB: |
- | LCEBD: sta HealthLoChange ; | + | LCEBD: |
- | LCEBF:* lda HealthLo ;Prepare to subtract from HealthLo. | + | LCEBF:* lda HealthLo |
- | LCEC2: sta $03 ; | + | LCEC2: |
- | LCEC4: lda HealthLoChange ;Amount to subtract from HealthLo. | + | LCEC4: |
- | LCEC6: sec ; | + | LCEC6: |
- | LCEC7: jsr Base10Subtract ; | + | LCEC7: |
- | LCECA: sta HealthLo ;Save results. | + | LCECA: |
- | LCECD: | + | LCECD: |
- | LCED0: sta $03 ; | + | LCED0: |
- | LCED2: lda HealthHiChange ;Amount to subtract from HealthHi. | + | LCED2: |
- | LCED4: jsr Base10Subtract ; | + | LCED4: |
- | LCED7: sta HealthHi ;Save Results. | + | LCED7: |
- | LCEDA: lda HealthLo ; | + | LCEDA: |
- | LCEDD: and #$F0 ;Is Samus health at 0? If so, branch to--> | + | LCEDD: |
- | LCEDF: ora HealthHi ;begin death routine. | + | LCEDF: |
- | LCEE2: beq + ; | + | LCEE2: |
- | LCEE4: bcs ++ ;Samus not dead. Branch to exit. | + | LCEE4: |
- | LCEE6:* lda #$00 ;Samus is dead. | + | LCEE6:* lda #$00 ;Samus is dead. |
- | LCEE8: sta HealthLo ; | + | LCEE8: |
- | LCEEB: sta HealthHi ;Set health to #$00. | + | LCEEB: |
- | LCEEE: lda #sa_Dead ; | + | LCEEE: |
- | LCEF0: sta ObjAction ;Death handler. | + | LCEF0: |
- | LCEF3: jsr SFX_SamusDie ; | + | LCEF3: |
- | LCEF6: jmp SetSamusExplode ;($CC8B)Set Samus exlpode routine. | + | LCEF6: |
; | ; | ||
AddHealth: | AddHealth: | ||
- | LCEF9: lda HealthLo ;Prepare to add to HealthLo. | + | LCEF9: |
- | LCEFC: sta $03 ; | + | LCEFC: |
- | LCEFE: lda HealthLoChange ;Amount to add to HealthLo. | + | LCEFE: |
- | LCF00: clc ; | + | LCF00: |
- | LCF01: jsr Base10Add ; | + | LCF01: |
- | LCF04: sta HealthLo ;Save results. | + | LCF04: |
- | LCF07: lda HealthHi ;Prepare to add to HealthHi. | + | LCF07: |
- | LCF0A: sta $03 ; | + | LCF0A: |
- | LCF0C: lda HealthHiChange ;Amount to add to HealthHi. | + | LCF0C: |
- | LCF0E: jsr Base10Add ; | + | LCF0E: |
- | LCF11: sta HealthHi ;Save results. | + | LCF11: |
- | LCF14: lda TankCount ; | + | LCF14: |
- | LCF17: jsr Amul16 ; | + | LCF17: |
- | LCF1A: ora #$0F ;Set lower 4 bits. | + | LCF1A: |
- | LCF1C: cmp HealthHi ; | + | LCF1C: |
- | LCF1F: bcs + ;Is life less than max? if so, branch. | + | LCF1F: |
- | LCF21: and #$F9 ;Life is more than max amount. | + | LCF21: |
- | LCF23: sta HealthHi ; | + | LCF23: |
- | LCF26: lda #$99 ;Set life to max amount. | + | LCF26: |
- | LCF28: sta HealthLo ; | + | LCF28: |
- | LCF2B:* jmp ClearHealthChange ;($F323) | + | LCF2B:* jmp ClearHealthChange |
; | ; | ||
- | LCF2E: lda SamusHit | + | LCF2E: |
- | LCF31: | + | LCF31: |
- | and #$02 | + | and #$02 |
- | beq +++ | + | beq +++ |
- | bcs + | + | bcs + |
- | lda SamusHorzAccel | + | lda SamusHorzAccel |
- | bmi +++ | + | bmi +++ |
- | bpl ++ | + | bpl ++ |
* lda SamusHorzAccel | * lda SamusHorzAccel | ||
- | bmi + | + | |
- | bne ++ | + | bne ++ |
- | * jsr TwosCompliment ;($C3D4) | + | * |
- | sta SamusHorzAccel | + | sta SamusHorzAccel |
ClearHorzMvmntData: | ClearHorzMvmntData: | ||
- | LCF4C: | + | LCF4C: |
- | LCF4E: | + | LCF4E: |
- | sty HorzCntrLinear ;linear counter to #$00. | + | sty HorzCntrLinear |
- | * rts ; | + | * |
StopHorzMovement: | StopHorzMovement: | ||
- | LCF55: | + | LCF55: |
- | bne ClearHorzMvmtAnimData ; | + | bne ClearHorzMvmtAnimData |
- | jsr SFX_SamusWalk ; | + | jsr SFX_SamusWalk |
ClearHorzMvmtAnimData: | ClearHorzMvmtAnimData: | ||
- | LCF5D: | + | LCF5D: |
- | sty ObjAction ;Samus is standing. | + | sty ObjAction |
- | 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 + |
- | lda # | + | lda # |
SetSamusAnim: | SetSamusAnim: | ||
- | LCF6B: sta AnimResetIndex ;Set new animation reset index. | + | LCF6B: |
SetSamusNextAnim: | SetSamusNextAnim: | ||
- | sta AnimIndex ;Set new animation data index. | + | |
- | lda #$00 ; | + | lda #$00 ; |
- | sta AnimDelay ;New animation to take effect immediately. | + | sta AnimDelay |
- | rts ; | + | rts |
SetSamusPntUp: | SetSamusPntUp: | ||
- | LCF77:* lda #sa_PntUp ; | + | LCF77:* lda # |
- | sta ObjAction ;Samus is pointing up. | + | sta ObjAction |
- | lda # | + | lda # |
- | jsr SetSamusAnim ;($CF6B)Set new animation values. | + | jsr SetSamusAnim |
NoHorzMoveNoDelay: | NoHorzMoveNoDelay: | ||
- | LCF81: | + | LCF81: |
- | sty AnimDelay ;Clear animation delay data. | + | sty AnimDelay |
- | rts ; | + | rts |
LCF88: | LCF88: | ||
- | and #$03 | + | |
- | beq + | + | beq + |
- | jsr BitScan ;($E1E1) | + | jsr BitScan |
- | tax | + | tax |
- | jsr LCCB7 | + | jsr LCCB7 |
- | lda SamusGravity | + | lda SamusGravity |
- | bmi ++ | + | bmi ++ |
- | lda AnimResetIndex | + | lda AnimResetIndex |
- | cmp # | + | cmp # |
- | beq ++ | + | beq ++ |
- | stx SamusDir | + | stx SamusDir |
- | lda Table06+1, | + | lda Table06+1, |
- | jmp SetSamusAnim | + | jmp SetSamusAnim |
* lda SamusGravity | * lda SamusGravity | ||
- | bmi + | + | |
- | beq + | + | beq + |
- | lda AnimResetIndex | + | lda AnimResetIndex |
- | cmp # | + | cmp # |
- | bne + | + | bne + |
ClearHorzData: | ClearHorzData: | ||
- | LCFB7: | + | LCFB7: |
- | sty SamusHorzAccel ;Clear horizontal acceleration data. | + | sty SamusHorzAccel |
- | * rts ; | + | * |
LCFBE: | LCFBE: | ||
- | jmp + | + | |
SetSamusJump: | SetSamusJump: | ||
LCFC3: | LCFC3: | ||
* sty AnimResetIndex | * sty AnimResetIndex | ||
- | 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 # | + | and # |
- | beq + ; branch if Samus doesn' | + | beq + ; branch if Samus doesn' |
- | lda #$00 | + | lda #$00 |
- | sta $0686 | + | sta $0686 |
- | jsr SFX_ScrewAttack | + | jsr SFX_ScrewAttack |
* jsr SFX_SamusJump | * jsr SFX_SamusJump | ||
- | LCFF3: | + | LCFF3: |
- | lda SamusGear | + | lda SamusGear |
- | and # | + | and # |
- | beq + ; branch if Samus doesn' | + | beq + ; branch if Samus doesn' |
- | ldy #$12 ; lower gravity value -> high jump! | + | ldy #$12 ; lower gravity value -> high jump! |
* sty SamusGravity | * sty SamusGravity | ||
- | rts | + | |
SamusJump: | SamusJump: | ||
- | 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 ; | + | jsr StopVertMovement |
* jsr LD055 | * jsr LD055 | ||
- | jsr LCF2E | + | |
- | lda Joy1Status | + | lda Joy1Status |
- | and #$08 ; UP pressed? | + | and #$08 ; UP pressed? |
- | beq + ; branch if not | + | beq + ; branch if not |
- | lda # | + | lda # |
- | sta AnimResetIndex | + | sta AnimResetIndex |
- | lda # | + | lda # |
- | sta ObjAction | + | sta ObjAction |
* jsr LD09C | * jsr LD09C | ||
- | 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 ++ | + | |
- | lda ObjAction | + | lda ObjAction |
- | cmp # | + | cmp # |
- | bne + | + | bne + |
- | jsr LCF77 | + | jsr LCF77 |
- | bne ++ | + | bne ++ |
* jsr LCF55 | * jsr LCF55 | ||
- | * lda #$03 | + | * |
- | jmp SetSamusData ;($CD6D)Set Samus control data and animation. | + | jmp SetSamusData |
LD055: | LD055: | ||
- | 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 +++ | + | |
- | lda ObjAction | + | lda ObjAction |
- | cmp # | + | cmp # |
- | 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 | + | |
- | bne + | + | bne + |
- | lda Table06+1, | + | lda Table06+1, |
- | * jsr SetSamusAnim | + | * |
- | lda #$08 | + | lda #$08 |
- | sta AnimDelay | + | sta AnimDelay |
- | sty SamusDir | + | sty SamusDir |
- | * stx ObjHorzSpeed | + | * |
* rts | * rts | ||
Line 2743: | Line 2743: | ||
Table06: | Table06: | ||
- | .byte $0C | + | |
- | .byte $0C | + | .byte $0C |
- | .byte $0C | + | .byte $0C |
Table04: | Table04: | ||
- | .byte $35 | + | |
- | .byte $35 | + | .byte $35 |
- | .byte $35 | + | .byte $35 |
LD09C: | LD09C: | ||
- | ora Joy1Retrig | + | |
- | asl | + | asl |
- | bpl - ; exit if FIRE not pressed | + | bpl - ; exit if FIRE not pressed |
- | lda AnimResetIndex | + | lda AnimResetIndex |
- | cmp # | + | cmp # |
- | bne + | + | bne + |
- | jmp LD275 | + | jmp LD275 |
* jsr LD210 | * jsr LD210 | ||
- | lda # | + | |
- | jmp SetSamusAnim | + | jmp SetSamusAnim |
SetSamusRoll: | SetSamusRoll: | ||
LD0B5: | LD0B5: | ||
- | and # | + | |
- | beq + ; branch if Samus doesn' | + | beq + ; branch if Samus doesn' |
- | lda SamusGravity | + | lda SamusGravity |
- | bne + | + | bne + |
;Turn Samus into ball | ;Turn Samus into ball | ||
- | ldx SamusDir | + | |
- | lda # | + | lda # |
- | sta AnimResetIndex | + | sta AnimResetIndex |
- | lda # | + | lda # |
- | 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 | + | |
- | rts | + | rts |
; 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 ; | + | bit Joy1Change |
- | bpl ++ | + | bpl ++ ; branch if no |
* lda Joy1Status | * lda Joy1Status | ||
- | and #$04 ; DOWN pressed? | + | |
- | bne + | + | bne + |
;break out of "ball mode" | ;break out of "ball mode" | ||
- | lda ObjRadY | + | |
- | clc | + | clc |
- | adc #$08 | + | adc #$08 |
- | sta ObjRadY | + | sta ObjRadY |
- | jsr CheckMoveUp | + | jsr CheckMoveUp |
- | bcc + | + | bcc + |
- | 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 |
- | lda #$04 | + | lda #$04 |
- | jmp LD144 | + | jmp LD144 |
- | * lda Joy1Change | + | * |
- | jsr BitScan ;($E1E1) | + | jsr BitScan |
- | cmp #$02 | + | cmp #$02 |
- | bcs + | + | bcs + |
- | sta SamusDir | + | sta SamusDir |
- | lda # | + | lda # |
- | jsr SetSamusAnim | + | jsr SetSamusAnim |
* ldx SamusDir | * ldx SamusDir | ||
- | 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: | + | LD144: |
StopVertMovement: | StopVertMovement: | ||
LD147: | LD147: | ||
- | 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: | + | |
- | lda SamusGear | + | lda SamusGear |
- | lsr | + | lsr |
- | bcc ++ | + | bcc ++ ; exit if Samus doesn' |
- | lda Joy1Change | + | lda Joy1Change |
- | ora Joy1Retrig | + | ora Joy1Retrig |
- | asl ; bit 7 = status of FIRE button | + | asl |
- | bpl ++ | + | 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 ++ | + | 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, | + | |
- | 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 # | + | lda # |
- | sta ObjAction, | + | sta ObjAction, |
- | jsr SFX_BombLaunch | + | jsr SFX_BombLaunch |
- | * rts | + | * |
- | SamusPntUp: | + | |
- | lda Joy1Status | + | lda Joy1Status |
- | and #$08 ; UP still pressed? | + | and #$08 ; UP still pressed? |
- | bne + ; branch if yes | + | bne + ; branch if yes |
- | lda # | + | lda # |
- | sta ObjAction | + | sta ObjAction |
* lda Joy1Status | * lda Joy1Status | ||
- | and #$07 ; DOWN, LEFT, RIGHT pressed? | + | |
- | beq ++ | + | beq ++ ; branch if no |
- | jsr BitScan ;($E1E1) | + | jsr BitScan |
- | cmp #$02 | + | cmp #$02 |
- | bcs + | + | bcs + |
- | sta SamusDir | + | sta SamusDir |
* tax | * tax | ||
- | lda Table07,x | + | |
- | sta ObjAction | + | sta ObjAction |
- | * lda Joy1Change | + | * |
- | ora Joy1Retrig | + | ora Joy1Retrig |
- | asl | + | asl |
- | bpl + ; branch if FIRE not pressed | + | bpl + ; branch if FIRE not pressed |
- | jsr FireWeapon ; | + | jsr FireWeapon |
* bit Joy1Change | * bit Joy1Change | ||
- | bpl + ; branch if JUMP not pressed | + | |
- | lda # | + | lda # |
- | sta ObjAction | + | sta ObjAction |
* lda #$04 | * lda #$04 | ||
- | 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 $CC98 | + | .word $CC98 |
- | .word ExitSub | + | .word ExitSub |
- | .word $D0B5 | + | .word $D0B5 |
- | .word ExitSub | + | .word ExitSub |
- | .word ExitSub | + | .word ExitSub |
- | .word $CFBE | + | .word $CFBE |
- | .word ExitSub | + | .word ExitSub |
- | .word ExitSub | + | .word ExitSub |
- | .word ExitSub | + | .word ExitSub |
; Table used by above subroutine | ; Table used by above subroutine | ||
Table07: | Table07: | ||
- | .byte sa_Run | + | |
- | .byte sa_Run | + | .byte sa_Run |
- | .byte sa_Roll | + | .byte sa_Roll |
FireWeapon: | FireWeapon: | ||
LD1EE: | LD1EE: | ||
- | and #$08 | + | |
- | beq LD210 | + | beq LD210 |
- | jmp LD275 | + | jmp LD275 |
LD1F7: | LD1F7: | ||
* lda ObjAction,y | * lda ObjAction,y | ||
- | beq + | + | |
- | jsr Yplus16 | + | jsr Yplus16 |
- | bne - | + | bne - |
- | iny | + | iny |
- | rts | + | rts |
* sta $030A,y | * sta $030A,y | ||
- | lda MissileToggle | + | |
- | beq + | + | beq + |
- | cpy #$D0 | + | cpy #$D0 |
* rts | * rts | ||
LD210: | LD210: | ||
- | 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, | + | lda Table99, |
- | sta ObjHorzSpeed, | + | sta ObjHorzSpeed, |
- | 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 # | + | and # |
- | 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: | LD26B: | ||
- | jmp SetSamusNextAnim | + | |
Table08: | Table08: | ||
- | .byte $0C | + | |
- | .byte $F4 | + | .byte $F4 |
- | .byte $08 | + | .byte $08 |
- | .byte $F8 | + | .byte $F8 |
Table99: | Table99: | ||
- | .byte $04 | + | |
- | .byte $FC | + | .byte $FC |
LD275: | LD275: | ||
- | 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 # | + | and # |
- | 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 | + | |
- | lda SamusGravity | + | lda SamusGravity |
- | beq + | + | beq + |
- | ldy Table09+2,x | + | ldy Table09+2,x |
* lda ObjAction | * lda ObjAction | ||
- | 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 $34 | + | .byte $34 |
- | .byte $34 | + | .byte $34 |
- | .byte $01 | + | .byte $01 |
- | .byte $FF | + | .byte $FF |
- | .byte $EC | + | .byte $EC |
- | .byte $F0 | + | .byte $F0 |
LD2EB: | LD2EB: | ||
- | 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 AnimIndex, | + | sta AnimIndex, |
- | lda #$00 | + | lda #$00 |
- | sta AnimDelay,x | + | sta AnimDelay,x |
* rts | * rts | ||
LD306: | LD306: | ||
- | jsr LE8BE | + | |
- | tya | + | tya |
- | tax | + | tax |
- | jsr LFD8F | + | jsr LFD8F |
- | txa | + | txa |
- | tay | + | tay |
- | jmp LD638 | + | jmp LD638 |
CheckMissileLaunch: | CheckMissileLaunch: | ||
- | lda MissileToggle | + | |
- | beq Exit4 ; exit if Samus not in " | + | beq Exit4 ; exit if Samus not in " |
- | cpy #$D0 | + | cpy #$D0 |
- | bne Exit4 | + | bne Exit4 |
- | ldx SamusDir | + | ldx SamusDir |
- | lda MissileAnims, | + | lda MissileAnims, |
* jsr SetBulletAnim | * jsr SetBulletAnim | ||
- | jsr SFX_MissileLaunch | + | |
- | lda # | + | lda #wa_Missile ; missile handler |
- | sta ObjAction, | + | sta ObjAction, |
- | lda #$FF | + | lda #$FF |
- | sta $030F, | + | sta $030F, |
- | 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 | + | |
- | jmp SelectSamusPal | + | jmp SelectSamusPal |
MissileAnims: | MissileAnims: | ||
- | .byte an_MissileRight | + | |
- | .byte an_MissileLeft | + | .byte an_MissileLeft |
LD340: | LD340: | ||
- | beq Exit4 | + | |
- | cpy #$D0 | + | cpy #$D0 |
- | bne Exit4 | + | bne Exit4 |
- | lda #$8F | + | lda #$8F |
- | bne - | + | bne - |
SetBulletAnim: | SetBulletAnim: | ||
- | sta AnimIndex, | + | |
- | sta AnimResetIndex, | + | sta AnimResetIndex, |
- | lda #$00 | + | lda #$00 |
- | sta AnimDelay,y | + | sta AnimDelay,y |
Exit4: | Exit4: | ||
LD359: | LD359: | ||
* sta $0502,y | * sta $0502,y | ||
- | bit SamusGear | + | |
- | bvc Exit4 ; branch if Samus doesn' | + | bvc Exit4 ; branch if Samus doesn' |
- | 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 | + | jsr Adiv32 |
- | lda #$00 | + | lda #$00 |
- | bcs + | + | bcs + |
- | lda #$0C | + | lda #$0C |
* sta $0500,y | * sta $0500,y | ||
- | lda # | + | |
- | sta ObjAction, | + | sta ObjAction, |
- | lda # | + | lda # |
- | jsr SetBulletAnim | + | jsr SetBulletAnim |
- | jmp SFX_WaveFire | + | jmp SFX_WaveFire |
LD38A: | LD38A: | ||
- | bne -- | + | |
LD38E: | LD38E: | ||
- | bne Exit4 | + | |
- | lda SamusGear | + | lda SamusGear |
- | bpl Exit4 ; branch if Samus doesn' | + | bpl Exit4 ; branch if Samus doesn' |
- | lda # | + | lda # |
- | 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 | + | |
- | 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 | + | |
- | bne MoveOutDoor | + | bne MoveOutDoor |
; done moving | ; done moving | ||
- | asl | + | |
- | bcc + | + | bcc + |
- | lsr | + | lsr |
- | sta DoorStatus | + | sta DoorStatus |
- | bne +++++++ | + | bne +++++++ |
* jsr LD48C | * jsr LD48C | ||
- | 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 | + | |
* lda KraidRidleyPresent | * lda KraidRidleyPresent | ||
- | beq + | + | |
- | jsr LCC07 | + | jsr LCC07 |
- | lda #$00 | + | lda #$00 |
- | sta KraidRidleyPresent | + | sta KraidRidleyPresent |
- | beq -- ; branch always | + | beq -- |
* lda SamusDoorData | * lda SamusDoorData | ||
- | and #$0F | + | |
- | sta ObjAction | + | sta ObjAction |
- | lda #$00 | + | lda #$00 |
- | sta SamusDoorData | + | sta SamusDoorData |
- | sta DoorStatus | + | sta DoorStatus |
- | jsr StopVertMovement ;($D147) | + | jsr StopVertMovement |
MoveOutDoor: | MoveOutDoor: | ||
- | lda SamusDoorDir | + | |
- | beq ++ | + | beq ++ ; branch if door leads to the right |
- | ldy ObjectX | + | ldy ObjectX |
- | bne + | + | bne + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
* dec ObjectX | * dec ObjectX | ||
- | jmp ++ | + | |
- | * inc ObjectX | + | * |
- | bne + | + | bne + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
- | * jsr CheckHealthStatus ; | + | * |
- | jsr SetmirrorCntrlBit | + | jsr SetmirrorCntrlBit |
- | jmp DrawFrame | + | jmp DrawFrame |
SamusDead: | SamusDead: | ||
- | D41A: lda #$01 | + | D41A: |
- | jmp SetSamusData ;($CD6D)Set Samus control data and animation. | + | jmp SetSamusData |
SamusDead2: | SamusDead2: | ||
- | dec AnimDelay | + | |
- | rts | + | rts |
; SamusElevator | ; SamusElevator | ||
Line 3236: | Line 3236: | ||
SamusElevator: | SamusElevator: | ||
- | lda ElevatorStatus | + | |
- | cmp #$03 | + | cmp #$03 |
- | beq + | + | beq + |
- | cmp #$08 | + | cmp #$08 |
- | bne +++++++ | + | bne +++++++ |
* lda $032F | * lda $032F | ||
- | bmi +++ | + | |
- | lda ObjectY | + | lda ObjectY |
- | sec | + | sec |
- | sbc ScrollY | + | sbc ScrollY |
- | cmp #$84 | + | cmp #$84 |
- | bcc + ; if ScreenY < $84, don't scroll | + | bcc + ; if ScreenY < $84, don't scroll |
- | jsr ScrollDown | + | jsr ScrollDown |
* ldy ObjectY | * ldy ObjectY | ||
- | cpy #239 ; wrap-around required? | + | |
- | bne + | + | bne + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
- | ldy #$FF ; ObjectY will now be 0 | + | ldy #$FF ; ObjectY will now be 0 |
* iny | * iny | ||
- | sty ObjectY | + | |
- | jmp LD47E | + | jmp LD47E |
- | * lda ObjectY | + | * |
- | sec | + | sec |
- | sbc ScrollY | + | sbc ScrollY |
- | cmp #$64 | + | cmp #$64 |
- | bcs + ; if ScreenY >= $64, don't scroll | + | bcs + ; if ScreenY >= $64, don't scroll |
- | jsr ScrollUp | + | jsr ScrollUp |
* ldy ObjectY | * ldy ObjectY | ||
- | bne + ; wraparound required? (branch if not) | + | |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
- | ldy #240 ; ObjectY will now be 239 | + | ldy #240 ; ObjectY will now be 239 |
* dey | * dey | ||
- | sty ObjectY | + | |
- | jmp LD47E | + | jmp LD47E |
- | * ldy #$00 | + | * |
- | sty ObjVertSpeed | + | sty ObjVertSpeed |
- | cmp #$05 | + | cmp #$05 |
- | beq + | + | beq + |
- | cmp #$07 | + | cmp #$07 |
- | beq + | + | beq + |
LD47E: | LD47E: | ||
- | lsr | + | |
- | bcc ++ | + | bcc ++ |
- | * jsr SetmirrorCntrlBit ; | + | * jsr SetmirrorCntrlBit |
- | lda #$01 | + | lda #$01 |
- | jmp AnimDrawObject | + | jmp AnimDrawObject |
- | * rts | + | * |
LD48C: | LD48C: | ||
- | sec | + | |
* jsr LD4B4 | * jsr LD4B4 | ||
- | txa | + | |
- | sbc #$20 | + | sbc #$20 |
- | tax | + | tax |
- | bpl - | + | bpl - |
- | jsr GetNameTable ;($EB85) | + | jsr GetNameTable |
- | tay | + | tay |
- | ldx #$18 | + | ldx #$18 |
* jsr LD4A8 | * jsr LD4A8 | ||
- | txa | + | |
- | sec | + | sec |
- | sbc #$08 | + | sbc #$08 |
- | tax | + | tax |
- | bne - | + | bne - |
LD4A8: | LD4A8: | ||
- | cmp $072C,x | + | |
- | bne + | + | bne + |
- | lda #$FF | + | lda #$FF |
- | sta $0728,x | + | sta $0728,x |
* rts | * rts | ||
- | LD4B4: lda $0405,x | + | LD4B4: |
- | LD4B7: and #$02 | + | LD4B7: |
- | LD4B9: bne + | + | LD4B9: |
- | LD4BB: sta EnStatus, | + | LD4BB: |
- | LD4BE:* rts | + | LD4BE:* rts |
; UpdateProjectiles | ; UpdateProjectiles | ||
Line 3319: | Line 3319: | ||
UpdateProjectiles: | UpdateProjectiles: | ||
- | ldx #$D0 | + | |
jsr DoOneProjectile | jsr DoOneProjectile | ||
- | ldx #$E0 | + | |
jsr DoOneProjectile | jsr DoOneProjectile | ||
- | ldx #$F0 | + | |
DoOneProjectile: | DoOneProjectile: | ||
- | stx PageIndex | + | |
- | lda ObjAction, | + | lda ObjAction, |
- | LD4D0: jsr ChooseRoutine | + | LD4D0: |
- | LD4D3: | + | LD4D3: |
- | LD4D5: | + | LD4D5: |
- | .word UpdateWaveBullet | + | .word UpdateWaveBullet |
- | .word UpdateIceBullet | + | .word UpdateIceBullet |
- | .word BulletExplode | + | .word BulletExplode |
- | .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 | + | .word UpdateBullet |
UpdateBullet: | UpdateBullet: | ||
- | lda #$01 | + | |
- | sta UpdatingProjectile | + | sta UpdatingProjectile |
- | jsr LD5FC | + | jsr LD5FC |
- | jsr LD5DA | + | jsr LD5DA |
- | jsr LD609 | + | jsr LD609 |
CheckBulletStat: | CheckBulletStat: | ||
- | ldx PageIndex | + | |
- | bcc + | + | bcc + |
- | lda SamusGear | + | lda SamusGear |
- | and # | + | and # |
- | bne DrawBullet | + | bne DrawBullet |
- | dec $030F, | + | dec $030F, |
- | bne DrawBullet | + | bne DrawBullet |
- | lda #$00 ; timer hit 0, kill bullet | + | lda #$00 ; timer hit 0, kill bullet |
- | sta ObjAction, | + | sta ObjAction, |
- | beq DrawBullet | + | beq DrawBullet |
* lda ObjAction,x | * lda ObjAction,x | ||
- | beq + | + | |
- | jsr LD5E4 | + | jsr LD5E4 |
DrawBullet: | DrawBullet: | ||
- | lda #$01 | + | |
- | jsr AnimDrawObject | + | jsr AnimDrawObject |
* dec UpdatingProjectile | * dec UpdatingProjectile | ||
- | rts | + | |
* inc $0500,x | * inc $0500,x | ||
LD522: | LD522: | ||
- | lda #$00 | + | |
- | sta $0501,x | + | sta $0501,x |
- | beq + ; branch always | + | beq + ; branch always |
UpdateWaveBullet: | UpdateWaveBullet: | ||
- | 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 | + | |
- | cmp #$FF | + | cmp #$FF |
- | bne + | + | bne + |
- | sta $0500,x | + | sta $0500,x |
- | jmp LD522 | + | jmp LD522 |
* cmp $0501,x | * cmp $0501,x | ||
- | 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 |
- | sta ObjHorzSpeed, | + | sta ObjHorzSpeed, |
* jsr LD609 | * jsr LD609 | ||
- | bcs + | + | |
- | jsr LD624 | + | jsr LD624 |
* jmp CheckBulletStat | * jmp CheckBulletStat | ||
Table0A: | Table0A: | ||
- | .word Table0C | + | |
- | .word Table0D | + | .word Table0D |
; Table #1 (size: 25 bytes) | ; Table #1 (size: 25 bytes) | ||
Table0C: | Table0C: | ||
- | .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 $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: | + | |
- | lda #$81 | + | lda #$81 |
- | sta ObjectCntrl | + | sta ObjectCntrl |
- | jmp UpdateBullet | + | jmp UpdateBullet |
; BulletExplode | ; BulletExplode | ||
Line 3491: | Line 3491: | ||
; bullet/ | ; bullet/ | ||
- | 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, | + | sta ObjAction, |
* jmp DrawBullet | * jmp DrawBullet | ||
LD5DA: | LD5DA: | ||
- | beq Exit5 | + | |
- | lda #$00 | + | lda #$00 |
- | sta $030A,x | + | sta $030A,x |
LD5E4: | LD5E4: | ||
- | ldy ObjAction, | + | |
- | cpy # | + | cpy # |
- | beq Exit5 | + | beq Exit5 |
- | cpy # | + | cpy # |
- | bne + | + | bne + |
- | lda # | + | lda # |
* jsr SetProjectileAnim | * jsr SetProjectileAnim | ||
- | lda # | + | |
* sta ObjAction,x | * sta ObjAction,x | ||
Exit5: | Exit5: | ||
LD5FC: | LD5FC: | ||
- | lsr | + | |
- | bcs Exit5 | + | bcs Exit5 |
- | * lda #$00 | + | * |
- | beq -- ; branch always | + | beq -- |
* jmp LE81E | * jmp LE81E | ||
Line 3527: | Line 3527: | ||
LD609: | LD609: | ||
- | ldy #$00 | + | |
- | lda ($04), | + | lda ($04), |
- | 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: | LD624: | ||
- | 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: | LD638: | ||
- | 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 | + | * |
LD651: | LD651: | ||
- | cpy #$10 | + | |
- | beq + | + | beq + |
- | cmp #$70 | + | cmp #$70 |
- | bcs ++ | + | bcs ++ |
* cmp #$80 | * cmp #$80 | ||
- | * rts | + | * |
LD65E: | LD65E: | ||
- | jsr SetProjectileAnim | + | |
- | lda #$18 ; fuse length :-) | + | lda #$18 ; fuse length :-) |
- | sta $030F,x | + | sta $030F,x |
- | inc ObjAction, | + | inc ObjAction, |
- | DrawBomb: | + | DrawBomb: |
- | lda #$03 | + | lda #$03 |
- | jmp AnimDrawObject | + | jmp AnimDrawObject |
LD670: | LD670: | ||
- | lsr | + | |
- | bcc ++ | + | 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 # | + | lda # |
* jsr SetProjectileAnim | * jsr SetProjectileAnim | ||
- | inc ObjAction, | + | |
- | jsr SFX_BombExplode | + | jsr SFX_BombExplode |
- | * jmp DrawBomb | + | * |
LD691: | LD691: | ||
- | jsr LD6A7 | + | |
- | ldx PageIndex | + | ldx PageIndex |
- | lda $0303,x | + | lda $0303,x |
- | sec | + | sec |
- | sbc #$F7 | + | sbc #$F7 |
- | bne + | + | bne + |
- | sta ObjAction, | + | sta ObjAction, |
* jmp DrawBomb | * jmp DrawBomb | ||
LD6A7: | LD6A7: | ||
- | 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 | + | |
- | 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 | + | * |
Exit6: | Exit6: | ||
- | * 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 | + | |
- | 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 | + | * |
- | 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 | + | |
- | 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 | + | * |
- | 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 | + | |
- | 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: | LD76A: | ||
- | 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 | + | |
Exit7: | Exit7: | ||
LD77F: | LD77F: | ||
- | adc $0A | + | |
- | sta $04 | + | sta $04 |
- | lda $0B | + | lda $0B |
- | adc #$00 | + | adc #$00 |
- | jmp LD798 | + | jmp LD798 |
LD78B: | LD78B: | ||
- | lda $0A | + | |
- | sec | + | sec |
- | sbc $00 | + | sbc $00 |
- | sta $04 | + | sta $04 |
- | lda $0B | + | lda $0B |
- | sbc #$00 | + | sbc #$00 |
LD798: | LD798: | ||
- | 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: |
- | LD7A1: lda ObjectY,x ; | + | LD7A1: |
- | LD7A4: sta $02 ;Load and save temp copy of object y coord. | + | LD7A4: |
- | LD7A6: lda ObjectX,x ; | + | LD7A6: |
- | LD7A9: sta $03 ;Load and save temp copy of object x coord. | + | LD7A9: |
- | LD7AB: lda ObjectHi,x ; | + | LD7AB: |
- | LD7AE: sta $0B ;Load and save temp copy of object nametable. | + | LD7AE: |
- | LD7B0: jmp MakeCartRAMPtr ; | + | LD7B0: |
; | ; | ||
UpdateElevator: | UpdateElevator: | ||
- | 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 | + | |
- | .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: | + | |
- | 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 |
* and Joy1Status | * and Joy1Status | ||
- | beq ShowElevator | + | |
; start elevator! | ; start elevator! | ||
- | jsr StopVertMovement ;($D147) | + | |
- | sty AnimDelay | + | sty AnimDelay |
- | sty SamusGravity | + | sty SamusGravity |
- | tya | + | tya |
- | sta ObjVertSpeed, | + | sta ObjVertSpeed, |
- | inc ObjAction, | + | inc ObjAction, |
- | lda # | + | lda # |
- | sta ObjAction | + | sta ObjAction |
- | lda # | + | lda # |
- | jsr SetSamusAnim | + | jsr SetSamusAnim |
- | lda #128 | + | lda #128 |
- | sta ObjectX | + | sta ObjectX |
- | lda #112 | + | lda #112 |
- | sta ObjectY | + | sta ObjectY |
- | ShowElevator: | + | ShowElevator: |
- | lda FrameCount | + | lda FrameCount |
- | lsr | + | lsr |
- | bcc -- | + | bcc -- ; only display elevator at odd frames |
- | jmp DrawFrame | + | jmp DrawFrame |
LD80E: | LD80E: | ||
- | 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 | + | |
- | 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 | + | |
- | ElevatorMove: | + | |
- | lda $030F,x | + | lda $030F,x |
- | bpl ++ | + | bpl ++ ; branch if elevator going down |
; move elevator up one pixel | ; move elevator up one pixel | ||
- | ldy ObjectY,x | + | |
- | bne + | + | bne + |
- | jsr ToggleObjectHi | + | jsr ToggleObjectHi |
- | ldy #240 | + | ldy #240 |
* dey | * dey | ||
- | tya | + | |
- | sta ObjectY,x | + | sta ObjectY,x |
- | jmp ++ | + | jmp ++ |
; move elevator down one pixel | ; move elevator down one pixel | ||
- | * 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 | + | * |
- | bne + ; move until Y coord = $83 | + | bne + ; move until Y coord = $83 |
- | inc ObjAction,x | + | inc ObjAction,x |
* jmp ShowElevator | * jmp ShowElevator | ||
- | ElevatorScroll: | + | |
- | lda ScrollY | + | lda ScrollY |
- | bne ElevScrollRoom | + | bne ElevScrollRoom |
- | 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: | + | |
- | 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 | + | |
LD8A3: | LD8A3: | ||
- | lda ObjAction, | + | |
- | cmp #$08 ; ElevatorMove | + | cmp #$08 ; ElevatorMove |
- | bne + | + | bne + |
- | lda #$23 | + | lda #$23 |
- | sta $0303,x | + | sta $0303,x |
- | lda # | + | lda # |
- | jsr SetSamusAnim | + | jsr SetSamusAnim |
- | jmp ShowElevator | + | jmp ShowElevator |
* lda #$01 | * lda #$01 | ||
- | jmp AnimDrawObject | + | |
LD8BF: | LD8BF: | ||
- | 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 | + | |
- | sta MainRoutine | + | sta MainRoutine |
- | inc AtEnding | + | inc AtEnding |
- | ldy #$00 | + | ldy #$00 |
- | sty $33 | + | sty $33 |
- | iny | + | iny |
- | sty SwitchPending | + | sty SwitchPending |
- | lda #$1D ; ending | + | lda #$1D ; ending |
- | sta TitleRoutine | + | sta TitleRoutine |
- | rts | + | rts |
* tya | * tya | ||
- | bpl ++ | + | |
- | ldy #$00 | + | ldy #$00 |
- | cmp #$84 | + | cmp #$84 |
- | bne + | + | bne + |
- | iny | + | iny |
* tya | * tya | ||
- | * 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 SelectSamusPal | + | jsr SelectSamusPal |
- | jsr StartMusic ; | + | jsr StartMusic |
- | 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: |
- | cmp #$06 | + | cmp #$06 |
- | bne + | + | bne + |
- | lda $032F | + | lda $032F |
- | bmi ++ | + | bmi ++ |
- | * lda $95CD ;Load proper bit flag for area music. | + | * lda $95CD |
- | ldy ItemRoomMusicStatus | + | ldy ItemRoomMusicStatus |
- | bmi ++ | + | bmi ++ |
- | beq ++ | + | beq ++ |
- | * 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 ; | + | * |
- | sta MusicInitFlag ;Store music flag info. | + | sta MusicInitFlag |
- | rts ; | + | rts |
ElevatorStop: | ElevatorStop: | ||
- | lda ScrollY | + | |
- | bne ++ | + | bne ++ ; scroll until ScrollY = 0 |
- | lda #sa_Stand | + | lda #sa_Stand |
- | sta ObjAction | + | sta ObjAction |
- | jsr LCF55 | + | jsr LCF55 |
- | ldx PageIndex | + | ldx PageIndex |
- | 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 | + | * |
SamusOnElevatorOrEnemy: | SamusOnElevatorOrEnemy: | ||
- | LD976: | + | LD976: |
- | sta SamusOnElevator ;Assume Samus is not on an elevator or on a frozen enemy. | + | sta SamusOnElevator |
- | sta OnFrozenEnemy ; | + | sta OnFrozenEnemy |
- | tay | + | tay |
- | ldx #$50 | + | ldx #$50 |
- | jsr LF186 | + | jsr LF186 |
* lda EnStatus,x | * lda EnStatus,x | ||
- | 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: |
- | bne ++ | + | bne ++ |
* jsr Xminus16 | * jsr Xminus16 | ||
- | bpl -- | + | |
- | * 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 |
* rts | * rts | ||
LD9BA: | LD9BA: | ||
- | and #$02 | + | |
- | bne + | + | bne + |
- | ldy $11 | + | ldy $11 |
- | iny | + | iny |
- | cpy $04 | + | cpy $04 |
- | beq Exit8 | + | beq Exit8 |
* lda SamusHit | * lda SamusHit | ||
- | and #$38 | + | |
- | ora $10 | + | ora $10 |
- | ora #$40 | + | ora #$40 |
- | sta SamusHit | + | sta SamusHit |
Exit8: | Exit8: | ||
Line 4022: | Line 4022: | ||
; ============= | ; ============= | ||
- | 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 | + | |
- | bne +++ | + | bne +++ |
- | lda KraidStatueStatus | + | lda KraidStatueStatus |
- | bpl + | + | bpl + |
- | ldy #$02 | + | ldy #$02 |
- | jsr LDAB0 | + | jsr LDAB0 |
* lda $687C | * lda $687C | ||
- | bpl + | + | |
- | ldy #$03 | + | ldy #$03 |
- | jsr LDAB0 | + | jsr LDAB0 |
* bcs + | * bcs + | ||
- | inc $0360 | + | |
- | * ldx #$60 | + | * |
- | jsr LDA1A | + | jsr LDA1A |
- | ldx #$61 | + | ldx #$61 |
- | jsr LDA1A | + | jsr LDA1A |
- | jmp LDADA | + | jmp LDADA |
LDA1A: | LDA1A: | ||
- | 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 ++ | + | bcc ++ ; only display statue at odd frames |
* jmp DrawFrame | * jmp DrawFrame | ||
LDA39: | LDA39: | ||
- | .byte $68 | + | |
LDA3B: | LDA3B: | ||
- | .byte $66 | + | |
LDA3D: | LDA3D: | ||
- | 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 | + | * |
LDA7C: | LDA7C: | ||
- | 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 | + | |
- | rts | + | rts |
LDAB0: | LDAB0: | ||
- | 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 $AC | + | .byte $AC |
- | .byte $F0 | + | .byte $F0 |
- | .byte $6C | + | .byte $6C |
Table1B: | Table1B: | ||
- | .byte $61 | + | |
- | .byte $60 | + | .byte $60 |
- | .byte $60 | + | .byte $60 |
- | .byte $60 | + | .byte $60 |
LDADA: | LDADA: | ||
- | 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 | + | |
- | 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: | Exit0: | ||
Line 4193: | Line 4193: | ||
CheckMissileToggle: | CheckMissileToggle: | ||
- | 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: | + | LDB2F: |
- | LDB30: lda #$00 | + | LDB30: |
- | LDB32: | + | LDB32:* rol |
- | LDB33: | + | LDB33: |
- | LDB34: bpl - | + | LDB34: |
- | LDB36:* rts | + | LDB36:* rts |
; | ; | ||
UpdateItems: | UpdateItems: | ||
- | LDB37: lda #$40 ;PowerUp RAM starts at $0340. | + | LDB37: |
- | LDB39: sta PageIndex ; | + | LDB39: |
- | LDB3B: ldx #$00 ;Check first item slot. | + | LDB3B: |
- | LDB3D: jsr CheckOneItem ; | + | LDB3D: |
- | LDB40: ldx #$08 ;Check second item slot. | + | LDB40: |
CheckOneItem: | CheckOneItem: | ||
- | LDB42: stx ItemIndex ;First or second item slot index(#$00 or #$08). | + | LDB42: |
- | LDB44: ldy PowerUpType, | + | LDB44: |
- | LDB47: iny ;Is no item present in item slot(# | + | LDB47: |
- | LDB48: beq - ;If so, branch to exit. | + | LDB48: |
- | LDB4A: lda PowerUpYCoord, | + | LDB4A: |
- | LDB4D: sta PowerUpY ; | + | LDB4D: |
- | LDB50: lda PowerUpXCoord, | + | LDB50: |
- | LDB53: sta PowerUpX ; | + | LDB53: |
- | LDB56: lda PowerUpNameTable, | + | LDB56: |
- | LDB59: sta PowerUpHi ; | + | LDB59: |
- | LDB5C: jsr GetObjCoords ; | + | LDB5C: |
- | LDB5F: ldx ItemIndex ;Index to proper power up item. | + | LDB5F: |
- | LDB61: ldy #$00 ;Reset index. | + | LDB61: |
- | LDB63: lda ($04),y ;Load pointer into room RAM. | + | LDB63: |
- | LDB65: cmp #$A0 ;Is object being placed on top of a solid tile? | + | LDB65: |
- | LDB67: bcc - ;If so, branch to exit. | + | LDB67: |
- | LDB69: lda PowerUpType, | + | LDB69: |
- | LDB6C: and #$0F ;Load power up type byte and keep only bits 0 thru 3. | + | LDB6C: |
- | LDB6E: ora #$50 ;Set bits 4 and 6. | + | LDB6E: |
- | LDB70: sta PowerUpAnimFrame ;Save index to find object animation. | + | LDB70: |
- | LDB73: lda FrameCount ; | + | LDB73: |
- | LDB75: lsr ;Color affected every other frame. | + | LDB75: |
- | LDB76: and #$03 ;the 2 LSBs of object control byte change palette of object. | + | LDB76: |
- | LDB78: ora #$80 ;Indicate ObjectCntrl contains valid data by setting MSB. | + | LDB78: |
- | LDB7A: sta ObjectCntrl ;Change color of item every other frame. | + | LDB7A: |
- | LDB7C: lda SpritePagePos ;Load current index into sprite RAM. | + | LDB7C: |
- | LDB7E: pha ;Temp save sprite RAM position. | + | LDB7E: |
- | LDB7F: lda PowerUpAnimIndex, | + | LDB7F: |
- | LDB82: jsr DrawFrame ; | + | LDB82: |
- | LDB85: pla ;Restore sprite page position byte. | + | LDB85: |
- | LDB86: cmp SpritePagePos ;Was power up item successfully drawn? | + | LDB86: |
- | LDB88: beq Exit9 ;If not, branch to exit. | + | LDB88: |
- | LDB8A: tax ;Store sprite page position in x. | + | LDB8A: |
- | LDB8B: ldy ItemIndex ;Load index to proper power up data slot. | + | LDB8B: |
- | LDB8D: lda PowerUpType, | + | LDB8D: |
- | LDB90: ldy #$01 ;Set power up color for ice beam orb. | + | LDB90: |
- | LDB92: cmp #$07 ;Is power up item the ice beam? | + | LDB92: |
- | LDB94: beq + ;If so, branch. | + | LDB94: |
- | LDB96: dey ;Set power up color for long/wave beam orb. | + | LDB96: |
- | LDB97: cmp #$06 ;Is power up item the wave beam? | + | LDB97: |
- | LDB99: beq + ;If so, branch. | + | LDB99: |
- | LDB9B: cmp #$02 ;Is power up item the long beam? | + | LDB9B: |
- | LDB9D: bne ++ ;If not, branch. | + | LDB9D: |
- | LDB9F: | + | LDB9F:* tya |
- | LDBA0: sta Sprite01RAM+2, | + | LDBA0: |
- | LDBA3: lda #$FF ;Indicate power up obtained is a beam weapon. | + | LDBA3: |
- | LDBA5: | + | LDBA5:* pha |
- | LDBA6: ldx #$00 ;Index to object 0(Samus). | + | LDBA6: |
- | LDBA8: ldy #$40 ;Index to object 1(power up). | + | LDBA8: |
- | LDBAA: jsr AreObjectsTouching ; | + | LDBAA: |
- | LDBAD: pla ;Restore power up type byte. | + | LDBAD: |
- | LDBAE: bcs Exit9 ;Carry clear=Samus touching power up. Carry set=not touching. | + | LDBAE: |
- | LDBB0: tay ;Store power-up type byte in Y. | + | LDBB0: |
- | LDBB1: jsr PowerUpMusic ; | + | LDBB1: |
- | LDBB4: ldx ItemIndex ;X=index to power up item slot. | + | LDBB4: |
- | LDBB6: iny ;Is item obtained a beam weapon? | + | LDBB6: |
- | LDBB7: beq + ;If so, branch. | + | LDBB7: |
- | LDBB9: lda PowerUpNameTable, | + | LDBB9: |
- | LDBBC: sta $08 ;Temp storage of nametable and power-up type in $08--> | + | LDBBC: |
- | LDBBE: lda PowerUpType, | + | LDBBE: |
- | LDBC1: sta $09 ; | + | LDBC1: |
- | LDBC3: jsr GetItemXYPos ;($DC1C)Get proper X and Y coords of item, save in history. | + | LDBC3: |
- | LDBC6:* lda PowerUpType, | + | LDBC6:* lda PowerUpType, |
- | LDBC9: tay ; | + | LDBC9: |
- | LDBCA: cpy #$08 ;Is power-up item a missile or energy tank? | + | LDBCA: |
- | LDBCC: bcs ++++ ;If so, branch. | + | LDBCC: |
- | LDBCE: cpy #$06 ;Is item the wave beam or ice beam? | + | LDBCE: |
- | LDBD0: bcc + ;If not, branch. | + | LDBD0: |
- | LDBD2: lda SamusGear ;Clear status of wave beam and ice beam power ups. | + | LDBD2: |
- | LDBD5: and #$3F ; | + | LDBD5: |
- | LDBD7: sta SamusGear ;Remove beam weapon data from Samus gear byte. | + | LDBD7: |
- | LDBDA:* jsr MakeBitMask ; | + | LDBDA:* jsr MakeBitMask |
- | LDBDD: ora SamusGear ; | + | LDBDD: |
- | LDBE0: sta SamusGear ;Update Samus gear with new beam weapon. | + | LDBE0: |
- | LDBE3:* lda #$FF ; | + | LDBE3:* lda #$FF ; |
- | LDBE5: sta PowerUpDelay ;Initiate delay while power up music plays. | + | LDBE5: |
- | LDBE8: sta PowerUpType, | + | LDBE8: |
- | LDBEB: ldy ItemRoomMusicStatus ;Is Samus not in an item room? | + | LDBEB: |
- | LDBED: beq + ;If not, branch. | + | LDBED: |
- | LDBEF: ldy #$01 ;Restart item room music after special item music is done. | + | LDBEF: |
- | LDBF1:* sty ItemRoomMusicStatus ; | + | LDBF1:* sty ItemRoomMusicStatus |
- | LDBF3: jmp SelectSamusPal ;($CB73)Set Samus new palette. | + | LDBF3: |
Exit9: | Exit9: | ||
- | LDBF6: rts ;Exit for multiple routines above. | + | LDBF6: |
MissileEnergyPickup: | MissileEnergyPickup: | ||
- | LDBF7:* beq + ;Branch if item is an energy tank. | + | LDBF7:* beq + |
- | LDBF9: lda #$05 ; | + | LDBF9: |
- | LDBFB: jsr AddToMaxMissiles ; | + | LDBFB: |
- | LDBFE: bne --- ;Branch always. | + | LDBFE: |
- | LDC00:* lda TankCount ; | + | LDC00:* lda TankCount |
- | LDC03: cmp #$06 ;Has Samus got 6 energy tanks? | + | LDC03: |
- | LDC05: beq + ;If so, she can't have any more.--> | + | LDC05: |
- | LDC07: inc TankCount ;Otherwise give her a new tank. | + | LDC07: |
- | LDC0A:* lda TankCount ; | + | LDC0A:* lda TankCount |
- | LDC0D: jsr Amul16 ;Get tank count and shift into upper nibble. | + | LDC0D: |
- | LDC10: ora #$09 ; | + | LDC10: |
- | LDC12: sta HealthHi ;Set new tank count. Upper health digit set to 9. | + | LDC12: |
- | LDC15: lda #$99 ;Max out low health digit. | + | LDC15: |
- | LDC17: sta HealthLo ;Health is now FULL! | + | LDC17: |
- | LDC1A: bne ----- ;Branch always. | + | LDC1A: |
;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: | + | LDC1C: |
- | LDC1E: sta $07 ;Temp storage of Samus map position x and y in $07--> | + | LDC1E: |
- | LDC20: lda MapPosY ;and $06 respectively. | + | LDC20: |
- | LDC22: sta $06 ; | + | LDC22: |
- | LDC24: lda ScrollDir ;Load scroll direction and shift LSB into carry bit. | + | LDC24: |
- | LDC26: lsr ; | + | LDC26: |
- | LDC27: php ;Temp storage of processor status. | + | LDC27: |
- | LDC28: beq + ;Branch if scrolling up/down. | + | LDC28: |
- | LDC2A: bcc ++ ;Branch if scrolling right. | + | LDC2A: |
;Scrolling left. | ;Scrolling left. | ||
- | LDC2C: lda ScrollX ;Unless the scroll x offset is 0, the actual room x pos--> | + | LDC2C: |
- | LDC2E: beq ++ ;needs to be decremented in order to be correct. | + | LDC2E: |
- | LDC30: dec $07 ; | + | LDC30: |
- | LDC32: bcs ++ ;Branch always. | + | LDC32: |
- | LDC34:* bcc + ;Branch if scrolling up. | + | LDC34:* bcc + |
;Scrolling down. | ;Scrolling down. | ||
- | LDC36: lda ScrollY ;Unless the scroll y offset is 0, the actual room y pos--> | + | LDC36: |
- | LDC38: beq + ;needs to be decremented in order to be correct. | + | LDC38: |
- | LDC3A: dec $06 ; | + | LDC3A: |
- | LDC3C:* lda PPUCNT0ZP ;If item is on the same nametable as current nametable, | + | LDC3C:* lda PPUCNT0ZP |
- | LDC3E: eor $08 ;then no further adjustment to item x and y position needed. | + | LDC3E: |
- | LDC40: and #$01 ; | + | LDC40: |
- | LDC42: plp ;Restore the processor status and clear the carry bit. | + | LDC42: |
- | LDC43: clc ; | + | LDC43: |
- | LDC44: beq + ;If Scrolling up/down, branch to adjust item y position. | + | LDC44: |
- | LDC46: adc $07 ;Scrolling left/right. Make any necessary adjustments to--> | + | LDC46: |
- | LDC48: sta $07 ;item x position before writing to unique item history. | + | LDC48: |
- | LDC4A: jmp AddItemToHistory ;($DC51)Add unique item to unique item history. | + | LDC4A: |
- | LDC4D:* adc $06 ;Scrolling up/down. Make any necessary adjustments to--> | + | LDC4D:* adc $06 |
- | LDC4F: sta $06 ;item y position before writing to unique item history. | + | LDC4F: |
AddItemToHistory: | AddItemToHistory: | ||
- | LDC51: | + | LDC51: |
- | LDC54: | + | LDC54: |
- | LDC57: lda $06 ; | + | LDC57: |
- | LDC59: sta UniqueItemHistory, | + | LDC59: |
- | LDC5C: lda $07 ; | + | LDC5C: |
- | LDC5E: sta UniqueItemHistory+1, | + | LDC5E: |
- | LDC61: iny ;Add 2 to Y. 2 bytes ber unique item. | + | LDC61: |
- | LDC62: iny ; | + | LDC62: |
- | LDC63: sty NumberOfUniqueItems ;Store new number of unique items. | + | LDC63: |
- | LDC66: rts ; | + | LDC66: |
; | ; | ||
Line 4418: | Line 4418: | ||
CreateItemID: | CreateItemID: | ||
- | LDC67: lda $07 ;Load x map position of item. | + | LDC67: |
- | LDC69: jsr Amul32 ; | + | LDC69: |
- | LDC6C: ora $06 ;combine Y coordinates into data byte. | + | LDC6C: |
- | LDC6E: sta $06 ;Lower data byte complete. Save in $06. | + | LDC6E: |
- | LDC70: lsr $07 ; | + | LDC70: |
- | LDC72: lsr $07 ;Move upper two bits of X coordinate to LSBs. | + | LDC72: |
- | LDC74: lsr $07 ; | + | LDC74: |
- | LDC76: lda $09 ;Load item type bits. | + | LDC76: |
- | LDC78: asl ;Move the 6 bits of item type to upper 6 bits of byte. | + | LDC78: |
- | LDC79: asl ; | + | LDC79: |
- | LDC7A: ora $07 ;Add upper two bits of X coordinate to byte. | + | LDC7A: |
- | LDC7C: sta $07 ;Upper data byte complete. Save in #$06. | + | LDC7C: |
- | LDC7E: rts ; | + | LDC7E: |
; | ; | ||
Line 4437: | Line 4437: | ||
LDC7F: | LDC7F: | ||
LDC82: | LDC82: | ||
- | LDC85: jsr LF1A7 | + | LDC85: |
- | LDC88: jmp LF1FA | + | LDC88: |
;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: | + | LDC8B: |
- | LDC8C: | + | LDC8C: |
- | LDC8D: | + | LDC8D: |
- | LDC8E: | + | LDC8E: |
; UpdateObjAnim | ; UpdateObjAnim | ||
Line 4453: | Line 4453: | ||
UpdateObjAnim: | UpdateObjAnim: | ||
- | LDC8F: ldx PageIndex | + | LDC8F: |
- | 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, | + | dec AnimDelay, |
- | bne +++ ; exit if still not zero (don't update animation) | + | bne +++ ; exit if still not zero (don't update animation) |
* sta AnimDelay, | * sta AnimDelay, | ||
- | ldy AnimIndex, | + | |
- | * lda ObjectAnimIndexTbl, | + | * lda ObjectAnimIndexTbl, |
- | cmp #$FF ; has end of anim been reached? | + | cmp #$FF ; has end of anim been reached? |
- | beq ++ | + | beq ++ |
- | sta AnimFrame, | + | sta AnimFrame, |
- | iny ; inc anim index | + | iny ; inc anim index |
- | tya | + | tya |
- | sta AnimIndex, | + | sta AnimIndex, |
- | * rts | + | * |
* ldy AnimResetIndex, | * ldy AnimResetIndex, | ||
- | jmp --- ; do first frame of animation | + | |
LDCB7: | LDCB7: | ||
- | lda #$00 | + | |
- | sta $06 | + | sta $06 |
- | pla | + | pla |
- | bpl + | + | bpl + |
- | dec $06 | + | dec $06 |
* clc | * clc | ||
- | rts | + | |
; | ; | ||
Line 4489: | Line 4489: | ||
GetSpriteCntrlData: | GetSpriteCntrlData: | ||
- | LDCC3: | + | LDCC3: |
- | LDCC5: sty $0F ;Clear index into placement data. | + | LDCC5: |
- | LDCC7: lda ($00),y ;Load control byte from frame pointer data. | + | LDCC7: |
- | LDCC9: sta $04 ;Store value in $04 for processing below. | + | LDCC9: |
- | LDCCB: tax ;Keep a copy of the value in x as well. | + | LDCCB: |
- | LDCCC: jsr Adiv16 ; | + | LDCCC: |
- | LDCCF: and #$03 ; | + | LDCCF: |
- | LDCD1: sta $05 ;The following lines take the upper 4 bits in the--> | + | LDCD1: |
- | LDCD3: txa ;control byte and transfer bits 4 and 5 into $05 bits 0--> | + | LDCD3: |
- | LDCD4: and #$C0 ;and 1(sprite color bits). | + | LDCD4: |
- | LDCD6: ora #$20 ; | + | LDCD6: |
- | LDCD8: ora $05 ;bit 5 is then set(sprite always drawn behind background). | + | LDCD8: |
- | LDCDA: sta $05 ; | + | LDCDA: |
- | LDCDC: lda ObjectCntrl ;Extract bit from control byte that controls the | + | LDCDC: |
- | LDCDE: and #$10 ;object mirroring. | + | LDCDE: |
- | LDCE0: asl ; | + | LDCE0: |
- | LDCE1: asl ; | + | LDCE1: |
- | LDCE2: eor $04 ;Move it to the bit 6 position and use it to flip the--> | + | LDCE2: |
- | LDCE4: sta $04 ;horizontal mirroring of the sprite if set. | + | LDCE4: |
- | LDCE6: lda ObjectCntrl ; | + | LDCE6: |
- | LDCE8: bpl + ;If MSB is set in ObjectCntrl, | + | LDCE8: |
- | LDCEA: asl ObjectCntrl ; | + | LDCEA: |
- | LDCEC: jsr SpriteFlipBitsOveride ; | + | LDCEC: |
- | LDCEF: | + | LDCEF:* txa |
- | LDCF0: and #$0F ; | + | LDCF0: |
- | LDCF2: asl ;*2. pointers in PlacePntrTbl are 2 bytes in size. | + | LDCF2: |
- | LDCF3: tax ;Transfer to X to use as an index to find proper--> | + | LDCF3: |
- | LDCF4: rts ;placement data segment. | + | LDCF4: |
; | ; | ||
- | LDCF5: | + | LDCF5: |
- | pla | + | pla |
- | pla | + | pla |
- | ldx PageIndex | + | ldx PageIndex |
LDCFC: | LDCFC: | ||
- | 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 | + | |
- | 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 | + | * |
- | 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 | + | |
- | beq LDD5B | + | beq LDD5B |
- | inc CurrentEnergyPickups | + | inc CurrentEnergyPickups |
- | cmp #$89 | + | cmp #$89 |
- | bne -- | + | bne -- |
- | lsr $00 | + | lsr $00 |
- | bcs -- | + | bcs -- |
LDD5B: | LDD5B: | ||
- | lda InArea | + | |
- | cmp #$13 | + | cmp #$13 |
- | beq ++ | + | beq ++ |
- | * jmp KillObject ; | + | * |
* lda RandomNumber1 | * lda RandomNumber1 | ||
- | ldy #$00 | + | |
- | sty CurrentEnergyPickups | + | sty CurrentEnergyPickups |
- | sty CurrentMissilePickups | + | sty CurrentMissilePickups |
- | iny | + | iny |
- | sty MaxMissilePickup | + | sty MaxMissilePickup |
- | sty MaxEnergyPickup | + | sty MaxEnergyPickup |
- | bne ----- | + | bne ----- |
LDD75: | LDD75: | ||
- | 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: | LDD8B: | ||
- | lda EnAnimFrame, | + | |
- | cmp #$F7 | + | cmp #$F7 |
- | bne +++ | + | bne +++ |
- | jmp ClearObjectCntrl ; | + | jmp ClearObjectCntrl |
; AddToMaxMissiles | ; AddToMaxMissiles | ||
Line 4608: | Line 4608: | ||
AddToMaxMissiles: | AddToMaxMissiles: | ||
- | 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 | + | |
- | clc | + | clc |
- | adc MaxMissiles | + | adc MaxMissiles |
- | bcc + | + | bcc + |
- | lda #$FF | + | lda #$FF |
* sta MaxMissiles | * sta MaxMissiles | ||
- | rts | + | |
- | * 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 | + | |
- | 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. | + | |
- | 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 | + | |
- | lda ($00),y | + | lda ($00),y |
- | sta EnRadY,x | + | sta EnRadY,x |
- | jsr ReduceYRadius ; | + | jsr ReduceYRadius |
- | 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 ; | + | jsr IsObjectVisible |
- | 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 |
; | ; | ||
Line 4694: | Line 4694: | ||
ItemDropTbl: | ItemDropTbl: | ||
- | LDE35: | + | LDE35: |
- | LDE36: | + | LDE36: |
- | LDE37: | + | LDE37: |
- | LDE38: | + | LDE38: |
- | LDE39: | + | LDE39: |
- | LDE3A: | + | LDE3A: |
- | LDE3B: | + | LDE3B: |
- | LDE3C: | + | LDE3C: |
; | ; | ||
Line 4709: | Line 4709: | ||
ReduceYRadius: | ReduceYRadius: | ||
- | LDE3D: sec ; | + | LDE3D: |
- | LDE3E: sbc #$10 ;Subtract #$10 from object y radius. | + | LDE3E: |
- | LDE40: bcs + ;If number is still a positive number, branch to store value. | + | LDE40: |
- | LDE42: lda #$00 ;Number is negative. | + | LDE42: |
- | LDE44:* sta $08 ;Store result and return. | + | LDE44:* sta $08 |
- | LDE46: rts ; | + | LDE46: |
AnimDrawObject: | AnimDrawObject: | ||
- | LDE47: jsr UpdateObjAnim ; | + | LDE47: |
DrawFrame: | DrawFrame: | ||
- | LDE4A: ldx PageIndex ;Get index to proper object to work with. | + | LDE4A: |
- | LDE4C: lda AnimFrame, | + | LDE4C: |
- | LDE4F: cmp #$F7 ;Is the frame valid? | + | LDE4F: |
- | LDE51: bne ++ ;Branch if yes. | + | LDE51: |
- | LDE53:* jmp ClearObjectCntrl ; | + | LDE53:* jmp ClearObjectCntrl |
- | 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: |
- | LDE5A: lda ObjectCntrl ;Ensure object mirroring bit is clear so Samus' | + | LDE5A: |
- | LDE5C: and #$EF ;sprite appears properly when going up and down--> | + | LDE5C: |
- | LDE5E: sta ObjectCntrl ;elevators. | + | LDE5E: |
- | LDE60:* lda ObjectY,x ; | + | LDE60:* lda ObjectY, |
- | LDE63: sta $0A ; | + | LDE63: |
- | LDE65: lda ObjectX,x ;Copy object y and x room position and name table--> | + | LDE65: |
- | LDE68: sta $0B ;data into $0A, $0B and $06 respectively. | + | LDE68: |
- | LDE6A: lda ObjectHi,x ; | + | LDE6A: |
- | LDE6D: sta $06 ; | + | LDE6D: |
- | LDE6F: lda AnimFrame, | + | LDE6F: |
- | LDE72: asl ;*2. Frame pointers are two bytes. | + | LDE72: |
- | LDE73: tax ;X is now the index into the FramePtrTable. | + | LDE73: |
- | LDE74: lda FramePtrTable, | + | LDE74: |
- | LDE77: sta $00 ; | + | LDE77: |
- | LDE79: lda FramePtrTable+1, | + | LDE79: |
- | LDE7C: sta $01 ; | + | LDE7C: |
- | LDE7E: jsr GetSpriteCntrlData ;($DCC3)Get place pointer index and sprite control data. | + | LDE7E: |
- | LDE81: lda PlacePtrTable, | + | LDE81: |
- | LDE84: sta $02 ; | + | LDE84: |
- | LDE86: lda PlacePtrTable+1, | + | LDE86: |
- | LDE89: sta $03 ; | + | LDE89: |
- | LDE8B: lda IsSamus ;Is Samus the object being drawn? | + | LDE8B: |
- | LDE8D: beq + ;If not, branch. | + | LDE8D: |
;Special case for Samus exploding. | ;Special case for Samus exploding. | ||
- | LDE8F: cpx #$0E ;Is Samus exploding? | + | LDE8F: |
- | LDE91: bne + ;If not, branch to skip this section of code. | + | LDE91: |
- | LDE93: ldx PageIndex ;X=0. | + | LDE93: |
- | LDE95: inc ObjectCounter ; | + | LDE95: |
- | LDE97: lda ObjectCounter ;Bottom two bits used for index into ExplodeRotationTbl. | + | LDE97: |
- | LDE99: pha ;Save value of A. | + | LDE99: |
- | LDE9A: and #$03 ;Use 2 LSBs for index into ExplodeRotationTbl. | + | LDE9A: |
- | LDE9C: tax ; | + | LDE9C: |
- | LDE9D: lda $05 ;Drop mirror control bits from sprite control byte. | + | LDE9D: |
- | LDE9F: and #$3F ; | + | LDE9F: |
- | LDEA1: ora ExplodeRotationTbl, | + | LDEA1: |
- | LDEA4: sta $05 ;Save modified sprite control byte. | + | LDEA4: |
- | LDEA6: pla ;Restore A | + | LDEA6: |
- | LDEA7: cmp #$19 ;After 25 frames, Move on to second part of death--> | + | LDEA7: |
- | LDEA9: bne + ;handler, else branch to skip the rest of this code. | + | LDEA9: |
- | LDEAB: ldx PageIndex ;X=0. | + | LDEAB: |
- | LDEAD: lda #sa_Dead2 ; | + | LDEAD: |
- | LDEAF: sta ObjAction, | + | LDEAF: |
- | LDEB2: lda #$28 ; | + | LDEB2: |
- | LDEB4: sta AnimDelay, | + | LDEB4: |
- | LDEB7: pla ;Pull last return address off of the stack. | + | LDEB7: |
- | LDEB8: pla ; | + | LDEB8: |
- | LDEB9: jmp ClearObjectCntrl ; | + | LDEB9: |
- | LDEBC:* ldx PageIndex ; | + | LDEBC:* ldx PageIndex |
- | LDEBE: iny ;Increment to second frame data byte. | + | LDEBE: |
- | LDEBF: lda ($00),y ; | + | LDEBF: |
- | LDEC1: sta ObjRadY,x ;Get verticle radius in pixles of object. | + | LDEC1: |
- | LDEC3: jsr ReduceYRadius ; | + | LDEC3: |
- | LDEC6: iny ;Increment to third frame data byte. | + | LDEC6: |
- | LDEC7: lda ($00),y ;Get horizontal radius in pixels of object. | + | LDEC7: |
- | LDEC9: sta ObjRadX,x ; | + | LDEC9: |
- | LDECB: sta $09 ;Temp storage for object x radius. | + | LDECB: |
- | LDECD: iny ;Set index to 4th byte of frame data. | + | LDECD: |
- | LDECE: sty $11 ;Store current index into frame data. | + | LDECE: |
- | LDED0: jsr IsObjectVisible ; | + | LDED0: |
- | LDED3: txa ; | + | LDED3: |
- | LDED4: ldx PageIndex ;Get index to object. | + | LDED4: |
- | LDED6: sta ObjectOnScreen, | + | LDED6: |
- | LDEDB: tax ; | + | LDEDB: |
- | LDEDC: beq + ;Branch if object is not within the screen boundaries. | + | LDEDC: |
- | LDEDE: | + | LDEDE: |
- | LDEE0: jmp DrawSpriteObject ; | + | LDEE0: |
- | LDEE3:* jmp ClearObjectCntrl ; | + | LDEE3:* jmp ClearObjectCntrl |
WriteSpriteRAM: | WriteSpriteRAM: | ||
- | LDEE6:* ldy $0F ;Load index for placement data. | + | LDEE6:* ldy $0F |
- | LDEE8: jsr YDisplacement ;($DF6B)Get displacement for y direction. | + | LDEE8: |
- | LDEEB: adc $10 ;Add initial Y position. | + | LDEEB: |
- | LDEED: sta Sprite00RAM, | + | LDEED: |
- | LDEF0: dec Sprite00RAM, | + | LDEF0: |
- | LDEF3: inc $0F ;Increment index to next byte of placement data. | + | LDEF3: |
- | LDEF5: ldy $11 ;Get index to frame data. | + | LDEF5: |
- | LDEF7: lda ($00),y ;Tile value. | + | LDEF7: |
- | LDEF9: sta Sprite00RAM+1, | + | LDEF9: |
- | LDEFC: lda ObjectCntrl ; | + | LDEFC: |
- | LDEFE: asl ;Move horizontal mirror control byte to bit 6 and--> | + | LDEFE: |
- | LDEFF: asl ;discard all other bits. | + | LDEFF: |
- | LDF00: and #$40 ; | + | LDF00: |
- | LDF02: eor $05 ;Use it to override sprite horz mirror bit. | + | LDF02: |
- | LDF04: sta Sprite00RAM+2, | + | LDF04: |
- | LDF07: inc $11 ;Increment to next byte of frame data. | + | LDF07: |
- | LDF09: ldy $0F ;Load index for placement data. | + | LDF09: |
- | LDF0B: jsr XDisplacement ;($DFA3)Get displacement for x direction. | + | LDF0B: |
- | LDF0E: adc $0E ;Add initial X pos | + | LDF0E: |
- | LDF10: sta Sprite00RAM+3, | + | LDF10: |
- | LDF13: inc $0F ;Increment to next placement data byte. | + | LDF13: |
- | LDF15: inx ; | + | LDF15: |
- | LDF16: inx ; | + | LDF16: |
- | LDF17: inx ;Advance to next sprite. | + | LDF17: |
- | LDF18: inx ; | + | LDF18: |
DrawSpriteObject: | DrawSpriteObject: | ||
- | LDF19: | + | LDF19: |
GetNextFrameByte: | GetNextFrameByte: | ||
- | LDF1B: | + | LDF1B: |
- | LDF1D: cmp #$FC ;If byte < #$FC, byte is tile data. If >= #$FC, byte is--> | + | LDF1D: |
- | LDF1F: bcc WriteSpriteRAM ;frame data control info. Branch to draw sprite. | + | LDF1F: |
- | LDF21: beq OffsetObjectPosition ;# | + | LDF21: |
- | LDF23: cmp #$FD ; | + | LDF23: |
- | LDF25: beq GetNewControlByte ;#$FD sets new control byte information for the next sprites. | + | LDF25: |
- | LDF27: cmp #$FE ;#$FE skips next sprite placement x and y bytes. | + | LDF27: |
- | LDF29: beq SkipPlacementData ; | + | LDF29: |
- | LDF2B: stx SpritePagePos ;Keep track of current position in sprite RAM. | + | LDF2B: |
ClearObjectCntrl: | ClearObjectCntrl: | ||
- | LDF2D: | + | LDF2D: |
- | LDF2F: sta ObjectCntrl ;Clear object control byte. | + | LDF2F: |
- | LDF31: rts ; | + | LDF31: |
SkipPlacementData: | SkipPlacementData: | ||
- | LDF32:* inc $0F ;Skip next y and x placement data bytes. | + | LDF32:* inc $0F |
- | LDF34: inc $0F ; | + | LDF34: |
- | LDF36: inc $11 ;Increment to next data item in frame data. | + | LDF36: |
- | LDF38: jmp DrawSpriteObject ; | + | LDF38: |
GetNewControlByte: | GetNewControlByte: | ||
- | LDF3B: | + | LDF3B:* iny |
- | LDF3C: asl ObjectCntrl ;If MSB of ObjectCntrl is not set, no overriding of--> | + | LDF3C: |
- | LDF3E: bcc + ;flip bits needs to be performed. | + | LDF3E: |
- | LDF40: jsr SpriteFlipBitsOveride ; | + | LDF40: |
- | LDF43: bne ++ ;Branch always. | + | LDF43: |
- | LDF45:* lsr ObjectCntrl ;Restore MSB of ObjectCntrl. | + | LDF45:* lsr ObjectCntrl |
- | LDF47: lda ($00),y ; | + | LDF47: |
- | LDF49: sta $05 ;Save new sprite control byte. | + | LDF49: |
- | LDF4B: | + | LDF4B:* iny |
- | LDF4C: sty $11 ;Save index of frame data. | + | LDF4C: |
- | LDF4E: jmp GetNextFrameByte ; | + | LDF4E: |
OffsetObjectPosition: | OffsetObjectPosition: | ||
- | LDF51: | + | LDF51:* iny |
- | LDF52: lda ($00),y ;This data byte is used to offset the object from--> | + | LDF52: |
- | LDF54: clc ;its current y positon. | + | LDF54: |
- | LDF55: adc $10 ; | + | LDF55: |
- | LDF57: sta $10 ;Add offset amount to object y screen position. | + | LDF57: |
- | LDF59: inc $11 ; | + | LDF59: |
- | LDF5B: inc $11 ;Increment past control byte and y offset byte. | + | LDF5B: |
- | LDF5D: ldy $11 ; | + | LDF5D: |
- | LDF5F: lda ($00),y ;Load x offset data byte. | + | LDF5F: |
- | LDF61: clc ; | + | LDF61: |
- | LDF62: adc $0E ;Add offset amount to object x screen position. | + | LDF62: |
- | LDF64: sta $0E ; | + | LDF64: |
- | LDF66: inc $11 ;Increment past x offset byte. | + | LDF66: |
- | LDF68: jmp DrawSpriteObject ; | + | LDF68: |
; | ; | ||
YDisplacement: | YDisplacement: | ||
- | LDF6B: | + | LDF6B: |
- | LDF6D: tay ; | + | LDF6D: |
- | LDF6E: and #$F0 ;Check to see if this is placement data for the object--> | + | LDF6E: |
- | LDF70: cmp #$80 ; | + | LDF70: |
- | LDF72: beq ++ ; | + | LDF72: |
- | LDF74: tya ;Restore placement data byte to A. | + | LDF74: |
- | LDF75:* bit $04 ; | + | LDF75:* bit $04 |
- | LDF77: bmi NegativeDisplacement ; | + | LDF77: |
- | LDF79: clc ;Clear carry before returning. | + | LDF79: |
- | LDF7A: rts ; | + | LDF7A: |
ExplodeYDisplace: | ExplodeYDisplace: | ||
- | LDF7B: | + | LDF7B:* tya |
- | LDF7C: and #$0E ;Discard bits 7,6,5,4 and 0. | + | LDF7C: |
- | LDF7E: lsr ;/2. | + | LDF7E: |
- | LDF7F: tay ; | + | LDF7F: |
- | LDF80: lda ExplodeIndexTbl, | + | LDF80: |
- | LDF83: ldy IsSamus ; | + | LDF83: |
- | LDF85: bne + ;Is Samus the object exploding? if so, branch. | + | LDF85: |
- | LDF87: ldy PageIndex ;Load index to proper enemy data. | + | LDF87: |
- | LDF89: adc EnCounter, | + | LDF89: |
- | LDF8C: jmp ++ ;Jump to load explode placement data. | + | LDF8C: |
;Special case for Samus exploding. | ;Special case for Samus exploding. | ||
- | LDF8F:* adc ObjectCounter ;Increments every frame Samus is exploding. Initial=# | + | LDF8F:* adc ObjectCounter |
- | LDF91: | + | LDF91:* tay |
- | LDF92: lda ExplodeIndexTbl+2, | + | LDF92: |
- | LDF95: pha ;Save data on stack. | + | LDF95: |
- | LDF96: lda $0F ;Load placement data index. | + | LDF96: |
- | LDF98: clc ; | + | LDF98: |
- | LDF99: adc #$0C ;Move index forward by 12 bytes. to find y--> | + | LDF99: |
- | LDF9B: tay ;placement data. | + | LDF9B: |
- | LDF9C: pla ;Restore A with ExplodePlacementTbl data. | + | LDF9C: |
- | LDF9D: clc ; | + | LDF9D: |
- | LDF9E: adc ($02),y ;Add table displacements with sprite placement data. | + | LDF9E: |
- | LDFA0: jmp ---- ;Branch to add y placement values to sprite coords. | + | LDFA0: |
XDisplacement: | XDisplacement: | ||
- | LDFA3: | + | LDFA3: |
- | LDFA5: tay ; | + | LDFA5: |
- | LDFA6: and #$F0 ;Check to see if this is placement data for the object--> | + | LDFA6: |
- | LDFA8: cmp #$80 ; | + | LDFA8: |
- | LDFAA: beq +++ ; | + | LDFAA: |
- | LDFAC: tya ;Restore placement data byte to A. | + | LDFAC: |
- | LDFAD:* bit $04 ; | + | LDFAD:* bit $04 |
- | LDFAF: bvc + ;Branch if bit 6 cleared, else data is negative displacement. | + | LDFAF: |
NegativeDisplacement: | NegativeDisplacement: | ||
- | LDFB1: | + | LDFB1: |
- | LDFB3: sec ; | + | LDFB3: |
- | LDFB4: adc #$F8 ;If flip bit is set in $04, this function flips the--> | + | LDFB4: |
- | LDFB6: | + | LDFB6:* clc |
- | LDFB7: rts ;8x8 pixels). | + | LDFB7: |
ExplodeXDisplace: | ExplodeXDisplace: | ||
- | LDFB8:* ldy PageIndex ;Load index to proper enemy slot. | + | LDFB8:* ldy PageIndex |
- | LDFBA: lda EnCounter, | + | LDFBA: |
- | LDFBD: ldy IsSamus ;Is Samus the one exploding? | + | LDFBD: |
- | LDFBF: beq + ;If not, branch. | + | LDFBF: |
- | LDFC1: lda ObjectCounter ;Load object counter if it is Samus who is exploding. | + | LDFC1: |
- | LDFC3: | + | LDFC3:* asl |
- | LDFC4: pha ;Store value on stack. | + | LDFC4: |
- | LDFC5: ldy $0F ; | + | LDFC5: |
- | LDFC7: lda ($02),y ;Load placement data byte. | + | LDFC7: |
- | LDFC9: lsr ; | + | LDFC9: |
- | LDFCA: bcs + ;Check if LSB is set. If not, the byte stored on stack--> | + | LDFCA: |
- | LDFCC: pla ;Will be twos complimented and used to move sprite in--> | + | LDFCC: |
- | LDFCD: eor #$FF ;the negative x direction. | + | LDFCD: |
- | LDFCF: adc #$01 ; | + | LDFCF: |
- | LDFD1: pha ; | + | LDFD1: |
- | LDFD2:* lda $0F ;Load placement data index. | + | LDFD2:* lda $0F |
- | LDFD4: clc ; | + | LDFD4: |
- | LDFD5: adc #$0C ;Move index forward by 12 bytes. to find x--> | + | LDFD5: |
- | LDFD7: tay ;placement data. | + | LDFD7: |
- | LDFD8: pla ;Restore A with x displacement data. | + | LDFD8: |
- | LDFD9: clc ; | + | LDFD9: |
- | LDFDA: adc ($02),y ;Add x displacement with sprite placement data. | + | LDFDA: |
- | LDFDC: jmp ----- ;Branch to add x placement values to sprite coords. | + | LDFDC: |
; | ; | ||
Line 4972: | Line 4972: | ||
IsObjectVisible: | IsObjectVisible: | ||
- | LDFDF: | + | LDFDF: |
- | LDFE1: lda $0A ;Object Y position in room. | + | LDFE1: |
- | LDFE3: tay ; | + | LDFE3: |
- | LDFE4: sec ;Subtract y scroll to find sprite' | + | LDFE4: |
- | LDFE5: sbc ScrollY ; | + | LDFE5: |
- | LDFE7: sta $10 ;Store result in $10. | + | LDFE7: |
- | LDFE9: lda $0B ;Object X position in room. | + | LDFE9: |
- | LDFEB: sec ; | + | LDFEB: |
- | LDFEC: sbc ScrollX ;Subtract x scroll to find sprite' | + | LDFEC: |
- | LDFEE: sta $0E ;Store result in $0E. | + | LDFEE: |
- | LDFF0: lda ScrollDir ; | + | LDFF0: |
- | LDFF2: and #$02 ;Is Samus scrolling left or right? | + | LDFF2: |
- | LDFF4: bne HorzScrollCheck ;($E01C)If so, branch. | + | LDFF4: |
VertScrollCheck: | VertScrollCheck: | ||
- | LDFF6: cpy ScrollY ;If object room pos is >= scrollY, set carry. | + | LDFF6: |
- | LDFF8: lda $06 ;Check if object is on different name table as current--> | + | LDFF8: |
- | LDFFA: eor PPUCNT0ZP ;name table active in PPU.--> | + | LDFFA: |
- | LDFFC: and #$01 ;If not, branch. | + | LDFFC: |
- | LDFFE: beq + ; | + | LDFFE: |
- | LE000: bcs ++ ;If carry is still set, sprite is not in screen boundaries. | + | LE000: |
- | LE002: lda $10 ; | + | LE002: |
- | LE004: sbc #$0F ;Move sprite y position up 15 pixles. | + | LE004: |
- | LE006: sta $10 ; | + | LE006: |
- | LE008: lda $09 ; | + | LE008: |
- | LE00A: clc ;If a portion of the object is outside the sceen--> | + | LE00A: |
- | LE00B: adc $10 ; | + | LE00B: |
- | LE00D: cmp #$F0 ;not visible. | + | LE00D: |
- | LE00F: bcc +++ ; | + | LE00F: |
- | LE011: clc ;Causes next statement to branch always. | + | LE011: |
- | LE012:* bcc + ; | + | LE012:* bcc + |
- | LE014: lda $09 ;If object is on same name table as the current one in--> | + | LE014: |
- | LE016: cmp $10 ;the PPU, check if part of object is out of screen--> | + | LE016: |
- | LE018: bcc ++ ; | + | LE018: |
- | LE01A: | + | LE01A:* dex |
- | LE01B: | + | LE01B:* rts |
HorzScrollCheck: | HorzScrollCheck: | ||
- | LE01C: | + | LE01C: |
- | LE01E: eor PPUCNT0ZP ;Check if object is on different name table as current--> | + | LE01E: |
- | LE020: and #$01 ;name table active in PPU.--> | + | LE020: |
- | LE022: beq + ;If not, branch. | + | LE022: |
- | LE024: bcs ++ ;If carry is still set, sprite is not in screen boundaries. | + | LE024: |
- | LE026: lda $09 ; | + | LE026: |
- | LE028: clc ;If a portion of the object is outside the sceen--> | + | LE028: |
- | LE029: adc $0E ; | + | LE029: |
- | LE02B: bcc +++ ;not visible. | + | LE02B: |
- | LE02D: clc ;Causes next statement to branch always. | + | LE02D: |
- | LE02E:* bcc + ; | + | LE02E:* bcc + |
- | LE030: lda $09 ;If object is on same name table as the current one in--> | + | LE030: |
- | LE032: cmp $0E ;the PPU, check if part of object is out of screen--> | + | LE032: |
- | LE034: bcc ++ ; | + | LE034: |
- | LE036: | + | LE036:* dex |
- | LE037: | + | LE037:* rts |
; | ; | ||
Line 5034: | Line 5034: | ||
SpriteFlipBitsOveride: | SpriteFlipBitsOveride: | ||
- | LE038: lsr ObjectCntrl ;Restore MSB. | + | LE038: |
- | LE03A: lda ($00),y ;Reload frame data control byte into A. | + | LE03A: |
- | LE03C: and #$C0 ;Extract the two sprite flip bytes from theoriginal--> | + | LE03C: |
- | LE03E: ora ObjectCntrl ;control byte and set any additional bits from ObjectCntrl. | + | LE03E: |
- | LE040: sta $05 ;Store modified byte to load in sprite control byte later. | + | LE040: |
- | LE042: lda ObjectCntrl ; | + | LE042: |
- | LE044: ora #$80 ; | + | LE044: |
- | LE046: sta ObjectCntrl ;Ensure MSB of object control byte remains set. | + | LE046: |
- | LE048: rts ; | + | LE048: |
; | ; | ||
Line 5050: | Line 5050: | ||
ExplodeIndexTbl: | ExplodeIndexTbl: | ||
- | LE049: | + | LE049: |
;The following table is used to produce the arcing motion of exploding objects. | ;The following table is used to produce the arcing motion of exploding objects. | ||
Line 5058: | Line 5058: | ||
;Bottom sprites. | ;Bottom sprites. | ||
- | LE04C: | + | LE04C: |
- | LE05C: | + | LE05C: |
;Middle sprites. | ;Middle sprites. | ||
- | LE064: | + | LE064: |
- | LE074: | + | LE074: |
;Top sprites. | ;Top sprites. | ||
- | LE07C: | + | LE07C: |
- | LE08C: | + | LE08C: |
; | ; | ||
Line 5074: | Line 5074: | ||
UpdateEnemyAnim: | UpdateEnemyAnim: | ||
- | LE094: ldx PageIndex ;Load index to desired enemy. | + | LE094: |
- | LE096: ldy EnStatus,x ; | + | LE096: |
- | LE099: cpy #$05 ;Is enemy in the process of dying? | + | LE099: |
- | LE09B: beq +++ ;If so, branch to exit. | + | LE09B: |
- | LE09D: ldy EnAnimDelay, | + | LE09D: |
- | LE0A0: beq + ;Check if current anumation frame is ready to be updated. | + | LE0A0: |
- | LE0A2: dec EnAnimDelay, | + | LE0A2: |
- | LE0A5: bne +++ ;branch to exit. | + | LE0A5: |
- | LE0A7:* sta EnAnimDelay, | + | LE0A7:* sta EnAnimDelay, |
- | LE0AA: ldy EnAnimIndex, | + | LE0AA: |
- | LE0AD:* lda (EnemyAnimPtr), | + | LE0AD:* lda (EnemyAnimPtr), |
- | LE0AF: cmp #$FF ;End of animation? | + | LE0AF: |
- | LE0B1: beq ++ ;If so, branch to reset animation. | + | LE0B1: |
- | LE0B3: sta EnAnimFrame, | + | LE0B3: |
- | LE0B6: iny ;Increment to next animation data index. | + | LE0B6: |
- | LE0B7: tya ; | + | LE0B7: |
- | LE0B8: sta EnAnimIndex, | + | LE0B8: |
- | LE0BB: | + | LE0BB:* rts |
- | LE0BC:* ldy EnResetAnimIndex, | + | LE0BC:* ldy EnResetAnimIndex, |
- | LE0BF: bcs --- ;Branch always. | + | LE0BF: |
; | ; | ||
Line 5101: | Line 5101: | ||
DisplayBar: | DisplayBar: | ||
- | LE0C1: ldy #$00 ;Reset data index. | + | LE0C1: |
- | LE0C3: lda SpritePagePos ;Load current sprite index. | + | LE0C3: |
- | LE0C5: pha ;save sprite page pos. | + | LE0C5: |
- | LE0C6: tax ; | + | LE0C6: |
- | LE0C7:* lda DataDisplayTbl, | + | LE0C7:* lda DataDisplayTbl, |
- | LE0CA: sta Sprite00RAM, | + | LE0CA: |
- | LE0CD: inx ; | + | LE0CD: |
- | LE0CE: iny ; | + | LE0CE: |
- | LE0CF: cpy #$28 ;10*4. At end of DataDisplayTbl? | + | LE0CF: |
- | LE0D1: bne - ;load next byte from table. | + | LE0D1: |
;Display 2-digit health count. | ;Display 2-digit health count. | ||
- | LE0D3: stx SpritePagePos ;Save new location in sprite RAM. | + | LE0D3: |
- | LE0D5: pla ;Restore initial sprite page pos. | + | LE0D5: |
- | LE0D6: tax ; | + | LE0D6: |
- | LE0D7: lda HealthHi ; | + | LE0D7: |
- | LE0DA: and #$0F ;Extract upper health digit. | + | LE0DA: |
- | LE0DC: jsr SPRWriteDigit ; | + | LE0DC: |
- | LE0DF: lda HealthLo ; | + | LE0DF: |
- | LE0E2: jsr Adiv16 ; | + | LE0E2: |
- | LE0E5: jsr SPRWriteDigit ; | + | LE0E5: |
- | LE0E8: ldy EndTimerHi ; | + | LE0E8: |
- | LE0EB: iny ;Is Samus in escape sequence? | + | LE0EB: |
- | LE0EC: bne ++ ;If so, branch. | + | LE0EC: |
- | LE0EE: ldy MaxMissiles ; | + | LE0EE: |
- | LE0F1: beq + ;Don't show missile count if Samus has no missile containers. | + | LE0F1: |
;Display 3-digit missile count. | ;Display 3-digit missile count. | ||
- | LE0F3: lda MissileCount ; | + | LE0F3: |
- | LE0F6: jsr HexToDec ; | + | LE0F6: |
- | LE0F9: lda $02 ;Upper digit. | + | LE0F9: |
- | LE0FB: jsr SPRWriteDigit ; | + | LE0FB: |
- | LE0FE: lda $01 ;Middle digit. | + | LE0FE: |
- | LE100: jsr SPRWriteDigit ; | + | LE100: |
- | LE103: lda $00 ;Lower digit. | + | LE103: |
- | LE105: jsr SPRWriteDigit ; | + | LE105: |
- | LE108: bne +++ ;Branch always. | + | LE108: |
;Samus has no missiles, erase missile sprite. | ;Samus has no missiles, erase missile sprite. | ||
- | LE10A:* lda #$FF ;" | + | LE10A:* lda #$FF ;" |
- | LE10C: cpx #$F4 ;If at last 3 sprites, branch to skip. | + | LE10C: |
- | LE10E: bcs ++ ; | + | LE10E: |
- | LE110: sta Sprite03RAM+1, | + | LE110: |
- | LE113: cpx #$F0 ;If at last 4 sprites, branch to skip. | + | LE113: |
- | LE115: bcs ++ ; | + | LE115: |
- | LE117: sta Sprite04RAM+1, | + | LE117: |
- | LE11A: bne ++ ;Branch always. | + | LE11A: |
;Display 3-digit end sequence timer. | ;Display 3-digit end sequence timer. | ||
- | LE11C:* lda EndTimerHi ; | + | LE11C:* lda EndTimerHi |
- | LE11F: jsr Adiv16 ; | + | LE11F: |
- | LE122: jsr SPRWriteDigit ; | + | LE122: |
- | LE125: lda EndTimerHi ; | + | LE125: |
- | LE128: and #$0F ;Middle timer digit. | + | LE128: |
- | LE12A: jsr SPRWriteDigit ; | + | LE12A: |
- | LE12D: lda EndTimerLo ; | + | LE12D: |
- | LE130: jsr Adiv16 ; | + | LE130: |
- | LE133: jsr SPRWriteDigit ; | + | LE133: |
- | LE136: lda #$58 ;" | + | LE136: |
- | LE138: sta Sprite00RAM+1, | + | LE138: |
- | LE13B: inc Sprite00RAM+2, | + | LE13B: |
- | LE13E: cpx #$FC ;If at last sprite, branch to skip. | + | LE13E: |
- | LE140: bcs + ; | + | LE140: |
- | LE142: lda #$59 ;" | + | LE142: |
- | LE144: sta Sprite01RAM+1, | + | LE144: |
- | LE147: inc Sprite01RAM+2, | + | LE147: |
- | LE14A:* ldx SpritePagePos ;Restore initial sprite page pos. | + | LE14A:* ldx SpritePagePos |
- | LE14C: lda TankCount ; | + | LE14C: |
- | LE14F: beq ++ ;Branch to exit if Samus has no energy tanks. | + | LE14F: |
;Display full/empty energy tanks. | ;Display full/empty energy tanks. | ||
- | LE151: sta $03 ;Temp store tank count. | + | LE151: |
- | LE153: lda #$40 ;X coord of right-most energy tank. | + | LE153: |
- | LE155: sta $00 ;Energy tanks are drawn from right to left. | + | LE155: |
- | LE157: ldy #$6F ;"Full energy tank" tile. | + | LE157: |
- | LE159: lda HealthHi ; | + | LE159: |
- | LE15C: jsr Adiv16 ; | + | LE15C: |
- | LE15F: sta $01 ;Storage of full tanks. | + | LE15F: |
- | LE161: bne AddTanks ;Branch if at least 1 tank is full. | + | LE161: |
- | LE163: dey ;Else switch to "empty energy tank" tile. | + | LE163: |
AddTanks: | AddTanks: | ||
- | LE164: jsr AddOneTank ;($E17B)Add energy tank to display. | + | LE164: |
- | LE167: dec $01 ;Any more full energy tanks left? | + | LE167: |
- | LE169: bne + ;If so, then branch.--> | + | LE169: |
- | LE16B: dey ;Otherwise, switch to "empty energy tank" tile. | + | LE16B: |
- | LE16C:* dec $03 ;done all tanks? | + | LE16C:* dec $03 |
- | LE16E: bne AddTanks ;if not, loop to do another. | + | LE16E: |
- | LE170: stx SpritePagePos ;Store new sprite page position. | + | LE170: |
- | LE172: | + | LE172:* rts |
; | ; | ||
Line 5200: | Line 5200: | ||
SPRWriteDigit: | SPRWriteDigit: | ||
- | LE173: ora #$A0 ;#$A0 is index into pattern table for numbers. | + | LE173: |
- | LE175: sta Sprite00RAM+1, | + | LE175: |
- | LE178: jmp Xplus4 ;Find next sprite pattern table byte. | + | LE178: |
; | ; | ||
Line 5209: | Line 5209: | ||
AddOneTank: | AddOneTank: | ||
- | LE17B: lda #$17 ;Y coord-1. | + | LE17B: |
- | LE17D: sta Sprite00RAM, | + | LE17D: |
- | LE180: tya ;Tile value. | + | LE180: |
- | LE181: sta Sprite00RAM+1, | + | LE181: |
- | LE184: lda #$01 ;Palette #. | + | LE184: |
- | LE186: sta Sprite00RAM+2, | + | LE186: |
- | LE189: lda $00 ;X coord. | + | LE189: |
- | LE18B: sta Sprite00RAM+3, | + | LE18B: |
- | LE18E: sec ; | + | LE18E: |
- | LE18F: sbc #$0A ;Find x coord of next energy tank. | + | LE18F: |
- | LE191: sta $00 ; | + | LE191: |
; | ; | ||
Xplus4: | Xplus4: | ||
- | LE193: inx ; | + | LE193: |
- | LE194: inx ; | + | LE194: |
- | LE195: inx ;Add 4 to value stored in X. | + | LE195: |
- | LE196: inx ; | + | LE196: |
- | LE197: rts ; | + | LE197: |
; | ; | ||
Line 5235: | Line 5235: | ||
HexToDec: | HexToDec: | ||
- | LE198: ldy #100 ;Find upper digit. | + | LE198: |
- | LE19A: sty $0A ; | + | LE19A: |
- | LE19C: jsr GetDigit ; | + | LE19C: |
- | LE19F: sty $02 ;Store upper digit in $02. | + | LE19F: |
- | LE1A1: ldy #10 ;Find middle digit. | + | LE1A1: |
- | LE1A3: sty $0A ; | + | LE1A3: |
- | LE1A5: jsr GetDigit ; | + | LE1A5: |
- | LE1A8: sty $01 ;Store middle digit in $01. | + | LE1A8: |
- | LE1AA: sta $00 ;Store lower digit in $00 | + | LE1AA: |
- | LE1AC: rts ; | + | LE1AC: |
GetDigit: | GetDigit: | ||
- | LE1AD: ldy #$00 ; | + | LE1AD: |
- | LE1AF: sec ; | + | LE1AF: |
- | LE1B0: | + | LE1B0:* iny |
- | LE1B1: sbc $0A ;Loop and subtract value in $0A from A until carry flag--> | + | LE1B1: |
- | LE1B3: bcs - ;is not set. The resulting number of loops is the decimal--> | + | LE1B3: |
- | LE1B5: dey ;number extracted and A is the remainder. | + | LE1B5: |
- | LE1B6: adc $0A ; | + | LE1B6: |
- | LE1B8: rts ; | + | LE1B8: |
; | ; | ||
Line 5261: | Line 5261: | ||
DataDisplayTbl: | DataDisplayTbl: | ||
- | LE1B9: | + | LE1B9: |
- | LE1BD: | + | LE1BD: |
- | LE1C1: | + | LE1C1: |
- | LE1C5: | + | LE1C5: |
- | LE1C9: | + | LE1C9: |
- | LE1CD: | + | LE1CD: |
- | LE1D1: | + | LE1D1: |
- | LE1D5: | + | LE1D5: |
- | LE1D9: | + | LE1D9: |
- | LE1DD: | + | LE1DD: |
; | ; | ||
Line 5279: | Line 5279: | ||
BitScan: | BitScan: | ||
- | LE1E1: stx $0E ;Save X. | + | LE1E1: |
- | LE1E3: ldx #$00 ;First bit is bit 0. | + | LE1E3: |
- | LE1E5: | + | LE1E5:* lsr |
- | LE1E6: bcs + ;If the shifted bit was 1, Branch out of loop. | + | LE1E6: |
- | LE1E8: inx ;Increment X to keep of # of bits checked. | + | LE1E8: |
- | LE1E9: cpx #$08 ;Have all 8 bit been tested? | + | LE1E9: |
- | LE1EB: bne - ;If not, branch to check the next bit. | + | LE1EB: |
- | LE1ED: | + | LE1ED:* txa |
- | LE1EE: ldx $0E ;Restore X. | + | LE1EE: |
- | LE1F0: | + | LE1F0:* rts |
; | ; | ||
Line 5295: | Line 5295: | ||
ScrollDoor: | ScrollDoor: | ||
- | LE1F1: ldx DoorStatus ; | + | LE1F1: |
- | LE1F3: beq - ;Exit if Samus isn't in a door. | + | LE1F3: |
- | LE1F5: dex ; | + | LE1F5: |
- | LE1F6: bne + ;Not in right door. branch to check left door. | + | LE1F6: |
- | LE1F8: jsr ScrollRight ; | + | LE1F8: |
- | LE1FB: jmp ++ ;Jump to check if door scroll is finished. | + | LE1FB: |
- | LE1FE: | + | LE1FE:* dex |
- | LE1FF: bne ++ ; | + | LE1FF: |
- | LE201: jsr ScrollLeft ; | + | LE201: |
- | LE204:* ldx ScrollX ;Has x scroll offset reached 0?--> | + | LE204:* ldx ScrollX |
- | LE206: bne Exit15 ;If not, branch to exit. | + | LE206: |
;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: |
- | LE20A: bne DoOneDoorScroll ;Branch always. | + | LE20A: |
- | LE20C: | + | LE20C:* dex |
- | LE20D: bne + ;Check if need to scroll down to center door. | + | LE20D: |
- | LE20F: jsr ScrollDown ; | + | LE20F: |
- | LE212: jmp ++ ;Jump to check y scrolling value. | + | LE212: |
- | LE215: | + | LE215:* dex |
- | LE216: bne Exit15 ;Check if need to scroll up to center door. | + | LE216: |
- | LE218: jsr ScrollUp ; | + | LE218: |
VerticalRoomCentered: | VerticalRoomCentered: | ||
- | LE21B:* ldx ScrollY ;Has room been centered on screen? | + | LE21B:* ldx ScrollY |
- | LE21D: bne Exit15 ;If not, branch to exit. | + | LE21D: |
- | LE21F: stx DoorOnNameTable3 ; | + | LE21F: |
- | LE221: stx DoorOnNameTable0 ;Erase door nametable data. | + | LE221: |
- | LE223: inx ;X=1. | + | LE223: |
- | LE224: lda ObjectX ;Did Samus enter in the right hand door? | + | LE224: |
- | LE227: bmi ++ ;If so, branch. | + | LE227: |
- | LE229: inx ;X=2. Samus is in left door. | + | LE229: |
- | LE22A: bne ++ ;Branch always. | + | LE22A: |
;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: |
- | LE22E: sta DoorDelay ; | + | LE22E: |
- | LE230: lda SamusDoorData ;Check if scrolling should be toggled. | + | LE230: |
- | LE232: jsr Amul8 ;($C2C6)*8. Is door not to toggle scrolling(item room, | + | LE232: |
- | LE235: bcs + ;bridge room, etc.)? If so, branch to NOT toggle scrolling. | + | LE235: |
- | LE237: ldy DoorScrollStatus ;If comming from vertical shaft, skip ToggleScroll because--> | + | LE237: |
- | LE239: cpy #$03 ;the scroll was already toggled after room was centered--> | + | LE239: |
- | LE23B: bcc ++ ;by the routine just above. | + | LE23B: |
- | 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: |
- | LE241:* jsr ToggleScroll ; | + | LE241:* jsr ToggleScroll |
- | LE244:* sta MirrorCntrl ;Store new mirror control data. | + | LE244:* sta MirrorCntrl |
- | LE246: stx DoorStatus ; | + | LE246: |
Exit15: | Exit15: | ||
- | LE248: rts ;Exit for several routines above. | + | LE248: |
; | ; | ||
ToggleSamusHi: | ToggleSamusHi: | ||
- | LE249: lda ObjectHi ; | + | LE249: |
- | LE24C: eor #$01 ;Change Samus' current nametable from one to the other. | + | LE24C: |
- | LE24E: sta ObjectHi ; | + | LE24E: |
- | LE251: rts ; | + | LE251: |
; | ; | ||
Line 5366: | Line 5366: | ||
ToggleScroll: | ToggleScroll: | ||
- | LE252: lda ScrollDir ; | + | LE252: |
- | LE254: eor #$03 ;Toggle scroll direction. | + | LE254: |
- | LE256: sta ScrollDir ; | + | LE256: |
- | LE258: lda MirrorCntrl ;Toggle mirroring. | + | LE258: |
- | LE25A: eor #$08 ; | + | LE25A: |
- | LE25C: rts ; | + | LE25C: |
; | ; | ||
Line 5381: | Line 5381: | ||
IsSamusInLava: | IsSamusInLava: | ||
- | LE25D: | + | LE25D: |
- | LE25F: cmp ScrollDir ;Set carry bit(and exit) if scrolling up or down. | + | LE25F: |
- | LE261: bcs + ; | + | LE261: |
- | LE263: lda #$D8 ;If Samus is Scrolling left or right and within 24 pixels--> | + | LE263: |
- | LE265: cmp ObjectY ;of the bottom of the screen, she is in lava. Clear carry bit. | + | LE265: |
- | LE268: | + | LE268:* rts |
; | ; | ||
LavaAndMoveCheck: | LavaAndMoveCheck: | ||
- | LE269: | + | LE269: |
- | LE26C: cmp # | + | LE26C: |
- | LE26E: beq + ;If so, branch. | + | LE26E: |
- | LE270: cmp #sa_Dead ;Is Samus Dead--> | + | LE270: |
- | LE272: bcs - ;If so, branch to exit. | + | LE272: |
- | LE274:* jsr IsSamusInLava ; | + | LE274:* jsr IsSamusInLava |
- | LE277: ldy #$FF ;Assume Samus not in lava. | + | LE277: |
- | LE279: bcs ++++ ;Samus not in lava so branch. | + | LE279: |
;Samus is in lava. | ;Samus is in lava. | ||
- | LE27B: sty DamagePushDirection ;Don't push Samus from lava damage. | + | LE27B: |
- | LE27D: jsr ClearHealthChange ; | + | LE27D: |
- | LE280: lda #$32 ; | + | LE280: |
- | LE282: sta SamusBlink ;Make Samus blink. | + | LE282: |
- | LE284: lda FrameCount ; | + | LE284: |
- | LE286: and #$03 ;Start the jump SFX every 4th frame while in lava. | + | LE286: |
- | LE288: bne + ; | + | LE288: |
- | LE28A: jsr SFX_SamusJump ; | + | LE28A: |
- | LE28D:* lda FrameCount ; | + | LE28D:* lda FrameCount |
- | LE28F: lsr ;This portion of the code causes Samus to be damaged by--> | + | LE28F: |
- | LE290: and #$03 ;lava twice every 8 frames if she does not have the varia--> | + | LE290: |
- | LE292: bne ++ ;but only once every 8 frames if she does. | + | LE292: |
- | LE294: lda SamusGear ; | + | LE294: |
- | LE297: and #gr_VARIA ;Does Samus have the Varia? | + | LE297: |
- | LE299: beq + ;If not, branch. | + | LE299: |
- | LE29B: bcc ++ ;Samus has varia. Carry set every other frame. Half damage. | + | LE29B: |
- | LE29D:* lda #$07 ; | + | LE29D:* lda #$07 ; |
- | LE29F: sta HealthLoChange ;Samus takes lava damage. | + | LE29F: |
- | LE2A1: jsr SubtractHealth ;($CE92) | + | LE2A1: |
- | LE2A4:* ldy #$00 ;Prepare to indicate Samus is in lava. | + | LE2A4:* ldy #$00 ;Prepare to indicate Samus is in lava. |
- | LE2A6: | + | LE2A6:* iny |
- | LE2A7: sty SamusInLava ; | + | LE2A7: |
SamusMoveVertically: | SamusMoveVertically: | ||
- | LE2A9: jsr VertAccelerate ; | + | LE2A9: |
- | LE2AC: lda ObjectY ; | + | LE2AC: |
- | LE2AF: sec ; | + | LE2AF: |
- | LE2B0: sbc ScrollY ;Calculate Samus' screen y position. | + | LE2B0: |
- | LE2B2: sta SamusScrY ; | + | LE2B2: |
- | LE2B4: lda $00 ;Load temp copy of vertical speed. | + | LE2B4: |
- | LE2B6: bpl ++++ ;If Samus is moving downwards, branch. | + | LE2B6: |
- | LE2B8: jsr TwosCompliment ;($C3D4)Get twos compliment of vertical speed. | + | LE2B8: |
- | LE2BB: ldy SamusInLava ;Is Samus in lava? | + | LE2BB: |
- | LE2BD: beq + ;If not, branch, | + | LE2BD: |
- | LE2BF: lsr ;else cut vertical speed in half. | + | LE2BF: |
- | LE2C0: beq SamusMoveHorizontally ; | + | LE2C0: |
;Samus is moving upwards. | ;Samus is moving upwards. | ||
- | LE2C2:* sta ObjectCounter ;Store number of pixels to move Samus this frame. | + | LE2C2:* sta ObjectCounter |
- | LE2C4:* jsr MoveSamusUp ; | + | LE2C4:* jsr MoveSamusUp |
- | LE2C7: bcs + ;Branch if Samus successfully moved up 1 pixel. | + | LE2C7: |
- | LE2C9: sec ;Samus blocked upwards. Divide her speed by 2 and set the | + | LE2C9: |
- | LE2CA: ror ObjVertSpeed ;MSB to reverse her direction of travel. | + | LE2CA: |
- | LE2CD: ror VertCntrLinear ; | + | LE2CD: |
- | LE2D0: jmp SamusMoveHorizontally ; | + | LE2D0: |
- | LE2D3:* dec ObjectCounter ;1 pixel movement is complete. | + | LE2D3:* dec ObjectCounter |
- | LE2D5: bne -- ;Branch if Samus needs to be moved another pixel. | + | LE2D5: |
;Samus is moving downwards. | ;Samus is moving downwards. | ||
- | LE2D7:* beq SamusMoveHorizontally ; | + | LE2D7:* beq SamusMoveHorizontally |
- | LE2D9: ldy SamusInLava ;Is Samus in lava? | + | LE2D9: |
- | LE2DB: beq + ;If not, branch, | + | LE2DB: |
- | LE2DD: lsr ;Else reduce Samus speed by 75%(divide by 4). | + | LE2DD: |
- | LE2DE: lsr ; | + | LE2DE: |
- | LE2DF: beq SamusMoveHorizontally ; | + | LE2DF: |
- | LE2E1:* sta ObjectCounter ;Store number of pixels to move Samus this frame. | + | LE2E1:* sta ObjectCounter |
- | LE2E3:* jsr MoveSamusDown ; | + | LE2E3:* jsr MoveSamusDown |
- | LE2E6: bcs +++ ;Branch if Samus successfully moved down 1 pixel. | + | LE2E6: |
;Samus bounce after hitting the ground in ball form. | ;Samus bounce after hitting the ground in ball form. | ||
- | LE2E8: lda ObjAction ; | + | LE2E8: |
- | LE2EB: cmp #sa_Roll ;Is Samus rolled into a ball? | + | LE2EB: |
- | LE2ED: bne + ;If not, branch. | + | LE2ED: |
- | LE2EF: lsr ObjVertSpeed ;Divide verticle speed by 2. | + | LE2EF: |
- | LE2F2: beq ++ ;Speed not fast enough to bounce. branch to skip. | + | LE2F2: |
- | LE2F4: ror VertCntrLinear ;Move carry bit into MSB to reverse Linear counter. | + | LE2F4: |
- | LE2F7: lda #$00 ; | + | LE2F7: |
- | LE2F9: sec ; | + | LE2F9: |
- | LE2FA: sbc VertCntrLinear ;Subtract linear counter from 0 and save the results.--> | + | LE2FA: |
- | LE2FD: sta VertCntrLinear ;Carry will be cleared. | + | LE2FD: |
- | LE300: lda #$00 ; | + | LE300: |
- | LE302: sbc ObjVertSpeed ;Subtract vertical speed from 0. this will reverse the--> | + | LE302: |
- | LE305: sta ObjVertSpeed ;vertical direction of travel(bounce up). | + | LE305: |
- | LE308: jmp SamusMoveHorizontally ; | + | LE308: |
;Samus has hit the ground after moving downwards. | ;Samus has hit the ground after moving downwards. | ||
- | LE30B:* jsr SFX_SamusWalk ; | + | LE30B:* jsr SFX_SamusWalk |
- | LE30E:* jsr StopVertMovement ; | + | LE30E:* jsr StopVertMovement |
- | LE311: sty SamusGravity ;Clear Samus gravity value. | + | LE311: |
- | LE314: beq SamusMoveHorizontally ; | + | LE314: |
- | LE316:* dec ObjectCounter ;1 pixel movement is complete. | + | LE316:* dec ObjectCounter |
- | LE318: bne ---- ;Branch if Samus needs to be moved another pixel. | + | LE318: |
SamusMoveHorizontally: | SamusMoveHorizontally: | ||
- | LE31A: | + | LE31A: |
- | LE31D: lda ObjectX ; | + | LE31D: |
- | LE320: sec ;Calculate Samus' x position on screen. | + | LE320: |
- | LE321: sbc ScrollX ; | + | LE321: |
- | LE323: sta SamusScrX ;Save Samus' x position. | + | LE323: |
- | LE325: lda $00 ;Load Samus' current horizontal speed. | + | LE325: |
- | LE327: bpl +++ ;Branch if moving right. | + | LE327: |
;Samus is moving left. | ;Samus is moving left. | ||
- | LE329: jsr TwosCompliment ;($C3D4)Get twos compliment of horizontal speed. | + | LE329: |
- | LE32C: ldy SamusInLava ;Is Samus in lava? | + | LE32C: |
- | LE32E: beq + ;If not, branch, | + | LE32E: |
- | LE330: lsr ;else cut horizontal speed in half. | + | LE330: |
- | LE331: beq Exit10 ;Branch to exit if Samus not going to move this frame. | + | LE331: |
- | LE333:* sta ObjectCounter ;Store number of pixels to move Samus this frame. | + | LE333:* sta ObjectCounter |
- | LE335:* jsr MoveSamusLeft ; | + | LE335:* jsr MoveSamusLeft |
- | LE338: jsr CheckStopHorzMvmt ; | + | LE338: |
- | LE33B: dec ObjectCounter ;1 pixel movement is complete. | + | LE33B: |
- | LE33D: bne - ;Branch if Samus needs to be moved another pixel. | + | LE33D: |
- | LE33F: lda SamusDoorData ;Has Samus entered a door? | + | LE33F: |
- | LE341: beq Exit10 ;If not, branch to exit. | + | LE341: |
- | LE343: lda #$01 ;Door leads to the left. | + | LE343: |
- | LE345: bne ++++ ;Branch always. | + | LE345: |
;Samus is moving right. | ;Samus is moving right. | ||
- | LE347:* beq Exit10 ;Branch to exit if Samus not moving horizontally. | + | LE347:* beq Exit10 |
- | LE349: ldy SamusInLava ;Is Samus in lava? | + | LE349: |
- | LE34B: beq + ;If not, branch, | + | LE34B: |
- | LE34D: lsr ;else cut horizontal speed in half. | + | LE34D: |
- | LE34E: beq Exit10 ;Branch to exit if Samus not going to move this frame. | + | LE34E: |
- | LE350:* sta ObjectCounter ;Store number of pixels to move Samus this frame. | + | LE350:* sta ObjectCounter |
- | LE352:* jsr MoveSamusRight ; | + | LE352:* jsr MoveSamusRight |
- | LE355: jsr CheckStopHorzMvmt ; | + | LE355: |
- | LE358: dec ObjectCounter ;1 pixel movement is complete. | + | LE358: |
- | LE35A: bne - ;Branch if Samus needs to be moved another pixel. | + | LE35A: |
- | LE35C: lda SamusDoorData ;Has Samus entered a door? | + | LE35C: |
- | LE35E: beq Exit10 ;If not, branch to exit. | + | LE35E: |
- | LE360: lda #$00 ; | + | LE360: |
- | LE362:* sta SamusDoorDir ;Door leads to the right. | + | LE362:* sta SamusDoorDir |
Exit10: | Exit10: | ||
- | LE364: rts ;Exit for routines above and below. | + | LE364: |
CheckStopHorzMvmt: | CheckStopHorzMvmt: | ||
- | LE365: | + | LE365: |
- | LE367: lda #$01 ;Load counter with #$01 so this function will not be--> | + | LE367: |
- | LE369: sta ObjectCounter ;called again. | + | LE369: |
- | LE36C: lda SamusGravity ;Is Samus on the ground? | + | LE36C: |
- | LE36E: bne Exit10 ;If not, branch to exit. | + | LE36E: |
- | LE370: lda ObjAction ; | + | LE370: |
- | LE373: cmp #sa_Roll ;Is Samus rolled into a ball? | + | LE373: |
- | LE375: beq Exit10 ;If so, branch to exit. | + | LE375: |
- | LE377: jmp StopHorzMovement ; | + | LE377: |
; | ; | ||
Line 5559: | Line 5559: | ||
VertAccelerate: | VertAccelerate: | ||
- | LE37A: | + | LE37A: |
- | LE37D: bne ++ ;Branch if yes. | + | LE37D: |
- | LE37F: lda #$18 ; | + | LE37F: |
- | LE381: sta SamusHorzSpeedMax ;Set Samus maximum running speed. | + | LE381: |
- | LE384: lda ObjectY ; | + | LE384: |
- | LE387: clc ; | + | LE387: |
- | LE388: adc ObjRadY ;Check is Samus is obstructed downwards on y room--> | + | LE388: |
- | LE38B: and #$07 ;positions divisible by 8(every 8th pixel). | + | LE38B: |
- | LE38D: bne + ; | + | LE38D: |
- | LE38F: jsr CheckMoveDown ;($E7AD)Is Samus obstructed downwards? | + | LE38F: |
- | LE392: bcc ++ ;Branch if yes. | + | LE392: |
- | LE394:* jsr SamusOnElevatorOrEnemy ; | + | LE394:* jsr SamusOnElevatorOrEnemy |
- | LE397: lda SamusOnElevator ;Is Samus on an elevator? | + | LE397: |
- | LE39A: bne + ;Branch if yes. | + | LE39A: |
- | LE39C: lda OnFrozenEnemy ;Is Samus standing on a frozen enemy? | + | LE39C: |
- | LE39E: bne + ;Branch if yes. | + | LE39E: |
- | LE3A0: lda #$1A ;Samus is falling. Store falling gravity value. | + | LE3A0: |
- | LE3A2: sta SamusGravity ; | + | LE3A2: |
- | LE3A5:* ldx #$05 ;Load X with maximum downward speed. | + | LE3A5:* ldx #$05 ;Load X with maximum downward speed. |
- | LE3A7: lda VertCntrLinear ; | + | LE3A7: |
- | LE3AA: clc ;The higher the gravity, the faster this addition overflows--> | + | LE3AA: |
- | LE3AB: adc SamusGravity ;and the faster ObjVertSpeed is incremented. | + | LE3AB: |
- | LE3AE: sta VertCntrLinear ; | + | LE3AE: |
- | LE3B1: lda ObjVertSpeed ;Every time above addition sets carry bit, ObjVertSpeed is--> | + | LE3B1: |
- | LE3B4: adc #$00 ; | + | LE3B4: |
- | LE3B6: sta ObjVertSpeed ;and slowing down a jump. | + | LE3B6: |
- | LE3B9: bpl + ;Branch if Samus is moving downwards. | + | LE3B9: |
;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: |
- | LE3BD: cmp VertCntrLinear ;Sets carry bit. | + | LE3BD: |
- | LE3C0: sbc ObjVertSpeed ;Subtract ObjVertSpeed to see if maximum speed has--> | + | LE3C0: |
- | LE3C3: cmp #$06 ;been exceeded. | + | LE3C3: |
- | LE3C5: ldx #$FA ;Load X with maximum upward speed. | + | LE3C5: |
- | LE3C7: bne ++ ;Branch always. | + | LE3C7: |
;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 + |
;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 ; | + | LE3CD: |
- | LE3D0: stx ObjVertSpeed ;Set Samus vertical speed to max. | + | LE3D0: |
;This portion of the function creates an exponential increase/ | ;This portion of the function creates an exponential increase/ | ||
;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: |
- | LE3D7: adc VertCntrLinear ;onto itself every frame. | + | LE3D7: |
- | LE3DA: sta VertCntrNonLinear ;counter to increase exponentially. | + | LE3DA: |
- | LE3DD: lda #$00 ;cause Samus to reach maximum speed first in most--> | + | LE3DD: |
- | LE3DF: adc ObjVertSpeed ;situations before the linear counter. | + | LE3DF: |
- | LE3E2: sta $00 ;$00 stores temp copy of current verticle speed. | + | LE3E2: |
- | LE3E4: rts ; | + | LE3E4: |
; | ; | ||
Line 5619: | Line 5619: | ||
HorzAccelerate: | HorzAccelerate: | ||
LE3E5: | LE3E5: | ||
- | jsr Amul16 | + | |
- | sta $00 | + | sta $00 |
- | sta $02 | + | sta $02 |
- | lda SamusHorzSpeedMax | + | lda SamusHorzSpeedMax |
- | jsr Adiv16 | + | jsr Adiv16 |
- | sta $01 | + | sta $01 |
- | sta $03 | + | sta $03 |
- | 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 + |
- | lda #$FF | + | |
* adc ObjHorzSpeed | * adc ObjHorzSpeed | ||
- | sta ObjHorzSpeed | + | |
- | tay | + | tay |
- | bpl + ;Branch if Samus accelerating to the right. | + | bpl + |
- | 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 | + | |
- | 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 | + | |
- | 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 |
- | rts ; | + | rts |
LE449: | LE449: | ||
- | 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: |
- | sec ; | + | sec |
- | sbc ObjRadY ;Subtract Samus' vertical radius. | + | sbc ObjRadY |
- | LE45E: and #$07 ;Check if result is a multiple of 8. If so, branch to--> | + | LE45E: |
- | LE460: bne + ;Only call crash detection every 8th pixel. | + | LE460: |
- | LE462: jsr CheckMoveUp ; | + | LE462: |
- | bcc +++++++ ;If so, branch to exit(can' | + | bcc +++++++ |
- | * lda ObjAction ; | + | * lda ObjAction |
- | cmp # | + | cmp # |
- | beq + ;If so, branch. | + | beq + |
- | jsr SamusOnElevatorOrEnemy ; | + | jsr SamusOnElevatorOrEnemy |
- | 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? | + | |
- | bcs + ; branch if not | + | bcs + ; branch if not |
- | jsr ScrollUp | + | jsr ScrollUp |
- | bcc ++ | + | bcc ++ |
* dec SamusScrY | * dec SamusScrY | ||
- | * lda ObjectY | + | * |
- | bne ++ | + | bne ++ |
- | lda ScrollDir | + | lda ScrollDir |
- | and #$02 | + | and #$02 |
- | bne + | + | bne + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
* lda #240 | * lda #240 | ||
- | sta ObjectY | + | |
- | * dec ObjectY | + | * |
- | inc SamusJumpDsplcmnt | + | inc SamusJumpDsplcmnt |
- | sec | + | sec |
- | * rts | + | * |
; attempt to move Samus one pixel down | ; attempt to move Samus one pixel down | ||
MoveSamusDown: | MoveSamusDown: | ||
- | 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 | + | jsr CheckMoveDown |
- | bcc +++++++ ; exit if yes | + | bcc +++++++ |
* lda ObjAction | * lda ObjAction | ||
- | cmp # | + | |
- | 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? | + | |
- | bcc + ; branch if not | + | bcc + ; branch if not |
- | jsr ScrollDown | + | jsr ScrollDown |
- | bcc ++ | + | bcc ++ |
* inc SamusScrY | * inc SamusScrY | ||
- | * lda ObjectY | + | * |
- | cmp #239 | + | cmp #239 |
- | bne ++ | + | bne ++ |
- | lda ScrollDir | + | lda ScrollDir |
- | and #$02 | + | and #$02 |
- | bne + | + | bne + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
* lda #$FF | * lda #$FF | ||
- | sta ObjectY | + | |
- | * inc ObjectY | + | * |
- | dec SamusJumpDsplcmnt | + | dec SamusJumpDsplcmnt |
- | sec | + | sec |
- | * rts | + | * |
; Attempt to scroll UP | ; Attempt to scroll UP | ||
- | 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 + | + | |
- | dec MapPosY | + | dec MapPosY |
- | jsr GetRoomNum | + | jsr GetRoomNum |
- | 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 | + | * |
- | jmp LE53F | + | jmp LE53F |
- | * inc MapPosY | + | * |
- | * sec | + | * |
- | rts | + | rts |
; Attempt to scroll DOWN | ; Attempt to scroll DOWN | ||
- | 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 + | + | |
- | inc MapPosY | + | inc MapPosY |
- | jsr GetRoomNum | + | jsr GetRoomNum |
- | 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 | + | |
- | 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: | LE53F: | ||
- | jsr LE54A ; check if it's time to update Name Table | + | |
- | clc | + | clc |
- | rts | + | rts |
- | * dec MapPosY | + | * |
- | * sec | + | * |
* rts | * rts | ||
LE54A: | LE54A: | ||
- | 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 $00 | + | .byte $00 |
; | ; | ||
PPUAddrs: | PPUAddrs: | ||
- | LE560: | + | LE560: |
- | LE561: | + | LE561: |
WRAMAddrs: | WRAMAddrs: | ||
- | LE562: | + | LE562: |
- | LE563: | + | LE563: |
GetNameAddrs: | GetNameAddrs: | ||
- | LE564: jsr GetNameTable ;($EB85)Get current name table number. | + | LE564: |
- | LE567: and #$01 ;Update name table 0 or 3. | + | LE567: |
- | LE569: tay ; | + | LE569: |
- | LE56A: lda PPUAddrs,y ;Get high PPU addr of nametable(dest). | + | LE56A: |
- | LE56D: ldx WRAMAddrs, | + | LE56D: |
- | LE570: rts ; | + | LE570: |
; | ; | ||
Line 5852: | Line 5852: | ||
LE571: | LE571: | ||
- | 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 -- |
- | LE57C: | + | LE57C: |
- | cpx TempScrollDir ;Still scrolling same direction when room was loaded? | + | cpx TempScrollDir |
- | 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: | + | LE590: |
- | 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 |
- | tax | + | tax |
- | lda Table01,x | + | lda Table01,x |
- | sta $04 | + | sta $04 |
- | ldy #$01 | + | ldy #$01 |
- | sty PPUDataPending | + | sty PPUDataPending |
- | dey | + | dey |
- | ldx PPUStrIndex | + | ldx PPUStrIndex |
- | lda $03 | + | lda $03 |
- | jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | jsr WritePPUByte |
- | lda $02 | + | lda $02 |
- | jsr WritePPUByte | + | jsr WritePPUByte |
- | lda $04 | + | lda $04 |
- | jsr SeparateControlBits ;($C3C6) | + | jsr SeparateControlBits |
* lda ($00),y | * lda ($00),y | ||
- | 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 |
- | 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 $9E ;Vertical write... PPU inc = 32, length = 30 tiles. | + | .byte $9E |
; | ; | ||
WritePPUAttribTbl: | WritePPUAttribTbl: | ||
- | LE5E2: | + | LE5E2: |
- | LE5E4: lda RoomNumber ; | + | LE5E4: |
- | LE5E6: cmp #$F2 ;Is this the second pass through the routine? | + | LE5E6: |
- | LE5E8: beq + ;If so, branch. | + | LE5E8: |
- | LE5EA: ldx #$E0 ;Low byte of second row of attribute table. | + | LE5EA: |
- | LE5EC:* stx $00 ; | + | LE5EC:* stx $00 |
- | LE5EE: stx $02 ;$0002=PPU attrib table starting address. | + | LE5EE: |
- | LE5F0: jsr GetNameAddrs ;($E564)Get name table addr and corresponding RoomRAM addr. | + | LE5F0: |
- | LE5F3: ora #$03 ;#$23 for attrib table 0, #$2F for attrib table 3. | + | LE5F3: |
- | LE5F5: sta $03 ;Store results. | + | LE5F5: |
- | LE5F7: txa ;move high byte of RoomRAM to A. | + | LE5F7: |
- | LE5F8: ora #$03 ;#$63 for RoomRAMA, #$67 for RoomRAMB(Attrib tables). | + | LE5F8: |
- | LE5FA: sta $01 ;Store results. | + | LE5FA: |
- | LE5FC: lda #$01 ; | + | LE5FC: |
- | LE5FE: sta PPUDataPending ;Data pending = YES. | + | LE5FE: |
- | LE600: ldx PPUStrIndex ;Load current index into PPU strng to append data. | + | LE600: |
- | LE603: lda $03 ;Store high byte of starting address(attrib table). | + | LE603: |
- | LE605: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | LE605: |
- | LE608: lda $02 ;Store low byte of starting address(attrib table). | + | LE608: |
- | LE60A: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | LE60A: |
- | LE60D: lda #$20 ;Length of data to write(1 row of attrib data). | + | LE60D: |
- | LE60F: sta $04 ; | + | LE60F: |
- | LE611: jsr WritePPUByte ; | + | LE611: |
- | LE614: ldy #$00 ;Reset index into data string. | + | LE614: |
- | LE616:* lda ($00),y ;Get data byte. | + | LE616:* lda ($00), |
- | LE618: jsr WritePPUByte ;($C36B)Put data byte into PPUDataString. | + | LE618: |
- | LE61B: iny ;Increment to next attrib data byte. | + | LE61B: |
- | LE61C: dec $04 ; | + | LE61C: |
- | LE61E: bne - ;Loop until all attrib data loaded into PPU. | + | LE61E: |
- | LE620: stx PPUStrIndex ;Store updated PPU string index. | + | LE620: |
- | LE623: jsr EndPPUString ; | + | LE623: |
; | ; | ||
Line 5951: | Line 5951: | ||
MoveSamusLeft: | MoveSamusLeft: | ||
- | LE626: lda ObjectX | + | LE626: |
- | 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 | + | jsr CheckMoveLeft |
- | bcc +++++ ; branch if yes! (CF = 0) | + | bcc +++++ ; branch if yes! (CF = 0) |
* jsr LD976 | * jsr LD976 | ||
- | 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 | + | * |
- | bne + | + | bne + |
- | lda ScrollDir | + | lda ScrollDir |
- | and #$02 | + | and #$02 |
- | beq + | + | beq + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
* dec ObjectX | * dec ObjectX | ||
- | sec | + | |
- | rts | + | rts |
; crash with object on the left | ; crash with object on the left | ||
- | * 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 | + | |
- | 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 | + | jsr CheckMoveRight |
- | bcc +++++ ; branch if yes! (CF = 0) | + | bcc +++++ ; branch if yes! (CF = 0) |
* jsr LD976 | * jsr LD976 | ||
- | 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 | + | * |
- | bne + | + | bne + |
- | lda ScrollDir | + | lda ScrollDir |
- | and #$02 | + | and #$02 |
- | beq + | + | beq + |
- | jsr ToggleSamusHi | + | jsr ToggleSamusHi |
* sec | * sec | ||
- | rts | + | |
; crash with object on the right | ; crash with object on the right | ||
- | * lda #$00 | + | * |
- | sta SamusDoorData | + | sta SamusDoorData |
- | rts | + | rts |
; Attempt to scroll LEFT | ; Attempt to scroll LEFT | ||
- | 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 + | + | |
- | dec MapPosX | + | dec MapPosX |
- | jsr GetRoomNum | + | jsr GetRoomNum |
- | 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 | + | |
- | clc | + | clc |
- | rts | + | rts |
- | * inc MapPosX | + | * |
- | * sec | + | * |
- | rts | + | rts |
; Attempt to scroll RIGHT | ; Attempt to scroll RIGHT | ||
ScrollRight: | ScrollRight: | ||
- | 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 + | + | |
- | inc MapPosX | + | inc MapPosX |
- | jsr GetRoomNum | + | jsr GetRoomNum |
- | 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 + | + | |
- | 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 | + | |
- | rts | + | rts |
- | * dec MapPosX | + | * |
- | * sec | + | * |
* rts | * rts | ||
Table02: | Table02: | ||
- | .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: | LE701: | ||
- | 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: | LE70C: | ||
- | 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 |
; | ; | ||
Line 6105: | Line 6105: | ||
GetRoomNum: | GetRoomNum: | ||
- | LE720: lda ScrollDir ; | + | LE720: |
- | LE722: lsr ;Branch if scrolling vertical. | + | LE722: |
- | LE723: beq + ; | + | LE723: |
- | LE725: rol ;Restore value of a | + | LE725: |
- | LE726: adc #$FF ;A=#$01 if scrolling left, A=#$02 if scrolling right. | + | LE726: |
- | LE728: pha ;Save A. | + | LE728: |
- | LE729: jsr OnNameTable0 ;($EC93)Y=1 if name table=0, Y=0 if name table=3. | + | LE729: |
- | LE72C: pla ;Restore A. | + | LE72C: |
- | LE72D: and $006C,y ; | + | LE72D: |
- | LE730: sec ; | + | LE730: |
- | LE731: bne +++++ ;Can't load room, a door is in the way. This has the--> | + | LE731: |
- | ;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 |
- | LE735: jsr Amul16 ; | + | LE735: |
- | LE738: sta $00 ;Store multiplied value in $00. | + | LE738: |
- | LE73A: lda #$00 ; | + | LE73A: |
- | LE73C: rol ;Save carry, if any. | + | LE73C: |
- | LE73D: rol $00 ;Multiply value in $00 by 2. | + | LE73D: |
- | LE73F: rol ;Save carry, if any. | + | LE73F: |
- | LE740: sta $01 ; | + | LE740: |
- | LE742: lda $00 ; | + | LE742: |
- | LE744: adc MapPosX ;Add map pos X to A. | + | LE744: |
- | LE746: sta $00 ;Store result. | + | LE746: |
- | LE748: lda $01 ; | + | LE748: |
- | LE74A: adc #$70 ;Add #$7000 to result. | + | LE74A: |
- | LE74C: sta $01 ;$0000 = (MapY*32)+MapX+# | + | LE74C: |
- | LE74E: ldy #$00 ; | + | LE74E: |
- | LE750: lda ($00),y ;Load room number. | + | LE750: |
- | LE752: cmp #$FF ;Is it unused? | + | LE752: |
- | LE754: beq ++++ ;If so, branch to exit with carry flag set. | + | LE754: |
- | LE756: sta RoomNumber ;Store room number. | + | LE756: |
- | LE758:* cmp $95D0,y ;Is it a special room? | + | LE758:* cmp $95D0, |
- | LE75B: beq + ;If so, branch to set flag to play item room music. | + | LE75B: |
- | LE75D: iny ; | + | LE75D: |
- | LE75E: cpy #$07 ; | + | LE75E: |
- | LE760: bne - ;Loop until all special room numbers are checked. | + | LE760: |
- | LE762: lda ItemRoomMusicStatus ;Load item room music status. | + | LE762: |
- | LE764: beq ++ ;Branch if not in special room. | + | LE764: |
- | LE766: lda #$80 ;Ptop playing item room music after next music start. | + | LE766: |
- | LE768: bne ++ ;Branch always. | + | LE768: |
- | 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: |
- | LE76F: | + | LE76F:* rts |
; | ; | ||
- | LE770: ldx PageIndex | + | LE770: |
- | lda EnRadY,x | + | lda EnRadY,x |
- | clc | + | clc |
- | adc #$08 | + | adc #$08 |
- | jmp LE783 | + | jmp LE783 |
LE77B: | LE77B: | ||
- | lda #$00 | + | |
- | sec | + | sec |
- | sbc EnRadY,x | + | sbc EnRadY,x |
LE783: | LE783: | ||
- | lda #$08 | + | |
- | sta $04 | + | sta $04 |
- | jsr LE792 | + | jsr LE792 |
- | lda EnRadX,x | + | lda EnRadX,x |
- | jmp LE7BD | + | jmp LE7BD |
LE792: | LE792: | ||
- | 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: |
- | lda ObjRadY,x | + | lda ObjRadY,x |
- | clc | + | clc |
- | adc #$08 | + | adc #$08 |
- | jmp + | + | jmp + |
CheckMoveDown: | CheckMoveDown: | ||
- | ldx PageIndex | + | |
- | lda #$00 | + | lda #$00 |
- | sec | + | sec |
- | sbc ObjRadY,x | + | sbc ObjRadY,x |
* sta $02 | * sta $02 | ||
- | jsr LE8BE | + | |
- | lda ObjRadX,x | + | lda ObjRadX,x |
LE7BD: | LE7BD: | ||
- | sec | + | |
- | rts | + | rts |
* sta $03 | * sta $03 | ||
- | 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 | + | |
- | jsr LE90F | + | jsr LE90F |
- | ldx #$00 | + | ldx #$00 |
- | ldy #$08 | + | ldy #$08 |
- | lda $00 | + | lda $00 |
LE7DE: | LE7DE: | ||
- | stx $06 | + | |
- | sty $07 | + | sty $07 |
- | ldx $04 | + | ldx $04 |
; object< | ; object< | ||
- | LE7E6: | + | LE7E6: |
- | ldy #$00 | + | ldy #$00 |
- | lda ($04), | + | lda ($04), |
- | cmp #$4E | + | cmp #$4E |
- | beq LE81E | + | beq LE81E |
- | jsr $95C0 | + | jsr $95C0 |
- | jsr LD651 | + | jsr LD651 |
- | bcc Exit16 | + | bcc Exit16 |
- | cmp #$A0 ; is tile >= A0h? (walkable tile) | + | cmp #$A0 ; is tile >= A0h? (walkable tile) |
- | bcs IsWalkableTile | + | bcs IsWalkableTile |
- | jmp IsBlastTile | + | jmp IsBlastTile |
IsWalkableTile: | IsWalkableTile: | ||
- | ldy IsSamus | + | |
- | beq ++ | + | beq ++ |
; special case for Samus | ; special case for Samus | ||
- | 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 | + | * |
- | beq + | + | beq + |
- | jsr LE98E | + | jsr LE98E |
- | jmp LE7E6 | + | jmp LE7E6 |
- | * sec ; no crash | + | * |
- | Exit16: | + | Exit16: |
- | rts | + | rts |
LE81E: | LE81E: | ||
- | beq ClcExit | + | |
- | ldx #$06 | + | ldx #$06 |
* lda $05 | * lda $05 | ||
- | 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 | + | |
- | sta $0683 | + | sta $0683 |
- | * lda #$04 | + | * |
- | sta $030A,y | + | sta $030A,y |
- | bne ClcExit | + | bne ClcExit |
- | * 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 | + | |
- | rts | + | rts |
PlaySnd4: | PlaySnd4: | ||
- | jmp SFX_Metal | + | |
CheckMoveLeft: | CheckMoveLeft: | ||
- | ldx PageIndex | + | |
- | lda ObjRadX,x | + | lda ObjRadX,x |
- | clc | + | clc |
- | adc #$08 | + | adc #$08 |
- | jmp + | + | jmp + |
CheckMoveRight: | CheckMoveRight: | ||
- | ldx PageIndex | + | |
- | lda #$00 | + | lda #$00 |
- | sec | + | sec |
- | sbc ObjRadX,x | + | sbc ObjRadX,x |
* sta $03 | * sta $03 | ||
- | jsr LE8BE | + | |
- | ldy ObjRadY,x | + | ldy ObjRadY,x |
LE89B: | LE89B: | ||
- | sec | + | |
- | rts | + | rts |
* sty $02 | * sty $02 | ||
- | 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 | + | |
- | jsr LE90F | + | jsr LE90F |
- | ldx #$08 | + | ldx #$08 |
- | ldy #$00 | + | ldy #$00 |
- | lda $01 | + | lda $01 |
- | jmp LE7DE | + | jmp LE7DE |
LE8BE: | LE8BE: | ||
- | 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: | LE8CE: | ||
- | 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 |
- | sta $04 | + | sta $04 |
- | tya | + | tya |
- | and #$07 | + | and #$07 |
- | beq + | + | beq + |
- | inx | + | inx |
* txa | * txa | ||
- | clc | + | |
- | adc $04 | + | adc $04 |
- | rts | + | rts |
LE8F1: | LE8F1: | ||
- | lda EnRadX,x | + | |
- | clc | + | clc |
- | adc #$08 | + | adc #$08 |
- | jmp LE904 | + | jmp LE904 |
LE8FC: | LE8FC: | ||
- | lda #$00 | + | |
- | sec | + | sec |
- | sbc EnRadX,x | + | sbc EnRadX,x |
LE904: | LE904: | ||
- | jsr LE792 | + | |
- | ldy EnRadY,x | + | ldy EnRadY,x |
- | jmp LE89B | + | jmp LE89B |
LE90F: | LE90F: | ||
- | bpl ++ | + | |
- | jsr LE95F | + | jsr LE95F |
- | bcs + | + | bcs + |
- | cpx #$F0 | + | cpx #$F0 |
- | bcc +++ | + | bcc +++ |
* txa | * txa | ||
- | adc #$0F | + | |
- | jmp LE934 | + | jmp LE934 |
- | * 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: | LE934: | ||
- | lda ScrollDir | + | |
- | and #$02 | + | and #$02 |
- | bne + | + | bne + |
- | inc $0B | + | inc $0B |
- | * stx $02 | + | * |
- | ldx #$00 | + | ldx #$00 |
- | lda $03 | + | lda $03 |
- | bmi + | + | bmi + |
- | dex | + | dex |
* lda $09 | * lda $09 | ||
- | 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: | LE95F: | ||
- | sec | + | |
- | sbc $02 | + | sbc $02 |
- | tax | + | tax |
- | and #$07 | + | and #$07 |
- | sta $00 | + | sta $00 |
- | rts | + | rts |
; | ; | ||
Line 6452: | Line 6452: | ||
MakeCartRAMPtr: | MakeCartRAMPtr: | ||
- | LE96A: lda #$18 ;Set pointer to $6xxx(cart RAM). | + | LE96A: |
- | LE96C: sta $05 ; | + | LE96C: |
- | LE96E: lda $02 ;Object Y room position. | + | LE96E: |
- | LE970: and #$F8 ;Drop 3 LSBs. Only use multiples of 8. | + | LE970: |
- | LE972: asl ; | + | LE972: |
- | LE973: rol $05 ; | + | LE973: |
- | LE975: asl ;Move upper 2 bits to lower 2 bits of $05 and move y bits--> | + | LE975: |
- | LE976: rol $05 ;3, 4, 5 to upper 3 bits of $04. | + | LE976: |
- | LR978: sta $04 ; | + | LR978: |
- | LE97A: lda $03 ;Object X room position. | + | LE97A: |
- | LE97C: lsr ; | + | LE97C: |
- | LE97D: lsr ; | + | LE97D: |
- | LE97E: lsr ; | + | LE97E: |
- | LE97F: ora $04 ; | + | LE97F: |
- | LE981: sta $04 ;Put bits 0 thru 4 into $04. | + | LE981: |
- | LE983: lda $0B ;Object nametable. | + | LE983: |
- | LE985: asl ; | + | LE985: |
- | LE986: asl ; A=ObjectHi*4. | + | LE986: |
- | LE987: and #$04 ;Set bit 2 if object is on nametable 3. | + | LE987: |
- | LE989: ora $05 ; | + | LE989: |
- | LE98B: sta $05 ;Include nametable bit in $05. | + | LE98B: |
- | LE98D: rts ;Return pointer in $04 = 01100HYY YYYXXXXX. | + | LE98D: |
; | ; | ||
LE98E: | LE98E: | ||
- | 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 | + | |
- | 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: | LE9B7: | ||
- | eor #$03 | + | |
- | sta PPUCNT0ZP | + | sta PPUCNT0ZP |
- | rts | + | rts |
IsBlastTile: | IsBlastTile: | ||
- | ldy UpdatingProjectile | + | |
- | beq Exit18 | + | beq Exit18 |
LE9C2: | LE9C2: | ||
- | jsr $95BD | + | |
- | cpy #$98 | + | cpy #$98 |
- | bcs +++++ | + | bcs +++++ |
; attempt to find a vacant tile slot | ; attempt to find a vacant tile slot | ||
- | ldx #$C0 | + | |
* lda TileRoutine, | * lda TileRoutine, | ||
- | 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, | * inc TileRoutine, | ||
- | 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 | + | * |
- | clc | + | clc |
- | adc #$10 | + | adc #$10 |
- | and #$3C | + | and #$3C |
- | lsr | + | lsr |
- | * lsr | + | * |
- | sta TileType, | + | sta TileType, |
- | * clc | + | * |
Exit18: rts | Exit18: rts | ||
Line 6546: | Line 6546: | ||
SelectRoomRAM: | SelectRoomRAM: | ||
- | LEA05: jsr GetNameTable ; | + | LEA05: |
- | LEA08: asl ; | + | LEA08: |
- | LEA09: asl ; | + | LEA09: |
- | LEA0A: ora #$60 ;A=#$64 for name table 3, A=#$60 for name table 0. | + | LEA0A: |
- | LEA0C: sta CartRAMPtr+1 ; | + | LEA0C: |
- | LEA0E: lda #$00 ; | + | LEA0E: |
- | LEA10: sta CartRAMPtr ;Save two byte pointer to start of proper room RAM. | + | LEA10: |
- | LEA12: rts ; | + | LEA12: |
; | ; | ||
AttribTableWrite: | AttribTableWrite: | ||
- | LEA13:* lda RoomNumber ; | + | LEA13:* lda RoomNumber |
- | LEA15: and #$0F ;Determine what row of PPU attribute table data, if any, | + | LEA15: |
- | LEA17: inc RoomNumber ;to load from RoomRAM into PPU. | + | LEA17: |
- | LEA19: jsr ChooseRoutine ; | + | LEA19: |
;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: | + | LEA1c: |
- | LEA1E: | + | LEA1E: |
- | LEA20: | + | LEA20: |
- | LEA22: | + | LEA22: |
- | LEA24: | + | LEA24: |
; | ; | ||
RoomFinished: | RoomFinished: | ||
- | LEA26: | + | LEA26: |
- | LEA28: sta RoomNumber ;Set RoomNumber to #$FF. | + | LEA28: |
- | LEA2A: | + | LEA2A:* rts |
; | ; | ||
SetupRoom: | SetupRoom: | ||
- | LEA2B: lda RoomNumber ;Room number. | + | LEA2B: |
- | LEA2D: cmp #$FF ; | + | LEA2D: |
- | LEA2F: beq - ;Branch to exit if room is undefined. | + | LEA2F: |
- | LEA31: cmp #$FE ; | + | LEA31: |
- | LEA33: beq + ;Branch if empty place holder byte found in room data. | + | LEA33: |
- | LEA35: cmp #$F0 ; | + | LEA35: |
- | LEA37: bcs -- ;Branch if time to write PPU attribute table data. | + | LEA37: |
- | LEA39: jsr UpdateRoomSpriteInfo ; | + | LEA39: |
- | LEA3C: jsr ScanForItems ;($ED98)Set up any special items. | + | LEA3C: |
- | LEA3F: lda RoomNumber ;Room number to load. | + | LEA3F: |
- | LEA41: asl ;*2(for loading address of room pointer). | + | LEA41: |
- | LEA42: tay ; | + | LEA42: |
- | LEA43: lda (RoomPtrTable), | + | LEA43: |
- | LEA45: sta RoomPtr ;Base copied from $959A to $3B. | + | LEA45: |
- | LEA47: iny ; | + | LEA47: |
- | LEA48: lda (RoomPtrTable), | + | LEA48: |
- | LEA4A: sta RoomPtr+1 ;Base copied from $959B to $3C. | + | LEA4A: |
- | LEA4C: ldy #$00 ; | + | LEA4C: |
- | LEA4E: lda (RoomPtr), | + | LEA4E: |
- | LEA50: sta RoomPal ;store initial palette # to fill attrib table with. | + | LEA50: |
- | LEA52: lda #$01 ; | + | LEA52: |
- | LEA54: jsr AddToRoomPtr ; | + | LEA54: |
- | LEA57: jsr SelectRoomRAM ; | + | LEA57: |
- | LEA5A: jsr InitTables ; | + | LEA5A: |
- | LEA5D:* jmp DrawRoom ; | + | LEA5D:* jmp DrawRoom |
; | ; | ||
DrawObject: | DrawObject: | ||
- | LEA60: sta $0E ;Store object position byte(%yyyyxxxx). | + | LEA60: |
- | LEA62: lda CartRAMPtr ; | + | LEA62: |
- | LEA64: sta CartRAMWorkPtr ;Set the working pointer equal to the room pointer--> | + | LEA64: |
- | LEA66: lda CartRAMPtr+1 ;(start at beginning of the room). | + | LEA66: |
- | LEA68: sta CartRAMWorkPtr+1 ; | + | LEA68: |
- | LEA6A: lda $0E ;Reload object position byte. | + | LEA6A: |
- | LEA6C: jsr Adiv16 ; | + | LEA6C: |
- | LEA6F: tax ;Transfer it to X, prepare for loop. | + | LEA6F: |
- | LEA70: beq +++ ;Skip y position calculation loop as y position=0 and--> | + | LEA70: |
- | ;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 |
- | LEA74: clc ; | + | LEA74: |
- | LEA75: adc #$40 ;Advance two rows in room RAM(one y unit). | + | LEA75: |
- | LEA77: sta CartRAMWorkPtr ; | + | LEA77: |
- | LEA79: bcc + ;If carry occurred, increment high byte of pointer--> | + | LEA79: |
- | LEA7B: inc CartRAMWorkPtr+1 ;in room RAM. | + | LEA7B: |
- | LEA7D: | + | LEA7D:* dex |
- | LEA7E: bne -- ;Repeat until at desired y position(X=0). | + | LEA7E: |
- | LEA80:* lda $0E ;Reload object position byte. | + | LEA80:* lda $0E |
- | LEA82: and #$0F ;Remove y position upper nibble. | + | LEA82: |
- | LEA84: asl ;Each x unit is 2 tiles. | + | LEA84: |
- | LEA85: adc CartRAMWorkPtr ; | + | LEA85: |
- | LEA87: sta CartRAMWorkPtr ;Add x position to room RAM work pointer. | + | LEA87: |
- | LEA89: bcc + ;If carry occurred, increment high byte of room RAM work--> | + | LEA89: |
- | LEA8B: inc CartRAMWorkPtr+1 ;pointer, else branch to draw object. | + | LEA8B: |
; | ; | ||
;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: | + | LEA8D:* iny |
- | LEA8E: lda (RoomPtr), | + | LEA8E: |
- | LEA90: tax ;Transfer structure pointer index into X. | + | LEA90: |
- | LEA91: iny ;Move to the next byte of room data which is--> | + | LEA91: |
- | LEA92: lda (RoomPtr), | + | LEA92: |
- | LEA94: sta ObjectPal ;Save attribute table info. | + | LEA94: |
- | LEA96: txa ;Restore structure pointer to A. | + | LEA96: |
- | LEA97: asl ;*2. Structure pointers are two bytes in size. | + | LEA97: |
- | LEA98: tay ; | + | LEA98: |
- | LEA99: lda (StructPtrTable), | + | LEA99: |
- | LEA9B: sta StructPtr ; | + | LEA9B: |
- | LEA9D: iny ; | + | LEA9D: |
- | LEA9E: lda (StructPtrTable), | + | LEA9E: |
- | LEAA0: sta StructPtr+1 ; | + | LEAA0: |
- | LEAA2: jsr DrawStruct ; | + | LEAA2: |
- | LEAA5: lda #$03 ;Move to next set of structure data. | + | LEAA5: |
- | LEAA7: jsr AddToRoomPtr ;($EAC0)Add A to room data pointer. | + | LEAA7: |
; | ; | ||
Line 6664: | Line 6664: | ||
DrawRoom: | DrawRoom: | ||
- | LEAAA: ldy #$00 ;Zero index. | + | LEAAA: |
- | LEAAC: lda (RoomPtr), | + | LEAAC: |
- | LEAAE: cmp #$FF ;Is it # | + | LEAAE: |
- | LEAB0: beq EndOfRoom ;If so, branch to exit. | + | LEAB0: |
- | LEAB2: cmp #$FE ;Place holder for empty room objects(not used). | + | LEAB2: |
- | LEAB4: beq + ; | + | LEAB4: |
- | LEAB6: cmp #$FD ;is A=# | + | LEAB6: |
- | LEAB8: bne DrawObject ;If not, branch to draw room object.--> | + | LEAB8: |
- | LEABA: beq EndOfObjs ;Else branch to set up enemies/ | + | LEABA: |
- | LEABC:* sta RoomNumber ;Store #$FE if room object is empty. | + | LEABC:* sta RoomNumber |
- | LEABE: lda #$01 ;Prepare to increment RoomPtr. | + | LEABE: |
; | ; | ||
AddToRoomPtr: | AddToRoomPtr: | ||
- | LEAC0: clc ;Prepare to add index in A to room pointer. | + | LEAC0: |
- | LEAC1: adc RoomPtr ; | + | LEAC1: |
- | LEAC3: sta RoomPtr ; | + | LEAC3: |
- | LEAC5: bcc + ;Did carry occur? If not branch to exit. | + | LEAC5: |
- | LEAC7: inc RoomPtr+1 ;Increment high byte of room pointer if carry occured. | + | LEAC7: |
- | LEAC9: | + | LEAC9:* rts |
; | ; | ||
EndOfObjs: | EndOfObjs: | ||
- | LEACA: lda RoomPtr ; | + | LEACA: |
- | LEACC: sta $00 ;Store room pointer in $0000. | + | LEACC: |
- | LEACE: lda RoomPtr+1 ; | + | LEACE: |
- | LEAD0: sta $01 ; | + | LEAD0: |
- | LEAD2: lda #$01 ;Prepare to increment to enemy/door data. | + | LEAD2: |
EnemyLoop: | EnemyLoop: | ||
- | LEAD4: jsr AddToPtr00 ;($EF09)Add A to pointer at $0000. | + | LEAD4: |
- | LEAD7: ldy #$00 ; | + | LEAD7: |
- | LEAD9: lda ($00),y ;Get first byte of enemy/door data. | + | LEAD9: |
- | LEADB: cmp #$FF ;End of enemy/door data? | + | LEADB: |
- | LEADD: beq EndOfRoom ;If so, branch to finish room setup. | + | LEADD: |
- | LEADF: and #$0F ;Discard upper four bits of data. | + | LEADF: |
- | LEAE1: jsr ChooseRoutine ;Jump to proper enemy/door handling routine. | + | LEAE1: |
;Pointer table to code. | ;Pointer table to code. | ||
- | LEAE4: | + | LEAE4: |
- | LEAE6: | + | LEAE6: |
- | LEAE8: | + | LEAE8: |
- | LEAEA: | + | LEAEA: |
- | LEAEC: | + | LEAEC: |
- | LEAEE: | + | LEAEE: |
- | LEAF0: | + | LEAF0: |
- | LEAF2: | + | LEAF2: |
EndOfRoom: | EndOfRoom: | ||
- | LEAF4: ldx #$F0 ;Prepare for PPU attribute table write. | + | LEAF4: |
- | stx RoomNumber ; | + | stx RoomNumber |
- | lda ScrollDir ; | + | lda ScrollDir |
- | sta TempScrollDir ;Make temp copy of ScrollDir. | + | sta TempScrollDir |
- | 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: |
- | LEB09: jmp EnemyLoop ;($EAD4)Do next room object. | + | LEB09: |
GetEnemyData: | GetEnemyData: | ||
- | LEB0C: lda ($00),y ;Get 1st byte again. | + | LEB0C: |
- | and #$F0 ;Get object slot that enemy will occupy. | + | and #$F0 ;Get object slot that enemy will occupy. |
- | tax ; | + | tax |
- | jsr IsSlotTaken ; | + | jsr IsSlotTaken |
- | bne ++ ;Exit if object slot taken. | + | bne ++ ;Exit if object slot taken. |
- | iny ; | + | iny |
- | lda ($00),y ;Get enemy type. | + | lda ($00), |
- | jsr GetEnemyType ; | + | jsr GetEnemyType |
- | ldy #$02 ; | + | ldy #$02 ; |
- | lda ($00),y ;Get enemy initial position(%yyyyxxxx). | + | lda ($00), |
- | 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: |
- | and #$C0 ;If MSB is set, the " | + | and #$C0 ;If MSB is set, the " |
- | sta EnSpecialAttribs, | + | sta EnSpecialAttribs, |
- | 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 |
- | and #$06 ;Ridley is alive or dead). | + | and #$06 ;Ridley is alive or dead). |
- | lsr ;Use InArea to find status of Kraid/ | + | lsr |
- | tay ; | + | tay |
- | lda MaxMissiles, | + | lda MaxMissiles, |
- | beq + ;Branch if Kraid or Ridley needs to be loaded. | + | beq + |
- | pla ; | + | pla |
- | pla ;Mini boss is dead so pull enemy info and last address off--> | + | pla |
- | 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' | + | * lda #$01 ;Samus is in Kraid or Ridley' |
- | sta KraidRidleyPresent ;mini boss is alive and needs to be loaded. | + | sta KraidRidleyPresent |
- | * 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, | + | sta EnDataIndex, |
- | rts ; | + | rts |
- | LEB4D: | + | LEB4D: |
- | 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, | + | sta EnYRoomPos, |
- | tya ;Restore enemy position data. | + | tya |
- | jsr Amul16 ;*16 to extract enemy x position. | + | jsr Amul16 |
- | 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, | + | sta EnXRoomPos, |
- | lda #$01 ; | + | lda #$01 ; |
- | sta EnStatus,x ;Indicate object slot is taken. | + | sta EnStatus, |
- | lda #$00 | + | lda #$00 |
- | sta $0404,x | + | sta $0404,x |
- | jsr GetNameTable ;($EB85)Get name table to place enemy on. | + | jsr GetNameTable |
- | sta EnNameTable, | + | sta EnNameTable, |
- | ldy EnDataIndex, | + | ldy EnDataIndex, |
- | asl $0405,x ;*2 | + | asl $0405, |
- | jsr LFB7B | + | jsr LFB7B |
- | jmp LF85A | + | jmp LF85A |
IsSlotTaken: | IsSlotTaken: | ||
- | LEB7A: lda EnStatus, | + | LEB7A: |
- | beq + | + | beq + |
- | lda $0405,x | + | lda $0405,x |
- | and #$02 | + | and #$02 |
* rts | * rts | ||
Line 6805: | Line 6805: | ||
;like so: | ;like so: | ||
; | ; | ||
- | ; +-----+-----+ | + | ; +-----+-----+ |
- | ; | | + | ; | |
; | 2 | 3 | Samus goes from one name table to the next-----> | ; | 2 | 3 | Samus goes from one name table to the next-----> | ||
- | ; | | + | ; | |
- | ; +-----+-----+ | + | ; +-----+-----+ |
- | ; | | + | ; | |
- | ; | 0 | 1 | | + | ; | 0 | 1 | |
- | ; | | + | ; | |
- | ; +-----+-----+ | + | ; +-----+-----+ |
; | ; | ||
;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 | |
- | ; | | + | ; | |
- | ; +-----+-----+ | + | ; +-----+-----+ |
- | ; | /| | | | + | ; | /| |
- | ; | 0<- | 1 | +-|-> | + | ; | 0<- | 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: |
- | LEB87: eor ScrollDir ;Store #$01 if object should be loaded onto name table 3--> | + | LEB87: |
- | LEB89: and #$01 ;store #$00 if it should be loaded onto name table 0. | + | LEB89: |
- | LEB8B: rts ; | + | LEB8B: |
; | ; | ||
Line 6843: | Line 6843: | ||
; ======== | ; ======== | ||
- | LoadDoor: | + | |
- | jsr LEB92 | + | jsr LEB92 |
* jmp EnemyLoop | * jmp EnemyLoop | ||
LEB92: | LEB92: | ||
- | lda ($00), | + | |
- | pha | + | pha |
- | jsr Amul16 | + | jsr Amul16 |
- | 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, | + | sta $0307, |
- | 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 | + | jsr Amul16 |
- | bcc + | + | bcc + |
- | dey | + | dey |
* tya | * tya | ||
- | jsr LEE41 | + | |
- | jsr LEE4A | + | jsr LEE4A |
- | bcs ++ | + | bcs ++ |
- | * lda #$01 | + | * |
- | sta ObjAction,x | + | sta ObjAction,x |
* pla | * pla | ||
- | and #$01 ; A = door side (0=right, 1=left) | + | |
- | tay | + | tay |
- | jsr GetNameTable ;($EB85) | + | jsr GetNameTable |
- | sta ObjectHi, | + | sta ObjectHi, |
- | lda DoorXs, | + | lda DoorXs, |
- | 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 |
- | 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 $10 ; X coord of LEFT door | + | .byte $10 ; X coord of LEFT door |
LEBFE: | LEBFE: | ||
- | .byte $01 | + | |
LEC00: | LEC00: | ||
- | .byte $B0 | + | |
- | .byte $A0 | + | .byte $A0 |
- | .byte $90 | + | .byte $90 |
; LoadElevator | ; LoadElevator | ||
; ============ | ; ============ | ||
- | LoadElevator: | + | |
- | jsr LEC09 | + | jsr LEC09 |
- | bne ---- ; branch always | + | bne ---- |
LEC09: | LEC09: | ||
- | 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 |
- | 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 |
* lda #$02 | * lda #$02 | ||
- | rts | + | |
; LoadStatues | ; LoadStatues | ||
; =========== | ; =========== | ||
- | LoadStatues: | + | |
- | jsr GetNameTable ;($EB85) | + | jsr GetNameTable |
- | 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 | + | |
- | 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 | + | |
- | lda #$01 | + | lda #$01 |
- | sta $0360 | + | sta $0360 |
- | * jmp EnemyLoop | + | * |
ZebHole: | ZebHole: | ||
LEC57: | LEC57: | ||
* txa | * txa | ||
- | 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 | + | jsr Amul16 |
- | ora #$00 | + | ora #$00 |
- | sta $072B,x | + | sta $072B,x |
- | jsr GetNameTable ;($EB85) | + | jsr GetNameTable |
- | sta $072C,x | + | sta $072C,x |
* lda #$03 | * lda #$03 | ||
- | bne --- | + | |
OnNameTable0: | OnNameTable0: | ||
- | LEC93: lda PPUCNT0ZP ; | + | LEC93: |
- | 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: |
- | dex | + | dex |
- | ldy #$00 | + | ldy #$00 |
- | jsr UpdateDoorData ; | + | jsr UpdateDoorData |
- | iny | + | iny |
- | jsr UpdateDoorData ; | + | jsr UpdateDoorData |
- | ldx #$50 | + | ldx #$50 |
- | jsr GetNameTable ;($EB85) | + | jsr GetNameTable |
- | tay | + | tay |
* tya | * tya | ||
- | 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 -- | + | |
- | ldx #$18 | + | ldx #$18 |
* tya | * tya | ||
- | eor $B3,x | + | |
- | lsr | + | lsr |
- | bcs + | + | bcs + |
- | lda #$00 | + | lda #$00 |
- | sta $B0,x | + | sta $B0,x |
* txa | * txa | ||
- | sec | + | |
- | sbc #$08 | + | sbc #$08 |
- | tax | + | tax |
- | bpl -- | + | bpl -- |
- | jsr LED65 | + | jsr LED65 |
- | jsr LED5B | + | jsr LED5B |
- | jsr GetNameTable ;(EB85) | + | jsr GetNameTable |
- | asl | + | asl |
- | asl | + | asl |
- | tay | + | tay |
- | ldx #$C0 | + | ldx #$C0 |
* tya | * tya | ||
- | eor TileWRAMHi, | + | |
- | and #$04 | + | and #$04 |
- | bne + | + | bne + |
- | sta $0500,x | + | sta $0500,x |
* jsr Xminus16 | * jsr Xminus16 | ||
- | 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 + | + | |
- | lda #$FF | + | lda #$FF |
- | sta $0700,x | + | sta $0700,x |
* txa | * txa | ||
- | 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 | + | |
- | bne + | + | bne + |
- | lda #$FF | + | lda #$FF |
- | sta $0728,x | + | sta $0728,x |
* txa | * txa | ||
- | 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: |
- | LED52: eor #$03 ; | + | LED52: |
- | LED54: and $006C,y ;Moves door info from one name table to the next--> | + | LED54: |
- | LED57:* sta $006C,y ;when the room is transferred across name tables. | + | LED57:* sta $006C, |
- | LED5A: rts ; | + | LED5A: |
- | LED5B: | + | LED5B: |
- | eor #$01 | + | eor #$01 |
- | tay | + | tay |
- | lda #$00 | + | lda #$00 |
- | beq - | + | beq - |
LED65: | LED65: | ||
* lda ObjAction,x | * lda ObjAction,x | ||
- | beq + | + | |
- | lda ObjectOnScreen, | + | lda ObjectOnScreen, |
- | bne + | + | bne + |
- | sta ObjAction,x | + | sta ObjAction,x |
* jsr Xminus16 | * jsr Xminus16 | ||
- | bmi -- | + | |
- | rts | + | rts |
LED7A: | LED7A: | ||
- | cmp #$05 | + | |
- | bcc + | + | bcc + |
- | tya | + | tya |
- | eor ObjectHi, | + | eor ObjectHi, |
- | lsr | + | lsr |
- | bcs + | + | bcs + |
- | sta ObjAction,x | + | sta ObjAction,x |
* rts | * rts | ||
LED8C: | LED8C: | ||
- | cmp PowerUpNameTable, | + | |
- | bne Exit11 | + | bne Exit11 |
- | lda #$FF | + | lda #$FF |
- | sta PowerUpType, | + | sta PowerUpType, |
Exit11: rts | Exit11: rts | ||
Line 7135: | Line 7135: | ||
ScanForItems: | ScanForItems: | ||
- | LED98: lda SpecItmsTable ;Low byte of ptr to 1st item data. | + | LED98: |
- | LED9B: sta $00 ; | + | LED9B: |
- | LED9D: lda SpecItmsTable+1 ;High byte of ptr to 1st item data. | + | LED9D: |
ScanOneItem: | ScanOneItem: | ||
- | LEDA0: sta $01 ; | + | LEDA0: |
- | LEDA2: ldy #$00 ;Index starts at #$00. | + | LEDA2: |
- | LEDA4: lda ($00),y ;Load map Ypos of item.--> | + | LEDA4: |
- | LEDA6: cmp MapPosY ;Does it equal Samus' Ypos on map? | + | LEDA6: |
- | LEDA8: beq + ;If yes, check Xpos too. | + | LEDA8: |
- | LEDAA: bcs Exit11 ;Exit if item Y pos > Samus Y Pos. | + | LEDAA: |
- | LEDAC: iny ; | + | LEDAC: |
- | LEDAD: lda ($00),y ;Low byte of ptr to next item data. | + | LEDAD: |
- | LEDAF: tax ; | + | LEDAF: |
- | LEDB0: iny ; | + | LEDB0: |
- | LEDB1: and ($00),y ;AND with hi byte of item ptr. | + | LEDB1: |
- | LEDB3: cmp #$FF ;if result is FFh, then this was the last item--> | + | LEDB3: |
- | LEDB5: beq Exit11 ;(item ptr = FFFF). Branch to exit. | + | LEDB5: |
- | LEDB7: lda ($00),y ;High byte of ptr to next item data. | + | LEDB7: |
- | LEDB9: stx $00 ;Write low byte for next item. | + | LEDB9: |
- | LEDBB: jmp ScanOneItem ;Process next item. | + | LEDBB: |
- | 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: |
ScanItemX: | ScanItemX: | ||
- | LEDC3: ldy #$00 ; | + | LEDC3: |
- | LEDC5: lda ($00),y ;Load map Xpos of object.--> | + | LEDC5: |
- | LEDC7: cmp MapPosX ;Does it equal Samus' Xpos on map? | + | LEDC7: |
- | LEDC9: beq + ;If so, then load object. | + | LEDC9: |
- | LEDCB: bcs Exit11 ;Exit if item pos X > Samus Pos X. | + | LEDCB: |
- | LEDCD: iny ; | + | LEDCD: |
- | LEDCE: jsr AnotherItem ; | + | LEDCE: |
- | LEDD1: jmp ScanItemX ;Try next X coord. | + | LEDD1: |
- | 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: |
- | LEDD9: ldy #$00 ; | + | LEDD9: |
- | LEDDB: lda ($00),y ;Object type | + | LEDDB: |
- | LEDDD: and #$0F ;Object handling routine index stored in 4 LSBs. | + | LEDDD: |
- | LEDDF: jsr ChooseRoutine ; | + | LEDDF: |
;Handler routines jumped to by above code. | ;Handler routines jumped to by above code. | ||
- | LEDE2: | + | LEDE2: |
- | LEDE4: | + | LEDE4: |
- | LEDE6: | + | LEDE6: |
- | LEDE8: | + | LEDE8: |
- | LEDEA: | + | LEDEA: |
- | LEDEC: | + | LEDEC: |
- | LEDEE: | + | LEDEE: |
- | LEDF0: | + | LEDF0: |
- | LEDF2: | + | LEDF2: |
- | LEDF4: | + | LEDF4: |
- | LEDF6: | + | LEDF6: |
; | ; | ||
SqueeptHandler: | SqueeptHandler: | ||
- | LEDF8: jsr GetEnemyData ; | + | LEDF8: |
- | LEDFB:* jmp ChooseHandlerRoutine ; | + | LEDFB:* jmp ChooseHandlerRoutine |
; | ; | ||
PowerUpHandler: | PowerUpHandler: | ||
- | LEDFE: iny ;Prepare to store item type. | + | LEDFE: |
- | LEDFF: ldx #$00 ; | + | LEDFF: |
- | LEE01: lda #$FF ; | + | LEE01: |
- | LEE03: cmp PowerUpType ;Is first power-up item slot available? | + | LEE03: |
- | LEE06: beq + ;if yes, branch to load item. | + | LEE06: |
- | LEE08: ldx #$08 ;Prepare to check second power-up item slot. | + | LEE08: |
- | LEE0A: cmp PowerUpBType ;Is second power-up item slot available? | + | LEE0A: |
- | LEE0D: bne ++ ;If not, branch to exit. | + | LEE0D: |
- | LEE0F:* lda ($00),y ;Power-up item type. | + | LEE0F:* lda ($00), |
- | LEE11: jsr PrepareItemID ;($EE3D)Get unique item ID. | + | LEE11: |
- | LEE14: jsr CheckForItem ; | + | LEE14: |
- | LEE17: bcs + ;Samus already has item. do not load it. | + | LEE17: |
- | LEE19: ldy #$02 ;Prepare to load item coordinates. | + | LEE19: |
- | LEE1B: lda $09 ; | + | LEE1B: |
- | LEE1D: sta PowerUpType, | + | LEE1D: |
- | LEE20: lda ($00),y ;Load x and y screen positions of item. | + | LEE20: |
- | LEE22: tay ;Save position data for later processing. | + | LEE22: |
- | LEE23: and #$F0 ;Extract Y coordinate. | + | LEE23: |
- | LEE25: ora #$08 ;+ 8 to find Y coordinate center. | + | LEE25: |
- | LEE27: sta PowerUpYCoord, | + | LEE27: |
- | LEE2A: tya ;Reload position data. | + | LEE2A: |
- | LEE2B: jsr Amul16 ; | + | LEE2B: |
- | LEE2E: ora #$08 ;+ 8 to find X coordinate center. | + | LEE2E: |
- | LEE30: sta PowerUpXCoord, | + | LEE30: |
- | LEE33: jsr GetNameTable ;($EB85)Get name table to place item on. | + | LEE33: |
- | LEE36: sta PowerUpNameTable, | + | LEE36: |
- | 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: |
- | + | ||
PrepareItemID: | PrepareItemID: | ||
- | LEE3D: sta $09 ;Store item type. | + | LEE3D: |
- | LEE3E: lda MapPosX ; | + | LEE3E: |
- | LEE41: sta $07 ;Store item X coordinate. | + | LEE41: |
- | LEE42: lda MapPosY ; | + | LEE42: |
- | LEE45: sta $06 ;Store item Y coordinate. | + | LEE45: |
- | LEE47: jmp CreateItemID ;($DC67)Get unique item ID. | + | LEE47: |
CheckForItem: | CheckForItem: | ||
- | LEE4A: ldy NumberOfUniqueItems ; | + | LEE4A: |
- | LEE4D: beq +++ ;Samus has no unique items. Load item and exit. | + | LEE4D: |
- | LEE4F:* lda $07 ; | + | LEE4F:* lda $07 |
- | LEE51: cmp NumberOfUniqueItems, | + | LEE51: |
- | LEE54: bne + ; | + | LEE54: |
- | LEE56: lda $06 ;Look for upper byte of unique item. | + | LEE56: |
- | LEE58: cmp DataSlot,y ; | + | LEE58: |
- | LEE5B: beq +++ ;Samus already has item. Branch to exit. | + | LEE5B: |
- | LEE5D: | + | LEE5D:* dey |
- | LEE5E: dey ; | + | LEE5E: |
- | LEE5F: bne -- ;Loop until all Samus' unique items are checked. | + | LEE5F: |
- | LEE61: | + | LEE61:* clc |
- | LEE62: | + | LEE62:* rts |
; | ; | ||
Line 7265: | Line 7265: | ||
SpecEnemyHandler: | SpecEnemyHandler: | ||
LEE63: | LEE63: | ||
- | lda RandomNumber1 | + | |
- | adc FrameCount | + | adc FrameCount |
- | sta $8A | + | sta $8A |
* jsr LEE86 | * jsr LEE86 | ||
- | 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 ; | + | * jmp ChooseHandlerRoutine |
LEE86: | LEE86: | ||
- | 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 |
- | 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: | LEEA1: | ||
- | bne -- ;Branch always. | + | |
CannonHandler: | CannonHandler: | ||
LEEA6: | LEEA6: | ||
- | lda #$02 | + | |
- | * jmp ChooseHandlerRoutine ; | + | * jmp ChooseHandlerRoutine |
MotherBrainHandler: | MotherBrainHandler: | ||
LEEAE: | LEEAE: | ||
- | 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: | LEEC6: | ||
- | bne - | + | |
ZeebetiteHandler: | ZeebetiteHandler: | ||
LEECA: | LEECA: | ||
- | 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: | LEEEE: | ||
- | jmp LEEC6 | + | |
DoorHandler: | DoorHandler: | ||
LEEF4: | LEEF4: | ||
- | jmp ChooseHandlerRoutine ; | + | |
PaletteHandler: | PaletteHandler: | ||
LEEFA: | LEEFA: | ||
- | sta $91 | + | |
- | bne LEEC6 | + | bne LEEC6 |
AnotherItem: | AnotherItem: | ||
- | LEF00: lda ($00),y ;Is there another item with same Y pos? | + | LEF00: |
- | 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 |
- | pla ; | + | pla |
- | pla ;No more items to check. Pull last subroutine--> | + | pla |
- | rts ;off stack and exit. | + | rts |
AddToPtr00: | AddToPtr00: | ||
- | LEF09: clc ; | + | LEF09: |
- | adc $00 ; | + | adc $00 |
- | sta $00 ;A is added to the 16 bit address stored in $0000. | + | sta $00 |
- | bcc + ; | + | bcc + |
- | inc $01 ; | + | inc $01 |
- | * rts ; | + | * |
; | ; | ||
Line 7373: | Line 7373: | ||
DrawStructRow: | DrawStructRow: | ||
- | LEF13: and #$0F ;Row length(in macros). Range #$00 thru #$0F. | + | LEF13: |
- | LEF15: bne + ; | + | LEF15: |
- | LEF17: lda #$10 ;#$00 in row length=16. | + | LEF17: |
- | LEF19:* sta $0E ;Store horizontal macro count. | + | LEF19:* sta $0E |
- | LEF1B: lda (StructPtr), | + | LEF1B: |
- | LEF1D: jsr Adiv16 ; | + | LEF1D: |
- | LEF20: asl ;*2, because a macro is 2 tiles wide. | + | LEF20: |
- | LEF21: adc CartRAMWorkPtr ;Add x coord offset to CartRAMWorkPtr and save in $00. | + | LEF21: |
- | LEF23: sta $00 ; | + | LEF23: |
- | LEF25: lda #$00 ; | + | LEF25: |
- | LEF27: adc CartRAMWorkPtr+1 ;Save high byte of work pointer in $01. | + | LEF27: |
- | LEF29: sta $01 ;$0000 = work pointer. | + | LEF29: |
DrawMacro: | DrawMacro: | ||
- | LEF2B: lda $01 ;High byte of current location in room RAM. | + | LEF2B: |
- | LEF2D: cmp #$63 ;Check high byte of room RAM address for both room RAMs--> | + | LEF2D: |
- | LEF2F: beq + ;to see if the attribute table data for the room RAM has--> | + | LEF2F: |
- | LEF31: cmp #$67 ;been reached. | + | LEF31: |
- | LEF33: bcc ++ ;If not at end of room RAM, branch to draw macro. | + | LEF33: |
- | LEF35: beq + ; | + | LEF35: |
- | LEF37: rts ;Return if have gone past room RAM(should never happen). | + | LEF37: |
- | LEF38:* lda $00 ;Low byte of current nametable address. | + | LEF38:* lda $00 |
- | LEF3A: cmp #$A0 ;Reached attrib table? | + | LEF3A: |
- | LEF3C: bcc + ;If not, branch to draw the macro. | + | LEF3C: |
- | LEF3E: rts ;Can't draw any more of the structure, exit. | + | LEF3E: |
- | LEF3F:* inc $10 ;Increase struct data index. | + | LEF3F:* inc $10 |
- | LEF41: ldy $10 ;Load struct data index into Y. | + | LEF41: |
- | LEF43: lda (StructPtr), | + | LEF43: |
- | LEF45: asl ; | + | LEF45: |
- | LEF46: asl ;A=macro number * 4. Each macro is 4 bytes long. | + | LEF46: |
- | LEF47: sta $11 ;Store macro index. | + | LEF47: |
- | LEF49: ldx #$03 ;Prepare to copy four tile numbers. | + | LEF49: |
- | LEF4B:* ldy $11 ;Macro index loaded into Y. | + | LEF4B:* ldy $11 |
- | LEF4D: lda (MacroPtr), | + | LEF4D: |
- | LEF4F: inc $11 ;Increase macro index | + | LEF4F: |
- | LEF51: ldy TilePosTable, | + | LEF51: |
- | LEF54: sta ($00),y ;Write tile number to room RAM. | + | LEF54: |
- | LEF56: dex ;Done four tiles yet? | + | LEF56: |
- | LEF57: bpl - ;If not, loop to do another. | + | LEF57: |
- | LEF59: jsr UpdateAttrib ; | + | LEF59: |
- | LEF5C: ldy #$02 ;Macro width(in tiles). | + | LEF5C: |
- | LEF5E: jsr AddYToPtr00 ;($C2A8)Add 2 to pointer to move to next macro. | + | LEF5E: |
- | LEF61: lda $00 ;Low byte of current room RAM work pointer. | + | LEF61: |
- | LEF63: and #$1F ;Still room left in current row? | + | LEF63: |
- | LEF65: bne + ;If yes, branch to do another macro. | + | LEF65: |
;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: |
- | LEF69: clc ; | + | LEF69: |
- | LEF6A: adc $0E ;Add number of macros remaining in current row. | + | LEF6A: |
- | LEF6C: sec ; | + | LEF6C: |
- | LEF6D: sbc #$01 ;-1 from macros remaining in current row. | + | LEF6D: |
- | LEF6F: jmp AdvanceRow ; | + | LEF6F: |
- | LEF72:* dec $0E ;Have all macros been drawn on this row? | + | LEF72:* dec $0E |
- | LEF74: bne DrawMacro ;If not, branch to draw another macro. | + | LEF74: |
- | LEF76: lda $10 ;Load struct index. | + | LEF76: |
AdvanceRow: | AdvanceRow: | ||
- | LEF78: sec ;Since carry bit is set, | + | LEF78: |
- | LEF79: adc StructPtr ;addition will be one more than expected. | + | LEF79: |
- | LEF7B: sta StructPtr ;Update the struct pointer. | + | LEF7B: |
- | LEF7D: bcc + ; | + | LEF7D: |
- | LEF7F: inc StructPtr+1 ;Update high byte of struct pointer if carry occured. | + | LEF7F: |
- | LEF81:* lda #$40 ; | + | LEF81:* lda #$40 ; |
- | LEF83: clc ; | + | LEF83: |
- | LEF84: adc CartRAMWorkPtr ;Advance to next macro row in room RAM(two tile rows). | + | LEF84: |
- | LEF86: sta CartRAMWorkPtr ; | + | LEF86: |
- | LEF88: bcc DrawStruct ;Begin drawing next structure row. | + | LEF88: |
- | LEF8A: inc CartRAMWorkPtr+1 ;Increment high byte of pointer if necessary. | + | LEF8A: |
DrawStruct: | DrawStruct: | ||
- | LEF8C: ldy #$00 ;Reset struct index. | + | LEF8C: |
- | LEF8E: sty $10 ; | + | LEF8E: |
- | LEF90: lda (StructPtr), | + | LEF90: |
- | LEF92: cmp #$FF ; | + | LEF92: |
- | LEF94: beq + ;If so, branch to exit. | + | LEF94: |
- | LEF96: jmp DrawStructRow ; | + | LEF96: |
- | LEF99: | + | 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: | + | LEF9A: |
- | LEF9B: | + | LEF9B: |
- | LEF9C: | + | LEF9C: |
- | LEF9D: | + | LEF9D: |
; | ; | ||
Line 7469: | Line 7469: | ||
UpdateAttrib: | UpdateAttrib: | ||
- | LEF9E: lda ObjectPal ;Load attribute data of structure. | + | LEF9E: |
- | LEFA0: cmp RoomPal ;Is it the same as the room's default attribute data? | + | LEFA0: |
- | LEFA2: beq +++++ ;If so, no need to modify the attribute table, exit. | + | LEFA2: |
;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: |
- | LEFA6: sta $02 ; | + | LEFA6: |
- | LEFA8: lda $01 ; | + | LEFA8: |
- | LEFAA: lsr ; | + | LEFAA: |
- | LEFAB: ror $02 ; | + | LEFAB: |
- | LEFAD: lsr ; | + | LEFAD: |
- | LEFAE: ror $02 ; | + | LEFAE: |
- | LEFB0: lda $02 ;The following section of code calculates the--> | + | LEFB0: |
- | LEFB2: and #$07 ;proper attribute byte that corresponds to the--> | + | LEFB2: |
- | LEFB4: sta $03 ;macro that has just been placed in the room RAM. | + | LEFB4: |
- | LEFB6: lda $02 ; | + | LEFB6: |
- | LEFB8: lsr ; | + | LEFB8: |
- | LEFB9: lsr ; | + | LEFB9: |
- | LEFBA: and #$38 ; | + | LEFBA: |
- | LEFBC: ora $03 ; | + | LEFBC: |
- | LEFBE: ora #$C0 ; | + | LEFBE: |
- | LEFC0: sta $02 ; | + | LEFC0: |
- | LEFC2: lda #$63 ; | + | LEFC2: |
- | LEFC4: sta $03 ;$0002 contains pointer to attribute byte. | + | LEFC4: |
- | LEFC6: ldx #$00 ; | + | LEFC6: |
- | LEFC8: bit $00 ; | + | LEFC8: |
- | LEFCA: bvc + ; | + | LEFCA: |
- | LEFCC: ldx #$02 ;The following section of code figures out which--> | + | LEFCC: |
- | LEFCE:* lda $00 ;pair of bits to modify in the attribute table byte--> | + | LEFCE:* lda $00 |
- | LEFD0: and #$02 ;for the macro that has just been placed in the--> | + | LEFD0: |
- | LEFD2: beq + ;room RAM. | + | LEFD2: |
- | LEFD4: inx ; | + | LEFD4: |
;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 |
- | LEFD7: and #$04 ; | + | LEFD7: |
- | LEFD9: ora $03 ;Choose proper attribute table associated with the--> | + | LEFD9: |
- | LEFDB: sta $03 ;current room RAM. | + | LEFDB: |
- | LEFDD: lda AttribMaskTable, | + | LEFDD: |
- | LEFE0: ldy #$00 ; | + | LEFE0: |
- | LEFE2: and ($02),y ;clear the old attribute table bits. | + | LEFE2: |
- | LEFE4: sta ($02),y ; | + | LEFE4: |
- | LEFE6: lda ObjectPal ;Load new attribute table data(#$00 thru #$03). | + | LEFE6: |
- | LEFE8: | + | LEFE8:* dex |
- | LEFE9: bmi + ; | + | LEFE9: |
- | LEFEB: asl ; | + | LEFEB: |
- | LEFEC: asl ;Attribute table bits shifted one step left | + | LEFEC: |
- | LEFED: bcc - ;Loop until attribute table bits are in the proper location. | + | LEFED: |
- | LEFEF:* ora ($02),y ; | + | LEFEF:* ora ($02), |
- | LEFF1: sta ($02),y ;Set attribute table bits. | + | LEFF1: |
- | LEFF3: | + | LEFF3:* rts |
AttribMaskTable: | AttribMaskTable: | ||
- | LEFF4: | + | LEFF4: |
- | LEFF5: | + | LEFF5: |
- | LEFF6: | + | LEFF6: |
- | LEFF7: | + | LEFF7: |
; | ; | ||
InitTables: | InitTables: | ||
- | LEFF8: lda CartRAMPtr+1 ;#$60 or #$64. | + | LEFF8: |
- | LEFFA: tay ; | + | LEFFA: |
- | LEFFB: tax ;Save value to create counter later. | + | LEFFB: |
- | LEFFC: iny ; | + | LEFFC: |
- | LEFFD: iny ;High byte of address to fill to ($63 or $67). | + | LEFFD: |
- | LEFFE: iny ; | + | LEFFE: |
- | LEFFF: lda #$FF ;Value to fill room RAM with. | + | LEFFF: |
- | LF001: jsr FillRoomRAM ; | + | LF001: |
- | LF004: ldx $01 ;#$5F or #$63 depening on which room RAM was initialized. | + | LF004: |
- | LF006: jsr Xplus4 ;($E193)X = X + 4. | + | LF006: |
- | LF009: stx $01 ;Set high byte for attribute table write(#$63 or #$67). | + | LF009: |
- | LF00B: ldx RoomPal ;Index into table below (Lowest 2 bits). | + | LF00B: |
- | LF00D: lda ATDataTable, | + | LF00D: |
- | LF010: ldy #$C0 ;Low byte of start of all attribute tables. | + | LF010: |
- | LF012:* sta ($00),y ;Fill attribute table. | + | LF012:* sta ($00), |
- | LF014: iny ; | + | LF014: |
- | LF015: bne - ;Loop until entire attribute table is filled. | + | LF015: |
- | LF017: rts ; | + | LF017: |
ATDataTable: | ATDataTable: | ||
- | LF018: | + | LF018: |
- | LF019: | + | LF019: |
- | LF01A: | + | LF01A: |
- | LF01B: | + | LF01B: |
FillRoomRAM: | FillRoomRAM: | ||
- | LF01C: pha ; | + | LF01C: |
- | LF01D: txa ; | + | LF01D: |
- | LF01E: sty $01 ;Calculate value to store in X to use as upper byte--> | + | LF01E: |
- | LF020: clc ;counter for initilaizing room RAM(X=# | + | LF020: |
- | LF021: sbc $01 ;Since carry bit is cleared, result is one less than expected. | + | LF021: |
- | LF023: tax ; | + | LF023: |
- | LF024: pla ;Restore value to fill room RAM with(# | + | LF024: |
- | LF025: ldy #$00 ;Lower address byte to start at. | + | LF025: |
- | LF027: sty $00 ; | + | LF027: |
- | LF029:* sta ($00),y ; | + | LF029:* sta ($00), |
- | LF02B: dey ; | + | LF02B: |
- | LF02C: bne - ; | + | LF02C: |
- | LF02E: dec $01 ;Loop until all the room RAM is filled with # | + | LF02E: |
- | LF030: inx ; | + | LF030: |
- | LF031: bne - ; | + | LF031: |
- | LF033: rts ; | + | LF033: |
; | ; | ||
Line 7590: | Line 7590: | ||
LF034: | LF034: | ||
- | sta $73 | + | |
- | sta $010F | + | sta $010F |
; check for crash with Memus | ; check for crash with Memus | ||
- | ldx #$18 | + | |
* lda $B0,x | * lda $B0,x | ||
- | beq +++++ | + | |
- | 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, | * lda ObjAction, | ||
- | beq ++ | + | |
- | cmp # | + | cmp # |
- | bcc + | + | bcc + |
- | cmp #$07 | + | cmp #$07 |
- | beq + | + | beq + |
- | cmp # | + | cmp # |
- | beq + | + | beq + |
- | cmp # | + | cmp # |
- | bne ++ | + | bne ++ |
* jsr LF149 | * jsr LF149 | ||
- | jsr LF32A | + | |
* jsr Yplus16 | * jsr Yplus16 | ||
- | bne --- | + | |
- | * txa | + | * |
- | sec | + | sec |
- | sbc #$08 ; each Memu occupies 8 bytes | + | sbc #$08 ; each Memu occupies 8 bytes |
- | tax | + | tax |
- | bpl ------ | + | bpl ------ |
- | ldx #$B0 | + | |
* lda ObjAction,x | * lda ObjAction,x | ||
- | cmp #$02 | + | |
- | bne + | + | bne + |
- | ldy #$00 | + | ldy #$00 |
- | jsr IsSamusDead | + | jsr IsSamusDead |
- | beq ++ | + | beq ++ |
- | jsr AreObjectsTouching ;($DC7F) | + | jsr AreObjectsTouching |
- | jsr LF277 | + | jsr LF277 |
* jsr Xminus16 | * jsr Xminus16 | ||
- | bmi -- | + | |
; enemy <--> bullet/ | ; enemy <--> bullet/ | ||
- | * ldx #$50 ; start with enemy slot #5 | + | * |
- | LF09F: | + | LF09F: |
- | beq + ; branch if not | + | beq + ; branch if not |
- | cmp #$03 | + | cmp #$03 |
- | * beq NextEnemy ; next slot | + | * beq NextEnemy |
- | 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, | + | * lda ObjAction, |
- | beq ++ | + | beq ++ ; branch if not |
- | cmp # | + | cmp # |
- | bcc + | + | bcc + |
- | cmp #$07 | + | cmp #$07 |
- | beq + | + | beq + |
- | cmp # | + | cmp # |
- | beq + | + | beq + |
- | cmp # | + | cmp # |
- | bne ++ | + | bne ++ |
; check if enemy is actually hit | ; check if enemy is actually hit | ||
* jsr LF140 | * jsr LF140 | ||
- | jsr LF2CA | + | |
- | * jsr Yplus16 ; next projectile slot | + | * |
- | bne --- | + | bne --- |
- | * 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 | + | |
- | ldy #$60 | + | ldy #$60 |
* lda EnStatus,y | * lda EnStatus,y | ||
- | 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 | + | |
- | 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 | + | |
- | beq + | + | beq + |
- | cmp #$0A | + | cmp #$0A |
- | bne ++ | + | bne ++ |
* jsr LDC82 | * jsr LDC82 | ||
- | jsr LF311 | + | |
- | * jsr Xminus16 | + | * |
- | cmp #$C0 | + | cmp #$C0 |
- | bne --- | + | bne --- |
- | * jmp SubtractHealth ;($CE92) | + | * |
LF140: | LF140: | ||
- | jsr LF186 | + | |
- | jmp LF1FA | + | jmp LF1FA |
LF149: | LF149: | ||
- | jsr LF1D2 | + | |
- | jmp LF1FA | + | jmp LF1FA |
LF152: | LF152: | ||
- | sta $07 ; Y coord | + | |
- | lda EnXRoomPos, | + | lda EnXRoomPos, |
- | sta $09 ; X coord | + | sta $09 ; X coord |
- | lda EnNameTable, | + | lda EnNameTable, |
- | jmp LF17F | + | jmp LF17F |
LF162: | LF162: | ||
- | sta $06 | + | |
- | lda EnXRoomPos, | + | lda EnXRoomPos, |
- | sta $08 | + | sta $08 |
- | lda EnNameTable, | + | lda EnNameTable, |
- | jmp LF193 | + | jmp LF193 |
GetObject0CoordData: | GetObject0CoordData: | ||
LF172: | LF172: | ||
- | sta $07 | + | |
- | lda ObjectX,x | + | lda ObjectX,x |
- | sta $09 | + | sta $09 |
- | lda ObjectHi,x | + | lda ObjectHi,x |
LF17F: | LF17F: | ||
- | and #$01 | + | |
- | sta $0B | + | sta $0B |
- | rts | + | rts |
GetObject1CoordData: | GetObject1CoordData: | ||
LF186: | LF186: | ||
- | sta $06 | + | |
- | lda ObjectX,y | + | lda ObjectX,y |
- | sta $08 | + | sta $08 |
- | lda ObjectHi,y | + | lda ObjectHi,y |
LF193: | LF193: | ||
- | and #$01 | + | |
- | sta $0A | + | sta $0A |
- | rts | + | rts |
LF19A: | LF19A: | ||
- | 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: | LF1A7: | ||
- | jsr LF1E0 | + | |
- | lda ObjRadX,x | + | lda ObjRadX,x |
- | jmp LF1D9 | + | jmp LF1D9 |
DistFromObj0ToEn1: | DistFromObj0ToEn1: | ||
LF1B3: | LF1B3: | ||
- | jsr LF1E7 | + | |
- | lda ObjRadX,x | + | lda ObjRadX,x |
- | jmp LF1CB | + | jmp LF1CB |
DistFromEn0ToObj1: | DistFromEn0ToObj1: | ||
LF1BF: | LF1BF: | ||
- | jsr LF1E0 | + | |
- | lda EnRadX,x | + | lda EnRadX,x |
- | jmp LF1D9 | + | jmp LF1D9 |
AddEnemy1XRadius: | AddEnemy1XRadius: | ||
LF1CB: | LF1CB: | ||
- | adc EnRadX,y | + | |
- | sta $05 | + | sta $05 |
- | rts | + | rts |
LF1D2: | LF1D2: | ||
- | jsr LF1E0 | + | |
- | lda #$08 | + | lda #$08 |
AddObject1XRadius: | AddObject1XRadius: | ||
LF1D9: | LF1D9: | ||
- | adc ObjRadX,y | + | |
- | sta $05 | + | sta $05 |
- | rts | + | rts |
AddObject1YRadius: | AddObject1YRadius: | ||
LF1E0: | LF1E0: | ||
- | adc ObjRadY,y | + | |
- | sta $04 | + | sta $04 |
- | rts | + | rts |
LF1E7: | LF1E7: | ||
- | adc EnRadY,y | + | |
- | sta $04 | + | sta $04 |
- | rts | + | rts |
; Y = Y + 16 | ; Y = Y + 16 | ||
Yplus16: | Yplus16: | ||
- | tya | + | |
- | clc | + | clc |
- | adc #$10 | + | adc #$10 |
- | tay | + | tay |
- | rts | + | rts |
; X = X - 16 | ; X = X - 16 | ||
Xminus16: | Xminus16: | ||
- | txa | + | |
- | sec | + | sec |
- | sbc #$10 | + | sbc #$10 |
- | tax | + | tax |
- | rts | + | rts |
LF1FA: | LF1FA: | ||
- | sta $10 | + | |
- | and ScrollDir | + | and ScrollDir |
- | sta $03 | + | sta $03 |
- | lda $07 ;Load object 0 y coord. | + | lda $07 |
- | sec ; | + | sec |
- | sbc $06 ;Subtract object 1 y coord. | + | sbc $06 |
- | sta $00 ;Store difference in $00. | + | sta $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 | + | * |
- | sbc #$00 | + | sbc #$00 |
- | jsr LF266 | + | jsr LF266 |
LF22B: | LF22B: | ||
- | 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 | + | |
LF256: | LF256: | ||
- | lda $01 | + | |
- | bne + | + | bne + |
- | lda $00 | + | lda $00 |
- | sta $0F | + | sta $0F |
- | cmp $05 | + | cmp $05 |
- | * rts | + | * |
LF262: | LF262: | ||
- | sbc $0A | + | |
LF266: | LF266: | ||
- | bpl + | + | |
- | jsr LE449 | + | jsr LE449 |
- | inc $10 | + | inc $10 |
* rts | * rts | ||
LF270: | LF270: | ||
- | sta $030A,x | + | |
- | rts | + | rts |
LF277: | LF277: | ||
LF279: | LF279: | ||
LF27B: | LF27B: | ||
- | sta $030A,y | + | |
- | Exit17: | + | Exit17: |
- | rts | + | rts |
LF282: | LF282: | ||
- | jsr LF2E8 | + | |
- | jsr IsScrewAttackActive ; | + | jsr IsScrewAttackActive |
- | ldy #$00 | + | ldy #$00 |
- | bcc +++ | + | bcc +++ |
- | lda EnStatus, | + | lda EnStatus, |
- | cmp #$04 | + | cmp #$04 |
- | bcs Exit17 | + | bcs Exit17 |
- | lda EnDataIndex, | + | lda EnDataIndex, |
* sta $010F | * sta $010F | ||
- | tay | + | |
- | bmi + | + | bmi + |
- | lda $968B,y | + | lda $968B,y |
- | and #$10 | + | and #$10 |
- | bne Exit17 | + | bne Exit17 |
* ldy #$00 | * ldy #$00 | ||
- | jsr LF338 | + | |
- | jmp LF306 | + | jmp LF306 |
- | * lda #$81 | + | * |
- | sta $040E,x | + | sta $040E,x |
- | bne ++ | + | bne ++ |
LF2B4: | LF2B4: | ||
- | jsr IsScrewAttackActive ; | + | |
- | ldy #$00 | + | ldy #$00 |
- | lda #$C0 | + | lda #$C0 |
- | bcs --- | + | bcs --- |
LF2BF: | LF2BF: | ||
- | and #$F8 | + | |
- | ora $10 | + | ora $10 |
- | eor #$03 | + | eor #$03 |
- | sta $B6,x | + | sta $B6,x |
* rts | * rts | ||
LF2CA: | LF2CA: | ||
- | lda ObjAction, | + | |
- | sta $040E,x | + | sta $040E,x |
- | jsr LF279 | + | jsr LF279 |
- | * jsr LF332 | + | * |
* ora $0404,x | * ora $0404,x | ||
- | sta $0404,x | + | |
* rts | * rts | ||
LF2DF: | LF2DF: | ||
- | ora $0404,y | + | |
- | sta $0404,y | + | sta $0404,y |
- | rts | + | rts |
LF2E8: | LF2E8: | ||
- | bne -- | + | |
LF2ED: | LF2ED: | ||
- | jsr LF2DF | + | |
- | tya | + | tya |
- | pha | + | pha |
- | jsr IsScrewAttackActive ; | + | jsr IsScrewAttackActive |
- | pla | + | pla |
- | tay | + | tay |
- | bcc + | + | bcc + |
- | lda #$80 | + | lda #$80 |
- | sta $010F | + | sta $010F |
- | jsr LF332 | + | jsr LF332 |
- | jsr LF270 | + | jsr LF270 |
LF306: | LF306: | ||
- | sta HealthLoChange | + | |
- | lda $95CF | + | lda $95CF |
- | sta HealthHiChange | + | sta HealthHiChange |
* rts | * rts | ||
LF311: | LF311: | ||
- | 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: |
- | LF325: sta HealthLoChange | + | LF325: |
- | LF327: sta HealthHiChange | + | LF327: |
Exit22: | Exit22: | ||
- | LF329: rts ;Return for routine above and below. | + | LF329: |
LF32A: | LF32A: | ||
- | jsr LF279 | + | |
- | jmp LF2BF | + | jmp LF2BF |
LF332: | LF332: | ||
- | jmp Amul8 ; * 8 | + | |
LF338: | LF338: | ||
- | asl | + | |
- | asl | + | asl |
- | asl | + | asl |
- | jmp LF27B | + | jmp LF27B |
LF340: | LF340: | ||
- | eor #$03 | + | |
- | rts | + | rts |
; UpdateEnemies | ; UpdateEnemies | ||
Line 8010: | Line 8010: | ||
UpdateEnemies: | UpdateEnemies: | ||
- | LF345: ldx #$50 ;Load x with #$50 | + | LF345: |
- | * jsr DoOneEnemy ;($F351) | + | * jsr DoOneEnemy |
- | 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: |
- | ;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, | + | |
- | sta $81 | + | sta $81 |
- | cmp #$07 | + | cmp #$07 |
- | bcs + | + | bcs + |
- | jsr ChooseRoutine | + | jsr ChooseRoutine |
; Pointer table to code | ; Pointer table to code | ||
- | .word ExitSub | + | |
- | .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 ; | + | * jmp KillObject |
LF37F: | LF37F: | ||
- | and #$02 | + | |
- | bne + | + | bne + |
- | lda EnYRoomPos, | + | lda EnYRoomPos, |
- | sta $0A | + | sta $0A |
- | lda EnXRoomPos, | + | lda EnXRoomPos, |
- | sta $0B | + | sta $0B |
- | lda EnNameTable, | + | lda EnNameTable, |
- | 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 ; | + | jsr IsObjectVisible |
- | txa | + | txa |
- | bne + | + | bne + |
- | pla | + | pla |
- | pla | + | pla |
* ldx PageIndex | * ldx PageIndex | ||
- | rts | + | |
LF3AA: | LF3AA: | ||
- | asl | + | |
- | rol | + | rol |
- | tay | + | tay |
- | txa | + | txa |
- | jsr Adiv16 ; | + | jsr Adiv16 |
- | eor FrameCount | + | eor FrameCount |
- | lsr | + | lsr |
- | tya | + | tya |
- | ror | + | ror |
- | ror | + | ror |
- | sta $0405,x | + | sta $0405,x |
- | rts | + | rts |
LF3BE: | LF3BE: | ||
- | 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: | LF3E6: | ||
- | asl | + | |
- | bmi ++ | + | bmi ++ |
- | lda $0405,x | + | lda $0405,x |
- | and #$20 | + | and #$20 |
- | beq + | + | beq + |
- | ldy EnDataIndex, | + | ldy EnDataIndex, |
- | lda EnemyInitDelayTbl, | + | lda EnemyInitDelayTbl, |
- | sta EnDelay,x | + | sta EnDelay,x |
- | dec EnStatus, | + | dec EnStatus, |
- | bne ++ | + | bne ++ |
* jsr LF6B9 | * jsr LF6B9 | ||
- | jsr LF75B | + | |
- | jsr LF51E | + | jsr LF51E |
- | LF40A:* jsr LF536 | + | LF40A:* jsr LF536 |
- | jmp $95E5 | + | jmp $95E5 |
- | LF410: jsr UpdateEnemyAnim | + | LF410: |
- | jsr $8058 | + | jsr $8058 |
LF416: | LF416: | ||
- | lda EnSpecialAttribs, | + | |
- | bpl + | + | bpl + |
- | lda ObjectCntrl | + | lda ObjectCntrl |
- | bmi + | + | bmi + |
- | lda #$A3 | + | lda #$A3 |
LF423: | LF423: | ||
* lda EnStatus,x | * lda EnStatus,x | ||
- | beq LF42D | + | |
- | jsr LDD8B | + | jsr LDD8B |
LF42D: | LF42D: | ||
- | lda #$00 | + | |
- | sta $0404,x | + | sta $0404,x |
- | sta $040E,x | + | sta $040E,x |
- | rts | + | rts |
LF438: | LF438: | ||
Line 8132: | Line 8132: | ||
LF43E: | LF43E: | ||
- | 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 | + | |
- | 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 | + | |
- | bcs + | + | bcs + |
- | lda FrameCount | + | lda FrameCount |
- | and #$02 | + | and #$02 |
- | beq + | + | beq + |
- | asl ObjectCntrl | + | asl ObjectCntrl |
* jmp LF416 | * jmp LF416 | ||
LF483: | LF483: | ||
- | and #$24 | + | |
- | beq ++++++ | + | beq ++++++ |
- | jsr KillObject ; | + | jsr KillObject |
- | 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 | + | * |
- | sty HealthLoChange | + | sty HealthLoChange |
- | stx HealthHiChange | + | stx HealthHiChange |
- | jsr AddHealth ;($CEF9)Add health to Samus. | + | jsr AddHealth |
- | jmp SFX_EnergyPickup | + | jmp SFX_EnergyPickup |
PickupMissile: | PickupMissile: | ||
- | lda #$02 | + | |
- | ldy EnDataIndex, | + | ldy EnDataIndex, |
- | beq + | + | beq + |
- | lda #$1E | + | lda #$1E |
* clc | * clc | ||
- | 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 |
- | bcc ++ | + | bcc ++ ; branch if yes |
- | * lda MaxMissiles ; set to max. # of missiles allowed | + | * lda MaxMissiles |
- | * sta MissileCount | + | * |
- | jmp SFX_MissilePickup | + | jmp SFX_MissilePickup |
- | * lda FrameCount | + | * |
- | and #$03 | + | and #$03 |
- | bne + | + | bne + |
- | dec $040D,x | + | dec $040D,x |
- | bne + | + | bne + |
- | jsr KillObject ; | + | jsr KillObject |
- | * lda FrameCount | + | * |
- | and #$02 | + | and #$02 |
- | lsr | + | lsr |
- | ora #$A0 | + | ora #$A0 |
- | sta ObjectCntrl | + | sta ObjectCntrl |
- | jmp LF416 | + | jmp LF416 |
LF4EE: | LF4EE: | ||
- | 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 | + | * |
- | jmp LF423 | + | jmp LF423 |
LF515: | LF515: | ||
LF518: | LF518: | ||
- | sta EnStatus, | + | |
- | rts | + | rts |
LF51E: | LF51E: | ||
- | ldx PageIndex | + | |
- | cmp #$02 | + | cmp #$02 |
- | bcc ++ | + | bcc ++ |
- | lda EnYRoomPos, | + | lda EnYRoomPos, |
- | cmp #$EC | + | cmp #$EC |
- | bcc ++ | + | bcc ++ |
- | jmp KillObject ; | + | jmp KillObject |
* jsr SFX_MetroidHit | * jsr SFX_MetroidHit | ||
- | jmp GetPageIndex | + | |
LF536: | LF536: | ||
- | 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 | + | * |
- | and #$20 | + | and #$20 |
- | bne --- | + | bne --- |
- | jsr SFX_Metal | + | jsr SFX_Metal |
- | jmp LF42D | + | jmp LF42D |
- | * lda EnHitPoints, | + | * |
- | cmp #$FF | + | cmp #$FF |
- | beq -- | + | beq -- |
- | bit $0A | + | bit $0A |
- | bvc + | + | bvc + |
- | jsr SFX_BossHit | + | jsr SFX_BossHit |
- | bne ++ | + | bne ++ |
- | * 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 | + | |
- | bne + ; branch always | + | bne + ; branch always |
PlaySnd2: | PlaySnd2: | ||
- | jsr SFX_EnemyHit | + | |
- | bne + ; branch always | + | bne + ; branch always |
PlaySnd3: | PlaySnd3: | ||
- | jsr SFX_BigEnemyHit ;($CBCE) | + | |
- | * 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 | + | |
- | bne + | + | bne + |
- | lda $040C,x | + | lda $040C,x |
* ora $0A | * ora $0A | ||
- | 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, | + | |
- | lda #$0A | + | lda #$0A |
- | bit $0A | + | bit $0A |
- | bvc + | + | bvc + |
- | lda #$03 | + | lda #$03 |
* sta EnSpecialAttribs, | * sta EnSpecialAttribs, | ||
- | 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, | * dec EnHitPoints, | ||
- | beq ++ | + | |
- | * dec EnHitPoints, | + | * |
- | bne GetPageIndex | + | bne GetPageIndex |
- | * 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 | + | |
- | jsr LF68D | + | jsr LF68D |
- | sta EnCounter, | + | sta EnCounter, |
- | ldx #$C0 | + | ldx #$C0 |
* lda EnStatus,x | * lda EnStatus,x | ||
- | 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 | + | |
- | 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 | + | |
- | 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: | LF676: | ||
- | asl | + | |
- | asl | + | asl |
- | asl | + | asl |
- | and #$C0 | + | and #$C0 |
- | sta $6B03,x | + | sta $6B03,x |
- | rts | + | rts |
LF682: | LF682: | ||
- | lda $963B,y | + | |
- | cmp EnResetAnimIndex, | + | cmp EnResetAnimIndex, |
- | beq + | + | beq + |
LF68D: | LF68D: | ||
LF690: | LF690: | ||
LF693: | LF693: | ||
- | sta EnAnimDelay, | + | |
* rts | * rts | ||
LF699: | LF699: | ||
- | 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, | * dec EnAnimIndex, | ||
- | dey | + | |
- | bne - | + | bne - |
Exit12: rts | Exit12: rts | ||
LF6B9: | LF6B9: | ||
- | 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 | + | |
- | 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, | * lda EnXRoomPos, | ||
- | cmp ObjectX | + | |
- | bne + | + | bne + |
- | inc $82 | + | inc $82 |
* rol | * rol | ||
- | * and #$01 | + | * |
- | jsr LF744 | + | jsr LF744 |
- | lsr | + | lsr |
- | ror | + | ror |
- | eor $0403,x | + | eor $0403,x |
- | bpl + | + | bpl + |
- | jsr $81DA | + | jsr $81DA |
- | * 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, | + | * |
- | cmp ObjectY | + | cmp ObjectY |
- | bne + | + | bne + |
- | inc $82 | + | inc $82 |
- | inc $82 | + | inc $82 |
- | * rol | + | * |
- | * 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: | LF744: | ||
- | sta $0405,x | + | |
* rts | * rts | ||
LF74B: | LF74B: | ||
- | lda $968B,y | + | |
- | rts | + | rts |
LF752: | LF752: | ||
- | tay | + | |
- | eor ObjectHi | + | eor ObjectHi |
- | lsr | + | lsr |
- | rts | + | rts |
LF75B: | LF75B: | ||
- | 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 | + | |
- | 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, | + | ldy EnXRoomPos, |
* lda ObjectHi | * lda ObjectHi | ||
- | 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 |
* lsr | * lsr | ||
- | lsr | + | |
- | lsr | + | lsr |
- | cmp $02 | + | cmp $02 |
- | bcc ++ | + | bcc ++ |
- | * lda $06 | + | * |
LF7B3: | LF7B3: | ||
- | sta $0405,x | + | |
- | * rts | + | * |
LF7BA: | LF7BA: | ||
- | bne + | + | |
- | lda $0405,x | + | lda $0405,x |
- | and #$08 | + | and #$08 |
- | bne ++ | + | bne ++ |
- | inc EnDelay,x | + | inc EnDelay,x |
* rts | * rts | ||
- | * lda EnDataIndex, | + | * |
- | cmp #$07 | + | cmp #$07 |
- | bne + | + | bne + |
- | jsr SFX_OutOfHole | + | jsr SFX_OutOfHole |
- | ldx PageIndex | + | ldx PageIndex |
- | * 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 + | + | |
- | jsr $8206 | + | jsr $8206 |
- | * lda #$DF | + | * |
- | jmp LF7B3 | + | jmp LF7B3 |
LF83E: | LF83E: | ||
Line 8623: | Line 8623: | ||
LF844: | LF844: | ||
- | bpl + | + | |
- | lsr | + | lsr |
- | lsr | + | lsr |
- | * lsr | + | * |
- | lda EnDataIndex, | + | lda EnDataIndex, |
- | rol | + | rol |
- | tay | + | tay |
- | rts | + | rts |
LF852: | LF852: | ||
- | lsr | + | |
- | lsr | + | lsr |
- | lsr | + | lsr |
- | adc FrameCount | + | adc FrameCount |
- | lsr | + | lsr |
- | rts | + | rts |
LF85A: | LF85A: | ||
- | lda $969B,y | + | |
- | sta $040D,x | + | sta $040D,x |
- | lda EnemyHitPointTbl, | + | lda EnemyHitPointTbl, |
- | ldy EnSpecialAttribs, | + | ldy EnSpecialAttribs, |
- | bpl + | + | bpl + |
- | asl | + | asl |
* sta EnHitPoints, | * sta EnHitPoints, | ||
* rts | * rts | ||
LF870: | LF870: | ||
- | 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 ++ | + | |
- | 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: | LF8E8: | ||
- | clc | + | |
* lda EnStatus,y | * lda EnStatus,y | ||
- | beq + | + | |
- | jsr Yplus16 | + | jsr Yplus16 |
- | cmp #$C0 | + | cmp #$C0 |
- | bne - | + | bne - |
* rts | * rts | ||
LF8F8: | LF8F8: | ||
- | 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: | LF91D: | ||
- | 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 $FE | + | .byte $FE |
LF92C: | LF92C: | ||
- | sta EnRadY,y | + | |
- | sta EnRadX,y | + | sta EnRadX,y |
- | ora $0405,y | + | ora $0405,y |
- | sta $0405,y | + | sta $0405,y |
- | rts | + | rts |
LF93B: | LF93B: | ||
* jsr LF949 | * jsr LF949 | ||
- | ldx PageIndex | + | |
- | jsr Xminus16 | + | jsr Xminus16 |
- | cmp #$60 | + | cmp #$60 |
- | bne - | + | bne - |
LF949: | LF949: | ||
- | lda $0405,x | + | |
- | and #$02 | + | and #$02 |
- | bne + | + | bne + |
- | jsr KillObject ; | + | jsr KillObject |
* lda EnStatus,x | * lda EnStatus,x | ||
- | beq Exit19 | + | |
- | jsr ChooseRoutine | + | jsr ChooseRoutine |
; Pointer table to code | ; Pointer table to code | ||
- | .word ExitSub | + | |
- | .word $F96A | + | .word $F96A |
- | .word LF991 ; spit dragon' | + | .word LF991 ; spit dragon' |
- | .word ExitSub | + | .word ExitSub |
- | .word $FA6B | + | .word $FA6B |
- | .word $FA91 | + | .word $FA91 |
Exit19: rts | Exit19: rts | ||
LF96A: | LF96A: | ||
- | jsr LFA1E | + | |
- | ldx PageIndex | + | ldx PageIndex |
- | bcs LF97C | + | bcs LF97C |
- | lda EnStatus, | + | lda EnStatus, |
- | beq Exit19 | + | beq Exit19 |
- | jsr LFA60 | + | jsr LFA60 |
LF97C: | LF97C: | ||
LF97E: | LF97E: | ||
- | jmp LDD8B | + | |
* inc $0408,x | * inc $0408,x | ||
LF987: | LF987: | ||
- | lda #$00 | + | |
- | sta EnDelay,x | + | sta EnDelay,x |
- | beq + | + | beq + |
LF991: | LF991: | ||
- | 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 | + | |
- | cmp #$FF | + | cmp #$FF |
- | bne + | + | bne + |
- | sta $0408,x | + | sta $0408,x |
- | jmp LF987 | + | jmp LF987 |
* cmp EnDelay,x | * cmp EnDelay,x | ||
- | 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 |
- | sta $0403,x | + | sta $0403,x |
* plp | * plp | ||
- | 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, | + | sta EnResetAnimIndex, |
* jsr LFA1E | * jsr LFA1E | ||
- | 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 LF518 | + | jsr LF518 |
- | lda #$0A | + | lda #$0A |
- | sta EnDelay,x | + | sta EnDelay,x |
* jmp LF97C | * jmp LF97C | ||
KillObject: | KillObject: | ||
- | LFA18: lda #$00 ; | + | LFA18: |
- | LFA1A: sta EnStatus,x ;Store #$00 as enemy status(enemy slot is open). | + | LFA1A: |
- | LFA1D: rts ; | + | LFA1D: |
; enemy< | ; enemy< | ||
LFA1E: | LFA1E: | ||
- | cmp #$11 | + | |
- | bne + | + | bne + |
- | lda EnStatus, | + | lda EnStatus, |
- | lsr | + | lsr |
- | bcc ++ | + | bcc ++ |
* jsr LFA7D | * jsr LFA7D | ||
- | 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 | + | |
- | lda $0402,x | + | lda $0402,x |
- | sta $04 | + | sta $04 |
LFA41: | LFA41: | ||
- | jsr LFD8F | + | |
- | bcc KillObject ; | + | bcc KillObject |
LFA49: | LFA49: | ||
- | sta EnYRoomPos, | + | |
- | lda $09 | + | lda $09 |
- | sta EnXRoomPos, | + | sta EnXRoomPos, |
- | lda $0B | + | lda $0B |
- | and #$01 | + | and #$01 |
- | sta EnNameTable, | + | sta EnNameTable, |
* rts | * rts | ||
LFA5B: | LFA5B: | ||
- | beq Exit20 | + | |
LFA60: | LFA60: | ||
- | sta $0404,x | + | |
- | lda #$05 | + | lda #$05 |
- | sta EnStatus,x | + | sta EnStatus,x |
Exit20: rts | Exit20: rts | ||
LFA6B: | LFA6B: | ||
- | cmp #$F7 | + | |
- | beq + | + | beq + |
- | dec EnDelay,x | + | dec EnDelay,x |
- | bne ++ | + | bne ++ |
- | * jsr KillObject ; | + | * jsr KillObject |
* jmp LF97C | * jmp LF97C | ||
LFA7D: | LFA7D: | ||
- | lda EnYRoomPos, | + | |
- | sta $02 | + | sta $02 |
- | lda EnXRoomPos, | + | lda EnXRoomPos, |
- | sta $03 | + | sta $03 |
- | lda EnNameTable, | + | lda EnNameTable, |
- | sta $0B | + | sta $0B |
- | jmp MakeCartRAMPtr ; | + | jmp MakeCartRAMPtr |
- | LFA91: | + | LFA91: |
- | lda $95DC | + | lda $95DC |
- | jsr LF68D | + | jsr LF68D |
- | jmp LF97C | + | jmp LF97C |
LFA9D: | LFA9D: | ||
* stx PageIndex | * stx PageIndex | ||
- | lda EnStatus, | + | |
- | beq + | + | beq + |
- | jsr LFAB4 | + | jsr LFAB4 |
* lda PageIndex | * lda PageIndex | ||
- | clc | + | |
- | adc #$08 | + | adc #$08 |
- | tax | + | tax |
- | cmp #$E0 | + | cmp #$E0 |
- | bne -- | + | bne -- |
* rts | * rts | ||
LFAB4: | LFAB4: | ||
- | bne ++ | + | |
- | lda #$0C | + | lda #$0C |
- | sta EnCounter, | + | sta EnCounter, |
- | dec $0407,x | + | dec $0407,x |
- | bmi + | + | bmi + |
- | bne ++ | + | bne ++ |
- | * jsr KillObject ; | + | * jsr KillObject |
- | * 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 | + | |
- | 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 $0C | + | .byte $0C |
- | .byte $1C | + | .byte $1C |
- | .byte $10 | + | .byte $10 |
- | .byte $F0 | + | .byte $F0 |
- | .byte $F0 | + | .byte $F0 |
- | .byte $08 | + | .byte $08 |
LFAF2: | LFAF2: | ||
* jsr LFAFF | * jsr LFAFF | ||
- | lda PageIndex | + | |
- | sec | + | sec |
- | sbc #$08 | + | sbc #$08 |
- | tay | + | tay |
- | bne - | + | bne - |
LFAFF: | LFAFF: | ||
- | 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 | + | |
- | 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, | * sta EnDataIndex, | ||
- | lda #$01 | + | |
- | sta EnDelay,x | + | sta EnDelay,x |
- | jmp KillObject ; | + | jmp KillObject |
LFB7B: | LFB7B: | ||
- | ror $0405,x | + | |
- | lda EnemyInitDelayTbl, | + | lda EnemyInitDelayTbl, |
- | sta EnDelay,x ; | + | sta EnDelay, |
Exit13: | Exit13: | ||
- | rts ;Exit from multiple routines. | + | |
LFB88: | LFB88: | ||
- | 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) | + | |
* cmp #$08 | * cmp #$08 | ||
- | 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, | + | |
- | beq Exit13 | + | beq Exit13 |
- | jmp LF68D | + | jmp LF68D |
LFBCA: | LFBCA: | ||
- | 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: | LFBDD: | ||
- | sta PageIndex | + | |
- | ldx #$0C | + | ldx #$0C |
* jsr LFBEC | * jsr LFBEC | ||
- | dex | + | |
- | dex | + | dex |
- | dex | + | dex |
- | dex | + | dex |
- | bne - | + | bne - |
LFBEC: | LFBEC: | ||
- | 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 |
- | 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 |
- | bcs + | + | bcs + |
- | jsr IsScrewAttackActive ; | + | jsr IsScrewAttackActive |
- | 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 |
* pla | * pla | ||
- | tax | + | |
- | * rts | + | * |
- | * 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 $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: | LFC65: | ||
- | 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 | + | |
- | 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 ; | + | * jmp KillObject |
LFC98: | LFC98: | ||
- | jsr ChooseRoutine | + | |
; Pointer table to code | ; Pointer table to code | ||
- | .word ExitSub | + | |
- | .word $FCA5 | + | .word $FCA5 |
- | .word $FCB1 | + | .word $FCB1 |
- | .word $FCBA | + | .word $FCBA |
LFCA5: | LFCA5: | ||
- | jsr LFD08 | + | |
- | jsr LFD25 | + | jsr LFD25 |
- | jmp LDD8B | + | jmp LDD8B |
LFCB1: | LFCB1: | ||
- | jsr LFCC1 | + | |
- | jmp LDD8B | + | jmp LDD8B |
LFCBA: | LFCBA: | ||
- | sta $B0,x | + | |
- | jmp SFX_EnemyHit | + | jmp SFX_EnemyHit |
LFCC1: | LFCC1: | ||
- | 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 | + | |
- | lsr | + | lsr |
- | bcc + | + | bcc + |
- | ldy #$FF | + | ldy #$FF |
* sty $05 | * sty $05 | ||
- | ldy #$04 | + | |
- | lsr | + | lsr |
- | lda $B5,x | + | lda $B5,x |
- | bcc + | + | bcc + |
- | ldy #$FD | + | ldy #$FD |
* sty $04 | * sty $04 | ||
- | 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 | + | |
* lda $B5,x | * lda $B5,x | ||
- | cmp #$50 | + | |
- | bcc + | + | bcc + |
- | lda #$01 | + | lda #$01 |
- | sta $B0,x | + | sta $B0,x |
* rts | * rts | ||
LFD08: | LFD08: | ||
- | 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 |
* cmp #$10 | * cmp #$10 | ||
- | bcs + | + | |
- | tya | + | tya |
- | sta $B4,x | + | sta $B4,x |
- | lda #$02 | + | lda #$02 |
- | sta $B0,x | + | sta $B0,x |
* rts | * rts | ||
LFD25: | LFD25: | ||
- | 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 |
- | cpy #$80 | + | cpy #$80 |
- | bcc ++ | + | bcc ++ |
* sta $04 | * sta $04 | ||
* jsr LFD8F | * jsr LFD8F | ||
- | jmp LFD6C | + | |
; Table used by above subroutine | ; Table used by above subroutine | ||
Table18: | Table18: | ||
- | .byte $02 | + | |
- | .byte $FE | + | .byte $FE |
- | .byte $01 | + | .byte $01 |
- | .byte $FF | + | .byte $FF |
- | .byte $02 | + | .byte $02 |
LFD5F: | LFD5F: | ||
- | 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: | LFD6C: | ||
- | 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: | LFD84: | ||
- | and #$04 | + | |
- | beq + | + | beq + |
- | lda #$03 | + | lda #$03 |
- | sta $B0,x | + | sta $B0,x |
* rts | * rts | ||
LFD8F: | LFD8F: | ||
- | 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 | + | |
- | bne ClcExit2 | + | bne ClcExit2 |
- | inc $0B | + | inc $0B |
* sta $08 | * sta $08 | ||
- | jmp LFDBF | + | |
- | * 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: | LFDBF: | ||
- | 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 + | + | |
- | ldy $02 | + | ldy $02 |
- | beq ClcExit2 | + | beq ClcExit2 |
- | inc $0B | + | inc $0B |
* sta $09 | * sta $09 | ||
- | SecExit: | + | |
- | sec | + | sec |
- | rts | + | rts |
- | ClcExit2: | + | |
- | clc | + | clc |
- | * rts | + | * |
- | + | ||
- | LFDE3: | + | |
- | cmp #$99 | + | |
- | bne + | + | |
- | clc | + | |
- | sbc EndTimerLo | + | |
- | bne + ; branch if not | + | |
- | sta $06 | + | |
- | lda #$38 | + | |
- | sta $07 | + | |
- | jsr LDC54 | + | |
- | * ldx #$20 | + | |
- | * jsr LFE05 | + | |
- | txa | + | |
- | sec | + | |
- | sbc #$08 | + | |
- | tax | + | |
- | bne - | + | |
- | LFE05: | + | UpdateTourianItems: |
- | sec | + | ; Adds mother brain and zebetite |
- | sbc #$02 | + | LFDE3: |
- | 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 ; | ||
+ | jsr LDC54 ; | ||
+ | |||
+ | * ldx #$20 ; Loop through zebetites (@ x = 20, 18, 10, 8, 0) | ||
+ | * jsr CheckZebetite | ||
+ | txa ; | ||
+ | sec | ||
+ | sbc #$08 | ||
+ | tax | ||
+ | bne - | ||
+ | |||
+ | CheckZebetite | ||
+ | LFE05: | ||
+ | sec | ||
+ | sbc #$02 ; | ||
+ | bne --- ; Exit if zebetite state != 2 | ||
+ | sta $06 ; Store 0 to $06 | ||
+ | inc $0758, | ||
+ | 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/ | ; Tile degenerate/ | ||
UpdateTiles: | UpdateTiles: | ||
- | ldx #$C0 | + | |
* jsr DoOneTile | * jsr DoOneTile | ||
- | 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 | + | |
- | .word $FE3D | + | .word $FE3D |
- | .word $FE54 | + | .word $FE54 |
- | .word $FE59 | + | .word $FE59 |
- | .word $FE54 | + | .word $FE54 |
- | .word $FE83 | + | .word $FE83 |
LFE3D: | LFE3D: | ||
- | lda #$00 | + | |
- | jsr SetTileAnim | + | jsr SetTileAnim |
- | lda #$50 | + | lda #$50 |
- | sta TileDelay, | + | sta TileDelay, |
- | lda TileWRAMLo, | + | lda TileWRAMLo, |
- | sta $00 | + | sta $00 |
- | lda TileWRAMHi, | + | lda TileWRAMHi, |
- | sta $01 | + | sta $01 |
LFE54: | LFE54: | ||
- | jmp UpdateTileAnim | + | |
LFE59: | LFE59: | ||
- | 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, | + | sta TileAnimDelay, |
* rts | * rts | ||
Line 9455: | Line 9460: | ||
Table19: | Table19: | ||
- | .byte $18, | + | |
LFE83: | LFE83: | ||
- | sta TileRoutine, | + | |
- | 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 |
- | 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: | + | |
- | 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 | + | jsr Adiv16 |
- | 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 | + | |
- | 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 | + | |
- | sta $01 | + | sta $01 |
- | jsr LC328 | + | jsr LC328 |
- | clc | + | clc |
- | rts | + | rts |
LFF3C: | LFF3C: | ||
- | 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 | + | |
- | ldy TileAnimDelay, | + | ldy TileAnimDelay, |
- | beq + | + | beq + |
- | dec TileAnimDelay, | + | dec TileAnimDelay, |
- | bne ++ | + | bne ++ |
* sta TileAnimDelay, | * sta TileAnimDelay, | ||
- | ldy TileAnimIndex, | + | |
- | lda TileBlastAnim, | + | lda TileBlastAnim, |
- | cmp #$FE | + | cmp #$FE ; end of " |
- | 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 | + | * |
* inc TileRoutine, | * inc TileRoutine, | ||
- | pla | + | |
- | pla | + | pla |
- | rts | + | rts |
; Frame data for tile blasts | ; Frame data for tile blasts | ||
- | TileBlastAnim: | + | |
- | .byte $06, | + | .byte $06, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $07, | + | .byte $07, |
- | .byte $00 | + | |
- | .byte $00 | + | .byte $00 |
; | ; | ||
RESET: | RESET: | ||
- | LFFB0: SEI ;Disables interrupt | + | LFFB0: |
- | LFFB1: CLD ;Sets processor to binary mode | + | LFFB1: |
- | LFFB2: LDX #$00 ; | + | LFFB2: |
- | LFFB4: STX PPUControl0 ;Clear PPU control registers | + | LFFB4: |
- | LFFB7: STX PPUControl1 ; | + | LFFB7: |
- | LFFBA:* LDA PPUStatus ; | + | LFFBA:* LDA PPUStatus |
- | LFFBD: BPL - ;Wait for VBlank | + | LFFBD: |
- | LFFBF:* LDA PPUStatus ; | + | LFFBF:* LDA PPUStatus |
- | LFFC2: BPL - ; | + | LFFC2: |
- | LFFC4: ORA #$FF ; | + | LFFC4: |
- | LFFC6: STA MMC1Reg0 ;Reset MMC1 chip | + | LFFC6: |
- | LFFC9: STA MMC1Reg1 ;(MSB is set) | + | LFFC9: |
- | LFFCC: STA MMC1Reg2 ; | + | LFFCC: |
- | LFFCF: STA MMC1Reg3 ; | + | LFFCF: |
- | LFFD2: JMP Startup ;($C01A)Do preliminary housekeeping. | + | LFFD2: |
;Not used. | ;Not used. | ||
- | LFFD5: | + | LFFD5: |
- | LFFE5: | + | LFFE5: |
- | LFFF5: | + | LFFF5: |
; | ; | ||
- | LBFFA: | + | LBFFA: |
- | LBFFC: | + | LBFFC: |
- | LBFFE: | + | LBFFE: |
</ | </ | ||
+ |