Advertisement
imbuedl

jp 1.0 index 219 setup notes/questions

Aug 13th, 2019
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.14 KB | None | 0 0
  1. Line 565 in doc: 0x3FDBEC (JP 1.0 address "Menu Type Open"): if this is 7 or 14, then OoT save menu can open while debug menu is open
  2. Line 566 in doc: 0x3FDBEE (JP 1.0 address "Debug Menu Open") want this address to be either 1 or 2 to open debug menu
  3.  
  4.  
  5.  
  6. Length Array starts at 0x1CAEC8
  7. Message Array starts at 0x1CAE00
  8.  
  9. Soar Cursor Index (JP 1.0 Address 0x3FDC40)
  10.  
  11.  
  12. Want Soar Cursor Index = 219 for this setup
  13.  
  14.  
  15. Length Offset = 219*2 = 438
  16.  
  17. So we should read the Length from the 2 bytes that start at 438 bytes after 0x1CAEC8.
  18. So we should read the Length from the 2 bytes starting at 0x1CB07E.
  19.  
  20. For me, the Length value is 0x008E which is 142 in decimal, this is the length in characters and
  21. each JP character is 2 bytes, so the length of the Message will be 284 bytes.
  22.  
  23.  
  24.  
  25. Message Offset = 219*18 = 3942
  26.  
  27. So we should read the Message from the 284 bytes that start 3942 bytes after 0x1CAE00
  28. So we should start reading the Message from 0x1CBD66
  29.  
  30.  
  31.  
  32. ---------
  33.  
  34. "Buffer A" is 200 bytes and starts at 0x3FCFE0 (this is a bit before Current Message Content II (aka "Buffer B") and Buffer A should have the same values as Buffer B when a textbox comes up)
  35.  
  36. Buffer A starts at 0x3FCFE0 and Buffer B starts at 0x3FD51C, so Buffer B starts 1340 bytes after the start of Buffer A
  37.  
  38. ---------
  39.  
  40. Text Instruction Counter is stored at the 2 bytes starting at 0x3FD5E4 and Buffer B starts at 0x3FD51C, so it starts 200 bytes after the start of Buffer B.
  41.  
  42. The first 2 bytes of Buffer B are already filled in from the JP equivalent of "Soar to ", so the value of Text Instruction Counter will be obtained from bytes 199 and 200 (if I define "byte 1" to be at 0x1CBD66 which is the start of where we read the Message from based on the Message Offset above), so starting 198 bytes after 0x1CBD66.
  43.  
  44. 198 bytes after 0x1CBD66 is 0x1CBE2C
  45.  
  46.  
  47.  
  48. So the value of Text Instruction Counter will become the value that the address 0x1CBE2C has. For me (i.e. based on what Bizhawk RAM Watch says for my current savestate, which has successfully been used to bring up the Debug Menu using this setup), this will give Text Instruction Counter a value of 0x036A which is 874 in decimal. (This DOES happen, so this is correct!)
  49.  
  50.  
  51. On JP, the main text processing function is now copying starting from (Start of Buffer A) + 2 + 2*(Text Instruction Counter), so on JP 1.0, it starts reading from 0x3FCFE2 + 2*(Text Instruction Counter) because Buffer A starts at 0x3FCFE0
  52.  
  53. 0x3FCFE2 + 2*(Text Instruction Counter) = 0x3FCFE2 + 2*874 = 0x3FCFE2 + 1748 = 0x3FD6B6
  54.  
  55. The first 2 bytes starting at Buffer B were already filled, then the next 284 bytes were filled, so a total of 2 + 284 = 286 bytes are filled. So the text processing function starts writing at 286 bytes after the start of Buffer B, which is 286 bytes after 0x3FD51C which is 0x3FD63A
  56.  
  57. So the text processing function starts reading from 0x3FD6B6 and starts writing to 0x3FD63A and will proceed to do this character-by-character (I think? i.e. 2 bytes at a time on JP) until a terminating character is found.
  58.  
  59.  
  60. Buffer B starts at 0x3FD51C and Menu Type Open (2 bytes long) starts at 0x3FDBEC and Debug Menu Open (2 bytes long) starts at 0x3FDBEE, so Menu Type Open is 1744 bytes after the start of Buffer B and Debug Menu Open is 1746 bytes after the start of Buffer B
  61.  
  62.  
  63. If 1750 bytes after the start of Buffer A (i.e. 0x3FD6B6) gets written to 286 bytes after the start of Buffer B, then the 2 bytes starting at 3208 bytes after the start of Buffer A get written to the 2 bytes starting 1744 bytes after the start of Buffer B (Menu Type Open) and the 2 bytes starting at 3210 bytes after the start of Buffer A get written to the 2 bytes starting 1746 bytes after the start of Buffer B (Debug Menu Open).
  64.  
  65. Buffer A starts at 0x3FCFE0
  66. Buffer B starts at 0x3FD51C
  67.  
  68. So 3208 bytes after start of Buffer A is 0x3FDC68
  69. And 3210 bytes after the start of Buffer A is 0x3FDC6A
  70.  
  71. So the 2 bytes starting at 0x3FDC68 get written to the 2 bytes starting at 0x3FDBEC (Menu Type Open)
  72. and the 2 bytes starting at 0x3FDC6A get written to the 2 bytes starting at 0x3FDBEE (Debug Menu Open)
  73.  
  74.  
  75.  
  76. For me, the 2 bytes starting at 0x3FDC68 originally have value 0x0000
  77. For me, the 2 bytes starting at 0x3FDC6A originally have value 0x0008
  78.  
  79. Observation 1: 0x3FDC38 is the address for Item Screen Slot, but 0x3FDC68 (which is 48 bytes after the address for Item Screen Slot) appears to have the same values/behavior as the Item Screen Slot address. Why? I'm not sure.
  80.  
  81. Observation 2: 0x3FDC6A is the Soar Cursor Index shifted by 31 (decimal) in the positive direction. Why? I'm not sure.
  82.  
  83. After the pause menu stuff, the 2 bytes starting at 0x3FDC68 have value 0x0000 (because item cursor is on ocarina) and the 2 bytes starting at 0x3FDC6A change to 0x00FA once the Soar Map comes up
  84.  
  85. While the Text Instruction Counter is originally 0x036A, as expected, it changes several times before the Debug Menu opens (and ultimately 0x3FDC68 and 0x3FDC6A, which are the addresses I would expect to write to the Menu Type Open and Debug Menu Open address (and they indeed do that if you don't do the pause menu stuff for the setup), end up not writing their exact values onto Menu Type Open and Debug Menu Open). I'm not really sure what is going on to make Text Instruction Counter change so many times.
  86.  
  87.  
  88.  
  89.  
  90.  
  91. -----------------------------------------------------------------------------------------------------
  92.  
  93.  
  94. NOTE: 0224 is the JP equivalent of the control code D4 (I did not know this and that is why I was so confused at the start of this conversation lol)
  95.  
  96.  
  97.  
  98.  
  99. ImbuedToday at 6:19 PM
  100. Can someone explain the pause menu/control stick portion of the jp 1.0 219 index setup? I noticed the two addresses that would've written to Menu Type Open and Debug Menu Open without the pause menu/control stick portion of the setup are related to the Item Screen Index and Soar Cursor Index values, but not sure how all of the logic works. Regardless of whether or not I do the pause menu/control stick portion of the setup, the Text Instruction Counter changes several times and I'm not sure why (I would have expected Text Instruction Counter to just remain the same value; not sure why anything would overwrite it). Here are some notes I made for myself that show most of my logic https://pastebin.com/Mbj4Js4x
  101. Pastebin
  102. jp 1.0 index 219 setup notes/questions - Pastebin.com
  103.  
  104.  
  105. faschToday at 6:23 PM
  106. the instruction counter will update whenever it catches a "control code"
  107. which are special codes that don't print the character they are, but rather specific things
  108. So if you go to my setup you'll notice the bytes that overwrite the pause/editor combo
  109. come an additional 12 bytes after what you calculated
  110.  
  111. ImbuedToday at 6:24 PM
  112. so once a control code is seen, I assume that'll then change where the text processing function starts reading characters from next?
  113. since it changes the text instruction counter
  114.  
  115. faschToday at 6:24 PM
  116. yea, its just used to keep its place
  117. so in my setup video I set lens to c-down which sets 3FDC74 to 000E0001
  118. 3FDC74 - 3FDC68 = C
  119. thats where the 1F comes into play
  120. 001F is a special character
  121. that reads the next character as the number of spaces to print
  122. 001F 00xx specifically
  123. So the memory is set up so that there are 3 of these
  124. 001F 0000 means to print 0 spaces
  125. since 001F000 = 4 bytes in total
  126. and i do 3 of those
  127. thats the 12 bytes required to push the manipulated pause/editor further up to a better address
  128. 2 of the 1Fs come from the control stick, the other comes from hovering over spring water in the mask inventory and hovering over ocarina slot
  129. and the other important action of my setup is hovering over song of soaring to set the selected song to 09 which acts as a terminator, but also being aware that the selected slot on the quest status screen sets another terminator so you just need to move away without hovering over another song
  130. because that quest status slot would prematurely terminate printing
  131.  
  132. ImbuedToday at 6:42 PM
  133. so I guess before addressing some of those details, something I'm wondering right now is: once the soar location message has been written into Buffer B, the main text processing function starts writing 286 bytes after the start of Buffer B (reading starting from 1750 bytes after the start of Buffer A). So it has like 1400 or 1500 ish bytes to read before writing anything to Menu Type Open or Debug Menu Open and in those 1400-1500 bytes, wouldn't there be a good chance that a control code is hit which would change the Text Instruction Counter which would then offset where the text processing function is reading from (potentially by a lot)? If we actually do reach at least one control code in those 1400-1500 bytes, then I imagine what bytes are read from to write to Menu Type Open and Debug Menu open likely wouldn't be so close to the ones I expected to write to them (unsure if you do something to check if any control codes exist in those 1400-1500 bytes)
  134.  
  135. faschToday at 6:43 PM
  136. Ok so any time the instruction counter updates
  137. thats the intended functionality
  138. If you take a look at the buffer A on a normal instance
  139. you'll see it it starts reading from the start
  140. and then when it reaches that 0224 for the location name
  141. it'll update the instruction counter to point to the character following that 0224
  142. so that way it knows when its done printing the location name, it can go back to buffer A and print whatever is next
  143.  
  144. ImbuedToday at 6:45 PM
  145. which 0224?
  146.  
  147. faschToday at 6:46 PM
  148. it should be the second character
  149.  
  150. ImbuedToday at 6:48 PM
  151. like the soar location name happens to have 0224 as its second character?
  152. (I didnt check it)
  153.  
  154. faschToday at 6:49 PM
  155. So buffer A is before processing and putting any variables
  156. since the location is a variable
  157. they just put it as 1 character in the preprocessed message
  158.  
  159. ImbuedToday at 6:51 PM
  160. not sure what you mean by "So buffer A is before processing and putting any variables"
  161.  
  162. faschToday at 6:52 PM
  163. So the string that is put into buffer A would look like this "Soar to %?"
  164. the function copies everything from buffer A to buffer B
  165.  
  166. ImbuedToday at 6:52 PM
  167. yup
  168.  
  169. faschToday at 6:52 PM
  170. but when it encounters special characters
  171. like in the case of "%" here
  172. it'll do special printing
  173. after its done with special printing
  174. it'll return back to buffer A based on the instruction counter, because there is still more to print
  175. which is the "?"
  176.  
  177. ImbuedToday at 6:53 PM
  178. Yes I agree with that
  179.  
  180. faschToday at 6:54 PM
  181. so thats why it updates the instruction counter
  182.  
  183. ImbuedToday at 7:01 PM
  184. So normally would it be like "Soar to (D4)?" is copied into Buffer A, then "Soar to " (9 bytes) is written from Buffer A into the first 9 bytes of Buffer B and then the D4 control code is read which causes the soar location message to be copied into Buffer B and then would the Text Instruction Counter update to be 10 to start reading 10 bytes after the start of Buffer A so that it reads the "?" (which I picture to be 1 byte after the byte of Buffer A that has the D4 control code)?
  185.  
  186. faschToday at 7:01 PM
  187. yeah
  188.  
  189. ImbuedToday at 7:02 PM
  190. ah ok so really when the Text Instruction Counter was changing in the setup, it was changing in a way so that it would return to the byte directly after the control code it just read?
  191.  
  192. faschToday at 7:03 PM
  193. exactly
  194.  
  195. ImbuedToday at 7:03 PM
  196. and therefore nothing crazy could happen
  197.  
  198. faschToday at 7:03 PM
  199. yep
  200.  
  201. ImbuedToday at 7:03 PM
  202. ok that makes sense
  203.  
  204. faschToday at 7:03 PM
  205. the only time something crazy would happen is by printing over it
  206.  
  207. ImbuedToday at 7:03 PM
  208. that is good to know
  209.  
  210. faschToday at 7:03 PM
  211. As for the 2nd part of the question regarding accidental control codes
  212. Yes there could be some, but it wasn't really an issue because most of the addresses are constant and just don't line up
  213. and its japanese
  214. so theres a significantly smaller portion of control codes to character ratio
  215.  
  216. ImbuedToday at 7:11 PM
  217. I'm not really familiar with most control codes, so not sure what potentially problematic things running into them could do (I imagine running into a D4 could cause the Soar Location Message to be copied into Buffer B again which would maybe cause some issues since the difference between where in Buffer A the function reads from and writes to in Buffer B would increase; for example suppose where the text processing function is reading from is exactly 2000 bytes away from where it writes to, but then a D4 is hit and the soar location message is 100 bytes long, then once it finishes writing that into Buffer B, the difference between them would be 2100 (or 1900 depending on which one is first in memory I guess))
  218. though I imagine most wouldn't be problematic as I imagine most likely wouldn't write something extra into buffer B
  219.  
  220. faschToday at 7:12 PM
  221. yeah it just reprints the location again
  222. lets say it was 'Snowhead' as the location
  223. and you had "Soar to (D4)(D4)?"
  224. it would do
  225. "Soar to SnowheadSnowhead?"
  226.  
  227. ImbuedToday at 7:14 PM
  228. Yeah makes sense
  229.  
  230. faschToday at 7:14 PM
  231. so its a nice way to print a lot of characters with very few bytes to manipulate
  232. so my setup follows the reverse of that, I wanted less characters printed
  233.  
  234. ImbuedToday at 7:16 PM
  235. What I'm getting at is if there's some random D4 in the 1400-1500 bytes I was talking about earlier, then it would end up changing what bytes in memory are read from to write over Menu Type Open and Debug Menu Open, so in the jp 1.0 219 index setup there definitely was not a D4 anywhere in those 1400-1500 bytes or else we'd have had a difference of more than 12 with our addresses that write to menu/debug
  236.  
  237. faschToday at 7:16 PM
  238. yeah
  239.  
  240. ImbuedToday at 7:17 PM
  241. ok so rereading what you said earlier is making more sense now
  242. you basically used a 001F control code to write 0 spaces to advance 4 bytes further into where we're reading from, but without advancing where we're writing to and you did that 3 times and that is why where you read from was 12 bytes ahead of me
  243.  
  244. faschToday at 7:19 PM
  245. yep
  246.  
  247. ImbuedToday at 7:20 PM
  248. so that part makes a lot more sense now. However, I'm unsure why you need the 09 terminator. Is this to stop overwriting stuff because there is stuff nearby (after the Menu Type Open and Debug Menu Open adresses) that if you overwrite it you'll get a crash?
  249.  
  250. faschToday at 7:21 PM
  251. yeah
  252. not necessarily nearby
  253. but still prevents a lot from being overwritten
  254.  
  255. ImbuedToday at 7:22 PM
  256. yeah makes sense
  257. so is there a list of terminators/control codes? I've seen this before (but haven't really read most of it) which has info on some control codes to my understanding https://wiki.cloudmodding.com/mm/Text_Format#Text_Format
  258. Text Format
  259.  
  260. faschToday at 7:24 PM
  261. thats what i use
  262.  
  263. ImbuedToday at 7:24 PM
  264. ctfl + f "terminator" gives me nothing though
  265.  
  266. faschToday at 7:24 PM
  267. oh
  268. theres a message from exodus with the japanese ones
  269. and mrcheeze with the US ones
  270. 0009, 000B, 0103, 0104, 0110, 0111, 0112, 0230, 0240, 0500 are the terminators for JP 1.0
  271. the terminators are characters 10,12,15,19,1A,1B,1C,1D,BF,E0 on US
  272.  
  273. ImbuedToday at 7:28 PM
  274. cool thanks for all the info (didn't see a message with JP 1.1 ones when I searched past discord messages, but saw JP 1.0 and English like you linked)
  275.  
  276. faschToday at 7:28 PM
  277. i'm 99% certain they would be the same on J 1.1
  278. as on J
  279. 1.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement