1
1
/*
2
- * Copyright (c) 2017-2020 Michael Chaban. All rights reserved.
2
+ * Copyright (c) 2017-2021 Michael Chaban. All rights reserved.
3
3
* Original game is written by Core Design Ltd. in 1997.
4
4
* Lara Croft and Tomb Raider are trademarks of Square Enix Ltd.
5
5
*
@@ -173,6 +173,43 @@ int __cdecl ControlPhase(int nTicks, BOOL demoMode) {
173
173
return 0 ;
174
174
}
175
175
176
+ void __cdecl TriggerCDTrack (__int16 value, UINT16 flags, __int16 type) {
177
+ if ( value > 1 && value < 64 ) {
178
+ TriggerNormalCDTrack (value, flags, type);
179
+ }
180
+ }
181
+
182
+ void __cdecl TriggerNormalCDTrack (__int16 value, UINT16 flags, __int16 type) {
183
+ if ( type != 2 ) {
184
+ UINT16 codebits = flags & IFL_CODEBITS;
185
+ if ( CHK_ANY (codebits, CD_Flags[value]) ){
186
+ return ;
187
+ }
188
+ if ( CHK_ANY (flags, IFL_INVISIBLE) ) {
189
+ CD_Flags[value] |= codebits;
190
+ }
191
+ }
192
+
193
+ if ( value == CD_TrackID ) {
194
+ UINT8 timer = CD_Flags[value] & 0xFF ;
195
+ if ( timer ) {
196
+ if ( !--timer ) {
197
+ CD_TrackID = -1 ;
198
+ S_CDPlay (value, FALSE );
199
+ }
200
+ CD_Flags[value] = (CD_Flags[value] & ~0xFF ) | timer;
201
+ }
202
+ } else {
203
+ UINT8 timer = flags & 0xFF ;
204
+ if ( timer ) {
205
+ CD_TrackID = value;
206
+ CD_Flags[value] = (CD_Flags[value] & ~0xFF ) | ((timer * 30 ) & 0xFF );
207
+ } else {
208
+ S_CDPlay (value, FALSE );
209
+ }
210
+ }
211
+ }
212
+
176
213
/*
177
214
* Inject function
178
215
*/
@@ -197,6 +234,7 @@ void Inject_Control() {
197
234
// INJECT(0x00416610, FlipMap);
198
235
// INJECT(0x004166D0, RemoveRoomFlipItems);
199
236
// INJECT(0x00416770, AddRoomFlipItems);
200
- // INJECT(0x004167D0, TriggerCDTrack);
201
- // INJECT(0x00416800, TriggerNormalCDTrack);
237
+
238
+ INJECT (0x004167D0 , TriggerCDTrack);
239
+ INJECT (0x00416800 , TriggerNormalCDTrack);
202
240
}
0 commit comments