Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Insert this as gamemode 14 under "main:"
- incsrc "../SSPDef/Defines.asm"
- !Freeram_PipeCannonState = $13E6+!addr
- ;^[1 byte], the state mario would be when in pipe.
- !Freeram_PipeCannonTmr = $13E7+!addr
- ;^[1 byte], the timer when mario switches action.
- !freeram_door_dir = $1473+!addr ;>change this if used by other stuff
- main:
- .ScreenScrollingPipes:
- LDA !Freeram_PipeDir ;\don't do anything while outside the pipe.
- ORA !Freeram_PipeTmr ;|
- BNE ..PipeCodeStart ;|
- JMP ..PipeCodeReturn ;/
- ;-------------------------------------------------------
- ;Speed tables, Do not change the cap speeds.
- ;-------------------------------------------------------
- ; unused| Stem speed | Cap speed |
- ; - U R D L U R D L
- ;indexes: 0 1 2 3 4 5 6 7 8
- ..pipe_x_spd db $00,$00,$20,$00,$E0,$00,$08,$00,$F8 ;>x Speed.
- ..pipe_y_spd db $00,$E0,$00,$20,$00,$F0,$00,$10,$00 ;>y speed.
- ;Don't touch these unless you remap the poses: [beta stuff]
- ;WalkingFrames:
- ;db $00,$00,$00,$00,$01,$01,$01,$01,$02,$02,$02,$02
- ;---------------------------------
- ;This sets mario's status
- ;---------------------------------
- ..PipeCodeStart
- ...MarioStatus
- LDA !Freeram_CarrySpr ;\fix automatic drop item when carrying
- BEQ ....NotCarrying ;|
- LDA #$40 ;|
- BRA ....SetControls ;|
- ....NotCarrying
- LDA #$00 ;/
- ....SetControls
- STA $15 ;\lock controls
- STZ $16 ;|
- STZ $17 ;|
- STZ $18 ;/
- STZ $13F3+!addr ;\remove p-balloon
- STZ $1891+!addr ;/
- STZ $1697+!addr ;>remove consecutive stomps.
- STZ $140D+!addr ;>so fire mario cannot shoot fireballs in pipe
- LDA !Freeram_EntrExtFlg ;\hide player if timer hits zero when entering.
- CMP #$02 ;|
- BEQ ....NoHide ;|
- LDA !Freeram_PipeTmr ;|
- BNE ....NoHide ;|
- if !PipeDebug == 0
- LDA #$FF ;|
- STA $78 ;/
- endif
- ....NoHide
- LDA $187A+!addr ;\if on yoshi, then use yoshi poses
- BNE ....OnYoshi ;/
- STZ $73 ;>so mario cannot remain ducking (unless on yoshi) as he exits.
- ....OnYoshi
- LDA !Freeram_PipeDir ;\different yoshi pose, If going vertical, then yoshi faces the screen.
- CMP #$01 ;|(this should make mario carry carryable sprites in center of him facing the screen)
- BEQ ....YoshiFaceScreen ;|
- CMP #$03 ;|
- BEQ ....YoshiFaceScreen ;|
- CMP #$05 ;|
- BEQ ....YoshiFaceScreen ;|
- CMP #$07 ;|
- BEQ ....YoshiFaceScreen ;/
- ....YoshiDuck ;>horizontal pipe
- LDA $187A+!addr ;\Do not duck if not riding yoshi.
- BEQ ....NoDuck ;/
- LDA #$04 ;\crouch on yoshi
- STA $73 ;/
- ....NoDuck
- LDA #$01 ;|(this should make mario face left or right carrying sprites to the side)
- BRA ....SkipYoshiFaceScrn ;/
- ....YoshiFaceScreen ;\yoshi face the screen (vertical pipe, Nintendo did this so that yoshi's head
- LDA #$02 ;/doesn't display a glitch graphic).
- ....SkipYoshiFaceScrn
- STA $1419+!addr ;>Even if you are not mounted on yoshi, you still have to write a value here, or carrying sprites don't work.
- ....SkipYoshiPose
- if !PipeDebug == 0
- LDA #$01 ;\go behind layers
- STA $13F9+!addr ;/
- endif
- LDA #$0B ;\freeze time
- STA $71 ;|
- STA $9D ;/
- LDA #$01 ;\allow vertical scroll up.
- STA $1404+!addr ;/
- STZ $14A6+!addr ;>no spinning.
- STZ $1407+!addr ;>so mario cannot fly out of the cap
- STZ $72 ;>zero air flag.
- STZ $14A3+!addr ;>no yoshi tongue
- LDA !Freeram_CarrySpr ;\if mario not carrying anything, then skip
- BEQ ....NotCarry ;/
- LDA #$01 ;\force keep carrying
- STA $1470+!addr ;|
- STA $148F+!addr ;/
- ....NotCarry
- LDA !Freeram_PipeDir ;\set player speed within pipe (use transfer commands
- TAY ;|so you can use long freeram address)
- LDA ..pipe_x_spd,y ;|
- STA $7B ;|
- LDA ..pipe_y_spd,y ;|
- STA $7D ;/
- ;-------------------------------
- ;Entering and exiting
- ;-------------------------------
- ...EnterExitTransition
- LDA !Freeram_EntrExtFlg ;>If mario is out of a pipe and is entering them...
- BNE ....InPipe ;>if not 0, skip
- JMP ..PipeCodeReturn ;>branch out of range
- ....InPipe
- CMP #$01 ;\If entering a pipe...
- BEQ ....entering_pipe ;/
- CMP #$02 ;\If exiting a pipe...
- BEQ ....ExitingPipe ;/
- JMP ..PipeCodeReturn
- ....entering_pipe ;
- LDA !Freeram_PipeTmr ;\If timer is 0, set pose
- BEQ ...pose ;/
- DEC A ;\Otherwise decrement it
- STA !Freeram_PipeTmr ;/
- BEQ ....accel ;>If decremented from 1 to 0, accelerate for stem speed
- BRA ...pose ;>Otherwise still set pose.
- ....accel
- LDA !Freeram_PipeDir ;\Use another set of 4 speeds.
- SEC ;|
- SBC #$04 ;/
- BMI ....AccelDone ;>Prevent continously decrementing into negative
- STA !Freeram_PipeDir ;>And set pipe direction
- ....AccelDone
- BRA ...pose
- ....ExitingPipe ;
- LDA !Freeram_PipeTmr ;\if timer already = 0, then skip the reset (so it does it once).
- BEQ ...pose ;/
- DEC A ;\otherwise decrement timer.
- STA !Freeram_PipeTmr ;/
- BEQ ...ResetStatus ;>Reset status if timer hits zero (happens once after -1 to 0).
- ;decel
- LDA !Freeram_PipeDir ;\Use the first 4 speeds (excluding index 0)
- CLC ;|
- ADC #$04 ;/
- CMP #$09 ;\Prevent incrementing beyond the 8th index
- BCS ...pose ;/
- STA !Freeram_PipeDir ;>Set direction
- BRA ...pose ;>and skip the reset routine
- ;---------------------------------
- ;This resets mario's status.
- ;It must be exceuted once.
- ;---------------------------------
- ...ResetStatus
- LDA !Freeram_CarrySpr ;\Holding sprites routine
- BEQ ....NotCarry1 ;|
- LDA #$40 ;|
- BRA ....SkipNtCarry1 ;|
- ....NotCarry1 ;|
- LDA #$00 ;|
- ....SkipNtCarry1 ;|
- STA $15 ;/
- STZ $9D ;>back in motion
- STZ $13F9+!addr ;>go in front
- STZ $71 ;>mario can move
- STZ $73 ;>stop crouching (when going exiting down on yoshi)
- STZ $140D+!addr ;>no spinjump out the pipe (possable if both enter and exit caps are bottoms)
- STZ $7B ;\cancel speed
- STZ $7D ;/
- STZ $1419+!addr ;>revert yoshi
- STZ $149F+!addr ;>zero cape "rise up timer"
- LDA #$00 ;\reset freeram flags
- STA !Freeram_PipeDir ;|
- STA !Freeram_PipeTmr ;|
- STA !Freeram_CarrySpr ;|
- STA !Freeram_EntrExtFlg ;/>Make code assume mario is out of the pipe.
- JMP ..PipeCodeReturn
- ;-----------------------------------------
- ;code that controls mario's pose
- ;-----------------------------------------
- ...pose
- LDA !Freeram_PipeDir ;\set pose according to direction.
- CMP #$01 ;|\Vertical direction
- BEQ ....Vert ;||
- CMP #$03 ;||
- BEQ ....Vert ;||
- CMP #$05 ;||
- BEQ ....Vert ;||
- CMP #$07 ;||
- BEQ ....Vert ;|/
- CMP #$02 ;|\Horizontal direction
- BEQ ....Horiz ;||
- CMP #$04 ;||
- BEQ ....Horiz ;||
- CMP #$06 ;||
- BEQ ....Horiz ;||
- CMP #$08 ;||
- BEQ ....Horiz ;//
- ....Vert
- LDA $187A+!addr ;\if mario is riding yoshi, then
- BNE ....YoshiFaceScrn ;/use face screen instead
- LDA #$0F ;>vertical pipe pose (without regard to powerup status)
- BRA ....SetPose
- ....Horiz
- LDA $187A+!addr ;\if mario is riding yoshi, then
- BNE ....YoshiFaceHoriz ;/use "ride yoshi" pose
- LDA #$00
- BRA ....SetPose
- ....YoshiFaceScrn
- LDA #$21 ;>pose that mario turns around partically face the screen
- BRA ....SetPose
- ....YoshiFaceHoriz
- LDA #$1D ;>crouch as entering a horizontal pipe on yoshi.
- ....SetPose
- STA $13E0+!addr ;>set player pose
- ..PipeCodeReturn
- JSR .PipeCannon
- RTL
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;Paste this in level code in levels you are going to use this.
- ;If you wanted multiple levels to use this, simply use JSR PipeCannon
- ;to recycle the code (but make sure there are no codes below this code
- ;that you wanted it to execute in specific levels, if true then instead
- ;of pasting in the levels, paste it past the last RTS at the very bottom
- ;and have any levels that use this code all use JSR PipeCannon).
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .PipeCannon:
- LDA $71 ;\If dying, don't continue cannon mode.
- CMP #$09 ;|(fixes time limit bug)
- BNE ..NotDying ;|
- JML ..Return ;/
- ..NotDying
- LDA !Freeram_PipeCannonTmr ;\Decrement timer
- DEC A ;/
- BMI ..NoDecrement ;>If negative, don't decrement
- STA !Freeram_PipeCannonTmr ;>Store to decrement (#$00 is the smallest value)
- ..NoDecrement
- LDA !Freeram_PipeCannonState ;>Load state into A
- BEQ ..NoState ;>Allow mario to have control if #$00
- PHA ;>This is faster
- LDA #$0B ;\Throughout the launch, mario cannot
- STA $71 ;/move.
- PLA ;>Restore it
- ..NoState
- ASL ;>Left shift bits (*2, because each address has 2 bytes).
- TAX ;>Index it with X
- JMP.w (..States,x)
- ..States
- dw ..Return ;>#$00
- dw ...Entering ;>#$01
- dw ...Waiting ;>#$02
- dw ...PriorShoot ;>#$03
- dw ...Shoot ;>#$04
- dw ..SelfReset ;>#$05
- ;;;;;;;;;;;;;;;;;;;;;;;;
- ...Entering
- LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
- BEQ ....NextState ;/
- LDA #$01 ;>Set...
- STA $9D ;>...Freeze time
- STA $13F9+!addr ;>...Behind layers
- LDA #$0F ;\Set pose
- STA $13E0+!addr ;/
- LDA #$10 ;\Set speed
- STA $7D ;/
- STZ $7B ;>Blocks don't perfectly halt x speed.
- JMP ..Return
- ....NextState
- LDA #$02 ;\Switch state to waiting
- STA !Freeram_PipeCannonState ;/
- LDA.b #60 ;\Set timer of the waiting
- STA !Freeram_PipeCannonTmr ;/
- LDA #$01 ;>Set...
- STA $13F9+!addr ;>...Behind layers (without this, mario goes in front for 1 frame
- BRA ..Return
- ...Waiting
- LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
- BEQ ....NextState ;/
- LDA #$01 ;>Set...
- STA $9D ;>...Freeze time
- STA $13F9+!addr ;>...Behind layers
- STZ $7D ;>Stop Y speed
- BRA ..Return
- ....NextState
- LDA #$03 ;\Set state to prior shoot
- STA !Freeram_PipeCannonState ;/
- LDA #$09 ;\SFX
- STA $1DFC+!addr ;/
- LDA.b #04 ;\Set timer for the go in front of layers (for prior shoot)
- STA !Freeram_PipeCannonTmr ;/(he must go in front as soon mario gets completly out of pipe)
- STZ $9D ;>Unfreeze game
- LDA #$01 ;>Set...
- STA $13F9+!addr ;>...Behind layers (without this, mario goes in front for 1 frame).
- BRA ..Return
- ...PriorShoot
- LDA !Freeram_PipeCannonTmr ;\If timer runs out, goto next state
- BEQ ....NextState ;/
- LDA #$01 ;\Behind layer as you exit.
- STA $13F9+!addr ;/
- STZ $73 ;>Prevent crouching if mairo crouch slide into cannon.
- LDA #$01 ;\Behind layers (without this, mario goes in front for 1 frame).
- STA $13F9+!addr ;/
- BRA ..SharedCode
- ....NextState
- LDA #$04 ;\Set state to post shoot
- STA !Freeram_PipeCannonState ;/
- LDA #$00 ;\Clear timer since this last state no longer uses the timer.
- STA !Freeram_PipeCannonTmr ;/
- LDA #$01 ;\Behind layers (without this, mario goes in front for 1 frame).
- STA $13F9+!addr ;/
- BRA ..Return
- ...Shoot
- STZ $13F9+!addr ;>Go in front of layers
- ..SharedCode
- LDA #$80 ;\Shoot player upwards
- STA $7D ;/
- LDA #$0B ;\Up jump pose
- STA $13E0+!addr ;|
- STA $72 ;/
- LDA #$01 ;\Screen scrolls up.
- STA $1404+!addr ;/
- LDA $77 ;\If mario hits a ceiling...
- AND.b #%00001000 ;|
- BEQ ...NotBlocked ;/
- LDA #$00 ;\Then cancel out cannon mode
- STA !Freeram_PipeCannonState ;/
- STA $71 ;>Allow movement.
- ...NotBlocked
- BRA ..Return
- ..SelfReset
- STZ !Freeram_PipeCannonState ;\This needed to be cleared for 1 frame or there will be
- STZ $71 ;/glitches.
- ..Return
- JSR .SSDoorRoutine
- RTS
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;do not insert this as blocks. This is a non-block ASM code for the
- ;screen scrolling doors. put this in gamemode_code.asm in "gamemode_14:"
- ;or level_code.asm (if multiple levels, use "JSR levelxxx" to a level that
- ;have this code to recycle code and save space).
- ;
- ;if you wanted to edit the speed, go to the table on the bottom of
- ;this code, and change the value.
- ;
- ;TIP: To have "equal" positive (#$01-#$7F) and negative (#$80-#$FF) speed,
- ;use this forumla (all in hex):
- ;
- ;N=100-P
- ;
- ;N = negative (left and up speed)
- ;P = positive (right and down speed)
- ;
- ;tip2:
- ;you can instantly copy this code by pressing "ctrl+A" to select all then
- ;"ctrl+C" to copy
- ;
- ;freeram address------------------------------------------------------------
- ;
- ; ;besides the screen scrolling doors.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;code begins;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .SSDoorRoutine:
- LDA !freeram_door_dir ;\if door_mode mode is 00 (not launching)
- BEQ ..returndoor ;/then return_door_mode
- TAY ;\set x and Y speed according to direction
- LDA ..x_speed_table,y ;|
- STA $7B ;|
- LDA ..y_speed_table,y ;|
- STA $7D ;/
- LDA !freeram_door_dir ;\if going left or right
- CMP #$02 ;|set facing direction
- BEQ ..face_right ;|
- CMP #$04 ;|
- BEQ ..face_left ;/
- BRA ..skip_face_dir ;>or don't set it at all if vertical
- ..face_right ;\set facing direction
- LDA #$01 ;|
- STA $76 ;|
- BRA ..skip_face_dir ;|
- ..face_left ;|
- STZ $76 ;/
- ..skip_face_dir
- STZ $15 ;\
- STZ $16 ;|lock controls while door mode
- STZ $17 ;|
- STZ $18 ;/
- STZ $149A+!addr ;>remove kick pose if player enters door immediately after kicking.
- LDA #$FF ;\hide player
- STA $78 ;/
- LDA #$0B ;\freeze player (so $9D works)
- STA $71 ;/
- STA $9D ;>lock animations
- STA $1404+!addr ;>allow screen to scroll up.
- LDA #$01 ;>load nonzero
- STA $1497+!addr ;>set Flashing invulnerability timer
- STA $13F9+!addr ;>go behind layer
- STA $73 ;>maintain ducking flag
- ..returndoor
- RTS ;>if you have a following code from here
- ;then move the table that was below here
- ;to the very bottom and have the other codes
- ;between here and the table below.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;x and y speed table. Make sure that the table is right after (or below) the
- ;codes that points to it (so this table is after "LDA x_speed_table,y being
- ;used), or the game will crash.
- ;
- ;Each seprate number is a value for mario x and y speed, the order in the table
- ;corrosponds the value order present within the selected ram. For example: the
- ;first number in the table means that the ram is #$00, the 2nd number is when
- ;the ram address = #$01 and so on.
- ;(order from left to right)
- ;1st number = not used
- ;2nd number = up
- ;3rd number = right
- ;4th number = down
- ;5th number = left
- ;
- ;If you change this, you should also change how many pixels down
- ;from the center of the door that mario will exit upwards from
- ;door_down.asm in the blocks' definition.
- ;
- ..x_speed_table
- db $00,$00,$2F,$00,$D1
- RTS
- ..y_speed_table
- db $00,$D1,$00,$2F,$00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement