AndroidModLoader / JPatch

A little (yet) patch-mod that does a good thing!
MIT License
76 stars 4 forks source link

Few more updates #15

Closed bloodyplayer closed 8 months ago

bloodyplayer commented 1 year ago

Jpatch Dev's

BengbuGuards commented 1 year ago

@RusJJ I have an idea but I don't want to open another issue so I'll say here.

In PC version, emergency vehicles have two kinds of siren, the second siren can be actived by keeping pressing H while the default siren is on.

Mobile disabled it by bad code implement. I have an idea to reenable that:

  1. Place a 4-byte NOP at CVehicle::ProcessSirenAndHorn + 0x7A

  2. Place 0x2100 ( MOVS R1, #0 ) at CVehicle::ProcessSirenAndHorn + 0x7A + 4

  3. Place a 4-byte NOP at CVehicle::ProcessSirenAndHorn + 0xB0

That's "SecondSirenFix" at all.

RusJJ commented 1 year ago

That's "SecondSirenFix" at all.

Grab the artifact at https://github.com/AndroidModLoader/JPatch/actions/runs/5796999054 and test it if you like. Let me know!

BengbuGuards commented 1 year ago

@RusJJ I'm glad to see that you did it. I tried it :) The second siren works well but after releasing the button the siren state will be reversed. I think the code implement should be that:

aml->Write(pGTASA + 0x590132, "\xAF\xF3\x00\x80\x00\x21", 6);
aml->Write(pGTASA + 0x590168, "\xAF\xF3\x00\x80", 4); // It's NOP.W so it doesn't make glitch (maybe?)

Based on cleo code:

{$CLEO .csa}
0DD0: 11@ = get_label_addr @CVehicle_ProcessSirenAndHorn
0DD1: 11@ = get_func_addr_by_cstr_name 11@
11@ -= 1
11@ += 0x7A // MOVS  R1, #0 
0DD9: write_mem_addr 11@ value 0x8000F3AF size 4 add_ib 0 protect 1 // NOP.W
11@ += 4  // CMP.W  R1, R0,LSR#7
0DD9: write_mem_addr 11@ value 0x2100 size 2 add_ib 0 protect 1 // MOVS  R1, #0 
11@ += 0x32 // BICGT.W  R2, R2, #0x8000
0DD9: write_mem_addr 11@ value 0x8000F3AF size 4 add_ib 0 protect 1 // NOP.W

:CVehicle_ProcessSirenAndHorn
hex
    "_ZN8CVehicle19ProcessSirenAndHornEb" 00
end
RusJJ commented 1 year ago

BICGT.W R2, R2, #0x8000

This is not a NOP. NOP in Thumb/ThumbV2 execution set is BF00, or any MOV Rd,Rd. BICGT is a working instruction: https://developer.arm.com/documentation/ddi0406/cb/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-instructions/BIC--register-

BengbuGuards commented 1 year ago

This is not a NOP. NOP in Thumb/ThumbV2 execution set is BF00, or any MOV Rd,Rd. BICGT is a working instruction: https://developer.arm.com/documentation/ddi0406/cb/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-instructions/BIC--register-

Hmm, that's games original opcode, and what we are going to write is NOP. (0x8000F3AF) All the patch has been verified by me in IDA.

RusJJ commented 1 year ago

No, that's not the reason. Try now.

BengbuGuards commented 1 year ago

I tried again and the problem doesn't change. The third step (to make game don't reverse siren state when press the horn button for more than 0.2 second) was strange but my cleo code works properly. PlaceNOP(xxx, 2) will write 00 BF 00 BF in memory, but my idea is write AF F3 00 80 in memory. Or try that in IDA, change these bytes and decompile that function.

BengbuGuards commented 1 year ago

@RusJJ At least, I found the way to enable to control polmavs' searchlight.

Just hook CPad::HornJustDown(), check if the vehicle is a polmav, if so, call CTouchInterface::IsReleased(), if not, call original function.;)

BengbuGuards commented 1 year ago

Because, polmavs' vehicle class is 3, and HornJustDown will check that, so we need to do a special check.

And about the second siren fix, we really need to write a 64-bit NOP at pGTASA + 0x590168, or the code logic will be wrong(?).

bloodyplayer commented 1 year ago

Bros what is the answer for my request?

BengbuGuards commented 1 year ago

@bloodyplayer I see. For №2, that's by game design, no bug.

For crosshair of flamethrower, that's related to whether we are aiming.

And crouch ability, PC mixsets will not make us able to crouch with file ex, that's true.

About LV pay'n spray, even a small cleo script can do that.

At last, tanks won't shoot at some fixed point on screen, the crosshair will be useless. Or you need a useful crosshair, sadly we need to rewrite game's tank fire system at all, that's to difficult.(A PC mod did that, but still has many problems)

bloodyplayer commented 1 year ago

Thank u for ur reply guys I have two requests: 1) for jetpack instead of holding the screen for being idle in air instead add a lock button for being idle it would be easy for rotating the camera 360° and shooting 2) can the countermeasures of hydra can restored? For mobile war drum studios screwed that to implement in the game I think so 🤔

(shooting a minigun/flamethrower when Crouching it's animation is weird)

I hope u guys rock for gta sa mobile improvements

On Sun, Aug 13, 2023, 6:46 AM 小流汗黄豆 @.***> wrote:

@bloodyplayer https://github.com/bloodyplayer I see. For №2, that's by game design, no bug.

For crosshair of flamethrower, that's related to whether we are aiming.

And crouch ability, PC mixsets will not make us able to crouch with file ex, that's true.

About LV pay'n spray, even a small cleo script can do that.

At last, tanks won't shoot at some fixed point on screen, the crosshair will be useless. Or you need a useful crosshair, sadly we need to rewrite game's tank fire system at all, that's to difficult.(A PC mod did that, but still has many problems)

— Reply to this email directly, view it on GitHub https://github.com/AndroidModLoader/JPatch/issues/15#issuecomment-1676172829, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6U3YZL37BLS4BQGIPHSRSDXVATILANCNFSM6AAAAAA3AS34MM . You are receiving this because you were mentioned.Message ID: @.***>

bloodyplayer commented 1 year ago

Can we see idle cam in the next update it will be look cool Like in ps2/pc

RusJJ commented 1 year ago

we really need to write a 64-bit NOP at pGTASA + 0x590168, or the code logic will be wrong(?) Ok, i got some time to investigate on this. Yes, it should be 4-byte opcode, otherwise the next important opcode "EOR" will be always called no matter what (because of IT instruction).

Can we see idle cam in the next update it will be look cool Checked the game code, probably, that's possible. But dont wait for it now.

idle in air Most likely it's a glitch. Im not going to add this.

BengbuGuards commented 1 year ago

@RusJJ Works properly :)

Jetpack can be hovered in, just press Q and E on PC (some versions have bug, but no matter). It's also a command to look back, so pressing screen in mobile version makes jetpack to hover. Add a button to control is a good idea perhaps? Like control hydra's jet mode by button.

BengbuGuards commented 1 year ago

Add a button to control is a good idea perhaps? Like control hydra's jet mode by button.

After 5 minutes trying, I found a VERY simple method to let us hover jetpack by button:In CPad::GetJetpackHover() func, turn CTouchInterface::IsHeldDown(175, 1) to CTouchInterface::IsTouched(30, 1, 0)

3FA49A: MOVS  R0, #175 -> MOVS  R0, #30 ; We can use any widget id but 30 (nitro ctrl) is the best I think ;)
3FA4A0: BLX  j__ZN15CTouchInterface10IsHeldDownENS_9WidgetIDsEi -> BLX  j__ZN15CTouchInterface9IsTouchedENS_9WidgetIDsEP9CVector2Di ; Now we needn't long press
bloodyplayer commented 1 year ago

Add a button to control is a good idea perhaps? Like control hydra's jet mode by button.

After 5 minutes trying, I found a VERY simple method to let us hover jetpack by button:In CPad::GetJetpackHover() func, turn CTouchInterface::IsHeldDown(175, 1) to CTouchInterface::IsTouched(30, 1, 0)

3FA49A: MOVS  R0, #175 -> MOVS  R0, #30 ; We can use any widget id but 30 (nitro ctrl) is the best I think ;)
3FA4A0: BLX  j__ZN15CTouchInterface10IsHeldDownENS_9WidgetIDsEi -> BLX  j__ZN15CTouchInterface9IsTouchedENS_9WidgetIDsEP9CVector2Di ; Now we needn't long press

Will it available for players soon bro?

BengbuGuards commented 1 year ago

Will it available for players soon bro?

It's up to Killman to decide.

bloodyplayer commented 1 year ago

Yeah I know that

On Mon, Aug 21, 2023, 11:27 AM 小流汗黄豆 @.***> wrote:

Will it available for players soon bro?

It's up to Killman to decide.

— Reply to this email directly, view it on GitHub https://github.com/AndroidModLoader/JPatch/issues/15#issuecomment-1685697870, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6U3YZJ4ENBCB43O6EK6SSDXWL2FHANCNFSM6AAAAAA3AS34MM . You are receiving this because you were mentioned.Message ID: @.***>

BengbuGuards commented 1 year ago

It seems that my jetpack patch solution does not define the R2 register, will make a bug. So the best way is hook CTouchInterface::IsHeldDown, do a special check if player is on a jetpack, and call IsTouched(30, 0, 2).

@RusJJ What's more, boat Predator has a fixed gun can used by player and cops, but in mobile version, it has messed up. A very simple way to patch is that:

5E2940: MOVS  R1, #0 -> #1

And it will work when FixMissingShootBtnForSWAT option of JPatch is enabled.

bloodyplayer commented 1 year ago

Thanks for the tip!

On Wed, Aug 23, 2023, 1:04 PM 小流汗黄豆 @.***> wrote:

It seems that my jetpack patch solution does not define the R3 register, will make a bug. So the best way is hook CTouchInterface::IsHeldDown, do a special check if player is on a jetpack, and call IsTouched(30, 0, 2).

What's more, boat Predator has a fixed gun can used by player and cops, but in mobile version, it has messed up. A very simple way to patch is that:

5E2940: MOVS R1, #0 -> #15E2942: MOVS R2, #0 -> #1

And it will work whether FixMissingShootBtnForSWAT option of JPatch is enabled.

— Reply to this email directly, view it on GitHub https://github.com/AndroidModLoader/JPatch/issues/15#issuecomment-1689439506, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6U3YZL54A34KADRMB4JF23XWWXARANCNFSM6AAAAAA3AS34MM . You are receiving this because you were mentioned.Message ID: @.***>

bloodyplayer commented 8 months ago

Thank u for ur reply guys I have two requests: 1) for jetpack instead of holding the screen for being idle in air instead add a lock button for being idle it would be easy for rotating the camera 360° and shooting 2) can the countermeasures of hydra can restored? For mobile war drum studios screwed that to implement in the game I think so 🤔 #(shooting a minigun/flamethrower when Crouching it's animation is weird) I hope u guys rock for gta sa mobile improvements On Sun, Aug 13, 2023, 6:46 AM 小流汗黄豆 @.> wrote: @bloodyplayer https://github.com/bloodyplayer I see. For №2, that's by game design, no bug. For crosshair of flamethrower, that's related to whether we are aiming. And crouch ability, PC mixsets will not make us able to crouch with file ex, that's true. About LV pay'n spray, even a small cleo script can do that. At last, tanks won't shoot at some fixed point on screen, the crosshair will be useless. Or you need a useful crosshair, sadly we need to rewrite game's tank fire system at all, that's to difficult.(A PC mod did that, but still has many problems) — Reply to this email directly, view it on GitHub <#15 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6U3YZL37BLS4BQGIPHSRSDXVATILANCNFSM6AAAAAA3AS34MM . You are receiving this because you were mentioned.Message ID: @.>

Will these things get a response in future?

RusJJ commented 8 months ago

No, if you will beg for it every day

RusJJ commented 8 months ago

Some of the features will be in the future JPatch. If they are not, that means im not going to do this. Like asking me to add missing icon in a third-party main.scm ... 🤦