Stunts Forum

Stunts - the Game => Stunts Reverse Engineering => Topic started by: llm on February 12, 2022, 08:47:51 AM

Title: masm2c seems to work better and better
Post by: llm on February 12, 2022, 08:47:51 AM
https://github.com/xor2003/masm2c/issues/10#issuecomment-1037026893

QuoteFor example I already ported Test drive 3...
Title: Re: masm2c seems to work better and better
Post by: Ryoma on February 12, 2022, 09:36:32 AM
There are some demos here
https://github.com/gabonator/Education/tree/master/2021/CicoParser
Title: Re: masm2c seems to work better and better
Post by: Daniel3D on February 12, 2022, 09:51:00 AM
Quote from: llm on February 12, 2022, 08:47:51 AM
https://github.com/xor2003/masm2c/issues/10#issuecomment-1037026893

QuoteFor example I already ported Test drive 3...
llm, could you do it for stunts?
Title: Re: masm2c seems to work better and better
Post by: llm on February 12, 2022, 05:12:47 PM
Quote from: Daniel3D on February 12, 2022, 09:51:00 AM
Quote from: llm on February 12, 2022, 08:47:51 AM
https://github.com/xor2003/masm2c/issues/10#issuecomment-1037026893

QuoteFor example I already ported Test drive 3...
llm, could you do it for stunts?

Im a fullblown system developer, i can do nearly everything :)
My biggest problem that i have nearly no free time for anything except writing small forum posts :(
i hope xor2003 will also test his converter on stunts (he already used the asm source for testing)
Title: Re: masm2c seems to work better and better
Post by: Daniel3D on February 12, 2022, 05:58:38 PM
Quote from: llm on February 12, 2022, 05:12:47 PM
Quote from: Daniel3D on February 12, 2022, 09:51:00 AM
Quote from: llm on February 12, 2022, 08:47:51 AM
https://github.com/xor2003/masm2c/issues/10#issuecomment-1037026893

QuoteFor example I already ported Test drive 3...
llm, could you do it for stunts?
Im a fullblown system developer, i can do nearly everything :)
I know. That's why I asked 😂
But it seems that everyone who is even slightly capable is very busy.
Title: Re: masm2c seems to work better and better
Post by: alanrotoi on February 13, 2022, 12:19:01 AM
Quote from: llm on February 12, 2022, 05:12:47 PM
Quote from: Daniel3D on February 12, 2022, 09:51:00 AM
Quote from: llm on February 12, 2022, 08:47:51 AM
https://github.com/xor2003/masm2c/issues/10#issuecomment-1037026893

QuoteFor example I already ported Test drive 3...
llm, could you do it for stunts?

Im a fullblown system developer, i can do nearly everything :)
My biggest problem that i have nearly no free time for anything except writing small forum posts :(
i hope xor2003 will also test his converter on stunts (he already used the asm source for testing)

Maybe if we make a paypal donation ::) ::) ::) Kidding  ;D
Title: Re: masm2c seems to work better and better
Post by: llm on February 14, 2022, 12:27:22 PM
xor2003 is showing a small game and his Test Driver 3 Port:

https://www.youtube.com/watch?v=MzK9RVgeWGM

mas2c converts assembler or emulated code to assembler looking C code
that means the game still needs to be ported slowly - but that can be done under 64bit Windows/Linux in your prefered IDE/Editor

its runs partially on a special version of dosbox for hardware support etc. but nearly to no emulation
Title: Re: masm2c seems to work better and better
Post by: llm on February 19, 2022, 07:24:33 AM
xor2003 ported restunts! that means its nearly (game/sound code 100% but still using hardware emulation for sound/input/drawing) pure asm-looking C code but running pure under Windows

https://github.com/xor2003/libdosbox/tree/masm2c/src/custom/src_restunts

there are two flavors of masm2c

1. run the game in dosbox emulation, trace the code and then creates a "port" on the fly based on this trace
pro: it will more or less work with any game thats not to evil programmed
con: NO symbols like names etc. - the resulting C code looks more or less like assembler with just number offsets

2. parse MASM assembler source code and create the "port"
pro: symbols from the asm code are preserved so variables/labels etc. got the same name as in original asm
con: the source needs to be MASM/UASM compatible - currently that is not 100% the case - im working on that

current port is a in-between of 1 and 2

i hope he releases later a demo of his work so real stunts-pros can give it a try :)

Title: Re: masm2c seems to work better and better
Post by: Daniel3D on February 19, 2022, 11:15:20 AM
Does that mean we can build a version of stunts that is free from the 640k memory constraint?
Title: Re: masm2c seems to work better and better
Post by: llm on February 19, 2022, 12:39:46 PM
Quote from: Daniel3D on February 19, 2022, 11:15:20 AM
Does that mean we can build a version of stunts that is free from the 640k memory constraint?

no - the C code still fakes 16bit assembler behavior - so we are constraint the same way as were running under dos

but its not real 16bit code anymore - its just C code that looks like it

no ancient builds tools need, but a normal C/C++ compiler+debugger can be used, it runs nativly on windows/linux

that eases the porting alot

lets see how good the assembler-source will look
Title: Re: masm2c seems to work better and better
Post by: Daniel3D on February 19, 2022, 01:34:57 PM
If it can be freed from the memory constraints, then I think there are updates possible that are now unthinkable.
Title: Re: masm2c seems to work better and better
Post by: llm on February 19, 2022, 02:10:01 PM
Quote from: Daniel3D on February 19, 2022, 01:34:57 PM
If it can be freed from the memory constraints, then I think there are updates possible that are now unthinkable.

Your question makes not really sense, the current code is 16bit so the code itself constraint it to 640k, this can be only removed by porting the 16bit asm over to C, there are only micro differences between 16bit or 32bit C, but 16bit asm is totaly different to 32bit asm, because you directly doing the memory oprations in asm and C hides that

masm2c just make it able to copy over the semantic of the game code by replicating the original behavior in asm like functions but then the game code runs in 32bit

So its more or less the first step to ease porting or adding code, but only a full C port will get rid of all constraints






Title: Re: masm2c seems to work better and better
Post by: Daniel3D on February 19, 2022, 02:22:36 PM
Quote from: llm on February 19, 2022, 02:10:01 PM
Quote from: Daniel3D on February 19, 2022, 01:34:57 PM
If it can be freed from the memory constraints, then I think there are updates possible that are now unthinkable.

Your question makes not really sense,
That's probably because of my poor understanding of it.. but thank you for answering like you did.
Quote
So its more or less the first step to ease porting or adding code, but only a full C port will get rid of all constraints
Can't wait. I have plans for the code that might give the game another 30 years.
Title: Re: masm2c seems to work better and better
Post by: llm on February 21, 2022, 05:39:28 PM
first demo: https://filetransfer.io/data-package/ejyAdiV6#link

copy the files into a folder with a clean stunts 1.1 installation

the complete game-code (3d engine, sound) is running in 32/64bit (based on this very asm-looking C code that gets generated by masm2c)

only the sound/gfx hardware stuff is emulated by libdosbox (special fork of dosbox for masm2c)

Title: Re: masm2c seems to work better and better
Post by: xor2003 on February 21, 2022, 05:53:59 PM
Converted source code is here https://github.com/xor2003/libdosbox/tree/masm2c/src/custom/src_restunts

Yes, you can modify converted source code and it will be able to use more memory.
By default data is inside 640k memory structure but you can create new data outside. The asm-like code does not care there the data is located.
Title: Re: masm2c seems to work better and better
Post by: xor2003 on February 21, 2022, 06:30:18 PM
Next steps:
1. Make functions separate. Currently due cross jumps one code segment is one function
2. Translate structures

Function arguments are transfered over virtual registers. But new code not restricted
Title: Re: masm2c seems to work better and better
Post by: Daniel3D on February 23, 2022, 09:57:26 AM
Awesome. I really need to try this.
I hope this weekend will be better 🙂
Title: Re: masm2c seems to work better and better
Post by: llm on March 07, 2022, 08:03:12 AM
@Daniel3D
did you had time for testing?
Title: Re: masm2c seems to work better and better
Post by: Daniel3D on March 07, 2022, 08:24:26 AM
Quote from: llm on March 07, 2022, 08:03:12 AM
@Daniel3D
did you had time for testing?
No, unfortunately we got hit by Corona once again. I thought that would give me more time. But I was a tired wreck by the time the kids went to bed.
Title: Re: masm2c seems to work better and better
Post by: Daniel3D on March 07, 2022, 10:28:08 AM
Quote from: llm on March 07, 2022, 08:03:12 AM
@Daniel3D
did you had time for testing?
Ok, I had some time. So I've started the game and ran a few laps.

Although I do not see any problems with the game code, I do see some problems with the configuration of dosbox.
I've noticed that (my) game starts with 3.000 cycles. I normally run the game at 20.000 (5.000 for testing, but lower than that doesn't run smooth)
I also noticed here that the game sound is segmented. (like somebody is playing with the mute button). It might be related to the cycles.
And lastly, the game feels a bit slow. It might be related to the cycles as well.

Title: Re: masm2c seems to work better and better
Post by: Daniel3D on March 07, 2022, 10:30:03 AM
Afterthought, related to the DOSBox fork.
Does it run on linux?