Advertisement
Telinc1

Multi-Midway Points for UberASM

Apr 27th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1.  
  2. HEADER
  3. LOROM
  4.  
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6. ;Defines
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9. !RAM_MIDWAY = $7FB800 ; holds which midway point to use (96 bytes, one for each level)
  10.  
  11. ORG $05D8BC
  12. autoclean JML MAIN ;Point to new routine
  13. BRA $01 : NOP
  14.  
  15. ORG $05D9DE
  16. autoclean JML SECONDARIES2 ; additional code for secondary exits
  17.  
  18. ORG $048F74
  19. autoclean JML RESET_MIDWAY ; hijack the code that resets the midway point
  20.  
  21. ORG $00A19A
  22. autoclean JML MIDWAY_INIT ; hijack the OW initialization to reset the table
  23.  
  24. ORG $05DAA3
  25. autoclean JML NO_YOSHI ; make secondary exits compatible with no yoshi intros
  26.  
  27.  
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. ;New main code
  30. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  31.  
  32. freecode
  33.  
  34. !MIDWAY_NUMBER = $0002 ; max number of midway points per level
  35. ; using more vastly increases the size of the table
  36. ; if you changed it to, for example, 0003
  37. ; the tables for EVERY level would look similar to this:
  38. ; dw $0001 : dw $0001 : dw $0001
  39. ; the maximum of midway points would be 00FF (256 decimal)
  40.  
  41.  
  42. LEVEL_TABLES:
  43. ;levels 0-F
  44. dw $0000 : dw $0000 ;
  45. dw $0001 : dw $0001 ; place the level number which you want to use here
  46. dw $0002 : dw $0002 ;
  47. dw $0003 : dw $0003 ; IE: $0140 will use level 140's midway entrance
  48. dw $0004 : dw $0004 ; $00FF will use level 0FF's midway entrance
  49. dw $0005 : dw $0005 ; $0100 will use level 100's
  50. dw $0006 : dw $0006 ; ect
  51. dw $0007 : dw $0007
  52. dw $0008 : dw $0008
  53. dw $0009 : dw $0009 ; setting the highest nybble (making it 1000+ )
  54. dw $000A : dw $000A ; will use a secondary entrance instead
  55. dw $000B : dw $000B ; IE: $1003 will use secondary entrance 003
  56. dw $000C : dw $000C ; $1138 will use secondary entrance 138
  57. dw $000D : dw $000D ; $1000 will use secondary entrance 000
  58. dw $000E : dw $000E ; ect
  59. dw $000F : dw $000F
  60. ;levels 10-1F
  61. dw $0010 : dw $0010
  62. dw $0011 : dw $0011
  63. dw $0012 : dw $0012
  64. dw $0013 : dw $0013
  65. dw $0014 : dw $0014
  66. dw $0015 : dw $0015
  67. dw $0016 : dw $0016
  68. dw $0017 : dw $0017
  69. dw $0018 : dw $0018
  70. dw $0019 : dw $0019
  71. dw $001A : dw $001A
  72. dw $001B : dw $001B
  73. dw $001C : dw $001C
  74. dw $001D : dw $001D
  75. dw $001E : dw $001E
  76. dw $001F : dw $001F
  77. ;levels 20-24
  78. dw $0020 : dw $0020
  79. dw $0021 : dw $0021
  80. dw $0022 : dw $0022
  81. dw $0023 : dw $0023
  82. dw $0024 : dw $0024
  83. ;levels 101-10F
  84. dw $0101 : dw $0101
  85. dw $0102 : dw $0102
  86. dw $0103 : dw $0103
  87. dw $0104 : dw $0104
  88. dw $11CA : dw $0105
  89. dw $0106 : dw $0106
  90. dw $0107 : dw $0107
  91. dw $0108 : dw $0108
  92. dw $0109 : dw $0109
  93. dw $010A : dw $010A
  94. dw $010B : dw $010B
  95. dw $010C : dw $010C
  96. dw $010D : dw $010D
  97. dw $010E : dw $010E
  98. dw $010F : dw $010F
  99. ;levels 110-11F
  100. dw $0110 : dw $0110
  101. dw $0111 : dw $0111
  102. dw $0112 : dw $0112
  103. dw $0113 : dw $0113
  104. dw $0114 : dw $0114
  105. dw $0115 : dw $0115
  106. dw $0116 : dw $0116
  107. dw $0117 : dw $0117
  108. dw $0118 : dw $0118
  109. dw $0119 : dw $0119
  110. dw $011A : dw $011A
  111. dw $011B : dw $011B
  112. dw $011C : dw $011C
  113. dw $011D : dw $011D
  114. dw $011E : dw $011E
  115. dw $011F : dw $011F
  116. ;levels 120-12F
  117. dw $0120 : dw $0120
  118. dw $0121 : dw $0121
  119. dw $0122 : dw $0122
  120. dw $0123 : dw $0123
  121. dw $0124 : dw $0124
  122. dw $0125 : dw $0125
  123. dw $0126 : dw $0126
  124. dw $0127 : dw $0127
  125. dw $0128 : dw $0128
  126. dw $0129 : dw $0129
  127. dw $012A : dw $012A
  128. dw $012B : dw $012B
  129. dw $012C : dw $012C
  130. dw $012D : dw $012D
  131. dw $012E : dw $012E
  132. dw $012F : dw $012F
  133. ;levels 130-13B
  134. dw $0130 : dw $0130
  135. dw $0131 : dw $0131
  136. dw $0132 : dw $0132
  137. dw $0133 : dw $0133
  138. dw $0134 : dw $0134
  139. dw $0135 : dw $0135
  140. dw $0136 : dw $0136
  141. dw $0137 : dw $0137
  142. dw $0138 : dw $0138
  143. dw $0139 : dw $0139
  144. dw $013A : dw $013A
  145. dw $013B : dw $013B
  146.  
  147.  
  148.  
  149. MAIN:
  150. REP #$30 ; 16-bit A X Y
  151. LDA $0E ; (this is stolen from levelasm)
  152. STA $010B ;
  153. PHY ; push y
  154. SEP #$30 ; 8 bit A X Y
  155. LDA $141A ; skip if not the opening level
  156. BNE RETURN
  157. LDA $1B93 ; prevent infinite loop if using a secondary exit
  158. BNE RETURN
  159. LDY $13BF ; get translevel number
  160. LDA $1EA2,y ; get level settings
  161. AND #$40 ; check midway point flag
  162. BEQ RETURN ; return if not set
  163. PHB ;
  164. PHK ; wrapper
  165. PLB ;
  166. TYA ; stick translevel number in A
  167. REP #$30 ; 16 bit A X Y
  168. AND #$00FF ; clear high byte of A
  169. ASL ; x 2
  170. STA $0E ; store to scratch
  171. PHX ; push x
  172. TYX ; stick y in x temporarily
  173. LDA !RAM_MIDWAY,x ;\ get midway point number to use
  174. AND #$00FF ; |
  175. ASL ;/
  176. PLX ; pull x
  177. LDY #$0000 ;
  178. CLC
  179. LOOP:
  180. ADC $0E ; multiply it by the number of midway points in use per level
  181. INY
  182. CPY #!MIDWAY_NUMBER
  183. BCC LOOP
  184. TAY ; stick in y
  185. LDA LEVEL_TABLES,y ; get new level number
  186. CMP #$1000 ; check secondary exit flag
  187. BCS SECONDARIES ; use secondary exit
  188. AND #$01FF ; failsafe
  189. STA $0E ; store level number
  190. STA $010B
  191. SEP #$30 ; 8 bit A X Y
  192. PLB ; get bank back
  193. RETURN:
  194. REP #$30 ; 16 bit A X Y
  195. PLY ; pull y
  196. LDA $0E
  197. JML $05D8C3 ; return
  198.  
  199. SECONDARIES:
  200. AND #$0FFF ; clear secondary exit flag here
  201. ORA #$0600 ; these bits have to be set
  202. SEP #$30 ; 8 bit A X Y
  203. STA $19B8 ; store secondary exit number (low)
  204. XBA ; flip high and low byte of A
  205. STA $19D8 ; store secondary exit number (high and properties)
  206. STZ $95 ; set these to 0
  207. STZ $97
  208. PLB ; get bank back
  209. REP #$30 ; 16 bit A X Y
  210. PLY ; pull y back
  211. SEP #$30 ; 8 bit A X Y
  212. JML $05D7B3 ; return and load level at a secondary exit position
  213.  
  214. SECONDARIES2:
  215. LDX $1B93 ; check if using a secondary exit for this
  216. BNE RETURN2 ; if so, skip the code that sets mario's x position to the midway entrance
  217. STA $13CF ; restore old code
  218. LDA $02 ; restore old code
  219. JML $05D9E3 ; return
  220.  
  221. RETURN2:
  222. JML $05D9EC ; return without setting mario's x to the midway entrance
  223.  
  224. RESET_MIDWAY:
  225. STA $1EA2,x ; restore old code
  226. INC $13D9 ;
  227. LDA !RAM_MIDWAY,x
  228. AND #$FF00 ; reset midway point number too
  229. STA !RAM_MIDWAY,x
  230. JML $048F7A ; return
  231.  
  232. MIDWAY_INIT:
  233. LDA $1F49,x ; restore old code
  234. STA $1EA2,x ;
  235. LDA #$00 ; reset this table
  236. STA !RAM_MIDWAY,x
  237. JML $00A1A0 ; return
  238.  
  239. NO_YOSHI:
  240. STZ $1B93 ; reset this (prevents glitch with no yoshi intros and secondary entrances)
  241. LDA $05D78A,x ; restore old code
  242. JML $05DAA7 ; return
  243.  
  244. print freespaceuse
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement