Skip to content

Commit 5b6df7a

Browse files
committed
swars: Remade do_net_protocol_select()
1 parent 6ecda6b commit 5b6df7a

File tree

2 files changed

+112
-5
lines changed

2 files changed

+112
-5
lines changed

src/fenet.c

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,117 @@ ubyte show_net_comms_box(struct ScreenBox *box)
532532

533533
ubyte do_net_protocol_select(ubyte click)
534534
{
535+
#if 0
535536
ubyte ret;
536537
asm volatile ("call ASM_do_net_protocol_select\n"
537538
: "=r" (ret) : "a" (click));
538539
return ret;
540+
#endif
541+
const char *text;
542+
int i;
543+
short proto;
544+
short pos_x;
545+
546+
if (byte_1C4A7C)
547+
{
548+
LbNetworkReset();
549+
byte_1C4A7C = 0;
550+
}
551+
552+
pos_x = net_protocol_select_button.X - 12 + net_protocol_select_button.Width + 4;
553+
554+
proto = nsvc.I.Type;
555+
if (click)
556+
{
557+
proto--;
558+
if (proto <= NetSvc_NONE)
559+
{
560+
proto = NetSvc_COM4;
561+
if (data_1c4a70)
562+
{
563+
net_protocol_select_button.X -= 12;
564+
net_unkn40_button.X = pos_x;
565+
byte_1C4A6F = 1;
566+
}
567+
}
568+
else if (proto == NetSvc_IPX) // IPX needs to be accepted
569+
{
570+
if (byte_1C4A6F)
571+
{
572+
byte_1C4A6F = 0;
573+
proto = NetSvc_COM4;
574+
net_protocol_select_button.X += 12;
575+
}
576+
}
577+
nsvc.I.Type = proto;
578+
}
579+
else
580+
{
581+
proto++;
582+
if (proto > NetSvc_COM4)
583+
{
584+
if (byte_1C4A6F || !data_1c4a70)
585+
{
586+
proto = NetSvc_IPX;
587+
if (byte_1C4A6F)
588+
{
589+
byte_1C4A6F = 0;
590+
net_protocol_select_button.X += 12;
591+
}
592+
}
593+
else
594+
{
595+
proto = NetSvc_COM1;
596+
net_protocol_select_button.X -= 12;
597+
net_unkn40_button.X = pos_x;
598+
byte_1C4A6F = 1;
599+
}
600+
}
601+
nsvc.I.Type = proto;
602+
}
603+
604+
switch (nsvc.I.Type)
605+
{
606+
case NetSvc_NONE:
607+
default:
608+
break;
609+
case NetSvc_IPX:
610+
net_protocol_select_button.Text = gui_strings[497 + NetSvc_IPX];
611+
612+
memset(unkstruct04_arr, 0, sizeof(unkstruct04_arr));
613+
byte_1C6D48 = 0;
614+
for (i = 0; i < 8; i++)
615+
unkn2_names[i][0] = '\0';
616+
if (LbNetworkServiceStart(&nsvc.I) != Lb_SUCCESS)
617+
{
618+
nsvc.I.Type = NetSvc_COM1;
619+
net_protocol_select_button.Text = gui_strings[499];
620+
net_protocol_option_button.Text = net_baudrate_text;
621+
net_protocol_option_button.CallBackFn = ac_do_serial_speed_switch;
622+
623+
alert_box_text_fmt("%s", gui_strings[568]);
624+
break;
625+
}
626+
byte_1C4A7C = 1;
627+
byte_15516C = -1;
628+
net_protocol_option_button.Text = net_proto_param_text;
629+
net_protocol_option_button.CallBackFn = ac_do_net_protocol_option;
630+
break;
631+
case NetSvc_COM1:
632+
case NetSvc_COM2:
633+
case NetSvc_COM3:
634+
case NetSvc_COM4:
635+
net_protocol_option_button.Text = net_baudrate_text;
636+
if (byte_1C4A6F)
637+
text = gui_strings[522 + nsvc.I.Type];
638+
else
639+
text = gui_strings[497 + nsvc.I.Type];
640+
net_protocol_option_button.CallBackFn = ac_do_serial_speed_switch;
641+
net_protocol_select_button.Text = text;
642+
byte_15516C = 0;
643+
break;
644+
}
645+
return 1;
539646
}
540647

541648
ubyte show_net_protocol_box(struct ScreenBox *box)

src/network.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,13 +1341,13 @@ TbResult LbModemRingType(ushort dev_id, ubyte rtyp)
13411341
return Lb_SUCCESS;
13421342
}
13431343

1344-
TbResult LbNetworkServiceStart(struct NetworkServiceInfo *nsvc)
1344+
TbResult LbNetworkServiceStart(struct NetworkServiceInfo *p_nsvc)
13451345
{
13461346
TbResult ret;
13471347
ulong k;
13481348

13491349
ret = Lb_FAIL;
1350-
memcpy(&NetworkServicePtr.I, nsvc, sizeof(struct NetworkServiceInfo));
1350+
memcpy(&NetworkServicePtr.I, p_nsvc, sizeof(struct NetworkServiceInfo));
13511351
switch (NetworkServicePtr.I.Type)
13521352
{
13531353
case NetSvc_IPX:
@@ -1361,8 +1361,8 @@ TbResult LbNetworkServiceStart(struct NetworkServiceInfo *nsvc)
13611361
}
13621362
memset(&IPXPlayer.Header, 0, sizeof(struct TbIPXPlayerHeader));
13631363
memset(&IPXPlayer.Data, 0, sizeof(struct TbIPXPlayerData));
1364-
IPXPlayer.Header.field_2 = nsvc->GameId;
1365-
k = (nsvc->Flags >> 16) + 0x4545;
1364+
IPXPlayer.Header.field_2 = p_nsvc->GameId;
1365+
k = p_nsvc->Param + 0x4545;
13661366
NetworkServicePtr.I.Id = &IPXPlayer.Header;
13671367
if (k > 0x4FFF)
13681368
k = 0x4FFF;
@@ -1382,7 +1382,7 @@ TbResult LbNetworkServiceStart(struct NetworkServiceInfo *nsvc)
13821382
ret = Lb_SUCCESS;
13831383
break;
13841384
case NetSvc_RADICA:
1385-
ret = radica_service_init(nsvc);
1385+
ret = radica_service_init(p_nsvc);
13861386
if (ret != Lb_SUCCESS) {
13871387
LOGERR("RADICA service init failed");
13881388
ret = Lb_FAIL;

0 commit comments

Comments
 (0)