Thanks Johannes for the address, it took me quite a while to figure out that it was a float ( :P ), but I found some important addresses in that area.
EDIT: It turns out that mario's direction, x,y and z values, horizontal velocity(speed) and x and y components of velocity are all on the C26C00 page. I wouldn't have been able to find any of these.
EDIT2: The reason I wanted to find those addresses was so I could do this: It should make Mario travel in a perfectly straight line, but nothing ever goes to plan eh? oh well, here's what I got, if anyone can correct any mistakes that'd be great.
EDIT3: YAY, it works, except Mario sometimes sporadically turns around for some reason.
The following code gets copied into a script lock for the address for the x axis of the analog stick, there is a similar version of this code that locks the y axis. Before today, I had never used a programming language like this, so there might be some really obvious errors.
VOID Lock(MHS_ADDRESS aAddress, INT iTemSize){
extern BYTE anlgx = { "", aAddress }; //analog x
extern float camy = { "", 0x00C28124 };
extern float camx = { "", 0x00C2812C }; //camera and mar x,y
extern float mary = { "", 0x00C26C2C };
extern float marx = { "", 0x00C26C34 };
float radam; // angles
float radac;
float desty; //destinations, change in mario and camera x,y
float destx;
float dltmy;
float dltmx;
float dltcy;
float dltcx;
desty = 0;
destx = 0;
dltcx = marx - camx;
dltcy = mary - camy;
dltmx = destx - marx;
dltmy = desty - mary;
if (dltmx == 0 && dltmy < 0) { //avoiding any div0 errors
radam = 90;
}
else if (dltmx == 0 && dltmy < 0) {
radam = 270;
}
else { //do the actual calculation
if ( dltmx > 0) {
radam = ATan( dltmy / dltmx );
}
else if ( dltmx < 0 ) {
radam = 180 + ATan( dltmy / dltmx );
}
}
if (radam < 0) {
radam += 360;
}
// up to here is good, below here, a lot of assumptions
if ( dltcx == 0 && dltcy > 0 ) { // have been made that could compromise the code.
radac = 90;
}
else if ( dltcx == 0 && dltcy < 0 ) {
radac = 270;
}
else {
if ( dltcx > 0) {
radac = ATan( dltcy / dltcx );
}
else if ( dltcx < 0 ) {
radac = 180 + ATan( dltcy / dltcx );
}
}
if (radac < 0) {
radac += 360;
}
anlgx = Floor(0.5 + (127 * Sin( radac - radam )));
}
EDIT: fixed a few things in the code (redundancies, useless lines, and some errors), and changed all the variables to single precision floating points.
YETANOTHEREDIT: Finally! smoothed out all the bugs. Mario goes straight towards the destination (destx, desty), which in this case, is the origin, then acts weirdly, which is what is expected.
here is the file to use in MHS: IMPORTANT: IF YOU WANT TO MAX A TAS OF SM64, USE THIS FILE. It has never been easier to travel in a perfectly straight line, and requires much less effort than any other method.
To use this script:
1. load in MHS and open the mupen 64 process.
2. right click on "anlgx", chose "modify address", click on the "script lock" tab, and where it has the lines:
desty = 0;
destx = 0;
change the 0's to your destination. i.e., walk to your destination, when you get there, look at mario's x and y, and then input them here.
3. do the same for "anlgy"
4. right click on "anlgx" and select lock address, then do the same for "anlgy"
5. mario should now travel in a perfectly straight line towards the destination point.
http://cid-de1e7fef4aaf7e0d.skydrive.live.com/self.aspx/.Public/sm64.lssave?lc=3081