summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2020-07-14 19:58:38 -0400
committerGitHub <noreply@github.com>2020-07-14 19:58:38 -0400
commit3c356a1d7af543d84c06f28f670b6ddc4b27fdd6 (patch)
treeeb8f0ae6435b7fe9515928f6fedba5c872aa5827
parent6f3c7925775bedb2195c9be03ab38a3fcee23836 (diff)
parentbeeb673ba16e02cacadb2de0ee3608d2106ed14a (diff)
Merge pull request #1082 from GriffinRichards/add-flagvarsave
Allow flag/var counts to be updated alongside values
-rw-r--r--include/constants/flags.h8
-rw-r--r--include/constants/global.h2
-rw-r--r--include/constants/opponents.h1
-rw-r--r--include/constants/vars.h1
-rw-r--r--include/event_data.h3
-rw-r--r--include/global.h11
-rw-r--r--src/bike.c1
-rw-r--r--src/braille_puzzles.c1
-rw-r--r--src/contest.c1
-rw-r--r--src/contest_link.c1
-rw-r--r--src/contest_util.c1
-rw-r--r--src/credits.c1
-rw-r--r--src/easy_chat.c1
-rwxr-xr-xsrc/faraway_island.c2
-rw-r--r--src/field_door.c1
-rw-r--r--src/field_player_avatar.c1
-rw-r--r--src/field_special_scene.c1
-rw-r--r--src/field_specials.c1
-rw-r--r--src/field_tasks.c1
-rw-r--r--src/fldeff_misc.c1
-rw-r--r--src/gym_leader_rematch.c1
-rwxr-xr-xsrc/item_use.c2
-rw-r--r--src/main_menu.c1
-rw-r--r--src/mauville_old_man.c1
-rw-r--r--src/menu.c1
-rw-r--r--src/mirage_tower.c1
-rw-r--r--src/naming_screen.c1
-rwxr-xr-xsrc/party_menu.c2
-rwxr-xr-xsrc/pokedex_area_screen.c1
-rwxr-xr-xsrc/pokenav_match_call_1.c1
-rw-r--r--src/post_battle_event_funcs.c1
-rw-r--r--src/region_map.c1
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c1
-rwxr-xr-xsrc/trainer_card.c1
-rw-r--r--src/union_room_player_avatar.c1
35 files changed, 16 insertions, 42 deletions
diff --git a/include/constants/flags.h b/include/constants/flags.h
index 4dd18880f..a9c7abae1 100644
--- a/include/constants/flags.h
+++ b/include/constants/flags.h
@@ -1573,7 +1573,9 @@
#define FLAG_UNUSED_0x91F (SYSTEM_FLAGS + 0xBF) // Unused Flag
// Daily Flags
-#define DAILY_FLAGS_START 0x920
+// These flags are cleared once per day
+// The start and end are byte-aligned because the flags are cleared in byte increments
+#define DAILY_FLAGS_START (FLAG_UNUSED_0x91F + (8 - FLAG_UNUSED_0x91F % 8))
#define FLAG_UNUSED_0x920 (DAILY_FLAGS_START + 0x0) // Unused Flag
#define FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY (DAILY_FLAGS_START + 0x1)
#define FLAG_DAILY_SECRET_BASE (DAILY_FLAGS_START + 0x2)
@@ -1639,7 +1641,9 @@
#define FLAG_UNUSED_0x95D (DAILY_FLAGS_START + 0x3D) // Unused Flag
#define FLAG_UNUSED_0x95E (DAILY_FLAGS_START + 0x3E) // Unused Flag
#define FLAG_UNUSED_0x95F (DAILY_FLAGS_START + 0x3F) // Unused Flag
-#define DAILY_FLAGS_END FLAG_UNUSED_0x95F
+#define DAILY_FLAGS_END (FLAG_UNUSED_0x95F + (7 - FLAG_UNUSED_0x95F % 8))
+
+#define FLAGS_COUNT (DAILY_FLAGS_END + 1)
// Special Flags (Stored in EWRAM (gSpecialFlags), not in the SaveBlock)
#define SPECIAL_FLAGS_START 0x4000
diff --git a/include/constants/global.h b/include/constants/global.h
index 956f86a05..98f15e7dc 100644
--- a/include/constants/global.h
+++ b/include/constants/global.h
@@ -34,8 +34,6 @@
#define POKEBLOCKS_COUNT 40
#define OBJECT_EVENTS_COUNT 16
#define BERRY_TREES_COUNT 128
-#define FLAGS_COUNT 300
-#define VARS_COUNT 256
#define MAIL_COUNT 16
#define SECRET_BASES_COUNT 20
#define TV_SHOWS_COUNT 25
diff --git a/include/constants/opponents.h b/include/constants/opponents.h
index cd35cf6b7..c9cf9239d 100644
--- a/include/constants/opponents.h
+++ b/include/constants/opponents.h
@@ -859,6 +859,7 @@
// NOTE: Because each Trainer uses a flag to determine when they are defeated, there is only space for 9 additional trainers before trainer flag space overflows
// More space can be made by shifting flags around in constants/flags.h or changing how trainer flags are handled
+// MAX_TRAINERS_COUNT can be increased but will take up additional saveblock space
#define TRAINERS_COUNT 855
#define MAX_TRAINERS_COUNT 864
diff --git a/include/constants/vars.h b/include/constants/vars.h
index 4a38bde81..625c37aa9 100644
--- a/include/constants/vars.h
+++ b/include/constants/vars.h
@@ -274,6 +274,7 @@
#define VAR_UNUSED_0x40FF 0x40FF // Unused Var
#define VARS_END 0x40FF
+#define VARS_COUNT (VARS_END - VARS_START + 1)
#define SPECIAL_VARS_START 0x8000
// special vars
diff --git a/include/event_data.h b/include/event_data.h
index 53999320f..8b4510e39 100644
--- a/include/event_data.h
+++ b/include/event_data.h
@@ -1,9 +1,6 @@
#ifndef GUARD_EVENT_DATA_H
#define GUARD_EVENT_DATA_H
-#include "constants/flags.h"
-#include "constants/vars.h"
-
void InitEventData(void);
void ClearTempFieldEventData(void);
void ClearDailyFlags(void);
diff --git a/include/global.h b/include/global.h
index abcf1d545..9612a25f0 100644
--- a/include/global.h
+++ b/include/global.h
@@ -6,6 +6,8 @@
#include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines.
#include "gba/gba.h"
#include "constants/global.h"
+#include "constants/flags.h"
+#include "constants/vars.h"
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
@@ -109,6 +111,11 @@
f; \
})
+#define ROUND_BITS_TO_BYTES(numBits)(((numBits) / 8) + (((numBits) % 8) ? 1 : 0))
+
+#define DEX_FLAGS_NO (ROUND_BITS_TO_BYTES(POKEMON_SLOTS_NUMBER))
+#define NUM_FLAG_BYTES (ROUND_BITS_TO_BYTES(FLAGS_COUNT))
+
struct Coords8
{
s8 x;
@@ -153,8 +160,6 @@ struct Time
/*0x04*/ s8 seconds;
};
-#define DEX_FLAGS_NO ((POKEMON_SLOTS_NUMBER / 8) + ((POKEMON_SLOTS_NUMBER % 8) ? 1 : 0))
-
struct Pokedex
{
/*0x00*/ u8 order;
@@ -923,7 +928,7 @@ struct SaveBlock1
/*0x9CA*/ u8 trainerRematches[MAX_REMATCH_ENTRIES];
/*0xA30*/ struct ObjectEvent objectEvents[OBJECT_EVENTS_COUNT];
/*0xC70*/ struct ObjectEventTemplate objectEventTemplates[OBJECT_EVENT_TEMPLATES_COUNT];
- /*0x1270*/ u8 flags[FLAGS_COUNT];
+ /*0x1270*/ u8 flags[NUM_FLAG_BYTES];
/*0x139C*/ u16 vars[VARS_COUNT];
/*0x159C*/ u32 gameStats[NUM_GAME_STATS];
/*0x169C*/ struct BerryTree berryTrees[BERRY_TREES_COUNT];
diff --git a/src/bike.c b/src/bike.c
index cd24d2487..3685ebfad 100644
--- a/src/bike.c
+++ b/src/bike.c
@@ -7,7 +7,6 @@
#include "metatile_behavior.h"
#include "overworld.h"
#include "sound.h"
-#include "constants/flags.h"
#include "constants/map_types.h"
#include "constants/songs.h"
diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c
index c00be82ad..f9f06823a 100644
--- a/src/braille_puzzles.c
+++ b/src/braille_puzzles.c
@@ -6,7 +6,6 @@
#include "sound.h"
#include "task.h"
#include "constants/field_effects.h"
-#include "constants/flags.h"
#include "constants/maps.h"
#include "constants/songs.h"
#include "constants/species.h"
diff --git a/src/contest.c b/src/contest.c
index 314ebb381..0b56569cb 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -7,7 +7,6 @@
#include "constants/moves.h"
#include "constants/songs.h"
#include "constants/species.h"
-#include "constants/flags.h"
#include "battle.h"
#include "battle_anim.h"
#include "contest.h"
diff --git a/src/contest_link.c b/src/contest_link.c
index eb688f55e..692c58603 100644
--- a/src/contest_link.c
+++ b/src/contest_link.c
@@ -7,7 +7,6 @@
#include "random.h"
#include "task.h"
#include "contest_link.h"
-#include "constants/flags.h"
static void sub_80FC5C0(u8);
static void sub_80FC5DC(u8);
diff --git a/src/contest_util.c b/src/contest_util.c
index 22074e1a1..e82560a6e 100644
--- a/src/contest_util.c
+++ b/src/contest_util.c
@@ -41,7 +41,6 @@
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/tv.h"
-#include "constants/vars.h"
#include "contest.h"
enum {
diff --git a/src/credits.c b/src/credits.c
index dd1166d82..8fc8a1f88 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -20,7 +20,6 @@
#include "trig.h"
#include "graphics.h"
#include "pokedex.h"
-#include "constants/vars.h"
#include "event_data.h"
#include "random.h"
#include "constants/species.h"
diff --git a/src/easy_chat.c b/src/easy_chat.c
index 2a4c49213..44a7b90c1 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -29,7 +29,6 @@
#include "window.h"
#include "constants/easy_chat.h"
#include "constants/event_objects.h"
-#include "constants/flags.h"
#include "constants/lilycove_lady.h"
#include "constants/mauville_old_man.h"
#include "constants/songs.h"
diff --git a/src/faraway_island.c b/src/faraway_island.c
index 2ac9d5c1f..06e47cd21 100755
--- a/src/faraway_island.c
+++ b/src/faraway_island.c
@@ -6,10 +6,8 @@
#include "metatile_behavior.h"
#include "sprite.h"
#include "constants/event_objects.h"
-#include "constants/flags.h"
#include "constants/maps.h"
#include "constants/metatile_behaviors.h"
-#include "constants/vars.h"
static u8 sub_81D4890(u8);
static bool8 sub_81D4C14(struct ObjectEvent*, u8);
diff --git a/src/field_door.c b/src/field_door.c
index b4794349c..e81c3dc4b 100644
--- a/src/field_door.c
+++ b/src/field_door.c
@@ -5,7 +5,6 @@
#include "fieldmap.h"
#include "metatile_behavior.h"
#include "task.h"
-#include "constants/flags.h"
#include "constants/maps.h"
#include "constants/songs.h"
#include "constants/metatile_labels.h"
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index b0918a78d..f5f6e99f7 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -25,7 +25,6 @@
#include "constants/event_objects.h"
#include "constants/event_object_movement.h"
#include "constants/field_effects.h"
-#include "constants/flags.h"
#include "constants/maps.h"
#include "constants/moves.h"
#include "constants/songs.h"
diff --git a/src/field_special_scene.c b/src/field_special_scene.c
index 540bcd1d4..3a3367957 100644
--- a/src/field_special_scene.c
+++ b/src/field_special_scene.c
@@ -17,7 +17,6 @@
#include "constants/event_object_movement.h"
#include "constants/field_specials.h"
#include "constants/songs.h"
-#include "constants/vars.h"
#include "constants/metatile_labels.h"
#define SECONDS(value) ((signed) (60.0 * value + 0.5))
diff --git a/src/field_specials.c b/src/field_specials.c
index e806440f7..6d212b4c9 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -63,7 +63,6 @@
#include "constants/species.h"
#include "constants/moves.h"
#include "constants/party_menu.h"
-#include "constants/vars.h"
#include "constants/battle_frontier.h"
#include "constants/weather.h"
#include "constants/metatile_labels.h"
diff --git a/src/field_tasks.c b/src/field_tasks.c
index 21b2732c3..901535677 100644
--- a/src/field_tasks.c
+++ b/src/field_tasks.c
@@ -19,7 +19,6 @@
#include "constants/field_tasks.h"
#include "constants/items.h"
#include "constants/songs.h"
-#include "constants/vars.h"
#include "constants/metatile_labels.h"
struct PacifidlogMetatileOffsets
diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c
index ab04e47ff..410af9fdd 100644
--- a/src/fldeff_misc.c
+++ b/src/fldeff_misc.c
@@ -23,7 +23,6 @@
#include "constants/metatile_labels.h"
#include "constants/songs.h"
#include "constants/tv.h"
-#include "constants/vars.h"
EWRAM_DATA struct MapPosition gPlayerFacingPosition = {0};
diff --git a/src/gym_leader_rematch.c b/src/gym_leader_rematch.c
index 355ae5534..efe874894 100644
--- a/src/gym_leader_rematch.c
+++ b/src/gym_leader_rematch.c
@@ -1,5 +1,4 @@
#include "global.h"
-#include "constants/flags.h"
#include "random.h"
#include "event_data.h"
#include "battle_setup.h"
diff --git a/src/item_use.c b/src/item_use.c
index ff689a19a..0aae441c8 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -38,11 +38,9 @@
#include "text.h"
#include "constants/event_bg.h"
#include "constants/event_objects.h"
-#include "constants/flags.h"
#include "constants/item_effects.h"
#include "constants/items.h"
#include "constants/songs.h"
-#include "constants/vars.h"
static void SetUpItemUseCallback(u8 taskId);
static void FieldCB_UseItemOnField(void);
diff --git a/src/main_menu.c b/src/main_menu.c
index 91931e581..781d7f85c 100644
--- a/src/main_menu.c
+++ b/src/main_menu.c
@@ -1,7 +1,6 @@
#include "global.h"
#include "trainer_pokemon_sprites.h"
#include "bg.h"
-#include "constants/flags.h"
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/species.h"
diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c
index dc5a0b335..bbf0f8972 100644
--- a/src/mauville_old_man.c
+++ b/src/mauville_old_man.c
@@ -3,7 +3,6 @@
#include "constants/songs.h"
#include "constants/easy_chat.h"
#include "constants/event_objects.h"
-#include "constants/vars.h"
#include "mauville_old_man.h"
#include "event_data.h"
#include "string_util.h"
diff --git a/src/menu.c b/src/menu.c
index 7d5f02b60..7c90c4d93 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -18,7 +18,6 @@
#include "task.h"
#include "text_window.h"
#include "window.h"
-#include "constants/flags.h"
#include "constants/songs.h"
#define DLG_WINDOW_PALETTE_NUM 15
diff --git a/src/mirage_tower.c b/src/mirage_tower.c
index 2a6d6d6c4..e2f5cefb7 100644
--- a/src/mirage_tower.c
+++ b/src/mirage_tower.c
@@ -14,7 +14,6 @@
#include "sprite.h"
#include "task.h"
#include "window.h"
-#include "constants/flags.h"
#include "constants/maps.h"
#include "constants/rgb.h"
#include "constants/songs.h"
diff --git a/src/naming_screen.c b/src/naming_screen.c
index 161d4a7e0..84b540e99 100644
--- a/src/naming_screen.c
+++ b/src/naming_screen.c
@@ -13,7 +13,6 @@
#include "field_player_avatar.h"
#include "event_object_movement.h"
#include "event_data.h"
-#include "constants/vars.h"
#include "constants/songs.h"
#include "pokemon_storage_system.h"
#include "graphics.h"
diff --git a/src/party_menu.c b/src/party_menu.c
index e9cbfc2ad..d5bc6dfb6 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -67,7 +67,6 @@
#include "constants/battle_frontier.h"
#include "constants/easy_chat.h"
#include "constants/field_effects.h"
-#include "constants/flags.h"
#include "constants/item_effects.h"
#include "constants/items.h"
#include "constants/maps.h"
@@ -76,7 +75,6 @@
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/species.h"
-#include "constants/vars.h"
#define PARTY_PAL_SELECTED (1 << 0)
#define PARTY_PAL_FAINTED (1 << 1)
diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c
index a2545cc1a..0232d4fc4 100755
--- a/src/pokedex_area_screen.c
+++ b/src/pokedex_area_screen.c
@@ -21,7 +21,6 @@
#include "constants/rgb.h"
#include "constants/songs.h"
#include "constants/species.h"
-#include "constants/vars.h"
#define AREA_SCREEN_WIDTH 32
#define AREA_SCREEN_HEIGHT 20
diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c
index ef1d5343f..1e4239bbc 100755
--- a/src/pokenav_match_call_1.c
+++ b/src/pokenav_match_call_1.c
@@ -12,7 +12,6 @@
#include "sound.h"
#include "string_util.h"
#include "strings.h"
-#include "constants/flags.h"
#include "constants/songs.h"
struct Pokenav3Struct
diff --git a/src/post_battle_event_funcs.c b/src/post_battle_event_funcs.c
index 4fa5d1b21..07690960f 100644
--- a/src/post_battle_event_funcs.c
+++ b/src/post_battle_event_funcs.c
@@ -8,7 +8,6 @@
#include "script_pokemon_util_80F87D8.h"
#include "tv.h"
#include "constants/heal_locations.h"
-#include "constants/flags.h"
#include "constants/tv.h"
int GameClear(void)
diff --git a/src/region_map.c b/src/region_map.c
index 287e97fe9..b8e07c835 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -9,7 +9,6 @@
#include "trig.h"
#include "constants/maps.h"
#include "overworld.h"
-#include "constants/flags.h"
#include "event_data.h"
#include "secret_base.h"
#include "string_util.h"
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index a6ab1693b..70f68b879 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -30,7 +30,6 @@
#include "constants/items.h"
#include "constants/species.h"
#include "constants/tv.h"
-#include "constants/vars.h"
#include "constants/battle_frontier.h"
extern const u16 gObjectEventPalette8[];
diff --git a/src/trainer_card.c b/src/trainer_card.c
index fb92dc336..d625bc13e 100755
--- a/src/trainer_card.c
+++ b/src/trainer_card.c
@@ -27,7 +27,6 @@
#include "trainer_pokemon_sprites.h"
#include "script_pokemon_util_80F87D8.h"
#include "constants/songs.h"
-#include "constants/flags.h"
#include "constants/game_stat.h"
#include "constants/battle_frontier.h"
#include "constants/rgb.h"
diff --git a/src/union_room_player_avatar.c b/src/union_room_player_avatar.c
index cac789685..c012fd84d 100644
--- a/src/union_room_player_avatar.c
+++ b/src/union_room_player_avatar.c
@@ -8,7 +8,6 @@
#include "union_room.h"
#include "constants/event_objects.h"
#include "constants/event_object_movement.h"
-#include "constants/flags.h"
#define UR_SPRITE_START_ID (MAX_SPRITES - MAX_UNION_ROOM_PLAYERS)
#define UR_PLAYER_SPRITE_ID(playerIdx, facingDir)(5 * playerIdx + facingDir)