Stunts Forum

Stunts - the Game => Stunts Reverse Engineering => Topic started by: Ryoma on August 22, 2021, 06:46:18 PM

Title: Color changing of the needle
Post by: Ryoma on August 22, 2021, 06:46:18 PM
While working on the Delta, I made a mistake with inm1 and succeed to change color of needle.

I try again with the Musa and it works only when turning wheel.

See enclosed pictures.
Title: Re: Color changing of the needle
Post by: Daniel3D on August 22, 2021, 07:23:41 PM
I think that is because that mask is only active when the wheel is turned.
Title: Re: Color changing of the needle
Post by: Ryoma on August 22, 2021, 07:57:13 PM
Yes in order to priority of display : insX and inmX and after dasX. And inm2 does not exist anymore.

So this solution is not the way to go. I made a lot of tests.
Title: Re: Color changing of the needle
Post by: Daniel3D on August 22, 2021, 08:45:53 PM
O don't think that changing the color of the needle is possible.
The car files contain the graphics and the needle position.
But no information about the animation of the needle.
Therefore, I think that the needle is drawn by the main game engine.
That is where the color is given. If the color can be changed, then it will be for all cars.
Title: Re: Color changing of the needle
Post by: Ryoma on August 22, 2021, 09:38:41 PM
Red for all cars will be cool!!!!
Title: Re: Color changing of the needle
Post by: Daniel3D on August 22, 2021, 09:57:02 PM
I had a quick look in the source and found this.

https://bitbucket.org/dreadnaut/restunts/src/master/src/restunts/asm/seg005.asm#lines-2710 (https://bitbucket.org/dreadnaut/restunts/src/master/src/restunts/asm/seg005.asm#lines-2710)

meter_needle_color

Code: [Select]
loc_23456:
    cmp     [bp+var_6], 0
    jnz     short loc_23485
    mov     ax, si
    shl     ax, 1
    mov     [bp+var_20], ax
    push    meter_needle_color
    mov     bx, ax
    mov     al, (simd_player.spdpoints+1)[bx]
    sub     ah, ah
    push    ax
    mov     al, simd_player.spdpoints[bx]
    push    ax
    push    simd_player.spdcenter.y2
    push    simd_player.spdcenter.x2
    call    preRender_line
    add     sp, 0Ah
loc_23485:
    mov     ax, di
    shl     ax, 1
    mov     [bp+var_20], ax
    push    meter_needle_color
    mov     bx, ax
    mov     al, (simd_player.revpoints+1)[bx]
    sub     ah, ah
    push    ax
    mov     al, simd_player.revpoints[bx]
    push    ax
    push    simd_player.revcenter.y2
    push    simd_player.revcenter.x2
    call    preRender_line
    add     sp, 0Ah
    mov     al, [bp+var_2]
    cbw
    or      ax, ax
    jz      short loc_234BE
    cmp     ax, 2           ; st. whl. position flag
    jz      short loc_234EC
    jmp     short loc_234DE
    ; align 2
    db 144

After tracing the meter_needle_color back it is loaded without value, it seems to be tied to the font color.
Title: Re: Color changing of the needle
Post by: Cas on August 23, 2021, 12:55:34 AM
Tweaking the code a little bit, it could be possible to get this value loaded from a byte in "simd" instead of that variable. This would make the needle colour configurable. Just loading it this way maybe can be done without changing the opcode length, but there are a few catches.

I think the best candidate in "simd" for this is the byte right after the number of gears. That is, the number of gears is being stored as a word, but only the lower byte is interpreted, so the high byte is normally zero, but if you change it, it has no effect. Of course, 0 is black, so doing this would make the needle of all previously created cars to be black. With some additional code, this byte could be, for example, XORed against 0Fh or ADDed 0Fh to, in order to make white the default.

I'll be researching on that, although I have a ton of other things to do and not much time.