port TriggerCDTrack and TriggerNormalCDTrack

This commit is contained in:
rr- 2021-02-26 01:08:49 +01:00
parent 1a4fdea193
commit 26d103678d
7 changed files with 102 additions and 14 deletions

View file

@ -168,7 +168,7 @@
<rect width="12.00" height="12.00" x="210.00" y="59.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="224.00" y="59.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="238.00" y="59.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="252.00" y="59.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="252.00" y="59.00" fill="forestgreen"/>
<rect width="12.00" height="12.00" x="266.00" y="59.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="280.00" y="59.00" fill="lightpink"/>
<rect width="12.00" height="12.00" x="294.00" y="59.00" fill="forestgreen"/>
@ -889,7 +889,7 @@
<rect width="17.06" height="16.57" x="566.60" y="269.00" fill="forestgreen"/>
<rect width="16.86" height="16.57" x="585.66" y="269.00" fill="lightpink"/>
<rect width="16.86" height="16.57" x="604.52" y="269.00" fill="forestgreen"/>
<rect width="16.78" height="16.57" x="623.38" y="269.00" fill="lightpink"/>
<rect width="16.78" height="16.57" x="623.38" y="269.00" fill="forestgreen"/>
<rect width="16.70" height="16.57" x="642.15" y="269.00" fill="lightpink"/>
<rect width="16.58" height="16.57" x="660.85" y="269.00" fill="forestgreen"/>
<rect width="16.58" height="16.57" x="679.42" y="269.00" fill="lightpink"/>
@ -1459,10 +1459,10 @@
<rect width="-0.46" height="0.42" x="695.22" y="535.58" fill="mistyrose"/>
<rect width="-0.76" height="-0.18" x="696.76" y="535.58" fill="mistyrose"/>
<rect width="-0.76" height="-1.39" x="696.76" y="537.39" fill="lightpink"/>
<rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 33.74%</text>
<rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 33.24%</text>
<rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 52.26%</text>
<rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 50.79%</text>
<rect width="12.00" height="12.00" x="0.00" y="564.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="570.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (count): 33.88%</text>
<rect width="12.00" height="12.00" x="0.00" y="582.50" fill="forestgreen"/><text alignment-baseline="central" x="17.00" y="588.50" style="font-family: sans-serif; font-size: 15px">Functions decompiled (bytesize): 33.42%</text>
<rect width="12.00" height="12.00" x="0.00" y="600.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="606.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (count): 52.13%</text>
<rect width="12.00" height="12.00" x="0.00" y="618.50" fill="lightpink"/><text alignment-baseline="central" x="17.00" y="624.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, but with known names (bytesize): 50.61%</text>
<rect width="12.00" height="12.00" x="0.00" y="636.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="642.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (count): 13.99%</text>
<rect width="12.00" height="12.00" x="0.00" y="654.50" fill="mistyrose"/><text alignment-baseline="central" x="17.00" y="660.50" style="font-family: sans-serif; font-size: 15px">Functions not decompiled, with unknown names (bytesize): 15.97%</text>
</svg>

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Before After
Before After

View file

@ -210,8 +210,8 @@ ClipTarget 0x004150C0 0x000000DC +
FlipMap 0x004151A0 0x0000016F +
RemoveRoomFlipItems ---------- ---------- +
AddRoomFlipItems ---------- ---------- +
TriggerCDTrack 0x00415310 0x000001D2 -
TriggerNormalCDTrack ---------- ---------- -
TriggerCDTrack 0x00415310 0x000001D2 +
TriggerNormalCDTrack ---------- ---------- +
# croc.cpp
AlligatorControl 0x00415520 0x00000326 *
@ -854,7 +854,7 @@ sub_438CA0 0x00438CA0 0x00000015 -
S_SoundStopAllSamples 0x00438CC0 0x0000000F -
S_SoundStopSample 0x00438CD0 0x0000001B -
sub_438CF0 0x00438CF0 0x00000044 -
S_CDPlay 0x00438D40 0x000000FD -
S_CDPlay 0x00438D40 0x000000FD *
S_CDStop 0x00438E40 0x00000043 *
SampleLoader 0x00438E90 0x00000005 -
LoadSamples 0x00438EA0 0x00000189 -

View file

@ -8,6 +8,7 @@
#define MAX_ROOMS 1024
#define MAX_ROOMS_TO_DRAW 100
#define MAX_FRAMES 10
#define MAX_CD_TRACKS 64
#define MAX_TEXTURES 2048
#define NUMBER_ITEMS 256
#define MAX_SECRETS 16

View file

@ -982,6 +982,88 @@ void AddRoomFlipItems(ROOM_INFO* r)
}
}
void TriggerCDTrack(int16_t value, int16_t flags, int16_t type)
{
if (value <= 1 || value >= MAX_CD_TRACKS) {
return;
}
switch (value) {
case 28:
if ((CDFlags[value] & IF_ONESHOT)
&& LaraItem->current_anim_state == AS_UPJUMP) {
value = 29;
}
break;
case 37:
if (LaraItem->current_anim_state != AS_HANG) {
return;
}
break;
case 41:
if (LaraItem->current_anim_state != AS_HANG) {
return;
}
break;
case 42:
if ((CDFlags[value] & IF_ONESHOT)
&& LaraItem->current_anim_state == AS_HANG) {
value = 43;
}
break;
case 49:
if (LaraItem->current_anim_state != AS_SURFTREAD) {
return;
}
break;
case 50:
if (CDFlags[value] & IF_ONESHOT) {
static int16_t gym_completion_counter = 0;
gym_completion_counter++;
if (gym_completion_counter == 30 * 4) {
LevelComplete = 1;
gym_completion_counter = 0;
}
} else if (LaraItem->current_anim_state != AS_WATEROUT) {
return;
}
break;
}
TriggerNormalCDTrack(value, flags, type);
}
void TriggerNormalCDTrack(int16_t value, int16_t flags, int16_t type)
{
if (CDFlags[value] & IF_ONESHOT) {
return;
}
if (type == TT_SWITCH) {
CDFlags[value] ^= flags & IF_CODE_BITS;
} else if (type == TT_ANTIPAD) {
CDFlags[value] &= -1 - (flags & IF_CODE_BITS);
} else if (flags & IF_CODE_BITS) {
CDFlags[value] |= flags & IF_CODE_BITS;
}
if ((CDFlags[value] & IF_CODE_BITS) == IF_CODE_BITS) {
if (flags & IF_ONESHOT) {
CDFlags[value] |= IF_ONESHOT;
}
if (value != CDTrack) {
S_CDPlay(value);
}
} else {
S_CDStop();
}
}
void T1MInjectGameControl()
{
INJECT(0x004133B0, ControlPhase);
@ -1000,4 +1082,5 @@ void T1MInjectGameControl()
INJECT(0x00414E50, xLOS);
INJECT(0x004150C0, ClipTarget);
INJECT(0x004151A0, FlipMap);
INJECT(0x00415310, TriggerCDTrack);
}

View file

@ -27,6 +27,8 @@ int32_t ClipTarget(GAME_VECTOR* start, GAME_VECTOR* target, FLOOR_INFO* floor);
void FlipMap();
void RemoveRoomFlipItems(ROOM_INFO* r);
void AddRoomFlipItems(ROOM_INFO* r);
void TriggerCDTrack(int16_t value, int16_t flags, int16_t type);
void TriggerNormalCDTrack(int16_t value, int16_t flags, int16_t type);
void T1MInjectGameControl();

View file

@ -110,6 +110,7 @@
#define ControlText ARRAY_(0x0045A2F8, TEXTSTRING*, [2])
#define ScanCodeNames ARRAY_(0x00454A40, char*, [])
#define OptionMusicVolume VAR_I_(0x00456334, int32_t, 255)
#define CDFlags ARRAY_(0x00462C20, int16_t, [MAX_CD_TRACKS])
// #define LaraControlRoutines ARRAY_(0x00456490, ControlRoutine, [])
// #define LaraCollisionRoutines ARRAY_(0x00456570, CollisionRoutine, [])

View file

@ -2,11 +2,12 @@
#define T1M_SPECIFIC_SNDPC_H
// clang-format off
#define S_CDLoop ((void (*)())0x004380B0)
#define S_CDStop ((void (*)())0x00438E40)
#define S_CDVolume ((void (*)(int16_t volume))0x00437F30)
#define SoundStart ((void (*)())0x0041CDA0)
#define SoundInit ((int32_t (*)())0x00437E00)
#define S_CDLoop ((void (*)())0x004380B0)
#define S_CDStop ((void (*)())0x00438E40)
#define S_CDPlay ((void (*)(int16_t track))0x00438D40)
#define S_CDVolume ((void (*)(int16_t volume))0x00437F30)
#define SoundStart ((void (*)())0x0041CDA0)
#define SoundInit ((int32_t (*)())0x00437E00)
// clang-format on
#endif