;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;INIT_ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; dcb "INIT" RTL dcb "MAIN" PHB PHK PLB JSR SPRITE_ROUTINE PLB RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SPRITE_ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; X_Speed dcb $00,$00 ; X speed (right,left) SPRITE_ROUTINE LDA $14C8,x ; return if sprite status != 8 CMP #$08 BNE RETURN JSR SUB_GFX LDA $9D ; return if sprites locked BNE RETURN JSR SUB_OFF_SCREEN_X0 ; only process sprite while on screen JSL Fire_Routine Powerup_routine LDA $187A ;\ If touching Mario... BNE RETURN1 ; | JSL $01A7DC ; | BCC RETURN1 ; | JSR PowerupRoutine ;/ Run powerup routine STZ $14C8,x ; Erase sprite RETURN1 JSL $01802A ; Update position based on speed value RETURN RTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; fire routine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Fire_Routine LDX.B #$09 ; \ Find a free fireball slot (08-09) LDA.W RAM_ExSpriteNum,X ; | BEQ CODE_00FEB5 ; | DEX ; | CPX.B #$07 ; | BNE CODE_00FEAA ; | RTS ; / Return if no free slots LDA.B #$06 STA.W $1DFC ; / Play sound effect LDA.B #$0A STA.W RAM_FireballImgTimer LDA.B #$05 ; \ Extended sprite = Mario fireball STA.W RAM_ExSpriteNum,X ; / LDA.B #$30 STA.W RAM_ExSprSpeedY,X LDY RAM_MarioDirection LDA.W DATA_00FE94,Y STA.W RAM_ExSprSpeedX,X LDA.W RAM_OnYoshi BEQ CODE_00FEDF INY INY LDA.W $18DC BEQ CODE_00FEDF INY INY LDA RAM_MarioXPos CLC ADC.W DATA_00FE96,Y STA.W RAM_ExSpriteXLo,X LDA RAM_MarioXPosHi ADC.W DATA_00FE9C,Y STA.W RAM_ExSpriteXHi,X LDA RAM_MarioYPos CLC ADC.W DATA_00FEA2,Y STA.W RAM_ExSpriteYLo,X LDA RAM_MarioYPosHi ADC.B #$00 STA.W RAM_ExSpriteYHi,X LDA.W RAM_IsBehindScenery STA.W $1779,X JSR powerup_routine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; GRAPHICS ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Properties dcb $40,$00 SUB_GFX JSR GET_DRAW_INFO ; after: Y = index to sprite OAM ($300) ; $00 = sprite x position relative to screen boarder ; $01 = sprite y position relative to screen boarder LDA $14 ; \ Flip flower every 8 frames AND #$00 ; | LSR ; | LSR ; | LSR ; | ($02,x = 0 or 1) STA $02 ; / LDA $00 ; set x position of the tile STA $0300,y LDA $01 ; set y position of the tile STA $0301,y LDA #$80 ; set tile number STA $0302,y LDA $15F6,x ; get sprite palette info PHX LDX $02 ; flip the tile if the sprite direction is 0 ORA Properties,x PLX ORA $64 ; add in the priority bits from the level settings STA $0303,y ; set properties INY ; get the index to the next slot of the OAM INY ; (this is needed if you wish to draw another tile) INY INY LDY #$02 ; #$02 means the tiles are 16x16 LDA #$00 ; This means we drew one tile JSL $01B7B3 RTS