DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
menuitemstep.cpp
1
#pragma helper_mask_gpr 0x30
2
#pragma helper_mask_fpr 0x1000
3
#include "menuitemstep.hpp"
4
5
#include <cstring>
6
7
#include "dngstatusdata.hpp"
8
#include "
itemdata.hpp
"
9
#include "
savedata.hpp
"
10
11
void
CMenuItemStep::Initialize
() {
12
frame
= 0;
13
last_item
= -1;
14
last_slot
= -1;
15
enabled
=
true
;
16
pending_volume
= 0;
17
18
for
(
int
i = 0; i < 4; i++) {
19
held_item
[i] = 0;
20
}
21
22
for
(
int
i = 0; i < 4; i++) {
23
chara_slot
[i] = -1;
24
chara_item
[i] = -1;
25
}
26
}
27
28
void
CMenuItemStep::LoopStep
(
int
interval) {
29
if
(
enabled
!= 0) {
30
// A negative interval asks for the default of one second.
31
if
(
interval
< 0) {
32
interval
= 60;
33
}
34
35
frame
++;
36
37
if
(
frame
>=
interval
) {
38
pending_volume
++;
39
frame
= 0;
40
}
41
}
42
}
43
44
void
CMenuItemStep::CheckItemVolume
() {
45
int
slot;
46
ITEM_PACK
*
pack
;
47
int
elapsed
=
pending_volume
;
48
49
if
(
elapsed
> 0) {
50
int
preservation
[100];
51
memset
(
preservation
, 0,
sizeof
(
preservation
));
52
pack
= &SaveData->
GetDngStatus
()->
item_pack
;
53
chara_no
= 0;
54
55
for
(slot = 0; slot <
pack
->num; slot++) {
56
if
(
pack
->item[slot] == ITEM_ICE_BLOCK ||
pack
->item[slot] == ITEM_SMALL_ICE ||
pack
->item[slot] == ITEM_TINY_ICE) {
57
int
neighbor
[4] = {-1, -1, -1, -1};
58
int
row = slot / 5;
59
60
if
(row != 0) {
61
preservation
[slot - 5] += 100;
62
}
63
64
if
(row !=
pack
->num / 5) {
65
preservation
[slot + 5] += 100;
66
}
67
68
int
column = slot % 5;
69
70
if
(column != 0) {
71
preservation
[slot - 1] += 100;
72
}
73
74
if
(column != 4) {
75
preservation
[slot + 1] += 100;
76
}
77
78
pack
->
item_vol
[slot] -=
elapsed
;
79
80
if
(
pack
->item_vol[slot] <= 0) {
81
pack
->item[slot]++;
82
83
if
(
pack
->item[slot] >= ITEM_TINY_ICE + 1) {
84
pack
->item[slot] = -1;
85
}
else
{
86
pack
->item_vol[slot] = GetItemData(
pack
->item[slot])->
vol
;
87
}
88
}
89
}
90
}
91
92
for
(slot = 0; slot <
pack
->num; slot++) {
93
if
(
pack
->item[slot] == ITEM_FLAPPING_FISH) {
94
if
(
preservation
[slot] > 100) {
95
preservation
[slot] = 100;
96
}
97
98
int
loss
=
elapsed
* (
float
) (100.0f -
preservation
[slot]) / 100.0f;
99
pack
->item_vol[slot] =
pack
->item_vol[slot] -
loss
;
100
101
if
(
pack
->item_vol[slot] <= 0) {
102
pack
->item[slot]++;
103
}
104
}
105
}
106
107
if
(
held_item
[
chara_no
] >= ITEM_DUNGEON_START) {
108
dungeon_item_held
= 1;
109
}
110
111
pending_volume
= 0;
112
frame
= 0;
113
}
114
}
CMenuItemStep::chara_slot
s16 chara_slot[4]
Definition
menuitemstep.hpp:17
CMenuItemStep::held_item
s16 held_item[4]
Definition
menuitemstep.hpp:16
CMenuItemStep::CheckItemVolume
void CheckItemVolume()
Definition
menuitemstep.cpp:44
CMenuItemStep::last_item
s16 last_item
Definition
menuitemstep.hpp:12
CMenuItemStep::pending_volume
s32 pending_volume
Definition
menuitemstep.hpp:19
CMenuItemStep::enabled
s16 enabled
Definition
menuitemstep.hpp:14
CMenuItemStep::chara_no
s16 chara_no
Definition
menuitemstep.hpp:15
CMenuItemStep::Initialize
void Initialize()
Definition
menuitemstep.cpp:11
CMenuItemStep::LoopStep
void LoopStep(int interval)
Definition
menuitemstep.cpp:28
CMenuItemStep::chara_item
s16 chara_item[4]
Definition
menuitemstep.hpp:18
CMenuItemStep::frame
s32 frame
Definition
menuitemstep.hpp:10
CMenuItemStep::last_slot
s32 last_slot
Definition
menuitemstep.hpp:11
CMenuItemStep::dungeon_item_held
s16 dungeon_item_held
Definition
menuitemstep.hpp:13
CSaveData::GetDngStatus
CDngStatusData * GetDngStatus()
Definition
savedata.cpp:250
CUserStatus::item_pack
ITEM_PACK item_pack
Definition
userstatus.hpp:117
itemdata.hpp
savedata.hpp
ITEM_DATA::vol
s16 vol
Definition
itemdata.hpp:529
ITEM_PACK
Definition
userstatus.hpp:53
ITEM_PACK::item_vol
s16 item_vol[103]
Definition
userstatus.hpp:59
ps2
src
menuitemstep.cpp
Generated by
1.9.8