P04 Custom Code

For discussion and distribution of custom code and hacks
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

P04 Custom Code

Post by ProfessWRX »

I've created a "patch" to give myself a performance shift control in car without an actual button.

To Turn On Performance Shift:
Press Throttle above 60%
Or
Turn Off Traction Control.
Or
Hold Brake and Press Throttle above 4%.

To Turn Off Performance Shift:
Move Gear Shift to Neutral or Park for 3 seconds.


The only 'issue' is that the neutral switch is only updated about every 3 seconds it seems so neutral must be held a bit long to turn off performance shift.


This is the code for 12588500. The code is stock until Byte 50659.

Code: Select all

ROM:0005063E     sub_5063E:                              ; CODE XREF: sub_5B878+4A2p
ROM:0005063E 000                 movem.l d0-d1/a4,-(sp)  ; Move Multiple Registers
ROM:00050642 00C                 movea.l a0,a4           ; Move Address
ROM:00050644 00C                 tst.b   (byte_FFFFA550).w ; Test an Operand
ROM:00050648 00C                 beq.s   loc_5065A       ; Branch if Equal
ROM:0005064A 00C                 move.b  #3,(a4)         ; Move Data from Source to Destination
ROM:0005064E 00C                 clr.b   (a1)            ; Clear an Operand
ROM:00050650 00C                 move.w  (word_FFFF9116).w,(pPerfShiftButtonDebounceTimer).w ; Move Data from Source to Destination
ROM:00050656 00C                 bra.w   loc_50694       ; Branch Always
ROM:0005065A     ; ---------------------------------------------------------------------------
ROM:0005065A
ROM:0005065A     loc_5065A:                              ; CODE XREF: sub_5063E+Aj
ROM:0005065A 00C                 tst.b   (pTransmissionShiftPattern).w ; Test If Performance Shift is On
ROM:0005065E 00C                 beq.s   loc_5066E       ; Branch if Off To Check for Turn On
ROM:00050660 00C                 tst.b   (pGear_or_PN_Drive_Status).w ; Test for Park/Neutral
ROM:00050664 00C                 bne.s   loc_50692       ; Branch if Not in Park/Neutral
ROM:00050666 00C                 moveq   #0,d1           ; Turn Off Performance shift
ROM:00050668 00C                 move.b  d1,(a4)         ; 
ROM:0005066A 00C                 bra.w   loc_50692       ; Exit
ROM:0005066E     ; ---------------------------------------------------------------------------
ROM:0005066E
ROM:0005066E     loc_5066E:                              ; CODE XREF: sub_5063E+20j
ROM:0005066E 00C                 clr.l   d0              ; Clear an Operand
ROM:00050670 00C                 tst.b   (pTractionControlButton).w ; Test For Traction Control Turned Off
ROM:00050674 00C                 bne.s   loc_5068E       ; Branch if Turned Off --> Turn ON performance shift
ROM:00050676 00C                 move.w  (pTPS_AD).w,d0  ; Check Throttle Position
ROM:0005067A 00C                 cmpi.b  #144,d0         ; 
ROM:0005067E 00C                 bhi.s   loc_5068E       ; Branch if Higher than 60% Throttle -----> Turn ON performance shift
ROM:00050680 00C                 cmpi.b  #35,d0          ; Check Throttle Position Again
ROM:00050684 00C                 bls.s   loc_50692       ; Branch if Below 4% throttle  ----> Exit and Leave Performance Shift OFF
ROM:00050686 00C                 btst    #7,(byte_FFFFAD16).w ; Test for Brake Pedal On
ROM:0005068C 00C                 beq.s   loc_50692       ; Branch if Not Braking --->  Exit and Leave Performance Shift OFF
ROM:0005068E
ROM:0005068E     loc_5068E:                              ; CODE XREF: sub_5063E+36j
ROM:0005068E                                             ; sub_5063E+40j
ROM:0005068E 00C                 moveq   #1,d1           ; Turn ON Performance Shift
ROM:00050690 00C                 move.b  d1,(a4)         ; 
ROM:00050692
ROM:00050692     loc_50692:                              ; CODE XREF: sub_5063E+26j
ROM:00050692                                             ; sub_5063E+2Cj ...
ROM:00050692 00C                 clr.b   (a1)            ;
ROM:00050694
ROM:00050694     loc_50694:                              ; CODE XREF: sub_5063E+18j
ROM:00050694 00C                 movem.l (sp)+,d0-d1/a4  ; 
ROM:00050698 000                 rts                     ;                       EXIT
ROM:00050698     ; End of function sub_5063E
Attachments
PerformanceShiftFinal12588500.txt
(1.7 KiB) Downloaded 191 times
Last edited by ProfessWRX on Sat Nov 18, 2023 3:08 am, edited 10 times in total.
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

Re: P04 Custom Code

Post by ProfessWRX »

I’m going to add a throttle only switch as well. Probably try it around 60% throttle switches in on also.
After that I think the meat of it is probably good to go.

Edit, Done.
Last edited by ProfessWRX on Fri Nov 10, 2023 1:24 am, edited 1 time in total.
User avatar
antus
Site Admin
Posts: 8253
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: P04 Custom Code

Post by antus »

I am not sure what you are showing us here? Is this a stock routine, or your code? Is it a patched piece of code? Against what OS? Is it supposed to be something someone else can use? I am not sure what is what. Tthere are no additional comments beyond what IDA auto generates for 68k instructions.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

Re: P04 Custom Code

Post by ProfessWRX »

antus wrote:I am not sure what you are showing us here? Is this a stock routine, or your code? Is it a patched piece of code? Against what OS? Is it supposed to be something someone else can use? I am not sure what is what. Tthere are no additional comments beyond what IDA auto generates for 68k instructions.
That's the subroutine I wrote for 12588500. I've uploaded a dif file for 12588500.

I've also commented the code above. Should be easy to follow for anybody now.
Last edited by ProfessWRX on Fri Nov 10, 2023 1:25 am, edited 1 time in total.
User avatar
antus
Site Admin
Posts: 8253
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: P04 Custom Code

Post by antus »

Cool, thanks :thumbup:
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

Re: P04 Custom Code

Post by ProfessWRX »

I've updated the above to include the throttle only activation, though it has NOT been tested.
I've also swapped all of this completely over to 12588500 so there's no more confusion.
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

Re: P04 Custom Code

Post by ProfessWRX »

Added in an Extra switch for Traction Control to turn ON performance shift. It does not turn it off.

Also, tested the heavy Throttle activation code in car above. Worked as expected.

After this is tested, I'm done with performance Mode switching. I will more than likely add in performance shift functionality as I need/want. (performance shift changes to fueling/timing etc.)
Last edited by ProfessWRX on Sat Nov 18, 2023 7:45 am, edited 1 time in total.
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

Re: P04 Custom Code

Post by ProfessWRX »

Traction Control Switch code works as expected.
User avatar
antus
Site Admin
Posts: 8253
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: P04 Custom Code

Post by antus »

good work :thumbup:
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
ProfessWRX
Posts: 139
Joined: Tue Oct 03, 2023 9:33 am
cars: 04 Monte SSSC
04 Tahoe
92 Trans Am
Location: AZ USA

Re: P04 Custom Code

Post by ProfessWRX »

Wrote code to flash the change oil and low fuel lights when kr is over a threshold.

Run into one issue. My car seems to be so well tuned to 87 that either I’m not knocking long enough or enough at all to turn them on.

I do know the code works as I tried it at zero knock threshold (greater or equal to) and it lights up.
I will run this code as is and try to heat soak and see if I can get activity.
The other possibility is the subroutine I hooked doesn’t run at WOT.

I’ll probably change the lights it flashes down the road but with pcm hammer having issues I cant pin down yet I’m afraid to flash more than I have to do this was the first lights I got to react.
Post Reply