Trying to figure out how P59 axis's are referenced and where

Disassembly, Reassembly, Tools and devleopment. Going deep with Hardware and Software.
Post Reply
User avatar
vwnut8392
Posts: 68
Joined: Fri Feb 28, 2014 7:38 am
cars: AAN powered 83 audi 4000 quattro
1983 audi UR quattro
1992 GTI VR6

Trying to figure out how P59 axis's are referenced and where

Post by vwnut8392 »

Ive been looking at 12587603 disassembly some more and i cant seem to figure out how the axis's are referenced. i can see where the variables for the axis's are pulled from RAM but how the axis's are actually read are still a mystery to me. anyone have any insight on this?

im studying how the main high octane ignition table is read.

Code: Select all

OS1:00039FAC 3038 AEDA                           move.w  (RAM_RPM_2).w,d0 ; move RPM from RAM to register D0
OS1:00039FB0 3238 AEDC                           move.w  (RAM_MAF).w,d1  ; move MAF from RAM to register D1
OS1:00039FB4 7419                                moveq   #$19,d2         ; Move Quick
OS1:00039FB6 207C 0001 0E3A                      movea.l #SPARK_ADVANCE_KA_MAIN_OT_LOW_OCTANE,a0 ; This calibration determines base spark 'bad fuel' contribution to spark advance.
OS1:00039FB6                                                             ; Degrees
OS1:00039FBC 4EB9 0002 6994                      jsr     INTERPOLATE_TABLE ; Jump to Subroutine
OS1:00039FC2 3240                                movea.w d0,a1           ; Move Address
User avatar
antus
Site Admin
Posts: 8896
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: Trying to figure out how P59 axis's are referenced and where

Post by antus »

INTERPOLATE_TABLE is the 3D lookup routine. A0 is the address of the table, D0 (word) value searched on the X axis, D1 (word) is the value searched on the Y axis. d2 is the size of the of X axis, and the result comes back in D0 as word. So in the above, 19 hex is 25 cells of the table in the X direction which is the only dimension it needs to lookup the value.

If you look at the table, 25 cells in the X direction (400->8000).

The values are scaled before going in to the routine to take into account the axis so the lookup function does not need to know the axis beyond the X size.

So RAM_RPM2 is really RAM_RPM_SCALED and RAM_MAF is RAM_AIR_GPC_SCALED (or something like that). Where GPC=Grams Per Cylinder.

You'll find the scaling code between the ADC read and what writes it to that location in RAM. And all the rest of high and low octane scaling code, just to really keep you on your toes.
Attachments
Screenshot 2024-07-01 180733.png
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
1fast72nova
Posts: 7
Joined: Fri May 31, 2024 4:37 am
cars: 72 nova

Re: Trying to figure out how P59 axis's are referenced and where

Post by 1fast72nova »

So... If it was 1a instead of 19 it would automatically jump to the first cell of the next row? In other words it reads the table as a single row essentially?
Or am I misunderstanding and it jumps 25 cells depending on the y axis lookup.
1fast72nova
Posts: 7
Joined: Fri May 31, 2024 4:37 am
cars: 72 nova

Re: Trying to figure out how P59 axis's are referenced and where

Post by 1fast72nova »

antus wrote: Mon Jul 01, 2024 6:53 pm INTERPOLATE_TABLE is the 3D lookup routine. A0 is the address of the table, D0 (word) value searched on the X axis, D1 (word) is the value searched on the Y axis. d2 is the size of the of X axis, and the result comes back in D0 as word. So in the above, 19 hex is 25 cells of the table in the X direction which is the only dimension it needs to lookup the value.

If you look at the table, 25 cells in the X direction (400->8000).

The values are scaled before going in to the routine to take into account the axis so the lookup function does not need to know the axis beyond the X size.

So RAM_RPM2 is really RAM_RPM_SCALED and RAM_MAF is RAM_AIR_GPC_SCALED (or something like that). Where GPC=Grams Per Cylinder.

You'll find the scaling code between the ADC read and what writes it to that location in RAM. And all the rest of high and low octane scaling code, just to really keep you on your toes.
Do you mind elaboration, maybe with another example further down the table?
User avatar
vwnut8392
Posts: 68
Joined: Fri Feb 28, 2014 7:38 am
cars: AAN powered 83 audi 4000 quattro
1983 audi UR quattro
1992 GTI VR6

Re: Trying to figure out how P59 axis's are referenced and where

Post by vwnut8392 »

antus wrote: Mon Jul 01, 2024 6:53 pm INTERPOLATE_TABLE is the 3D lookup routine. A0 is the address of the table, D0 (word) value searched on the X axis, D1 (word) is the value searched on the Y axis. d2 is the size of the of X axis, and the result comes back in D0 as word. So in the above, 19 hex is 25 cells of the table in the X direction which is the only dimension it needs to lookup the value.

If you look at the table, 25 cells in the X direction (400->8000).

The values are scaled before going in to the routine to take into account the axis so the lookup function does not need to know the axis beyond the X size.

So RAM_RPM2 is really RAM_RPM_SCALED and RAM_MAF is RAM_AIR_GPC_SCALED (or something like that). Where GPC=Grams Per Cylinder.

You'll find the scaling code between the ADC read and what writes it to that location in RAM. And all the rest of high and low octane scaling code, just to really keep you on your toes.
thank you for explaining that! makes a lot more sense now! so looking at this if you wanted to changed the Y axis to manifold pressure instead of grams per cylinder all i would have to do is change what is looked up in RAM instead?
User avatar
AngelMarc
Posts: 104
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Trying to figure out how P59 axis's are referenced and where

Post by AngelMarc »

Unless I'm missing a lot (which is likely), looks like forcing speed density is as simple as replacing one RAM address at ROM address 0x7a8e4.
Replace ffffaedc with fffff2bc. Apparently, I don't know.
Don't stress specific units.
User avatar
antus
Site Admin
Posts: 8896
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: Trying to figure out how P59 axis's are referenced and where

Post by antus »

Thats probably a subject for another thread, but yes if you disconnect the MAF and trigger a DTC and then mask the CEL so you dont get a light, you can get speed density with no code patch. But you loose... I think its traction control? So if your location is correct, you'd need to update the OS Checksum, consider DTCs (assuming you want to remove the MAF), and patch any other part of the OS that disables with the error to restore normal operation. Not too much code but more than one patch.
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
User avatar
AngelMarc
Posts: 104
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Trying to figure out how P59 axis's are referenced and where

Post by AngelMarc »

You loose Open throttle spark too apparently. Stuck at 4800 RPM timing and no octane/knock scale.
Don't stress specific units.
User avatar
NSFW
Posts: 741
Joined: Fri Feb 02, 2018 3:13 pm

Re: Trying to figure out how P59 axis's are referenced and where

Post by NSFW »

Just thinking out loud here...

The SD math writes a grams-per-second value here: 0xFFB0FA
The MAF sensor writes its grams-per-second value here: 0xFFB0F8
PID 0010 is the final MAF value. I haven't looked at the code for a LONG time but I think it just reads from a single RAM address, which is shared by all other code that needs a MAF value, including (I think?) the code that calculates the load (g/cyl) value for the spark table.

If you can find a function that reads from SD-MAF and sensor-MAF addresses, and writes to the final-MAF address, that's the function you'd want to modify to force full-time MAF or full-time SD. Hopefully it won't be too hard to find. But if you can find it, I suspect that it will be straightforward to just force it to copy your chosen input value into the final-MAF address.
Please don't PM me with technical questions - start a thread instead, and send me a link to it. That way I can answer in public, and help other people who have the same question. Thanks!
User avatar
AngelMarc
Posts: 104
Joined: Sat Apr 08, 2023 9:23 pm
cars: A CB450 running to 8,000RPM with a P59.

Re: Trying to figure out how P59 axis's are referenced and where

Post by AngelMarc »

I think I found a crude example of that, but my main concern was the loss of higher RPM tables.
Found 2 spots to replace an address. It would fuck up a lot of things, but still be usable if I'm not missing more.
https://www.facebook.com/marc.wolfe.568 ... Jquwwzh6nl
Haven't opened Ghidra since.
Don't stress specific units.
Post Reply