;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Balrog 1 and 3
; by Sonikku
; Description: Based off of the first Balrog encounter. He runs around and then
; jumps. If you fail to stomp him but still make contact, he grabs you and then
; throws you. If the extra bit is set, he will launch a few missiles like the
; third Balrog encounter.
HP1 = $07 ; how many stomps before the level is beaten (Extra bit clear).
HP2 = $09 ; how many stomps before the level is beaten (Extra bit set).
PROJECT = $03 ; sprite number of BalrogProjectile.cfg.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INIT and MAIN JSL targets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "INIT"
JSR SUB_HORZ_POS
TYA
STA $157C,x
RTL
dcb "MAIN"
PHB
PHK
PLB
JSR SPRITE_ROUTINE
PLB
RTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SPRITE_ROUTINE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
WALKFRM dcb $04,$00,$05,$00
XMAX dcb $18,$E8
XACCEL dcb $01,$FF
TIMER dcb $40,$20,$70,$B0,$20,$60,$60,$A0
MARSPD dcb $30,$D0
RETURN RTS
SPRITE_ROUTINE
JSR SUB_OFF_SCREEN_X0
JSR SUB_GFX
LDA $9D
BNE RETURN
LDA $C2,x
CMP #$02
BEQ NOCON
LDA $1FE2,x
BNE NOCON
JSL $01A7DC
BCC NOCON
JSR SUB_VERT_POS
LDA $0E
CMP #$E6
BPL SPRITE_WINS
LDA $7D
BMI NOCON
JSL $01AA33
JSL $01AB99
LDA $1564,x
BNE NOSTUN
LDA #$13
STA $1DF9
LDA #$80
STA $1564,x
LDA #$08
STA $1FE2,x
INC $1594,x
LDA $7FAB10,x
AND #$04
BEQ CLEAR
LDA #HP2
BRA SETHP
CLEAR LDA #HP1
SETHP CMP $1594,x
BNE NOCON
LDA #$02
STA $C2,x
LDA #$50
STA $154C,x
STZ $B6,x
STZ $AA,x
BRA NOCON
NOSTUN LDA #$02
STA $1DF9
LDA #$08
STA $154C,x
BRA NOCON
SPRITE_WINS
LDA $154C,x
BNE NOCON
LDA #$B0
STA $154C,x
LDA #$60
STA $1558,x
LDA #$FF
STA $78
JSL $00F5B7
NOCON JSL $01802A
LDA $1588,x
AND #$04
BEQ INAIR
LDA $C2,x
BEQ NOTIMR
LDA $163E,x
BEQ NOTIMR
CMP #$10
BMI STANDG
LDA #$02
STA $1602,x
BRA NOTIMR
STANDG STZ $1602,x
NOTIMR LDA $151C,x
BEQ NOSMSH
STZ $151C,x
LDA #$10
STA $1887
LDA #$09
STA $1DFC
LDA $C2,x
BEQ NOSMSH
LDA #$20
STA $163E,x
BRA NOSMSH
INAIR LDA #$01
STA $151C,x
LDA #$03
STA $1602,x
LDA $7FAB10,x
AND #$04
BEQ NOSMSH
JSR SUB_HORZ_POS
TYA
STA $157C,x
NOSMSH LDA $C2,x
JSL $0086DF
dcw STATE0&$FFFF
dcw STATE1&$FFFF
dcw STATE2&$FFFF
STATE0 STZ $7D
STZ $7B
LDA #$0B
STA $71
LDA $1588,x
AND #$04
BEQ RETURN0
LDA $163E,x
BEQ SETTIMR
CMP #$01
BEQ INCSTT
CMP #$50
BPL STUND0
CMP #$30
BPL STAND0
CMP #$08
BMI STAND0
LDA #$07
BRA STRFRM0
SETTIMR LDA #$60
STA $163E,x
RTS
STUND0 LDA #$02
BRA STRFRM0
STAND0 LDA #$00
BRA STRFRM0
STRFRM0 STA $1602,x
RTS
INCSTT INC $C2,x
STZ $71
LDA #$70
STA $1540,x
RETURN0 RTS
STATE1 LDA $1558,x
BEQ NOGRAB
CMP #$01
BEQ LNCHMAR
CMP #$5D
BPL NOWARP
LDA $E4,x
CLC
ADC #$08
STA $94
LDA $14E0,x
ADC #$00
STA $95
LDA $D8,x
SEC
SBC #$14
STA $96
LDA $14D4,x
SBC #$00
STA $97
NOWARP LDA #$FF
STA $78
LDA #$08
STA $1602,x
LDA #$03
STA $1497
STZ $B6,x
RTS
LNCHMAR LDY $157C,x
LDA MARSPD,y
STA $7B
LDA #$20
STA $1497
NOGRAB LDA $1510,x
BEQ NOGRAB2
LDA #$03
CMP $1602,x
BNE NOGRAB2
DEC $1510,x
LDA #$10
CMP $1510,x
BCC NOGRAB2
LDA $14
AND #$03
BNE NOGRAB2
JSL $02A9DE
BMI NOGRAB2
LDA #$01
STA $14C8,y
PHX
LDA #PROJECT
TYX
STA $7FAB9E,x
PLX
LDA $E4,x
CLC
ADC #$08
STA $00E4,y
LDA $14E0,x
ADC #$00
STA $14E0,y
LDA $D8,x
STA $00D8,y
LDA $14D4,x
STA $14D4,y
PHX
TYX
JSL $07F7D2
JSL $0187A7
LDA #$08
STA $7FAB10,x
PLX
LDA #$02
STA $1594,y
LDA #$20
STA $1540,y
JSL $01ACF9
AND #$01
TAY
STA $C2,y
NOGRAB2 LDA $1588,x
AND #$03
BEQ WALK
STZ $B6,x
WALK LDA $1588,x
AND #$04
BEQ INAIR1
LDA $154C,x
CMP #$01
BEQ JUMP
BPL SET2JMP
LDA $14
AND #$FF
BNE NOJMP
LDA #$10
STA $154C,x
BRA NOJMP
JUMP LDA #$C0
STA $AA,x
LDY $157C,x
LDA XMAX,y
STA $B6,x
LDA $7FAB10,x
AND #$04
BEQ SET2JMP
LDA #$25
STA $1510,x
SET2JMP LDA #$02
STA $1602,x
BRA DECSPD
INAIR1 DEC $AA,x
RTS
NOJMP LDA $1540,x
BEQ STAND
LDA $14
LSR A
LSR A
AND #$03
TAY
LDA WALKFRM,y
STA $1602,x
LDY $157C,x
LDA XMAX,y
CMP $B6,x
BEQ RETURN1
LDA $14
AND #$01
BNE RETURN1
LDA $B6,x
CLC
ADC XACCEL,y
STA $B6,x
RTS
STAND STZ $1602,x
DECSPD LDA $B6,x
BEQ FACEMAR
LDA $B6,x
SEC
SBC XACCEL,y
STA $B6,x
LDA #$10
STA $163E,x
RETURN1 RTS
FACEMAR LDA $163E,x
BNE RETURN1
JSR SUB_HORZ_POS
TYA
STA $157C,x
JSL $01ACF9
AND #$07
TAY
LDA TIMER,y
STA $1540,x
RTS
STATE2 LDA $154C,x
BEQ UP
CMP #$10
BPL DEAD
LDA #$02
STA $1602,x
STZ $B6,x
RTS
DEAD LDA #$06
STA $1602,x
STZ $151C,x
LDA $1588,x
AND #$04
BNE ONGND2
DEC $AA,x
ONGND2 LDA $14
AND #$01
BNE RETURN2
LDA $E4,x
EOR #$02
STA $E4,x
RTS
UP LDA #$A0
STA $AA,x
INC $1594,x
LDA $1594,x
CMP #$30
BNE RETURN2
LDA #$0B
STA $71
LDA #$FF
STA $1493
STA $1DFB
LDA #$05
STA $1DF9
STZ $14C8,x
RETURN2 RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; graphics routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TILEMAP dcb $80,$82,$90,$92 ; stand ; $00
dcb $80,$82,$84,$86 ; stand (eyes closed) ; $01
dcb $80,$82,$88,$8A ; charging/land (for jump) ; $02
dcb $A8,$AA,$B8,$BA ; jumping/in air ; $03
dcb $80,$82,$C4,$C6 ; walk 1 ; $04
dcb $80,$82,$E4,$E6 ; walk 2 ; $05
dcb $B0,$B2,$C0,$C2 ; shocked/dead ; $06
dcb $80,$82,$A4,$A6 ; standing (smiling) ; $07
dcb $D8,$DA,$E8,$EA ; facing away from screen ; $08
dcb $8C,$8E,$9C,$9E ; fly 1 ; $09
dcb $BC,$BE,$CC,$CD ; fly 2 ; $0A
dcb $80,$82,$E0,$E2 ; stand (mouth open) ; $0B
X_OFFSET dcb $10,$00,$10,$00 ; $157C,x = #$00
dcb $00,$10,$00,$10 ; $157C,x = #$01
Y_OFFSET dcb $F8,$F8,$00,$00
dcb $F8,$F8,$00,$00
dcb $FA,$FA,$00,$00
dcb $F8,$F8,$00,$00
dcb $F7,$F7,$FF,$FF
dcb $F7,$F7,$FF,$FF
dcb $F8,$F8,$00,$00
dcb $F8,$F8,$00,$00
dcb $F8,$F8,$00,$00
dcb $F8,$F8,$00,$00
dcb $F8,$F8,$00,$00
dcb $F8,$F8,$00,$00
SUB_GFX JSR GET_DRAW_INFO ; sets y = OAM offset
LDA $157C,x ; \ $02 = direction
ASL A
ASL A
STA $02 ; /
LDA $1602,x
ASL A
ASL A
STA $03
PHX
LDX #$03
LOOP_START PHX
TXA
CLC
ADC $02
TAX
LDA X_OFFSET,x
CLC
ADC $00 ; \ tile x position = sprite y location ($01)
STA $0300,y ; /
PLX
PHX
TXA
CLC
ADC $03
TAX
LDA TILEMAP,x
STA $0302,y
LDA Y_OFFSET,x
CLC
ADC $01 ; \ tile y position = sprite x location ($00)
STA $0301,y ; /
PLX
PHX
LDX $15E9
LDA $15F6,x ; tile properties xyppccct, format
LDX $02 ; \ if direction == 0...
BNE NO_FLIP ; |
ORA #$40 ; / ...flip tile
NO_FLIP ORA $64 ; add in tile priority of level
STA $0303,y ; store tile properties
PLX
INY ; \ increase index to sprite tile map ($300)...
INY ; | ...we wrote 1 16x16 tile...
INY ; | ...sprite OAM is 8x8...
INY ; / ...so increment 4 times
DEX
BPL LOOP_START
PLX
LDY #$02 ; \ 460 = 2 (all 16x16 tiles)
LDA #$03 ; | A = (number of tiles drawn - 1)
JSL $01B7B3 ; / don't draw if offscreen
RTS ; return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ROUTINES FROM THE LIBRARY ARE PASTED BELOW
; You should never have to modify this code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine. It sets off screen flags, and sets up
; variables. It will return with the following:
;
; Y = index to sprite OAM ($300)
; $00 = sprite x position relative to screen boarder
; $01 = sprite y position relative to screen boarder
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPR_T1 dcb $0C,$1C
SPR_T2 dcb $01,$02
GET_DRAW_INFO STZ $186C,x ; reset sprite offscreen flag, vertical
STZ $15A0,x ; reset sprite offscreen flag, horizontal
LDA $E4,x ; \
CMP $1A ; | set horizontal offscreen if necessary
LDA $14E0,x ; |
SBC $1B ; |
BEQ ON_SCREEN_X ; |
INC $15A0,x ; /
ON_SCREEN_X LDA $14E0,x ; \
XBA ; |
LDA $E4,x ; |
REP #$20 ; |
SEC ; |
SBC $1A ; | mark sprite invalid if far enough off screen
CLC ; |
ADC.W #$0040 ; |
CMP.W #$0180 ; |
SEP #$20 ; |
ROL A ; |
AND #$01 ; |
STA $15C4,x ; /
BNE INVALID ;
LDY #$00 ; \ set up loop:
LDA $1662,x ; |
AND #$20 ; | if not smushed (1662 & 0x20), go through loop twice
BEQ ON_SCREEN_LOOP ; | else, go through loop once
INY ; /
ON_SCREEN_LOOP LDA $D8,x ; \
CLC ; | set vertical offscreen if necessary
ADC SPR_T1,y ; |
PHP ; |
CMP $1C ; | (vert screen boundry)
ROL $00 ; |
PLP ; |
LDA $14D4,x ; |
ADC #$00 ; |
LSR $00 ; |
SBC $1D ; |
BEQ ON_SCREEN_Y ; |
LDA $186C,x ; | (vert offscreen)
ORA SPR_T2,y ; |
STA $186C,x ; |
ON_SCREEN_Y DEY ; |
BPL ON_SCREEN_LOOP ; /
LDY $15EA,x ; get offset to sprite OAM
LDA $E4,x ; \
SEC ; |
SBC $1A ; | $00 = sprite x position relative to screen boarder
STA $00 ; /
LDA $D8,x ; \
SEC ; |
SBC $1C ; | $01 = sprite y position relative to screen boarder
STA $01 ; /
RTS ; return
INVALID PLA ; \ return from *main gfx routine* subroutine...
PLA ; | ...(not just this subroutine)
RTS ; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SUB_OFF_SCREEN
; This subroutine deals with sprites that have moved off screen
; It is adapted from the subroutine at $01AC0D
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPR_T12 dcb $40,$B0
SPR_T13 dcb $01,$FF
SPR_T14 dcb $30,$C0,$A0,$C0,$A0,$F0,$60,$90 ;bank 1 sizes
dcb $30,$C0,$A0,$80,$A0,$40,$60,$B0 ;bank 3 sizes
SPR_T15 dcb $01,$FF,$01,$FF,$01,$FF,$01,$FF ;bank 1 sizes
dcb $01,$FF,$01,$FF,$01,$00,$01,$FF ;bank 3 sizes
SUB_OFF_SCREEN_X1 LDA #$02 ; \ entry point of routine determines value of $03
BRA STORE_03 ; | (table entry to use on horizontal levels)
SUB_OFF_SCREEN_X2 LDA #$04 ; |
BRA STORE_03 ; |
SUB_OFF_SCREEN_X3 LDA #$06 ; |
BRA STORE_03 ; |
SUB_OFF_SCREEN_X4 LDA #$08 ; |
BRA STORE_03 ; |
SUB_OFF_SCREEN_X5 LDA #$0A ; |
BRA STORE_03 ; |
SUB_OFF_SCREEN_X6 LDA #$0C ; |
BRA STORE_03 ; |
SUB_OFF_SCREEN_X7 LDA #$0E ; |
STORE_03 STA $03 ; |
BRA START_SUB ; |
SUB_OFF_SCREEN_X0 STZ $03 ; /
START_SUB JSR SUB_IS_OFF_SCREEN ; \ if sprite is not off screen, return
BEQ RETURN_35 ; /
LDA $5B ; \ goto VERTICAL_LEVEL if vertical level
AND #$01 ; |
BNE VERTICAL_LEVEL ; /
LDA $D8,x ; \
CLC ; |
ADC #$50 ; | if the sprite has gone off the bottom of the level...
LDA $14D4,x ; | (if adding 0x50 to the sprite y position would make the high byte >= 2)
ADC #$00 ; |
CMP #$02 ; |
BPL ERASE_SPRITE ; / ...erase the sprite
LDA $167A,x ; \ if "process offscreen" flag is set, return
AND #$04 ; |
BNE RETURN_35 ; /
LDA $13 ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0756 VC:176 00 FL:205
AND #$01 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0780 VC:176 00 FL:205
ORA $03 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0796 VC:176 00 FL:205
STA $01 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0820 VC:176 00 FL:205
TAY ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0844 VC:176 00 FL:205
LDA $1A ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0858 VC:176 00 FL:205
CLC ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0882 VC:176 00 FL:205
ADC SPR_T14,y ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0896 VC:176 00 FL:205
ROL $00 ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizcHC:0928 VC:176 00 FL:205
CMP $E4,x ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:0966 VC:176 00 FL:205
PHP ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:0996 VC:176 00 FL:205
LDA $1B ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdizCHC:1018 VC:176 00 FL:205
LSR $00 ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdiZCHC:1042 VC:176 00 FL:205
ADC SPR_T15,y ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdizcHC:1080 VC:176 00 FL:205
PLP ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F0 P:eNvMXdizcHC:1112 VC:176 00 FL:205
SBC $14E0,x ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1140 VC:176 00 FL:205
STA $00 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:1172 VC:176 00 FL:205
LSR $01 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:1196 VC:176 00 FL:205
BCC SPR_L31 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZCHC:1234 VC:176 00 FL:205
EOR #$80 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZCHC:1250 VC:176 00 FL:205
STA $00 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1266 VC:176 00 FL:205
SPR_L31 LDA $00 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1290 VC:176 00 FL:205
BPL RETURN_35 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1314 VC:176 00 FL:205
ERASE_SPRITE LDA $14C8,x ; \ if sprite status < 8, permanently erase sprite
CMP #$08 ; |
BCC KILL_SPRITE ; /
LDY $161A,x ;A:FF08 X:0007 Y:0001 D:0000 DB:01 S:01F3 P:envMXdiZCHC:1108 VC:059 00 FL:2878
CPY #$FF ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdiZCHC:1140 VC:059 00 FL:2878
BEQ KILL_SPRITE ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdizcHC:1156 VC:059 00 FL:2878
LDA #$00 ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdizcHC:1172 VC:059 00 FL:2878
STA $1938,y ;A:FF00 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdiZcHC:1188 VC:059 00 FL:2878
KILL_SPRITE STZ $14C8,x ; erase sprite
RETURN_35 RTS ; return
VERTICAL_LEVEL LDA $167A,x ; \ if "process offscreen" flag is set, return
AND #$04 ; |
BNE RETURN_35 ; /
LDA $13 ; \
LSR A ; |
BCS RETURN_35 ; /
LDA $E4,x ; \
CMP #$00 ; | if the sprite has gone off the side of the level...
LDA $14E0,x ; |
SBC #$00 ; |
CMP #$02 ; |
BCS ERASE_SPRITE ; / ...erase the sprite
LDA $13 ;A:0000 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:1218 VC:250 00 FL:5379
LSR A ;A:0016 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1242 VC:250 00 FL:5379
AND #$01 ;A:000B X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1256 VC:250 00 FL:5379
STA $01 ;A:0001 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1272 VC:250 00 FL:5379
TAY ;A:0001 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1296 VC:250 00 FL:5379
LDA $1C ;A:001A X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0052 VC:251 00 FL:5379
CLC ;A:00BD X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0076 VC:251 00 FL:5379
ADC SPR_T12,y ;A:00BD X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0090 VC:251 00 FL:5379
ROL $00 ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:enVMXdizCHC:0122 VC:251 00 FL:5379
CMP $D8,x ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0160 VC:251 00 FL:5379
PHP ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0190 VC:251 00 FL:5379
LDA.W $001D ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F2 P:eNVMXdizcHC:0212 VC:251 00 FL:5379
LSR $00 ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:enVMXdiZcHC:0244 VC:251 00 FL:5379
ADC SPR_T13,y ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:enVMXdizCHC:0282 VC:251 00 FL:5379
PLP ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:envMXdiZCHC:0314 VC:251 00 FL:5379
SBC $14D4,x ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0342 VC:251 00 FL:5379
STA $00 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0374 VC:251 00 FL:5379
LDY $01 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0398 VC:251 00 FL:5379
BEQ SPR_L38 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0422 VC:251 00 FL:5379
EOR #$80 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0438 VC:251 00 FL:5379
STA $00 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0454 VC:251 00 FL:5379
SPR_L38 LDA $00 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0478 VC:251 00 FL:5379
BPL RETURN_35 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0502 VC:251 00 FL:5379
BMI ERASE_SPRITE ;A:8AFF X:0002 Y:0000 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0704 VC:184 00 FL:5490
SUB_IS_OFF_SCREEN LDA $15A0,x ; \ if sprite is on screen, accumulator = 0
ORA $186C,x ; |
RTS ; / return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SUB_HORZ_POS
; This routine determines which side of the sprite Mario is on. It sets the Y register
; to the direction such that the sprite would face Mario
; It is ripped from $03B817
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SUB_HORZ_POS LDY #$00 ;A:25D0 X:0006 Y:0001 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1020 VC:097 00 FL:31642
LDA $94 ;A:25D0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZCHC:1036 VC:097 00 FL:31642
SEC ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1060 VC:097 00 FL:31642
SBC $E4,x ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1074 VC:097 00 FL:31642
STA $0F ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1104 VC:097 00 FL:31642
LDA $95 ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1128 VC:097 00 FL:31642
SBC $14E0,x ;A:2500 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZcHC:1152 VC:097 00 FL:31642
BPL SPR_L16 ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1184 VC:097 00 FL:31642
INY ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1200 VC:097 00 FL:31642
SPR_L16 RTS ;A:25FF X:0006 Y:0001 D:0000 DB:03 S:01ED P:envMXdizcHC:1214 VC:097 00 FL:31642
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SUB_VERT_POS
; This routine determines if Mario is above or below the sprite. It sets the Y register
; to the direction such that the sprite would face Mario
; It is ripped from $03B829
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SUB_VERT_POS LDY #$00 ;A:25A1 X:0007 Y:0001 D:0000 DB:03 S:01EA P:envMXdizCHC:0130 VC:085 00 FL:924
LDA $96 ;A:25A1 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdiZCHC:0146 VC:085 00 FL:924
SEC ;A:2546 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizCHC:0170 VC:085 00 FL:924
SBC $D8,x ;A:2546 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizCHC:0184 VC:085 00 FL:924
STA $0F ;A:25D6 X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0214 VC:085 00 FL:924
LDA $97 ;A:25D6 X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0238 VC:085 00 FL:924
SBC $14D4,x ;A:2501 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizcHC:0262 VC:085 00 FL:924
BPL SPR_L11 ;A:25FF X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0294 VC:085 00 FL:924
INY ;A:25FF X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0310 VC:085 00 FL:924
SPR_L11 RTS ;A:25FF X:0007 Y:0001 D:0000 DB:03 S:01EA P:envMXdizcHC:0324 VC:085 00 FL:924