Skip to content

Commit cdd9efe

Browse files
committed
swars: Remade draw_sort_sprite_veh_health_bar()
1 parent 6dfe392 commit cdd9efe

3 files changed

Lines changed: 58 additions & 23 deletions

File tree

conf/wrappers_game.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ draw_object_face4f W v i
419419
draw_person_shadow W v i
420420
draw_shrapnel W v i
421421
draw_phwoar W v i
422-
draw_sort_sprite_tng W v i
423-
draw_object_face4e W v i
424-
draw_object_face1d W v i
422+
draw_sort_sprite_veh_health_bar W v i
423+
draw_object_face4_deep_rdr W v i
424+
draw_object_face3_deep_rdr W v i
425425
draw_fire_flame W v i
426426
draw_unkn1_scaled_alpha_sprite W v iiiii
427427
draw_hud W v i

src/engindrwlst.c

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
/******************************************************************************/
1919
#include "engindrwlst.h"
2020

21+
#include "bfbox.h"
2122
#include "bfkeybd.h"
2223
#include "bfgentab.h"
2324
#include "bfsprite.h"
@@ -38,6 +39,7 @@
3839
#include "game_sprts.h"
3940
#include "game.h"
4041
#include "player.h"
42+
#include "thing.h"
4143
#include "swlog.h"
4244
/******************************************************************************/
4345
extern ushort next_screen_point;
@@ -455,11 +457,11 @@ void draw_sort_sprite1c_sub(ushort a1, short a2, short a3, ubyte a4, ushort a5)
455457
: : "a" (a1), "d" (a2), "b" (a3), "c" (a4), "g" (a5));
456458
}
457459

458-
void draw_sort_sprite1c(ushort a1)
460+
void draw_sort_sprite1c(ushort sspr)
459461
{
460-
struct SortSprite *sspr;
461-
sspr = &game_sort_sprites[a1];
462-
draw_sort_sprite1c_sub(sspr->Frame, sspr->X, sspr->Y, sspr->Brightness, sspr->Scale);
462+
struct SortSprite *p_sspr;
463+
p_sspr = &game_sort_sprites[sspr];
464+
draw_sort_sprite1c_sub(p_sspr->Frame, p_sspr->X, p_sspr->Y, p_sspr->Brightness, p_sspr->Scale);
463465
}
464466

465467
void check_mouse_over_face(struct PolyPoint *pt1, struct PolyPoint *pt2,
@@ -1469,21 +1471,54 @@ void draw_phwoar(ushort ph)
14691471
lbDisplay.DrawFlags = 0;
14701472
}
14711473

1472-
void draw_sort_sprite_tng(short a1)
1474+
void draw_sort_sprite_veh_health_bar(short sspr)
14731475
{
1474-
#if 1
1476+
#if 0
14751477
asm volatile (
1476-
"call ASM_draw_sort_sprite_tng\n"
1477-
: : "a" (a1));
1478+
"call ASM_draw_sort_sprite_veh_health_bar\n"
1479+
: : "a" (sspr));
14781480
return;
14791481
#endif
1482+
struct SortSprite *p_sspr;
1483+
struct Thing *p_thing;
1484+
ushort max_health;
1485+
short health;
1486+
ushort range_x;
1487+
short level_x;
1488+
ushort h;
1489+
1490+
p_sspr = &game_sort_sprites[sspr];
1491+
p_thing = p_sspr->PThing;
1492+
1493+
max_health = p_thing->U.UVehicle.MaxHealth;
1494+
health = p_thing->Health;
1495+
if (max_health == 0)
1496+
max_health = 1;
1497+
if (health < 0)
1498+
health = 0;
1499+
else if (health > max_health)
1500+
health = max_health + 1;
1501+
1502+
range_x = (40 * overall_scale) >> 8;
1503+
if (ingame.PanelPermutation == -3)
1504+
h = 42;
1505+
else
1506+
h = 19;
1507+
LbDrawBox(p_sspr->X - (range_x >> 1), p_sspr->Y, range_x + 4, 6, h);
1508+
1509+
level_x = range_x * health / max_health;
1510+
if (ingame.PanelPermutation == -3)
1511+
h = 33;
1512+
else
1513+
h = 15;
1514+
LbDrawBox(p_sspr->X - (range_x >> 1) + 2, p_sspr->Y + 1, level_x, 4, h);
14801515
}
14811516

1482-
void draw_object_face4e(ushort face4)
1517+
void draw_object_face4_deep_rdr(ushort face4)
14831518
{
14841519
#if 0
14851520
asm volatile (
1486-
"call ASM_draw_object_face4e\n"
1521+
"call ASM_draw_object_face4_deep_rdr\n"
14871522
: : "a" (face4));
14881523
return;
14891524
#endif
@@ -1575,11 +1610,11 @@ void draw_object_face4e(ushort face4)
15751610
}
15761611
}
15771612

1578-
void draw_object_face1d(ushort face)
1613+
void draw_object_face3_deep_rdr(ushort face)
15791614
{
15801615
#if 0
15811616
asm volatile (
1582-
"call ASM_draw_object_face1d\n"
1617+
"call ASM_draw_object_face3_deep_rdr\n"
15831618
: : "a" (face));
15841619
return;
15851620
#endif
@@ -1664,7 +1699,7 @@ void draw_fire_flame(ushort flm)
16641699
}
16651700
}
16661701

1667-
void draw_screen_number(ushort sospr)
1702+
void draw_sort_sprite_number(ushort sospr)
16681703
{
16691704
char locstr[50];
16701705
struct SortSprite *p_sospr;
@@ -1800,19 +1835,19 @@ void draw_drawitem_2(ushort dihead)
18001835
draw_phwoar(itm->Offset);
18011836
break;
18021837
case DrIT_Unkn22:
1803-
draw_sort_sprite_tng(itm->Offset);
1838+
draw_sort_sprite_veh_health_bar(itm->Offset);
18041839
break;
18051840
case DrIT_Unkn23:
1806-
draw_object_face4e(itm->Offset);
1841+
draw_object_face4_deep_rdr(itm->Offset);
18071842
break;
18081843
case DrIT_Unkn24:
1809-
draw_object_face1d(itm->Offset);
1844+
draw_object_face3_deep_rdr(itm->Offset);
18101845
break;
18111846
case DrIT_Unkn25:
18121847
draw_fire_flame(itm->Offset);
18131848
break;
18141849
case DrIT_Unkn26:
1815-
draw_screen_number(itm->Offset);
1850+
draw_sort_sprite_number(itm->Offset);
18161851
break;
18171852
default:
18181853
break;

src/swars.sx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22529,7 +22529,7 @@ GLOBAL_FUNC(ASM_draw_object_face1c) /* 0x027638 */
2252922529

2253022530

2253122531
/*----------------------------------------------------------------*/
22532-
GLOBAL_FUNC(ASM_draw_object_face1d) /* 0x027BBC */
22532+
GLOBAL_FUNC(ASM_draw_object_face3_deep_rdr) /* 0x027BBC */
2253322533
/*----------------------------------------------------------------*/
2253422534
push %ebx
2253522535
push %ecx
@@ -23243,7 +23243,7 @@ GLOBAL_FUNC(ASM_draw_object_face4d) /* 0x027D78 */
2324323243

2324423244

2324523245
/*----------------------------------------------------------------*/
23246-
GLOBAL_FUNC(ASM_draw_object_face4e) /* 0x028568 */
23246+
GLOBAL_FUNC(ASM_draw_object_face4_deep_rdr) /* 0x028568 */
2324723247
/*----------------------------------------------------------------*/
2324823248
push %ebx
2324923249
push %ecx
@@ -25921,7 +25921,7 @@ GLOBAL_FUNC(ASM_draw_falling_snow) /* 0x2AAA0 */
2592125921

2592225922

2592325923
/*----------------------------------------------------------------*/
25924-
GLOBAL_FUNC(ASM_draw_sort_sprite_tng) /* 0x02ABE0 */
25924+
GLOBAL_FUNC(ASM_draw_sort_sprite_veh_health_bar) /* 0x02ABE0 */
2592525925
/*----------------------------------------------------------------*/
2592625926
push %ebx
2592725927
push %ecx

0 commit comments

Comments
 (0)