blob: c0ddc1890c6d4fb7a3192791022d5006f2fc3324 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#include "global.h"
#include "room.h"
#include "enemy.h"
#include "common.h"
extern void MemFill32(u32, void*, u32);
void UpdateCurrentRoom(RoomMemory*);
RoomMemory* AddCurrentRoom(void);
void ClearRoomMemory(void) {
MemFill32(0xFFFFFFFF, gRoomMemory, 0x40);
gCurrentRoomMemory = gRoomMemory;
}
void EnemyDisableRespawn(Enemy* ent) {
u8 idx = ent->idx;
if (idx & 0x80) {
gCurrentRoomMemory->enemyBits |= 1 << (idx & 0x1f);
}
}
u32 EnemyEnableRespawn(u32 enemyIdx) {
u32 bitmask = gCurrentRoomMemory->enemyBits >> enemyIdx;
u32 output = 1;
output &= ~bitmask;
return output;
}
void UpdateRoomTracker(void) {
gCurrentRoomMemory = gRoomMemory;
do {
if (gCurrentRoomMemory->area == gRoomControls.area && gCurrentRoomMemory->room == gRoomControls.room) {
UpdateCurrentRoom(gCurrentRoomMemory);
return;
}
gCurrentRoomMemory++;
} while (gCurrentRoomMemory < gRoomMemory + 8);
gCurrentRoomMemory = AddCurrentRoom();
}
RoomMemory* AddCurrentRoom(void) {
RoomMemory* rm = gRoomMemory;
RoomMemory* r1 = rm + 1;
do {
if (r1->unk_02 > rm->unk_02) {
rm = r1;
}
r1++;
} while (r1 < gRoomMemory + 8);
rm->area = gRoomControls.area;
rm->room = gRoomControls.room;
rm->unk_02 = 0xFFFF;
rm->enemyBits = 0;
UpdateCurrentRoom(rm);
return rm;
}
void UpdateCurrentRoom(RoomMemory* rm) {
RoomMemory* r1 = gRoomMemory;
do {
if (r1->unk_02 < rm->unk_02) {
r1->unk_02++;
}
r1++;
} while (r1 < gRoomMemory + 8);
rm->unk_02 = 0;
}
|