Implementation if Pyredrid and AsparagusEduardo debug menu plus huge rewrite and tons of additions

V2: Fly, Warp, Flags, Vars, give items, give pkm 2 versions

Improved cheats, reworked the vars system

vars function now starts at VARS_START and end VARS_END

Figured out how to display FieldMessages, reimplemented CheckSafeBlock, cleanup

DebugAction_DestroyExtraWindow instead of multiple, renamed text variables

cleanup + pokemon simple

give pokemon complex nearly done

Complex pkm works, items now with icons

if statement cleanup

alter build tools to include maps per map group

Warp functionallity

added hex value to flags and vars

cleanup

Credits
This commit is contained in:
TheXaman 2020-09-26 00:51:02 +02:00
parent 16ecbc6446
commit 6456009a44
18 changed files with 2187 additions and 11 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ porymap.project.cfg
.vscode/
*.a
.fuse_hidden*
mgba.sh

View File

@ -248,6 +248,12 @@ ifeq ($(DINFO),1)
override CFLAGS += -g
endif
# DebugMenu
ifeq ($(DDEBUG),1)
override ASFLAGS += --defsym DEBUG=1
override CPPFLAGS += -D DEBUG=1
endif
$(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep)
@$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i
@$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s

View File

@ -576,6 +576,8 @@ gStdScripts_End:: @ 81DC2CC
.include "data/scripts/new_game.inc"
.include "data/scripts/hall_of_fame.inc"
.include "data/scripts/debug.inc"
EventScript_WhiteOut:: @ 8271857
call EverGrandeCity_HallOfFame_EventScript_ResetEliteFour
goto EventScript_ResetMrBriney

60
data/scripts/debug.inc Normal file
View File

@ -0,0 +1,60 @@
Debug_ShowFieldMessageStringVar4::
special ShowFieldMessageStringVar4
waitmessage
waitbuttonpress
releaseall
end
Debug_CheckWeekDay_Text:
.string "Aaaaah, yes!\l"
.string "{STR_VAR_1}s are made for dads!\l"
.string "And dad's car!$"
Debug_CheatStart::
lockall
setflag FLAG_SYS_POKEMON_GET
setflag FLAG_RESCUED_BIRCH
setflag FLAG_HIDE_ROUTE_101_BIRCH_ZIGZAGOON_BATTLE
clearflag FLAG_HIDE_LITTLEROOT_TOWN_BIRCHS_LAB_BIRCH
setflag FLAG_HIDE_ROUTE_101_BIRCH_STARTERS_BAG
setvar VAR_BIRCH_LAB_STATE, 2
setvar VAR_ROUTE101_STATE, 3
givemon SPECIES_TREECKO, 20, ITEM_NONE
givemon SPECIES_TORCHIC, 20, ITEM_NONE
givemon SPECIES_MUDKIP, 20, ITEM_NONE
setflag FLAG_SYS_POKEDEX_GET
special SetUnlockedPokedexFlags
setflag FLAG_RECEIVED_POKEDEX_FROM_BIRCH
setvar VAR_CABLE_CLUB_TUTORIAL_STATE, 1
@ setflag FLAG_SYS_NATIONAL_DEX
@ special EnableNationalPokedex
setflag FLAG_RECEIVED_RUNNING_SHOES
setflag FLAG_SYS_B_DASH
setvar VAR_LITTLEROOT_TOWN_STATE, 4 @ 4: Received Running Shoes
setvar VAR_LITTLEROOT_INTRO_STATE, 7 @ 7: Told to go meet rival
setvar VAR_LITTLEROOT_HOUSES_STATE_BRENDAN, 2 @ 2: Met Rival's Mom (and is corresponding gender)
setvar VAR_LITTLEROOT_HOUSES_STATE_MAY, 2 @ 2: Met Rival's Mom (and is corresponding gender)
setvar VAR_LITTLEROOT_RIVAL_STATE, 4 @ 4: Received Pokedex
setflag FLAG_RECEIVED_BIKE
giveitem ITEM_ACRO_BIKE
setvar VAR_BRINEY_HOUSE_STATE, 1
setvar VAR_ROUTE116_STATE, 2
setflag FLAG_HIDE_ROUTE_116_MR_BRINEY
clearflag FLAG_HIDE_BRINEYS_HOUSE_MR_BRINEY
clearflag FLAG_HIDE_BRINEYS_HOUSE_PEEKO
@ additem ITEM_MAX_REPEL, 10
@ giveitem ITEM_EON_TICKET
@ setflag FLAG_SYS_HAS_EON_TICKET
@ setvar VAR_DISTRIBUTE_EON_TICKET, 0
@ giveitem ITEM_MYSTIC_TICKET
@ setflag FLAG_ENABLE_SHIP_NAVEL_ROCK
@ setflag FLAG_RECEIVED_MYSTIC_TICKET
@ giveitem ITEM_AURORA_TICKET
@ setflag FLAG_ENABLE_SHIP_BIRTH_ISLAND
@ setflag FLAG_RECEIVED_AURORA_TICKET
@ setflag FLAG_BADGE06_GET @ Badge for flying filed move
@ setweather WEATHER_VOLCANIC_ASH
@ doweather
closemessage
release
end

View File

@ -40,12 +40,12 @@
#define FLAG_TEMP_1E (TEMP_FLAGS_START + 0x1E)
#define FLAG_TEMP_1F (TEMP_FLAGS_START + 0x1F)
#define TEMP_FLAGS_END FLAG_TEMP_1F
#define FLAG_UNUSED_0x020 0x20 // Unused Flag
#define FLAG_UNUSED_0x021 0x21 // Unused Flag
#define FLAG_UNUSED_0x022 0x22 // Unused Flag
#define FLAG_UNUSED_0x023 0x23 // Unused Flag
#define FLAG_UNUSED_0x024 0x24 // Unused Flag
#define FLAG_SYS_NO_COLLISION 0x20 // Unused Flag //DEBUG
#define FLAG_SYS_NO_ENCOUNTER 0x21 // Unused Flag //DEBUG
#define FLAG_SYS_NO_TRAINER_SEE 0x22 // Unused Flag //DEBUG
#define FLAG_SYS_NO_BAG_USE 0x23 // Unused Flag //DEBUG
#define FLAG_SYS_NO_CATCHING 0x24 // Unused Flag //DEBUG
#define FLAG_UNUSED_0x025 0x25 // Unused Flag
#define FLAG_UNUSED_0x026 0x26 // Unused Flag
#define FLAG_UNUSED_0x027 0x27 // Unused Flag

View File

@ -593,4 +593,6 @@
#define MAP_GROUPS_COUNT 34
// static const u8 MAP_GROUP_COUNT[] = {57, 5, 5, 6, 7, 8, 9, 7, 7, 14, 8, 17, 10, 23, 13, 15, 15, 2, 2, 2, 3, 1, 1, 1, 108, 61, 89, 2, 1, 13, 1, 1, 3, 1, 0};
#endif // GUARD_CONSTANTS_MAP_GROUPS_H

8
include/debug.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef GUARD_DEBUG_H
#define GUARD_DEBUG_H
#if DEBUG
void Debug_ShowMainMenu(void);
#endif
#endif // GUARD_DEBUG_H

View File

@ -20,10 +20,12 @@ void EnableResetRTC(void);
bool32 CanResetRTC(void);
u16 *GetVarPointer(u16 id);
u16 VarGet(u16 id);
u16 VarGetIfExist(u16 id);
bool8 VarSet(u16 id, u16 value);
u8 VarGetObjectEventGraphicsId(u8 id);
u8 *GetFlagPointer(u16 id);
u8 FlagSet(u16 id);
u8 FlagToggle(u16 id);
u8 FlagClear(u16 id);
bool8 FlagGet(u16 id);

View File

@ -99,6 +99,7 @@ SECTIONS {
src/random.o(.text);
src/util.o(.text);
src/daycare.o(.text);
src/debug.o(.text);
src/egg_hatch.o(.text);
src/battle_interface.o(.text);
src/battle_anim_smokescreen.o(.text);
@ -482,6 +483,7 @@ SECTIONS {
src/trig.o(.rodata);
src/util.o(.rodata);
src/daycare.o(.rodata);
src/debug.o(.rodata);
src/egg_hatch.o(.rodata);
src/battle_gfx_sfx_util.o(.rodata);
src/battle_interface.o(.rodata);

View File

@ -4259,7 +4259,7 @@ static void HandleTurnActionSelectionState(void)
}
break;
case B_ACTION_USE_ITEM:
if (gBattleTypeFlags & (BATTLE_TYPE_LINK
if (FlagGet(FLAG_SYS_NO_BAG_USE) || gBattleTypeFlags & (BATTLE_TYPE_LINK //DEBUG
| BATTLE_TYPE_FRONTIER_NO_PYRAMID
| BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_x2000000))

2008
src/debug.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -184,6 +184,14 @@ u16 VarGet(u16 id)
return *ptr;
}
u16 VarGetIfExist(u16 id)
{
u16 *ptr = GetVarPointer(id);
if (!ptr)
return 65535;
return *ptr;
}
bool8 VarSet(u16 id, u16 value)
{
u16 *ptr = GetVarPointer(id);
@ -216,6 +224,14 @@ u8 FlagSet(u16 id)
return 0;
}
u8 FlagToggle(u16 id)
{
u8 *ptr = GetFlagPointer(id);
if (ptr)
*ptr ^= 1 << (id & 7);
return 0;
}
u8 FlagClear(u16 id)
{
u8 *ptr = GetFlagPointer(id);

View File

@ -4723,6 +4723,12 @@ static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction)
u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
{
u8 direction = dir;
#if DEBUG //DEBUG
if (FlagGet(FLAG_SYS_NO_COLLISION))
return COLLISION_NONE;
#endif //
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
return COLLISION_OUTSIDE_RANGE;
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))

View File

@ -3,6 +3,7 @@
#include "bike.h"
#include "coord_event_weather.h"
#include "daycare.h"
#include "debug.h"
#include "faraway_island.h"
#include "event_data.h"
#include "event_object_movement.h"
@ -130,6 +131,35 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
input->dpadDirection = DIR_WEST;
else if (heldKeys & DPAD_RIGHT)
input->dpadDirection = DIR_EAST;
//DEBUG
if (heldKeys & R_BUTTON)
{
if(input->pressedSelectButton)
{
input->input_field_1_0 = TRUE;
input->pressedSelectButton = FALSE;
}else if(input->pressedStartButton)
{
input->input_field_1_2 = TRUE;
input->pressedStartButton = FALSE;
}
}
if (heldKeys & L_BUTTON)
{
if(input->pressedSelectButton)
{
input->input_field_1_1 = TRUE;
input->pressedSelectButton = FALSE;
}else if(input->pressedStartButton)
{
input->input_field_1_3 = TRUE;
input->pressedStartButton = FALSE;
}
}
//
}
int ProcessPlayerFieldInput(struct FieldInput *input)
@ -189,6 +219,15 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
if (input->pressedSelectButton && UseRegisteredKeyItemOnField() == TRUE)
return TRUE;
#if DEBUG
if (input->input_field_1_2)
{
PlaySE(SE_WIN_OPEN);
Debug_ShowMainMenu();
return TRUE;
}
#endif
return FALSE;
}
@ -668,6 +707,9 @@ void RestartWildEncounterImmunitySteps(void)
static bool8 CheckStandardWildEncounter(u16 metatileBehavior)
{
if (FlagGet(FLAG_SYS_NO_ENCOUNTER)) //DEBUG
return FALSE;//
if (sWildEncounterImmunitySteps < 4)
{
sWildEncounterImmunitySteps++;
@ -683,7 +725,7 @@ static bool8 CheckStandardWildEncounter(u16 metatileBehavior)
}
sPreviousPlayerMetatileBehavior = metatileBehavior;
return FALSE;
return FALSE;
}
static bool8 TryArrowWarp(struct MapPosition *position, u16 metatileBehavior, u8 direction)

View File

@ -938,7 +938,11 @@ void ItemUseOutOfBattle_EvolutionStone(u8 taskId)
void ItemUseInBattle_PokeBall(u8 taskId)
{
if (IsPlayerPartyAndPokemonStorageFull() == FALSE) // have room for mon?
if (FlagGet(FLAG_SYS_NO_CATCHING)){ //DEBUG
static const u8 sText_BallsCannotBeUsed[] = _("Poké Balls cannot be used\nright now!\p");
DisplayItemMessage(taskId, 1, sText_BallsCannotBeUsed, BagMenu_InitListsMenu);
} //
else if (IsPlayerPartyAndPokemonStorageFull() == FALSE) // have room for mon?
{
RemoveBagItem(gSpecialVar_ItemId, 1);
if (!InBattlePyramid())

View File

@ -94,7 +94,7 @@ static void InitPlayerTrainerId(void)
// L=A isnt set here for some reason.
static void SetDefaultOptions(void)
{
gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID;
gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_FAST;
gSaveBlock2Ptr->optionsWindowFrameType = 0;
gSaveBlock2Ptr->optionsSound = OPTIONS_SOUND_MONO;
gSaveBlock2Ptr->optionsBattleStyle = OPTIONS_BATTLE_STYLE_SHIFT;

View File

@ -177,6 +177,11 @@ bool8 CheckForTrainersWantingBattle(void)
{
u8 i;
#if DEBUG //DEBUG
if (FlagGet(FLAG_SYS_NO_TRAINER_SEE))
return FALSE;
#endif //
gNoOfApproachingTrainers = 0;
gApproachingTrainerId = 0;

View File

@ -393,11 +393,14 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
text << "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from data/maps/map_groups.json\n//\n\n";
int group_num = 0;
vector<int> map_count_vec; //DEBUG
for (auto &group : groups_data["group_order"].array_items()) {
text << "// Map Group " << group_num << "\n";
vector<Json> map_ids;
size_t max_length = 0;
size_t max_length = 0; //DEBUG
int map_count = 0; //DEBUG
for (auto &map_name : groups_data[group.string_value()].array_items()) {
string header_filepath = file_dir + map_name.string_value() + dir_separator + "map.json";
@ -406,6 +409,7 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
map_ids.push_back(map_data["id"]);
if (map_data["id"].string_value().length() > max_length)
max_length = map_data["id"].string_value().length();
map_count++; //DEBUG
}
int map_id_num = 0;
@ -416,9 +420,17 @@ string generate_map_constants_text(string groups_filepath, Json groups_data) {
text << "\n";
group_num++;
map_count_vec.push_back(map_count); //DEBUG
}
text << "#define MAP_GROUPS_COUNT " << group_num << "\n\n";
text << "// static const u8 MAP_GROUP_COUNT[] = {"; //DEBUG
for(int i=0; i<group_num; i++){ //DEBUG
text << map_count_vec[i] << ", "; //DEBUG
} //DEBUG
text << "0};\n\n"; //DEBUG
text << "#endif // GUARD_CONSTANTS_MAP_GROUPS_H\n";
return text.str();