Skip to content

Commit 73f2702

Browse files
committed
syndwarsfx: Remade more check_mouse_overlap*() functs
1 parent a837993 commit 73f2702

2 files changed

Lines changed: 82 additions & 12 deletions

File tree

src/engindrwlstx.c

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ ushort next_special_face = 1;
6666
ushort next_special_face4 = 1;
6767

6868
extern long dword_176CC4;
69+
70+
extern struct Thing *dword_176CC8;
71+
extern int dword_176CCC;
72+
extern int dword_176CD0;
73+
6974
extern long unkn1_pos_x;
7075
extern long unkn1_pos_y;
7176
extern struct TbSprite *unkn1_spr;
@@ -708,7 +713,7 @@ ubyte check_mouse_overlap_item(ushort sspr)
708713
if ( VX )
709714
{
710715
if (VX < 12 || VX > 13)
711-
return;
716+
return 0;
712717
box.X -= (box.Width >> 1);
713718
box.Y -= (box.Height >> 1);
714719
box.Width *= 2;
@@ -726,20 +731,85 @@ ubyte check_mouse_overlap_item(ushort sspr)
726731

727732
ubyte check_mouse_overlap_corpse(ushort sspr)
728733
{
734+
#if 0
729735
ubyte ret;
730736
asm volatile (
731737
"call ASM_check_mouse_overlap_corpse\n"
732738
: "=r" (ret) : "a" (sspr));
733739
return ret;
740+
#endif
741+
struct ScreenBoxBase box;
742+
struct SortSprite *p_sspr;
743+
struct Frame *p_frm;
744+
PlayerInfo *p_locplayer;
745+
746+
p_sspr = &game_sort_sprites[sspr];
747+
box.X = p_sspr->X + ((overall_scale * word_1A5834) >> 8);
748+
box.Y = p_sspr->Y + ((overall_scale * word_1A5836) >> 8);
749+
750+
p_frm = &frame[p_sspr->Frame];
751+
box.Width = (overall_scale * p_frm->SWidth) >> 9;
752+
box.Height = (overall_scale * p_frm->SHeight) >> 9;
753+
754+
p_locplayer = &players[local_player_no];
755+
if (box.Width < 16)
756+
{
757+
box.X -= ((17 - box.Width) >> 1);
758+
box.Width = 16;
759+
}
760+
if (box.Height < 20) {
761+
box.Y -= ((21 - box.Height) >> 1);
762+
box.Height = 20;
763+
}
764+
765+
if (in_box(lbDisplay.MMouseX, lbDisplay.MMouseY, box.X, box.Y, box.Width, box.Height))
766+
{
767+
p_locplayer->Target = p_sspr->PThing->ThingOffset;
768+
p_locplayer->TargetType = TrgTp_Unkn1;
769+
return 1;
770+
}
771+
return 0;
734772
}
735773

736774
ubyte check_mouse_over_unkn2(ushort sspr, struct Thing *p_thing)
737775
{
776+
#if 0
738777
ubyte ret;
739778
asm volatile (
740779
"call ASM_check_mouse_over_unkn2\n"
741780
: "=r" (ret) : "a" (sspr), "d" (p_thing));
742781
return ret;
782+
#endif
783+
struct ScreenBoxBase box;
784+
struct SortSprite *p_sspr;
785+
struct Frame *p_frm;
786+
787+
p_sspr = &game_sort_sprites[sspr];
788+
box.X = p_sspr->X + ((overall_scale * word_1A5834) >> 8);
789+
box.Y = p_sspr->Y + ((overall_scale * word_1A5836) >> 8);
790+
791+
p_frm = &frame[p_sspr->Frame];
792+
box.Width = (overall_scale * p_frm->SWidth) >> 9;
793+
box.Height = (overall_scale * p_frm->SHeight) >> 9;
794+
795+
if (box.Width < 16)
796+
{
797+
box.X -= ((17 - box.Width) >> 1);
798+
box.Width = 16;
799+
}
800+
if (box.Height < 20) {
801+
box.Y -= ((21 - box.Height) >> 1);
802+
box.Height = 20;
803+
}
804+
805+
if (in_box(lbDisplay.MMouseX, lbDisplay.MMouseY, box.X, box.Y, box.Width, box.Height))
806+
{
807+
dword_176CC8 = p_thing;
808+
dword_176CD0 = box.Y - 8;
809+
dword_176CCC = box.X + (box.Height >> 1);
810+
return 1;
811+
}
812+
return 0;
743813
}
744814

745815
void check_mouse_over_face(struct PolyPoint *pt1, struct PolyPoint *pt2,

src/swars.sx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,7 +2868,7 @@ GLOBAL_FUNC(ASM_draw_engine_net_text) /* 0x020B50 */
28682868
push %edi
28692869
push %ebp
28702870
sub $0x28,%esp
2871-
mov data_176cc8,%edx
2871+
mov EXPORT_SYMBOL(dword_176CC8),%edx
28722872
test %edx,%edx
28732873
je jump_20c57
28742874
mov 0x54(%edx),%ax
@@ -2906,7 +2906,7 @@ GLOBAL_FUNC(ASM_draw_engine_net_text) /* 0x020B50 */
29062906
test %bl,%bl
29072907
jne jump_20ba2
29082908
jump_20bb5:
2909-
mov data_176cc8,%eax
2909+
mov EXPORT_SYMBOL(dword_176CC8),%eax
29102910
mov %esp,%edi
29112911
mov 0x54(%eax),%ax
29122912
and $0xffff,%eax
@@ -2915,8 +2915,8 @@ GLOBAL_FUNC(ASM_draw_engine_net_text) /* 0x020B50 */
29152915
mov EXPORT_SYMBOL(net_player_colours)(%eax),%al
29162916
mov (%esp),%bh
29172917
mov %al,0x24(%esp)
2918-
mov data_176cd0,%eax
2919-
mov data_176ccc,%esi
2918+
mov EXPORT_SYMBOL(dword_176CD0),%eax
2919+
mov EXPORT_SYMBOL(dword_176CCC),%esi
29202920
mov %eax,0x20(%esp)
29212921
xor %eax,%eax
29222922
test %bh,%bh
@@ -2959,7 +2959,7 @@ GLOBAL_FUNC(ASM_draw_engine_net_text) /* 0x020B50 */
29592959
jne jump_20c19
29602960
jump_20c4f:
29612961
xor %ebx,%ebx
2962-
mov %ebx,data_176cc8
2962+
mov %ebx,EXPORT_SYMBOL(dword_176CC8)
29632963
jump_20c57:
29642964
add $0x28,%esp
29652965
pop %ebp
@@ -6625,13 +6625,13 @@ GLOBAL_FUNC(ASM_check_mouse_over_unkn2)
66256625
je jump_2541f
66266626
jump_25401:
66276627
mov -0xc(%ebp),%eax
6628-
mov %eax,data_176cc8
6628+
mov %eax,EXPORT_SYMBOL(dword_176CC8)
66296629
mov -0x8(%ebp),%eax
66306630
sar %eax
66316631
sub $0x8,%esi
66326632
add %eax,%edi
6633-
mov %esi,data_176cd0
6634-
mov %edi,data_176ccc
6633+
mov %esi,EXPORT_SYMBOL(dword_176CD0)
6634+
mov %edi,EXPORT_SYMBOL(dword_176CCC)
66356635
jump_2541f:
66366636
mov %ebp,%esp
66376637
pop %ebp
@@ -182805,11 +182805,11 @@ GLOBAL (dword_176CC0) /* 0x176CC0 */
182805182805
.long 0x0
182806182806
GLOBAL (dword_176CC4) /* 0x176CC4 */
182807182807
.long 0x0
182808-
data_176cc8:
182808+
GLOBAL (dword_176CC8) /* 0x176CC8 */
182809182809
.long 0x0
182810-
data_176ccc:
182810+
GLOBAL (dword_176CCC) /* 0x176CCC */
182811182811
.long 0x0
182812-
data_176cd0:
182812+
GLOBAL (dword_176CD0) /* 0x176CD0 */
182813182813
.long 0x0
182814182814
GLOBAL (unkn1_pos_x) /* 0x176CD4 */
182815182815
.long 0x0

0 commit comments

Comments
 (0)