Skip to content

Commit 9c6dbc2

Browse files
committed
swars: Remade reinit_starting_credits()
1 parent e9891a1 commit 9c6dbc2

File tree

5 files changed

+51
-20
lines changed

5 files changed

+51
-20
lines changed

conf/wrappers_game.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ vfx1_init W i
10851085
vfx1_unkn_func_03 W i
10861086
vfx1_unkn_func_12 W i pi
10871087
traffic_unkn_func_01 W v
1088-
sub_CCE8C W i i
1088+
reinit_starting_credits W i i
10891089
net_unkn_func_33 W v
10901090
net_unkn_func_29 W v iiiii
10911091
net_unkn_func_352 W i

src/fenet.c

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ extern struct ScreenButton net_protocol_option_button;
6262
extern char net_unkn40_text[];
6363
extern char net_baudrate_text[8];
6464
extern char net_proto_param_text[8];
65-
extern ulong dword_155750[];
6665
extern ubyte byte_155174; // = 166;
6766
extern ubyte byte_155175[];
6867
extern ubyte byte_155180; // = 109;
@@ -666,12 +665,45 @@ void show_net_benefits_sub4(struct ScreenBox *box)
666665
draw_sprite_purple_list(box2.X - 7, box2.Y, &fe_icons_sprites[109]);
667666
}
668667

669-
ulong sub_CCE8C(sbyte change)
668+
ubyte get_current_starting_cash_level(void)
670669
{
670+
int i, lv_curr;
671+
672+
lv_curr = 0;
673+
for (i = 0; i < 8; i++)
674+
{
675+
if (login_control__Money == starting_cash_amounts[i])
676+
break;
677+
lv_curr++;
678+
}
679+
return lv_curr;
680+
}
681+
682+
uint reinit_starting_credits(sbyte change)
683+
{
684+
#if 0
671685
ulong ret;
672-
asm volatile ("call ASM_sub_CCE8C\n"
686+
asm volatile ("call ASM_reinit_starting_credits\n"
673687
: "=r" (ret) : "a" (change));
674688
return ret;
689+
#endif
690+
int lv, lv_curr;
691+
uint creds;
692+
693+
lv_curr = get_current_starting_cash_level();
694+
lv = lv_curr + change;
695+
if (lv < 0)
696+
lv = 0;
697+
if (lv > 7)
698+
lv = 7;
699+
700+
creds = starting_cash_amounts[lv];
701+
login_control__Money = creds;
702+
ingame.Credits = creds;
703+
ingame.CashAtStart = creds;
704+
ingame.Expenditure = 0;
705+
706+
return creds;
675707
}
676708

677709
void show_net_benefits_sub5(short x0, short y0, TbPixel *colours)
@@ -689,7 +721,7 @@ void show_net_benefits_sub5(short x0, short y0, TbPixel *colours)
689721
short delta;
690722

691723
p_sprite = &fe_icons_sprites[spridx];
692-
if (login_control__Money >= dword_155750[i])
724+
if (login_control__Money >= starting_cash_amounts[i])
693725
{
694726
lbDisplay.DrawFlags = Lb_TEXT_ONE_COLOR;
695727
lbDisplay.DrawColour = colours[i];
@@ -704,7 +736,7 @@ void show_net_benefits_sub5(short x0, short y0, TbPixel *colours)
704736
if (is_unkn_current_player() && ((unkn_flags_08 & 0x01) == 0)
705737
&& (login_control__State == 5))
706738
{
707-
login_control__Money = dword_155750[i];
739+
login_control__Money = starting_cash_amounts[i];
708740
ingame.Credits = login_control__Money;
709741
}
710742
}
@@ -742,7 +774,7 @@ void show_net_benefits_sub6(struct ScreenBox *box)
742774
if (is_unkn_current_player() && ((unkn_flags_08 & 0x01) == 0)
743775
&& (login_control__State == 5))
744776
{
745-
sub_CCE8C(-1);
777+
reinit_starting_credits(-1);
746778
}
747779
}
748780
}
@@ -768,7 +800,7 @@ void show_net_benefits_sub7(struct ScreenBox *box)
768800
if (is_unkn_current_player() && ((unkn_flags_08 & 0x01) == 0)
769801
&& (login_control__State == 5))
770802
{
771-
sub_CCE8C(1);
803+
reinit_starting_credits(1);
772804
}
773805
}
774806
}

src/game.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,7 +3824,7 @@ void init_variables(void)
38243824
global_date.Year = 74;
38253825
//word_15518A = -1; -- set but never used - remove pending
38263826
ingame.MissionStatus = ObvStatu_COMPLETED;
3827-
login_control__Money = starting_cash_amounts[0];
3827+
login_control__Money = starting_cash_amounts[4];
38283828
if (login_control__State == 6)
38293829
{
38303830
ingame.Credits = 50000;
@@ -5525,7 +5525,7 @@ void net_new_game_prepare(void)
55255525
login_control__City = -1;
55265526
ingame.Expenditure = 0;
55275527
unkn_flags_08 = 0x3C;
5528-
login_control__Money = starting_cash_amounts[0];
5528+
login_control__Money = starting_cash_amounts[4];
55295529
init_agents();
55305530
load_missions(background_type);
55315531
load_objectives_text();

src/game.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ extern ubyte byte_1C5C28[8];
396396
extern ubyte byte_1C6D48;
397397
extern ubyte unkn_flags_08;
398398
extern long dword_153194;
399-
extern ulong starting_cash_amounts[4];
399+
extern ulong starting_cash_amounts[8];
400400
extern sbyte unkn_city_no;
401401
extern ubyte group_types[8];
402402
extern ubyte byte_1C4AA3;

src/swars.sx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165107,7 +165107,7 @@ GLOBAL_FUNC(ASM_is_mission_active_in_city) /* 0x0CCD10 */
165107165107

165108165108

165109165109
/*----------------------------------------------------------------*/
165110-
GLOBAL_FUNC(ASM_sub_CCE8C) /* 0xCCE8C */
165110+
GLOBAL_FUNC(ASM_reinit_starting_credits) /* 0xCCE8C */
165111165111
/*----------------------------------------------------------------*/
165112165112
push %ebx
165113165113
push %ecx
@@ -165118,7 +165118,7 @@ GLOBAL_FUNC(ASM_sub_CCE8C) /* 0xCCE8C */
165118165118
xor %edx,%edx
165119165119
xor %eax,%eax
165120165120
jump_cce9c:
165121-
cmp EXPORT_SYMBOL(dword_155750)(%eax),%ebx
165121+
cmp EXPORT_SYMBOL(starting_cash_amounts)(%eax),%ebx
165122165122
jne jump_ccedc
165123165123
jump_ccea4:
165124165124
movsbl %cl,%eax
@@ -165131,7 +165131,7 @@ GLOBAL_FUNC(ASM_sub_CCE8C) /* 0xCCE8C */
165131165131
jle jump_cceb9
165132165132
mov $0x7,%edx
165133165133
jump_cceb9:
165134-
mov EXPORT_SYMBOL(dword_155750)(,%edx,4),%eax
165134+
mov EXPORT_SYMBOL(starting_cash_amounts)(,%edx,4),%eax
165135165135
xor %edi,%edi
165136165136
mov %eax,login_control__Money
165137165137
mov %eax,EXPORT_SYMBOL(ingame)+0x923 # ingame.Credits
@@ -167947,7 +167947,7 @@ GLOBAL_FUNC(ASM_init_variables) /* 0x0D0B9C */
167947167947
mov %di,EXPORT_SYMBOL(word_15518A)
167948167948
mov %ax,EXPORT_SYMBOL(ingame)+0x92D # ingame.MissionStatus
167949167949
xor %cl,%cl
167950-
mov starting_cash_amounts,%eax
167950+
mov EXPORT_SYMBOL(starting_cash_amounts)+0x10,%eax
167951167951
mov %cx,EXPORT_SYMBOL(next_email)
167952167952
mov %cx,next_ref
167953167953
mov %eax,login_control__Money
@@ -168707,7 +168707,7 @@ GLOBAL_FUNC(ASM_do_serial_speed_switch) /* 0x0D2EA4 */
168707168707
xor %edx,%edx
168708168708
xor %eax,%eax
168709168709
jump_d2eb8:
168710-
mov data_155770(%eax),%ecx
168710+
mov EXPORT_SYMBOL(serial_speeds)(%eax),%ecx
168711168711
lea 0x1(%edx),%ebx
168712168712
cmp %esi,%ecx
168713168713
je jump_d2ecc
@@ -168728,7 +168728,7 @@ GLOBAL_FUNC(ASM_do_serial_speed_switch) /* 0x0D2EA4 */
168728168728
jle jump_d2ee7
168729168729
xor %ebx,%edx
168730168730
jump_d2ee7:
168731-
mov data_155770(,%edx,4),%esi
168731+
mov EXPORT_SYMBOL(serial_speeds)(,%edx,4),%esi
168732168732
push %esi
168733168733
push $ascD_14
168734168734
push $EXPORT_SYMBOL(net_baudrate_text)
@@ -183572,13 +183572,12 @@ data_155744:
183572183572
.ascii "\xfb\xff"
183573183573
.ascii "\xfb\xff"
183574183574
.ascii "\xfb\xff"
183575-
GLOBAL (dword_155750) /* 0x155750 */
183575+
GLOBAL (starting_cash_amounts) /* 0x155750 */
183576183576
.ascii "\x20\x4e\x00\x00\x50\xc3\x00\x00"
183577183577
.ascii "\x40\x0d\x03\x00\x20\xa1\x07\x00"
183578-
GLOBAL (starting_cash_amounts) /* 0x155760 */
183579183578
.ascii "\x80\x84\x1e\x00\x40\x4b\x4c\x00"
183580183579
.ascii "\x00\x2d\x31\x01\x00\xe1\xf5\x05"
183581-
data_155770:
183580+
GLOBAL (serial_speeds) /* 0x155770 */
183582183581
.ascii "\x80\x25\x00\x00\x40\x38\x00\x00"
183583183582
.ascii "\x00\x4b\x00\x00\x80\x70\x00\x00"
183584183583
.ascii "\x00\x96\x00\x00\x00\xe1\x00\x00"

0 commit comments

Comments
 (0)