HEADER
LOROM
;;;;;;;;;;;;;;;;;;;;
;;
;; Definitions of stuff
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
incsrc defs.asm
!CodeLength = CodeEnd-CodeStart ;The length of the code for a RATS tag and byte fill ($FF)
!BJump = !DataLocation+$40 ;Spot for loading the Block code for the "below" offset
!AJump = !DataLocation+$60 ;Code for "above" offset
!SJump = !DataLocation+$80 ;I think you get it ...
!CJump = !DataLocation+$C0 ;What!? You've never heard of the center offset?!
!NumBlocksB = $00A0 ;Number of blocks (doubled) for "below" offset coding
!NumBlocksA = $000C ;For "above" offset coding
!NumBlocksS = $0010 ;I think you get it ...
!NumBlocksC = $0004 ;Hmm ... what ever could the center offsets do?
!BTiles = !DataLocation+$01A0 ;Location of the Map16 tile numbers for "below" offset
!BCode = !BTiles+!NumBlocksB ;Location of the pointers to the code for "below" offset
!ATiles = !BCode+!NumBlocksB
!ACode = !ATiles+!NumBlocksA
!STiles = !ACode+!NumBlocksA
!SCode = !STiles+!NumBlocksS
!CTiles = !SCode+!NumBlocksS
!CCode = !CTiles+!NumBlocksC
!MiscData = $3FE00 ;Change this to where you want a tiny ASM hack (~60 bytes)
!P = !Map16Page*$0100 ;A short little name to speed up the writing of Map16 tiles
!Speed = $0004 ;Not recommended to change unless you know what you're doing
!DSpeed = !Speed*$02 ;Used once
!HSpeed = !Speed/$02 ;Used once
!Status1 = $7FFFE6
!Image = $7FFFE8 ;#$0042 makes him disappear and #$0043 is a peace sign
!Travel = $7FFFEA ;#$01 means vertical and #$00 means horizontal
!Vertical = $7FFFEC ;#$01 goes up and #$00 goes down
!Horizontal = $7FFFEE ;#$01 goes right and #$00 goes left
!PowerupHold = $7FFFF0 ;A holder of Mario's current powerup
!Status = $7FFFF2 ;#$0042 if Mario is in a pipe and #$0000 if he isn't
!MarioXPos = $7FFFF4 ;Mario's X position in a pipe
!MarioYPos = $7FFFF6 ;Mario's Y position in a pipe
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Map16 Tiles and their respective code pointers
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; The naming is designed to first name whether it is top
;; or bottom or left or right piece (T,B,L,R). Then whether it is
;; horizontal or vertical (H,V). Then entrance, exit, continuous,
;; or a reappear tile (E,X,C,R). And finally if it's moving left,
;; right, or horizontal or up, down, or vertical (L,R,H,U,D,V). Other
;; certain tiles may be given special names if they do not fit this
;; criteria. A description of what it does will be included. For
;; code pointers, it will start with a B, A, S, or C (offset related).
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
!BHER = !P+$FC ;The "B"ottom part of a "H"orizontal "E"ntrance pipe going "R"ight
!BHCR = !P+$FD
!BHXR = !P+$FE
!THER = !P+$EC
!THCR = !P+$ED
!THXR = !P+$EE
!AHRR = !P+$FF ;An "A"ir reappear tile
!WHRR = !P+$EF ;A "W"ater reappear tile (part of the naming system now)
!BHXL = !P+$F9
!BHCL = !P+$FA
!BHEL = !P+$FB
!THXL = !P+$E9
!THCL = !P+$EA
!THEL = !P+$EB
!AHRL = !P+$F8
!WHRL = !P+$E8
!BHLH = !P+$F4 ;Here, the entrance/exit letter is replaced with an L or R, meaning the
!BHCH = !P+$F5 ;entrance/exit is on the left or right side of the pipe. Sorry if this
!BHRH = !P+$F6 ;is confusing, but I really can't think of a better way to write this.
!THLH = !P+$E4
!THCH = !P+$E5
!THRH = !P+$E6
!AHRH = !P+$F7 ;Since you are probably lost in the naming system, please take solace
!WHRH = !P+$E7 ;in the fact that I will be giving a description before the coding of
!AHLH = !P+$F3 ;of every pipe in the ASM file, so you'll have a better time knowing
!WHLH = !P+$E3 ;what it means the. ;)
!SHER = !P+$F0 ;"S"mall Mario only pipe
!SHCR = !P+$F1
!SHXR = !P+$F2
!SHXL = !P+$E0
!SHCL = !P+$E1
!SHEL = !P+$E2
!SHLH = !P+$D0
!SHCH = !P+$D1
!SHRH = !P+$D2
!RVEU = !P+$9F
!RVCU = !P+$8F
!RVXU = !P+$7F
!WVRU = !P+$6F
!LVEU = !P+$9E
!LVCU = !P+$8E
!LVXU = !P+$7E
!AVRU = !P+$6E
!WVRD = !P+$DF
!RVXD = !P+$CF
!RVCD = !P+$BF
!RVED = !P+$AF
!AVRD = !P+$DE
!LVXD = !P+$CE
!LVCD = !P+$BE
!LVED = !P+$AE
!WVDV = !P+$5F
!RVDV = !P+$4F
!RVCV = !P+$3F
!RVUV = !P+$2F
!WVUV = !P+$1F
!AVDV = !P+$5E
!LVDV = !P+$4E
!LVCV = !P+$3E
!LVUV = !P+$2E
!AVUV = !P+$1E
!SVEU = !P+$C2
!SVCE = !P+$B2
!SVXU = !P+$A2
!SVXD = !P+$C1
!SVCD = !P+$B1
!SVED = !P+$A1
!SVDV = !P+$C0
!SVCV = !P+$B0
!SVUV = !P+$A0
!BU = !P+$B4 ;A "B"ottom piece of pipe which will change the direction to "U"p for the next turn
!TU = !P+$A4
!BD = !P+$B3
!TD = !P+$A3
!LF = !P+$D3 ;A "L"eft piece of pipe making the next turn go "F"orward (right).
!RF = !P+$D4
!LB = !P+$C3
!RB = !P+$C4
!N = !P+$0F ;A null pipe piece (mario travels unaltered)
!T = !P+$00 ;The blue Turn piece (which way it turns Mario depends on the two letter values)
!TRB = !P+$21 ;This and the following are only used once for special cases
!TLB = !P+$20
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Minor ASM Hack to make SMB3 Pipes actually work
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG $CD8b
JSL MovementCode ;A few tweaks to fix what couldn't be done in Map16 coding
ORG $ED20
JSL PageCode1 ;Modifies the page for the SMB3 Pipes. No other custom blocks
ORG $ED37
JSL PageCode2 ;can be put in this page without bad things happening to them
ORG !MiscData
MovementCode:
JSL $00CEB1
PHP
REP #$30
LDA !Image
CMP #$0043
BEQ OtherImage
CMP #$0042
BNE EndMovementCode
SEP #$20
LDA #$40 ;Not visible
StoreImage:
STA $13E0 ;Mario Image
EndMovementCode:
PLP
RTL
OtherImage:
SEP #$20
LDA #$26 ;Peace sign
BRA StoreImage
PageCode1:
STA $77
LDA $04
CMP #!Map16Page
BEQ PageCodeEnd1
LDA $77
ORA #$09
STA $77
PageCodeEnd1:
RTL
PageCode2:
LDA $04
CMP #!Map16Page
BEQ StoreCoord
LDA #$08
TSB $77
RTL
StoreCoord:
LDA #$04
STA $77
PHP
REP #$20
LDA !MarioXPos
STA $94 ;Mario's X position (level, next frame)
LDA !MarioYPos
STA $96 ;Mario's Y position (level, next frame)
PLP
RTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Jump Routines to the custom block code
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG $6F66F ;This code adds an extra offset needed to fix a few bugs
CMP #$B1 ;Center offset
BEQ Center ;Code for center offset
JMP $F602 ;Standard ending JMP found in the ROM
ORG $6F698
JSL !BJump ;"Touched the bottom" code
ORG $6F6A8
JSL !AJump ;"Touched the top" code
ORG $6F6B8
JSL !SJump ;"Touched the sides" code
ORG $6F6D0
Center:
JSL !CJump ;"Touched the center" code
ORG !DataLocation
fillbyte $FF : fill $1000
ORG !DataLocation
CodeStart:
db "STAR" ;The bytefill that came before this serves as an extra way of
dw !CodeLength-$09 ;preserving data. Lunar Magic doesn't write anything in the
dw !CodeLength-$09^$FFFF ;ROM unless it's $00 throughout. Technically, you don't need RATS.
incbin info.bin
ORG !BJump
PHP
REP #$30
PHB
PHX
PHK
PLB
LDA $03 ;Map16 tile number in Lunar Magic
LDX #!NumBlocksB ;Note the value is doubled because a tile number is two bytes long
IncorrectTileB:
DEX
DEX
BMI EndBCode ;Once we go below zero, we're out of blocks, so end the loop
CMP.w !BTiles,x ;Spot where we write the Map16 tiles we'll be changing
BNE IncorrectTileB ;That just means the current Map16 doesn't match the one we want to code
JSR (!BCode,x) ;Spot where we write the pointers to the custom block code
EndBCode:
REP #$30
PLX
PLB
PLP
RTL
ORG !AJump
PHP
REP #$30
PHB
PHX
PHK
PLB
LDA $03 ;Map16 tile number in Lunar Magic
LDX #!NumBlocksA ;Note the value is doubled because a tile number is two bytes long
IncorrectTileA:
DEX
DEX
BMI EndACode ;Once we go below zero, we're out of blocks, so end the loop
CMP.w !ATiles,x ;Spot where we write the Map16 tiles we'll be changing
BNE IncorrectTileA ;That just means the current Map16 doesn't match the one we want to code
JSR (!ACode,x) ;Spot where we write the pointers to the custom block code
EndACode:
REP #$30
PLX
PLB
PLP
RTL
ORG !SJump
PHP
REP #$30
PHB
PHX
PHK
PLB
LDA $03 ;Map16 tile number in Lunar Magic
LDX #!NumBlocksS ;Note the value is doubled because a tile number is two bytes long
IncorrectTileS:
DEX
DEX
BMI EndSCode ;Once we go below zero, we're out of blocks, so end the loop
CMP.w !STiles,x ;Spot where we write the Map16 tiles we'll be changing
BNE IncorrectTileS ;That just means the current Map16 doesn't match the one we want to code
JSR (!SCode,x) ;Spot where we write the pointers to the custom block code
EndSCode:
REP #$30
PLX
PLB
PLP
RTL
ORG !CJump
PHP
REP #$30
PHB
PHX
PHK
PLB
LDA $03 ;Map16 tile number in Lunar Magic
LDX #!NumBlocksC ;Note the value is doubled because a tile number is two bytes long
IncorrectTileC:
DEX
DEX
BMI EndCCode ;Once we go below zero, we're out of blocks, so end the loop
CMP.w !CTiles,x ;Spot where we write the Map16 tiles we'll be changing
BNE IncorrectTileC ;That just means the current Map16 doesn't match the one we want to code
JSR (!CCode,x) ;Spot where we write the pointers to the custom block code
EndCCode:
REP #$30
PLX
PLB
PLP
RTL
ORG !BTiles
dw !BHER,!BHCR,!BHXR,!THER,!THCR,!THXR,!AHRR,!WHRR
dw !BHXL,!BHCL,!BHEL,!THXL,!THCL,!THEL,!AHRL,!WHRL
dw !BHLH,!BHCH,!BHRH,!THLH,!THCH,!THRH,!AHRH,!WHRH
dw !AHLH,!WHLH,!SHER,!SHCR,!SHXR,!SHXL,!SHCL,!SHEL
dw !SHLH,!SHCH,!SHRH,!RVEU,!RVCU,!RVXU,!WVRU,!LVEU
dw !LVCU,!LVXU,!AVRU,!WVRD,!RVXD,!RVCD,!RVED,!AVRD
dw !LVXD,!LVCD,!LVED,!WVDV,!RVDV,!RVCV,!RVUV,!WVUV
dw !AVDV,!LVDV,!LVCV,!LVUV,!AVUV,!SVEU,!SVCE,!SVXU
dw !SVXD,!SVCD,!SVED,!SVDV,!SVCV,!SVUV,!BU,!TU,!BD
dw !TD,!LF,!RF,!LB,!RB,!N,!T
ORG !BCode
dw EnterRight,StandardRight,ExitRight,EnterRight
dw ActiveRight,ExitRight,RightExitTile,RightExitTile
dw ExitLeft,StandardLeft,EnterLeft,ExitLeft
dw ActiveLeft,EnterLeft,LeftExitTile,LeftExitTile
dw LeftHBlue,StandardHBlue,RightHBlue,LeftHBlue
dw ActiveHBlue,RightHBlue,BlueRHExitTile,BlueRHExitTile
dw BlueLHExitTile,BlueLHExitTile,EnterRight,StandardRight
dw ExitRight,ExitLeft,StandardLeft,EnterLeft
dw LeftHBlue,StandardHBlue,RightHBlue,RightEnterUp
dw StandardUp,StandardUp,TopExitTile,LeftEnterUp
dw StandardUp,StandardUp,TopExitTile,BottomExitTile
dw StandardDown,StandardDown,StandardDown,BottomExitTile
dw StandardDown,StandardDown,StandardDown,BlueBVExitTile
dw RightBVBlue,StandardVBlue,StandardVBlue,BlueTVExitTile
dw BlueBVExitTile,LeftBVBlue,StandardVBlue,StandardVBlue
dw BlueTVExitTile,SmallEnterUp,StandardUp,StandardUp
dw StandardDown,StandardDown,StandardDown,SmallBVBlue
dw StandardVBlue,StandardVBlue,SHBlueUp,AHBlueUp
dw SHBlueDown,AHBlueDown,SVBlueRight,SVBlueRight
dw SVBlueLeft,SVBlueLeft,NoDirectionChange,CrazyBlueCorner
ORG !ATiles
dw !LVED,!RVED,!LVUV,!RVUV,!SVED,!SVUV
ORG !ACode
dw LeftDownEnterPress,RightDownEnterPress,LeftBluePressDown
dw RightBluePressDown,SmallDownEnterPress,SmallBluePressDown
ORG !STiles
dw !BHER,!BHEL,!SHER,!SHEL,!BHLH,!BHRH,!SHLH,!SHRH
ORG !SCode
dw RightEnterPress,LeftEnterPress,SmallLeftEnterPress,SmallRightEnterPress
dw RightEnterPress,LeftEnterPress,SmallLeftEnterPress,SmallRightEnterPress
ORG !CTiles
dw !AVUV,!WVUV
ORG !CCode
dw BlueTVExitTile,BlueTVExitTile
;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Status-related code
;;
;;;;;;;;;;;;;;;;;
PipeSound:
PHP
SEP #$20
LDA #$04 ;Pipe noise
STA $1DF9 ;SPC700 I/O
PLP
RTS
Cement:
PHP
REP #$20
LDA #$0130 ;Cement Block
STA $03 ;Block # from LM Map16 Editor
PLP
RTS
NoYoshiSound:
PHP
SEP #$20
LDA #$20 ;Yoshi spit out an object
STA $1DF9 ;SPC700 I/O
PLP
RTS
Entered:
PHP
REP #$20
LDA #$0042 ;Give him the peace sign as he enters the pipe
STA !Image
SEP #$20
LDA $19 ;Powerup
BEQ NoPowerup
STA !PowerupHold
STZ $19
NoPowerup:
PLP
RTS
SavePowerup:
PHP
SEP #$20
LDA $19
STA !PowerupHold
PLP
RTS
Exited:
PHP
REP #$20
LDA #$0000 ;Resets his "entrance" flag
STA !Image
STA !Status1
SEP #$20
LDA !PowerupHold
STA $19
PLP
RTS
BehindStuff:
PHP
SEP #$20
LDA #$02
STA $13F9 ;"Mario goes behind stuff" flag
STA $1419 ;"Sprites go behind stuff" flag
REP #$20
LDA #$0042
STA !Status
PLP
RTS
NotBehind:
PHP
SEP #$20
LDA #$00
STA $13F9
STA $1419
REP #$20
LDA #$0000
STA !Status
PLP
RTS
;;;;;;;;;;;;;;;;;;
;;
;; Directional codes
;;
;;;;;;;;;;;;;;;;;;;;;;;
GoUp:
LDA #$0001
STA !Vertical
RTS
GoDown:
LDA #$0000
STA !Vertical
RTS
GoRight:
LDA #$0001
STA !Horizontal
RTS
GoLeft:
LDA #$0000
STA !Horizontal
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Change (or no change) movement pipes
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SHBlueUp:
JSR GoUp
JMP StandardHBlue
AHBlueUp:
JSR GoUp
JMP ActiveHBlue
SHBlueDown:
JSR GoDown
JMP StandardHBlue
AHBlueDown:
JSR GoDown
JMP ActiveHBlue
SVBlueRight:
JSR GoRight
JMP StandardVBlue
SVBlueLeft:
JSR GoLeft
JMP StandardVBlue
NoDirectionChange:
LDA !Travel
BEQ VerticalChosen
JMP StandardHBlue
VerticalChosen:
JMP StandardVBlue
CrazyBlueCorner:
LDA !Travel
BEQ TakeTheVertical
JSR StandardVBlue
JMP SetHorizontal
TakeTheVertical:
JSR StandardHBlue
JMP SetVertical
;;;;;;;;;;;;;;;;;;;;;;;
;;
;; More status-related code
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ModY:
LDA $03
CMP #!BHCR ;All the pieces it checks for are bottom horizontal pipe pieces
BEQ LowerHorizontalPiece
CMP #!BHCL
BEQ LowerHorizontalPiece
CMP #!BHCH
BEQ LowerHorizontalPiece
RTS
LowerHorizontalPiece:
LDA !MarioYPos
AND #$000F
CMP #$0008
BEQ HalfwayUp
RTS
HalfwayUp:
LDA !MarioYPos
AND #$FFF7
STA !MarioYPos
RTS
AddY:
LDA $03
CMP #!SHEL
BEQ Special
CMP #!SHXL
BEQ Special
CMP #!TRB
BEQ Special
CMP #!TLB
BEQ Special
RTS
Special:
LDA !MarioYPos
AND #$000F
CMP #$000C
BEQ ThreeQuarters
RTS
ThreeQuarters:
LDA !MarioYPos
CLC
ADC #$0006
STA !MarioYPos
RTS
FaceLeft:
LDA #$0000
BEQ Direction
FaceRight:
LDA #$0001
Direction:
SEP #$20
STA $76 ;Mario's left or right status
REP #$20
RTS
LockControls:
LDA $15 ;Controller Data 1
AND #$4040 ;Only saves the Y/X button status
STA $15
STZ $17 ;Controller Data 2
RTS
SetStatus1:
LDA #$0042
STA !Status1
RTS
SetStatus2:
LDA #$0043 ;Makes Mario invisible
STA !Image
RTS
SetVertical:
LDA #$0000
STA !Travel
RTS
SetHorizontal:
LDA #$0001
STA !Travel
RTS
;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Full code of blocks
;;
;;;;;;;;;;;;;;;;;;;
StandardRight:
LDA !Status
CMP #$0042
BEQ ActiveRight
JSR Cement
RTS
ActiveRight:
JSR Entered
MoveRight:
LDA !MarioXPos
CLC
ADC #!Speed
STA !MarioXPos
STA $94
JSR ModY
LDA !MarioYPos
STA $96
JSR SetHorizontal
JSR GoRight
JSR LockControls
RTS
EnterRight:
JSR MoveRight
JSR BehindStuff
JSR SavePowerup
JSR PipeSound
RTS
ExitRight:
JSR AddY
JSR ActiveRight
JSR Exited
JSR FaceRight
JSR PipeSound
RTS
RightExitTile:
LDA !Status
CMP #$0042
BNE StopRight
JSR MoveRight
JSR NotBehind
StopRight:
RTS
StandardLeft:
LDA !Status
CMP #$0042
BEQ ActiveLeft
JSR Cement
RTS
ActiveLeft:
JSR Entered
MoveLeft:
LDA !MarioXPos
SEC
SBC #!Speed
STA !MarioXPos
STA $94
JSR ModY
LDA !MarioYPos
STA $96
JSR SetHorizontal
JSR GoLeft
JSR LockControls
RTS
EnterLeft:
JSR MoveLeft
JSR BehindStuff
JSR SavePowerup
JSR PipeSound
RTS
ExitLeft:
JSR AddY
JSR MoveLeft
JSR Exited
JSR FaceLeft
JSR PipeSound
RTS
LeftExitTile:
LDA !Status
CMP #$0042
BNE StopLeft
JSR NotBehind
StopLeft:
RTS
StandardHBlue:
LDA !Horizontal
BNE SGoingRight
JMP StandardLeft
SGoingRight:
JMP StandardRight
ActiveHBlue:
LDA !Horizontal
BNE AGoingRight
JMP ActiveLeft
AGoingRight:
JMP ActiveRight
LeftHBlue:
LDA !Horizontal
BNE ERight
JMP ExitLeft
ERight:
JMP EnterRight
RightHBlue:
LDA !Horizontal
BNE XRight
JMP EnterLeft
XRight:
JMP ExitRight
BlueLHExitTile:
LDA !Horizontal
BNE StopHMove
JMP LeftExitTile
BlueRHExitTile:
LDA !Horizontal
BEQ StopHMove
JMP RightExitTile
StopHMove:
RTS
LeftBVBlue:
LDA !Status
CMP #$0042
BEQ VerticalDecision
JMP LeftEnterUp
VerticalDecision:
JMP DecideVertical
RightBVBlue:
LDA !Status
CMP #$0042
BEQ VerticalDecision
JMP RightEnterUp
LeftBluePressDown:
LDA !Status
CMP #$0042
BEQ CowardsWayOut
JMP LeftDownEnterPress
CowardsWayOut:
RTS
RightBluePressDown:
LDA !Status
CMP #$0042
BEQ CowardsWayOut
JMP RightDownEnterPress
SmallBVBlue:
LDA !Status
CMP #$0042
BEQ VerticalDecision
JMP SmallEnterUp
SmallBluePressDown:
LDA !Status
CMP #$0042
BEQ CowardsWayOut
JMP SmallDownEnterPress
StandardVBlue:
LDA !Vertical
BNE GoingUp
JMP StandardDown
GoingUp:
JMP StandardUp
BlueTVExitTile:
LDA !Vertical
BNE DisableExit
JMP TVExitDisable
DisableExit:
JMP TopExitTile
DecideVertical:
LDA !Vertical
BNE ChooseUp
JMP StandardDown
ChooseUp:
JMP MoveUp
BlueBVExitTile:
LDA !Vertical
BNE NotLeaving
JMP BottomExitTile
NotLeaving:
JMP BVEnterConfirm
LongBranch:
BRL MoveUp
LeftEnterUp:
LDA !Status1
CMP #$0042
BEQ NoUp
LDA !Status
CMP #$0042
BEQ LongBranch
LDA $15
AND #$0008 ;Pressing Up
BEQ NoUp
LDA $187A ;Riding Yoshi flag
BNE NoUpYoshi
LDA $94
AND #$000F
CMP #$0008
BCS NoUp
EnterUp:
LDA $94
AND #$FFF0
ORA #$0008
STA !MarioXPos
RegularUp:
LDA $96
SEC
SBC #!Speed
STA $96
AND #$FFFC
STA !MarioYPos
JSR GoUp
JSR GoRight
JSR BehindStuff
JSR SavePowerup
JSR SetStatus2
JSR PipeSound
RTS
NoUpYoshi:
JSR NoYoshiSound
NoUp:
JSR Cement
RTS
RightEnterUp:
LDA !Status1
CMP #$0042
BEQ NoUp
LDA !Status
CMP #$0042
BEQ StandardUp
LDA $15
AND #$0008
BEQ NoUp
LDA $187A
BNE NoUpYoshi
LDA $94
AND #$000F
CMP #$0008
BCC NoUp
JMP EnterUp
StandardUp:
LDA !Status
CMP #$0042
BEQ ActiveUp
JSR Cement
RTS
ActiveUp:
JSR Entered
MoveUp:
LDA !MarioYPos
SEC
SBC #!Speed
STA !MarioYPos
STA $96
LDA !MarioXPos
STA $94
JSR SetVertical
JSR GoUp
JSR LockControls
RTS
BVEnterConfirm:
LDA !Status1
CMP #$0042
BEQ NoUp
LDA !Status
CMP #$0042
BEQ MoveUp
RTS
TopExitTile:
LDA !Status
CMP #$0042
BNE StopUp
JSR MoveUp
LDA !MarioYPos
AND #$FFF0
STA $96
JSR NotBehind
JSR Exited
JSR PipeSound
StopUp:
RTS
SmallEnterUp:
LDA $19
AND #$00FF
BNE SmallCement
LDA !Status1
CMP #$0042
BEQ SmallCement
LDA !Status
CMP #$0042
BEQ MoveUp
LDA $15
AND #$0008
BEQ SmallCement
LDA $187A
BNE SmallNoYoshi
LDA $94
AND #$000F
CMP #$0008
BCS SmallCement
LDA $94
AND #$FFF0
STA !MarioXPos
JMP RegularUp
SmallNoYoshi:
JSR NoYoshiSound
SmallCement:
JSR Cement
RTS
TVExitDisable:
LDA !Status
CMP #$0042
BEQ MoveDown
RTS
BottomExitTile:
LDA !Status
CMP #$0042
BNE lawlnvm
JSR MoveDown
JSR NotBehind
JSR Exited
JSR PipeSound
lawlnvm:
RTS
StandardDown:
LDA !Status
CMP #$0042
BEQ ActiveDown
JSR Cement
RTS
ActiveDown:
JSR Entered
MoveDown:
LDA !MarioYPos
CLC
ADC #!Speed
STA !MarioYPos
STA $96
LDA !MarioXPos
STA $94
JSR SetVertical
JSR GoDown
JSR LockControls
RTS
LeftDownEnterPress:
LDA !Status
CMP #$0042
BEQ MoveDown
LDA $15
AND #$0004
BEQ TalkToCement
LDA $187A
BNE DGAFYoshi
LDA $94
AND #$000F
CMP #$0008
BCS TalkToCement
AboveOffsetDown:
LDA $94
AND #$FFF0
ORA #$0008
STA !MarioXPos
DownwardSpiral:
LDA $96
CLC
ADC #!Speed
STA $96
AND #$FFFC
STA !MarioYPos
JSR GoDown
JSR GoLeft
JSR BehindStuff
JSR SavePowerup
JSR SetStatus1
JSR SetStatus2
JSR PipeSound
RTS
DGAFYoshi:
JSR NoYoshiSound
TalkToCement:
JSR Cement
RTS
RightDownEnterPress:
LDA !Status
CMP #$0042
BEQ MoveDown
LDA $15
AND #$0004
BEQ TalkToCement
LDA $187A
BNE DGAFYoshi
LDA $94
AND #$000F
CMP #$0008
BCC TalkToCement
JMP AboveOffsetDown
SmallDownEnterPress:
LDA $19
AND #$00FF
BNE TinyCementSmack
LDA !Status
CMP #$0042
BEQ MovinOnDown
LDA $15
AND #$0004
BEQ TinyCementSmack
LDA $187A
BNE TinyYoshiBlock
LDA $94
INC A
AND #$000F
CMP #$0008
BCS TinyCementSmack
LDA $94
INC A
AND #$FFF0
STA !MarioXPos
JMP DownwardSpiral
MovinOnDown:
JMP MoveDown
TinyYoshiBlock:
JSR NoYoshiSound
TinyCementSmack:
JSR Cement
RTS
RightEnterPress:
LDA $15
AND #$0001
BEQ ItsTheEnd
LDA $187A
BNE ByeByeYoshi
LDA $96
AND #$000F
BNE ItsTheEnd
LDA $96
STA !MarioYPos
LDA $94
AND #$FFFC
CLC
ADC #!Speed
STA !MarioXPos
CLC
ADC #!HSpeed
STA $94
JSR GoRight
JSR GoUp
ItsTheEnd:
RTS
ByeByeYoshi:
JSR NoYoshiSound
RTS
LeftEnterPress:
LDA $15
AND #$0002
BEQ ItsALongRoad
LDA $187A
BNE ByeByeYoshi
LDA $96
AND #$000F
BNE ItsALongRoad
LDA $96
STA !MarioYPos
LDA $94
AND #$FFFC
SEC
SBC #!Speed
STA !MarioXPos
SEC
SBC #!HSpeed
STA $94
JSR GoLeft
JSR GoUp
ItsALongRoad:
RTS
SmallLeftEnterPress:
LDA $19
AND #$00FF
BNE ItsALongRoad
JMP RightEnterPress
SmallRightEnterPress:
LDA $19
AND #$00FF
BNE ItsALongRoad
JMP LeftEnterPress
CodeEnd: