Advertisement
imbuedl

abbreviated text overflow notes

Aug 15th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. On both English and JP, we compute the Soar Location Message Length Offset with 2*(Soar Cursor Index)
  2.  
  3. On English, we compute the Soar Location Message Offset with 16*(Soar Cursor Index)
  4. On JP, we compute the Soar Location Message Offset with 18*(Soar Cursor Index)
  5.  
  6. The Soar Location Message Length is 2 bytes. The value of Soar Location Message Length tells us how many characters long the Soar Message should be.
  7.  
  8. Note: "Buffer B" is just another name we use for "Current Message Content II" in this doc https://docs.google.com/spreadsheets/d/1QhucUVkOGwpO2d_OX8hsn61jHtYVQALj2iUag7HDiTQ/edit#gid=1277031729
  9. and "Buffer A" is just a similar block of memory (which comes a bit before Buffer B in memory) where the preprocessed message that will be displayed initially gets written to and then the main text processing function will read from here and write into Buffer B.
  10.  
  11. On English, a character is 1 byte. On JP, a character is 2 bytes.
  12.  
  13. - When you open up text in the Soar Map, on English "Soar to (D4)? Yes No" gets copied to Buffer A. (On JP, it uses 0224 instead of D4)
  14. - Characters from here get copied to Buffer B one character at a time (indexed by the Text Instruction Counter)
  15. - When control code D4 (or on JP 0224) is reached, a different text processing function is run entirely to get the soar location name (Soar Location Message)
  16. *** Extra note: whenever ANY control code is read, the Text Instruction Counter will be updated to point to the byte directly AFTER the control code that just got read
  17. - The Soar Location Message is then written into Buffer B (starting on the 10th byte on English and starting on the 3rd byte on JP because on English the "Soar to ", while seemingly being only 8 characters long, actually takes up 9 bytes because there is a color code after the space at the end and on JP the only character before the soar is a color control code) [i.e. The first 9 bytes of Buffer B are occupied on English and the first 2 bytes of Buffer B are occupied on JP before the D4 or 0224]
  18. - After all characters of the Soar Location Message are copied into Buffer B (and beyond if it is long enough), the game goes back to using the main text processing function (Assume that the Soar Location Message was sufficiently long so that the Text Instruction Counter is overwritten)
  19. * On JP, the main text processing function is now copying from (Start of Buffer A) + 2 + 2*(Text Instruction Counter), the + 2 being because a first character is skipped (for some reason******). So on JP 1.0, for example, it starts reading from
  20. 0x3FCFE2 + 2*(Text Instruction Counter) because Buffer A starts at 0x3FCFE0.
  21. ** Similarly, on English, the main text processing function is now copying from (Start of Buffer A) + 1 + Text Instruction Counter, the +1 being because the first character is skipped (for some reason******) and English characters are only 1 byte. Also note that the Text Instruction Counter is only multiplied by a factor of 1 on English instead of the factor of 2 used on JP (this has something to do with characters being 1 byte on English and 2 bytes on JP)
  22. - and (from where I said it's copying from in * and ** for JP and Eng resp.) the main text processing function is writing these values to the places in memory right AFTER where it the Soar Location Message was written in Buffer B (and beyond) and it will continue writing these values until a terminating character is found
  23.  
  24. ****** The reason that the first character is "skipped" is likely because of how the main text processing function is made to handle control codes. I'll elaborate. The main text processing function always reads from (Start of Buffer A) + (1 Character) + ("Text Instruction Counter" number of characters). The reason it is offset by an extra character is because when the main text processing function gets to a control code (a control code is just a special character that performs some function when the main text processing function reads it), a function entirely separate from the main text processing function is called to do something, so the game actually updates the Text Instruction Counter to be the value of however many characters after the start of Buffer A the control code was at, and then when the main text processing function returns to being used, the developers of course wanted it to start reading from 1 character AFTER the control code that was just read, so that is why we think it is offset by 1 character. Also, you might be thinking "Why doesn't being offset by 1 character mess up how the first character in Buffer A is read?" and the answer to that appears to be that the first few bytes of Buffer A are actually occupied by control codes which essentially "do nothing", so if one of these is skipped, it doesn't matter. EDIT: My testing on control codes seems to suggest that these control codes at the start of Buffer A actually don't do "nothing", so I'm missing some piece of information. Regardless, things still appear to work how I described them above.
  25.  
  26. Terminators (which are just control codes a.k.a. format codes):
  27.  
  28. 0009, 000B, 0103, 0104, 0110, 0111, 0112, 0230, 0240, 0500 are the terminators for JP 1.0
  29. the terminators are characters 10,12,15,19,1A,1B,1C,1D,BF,E0 on US. EDIT: my testing suggests that 1B is actually NOT a terminator...
  30. See my more complete notes on English control codes here: https://pastebin.com/QtqDrjV1
  31.  
  32. Link to all control codes: https://wiki.cloudmodding.com/mm/Text_Format#Text_Format
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement