Skip to content

Commit 10ae1d0

Browse files
committed
swars: Creaded play_post_mission_fmv()
Reordered the code so that FMVs are played from one place, then created a function for this purpose.
1 parent d713e7a commit 10ae1d0

4 files changed

Lines changed: 55 additions & 211 deletions

File tree

conf/wrappers_game.conf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ init_person_thing W v p
271271
update_mission_time W v i
272272
load_missions W v i
273273
load_objectives_text W i p
274-
compound_mission_immediate_start_next W v
275-
tweak_for_compound_mission_m84 W v
276274
init_mission_states W v
277275
check_delete_open_mission W v ii
278276
mission_over W v

src/game.c

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,6 @@ void play_smacker(ushort vid_type)
839839
char fname[FILENAME_MAX];
840840
TbScreenMode scr_md_fmvid;
841841

842-
// TODO MAPNO case for a specific map, remove
843-
if (current_map == 51)
844-
{
845-
overall_scale = get_overall_scale_max();
846-
unkn_flags_01 &= ~0x01;
847-
return;
848-
}
849842
update_danger_music(2);
850843

851844
sprint_fmv_filename(vid_type, fname, sizeof(fname));
@@ -4858,26 +4851,21 @@ void restart_back_into_mission(ushort missi)
48584851
}
48594852
}
48604853

4861-
void compound_mission_immediate_start_next(void)
4854+
void compound_mission_brief_store_next(void)
48624855
{
48634856
ushort old_missi, new_missi;
48644857

48654858
old_missi = ingame.CurrentMission;
48664859
new_missi = mission_list[old_missi].SuccessTrigger[0];
48674860
brief_store[open_brief - 1].Mission = new_missi;
48684861
replace_mission_state_slot(old_missi, new_missi);
4869-
4870-
restart_back_into_mission(new_missi);
48714862
}
48724863

4873-
// deprecated - use compound_mission_immediate_start_next()
4874-
void tweak_for_compound_mission_m84(void)
4864+
void compound_mission_immediate_start_next(void)
48754865
{
4876-
#if 0
4877-
asm volatile ("call ASM_tweak_for_compound_mission_m84\n"
4878-
: : : "eax" );
4879-
#endif
4880-
compound_mission_immediate_start_next();
4866+
ushort missi;
4867+
missi = brief_store[open_brief - 1].Mission;
4868+
restart_back_into_mission(missi);
48814869
}
48824870

48834871
short test_missions(ubyte flag)
@@ -6362,8 +6350,37 @@ ubyte check_open_next_mission(ushort mslot, sbyte state)
63626350
return OMiSta_NONE;
63636351
}
63646352

6365-
// TODO it does more than the delete; rename or divide
6366-
void check_delete_open_mission(ushort mslot, sbyte state)
6353+
void play_post_mission_fmv(ubyte misend)
6354+
{
6355+
switch (misend)
6356+
{
6357+
case OMiSta_EndSuccess:
6358+
play_smacker(MPly_MissiComplete);
6359+
break;
6360+
case OMiSta_ContImmSuccess:
6361+
// Reload the palette, potentially damaged by fading
6362+
show_black_screen();
6363+
LbFileLoadAt("qdata/pal.pal", display_palette);
6364+
// The setup_screen_mode() within play_smacker() will
6365+
// automatically switch current pal to display_palette
6366+
play_smacker_then_back_to_engine(MPly_MPartComplete);
6367+
break;
6368+
case OMiSta_EndFailed:
6369+
play_smacker(MPly_MissiFail);
6370+
break;
6371+
case OMiSta_ContSuccess:
6372+
break;
6373+
case OMiSta_ContFailed:
6374+
break;
6375+
case OMiSta_CampaignDone:
6376+
init_outro();
6377+
overall_scale = get_overall_scale_max();
6378+
unkn_flags_01 &= ~0x01;
6379+
break;
6380+
}
6381+
}
6382+
6383+
ubyte check_delete_open_mission(ushort mslot, sbyte state)
63676384
{
63686385
ushort missi;
63696386
TbBool conds_met;
@@ -6389,19 +6406,13 @@ void check_delete_open_mission(ushort mslot, sbyte state)
63896406
if (conds_met) {
63906407
mission_fire_success_triggers(missi);
63916408
}
6392-
play_smacker(MPly_MissiComplete);
63936409
remove_mission_state_slot(mslot);
63946410
break;
63956411
case OMiSta_ContImmSuccess:
63966412
if (conds_met) {
63976413
mission_fire_success_triggers(missi);
63986414
}
6399-
show_black_screen();
6400-
LbFileLoadAt("qdata/pal.pal", display_palette);
6401-
// The setup_screen_mode() within play_smacker() will
6402-
// automatically switch current pal to display_palette
6403-
play_smacker_then_back_to_engine(MPly_MPartComplete);
6404-
compound_mission_immediate_start_next();
6415+
compound_mission_brief_store_next();
64056416
break;
64066417
case OMiSta_EndFailed:
64076418
if (conds_met) {
@@ -6413,6 +6424,7 @@ void check_delete_open_mission(ushort mslot, sbyte state)
64136424
case OMiSta_ContFailed:
64146425
break;
64156426
}
6427+
return misend;
64166428
}
64176429

64186430
void mission_over(void)
@@ -6421,6 +6433,8 @@ void mission_over(void)
64216433
asm volatile ("call ASM_mission_over\n"
64226434
: : : "eax" );
64236435
#else
6436+
ubyte misend;
6437+
64246438
ingame.DisplayMode = DpM_UNKN_37;
64256439
LbMouseChangeSprite(0);
64266440
StopCD();
@@ -6443,12 +6457,6 @@ void mission_over(void)
64436457
if (mission_state[mslot] == 0)
64446458
mission_state[mslot] = ingame.MissionStatus;
64456459

6446-
if (mission_state[mslot] == 1)
6447-
{
6448-
if (mission_is_final_at_game_end(last_missi))
6449-
init_outro();
6450-
}
6451-
64526460
lstate = 0;
64536461
if (mission_state[mslot] == 1)
64546462
{
@@ -6464,7 +6472,7 @@ void mission_over(void)
64646472
ingame.Credits += cr_award;
64656473
if (email != 0)
64666474
queue_up_new_mail(0, -email);
6467-
check_delete_open_mission(mslot, 1);
6475+
misend = check_delete_open_mission(mslot, 1);
64686476
}
64696477
else if (mission_state[mslot] == -1)
64706478
{
@@ -6477,8 +6485,18 @@ void mission_over(void)
64776485
ingame.fld_unkC57++;
64786486
if (email != 0)
64796487
queue_up_new_mail(0, -email);
6480-
check_delete_open_mission(mslot, -1);
6481-
play_smacker(MPly_MissiFail);
6488+
misend = check_delete_open_mission(mslot, -1);
6489+
}
6490+
6491+
if (misend == OMiSta_EndSuccess) {
6492+
if (mission_is_final_at_game_end(last_missi))
6493+
misend = OMiSta_CampaignDone;
6494+
}
6495+
6496+
play_post_mission_fmv(misend);
6497+
6498+
if (misend == OMiSta_ContImmSuccess) {
6499+
compound_mission_immediate_start_next();
64826500
}
64836501

64846502
ingame.GameOver = 0;

src/game.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ enum OpenMissionEndStatus {
123123
OMiSta_ContFailed,
124124
/** Mission completed successfully, but is a part of multi-mission chain with immediately starting next mission */
125125
OMiSta_ContImmSuccess,
126+
/** Final mission completed successfully, campaign finished. */
127+
OMiSta_CampaignDone,
126128
};
127129

128130
enum MissionFMVPlay {

src/swars.sx

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -169927,180 +169927,6 @@ open_new_mission: /* 0x0A523C */
169927169927
ret
169928169928

169929169929

169930-
/*----------------------------------------------------------------*/
169931-
GLOBAL_FUNC(ASM_compound_mission_immediate_start_next) /* 0x0A52AC */
169932-
/*----------------------------------------------------------------*/
169933-
push %ebx
169934-
push %ecx
169935-
push %edx
169936-
push %esi
169937-
push %edi
169938-
xor %ah,%ah
169939-
mov display_palette,%edx
169940-
mov %ah,mission_result
169941-
mov $aQdataPal_pal_2,%eax
169942-
call ac_LbFileLoadAt
169943-
mov display_palette,%edx
169944-
push %edx
169945-
call ac_LbPaletteSet
169946-
add $0x4,%esp
169947-
mov $0x41,%eax
169948-
mov $0x1,%ebx
169949-
call ac_change_current_map
169950-
call ac_unkn_lights_func_11
169951-
mov data_19f432,%dx
169952-
mov ingame__CurrentMission,%cx
169953-
mov $0x2,%eax
169954-
cmp %cx,%dx
169955-
je jump_a531b
169956-
mov ingame__CurrentMission,%si
169957-
jump_a530b:
169958-
mov data_19f432(%eax),%dx
169959-
add $0x2,%eax
169960-
inc %ebx
169961-
cmp %si,%dx
169962-
jne jump_a530b
169963-
jump_a531b:
169964-
mov ingame__MyGroup,%eax
169965-
sar $0x10,%eax
169966-
cmp $0x58,%eax
169967-
jne jump_a5348
169968-
mov old_mission_brief,%eax
169969-
sar $0x10,%eax
169970-
lea -0x1(%eax),%edx
169971-
mov %edx,%eax
169972-
movb $0x65,data_1c6e74(%edx,%eax,4)
169973-
movw $0x65,ingame__CurrentMission
169974-
jmp jump_a5369
169975-
jump_a5348:
169976-
mov old_mission_brief,%edx
169977-
sar $0x10,%edx
169978-
dec %edx
169979-
mov $0x66,%edi
169980-
mov %edx,%eax
169981-
mov $0x66,%cl
169982-
mov %di,ingame__CurrentMission
169983-
mov %cl,data_1c6e74(%edx,%eax,4)
169984-
jump_a5369:
169985-
mov ingame__CurrentMission,%ax
169986-
xor %edx,%edx
169987-
mov %ax,mission_open(,%ebx,2)
169988-
mov %dx,mission_state(,%ebx,2)
169989-
mov ingame__MyGroup,%ebx
169990-
sar $0x10,%ebx
169991-
lea 0x0(,%ebx,4),%eax
169992-
add %ebx,%eax
169993-
shl $0x2,%eax
169994-
sub %ebx,%eax
169995-
xor %dl,%dl
169996-
mov %dl,data_1974c1(,%eax,4)
169997-
mov ingame_m2,%eax
169998-
sar $0x10,%eax
169999-
cmp $0x2,%eax
170000-
jne jump_a53b4
170001-
mov %dl,execute_commands
170002-
jump_a53b4:
170003-
xor %ebx,%ebx
170004-
mov $0x1,%eax
170005-
mov %ebx,engn_yc
170006-
call ac_init_game
170007-
xor %eax,%eax
170008-
mov $0xd15c1234,%ecx
170009-
mov pktrec_mode,%al
170010-
mov %ecx,EXPORT_SYMBOL(lbSeed)
170011-
cmp $0x1,%eax
170012-
jne jump_a53e7
170013-
call ac_PacketRecord_Close
170014-
call ac_PacketRecord_OpenWrite
170015-
jump_a53e7:
170016-
pop %edi
170017-
pop %esi
170018-
pop %edx
170019-
pop %ecx
170020-
pop %ebx
170021-
ret
170022-
170023-
170024-
/*----------------------------------------------------------------*/
170025-
GLOBAL_FUNC(ASM_tweak_for_compound_mission_m84) /* 0x0A53F0 */
170026-
/*----------------------------------------------------------------*/
170027-
push %ebx
170028-
push %ecx
170029-
push %edx
170030-
push %esi
170031-
xor %ah,%ah
170032-
mov EXPORT_SYMBOL(lbDisplay)+100,%bx # lbDisplay.ScreenMode
170033-
mov %ah,mission_result
170034-
call ac_show_black_screen
170035-
mov $aQdataPal_pal_3,%eax
170036-
mov display_palette,%edx
170037-
call ac_LbFileLoadAt
170038-
mov display_palette,%edx
170039-
push %edx
170040-
call ac_LbPaletteSet
170041-
add $0x4,%esp
170042-
xor %eax,%eax
170043-
call ac_play_smacker
170044-
mov $aQdataPal_pal_4,%eax
170045-
mov display_palette,%edx
170046-
call ac_LbFileLoadAt
170047-
xor %eax,%eax
170048-
mov %bx,%ax
170049-
call ac_setup_screen_mode
170050-
mov $0xb,%eax
170051-
call ac_change_current_map
170052-
call ac_unkn_lights_func_11
170053-
mov data_19f432,%dx
170054-
mov ingame__CurrentMission,%bx
170055-
mov $0x2,%eax
170056-
cmp %bx,%dx
170057-
je jump_a5485
170058-
mov ingame__CurrentMission,%cx
170059-
jump_a5476:
170060-
mov data_19f432(%eax),%dx
170061-
add $0x2,%eax
170062-
cmp %cx,%dx
170063-
jne jump_a5476
170064-
jump_a5485:
170065-
mov old_mission_brief,%ebx
170066-
sar $0x10,%ebx
170067-
dec %ebx
170068-
mov $0x58,%esi
170069-
mov %ebx,%edx
170070-
mov $0x58,%cl
170071-
mov %si,ingame__CurrentMission
170072-
mov %cl,data_1c6e74(%ebx,%edx,4)
170073-
xor %ebx,%edx
170074-
mov %si,mission_open(%eax)
170075-
mov %dx,mission_state(%eax)
170076-
mov ingame_m2,%eax
170077-
xor %ch,%ch
170078-
sar $0x10,%eax
170079-
mov %ch,data_198ee1
170080-
cmp $0x2,%eax
170081-
jne jump_a54d1
170082-
mov %ch,execute_commands
170083-
jump_a54d1:
170084-
xor %ebx,%ebx
170085-
mov $0x1,%eax
170086-
mov %ebx,engn_yc
170087-
call ac_init_game
170088-
xor %eax,%eax
170089-
mov $0xd15c1234,%ecx
170090-
mov pktrec_mode,%al
170091-
mov %ecx,EXPORT_SYMBOL(lbSeed)
170092-
cmp $0x1,%eax
170093-
jne jump_a5504
170094-
call ac_PacketRecord_Close
170095-
call ac_PacketRecord_OpenWrite
170096-
jump_a5504:
170097-
pop %esi
170098-
pop %edx
170099-
pop %ecx
170100-
pop %ebx
170101-
ret
170102-
170103-
170104169930
vtable_a5ea0:
170105169931
.long func_a605c
170106169932
.long func_a606d

0 commit comments

Comments
 (0)