Guide To Writing A Simple Sub-Routine
SneakyCodes Gaming Forum
Welcome to SneakyCodes. Contrary to what some may want you to think, SneakyWorld.forumotion is IN NO WAY affiliated with SneakyCodez. Anyone who tries to tell you different, is a lying piece of shit.

SneakyCodes is in the process of an entire site reboot, with no sections, topics, forums, and users. Feel free to sign up, and check back regularly for updates.

Thank you,
SwoRNLeaDejZ


SneakyCodes Gaming Forum

The Evolution Begins...
 
HomePortalRegisterLog inSneakyCodes RSS Feed
Everyone go to SneakyWorld! Link on the home page!
Sneaky Generators

Sneaky Image Editor
The Walking Dead Game

All Generators By SwoRNLeaDejZ


FTB3 Room Generator
FTB3 Name Generator
FTB2 Tag Generator
FTB2 Name Generator
FTB2 Room Generator


Donate to SneakyCodes Today!
Affiliates
Please Join and Visit the SneakyCodes Affiliates




We Love A-G!!!!

Join TheUnseenCoders.com Today!!


Free Forumotion Designs


kHaoZ is a frickin beast :)

Tech Support Guy
Latest topics
» Deepest regards to the Sneaky Community
Tue Oct 28, 2014 5:42 am by _-_EVIL-LOCO_-_

» damn sneaky, RiP. It was fun
Sat Oct 11, 2014 1:25 am by Sylen7Nato

» Just Another Blonde Joke xD FUNNY AS FAWK
Mon Mar 03, 2014 5:37 pm by Rossy Redness

» Hey it's Skinny107
Tue Dec 03, 2013 8:24 pm by o5Gz

» ps3 hacking!
Mon Jun 10, 2013 9:42 pm by Sylen7Nato

» PSP ISO List
Mon Jun 10, 2013 9:28 pm by Sylen7Nato

» tiger render
Fri May 10, 2013 3:11 pm by mk7

» SWORN.
Sun Dec 09, 2012 6:25 am by EverEffects

» homefront redeem code
Fri Nov 30, 2012 1:32 am by EverEffects

» Calling Sworn
Tue Nov 20, 2012 4:34 pm by EverEffects

» Thought Id Stop By And Say Hi
Thu Nov 15, 2012 3:40 am by HappySnacks69

» An Introduction
Tue Nov 13, 2012 2:33 am by Ace700

Views
Powered by web analytics software.
Statistics
We have 4719 registered users
The newest registered user is CraftPR

Our users have posted a total of 13085 messages in 2891 subjects
Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

Most users ever online was 59 on Sat Dec 03, 2011 5:04 pm
Facebook Stream
Top posters
SwoRNLeaDejZ
 
blckhwksfan
 
-Ch33zy-
 
EverEffects
 
l7annylvlex
 
+Elegance
 
Whiteyy
 
JZydex
 
PumaSnIpejZ
 
kHaoZ
 






Share | 
 

 Guide To Writing A Simple Sub-Routine

View previous topic View next topic Go down 
AuthorMessage
Sniper7410
Newbie
Newbie
avatar

Posts : 12
1337ness : 0
Join date : 2011-02-01

PostSubject: Guide To Writing A Simple Sub-Routine   Wed Feb 02, 2011 8:42 pm


THINGS YOU NEED TO KNOW:
Well Understanding Of MIPS
How to use registers and commands
The Negative Rule
Hooks And Areas

Ok before we get started you need to know a couple things.

The Negative Rule
First off is the 7FFF rule. The 7FFF rule only apply's to some CMD's(Commands) but not all. The 7FFF rule means that whenever you have a code, lets say Inf Ammo for FTB3, which is 0x0897F5DC in REAL addressing. Now as you can see the last 16 bytes of the address is F5DC, that is bigger than 7FFF. So now you have to add 0x0001 since the last 16 bytes are bigger than 7FFF. So the new code would be 0x0898F5DC.

Knowing How To Use Registers
Now, using registers is pretty simple if you know how to read. Ok the basic Sub-Rountine Temp looks like this:
Quote :
lui t0 $[First Half Of Address + 1 If Second Half Is 8000 Or More]
lui t1 $[First half Of Value]
ori t1 t1 $[Second Half Of Value]
sw t1 $[Second Half Of Address](t0)
JR RA

Now look at the first command. It's a lui t0. This is loading the first half of your code in REAL addressing into a temporary register. Now look where it command that loads the last half of the code. It's a sw t1 (t0) Now the t0 in brackets links back to the t0 which is the register thats holding the first half of the code. As you can see its linking them together. Don't get it? Lets try another. Ok look at the command loading the first half of the hex, it's a lui t1. Ok now look at the command loading the last half of the hex it's a ori t1, t1. As you can seen the last t1 in the Ori CMD links it to the first half of the hex completing it. (This is how i see it, you might see it differently)

Hooks And Areas
Ok Hooks are pretty simple here are some safe hooks:
0x00000024
0x0000004C
0x00000098

Ok you can chose anyone of these for you routine.
To find the hex of your hook you must chose what area you want to use. To do this find a large field of nops (No Operation) in the game's RAM. Now lets say you chose 0x00003000 as a area. The hex of your hook has to equal the area of your sub in REAL addressing. The REAL address of our area is 0x08803000. Now a hex to to equal this area is 0x0A200C00 ($08803000)
So your hook will look like this:

0x00000098 0x0A200C00 (I chose 98 for a hook you can use anything you like)

Ok so now you have a understanding of this lets write the routine.

Ok, first find the code you would like to sub. I'm going to use:
Quote :

#Inf Ammo
;Sniper7410
0x0017F5DC 0x10000000

Ok, now we have the code we are gonna put this into REAL address so break out the hex calc or just use your head.
Quote :

0x08800000 + 0x0017F5DC = 0x00897F5DC

Now notice the last 16bytes are bigger than 7FFF so lets add 0x0001 making our code 0x0898F5DC.

Ok, now we are ready!

#Inf Ammo SUB
0x00000098 0x0A200C00
0x00003000 0x3C080898

Ok as you see i loaded the first half of the code into a lui t0 which is 0x3C08.

Now time for the next line.

#Inf Ammo SUB
0x00000098 0x0A200C00
0x00003000 0x3C080898
0x00003004 0x3C090000

Now i loaded the first half of the hex into the CMD lui t1 which is 0x3C09.

Next Line:

#Inf Ammo SUB
0x00000098 0x0A200C00
0x00003000 0x3C080898
0x00003004 0x3C090000
0x00003008 0x35290001

Now i loaded the last half of the hex into a ori t1, t1 which is 0x3529

Next Line:

#Inf Ammo SUB
0x00000098 0x0A200C00
0x00003000 0x3C080898
0x00003004 0x3C090000
0x00003008 0x35290001
0x0000300C 0xAD09F5DC

Now i loaded the last half of the address into a sw t1 (t0) Which is 0xAD09

Last Line:

This is the last line and its simple all you have to do for the hex of a JR RA is 0x03E00008

#Inf Ammo SUB
0x00000098 0x0A200C00
0x00003000 0x3C080898
0x00003004 0x3C090000
0x00003008 0x35290001
0x0000300C 0xAD09F5DC
0x00003010 0x03E00008

Congrats this is our completed code.

Quick Re-Run:

#Inf Ammo SUB
0x00000098 0x0A200C00 =Hook ($08803000)
0x00003000 0x3C080898 lui t0 + 0x0001 ($0898)
0x00003004 0x3C090000 lui t1 ($0000)
0x00003008 0x35290001 ori t1, t1 ($0001)
0x0000300C 0xAD09F5CD sw t1 (t0) ($F5DC)
0x00003010 0x03E00008 = JR RA

---------------------------------------------------------------------------------------
Notes:

This is just a simple Sub-Routine Tutorial Writen By Sniper7410.

Any questions comments or problems please reply.
If i left anything out please tell me.

-Sniper7410
108 Coder
Back to top Go down
 

Guide To Writing A Simple Sub-Routine

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
SneakyCodes Gaming Forum :: PSP Section :: PSP Tutorials-
Jump to:  





SneakyCodes.tk | Sneaky-Media.com


Free GeoHot NOW!
I support George Hotz and
the FREEDOM OF INFORMATION

Create a forum on Forumotion | © phpBB | Free forum support | Contact | Report an abuse | Forumotion