Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: Translating heavy math code from c/c++ to pascal [ Award!! ]

  1. #11

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    100€ to the first person that makes it work!
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  2. #12

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    Delfi, what your asking isn't any trivial thing, especially given what you have provided. Some questions follow:

    Can you name the exact C/C++ files that you specifically need converted?
    Are you sure you have the exports proper for the methods you are calling?
    Can you give a SIMPLE sample that doesn't require hacking another project?
    * 2D top down a rectangle that "drives" around and shows what your looking for. As simple as you can make it.

    Update your RAR to include the latest source you have. No sense in us having to re-work your work by having to read/patch every reply.

    If that seems like too much to ask, then put your request on any of the bounty sites and see what happens. You might also try some of the Borland (sorry, Code Gear) News Groups.

  3. #13

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    Is there a particular reason about converting all dll source code and not using the dll itself, by translating header files only?
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  4. #14

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    Legolas: Perhaps, because i want to compile code on multiple platforms rather than just one i need to translate the code, rather than mess with c compiler and linking process on each platform?

    I'll put up the whole thing by the end of day in some more comfortable codebase to whoever wants to mess with the code.

    the translated header files btw work with the C dll (i don't think that includes fixed pascal dll header).
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #15

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    This is working older version which uses older dll version (it shows nice dynamics with proper physics constants tho)
    http://www.gtatools.com/TDC/Developm...%20c%20dll.rar

    This is delphi version, which uses C dll (works kinda, except the gearbox gear is always stuck in reverse)
    http://www.gtatools.com/TDC/Developm...sing%20dll.rar

    This is version using my (broken) translation of the dll code, this is what i'm trying to make work properly:
    http://www.gtatools.com/TDC/Developm...ranslation.rar

    Small hack to make glscene work with the models in demo apps:
    http://www.gtatools.com/TDC/Developm...cene%20fix.rar

    This is the dll source code (what i'm trying to translate), (requires parts of newton SDK examples code, translated c dll is there AS "TDC_RCV.pas", i think some records might be in rcv_records.pas):
    http://www.gtatools.com/TDC/Developm...dll%20code.rar

    any other questions? post here, or ask on msn (msn only: stdcall@volja.net)
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #16

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    So who's up the challenge?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  7. #17

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    I'd give it a go, but I need to find the time. too many things ont he go at the moment. Btw, not for the prize, as I have Delphi 1 somewhere.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #18

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    save the money I looked at your pascal C header conversion and everything looks fine...possible problems are...bool<->boolean...in C++ sizeof(bool) is compiler-specific (doesn't have to be 1 byte), sizeof(enum_type) is also compiler-specific and can be minimum size required to express the enumeration or fixed 32/64 bits....basicly the problem should be in field size/alignment....also in the original C source there is no packing directive so it defaults to the default of the compiler used which can also cause problems...

  9. #19

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    Quote Originally Posted by Setharian
    save the money I looked at your pascal C header conversion and everything looks fine...possible problems are...bool<->boolean...in C++ sizeof(bool) is compiler-specific (doesn't have to be 1 byte), sizeof(enum_type) is also compiler-specific and can be minimum size required to express the enumeration or fixed 32/64 bits....basicly the problem should be in field size/alignment....also in the original C source there is no packing directive so it defaults to the default of the compiler used which can also cause problems...
    err, what do you mean?? there is a problem in matrix math, the goal is to get the code translated into pascal and make it work, There is a bug in some math routines or some other code that i must have translated errorenous, i couldn't locate the error after 2 rewrites. I could use the c dll if i wanted to, and i can use it from delphi (see one of example apps) so that header has no byte alingment problem, but the one used in delphi translated project doesn't matter what alingment it has, since it is all native to delphi / fpc, isn't it?

    savage: there's now an additional 100€ award, not just copy of delphi 1.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  10. #20

    Translating heavy math code from c/c++ to pascal [ Award!! ]

    Quote Originally Posted by fire.tiger
    TDC_RCV.pas line 925 - procedure DriveTrainUpdate is strange.
    in C code is :

    Code:
    void DriveTrainUpdate&#40;TDriveTrain* pDTrain, float gas, int gear&#41;
    &#123;
    	float fActiveRPM;
    	static int counter = 0;
    	counter += 1;
    	float brakeCoef;
    	// telemetry
    	RCVehicle* pv = &#40;RCVehicle*&#41;pDTrain->pRcv;
    	dFloat* ts = pv->fTimeSlice;
    	int ofs = 45;
    
    	PrintDebug&#40;"-DriveTrainUpdate &#91;%d&#93;-\n", counter&#41;;
    in Pascal is :
    [pascal]
    procedure DriveTrainUpdate(var pDTrain: TDriveTrain; gas: single; gear: integer);
    var
    fActiveRPM: single;
    counter: integer;
    begin
    counter := 0;
    counter := counter + 1;

    // PrintDebug("-----DriveTrainUpdate [%d] -------\n", counter);[/pascal]


    I think there should be :

    [pascal]procedure DriveTrainUpdate(var pDTrain: TDriveTrain; gas: single; gear: integer);
    var
    fActiveRPM: Single;
    counter: Integer;
    brakeCoef: Single;
    pv: RCVehicle;
    ts: TFriction;
    ofs: Integer;
    begin
    counter := 0;
    Inc(counter);
    pv := pDTrain.pRcv;
    ts := pv.fTimeSlice;
    ofs := 45;[/pascal]


    Also from line 1019 it is strange...


    there should be in pascal this ( I think you forgot brakeCoef variable in there)

    This is just my short look.Maybe I'm wrong.
    I'll take deeper look inside...this is just first thing that I've seen...
    Unless I am mistaken, this code:
    Code:
    void DriveTrainUpdate&#40;TDriveTrain* pDTrain, float gas, int gear&#41;
    &#123;
    	float fActiveRPM;
    	static int counter = 0;
    	counter += 1;
    	float brakeCoef;
    	// telemetry
    	RCVehicle* pv = &#40;RCVehicle*&#41;pDTrain->pRcv;
    	dFloat* ts = pv->fTimeSlice;
    	int ofs = 45;
    
    	PrintDebug&#40;"-DriveTrainUpdate &#91;%d&#93;-\n", counter&#41;;
    initialize counter with 0 the very first time it runs (as it is static), and from then on each time it is called counter will be incremented by 1.

    With the pascal version below:

    [pascal]procedure DriveTrainUpdate(var pDTrain: TDriveTrain; gas: single; gear: integer);
    var
    fActiveRPM: Single;
    counter: Integer;
    brakeCoef: Single;
    pv: RCVehicle;
    ts: TFriction;
    ofs: Integer;
    begin
    counter := 0;
    Inc(counter);
    pv := pDTrain.pRcv;
    ts := pv.fTimeSlice;
    ofs := 45;[/pascal]

    This will always make counter become equal to +1 each run...

    this doesn't sound like the equivalent behavior at all...

    perhaps you could try defining counter as (local to the procedure)

    [pascal]Const
    counter: Integer = 0;
    [/pascal]

    or

    [pascal]Var
    counter: Integer = 0;[/pascal]

    counter may have to be a global constant/variable instead of local for it to work...you need to try both methods (local to the procedure first, then global) to see if they work for you.

    Hope this helps,
    cheers,
    Paul.

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •