summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_anim.c4
-rw-r--r--src/battle_arena.c2
-rw-r--r--src/battle_controller_link_opponent.c4
-rw-r--r--src/battle_controller_opponent.c4
-rw-r--r--src/battle_controller_player.c6
-rw-r--r--src/battle_controller_recorded_opponent.c4
-rw-r--r--src/battle_controller_recorded_player.c2
-rw-r--r--src/battle_pyramid.c23
-rw-r--r--src/battle_script_commands.c4
-rw-r--r--src/berry_blender.c2
-rw-r--r--src/braille_puzzles.c184
-rw-r--r--src/contest.c2
-rw-r--r--src/decoration.c24
-rw-r--r--src/event_object_movement.c34
-rwxr-xr-xsrc/faraway_island.c8
-rw-r--r--src/field_control_avatar.c16
-rw-r--r--src/field_door.c4
-rw-r--r--src/field_effect.c6
-rwxr-xr-xsrc/field_effect_helpers.c4
-rw-r--r--src/field_player_avatar.c4
-rw-r--r--src/field_special_scene.c12
-rw-r--r--src/field_specials.c60
-rw-r--r--src/field_tasks.c6
-rw-r--r--src/field_weather_effect.c3
-rw-r--r--src/fieldmap.c92
-rw-r--r--src/hall_of_fame.c4
-rwxr-xr-xsrc/item_use.c34
-rw-r--r--src/mauville_old_man.c8
-rw-r--r--src/mirage_tower.c4
-rw-r--r--src/overworld.c4
-rw-r--r--src/pokeball.c2
-rw-r--r--src/pokeblock_feed.c2
-rw-r--r--src/pokedex.c4
-rw-r--r--src/pokemon_summary_screen.c2
-rw-r--r--src/reshow_battle_screen.c12
-rw-r--r--src/rotating_gate.c40
-rw-r--r--src/rotating_tile_puzzle.c12
-rw-r--r--src/roulette.c8
-rw-r--r--src/scrcmd.c24
-rw-r--r--src/secret_base.c26
-rw-r--r--src/sound.c26
-rw-r--r--src/union_room.c5
-rw-r--r--src/union_room_player_avatar.c8
-rw-r--r--src/wild_encounter.c141
44 files changed, 382 insertions, 498 deletions
diff --git a/src/battle_anim.c b/src/battle_anim.c
index 80d511f4c..9fdf6bd53 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -1877,7 +1877,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
{
if (tableId == gMovesWithQuietBGM[i])
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 128);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 128);
break;
}
}
@@ -2143,7 +2143,7 @@ static void ScriptCmd_end(void)
if (!continuousAnim) // May have been used for debug?
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 256);
if (!IsContest())
{
sub_80A8278();
diff --git a/src/battle_arena.c b/src/battle_arena.c
index f61526edc..8b5f3c16d 100644
--- a/src/battle_arena.c
+++ b/src/battle_arena.c
@@ -614,7 +614,7 @@ u8 BattleArena_ShowJudgmentWindow(u8 *state)
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
HandleBattleWindow(5, 0, 24, 13, WINDOW_CLEAR);
CopyBgTilemapBufferToVram(0);
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 256);
BeginNormalPaletteFade(0x7FFFFF1C, 4, 8, 0, RGB_BLACK);
(*state)++;
break;
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c
index dc8b2bfd1..6369c0202 100644
--- a/src/battle_controller_link_opponent.c
+++ b/src/battle_controller_link_opponent.c
@@ -323,7 +323,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
}
else
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
}
@@ -465,7 +465,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
LinkOpponentBufferExecCompleted();
}
}
diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c
index 87bef4302..4da3b834a 100644
--- a/src/battle_controller_opponent.c
+++ b/src/battle_controller_opponent.c
@@ -334,7 +334,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
m4aMPlayContinue(&gMPlayInfo_BGM);
}
else
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
@@ -470,7 +470,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
OpponentBufferExecCompleted();
}
}
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index 8e7bc9a9f..94e25fadc 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -1024,7 +1024,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
m4aMPlayContinue(&gMPlayInfo_BGM);
else
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
@@ -1092,7 +1092,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& !IsCryPlayingOrClearCrySongs())
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlayerBufferExecCompleted();
}
@@ -1121,7 +1121,7 @@ void Task_PlayerController_RestoreBgmAfterCry(u8 taskId)
{
if (!IsCryPlayingOrClearCrySongs())
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
DestroyTask(taskId);
}
}
diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c
index adac43961..acf595918 100644
--- a/src/battle_controller_recorded_opponent.c
+++ b/src/battle_controller_recorded_opponent.c
@@ -301,7 +301,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
}
else
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
@@ -450,7 +450,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
RecordedOpponentBufferExecCompleted();
}
}
diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c
index bff81948b..ac2133592 100644
--- a/src/battle_controller_recorded_player.c
+++ b/src/battle_controller_recorded_player.c
@@ -318,7 +318,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
}
else
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
}
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index 169dc69c5..e334e75d5 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -34,6 +34,7 @@
#include "constants/items.h"
#include "constants/layouts.h"
#include "constants/maps.h"
+#include "constants/metatile_labels.h"
#include "constants/moves.h"
#include "constants/trainers.h"
@@ -1235,16 +1236,16 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
int x, y;
u8 textIndex = 0;
u16 *map = gBackupMapLayout.map;
- map += gBackupMapLayout.width * 7 + 7;
+ map += gBackupMapLayout.width * 7 + MAP_OFFSET;
for (y = 0; y < 32; map += 47, y++)
{
for (x = 0; x < 32; x++)
{
- if ((map[x] & METATILE_ID_MASK) == FLOOR_EXIT_METATILE)
+ if ((map[x] & METATILE_ID_MASK) == METATILE_BattlePyramid_Exit)
{
- x += 7 - gObjectEvents[gSelectedObjectEvent].initialCoords.x;
- y += 7 - gObjectEvents[gSelectedObjectEvent].initialCoords.y;
+ x += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.x;
+ y += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.y;
if (x >= minDistanceForExitHint
|| x <= -minDistanceForExitHint
|| y >= minDistanceForExitHint
@@ -1537,17 +1538,17 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
const u16 *layoutMap = mapLayout->map;
gBackupMapLayout.map = backupMapData;
- gBackupMapLayout.width = mapLayout->width * 4 + 15;
- gBackupMapLayout.height = mapLayout->height * 4 + 14;
+ gBackupMapLayout.width = mapLayout->width * 4 + MAP_OFFSET_W;
+ gBackupMapLayout.height = mapLayout->height * 4 + MAP_OFFSET_H;
map = backupMapData;
- yOffset = ((i / 4 * mapLayout->height) + 7) * gBackupMapLayout.width;
- xOffset = (i % 4 * mapLayout->width) + 7;
+ yOffset = ((i / 4 * mapLayout->height) + MAP_OFFSET) * gBackupMapLayout.width;
+ xOffset = (i % 4 * mapLayout->width) + MAP_OFFSET;
map += yOffset + xOffset;
for (y = 0; y < mapLayout->height; y++)
{
for (x = 0; x < mapLayout->width; x++)
{
- if ((layoutMap[x] & METATILE_ID_MASK) != FLOOR_EXIT_METATILE)
+ if ((layoutMap[x] & METATILE_ID_MASK) != METATILE_BattlePyramid_Exit)
{
map[x] = layoutMap[x];
}
@@ -1558,14 +1559,14 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
gSaveBlock1Ptr->pos.x = (mapLayout->width * (i % 4)) + x;
gSaveBlock1Ptr->pos.y = (mapLayout->height * (i / 4)) + y;
}
- map[x] = (layoutMap[x] & 0xFC00) | FLOOR_WALKABLE_METATILE;
+ map[x] = (layoutMap[x] & (METATILE_ELEVATION_MASK | METATILE_COLLISION_MASK)) | METATILE_BattlePyramid_Floor;
}
else
{
map[x] = layoutMap[x];
}
}
- map += 15 + (mapLayout->width * 4);
+ map += MAP_OFFSET_W + (mapLayout->width * 4);
layoutMap += mapLayout->width;
}
}
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index e7520b1ee..91f89137a 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -6412,10 +6412,10 @@ static void Cmd_various(void)
}
break;
case VARIOUS_VOLUME_DOWN:
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x55);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x55);
break;
case VARIOUS_VOLUME_UP:
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
break;
case VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT:
gBattleStruct->alreadyStatusedMoveAttempt |= gBitTable[gActiveBattler];
diff --git a/src/berry_blender.c b/src/berry_blender.c
index cccc80c18..9701c8c81 100644
--- a/src/berry_blender.c
+++ b/src/berry_blender.c
@@ -932,7 +932,7 @@ static const struct WindowTemplate sBlenderRecordWindowTemplate =
static void UpdateHitPitch(void)
{
- m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, 2 * (sBerryBlender->speed - MIN_ARROW_SPEED));
+ m4aMPlayPitchControl(&gMPlayInfo_SE2, TRACKS_ALL, 2 * (sBerryBlender->speed - MIN_ARROW_SPEED));
}
static void VBlankCB_BerryBlender(void)
diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c
index aa6664f35..d8410988d 100644
--- a/src/braille_puzzles.c
+++ b/src/braille_puzzles.c
@@ -85,12 +85,12 @@ bool8 ShouldDoBrailleDigEffect(void)
void DoBrailleDigEffect(void)
{
- MapGridSetMetatileIdAt(16, 8, METATILE_Cave_SealedChamberEntrance_TopLeft);
- MapGridSetMetatileIdAt(17, 8, METATILE_Cave_SealedChamberEntrance_TopMid);
- MapGridSetMetatileIdAt(18, 8, METATILE_Cave_SealedChamberEntrance_TopRight);
- MapGridSetMetatileIdAt(16, 9, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(17, 9, METATILE_Cave_SealedChamberEntrance_BottomMid);
- MapGridSetMetatileIdAt(18, 9, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft);
+ MapGridSetMetatileIdAt(10 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight);
+ MapGridSetMetatileIdAt( 9 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(10 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK);
DrawWholeMapView();
PlaySE(SE_BANG);
FlagSet(FLAG_SYS_BRAILLE_DIG);
@@ -112,84 +112,8 @@ bool8 CheckRelicanthWailord(void)
}
// THEORY: this was caused by block commenting out all of the older R/S braille functions but leaving the call to it itself, which creates the nullsub.
-// the code is shown below to show what this might look like.
void ShouldDoBrailleRegirockEffectOld(void)
{
- /*
- if (!FlagGet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED) && (gSaveBlock1.location.mapGroup == MAP_GROUP_DESERT_RUINS && gSaveBlock1.location.mapNum == MAP_ID_DESERT_RUINS))
- {
- if (gSaveBlock1.pos.x == 10 && gSaveBlock1.pos.y == 23)
- return TRUE;
- else if (gSaveBlock1.pos.x == 9 && gSaveBlock1.pos.y == 23)
- return TRUE;
- else if (gSaveBlock1.pos.x == 11 && gSaveBlock1.pos.y == 23)
- return TRUE;
- }
-
- return FALSE;
-}
-
-void DoBrailleRegirockEffect(void)
-{
- FieldEffectActiveListRemove(FLDEFF_USE_STRENGTH);
- MapGridSetMetatileIdAt(14, 26, 554);
- MapGridSetMetatileIdAt(15, 26, 555);
- MapGridSetMetatileIdAt(16, 26, 556);
- MapGridSetMetatileIdAt(14, 27, 3634);
- MapGridSetMetatileIdAt(15, 27, 563);
- MapGridSetMetatileIdAt(16, 27, 3636);
- DrawWholeMapView();
- PlaySE(SE_BANG);
- FlagSet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED);
- ScriptContext2_Disable();
-}
-
-bool8 ShouldDoBrailleRegisteelEffect(void)
-{
- if (!FlagGet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED) && (gSaveBlock1.location.mapGroup == MAP_GROUP_ANCIENT_TOMB && gSaveBlock1.location.mapNum == MAP_ID_ANCIENT_TOMB))
- {
- if (gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25)
- return TRUE;
- }
-
- return FALSE;
-}
-
-void DoBrailleRegisteelEffect(void)
-{
- gFieldEffectArguments[0] = gLastFieldPokeMenuOpened;
- FieldEffectStart(FLDEFF_USE_TOMB_PUZZLE_EFFECT);
-}
-
-bool8 FldEff_UseFlyAncientTomb(void)
-{
- u8 taskId = CreateFieldMoveTask();
-
- gTasks[taskId].data[8] = (u32)UseRegisteelHm_Callback >> 16;
- gTasks[taskId].data[9] = (u32)UseRegisteelHm_Callback;
- return FALSE;
-}
-
-void UseRegisteelHm_Callback(void)
-{
- FieldEffectActiveListRemove(FLDEFF_USE_TOMB_PUZZLE_EFFECT);
- UseFlyAncientTomb_Finish();
-}
-
-void UseFlyAncientTomb_Finish(void)
-{
- MapGridSetMetatileIdAt(14, 26, 554);
- MapGridSetMetatileIdAt(15, 26, 555);
- MapGridSetMetatileIdAt(16, 26, 556);
- MapGridSetMetatileIdAt(14, 27, 3634);
- MapGridSetMetatileIdAt(15, 27, 563);
- MapGridSetMetatileIdAt(16, 27, 3636);
- DrawWholeMapView();
- PlaySE(SE_BANG);
- FlagSet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED);
- ScriptContext2_Disable();
-}
- */
}
void DoSealedChamberShakingEffect1(void)
@@ -278,12 +202,12 @@ void UseRegirockHm_Callback(void)
void DoBrailleRegirockEffect(void)
{
- MapGridSetMetatileIdAt(14, 26, METATILE_Cave_SealedChamberEntrance_TopLeft);
- MapGridSetMetatileIdAt(15, 26, METATILE_Cave_SealedChamberEntrance_TopMid);
- MapGridSetMetatileIdAt(16, 26, METATILE_Cave_SealedChamberEntrance_TopRight);
- MapGridSetMetatileIdAt(14, 27, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(15, 27, METATILE_Cave_SealedChamberEntrance_BottomMid);
- MapGridSetMetatileIdAt(16, 27, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft);
+ MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid);
+ MapGridSetMetatileIdAt(9 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight);
+ MapGridSetMetatileIdAt(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(8 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid);
+ MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK);
DrawWholeMapView();
PlaySE(SE_BANG);
FlagSet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED);
@@ -317,12 +241,12 @@ void UseRegisteelHm_Callback(void)
void DoBrailleRegisteelEffect(void)
{
- MapGridSetMetatileIdAt(14, 26, METATILE_Cave_SealedChamberEntrance_TopLeft);
- MapGridSetMetatileIdAt(15, 26, METATILE_Cave_SealedChamberEntrance_TopMid);
- MapGridSetMetatileIdAt(16, 26, METATILE_Cave_SealedChamberEntrance_TopRight);
- MapGridSetMetatileIdAt(14, 27, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(15, 27, METATILE_Cave_SealedChamberEntrance_BottomMid);
- MapGridSetMetatileIdAt(16, 27, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft);
+ MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid);
+ MapGridSetMetatileIdAt(9 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopRight);
+ MapGridSetMetatileIdAt(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(8 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomMid);
+ MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | METATILE_COLLISION_MASK);
DrawWholeMapView();
PlaySE(SE_BANG);
FlagSet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED);
@@ -332,78 +256,6 @@ void DoBrailleRegisteelEffect(void)
// theory: another commented out DoBrailleWait and Task_BrailleWait.
void DoBrailleWait(void)
{
- /*
- if (!FlagGet(FLAG_SYS_BRAILLE_REGICE_COMPLETED))
- CreateTask(Task_BrailleWait, 0x50);
-}
-
-void Task_BrailleWait(u8 taskId)
-{
- s16 *data = gTasks[taskId].data;
-
- switch (data[0])
- {
- case 0:
- data[1] = 7200;
- data[0] = 1;
- break;
- case 1:
- if (BrailleWait_CheckButtonPress() != FALSE)
- {
- MenuZeroFillScreen();
- PlaySE(SE_SELECT);
- data[0] = 2;
- }
- else
- {
- data[1] = data[1] - 1;
- if (data[1] == 0)
- {
- MenuZeroFillScreen();
- data[0] = 3;
- data[1] = 30;
- }
- }
- break;
- case 2:
- if (BrailleWait_CheckButtonPress() == FALSE)
- {
- data[1] = data[1] - 1;
- if (data[1] == 0)
- data[0] = 4;
- break;
- }
- sub_8064E2C();
- DestroyTask(taskId);
- ScriptContext2_Disable();
- break;
- case 3:
- data[1] = data[1] - 1;
- if (data[1] == 0)
- data[0] = 4;
- break;
- case 4:
- sub_8064E2C();
- ScriptContext1_SetupScript(S_OpenRegiceChamber);
- DestroyTask(taskId);
- break;
- }
-}
-
-bool32 BrailleWait_CheckButtonPress(void)
-{
- u16 keyMask = A_BUTTON | B_BUTTON | START_BUTTON | SELECT_BUTTON | DPAD_ANY;
-
- if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
- keyMask |= L_BUTTON | R_BUTTON;
- if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A)
- keyMask |= L_BUTTON;
-
- if (gMain.newKeys & keyMask)
- return TRUE;
- else
- return FALSE;
- */
}
// this used to be FldEff_UseFlyAncientTomb . why did GF merge the 2 functions?
diff --git a/src/contest.c b/src/contest.c
index a87e8f28b..175b9da30 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -3820,7 +3820,7 @@ static void Task_UpdateAppealHearts(u8 taskId)
{
PlaySE(SE_CONTEST_HEART);
m4aMPlayImmInit(&gMPlayInfo_SE1);
- m4aMPlayPitchControl(&gMPlayInfo_SE1, 0xFFFF, pitchMod * 256);
+ m4aMPlayPitchControl(&gMPlayInfo_SE1, TRACKS_ALL, pitchMod * 256);
}
else
{
diff --git a/src/decoration.c b/src/decoration.c
index 131f6e502..838b5cb66 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -1481,7 +1481,7 @@ static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 behaviorBy)
static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 behaviorBy)
{
- if (x == gTasks[taskId].tInitialX + 7 && y == gTasks[taskId].tInitialY + 7 && behaviorBy != 0)
+ if (x == gTasks[taskId].tInitialX + MAP_OFFSET && y == gTasks[taskId].tInitialY + MAP_OFFSET && behaviorBy != 0)
return FALSE;
return TRUE;
}
@@ -1532,7 +1532,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
return FALSE;
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
- if (behaviorAt != 0 && behaviorAt != 16)
+ if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
return FALSE;
}
}
@@ -1552,7 +1552,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
return FALSE;
- if (GetObjectEventIdByXYZ(curX, curY, 0) != 16)
+ if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
return FALSE;
}
}
@@ -1570,7 +1570,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
return FALSE;
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
- if (behaviorAt != 0 && behaviorAt != 16)
+ if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
return FALSE;
}
break;
@@ -1606,7 +1606,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
return FALSE;
}
- if (GetObjectEventIdByXYZ(curX, curY, 0) != 16)
+ if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
return FALSE;
}
break;
@@ -1645,8 +1645,8 @@ static void PlaceDecoration(u8 taskId)
}
else
{
- sCurDecorMapX = gTasks[taskId].tCursorX - 7;
- sCurDecorMapY = gTasks[taskId].tCursorY - 7;
+ sCurDecorMapX = gTasks[taskId].tCursorX - MAP_OFFSET;
+ sCurDecorMapY = gTasks[taskId].tCursorY - MAP_OFFSET;
ScriptContext1_SetupScript(SecretBase_EventScript_SetDecoration);
}
@@ -1666,7 +1666,7 @@ static void PlaceDecoration_(u8 taskId)
if (sDecorationContext.items[i] == DECOR_NONE)
{
sDecorationContext.items[i] = gCurDecorationItems[gCurDecorationIndex];
- sDecorationContext.pos[i] = ((gTasks[taskId].tCursorX - 7) << 4) + (gTasks[taskId].tCursorY - 7);
+ sDecorationContext.pos[i] = ((gTasks[taskId].tCursorX - MAP_OFFSET) << 4) + (gTasks[taskId].tCursorY - MAP_OFFSET);
break;
}
}
@@ -2223,7 +2223,7 @@ static void ClearRearrangementNonSprites(void)
{
for (x = 0; x < sDecorRearrangementDataBuffer[i].width; x++)
{
- MapGridSetMetatileEntryAt(posX + 7 + x, posY + 7 - y, gMapHeader.mapLayout->map[posX + x + gMapHeader.mapLayout->width * (posY - y)] | 0x3000);
+ MapGridSetMetatileEntryAt(posX + MAP_OFFSET + x, posY + MAP_OFFSET - y, gMapHeader.mapLayout->map[posX + x + gMapHeader.mapLayout->width * (posY - y)] | 0x3000);
}
}
@@ -2461,12 +2461,12 @@ static bool8 DecorationIsUnderCursor(u8 taskId, u8 idx, struct DecorRearrangemen
u8 yOff;
u8 ht;
- x = gTasks[taskId].tCursorX - 7;
- y = gTasks[taskId].tCursorY - 7;
+ x = gTasks[taskId].tCursorX - MAP_OFFSET;
+ y = gTasks[taskId].tCursorY - MAP_OFFSET;
xOff = sDecorationContext.pos[idx] >> 4;
yOff = sDecorationContext.pos[idx] & 0x0F;
ht = data->height;
- if (sDecorationContext.items[idx] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(xOff + 7, yOff + 7) == METATILE_SecretBase_SandOrnament_BrokenBase)
+ if (sDecorationContext.items[idx] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(xOff + MAP_OFFSET, yOff + MAP_OFFSET) == METATILE_SecretBase_SandOrnament_BrokenBase)
ht--;
if (x >= xOff && x < xOff + data->width && y > yOff - ht && y <= yOff)
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index ba4f38419..2f7cb9e7a 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -1242,8 +1242,8 @@ static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template,
return OBJECT_EVENTS_COUNT;
objectEvent = &gObjectEvents[objectEventId];
ClearObjectEvent(objectEvent);
- x = template->x + 7;
- y = template->y + 7;
+ x = template->x + MAP_OFFSET;
+ y = template->y + MAP_OFFSET;
objectEvent->active = TRUE;
objectEvent->triggerGroundEffectsOnMove = TRUE;
objectEvent->graphicsId = template->graphicsId;
@@ -1469,8 +1469,8 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l
{
struct ObjectEventTemplate objectEventTemplate;
- x -= 7;
- y -= 7;
+ x -= MAP_OFFSET;
+ y -= MAP_OFFSET;
objectEventTemplate.localId = localId;
objectEventTemplate.graphicsId = graphicsId;
objectEventTemplate.inConnection = 0;
@@ -1560,8 +1560,8 @@ u8 CreateObjectSprite(u8 graphicsId, u8 objectEventId, s16 x, s16 y, u8 z, u8 di
graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, UpdateObjectEventSprite, &spriteTemplate, &subspriteTables);
*(u16 *)&spriteTemplate.paletteTag = TAG_NONE;
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
SetSpritePosToOffsetMapCoords(&x, &y, 8, 16);
spriteId = CreateSpriteAtEnd(&spriteTemplate, x, y, 0);
if (spriteId != MAX_SPRITES)
@@ -1606,9 +1606,9 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY)
if (gMapHeader.events != NULL)
{
s16 left = gSaveBlock1Ptr->pos.x - 2;
- s16 right = gSaveBlock1Ptr->pos.x + 17;
+ s16 right = gSaveBlock1Ptr->pos.x + MAP_OFFSET_W + 2;
s16 top = gSaveBlock1Ptr->pos.y;
- s16 bottom = gSaveBlock1Ptr->pos.y + 16;
+ s16 bottom = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H + 2;
if (InBattlePyramid())
objectCount = GetNumBattlePyramidObjectEvents();
@@ -1620,8 +1620,8 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY)
for (i = 0; i < objectCount; i++)
{
struct ObjectEventTemplate *template = &gSaveBlock1Ptr->objectEventTemplates[i];
- s16 npcX = template->x + 7;
- s16 npcY = template->y + 7;
+ s16 npcX = template->x + MAP_OFFSET;
+ s16 npcY = template->y + MAP_OFFSET;
if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX
&& !FlagGet(template->flagId))
@@ -2120,8 +2120,8 @@ void TryMoveObjectEventToMapCoords(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s1
u8 objectEventId;
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
{
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
MoveObjectEventToMapCoords(&gObjectEvents[objectEventId], x, y);
}
}
@@ -2470,8 +2470,8 @@ void OverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent)
objectEventTemplate = GetBaseTemplateForObjectEvent(objectEvent);
if (objectEventTemplate != NULL)
{
- objectEventTemplate->x = objectEvent->currentCoords.x - 7;
- objectEventTemplate->y = objectEvent->currentCoords.y - 7;
+ objectEventTemplate->x = objectEvent->currentCoords.x - MAP_OFFSET;
+ objectEventTemplate->y = objectEvent->currentCoords.y - MAP_OFFSET;
}
}
@@ -7937,9 +7937,9 @@ void GroundEffect_FlowingWater(struct ObjectEvent *objEvent, struct Sprite *spri
}
static void (*const sGroundEffectTracksFuncs[])(struct ObjectEvent *objEvent, struct Sprite *sprite, u8 a) = {
- DoTracksGroundEffect_None,
- DoTracksGroundEffect_Footprints,
- DoTracksGroundEffect_BikeTireTracks,
+ [TRACKS_NONE] = DoTracksGroundEffect_None,
+ [TRACKS_FOOT] = DoTracksGroundEffect_Footprints,
+ [TRACKS_BIKE_TIRE] = DoTracksGroundEffect_BikeTireTracks,
};
void GroundEffect_SandTracks(struct ObjectEvent *objEvent, struct Sprite *sprite)
diff --git a/src/faraway_island.c b/src/faraway_island.c
index 51ab8def4..3927d9ad5 100755
--- a/src/faraway_island.c
+++ b/src/faraway_island.c
@@ -29,10 +29,10 @@ extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
static const s16 sFarawayIslandRockCoords[4][2] =
{
- {14 + 7, 9 + 7},
- {18 + 7, 9 + 7},
- { 9 + 7, 10 + 7},
- {13 + 7, 13 + 7},
+ {14 + MAP_OFFSET, 9 + MAP_OFFSET},
+ {18 + MAP_OFFSET, 9 + MAP_OFFSET},
+ { 9 + MAP_OFFSET, 10 + MAP_OFFSET},
+ {13 + MAP_OFFSET, 13 + MAP_OFFSET},
};
static u8 GetMewObjectEventId(void)
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index 6ec280fd0..10f8d49bb 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -316,7 +316,7 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{
- struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
+ struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
if (bgEvent == NULL)
return NULL;
@@ -498,7 +498,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB
static bool8 TryStartCoordEventScript(struct MapPosition *position)
{
- u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
+ u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
if (script == NULL)
return FALSE;
@@ -785,7 +785,7 @@ static bool8 IsArrowWarpMetatileBehavior(u16 metatileBehavior, u8 direction)
static s8 GetWarpEventAtMapPosition(struct MapHeader *mapHeader, struct MapPosition *position)
{
- return GetWarpEventAtPosition(mapHeader, position->x - 7, position->y - 7, position->height);
+ return GetWarpEventAtPosition(mapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
}
static void SetupWarp(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position)
@@ -920,7 +920,7 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16
u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position)
{
- return GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
+ return GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
}
static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
@@ -944,7 +944,7 @@ bool8 TryDoDiveWarp(struct MapPosition *position, u16 metatileBehavior)
{
if (gMapHeader.mapType == MAP_TYPE_UNDERWATER && !MetatileBehavior_IsUnableToEmerge(metatileBehavior))
{
- if (SetDiveWarpEmerge(position->x - 7, position->y - 7))
+ if (SetDiveWarpEmerge(position->x - MAP_OFFSET, position->y - MAP_OFFSET))
{
StoreInitialPlayerAvatarState();
DoDiveWarp();
@@ -954,7 +954,7 @@ bool8 TryDoDiveWarp(struct MapPosition *position, u16 metatileBehavior)
}
else if (MetatileBehavior_IsDiveable(metatileBehavior) == TRUE)
{
- if (SetDiveWarpDive(position->x - 7, position->y - 7))
+ if (SetDiveWarpDive(position->x - MAP_OFFSET, position->y - MAP_OFFSET))
{
StoreInitialPlayerAvatarState();
DoDiveWarp();
@@ -974,12 +974,12 @@ u8 TrySetDiveWarp(void)
metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (gMapHeader.mapType == MAP_TYPE_UNDERWATER && !MetatileBehavior_IsUnableToEmerge(metatileBehavior))
{
- if (SetDiveWarpEmerge(x - 7, y - 7) == TRUE)
+ if (SetDiveWarpEmerge(x - MAP_OFFSET, y - MAP_OFFSET) == TRUE)
return 1;
}
else if (MetatileBehavior_IsDiveable(metatileBehavior) == TRUE)
{
- if (SetDiveWarpDive(x - 7, y - 7) == TRUE)
+ if (SetDiveWarpDive(x - MAP_OFFSET, y - MAP_OFFSET) == TRUE)
return 2;
}
return 0;
diff --git a/src/field_door.c b/src/field_door.c
index 3f2034ea6..f53e83d7a 100644
--- a/src/field_door.c
+++ b/src/field_door.c
@@ -346,14 +346,14 @@ static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame
{
DrawClosedDoorTiles(gfx, x, y);
if (ShouldUseMultiCorridorDoor())
- DrawClosedDoorTiles(gfx, gSpecialVar_0x8004 + 7, gSpecialVar_0x8005 + 7);
+ DrawClosedDoorTiles(gfx, gSpecialVar_0x8004 + MAP_OFFSET, gSpecialVar_0x8005 + MAP_OFFSET);
}
else
{
CopyDoorTilesToVram(gfx, frame);
DrawCurrentDoorAnimFrame(gfx, x, y, gfx->palette);
if (ShouldUseMultiCorridorDoor())
- DrawCurrentDoorAnimFrame(gfx, gSpecialVar_0x8004 + 7, gSpecialVar_0x8005 + 7, gfx->palette);
+ DrawCurrentDoorAnimFrame(gfx, gSpecialVar_0x8004 + MAP_OFFSET, gSpecialVar_0x8005 + MAP_OFFSET, gfx->palette);
}
}
diff --git a/src/field_effect.c b/src/field_effect.c
index 90d43c809..88f8065d3 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -3830,11 +3830,11 @@ bool8 FldEff_MoveDeoxysRock(struct Sprite* sprite)
int xPos, yPos;
u8 taskId;
object = &gObjectEvents[objectEventIdBuffer];
- xPos = object->currentCoords.x - 7;
- yPos = object->currentCoords.y - 7;
+ xPos = object->currentCoords.x - MAP_OFFSET;
+ yPos = object->currentCoords.y - MAP_OFFSET;
xPos = (gFieldEffectArguments[3] - xPos) * 16;
yPos = (gFieldEffectArguments[4] - yPos) * 16;
- ShiftObjectEventCoords(object, gFieldEffectArguments[3] + 7, gFieldEffectArguments[4] + 7);
+ ShiftObjectEventCoords(object, gFieldEffectArguments[3] + MAP_OFFSET, gFieldEffectArguments[4] + MAP_OFFSET);
taskId = CreateTask(Task_MoveDeoxysRock, 80);
gTasks[taskId].data[1] = object->spriteId;
gTasks[taskId].data[2] = gSprites[object->spriteId].x + xPos;
diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c
index bcc02efe9..0a0e465a8 100755
--- a/src/field_effect_helpers.c
+++ b/src/field_effect_helpers.c
@@ -1416,8 +1416,8 @@ u32 FldEff_Sparkle(void)
{
u8 spriteId;
- gFieldEffectArguments[0] += 7;
- gFieldEffectArguments[1] += 7;
+ gFieldEffectArguments[0] += MAP_OFFSET;
+ gFieldEffectArguments[1] += MAP_OFFSET;
SetSpritePosToOffsetMapCoords((s16 *)&gFieldEffectArguments[0], (s16 *)&gFieldEffectArguments[1], 8, 8);
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_SMALL_SPARKLE], gFieldEffectArguments[0], gFieldEffectArguments[1], 0x52);
if (spriteId != MAX_SPRITES)
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index c4d069cb5..276fb44b2 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -1368,8 +1368,8 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
playerObjEventTemplate.localId = OBJ_EVENT_ID_PLAYER;
playerObjEventTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, gender);
- playerObjEventTemplate.x = x - 7;
- playerObjEventTemplate.y = y - 7;
+ playerObjEventTemplate.x = x - MAP_OFFSET;
+ playerObjEventTemplate.y = y - MAP_OFFSET;
playerObjEventTemplate.elevation = 0;
playerObjEventTemplate.movementType = MOVEMENT_TYPE_PLAYER;
playerObjEventTemplate.movementRangeX = 0;
diff --git a/src/field_special_scene.c b/src/field_special_scene.c
index cb2d0e901..39e5d6698 100644
--- a/src/field_special_scene.c
+++ b/src/field_special_scene.c
@@ -215,9 +215,9 @@ void Task_HandleTruckSequence(u8 taskId)
data[1]++;
if (data[1] == 120)
{
- MapGridSetMetatileIdAt(11, 8, METATILE_InsideOfTruck_ExitLight_Top);
- MapGridSetMetatileIdAt(11, 9, METATILE_InsideOfTruck_ExitLight_Mid);
- MapGridSetMetatileIdAt(11, 10, METATILE_InsideOfTruck_ExitLight_Bottom);
+ MapGridSetMetatileIdAt(4 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_InsideOfTruck_ExitLight_Top);
+ MapGridSetMetatileIdAt(4 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_InsideOfTruck_ExitLight_Mid);
+ MapGridSetMetatileIdAt(4 + MAP_OFFSET, 3 + MAP_OFFSET, METATILE_InsideOfTruck_ExitLight_Bottom);
DrawWholeMapView();
PlaySE(SE_TRUCK_DOOR);
DestroyTask(taskId);
@@ -229,9 +229,9 @@ void Task_HandleTruckSequence(u8 taskId)
void ExecuteTruckSequence(void)
{
- MapGridSetMetatileIdAt(11, 8, METATILE_InsideOfTruck_DoorClosedFloor_Top);
- MapGridSetMetatileIdAt(11, 9, METATILE_InsideOfTruck_DoorClosedFloor_Mid);
- MapGridSetMetatileIdAt(11, 10, METATILE_InsideOfTruck_DoorClosedFloor_Bottom);
+ MapGridSetMetatileIdAt(4 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_InsideOfTruck_DoorClosedFloor_Top);
+ MapGridSetMetatileIdAt(4 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_InsideOfTruck_DoorClosedFloor_Mid);
+ MapGridSetMetatileIdAt(4 + MAP_OFFSET, 3 + MAP_OFFSET, METATILE_InsideOfTruck_DoorClosedFloor_Bottom);
DrawWholeMapView();
ScriptContext2_Enable();
CpuFastFill(0, gPlttBufferFaded, 0x400);
diff --git a/src/field_specials.c b/src/field_specials.c
index 131099ab7..ab02f9938 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -586,7 +586,7 @@ void SpawnLinkPartnerObjectEvent(void)
linkSpriteId = OBJ_EVENT_GFX_RIVAL_MAY_NORMAL;
break;
}
- SpawnSpecialObjectEventParameterized(linkSpriteId, movementTypes[j], 240 - i, coordOffsets[j][0] + x + 7, coordOffsets[j][1] + y + 7, 0);
+ SpawnSpecialObjectEventParameterized(linkSpriteId, movementTypes[j], 240 - i, coordOffsets[j][0] + x + MAP_OFFSET, coordOffsets[j][1] + y + MAP_OFFSET, 0);
LoadLinkPartnerObjectEventSpritePalette(linkSpriteId, 240 - i, i);
j++;
if (j == MAX_LINK_PLAYERS)
@@ -633,13 +633,12 @@ static void LoadLinkPartnerObjectEventSpritePalette(u8 graphicsId, u8 localEvent
}
}
-// NOTE: Coordinates are +7, +7 from actual in-map coordinates
static const struct UCoords8 sMauvilleGymSwitchCoords[] =
{
- { 7, 22},
- {11, 19},
- {10, 16},
- {15, 16}
+ { 0 + MAP_OFFSET, 15 + MAP_OFFSET},
+ { 4 + MAP_OFFSET, 12 + MAP_OFFSET},
+ { 3 + MAP_OFFSET, 9 + MAP_OFFSET},
+ { 8 + MAP_OFFSET, 9 + MAP_OFFSET}
};
// Presses the stepped-on switch and raises the rest
@@ -659,10 +658,10 @@ void MauvilleGymPressSwitch(void)
void MauvilleGymSetDefaultBarriers(void)
{
int x, y;
- // All switches/barriers are within these coord ranges -7
- for (y = 12; y < 24; y++)
+ // All switches/barriers are within these coord ranges
+ for (y = 5 + MAP_OFFSET; y < 17 + MAP_OFFSET; y++)
{
- for (x = 7; x < 16; x++)
+ for (x = 0 + MAP_OFFSET; x < 9 + MAP_OFFSET; x++)
{
switch (MapGridGetMetatileIdAt(x, y))
{
@@ -759,9 +758,9 @@ void MauvilleGymDeactivatePuzzle(void)
MapGridSetMetatileIdAt(switchCoords->x, switchCoords->y, METATILE_MauvilleGym_PressedSwitch);
switchCoords++;
}
- for (y = 12; y < 24; y++)
+ for (y = 5 + MAP_OFFSET; y < 17 + MAP_OFFSET; y++)
{
- for (x = 7; x < 16; x++)
+ for (x = 0 + MAP_OFFSET; x < 9 + MAP_OFFSET; x++)
{
switch (MapGridGetMetatileIdAt(x, y))
{
@@ -902,8 +901,8 @@ static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId)
}
for (i = 0; i < nDoors; i++)
{
- MapGridSetMetatileIdAt(doorCoordsX[i] + 7, doorCoordsY[i] + 7, metatileId | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(doorCoordsX[i] + 7, doorCoordsY[i] + 8, (metatileId + 8) | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET, metatileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET + 1, (metatileId + 8) | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
}
@@ -1115,7 +1114,7 @@ static void PCTurnOnEffect_1(s16 isPcTurnedOn, s8 dx, s8 dy)
tileId = METATILE_BrendansMaysHouse_MayPC_On;
}
}
- MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | METATILE_COLLISION_MASK);
}
void DoPCTurnOffEffect(void)
@@ -1156,7 +1155,7 @@ static void PCTurnOffEffect(void)
{
tileId = METATILE_BrendansMaysHouse_MayPC_Off;
}
- MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + 7, gSaveBlock1Ptr->pos.y + dy + 7, tileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | METATILE_COLLISION_MASK);
DrawWholeMapView();
}
@@ -1189,13 +1188,13 @@ static void LotteryCornerComputerEffect(struct Task *task)
task->data[3] = 0;
if (task->data[4] != 0)
{
- MapGridSetMetatileIdAt(18, 8, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(18, 9, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK);
}
else
{
- MapGridSetMetatileIdAt(18, 8, METATILE_Shop_Laptop1_Flash | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(18, 9, METATILE_Shop_Laptop2_Flash | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Flash | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Flash | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
task->data[4] ^= 1;
@@ -1209,8 +1208,8 @@ static void LotteryCornerComputerEffect(struct Task *task)
void EndLotteryCornerComputerEffect(void)
{
- MapGridSetMetatileIdAt(18, 8, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK);
- MapGridSetMetatileIdAt(18, 9, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | METATILE_COLLISION_MASK);
DrawWholeMapView();
}
@@ -1298,7 +1297,12 @@ void IsGrassTypeInParty(void)
void SpawnCameraObject(void)
{
- u8 obj = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_BOY_1, MOVEMENT_TYPE_FACE_DOWN, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3);
+ u8 obj = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_BOY_1,
+ MOVEMENT_TYPE_FACE_DOWN,
+ OBJ_EVENT_ID_CAMERA,
+ gSaveBlock1Ptr->pos.x + MAP_OFFSET,
+ gSaveBlock1Ptr->pos.y + MAP_OFFSET,
+ 3);
gObjectEvents[obj].invisible = TRUE;
CameraObjectSetFollowedSpriteId(gObjectEvents[obj].spriteId);
}
@@ -1949,23 +1953,15 @@ static void Task_MoveElevatorWindowLights(u8 taskId)
if (data[2] == FALSE)
{
for (y = 0; y < 3; y++)
- {
for (x = 0; x < 3; x++)
- {
- MapGridSetMetatileIdAt(x + 8, y + 7, sElevatorWindowTiles_Ascending[y][data[0] % 3] | METATILE_COLLISION_MASK);
- }
- }
+ MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Ascending[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
// descending
else
{
for (y = 0; y < 3; y++)
- {
for (x = 0; x < 3; x++)
- {
- MapGridSetMetatileIdAt(x + 8, y + 7, sElevatorWindowTiles_Descending[y][data[0] % 3] | METATILE_COLLISION_MASK);
- }
- }
+ MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Descending[y][data[0] % 3] | METATILE_COLLISION_MASK);
}
DrawWholeMapView();
data[1] = 0;
diff --git a/src/field_tasks.c b/src/field_tasks.c
index 676a9cfc7..187270f7a 100644
--- a/src/field_tasks.c
+++ b/src/field_tasks.c
@@ -529,7 +529,7 @@ void SetSootopolisGymCrackedIceMetatiles(void)
for (y = 0; y < height; y++)
{
if (IsIcePuzzleCoordVisited(x, y) == TRUE)
- MapGridSetMetatileIdAt(x + 7, y + 7, METATILE_SootopolisGym_Ice_Cracked);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SootopolisGym_Ice_Cracked);
}
}
}
@@ -586,7 +586,7 @@ static void SootopolisGymIcePerStepCallback(u8 taskId)
PlaySE(SE_ICE_CRACK);
MapGridSetMetatileIdAt(x, y, METATILE_SootopolisGym_Ice_Cracked);
CurrentMapDrawMetatileAt(x, y);
- MarkIcePuzzleCoordVisited(x - 7, y - 7);
+ MarkIcePuzzleCoordVisited(x - MAP_OFFSET, y - MAP_OFFSET);
data[1] = 1;
}
break;
@@ -689,7 +689,7 @@ static void SetMuddySlopeMetatile(s16 *data, s16 x, s16 y)
{
u16 tile;
if ((--data[0]) == 0)
- tile = 0xe8;
+ tile = METATILE_General_MuddySlope_Frame0;
else
tile = sMuddySlopeMetatiles[data[0] / 8];
diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c
index 732158733..27ade478f 100644
--- a/src/field_weather_effect.c
+++ b/src/field_weather_effect.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "battle_anim.h"
#include "event_object_movement.h"
+#include "fieldmap.h"
#include "field_weather.h"
#include "overworld.h"
#include "random.h"
@@ -189,7 +190,7 @@ static void CreateCloudSprites(void)
{
gWeatherPtr->sprites.s1.cloudSprites[i] = &gSprites[spriteId];
sprite = gWeatherPtr->sprites.s1.cloudSprites[i];
- SetSpritePosToMapCoords(sCloudSpriteMapCoords[i].x + 7, sCloudSpriteMapCoords[i].y + 7, &sprite->x, &sprite->y);
+ SetSpritePosToMapCoords(sCloudSpriteMapCoords[i].x + MAP_OFFSET, sCloudSpriteMapCoords[i].y + MAP_OFFSET, &sprite->x, &sprite->y);
sprite->coordOffsetEnabled = TRUE;
}
else
diff --git a/src/fieldmap.c b/src/fieldmap.c
index e437ea7fc..aff72c4c6 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -105,9 +105,9 @@ static void InitMapLayoutData(struct MapHeader *mapHeader)
mapLayout = mapHeader->mapLayout;
CpuFastFill16(METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
gBackupMapLayout.map = gBackupMapData;
- width = mapLayout->width + 15;
+ width = mapLayout->width + MAP_OFFSET_W;
gBackupMapLayout.width = width;
- height = mapLayout->height + 14;
+ height = mapLayout->height + MAP_OFFSET_H;
gBackupMapLayout.height = height;
if (width * height <= MAX_MAP_DATA_SIZE)
{
@@ -121,11 +121,11 @@ static void InitBackupMapLayoutData(u16 *map, u16 width, u16 height)
u16 *dest;
int y;
dest = gBackupMapLayout.map;
- dest += gBackupMapLayout.width * 7 + 7;
+ dest += gBackupMapLayout.width * 7 + MAP_OFFSET;
for (y = 0; y < height; y++)
{
CpuCopy16(map, dest, width * 2);
- dest += width + 15;
+ dest += width + MAP_OFFSET_W;
map += width;
}
}
@@ -197,8 +197,8 @@ static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
if (connectedMapHeader)
{
cWidth = connectedMapHeader->mapLayout->width;
- x = offset + 7;
- y = mapHeader->mapLayout->height + 7;
+ x = offset + MAP_OFFSET;
+ y = mapHeader->mapLayout->height + MAP_OFFSET;
if (x < 0)
{
x2 = -x;
@@ -222,7 +222,7 @@ static void FillSouthConnection(struct MapHeader const *mapHeader, struct MapHea
x, y,
connectedMapHeader,
x2, /*y2*/ 0,
- width, /*height*/ 7);
+ width, /*height*/ MAP_OFFSET);
}
}
@@ -237,8 +237,8 @@ static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
{
cWidth = connectedMapHeader->mapLayout->width;
cHeight = connectedMapHeader->mapLayout->height;
- x = offset + 7;
- y2 = cHeight - 7;
+ x = offset + MAP_OFFSET;
+ y2 = cHeight - MAP_OFFSET;
if (x < 0)
{
x2 = -x;
@@ -262,7 +262,7 @@ static void FillNorthConnection(struct MapHeader const *mapHeader, struct MapHea
x, /*y*/ 0,
connectedMapHeader,
x2, y2,
- width, /*height*/ 7);
+ width, /*height*/ MAP_OFFSET);
}
}
@@ -277,8 +277,8 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
{
cWidth = connectedMapHeader->mapLayout->width;
cHeight = connectedMapHeader->mapLayout->height;
- y = offset + 7;
- x2 = cWidth - 7;
+ y = offset + MAP_OFFSET;
+ x2 = cWidth - MAP_OFFSET;
if (y < 0)
{
y2 = -y;
@@ -301,7 +301,7 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
/*x*/ 0, y,
connectedMapHeader,
x2, y2,
- /*width*/ 7, height);
+ /*width*/ MAP_OFFSET, height);
}
}
@@ -314,8 +314,8 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
if (connectedMapHeader)
{
cHeight = connectedMapHeader->mapLayout->height;
- x = mapHeader->mapLayout->width + 7;
- y = offset + 7;
+ x = mapHeader->mapLayout->width + MAP_OFFSET;
+ y = offset + MAP_OFFSET;
if (y < 0)
{
y2 = -y;
@@ -338,7 +338,7 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
x, y,
connectedMapHeader,
/*x2*/ 0, y2,
- /*width*/ 8, height);
+ /*width*/ MAP_OFFSET + 1, height);
}
}
@@ -433,9 +433,9 @@ void SaveMapView(void)
width = gBackupMapLayout.width;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
- for (i = y; i < y + 14; i++)
+ for (i = y; i < y + MAP_OFFSET_H; i++)
{
- for (j = x; j < x + 15; j++)
+ for (j = x; j < x + MAP_OFFSET_W; j++)
*mapView++ = gBackupMapData[width * i + j];
}
}
@@ -480,28 +480,28 @@ static void LoadSavedMapView(void)
width = gBackupMapLayout.width;
x = gSaveBlock1Ptr->pos.x;
y = gSaveBlock1Ptr->pos.y;
- for (i = y; i < y + 14; i++)
+ for (i = y; i < y + MAP_OFFSET_H; i++)
{
if (i == y && i != 0)
yMode = 0;
- else if (i == y + 13 && i != gMapHeader.mapLayout->height - 1)
+ else if (i == y + MAP_OFFSET_H - 1 && i != gMapHeader.mapLayout->height - 1)
yMode = 1;
else
yMode = 0xFF;
- for (j = x; j < x + 15; j++)
+ for (j = x; j < x + MAP_OFFSET_W; j++)
{
if (!SkipCopyingMetatileFromSavedMap(&gBackupMapData[j + width * i], width, yMode))
gBackupMapData[j + width * i] = *mapView;
mapView++;
}
}
- for (j = x; j < x + 15; j++)
+ for (j = x; j < x + MAP_OFFSET_W; j++)
{
if (y != 0)
FixLongGrassMetatilesWindowTop(j, y - 1);
if (i < gMapHeader.mapLayout->height - 1)
- FixLongGrassMetatilesWindowBottom(j, y + 13);
+ FixLongGrassMetatilesWindowBottom(j, y + MAP_OFFSET_H - 1);
}
ClearSavedMapView();
}
@@ -524,25 +524,25 @@ static void MoveMapViewToBackup(u8 direction)
r8 = 0;
x0 = gSaveBlock1Ptr->pos.x;
y0 = gSaveBlock1Ptr->pos.y;
- x2 = 15;
- y2 = 14;
+ x2 = MAP_OFFSET_W;
+ y2 = MAP_OFFSET_H;
switch (direction)
{
case CONNECTION_NORTH:
y0 += 1;
- y2 = 13;
+ y2 = MAP_OFFSET_H - 1;
break;
case CONNECTION_SOUTH:
r8 = 1;
- y2 = 13;
+ y2 = MAP_OFFSET_H - 1;
break;
case CONNECTION_WEST:
x0 += 1;
- x2 = 14;
+ x2 = MAP_OFFSET_W - 1;
break;
case CONNECTION_EAST:
r9 = 1;
- x2 = 14;
+ x2 = MAP_OFFSET_W - 1;
break;
}
for (y = 0; y < y2; y++)
@@ -552,7 +552,7 @@ static void MoveMapViewToBackup(u8 direction)
for (x = 0; x < x2; x++)
{
desti = width * (y + y0);
- srci = (y + r8) * 15 + r9;
+ srci = (y + r8) * MAP_OFFSET_W + r9;
src = &mapView[srci + i];
dest = &gBackupMapData[x0 + desti + j];
*dest = *src;
@@ -568,28 +568,28 @@ int GetMapBorderIdAt(int x, int y)
if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED)
return CONNECTION_INVALID;
- if (x >= (gBackupMapLayout.width - 8))
+ if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1)))
{
if (!gMapConnectionFlags.east)
return CONNECTION_INVALID;
return CONNECTION_EAST;
}
- else if (x < 7)
+ else if (x < MAP_OFFSET)
{
if (!gMapConnectionFlags.west)
return CONNECTION_INVALID;
return CONNECTION_WEST;
}
- else if (y >= (gBackupMapLayout.height - 7))
+ else if (y >= (gBackupMapLayout.height - MAP_OFFSET))
{
if (!gMapConnectionFlags.south)
return CONNECTION_INVALID;
return CONNECTION_SOUTH;
}
- else if (y < 7)
+ else if (y < MAP_OFFSET)
{
if (!gMapConnectionFlags.north)
return CONNECTION_INVALID;
@@ -604,14 +604,14 @@ int GetMapBorderIdAt(int x, int y)
int GetPostCameraMoveMapBorderId(int x, int y)
{
- return GetMapBorderIdAt(gSaveBlock1Ptr->pos.x + 7 + x, gSaveBlock1Ptr->pos.y + 7 + y);
+ return GetMapBorderIdAt(gSaveBlock1Ptr->pos.x + MAP_OFFSET + x, gSaveBlock1Ptr->pos.y + MAP_OFFSET + y);
}
bool32 CanCameraMoveInDirection(int direction)
{
int x, y;
- x = gSaveBlock1Ptr->pos.x + 7 + gDirectionToVectors[direction].x;
- y = gSaveBlock1Ptr->pos.y + 7 + gDirectionToVectors[direction].y;
+ x = gSaveBlock1Ptr->pos.x + MAP_OFFSET + gDirectionToVectors[direction].x;
+ y = gSaveBlock1Ptr->pos.y + MAP_OFFSET + gDirectionToVectors[direction].y;
if (GetMapBorderIdAt(x, y) == CONNECTION_INVALID)
return FALSE;
@@ -771,14 +771,14 @@ struct MapConnection *GetConnectionAtCoords(s16 x, s16 y)
{
direction = connection->direction;
if ((direction == CONNECTION_DIVE || direction == CONNECTION_EMERGE)
- || (direction == CONNECTION_NORTH && y > 6)
- || (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + 7)
- || (direction == CONNECTION_WEST && x > 6)
- || (direction == CONNECTION_EAST && x < gMapHeader.mapLayout->width + 7))
+ || (direction == CONNECTION_NORTH && y > MAP_OFFSET - 1)
+ || (direction == CONNECTION_SOUTH && y < gMapHeader.mapLayout->height + MAP_OFFSET)
+ || (direction == CONNECTION_WEST && x > MAP_OFFSET - 1)
+ || (direction == CONNECTION_EAST && x < gMapHeader.mapLayout->width + MAP_OFFSET))
{
continue;
}
- if (IsPosInConnectingMap(connection, x - 7, y - 7) == TRUE)
+ if (IsPosInConnectingMap(connection, x - MAP_OFFSET, y - MAP_OFFSET) == TRUE)
{
return connection;
}
@@ -789,14 +789,14 @@ struct MapConnection *GetConnectionAtCoords(s16 x, s16 y)
void SetCameraFocusCoords(u16 x, u16 y)
{
- gSaveBlock1Ptr->pos.x = x - 7;
- gSaveBlock1Ptr->pos.y = y - 7;
+ gSaveBlock1Ptr->pos.x = x - MAP_OFFSET;
+ gSaveBlock1Ptr->pos.y = y - MAP_OFFSET;
}
void GetCameraFocusCoords(u16 *x, u16 *y)
{
- *x = gSaveBlock1Ptr->pos.x + 7;
- *y = gSaveBlock1Ptr->pos.y + 7;
+ *x = gSaveBlock1Ptr->pos.x + MAP_OFFSET;
+ *y = gSaveBlock1Ptr->pos.y + MAP_OFFSET;
}
// Unused
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 69e16ee84..3485f3ba3 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -1019,7 +1019,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
if (IsCryPlayingOrClearCrySongs())
{
StopCryAndClearCrySongs();
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}
@@ -1029,7 +1029,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
if (IsCryPlayingOrClearCrySongs())
{
StopCryAndClearCrySongs();
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}
diff --git a/src/item_use.c b/src/item_use.c
index c350d9d0b..0a3181608 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -353,12 +353,14 @@ static bool8 ItemfinderCheckForHiddenItems(const struct MapEvents *events, u8 ta
// Check if there are any hidden items on the current map that haven't been picked up
if (events->bgEvents[i].kind == BG_EVENT_HIDDEN_ITEM && !FlagGet(events->bgEvents[i].bgUnion.hiddenItem.hiddenItemId + FLAG_HIDDEN_ITEMS_START))
{
- itemX = (u16)events->bgEvents[i].x + 7;
+ itemX = (u16)events->bgEvents[i].x + MAP_OFFSET;
distanceX = itemX - playerX;
- itemY = (u16)events->bgEvents[i].y + 7;
+ itemY = (u16)events->bgEvents[i].y + MAP_OFFSET;
distanceY = itemY - playerY;
- if ((u16)(distanceX + 7) < 15 && (distanceY >= -5) && (distanceY < 6))
+ // Player can see 7 metatiles on either side horizontally
+ // and 5 metatiles on either side vertically
+ if (distanceX >= -7 && distanceX <= 7 && distanceY >= -5 && distanceY <= 5)
SetDistanceOfClosestHiddenItem(taskId, distanceX, distanceY);
}
}
@@ -402,27 +404,27 @@ static bool8 IsHiddenItemPresentInConnection(struct MapConnection *connection, i
{
// same weird temp variable behavior seen in IsHiddenItemPresentAtCoords
case 2:
- localOffset = connection->offset + 7;
+ localOffset = connection->offset + MAP_OFFSET;
localX = x - localOffset;
- localLength = mapHeader->mapLayout->height - 7;
+ localLength = mapHeader->mapLayout->height - MAP_OFFSET;
localY = localLength + y; // additions are reversed for some reason
break;
case 1:
- localOffset = connection->offset + 7;
+ localOffset = connection->offset + MAP_OFFSET;
localX = x - localOffset;
- localLength = gMapHeader.mapLayout->height + 7;
+ localLength = gMapHeader.mapLayout->height + MAP_OFFSET;
localY = y - localLength;
break;
case 3:
- localLength = mapHeader->mapLayout->width - 7;
+ localLength = mapHeader->mapLayout->width - MAP_OFFSET;
localX = localLength + x; // additions are reversed for some reason
- localOffset = connection->offset + 7;
+ localOffset = connection->offset + MAP_OFFSET;
localY = y - localOffset;
break;
case 4:
- localLength = gMapHeader.mapLayout->width + 7;
+ localLength = gMapHeader.mapLayout->width + MAP_OFFSET;
localX = x - localLength;
- localOffset = connection->offset + 7;
+ localOffset = connection->offset + MAP_OFFSET;
localY = y - localOffset;
break;
default:
@@ -435,14 +437,16 @@ static void CheckForHiddenItemsInMapConnection(u8 taskId)
{
s16 playerX, playerY;
s16 x, y;
- s16 width = gMapHeader.mapLayout->width + 7;
- s16 height = gMapHeader.mapLayout->height + 7;
+ s16 width = gMapHeader.mapLayout->width + MAP_OFFSET;
+ s16 height = gMapHeader.mapLayout->height + MAP_OFFSET;
- s16 var1 = 7;
- s16 var2 = 7;
+ s16 var1 = MAP_OFFSET;
+ s16 var2 = MAP_OFFSET;
PlayerGetDestCoords(&playerX, &playerY);
+ // Player can see 7 metatiles on either side horizontally
+ // and 5 metatiles on either side vertically
for (x = playerX - 7; x <= playerX + 7; x++)
{
for (y = playerY - 5; y <= playerY + 5; y++)
diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c
index 8de9fc3c9..d3c41236c 100644
--- a/src/mauville_old_man.c
+++ b/src/mauville_old_man.c
@@ -502,9 +502,9 @@ static void BardSing(struct Task *task, struct BardSong *song)
if (sound->var00 <= 50)
{
song->volume = 0x100 + sound->volume * 16;
- m4aMPlayVolumeControl(&gMPlayInfo_SE2, 0xFFFF, song->volume);
+ m4aMPlayVolumeControl(&gMPlayInfo_SE2, TRACKS_ALL, song->volume);
song->pitch = 0x200 + song->phonemes[song->currPhoneme].pitch;
- m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, song->pitch);
+ m4aMPlayPitchControl(&gMPlayInfo_SE2, TRACKS_ALL, song->pitch);
}
break;
case 1:
@@ -514,8 +514,8 @@ static void BardSing(struct Task *task, struct BardSong *song)
song->pitch += 64;
else
song->pitch -= 64;
- m4aMPlayVolumeControl(&gMPlayInfo_SE2, 0xFFFF, song->volume);
- m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, song->pitch);
+ m4aMPlayVolumeControl(&gMPlayInfo_SE2, TRACKS_ALL, song->volume);
+ m4aMPlayPitchControl(&gMPlayInfo_SE2, TRACKS_ALL, song->pitch);
song->voiceInflection++;
song->phonemeTimer--;
if (song->phonemeTimer == 0)
diff --git a/src/mirage_tower.c b/src/mirage_tower.c
index 65aae7255..7fc883ca1 100644
--- a/src/mirage_tower.c
+++ b/src/mirage_tower.c
@@ -479,7 +479,9 @@ static void SetInvisibleMirageTowerMetatiles(void)
{
u8 i;
for (i = 0; i < ARRAY_COUNT(sInvisibleMirageTowerMetatiles); i++)
- MapGridSetMetatileIdAt(sInvisibleMirageTowerMetatiles[i].x + 7, sInvisibleMirageTowerMetatiles[i].y + 7, sInvisibleMirageTowerMetatiles[i].metatileId);
+ MapGridSetMetatileIdAt(sInvisibleMirageTowerMetatiles[i].x + MAP_OFFSET,
+ sInvisibleMirageTowerMetatiles[i].y + MAP_OFFSET,
+ sInvisibleMirageTowerMetatiles[i].metatileId);
DrawWholeMapView();
}
diff --git a/src/overworld.c b/src/overworld.c
index 8347c67a6..a8d9a4a83 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -683,7 +683,7 @@ void UpdateEscapeWarp(s16 x, s16 y)
u8 currMapType = GetCurrentMapType();
u8 destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
if (IsMapTypeOutdoors(currMapType) && IsMapTypeOutdoors(destMapType) != TRUE)
- SetEscapeWarp(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x - 7, y - 6);
+ SetEscapeWarp(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x - MAP_OFFSET, y - MAP_OFFSET + 1);
}
void SetEscapeWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
@@ -957,7 +957,7 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr
static u16 GetCenterScreenMetatileBehavior(void)
{
- return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7);
+ return MapGridGetMetatileBehaviorAt(gSaveBlock1Ptr->pos.x + MAP_OFFSET, gSaveBlock1Ptr->pos.y + MAP_OFFSET);
}
bool32 Overworld_IsBikingAllowed(void)
diff --git a/src/pokeball.c b/src/pokeball.c
index 52d47b534..3aa969fbd 100644
--- a/src/pokeball.c
+++ b/src/pokeball.c
@@ -774,7 +774,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
}
else
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 128);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 128);
}
}
diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c
index 4eb60f3d0..99585407a 100644
--- a/src/pokeblock_feed.c
+++ b/src/pokeblock_feed.c
@@ -886,7 +886,7 @@ static void Task_ExitPokeblockFeed(u8 taskId)
{
ResetSpriteData();
FreeAllSpritePalettes();
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, -1, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
SetMainCallback2(gMain.savedCallback);
DestroyTask(taskId);
FreeAllWindowBuffers();
diff --git a/src/pokedex.c b/src/pokedex.c
index 98fa40dbf..fa64b155c 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -1637,7 +1637,7 @@ void CB2_OpenPokedex(void)
SetVBlankCallback(VBlankCB_Pokedex);
SetMainCallback2(CB2_Pokedex);
CreatePokedexList(sPokedexView->dexMode, sPokedexView->dexOrder);
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x80);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x80);
break;
}
}
@@ -1847,7 +1847,7 @@ static void Task_ClosePokedex(u8 taskId)
FreeWindowAndBgBuffers();
DestroyTask(taskId);
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
Free(sPokedexView);
}
}
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index 5c4b19bc4..f6371b088 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -1498,7 +1498,7 @@ static void CloseSummaryScreen(u8 taskId)
ResetSpriteData();
FreeAllSpritePalettes();
StopCryAndClearCrySongs();
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
if (gMonSpritesGfxPtr == NULL)
DestroyMonSpritesGfxManager(MON_SPR_GFX_MANAGER_A);
FreeSummaryScreen();
diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c
index 6bc0e175b..c8c03ede2 100644
--- a/src/reshow_battle_screen.c
+++ b/src/reshow_battle_screen.c
@@ -21,7 +21,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void);
static bool8 LoadBattlerSpriteGfx(u8 battlerId);
static void CreateBattlerSprite(u8 battlerId);
static void CreateHealthboxSprite(u8 battlerId);
-static void sub_80A95F4(void);
+static void ClearBattleBgCntBaseBlocks(void);
void ReshowBattleScreenDummy(void)
{
@@ -158,7 +158,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
break;
default:
SetVBlankCallback(VBlankCB_Battle);
- sub_80A95F4();
+ ClearBattleBgCntBaseBlocks();
BeginHardwarePaletteFade(0xFF, 0, 0x10, 0, 1);
gPaletteFade.bufferTransferDisabled = 0;
SetMainCallback2(BattleMainCB2);
@@ -169,14 +169,14 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
gBattleScripting.reshowMainState++;
}
-static void sub_80A95F4(void)
+static void ClearBattleBgCntBaseBlocks(void)
{
- struct BGCntrlBitfield *regBgcnt1, *regBgcnt2;
+ vBgCnt *regBgcnt1, *regBgcnt2;
- regBgcnt1 = (struct BGCntrlBitfield *)(&REG_BG1CNT);
+ regBgcnt1 = (vBgCnt *)(&REG_BG1CNT);
regBgcnt1->charBaseBlock = 0;
- regBgcnt2 = (struct BGCntrlBitfield *)(&REG_BG2CNT);
+ regBgcnt2 = (vBgCnt *)(&REG_BG2CNT);
regBgcnt2->charBaseBlock = 0;
}
diff --git a/src/rotating_gate.c b/src/rotating_gate.c
index 997404c27..ea2eec126 100644
--- a/src/rotating_gate.c
+++ b/src/rotating_gate.c
@@ -711,14 +711,14 @@ static void RotatingGate_CreateGatesWithinViewport(s16 deltaX, s16 deltaY)
// Calculate the bounding box of the camera
// Same as RotatingGate_DestroyGatesOutsideViewport
s16 x = gSaveBlock1Ptr->pos.x - 2;
- s16 x2 = gSaveBlock1Ptr->pos.x + 0x11;
+ s16 x2 = gSaveBlock1Ptr->pos.x + MAP_OFFSET_W + 2;
s16 y = gSaveBlock1Ptr->pos.y - 2;
- s16 y2 = gSaveBlock1Ptr->pos.y + 0xe;
+ s16 y2 = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H;
for (i = 0; i < gRotatingGate_PuzzleCount; i++)
{
- s16 x3 = gRotatingGate_PuzzleConfig[i].x + 7;
- s16 y3 = gRotatingGate_PuzzleConfig[i].y + 7;
+ s16 x3 = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET;
+ s16 y3 = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET;
if (y <= y3 && y2 >= y3 && x <= x3 && x2 >= x3 &&
gRotatingGate_GateSpriteIds[i] == MAX_SPRITES)
@@ -748,8 +748,8 @@ static u8 RotatingGate_CreateGate(u8 gateId, s16 deltaX, s16 deltaY)
if (spriteId == MAX_SPRITES)
return MAX_SPRITES;
- x = gate->x + 7;
- y = gate->y + 7;
+ x = gate->x + MAP_OFFSET;
+ y = gate->y + MAP_OFFSET;
sprite = &gSprites[spriteId];
sprite->data[0] = gateId;
@@ -803,15 +803,15 @@ static void RotatingGate_HideGatesOutsideViewport(struct Sprite *sprite)
x = sprite->x + sprite->x2 + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
- x2 = x + 0x40; // Dimensions of the rotating gate
- y2 = y + 0x40;
+ x2 = x + 64; // Dimensions of the rotating gate
+ y2 = y + 64;
- if ((s16)x > DISPLAY_WIDTH + 0x10 - 1 || x2 < -0x10)
+ if ((s16)x > DISPLAY_WIDTH + 16 - 1 || x2 < -16)
{
sprite->invisible = TRUE;
}
- if ((s16)y > DISPLAY_HEIGHT + 0x10 - 1 || y2 < -0x10)
+ if ((s16)y > DISPLAY_HEIGHT + 16 - 1 || y2 < -16)
{
sprite->invisible = TRUE;
}
@@ -828,14 +828,14 @@ static void RotatingGate_DestroyGatesOutsideViewport(void)
// Same as RotatingGate_CreateGatesWithinViewport
s16 x = gSaveBlock1Ptr->pos.x - 2;
- s16 x2 = gSaveBlock1Ptr->pos.x + 0x11;
+ s16 x2 = gSaveBlock1Ptr->pos.x + MAP_OFFSET_W + 2;
s16 y = gSaveBlock1Ptr->pos.y - 2;
- s16 y2 = gSaveBlock1Ptr->pos.y + 0xe;
+ s16 y2 = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H;
for (i = 0; i < gRotatingGate_PuzzleCount; i++)
{
- s16 xGate = gRotatingGate_PuzzleConfig[i].x + 7;
- s16 yGate = gRotatingGate_PuzzleConfig[i].y + 7;
+ s16 xGate = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET;
+ s16 yGate = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET;
if (gRotatingGate_GateSpriteIds[i] == MAX_SPRITES)
continue;
@@ -868,8 +868,8 @@ static s32 RotatingGate_CanRotate(u8 gateId, s32 rotationDirection)
orientation = RotatingGate_GetGateOrientation(gateId);
shape = gRotatingGate_PuzzleConfig[gateId].shape;
- x = gRotatingGate_PuzzleConfig[gateId].x + 7;
- y = gRotatingGate_PuzzleConfig[gateId].y + 7;
+ x = gRotatingGate_PuzzleConfig[gateId].x + MAP_OFFSET;
+ y = gRotatingGate_PuzzleConfig[gateId].y + MAP_OFFSET;
// Loop through the gate's "arms" clockwise (north, south, east, west)
for (i = GATE_ARM_NORTH; i <= GATE_ARM_WEST; i++)
@@ -964,8 +964,8 @@ bool8 CheckForRotatingGatePuzzleCollision(u8 direction, s16 x, s16 y)
return FALSE;
for (i = 0; i < gRotatingGate_PuzzleCount; i++)
{
- s16 gateX = gRotatingGate_PuzzleConfig[i].x + 7;
- s16 gateY = gRotatingGate_PuzzleConfig[i].y + 7;
+ s16 gateX = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET;
+ s16 gateY = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET;
if (gateX - 2 <= x && x <= gateX + 1 && gateY - 2 <= y && y <= gateY + 1)
{
@@ -1002,8 +1002,8 @@ bool8 CheckForRotatingGatePuzzleCollisionWithoutAnimation(u8 direction, s16 x, s
return FALSE;
for (i = 0; i < gRotatingGate_PuzzleCount; i++)
{
- s16 gateX = gRotatingGate_PuzzleConfig[i].x + 7;
- s16 gateY = gRotatingGate_PuzzleConfig[i].y + 7;
+ s16 gateX = gRotatingGate_PuzzleConfig[i].x + MAP_OFFSET;
+ s16 gateY = gRotatingGate_PuzzleConfig[i].y + MAP_OFFSET;
if (gateX - 2 <= x && x <= gateX + 1 && gateY - 2 <= y && y <= gateY + 1)
{
diff --git a/src/rotating_tile_puzzle.c b/src/rotating_tile_puzzle.c
index a3bee4180..56be9736f 100644
--- a/src/rotating_tile_puzzle.c
+++ b/src/rotating_tile_puzzle.c
@@ -119,8 +119,8 @@ u16 MoveRotatingTileObjects(u8 puzzleNumber)
{
s32 puzzleTileStart;
u8 puzzleTileNum;
- s16 x = objectEvents[i].x + 7;
- s16 y = objectEvents[i].y + 7;
+ s16 x = objectEvents[i].x + MAP_OFFSET;
+ s16 y = objectEvents[i].y + MAP_OFFSET;
u16 metatile = MapGridGetMetatileIdAt(x, y);
if (!sRotatingTilePuzzle->isTrickHouse)
@@ -211,8 +211,8 @@ void TurnRotatingTileObjects(void)
s32 rotation;
s8 tileDifference;
u8 objectEventId;
- s16 x = objectEvents[sRotatingTilePuzzle->objects[i].eventTemplateId].x + 7;
- s16 y = objectEvents[sRotatingTilePuzzle->objects[i].eventTemplateId].y + 7;
+ s16 x = objectEvents[sRotatingTilePuzzle->objects[i].eventTemplateId].x + MAP_OFFSET;
+ s16 y = objectEvents[sRotatingTilePuzzle->objects[i].eventTemplateId].y + MAP_OFFSET;
u16 metatile = MapGridGetMetatileIdAt(x, y);
// NOTE: The following 2 assignments and if else could all be replaced with rotation = ROTATE_COUNTERCLOCKWISE
@@ -322,8 +322,8 @@ static void TurnUnsavedRotatingTileObject(u8 eventTemplateId, u8 puzzleTileNum)
s32 puzzleTileStart;
u16 movementType;
struct ObjectEventTemplate *objectEvents = gSaveBlock1Ptr->objectEventTemplates;
- s16 x = objectEvents[eventTemplateId].x + 7;
- s16 y = objectEvents[eventTemplateId].y + 7;
+ s16 x = objectEvents[eventTemplateId].x + MAP_OFFSET;
+ s16 y = objectEvents[eventTemplateId].y + MAP_OFFSET;
u16 metatile = MapGridGetMetatileIdAt(x, y);
if (!sRotatingTilePuzzle->isTrickHouse)
diff --git a/src/roulette.c b/src/roulette.c
index 9b494d752..b6ef1168b 100644
--- a/src/roulette.c
+++ b/src/roulette.c
@@ -3999,8 +3999,8 @@ static void UpdateBallPos(struct Sprite *sprite)
sprite->y2 = -cos * sprite->sBallDistToCenter >> 12;
if (IsSEPlaying())
{
- m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, sprite->x2);
- m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, sprite->x2);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, sprite->x2);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, sprite->x2);
}
}
@@ -4704,8 +4704,8 @@ static void SpriteCB_Taillow_FlyIn(struct Sprite *sprite)
if (IsSEPlaying())
{
s8 pan = -((116 - sprite->x) / 2);
- m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
- m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
}
else
diff --git a/src/scrcmd.c b/src/scrcmd.c
index dfda7b3a2..de0ec7c26 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -791,9 +791,9 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx)
PlayerGetDestCoords(&x, &y);
if (mapGroup == 0xFF && mapNum == 0xFF)
- SetWarpDestinationToFixedHoleWarp(x - 7, y - 7);
+ SetWarpDestinationToFixedHoleWarp(x - MAP_OFFSET, y - MAP_OFFSET);
else
- SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
+ SetWarpDestination(mapGroup, mapNum, -1, x - MAP_OFFSET, y - MAP_OFFSET);
DoFallWarp();
ResetInitialPlayerAvatarState();
return TRUE;
@@ -2043,8 +2043,8 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
u16 tileId = VarGet(ScriptReadHalfword(ctx));
u16 isImpassable = VarGet(ScriptReadHalfword(ctx));
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
if (!isImpassable)
MapGridSetMetatileIdAt(x, y, tileId);
else
@@ -2057,8 +2057,8 @@ bool8 ScrCmd_opendoor(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
PlaySE(GetDoorSoundEffect(x, y));
FieldAnimateDoorOpen(x, y);
return FALSE;
@@ -2069,8 +2069,8 @@ bool8 ScrCmd_closedoor(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
FieldAnimateDoorClose(x, y);
return FALSE;
}
@@ -2094,8 +2094,8 @@ bool8 ScrCmd_setdooropen(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
FieldSetDoorOpened(x, y);
return FALSE;
}
@@ -2105,8 +2105,8 @@ bool8 ScrCmd_setdoorclosed(struct ScriptContext *ctx)
u16 x = VarGet(ScriptReadHalfword(ctx));
u16 y = VarGet(ScriptReadHalfword(ctx));
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
FieldSetDoorClosed(x, y);
return FALSE;
}
diff --git a/src/secret_base.c b/src/secret_base.c
index 0a1472e31..e728f3488 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -390,8 +390,8 @@ void SetOccupiedSecretBaseEntranceMetatiles(struct MapEvents const *events)
{
if (gSaveBlock1Ptr->secretBases[j].secretBaseId == events->bgEvents[bgId].bgUnion.secretBaseId)
{
- s16 x = events->bgEvents[bgId].x + 7;
- s16 y = events->bgEvents[bgId].y + 7;
+ s16 x = events->bgEvents[bgId].x + MAP_OFFSET;
+ s16 y = events->bgEvents[bgId].y + MAP_OFFSET;
s16 tile_id = MapGridGetMetatileIdAt(x, y);
for (i = 0; i < ARRAY_COUNT(sSecretBaseEntranceMetatiles); i++)
{
@@ -474,8 +474,8 @@ static void EnterNewlyCreatedSecretBase_StartFadeIn(void)
ScriptContext2_Enable();
HideMapNamePopUpWindow();
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
- x += 7;
- y += 7;
+ x += MAP_OFFSET;
+ y += MAP_OFFSET;
MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | METATILE_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
FadeInFromBlack();
@@ -530,20 +530,20 @@ void InitSecretBaseAppearance(bool8 hidePC)
for (x = 0; x < DECOR_MAX_SECRET_BASE; x++)
{
if (decorations[x] > 0 && decorations[x] <= NUM_DECORATIONS && gDecorations[decorations[x]].permission != DECORPERM_SPRITE)
- ShowDecorationOnMap((decorPos[x] >> 4) + 7, (decorPos[x] & 0xF) + 7, decorations[x]);
+ ShowDecorationOnMap((decorPos[x] >> 4) + MAP_OFFSET, (decorPos[x] & 0xF) + MAP_OFFSET, decorations[x]);
}
if (secretBaseIdx != 0)
{
// Another player's secret base. Change PC type to the "Register" PC.
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
- MapGridSetMetatileIdAt(x + 7, y + 7, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK);
}
else if (hidePC == TRUE && VarGet(VAR_SECRET_BASE_INITIALIZED) == 1)
{
// Change PC to regular ground tile.
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
- MapGridSetMetatileIdAt(x + 7, y + 7, METATILE_SecretBase_Ground | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_Ground | METATILE_COLLISION_MASK);
}
}
}
@@ -594,7 +594,7 @@ void InitSecretBaseDecorationSprites(void)
gSpecialVar_0x8006 = decorationPositions[i] >> 4;
gSpecialVar_0x8007 = decorationPositions[i] & 0xF;
- metatileBehavior = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + 7, gSpecialVar_0x8007 + 7);
+ metatileBehavior = MapGridGetMetatileBehaviorAt(gSpecialVar_0x8006 + MAP_OFFSET, gSpecialVar_0x8007 + MAP_OFFSET);
if (MetatileBehavior_HoldsSmallDecoration(metatileBehavior) == TRUE
|| MetatileBehavior_HoldsLargeDecoration(metatileBehavior) == TRUE)
{
@@ -660,7 +660,9 @@ void SetCurSecretBaseIdFromPosition(const struct MapPosition *position, const st
s16 i;
for (i = 0; i < events->bgEventCount; i++)
{
- if (events->bgEvents[i].kind == BG_EVENT_SECRET_BASE && position->x == events->bgEvents[i].x + 7 && position->y == events->bgEvents[i].y + 7)
+ if (events->bgEvents[i].kind == BG_EVENT_SECRET_BASE
+ && position->x == events->bgEvents[i].x + MAP_OFFSET
+ && position->y == events->bgEvents[i].y + MAP_OFFSET)
{
sCurSecretBaseId = events->bgEvents[i].bgUnion.secretBaseId;
break;
@@ -830,12 +832,14 @@ static void ClosePlayerSecretBaseEntrance(void)
if (events->bgEvents[i].kind == BG_EVENT_SECRET_BASE
&& gSaveBlock1Ptr->secretBases[0].secretBaseId == events->bgEvents[i].bgUnion.secretBaseId)
{
- metatileId = MapGridGetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7);
+ metatileId = MapGridGetMetatileIdAt(events->bgEvents[i].x + MAP_OFFSET, events->bgEvents[i].y + MAP_OFFSET);
for (j = 0; j < ARRAY_COUNT(sSecretBaseEntranceMetatiles); j++)
{
if (sSecretBaseEntranceMetatiles[j].openMetatileId == metatileId)
{
- MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, sSecretBaseEntranceMetatiles[j].closedMetatileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(events->bgEvents[i].x + MAP_OFFSET,
+ events->bgEvents[i].y + MAP_OFFSET,
+ sSecretBaseEntranceMetatiles[j].closedMetatileId | METATILE_COLLISION_MASK);
break;
}
}
diff --git a/src/sound.c b/src/sound.c
index 42f507b7c..a12475f1e 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -271,7 +271,7 @@ void FadeInNewBGM(u16 songNum, u8 speed)
songNum = 0;
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_BGM);
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0);
m4aSongNumStop(songNum);
m4aMPlayFadeIn(&gMPlayInfo_BGM, speed);
}
@@ -309,7 +309,7 @@ bool8 IsBGMStopped(void)
void PlayCry1(u16 species, s8 pan)
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, 0);
gPokemonCryBGMDuckingCounter = 2;
RestoreBGMVolumeAfterPokemonCry();
@@ -328,7 +328,7 @@ void PlayCry3(u16 species, s8 pan, u8 mode)
}
else
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, mode);
gPokemonCryBGMDuckingCounter = 2;
RestoreBGMVolumeAfterPokemonCry();
@@ -344,7 +344,7 @@ void PlayCry4(u16 species, s8 pan, u8 mode)
else
{
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, mode);
}
}
@@ -357,7 +357,7 @@ void PlayCry6(u16 species, s8 pan, u8 mode) // not present in R/S
}
else
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, mode);
gPokemonCryBGMDuckingCounter = 2;
}
@@ -365,7 +365,7 @@ void PlayCry6(u16 species, s8 pan, u8 mode) // not present in R/S
void PlayCry5(u16 species, u8 mode)
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, 0, CRY_VOLUME, 10, mode);
gPokemonCryBGMDuckingCounter = 2;
RestoreBGMVolumeAfterPokemonCry();
@@ -549,7 +549,7 @@ static void Task_DuckBGMForPokemonCry(u8 taskId)
if (!IsPokemonCryPlaying(gMPlay_PokemonCry))
{
- m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
+ m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 256);
DestroyTask(taskId);
}
}
@@ -579,28 +579,28 @@ void PlaySE12WithPanning(u16 songNum, s8 pan)
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_SE1);
m4aMPlayImmInit(&gMPlayInfo_SE2);
- m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
- m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
void PlaySE1WithPanning(u16 songNum, s8 pan)
{
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_SE1);
- m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
}
void PlaySE2WithPanning(u16 songNum, s8 pan)
{
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_SE2);
- m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
void SE12PanpotControl(s8 pan)
{
- m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
- m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
+ m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
bool8 IsSEPlaying(void)
diff --git a/src/union_room.c b/src/union_room.c
index 41d6ded29..db2d0247b 100644
--- a/src/union_room.c
+++ b/src/union_room.c
@@ -11,6 +11,7 @@
#include "easy_chat.h"
#include "event_data.h"
#include "event_object_lock.h"
+#include "fieldmap.h"
#include "field_control_avatar.h"
#include "field_player_avatar.h"
#include "field_screen_effect.h"
@@ -3999,10 +4000,10 @@ static bool32 IsPlayerFacingTradingBoard(void)
s16 x, y;
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
- if (x != 2 + 7)
+ if (x != 2 + MAP_OFFSET)
return FALSE;
- if (y != 1 + 7)
+ if (y != 1 + MAP_OFFSET)
return FALSE;
if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING)
diff --git a/src/union_room_player_avatar.c b/src/union_room_player_avatar.c
index 4fe470422..225386165 100644
--- a/src/union_room_player_avatar.c
+++ b/src/union_room_player_avatar.c
@@ -137,14 +137,14 @@ static u8 GetUnionRoomPlayerGraphicsId(u32 gender, u32 id)
static void GetUnionRoomPlayerCoords(u32 leaderId, u32 memberId, s32 * x, s32 * y)
{
- *x = sUnionRoomPlayerCoords[leaderId][0] + sUnionRoomGroupOffsets[memberId][0] + 7;
- *y = sUnionRoomPlayerCoords[leaderId][1] + sUnionRoomGroupOffsets[memberId][1] + 7;
+ *x = sUnionRoomPlayerCoords[leaderId][0] + sUnionRoomGroupOffsets[memberId][0] + MAP_OFFSET;
+ *y = sUnionRoomPlayerCoords[leaderId][1] + sUnionRoomGroupOffsets[memberId][1] + MAP_OFFSET;
}
static bool32 IsUnionRoomPlayerAt(u32 leaderId, u32 memberId, s32 x, s32 y)
{
- if ((sUnionRoomPlayerCoords[leaderId][0] + sUnionRoomGroupOffsets[memberId][0] + 7 == x)
- && (sUnionRoomPlayerCoords[leaderId][1] + sUnionRoomGroupOffsets[memberId][1] + 7 == y))
+ if ((sUnionRoomPlayerCoords[leaderId][0] + sUnionRoomGroupOffsets[memberId][0] + MAP_OFFSET == x)
+ && (sUnionRoomPlayerCoords[leaderId][1] + sUnionRoomGroupOffsets[memberId][1] + MAP_OFFSET == y))
return TRUE;
else
return FALSE;
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 8bcb17605..5d7425762 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -25,9 +25,27 @@
extern const u8 EventScript_RepelWoreOff[];
-#define NUM_FEEBAS_SPOTS 6
+#define MAX_ENCOUNTER_RATE 2880
+
+#define NUM_FEEBAS_SPOTS 6
+
+// Number of accessible fishing spots in each section of Route 119
+// Each section is an area of the route between the y coordinates in sRoute119WaterTileData
+#define NUM_FISHING_SPOTS_1 131
+#define NUM_FISHING_SPOTS_2 167
+#define NUM_FISHING_SPOTS_3 149
+#define NUM_FISHING_SPOTS (NUM_FISHING_SPOTS_1 + NUM_FISHING_SPOTS_2 + NUM_FISHING_SPOTS_3)
+
+enum {
+ WILD_AREA_LAND,
+ WILD_AREA_WATER,
+ WILD_AREA_ROCKS,
+ WILD_AREA_FISHING,
+};
+
+#define WILD_CHECK_REPEL (1 << 0)
+#define WILD_CHECK_KEEN_EYE (1 << 1)
-// this file's functions
static u16 FeebasRandom(void);
static void FeebasSeedRng(u16 seed);
static bool8 IsWildLevelAllowedByRepel(u8 level);
@@ -36,91 +54,108 @@ static void ApplyCleanseTagEncounterRateMod(u32 *encRate);
static bool8 TryGetAbilityInfluencedWildMonIndex(const struct WildPokemon *wildMon, u8 type, u8 ability, u8 *monIndex);
static bool8 IsAbilityAllowingEncounter(u8 level);
-// EWRAM vars
EWRAM_DATA static u8 sWildEncountersDisabled = 0;
EWRAM_DATA static u32 sFeebasRngValue = 0;
#include "data/wild_encounters.h"
-//Special Feebas-related data.
-const struct WildPokemon gWildFeebasRoute119Data = {20, 25, SPECIES_FEEBAS};
+static const struct WildPokemon sWildFeebas = {20, 25, SPECIES_FEEBAS};
-const u16 gRoute119WaterTileData[] =
+static const u16 sRoute119WaterTileData[] =
{
- 0, 0x2D, 0,
- 0x2E, 0x5B, 0x83,
- 0x5C, 0x8B, 0x12A,
+//yMin, yMax, numSpots in previous sections
+ 0, 45, 0,
+ 46, 91, NUM_FISHING_SPOTS_1,
+ 92, 139, NUM_FISHING_SPOTS_1 + NUM_FISHING_SPOTS_2,
};
-// code
void DisableWildEncounters(bool8 disabled)
{
sWildEncountersDisabled = disabled;
}
-static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section)
+// Each fishing spot on Route 119 is given a number between 1 and NUM_FISHING_SPOTS inclusive.
+// The number is determined by counting the valid fishing spots left to right top to bottom.
+// The map is divided into three sections, with each section having a pre-counted number of
+// fishing spots to start from to avoid counting a large number of spots at the bottom of the map.
+// Note that a spot is considered valid if it is surfable and not a waterfall. To exclude all
+// of the inaccessible water metatiles (so that they can't be selected as a Feebas spot) they
+// use a different metatile that isn't actually surfable because it has MB_NORMAL instead.
+// This function is given the coordinates and section of a fishing spot and returns which number it is.
+static u16 GetFeebasFishingSpotId(s16 targetX, s16 targetY, u8 section)
{
- u16 xCur;
- u16 yCur;
- u16 yMin = gRoute119WaterTileData[section * 3 + 0];
- u16 yMax = gRoute119WaterTileData[section * 3 + 1];
- u16 tileNum = gRoute119WaterTileData[section * 3 + 2];
+ u16 x, y;
+ u16 yMin = sRoute119WaterTileData[section * 3 + 0];
+ u16 yMax = sRoute119WaterTileData[section * 3 + 1];
+ u16 spotId = sRoute119WaterTileData[section * 3 + 2];
- for (yCur = yMin; yCur <= yMax; yCur++)
+ for (y = yMin; y <= yMax; y++)
{
- for (xCur = 0; xCur < gMapHeader.mapLayout->width; xCur++)
+ for (x = 0; x < gMapHeader.mapLayout->width; x++)
{
- u8 tileBehaviorId = MapGridGetMetatileBehaviorAt(xCur + 7, yCur + 7);
- if (MetatileBehavior_IsSurfableAndNotWaterfall(tileBehaviorId) == TRUE)
+ u8 behavior = MapGridGetMetatileBehaviorAt(x + MAP_OFFSET, y + MAP_OFFSET);
+ if (MetatileBehavior_IsSurfableAndNotWaterfall(behavior) == TRUE)
{
- tileNum++;
- if (x == xCur && y == yCur)
- return tileNum;
+ spotId++;
+ if (targetX == x && targetY == y)
+ return spotId;
}
}
}
- return tileNum + 1;
+ return spotId + 1;
}
static bool8 CheckFeebas(void)
{
u8 i;
u16 feebasSpots[NUM_FEEBAS_SPOTS];
- s16 x;
- s16 y;
+ s16 x, y;
u8 route119Section = 0;
- u16 waterTileNum;
+ u16 spotId;
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE119)
&& gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE119))
{
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
- x -= 7;
- y -= 7;
+ x -= MAP_OFFSET;
+ y -= MAP_OFFSET;
- if (y >= gRoute119WaterTileData[3 * 0 + 0] && y <= gRoute119WaterTileData[3 * 0 + 1])
+ // Get which third of the map the player is in
+ if (y >= sRoute119WaterTileData[3 * 0 + 0] && y <= sRoute119WaterTileData[3 * 0 + 1])
route119Section = 0;
- if (y >= gRoute119WaterTileData[3 * 1 + 0] && y <= gRoute119WaterTileData[3 * 1 + 1])
+ if (y >= sRoute119WaterTileData[3 * 1 + 0] && y <= sRoute119WaterTileData[3 * 1 + 1])
route119Section = 1;
- if (y >= gRoute119WaterTileData[3 * 2 + 0] && y <= gRoute119WaterTileData[3 * 2 + 1])
+ if (y >= sRoute119WaterTileData[3 * 2 + 0] && y <= sRoute119WaterTileData[3 * 2 + 1])
route119Section = 2;
- if (Random() % 100 > 49) // 50% chance of encountering Feebas
+ // 50% chance of encountering Feebas (assuming this is a Feebas spot)
+ if (Random() % 100 > 49)
return FALSE;
FeebasSeedRng(gSaveBlock1Ptr->dewfordTrends[0].rand);
+
+ // Assign each Feebas spot to a random fishing spot.
+ // Randomness is fixed depending on the seed above.
for (i = 0; i != NUM_FEEBAS_SPOTS;)
{
- feebasSpots[i] = FeebasRandom() % 447;
+ feebasSpots[i] = FeebasRandom() % NUM_FISHING_SPOTS;
if (feebasSpots[i] == 0)
- feebasSpots[i] = 447;
+ feebasSpots[i] = NUM_FISHING_SPOTS;
+
+ // < 1 below is a pointless check, it will never be TRUE.
+ // >= 4 to skip fishing spots 1-3, because these are inaccessible
+ // spots at the top of the map, at (9,7), (7,13), and (15,16).
+ // The first accessible fishing spot is spot 4 at (18,18).
if (feebasSpots[i] < 1 || feebasSpots[i] >= 4)
i++;
}
- waterTileNum = GetRoute119WaterTileNum(x, y, route119Section);
+
+ // Check which fishing spot the player is at, and see if
+ // it matches any of the Feebas spots.
+ spotId = GetFeebasFishingSpotId(x, y, route119Section);
for (i = 0; i < NUM_FEEBAS_SPOTS; i++)
{
- if (waterTileNum == feebasSpots[i])
+ if (spotId == feebasSpots[i])
return TRUE;
}
}
@@ -256,7 +291,6 @@ static u8 ChooseWildMonLevel(const struct WildPokemon *wildPokemon)
rand--;
}
}
-
return min + rand;
}
@@ -365,24 +399,13 @@ static void CreateWildMon(u16 species, u8 level)
else
gender = MON_FEMALE;
- CreateMonWithGenderNatureLetter(&gEnemyParty[0], species, level, 32, gender, PickWildMonNature(), 0);
+ CreateMonWithGenderNatureLetter(&gEnemyParty[0], species, level, USE_RANDOM_IVS, gender, PickWildMonNature(), 0);
return;
}
- CreateMonWithNature(&gEnemyParty[0], species, level, 32, PickWildMonNature());
+ CreateMonWithNature(&gEnemyParty[0], species, level, USE_RANDOM_IVS, PickWildMonNature());
}
-enum
-{
- WILD_AREA_LAND,
- WILD_AREA_WATER,
- WILD_AREA_ROCKS,
- WILD_AREA_FISHING,
-};
-
-#define WILD_CHECK_REPEL 0x1
-#define WILD_CHECK_KEEN_EYE 0x2
-
static bool8 TryGenerateWildMon(const struct WildPokemonInfo *wildMonInfo, u8 area, u8 flags)
{
u8 wildMonIndex = 0;
@@ -436,7 +459,7 @@ static bool8 SetUpMassOutbreakEncounter(u8 flags)
return FALSE;
CreateWildMon(gSaveBlock1Ptr->outbreakPokemonSpecies, gSaveBlock1Ptr->outbreakPokemonLevel);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < MAX_MON_MOVES; i++)
SetMonMoveSlot(&gEnemyParty[0], gSaveBlock1Ptr->outbreakPokemonMoves[i], i);
return TRUE;
@@ -444,7 +467,7 @@ static bool8 SetUpMassOutbreakEncounter(u8 flags)
static bool8 DoMassOutbreakEncounterTest(void)
{
- if (gSaveBlock1Ptr->outbreakPokemonSpecies != 0
+ if (gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE
&& gSaveBlock1Ptr->location.mapNum == gSaveBlock1Ptr->outbreakLocationMapNum
&& gSaveBlock1Ptr->location.mapGroup == gSaveBlock1Ptr->outbreakLocationMapGroup)
{
@@ -456,7 +479,7 @@ static bool8 DoMassOutbreakEncounterTest(void)
static bool8 DoWildEncounterRateDiceRoll(u16 encounterRate)
{
- if (Random() % 2880 < encounterRate)
+ if (Random() % MAX_ENCOUNTER_RATE < encounterRate)
return TRUE;
else
return FALSE;
@@ -486,8 +509,8 @@ static bool8 DoWildEncounterRateTest(u32 encounterRate, bool8 ignoreAbility)
else if (ability == ABILITY_SAND_VEIL && gSaveBlock1Ptr->weather == WEATHER_SANDSTORM)
encounterRate /= 2;
}
- if (encounterRate > 2880)
- encounterRate = 2880;
+ if (encounterRate > MAX_ENCOUNTER_RATE)
+ encounterRate = MAX_ENCOUNTER_RATE;
return DoWildEncounterRateDiceRoll(encounterRate);
}
@@ -639,7 +662,7 @@ void RockSmashWildEncounter(void)
gSpecialVar_Result = FALSE;
}
else if (DoWildEncounterRateTest(wildPokemonInfo->encounterRate, 1) == TRUE
- && TryGenerateWildMon(wildPokemonInfo, 2, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
+ && TryGenerateWildMon(wildPokemonInfo, WILD_AREA_ROCKS, WILD_CHECK_REPEL | WILD_CHECK_KEEN_EYE) == TRUE)
{
BattleSetup_StartWildBattle();
gSpecialVar_Result = TRUE;
@@ -744,9 +767,9 @@ void FishingWildEncounter(u8 rod)
if (CheckFeebas() == TRUE)
{
- u8 level = ChooseWildMonLevel(&gWildFeebasRoute119Data);
+ u8 level = ChooseWildMonLevel(&sWildFeebas);
- species = gWildFeebasRoute119Data.species;
+ species = sWildFeebas.species;
CreateWildMon(species, level);
}
else