Stunts Forum

Stunts - the Game => Stunts Reverse Engineering => Topic started by: alanrotoi on December 17, 2021, 01:27:56 AM

Title: Is it possible...?
Post by: alanrotoi on December 17, 2021, 01:27:56 AM
...to get a night sky?
Title: Re: Is it possible...?
Post by: Daniel3D on December 17, 2021, 08:19:35 AM
I might be wrong. But as far as I can understand the source..

When the sky box is loaded there's a colour set for the box. That can be changed.
It won't give you the moon and stars.
The horizon image will still have the blue sky.

Maybe the game allows for an alfa channel in the horizon, that would solve the blue on the horizon.

I think that we can make the skybox colour a variable in a similar way as with the needle colour.
But I don't know where to set it in a track file.

So similar to but not so easy as the needle color changes.
Title: Re: Is it possible...?
Post by: Daniel3D on December 18, 2021, 12:07:01 AM
I have looked up the part of the code that i remember.
I'm not sure if the color is set here, but there are a lot of skybox references.
https://bitbucket.org/dreadnaut/restunts/src/master/src/restunts/asmorig/seg003.asm#lines-6180 (https://bitbucket.org/dreadnaut/restunts/src/master/src/restunts/asmorig/seg003.asm#lines-6180)

loc_1D88E:
    mov     ax, material_clrlist_ptr
    mov     [bp+var_4], ax
    mov     bx, ax
    mov     ax, [bx+22h]
    mov     skybox_sky_color, ax
    mov     ax, [bx+20h]
    mov     skybox_grd_color, ax
    mov     ax, [bx+0C8h]
    mov     skybox_wat_color, ax
    mov     ax, dialog_fnt_colour
    mov     meter_needle_color, ax

This could also be something:
https://bitbucket.org/dreadnaut/restunts/src/master/src/restunts/asmorig/seg012.asm#lines-6504 (https://bitbucket.org/dreadnaut/restunts/src/master/src/restunts/asmorig/seg012.asm#lines-6504)

skybox_op_helper proc far
    var_A = byte ptr -10
     s = byte ptr 0
     r = byte ptr 2

    push    bp
    mov     bp, sp
    sub     sp, 7D0h
    push    si
    push    di
    mov     [bp+var_A], 1
    jmp     short loc_317FB
skybox_op_helper endp

So it is a bit more complicated than I remember. But i'm still sure it is possible.
But not if it is word the effort..
Title: Re: Is it possible...?
Post by: Duplode on December 18, 2021, 01:39:07 AM
Quote from: Daniel3D on December 18, 2021, 12:07:01 AM
I have looked up the part of the code that i remember.
I'm not sure if the color is set here, but there are a lot of skybox references.

Yup, it must be there or thereabouts. With respect to the first code snippet, note that if you divide 22h, 20h and C8h by two you get 16, 17 and 100 respectively, which are the material indexes (http://wiki.stunts.hu/index.php?title=Shape_materials) for sky, low ground and water. (I vaguely remember noticing these a long time ago; back then, I didn't go on to make a night mod because I was too lazy to prepare a matching set of night horizon bitmaps.)
Title: Re: Is it possible...?
Post by: alanrotoi on December 18, 2021, 05:07:23 AM
Anyway, to make it all night sky there must be edited the horizon too. I think this would be the easy part. Only an external editor like stressed I supose.
Title: Re: Is it possible...?
Post by: Daniel3D on December 18, 2021, 06:13:34 AM
Yes, but that would be a one time charge. You would be stuck with it until you change it again.
If the horizon image can have a alpha channel. then we could remove the sky from the pictures.
That may solve it.

So changes in color can probably be done.
Night sky will still be difficult to do.
The lighting of stunts doesn't change.. so clouds and objects are brightly lit up.
Title: Re: Is it possible...?
Post by: Cas on December 18, 2021, 10:54:13 PM
I think it'd look pretty weird because of the illumination of everything else, but setting the sky colour to black definitely is possible. Alpha channel cannot be used because Stunts works with an indexed colour palette. There is mask-based transparency, like Stunts uses in the dashboard, but it definitely does not do this with landscapes. Anyway, dedicated night landscapes could be made as described.

This is one of the matters that really makes me want to find the way to move forward with that engine, because it'd allow so many things that are not possible or won't work well with the original engine.
Title: Re: Is it possible...?
Post by: Overdrijf on January 11, 2022, 07:44:36 PM
Quote from: alanrotoi on December 18, 2021, 05:07:23 AM
Anyway, to make it all night sky there must be edited the horizon too. I think this would be the easy part. Only an external editor like stressed I supose.

I tried making an edited horizon ones. The game just didn't load the world and gave some sort of error, even though I had replaced one of the original horizon files (except of course not having the compressed file type) with it and had made sure the dimensions and mystery bites were the same as for an original skyline. My suspicion at the time was that an uncompressed Skyline might be too big and overflow some sort of value or the game is hardwired to only look for the compressed filetype.

Or maybe I just screwed up because I don't know enough about computers...
Title: Re: Is it possible...?
Post by: Cas on January 18, 2022, 02:31:03 AM
Your hypothesis sounds very reasonable to me. Of course, I"m just guessing, but I think it could be just that
Title: Re: Is it possible...?
Post by: Daniel3D on January 18, 2022, 09:00:13 AM
Quote from: Overdrijf on January 11, 2022, 07:44:36 PM
Quote from: alanrotoi on December 18, 2021, 05:07:23 AM
Anyway, to make it all night sky there must be edited the horizon too. I think this would be the easy part. Only an external editor like stressed I supose.
My suspicion at the time was that an uncompressed Skyline might be too big and overflow some sort of value or the game is hardwired to only look for the compressed filetype.
I tested this and it doesn't. Saving the horizon file as VSH with stressed and removing the PVS makes no difference in the game.
There is something about the mystery bytes and the images, though. And I can't figure it out (yet) .
All horizons have different scaled images and offsets. Most notably in CITY.
COUNTRY seems most normal but also has little details.
DESERT has a the same as CITY, sce4 seems to be a mirrored detail of sce2... don't know.

I think that editing the existing images and keeping the detentions is safe until we know more.