C development and patching for P01/P59

User avatar
turbo_v6
Posts: 512
Joined: Wed Apr 11, 2018 8:50 am
Contact:

Re: C development and patching for P01/P59

Post by turbo_v6 »

Yeah, now I just have to figure out the correct gcc commands to get a asm file compiled.
LS1 Boost OS Version 5 Available Here. For feature suggestions post in here Development Thread.
User avatar
antus
Site Admin
Posts: 9004
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: C development and patching for P01/P59

Post by antus »

start with the pcmhammer kernel in the pcmhammer repo, get that building then replace the kernel code with your code

https://github.com/LegacyNsfw/PcmHacks/ ... op/Kernels
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
Gampy
Posts: 2332
Joined: Sat Dec 15, 2018 7:38 am

Re: C development and patching for P01/P59

Post by Gampy »

Actually, for assembly the PcmHacks/kernels build system would need a little twisting ...

Try this ...
Build.cmd - Slightly twisted for Assembly
Clean.cmd - For keeping tidy
kernel.S - Empty source
kernel.ld - Linker script
AssemblyKernelBuildSystem.zip
(2.13 KiB) Downloaded 206 times
You know me, I'll answer any questions I can.
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
turbo_v6
Posts: 512
Joined: Wed Apr 11, 2018 8:50 am
Contact:

Re: C development and patching for P01/P59

Post by turbo_v6 »

Awesome thanks! That's a great starting point.
LS1 Boost OS Version 5 Available Here. For feature suggestions post in here Development Thread.
User avatar
turbo_v6
Posts: 512
Joined: Wed Apr 11, 2018 8:50 am
Contact:

Re: C development and patching for P01/P59

Post by turbo_v6 »

Well I still can't figure out how to create a label that allows me to easily reference addresses.

I've found documentation that shows how to do it but it doesn't want to compile.

I have a simple function I made to test with:

Code: Select all

MAPUpdate:
	lsr #1,%d3;
	move %d3, (0xFFFFAEEC).w;
	nop;
	nop;
	bra Test;
	nop;
Test:
	nop;
	rts;
I've tried to put this at the beginning at it won't work even though multiple sources have it formatted in this way.

Code: Select all

MAP EQU 0xFFFFAEEC;

MAPUpdate:
	lsr #1,%d3;
	move %d3, (MAP).w;
	nop;
	nop;
	bra Test;
	nop;
Test:
	nop;
	rts;

The branch label works which is great because I've previously had to calculate all the branch values which is really annoying and time consuming.
LS1 Boost OS Version 5 Available Here. For feature suggestions post in here Development Thread.
User avatar
Gampy
Posts: 2332
Joined: Sat Dec 15, 2018 7:38 am

Re: C development and patching for P01/P59

Post by Gampy »

Code: Select all

.equ MAP, 0xFFFFAEEC
Edit: Also, loose the semi-colons.
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
User avatar
turbo_v6
Posts: 512
Joined: Wed Apr 11, 2018 8:50 am
Contact:

Re: C development and patching for P01/P59

Post by turbo_v6 »

Sweet!

Yeah I did that already. Seems to work either way.
LS1 Boost OS Version 5 Available Here. For feature suggestions post in here Development Thread.
User avatar
NSFW
Posts: 745
Joined: Fri Feb 02, 2018 3:13 pm

Re: C development and patching for P01/P59

Post by NSFW »

I still think we can find some compiler switches to make C into usable asm, but I'll admit I haven't tried with th M68k compiler. I got reasonable good code from a different Gnu compiler that I used with Subaru though.

For existing addresses in memory I did this:

Code: Select all

#define pRPM                      ((float*)0xFFFF51F8)
#define pSpeed                    ((float*)0xFFFF51E8)
#define pFlagsRevLimit_0x80       ((char*) 0xFFFF5A40)
#define pCruiseFlagsA             ((char*) 0xFFFF4D65)
#define pLeftTgvVoltage           ((float*)0xFFFF2D2C)
#define pThrottlePedal            ((float*)0xFFFF5134)
And then wrote code like this:

Code: Select all

	// Check the clutch switch
	if (((*pCruiseFlagsA & 0x80) == 0) ||
		(pRamVariables->RevMatchState == RevMatchCalibration))
	{
		// Normal rev limiter thresholds.
		fuelCut = RedlineCut;
		fuelResume = RedlineResume;
	}
	else
	{
		if (*pSpeed > FlatFootShiftSpeedThreshold)
		{
			if (*pThrottlePedal > 90.0f)
			{
For the P01 / P59, everything is done with integer math, so instead of float you'd have something like:
#define pThrottlePedal ((uint16_t*)0xFFnnnnnn)

For variables that I created in memory, I defined a RamVariables struct, and did this:

Code: Select all

#define pRamVariables             ((RamVariables*) 0xFFFFA000)
And...

Code: Select all

pRamVariables->VariableName = foo;
foo = pRamVariables->OtherVariableName;
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
turbo_v6
Posts: 512
Joined: Wed Apr 11, 2018 8:50 am
Contact:

Re: C development and patching for P01/P59

Post by turbo_v6 »

Is there any reasonable documentation for the compiler? I was having a really hard time finding anything.

I found this: https://ftp.gnu.org/old-gnu/Manuals/gas ... /as_7.html

Edit: I found this page helpful for more syntax questions... https://ftp.gnu.org/old-gnu/Manuals/gas ... tml#SEC214
Last edited by turbo_v6 on Thu Mar 10, 2022 5:02 am, edited 1 time in total.
LS1 Boost OS Version 5 Available Here. For feature suggestions post in here Development Thread.
User avatar
Gampy
Posts: 2332
Joined: Sat Dec 15, 2018 7:38 am

Re: C development and patching for P01/P59

Post by Gampy »

Command line help is the best, then general GNU docs is all I know of, I'm sure there is others ...
Intelligence is in the details!

It is easier not to learn bad habits, then it is to break them!

If I was here to win a popularity contest, their would be no point, so I wouldn't be here!
Post Reply