Skip to content

Commit def5d67

Browse files
committed
Decompile bhEne00
1 parent fc89cb8 commit def5d67

File tree

2 files changed

+164
-122
lines changed

2 files changed

+164
-122
lines changed

src/ps2/veronica/prog/eneset.c

Lines changed: 153 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#include "eneset.h"
22
#include "MdlPut.h"
3+
#include "effect.h"
34
#include "face.h"
5+
#include "hitchk.h"
46
#include "light.h"
57
#include "njplus.h"
68
#include "pwksub.h"
9+
#include "weapon.h"
710
//#include "zonzon1.h"
811
#include "main.h"
912

1013
typedef void (*JumpEnemy_proc)();
1114

1215
JumpEnemy_proc bhJumpEnemy[100]; // DATA
13-
/*_anon23 En00CapColTab[5];
14-
BH_PWORK ene[0];
15-
_anon24* sys;
16-
BH_PWORK* plp;
17-
_anon9* rom;*/
16+
CPCL En00CapColTab[5]; // DATA
1817

1918
// 100% matching!
2019
void bhInitEnemy()
@@ -243,127 +242,159 @@ void bhControlEnemy()
243242
}
244243
}
245244

246-
/*//
247-
// Start address: 0x174c50
245+
// 98.23% matching (matches on GC)
248246
void bhEne00(BH_PWORK* ep)
249247
{
250-
_anon43 pnt;
251-
int i;
252-
_anon32 pos;
253-
_anon17* hp;
254-
// Line 628, Address: 0x174c50, Func Offset: 0
255-
// Line 632, Address: 0x174c60, Func Offset: 0x10
256-
// Line 634, Address: 0x174c8c, Func Offset: 0x3c
257-
// Line 653, Address: 0x174c90, Func Offset: 0x40
258-
// Line 640, Address: 0x174c94, Func Offset: 0x44
259-
// Line 643, Address: 0x174c98, Func Offset: 0x48
260-
// Line 634, Address: 0x174c9c, Func Offset: 0x4c
261-
// Line 640, Address: 0x174ca4, Func Offset: 0x54
262-
// Line 645, Address: 0x174ca8, Func Offset: 0x58
263-
// Line 646, Address: 0x174cac, Func Offset: 0x5c
264-
// Line 653, Address: 0x174cb0, Func Offset: 0x60
265-
// Line 654, Address: 0x174cb4, Func Offset: 0x64
266-
// Line 640, Address: 0x174cb8, Func Offset: 0x68
267-
// Line 642, Address: 0x174cc0, Func Offset: 0x70
268-
// Line 643, Address: 0x174ccc, Func Offset: 0x7c
269-
// Line 644, Address: 0x174cd8, Func Offset: 0x88
270-
// Line 645, Address: 0x174ce4, Func Offset: 0x94
271-
// Line 646, Address: 0x174ce8, Func Offset: 0x98
272-
// Line 647, Address: 0x174cec, Func Offset: 0x9c
273-
// Line 648, Address: 0x174cf0, Func Offset: 0xa0
274-
// Line 649, Address: 0x174cf4, Func Offset: 0xa4
275-
// Line 650, Address: 0x174cf8, Func Offset: 0xa8
276-
// Line 651, Address: 0x174cfc, Func Offset: 0xac
277-
// Line 652, Address: 0x174d00, Func Offset: 0xb0
278-
// Line 653, Address: 0x174d04, Func Offset: 0xb4
279-
// Line 654, Address: 0x174d08, Func Offset: 0xb8
280-
// Line 656, Address: 0x174d18, Func Offset: 0xc8
281-
// Line 657, Address: 0x174d1c, Func Offset: 0xcc
282-
// Line 659, Address: 0x174d24, Func Offset: 0xd4
283-
// Line 660, Address: 0x174d28, Func Offset: 0xd8
284-
// Line 663, Address: 0x174d2c, Func Offset: 0xdc
285-
// Line 657, Address: 0x174d30, Func Offset: 0xe0
286-
// Line 667, Address: 0x174d3c, Func Offset: 0xec
287-
// Line 680, Address: 0x174d40, Func Offset: 0xf0
288-
// Line 657, Address: 0x174d48, Func Offset: 0xf8
289-
// Line 658, Address: 0x174d5c, Func Offset: 0x10c
290-
// Line 680, Address: 0x174d68, Func Offset: 0x118
291-
// Line 658, Address: 0x174d70, Func Offset: 0x120
292-
// Line 659, Address: 0x174d8c, Func Offset: 0x13c
293-
// Line 660, Address: 0x174d90, Func Offset: 0x140
294-
// Line 661, Address: 0x174d94, Func Offset: 0x144
295-
// Line 665, Address: 0x174d98, Func Offset: 0x148
296-
// Line 661, Address: 0x174d9c, Func Offset: 0x14c
297-
// Line 663, Address: 0x174da0, Func Offset: 0x150
298-
// Line 664, Address: 0x174da4, Func Offset: 0x154
299-
// Line 665, Address: 0x174dac, Func Offset: 0x15c
300-
// Line 673, Address: 0x174dc0, Func Offset: 0x170
301-
// Line 665, Address: 0x174dc4, Func Offset: 0x174
302-
// Line 666, Address: 0x174dc8, Func Offset: 0x178
303-
// Line 667, Address: 0x174dd0, Func Offset: 0x180
304-
// Line 668, Address: 0x174dd4, Func Offset: 0x184
305-
// Line 669, Address: 0x174dd8, Func Offset: 0x188
306-
// Line 670, Address: 0x174ddc, Func Offset: 0x18c
307-
// Line 673, Address: 0x174de8, Func Offset: 0x198
308-
// Line 674, Address: 0x174dfc, Func Offset: 0x1ac
309-
// Line 675, Address: 0x174e00, Func Offset: 0x1b0
310-
// Line 676, Address: 0x174e04, Func Offset: 0x1b4
311-
// Line 677, Address: 0x174e08, Func Offset: 0x1b8
312-
// Line 678, Address: 0x174e0c, Func Offset: 0x1bc
313-
// Line 680, Address: 0x174e10, Func Offset: 0x1c0
314-
// Line 681, Address: 0x174e18, Func Offset: 0x1c8
315-
// Line 682, Address: 0x174e20, Func Offset: 0x1d0
316-
// Line 683, Address: 0x174e2c, Func Offset: 0x1dc
317-
// Line 685, Address: 0x174e30, Func Offset: 0x1e0
318-
// Line 682, Address: 0x174e34, Func Offset: 0x1e4
319-
// Line 683, Address: 0x174e50, Func Offset: 0x200
320-
// Line 685, Address: 0x174e54, Func Offset: 0x204
321-
// Line 687, Address: 0x174e58, Func Offset: 0x208
322-
// Line 688, Address: 0x174e5c, Func Offset: 0x20c
323-
// Line 690, Address: 0x174e64, Func Offset: 0x214
324-
// Line 691, Address: 0x174e70, Func Offset: 0x220
325-
// Line 690, Address: 0x174e74, Func Offset: 0x224
326-
// Line 691, Address: 0x174e8c, Func Offset: 0x23c
327-
// Line 693, Address: 0x174e98, Func Offset: 0x248
328-
// Line 698, Address: 0x174ea4, Func Offset: 0x254
329-
// Line 699, Address: 0x174ea8, Func Offset: 0x258
330-
// Line 701, Address: 0x174eb0, Func Offset: 0x260
331-
// Line 698, Address: 0x174eb4, Func Offset: 0x264
332-
// Line 699, Address: 0x174eb8, Func Offset: 0x268
333-
// Line 700, Address: 0x174ec4, Func Offset: 0x274
334-
// Line 701, Address: 0x174ec8, Func Offset: 0x278
335-
// Line 702, Address: 0x174ed0, Func Offset: 0x280
336-
// Line 704, Address: 0x174ed4, Func Offset: 0x284
337-
// Line 709, Address: 0x174ed8, Func Offset: 0x288
338-
// Line 702, Address: 0x174edc, Func Offset: 0x28c
339-
// Line 703, Address: 0x174ee4, Func Offset: 0x294
340-
// Line 704, Address: 0x174ef0, Func Offset: 0x2a0
341-
// Line 708, Address: 0x174efc, Func Offset: 0x2ac
342-
// Line 709, Address: 0x174f08, Func Offset: 0x2b8
343-
// Line 713, Address: 0x174f0c, Func Offset: 0x2bc
344-
// Line 714, Address: 0x174f14, Func Offset: 0x2c4
345-
// Line 715, Address: 0x174f1c, Func Offset: 0x2cc
346-
// Line 721, Address: 0x174f24, Func Offset: 0x2d4
347-
// Line 722, Address: 0x174f34, Func Offset: 0x2e4
348-
// Line 723, Address: 0x174f5c, Func Offset: 0x30c
349-
// Line 726, Address: 0x174f6c, Func Offset: 0x31c
350-
// Line 727, Address: 0x174f84, Func Offset: 0x334
351-
// Line 728, Address: 0x174f9c, Func Offset: 0x34c
352-
// Line 730, Address: 0x174fb4, Func Offset: 0x364
353-
// Line 732, Address: 0x174fc0, Func Offset: 0x370
354-
// Line 736, Address: 0x174fc4, Func Offset: 0x374
355-
// Line 732, Address: 0x174fcc, Func Offset: 0x37c
356-
// Line 733, Address: 0x174fd8, Func Offset: 0x388
357-
// Line 734, Address: 0x174fe8, Func Offset: 0x398
358-
// Line 735, Address: 0x174ff8, Func Offset: 0x3a8
359-
// Line 736, Address: 0x175000, Func Offset: 0x3b0
360-
// Line 737, Address: 0x17500c, Func Offset: 0x3bc
361-
// Line 738, Address: 0x175014, Func Offset: 0x3c4
362-
// Line 739, Address: 0x17501c, Func Offset: 0x3cc
363-
// Func End, Address: 0x175030, Func Offset: 0x3e0
248+
ATR_WORK* hp;
249+
NJS_POINT3 pos;
250+
int i;
251+
NJS_POINT6 pnt;
252+
253+
switch (ep->mode0)
254+
{
255+
case 0:
256+
ep->flg |= 0x8120;
257+
ep->flg &= ~0x6;
258+
259+
ep->flg2 |= 0x1;
260+
261+
ep->mdflg &= ~0x1;
262+
ep->mdflg |= 0x20;
263+
264+
ep->ar = 4.0f;
265+
ep->ah = 15.0f;
266+
267+
ep->aox = 0;
268+
ep->aoy = 0;
269+
ep->aoz = 0;
270+
271+
ep->car = 4.0f;
272+
ep->cah = 15.0f;
273+
274+
ep->hp = 0;
275+
276+
ep->cpcl = En00CapColTab;
277+
278+
if (!(ep->flg2 & 0x80000000))
279+
{
280+
ep->flg2 |= 0x80000000;
281+
282+
ep->ct0 = sys->mwal_n++;
283+
284+
hp = &sys->mwalp[ep->ct0];
285+
286+
hp->flg = 0x81;
287+
288+
hp->type = 3;
289+
290+
hp->flr_no = ep->flr_no;
291+
292+
hp->attr = 8;
293+
294+
hp->px = ep->px;
295+
hp->py = rom->grand[hp->flr_no + 2];
296+
hp->pz = ep->pz;
297+
298+
hp->w = 3.5f;
299+
hp->h = 15.0f;
300+
301+
hp->d = 0;
302+
303+
hp->prm2 = 0;
304+
hp->prm1 = 0;
305+
hp->prm0 = 0;
306+
hp->prm3 = sys->enow;
307+
308+
pnt.px = 0;
309+
pnt.py = 0;
310+
pnt.pz = 0;
311+
312+
pnt.ox = 0;
313+
pnt.oy = 0;
314+
pnt.oz = 0;
315+
316+
bhSetEffect(17, &pnt, (unsigned char*)ep, 0);
317+
}
318+
else
319+
{
320+
hp = &sys->mwalp[ep->ct0];
321+
322+
hp->flg = 0x81;
323+
324+
hp->attr = 8;
325+
}
326+
327+
ep->mode0 = 1;
328+
break;
329+
case 1:
330+
hp = &sys->mwalp[ep->ct0];
331+
332+
if (((ep->flg & 0x4)) && (ep->wpnr_no != 2))
333+
{
334+
pos.x = ep->px;
335+
pos.y = 10.0f + ep->py;
336+
pos.z = ep->pz;
337+
338+
bhSetExplosion(&pos);
339+
340+
ep->flg |= 0x2;
341+
342+
ep->mdflg |= 0x1;
343+
344+
ep->flg &= ~0x78;
345+
346+
hp->flg &= ~0x1;
347+
348+
ep->mode0 = 2;
349+
}
350+
351+
hp->px = ep->px;
352+
hp->py = ep->py;
353+
hp->pz = ep->pz;
354+
break;
355+
case 2:
356+
break;
357+
}
358+
359+
if ((ep->flg & 0x4))
360+
{
361+
for (i = 0; i < ep->mlwP->obj_num; i++)
362+
{
363+
ep->dam[i] = 0;
364+
}
365+
366+
ep->flg &= ~0x4;
367+
}
368+
369+
if ((ep->flg & 0x40))
370+
{
371+
bhCheckPlayer(ep);
372+
}
373+
374+
if ((ep->flg & 0x8))
375+
{
376+
bhCheckEnemies(ep);
377+
}
378+
379+
if ((ep->flg & 0x10))
380+
{
381+
bhCheckWall(ep);
382+
}
383+
384+
bhCalcModel(ep);
385+
386+
ep->watr.c1.x = ep->mlwP->owP->mtx[12];
387+
ep->watr.c1.y = ep->mlwP->owP->mtx[13];
388+
ep->watr.c1.z = ep->mlwP->owP->mtx[14];
389+
390+
ep->watr.c2.x = ep->watr.c1.x;
391+
ep->watr.c2.y = 15.0f + ep->watr.c1.y;
392+
ep->watr.c2.z = ep->watr.c1.z;
393+
394+
ep->watr.r = ep->car;
364395
}
365396

366-
//
397+
/*//
367398
// Start address: 0x175030
368399
void bhEne56(BH_PWORK* ep)
369400
{

src/ps2/veronica/prog/types.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,17 @@ typedef struct NJS_POINT4
924924
float w; // offset 0xC, size 0x4
925925
} NJS_POINT4;
926926

927+
typedef struct NJS_POINT6
928+
{
929+
// total size: 0x18
930+
float px; // offset 0x0, size 0x4
931+
float py; // offset 0x4, size 0x4
932+
float pz; // offset 0x8, size 0x4
933+
float ox; // offset 0xC, size 0x4
934+
float oy; // offset 0x10, size 0x4
935+
float oz; // offset 0x14, size 0x4
936+
} NJS_POINT6;
937+
927938
typedef struct PLANE
928939
{
929940
// total size: 0x8

0 commit comments

Comments
 (0)