News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Recent posts

#41
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by Cas - October 10, 2025, 04:52:28 PM
@dstien - That's amazing. Yeah, I'd like to be able to write a function that performs exactly the same and the physics engine and compare the car positions. Your porting will be a lot more optimal, of course. I just want to be able to see that I understand it and have it in my mind analytically, not just copying the code.

But mostly yes, my interest is on putting that in the core and build shells out from scratch. I wonder how much is in the core that limits what can be added outside. For example, if there are references to the current memory distribution of track elements, maybe it isn't possible to make a bigger map without modifying the core. But perhaps the required changes would be minimal. I don't know.

@Matei - I think here is a misunderstanding. I'm going to get a little philosophical here, but just to clarify... Yes, my engine is a proof of concept. I wrote it to build and see that it actually did the thing and I didn't make any effort to make it fast enough or to perfectly render things without glitches, so it's not ready be to put on a game.

Now, this unfinished nature of it has nothing to do with it being FreeBasic. Because it is a graphical engine, it is impossible to port it to C, as C has no graphics functions. What you surely mean is to port it to SDL. I don't have much interest in doing that as there are tons of SDL-based 3D graphics engines out there already. They're not bad, but why reinvent the wheel?  I would like to create a new painter's algorithm based engine analog to Stunts' original and software based, like that of Stunts, that runs natively on modern systems and allows for adding some more things. That's it.

There's a difference between translating code between two programming languages and porting code between two compilers. Porting is about creating a source code that can be compiled with another tool chain and result in a different binary that can be run on a different platform. Translating has to do with the syntax, with the language. Libraries play no role in translation and there's no software efficiency optimisation in translating code. In terms of languages, considering the functions that are present in FreeBasic and C and their definitions, there is no superiority in one on the other. Maybe we could say FB is superior because it can do graphics comprehensively, while see cannot (as a language). In terms of the compiler, there are many C compilers, most of which have had much more work on than FreeBasic's and are likely to be more efficient, but when talking about graphics code, since C does not include that, the C compiler will just "copy and paste" from the 3rd party library, say, SDL, so if you make a game in FreeBasic or in C that uses SDL, efficiency will be the same as regards graphics.

Beyond superiority, there's a trend of preference towards the C language (syntactically) because it's more commonly used and you have more compiler options. This makes a lot of sense and I would recommend to follow suit for non-graphical projects.
#42
General Chat - ZSC / Re: Statistics!
Last post by Cas - October 10, 2025, 04:14:15 PM
Wow!  Another important historical detail for 4:00am!  8)
#43
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by llm - October 10, 2025, 02:00:01 PM
what i can see so far:

ax seems to be undefined if x and y = 0 in the asm routine

   
    int16_t a;
    __asm{
        mov ax,0
        push ax
        push ax
        mov ax,1234
        call int_atan2_asm
        add sp,4
        mov a,ax
    }
    printf("a:%d\n", a);
    return 0;

returns 1234

so the question is: does Stunts rely on this "random" behavior? and if - how to fake it in C?

- bx is not safed (could that be problematic in combination with C code calls?)

#44
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by llm - October 10, 2025, 10:41:04 AM
test

    const int16_t min = -2;
    const int16_t max = +2;
   
    for(int i = min; i < max; ++i)
    {
      printf("[%d](x=0,y=0) a: %d, c: %d\n", i, int_atan2_asm(0, 0),int_atan2(0, 0));
    }

    for (int16_t x = min; x < max; ++x)
    {
        for (int16_t y = min; y < max; ++y)
        {
            int16_t a = int_atan2_asm(x, y);
            int16_t c = int_atan2(x, y);
            printf("x=%d, y=%d -> C=%d, ASM=%d\n", x, y, c, a);
        }
    }

result

[-2](x=0,y=0) a: 0, c: 0
[-1](x=0,y=0) a: 0, c: 0
[0](x=0,y=0) a: 0, c: 0
[1](x=0,y=0) a: 0, c: 0
x=-2, y=-2 -> C=-384, ASM=-384
x=-2, y=-1 -> C=-332, ASM=-332
x=-2, y=0 -> C=-256, ASM=-256
x=-2, y=1 -> C=-180, ASM=-180
x=-1, y=-2 -> C=-436, ASM=-436
x=-1, y=-1 -> C=-384, ASM=-384
x=-1, y=0 -> C=-256, ASM=-256
x=-1, y=1 -> C=-128, ASM=-128
x=0, y=-2 -> C=512, ASM=512
x=0, y=-1 -> C=512, ASM=512
x=0, y=0 -> C=0, ASM=28 <======= ???
x=0, y=1 -> C=0, ASM=0
x=1, y=-2 -> C=436, ASM=436
x=1, y=-1 -> C=384, ASM=384
x=1, y=0 -> C=256, ASM=256
x=1, y=1 -> C=128, ASM=128

the asm code returns also 0 if i rotate the calls so first C then asm or the result-value of asm changes if i disable the C call complete

            int16_t c = int_atan2(x, y);
            int16_t a = int_atan2_asm(x, y);

maybe im calling the asm-code the wrong way but it only fails for 1 of thousands of calls?
#45
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by llm - October 10, 2025, 09:17:00 AM
Quote from: dstien on October 09, 2025, 07:44:31 PM
Quotecompile with current Watcom V2 on Windows for DOS 16bit Model small exe using wcl+wasm
the test run was done on a real DOS 6.22 on VMWare Player (because dosbox failed to run the complete test without hanging)

Does this include the fix I pushed the other day? Strangely I can't reproduce it on my end with dosemu2 or DOSBox. Could you attach the exe file? I'm keen to have a look.

no it didn't include the fix - with the fix i only get one difference on DOS, XP/Win7(32bit) running on VMWare

on x=0, y=0  the C code returns 0, asm returns 512

(building the C code for 32bit windows results also in 0 for x=0, y=0 )

but that does only happen in the loop with x/y not when calling the routines directly with 0/0 - the result of the asm code for 0/0 seems to be only non null in the x/y loop?

FYI: comparing all values from C with x/y -1000...1000 showing no difference between a 16 and 32bit build

Quotepeak values crashes both implementations

for me the testrun just takes ages on dosbox

my Test:

this i my free-standing test (i've copied the asm and C code into the test - quick & dirty):

https://filebin.net/gw4diq3oa6l2gas2/restunts2_tests.zip

for testing speed:

im using DOS 6.22 in VMWare Player because its super much faster - compared to dosbox - just install DOS in VMWarePlayer and share Files using a floppy image in VMWare, maybe a qemu+KVM DOS is similar fast, or just a 32bit Windows OS...

to create an floppy-image using linux

mkfs.msdos -C myfloppy.img 1440
mcopy -i myfloppy.img test16.exe ::/
mdir -i myfloppy.img ::/

#46
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by dstien - October 09, 2025, 07:44:31 PM
Quote from: Cas on October 06, 2025, 11:33:59 PMIs it possible to isolate the physical engine for analysis?

Yes, this was the motivation for the repldump utility. We took the code path that Stunts uses when loading a replay from the options menu and processes it to the end, then ripped away as much as we could without breaking it. Simulation still requires a fair bit of loading and initialisation. The old repldump was a bit hairy since we hadn't analysed enough to properly separate the graphics, audio and input initialisation. That's why it changes video mode on startup and throws a fatal error after processing in order to stop all the interrupts. clvn did a lot of analysis and porting since, so with the current knowledge I have streamlined repldump further.

The essential part is:
// ...initialisations...

while (gameconfig.game_recordedframes > state.game_frame) {
    input = td16_rpl_buffer[state.game_frame];
    state.game_frame++;
    player_op(input);
}
repldump is slightly more complicated because we want it to create the exact same game state as the original code, so it also handles the movement of an opponent, the cameras, explosions and FPS smoothing.

player_op() (debug symbol moveplayer) is translated to C in state.c in the original restunts repo. The inner function call to update_car_speed (doengine) is in statecar.c, and update_player_state (movecar) is in stateply.c. These are mostly 1:1 unanalysed ASM to C translations. I can't remember whether they are 100% complete. The other inner function calls upd_statef20_from_steer_input (dosteering) and update_grip (dohandling) are not ported, but these are fairly simple functions. My current focus in restunts2 is to start with the basic leaf functions of the simulation and work my way down the call stack so that all ported code is tested for correctness when it is included.

Quote from: llm on October 07, 2025, 10:08:55 AM
QuoteParticularly the database from the program whose vendor has a history of refusing to sell to people outside the infosec clique.

isn't that like the myth that IDA dropped DOS support (which is only true for IDA freeware versions)

i know serveral private people that bought an IDA license - like me - without any infosec background

Hehe, true. I got a bit carried away with my bombastic parroting of blog hearsay from 18 years ago. At least now I know that 50% of my IDA licence holding friends don't work in the sec biz.

Quote from: llm on October 08, 2025, 11:04:26 AMwill you also try to compare to the original implementation - something like int_atan2 disassembly + C port over the complete integer range or is something like that too much?

That's a good idea to catch corner cases. I added an "-x" option to the DOS build of the unit tests. The full range should be INT16_MIN + 1 .. INT16_MAX - 1 (peak values crashes both implementations), but it takes an eternity to run, so I just used -0x400 .. 0x400

Quote from: llm on October 08, 2025, 11:04:26 AMcompile with current Watcom V2 on Windows for DOS 16bit Model small exe using wcl+wasm
the test run was done on a real DOS 6.22 on VMWare Player (because dosbox failed to run the complete test without hanging)

Does this include the fix I pushed the other day? Strangely I can't reproduce it on my end with dosemu2 or DOSBox. Could you attach the exe file? I'm keen to have a look.
#47
Custom Cars with Stressed / Re: Compatibility issue
Last post by stanceboyCZ - October 09, 2025, 05:18:41 PM
where do i put the files?
#48
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by Daniel3D - October 09, 2025, 12:38:08 PM
Quote from: Matei on October 08, 2025, 11:07:37 AMCAS's graphics engine is in FreeBASIC, it's slow and it's not finished. You already have a usable graphics engine which includes CAS's part that reads tracks from Stunts, converted from FreeBASIC to C.

You are right. Still I personally prefer CAS his approach to the graphics. It isn't finished, maybe it is to slow and would need to be rewritten in C. But it it uses a painters algoritme like stunts. And that gives the same ambiance as the original.

CAS and I share the same opinion about what is unique about the game an should be preserved. That makes it easy to work with each other. I really like what you created and i think you did an amazing job on your games. It's is not what I'm personally looking for.

So that's why my first thought went to CAS. It was not intended to exclude you from this and I am genuinely interested in what it would do with your graphic engine. But that would mean you have to accept stunts pseudo physics.

QuoteWhy not just keep the track editor out as a separate program? Much easier.
That is true, but stunts has an track editor, so we want to keep it for future players to have one game that includes all. Including a build in car manager.
#49
General Chat - ZSC / Re: Statistics!
Last post by alanrotoi - October 08, 2025, 09:47:13 PM
There are 4 leading pipsqueaks about most races won.

You cannot view this attachment.


We could add Renato Biker who matched Ayrton from zct153 to zct166.
The closest to dethrone Duplode is still Renato Biker. He would need at best until zct329 (november 2028).

In zct166 we had three pipsqueaks leading with 23 races won each: Ayrton, Renato Biker and Duplode.
#50
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by Matei - October 08, 2025, 11:07:37 AM
Quote from: Daniel3D on October 08, 2025, 09:55:33 AMif we understand that part fully we can hook it to CAS his graphics engine,

CAS's graphics engine is in FreeBASIC, it's slow and it's not finished. You already have a usable graphics engine which includes CAS's part that reads tracks from Stunts, converted from FreeBASIC to C.

https://matei.one/idxscr.html

https://sourceforge.net/projects/simple3d/files/SDL_grf/

Documentation of the graphical functions included. You can combine the part that renders the graphics from SimcarStunts with the part that reads tracks from Stunts, in the same program. I already fixed the 3D models to be rendered properly. Next:

Quotereplace the track editor with a simplified version of bliss,

Why not just keep the track editor out as a separate program? Much easier.

Quoteand extend the track elements library with new and exciting possibilities.

Which I actually did from the start before using the tracks from Stunts - link above and I also made some programs to edit 3D models, also there.