News:

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

Main Menu

Recent posts

#11
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by Cas - October 10, 2025, 10:28:15 PM
I don't really have a problem with SDL. I think it's good. It just doesn't do what I want to do. It's good for SDL to exist because it makes a standard instead of letting tons of different libraries take over. That's a very good thing. But programming for SDL feels very different to me from programming in a language. The library takes over and you really are no longer writing the graphics code. I was a low level programmer in DOS. Now, for GNU/Linux, that's practically banned, so I try to do the closest to it that is possible and SDL is not it. SDL is not C... it's SDL. With SDL, I'd feel that I'm no longer writing programs for the OS, but I'm writing scripts for some program. "SavePNG" (or whatever it's called) -> Boom!  You have a PNG file. I don't like that. Then wanting to copy and run a 2MB program and having to download half a gigabyte from the internet for it to run.... Also not my type.
#12
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by Daniel3D - October 10, 2025, 09:20:31 PM
I know what why CAS doesn't want to use an SDL, and I'll try to give a simple example.

I like to fly RC planes, and there are several kind of people who fly planes at my club.
Two main groups are,
* those who built a plane piece by piece, cut and glue and paint for months to get is just the way they want..
And
* Those who buy a whole plane, mod it and go flying.

CAS is a programmer of the first kind.
He doesn't use libraries, if he needs one he will probably write it himself.
Takes more time but is more satisfying.

Simple DirectMedia Layer (SDL) is a cross-platform library providing low-level access to hardware via OpenGL and Direct3D, supporting Windows, macOS, Linux, ...
#13
Stunts Reverse Engineering / Re: Restunts repository - Git ...
Last post by Matei - October 10, 2025, 08:02:26 PM
Quote from: Cas on October 10, 2025, 04:52:28 PMthere are tons of SDL-based 3D graphics engines out there already.

Any example that can be used for Stunts? I mean besides the one I know about.

Quotebut when talking about graphics code, since C does not include that,

C compilers sometimes do, but using SDL is much better and also much better than what functions FreeBASIC offers. I don't understand what's your problem with SDL. DosBOX uses it as well as OpenTTD, Simutrans, TyrQuake, Fuse, practically all games that work on GNU/Linux and even NetSurf.

https://matei.one/idxchess.html

QuoteThe version above uses SDL for graphics, but the version for DOS/DOSBox, which is available below, uses some graphical functions available with Open Watcom, as SDL has no support for DOS.
#14
Custom Cars with Stressed / Re: Compatibility issue
Last post by Cas - October 10, 2025, 04:58:36 PM
X11 (or Wayland) is part of the OS. It comes installed with it unless you're using a server distro. SDL is not. FreeBasic is semantically abstract from graphics libraries: it can describe graphics code. C cannot. When you program graphics in C, you're not really programming in C. I like comprehensive graphics code.

FreeBasic, the language, has nothing to do with hardware (or software) support. If you write a program in FreeBasic, maybe the compiler will build it for Wayland or maybe not and in the future yes. I don't know. I don't have to worry about it because I can read the code and understand what it does. If needed, I can actually plug FreeBasic to SDL, although I think it does it wrap it under the syntax, which would be great. That's why I prefer the default graphics functions.
#15
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.
#16
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)
#17
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?)

#18
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?
#19
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 ::/

#20
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.