Post: [PPC] Spawn Turret Bind
07-12-2014, 12:48 AM #1
Notorious
Caprisuns Is Back
(adsbygoogle = window.adsbygoogle || []).push({}); Hello NGU,


I was #bored and I wanted to do a little something with the new stuff that people released for this game! If you don't know what this is, this is a powerpc script that can bind spawn turret to a button, in this case dpad right. To actually put this to use you need to convert it to the memory and put it in debugger or an eboot.bin! I did not put this in an eboot because I was to lazy to switch cfw and go on mw2 and shit but yeah you can make this in an eboot and release it if you want. Also this script is a little messy but if it's that much of a problem then clean it up yourself. Enjoy everyone Smile

I will be using the rpc address as an example for the fps button monitor but feel free to use a different address.

TOC: 0x724C38
how to use:
options>general>analysis>processor specific analysis options>toc from: 0xFFFFFFFF to: 0x724C38

Store this in an un-used function (Like r_setframefog):
    
stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r3, 0x001B
addic r3, r3, 0xCD10 #0x001BCD10 (G_Spawn)
lis r4, 0x14E
addic r4, r4, 0x2200 #0x14E2200 (G_Client)
lfs f1, r4, 0x1C #Reading Your X Origin and Storing it in r5
lfs f2, r4, 0x20 #Reading Your Y Origin and Storing it in r6
lfs f3, r4, 0x24 #Reading Your Z Origin and Storing it in r7
stfs f1, r3, 0x138 #Writing Your X-Origin at G_Spawn + 0x138
stfs f2, r3, 0x13C #Writing Your Y-Origin at G_Spawn + 0x13C
stfs f3, r3, 0x140 #Writing Your Z-Origin at G_Spawn + 0x140
lfs f4, r4, 0x214 #Reading Your X-Angles and Storing it in r8
lfs f5, r4, 0x218 #Reading Your Y-Angles and Storing it in r9
lfs f6, r4, 0x21C #Reading Your Z-Angles and Storing it in r10
stfs f4, r3, 0x144 #Writing Your X-Angles at G_Spawn + 0x144
stfs f5, r3, 0x148 #Writing Your Y-Angles at G_Spawn + 0x148
stfs f6, r3, 0x14C #Writing Your Z-Angles at G_Spawn + 0x14C
bl 0x001BCD10 #Calling G_Spawn
li r3, 0 #Value will be returned here
lis r4, 0x007F
addic r4, r4, 0x62B0 #Address where the model string is stored
bl 0x001BE3F0 #Calling G_SetModel
lis r5, 0x007F
addic r5, r5, 0x63C0 #Address where the turret type string is stored
bl 0x001C8820 #Calling G_SpawnTurret
b end

end:
blr


Make sure to write the model name at 0x7F62B0. examle: weapon_minigun
And make sure to write the turret type at 0x7F63C0. Example: pavelow_minigun_mp


Store this button monitoring in fps: (0x253AB0)
    
stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r2, 0x0072
addic r2, r2, 0x4C38
li r3, 0 #Client
li r4, 0x17 #DPAD_RIGHT
bl Key_IsDown #Sorry I don't have the address lmao
cmpwi r3, 0
beq 0xC0 #End of fps else go to start
bl 0x38EDE8 #Calling R_SetFrameFog (you can use a different address amd you should use a different one if you use rpc)
b 0xB8 #End of fps
lis r2, 0x734BE8
addic r2, r2, 0x734BE8
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr

Btw if you notice anything I did wrong then please let me know and also this is untested so yeah.

How To Test It:
Compile the FPS PPC Function I provided (Button Monitoring) into memory (HEX) And then write it at the fps function address 0x253AB0
and then go to the address that is empty and not being called (test by putting a break point on it in debugger) and put the main function in there. (Make sure you paused the process while doing all of this). And then when its all written you can play the process and press dpad right and it should spawn a turret!

thanks to You must login or register to view this content. for the mw2 c# function. And BadLuckBrian for teaching me PPC! And SC58 for fixing it up a bit !
I hope you all enjoy and have fun everyone!
(adsbygoogle = window.adsbygoogle || []).push({});

The following 8 users say thank you to Notorious for this useful post:

HighModzz, Im Not Boobdidas, ImPiffHD, John, Smoky420, SnaY, Laser, Zambie
07-12-2014, 01:26 AM #2
seb5594
Proud Former Admin
Originally posted by Prime
Hello NGU,


I was #bored and I wanted to do a little something with the new stuff that people released for this game! If you don't know what this is, this is a powerpc script that can bind spawn turret to a button, in this case dpad right. To actually put this to use you need to convert it to the memory and put it in debugger or an eboot.bin! I did not put this in an eboot because I was to lazy to switch cfw and go on mw2 and shit but yeah you can make this in an eboot and release it if you want. Also this script is a little messy but if it's that much of a problem then clean it up yourself. Enjoy everyone Smile

I will be using the rpc address as an example for the fps button monitor but feel free to use a different address.

TOC: 0x724C38
how to use:
options>general>analysis>processor specific analysis options>toc from: 0xFFFFFFFF to: 0x724C38

Store this in an un-used function (Like r_setframefog):
    
lis r3, 0x001B
addic r3, r3, 0xCD10 #0x001BCD10 (G_Spawn)
lis r4, 0x14E
addic r4, r4, 0x2200 #0x14E2200 (G_Client)
lwz r5, r4, 0x1C #Reading Your X Origin and Storing it in r5
lwz r6, r4, 0x20 #Reading Your Y Origin and Storing it in r6
lwz r7, r4, 0x24 #Reading Your Z Origin and Storing it in r7
stw r5, r3, 0x138 #Writing Your X-Origin at G_Spawn + 0x138
stw r6, r3, 0x13C #Writing Your Y-Origin at G_Spawn + 0x13C
stw r7, r3, 0x140 #Writing Your Z-Origin at G_Spawn + 0x140
lwz r8, r4, 0x214 #Reading Your X-Angles and Storing it in r8
lwz r9, r4, 0x218 #Reading Your Y-Angles and Storing it in r9
lwz r10, r4, 0x21C #Reading Your Z-Angles and Storing it in r10
stw r8, r3, 0x144 #Writing Your X-Angles at G_Spawn + 0x144
stw r9, r3, 0x148 #Writing Your Y-Angles at G_Spawn + 0x148
stw r10, r3, 0x14C #Writing Your Z-Angles at G_Spawn + 0x14C
bl 0x001BCD10 #Calling G_Spawn
li r3, 0 #Value will be returned here
lis r4, 0x007F
addic r4, r4, 0x62B0 #Address where the model string is stored
bl 0x001BE3F0 #Calling G_SetModel
lis r5, 0x007F
addic r5, r5, 0x63C0 #Address where the turret type string is stored
bl 0x001C8820 #Calling G_SpawnTurret
b end

end:
blr


Make sure to write the model name at 0x7F62B0. examle: weapon_minigun
And make sure to write the turret type at 0x7F63C0. Example: pavelow_minigun_mp


Store this button monitoring in fps: (0x253AB0)
    
li r3, 0 #Client
li r4, 0x17 #DPAD_RIGHT
bl Key_IsDown #Sorry I don't have the address lmao
cmpwi r3, 0
beq 0xC0 #End of fps else go to start
bl 0x38EDE8 #Calling R_SetFrameFog (you can use a different address amd you should use a different one if you use rpc)
b 0xB8 #End of fps

Btw if you notice anything I did wrong then please let me know and also this is untested so yeah.

thanks to You must login or register to view this content. for the mw2 c# function. And BadLuckBrian for teaching me PPC!
I hope you all enjoy and have fun everyone!


Nice to see some PPC stuff there but why the hell are you using lwz instead of lfs? you know that origin/angles aren't integers?

The following 2 users say thank you to seb5594 for this useful post:

SC58, SnaY
07-12-2014, 09:47 AM #3
SC58
Former Staff
Originally posted by Prime
Hello NGU,


I was #bored and I wanted to do a little something with the new stuff that people released for this game! If you don't know what this is, this is a powerpc script that can bind spawn turret to a button, in this case dpad right. To actually put this to use you need to convert it to the memory and put it in debugger or an eboot.bin! I did not put this in an eboot because I was to lazy to switch cfw and go on mw2 and shit but yeah you can make this in an eboot and release it if you want. Also this script is a little messy but if it's that much of a problem then clean it up yourself. Enjoy everyone Smile

I will be using the rpc address as an example for the fps button monitor but feel free to use a different address.

TOC: 0x724C38
how to use:
options>general>analysis>processor specific analysis options>toc from: 0xFFFFFFFF to: 0x724C38

Store this in an un-used function (Like r_setframefog):
    
lis r3, 0x001B
addic r3, r3, 0xCD10 #0x001BCD10 (G_Spawn)
lis r4, 0x14E
addic r4, r4, 0x2200 #0x14E2200 (G_Client)
lwz r5, r4, 0x1C #Reading Your X Origin and Storing it in r5
lwz r6, r4, 0x20 #Reading Your Y Origin and Storing it in r6
lwz r7, r4, 0x24 #Reading Your Z Origin and Storing it in r7
stw r5, r3, 0x138 #Writing Your X-Origin at G_Spawn + 0x138
stw r6, r3, 0x13C #Writing Your Y-Origin at G_Spawn + 0x13C
stw r7, r3, 0x140 #Writing Your Z-Origin at G_Spawn + 0x140
lwz r8, r4, 0x214 #Reading Your X-Angles and Storing it in r8
lwz r9, r4, 0x218 #Reading Your Y-Angles and Storing it in r9
lwz r10, r4, 0x21C #Reading Your Z-Angles and Storing it in r10
stw r8, r3, 0x144 #Writing Your X-Angles at G_Spawn + 0x144
stw r9, r3, 0x148 #Writing Your Y-Angles at G_Spawn + 0x148
stw r10, r3, 0x14C #Writing Your Z-Angles at G_Spawn + 0x14C
bl 0x001BCD10 #Calling G_Spawn
li r3, 0 #Value will be returned here
lis r4, 0x007F
addic r4, r4, 0x62B0 #Address where the model string is stored
bl 0x001BE3F0 #Calling G_SetModel
lis r5, 0x007F
addic r5, r5, 0x63C0 #Address where the turret type string is stored
bl 0x001C8820 #Calling G_SpawnTurret
b end

end:
blr


Make sure to write the model name at 0x7F62B0. examle: weapon_minigun
And make sure to write the turret type at 0x7F63C0. Example: pavelow_minigun_mp


Store this button monitoring in fps: (0x253AB0)
    
li r3, 0 #Client
li r4, 0x17 #DPAD_RIGHT
bl Key_IsDown #Sorry I don't have the address lmao
cmpwi r3, 0
beq 0xC0 #End of fps else go to start
bl 0x38EDE8 #Calling R_SetFrameFog (you can use a different address amd you should use a different one if you use rpc)
b 0xB8 #End of fps

Btw if you notice anything I did wrong then please let me know and also this is untested so yeah.

thanks to You must login or register to view this content. for the mw2 c# function. And BadLuckBrian for teaching me PPC!
I hope you all enjoy and have fun everyone!


You will need the TOC in the function be for calling this else it will just freeze you console

At start
lis r2, TOC Address
addic r2, r2, TOC Address

And this at the end of the function
lis r2, unk_734BE8
addic r2, r2, unk_734BE8

Sooo like this

    
stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r2, TOC Address
addic r2, r2, TOC Address
li r3, 0 #Client
li r4, 0x17 #DPAD_RIGHT
bl Key_IsDown #Sorry I don't have the address lmao
cmpwi r3, 0
beq 0x08
bl 0x38EDE8
------------Branchs here
lis r2, 0x734BE8
addic r2, r2, 0x734BE8
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr

At 0x38EDE8

stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r3, 0x001B
addic r3, r3, 0xCD10 #0x001BCD10 (G_Spawn)
lis r4, 0x14E
addic r4, r4, 0x2200 #0x14E2200 (G_Client)
lwz r5, r4, 0x1C #Reading Your X Origin and Storing it in r5
lwz r6, r4, 0x20 #Reading Your Y Origin and Storing it in r6
lwz r7, r4, 0x24 #Reading Your Z Origin and Storing it in r7
stw r5, r3, 0x138 #Writing Your X-Origin at G_Spawn + 0x138
stw r6, r3, 0x13C #Writing Your Y-Origin at G_Spawn + 0x13C
stw r7, r3, 0x140 #Writing Your Z-Origin at G_Spawn + 0x140
lwz r8, r4, 0x214 #Reading Your X-Angles and Storing it in r8
lwz r9, r4, 0x218 #Reading Your Y-Angles and Storing it in r9
lwz r10, r4, 0x21C #Reading Your Z-Angles and Storing it in r10
stw r8, r3, 0x144 #Writing Your X-Angles at G_Spawn + 0x144
stw r9, r3, 0x148 #Writing Your Y-Angles at G_Spawn + 0x148
stw r10, r3, 0x14C #Writing Your Z-Angles at G_Spawn + 0x14C
bl 0x001BCD10 #Calling G_Spawn
li r3, 0 #Value will be returned here
lis r4, 0x007F
addic r4, r4, 0x62B0 #Address where the model string is stored
bl 0x001BE3F0 #Calling G_SetModel
lis r5, 0x007F
addic r5, r5, 0x63C0 #Address where the turret type string is stored
bl 0x001C8820 #Calling G_SpawnTurret
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr


This is how i would do it :p

But the ppc for this looks a bit crappy, i would fix it up for be i would use if i was too :p
07-12-2014, 11:23 AM #4
Notorious
Caprisuns Is Back
Originally posted by seb5594 View Post
Nice to see some PPC stuff there but why the hell are you using lwz instead of lfs? you know that origin/angles aren't integers?

lol I wasn't thinking sorry bout that :p
07-12-2014, 11:26 AM #5
Notorious
Caprisuns Is Back
Originally posted by SC58 View Post
You will need the TOC in the function be for calling this else it will just freeze you console

At start
lis r2, TOC Address
addic r2, r2, TOC Address

And this at the end of the function
lis r2, unk_734BE8
addic r2, r2, unk_734BE8

Sooo like this

    
stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r2, TOC Address
addic r2, r2, TOC Address
li r3, 0 #Client
li r4, 0x17 #DPAD_RIGHT
bl Key_IsDown #Sorry I don't have the address lmao
cmpwi r3, 0
beq 0x08
bl 0x38EDE8
------------Branchs here
lis r2, 0x734BE8
addic r2, r2, 0x734BE8
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr

At 0x38EDE8

stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r3, 0x001B
addic r3, r3, 0xCD10 #0x001BCD10 (G_Spawn)
lis r4, 0x14E
addic r4, r4, 0x2200 #0x14E2200 (G_Client)
lwz r5, r4, 0x1C #Reading Your X Origin and Storing it in r5
lwz r6, r4, 0x20 #Reading Your Y Origin and Storing it in r6
lwz r7, r4, 0x24 #Reading Your Z Origin and Storing it in r7
stw r5, r3, 0x138 #Writing Your X-Origin at G_Spawn + 0x138
stw r6, r3, 0x13C #Writing Your Y-Origin at G_Spawn + 0x13C
stw r7, r3, 0x140 #Writing Your Z-Origin at G_Spawn + 0x140
lwz r8, r4, 0x214 #Reading Your X-Angles and Storing it in r8
lwz r9, r4, 0x218 #Reading Your Y-Angles and Storing it in r9
lwz r10, r4, 0x21C #Reading Your Z-Angles and Storing it in r10
stw r8, r3, 0x144 #Writing Your X-Angles at G_Spawn + 0x144
stw r9, r3, 0x148 #Writing Your Y-Angles at G_Spawn + 0x148
stw r10, r3, 0x14C #Writing Your Z-Angles at G_Spawn + 0x14C
bl 0x001BCD10 #Calling G_Spawn
li r3, 0 #Value will be returned here
lis r4, 0x007F
addic r4, r4, 0x62B0 #Address where the model string is stored
bl 0x001BE3F0 #Calling G_SetModel
lis r5, 0x007F
addic r5, r5, 0x63C0 #Address where the turret type string is stored
bl 0x001C8820 #Calling G_SpawnTurret
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr


This is how i would do it :p

But the ppc for this looks a bit crappy, i would fix it up for be i would use if i was too :p

Thank you Smile
07-12-2014, 01:39 PM #6
Originally posted by SC58 View Post
You will need the TOC in the function be for calling this else it will just freeze you console

At start
lis r2, TOC Address
addic r2, r2, TOC Address

And this at the end of the function
lis r2, unk_734BE8
addic r2, r2, unk_734BE8

Sooo like this

    
stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r2, TOC Address
addic r2, r2, TOC Address
li r3, 0 #Client
li r4, 0x17 #DPAD_RIGHT
bl Key_IsDown #Sorry I don't have the address lmao
cmpwi r3, 0
beq 0x08
bl 0x38EDE8
------------Branchs here
lis r2, 0x734BE8
addic r2, r2, 0x734BE8
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr

At 0x38EDE8

stdu r1, -0x70(r1)
mflr r0
std r0, 0x70+arg_10(r1)
lis r3, 0x001B
addic r3, r3, 0xCD10 #0x001BCD10 (G_Spawn)
lis r4, 0x14E
addic r4, r4, 0x2200 #0x14E2200 (G_Client)
lwz r5, r4, 0x1C #Reading Your X Origin and Storing it in r5
lwz r6, r4, 0x20 #Reading Your Y Origin and Storing it in r6
lwz r7, r4, 0x24 #Reading Your Z Origin and Storing it in r7
stw r5, r3, 0x138 #Writing Your X-Origin at G_Spawn + 0x138
stw r6, r3, 0x13C #Writing Your Y-Origin at G_Spawn + 0x13C
stw r7, r3, 0x140 #Writing Your Z-Origin at G_Spawn + 0x140
lwz r8, r4, 0x214 #Reading Your X-Angles and Storing it in r8
lwz r9, r4, 0x218 #Reading Your Y-Angles and Storing it in r9
lwz r10, r4, 0x21C #Reading Your Z-Angles and Storing it in r10
stw r8, r3, 0x144 #Writing Your X-Angles at G_Spawn + 0x144
stw r9, r3, 0x148 #Writing Your Y-Angles at G_Spawn + 0x148
stw r10, r3, 0x14C #Writing Your Z-Angles at G_Spawn + 0x14C
bl 0x001BCD10 #Calling G_Spawn
li r3, 0 #Value will be returned here
lis r4, 0x007F
addic r4, r4, 0x62B0 #Address where the model string is stored
bl 0x001BE3F0 #Calling G_SetModel
lis r5, 0x007F
addic r5, r5, 0x63C0 #Address where the turret type string is stored
bl 0x001C8820 #Calling G_SpawnTurret
ld r0, 0x70+arg_10(r1)
mtlr r0
addi r1, r1, 0x70
blr


This is how i would do it :p

But the ppc for this looks a bit crappy, i would fix it up for be i would use if i was too :p


That wouldn't work either. GPR 2 is referred as RTOC, a pointer to the table. GPR 2 is also a read only anchor, no value can ever be set to the register. GPR 2 contains something like 0x0000200000000000, I can't remember for sure. Also, I see 0 point in even having a stack frame, you're never even using it...plus you're using definitions that aren't even declared (arg_10)

I suggest removing the stack frame, revising your code abit more.

This is how I would do it;
    
int spawnTurret(int ent)
{
__asm
{
; lrn2commentinppc
mr r31, r3 ; So we don't lose the data inside ent
bl G_Spawn
lfs f1, 0x18(r31) ;
lfs f2, 0x1C(r31) ; Storing the player entities origin
lfs f3, 0x20(r31) ; ~
lfs f4, 0x3C(r31) ;
lfs f5, 0x40(r31) ; Storing the player entities angles
lfs f6, 0x44(r31) ; ~
stfs f1, 0x138(r3) ;
stfs f2, 0x13C(r3) ; Setting the spawned entities origin
stfs f3, 0x140(r3) ; ~
stfs f4, 0x144(r3) ;
stfs f5, 0x148(r3) ;
stfs f6, 0x14C(r3) ; Setting the spawned entities angles
mr r28, r3 ; So we don't lose the data returned from G_Spawn
lis r3, 0x007F@h
ori r3, r3, 0x62B0@l
bl G_ModelIndex ; Getting the model index
sth r3, 0x168(r2Cool Man (aka Tustin) ; Setting the model
mr r3, r28
lis r4, 0x007F@h
addi r4, r4, 0x63C0@l
bl G_SpawnTurret ; cod4 it only has 2 params, possibily could have changed since then
blr ; Returning the spawned turret, stopping the function from further more continuing.


}
}

The following 3 users say thank you to Bitwise for this useful post:

ItsLollo1000, Shark
07-12-2014, 05:08 PM #7
SC58
Former Staff
Originally posted by Bitwise View Post
That wouldn't work either. GPR 2 is referred as RTOC, a pointer to the table. GPR 2 is also a read only anchor, no value can ever be set to the register. GPR 2 contains something like 0x0000200000000000, I can't remember for sure. Also, I see 0 point in even having a stack frame, you're never even using it...plus you're using definitions that aren't even declared (arg_10)

I suggest removing the stack frame, revising your code abit more.

This is how I would do it;
    
int spawnTurret(int ent)
{
__asm
{
; lrn2commentinppc
mr r31, r3 ; So we don't lose the data inside ent
bl G_Spawn
lfs f1, 0x18(r31) ;
lfs f2, 0x1C(r31) ; Storing the player entities origin
lfs f3, 0x20(r31) ; ~
lfs f4, 0x3C(r31) ;
lfs f5, 0x40(r31) ; Storing the player entities angles
lfs f6, 0x44(r31) ; ~
stfs f1, 0x138(r3) ;
stfs f2, 0x13C(r3) ; Setting the spawned entities origin
stfs f3, 0x140(r3) ; ~
stfs f4, 0x144(r3) ;
stfs f5, 0x148(r3) ;
stfs f6, 0x14C(r3) ; Setting the spawned entities angles
mr r28, r3 ; So we don't lose the data returned from G_Spawn
lis r3, 0x007F@h
ori r3, r3, 0x62B0@l
bl G_ModelIndex ; Getting the model index
sth r3, 0x168(r2Cool Man (aka Tustin) ; Setting the model
mr r3, r28
lis r4, 0x007F@h
addi r4, r4, 0x63C0@l
bl G_SpawnTurret ; cod4 it only has 2 params, possibily could have changed since then
blr ; Returning the spawned turret, stopping the function from further more continuing.


}
}


you have to change the toc for ps3 mw2 else it will not work plus it dont matter as ps3 is just like 360 all that stuff u release that never gets used well this is one of them
07-12-2014, 06:12 PM #8
Notorious
Caprisuns Is Back
Originally posted by SC58 View Post
you have to change the toc for ps3 mw2 else it will not work plus it dont matter as ps3 is just like 360 all that stuff u release that never gets used well this is one of them

that is so true tears
07-12-2014, 08:55 PM #9
Originally posted by SC58 View Post
you have to change the toc for ps3 mw2 else it will not work plus it dont matter as ps3 is just like 360 all that stuff u release that never gets used well this is one of them


RTOC cannot be modified. Note that TOC & RTOC are not the exact same thing. RTOC is read only. Also, I never released anything there? I was telling him how I would do it, since his ASM is messy & it wouldn't have worked. Or was that suppose to be a comeback to that MW2 reply?
07-14-2014, 06:18 PM #10
Cool stuff mang

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo