periwinkle_

Cave Story+ (Switch) credits warps explanation

Dec 13th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.58 KB | None | 0 0
  1. =====>>>>> Cave Story+ (Switch) credits warps, explained <<<<=====
  2.  
  3. Both the Normal Ending and Best Ending credits warps start with what I'll call
  4. "Core Escape": By pausing the game while cutscene-skipping the pre-Core fight cutscene,
  5. the cutscene continues to run, but certain things like animations are frozen, including
  6. that of the main shutter. After the fight, you are able to escape the room without
  7. having to drown first.
  8.  
  9. Note that this cutscene-pause bug does not exist in the JP version of the game, and so
  10. these credits warp setups will not work in that version.
  11.  
  12. After escaping the Core room, drowning in other rooms does crazy things instead of killing
  13. the player. In particular:
  14.  
  15. >>> To warp to the Normal Ending:
  16. 1) Perform Core Escape.
  17. 2) Backtrack to Labyrinth W and drown.
  18. 3) ???
  19. 4) Profit
  20.  
  21. >>> To warp to the Best Ending:
  22. 1) Perform Core Escape, then save in Dark Place.
  23. 2) Enter Mimiga Village (in any save file, though if your glitched save is in Curly Story,
  24. you must use a Curly Story save file), quit, reload back into Dark Place, and drown.
  25. This takes you to either First Cave (if you loaded the main story's Mimiga Village)
  26. or Assembly Hall (if you loaded Curly Story's Mimiga Village).
  27. Make your way to Start Point and save there.
  28. 3) Run Curly Story's normal ending (in any save file). Technically, the best ending
  29. would also work here, but the normal ending is obviously easier to get to. :)
  30. Quit in the "Fall" map (which, for normal ending, loads when the screen cuts to black
  31. after the island falls, and for best ending, loads shortly after Balrog says
  32. "A little beat up..."). Reload into Start Point, enter First Cave, and drown to
  33. trigger the credits warp.
  34.  
  35.  
  36. Below is a breakdown of everything that's happening to make this all work.
  37. I will not be assuming any knowledge of Cave Story modding, but if you have any
  38. experience at all with that, everything will be a lot easier to understand.
  39.  
  40.  
  41. ===== Why does drowning after Core Escape do weird things? =====
  42.  
  43. Each map in the game has an associated TSC (Text SCript) file (named after its *.tsc
  44. file extension in the game's data files) that contains the scripting for all of the
  45. "events" that happen in that map.
  46. For example, the Life Capsule event in the TSC file for First Cave looks like this:
  47.  
  48. #0400
  49. <PRI<SOU0022<DNP0400<CMU0016
  50. <MSG<GIT1006
  51. Obtained a Life Capsule.<WAI0160<NOD<RMU<ML+0003
  52. Max life increased by 3.<NOD<END
  53.  
  54. The game also stores an array of "flags", numbered 0 to 7999 (though not all of them are
  55. actually used), in order to keep track of the game's progression state. Each flag is a
  56. single bit, meaning it can either be set (1) or unset (0).
  57.  
  58. At the end of the post-Core fight cutscene (where Misery shows up to teleport the Core
  59. away), flag 4000 gets set:
  60.  
  61. [stuff]
  62. <MSG<FAC0121
  63. MISERY!!<FAC0221<NOD<CLR<FAC0121
  64. What are you doing?!?
  65. Move the Core to the lab NOW!<FAC0221<NOD<CLR<FAC0121
  66. While you still have time!<FAC0221<NOD<CLO<FAC0000
  67. <ANP0400:0013:0002<WAI0050
  68. <CNP0400:0082:0002<WAI0020
  69. <ANP0400:0025:0002<FMU
  70. <MSG
  71. WUUUUUUUH!!<WAI0050<NOD<CLO
  72. <BOA0600<WAI0030
  73. <ANP0400:0020:0002
  74. <ANP0402:0030:0000
  75. <ANP0410:0030:0000
  76. <ANP0450:0020:0002<DNA0181<DNA0182
  77. <CMP0040:0015:0047<CMP0040:0016:0047
  78. <WAI0100<CMU0000<FOM0016
  79. <FL+4000<FL+0832<FL+0341<FL+0783<FL+0837<END
  80. ^^^^^^^^
  81. |
  82. ----------- right here
  83.  
  84. Flag 4000 has a special treatment in the game's engine: Whenever the player runs out of
  85. air while underwater, the game checks the state of flag 4000. In most cases, flag 4000
  86. will not be set, so in that case the game will drown the player and run event #0041:
  87.  
  88. #0041
  89. <KEY<CMU0000<WAI0040<PRI<WAI0040<CMU0003
  90. <MSG
  91. You have drowned.<NOD<CLR
  92. Want to retry?<YNJ0049<CLO
  93. <FAO0001<WAI0050<FLJ0431:0048<INI<END
  94.  
  95. However, if flag 4000 is set, the game will *not* kill the player, but instead run
  96. event #1100. It's intended that the only place that you can drown with flag 4000 set is
  97. in the Core:
  98.  
  99. ----- notice, flag 4000 is unset here (this is the only place it ever gets unset)
  100. |
  101. #1100 v
  102. <KEY<FL-4000<FAO0004<WAI0050
  103. <MSG
  104. Losing... consciousness...<NOD<CLO
  105. <DNP0450
  106. <FL+0830<FL-0825<FL+0829<FL-0827
  107. <FL+0800<FL+0801<FL+0372<FL+0411
  108. <FL+0340<FL+0159<FL+0838
  109. <FL-1642<FL+1643<FL-0839
  110. <ITJ0030:1101<EVE1110
  111.  
  112.  
  113. With the Core Escape glitch, you're able to carry flag 4000 out of the Core room.
  114. By drowning in a different map, you can run event #1100 in that map's TSC file.
  115. However, most maps don't even have an event #1100, so this is where things get
  116. interesting.
  117.  
  118.  
  119. ===== TSC parsing =====
  120.  
  121. The game keeps a buffer in memory where it stores the script for the current area.
  122. When a new map is loaded, the game loads the contents of head.tsc into the buffer,
  123. followed by the contents of that map's TSC file, followed by a null character (to denote
  124. the end of the script).
  125.  
  126. When a request is made to run event number N, the game looks for it in the TSC buffer
  127. in the following way:
  128. 1) A "scan cursor" (so to speak) is placed at the beginning of the buffer.
  129. 2) The game scans the buffer, one character at a time, looking for the '#' character.
  130. 3) If a '#' is found:
  131. a) The scan cursor is advanced to the next character.
  132. b) The game peeks at the next 4 characters (without moving the scan cursor),
  133. converts them to a number, and checks whether that number is equal to N.
  134. c) If that number DOES equal N, we found the event we're looking for: The scan cursor
  135. is advanced to the beginning of the next line, in preparation for the event to be
  136. run.
  137. e) If that number is greater than N, we passed where the event should have been
  138. (events are supposed to be numbered in order in the TSC file). The game stops
  139. scanning at this point. [This case never occurs in normal gameplay.]
  140. f) Otherwise, we keep going (go to step 2).
  141. 4) If, while scanning, the game encounters a null character (meaning we hit the end of the
  142. script), it stops scanning. [This case also never occurs in normal gameplay.]
  143.  
  144. Here's the kicker: After these steps, regardless of whether the game actually found the
  145. correct event or not, it will start executing TSC beginning at wherever the scan cursor
  146. stopped scanning.
  147. Let's see how this lets us do credits warps:
  148.  
  149.  
  150. ===== Normal Ending credits warp =====
  151.  
  152. The Normal Ending warp is simple: All you have to do is drown in Labyrinth W after doing
  153. Core Escape.
  154.  
  155. Recall that drowning while flag 4000 is set runs event #1100. Let's take a look at
  156. Labyrinth W's TSC file and see if has that event number:
  157.  
  158. [stuff]
  159. #1000
  160. <KEY<FOB0000:0016<WAI0250<CMU0000
  161. <MS3<CMU0015
  162. Defeated Monster X!<FOM0016<WAI0160<NOD<CLO<CMU0037
  163. <ACH0036
  164. <CNP0300:0000:0000<FL+0680<END
  165.  
  166.  
  167. #1200
  168. <KEY<ANP1200:0020:0002
  169. <FON1200:0016<FAI0001
  170. <WAI0100<FAO0001<TRA0047:1200:0038:0016
  171.  
  172.  
  173. Uh-oh! Labyrinth W doesn't have a #1100. That means that when the game goes to look for
  174. it, it will find the '#' in "#1200", advance the scan cursor to the '1' in "1200", and
  175. then check to see if 1200 == 1100. Since 1200 > 1100, the game gives up looking
  176. for 1100...but as explained earlier, it'll start executing TSC from the current scan
  177. cursor location anyways. Since the scan cursor stopped at the '1' in "1200", this results
  178. in the text "1200" being printed to an invisible message box, followed by the commands
  179. that normally get executed for event #1200.
  180. Event #1200 is part of the normal ending "break down" cutscene...you know the rest.
  181.  
  182.  
  183. ===== The TSC overflow (over-read) glitch =====
  184.  
  185. Suppose that, instead of drowning in Labyrinth W to trigger the Normal Ending warp, one
  186. were to drown in Dark Place. What would happen?
  187. As before, drowning with flag 4000 set runs event #1100 instead of killing the player.
  188. Let's see what Dark Place's script looks like:
  189.  
  190. [stuff]
  191. We can't pass through here.<FAC0025<NOD<FAC0125
  192. We're going to have to keep
  193. moving forward.<FAC0025<NOD<CLO
  194. <ANP0300:0003:0002<WAI0141
  195. <ANP0300:0020:0002<WAI0010
  196. <SOU0011<ANP0110:0000:0002<WAI0020
  197. <DNP0300<WAI0020
  198. <SOU0011<ANP0110:0000:0000<FL+0820<END
  199. #0300
  200. #0330 <---------------- if you don't recognize this event, that's because it's unused :)
  201. <PRI<MSG
  202. There's a switch.<NOD<SOU0043<CLR<MSG
  203. You flip it.<NOD<CLO
  204. <WAI0050
  205. <SOU0071
  206. <CMP0010:0035:0000
  207. <CMP0011:0035:0000
  208. <CMP0029:0031:0111
  209. <WAI0050<END
  210.  
  211.  
  212. Dark Place, just like Labyrinth W, doesn't have an event #1100. In the case of
  213. Labyrinth W, the TSC scan cursor stopped at the next-highest event (#1200) while searching
  214. for #1100. However, Dark Place doesn't have any event numbers higher than #1100.
  215. That means that the scan cursor will instead end up at the null character at the end of
  216. the script. So, when the TSC parser goes to execute the script there, it'll start by
  217. printing a null character to an invisible message box...and then it'll be out of bounds.
  218.  
  219. What happens next? Well, the key thing to know here is that the game never clears the
  220. TSC buffer, even when loading a new area or quitting to the title screen -- it just
  221. overwrites the new script on top of the old script. So, what ends up happening when the
  222. game starts executing out-of-bounds TSC will be part of the last script that was loaded
  223. that's longer than the current area's script.
  224.  
  225. So, going back to this example, suppose we drown in Dark Place after entering from the
  226. Core (which has a longer script). Dark Place's script is 1320 bytes long, meaning that its
  227. script when loaded replaces the first 1320+1 characters of the Core's script (the +1 is to
  228. account for the terminating null character).
  229. The TSC buffer will thus look something like this:
  230.  
  231. [stuff]
  232. #0330
  233. <PRI<MSG
  234. There's a switch.<NOD<SOU0043<CLR<MSG
  235. You flip it.<NOD<CLO
  236. <WAI0050
  237. <SOU0071
  238. <CMP0010:0035:0000
  239. <CMP0011:0035:0000
  240. <CMP0029:0031:0111
  241. <WAI0050<END
  242. [null character; end of Dark Place script]<MSG
  243. >_ OPEN BLAST DOOR?<YNJ0000<CLR<FL+0825<2MV0001
  244. >_ OPENING BLAST DOOR.<NOD<CLO<WAI0040
  245. <ANP0256:0010:0001<WAI0050<ANP0301:0003:0002<ANP0302:0003:0002<WAI0078<DNP0256
  246. <MSG
  247. >_ BLAST DOOR OPENED.<NOD<END
  248. [stuff]
  249.  
  250. Thus, drowning will trigger the Core's ">_ OPEN BLAST DOOR?" computer. Nothing
  251. particularly interesting will happen if you say "yes", because the entities that it tries
  252. to animate don't exist in Dark Place.
  253.  
  254. For the sake of terminology, I'll call this a "TSC overflow from Dark Place into the Core
  255. script".
  256.  
  257. We can manipulate the contents of the TSC buffer to overflow into a different map's script
  258. by saving in Dark Place, opening up that map (in any save file), then quitting and
  259. reloading back into Dark Place to drown. For hopefully obvious reasons, this only works
  260. for maps whose script is longer than Dark Place's script.
  261.  
  262. For example, we can overflow into Mimiga Village rather than Core by loading
  263. Mimiga Village, then quitting out and reloading into Dark Place to drown. If we do that,
  264. the TSC buffer will look like this:
  265.  
  266. [stuff]
  267. #0330
  268. <PRI<MSG
  269. There's a switch.<NOD<SOU0043<CLR<MSG
  270. You flip it.<NOD<CLO
  271. <WAI0050
  272. <SOU0071
  273. <CMP0010:0035:0000
  274. <CMP0011:0035:0000
  275. <CMP0029:0031:0111
  276. <WAI0050<END
  277. [null character; end of Dark Place script]009
  278. #0110
  279. <PRI<FAO0000<TRA0012:0090:0055:0009
  280. #0111
  281. <KEY<FL+0327<FL+0443<MSG<FAC0109
  282. What did you say?!?<FAC0009<NOD<FAC0109
  283. Toroko's been kidnapped?!<FAC0009<NOD<FAC0109
  284. That's terrible!!<FAC0009<NOD<FAC0109
  285. We have to inform King!!!<FAC0009<NOD<CLO
  286. [stuff]
  287.  
  288. So, the overflow will print
  289. [null character]009
  290. #0110
  291. to an invisible message box, then fades the screen out and transports the player to
  292. map number 12...which is First Cave. (That event number, #0110, is actually just the door
  293. to First Cave.)
  294.  
  295.  
  296. One last thing to be aware of: Avoid opening the inventory while performing a
  297. TSC overflow. The inventory has its own (massively long) script, which loads into the same
  298. TSC buffer when opened and will clobber everything and mess up your setup. You'll end up
  299. overflowing into the inventory script instead of what you wanted (unless overflowing into
  300. the inventory IS what you wanted :thinking:).
  301.  
  302.  
  303. ===== Best Ending credits warp =====
  304.  
  305. At its core (no pun intended), the Best Ending credits warp is simply just a TSC overflow
  306. from First Cave into Curly Story's "Fall" map (which is the map where the Curly-falling-
  307. out-of-the-sky cutscene takes place, and also the map where Quote and Curly fly on top of
  308. Balrog's head).
  309.  
  310. In order to get to First Cave, however, we first have to get out of the Labyrinth.
  311. The usual ways of exiting the Labyrinth aren't available when doing Core Escape: The
  312. Waterway entrance will still be blocked off, and the Labyrinth B teleporter will still
  313. have no power.
  314. So, in order to escape the Labyrinth, we instead do a TSC overflow from
  315. Dark Place into Mimiga Village (explained above), which gets us out of the Labyrinth
  316. (conveniently, directly into First Cave).
  317.  
  318. Note: If you're playing in Curly Story (which uses a different set of scripts),
  319. the Dark Place to Mimiga Village overflow will send you to Assembly Hall instead:
  320.  
  321. [stuff]
  322. <CMP0029:0031:0111
  323. <WAI0050<END
  324. <END
  325. [null character; end of Dark Place]O0004<TRA0019:0094:0010:0010
  326.  
  327. [stuff]
  328.  
  329. (You get <TRA'ed to map 19, which is Assembly Hall)
  330.  
  331. Regardless, once you're out of the Labyrinth, you want to save in Start Point. Then, all
  332. that's left to do is another overflow from First Cave into Curly Story's "Fall" map.
  333. The easiest way to get there is by running Curly Story's normal ending. If you're already
  334. playing in Curly Story, you can do that by going to Bushlands and drowning, which triggers
  335. breakdown in exactly the same way that drowning in Labyrinth W triggers breakdown for the
  336. Normal Ending credits warp:
  337.  
  338. [stuff]
  339. <WAI0200<MSG
  340. It wooooooooooooon't stop!!!!!!<WAI0050<NOD<CMU0005
  341. <DNP0450<FL-0523<FL+0225<END
  342. #1200
  343. <KEY<ANP1200:0020:0002
  344. <FON1200:0016<FAI0001
  345. <WAI0100<FAO0001<TRA0010:1200:0050:0034
  346.  
  347. (When scanning for event #1100, the scan cursor ends up at #1200 and runs that instead.
  348. Event #1200 is part of the breakdown cutscene.)
  349.  
  350. Quit out any time after the screen goes black after the island falls, but before the
  351. credits roll (this is the Fall map), reload into Start Point, and head to First Cave to
  352. drown and trigger the Best Ending credits warp:
  353.  
  354. [stuff]
  355. #0400
  356. <PRI<SOU0022<DNP0400<CMU0016
  357. <MSG<GIT1006
  358. Obtained a Life Capsule.<WAI0160<NOD<RMU<ML+0003
  359. Max life increased by 3.<NOD<END
  360.  
  361. [null character; end of First Cave]100:0004:0015
  362.  
  363. #0120
  364. <KEY<CMU0000
  365. <FON0240:0016
  366. <CNP0230:0356:0002
  367. <DNP0220<WAI0200 |----- Flag 2000 is what determines Normal vs. Best Ending credits
  368. <FAI0001 v
  369. <MSG<FAC0105<FL+2000<FL+1460
  370. Close!<FAC0005<NOD<CLR<FAC0105
  371. Such a narrow escape.<FAC0005<NOD<CLR<FAC1119
  372. I thought I was scrap
  373. metal this time.<FAC1019<NOD<FAC1119
  374. [stuff]
Add Comment
Please, Sign In to add comment