SM64 Enhanced Text Engine
#1
The sm64 enhanced text engine is a new way to display text in sm64 that allows much more versatility and direct control on how each and every character is displayed including timing, size and location.

To see all the feature of this engine, see this video: https://youtu.be/A-YfaQpm5-A

This is installed as an asm patch, it will take the rom space from 0x1203800 -  0x12052C0. Included is the function itself "print string notes", the keyboard used for user input (simply place the entire file at 0x1204FFC) and an HTML file called "special_text_encode". This is a tool to make creating the strings easier since you can encode the cmds along with the text. The asm file includes two functions for the user to easily activate the text.

Code:
//80405218
//enable dialog with this object
//a0=x
//a1=y
//a2=*string
//everything but this object and mario will freeze, when dialog ends, everything will unfreeze (aka a 7C or a 7B cmd), call every frame while in dialog, 0x90 will be 1 during dialog, 0 when out of dialog
Code:
//display string during gameplay
//80404F40
//a0=x
//a1=y
//a2=*string


To make the strings, you place cmds inside the actual string. Cmds will be bytes unused by the normal sm64 text encoding and will have some parameters following them (ex. 40 00 01 - set text speed to 1 VI per character).

Below is a list of all the cmds included along with some things to keep in mind while using them
Code:
//40 set VIs per character, 2 byte - VIs per new char
//41 play sfx, 2 bytes - sfx arg
//42 set color of following characters, 4 bytes (white by default) - RGBA
//43 display short user string, 1 byte - user string number (each string is 10 bytes and goes from 6f00 to 6FF0, so inputs are 0 to F)
//44 display long user inputted string, up to FF characters
//45 return from user string (automatically generated by 4F cmd)
//46 make rainbow text (characters following cmd will rgb glow, call a new env color to disable) 1 byte - alpha value
//4E re enable user input on re-talk (by default, a user input only works once, then the cmd acts as if it is not there, ofc this does not stay after resetting the game)
//4F allow user input of short string, 1 byte - short user string ID. (This cmd will remove all other input and bring a keyboard up the player can type on. If you are not in time stop mario will move around while typing and it will suck)
//boxes will reset scaling and position and color. The only thing preserved is the character speed, and the blip flags.
//70 end of box, auto go to next box (put a pause before this so your string stays a while)
//71 end of box, goto next box on a press
//72 remove all text for certain number of VIs, 2 bytes - num of VIs with no text (Text will flash back to its previous spot after it is done, so if you had three sentences, it will auto go back to that point once the cmd is done), 0 has no effect
//74 pause - 2 bytes VIs to wait
//76 play small blip sound per character (think like in megaman or any other rpg with text scrolling)
//77 disable blip
//78 change music that plays after message to currently playing music (basically use this so if you switch tracks mid message, the track keeps playing)
//79 play music track, 1 byte - track number (original music will resume when string is done)
//7A disable all music (original music will resume when string is done)
//7B stop displaying string on A press (basically use this as an FF)
//7C stop displaying string after number of VI's (basically use this as an FF) - 2 bytes - num of VI's to wait until string is gone
//7F define background box, 2 bytes x start, 2 bytes y start, 2 bytes x end, 2 bytes y end. 4 bytes env color (coordinates go from the bottom right as the origin and increase)
//84 scale text, 4 bytes x scale float, 4 bytes y scale float (To compensate for large Y scaling, just do several line breaks the text will go farther up, e.g. y scale of 2 will need an empty line above it to not overlap, x will auto align)
//85 enable dialog options, 1 byte, number of options (they will be displayed vertically), the following strings will be the options, to use an user inputted string as an option do this (ex. 43 FF), returns byte of option selected (zero indexed, end each dialog option with an 0xFF)
//86 display following only on returned dialog option, 1 byte return, truncate string with FF, if return value does not match it will skip to following string, if there is no following string it will just display nothing (zero indexed)
//87 display general text (basically anything after this will display no matter what dialog option you choose, if you put another 86 cmd after this, general text will end and it will pass all text until another 87 or a matching 86)
//88 enable screen shake (only in certain levels?)
//89 disable screen shake

I have included two example objects on how you should use this engine. They are located at the very bottom of the asm file so you can read through those to see how simple it is to setup.
You can also find the special text encoder along with other tools I have made here: https://sites.google.com/view/supermario...authuser=0


Attached Files
.html   special_text_encode.html (Size: 17.25 KB / Downloads: 80)
.txt   print string notes.txt (Size: 50.61 KB / Downloads: 90)
.txt   keyboard.txt (Size: 388 bytes / Downloads: 161)
Reply
#2
I have updated the text engine, with 2 bugfixes and 4 new cmds.
Code:
//47 translate origin, 4 bytes - 2 bytes x pos, 2 bytes y pos
//48 jump string, 4 bytes - ram address
//4C enable A press to increase text speed, 2 bytes - speed while holding A
//4D disable A press to jump to end of box
I have removed the 7A cmd [disable music] and have now just absorbed that into the 79 play music cmd. Simply choose track 0 to disable music.
The bugs I have fixed are with the 79 and 43 cmd. The 79 cmd bug was that the music was not replaying properly after the string ended. The 43 cmd bug was that if you used it mid string, it would not return to the proper location and would instead jump back several characters. both are fixed in the new file.

I have changed the address of the function you need to call to setup the string. This is now the address:
Code:
//sets up string
//80404fc4
//a0=x
//a1=y
//a2=*string
The other one remains the same:

Code:
//80405218
//enable dialog with this object
//a0=x
//a1=y
//a2=*string
//everything but this object and mario will freeze, when dialog ends, everything will unfreeze (aka a 7C or a 7B cmd)
The final feature is I have now set the keyboard up to auto import with the file. Just have keyboard.bin in the same folder as print string notes.

The HTML has not been updated with the new cmds yet, I will do that later Smile


Attached Files
.zip   text engine files.zip (Size: 12.08 KB / Downloads: 60)
Reply
#3
Code:
//7A cleanup buffer
Code:
//82 enable cutscene, 1 byte - cutscene index (zero to disable all cutscenes, others see my documentation at https://sites.google.com/view/supermario64romhacks/tweaks-and-tutorials?authuser=0)

//83 non buffer padding (basically for asm modifying the string)
Code:
//8A change camera location, 6 bytes - 2 bytes x, 2 bytes y, 2 bytes z (set once on the would be character it would draw, aka if a string goes like "mari[83 cmd]o" then the camera would be set when the "i" would be drawn to the screen)

//8B change camera focus, 6 bytes - 2 bytes x, 2 bytes y, 2 bytes z (set once on the would be character it would draw, aka if a string goes like "mari[83 cmd]o" then the camera would be set when the "i" would be drawn to the screen)

//8C set camera speed, 8 bytes - 2 bytes VIs, 2 bytes x, 2 bytes y, 2 bytes z (sets the change in camera values. Use to set a speed after defining a location. This means if you set y spd to 10, it will continue to go up until you change the location  all speeds are units/every second VI)

//8D set camera focus speed, 8 bytes - 2 bytes VIs, 2 bytes x, 2 bytes y, 2 bytes z (sets the change in camera values. Use to set a speed after defining a location. This means if you set y spd to 10, it will continue to go up until you change the location  all speeds are units/every second VI)

//8E lock camera on object, 4 bytes - *object
I've added these new cmds. The function addresses are the same. As promised, I have updated the text encoding tool. 

You may be wondering what the buffer is, I have written this excerpt for it:
Quote:Basically certain cmds like the keyboard, camera cmds, pause and remove on VI make use of a buffer so that the cmds don't repeat every frame. What happens is the cmds are replaced by padding, and their location are stored in the buffer which is at 807f6000 and can basically theoretically be 0xE00 bytes long. This cmd cleans the buffer, which re-enables those cmds. This means if the current box has a pause or keyboard and you use this cmd, it will play again. I advise using this before a jump string cmd or for weird mindtricks.
If you want to leave padding for a possible self modifying string, then use the 0x83 cmd, not the 0x9D padding for buffer cmd.
This will probably be the last update for a while.

This update takes from 0x1203800 to around 0x1205700 in rom, plus something around 0x1202dc0 and 0x1205b00 because I never bothered to optimize those functions. You can optimize them yourself if need be.

As always, please notify me of any bugs.


Attached Files
.zip   text engine shiz camera update.zip (Size: 18.98 KB / Downloads: 43)
Reply
#4
I have fixed some bugs with the text engine:
  • Camera focus sweep accidentally set cam location sweep
  • Second dialog options were able to be selected before options were shown
Some other changes:
  • Everything has been aligned using labels. Now you should be able to change the hook, and everything will line up automagically. e.x. change .org from 80403800 to 80403900 and the entire engine will shift to match
  • Define custom keyboards easily. Simply change the "keyboard.bin" for your own keyboard and it will compile. Just make sure the upper and lowercase sets are the same length. You'll also have to make sure that space, shift and end are in the same locations at the bottom, but you can rearrange the order of letters however you want.
  • functions are now based on labels instead of addresses. To call a function to make a string, you must include the string engine. Use .include "print string notes.txt" to include the string.


Here are the functions you should use to call strings:
Code:
//SETUPSTRING
//sets up string
//a0=x
//a1=y
//a2=*string
Code:
//STARTDIALOGWITHTHISOBJFUNC
//enable dialog with this object
//a0=x
//a1=y
//a2=*string
//everything but this object and mario will freeze, when dialog ends, everything will unfreeze (aka a 7C or a 7B cmd)

Here are some tips for using the engine that I might have failed to mention previously. When you use dialog options, you should end every option with an FF (labeled end [FF] on the HTML tool).
When you use the jump string cmd, you should input a segmented address. If you want to put a ram address, just drop the 80, e.x. 80405600 should be 00405600.
If you use the cmd to enable fast dialog when holding A, you must set the normal text speed before using that cmd, in that box.
Now onto new cmds.
Code:
//a0 call function once, V0 is stored to array starting at 0x6d90, current string pos is stored to A1, 9 bytes -  4 bytes A1 arg, 4 bytes function Vaddresss, 1 byte return index

//a1 call function every frame while in box, V0 is stored to array starting at 0x6d90, current string pos is stored to A1, 9 bytes - 4 bytes A1 arg, 4 bytes function Vaddresss, 1 byte return index

//a2 display following only on matching function return, 1 byte - index of combined array (0 to 7 for A0 returns, 8 to 15 for A1 returns)
Returns are stored in an array of values starting at 0x807f6d90. They are stored automatically from the returned value of your function.
I have also made a basic dialog NPC for people who are not too great with asm, this means if you don't know asm at all, you should still be able to use the engine. Just compile the file "text engine dialog bob omb.txt" which is included in the zip attached while making sure the text engine and keyboard are in the same directory and you will have your object. I have just placed him at 0x1205600 for my own convenience. To use it in game, just give the object a bob omb model, use the behavior 00405600 and then set the Bparam equal to the ram address of your string. If you don't know how to get ram addresses, you should read my tutorial here: https://docs.google.com/document/d/1JnPT...Qis1c/edit
I have shown off this exact object in the community collab videos, check them out in this thread:https://hack64.net/Thread-SM64-Community-Hack-Project


Also if there is a cmd that you create please post in this thread as well. I have a few more planned that you may see on the top of the file with all my notes. The format should be easy enough to follow so feel free to make my code better or add some new things Smile
As always, if you find any bugs, please notify me.

edit:9/9/2019

found a bug with the buffer. It is fixed in newest attach


Attached Files
.zip   ADVANCED TEXT ENGINE.zip (Size: 20.68 KB / Downloads: 58)
Reply
#5
I have moved to gitlab for updates to this project. This will allow people to notify me of bugs in the text engine as well as work on a better tool for creating the text. Find it here: https://gitlab.com/scuttlebugraiser/sm64...ext-egnine
Reply




Users browsing this thread: 1 Guest(s)