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
12 frame = 0;
13 last_item = -1;
14 last_slot = -1;
15 enabled = true;
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
28void 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) {
39 frame = 0;
40 }
41 }
42}
43
45 int slot;
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) {
109 }
110
111 pending_volume = 0;
112 frame = 0;
113 }
114}
void CheckItemVolume()
void LoopStep(int interval)
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
ITEM_PACK item_pack
s16 item_vol[103]