Stunts Forum

Stunts - the Game => Stunts Reverse Engineering => Topic started by: earok on March 13, 2023, 01:39:22 AM

Title: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: earok on March 13, 2023, 01:39:22 AM
Thought this may be of some interest here - I did some experiments converting some of the DOS custom cars to Amiga, details are at English Amiga Board (https://eab.abime.net/showthread.php?p=1600245#post1600245).

I don't know if I'll do any more on the project, I got stuck on the dashboard graphics (which seem to be crunched in a custom format, and presumably are VERY different to the DOS format anyway). But in brief, I discovered:

- The resource files are identical to the DOS format, excepting that the byte order of words and longwords is flipped for the Motorola M68K processor.

- 3D shapes are almost identical (word/longword flipping not withstanding) except that the "reserved" part of the structure can have a value, and vertices are four words instead of three.
 
Having said that - I think they are just junk values, and the additional word of data on vertices is probably just to keep data aligned at multiples of 8.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: KyLiE on March 13, 2023, 06:34:23 AM
Even though the Amiga version of the game is considered inferior, any investigation into it is indeed very interesting.  Great work! :)
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Overdrijf on March 13, 2023, 07:40:12 AM
Quote from: KyLiE on March 13, 2023, 06:34:23 AMEven though the Amiga version of the game is considered inferior, any investigation into it is indeed very interesting.  Great work! :)

"Hi, welcome, I see this is your first post here, your game is inferior."  ;)


Hi earok, (welcome, I see this is your first post here!) This is really cool. I don't know the first thing about the Amiga file formats, but your solution to the dashboard problem, substituting an original dashboard, is pretty clever, and will serve well at least until a conversion method is found, if ever.

Note that there are two problems with this:
1 The coordinates for the meter needles are in the car____.res file so in many cases your meters are now nonsense. Even when the dashboard was adapted from an original car and the meters are the same size and in the same place the speed and rpm scales may still have been altered. This can be fixed if tou have a way to edit the .res files. Does Carblaster or Carworks work on Amiga files?
2 The same story goes for the gear shifting coordinates. But if you change those to match the new dashboard you're also very subtly altering the behavior of the car, the time it takes to shift.

I wish you a lot of luck with the endeavor. Sounds like fun!
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Daniel3D on March 13, 2023, 09:29:43 AM
Hey earok, and welcome here.

Thank you for your research, you have answered a question posted recently.
See This topic  (https://forum.stunts.hu/index.php?topic=4049.0) on the question if custom cars can be ported to the Amiga version.

Edit (after reading the Amiga forum post and realising that you were way ahead if where I thought you'd be)
If we know how they dashboars are different I think we could automate it and make a full converter.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: KyLiE on March 13, 2023, 09:44:17 AM
Quote from: Overdrijf on March 13, 2023, 07:40:12 AM
Quote from: KyLiE on March 13, 2023, 06:34:23 AMEven though the Amiga version of the game is considered inferior, any investigation into it is indeed very interesting.  Great work! :)

"Hi, welcome, I see this is your first post here, your game is inferior."  ;)

That certainly isn't what I was insinuating.  I was actually referring to a few comments on his original thread (https://eab.abime.net/showthread.php?t=113800) on the English Amiga Board.  I'm sorry if that was the impression I gave. :(
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Daniel3D on March 13, 2023, 11:26:21 AM
Ok. As far as I understand now you made a converter for the 3D shape. There is no conversion yet for dashboard.
What I don't see clearly is what you do with the res file.
The res file contains information that is used in the dashboard and the performance values.
 If you use a dashboard of another car you need a matching res file.. (same number of gears, same type of speedometer.)

So you made something amazing, but I don't think we are there yet. But I believe now that I can be done.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Cas on March 13, 2023, 10:46:38 PM
Very good work!  I would like to take a look at the Amiga dashboard format to see if I can understand it and maybe help. Is it a compressed format?
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Duplode on March 13, 2023, 11:11:17 PM
Hello and welcome, @earok ! This is a very interesting project. In particular, it can be very useful for the mods planned by Striker (https://forum.stunts.hu/index.php?topic=4056.msg87684;topicseen#msg87684) :)

Quote from: Daniel3D on March 13, 2023, 11:26:21 AMWhat I don't see clearly is what you do with the res file.
The res file contains information that is used in the dashboard and the performance values.
 If you use a dashboard of another car you need a matching res file.. (same number of gears, same type of speedometer.)

earok's progam also converts the CAR*.RES files to the Amiga format (https://github.com/earok/Stunts_DOS2Amiga/blob/664922c31d7700e01f9d7e0eb410a568e1c819d9/Stunts_DOS2Amiga/Program.cs#L358). That being so, this can be dealt with by adjusting the speedometer coordinates and other such things to match the new dashboard, as it used to be done in the days before Stressed, in the DOS file, and then running the converter. (Just remember to keep the spacing between the positions of the gear knob the same, as that actually affects car behaviour by changing the time it takes to shift gears.)
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: earok on March 16, 2023, 02:32:15 AM
I'm so sorry I missed all of these messages! I thought I had notifications set on this thread.

I did notice the needles etc didn't line up between the custom dashboard and the Amiga original, but I hadn't even thought of the idea of fixing the dashboard by copying the original Amiga dashboard settings into the RES file. I probably should add that to the utility if we can't solve the dashboard conversion issue.

I'll try to take another look at dashboards in the next few days. From memory, they were compressed in a way that I couldn't immediately recognise, it didn't have a header etc. But I'm assuming that the Amiga version will accept uncompressed dashboards so long as they're in the right format.

What I *might* be able to do is run the game, find the uncompressed dashboard in memory, and then dump that to give some clues as to what format is expected.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Cas on March 17, 2023, 12:22:41 AM
Quote from: earokWhat I *might* be able to do is run the game, find the uncompressed dashboard in memory, and then dump that to give some clues as to what format is expected.
I think this is a very good idea. If it got too complicated, taking a look at the compressed file may give a hint on what is expected if uncompressed. Especially, knowing the DOS uncompressed format to compare with.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: earok on March 24, 2023, 10:42:50 PM
Did a little bit further investigation:

In memory, once the dashboard files are unpacked, STDA (Acura) seems to contain these chunks.

dash
gbox
inm1
inm3
ins1
ins2
ins3
roof
whl1
whl2
whl3

(Notably there's no !CGA and !EGA chunks or anything similar, which makes sense - the Amiga version only supports a single graphics mode of 4 bitplanes / 16 colors)


STDB for the Acura is a little more curious:

!pal
dot
dot1
dot2
dota
gnab
gnob

All of those are present in the DOS version, except for the !PAL chunk.

This is where things start to get interesting. As I mentioned, the Amiga version is only running in 16 color mode, but when I took a screenshot it counted at least 22 colors.

What they appear to have done is implemented a unique 16 color palette for every dashboard, so even though it is running in 16 color mode it can display up to 32 colors at once, with a universal 16 color palette for the main game display and a custom set of 16 for every dashboard.

The Amiga "copper" co-processor allows you to change colors on the palette on a line, so the programming of the copper in 4D Sports Driving looks something like this:

- Set the colors to the top dashboard
- Wait for the scanline that starts rendering the main game display
- Set the colors to the main game palette
- Wait for the scanline that starts rendering the bottom dashboard
- Set the colors to the bottom dashboard


I think I'm not really going to have time to dig any deeper into it.

---

Another weird thing is - in the place in memory where the file size is supposed to be, instead we've got the ASCII characters "PPkc". When I did a search to find the significance, one of the first results was about Test Drive 2 on Amiga - https://eab.abime.net/showthread.php?p=1379496. I believe this suggests that the files are packed with "rpck" (like the 3D files are) but without the header that the 3D files have.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Daniel3D on March 24, 2023, 11:41:56 PM
QuoteAll of those are present in the DOS version, except for the !PAL chunk.
The dos version has that chunk as well. It's where the Custom pallet is stored.
That now I think about it might allow us to create dashboards with a different pallet than the base set..
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: KyLiE on March 30, 2023, 03:38:21 AM
Quote from: earok on March 24, 2023, 10:42:50 PMAll of those are present in the DOS version, except for the !PAL chunk.

@Daniel3D, I think you'll find this is correct.  The DOS version includes both !cg0 and !eg0 resources in the dashboard files, but not a !pal resource.

Quote from: earok on March 24, 2023, 10:42:50 PMI think I'm not really going to have time to dig any deeper into it.

What you have uncovered so far is still impressive.  I've always been interested in how developers of that era overcame palette limitations.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Daniel3D on March 30, 2023, 08:13:41 AM
Quote from: KyLiE on March 30, 2023, 03:38:21 AM
Quote from: earok on March 24, 2023, 10:42:50 PMAll of those are present in the DOS version, except for the !PAL chunk.

@Daniel3D, I think you'll find this is correct.  The DOS version includes both !cg0 and !eg0 resources in the dashboard files, but not a !pal resource.
They are not in the car resources I since noticed, so you are right about that.
But I have seen the !Pal pallet with the base stunts colours in an other resource.
Edit:  the stunts Wiki knew what I couldn't clearly remember.
The VGA palette itself is encoded as the !pal bitmap resource of SDMAIN.PVS
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Daniel3D on March 30, 2023, 09:17:09 AM
So, I don't know how the compare to each other. But I suspect that there is a relationship to the order of the colour.

Also. If the !pal in stunts is the colour palette used. What happens if we change colours there?
Maybe something worth checking out..
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Overdrijf on March 30, 2023, 09:30:48 AM
Quote from: Daniel3D on March 30, 2023, 09:17:09 AMSo, I don't know how the compare to each other. But I suspect that there is a relationship to the order of the colour.

Also. If the !pal in stunts is the colour palette used. What happens if we change colours there?
Maybe something worth checking out..

Ooh, that's an interesting thought. I don't think Stressed will allow it, but if we can make changes there that would be huge
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Daniel3D on March 30, 2023, 09:48:01 AM
Easy to test. One of the two whites is used for the text colour. Change those and we know if it can be done.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Striker on May 14, 2023, 03:27:55 PM
Hello earok, just discoverd the notification and this thread. Awesome!!! :D One question, which Version of .NET Framework does your converter need to run? I would like to convert and test some cars at once. :D
There comes no further CMD or a screen after allowed Windows 10 to start your program.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Duplode on May 14, 2023, 04:47:17 PM
Quote from: Striker on May 14, 2023, 03:27:55 PMOne question, which Version of .NET Framework does your converter need to run? I would like to convert and test some cars at once. :D
There comes no further CMD or a screen after allowed Windows 10 to start your program.

Trying the program here under Windows 10, I got it to run after installing the .NET 7 SDK (https://dotnet.microsoft.com/download) -- installing just the runtime wasn't enough.
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Striker on May 14, 2023, 10:23:28 PM
Thank you very much. Its working very nice! The custom cars are perfectly converted in the showroom. Only the stats text has a few glitches but that doesn't matter. :) I am curious which cars are working beside the fabulous Ikarus Bus. :)

Here is a little youtube short video: https://youtu.be/3kzGOOQshTo
Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Striker on May 19, 2023, 12:24:57 AM
Jaguar XJ220 is working fine on Amiga.  ;D
https://www.a1k.org/forum/index.php?threads/85902/#post-1690215
Can we make a list to sort out which custom cars are working and which not?

 ;D
Working:
Audi V8 Quattro DTM
BMW M3 E30 DTM
Ferrari 512 TR
Fiat 500 Abarth
GMC General '84 FLAG Truck Semi - Knight Rider !!!! :D
Ikarus 260 BUS
Jaguar XJ220
Lamborghini P114 Bravo
Lotus Esprit Turbo SE
Mercedes-Benz 190 E DTM
Porsche 959


 :-\
Working in Showroom but NOT working on the road:
Alfa Romeo SE048SP (LeMans) -> - Abnormal Termination - Shape Not Found
Ferrari F40
Ferrari Testarossa
McLaren MP4/4
Ponitac Firebirt KITT - Knight Rider

Title: Re: 4D Sports Driving Amiga formats + converting Stunts DOS cars to Amiga
Post by: Striker on August 11, 2023, 12:27:09 PM
I have again tested a few custom cars from Stunts for 4D Sports Driving on the Amiga.
Have fun with the cars. Todos are of course even better conversions or bug fixes for the non-functioning cars, dashboards and car sounds.

Here the download link to a full portable WinUAE version with everything included to go:

https://drive.google.com/file/d/1UtGCUxuBbNso9ewfzVH1Da6poeRBJBtp/view?usp=sharing

List of the cars:
Car Pack´s mit 28 Autos funktionieren!!!
Achtung 29 Autos können schon zu viel sein.
Es kommt sonst im Showroom zum Fehler Exception "Illegal Instruction" ($10) at ... occured.

Liste der getesteten/funktionierenden Stunts / 4D Sports Driving Custom Cars am Amiga:

Car Pack2:
==========
Alfa Romeo 164 ProCar
Bugatti EB110
Citroen CX25 GTI Turbo
Cizeta V16T
Ferrari 288 GTO
Ferrari 328 GTB/S
Ferrari 408
Ferrari F512M
Ferrari GTO Evoluzione
Ferrari Modulo 1970
Ferrari Pinin   
Ford Ranger Pickup 1988
Ford Sierra RS Cosworth
Jaguar XJR9 LM
Suka1.1 - Superkart
Toyota Corolla GTI
ZR1 GT3 (Corvette)


Car Pack1:
=============
Audi V8 Quattro DTM
BMW M3 E30 DTM
Ferrari 512 TR
Ferrari Mythos
Fiat 500 Abarth
Ford Thunderbird 1957
GMC General '84 FLAG Truck Semi - Knight Rider !!!! :D
Ikarus 260 BUS
Jaguar XJ220
Lamborghini Diablo
Lamborghini P114 Bravo
Lotus Esprit Turbo SE
McLaren F1
Mercedes-Benz 190 E DTM
Plymouth Fury 1958
Porsche 911 Turbo_final
Porsche 959

Standard Autos (11):
===============
*Lamborghini Countach
*Ferrari GTO
*Jaguar XJR9 IMSA
*Lancia Delta HF Integrale 16V
*Lamborghini LM-002
*Porsche 962 IMSA
*Porsche Carrera 4
*Porsche March Indy
*Corvette ZR1
*Acura NSX
*Audi Quattro Sport

Nicht funktionierend:
====================
Alfa Romeo SE048SP (LeMans) -> - Abnormal Termination - Shape Not Found
Audi Quattro Sport S1 -> Auto startet in der Luft, danach Exception "Integer Divide by Zero" ($2014) at $9B66C0 (ExpMem $846C0) occured.
Chevrolet Impala 1959 -> Funktioniert im Prinzip... Bei ganz wenig Ram sogar in der Aussenansicht mit wenig Details. Bei normaler Konfig aber Exception "Illegal Instruction" ($10) at... (ExpMem $477CC) occurred, sobald man mit C die Kameraperspektive wechselt.
Ferrari 308 GTS Quattrovalvole -> bereits im Showroom, auch ohne Extra-Autos installiert, Exception "Illegal Instruction" ($10) at $9798BE (ExpMem $478BE) occured.
Ferrari 637 Indy -> - Abnormal Termination - Shape Not Found
Ferrari 641 (F1) -> - Abnormal Termination - Shape Not Found
Ferrari F40 -> Auto startet in der Luft, Windschutzscheibe springt, Game Over.
Ferrari Testarossa -> Kurz nach dem man auf der Strecke ist: Exception "Integer Divide by Zero" ($2014) at...
McLaren MP4/4 -> - Abnormal Termination - Shape Not Found
Pontiac Firebird Turbo T/A KITT - Knight Rider -> - Abnormal Termination - Shape Not Found
Porsche 962 C Lemans -> Abnormal Termination, Shape not found!
Speedgate XSD -> stürzt im Showroom ab, Exception "Illegal Instruction" ($10) at $A occured.
Toyota Sprinter Trueno -> funktioniert beim ersten mal, verursacht danach aber (auch ohne Extra-Autos installiert) eine Exception "Address Error" ($200C) at $2F00A9 occured oder mit anderen Autos eine Exception "Illegal Instruction" ($10) at .. (ExpMem $4781A) occurd.
Xylocaine XF -> - Abnormal Termination - Shape Not Found

-----------------------------------------------------------------------

4D Sports Driving (am PC als Stunts bekannt) mit vielen Custom Tracks (meine persönliche Reinhold Strecke) und insgesamt !!29!! Autos!
Nicht vergessen im Optionsmenü -> Set graphic level -> Full einzustellen! :)

A = hoch schalten
Y = runter schalten
C = Camera

1) how many cars the game allows at max?  PC: 32, Amiga: 28
2) how many tracks per folder the game allows? PC: 128, Amiga: ?
3) how many replays? PC: 128, Amiga: ?