aimedbills

by perryman1138

Game: SMW

Description:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Aimed Bullet/Eerie Generator, by yoshicookiezeus
;; based on mikeyk's generic.asm
;;
;; Continuously generates sprites at Mario's height from the direction
;; he is facing.
;;
;; Uses first extra bit: NO
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    !SpriteToGen        = $1C   ; USE $1C for bullet bills, $38 for eeries
    !TimeBetweenSpawns  = $FE   ; needs to be one less than a power of 2
                                ; recommended: $7F for bills, $3F for eeries

    !RAM_ScreenBndryXLo = $1A
    !RAM_ScreenBndryXHi = $1B
    !RAM_ScreenBndryYLo = $1C
    !RAM_ScreenBndryYHi = $1D
    !RAM_MarioDirection = $76
    !RAM_MarioYPos      = $96
    !RAM_MarioYPosHi    = $97
    !RAM_SpritesLocked  = $9D
    !addr = $0000
;    !9E $7E009E
;    !14D4 $7E14D4
;    !14E0 $7E14E0
	
	
Main:
    LDA $14                     ;\  if not time to spawn sprite
    AND #!TimeBetweenSpawns     ; |
    ORA !RAM_SpritesLocked      ; | or if sprites locked,
    BNE .Return                 ;/  branch
    JSL $02A9DE                 ;\  find empty sprite slot
    BMI .Return                 ;/  if no slot found, return
    TYX        
    
    LDA #!SpriteToGen           ;\  set new sprite number
    STA $7E009E,x                   ;/
    JSL $07F7D2                 ; reset sprite properties
    LDA #$08                    ;\  set new sprite status
    STA $7E14C8,x                 ;/

    LDA !RAM_MarioYPos          ;\ set new sprite y position to Mario y position
    CLC                         ; |
    ADC #$08                    ; |
    STA $7E00D8,x                   ; |
    LDA !RAM_MarioYPosHi        ; |
    ADC #$00                    ; |
    STA $7E14D4,x                 ;/

    LDA !RAM_MarioDirection     ;\ use the direction Mario is facing
    TAY                         ;/ to determine sprite direction
    LDA .OffsetXLo,y            ;\  use direction to determine x offset
    CLC                         ; |
    ADC !RAM_ScreenBndryXLo     ; | add screen position
    STA $7E00E4,x                   ; | and set as sprite x position
    LDA !RAM_ScreenBndryXHi     ; |
    ADC .OffsetXHi,y            ; |
    STA $7E14E0,x                 ;/
    if !SpriteToGen == $1C
        LDA .Dir,y              ;\ set sprite direction
        STA $7E00C2,x               ;/
        LDA #$09                ;\ play sound effect
        STA $1DFC|!addr         ;/
    endif
    if !SpriteToGen == $38
        LDA .SpeedX,y           ;\ set sprite speed
        STA $7E00B6,x               ;/
    endif
.Return:
    RTL


.OffsetXLo: db $F0,$FF
.OffsetXHi: db $FF,$00
.Dir:       db $00,$01
.SpeedX:    db $10,$F0
back to listings