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: 24)
.txt   print string notes.txt (Size: 50.61 KB / Downloads: 26)
.txt   keyboard.txt (Size: 388 bytes / Downloads: 27)
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: 4)
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: 2)
Reply




Users browsing this thread: 1 Guest(s)