Skip to content

Commit 6d4169d

Browse files
committed
swars: Remade load_map_bnb()
Also removed load_packet() from ASM.
1 parent 9c6dbc2 commit 6d4169d

File tree

5 files changed

+80
-1289
lines changed

5 files changed

+80
-1289
lines changed

src/bat.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,12 @@ void BAT_play(void)
581581
#endif
582582
}
583583

584+
void BAT_unknsub_20(int a1, int a2, int a3, int a4, ubyte *p_screen)
585+
{
586+
asm volatile (
587+
"push %4\n"
588+
"call ASM_BAT_unknsub_20\n"
589+
: : "a" (a1), "d" (a2), "b" (a3), "c" (a4), "g" (p_screen));
590+
}
591+
584592
/******************************************************************************/

src/bat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ extern "C" {
2727
/******************************************************************************/
2828
#pragma pack(1)
2929

30-
3130
#pragma pack()
3231
/******************************************************************************/
3332

3433
void BAT_play(void);
3534

35+
void BAT_unknsub_20(int a1, int a2, int a3, int a4, ubyte *p_screen);
36+
3637
/******************************************************************************/
3738
#ifdef __cplusplus
3839
}

src/game.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ extern unsigned short unkn2_pos_x;
173173
extern unsigned short unkn2_pos_y;
174174
extern unsigned short unkn2_pos_z;
175175
extern int data_1c8428;
176-
extern const char *primvehobj_fname;
176+
const char *primvehobj_fname = "qdata/primveh.obj";
177177
extern unsigned char textwalk_data[640];
178178

179179
extern short word_1C6E08;
@@ -2291,14 +2291,6 @@ void setup_debug_obj_trace(void)
22912291
debug_trace_place(0);
22922292
}
22932293

2294-
void BAT_unknsub_20(int a1, int a2, int a3, int a4, ubyte *a5)
2295-
{
2296-
asm volatile (
2297-
"push %4\n"
2298-
"call ASM_BAT_unknsub_20\n"
2299-
: : "a" (a1), "d" (a2), "b" (a3), "c" (a4), "g" (a5));
2300-
}
2301-
23022294
TbResult prep_multicolor_sprites(void)
23032295
{
23042296
PathInfo *pinfo;
@@ -6838,10 +6830,6 @@ void input_mission_concluded(void)
68386830

68396831
void load_packet(void)
68406832
{
6841-
#if 0
6842-
asm volatile ("call ASM_load_packet\n"
6843-
: : : "eax" );
6844-
#else
68456833
PlayerInfo *p_locplayer;
68466834
struct Packet *p_pckt;
68476835
int did_actn;
@@ -6947,7 +6935,6 @@ void load_packet(void)
69476935
PacketRecord_Write(p_pckt);
69486936
}
69496937
}
6950-
#endif
69516938
}
69526939

69536940
void joy_input(void)

src/lvfiles.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "bfmath.h"
2525
#include "bfmemut.h"
2626

27+
#include "bat.h"
2728
#include "triangls.h"
2829
#include "trpoints.h"
2930
#include "trstate.h"
@@ -55,6 +56,17 @@
5556
#include "weapon.h"
5657
#include "swlog.h"
5758
/******************************************************************************/
59+
#pragma pack(1)
60+
61+
struct BillboardNBreakout {
62+
ubyte field_0;
63+
ubyte field_1;
64+
ubyte field_2;
65+
ubyte field_3;
66+
};
67+
68+
#pragma pack()
69+
/******************************************************************************/
5870

5971
TbBool level_deep_fix = false;
6072

@@ -94,6 +106,9 @@ struct QuickLoad quick_load_pc[] = {
94106

95107
ushort next_used_lvl_objective = 1;
96108

109+
extern uint dword_177790;
110+
extern struct BillboardNBreakout map_bnb;
111+
97112
void debug_level(const char *text, int player)
98113
{
99114
ThingIdx thing;
@@ -1401,8 +1416,45 @@ TbResult load_map_mad(ushort mapno)
14011416

14021417
void load_map_bnb(int a1)
14031418
{
1419+
#if 0
14041420
asm volatile ("call ASM_load_map_bnb\n"
14051421
: : "a" (a1));
1422+
#endif
1423+
char locstr[52];
1424+
TbFileHandle fh;
1425+
ubyte Amin, Amax;
1426+
ubyte Bmin, Bmax;
1427+
1428+
sprintf(locstr, "%s/map%03d.b&b", "maps", a1);
1429+
fh = LbFileOpen(locstr, 2u);
1430+
if (fh == INVALID_FILE)
1431+
{
1432+
map_bnb.field_0 = 0;
1433+
map_bnb.field_1 = 0;
1434+
map_bnb.field_2 = 0;
1435+
map_bnb.field_3 = 0;
1436+
dword_177790 = 0;
1437+
}
1438+
else
1439+
{
1440+
LbFileRead(fh, &map_bnb, 4);
1441+
LbFileClose(fh);
1442+
dword_177790 = 2;
1443+
}
1444+
Amin = map_bnb.field_0;
1445+
if (map_bnb.field_0 >= map_bnb.field_2)
1446+
Amin = map_bnb.field_2;
1447+
Bmin = map_bnb.field_1;
1448+
if (map_bnb.field_1 >= map_bnb.field_3)
1449+
Bmin = map_bnb.field_3;
1450+
Amax = map_bnb.field_0;
1451+
if (map_bnb.field_0 <= map_bnb.field_2)
1452+
Amax = map_bnb.field_2;
1453+
Bmax = map_bnb.field_1;
1454+
if (map_bnb.field_1 <= map_bnb.field_3)
1455+
Bmax = map_bnb.field_3;
1456+
1457+
BAT_unknsub_20(Amin, Bmin, Amax, Bmax, vec_tmap[4] + 0xA040);
14061458
}
14071459

14081460
TbResult load_mad_pc(ushort mapno)

0 commit comments

Comments
 (0)