Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HEADER
- LOROM
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;Defines
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- !RAM_MIDWAY = $7FB800 ; holds which midway point to use (96 bytes, one for each level)
- ORG $05D8BC
- autoclean JML MAIN ;Point to new routine
- BRA $01 : NOP
- ORG $05D9DE
- autoclean JML SECONDARIES2 ; additional code for secondary exits
- ORG $048F74
- autoclean JML RESET_MIDWAY ; hijack the code that resets the midway point
- ORG $00A19A
- autoclean JML MIDWAY_INIT ; hijack the OW initialization to reset the table
- ORG $05DAA3
- autoclean JML NO_YOSHI ; make secondary exits compatible with no yoshi intros
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;New main code
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- freecode
- !MIDWAY_NUMBER = $0002 ; max number of midway points per level
- ; using more vastly increases the size of the table
- ; if you changed it to, for example, 0003
- ; the tables for EVERY level would look similar to this:
- ; dw $0001 : dw $0001 : dw $0001
- ; the maximum of midway points would be 00FF (256 decimal)
- LEVEL_TABLES:
- ;levels 0-F
- dw $0000 : dw $0000 ;
- dw $0001 : dw $0001 ; place the level number which you want to use here
- dw $0002 : dw $0002 ;
- dw $0003 : dw $0003 ; IE: $0140 will use level 140's midway entrance
- dw $0004 : dw $0004 ; $00FF will use level 0FF's midway entrance
- dw $0005 : dw $0005 ; $0100 will use level 100's
- dw $0006 : dw $0006 ; ect
- dw $0007 : dw $0007
- dw $0008 : dw $0008
- dw $0009 : dw $0009 ; setting the highest nybble (making it 1000+ )
- dw $000A : dw $000A ; will use a secondary entrance instead
- dw $000B : dw $000B ; IE: $1003 will use secondary entrance 003
- dw $000C : dw $000C ; $1138 will use secondary entrance 138
- dw $000D : dw $000D ; $1000 will use secondary entrance 000
- dw $000E : dw $000E ; ect
- dw $000F : dw $000F
- ;levels 10-1F
- dw $0010 : dw $0010
- dw $0011 : dw $0011
- dw $0012 : dw $0012
- dw $0013 : dw $0013
- dw $0014 : dw $0014
- dw $0015 : dw $0015
- dw $0016 : dw $0016
- dw $0017 : dw $0017
- dw $0018 : dw $0018
- dw $0019 : dw $0019
- dw $001A : dw $001A
- dw $001B : dw $001B
- dw $001C : dw $001C
- dw $001D : dw $001D
- dw $001E : dw $001E
- dw $001F : dw $001F
- ;levels 20-24
- dw $0020 : dw $0020
- dw $0021 : dw $0021
- dw $0022 : dw $0022
- dw $0023 : dw $0023
- dw $0024 : dw $0024
- ;levels 101-10F
- dw $0101 : dw $0101
- dw $0102 : dw $0102
- dw $0103 : dw $0103
- dw $0104 : dw $0104
- dw $11CA : dw $0105
- dw $0106 : dw $0106
- dw $0107 : dw $0107
- dw $0108 : dw $0108
- dw $0109 : dw $0109
- dw $010A : dw $010A
- dw $010B : dw $010B
- dw $010C : dw $010C
- dw $010D : dw $010D
- dw $010E : dw $010E
- dw $010F : dw $010F
- ;levels 110-11F
- dw $0110 : dw $0110
- dw $0111 : dw $0111
- dw $0112 : dw $0112
- dw $0113 : dw $0113
- dw $0114 : dw $0114
- dw $0115 : dw $0115
- dw $0116 : dw $0116
- dw $0117 : dw $0117
- dw $0118 : dw $0118
- dw $0119 : dw $0119
- dw $011A : dw $011A
- dw $011B : dw $011B
- dw $011C : dw $011C
- dw $011D : dw $011D
- dw $011E : dw $011E
- dw $011F : dw $011F
- ;levels 120-12F
- dw $0120 : dw $0120
- dw $0121 : dw $0121
- dw $0122 : dw $0122
- dw $0123 : dw $0123
- dw $0124 : dw $0124
- dw $0125 : dw $0125
- dw $0126 : dw $0126
- dw $0127 : dw $0127
- dw $0128 : dw $0128
- dw $0129 : dw $0129
- dw $012A : dw $012A
- dw $012B : dw $012B
- dw $012C : dw $012C
- dw $012D : dw $012D
- dw $012E : dw $012E
- dw $012F : dw $012F
- ;levels 130-13B
- dw $0130 : dw $0130
- dw $0131 : dw $0131
- dw $0132 : dw $0132
- dw $0133 : dw $0133
- dw $0134 : dw $0134
- dw $0135 : dw $0135
- dw $0136 : dw $0136
- dw $0137 : dw $0137
- dw $0138 : dw $0138
- dw $0139 : dw $0139
- dw $013A : dw $013A
- dw $013B : dw $013B
- MAIN:
- REP #$30 ; 16-bit A X Y
- LDA $0E ; (this is stolen from levelasm)
- STA $010B ;
- PHY ; push y
- SEP #$30 ; 8 bit A X Y
- LDA $141A ; skip if not the opening level
- BNE RETURN
- LDA $1B93 ; prevent infinite loop if using a secondary exit
- BNE RETURN
- LDY $13BF ; get translevel number
- LDA $1EA2,y ; get level settings
- AND #$40 ; check midway point flag
- BEQ RETURN ; return if not set
- PHB ;
- PHK ; wrapper
- PLB ;
- TYA ; stick translevel number in A
- REP #$30 ; 16 bit A X Y
- AND #$00FF ; clear high byte of A
- ASL ; x 2
- STA $0E ; store to scratch
- PHX ; push x
- TYX ; stick y in x temporarily
- LDA !RAM_MIDWAY,x ;\ get midway point number to use
- AND #$00FF ; |
- ASL ;/
- PLX ; pull x
- LDY #$0000 ;
- CLC
- LOOP:
- ADC $0E ; multiply it by the number of midway points in use per level
- INY
- CPY #!MIDWAY_NUMBER
- BCC LOOP
- TAY ; stick in y
- LDA LEVEL_TABLES,y ; get new level number
- CMP #$1000 ; check secondary exit flag
- BCS SECONDARIES ; use secondary exit
- AND #$01FF ; failsafe
- STA $0E ; store level number
- STA $010B
- SEP #$30 ; 8 bit A X Y
- PLB ; get bank back
- RETURN:
- REP #$30 ; 16 bit A X Y
- PLY ; pull y
- LDA $0E
- JML $05D8C3 ; return
- SECONDARIES:
- AND #$0FFF ; clear secondary exit flag here
- ORA #$0600 ; these bits have to be set
- SEP #$30 ; 8 bit A X Y
- STA $19B8 ; store secondary exit number (low)
- XBA ; flip high and low byte of A
- STA $19D8 ; store secondary exit number (high and properties)
- STZ $95 ; set these to 0
- STZ $97
- PLB ; get bank back
- REP #$30 ; 16 bit A X Y
- PLY ; pull y back
- SEP #$30 ; 8 bit A X Y
- JML $05D7B3 ; return and load level at a secondary exit position
- SECONDARIES2:
- LDX $1B93 ; check if using a secondary exit for this
- BNE RETURN2 ; if so, skip the code that sets mario's x position to the midway entrance
- STA $13CF ; restore old code
- LDA $02 ; restore old code
- JML $05D9E3 ; return
- RETURN2:
- JML $05D9EC ; return without setting mario's x to the midway entrance
- RESET_MIDWAY:
- STA $1EA2,x ; restore old code
- INC $13D9 ;
- LDA !RAM_MIDWAY,x
- AND #$FF00 ; reset midway point number too
- STA !RAM_MIDWAY,x
- JML $048F7A ; return
- MIDWAY_INIT:
- LDA $1F49,x ; restore old code
- STA $1EA2,x ;
- LDA #$00 ; reset this table
- STA !RAM_MIDWAY,x
- JML $00A1A0 ; return
- NO_YOSHI:
- STZ $1B93 ; reset this (prevents glitch with no yoshi intros and secondary entrances)
- LDA $05D78A,x ; restore old code
- JML $05DAA7 ; return
- print freespaceuse
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement