2020-08-04 08:49:11 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
void clear_saved_variables(void) {
|
|
|
|
SaveData* saveFile = &gCurrentSaveFile;
|
|
|
|
s32 i;
|
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(saveFile->globalFlags); i++) {
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->globalFlags[i] = 0;
|
|
|
|
}
|
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(saveFile->globalBytes); i++) {
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->globalBytes[i] = 0;
|
|
|
|
}
|
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(saveFile->areaFlags); i++) {
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->areaFlags[i] = 0;
|
|
|
|
}
|
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(saveFile->areaBytes); i++) {
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->areaBytes[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
void clear_area_flags(void) {
|
|
|
|
SaveData* saveFile = &gCurrentSaveFile;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
if (GAME_STATUS->changedArea) {
|
2020-10-02 08:07:54 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(saveFile->areaFlags); i++) {
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->areaFlags[i] = 0;
|
|
|
|
}
|
2020-09-22 02:59:58 +02:00
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(saveFile->areaBytes); i++) {
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->areaBytes[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 clear_global_flag(s32 index) {
|
|
|
|
s32 wordIdx;
|
|
|
|
s32 bitIdx;
|
|
|
|
SaveData* saveFile;
|
|
|
|
s32 flag;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
if (index <= -120000000) {
|
|
|
|
index += 130000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
wordIdx = index / 32;
|
|
|
|
bitIdx = index % 32;
|
2020-09-22 02:59:58 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile = &gCurrentSaveFile;
|
|
|
|
flag = saveFile->globalFlags[wordIdx] & (1 << bitIdx);
|
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
if (flag != 0) {
|
2020-09-22 02:56:17 +02:00
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
saveFile->globalFlags[wordIdx] &= ~(1 << bitIdx);
|
|
|
|
return flag;
|
|
|
|
}
|
2020-09-20 02:12:28 +02:00
|
|
|
|
|
|
|
s32 set_global_flag(s32 index) {
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 wordIdx;
|
|
|
|
s32 bitIdx;
|
|
|
|
SaveData* saveFile;
|
2020-09-19 17:16:02 +02:00
|
|
|
s32 flag;
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-19 17:16:02 +02:00
|
|
|
if (index <= -120000000) {
|
|
|
|
index += 130000000;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
wordIdx = index / 32;
|
|
|
|
bitIdx = index % 32;
|
2020-09-22 02:59:58 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile = &gCurrentSaveFile;
|
|
|
|
flag = saveFile->globalFlags[wordIdx] & (1 << bitIdx);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-10-02 08:07:54 +02:00
|
|
|
if (flag != 0) {
|
2020-09-19 17:16:02 +02:00
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->globalFlags[wordIdx] |= (1 << bitIdx);
|
2020-09-19 17:16:02 +02:00
|
|
|
return flag;
|
2020-09-20 02:12:28 +02:00
|
|
|
}
|
2020-09-19 17:16:02 +02:00
|
|
|
|
2020-09-20 02:12:28 +02:00
|
|
|
s32 get_global_flag(s32 index) {
|
2020-09-19 17:16:02 +02:00
|
|
|
s32 wordIdx;
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 bitIdx;
|
|
|
|
s32 flag;
|
2020-09-19 17:16:02 +02:00
|
|
|
s32 phi_return;
|
|
|
|
|
|
|
|
if (index <= -120000000) {
|
|
|
|
index += 130000000;
|
2020-09-19 17:17:53 +02:00
|
|
|
}
|
2020-09-22 02:56:17 +02:00
|
|
|
|
2020-09-19 17:16:02 +02:00
|
|
|
wordIdx = index / 32;
|
|
|
|
bitIdx = index % 32;
|
2020-09-22 02:56:17 +02:00
|
|
|
flag = gCurrentSaveFile.globalFlags[wordIdx] & (1 << bitIdx);
|
2020-09-19 17:16:02 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
if (flag != 0) {
|
|
|
|
flag = 1;
|
2020-09-19 17:16:02 +02:00
|
|
|
}
|
2020-09-22 02:56:17 +02:00
|
|
|
return flag;
|
2020-09-20 02:12:28 +02:00
|
|
|
}
|
2020-09-22 02:56:17 +02:00
|
|
|
|
2020-09-19 17:16:02 +02:00
|
|
|
|
|
|
|
s8 set_global_byte(s32 index, s8 value) {
|
|
|
|
SaveData* saveFile = &gCurrentSaveFile;
|
|
|
|
s32 ret = saveFile->globalBytes[index];
|
|
|
|
|
|
|
|
saveFile->globalBytes[index] = value;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-09-22 05:10:53 +02:00
|
|
|
s32 get_global_byte(s32 index) {
|
2020-09-19 17:16:02 +02:00
|
|
|
return gCurrentSaveFile.globalBytes[index];
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 clear_area_flag(s32 index) {
|
|
|
|
s32 wordIdx = index / 32;
|
|
|
|
s32 bitIdx = index % 32;
|
2020-09-22 02:59:58 +02:00
|
|
|
SaveData* saveFile = &gCurrentSaveFile;
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 flag = saveFile->areaFlags[wordIdx] & (1 << bitIdx);
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
if (flag != 0) {
|
|
|
|
flag = 1;
|
|
|
|
}
|
2020-09-19 17:16:02 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->areaFlags[wordIdx] &= ~(1 << bitIdx);
|
|
|
|
return flag;
|
|
|
|
}
|
2020-09-19 17:16:02 +02:00
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 set_area_flag(s32 index) {
|
|
|
|
s32 wordIdx = index / 32;
|
|
|
|
s32 bitIdx = index % 32;
|
2020-09-22 02:59:58 +02:00
|
|
|
SaveData* saveFile = &gCurrentSaveFile;
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 flag = saveFile->areaFlags[wordIdx] & (1 << bitIdx);
|
2020-09-19 17:16:02 +02:00
|
|
|
|
|
|
|
if (flag != 0) {
|
|
|
|
flag = 1;
|
|
|
|
}
|
|
|
|
|
2020-09-22 02:56:17 +02:00
|
|
|
saveFile->areaFlags[wordIdx] |= 1 << bitIdx;
|
2020-09-19 17:16:02 +02:00
|
|
|
return flag;
|
2020-09-20 02:12:28 +02:00
|
|
|
}
|
2020-09-19 17:16:02 +02:00
|
|
|
|
|
|
|
s32 get_area_flag(s32 index) {
|
2020-09-22 02:56:17 +02:00
|
|
|
s32 wordIdx = index / 32;
|
|
|
|
s32 bitIdx = index % 32;
|
|
|
|
s32 flag = gCurrentSaveFile.areaFlags[wordIdx] & (1 << bitIdx);
|
2020-09-19 17:16:02 +02:00
|
|
|
|
|
|
|
if (flag != 0) {
|
|
|
|
flag = 1;
|
|
|
|
}
|
2020-09-22 02:56:17 +02:00
|
|
|
|
2020-09-19 17:16:02 +02:00
|
|
|
return flag;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-19 17:16:02 +02:00
|
|
|
s8 set_area_byte(s32 index, s8 value) {
|
|
|
|
SaveData* saveFile = &gCurrentSaveFile;
|
|
|
|
s32 ret = saveFile->areaBytes[index];
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-19 17:16:02 +02:00
|
|
|
saveFile->areaBytes[index] = value;
|
|
|
|
return ret;
|
|
|
|
}
|
2020-08-04 08:49:11 +02:00
|
|
|
|
2020-09-22 05:10:53 +02:00
|
|
|
s32 get_area_byte(s32 index) {
|
2020-09-19 17:16:02 +02:00
|
|
|
return gCurrentSaveFile.areaBytes[index];
|
|
|
|
}
|