summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_factory_screen.c6
-rw-r--r--src/battle_pyramid.c8
-rw-r--r--src/bike.c2
-rw-r--r--src/braille_puzzles.c12
-rw-r--r--src/data/party_menu.h36
-rw-r--r--src/decoration.c51
-rw-r--r--src/event_object_movement.c122
-rw-r--r--src/evolution_graphics.c10
-rw-r--r--src/field_camera.c102
-rw-r--r--src/field_control_avatar.c30
-rwxr-xr-xsrc/field_effect_helpers.c12
-rw-r--r--src/field_player_avatar.c8
-rw-r--r--src/field_specials.c56
-rw-r--r--src/field_tasks.c14
-rw-r--r--src/fieldmap.c58
-rw-r--r--src/fldeff_cut.c4
-rw-r--r--src/fldeff_escalator.c4
-rw-r--r--src/fldeff_misc.c8
-rw-r--r--src/fldeff_rocksmash.c6
-rwxr-xr-xsrc/item_use.c14
-rw-r--r--src/m4a.c2
-rw-r--r--src/metatile_behavior.c387
-rw-r--r--src/money.c2
-rw-r--r--src/overworld.c39
-rwxr-xr-xsrc/party_menu.c24
-rw-r--r--src/pokeball.c12
-rw-r--r--src/pokemon.c2
-rw-r--r--src/scrcmd.c6
-rw-r--r--src/secret_base.c16
-rwxr-xr-xsrc/shop.c10
-rw-r--r--src/slot_machine.c2739
-rw-r--r--src/trainer_hill.c4
-rw-r--r--src/trainer_see.c5
-rw-r--r--src/tv.c4
34 files changed, 2113 insertions, 1702 deletions
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index 247b8712f..787dc4740 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -2509,7 +2509,7 @@ static void Swap_Task_HandleYesNo(u8 taskId)
}
}
-static void Swap_HandleQuitSwappingResposne(u8 taskId)
+static void Swap_HandleQuitSwappingResponse(u8 taskId)
{
if (gTasks[taskId].tSaidYes == TRUE)
{
@@ -2533,8 +2533,8 @@ static void Swap_AskQuitSwapping(u8 taskId)
Swap_PrintOnInfoWindow(gText_QuitSwapping);
sFactorySwapScreen->monSwapped = FALSE;
gTasks[taskId].tState = STATE_YESNO_SHOW;
- gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_HandleQuitSwappingResposne) >> 16;
- gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_HandleQuitSwappingResposne);
+ gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_HandleQuitSwappingResponse) >> 16;
+ gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_HandleQuitSwappingResponse);
gTasks[taskId].func = Swap_Task_HandleYesNo;
}
}
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index b10690ce4..9039f60f2 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -1239,7 +1239,7 @@ static u8 GetPostBattleDirectionHintTextIndex(int *hintType, u8 minDistanceForEx
{
for (x = 0; x < 32; x++)
{
- if ((map[x] & METATILE_ID_MASK) == METATILE_BattlePyramid_Exit)
+ if ((map[x] & MAPGRID_METATILE_ID_MASK) == METATILE_BattlePyramid_Exit)
{
x += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.x;
y += MAP_OFFSET - gObjectEvents[gSelectedObjectEvent].initialCoords.y;
@@ -1465,7 +1465,7 @@ void CopyPyramidTrainerLoseSpeech(u16 trainerId)
FrontierSpeechToString(gFacilityTrainers[trainerId].speechLose);
}
-u8 GetBattlePyramindTrainerEncounterMusicId(u16 trainerId)
+u8 GetTrainerEncounterMusicIdInBattlePyramid(u16 trainerId)
{
int i;
@@ -1545,7 +1545,7 @@ void GenerateBattlePyramidFloorLayout(u16 *backupMapData, bool8 setPlayerPositio
{
for (x = 0; x < mapLayout->width; x++)
{
- if ((layoutMap[x] & METATILE_ID_MASK) != METATILE_BattlePyramid_Exit)
+ if ((layoutMap[x] & MAPGRID_METATILE_ID_MASK) != METATILE_BattlePyramid_Exit)
{
map[x] = layoutMap[x];
}
@@ -1556,7 +1556,7 @@ 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] & (METATILE_ELEVATION_MASK | METATILE_COLLISION_MASK)) | METATILE_BattlePyramid_Floor;
+ map[x] = (layoutMap[x] & (MAPGRID_ELEVATION_MASK | MAPGRID_COLLISION_MASK)) | METATILE_BattlePyramid_Floor;
}
else
{
diff --git a/src/bike.c b/src/bike.c
index c99d514cb..ae30ce288 100644
--- a/src/bike.c
+++ b/src/bike.c
@@ -900,7 +900,7 @@ static bool8 IsRunningDisallowedByMetatile(u8 tile)
{
if (MetatileBehavior_IsRunningDisallowed(tile))
return TRUE;
- if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetZCoord() & 1) == 0)
+ if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetElevation() & 1) == 0)
return TRUE;
return FALSE;
}
diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c
index 26caa830d..876e6b4a7 100644
--- a/src/braille_puzzles.c
+++ b/src/braille_puzzles.c
@@ -80,9 +80,9 @@ void DoBrailleDigEffect(void)
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( 9 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | MAPGRID_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);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | MAPGRID_COLLISION_MASK);
DrawWholeMapView();
PlaySE(SE_BANG);
FlagSet(FLAG_SYS_BRAILLE_DIG);
@@ -207,9 +207,9 @@ static void DoBrailleRegirockEffect(void)
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(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | MAPGRID_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);
+ MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | MAPGRID_COLLISION_MASK);
DrawWholeMapView();
PlaySE(SE_BANG);
FlagSet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED);
@@ -246,9 +246,9 @@ static void DoBrailleRegisteelEffect(void)
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(7 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomLeft | MAPGRID_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);
+ MapGridSetMetatileIdAt(9 + MAP_OFFSET, 20 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_BottomRight | MAPGRID_COLLISION_MASK);
DrawWholeMapView();
PlaySE(SE_BANG);
FlagSet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED);
diff --git a/src/data/party_menu.h b/src/data/party_menu.h
index f8093a9b6..7735dae58 100644
--- a/src/data/party_menu.h
+++ b/src/data/party_menu.h
@@ -571,34 +571,14 @@ static const struct WindowTemplate sUnusedWindowTemplate2 =
.baseBlock = 0x39D,
};
-// Tile nums
-static const u8 sMainSlotTileNums[] = {24, 25, 25, 25, 25, 25, 25, 25, 25, 26,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
- 40, 59, 60, 58, 58, 58, 58, 58, 58, 61,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 17,
- 46, 47, 47, 47, 47, 47, 47, 47, 47, 48};
-
-static const u8 sMainSlotTileNums_Egg[] = {24, 25, 25, 25, 25, 25, 25, 25, 25, 26,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
- 32, 33, 33, 33, 33, 33, 33, 33, 33, 34,
- 40, 41, 41, 41, 41, 41, 41, 41, 41, 42,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 17,
- 46, 47, 47, 47, 47, 47, 47, 47, 47, 48};
-
-static const u8 sOtherSlotsTileNums[] = {43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45,
- 49, 33, 33, 33, 33, 33, 33, 33, 33, 52, 53, 51, 51, 51, 51, 51, 51, 54,
- 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57};
-
-static const u8 sOtherSlotsTileNums_Egg[] = {43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45,
- 49, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 50,
- 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57};
-
-static const u8 sEmptySlotTileNums[] = {21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
- 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31,
- 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39};
+// Plain tilemaps for party menu slots.
+// The versions with no HP bar are used by eggs, and in certain displays like registering at a battle facility.
+// There is no empty version of the main slot because it shouldn't ever be empty.
+static const u8 sSlotTilemap_Main[] = INCBIN_U8("graphics/party_menu/slot_main.bin");
+static const u8 sSlotTilemap_MainNoHP[] = INCBIN_U8("graphics/party_menu/slot_main_no_hp.bin");
+static const u8 sSlotTilemap_Wide[] = INCBIN_U8("graphics/party_menu/slot_wide.bin");
+static const u8 sSlotTilemap_WideNoHP[] = INCBIN_U8("graphics/party_menu/slot_wide_no_hp.bin");
+static const u8 sSlotTilemap_WideEmpty[] = INCBIN_U8("graphics/party_menu/slot_wide_empty.bin");
// Palette offsets
static const u8 sGenderPalOffsets[] = {11, 12};
diff --git a/src/decoration.c b/src/decoration.c
index 85a74ed9d..7e102251a 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -1185,10 +1185,10 @@ static u16 GetDecorationElevation(u8 decoration, u8 tileIndex)
switch (decoration)
{
case DECOR_STAND:
- elevation = sDecorationStandElevations[tileIndex] << METATILE_ELEVATION_SHIFT;
+ elevation = sDecorationStandElevations[tileIndex] << MAPGRID_ELEVATION_SHIFT;
return elevation;
case DECOR_SLIDE:
- elevation = sDecorationSlideElevation[tileIndex] << METATILE_ELEVATION_SHIFT;
+ elevation = sDecorationSlideElevation[tileIndex] << MAPGRID_ELEVATION_SHIFT;
return elevation;
default:
return elevation;
@@ -1199,7 +1199,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
{
u16 i, j;
s16 x, y;
- u16 behavior;
+ u16 attributes;
u16 impassableFlag;
u16 overlapsWall;
u16 elevation;
@@ -1210,9 +1210,10 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
for (i = 0; i < decWidth; i++)
{
x = mapX + i;
- behavior = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
- if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (behavior >> METATILE_ELEVATION_SHIFT)))
- impassableFlag = METATILE_COLLISION_MASK;
+ attributes = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + gDecorations[decoration].tiles[j * decWidth + i]);
+ if (MetatileBehavior_IsSecretBaseImpassable(attributes & METATILE_ATTR_BEHAVIOR_MASK) == TRUE
+ || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (attributes >> METATILE_ATTR_LAYER_SHIFT) != METATILE_LAYER_TYPE_NORMAL))
+ impassableFlag = MAPGRID_COLLISION_MASK;
else
impassableFlag = 0;
@@ -1471,24 +1472,26 @@ static void AttemptCancelPlaceDecoration(u8 taskId)
DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt);
}
-// Note: behaviorBy is pre-anded with METATILE_ELEVATION_MASK.
-static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 behaviorBy)
+static bool8 IsSecretBaseTrainerSpot(u8 behaviorAt, u16 layerType)
{
- if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || behaviorBy != 0)
+ if (!(MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) == TRUE && layerType == METATILE_LAYER_TYPE_NORMAL))
return FALSE;
return TRUE;
}
-static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 behaviorBy)
+// Can't place decoration where the player was standing when they interacted with the PC
+static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 layerType)
{
- if (x == gTasks[taskId].tInitialX + MAP_OFFSET && y == gTasks[taskId].tInitialY + MAP_OFFSET && behaviorBy != 0)
+ if (x == gTasks[taskId].tInitialX + MAP_OFFSET
+ && y == gTasks[taskId].tInitialY + MAP_OFFSET
+ && layerType != METATILE_LAYER_TYPE_NORMAL)
return FALSE;
return TRUE;
}
static bool8 IsFloorOrBoardAndHole(u16 behaviorAt, const struct Decoration *decoration)
{
- if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE)
+ if (MetatileBehavior_IsSecretBaseTrainerSpot(behaviorAt) != TRUE)
{
if (decoration->id == DECOR_SOLID_BOARD && MetatileBehavior_IsSecretBaseHole(behaviorAt) == TRUE)
return TRUE;
@@ -1505,7 +1508,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
u8 i;
u8 j;
u8 behaviorAt;
- u16 behaviorBy;
+ u16 layerType;
u8 mapY;
u8 mapX;
s16 curY;
@@ -1524,14 +1527,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
- behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
+ layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
if (!IsFloorOrBoardAndHole(behaviorAt, decoration))
return FALSE;
- if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
+ if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE;
- behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
+ behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
return FALSE;
}
@@ -1545,14 +1548,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
- behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK;
- if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, behaviorBy))
+ layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ATTR_LAYER_MASK;
+ if (!MetatileBehavior_IsNormal(behaviorAt) && !IsSecretBaseTrainerSpot(behaviorAt, layerType))
return FALSE;
- if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
+ if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE;
- if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
+ if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
return FALSE;
}
}
@@ -1562,14 +1565,14 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
{
curX = gTasks[taskId].tCursorX + j;
behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY);
- behaviorBy = GetBehaviorByMetatileId(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ELEVATION_MASK;
+ layerType = GetMetatileAttributesById(NUM_TILES_IN_PRIMARY + decoration->tiles[j]) & METATILE_ATTR_LAYER_MASK;
if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt))
return FALSE;
- if (!IsntInitialPosition(taskId, curX, curY, behaviorBy))
+ if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE;
- behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
+ behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
return FALSE;
}
@@ -1606,7 +1609,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
return FALSE;
}
- if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
+ if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
return FALSE;
}
break;
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index 2c7ceedf4..df79a1d62 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -110,7 +110,7 @@ static void GetGroundEffectFlags_Seaweed(struct ObjectEvent*, u32*);
static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent*, u32*);
static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent*);
static u8 GetReflectionTypeByMetatileBehavior(u32);
-static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z);
+static void InitObjectPriorityByElevation(struct Sprite *, u8);
static void ObjectEventUpdateSubpriority(struct ObjectEvent*, struct Sprite*);
static void DoTracksGroundEffect_None(struct ObjectEvent*, struct Sprite*, u8);
static void DoTracksGroundEffect_Footprints(struct ObjectEvent*, struct Sprite*, u8);
@@ -142,27 +142,29 @@ static void ResetObjectEventFldEffData(struct ObjectEvent *);
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *);
static u8 FindObjectEventPaletteIndexByTag(u16);
static void _PatchObjectPalette(u16, u8);
-static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *, u8);
+static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *, u8);
static void SpriteCB_CameraObject(struct Sprite *);
static void CameraObject_0(struct Sprite *);
static void CameraObject_1(struct Sprite *);
static void CameraObject_2(struct Sprite *);
-static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count);
+static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, struct ObjectEventTemplate *, u8);
static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *);
static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8);
static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8);
-static void InitSpriteForFigure8Anim(struct Sprite *sprite);
-static bool8 AnimateSpriteInFigure8(struct Sprite *sprite);
+static void InitSpriteForFigure8Anim(struct Sprite *);
+static bool8 AnimateSpriteInFigure8(struct Sprite *);
static void SpriteCB_VirtualObject(struct Sprite *);
static void DoShadowFieldEffect(struct ObjectEvent *);
static void SetJumpSpriteData(struct Sprite *, u8, u8, u8);
-static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction);
-static bool8 UpdateWalkSlowAnim(struct Sprite *sprite);
-static u8 DoJumpSpriteMovement(struct Sprite *sprite);
-static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite);
+static void SetWalkSlowSpriteData(struct Sprite *, u8);
+static bool8 UpdateWalkSlowAnim(struct Sprite *);
+static u8 DoJumpSpriteMovement(struct Sprite *);
+static u8 DoJumpSpecialSpriteMovement(struct Sprite *);
static void CreateLevitateMovementTask(struct ObjectEvent *);
static void DestroyLevitateMovementTask(u8);
-static bool8 NpcTakeStep(struct Sprite *sprite);
+static bool8 NpcTakeStep(struct Sprite *);
+static bool8 IsElevationMismatchAt(u8, s16, s16);
+static bool8 AreElevationsCompatible(u8 a, u8 b);
static const struct SpriteFrameImage sPicTable_PechaBerryTree[];
@@ -1433,7 +1435,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl
if (!objectEvent->inanimate)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection));
- SetObjectSubpriorityByZCoord(objectEvent->previousElevation, sprite, 1);
+ SetObjectSubpriorityByElevation(objectEvent->previousElevation, sprite, 1);
UpdateObjectEventVisibility(objectEvent, sprite);
return objectEventId;
}
@@ -1470,7 +1472,7 @@ u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *objectEventTemplate)
return TrySpawnObjectEventTemplate(objectEventTemplate, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY);
}
-u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z)
+u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 elevation)
{
struct ObjectEventTemplate objectEventTemplate;
@@ -1481,7 +1483,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l
objectEventTemplate.inConnection = 0;
objectEventTemplate.x = x;
objectEventTemplate.y = y;
- objectEventTemplate.elevation = z;
+ objectEventTemplate.elevation = elevation;
objectEventTemplate.movementType = movementBehavior;
objectEventTemplate.movementRangeX = 0;
objectEventTemplate.movementRangeY = 0;
@@ -1560,7 +1562,7 @@ u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *),
// A unique id is given as an argument and stored in the sprite data to allow referring back to the same virtual object.
// They can be turned (and, in the case of the Union Room, animated teleporting in and out) but do not have movement types
// or any of the other data normally associated with object events.
-u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 direction)
+u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 elevation, u8 direction)
{
u8 spriteId;
struct Sprite *sprite;
@@ -1587,7 +1589,7 @@ u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 di
sprite->coordOffsetEnabled = TRUE;
sprite->sVirtualObjId = virtualObjId;
- sprite->sVirtualObjElev = z;
+ sprite->sVirtualObjElev = elevation;
if (graphicsInfo->paletteSlot == 10)
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
else if (graphicsInfo->paletteSlot >= 16)
@@ -1598,8 +1600,8 @@ u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 di
SetSubspriteTables(sprite, subspriteTables);
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
}
- InitObjectPriorityByZCoord(sprite, z);
- SetObjectSubpriorityByZCoord(z, sprite, 1);
+ InitObjectPriorityByElevation(sprite, elevation);
+ SetObjectSubpriorityByElevation(elevation, sprite, 1);
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(direction));
}
return spriteId;
@@ -1755,7 +1757,7 @@ static void SpawnObjectEventOnReturnToField(u8 objectEventId, s16 x, s16 y)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection));
ResetObjectEventFldEffData(objectEvent);
- SetObjectSubpriorityByZCoord(objectEvent->previousElevation, sprite, 1);
+ SetObjectSubpriorityByElevation(objectEvent->previousElevation, sprite, 1);
}
}
@@ -2148,7 +2150,7 @@ void UpdateObjectEventCoordsForCameraUpdate(void)
}
}
-u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z)
+u8 GetObjectEventIdByPosition(u16 x, u16 y, u8 elevation)
{
u8 i;
@@ -2156,16 +2158,18 @@ u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z)
{
if (gObjectEvents[i].active)
{
- if (gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y && ObjectEventDoesZCoordMatch(&gObjectEvents[i], z))
+ if (gObjectEvents[i].currentCoords.x == x
+ && gObjectEvents[i].currentCoords.y == y
+ && ObjectEventDoesElevationMatch(&gObjectEvents[i], elevation))
return i;
}
}
return OBJECT_EVENTS_COUNT;
}
-static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *objectEvent, u8 z)
+static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *objectEvent, u8 elevation)
{
- if (objectEvent->currentElevation != 0 && z != 0 && objectEvent->currentElevation != z)
+ if (objectEvent->currentElevation != 0 && elevation != 0 && objectEvent->currentElevation != elevation)
return FALSE;
return TRUE;
@@ -4626,11 +4630,11 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
u8 direction = dir;
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
return COLLISION_OUTSIDE_RANGE;
- else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
+ else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
return COLLISION_IMPASSABLE;
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
return COLLISION_IMPASSABLE;
- else if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y))
+ else if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
return COLLISION_ELEVATION_MISMATCH;
else if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
return COLLISION_OBJECT_EVENT;
@@ -4642,13 +4646,13 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d
u8 flags = 0;
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
- flags |= 1;
- if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
- flags |= 2;
- if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y))
- flags |= 4;
+ flags |= 1 << (COLLISION_OUTSIDE_RANGE - 1);
+ if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
+ flags |= 1 << (COLLISION_IMPASSABLE - 1);
+ if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
+ flags |= 1 << (COLLISION_ELEVATION_MISMATCH - 1);
if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
- flags |= 8;
+ flags |= 1 << (COLLISION_OBJECT_EVENT - 1);
return flags;
}
@@ -4699,7 +4703,7 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16
{
if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y))
{
- if (AreZCoordsCompatible(objectEvent->currentElevation, curObject->currentElevation))
+ if (AreElevationsCompatible(objectEvent->currentElevation, curObject->currentElevation))
return TRUE;
}
}
@@ -7667,23 +7671,23 @@ static void SetObjectEventSpriteOamTableForLongGrass(struct ObjectEvent *objEven
sprite->subspriteTableNum = 4;
- if (ZCoordToPriority(objEvent->previousElevation) == 1)
+ if (ElevationToPriority(objEvent->previousElevation) == 1)
sprite->subspriteTableNum = 5;
}
-bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y)
+static bool8 IsElevationMismatchAt(u8 elevation, s16 x, s16 y)
{
- u8 mapZ;
+ u8 mapElevation;
- if (z == 0)
+ if (elevation == 0)
return FALSE;
- mapZ = MapGridGetZCoordAt(x, y);
+ mapElevation = MapGridGetElevationAt(x, y);
- if (mapZ == 0 || mapZ == 15)
+ if (mapElevation == 0 || mapElevation == 15)
return FALSE;
- if (mapZ != z)
+ if (mapElevation != elevation)
return TRUE;
return FALSE;
@@ -7701,43 +7705,43 @@ static const u8 sElevationToSubspriteTableNum[] = {
1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1,
};
-void UpdateObjectEventZCoordAndPriority(struct ObjectEvent *objEvent, struct Sprite *sprite)
+static void UpdateObjectEventElevationAndPriority(struct ObjectEvent *objEvent, struct Sprite *sprite)
{
if (objEvent->fixedPriority)
return;
- ObjectEventUpdateZCoord(objEvent);
+ ObjectEventUpdateElevation(objEvent);
sprite->subspriteTableNum = sElevationToSubspriteTableNum[objEvent->previousElevation];
sprite->oam.priority = sElevationToPriority[objEvent->previousElevation];
}
-static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z)
+static void InitObjectPriorityByElevation(struct Sprite *sprite, u8 elevation)
{
- sprite->subspriteTableNum = sElevationToSubspriteTableNum[z];
- sprite->oam.priority = sElevationToPriority[z];
+ sprite->subspriteTableNum = sElevationToSubspriteTableNum[elevation];
+ sprite->oam.priority = sElevationToPriority[elevation];
}
-u8 ZCoordToPriority(u8 z)
+u8 ElevationToPriority(u8 elevation)
{
- return sElevationToPriority[z];
+ return sElevationToPriority[elevation];
}
-void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent)
+void ObjectEventUpdateElevation(struct ObjectEvent *objEvent)
{
- u8 z = MapGridGetZCoordAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
- u8 z2 = MapGridGetZCoordAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
+ u8 curElevation = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
+ u8 prevElevation = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
- if (z == 0xF || z2 == 0xF)
+ if (curElevation == 15 || prevElevation == 15)
return;
- objEvent->currentElevation = z;
+ objEvent->currentElevation = curElevation;
- if (z != 0 && z != 0xF)
- objEvent->previousElevation = z;
+ if (curElevation != 0 && curElevation != 15)
+ objEvent->previousElevation = curElevation;
}
-void SetObjectSubpriorityByZCoord(u8 elevation, struct Sprite *sprite, u8 subpriority)
+void SetObjectSubpriorityByElevation(u8 elevation, struct Sprite *sprite, u8 subpriority)
{
s32 tmp = sprite->centerToCornerVecY;
u32 tmpa = *(u16 *)&sprite->y;
@@ -7752,10 +7756,10 @@ static void ObjectEventUpdateSubpriority(struct ObjectEvent *objEvent, struct Sp
if (objEvent->fixedPriority)
return;
- SetObjectSubpriorityByZCoord(objEvent->previousElevation, sprite, 1);
+ SetObjectSubpriorityByElevation(objEvent->previousElevation, sprite, 1);
}
-bool8 AreZCoordsCompatible(u8 a, u8 b)
+static bool8 AreElevationsCompatible(u8 a, u8 b)
{
if (a == 0 || b == 0)
return TRUE;
@@ -8051,7 +8055,7 @@ static void DoGroundEffects_OnSpawn(struct ObjectEvent *objEvent, struct Sprite
if (objEvent->triggerGroundEffectsOnMove)
{
flags = 0;
- UpdateObjectEventZCoordAndPriority(objEvent, sprite);
+ UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnSpawn(objEvent, &flags);
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
DoFlaggedGroundEffects(objEvent, sprite, flags);
@@ -8067,7 +8071,7 @@ static void DoGroundEffects_OnBeginStep(struct ObjectEvent *objEvent, struct Spr
if (objEvent->triggerGroundEffectsOnMove)
{
flags = 0;
- UpdateObjectEventZCoordAndPriority(objEvent, sprite);
+ UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnBeginStep(objEvent, &flags);
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
filters_out_some_ground_effects(objEvent, &flags);
@@ -8084,7 +8088,7 @@ static void DoGroundEffects_OnFinishStep(struct ObjectEvent *objEvent, struct Sp
if (objEvent->triggerGroundEffectsOnStop)
{
flags = 0;
- UpdateObjectEventZCoordAndPriority(objEvent, sprite);
+ UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnFinishStep(objEvent, &flags);
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
FilterOutStepOnPuddleGroundEffectIfJumping(objEvent, &flags);
@@ -8548,7 +8552,7 @@ void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible)
static void SpriteCB_VirtualObject(struct Sprite *sprite)
{
VirtualObject_UpdateAnim(sprite);
- SetObjectSubpriorityByZCoord(sprite->sVirtualObjElev, sprite, 1);
+ SetObjectSubpriorityByElevation(sprite->sVirtualObjElev, sprite, 1);
UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible);
}
diff --git a/src/evolution_graphics.c b/src/evolution_graphics.c
index 50098743d..5d17cca84 100644
--- a/src/evolution_graphics.c
+++ b/src/evolution_graphics.c
@@ -501,12 +501,12 @@ static void SpriteCB_EvolutionMonSprite(struct Sprite* sprite)
u8 CycleEvolutionMonSprite(u8 preEvoSpriteId, u8 postEvoSpriteId)
{
u16 i;
- u16 stack[16];
+ u16 monPalette[16];
u8 taskId;
s32 toDiv;
- for (i = 0; i < ARRAY_COUNT(stack); i++)
- stack[i] = 0x7FFF;
+ for (i = 0; i < ARRAY_COUNT(monPalette); i++)
+ monPalette[i] = RGB_WHITE;
taskId = CreateTask(Task_CycleEvolutionMonSprite_Init, 0);
gTasks[taskId].tPreEvoSpriteId = preEvoSpriteId;
@@ -522,13 +522,13 @@ u8 CycleEvolutionMonSprite(u8 preEvoSpriteId, u8 postEvoSpriteId)
gSprites[preEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[preEvoSpriteId].oam.matrixNum = MATRIX_PRE_EVO;
gSprites[preEvoSpriteId].invisible = FALSE;
- CpuSet(stack, &gPlttBufferFaded[0x100 + (gSprites[preEvoSpriteId].oam.paletteNum * 16)], 16);
+ CpuSet(monPalette, &gPlttBufferFaded[0x100 + (gSprites[preEvoSpriteId].oam.paletteNum * 16)], 16);
gSprites[postEvoSpriteId].callback = SpriteCB_EvolutionMonSprite;
gSprites[postEvoSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[postEvoSpriteId].oam.matrixNum = MATRIX_POST_EVO;
gSprites[postEvoSpriteId].invisible = FALSE;
- CpuSet(stack, &gPlttBufferFaded[0x100 + (gSprites[postEvoSpriteId].oam.paletteNum * 16)], 16);
+ CpuSet(monPalette, &gPlttBufferFaded[0x100 + (gSprites[postEvoSpriteId].oam.paletteNum * 16)], 16);
gTasks[taskId].tEvoStopped = FALSE;
return taskId;
diff --git a/src/field_camera.c b/src/field_camera.c
index a36b6883c..0a00dcbee 100644
--- a/src/field_camera.c
+++ b/src/field_camera.c
@@ -14,7 +14,6 @@
EWRAM_DATA bool8 gUnusedBikeCameraAheadPanback = FALSE;
-// Static type declarations
struct FieldCameraOffset
{
u8 xPixelOffset;
@@ -24,18 +23,16 @@ struct FieldCameraOffset
bool8 copyBGToVRAM;
};
-// static functions
-static void RedrawMapSliceNorth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
-static void RedrawMapSliceSouth(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
-static void RedrawMapSliceEast(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
-static void RedrawMapSliceWest(struct FieldCameraOffset *cameraOffset, const struct MapLayout *mapLayout);
-static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *a, s32 x, s32 y);
-static void DrawWholeMapViewInternal(int x, int y, const struct MapLayout *mapLayout);
-static void DrawMetatileAt(const struct MapLayout *mapLayout, u16, int, int);
-static void DrawMetatile(s32 a, u16 *b, u16 c);
+static void RedrawMapSliceNorth(struct FieldCameraOffset *, const struct MapLayout *);
+static void RedrawMapSliceSouth(struct FieldCameraOffset *, const struct MapLayout *);
+static void RedrawMapSliceEast(struct FieldCameraOffset *, const struct MapLayout *);
+static void RedrawMapSliceWest(struct FieldCameraOffset *, const struct MapLayout *);
+static s32 MapPosToBgTilemapOffset(struct FieldCameraOffset *, s32, s32);
+static void DrawWholeMapViewInternal(int, int, const struct MapLayout *);
+static void DrawMetatileAt(const struct MapLayout *, u16, int, int);
+static void DrawMetatile(s32, u16 *, u16);
static void CameraPanningCB_PanAhead(void);
-// IWRAM bss vars
static struct FieldCameraOffset sFieldCameraOffset;
static s16 sHorizontalCameraPan;
static s16 sVerticalCameraPan;
@@ -46,7 +43,6 @@ struct CameraObject gFieldCamera;
u16 gTotalCameraPixelOffsetY;
u16 gTotalCameraPixelOffsetX;
-// text
static void ResetCameraOffset(struct FieldCameraOffset *cameraOffset)
{
cameraOffset->xTileOffset = 0;
@@ -222,7 +218,7 @@ void DrawDoorMetatileAt(int x, int y, u16 *arr)
if (offset >= 0)
{
- DrawMetatile(1, arr, offset);
+ DrawMetatile(METATILE_LAYER_TYPE_COVERED, arr, offset);
sFieldCameraOffset.copyBGToVRAM = TRUE;
}
}
@@ -244,66 +240,66 @@ static void DrawMetatileAt(const struct MapLayout *mapLayout, u16 offset, int x,
DrawMetatile(MapGridGetMetatileLayerTypeAt(x, y), metatiles + metatileId * 8, offset);
}
-static void DrawMetatile(s32 metatileLayerType, u16 *metatiles, u16 offset)
+static void DrawMetatile(s32 metatileLayerType, u16 *tiles, u16 offset)
{
switch (metatileLayerType)
{
- case 2: // LAYER_TYPE_
+ case METATILE_LAYER_TYPE_SPLIT:
// Draw metatile's bottom layer to the bottom background layer.
- gBGTilemapBuffers3[offset] = metatiles[0];
- gBGTilemapBuffers3[offset + 1] = metatiles[1];
- gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
- gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
+ gOverworldTilemapBuffer_Bg3[offset] = tiles[0];
+ gOverworldTilemapBuffer_Bg3[offset + 1] = tiles[1];
+ gOverworldTilemapBuffer_Bg3[offset + 0x20] = tiles[2];
+ gOverworldTilemapBuffer_Bg3[offset + 0x21] = tiles[3];
// Draw transparent tiles to the middle background layer.
- gBGTilemapBuffers1[offset] = 0;
- gBGTilemapBuffers1[offset + 1] = 0;
- gBGTilemapBuffers1[offset + 0x20] = 0;
- gBGTilemapBuffers1[offset + 0x21] = 0;
+ gOverworldTilemapBuffer_Bg2[offset] = 0;
+ gOverworldTilemapBuffer_Bg2[offset + 1] = 0;
+ gOverworldTilemapBuffer_Bg2[offset + 0x20] = 0;
+ gOverworldTilemapBuffer_Bg2[offset + 0x21] = 0;
// Draw metatile's top layer to the top background layer.
- gBGTilemapBuffers2[offset] = metatiles[4];
- gBGTilemapBuffers2[offset + 1] = metatiles[5];
- gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
- gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
+ gOverworldTilemapBuffer_Bg1[offset] = tiles[4];
+ gOverworldTilemapBuffer_Bg1[offset + 1] = tiles[5];
+ gOverworldTilemapBuffer_Bg1[offset + 0x20] = tiles[6];
+ gOverworldTilemapBuffer_Bg1[offset + 0x21] = tiles[7];
break;
- case 1: // LAYER_TYPE_COVERED_BY_OBJECTS
+ case METATILE_LAYER_TYPE_COVERED:
// Draw metatile's bottom layer to the bottom background layer.
- gBGTilemapBuffers3[offset] = metatiles[0];
- gBGTilemapBuffers3[offset + 1] = metatiles[1];
- gBGTilemapBuffers3[offset + 0x20] = metatiles[2];
- gBGTilemapBuffers3[offset + 0x21] = metatiles[3];
+ gOverworldTilemapBuffer_Bg3[offset] = tiles[0];
+ gOverworldTilemapBuffer_Bg3[offset + 1] = tiles[1];
+ gOverworldTilemapBuffer_Bg3[offset + 0x20] = tiles[2];
+ gOverworldTilemapBuffer_Bg3[offset + 0x21] = tiles[3];
// Draw metatile's top layer to the middle background layer.
- gBGTilemapBuffers1[offset] = metatiles[4];
- gBGTilemapBuffers1[offset + 1] = metatiles[5];
- gBGTilemapBuffers1[offset + 0x20] = metatiles[6];
- gBGTilemapBuffers1[offset + 0x21] = metatiles[7];
+ gOverworldTilemapBuffer_Bg2[offset] = tiles[4];
+ gOverworldTilemapBuffer_Bg2[offset + 1] = tiles[5];
+ gOverworldTilemapBuffer_Bg2[offset + 0x20] = tiles[6];
+ gOverworldTilemapBuffer_Bg2[offset + 0x21] = tiles[7];
// Draw transparent tiles to the top background layer.
- gBGTilemapBuffers2[offset] = 0;
- gBGTilemapBuffers2[offset + 1] = 0;
- gBGTilemapBuffers2[offset + 0x20] = 0;
- gBGTilemapBuffers2[offset + 0x21] = 0;
+ gOverworldTilemapBuffer_Bg1[offset] = 0;
+ gOverworldTilemapBuffer_Bg1[offset + 1] = 0;
+ gOverworldTilemapBuffer_Bg1[offset + 0x20] = 0;
+ gOverworldTilemapBuffer_Bg1[offset + 0x21] = 0;
break;
- case 0: // LAYER_TYPE_NORMAL
+ case METATILE_LAYER_TYPE_NORMAL:
// Draw garbage to the bottom background layer.
- gBGTilemapBuffers3[offset] = 0x3014;
- gBGTilemapBuffers3[offset + 1] = 0x3014;
- gBGTilemapBuffers3[offset + 0x20] = 0x3014;
- gBGTilemapBuffers3[offset + 0x21] = 0x3014;
+ gOverworldTilemapBuffer_Bg3[offset] = 0x3014;
+ gOverworldTilemapBuffer_Bg3[offset + 1] = 0x3014;
+ gOverworldTilemapBuffer_Bg3[offset + 0x20] = 0x3014;
+ gOverworldTilemapBuffer_Bg3[offset + 0x21] = 0x3014;
// Draw metatile's bottom layer to the middle background layer.
- gBGTilemapBuffers1[offset] = metatiles[0];
- gBGTilemapBuffers1[offset + 1] = metatiles[1];
- gBGTilemapBuffers1[offset + 0x20] = metatiles[2];
- gBGTilemapBuffers1[offset + 0x21] = metatiles[3];
+ gOverworldTilemapBuffer_Bg2[offset] = tiles[0];
+ gOverworldTilemapBuffer_Bg2[offset + 1] = tiles[1];
+ gOverworldTilemapBuffer_Bg2[offset + 0x20] = tiles[2];
+ gOverworldTilemapBuffer_Bg2[offset + 0x21] = tiles[3];
// Draw metatile's top layer to the top background layer, which covers object event sprites.
- gBGTilemapBuffers2[offset] = metatiles[4];
- gBGTilemapBuffers2[offset + 1] = metatiles[5];
- gBGTilemapBuffers2[offset + 0x20] = metatiles[6];
- gBGTilemapBuffers2[offset + 0x21] = metatiles[7];
+ gOverworldTilemapBuffer_Bg1[offset] = tiles[4];
+ gOverworldTilemapBuffer_Bg1[offset + 1] = tiles[5];
+ gOverworldTilemapBuffer_Bg1[offset + 0x20] = tiles[6];
+ gOverworldTilemapBuffer_Bg1[offset + 0x21] = tiles[7];
break;
}
ScheduleBgCopyTilemapToVram(1);
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index b5fcfdadf..cdb0db6d1 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -194,7 +194,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
static void GetPlayerPosition(struct MapPosition *position)
{
PlayerGetDestCoords(&position->x, &position->y);
- position->height = PlayerGetZCoord();
+ position->elevation = PlayerGetElevation();
}
static void GetInFrontOfPlayerPosition(struct MapPosition *position)
@@ -203,10 +203,10 @@ static void GetInFrontOfPlayerPosition(struct MapPosition *position)
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
PlayerGetDestCoords(&x, &y);
- if (MapGridGetZCoordAt(x, y) != 0)
- position->height = PlayerGetZCoord();
+ if (MapGridGetElevationAt(x, y) != 0)
+ position->elevation = PlayerGetElevation();
else
- position->height = 0;
+ position->elevation = 0;
}
static u16 GetPlayerCurMetatileBehavior(int runningState)
@@ -264,9 +264,9 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
s32 i;
if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y)))
- objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
+ objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
else
- objectEventId = GetObjectEventIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
+ objectEventId = GetObjectEventIdByPosition(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->elevation);
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
return NULL;
@@ -288,14 +288,14 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
u8 objectEventId;
const u8 *script;
- objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
+ objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
{
if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE)
return NULL;
// Look for an object event on the other side of the counter.
- objectEventId = GetObjectEventIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
+ objectEventId = GetObjectEventIdByPosition(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->elevation);
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
return NULL;
}
@@ -315,7 +315,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 - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
+ struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
if (bgEvent == NULL)
return NULL;
@@ -366,7 +366,7 @@ static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position
static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{
- s8 height;
+ s8 elevation;
if (MetatileBehavior_IsPlayerFacingTVScreen(metatileBehavior, direction) == TRUE)
return EventScript_TV;
@@ -409,8 +409,8 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me
if (MetatileBehavior_IsTrainerHillTimer(metatileBehavior) == TRUE)
return EventScript_TrainerHillTimer;
- height = position->height;
- if (height == MapGridGetZCoordAt(position->x, position->y))
+ elevation = position->elevation;
+ if (elevation == MapGridGetElevationAt(position->x, position->y))
{
if (MetatileBehavior_IsSecretBasePC(metatileBehavior) == TRUE)
return SecretBase_EventScript_PC;
@@ -497,7 +497,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB
static bool8 TryStartCoordEventScript(struct MapPosition *position)
{
- u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
+ u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
if (script == NULL)
return FALSE;
@@ -783,7 +783,7 @@ static bool8 IsArrowWarpMetatileBehavior(u16 metatileBehavior, u8 direction)
static s8 GetWarpEventAtMapPosition(struct MapHeader *mapHeader, struct MapPosition *position)
{
- return GetWarpEventAtPosition(mapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
+ return GetWarpEventAtPosition(mapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
}
static void SetupWarp(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position)
@@ -918,7 +918,7 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16
u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position)
{
- return GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
+ return GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
}
static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c
index 0acb15863..65617038d 100755
--- a/src/field_effect_helpers.c
+++ b/src/field_effect_helpers.c
@@ -359,7 +359,7 @@ void UpdateTallGrassFieldEffect(struct Sprite *sprite)
|| objectEvent->previousCoords.y != sprite->sY))
sprite->sObjectMoved = TRUE;
- // Metatile behavior var re-used
+ // Metatile behavior var re-used as subpriority
metatileBehavior = 0;
if (sprite->animCmdIndex == 0)
metatileBehavior = 4;
@@ -423,7 +423,7 @@ u32 FldEff_LongGrass(void)
{
sprite = &gSprites[spriteId];
sprite->coordOffsetEnabled = TRUE;
- sprite->oam.priority = ZCoordToPriority(gFieldEffectArguments[2]);
+ sprite->oam.priority = ElevationToPriority(gFieldEffectArguments[2]);
sprite->sElevation = gFieldEffectArguments[2];
sprite->sX = gFieldEffectArguments[0];
sprite->sY = gFieldEffectArguments[1];
@@ -1108,7 +1108,7 @@ void SynchroniseSurfPosition(struct ObjectEvent *playerObj, struct Sprite *sprit
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7])
{
MoveCoords(i, &x, &y);
- if (MapGridGetZCoordAt(x, y) == 3)
+ if (MapGridGetElevationAt(x, y) == 3)
{
sprite->data[5]++;
break;
@@ -1646,7 +1646,7 @@ void UpdateJumpImpactEffect(struct Sprite *sprite)
else
{
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
- SetObjectSubpriorityByZCoord(sprite->sElevation, sprite, 0);
+ SetObjectSubpriorityByElevation(sprite->sElevation, sprite, 0);
}
}
@@ -1658,14 +1658,14 @@ void WaitFieldEffectSpriteAnim(struct Sprite *sprite)
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
}
-static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 z, u8 offset)
+static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 elevation, u8 subpriority)
{
u8 i;
s16 var, xhi, lyhi, yhi, ylo;
const struct ObjectEventGraphicsInfo *graphicsInfo; // Unused Variable
struct Sprite *linkedSprite;
- SetObjectSubpriorityByZCoord(z, sprite, offset);
+ SetObjectSubpriorityByElevation(elevation, sprite, subpriority);
for (i = 0; i < OBJECT_EVENTS_COUNT; i ++)
{
struct ObjectEvent *objectEvent = &gObjectEvents[i];
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index 150c352fc..964a62187 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -708,8 +708,8 @@ static u8 CheckForObjectEventStaticCollision(struct ObjectEvent *objectEvent, s1
static bool8 CanStopSurfing(s16 x, s16 y, u8 direction)
{
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
- && MapGridGetZCoordAt(x, y) == 3
- && GetObjectEventIdByXYZ(x, y, 3) == OBJECT_EVENTS_COUNT)
+ && MapGridGetElevationAt(x, y) == 3
+ && GetObjectEventIdByPosition(x, y, 3) == OBJECT_EVENTS_COUNT)
{
CreateStopSurfingTask(direction);
return TRUE;
@@ -1168,7 +1168,7 @@ u8 GetPlayerMovementDirection(void)
return gObjectEvents[gPlayerAvatar.objectEventId].movementDirection;
}
-u8 PlayerGetZCoord(void)
+u8 PlayerGetElevation(void)
{
return gObjectEvents[gPlayerAvatar.objectEventId].previousElevation;
}
@@ -1306,7 +1306,7 @@ bool8 IsPlayerFacingSurfableFishableWater(void)
MoveCoords(playerObjEvent->facingDirection, &x, &y);
if (GetCollisionAtCoords(playerObjEvent, x, y, playerObjEvent->facingDirection) == COLLISION_ELEVATION_MISMATCH
- && PlayerGetZCoord() == 3
+ && PlayerGetElevation() == 3
&& MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y)))
return TRUE;
else
diff --git a/src/field_specials.c b/src/field_specials.c
index 45585bcd3..a4cdafafc 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -650,10 +650,10 @@ void MauvilleGymSetDefaultBarriers(void)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH2_On);
break;
case METATILE_MauvilleGym_GreenBeamH3_Off:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH3_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_GreenBeamH4_Off:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamH4_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_RedBeamH1_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH1_Off);
@@ -674,37 +674,37 @@ void MauvilleGymSetDefaultBarriers(void)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH2_On);
break;
case METATILE_MauvilleGym_RedBeamH3_Off:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH3_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_RedBeamH4_Off:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_GreenBeamV1_On:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_GreenBeamV2_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
break;
case METATILE_MauvilleGym_RedBeamV1_On:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_RedBeamV2_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_FloorTile);
break;
case METATILE_MauvilleGym_PoleBottom_On:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV1_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV1_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_FloorTile:
if (MapGridGetMetatileIdAt(x, y - 1) == METATILE_MauvilleGym_GreenBeamV1_On)
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV2_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_GreenBeamV2_On | MAPGRID_COLLISION_MASK);
else
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV2_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_PoleBottom_Off:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV1_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamV1_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_PoleTop_Off:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_PoleTop_On:
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleTop_Off);
@@ -755,10 +755,10 @@ void MauvilleGymDeactivatePuzzle(void)
MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_RedBeamH4_Off);
break;
case METATILE_MauvilleGym_GreenBeamV1_On:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_On | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_RedBeamV1_On:
- MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_MauvilleGym_PoleBottom_Off | MAPGRID_COLLISION_MASK);
break;
case METATILE_MauvilleGym_GreenBeamV2_On:
case METATILE_MauvilleGym_RedBeamV2_On:
@@ -867,8 +867,8 @@ static void PetalburgGymSetDoorMetatiles(u8 roomNumber, u16 metatileId)
}
for (i = 0; i < nDoors; i++)
{
- 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);
+ MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET, metatileId | MAPGRID_COLLISION_MASK);
+ MapGridSetMetatileIdAt(doorCoordsX[i] + MAP_OFFSET, doorCoordsY[i] + MAP_OFFSET + 1, (metatileId + 8) | MAPGRID_COLLISION_MASK);
}
DrawWholeMapView();
}
@@ -1040,7 +1040,7 @@ static void PCTurnOnEffect_1(s16 isPcTurnedOn, s8 dx, s8 dy)
else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
tileId = METATILE_BrendansMaysHouse_MayPC_On;
}
- MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | MAPGRID_COLLISION_MASK);
}
void DoPCTurnOffEffect(void)
@@ -1069,13 +1069,13 @@ static void PCTurnOffEffect(void)
dy = -1;
break;
}
- if (gSpecialVar_0x8004 == 0)
+ if (gSpecialVar_0x8004 == PC_LOCATION_OTHER)
tileId = METATILE_Building_PC_Off;
- else if (gSpecialVar_0x8004 == 1)
+ else if (gSpecialVar_0x8004 == PC_LOCATION_BRENDANS_HOUSE)
tileId = METATILE_BrendansMaysHouse_BrendanPC_Off;
- else if (gSpecialVar_0x8004 == 2)
+ else if (gSpecialVar_0x8004 == PC_LOCATION_MAYS_HOUSE)
tileId = METATILE_BrendansMaysHouse_MayPC_Off;
- MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(gSaveBlock1Ptr->pos.x + dx + MAP_OFFSET, gSaveBlock1Ptr->pos.y + dy + MAP_OFFSET, tileId | MAPGRID_COLLISION_MASK);
DrawWholeMapView();
}
@@ -1106,13 +1106,13 @@ static void LotteryCornerComputerEffect(struct Task *task)
task->data[3] = 0;
if (task->data[4] != 0)
{
- 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);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | MAPGRID_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | MAPGRID_COLLISION_MASK);
}
else
{
- 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);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Flash | MAPGRID_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Flash | MAPGRID_COLLISION_MASK);
}
DrawWholeMapView();
task->data[4] ^= 1;
@@ -1124,8 +1124,8 @@ static void LotteryCornerComputerEffect(struct Task *task)
void EndLotteryCornerComputerEffect(void)
{
- 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);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 1 + MAP_OFFSET, METATILE_Shop_Laptop1_Normal | MAPGRID_COLLISION_MASK);
+ MapGridSetMetatileIdAt(11 + MAP_OFFSET, 2 + MAP_OFFSET, METATILE_Shop_Laptop2_Normal | MAPGRID_COLLISION_MASK);
DrawWholeMapView();
}
@@ -1872,7 +1872,7 @@ static void Task_MoveElevatorWindowLights(u8 taskId)
for (y = 0; y < 3; y++)
{
for (x = 0; x < 3; x++)
- MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Ascending[y][data[0] % 3] | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Ascending[y][data[0] % 3] | MAPGRID_COLLISION_MASK);
}
}
// descending
@@ -1881,7 +1881,7 @@ static void Task_MoveElevatorWindowLights(u8 taskId)
for (y = 0; y < 3; y++)
{
for (x = 0; x < 3; x++)
- MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Descending[y][data[0] % 3] | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET + 1, y + MAP_OFFSET, sElevatorWindowTiles_Descending[y][data[0] % 3] | MAPGRID_COLLISION_MASK);
}
}
DrawWholeMapView();
diff --git a/src/field_tasks.c b/src/field_tasks.c
index 244036471..8e8875993 100644
--- a/src/field_tasks.c
+++ b/src/field_tasks.c
@@ -445,8 +445,8 @@ static void PacifidlogBridgePerStepCallback(u8 taskId)
static void TryLowerFortreeBridge(s16 x, s16 y)
{
- u8 z = PlayerGetZCoord();
- if (!(z & 1))
+ u8 elevation = PlayerGetElevation();
+ if (!(elevation & 1))
{
switch (MapGridGetMetatileIdAt(x, y))
{
@@ -462,8 +462,8 @@ static void TryLowerFortreeBridge(s16 x, s16 y)
static void TryRaiseFortreeBridge(s16 x, s16 y)
{
- u8 z = PlayerGetZCoord();
- if (!(z & 1))
+ u8 elevation = PlayerGetElevation();
+ if (!(elevation & 1))
{
switch (MapGridGetMetatileIdAt(x, y))
{
@@ -488,7 +488,7 @@ static void FortreeBridgePerStepCallback(u8 taskId)
{
bool8 isFortreeBridgeCur;
bool8 isFortreeBridgePrev;
- u8 z, onBridgeElevation;
+ u8 elevation, onBridgeElevation;
s16 x, y, prevX, prevY;
s16 *data = gTasks[taskId].data;
PlayerGetDestCoords(&x, &y);
@@ -520,9 +520,9 @@ static void FortreeBridgePerStepCallback(u8 taskId)
isFortreeBridgePrev = MetatileBehavior_IsFortreeBridge(MapGridGetMetatileBehaviorAt(prevX, prevY));
// Make sure player isn't below bridge
- z = PlayerGetZCoord();
+ elevation = PlayerGetElevation();
onBridgeElevation = FALSE;
- if ((u8)(z & 1) == 0)
+ if ((u8)(elevation & 1) == 0)
onBridgeElevation = TRUE;
if (onBridgeElevation && (isFortreeBridgeCur == TRUE || isFortreeBridgePrev == TRUE))
diff --git a/src/fieldmap.c b/src/fieldmap.c
index aff72c4c6..4dbf981cf 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -43,12 +43,12 @@ static void FillWestConnection(struct MapHeader const *mapHeader, struct MapHead
static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHeader const *connectedMapHeader, s32 offset);
static void InitBackupMapLayoutConnections(struct MapHeader *mapHeader);
static void LoadSavedMapView(void);
-static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode);
+static bool8 SkipCopyingMetatileFromSavedMap(u16* mapBlock, u16 mapWidth, u8 yMode);
static struct MapConnection *GetIncomingConnection(u8 direction, int x, int y);
static bool8 IsPosInIncomingConnectingMap(u8 direction, int x, int y, struct MapConnection *connection);
static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax, int offset);
-#define MapGridGetBorderTileAt(x, y) ({ \
+#define GetBorderBlockAt(x, y)({ \
u16 block; \
int i; \
u16 *border = gMapHeader.mapLayout->border; \
@@ -56,12 +56,12 @@ static bool8 IsCoordInIncomingConnectingMap(int coord, int srcMax, int destMax,
i = (x + 1) & 1; \
i += ((y + 1) & 1) * 2; \
\
- block = gMapHeader.mapLayout->border[i] | METATILE_COLLISION_MASK; \
+ block = gMapHeader.mapLayout->border[i] | MAPGRID_COLLISION_MASK; \
})
#define AreCoordsWithinMapGridBounds(x, y) (x >= 0 && x < gBackupMapLayout.width && y >= 0 && y < gBackupMapLayout.height)
-#define MapGridGetTileAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : MapGridGetBorderTileAt(x, y))
+#define GetMapGridBlockAt(x, y) (AreCoordsWithinMapGridBounds(x, y) ? gBackupMapLayout.map[x + gBackupMapLayout.width * y] : GetBorderBlockAt(x, y))
struct MapHeader const *const GetMapHeaderFromConnection(struct MapConnection *connection)
{
@@ -87,13 +87,13 @@ void InitMapFromSavedGame(void)
void InitBattlePyramidMap(bool8 setPlayerPosition)
{
- CpuFastFill(METATILE_ID_UNDEFINED << 16 | METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
+ CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
GenerateBattlePyramidFloorLayout(gBackupMapData, setPlayerPosition);
}
void InitTrainerHillMap(void)
{
- CpuFastFill(METATILE_ID_UNDEFINED << 16 | METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
+ CpuFastFill(MAPGRID_UNDEFINED << 16 | MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
GenerateTrainerHillFloorLayout(gBackupMapData);
}
@@ -103,7 +103,7 @@ static void InitMapLayoutData(struct MapHeader *mapHeader)
int width;
int height;
mapLayout = mapHeader->mapLayout;
- CpuFastFill16(METATILE_ID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
+ CpuFastFill16(MAPGRID_UNDEFINED, gBackupMapData, sizeof(gBackupMapData));
gBackupMapLayout.map = gBackupMapData;
width = mapLayout->width + MAP_OFFSET_W;
gBackupMapLayout.width = width;
@@ -342,46 +342,46 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
}
}
-u8 MapGridGetZCoordAt(int x, int y)
+u8 MapGridGetElevationAt(int x, int y)
{
- u16 block = MapGridGetTileAt(x, y);
+ u16 block = GetMapGridBlockAt(x, y);
- if (block == METATILE_ID_UNDEFINED)
+ if (block == MAPGRID_UNDEFINED)
return 0;
- return block >> METATILE_ELEVATION_SHIFT;
+ return block >> MAPGRID_ELEVATION_SHIFT;
}
bool8 MapGridIsImpassableAt(int x, int y)
{
- u16 block = MapGridGetTileAt(x, y);
+ u16 block = GetMapGridBlockAt(x, y);
- if (block == METATILE_ID_UNDEFINED)
+ if (block == MAPGRID_UNDEFINED)
return TRUE;
- return (block & METATILE_COLLISION_MASK) >> METATILE_COLLISION_SHIFT;
+ return (block & MAPGRID_COLLISION_MASK) >> MAPGRID_COLLISION_SHIFT;
}
u32 MapGridGetMetatileIdAt(int x, int y)
{
- u16 block = MapGridGetTileAt(x, y);
+ u16 block = GetMapGridBlockAt(x, y);
- if (block == METATILE_ID_UNDEFINED)
- return MapGridGetBorderTileAt(x, y) & METATILE_ID_MASK;
+ if (block == MAPGRID_UNDEFINED)
+ return GetBorderBlockAt(x, y) & MAPGRID_METATILE_ID_MASK;
- return block & METATILE_ID_MASK;
+ return block & MAPGRID_METATILE_ID_MASK;
}
u32 MapGridGetMetatileBehaviorAt(int x, int y)
{
u16 metatile = MapGridGetMetatileIdAt(x, y);
- return GetBehaviorByMetatileId(metatile) & METATILE_BEHAVIOR_MASK;
+ return GetMetatileAttributesById(metatile) & METATILE_ATTR_BEHAVIOR_MASK;
}
u8 MapGridGetMetatileLayerTypeAt(int x, int y)
{
u16 metatile = MapGridGetMetatileIdAt(x, y);
- return (GetBehaviorByMetatileId(metatile) & METATILE_ELEVATION_MASK) >> METATILE_ELEVATION_SHIFT;
+ return (GetMetatileAttributesById(metatile) & METATILE_ATTR_LAYER_MASK) >> METATILE_ATTR_LAYER_SHIFT;
}
void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
@@ -390,7 +390,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile)
if (AreCoordsWithinMapGridBounds(x, y))
{
i = x + y * gBackupMapLayout.width;
- gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & METATILE_ELEVATION_MASK) | (metatile & ~METATILE_ELEVATION_MASK);
+ gBackupMapLayout.map[i] = (gBackupMapLayout.map[i] & MAPGRID_ELEVATION_MASK) | (metatile & ~MAPGRID_ELEVATION_MASK);
}
}
@@ -404,7 +404,7 @@ void MapGridSetMetatileEntryAt(int x, int y, u16 metatile)
}
}
-u16 GetBehaviorByMetatileId(u16 metatile)
+u16 GetMetatileAttributesById(u16 metatile)
{
u16 *attributes;
if (metatile < NUM_METATILES_IN_PRIMARY)
@@ -565,7 +565,7 @@ static void MoveMapViewToBackup(u8 direction)
int GetMapBorderIdAt(int x, int y)
{
- if (MapGridGetTileAt(x, y) == METATILE_ID_UNDEFINED)
+ if (GetMapGridBlockAt(x, y) == MAPGRID_UNDEFINED)
return CONNECTION_INVALID;
if (x >= (gBackupMapLayout.width - (MAP_OFFSET + 1)))
@@ -817,23 +817,23 @@ void MapGridSetMetatileImpassabilityAt(int x, int y, bool32 impassable)
if (AreCoordsWithinMapGridBounds(x, y))
{
if (impassable)
- gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= METATILE_COLLISION_MASK;
+ gBackupMapLayout.map[x + gBackupMapLayout.width * y] |= MAPGRID_COLLISION_MASK;
else
- gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~METATILE_COLLISION_MASK;
+ gBackupMapLayout.map[x + gBackupMapLayout.width * y] &= ~MAPGRID_COLLISION_MASK;
}
}
-static bool8 SkipCopyingMetatileFromSavedMap(u16* mapMetatilePtr, u16 mapWidth, u8 yMode)
+static bool8 SkipCopyingMetatileFromSavedMap(u16* mapBlock, u16 mapWidth, u8 yMode)
{
if (yMode == 0xFF)
return FALSE;
if (yMode == 0)
- mapMetatilePtr -= mapWidth;
+ mapBlock -= mapWidth;
else
- mapMetatilePtr += mapWidth;
+ mapBlock += mapWidth;
- if (IsLargeBreakableDecoration(*mapMetatilePtr & METATILE_ID_MASK, yMode) == TRUE)
+ if (IsLargeBreakableDecoration(*mapBlock & MAPGRID_METATILE_ID_MASK, yMode) == TRUE)
return TRUE;
return FALSE;
}
diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c
index daa46ad76..9129c5208 100644
--- a/src/fldeff_cut.c
+++ b/src/fldeff_cut.c
@@ -181,7 +181,7 @@ bool8 SetUpFieldMove_Cut(void)
for (j = 0; j < CUT_NORMAL_SIDE; j++)
{
x = j - 1 + gPlayerFacingPosition.x;
- if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
+ if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.elevation)
{
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE
@@ -238,7 +238,7 @@ bool8 SetUpFieldMove_Cut(void)
if (tileCuttable == TRUE)
{
- if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
+ if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.elevation)
{
u8 tileArrayId = ((sHyperCutStruct[i].y * 5) + 12) + (sHyperCutStruct[i].x);
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
diff --git a/src/fldeff_escalator.c b/src/fldeff_escalator.c
index 769e73562..0dc98c319 100644
--- a/src/fldeff_escalator.c
+++ b/src/fldeff_escalator.c
@@ -126,13 +126,13 @@ static void Task_DrawEscalator(u8 taskId)
SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_1, 0);
break;
case 2:
- SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_2, METATILE_COLLISION_MASK);
+ SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_2, MAPGRID_COLLISION_MASK);
break;
case 3:
SetEscalatorMetatile(taskId, sEscalatorMetatiles_1F_3, 0);
break;
case 4:
- SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_0, METATILE_COLLISION_MASK);
+ SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_0, MAPGRID_COLLISION_MASK);
break;
case 5:
SetEscalatorMetatile(taskId, sEscalatorMetatiles_2F_1, 0);
diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c
index c01babb68..4f3f53fa6 100644
--- a/src/fldeff_misc.c
+++ b/src/fldeff_misc.c
@@ -840,9 +840,9 @@ void DoSecretBasePCTurnOffEffect(void)
PlaySE(SE_PC_OFF);
if (!VarGet(VAR_CURRENT_SECRET_BASE))
- MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | MAPGRID_COLLISION_MASK);
else
- MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_RegisterPC | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
}
@@ -1083,7 +1083,7 @@ static void SpriteCB_SandPillar_BreakTop(struct Sprite *sprite)
PlaySE(SE_M_ROCK_THROW);
if (MapGridGetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1) == METATILE_SecretBase_SandOrnament_TopWall)
- MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_Wall_TopMid | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_Wall_TopMid | MAPGRID_COLLISION_MASK);
else
MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6] - 1, METATILE_SecretBase_SandOrnament_BrokenTop);
@@ -1103,7 +1103,7 @@ static void SpriteCB_SandPillar_BreakBase(struct Sprite *sprite)
}
else
{
- MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6], METATILE_SecretBase_SandOrnament_BrokenBase | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(gFieldEffectArguments[5], gFieldEffectArguments[6], METATILE_SecretBase_SandOrnament_BrokenBase | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(gFieldEffectArguments[5], gFieldEffectArguments[6]);
sprite->data[0] = 0;
sprite->callback = SpriteCB_SandPillar_End;
diff --git a/src/fldeff_rocksmash.c b/src/fldeff_rocksmash.c
index 6f4ce8002..a30000e52 100644
--- a/src/fldeff_rocksmash.c
+++ b/src/fldeff_rocksmash.c
@@ -19,7 +19,6 @@
#include "constants/map_types.h"
#include "constants/songs.h"
-// static functions
static void Task_DoFieldMove_Init(u8 taskId);
static void Task_DoFieldMove_ShowMonAfterPose(u8 taskId);
static void Task_DoFieldMove_WaitForMon(u8 taskId);
@@ -28,14 +27,13 @@ static void Task_DoFieldMove_RunFunc(u8 taskId);
static void FieldCallback_RockSmash(void);
static void FieldMove_RockSmash(void);
-// text
bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId)
{
u8 objEventId;
GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
- gPlayerFacingPosition.height = PlayerGetZCoord();
- objEventId = GetObjectEventIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height);
+ gPlayerFacingPosition.elevation = PlayerGetElevation();
+ objEventId = GetObjectEventIdByPosition(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.elevation);
if (gObjectEvents[objEventId].graphicsId != graphicsId)
{
return FALSE;
diff --git a/src/item_use.c b/src/item_use.c
index 29ceb7cae..c03ede61b 100755
--- a/src/item_use.c
+++ b/src/item_use.c
@@ -403,25 +403,25 @@ static bool8 IsHiddenItemPresentInConnection(struct MapConnection *connection, i
switch (connection->direction)
{
// same weird temp variable behavior seen in IsHiddenItemPresentAtCoords
- case 2:
+ case CONNECTION_NORTH:
localOffset = connection->offset + MAP_OFFSET;
localX = x - localOffset;
localLength = mapHeader->mapLayout->height - MAP_OFFSET;
localY = localLength + y; // additions are reversed for some reason
break;
- case 1:
+ case CONNECTION_SOUTH:
localOffset = connection->offset + MAP_OFFSET;
localX = x - localOffset;
localLength = gMapHeader.mapLayout->height + MAP_OFFSET;
localY = y - localLength;
break;
- case 3:
+ case CONNECTION_WEST:
localLength = mapHeader->mapLayout->width - MAP_OFFSET;
localX = localLength + x; // additions are reversed for some reason
localOffset = connection->offset + MAP_OFFSET;
localY = y - localOffset;
break;
- case 4:
+ case CONNECTION_EAST:
localLength = gMapHeader.mapLayout->width + MAP_OFFSET;
localX = x - localLength;
localOffset = connection->offset + MAP_OFFSET;
@@ -725,11 +725,11 @@ static void ItemUseOnFieldCB_WailmerPailBerry(u8 taskId)
static bool8 TryToWaterSudowoodo(void)
{
u16 x, y;
- u8 z;
+ u8 elevation;
u8 objId;
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
- z = PlayerGetZCoord();
- objId = GetObjectEventIdByXYZ(x, y, z);
+ elevation = PlayerGetElevation();
+ objId = GetObjectEventIdByPosition(x, y, elevation);
if (objId == OBJECT_EVENTS_COUNT || gObjectEvents[objId].graphicsId != OBJ_EVENT_GFX_SUDOWOODO)
return FALSE;
else
diff --git a/src/m4a.c b/src/m4a.c
index b159e3873..faeef83e7 100644
--- a/src/m4a.c
+++ b/src/m4a.c
@@ -83,7 +83,7 @@ void m4aSoundInit(void)
for (i = 0; i < NUM_MUSIC_PLAYERS; i++)
{
struct MusicPlayerInfo *mplayInfo = gMPlayTable[i].info;
- MPlayOpen(mplayInfo, gMPlayTable[i].track, gMPlayTable[i].unk_8);
+ MPlayOpen(mplayInfo, gMPlayTable[i].track, gMPlayTable[i].numTracks);
mplayInfo->unk_B = gMPlayTable[i].unk_A;
mplayInfo->memAccArea = gMPlayMemAccArea;
}
diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c
index 6b58e3f05..72d3ac632 100644
--- a/src/metatile_behavior.c
+++ b/src/metatile_behavior.c
@@ -2,254 +2,129 @@
#include "metatile_behavior.h"
#include "constants/metatile_behaviors.h"
-#define TILE_FLAG_ENCOUNTER_TILE 1
-#define TILE_FLAG_SURFABLE 2
-
-#define TILE_ATTRIBUTES(unused, surfable, wildEncounter) (((wildEncounter) ? 1 : 0) | ((surfable) ? 2 : 0) | ((unused) ? 4 : 0))
-
-// wonder what the third flag is supposed to do
-static const u8 sTileBitAttributes[] =
-{
- [MB_NORMAL] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_WALL] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_TALL_GRASS] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_LONG_GRASS] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_UNUSED_04] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_05] = TILE_ATTRIBUTES(FALSE, FALSE, TRUE),
- [MB_DEEP_SAND] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_SHORT_GRASS] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_CAVE] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_LONG_GRASS_SOUTH_EDGE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_NO_RUNNING] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_INDOOR_ENCOUNTER] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_MOUNTAIN_TOP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BATTLE_PYRAMID_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_MOSSDEEP_GYM_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_MT_PYRE_HOLE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_POND_WATER] = TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
- [MB_SEMI_DEEP_WATER] = TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
- [MB_DEEP_WATER] = TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
- [MB_WATERFALL] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_SOOTOPOLIS_DEEP_WATER] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_OCEAN_WATER] = TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
- [MB_PUDDLE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SHALLOW_WATER] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_SOOTOPOLIS_DEEP_WATER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_NO_SURFACING] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_UNUSED_SOOTOPOLIS_DEEP_WATER_2] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_STAIRS_OUTSIDE_ABANDONED_SHIP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SHOAL_CAVE_ENTRANCE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_1D] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_1E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_1F] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_ICE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SAND] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SEAWEED] = TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
- [MB_UNUSED_23] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_ASHGRASS] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_FOOTPRINTS] = TILE_ATTRIBUTES(TRUE, FALSE, TRUE),
- [MB_THIN_ICE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_CRACKED_ICE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_HOT_SPRINGS] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_LAVARIDGE_GYM_B1F_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SEAWEED_NO_SURFACING] = TILE_ATTRIBUTES(TRUE, TRUE, TRUE),
- [MB_REFLECTION_UNDER_BRIDGE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_2C] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_2D] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_2E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_2F] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_IMPASSABLE_EAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_WEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_NORTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_SOUTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_NORTHEAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_NORTHWEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_SOUTHEAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_SOUTHWEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_JUMP_EAST] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_JUMP_WEST] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_JUMP_NORTH] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_JUMP_SOUTH] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_JUMP_NORTHEAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_JUMP_NORTHWEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_JUMP_SOUTHEAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_JUMP_SOUTHWEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_WALK_EAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_WALK_WEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_WALK_NORTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_WALK_SOUTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SLIDE_EAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SLIDE_WEST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SLIDE_NORTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SLIDE_SOUTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_49] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_4A] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_4B] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_4C] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_4D] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_4E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_4F] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_EASTWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_WESTWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_NORTHWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_SOUTHWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_UNUSED_54] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_55] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_56] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_57] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_58] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_59] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_5A] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_5B] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_5C] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_5D] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_5E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_5F] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_NON_ANIMATED_DOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_LADDER] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_EAST_ARROW_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_WEST_ARROW_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_NORTH_ARROW_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SOUTH_ARROW_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_CRACKED_FLOOR_HOLE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_AQUA_HIDEOUT_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_LAVARIDGE_GYM_1F_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_ANIMATED_DOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UP_ESCALATOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_DOWN_ESCALATOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_WATER_DOOR] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_WATER_SOUTH_ARROW_WARP] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_DEEP_SOUTH_WARP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_6F] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE),
- [MB_BRIDGE_OVER_OCEAN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_LOW] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_MED] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_HIGH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_PACIFIDLOG_VERTICAL_LOG_TOP] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_PACIFIDLOG_VERTICAL_LOG_BOTTOM] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_PACIFIDLOG_HORIZONTAL_LOG_LEFT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_PACIFIDLOG_HORIZONTAL_LOG_RIGHT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_FORTREE_BRIDGE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_79] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_MED_EDGE_1] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_MED_EDGE_2] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_HIGH_EDGE_1] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BRIDGE_OVER_POND_HIGH_EDGE_2] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_BRIDGE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BIKE_BRIDGE_OVER_BARRIER] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_COUNTER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_81] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_82] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_CABLE_BOX_RESULTS_1] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_REGION_MAP] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_TELEVISION] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_POKEBLOCK_FEEDER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_88] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SLOT_MACHINE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_ROULETTE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_CLOSED_SOOTOPOLIS_DOOR] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_TRICK_HOUSE_PUZZLE_DOOR] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_PETALBURG_GYM_DOOR] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_RUNNING_SHOES_INSTRUCTION] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_QUESTIONNAIRE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_RED_CAVE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_RED_CAVE_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_BROWN_CAVE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_BROWN_CAVE_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_YELLOW_CAVE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_YELLOW_CAVE_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_TREE_LEFT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_TREE_LEFT_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_SHRUB] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_SHRUB_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_BLUE_CAVE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_BLUE_CAVE_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_TREE_RIGHT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_SPOT_TREE_RIGHT_OPEN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_9E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_9F] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_BERRY_TREE_SOIL] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A1] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A2] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A3] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A4] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A5] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A6] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A7] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A8] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_A9] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_AA] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_AB] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_AC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_AD] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_AE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_AF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_REGISTER_PC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_UNUSED] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BLOCK_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_DECORATION] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_HOLDS_SMALL_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_B6] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_NORTH_WALL] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_BALLOON] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_IMPASSABLE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_GLITTER_MAT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_JUMP_MAT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_SPIN_MAT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_SOUND_MAT] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_BREAKABLE_DOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_SAND_ORNAMENT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_IMPASSABLE_SOUTH_AND_NORTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_IMPASSABLE_WEST_AND_EAST] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_HOLE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_HOLDS_LARGE_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_TV_SHIELD] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_PLAYER_ROOM_PC_ON] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_SECRET_BASE_DECORATION_BASE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SECRET_BASE_POSTER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_C8] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_C9] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_CA] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_CB] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_CC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_CD] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_CE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_CF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_MUDDY_SLOPE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_BUMPY_SLOPE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_CRACKED_FLOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_ISOLATED_VERTICAL_RAIL] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_ISOLATED_HORIZONTAL_RAIL] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_VERTICAL_RAIL] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_HORIZONTAL_RAIL] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE),
- [MB_UNUSED_D7] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_D8] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_D9] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_DA] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_DB] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_DC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_DD] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_DE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_DF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_PICTURE_BOOK_SHELF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_BOOKSHELF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_POKEMON_CENTER_BOOKSHELF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_VASE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_TRASH_CAN] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SHOP_SHELF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_BLUEPRINT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_CABLE_BOX_RESULTS_2] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_WIRELESS_BOX_RESULTS] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_TRAINER_HILL_TIMER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_SKY_PILLAR_CLOSED_DOOR] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_EB] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_EC] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_ED] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_EE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
- [MB_UNUSED_EF] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE),
+#define TILE_FLAG_HAS_ENCOUNTERS (1 << 0)
+#define TILE_FLAG_SURFABLE (1 << 1)
+#define TILE_FLAG_UNUSED (1 << 2) // Roughly all of the traversable metatiles. Set but never read
+
+static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] =
+{
+ [MB_NORMAL] = TILE_FLAG_UNUSED,
+ [MB_TALL_GRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_LONG_GRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_UNUSED_05] = TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_DEEP_SAND] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_SHORT_GRASS] = TILE_FLAG_UNUSED,
+ [MB_CAVE] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_LONG_GRASS_SOUTH_EDGE] = TILE_FLAG_UNUSED,
+ [MB_NO_RUNNING] = TILE_FLAG_UNUSED,
+ [MB_INDOOR_ENCOUNTER] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_MOUNTAIN_TOP] = TILE_FLAG_UNUSED,
+ [MB_BATTLE_PYRAMID_WARP] = TILE_FLAG_UNUSED,
+ [MB_MOSSDEEP_GYM_WARP] = TILE_FLAG_UNUSED,
+ [MB_MT_PYRE_HOLE] = TILE_FLAG_UNUSED,
+ [MB_POND_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_SEMI_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_WATERFALL] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_SOOTOPOLIS_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_OCEAN_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_PUDDLE] = TILE_FLAG_UNUSED,
+ [MB_SHALLOW_WATER] = TILE_FLAG_UNUSED,
+ [MB_NO_SURFACING] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_STAIRS_OUTSIDE_ABANDONED_SHIP] = TILE_FLAG_UNUSED,
+ [MB_SHOAL_CAVE_ENTRANCE] = TILE_FLAG_UNUSED,
+ [MB_ICE] = TILE_FLAG_UNUSED,
+ [MB_SAND] = TILE_FLAG_UNUSED,
+ [MB_SEAWEED] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_UNUSED_23] = TILE_FLAG_UNUSED,
+ [MB_ASHGRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_FOOTPRINTS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_THIN_ICE] = TILE_FLAG_UNUSED,
+ [MB_CRACKED_ICE] = TILE_FLAG_UNUSED,
+ [MB_HOT_SPRINGS] = TILE_FLAG_UNUSED,
+ [MB_LAVARIDGE_GYM_B1F_WARP] = TILE_FLAG_UNUSED,
+ [MB_SEAWEED_NO_SURFACING] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS,
+ [MB_REFLECTION_UNDER_BRIDGE] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_EAST] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_WEST] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_NORTH] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_SOUTH] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_NORTHEAST] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_NORTHWEST] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_SOUTHEAST] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_SOUTHWEST] = TILE_FLAG_UNUSED,
+ [MB_JUMP_NORTHEAST] = TILE_FLAG_UNUSED,
+ [MB_JUMP_NORTHWEST] = TILE_FLAG_UNUSED,
+ [MB_JUMP_SOUTHEAST] = TILE_FLAG_UNUSED,
+ [MB_JUMP_SOUTHWEST] = TILE_FLAG_UNUSED,
+ [MB_WALK_EAST] = TILE_FLAG_UNUSED,
+ [MB_WALK_WEST] = TILE_FLAG_UNUSED,
+ [MB_WALK_NORTH] = TILE_FLAG_UNUSED,
+ [MB_WALK_SOUTH] = TILE_FLAG_UNUSED,
+ [MB_SLIDE_EAST] = TILE_FLAG_UNUSED,
+ [MB_SLIDE_WEST] = TILE_FLAG_UNUSED,
+ [MB_SLIDE_NORTH] = TILE_FLAG_UNUSED,
+ [MB_SLIDE_SOUTH] = TILE_FLAG_UNUSED,
+ [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_FLAG_UNUSED,
+ [MB_UNUSED_49] = TILE_FLAG_UNUSED,
+ [MB_UNUSED_4A] = TILE_FLAG_UNUSED,
+ [MB_EASTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_WESTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_NORTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_SOUTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_NON_ANIMATED_DOOR] = TILE_FLAG_UNUSED,
+ [MB_LADDER] = TILE_FLAG_UNUSED,
+ [MB_EAST_ARROW_WARP] = TILE_FLAG_UNUSED,
+ [MB_WEST_ARROW_WARP] = TILE_FLAG_UNUSED,
+ [MB_NORTH_ARROW_WARP] = TILE_FLAG_UNUSED,
+ [MB_SOUTH_ARROW_WARP] = TILE_FLAG_UNUSED,
+ [MB_CRACKED_FLOOR_HOLE] = TILE_FLAG_UNUSED,
+ [MB_AQUA_HIDEOUT_WARP] = TILE_FLAG_UNUSED,
+ [MB_LAVARIDGE_GYM_1F_WARP] = TILE_FLAG_UNUSED,
+ [MB_ANIMATED_DOOR] = TILE_FLAG_UNUSED,
+ [MB_UP_ESCALATOR] = TILE_FLAG_UNUSED,
+ [MB_DOWN_ESCALATOR] = TILE_FLAG_UNUSED,
+ [MB_WATER_DOOR] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_WATER_SOUTH_ARROW_WARP] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_DEEP_SOUTH_WARP] = TILE_FLAG_UNUSED,
+ [MB_UNUSED_6F] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
+ [MB_BRIDGE_OVER_POND_LOW] = TILE_FLAG_UNUSED,
+ [MB_BRIDGE_OVER_POND_MED] = TILE_FLAG_UNUSED,
+ [MB_BRIDGE_OVER_POND_HIGH] = TILE_FLAG_UNUSED,
+ [MB_PACIFIDLOG_VERTICAL_LOG_TOP] = TILE_FLAG_UNUSED,
+ [MB_PACIFIDLOG_VERTICAL_LOG_BOTTOM] = TILE_FLAG_UNUSED,
+ [MB_PACIFIDLOG_HORIZONTAL_LOG_LEFT] = TILE_FLAG_UNUSED,
+ [MB_PACIFIDLOG_HORIZONTAL_LOG_RIGHT] = TILE_FLAG_UNUSED,
+ [MB_FORTREE_BRIDGE] = TILE_FLAG_UNUSED,
+ [MB_BRIDGE_OVER_POND_MED_EDGE_1] = TILE_FLAG_UNUSED,
+ [MB_BRIDGE_OVER_POND_MED_EDGE_2] = TILE_FLAG_UNUSED,
+ [MB_BRIDGE_OVER_POND_HIGH_EDGE_1] = TILE_FLAG_UNUSED,
+ [MB_BRIDGE_OVER_POND_HIGH_EDGE_2] = TILE_FLAG_UNUSED,
+ [MB_UNUSED_BRIDGE] = TILE_FLAG_UNUSED,
+ [MB_BIKE_BRIDGE_OVER_BARRIER] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_SCENERY] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_TRAINER_SPOT] = TILE_FLAG_UNUSED,
+ [MB_HOLDS_SMALL_DECORATION] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_BALLOON] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_IMPASSABLE] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_GLITTER_MAT] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_JUMP_MAT] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_SPIN_MAT] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_SOUND_MAT] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_BREAKABLE_DOOR] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_SOUTH_AND_NORTH] = TILE_FLAG_UNUSED,
+ [MB_IMPASSABLE_WEST_AND_EAST] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_HOLE] = TILE_FLAG_UNUSED,
+ [MB_HOLDS_LARGE_DECORATION] = TILE_FLAG_UNUSED,
+ [MB_SECRET_BASE_TV_SHIELD] = TILE_FLAG_UNUSED,
+ [MB_PLAYER_ROOM_PC_ON] = TILE_FLAG_UNUSED,
+ [MB_MUDDY_SLOPE] = TILE_FLAG_UNUSED,
+ [MB_BUMPY_SLOPE] = TILE_FLAG_UNUSED,
+ [MB_CRACKED_FLOOR] = TILE_FLAG_UNUSED,
+ [MB_ISOLATED_VERTICAL_RAIL] = TILE_FLAG_UNUSED,
+ [MB_ISOLATED_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED,
+ [MB_VERTICAL_RAIL] = TILE_FLAG_UNUSED,
+ [MB_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED,
};
bool8 MetatileBehavior_IsATile(u8 metatileBehavior)
@@ -259,7 +134,7 @@ bool8 MetatileBehavior_IsATile(u8 metatileBehavior)
bool8 MetatileBehavior_IsEncounterTile(u8 metatileBehavior)
{
- if ((sTileBitAttributes[metatileBehavior] & TILE_FLAG_ENCOUNTER_TILE))
+ if ((sTileBitAttributes[metatileBehavior] & TILE_FLAG_HAS_ENCOUNTERS))
return TRUE;
else
return FALSE;
@@ -687,17 +562,19 @@ bool8 MetatileBehavior_IsRecordMixingSecretBasePC(u8 metatileBehavior)
return FALSE;
}
-bool8 Unref_MetatileBehavior_IsSecretBaseUnused_B2(u8 metatileBehavior)
+// Used by the rock/grass floor spaces that the secret base trainer is not standing on
+bool8 MetatileBehavior_IsSecretBaseScenery1(u8 metatileBehavior)
{
- if (metatileBehavior == MB_SECRET_BASE_UNUSED)
+ if (metatileBehavior == MB_SECRET_BASE_SCENERY)
return TRUE;
else
return FALSE;
}
-bool8 MetatileBehavior_IsBlockDecoration(u8 metatileBehavior)
+// Used by the rock/grass floor space that the secret base trainer stands on
+bool8 MetatileBehavior_IsSecretBaseTrainerSpot(u8 metatileBehavior)
{
- if (metatileBehavior == MB_BLOCK_DECORATION)
+ if (metatileBehavior == MB_SECRET_BASE_TRAINER_SPOT)
return TRUE;
else
return FALSE;
@@ -743,9 +620,9 @@ bool8 MetatileBehavior_IsSecretBaseNorthWall(u8 metatileBehavior)
return FALSE;
}
-bool8 Unref_MetatileBehavior_IsSecretBaseUnused_B2_2(u8 metatileBehavior)
+bool8 MetatileBehavior_IsSecretBaseScenery2(u8 metatileBehavior)
{
- if (metatileBehavior == MB_SECRET_BASE_UNUSED)
+ if (metatileBehavior == MB_SECRET_BASE_SCENERY)
return TRUE;
else
return FALSE;
diff --git a/src/money.c b/src/money.c
index 592ce9f75..5723974a8 100644
--- a/src/money.c
+++ b/src/money.c
@@ -132,7 +132,7 @@ void SubtractMoneyFromVar0x8005(void)
void PrintMoneyAmountInMoneyBox(u8 windowId, int amount, u8 speed)
{
- PrintMoneyAmount(windowId, 0x26, 1, amount, speed);
+ PrintMoneyAmount(windowId, 38, 1, amount, speed);
}
void PrintMoneyAmount(u8 windowId, u8 x, u8 y, int amount, u8 speed)
diff --git a/src/overworld.c b/src/overworld.c
index 4aa579fdd..ba6eaa167 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -183,9 +183,9 @@ static u16 (*sPlayerKeyInterceptCallback)(u32);
static bool8 sReceivingFromLink;
static u8 sRfuKeepAliveTimer;
-u16 *gBGTilemapBuffers1;
-u16 *gBGTilemapBuffers2;
-u16 *gBGTilemapBuffers3;
+u16 *gOverworldTilemapBuffer_Bg2;
+u16 *gOverworldTilemapBuffer_Bg1;
+u16 *gOverworldTilemapBuffer_Bg3;
u16 gHeldKeyCodeToSend;
void (*gFieldCallback)(void);
bool8 (*gFieldCallback2)(void);
@@ -1394,12 +1394,12 @@ static void InitOverworldBgs(void)
SetBgAttribute(1, BG_ATTR_MOSAIC, 1);
SetBgAttribute(2, BG_ATTR_MOSAIC, 1);
SetBgAttribute(3, BG_ATTR_MOSAIC, 1);
- gBGTilemapBuffers2 = AllocZeroed(BG_SCREEN_SIZE);
- gBGTilemapBuffers1 = AllocZeroed(BG_SCREEN_SIZE);
- gBGTilemapBuffers3 = AllocZeroed(BG_SCREEN_SIZE);
- SetBgTilemapBuffer(1, gBGTilemapBuffers2);
- SetBgTilemapBuffer(2, gBGTilemapBuffers1);
- SetBgTilemapBuffer(3, gBGTilemapBuffers3);
+ gOverworldTilemapBuffer_Bg1 = AllocZeroed(BG_SCREEN_SIZE);
+ gOverworldTilemapBuffer_Bg2 = AllocZeroed(BG_SCREEN_SIZE);
+ gOverworldTilemapBuffer_Bg3 = AllocZeroed(BG_SCREEN_SIZE);
+ SetBgTilemapBuffer(1, gOverworldTilemapBuffer_Bg1);
+ SetBgTilemapBuffer(2, gOverworldTilemapBuffer_Bg2);
+ SetBgTilemapBuffer(3, gOverworldTilemapBuffer_Bg3);
InitStandardTextBoxWindows();
}
@@ -1407,12 +1407,9 @@ void CleanupOverworldWindowsAndTilemaps(void)
{
ClearMirageTowerPulseBlendEffect();
FreeAllOverworldWindowBuffers();
- if (gBGTilemapBuffers3)
- FREE_AND_SET_NULL(gBGTilemapBuffers3);
- if (gBGTilemapBuffers1)
- FREE_AND_SET_NULL(gBGTilemapBuffers1);
- if (gBGTilemapBuffers2)
- FREE_AND_SET_NULL(gBGTilemapBuffers2);
+ TRY_FREE_AND_SET_NULL(gOverworldTilemapBuffer_Bg3);
+ TRY_FREE_AND_SET_NULL(gOverworldTilemapBuffer_Bg2);
+ TRY_FREE_AND_SET_NULL(gOverworldTilemapBuffer_Bg1);
}
static void ResetSafariZoneFlag_(void)
@@ -2695,7 +2692,7 @@ static void LoadCableClubPlayer(s32 linkPlayerId, s32 myPlayerId, struct CableCl
GetLinkPlayerCoords(linkPlayerId, &x, &y);
trainer->pos.x = x;
trainer->pos.y = y;
- trainer->pos.height = GetLinkPlayerElevation(linkPlayerId);
+ trainer->pos.elevation = GetLinkPlayerElevation(linkPlayerId);
trainer->metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
}
@@ -2748,7 +2745,7 @@ static const u8 *TryInteractWithPlayer(struct CableClubPlayer *player)
otherPlayerPos = player->pos;
otherPlayerPos.x += gDirectionToVectors[player->facing].x;
otherPlayerPos.y += gDirectionToVectors[player->facing].y;
- otherPlayerPos.height = 0;
+ otherPlayerPos.elevation = 0;
linkPlayerId = GetLinkPlayerIdAt(otherPlayerPos.x, otherPlayerPos.y);
if (linkPlayerId != MAX_LINK_PLAYERS)
@@ -2958,7 +2955,7 @@ static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s1
objEvent->previousCoords.y = y;
SetSpritePosToMapCoords(x, y, &objEvent->initialCoords.x, &objEvent->initialCoords.y);
objEvent->initialCoords.x += 8;
- ObjectEventUpdateZCoord(objEvent);
+ ObjectEventUpdateElevation(objEvent);
}
static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir)
@@ -3098,7 +3095,7 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer
{
objEvent->directionSequenceIndex = 16;
ShiftObjectEventCoords(objEvent, x, y);
- ObjectEventUpdateZCoord(objEvent);
+ ObjectEventUpdateElevation(objEvent);
return TRUE;
}
}
@@ -3204,8 +3201,8 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
struct ObjectEvent *objEvent = &gObjectEvents[linkPlayerObjEvent->objEventId];
sprite->x = objEvent->initialCoords.x;
sprite->y = objEvent->initialCoords.y;
- SetObjectSubpriorityByZCoord(objEvent->previousElevation, sprite, 1);
- sprite->oam.priority = ZCoordToPriority(objEvent->previousElevation);
+ SetObjectSubpriorityByElevation(objEvent->previousElevation, sprite, 1);
+ sprite->oam.priority = ElevationToPriority(objEvent->previousElevation);
if (linkPlayerObjEvent->movementMode == MOVEMENT_MODE_FREE)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(linkDirection(objEvent)));
diff --git a/src/party_menu.c b/src/party_menu.c
index 36e83a168..e15d001c6 100755
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -97,7 +97,7 @@ enum
struct PartyMenuBoxInfoRects
{
- void (*blitFunc)(u8, u8, u8, u8, u8, u8);
+ void (*blitFunc)(u8, u8, u8, u8, u8, bool8);
u8 dimensions[24];
u8 descTextLeft;
u8 descTextTop;
@@ -377,8 +377,8 @@ static void Task_ChooseMonForMoveRelearner(u8);
static void CB2_ChooseMonForMoveRelearner(void);
static void Task_BattlePyramidChooseMonHeldItems(u8);
static void ShiftMoveSlot(struct Pokemon*, u8, u8);
-static void BlitBitmapToPartyWindow_LeftColumn(u8, u8, u8, u8, u8, u8);
-static void BlitBitmapToPartyWindow_RightColumn(u8, u8, u8, u8, u8, u8);
+static void BlitBitmapToPartyWindow_LeftColumn(u8, u8, u8, u8, u8, bool8);
+static void BlitBitmapToPartyWindow_RightColumn(u8, u8, u8, u8, u8, bool8);
static void CursorCb_Summary(u8);
static void CursorCb_Switch(u8);
static void CursorCb_Cancel1(u8);
@@ -2086,35 +2086,35 @@ static void BlitBitmapToPartyWindow(u8 windowId, const u8 *b, u8 c, u8 x, u8 y,
}
}
-static void BlitBitmapToPartyWindow_LeftColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 isEgg)
+static void BlitBitmapToPartyWindow_LeftColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, bool8 hideHP)
{
if (width == 0 && height == 0)
{
width = 10;
height = 7;
}
- if (isEgg == FALSE)
- BlitBitmapToPartyWindow(windowId, sMainSlotTileNums, 10, x, y, width, height);
+ if (hideHP == FALSE)
+ BlitBitmapToPartyWindow(windowId, sSlotTilemap_Main, 10, x, y, width, height);
else
- BlitBitmapToPartyWindow(windowId, sMainSlotTileNums_Egg, 10, x, y, width, height);
+ BlitBitmapToPartyWindow(windowId, sSlotTilemap_MainNoHP, 10, x, y, width, height);
}
-static void BlitBitmapToPartyWindow_RightColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, u8 isEgg)
+static void BlitBitmapToPartyWindow_RightColumn(u8 windowId, u8 x, u8 y, u8 width, u8 height, bool8 hideHP)
{
if (width == 0 && height == 0)
{
width = 18;
height = 3;
}
- if (isEgg == FALSE)
- BlitBitmapToPartyWindow(windowId, sOtherSlotsTileNums, 18, x, y, width, height);
+ if (hideHP == FALSE)
+ BlitBitmapToPartyWindow(windowId, sSlotTilemap_Wide, 18, x, y, width, height);
else
- BlitBitmapToPartyWindow(windowId, sOtherSlotsTileNums_Egg, 18, x, y, width, height);
+ BlitBitmapToPartyWindow(windowId, sSlotTilemap_WideNoHP, 18, x, y, width, height);
}
static void DrawEmptySlot(u8 windowId)
{
- BlitBitmapToPartyWindow(windowId, sEmptySlotTileNums, 18, 0, 0, 18, 3);
+ BlitBitmapToPartyWindow(windowId, sSlotTilemap_WideEmpty, 18, 0, 0, 18, 3);
}
#define LOAD_PARTY_BOX_PAL(paletteIds, paletteOffsets) \
diff --git a/src/pokeball.c b/src/pokeball.c
index 0250a0c5b..a9ccd42d6 100644
--- a/src/pokeball.c
+++ b/src/pokeball.c
@@ -204,6 +204,7 @@ static const union AffineAnimCmd *const sAffineAnim_BallRotate[] =
const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
{
+ [BALL_POKE] =
{
.tileTag = GFX_TAG_POKEBALL,
.paletteTag = GFX_TAG_POKEBALL,
@@ -213,6 +214,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_GREAT] =
{
.tileTag = GFX_TAG_GREATBALL,
.paletteTag = GFX_TAG_GREATBALL,
@@ -222,6 +224,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_SAFARI] =
{
.tileTag = GFX_TAG_SAFARIBALL,
.paletteTag = GFX_TAG_SAFARIBALL,
@@ -231,6 +234,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_ULTRA] =
{
.tileTag = GFX_TAG_ULTRABALL,
.paletteTag = GFX_TAG_ULTRABALL,
@@ -240,6 +244,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_MASTER] =
{
.tileTag = GFX_TAG_MASTERBALL,
.paletteTag = GFX_TAG_MASTERBALL,
@@ -249,6 +254,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_NET] =
{
.tileTag = GFX_TAG_NETBALL,
.paletteTag = GFX_TAG_NETBALL,
@@ -258,6 +264,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_DIVE] =
{
.tileTag = GFX_TAG_DIVEBALL,
.paletteTag = GFX_TAG_DIVEBALL,
@@ -267,6 +274,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_NEST] =
{
.tileTag = GFX_TAG_NESTBALL,
.paletteTag = GFX_TAG_NESTBALL,
@@ -276,6 +284,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_REPEAT] =
{
.tileTag = GFX_TAG_REPEATBALL,
.paletteTag = GFX_TAG_REPEATBALL,
@@ -285,6 +294,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_TIMER] =
{
.tileTag = GFX_TAG_TIMERBALL,
.paletteTag = GFX_TAG_TIMERBALL,
@@ -294,6 +304,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_LUXURY] =
{
.tileTag = GFX_TAG_LUXURYBALL,
.paletteTag = GFX_TAG_LUXURYBALL,
@@ -303,6 +314,7 @@ const struct SpriteTemplate gBallSpriteTemplates[POKEBALL_COUNT] =
.affineAnims = sAffineAnim_BallRotate,
.callback = SpriteCB_BallThrow,
},
+ [BALL_PREMIER] =
{
.tileTag = GFX_TAG_PREMIERBALL,
.paletteTag = GFX_TAG_PREMIERBALL,
diff --git a/src/pokemon.c b/src/pokemon.c
index 08a6fd0f9..61125e362 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -5810,7 +5810,7 @@ s32 GetBattlerMultiplayerId(u16 a1)
u8 GetTrainerEncounterMusicId(u16 trainerOpponentId)
{
if (InBattlePyramid())
- return GetBattlePyramindTrainerEncounterMusicId(trainerOpponentId);
+ return GetTrainerEncounterMusicIdInBattlePyramid(trainerOpponentId);
else if (InTrainerHillChallenge())
return GetTrainerEncounterMusicIdInTrainerHill(trainerOpponentId);
else
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 4b7477fe1..418bf5877 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -1916,9 +1916,9 @@ bool8 ScrCmd_pokemartdecoration2(struct ScriptContext *ctx)
bool8 ScrCmd_playslotmachine(struct ScriptContext *ctx)
{
- u8 slotMachineIndex = VarGet(ScriptReadHalfword(ctx));
+ u8 machineId = VarGet(ScriptReadHalfword(ctx));
- PlaySlotMachine(slotMachineIndex, CB2_ReturnToFieldContinueScriptPlayMapMusic);
+ PlaySlotMachine(machineId, CB2_ReturnToFieldContinueScriptPlayMapMusic);
ScriptContext1_Stop();
return TRUE;
}
@@ -2046,7 +2046,7 @@ bool8 ScrCmd_setmetatile(struct ScriptContext *ctx)
if (!isImpassable)
MapGridSetMetatileIdAt(x, y, tileId);
else
- MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, tileId | MAPGRID_COLLISION_MASK);
return FALSE;
}
diff --git a/src/secret_base.c b/src/secret_base.c
index 8fc97141f..9398c4bb2 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -305,7 +305,7 @@ static void FindMetatileIdMapCoords(s16 *x, s16 *y, u16 metatileId)
{
for (i = 0; i < mapLayout->width; i++)
{
- if ((mapLayout->map[j * mapLayout->width + i] & METATILE_ID_MASK) == metatileId)
+ if ((mapLayout->map[j * mapLayout->width + i] & MAPGRID_METATILE_ID_MASK) == metatileId)
{
*x = i;
*y = j;
@@ -330,7 +330,7 @@ void ToggleSecretBaseEntranceMetatile(void)
{
if (sSecretBaseEntranceMetatiles[i].closedMetatileId == metatileId)
{
- MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
return;
}
@@ -341,7 +341,7 @@ void ToggleSecretBaseEntranceMetatile(void)
{
if (sSecretBaseEntranceMetatiles[i].openMetatileId == metatileId)
{
- MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].closedMetatileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].closedMetatileId | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
return;
}
@@ -396,7 +396,7 @@ void SetOccupiedSecretBaseEntranceMetatiles(struct MapEvents const *events)
{
if (sSecretBaseEntranceMetatiles[i].closedMetatileId == tile_id)
{
- MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, sSecretBaseEntranceMetatiles[i].openMetatileId | MAPGRID_COLLISION_MASK);
break;
}
}
@@ -475,7 +475,7 @@ static void EnterNewlyCreatedSecretBase_StartFadeIn(void)
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
x += MAP_OFFSET;
y += MAP_OFFSET;
- MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, METATILE_SecretBase_PC | MAPGRID_COLLISION_MASK);
CurrentMapDrawMetatileAt(x, y);
FadeInFromBlack();
CreateTask(EnterNewlyCreatedSecretBase_WaitFadeIn, 0);
@@ -536,13 +536,13 @@ void InitSecretBaseAppearance(bool8 hidePC)
{
// Another player's secret base. Change PC type to the "Register" PC.
FindMetatileIdMapCoords(&x, &y, METATILE_SecretBase_PC);
- MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_RegisterPC | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_RegisterPC | MAPGRID_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 + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_Ground | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x + MAP_OFFSET, y + MAP_OFFSET, METATILE_SecretBase_Ground | MAPGRID_COLLISION_MASK);
}
}
}
@@ -838,7 +838,7 @@ static void ClosePlayerSecretBaseEntrance(void)
{
MapGridSetMetatileIdAt(events->bgEvents[i].x + MAP_OFFSET,
events->bgEvents[i].y + MAP_OFFSET,
- sSecretBaseEntranceMetatiles[j].closedMetatileId | METATILE_COLLISION_MASK);
+ sSecretBaseEntranceMetatiles[j].closedMetatileId | MAPGRID_COLLISION_MASK);
break;
}
}
diff --git a/src/shop.c b/src/shop.c
index b65cace09..700a53e37 100755
--- a/src/shop.c
+++ b/src/shop.c
@@ -743,7 +743,7 @@ static void BuyMenuDrawMapBg(void)
if (BuyMenuCheckForOverlapWithMenuBg(i, j) == TRUE)
metatileLayerType = MapGridGetMetatileLayerTypeAt(x + i, y + j);
else
- metatileLayerType = 1;
+ metatileLayerType = METATILE_LAYER_TYPE_COVERED;
if (metatile < NUM_METATILES_IN_PRIMARY)
{
@@ -764,15 +764,15 @@ static void BuyMenuDrawMapMetatile(s16 x, s16 y, const u16 *src, u8 metatileLaye
switch (metatileLayerType)
{
- case 0:
+ case METATILE_LAYER_TYPE_NORMAL:
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src);
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
break;
- case 1:
+ case METATILE_LAYER_TYPE_COVERED:
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[3], offset1, offset2, src + 4);
break;
- case 2:
+ case METATILE_LAYER_TYPE_SPLIT:
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[2], offset1, offset2, src);
BuyMenuDrawMapMetatileLayer(sShopData->tilemapBuffers[1], offset1, offset2, src + 4);
break;
@@ -866,7 +866,7 @@ static void BuyMenuDrawObjectEvents(void)
static bool8 BuyMenuCheckIfObjectEventOverlapsMenuBg(s16 *object)
{
- if (!BuyMenuCheckForOverlapWithMenuBg(object[X_COORD], object[Y_COORD] + 2) && object[LAYER_TYPE] != MB_SECRET_BASE_WALL)
+ if (!BuyMenuCheckForOverlapWithMenuBg(object[X_COORD], object[Y_COORD] + 2) && object[LAYER_TYPE] != METATILE_LAYER_TYPE_COVERED)
{
return TRUE;
}
diff --git a/src/slot_machine.c b/src/slot_machine.c
index c58de415b..1dfa026e5 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -31,20 +31,60 @@
#define SLOTMACHINE_GFX_TILES 233
#define MAX_BET 3
-#define SYMBOLS_PER_REEL 21
-#define REEL_SYMBOL_HEIGHT 24
-
-// Lucky Flags
-#define LUCKY_BIAS_REPLAY (1 << 0)
-#define LUCKY_BIAS_CHERRY (1 << 1)
-#define LUCKY_BIAS_LOTAD (1 << 2)
-#define LUCKY_BIAS_AZURILL (1 << 3)
-#define LUCKY_BIAS_POWER (1 << 4)
-#define LUCKY_BIAS_REELTIME (1 << 5)
-#define LUCKY_BIAS_MIXED_777 (1 << 6)
-#define LUCKY_BIAS_777 (1 << 7)
+#define SYMBOLS_PER_REEL 21
+#define REEL_SYMBOL_HEIGHT 24
+#define REEL_HEIGHT (SYMBOLS_PER_REEL * REEL_SYMBOL_HEIGHT)
+
+#define REELTIME_SYMBOLS 6
+#define REELTIME_SYMBOL_HEIGHT 20
+#define REELTIME_REEL_HEIGHT (REELTIME_SYMBOLS * REELTIME_SYMBOL_HEIGHT)
+
+// There are three categories of biases: 7's, ReelTime, Regular
+// - 7's: BIAS_STRAIGHT_7, BIAS_MIXED_7
+// - ReelTime: BIAS_REELTIME
+// - Regular: everything else
+//
+// The 7's and ReelTime biases can be grouped together as 'Special' biases.
+//
+// There can be at most two biases at a time. If there are two, one bias will be
+// ReelTime and the other will be one of the Regular biases.
+//
+// A new bias is drawn every round, except during ReelTime. Bias towards 7's
+// persists across rounds until you match 7's. All other biases are reset after
+// the round.
+#define BIAS_REPLAY (1 << 0)
+#define BIAS_CHERRY (1 << 1)
+#define BIAS_LOTAD (1 << 2)
+#define BIAS_AZURILL (1 << 3)
+#define BIAS_POWER (1 << 4)
+#define BIAS_REELTIME (1 << 5)
+#define BIAS_MIXED_7 (1 << 6)
+#define BIAS_STRAIGHT_7 (1 << 7)
+
+#define BIAS_7 (BIAS_STRAIGHT_7 | BIAS_MIXED_7)
+#define BIAS_SPECIAL (BIAS_7 | BIAS_REELTIME)
+#define BIAS_REGULAR (BIAS_REPLAY | BIAS_CHERRY | BIAS_LOATAD | BIAS_AZURILL | BIAS_POWER)
+
+// The slot machine will try to manipulate the outcome by adding up to 4 extra
+// turns to the reel after you press stop.
+//
+// The only exception is when it is stopping the third reel and it has decided
+// you will lose. In this case, it adds as many turns as necessary to prevent a
+// match.
+#define MAX_EXTRA_TURNS 4
enum {
+ SYMBOL_7_RED,
+ SYMBOL_7_BLUE,
+ SYMBOL_AZURILL,
+ SYMBOL_LOTAD,
+ SYMBOL_CHERRY,
+ SYMBOL_POWER,
+ SYMBOL_REPLAY,
+};
+
+enum
+{
GFXTAG_7_RED,
GFXTAG_7_BLUE,
GFXTAG_AZURILL,
@@ -72,6 +112,10 @@ enum {
#define GFXTAG_SYMBOLS_START (GFXTAG_7_RED)
#define GFXTAG_NUMBERS_START (GFXTAG_NUM_0)
+#define REEL_NORMAL_SPEED 8
+#define REEL_HALF_SPEED 4
+#define REEL_QUARTER_SPEED 2
+
enum {
PALTAG_REEL,
PALTAG_REEL_TIME_PIKACHU,
@@ -84,16 +128,16 @@ enum {
};
enum {
- MATCHED_1CHERRY,
- MATCHED_2CHERRY,
- MATCHED_REPLAY,
- MATCHED_LOTAD,
- MATCHED_AZURILL,
- MATCHED_POWER,
- MATCHED_777_MIXED,
- MATCHED_777_RED,
- MATCHED_777_BLUE,
- MATCHED_NONE,
+ MATCH_CHERRY, // Cherry in center of first reel
+ MATCH_TOPBOT_CHERRY, // Cherry in top/bottom of first reel
+ MATCH_REPLAY,
+ MATCH_LOTAD,
+ MATCH_AZURILL,
+ MATCH_POWER,
+ MATCH_MIXED_7, // First two 7's are same color; last is other color
+ MATCH_RED_7,
+ MATCH_BLUE_7,
+ MATCH_NONE,
};
enum {
@@ -113,43 +157,78 @@ enum {
};
enum {
- SLOT_ACTION_UNFADE,
- SLOT_ACTION_WAIT_FADE,
- SLOT_ACTION_READY_NEW_SPIN,
- SLOT_ACTION_READY_NEW_RT_SPIN,
- SLOT_ACTION_ASK_INSERT_BET,
- SLOT_ACTION_BET_INPUT,
- SLOT_ACTION_MSG_NEED_3_COINS,
- SLOT_ACTION_WAIT_MSG_NEED_3_COINS,
- SLOT_ACTION_WAIT_INFO_BOX,
- SLOT_ACTION_START_SPIN,
- SLOT_ACTION_START_RT_SPIN,
- SLOT_ACTION_SET_LUCKY_SPINS,
- SLOT_ACTION_AWAIT_REEL_STOP,
- SLOT_ACTION_AWAIT_ALL_REELS_STOP,
- SLOT_ACTION_CHECK_MATCHES,
- SLOT_ACTION_WAIT_PAYOUT,
- SLOT_ACTION_END_PAYOUT,
- SLOT_ACTION_MATCHED_POWER,
- SLOT_ACTION_WAIT_RT_ANIM,
- SLOT_ACTION_RESET_BET_TILES,
- SLOT_ACTION_NO_MATCHES,
- SLOT_ACTION_ASK_QUIT,
- SLOT_ACTION_HANDLE_QUIT_INPUT,
- SLOT_ACTION_MSG_MAX_COINS,
- SLOT_ACTION_WAIT_MSG_MAX_COINS,
- SLOT_ACTION_MSG_NO_MORE_COINS,
- SLOT_ACTION_WAIT_MSG_NO_MORE_COINS,
- SLOT_ACTION_END,
- SLOT_ACTION_FREE,
+ SLOTTASK_UNFADE,
+ SLOTTASK_WAIT_FADE,
+ SLOTTASK_READY_NEW_SPIN,
+ SLOTTASK_READY_NEW_RT_SPIN,
+ SLOTTASK_ASK_INSERT_BET,
+ SLOTTASK_BET_INPUT,
+ SLOTTASK_MSG_NEED_3_COINS,
+ SLOTTASK_WAIT_MSG_NEED_3_COINS,
+ SLOTTASK_WAIT_INFO_BOX,
+ SLOTTASK_START_SPIN,
+ SLOTTASK_START_RT_SPIN,
+ SLOTTASK_RESET_BIAS_FAILURE,
+ SLOTTASK_WAIT_REEL_STOP,
+ SLOTTASK_WAIT_ALL_REELS_STOP,
+ SLOTTASK_CHECK_MATCHES,
+ SLOTTASK_WAIT_PAYOUT,
+ SLOTTASK_END_PAYOUT,
+ SLOTTASK_MATCHED_POWER,
+ SLOTTASK_WAIT_RT_ANIM,
+ SLOTTASK_RESET_BET_TILES,
+ SLOTTASK_NO_MATCHES,
+ SLOTTASK_ASK_QUIT,
+ SLOTTASK_HANDLE_QUIT_INPUT,
+ SLOTTASK_MSG_MAX_COINS,
+ SLOTTASK_WAIT_MSG_MAX_COINS,
+ SLOTTASK_MSG_NO_MORE_COINS,
+ SLOTTASK_WAIT_MSG_NO_MORE_COINS,
+ SLOTTASK_END,
+ SLOTTASK_FREE,
+};
+enum
+{
+ PAYOUT_TASK_INIT,
+ PAYOUT_TASK_GIVE_PAYOUT,
+ PAYOUT_TASK_FREE,
};
enum {
- REEL_ACTION_STILL,
- REEL_ACTION_SPIN,
- REEL_ACTION_STOP,
- REEL_ACTION_STOP_MOVE,
- REEL_ACTION_STOP_SHAKE,
+ REEL_TASK_STILL,
+ REEL_TASK_SPIN,
+ REEL_TASK_DECIDE_STOP,
+ REEL_TASK_STOP_MOVE,
+ REEL_TASK_STOP_SHAKE,
+};
+
+enum {
+ PIKABOLT_TASK_IDLE,
+ PIKABOLT_TASK_ADD_BOLT,
+ PIKABOLT_TASK_WAIT_ANIM,
+ PIKABOLT_TASK_CLEAR_ALL,
+};
+
+enum {
+ RT_TASK_INIT,
+ RT_TASK_WINDOW_ENTER,
+ RT_TASK_WAIT_START_PIKA,
+ RT_TASK_PIKA_SPEEDUP1,
+ RT_TASK_PIKA_SPEEDUP2,
+ RT_TASK_WAIT_REEL,
+ RT_TASK_CHECK_EXPLODE,
+ RT_TASK_LAND,
+ RT_TASK_PIKA_REACT,
+ RT_TASK_WAIT_CLEAR_POWER,
+ RT_TASK_CLOSE_WINDOW_SUCCESS,
+ RT_TASK_DESTROY_SPRITES,
+ RT_TASK_SET_REEL_SPEED,
+ RT_TASK_END_SUCCESS,
+ RT_TASK_EXPLODE,
+ RT_TASK_WAIT_EXPLODE,
+ RT_TASK_WAIT_SMOKE,
+ RT_TASK_CLOSE_WINDOW_FAILURE,
+ RT_TASK_END_FAILURE,
};
#define DIG_SPRITE_DUMMY {255, 0, 0}
@@ -235,29 +314,74 @@ enum {
DIG_DISPLAY_BONUS_BIG
};
+
+// How ReelTime works
+// ==================
+// Entering ReelTime:
+// - If the bias you draw at the start of the round is BIAS_REELTIME, the
+// ReelTime lottery begins.
+// - At the start of the lottery, the game selects how many ReelTime spins you
+// will get, based on how many Power bolts you've collected and whether it
+// is a lucky game.
+// - The lottery machine rolls until it lands on the selected number. If it
+// selected 0 spins, the lottery machine will mostly likely explode before
+// landing on 0.
+// - If you win:
+// - You receive the selected number of ReelTime spins
+// - You lose all the Power bolts you've collected thus far
+// - The lottery window closes and ReelTime officially begins
+//
+// During ReelTime:
+// - You still have to pay coins for bets.
+// - The slot reels may spin slower than usual in ReelTime. The machine draws a
+// reel speed at the beginning of each ReelTime spin. The more coins you've
+// lost to the machine, and the more consecutive ReelTime spins you've done,
+// the higher your chances of getting a slower reel speed.
+// - In ReelTime, the reel stops exactly on your input. That is, it won't add
+// extra turns to manipulate the outcome.
+// - ReelTime ends early if you win red 7's or blue 7's.
+
+
+// SlotMachine field explanations:
+//
+// luckyGame:
+// Determined at random when you start playing. Some events modify this:
+// - Blue 7 match: game becomes lucky
+// - Red 7 match: game becomes normal
+//
+// Effectively, a lucky game inreases the odds of getting more ReelTime spins.
+// If the game is lucky, you have a slightly higher chance of matching Power
+// bolts (at the expense of Replays). This helps you fill your Power bolt
+// gauge faster.
+//
+// During ReelTime, the more Power bolts you have, the greater your chances
+// of drawing more ReelTime spins. In a lucky game, you have greater odds of
+// drawing high yields (3+ RT spins). You also have greater odds of drawing 0
+// RT spins. But drawing 0 lets you keep all your Power bolts, allowing you to
+// fill your gauge further.
struct SlotMachine
{
/*0x00*/ u8 state;
/*0x01*/ u8 machineId;
- /*0x02*/ u8 pikaPower;
- /*0x03*/ u8 luckyGame;
- /*0x04*/ u8 luckyFlags;
+ /*0x02*/ u8 pikaPowerBolts;
+ /*0x03*/ bool8 luckyGame;
+ /*0x04*/ u8 machineBias;
/*0x05*/ u8 reelTimeDraw;
- /*0x06*/ u8 isLuckySpin;
- /*0x07*/ u8 biasTag;
- /*0x08*/ u16 matchedSymbols;
+ /*0x06*/ bool8 didNotFailBias;
+ /*0x07*/ u8 biasSymbol;
+ /*0x08*/ u16 matches;
/*0x0A*/ u8 reelTimeSpinsLeft;
/*0x0B*/ u8 reelTimeSpinsUsed;
/*0x0C*/ s16 coins;
/*0x0E*/ s16 payout;
- /*0x10*/ s16 netCoinLoss; // coins lost to machine (but never goes below 0)
+ /*0x10*/ s16 netCoinLoss; // never negative
/*0x12*/ s16 bet;
/*0x14*/ s16 reeltimePixelOffset;
/*0x16*/ s16 reeltimePosition;
- /*0x18*/ s16 currReel;
- /*0x1A*/ s16 reelIncrement; // speed of reel
+ /*0x18*/ s16 currentReel;
+ /*0x1A*/ s16 reelSpeed;
/*0x1C*/ s16 reelPixelOffsets[NUM_REELS];
- /*0x22*/ u16 reelPixelOffsetsWhileStopping[NUM_REELS];
+ /*0x22*/ u16 reelShockOffsets[NUM_REELS];
/*0x28*/ s16 reelPositions[NUM_REELS];
/*0x2E*/ s16 reelExtraTurns[NUM_REELS];
/*0x34*/ s16 winnerRows[NUM_REELS];
@@ -299,7 +423,7 @@ static void SlotMachineSetup_InitBgsWindows(void);
static void SlotMachineSetup_InitVRAM(void);
static void SlotMachineSetup_InitOAM(void);
static void SlotMachineSetup_InitGpuRegs(void);
-static void SlotMachineSetup_InitSlotMachineStruct(void);
+static void InitSlotMachine(void);
static void SlotMachineSetup_InitPalsSpritesTasks(void);
static void SlotMachineSetup_InitTilemaps(void);
static void SlotMachineSetup_LoadGfxAndTilemaps(void);
@@ -308,84 +432,84 @@ static void AllocDigitalDisplayGfx(void);
static void SetDigitalDisplayImagePtrs(void);
static void CreateSlotMachineSprites(void);
static void CreateGameplayTasks(void);
-static void CreateSlotMachineTask(void);
+static void CreateSlotMachineTasks(void);
static void DestroyDigitalDisplayScene(void);
static void Task_SlotMachine(u8);
-static bool8 SlotAction_UnfadeScreen(struct Task *);
-static bool8 SlotAction_WaitForUnfade(struct Task *);
-static bool8 SlotAction_ReadyNewSpin(struct Task *);
-static bool8 SlotAction_ReadyNewReelTimeSpin(struct Task *);
-static bool8 SlotAction_AskInsertBet(struct Task *);
-static bool8 SlotAction_HandleBetInput(struct Task *);
-static bool8 SlotAction_PrintMsg_Need3Coins(struct Task *);
-static bool8 SlotAction_WaitMsg_Need3Coins(struct Task *);
-static bool8 SlotAction_WaitForInfoBox(struct Task *);
-static bool8 SlotAction_StartSpin(struct Task *);
-static bool8 SlotAction_StartReelTimeSpin(struct Task *);
-static bool8 SlotAction_SetLuckySpins(struct Task *);
-static bool8 SlotAction_AwaitReelStop(struct Task *);
-static bool8 SlotAction_WaitForAllReelsToStop(struct Task *);
-static bool8 SlotAction_CheckMatches(struct Task *);
-static bool8 SlotAction_WaitForPayoutToBeAwarded(struct Task *);
-static bool8 SlotAction_EndPayout(struct Task *);
-static bool8 SlotAction_MatchedPower(struct Task *);
-static bool8 SlotAction_WaitReelTimeAnim(struct Task *);
-static bool8 SlotAction_ResetBetTiles(struct Task *);
-static bool8 SlotAction_NoMatches(struct Task *);
-static bool8 SlotAction_AskQuit(struct Task *);
-static bool8 SlotAction_HandleQuitInput(struct Task *);
-static bool8 SlotAction_PrintMsg_9999Coins(struct Task *);
-static bool8 SlotAction_WaitMsg_9999Coins(struct Task *);
-static bool8 SlotAction_PrintMsg_NoMoreCoins(struct Task *);
-static bool8 SlotAction_WaitMsg_NoMoreCoins(struct Task *);
-static bool8 SlotAction_EndGame(struct Task *);
-static bool8 SlotAction_FreeDataStructures(struct Task *);
-static void DrawLuckyFlags(void);
-static void SetLuckySpins(void);
-static bool8 IsThisRoundLucky(void);
-static u8 AttemptsAtLuckyFlags_Top3(void);
-static u16 SlowReelSpeed(void);
-static u8 AttemptsAtLuckyFlags_NotTop3(void);
+static bool8 SlotTask_UnfadeScreen(struct Task *);
+static bool8 SlotTask_WaitUnfade(struct Task *);
+static bool8 SlotTask_ReadyNewSpin(struct Task *);
+static bool8 SlotTask_ReadyNewReelTimeSpin(struct Task *);
+static bool8 SlotTask_AskInsertBet(struct Task *);
+static bool8 SlotTask_HandleBetInput(struct Task *);
+static bool8 SlotTask_PrintMsg_Need3Coins(struct Task *);
+static bool8 SlotTask_WaitMsg_Need3Coins(struct Task *);
+static bool8 SlotTask_WaitInfoBox(struct Task *);
+static bool8 SlotTask_StartSpin(struct Task *);
+static bool8 SlotTask_StartReelTimeSpin(struct Task *);
+static bool8 SlotTask_ResetBiasFailure(struct Task *);
+static bool8 SlotTask_WaitReelStop(struct Task *);
+static bool8 SlotTask_WaitAllReelsStop(struct Task *);
+static bool8 SlotTask_CheckMatches(struct Task *);
+static bool8 SlotTask_WaitPayout(struct Task *);
+static bool8 SlotTask_EndPayout(struct Task *);
+static bool8 SlotTask_MatchedPower(struct Task *);
+static bool8 SlotTask_WaitReelTimeAnim(struct Task *);
+static bool8 SlotTask_ResetBetTiles(struct Task *);
+static bool8 SlotTask_NoMatches(struct Task *);
+static bool8 SlotTask_AskQuit(struct Task *);
+static bool8 SlotTask_HandleQuitInput(struct Task *);
+static bool8 SlotTask_PrintMsg_MaxCoins(struct Task *);
+static bool8 SlotTask_WaitMsg_MaxCoins(struct Task *);
+static bool8 SlotTask_PrintMsg_NoMoreCoins(struct Task *);
+static bool8 SlotTask_WaitMsg_NoMoreCoins(struct Task *);
+static bool8 SlotTask_EndGame(struct Task *);
+static bool8 SlotTask_FreeDataStructures(struct Task *);
+static void DrawMachineBias(void);
+static void ResetBiasFailure(void);
+static bool8 ShouldTrySpecialBias(void);
+static u8 TrySelectBias_Special(void);
+static u16 ReelTimeSpeed(void);
+static u8 TrySelectBias_Regular(void);
static void CheckMatch(void);
static void CheckMatch_CenterRow(void);
static void CheckMatch_TopAndBottom(void);
static void CheckMatch_Diagonals(void);
static u8 GetMatchFromSymbols(u8, u8, u8);
static void AwardPayout(void);
-static void RunAwardPayoutActions(u8);
-static bool8 IsFinalTask_RunAwardPayoutActions(void);
-static bool8 AwardPayoutAction0(struct Task *);
-static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *);
-static bool8 AwardPayoutAction_FreeTask(struct Task *);
-static u8 GetTagAtRest(u8, s16);
-static void CreateSlotReelTasks(void);
+static void Task_Payout(u8);
+static bool8 IsFinalTask_Task_Payout(void);
+static bool8 PayoutTask_Init(struct Task *);
+static bool8 PayoutTask_GivePayout(struct Task *);
+static bool8 PayoutTask_Free(struct Task *);
+static u8 GetSymbolAtRest(u8, s16);
+static void CreateReelTasks(void);
static void SpinSlotReel(u8);
static void StopSlotReel(u8);
static bool8 IsSlotReelMoving(u8);
-static void Task_RunSlotReelActions(u8);
-static bool8 SlotReelAction_StayStill(struct Task *);
-static bool8 SlotReelAction_Spin(struct Task *);
-static bool8 SlotReelAction_DecideWhereToStop(struct Task *);
-static bool8 SlotReelAction_MoveToStop(struct Task *);
-static bool8 SlotReelAction_OscillatingStop(struct Task *);
-static bool8 DecideReelTurns_BiasTag_Reel1(void);
-static bool8 DecideReelTurns_BiasTag_Reel1_Bet1(u8, u8);
-static bool8 DecideReelTurns_BiasTag_Reel1_Bet2or3(u8, u8);
-static bool8 DecideReelTurns_BiasTag_Reel2(void);
-static bool8 DecideReelTurns_BiasTag_Reel2_Bet1or2(void);
-static bool8 DecideReelTurns_BiasTag_Reel2_Bet3(void);
-static bool8 DecideReelTurns_BiasTag_Reel3(void);
-static bool8 DecideReelTurns_BiasTag_Reel3_Bet1or2(u8);
-static bool8 DecideReelTurns_BiasTag_Reel3_Bet3(u8);
-static void DecideReelTurns_NoBiasTag_Reel1(void);
-static void DecideReelTurns_NoBiasTag_Reel2(void);
-static void DecideReelTurns_NoBiasTag_Reel2_Bet1(void);
-static void DecideReelTurns_NoBiasTag_Reel2_Bet2(void);
-static void DecideReelTurns_NoBiasTag_Reel2_Bet3(void);
-static void DecideReelTurns_NoBiasTag_Reel3(void);
-static void DecideReelTurns_NoBiasTag_Reel3_Bet1(void);
-static void DecideReelTurns_NoBiasTag_Reel3_Bet2(void);
-static void DecideReelTurns_NoBiasTag_Reel3_Bet3(void);
+static void Task_Reel(u8);
+static bool8 ReelTask_StayStill(struct Task *);
+static bool8 ReelTask_Spin(struct Task *);
+static bool8 ReelTask_DecideStop(struct Task *);
+static bool8 ReelTask_MoveToStop(struct Task *);
+static bool8 ReelTask_ShakingStop(struct Task *);
+static bool8 DecideStop_Bias_Reel1(void);
+static bool8 DecideStop_Bias_Reel1_Bet1(u8, u8);
+static bool8 DecideStop_Bias_Reel1_Bet2or3(u8, u8);
+static bool8 DecideStop_Bias_Reel2(void);
+static bool8 DecideStop_Bias_Reel2_Bet1or2(void);
+static bool8 DecideStop_Bias_Reel2_Bet3(void);
+static bool8 DecideStop_Bias_Reel3(void);
+static bool8 DecideStop_Bias_Reel3_Bet1or2(u8);
+static bool8 DecideStop_Bias_Reel3_Bet3(u8);
+static void DecideStop_NoBias_Reel1(void);
+static void DecideStop_NoBias_Reel2(void);
+static void DecideStop_NoBias_Reel2_Bet1(void);
+static void DecideStop_NoBias_Reel2_Bet2(void);
+static void DecideStop_NoBias_Reel2_Bet3(void);
+static void DecideStop_NoBias_Reel3(void);
+static void DecideStop_NoBias_Reel3_Bet1(void);
+static void DecideStop_NoBias_Reel3_Bet2(void);
+static void DecideStop_NoBias_Reel3_Bet3(void);
static void PressStopReelButton(u8);
static void Task_PressStopReelButton(u8);
static void LightenBetTiles(u8);
@@ -427,7 +551,7 @@ static void ReelTime_PikachuReact(struct Task *);
static void ReelTime_WaitClearPikaPower(struct Task *);
static void ReelTime_CloseWindow(struct Task *);
static void ReelTime_DestroySprites(struct Task *);
-static void ReelTime_SetReelIncrement(struct Task *);
+static void ReelTime_SetReelSpeed(struct Task *);
static void ReelTime_EndSuccess(struct Task *);
static void ReelTime_ExplodeMachine(struct Task *);
static void ReelTime_WaitExplode(struct Task *);
@@ -437,11 +561,11 @@ static void LoadReelTimeWindowTilemap(s16, s16);
static void ClearReelTimeWindowTilemap(s16);
static void OpenInfoBox(u8);
static bool8 IsInfoBoxClosed(void);
-static void RunInfoBoxActions(u8 );
+static void Task_InfoBox(u8 );
static void InfoBox_FadeIn(struct Task *);
-static void InfoBox_WaitForFade(struct Task *);
+static void InfoBox_WaitFade(struct Task *);
static void InfoBox_DrawWindow(struct Task *);
-static void InfoBox_AwaitPlayerInput(struct Task *);
+static void InfoBox_WaitInput(struct Task *);
static void InfoBox_AddText(struct Task *);
static void InfoBox_LoadPikaPowerMeter(struct Task *);
static void InfoBox_LoadSlotMachineTilemap(struct Task *);
@@ -557,10 +681,10 @@ static struct SpriteFrameImage *sImageTables_DigitalDisplay[NUM_DIG_DISPLAY_SPRI
// Const rom data.
static const struct DigitalDisplaySprite *const sDigitalDisplayScenes[];
static const u16 sUnkPalette[];
-static const u8 sLuckyRoundProbabilities[NUM_SLOT_MACHINE_IDS][MAX_BET];
-static const u8 sBiasTags[];
-static const u16 sLuckyFlagSettings_Top3[3];
-static const u16 sLuckyFlagSettings_NotTop3[5];
+static const u8 sSpecialDrawOdds[NUM_SLOT_MACHINE_IDS][MAX_BET];
+static const u8 sBiasSymbols[];
+static const u16 sBiasesSpecial[3];
+static const u16 sBiasesRegular[5];
static const s16 sDigitalDisplay_SpriteCoords[][2];
static const SpriteCallback sDigitalDisplay_SpriteCallbacks[];
static const struct SpriteTemplate *const sSpriteTemplates_DigitalDisplay[NUM_DIG_DISPLAY_SPRITES];
@@ -572,8 +696,8 @@ static const struct SpriteTemplate sSpriteTemplate_ReelTimeExplosion;
static const struct SpriteTemplate sSpriteTemplate_ReelTimePikachuAura;
static const u16 sReelTimeExplodeProbability[];
static const u16 *const sPokeballShiningPalTable[];
-static const u16 sReelIncrementTable[][2];
-static const u16 sReelTimeBonusIncrementTable[];
+static const u16 sReelTimeSpeed_Probabilities[][2];
+static const u16 sQuarterSpeed_ProbabilityBoost[];
static const u16 sSlotMatchFlags[];
static const u16 sSlotPayouts[];
static const u8 *const sReelBackground_Tilemap;
@@ -582,13 +706,13 @@ static const struct SpriteSheet sSlotMachineSpriteSheets[22];
static const struct SpritePalette sSlotMachineSpritePalettes[];
static const u16 *const sDigitalDisplay_Pal;
static const s16 sInitialReelPositions[NUM_REELS][2];
-static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS];
-static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS];
-static const u8 sReeltimeProbabilities_UnluckyGame[][17];
+static const u8 sBiasProbabilities_Special[][NUM_SLOT_MACHINE_IDS];
+static const u8 sBiasProbabilities_Regular[][NUM_SLOT_MACHINE_IDS];
+static const u8 sReelTimeProbabilities_NormalGame[][17];
static const u8 sReelTimeProbabilities_LuckyGame[][17];
-static const u8 sSymToMatch[];
-static const u8 sReelTimeTags[];
-static const u8 sReelSymbolTileTags[NUM_REELS][SYMBOLS_PER_REEL];
+static const u8 sSymbolToMatch[];
+static const u8 sReelTimeSymbols[];
+static const u8 sReelSymbols[NUM_REELS][SYMBOLS_PER_REEL];
static const u16 *const sLitMatchLinePalTable[NUM_MATCH_LINES];
static const u16 *const sDarkMatchLinePalTable[NUM_MATCH_LINES];
static const u8 sMatchLinePalOffsets[NUM_MATCH_LINES];
@@ -684,123 +808,131 @@ static const struct WindowTemplate sWindowTemplate_InfoBox =
static const u8 sColors_ReeltimeHelp[] = {TEXT_COLOR_LIGHT_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY};
-static bool8 (*const sSlotActions[])(struct Task *task) =
-{
- [SLOT_ACTION_UNFADE] = SlotAction_UnfadeScreen,
- [SLOT_ACTION_WAIT_FADE] = SlotAction_WaitForUnfade,
- [SLOT_ACTION_READY_NEW_SPIN] = SlotAction_ReadyNewSpin,
- [SLOT_ACTION_READY_NEW_RT_SPIN] = SlotAction_ReadyNewReelTimeSpin,
- [SLOT_ACTION_ASK_INSERT_BET] = SlotAction_AskInsertBet,
- [SLOT_ACTION_BET_INPUT] = SlotAction_HandleBetInput,
- [SLOT_ACTION_MSG_NEED_3_COINS] = SlotAction_PrintMsg_Need3Coins,
- [SLOT_ACTION_WAIT_MSG_NEED_3_COINS] = SlotAction_WaitMsg_Need3Coins,
- [SLOT_ACTION_WAIT_INFO_BOX] = SlotAction_WaitForInfoBox,
- [SLOT_ACTION_START_SPIN] = SlotAction_StartSpin,
- [SLOT_ACTION_START_RT_SPIN] = SlotAction_StartReelTimeSpin,
- [SLOT_ACTION_SET_LUCKY_SPINS] = SlotAction_SetLuckySpins,
- [SLOT_ACTION_AWAIT_REEL_STOP] = SlotAction_AwaitReelStop,
- [SLOT_ACTION_AWAIT_ALL_REELS_STOP] = SlotAction_WaitForAllReelsToStop,
- [SLOT_ACTION_CHECK_MATCHES] = SlotAction_CheckMatches,
- [SLOT_ACTION_WAIT_PAYOUT] = SlotAction_WaitForPayoutToBeAwarded,
- [SLOT_ACTION_END_PAYOUT] = SlotAction_EndPayout,
- [SLOT_ACTION_MATCHED_POWER] = SlotAction_MatchedPower,
- [SLOT_ACTION_WAIT_RT_ANIM] = SlotAction_WaitReelTimeAnim,
- [SLOT_ACTION_RESET_BET_TILES] = SlotAction_ResetBetTiles,
- [SLOT_ACTION_NO_MATCHES] = SlotAction_NoMatches,
- [SLOT_ACTION_ASK_QUIT] = SlotAction_AskQuit,
- [SLOT_ACTION_HANDLE_QUIT_INPUT] = SlotAction_HandleQuitInput,
- [SLOT_ACTION_MSG_MAX_COINS] = SlotAction_PrintMsg_9999Coins,
- [SLOT_ACTION_WAIT_MSG_MAX_COINS] = SlotAction_WaitMsg_9999Coins,
- [SLOT_ACTION_MSG_NO_MORE_COINS] = SlotAction_PrintMsg_NoMoreCoins,
- [SLOT_ACTION_WAIT_MSG_NO_MORE_COINS] = SlotAction_WaitMsg_NoMoreCoins,
- [SLOT_ACTION_END] = SlotAction_EndGame,
- [SLOT_ACTION_FREE] = SlotAction_FreeDataStructures,
-};
-
-static bool8 (*const sAwardPayoutActions[])(struct Task *task) =
-{
- AwardPayoutAction0,
- AwardPayoutAction_GivePayoutToPlayer,
- AwardPayoutAction_FreeTask
-};
-
-static bool8 (*const sSlotReelActions[])(struct Task *task) =
-{
- [REEL_ACTION_STILL] = SlotReelAction_StayStill,
- [REEL_ACTION_SPIN] = SlotReelAction_Spin,
- [REEL_ACTION_STOP] = SlotReelAction_DecideWhereToStop,
- [REEL_ACTION_STOP_MOVE] = SlotReelAction_MoveToStop,
- [REEL_ACTION_STOP_SHAKE] = SlotReelAction_OscillatingStop
-};
-
-// returns True if a match with the biasTag is possible in that reel
-// also modifies data in sSlotMachine reel arrays to indicate how to get to the matching state
-static bool8 (*const sDecideReelTurns_BiasTag[NUM_REELS])(void) =
-{
- DecideReelTurns_BiasTag_Reel1,
- DecideReelTurns_BiasTag_Reel2,
- DecideReelTurns_BiasTag_Reel3
-};
-
-static void (*const sDecideReelTurns_NoBiasTag[NUM_REELS])(void) =
-{
- DecideReelTurns_NoBiasTag_Reel1,
- DecideReelTurns_NoBiasTag_Reel2,
- DecideReelTurns_NoBiasTag_Reel3
-};
-
+static bool8 (*const sSlotTasks[])(struct Task *task) =
+{
+ [SLOTTASK_UNFADE] = SlotTask_UnfadeScreen,
+ [SLOTTASK_WAIT_FADE] = SlotTask_WaitUnfade,
+ [SLOTTASK_READY_NEW_SPIN] = SlotTask_ReadyNewSpin,
+ [SLOTTASK_READY_NEW_RT_SPIN] = SlotTask_ReadyNewReelTimeSpin,
+ [SLOTTASK_ASK_INSERT_BET] = SlotTask_AskInsertBet,
+ [SLOTTASK_BET_INPUT] = SlotTask_HandleBetInput,
+ [SLOTTASK_MSG_NEED_3_COINS] = SlotTask_PrintMsg_Need3Coins,
+ [SLOTTASK_WAIT_MSG_NEED_3_COINS] = SlotTask_WaitMsg_Need3Coins,
+ [SLOTTASK_WAIT_INFO_BOX] = SlotTask_WaitInfoBox,
+ [SLOTTASK_START_SPIN] = SlotTask_StartSpin,
+ [SLOTTASK_START_RT_SPIN] = SlotTask_StartReelTimeSpin,
+ [SLOTTASK_RESET_BIAS_FAILURE] = SlotTask_ResetBiasFailure,
+ [SLOTTASK_WAIT_REEL_STOP] = SlotTask_WaitReelStop,
+ [SLOTTASK_WAIT_ALL_REELS_STOP] = SlotTask_WaitAllReelsStop,
+ [SLOTTASK_CHECK_MATCHES] = SlotTask_CheckMatches,
+ [SLOTTASK_WAIT_PAYOUT] = SlotTask_WaitPayout,
+ [SLOTTASK_END_PAYOUT] = SlotTask_EndPayout,
+ [SLOTTASK_MATCHED_POWER] = SlotTask_MatchedPower,
+ [SLOTTASK_WAIT_RT_ANIM] = SlotTask_WaitReelTimeAnim,
+ [SLOTTASK_RESET_BET_TILES] = SlotTask_ResetBetTiles,
+ [SLOTTASK_NO_MATCHES] = SlotTask_NoMatches,
+ [SLOTTASK_ASK_QUIT] = SlotTask_AskQuit,
+ [SLOTTASK_HANDLE_QUIT_INPUT] = SlotTask_HandleQuitInput,
+ [SLOTTASK_MSG_MAX_COINS] = SlotTask_PrintMsg_MaxCoins,
+ [SLOTTASK_WAIT_MSG_MAX_COINS] = SlotTask_WaitMsg_MaxCoins,
+ [SLOTTASK_MSG_NO_MORE_COINS] = SlotTask_PrintMsg_NoMoreCoins,
+ [SLOTTASK_WAIT_MSG_NO_MORE_COINS] = SlotTask_WaitMsg_NoMoreCoins,
+ [SLOTTASK_END] = SlotTask_EndGame,
+ [SLOTTASK_FREE] = SlotTask_FreeDataStructures,
+};
+
+static bool8 (*const sPayoutTasks[])(struct Task *task) =
+{
+ [PAYOUT_TASK_INIT] = PayoutTask_Init,
+ [PAYOUT_TASK_GIVE_PAYOUT] = PayoutTask_GivePayout,
+ [PAYOUT_TASK_FREE] = PayoutTask_Free,
+};
+
+static bool8 (*const sReelTasks[])(struct Task *task) =
+{
+ [REEL_TASK_STILL] = ReelTask_StayStill,
+ [REEL_TASK_SPIN] = ReelTask_Spin,
+ [REEL_TASK_DECIDE_STOP] = ReelTask_DecideStop,
+ [REEL_TASK_STOP_MOVE] = ReelTask_MoveToStop,
+ [REEL_TASK_STOP_SHAKE] = ReelTask_ShakingStop,
+};
+
+// Returns true if it is possible to match the bias symbol in the reel.
+//
+// Modifies the winnerRows and reelExtraTurns to indicate how to match the bias
+// symbol.
+static bool8 (*const sDecideStop_Bias[NUM_REELS])(void) =
+{
+ DecideStop_Bias_Reel1,
+ DecideStop_Bias_Reel2,
+ DecideStop_Bias_Reel3,
+};
+
+// The player will always lose (barring a few rare circumstances that were not
+// accounted for in implementation).
+//
+// Modifies the winnerRows and reelExtraTurns to indicate how to make the player
+// lose.
+static void (*const sDecideStop_NoBias[NUM_REELS])(void) =
+{
+ DecideStop_NoBias_Reel1,
+ DecideStop_NoBias_Reel2,
+ DecideStop_NoBias_Reel3,
+};
+
+// The magnitude of the shock depends on how many extra turns are added.
static const u16 sReelStopShocks[] = {2, 4, 4, 4, 8};
-static bool8 (*const sDecideReelTurns_BiasTag_Reel1_Bets[MAX_BET])(u8 tag1, u8 tag2) =
+static bool8 (*const sDecideStop_Bias_Reel1_Bets[MAX_BET])(u8 sym1, u8 sym2) =
{
- DecideReelTurns_BiasTag_Reel1_Bet1,
- DecideReelTurns_BiasTag_Reel1_Bet2or3,
- DecideReelTurns_BiasTag_Reel1_Bet2or3
+ DecideStop_Bias_Reel1_Bet1,
+ DecideStop_Bias_Reel1_Bet2or3,
+ DecideStop_Bias_Reel1_Bet2or3,
};
-static bool8 (*const sDecideReelTurns_BiasTag_Reel2_Bets[MAX_BET])(void) =
+static bool8 (*const sDecideStop_Bias_Reel2_Bets[MAX_BET])(void) =
{
- DecideReelTurns_BiasTag_Reel2_Bet1or2,
- DecideReelTurns_BiasTag_Reel2_Bet1or2,
- DecideReelTurns_BiasTag_Reel2_Bet3
+ DecideStop_Bias_Reel2_Bet1or2,
+ DecideStop_Bias_Reel2_Bet1or2,
+ DecideStop_Bias_Reel2_Bet3,
};
-static bool8 (*const sDecideReelTurns_BiasTag_Reel3_Bets[MAX_BET])(u8 biasTag) =
+static bool8 (*const sDecideStop_Bias_Reel3_Bets[MAX_BET])(u8 biasSymbol) =
{
- DecideReelTurns_BiasTag_Reel3_Bet1or2,
- DecideReelTurns_BiasTag_Reel3_Bet1or2,
- DecideReelTurns_BiasTag_Reel3_Bet3
+ DecideStop_Bias_Reel3_Bet1or2,
+ DecideStop_Bias_Reel3_Bet1or2,
+ DecideStop_Bias_Reel3_Bet3,
};
-static void (*const sDecideReelTurns_NoBiasTag_Reel2_Bets[MAX_BET])(void) =
+static void (*const sDecideStop_NoBias_Reel2_Bets[MAX_BET])(void) =
{
- DecideReelTurns_NoBiasTag_Reel2_Bet1,
- DecideReelTurns_NoBiasTag_Reel2_Bet2,
- DecideReelTurns_NoBiasTag_Reel2_Bet3
+ DecideStop_NoBias_Reel2_Bet1,
+ DecideStop_NoBias_Reel2_Bet2,
+ DecideStop_NoBias_Reel2_Bet3,
};
-static void (*const sDecideReelTurns_NoBiasTag_Reel3_Bets[MAX_BET])(void) =
+static void (*const sDecideStop_NoBias_Reel3_Bets[MAX_BET])(void) =
{
- DecideReelTurns_NoBiasTag_Reel3_Bet1,
- DecideReelTurns_NoBiasTag_Reel3_Bet2,
- DecideReelTurns_NoBiasTag_Reel3_Bet3
+ DecideStop_NoBias_Reel3_Bet1,
+ DecideStop_NoBias_Reel3_Bet2,
+ DecideStop_NoBias_Reel3_Bet3,
};
-static void (*const sReelStopButtonFuncs[])(struct Task *task, u8 taskId) =
+static void (*const sReelStopButtonTasks[])(struct Task *task, u8 taskId) =
{
StopReelButton_Press,
StopReelButton_Wait,
- StopReelButton_Unpress
+ StopReelButton_Unpress,
};
static const s16 sReelButtonOffsets[NUM_REELS] = {5, 10, 15};
-static void (*const sPikaPowerBoltFuncs[])(struct Task *task) =
+static void (*const sPikaPowerBoltTasks[])(struct Task *task) =
{
PikaPowerBolt_Idle,
PikaPowerBolt_AddBolt,
PikaPowerBolt_WaitAnim,
- PikaPowerBolt_ClearAll
+ PikaPowerBolt_ClearAll,
};
static const u16 sPikaPowerTileTable[][2] =
@@ -810,65 +942,61 @@ static const u16 sPikaPowerTileTable[][2] =
{0xaf, 0x7f},
};
-static void (*const sReelTimeActions[])(struct Task *task) =
-{
- ReelTime_Init,
- ReelTime_WindowEnter,
- ReelTime_WaitStartPikachu,
- ReelTime_PikachuSpeedUp1,
- ReelTime_PikachuSpeedUp2,
- ReelTime_WaitReel,
- ReelTime_CheckExplode,
- ReelTime_LandOnOutcome,
- ReelTime_PikachuReact,
- ReelTime_WaitClearPikaPower,
- ReelTime_CloseWindow,
- ReelTime_DestroySprites,
- ReelTime_SetReelIncrement,
- ReelTime_EndSuccess,
- ReelTime_ExplodeMachine,
- ReelTime_WaitExplode,
- ReelTime_WaitSmoke,
- ReelTime_CloseWindow,
- ReelTime_EndFailure
+static void (*const sReelTimeTasks[])(struct Task *task) =
+{
+ [RT_TASK_INIT] = ReelTime_Init,
+ [RT_TASK_WINDOW_ENTER] = ReelTime_WindowEnter,
+ [RT_TASK_WAIT_START_PIKA] = ReelTime_WaitStartPikachu,
+ [RT_TASK_PIKA_SPEEDUP1] = ReelTime_PikachuSpeedUp1,
+ [RT_TASK_PIKA_SPEEDUP2] = ReelTime_PikachuSpeedUp2,
+ [RT_TASK_WAIT_REEL] = ReelTime_WaitReel,
+ [RT_TASK_CHECK_EXPLODE] = ReelTime_CheckExplode,
+ [RT_TASK_LAND] = ReelTime_LandOnOutcome,
+ [RT_TASK_PIKA_REACT] = ReelTime_PikachuReact,
+ [RT_TASK_WAIT_CLEAR_POWER] = ReelTime_WaitClearPikaPower,
+ [RT_TASK_CLOSE_WINDOW_SUCCESS] = ReelTime_CloseWindow,
+ [RT_TASK_DESTROY_SPRITES] = ReelTime_DestroySprites,
+ [RT_TASK_SET_REEL_SPEED] = ReelTime_SetReelSpeed,
+ [RT_TASK_END_SUCCESS] = ReelTime_EndSuccess,
+ [RT_TASK_EXPLODE] = ReelTime_ExplodeMachine,
+ [RT_TASK_WAIT_EXPLODE] = ReelTime_WaitExplode,
+ [RT_TASK_WAIT_SMOKE] = ReelTime_WaitSmoke,
+ [RT_TASK_CLOSE_WINDOW_FAILURE] = ReelTime_CloseWindow,
+ [RT_TASK_END_FAILURE] = ReelTime_EndFailure,
};
static const u8 sReelTimePikachuAnimIds[] = {1, 1, 2, 2};
static const s16 sReelTimeBoltDelays[] = {64, 48, 24, 8};
static const s16 sPikachuAuraFlashDelays[] = {10, 8, 6, 4};
-static void (*const sInfoBoxActions[])(struct Task *task) =
+static void (*const sInfoBoxTasks[])(struct Task *task) =
{
// Go to Info screen
InfoBox_FadeIn,
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
InfoBox_DrawWindow,
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
InfoBox_AddText,
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
// On Info screen
- InfoBox_AwaitPlayerInput,
+ InfoBox_WaitInput,
// Exit Info screen
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
InfoBox_LoadSlotMachineTilemap,
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
InfoBox_CreateDigitalDisplay,
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
InfoBox_LoadPikaPowerMeter,
- InfoBox_WaitForFade,
+ InfoBox_WaitFade,
InfoBox_FreeTask,
};
// Just idles, digital display is handled by CreateDigitalDisplayScene and sprite callbacks
-static void (*const sDigitalDisplayActions[])(struct Task *task) =
+static void (*const sDigitalDisplayTasks[])(struct Task *task) =
{
DigitalDisplay_Idle,
};
-
-
-
-// code
#define tState data[0]
static void Task_FadeToSlotMachine(u8 taskId)
@@ -889,12 +1017,12 @@ static void Task_FadeToSlotMachine(u8 taskId)
}
}
-void PlaySlotMachine(u8 slotMachineIndex, MainCallback exitCallback)
+void PlaySlotMachine(u8 machineId, MainCallback exitCallback)
{
u8 taskId;
sSlotMachine = AllocZeroed(sizeof(*sSlotMachine));
- PlaySlotMachine_Internal(slotMachineIndex, exitCallback);
+ PlaySlotMachine_Internal(machineId, exitCallback);
taskId = CreateTask(Task_FadeToSlotMachine, 0);
gTasks[taskId].tState = 0;
}
@@ -907,7 +1035,7 @@ static void CB2_SlotMachineSetup(void)
{
case 0:
SlotMachineSetup_InitBgsWindows();
- SlotMachineSetup_InitSlotMachineStruct();
+ InitSlotMachine();
gMain.state++;
break;
case 1:
@@ -981,25 +1109,31 @@ static void SlotMachine_VBlankCB(void)
SetGpuReg(REG_OFFSET_WINOUT, sSlotMachine->winOut);
}
-static void PlaySlotMachine_Internal(u8 slotMachineIndex, MainCallback exitCallback)
+#define tMachineId data[0]
+#define tExitCallback data[1]
+
+static void PlaySlotMachine_Internal(u8 machineId, MainCallback exitCallback)
{
struct Task *task = &gTasks[CreateTask(SlotMachineDummyTask, 0xFF)];
- task->data[0] = slotMachineIndex;
- StoreWordInTwoHalfwords(&task->data[1], (intptr_t)exitCallback);
+ task->tMachineId = machineId;
+ StoreWordInTwoHalfwords(&task->tExitCallback, (intptr_t)exitCallback);
}
-
-static void SlotMachineInitDummyTask(void)
+// Extracts and assigns machineId and exit callback from task.
+static void SlotMachine_InitFromTask(void)
{
struct Task *task = &gTasks[FindTaskIdByFunc(SlotMachineDummyTask)];
- sSlotMachine->machineId = task->data[0];
- LoadWordFromTwoHalfwords((u16 *)&task->data[1], (u32 *)&sSlotMachine->prevMainCb);
+ sSlotMachine->machineId = task->tMachineId;
+ LoadWordFromTwoHalfwords((u16 *)&task->tExitCallback, (u32 *)&sSlotMachine->prevMainCb);
}
static void SlotMachineDummyTask(u8 taskId)
{
}
+#undef tMachineId
+#undef tExitCallback
+
static void SlotMachineSetup_InitBgsWindows(void)
{
SetVBlankCallback(NULL);
@@ -1048,25 +1182,25 @@ static void SlotMachineSetup_InitGpuRegs(void)
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(9, 8));
}
-// set up initial state of slot machine
-static void SlotMachineSetup_InitSlotMachineStruct(void)
+// Set up initial state of slot machine
+static void InitSlotMachine(void)
{
u8 i;
- SlotMachineInitDummyTask(); // assigns sSlotMachine->machineId, etc.
- sSlotMachine->state = 0;
- sSlotMachine->pikaPower = 0;
+ SlotMachine_InitFromTask();
+ sSlotMachine->state = SLOTTASK_UNFADE;
+ sSlotMachine->pikaPowerBolts = 0;
sSlotMachine->luckyGame = Random() & 1;
- sSlotMachine->luckyFlags = 0;
- sSlotMachine->matchedSymbols = 0;
+ sSlotMachine->machineBias = 0;
+ sSlotMachine->matches = 0;
sSlotMachine->reelTimeSpinsLeft = 0;
sSlotMachine->reelTimeSpinsUsed = 0;
sSlotMachine->coins = GetCoins();
sSlotMachine->payout = 0;
sSlotMachine->netCoinLoss = 0;
sSlotMachine->bet = 0;
- sSlotMachine->currReel = 0;
- sSlotMachine->reelIncrement = 8;
+ sSlotMachine->currentReel = LEFT_REEL;
+ sSlotMachine->reelSpeed = REEL_NORMAL_SPEED;
sSlotMachine->win0h = DISPLAY_WIDTH;
sSlotMachine->win0v = DISPLAY_HEIGHT;
sSlotMachine->winIn = WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR;
@@ -1075,10 +1209,10 @@ static void SlotMachineSetup_InitSlotMachineStruct(void)
for (i = 0; i < NUM_REELS; i++)
{
- sSlotMachine->reelPixelOffsetsWhileStopping[i] = 0;
+ sSlotMachine->reelShockOffsets[i] = 0;
sSlotMachine->reelPositions[i] = sInitialReelPositions[i][sSlotMachine->luckyGame] % SYMBOLS_PER_REEL;
- sSlotMachine->reelPixelOffsets[i] = SYMBOLS_PER_REEL * REEL_SYMBOL_HEIGHT - sSlotMachine->reelPositions[i] * REEL_SYMBOL_HEIGHT;
- sSlotMachine->reelPixelOffsets[i] %= SYMBOLS_PER_REEL * REEL_SYMBOL_HEIGHT;
+ sSlotMachine->reelPixelOffsets[i] = REEL_HEIGHT - sSlotMachine->reelPositions[i] * REEL_SYMBOL_HEIGHT;
+ sSlotMachine->reelPixelOffsets[i] %= REEL_HEIGHT;
}
AlertTVThatPlayerPlayedSlotMachine(GetCoins());
}
@@ -1129,89 +1263,92 @@ static void CreateSlotMachineSprites(void)
static void CreateGameplayTasks(void)
{
CreatePikaPowerBoltTask();
- CreateSlotReelTasks();
+ CreateReelTasks();
CreateDigitalDisplayTask();
- CreateSlotMachineTask();
+ CreateSlotMachineTasks();
}
-static void CreateSlotMachineTask(void)
+static void CreateSlotMachineTasks(void)
{
Task_SlotMachine(CreateTask(Task_SlotMachine, 0));
}
-// task->data[0] is a timer
static void Task_SlotMachine(u8 taskId)
{
- while (sSlotActions[sSlotMachine->state](&gTasks[taskId]))
+ while (sSlotTasks[sSlotMachine->state](&gTasks[taskId]))
;
}
-// SLOT_ACTION_UNFADE
-static bool8 SlotAction_UnfadeScreen(struct Task *task)
+#define tTimer data[0]
+#define tTimer2 data[1]
+
+// SLOTTASK_UNFADE
+static bool8 SlotTask_UnfadeScreen(struct Task *task)
{
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB(0, 0, 0));
- LoadPikaPowerMeter(sSlotMachine->pikaPower);
- sSlotMachine->state++; // SLOT_ACTION_WAIT_FADE
+ LoadPikaPowerMeter(sSlotMachine->pikaPowerBolts);
+ sSlotMachine->state++; // SLOTTASK_WAIT_FADE
return FALSE;
}
-// SLOT_ACTION_WAIT_FADE
-static bool8 SlotAction_WaitForUnfade(struct Task *task)
+// SLOTTASK_WAIT_FADE
+static bool8 SlotTask_WaitUnfade(struct Task *task)
{
if (!gPaletteFade.active)
sSlotMachine->state++;
return FALSE;
}
-// SLOT_ACTION_READY_NEW_SPIN
-static bool8 SlotAction_ReadyNewSpin(struct Task *task)
+// SLOTTASK_READY_NEW_SPIN
+static bool8 SlotTask_ReadyNewSpin(struct Task *task)
{
sSlotMachine->payout = 0;
sSlotMachine->bet = 0;
- sSlotMachine->currReel = 0;
- sSlotMachine->luckyFlags &= (LUCKY_BIAS_777 | LUCKY_BIAS_MIXED_777);
- sSlotMachine->state = SLOT_ACTION_ASK_INSERT_BET;
+ sSlotMachine->currentReel = LEFT_REEL;
+ sSlotMachine->machineBias &= (BIAS_STRAIGHT_7 | BIAS_MIXED_7);
+ sSlotMachine->state = SLOTTASK_ASK_INSERT_BET;
if (sSlotMachine->coins <= 0)
{
- sSlotMachine->state = SLOT_ACTION_MSG_NO_MORE_COINS;
+ sSlotMachine->state = SLOTTASK_MSG_NO_MORE_COINS;
}
else if (sSlotMachine->reelTimeSpinsLeft)
{
- sSlotMachine->state = SLOT_ACTION_READY_NEW_RT_SPIN;
+ sSlotMachine->state = SLOTTASK_READY_NEW_RT_SPIN;
CreateDigitalDisplayScene(DIG_DISPLAY_REEL_TIME);
}
return TRUE;
}
-// SLOT_ACTION_READY_NEW_RT_SPIN
-static bool8 SlotAction_ReadyNewReelTimeSpin(struct Task *task)
+// SLOTTASK_READY_NEW_RT_SPIN
+static bool8 SlotTask_ReadyNewReelTimeSpin(struct Task *task)
{
if (IsDigitalDisplayAnimFinished())
- sSlotMachine->state = SLOT_ACTION_ASK_INSERT_BET;
+ sSlotMachine->state = SLOTTASK_ASK_INSERT_BET;
return FALSE;
}
-// SLOT_ACTION_ASK_INSERT_BET
-static bool8 SlotAction_AskInsertBet(struct Task *task)
+// SLOTTASK_ASK_INSERT_BET
+static bool8 SlotTask_AskInsertBet(struct Task *task)
{
CreateDigitalDisplayScene(DIG_DISPLAY_INSERT_BET);
- sSlotMachine->state = SLOT_ACTION_BET_INPUT;
+ sSlotMachine->state = SLOTTASK_BET_INPUT;
if (sSlotMachine->coins >= MAX_COINS)
- sSlotMachine->state = SLOT_ACTION_MSG_MAX_COINS;
+ sSlotMachine->state = SLOTTASK_MSG_MAX_COINS;
return TRUE;
}
-// SLOT_ACTION_BET_INPUT
-static bool8 SlotAction_HandleBetInput(struct Task *task)
+// SLOTTASK_BET_INPUT
+static bool8 SlotTask_HandleBetInput(struct Task *task)
{
s16 i;
if (JOY_NEW(SELECT_BUTTON))
{
OpenInfoBox(DIG_DISPLAY_INSERT_BET);
- sSlotMachine->state = SLOT_ACTION_WAIT_INFO_BOX;
+ sSlotMachine->state = SLOTTASK_WAIT_INFO_BOX;
}
- else if (JOY_NEW(R_BUTTON)) // bet the max amount
+ // Try to bet the max amount
+ else if (JOY_NEW(R_BUTTON))
{
if (sSlotMachine->coins - (MAX_BET - sSlotMachine->bet) >= 0)
{
@@ -1219,12 +1356,13 @@ static bool8 SlotAction_HandleBetInput(struct Task *task)
LightenBetTiles(i);
sSlotMachine->coins -= (MAX_BET - sSlotMachine->bet);
sSlotMachine->bet = MAX_BET;
- sSlotMachine->state = SLOT_ACTION_START_SPIN;
+ sSlotMachine->state = SLOTTASK_START_SPIN;
PlaySE(SE_SHOP);
}
- else // you didn't have enough coins to bet the max
+ // Not enough coins
+ else
{
- sSlotMachine->state = SLOT_ACTION_MSG_NEED_3_COINS;
+ sSlotMachine->state = SLOTTASK_MSG_NEED_3_COINS;
}
}
else
@@ -1240,48 +1378,48 @@ static bool8 SlotAction_HandleBetInput(struct Task *task)
// Maxed bet or finished betting
if (sSlotMachine->bet >= MAX_BET || (sSlotMachine->bet != 0 && JOY_NEW(A_BUTTON)))
- sSlotMachine->state = SLOT_ACTION_START_SPIN;
+ sSlotMachine->state = SLOTTASK_START_SPIN;
// Quit prompt
if (JOY_NEW(B_BUTTON))
- sSlotMachine->state = SLOT_ACTION_ASK_QUIT;
+ sSlotMachine->state = SLOTTASK_ASK_QUIT;
}
return FALSE;
}
-// SLOT_ACTION_NEED_3_COINS
-static bool8 SlotAction_PrintMsg_Need3Coins(struct Task *task)
+// SLOTTASK_MSG_NEED_3_COINS
+static bool8 SlotTask_PrintMsg_Need3Coins(struct Task *task)
{
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouDontHaveThreeCoins, 0, 1, 0, 0);
CopyWindowToVram(0, COPYWIN_FULL);
- sSlotMachine->state = SLOT_ACTION_WAIT_MSG_NEED_3_COINS;
+ sSlotMachine->state = SLOTTASK_WAIT_MSG_NEED_3_COINS;
return FALSE;
}
-// SLOT_ACTION_WAIT_MSG_NEED_3_COINS
-static bool8 SlotAction_WaitMsg_Need3Coins(struct Task *task)
+// SLOTTASK_WAIT_MSG_NEED_3_COINS
+static bool8 SlotTask_WaitMsg_Need3Coins(struct Task *task)
{
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
ClearDialogWindowAndFrame(0, TRUE);
- sSlotMachine->state = SLOT_ACTION_BET_INPUT;
+ sSlotMachine->state = SLOTTASK_BET_INPUT;
}
return FALSE;
}
-// SLOT_ACTION_WAIT_INFO_BOX
-static bool8 SlotAction_WaitForInfoBox(struct Task *task)
+// SLOTTASK_WAIT_INFO_BOX
+static bool8 SlotTask_WaitInfoBox(struct Task *task)
{
if (IsInfoBoxClosed())
- sSlotMachine->state = SLOT_ACTION_BET_INPUT;
+ sSlotMachine->state = SLOTTASK_BET_INPUT;
return FALSE;
}
-// SLOT_ACTION_START_SPIN
-static bool8 SlotAction_StartSpin(struct Task *task)
+// SLOTTASK_START_SPIN
+static bool8 SlotTask_StartSpin(struct Task *task)
{
- DrawLuckyFlags();
+ DrawMachineBias();
DestroyDigitalDisplayScene();
SpinSlotReel(LEFT_REEL);
@@ -1290,79 +1428,79 @@ static bool8 SlotAction_StartSpin(struct Task *task)
IncrementDailySlotsUses();
- task->data[0] = 0;
- if (sSlotMachine->luckyFlags & LUCKY_BIAS_REELTIME)
+ task->tTimer = 0;
+ if (sSlotMachine->machineBias & BIAS_REELTIME)
{
BeginReelTime();
- sSlotMachine->state = SLOT_ACTION_START_RT_SPIN;
+ sSlotMachine->state = SLOTTASK_START_RT_SPIN;
}
else
{
CreateDigitalDisplayScene(DIG_DISPLAY_STOP_REEL);
- sSlotMachine->state = SLOT_ACTION_SET_LUCKY_SPINS;
+ sSlotMachine->state = SLOTTASK_RESET_BIAS_FAILURE;
}
- sSlotMachine->reelIncrement = 8;
+ sSlotMachine->reelSpeed = REEL_NORMAL_SPEED;
if (sSlotMachine->reelTimeSpinsLeft)
- sSlotMachine->reelIncrement = SlowReelSpeed();
+ sSlotMachine->reelSpeed = ReelTimeSpeed();
return FALSE;
}
-// SLOT_ACTION_START_RT_SPIN
-static bool8 SlotAction_StartReelTimeSpin(struct Task *task)
+// SLOTTASK_START_RT_SPIN
+static bool8 SlotTask_StartReelTimeSpin(struct Task *task)
{
if (IsReelTimeTaskDone())
{
CreateDigitalDisplayScene(DIG_DISPLAY_STOP_REEL);
- sSlotMachine->luckyFlags &= ~LUCKY_BIAS_REELTIME;
- sSlotMachine->state = SLOT_ACTION_SET_LUCKY_SPINS;
+ sSlotMachine->machineBias &= ~BIAS_REELTIME;
+ sSlotMachine->state = SLOTTASK_RESET_BIAS_FAILURE;
}
return FALSE;
}
-// SLOT_ACTION_SET_LUCKY_SPINS
-static bool8 SlotAction_SetLuckySpins(struct Task *task)
+// SLOTTASK_RESET_BIAS_FAILURE
+static bool8 SlotTask_ResetBiasFailure(struct Task *task)
{
- if (++task->data[0] >= 30)
+ if (++task->tTimer >= 30)
{
- SetLuckySpins();
- sSlotMachine->state = SLOT_ACTION_AWAIT_REEL_STOP;
+ ResetBiasFailure();
+ sSlotMachine->state = SLOTTASK_WAIT_REEL_STOP;
}
return FALSE;
}
-// SLOT_ACTION_AWAIT_REEL_STOP
-static bool8 SlotAction_AwaitReelStop(struct Task *task)
+// SLOTTASK_WAIT_REEL_STOP
+static bool8 SlotTask_WaitReelStop(struct Task *task)
{
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_CONTEST_PLACE);
- StopSlotReel(sSlotMachine->currReel);
- PressStopReelButton(sSlotMachine->currReel);
- sSlotMachine->state = SLOT_ACTION_AWAIT_ALL_REELS_STOP;
+ StopSlotReel(sSlotMachine->currentReel);
+ PressStopReelButton(sSlotMachine->currentReel);
+ sSlotMachine->state = SLOTTASK_WAIT_ALL_REELS_STOP;
}
return FALSE;
}
-// SLOT_ACTION_AWAIT_ALL_REELS_STOP
-static bool8 SlotAction_WaitForAllReelsToStop(struct Task *task)
+// SLOTTASK_WAIT_ALL_REELS_STOP
+static bool8 SlotTask_WaitAllReelsStop(struct Task *task)
{
- if (!IsSlotReelMoving(sSlotMachine->currReel))
+ if (!IsSlotReelMoving(sSlotMachine->currentReel))
{
- sSlotMachine->currReel++;
- sSlotMachine->state = SLOT_ACTION_AWAIT_REEL_STOP;
- if (sSlotMachine->currReel >= NUM_REELS)
+ sSlotMachine->currentReel++;
+ sSlotMachine->state = SLOTTASK_WAIT_REEL_STOP;
+ if (sSlotMachine->currentReel >= NUM_REELS)
{
- sSlotMachine->state = SLOT_ACTION_CHECK_MATCHES;
+ sSlotMachine->state = SLOTTASK_CHECK_MATCHES;
}
return TRUE;
}
return FALSE;
}
-// SLOT_ACTION_CHECK_MATCHES
-static bool8 SlotAction_CheckMatches(struct Task *task)
+// SLOTTASK_CHECK_MATCHES
+static bool8 SlotTask_CheckMatches(struct Task *task)
{
- sSlotMachine->luckyFlags &= (LUCKY_BIAS_777 | LUCKY_BIAS_MIXED_777);
+ sSlotMachine->machineBias &= (BIAS_STRAIGHT_7 | BIAS_MIXED_7);
CheckMatch();
if (sSlotMachine->reelTimeSpinsLeft)
{
@@ -1370,21 +1508,21 @@ static bool8 SlotAction_CheckMatches(struct Task *task)
sSlotMachine->reelTimeSpinsUsed++;
}
- if (sSlotMachine->matchedSymbols)
+ if (sSlotMachine->matches)
{
- sSlotMachine->state = SLOT_ACTION_WAIT_PAYOUT;
+ sSlotMachine->state = SLOTTASK_WAIT_PAYOUT;
AwardPayout();
FlashSlotMachineLights();
if ((sSlotMachine->netCoinLoss -= sSlotMachine->payout) < 0)
{
sSlotMachine->netCoinLoss = 0;
}
- if (sSlotMachine->matchedSymbols & ((1 << MATCHED_777_BLUE) | (1 << MATCHED_777_RED)))
+ if (sSlotMachine->matches & ((1 << MATCH_BLUE_7) | (1 << MATCH_RED_7)))
{
PlayFanfare(MUS_SLOTS_JACKPOT);
CreateDigitalDisplayScene(DIG_DISPLAY_BONUS_BIG);
}
- else if (sSlotMachine->matchedSymbols & (1 << MATCHED_777_MIXED))
+ else if (sSlotMachine->matches & (1 << MATCH_MIXED_7))
{
PlayFanfare(MUS_SLOTS_JACKPOT);
CreateDigitalDisplayScene(DIG_DISPLAY_BONUS_REG);
@@ -1394,212 +1532,212 @@ static bool8 SlotAction_CheckMatches(struct Task *task)
PlayFanfare(MUS_SLOTS_WIN);
CreateDigitalDisplayScene(DIG_DISPLAY_WIN);
}
- // if you matched 777...
- if (sSlotMachine->matchedSymbols & ((1 << MATCHED_777_MIXED) | (1 << MATCHED_777_BLUE) | (1 << MATCHED_777_RED)))
+
+ if (sSlotMachine->matches & ((1 << MATCH_MIXED_7) | (1 << MATCH_BLUE_7) | (1 << MATCH_RED_7)))
{
- sSlotMachine->luckyFlags &= ~(LUCKY_BIAS_777 | LUCKY_BIAS_MIXED_777);
- if (sSlotMachine->matchedSymbols & ((1 << MATCHED_777_BLUE) | (1 << MATCHED_777_RED)))
+ sSlotMachine->machineBias &= ~(BIAS_STRAIGHT_7 | BIAS_MIXED_7);
+ if (sSlotMachine->matches & ((1 << MATCH_BLUE_7) | (1 << MATCH_RED_7)))
{
+ // ReelTime ends if it was ongoing
sSlotMachine->reelTimeSpinsLeft = 0;
sSlotMachine->reelTimeSpinsUsed = 0;
sSlotMachine->luckyGame = FALSE;
- if (sSlotMachine->matchedSymbols & (1 << MATCHED_777_BLUE))
- // this may be an error, but if you get blue 777, the game becomes lucky
+ if (sSlotMachine->matches & (1 << MATCH_BLUE_7))
sSlotMachine->luckyGame = TRUE;
}
}
- if (sSlotMachine->matchedSymbols & (1 << MATCHED_POWER) && sSlotMachine->pikaPower < 16)
+ if (sSlotMachine->matches & (1 << MATCH_POWER) && sSlotMachine->pikaPowerBolts < 16)
{
- sSlotMachine->pikaPower++;
- AddPikaPowerBolt(sSlotMachine->pikaPower);
+ sSlotMachine->pikaPowerBolts++;
+ AddPikaPowerBolt(sSlotMachine->pikaPowerBolts);
}
}
else
{
CreateDigitalDisplayScene(DIG_DISPLAY_LOSE);
- sSlotMachine->state = SLOT_ACTION_NO_MATCHES;
+ sSlotMachine->state = SLOTTASK_NO_MATCHES;
if ((sSlotMachine->netCoinLoss += sSlotMachine->bet) > MAX_COINS)
sSlotMachine->netCoinLoss = MAX_COINS;
}
return FALSE;
}
-// SLOT_ACTION_WAIT_PAYOUT
-static bool8 SlotAction_WaitForPayoutToBeAwarded(struct Task *task)
+// SLOTTASK_WAIT_PAYOUT
+static bool8 SlotTask_WaitPayout(struct Task *task)
{
- if (IsFinalTask_RunAwardPayoutActions())
- sSlotMachine->state = SLOT_ACTION_END_PAYOUT;
+ if (IsFinalTask_Task_Payout())
+ sSlotMachine->state = SLOTTASK_END_PAYOUT;
return FALSE;
}
-// SLOT_ACTION_END_PAYOUT
-static bool8 SlotAction_EndPayout(struct Task *task)
+// SLOTTASK_END_PAYOUT
+static bool8 SlotTask_EndPayout(struct Task *task)
{
if (TryStopSlotMachineLights())
{
- sSlotMachine->state = SLOT_ACTION_RESET_BET_TILES;
+ sSlotMachine->state = SLOTTASK_RESET_BET_TILES;
- if (sSlotMachine->matchedSymbols & ((1 << MATCHED_777_RED) | (1 << MATCHED_777_BLUE)))
+ if (sSlotMachine->matches & ((1 << MATCH_RED_7) | (1 << MATCH_BLUE_7)))
IncrementGameStat(GAME_STAT_SLOT_JACKPOTS);
- if (sSlotMachine->matchedSymbols & (1 << MATCHED_REPLAY))
+ if (sSlotMachine->matches & (1 << MATCH_REPLAY))
{
- sSlotMachine->currReel = 0;
- sSlotMachine->state = SLOT_ACTION_START_SPIN;
+ sSlotMachine->currentReel = LEFT_REEL;
+ sSlotMachine->state = SLOTTASK_START_SPIN;
}
- if (sSlotMachine->matchedSymbols & (1 << MATCHED_POWER))
- sSlotMachine->state = SLOT_ACTION_MATCHED_POWER;
+ if (sSlotMachine->matches & (1 << MATCH_POWER))
+ sSlotMachine->state = SLOTTASK_MATCHED_POWER;
- if (sSlotMachine->reelTimeSpinsLeft && sSlotMachine->matchedSymbols & (1 << MATCHED_REPLAY))
+ if (sSlotMachine->reelTimeSpinsLeft && sSlotMachine->matches & (1 << MATCH_REPLAY))
{
CreateDigitalDisplayScene(DIG_DISPLAY_REEL_TIME);
- sSlotMachine->state = SLOT_ACTION_WAIT_RT_ANIM;
+ sSlotMachine->state = SLOTTASK_WAIT_RT_ANIM;
}
}
return FALSE;
}
-// SLOT_ACTION_MATCHED_POWER
-static bool8 SlotAction_MatchedPower(struct Task *task)
+// SLOTTASK_MATCHED_POWER
+static bool8 SlotTask_MatchedPower(struct Task *task)
{
if (!IsPikaPowerBoltAnimating())
{
- sSlotMachine->state = SLOT_ACTION_RESET_BET_TILES;
- if (sSlotMachine->matchedSymbols & (1 << MATCHED_REPLAY))
+ sSlotMachine->state = SLOTTASK_RESET_BET_TILES;
+ if (sSlotMachine->matches & (1 << MATCH_REPLAY))
{
- sSlotMachine->state = SLOT_ACTION_START_SPIN;
+ sSlotMachine->state = SLOTTASK_START_SPIN;
if (sSlotMachine->reelTimeSpinsLeft)
{
CreateDigitalDisplayScene(DIG_DISPLAY_REEL_TIME);
- sSlotMachine->state = SLOT_ACTION_WAIT_RT_ANIM;
+ sSlotMachine->state = SLOTTASK_WAIT_RT_ANIM;
}
}
}
return FALSE;
}
-// SLOT_ACTION_WAIT_RT_ANIM
-static bool8 SlotAction_WaitReelTimeAnim(struct Task *task)
+// SLOTTASK_WAIT_RT_ANIM
+static bool8 SlotTask_WaitReelTimeAnim(struct Task *task)
{
if (IsDigitalDisplayAnimFinished())
{
- sSlotMachine->state = SLOT_ACTION_RESET_BET_TILES;
- if (sSlotMachine->matchedSymbols & (1 << MATCHED_REPLAY))
+ sSlotMachine->state = SLOTTASK_RESET_BET_TILES;
+ if (sSlotMachine->matches & (1 << MATCH_REPLAY))
{
- sSlotMachine->state = SLOT_ACTION_START_SPIN;
+ sSlotMachine->state = SLOTTASK_START_SPIN;
}
}
return FALSE;
}
-// SLOT_ACTION_RESET_BET_TILES
-static bool8 SlotAction_ResetBetTiles(struct Task *task)
+// SLOTTASK_RESET_BET_TILES
+static bool8 SlotTask_ResetBetTiles(struct Task *task)
{
DarkenBetTiles(0);
DarkenBetTiles(1);
DarkenBetTiles(2);
- sSlotMachine->state = SLOT_ACTION_READY_NEW_SPIN;
+ sSlotMachine->state = SLOTTASK_READY_NEW_SPIN;
return FALSE;
}
-// SLOT_ACTION_NO_MATCHES
-static bool8 SlotAction_NoMatches(struct Task *task)
+// SLOTTASK_NO_MATCHES
+static bool8 SlotTask_NoMatches(struct Task *task)
{
- if (++task->data[1] > 64)
+ if (++task->tTimer2 > 64)
{
- task->data[1] = 0;
- sSlotMachine->state = SLOT_ACTION_RESET_BET_TILES;
+ task->tTimer2 = 0;
+ sSlotMachine->state = SLOTTASK_RESET_BET_TILES;
}
return FALSE;
}
-// SLOT_ACTION_ASK_QUIT
-static bool8 SlotAction_AskQuit(struct Task *task)
+// SLOTTASK_ASK_QUIT
+static bool8 SlotTask_AskQuit(struct Task *task)
{
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_QuitTheGame, 0, 1, 0, 0);
CopyWindowToVram(0, COPYWIN_FULL);
CreateYesNoMenuParameterized(0x15, 7, 0x214, 0x180, 0xE, 0xF);
- sSlotMachine->state = SLOT_ACTION_HANDLE_QUIT_INPUT;
+ sSlotMachine->state = SLOTTASK_HANDLE_QUIT_INPUT;
return FALSE;
}
-// SLOT_ACTION_HANDLE_QUIT_INPUT
-static bool8 SlotAction_HandleQuitInput(struct Task *task)
+// SLOTTASK_HANDLE_QUIT_INPUT
+static bool8 SlotTask_HandleQuitInput(struct Task *task)
{
s8 input = Menu_ProcessInputNoWrapClearOnChoose();
- if (input == 0) // player chooses to quit
+ if (input == 0) // Chose to quit
{
ClearDialogWindowAndFrame(0, TRUE);
DarkenBetTiles(0);
DarkenBetTiles(1);
DarkenBetTiles(2);
sSlotMachine->coins += sSlotMachine->bet;
- sSlotMachine->state = SLOT_ACTION_END;
+ sSlotMachine->state = SLOTTASK_END;
}
- else if (input == 1 || input == -1) // player chooses not to quit
+ else if (input == 1 || input == -1) // Chose not to quit
{
ClearDialogWindowAndFrame(0, TRUE);
- sSlotMachine->state = SLOT_ACTION_BET_INPUT;
+ sSlotMachine->state = SLOTTASK_BET_INPUT;
}
return FALSE;
}
-// SLOT_ACTION_MSG_MAX_COINS
-static bool8 SlotAction_PrintMsg_9999Coins(struct Task *task)
+// SLOTTASK_MSG_MAX_COINS
+static bool8 SlotTask_PrintMsg_MaxCoins(struct Task *task)
{
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveGot9999Coins, 0, 1, 0, 0);
CopyWindowToVram(0, COPYWIN_FULL);
- sSlotMachine->state = SLOT_ACTION_WAIT_MSG_MAX_COINS;
+ sSlotMachine->state = SLOTTASK_WAIT_MSG_MAX_COINS;
return FALSE;
}
-// SLOT_ACTION_WAIT_MSG_MAX_COINS
-static bool8 SlotAction_WaitMsg_9999Coins(struct Task *task)
+// SLOTTASK_WAIT_MSG_MAX_COINS
+static bool8 SlotTask_WaitMsg_MaxCoins(struct Task *task)
{
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
ClearDialogWindowAndFrame(0, TRUE);
- sSlotMachine->state = SLOT_ACTION_BET_INPUT;
+ sSlotMachine->state = SLOTTASK_BET_INPUT;
}
return FALSE;
}
-// SLOT_ACTION_MSG_NO_MORE_COINS
-static bool8 SlotAction_PrintMsg_NoMoreCoins(struct Task *task)
+// SLOTTASK_MSG_NO_MORE_COINS
+static bool8 SlotTask_PrintMsg_NoMoreCoins(struct Task *task)
{
DrawDialogueFrame(0, 0);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveRunOutOfCoins, 0, 1, 0, 0);
CopyWindowToVram(0, COPYWIN_FULL);
- sSlotMachine->state = SLOT_ACTION_WAIT_MSG_NO_MORE_COINS;
+ sSlotMachine->state = SLOTTASK_WAIT_MSG_NO_MORE_COINS;
return FALSE;
}
-// SLOT_ACTION_WAIT_MSG_NO_MORE_COINS
-static bool8 SlotAction_WaitMsg_NoMoreCoins(struct Task *task)
+// SLOTTASK_WAIT_MSG_NO_MORE_COINS
+static bool8 SlotTask_WaitMsg_NoMoreCoins(struct Task *task)
{
if (JOY_NEW(A_BUTTON | B_BUTTON))
{
ClearDialogWindowAndFrame(0, TRUE);
- sSlotMachine->state = SLOT_ACTION_END;
+ sSlotMachine->state = SLOTTASK_END;
}
return FALSE;
}
-// SLOT_ACTION_END
-static bool8 SlotAction_EndGame(struct Task *task)
+// SLOTTASK_END
+static bool8 SlotTask_EndGame(struct Task *task)
{
SetCoins(sSlotMachine->coins);
TryPutFindThatGamerOnAir(GetCoins());
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0));
- sSlotMachine->state++; // SLOT_ACTION_FREE
+ sSlotMachine->state++; // SLOTTASK_FREE
return FALSE;
}
-// SLOT_ACTION_FREE
-static bool8 SlotAction_FreeDataStructures(struct Task *task)
+// SLOTTASK_FREE
+static bool8 SlotTask_FreeDataStructures(struct Task *task)
{
if (!gPaletteFade.active)
{
@@ -1640,93 +1778,122 @@ static bool8 SlotAction_FreeDataStructures(struct Task *task)
return FALSE;
}
-static void DrawLuckyFlags(void)
+# undef tTimer
+# undef tTimer2
+
+// Determine the biases for this round. There can be at most two biases, one of
+// which would need to be a ReelTime bias.
+//
+// HOW IT WORKS:
+// If the machine is already biased toward 7's, keep this bias.
+//
+// Otherwise, there are up to three draws. You first draw to see if you'll get
+// to draw a Special bias. If so, then you draw for the Special bias (and can
+// still potentially miss).
+//
+// If you didn't get to draw a Special bias, missed a Special bias, or drew a
+// ReelTime bias, then you can still try to draw a Regular bias.
+static void DrawMachineBias(void)
{
- u8 attempts;
+ u8 whichBias;
if (sSlotMachine->reelTimeSpinsLeft == 0)
{
- if (!(sSlotMachine->luckyFlags & (LUCKY_BIAS_777 | LUCKY_BIAS_MIXED_777)))
+ if (!(sSlotMachine->machineBias & (BIAS_STRAIGHT_7 | BIAS_MIXED_7)))
{
- if (IsThisRoundLucky())
+ if (ShouldTrySpecialBias())
{
- attempts = AttemptsAtLuckyFlags_Top3();
- if (attempts != ARRAY_COUNT(sLuckyFlagSettings_Top3)) // if you found a lucky number
+ whichBias = TrySelectBias_Special();
+ if (whichBias != ARRAY_COUNT(sBiasesSpecial)) // A bias was selected
{
- // attempts == 1: reelTime flag set
- sSlotMachine->luckyFlags |= sLuckyFlagSettings_Top3[attempts];
- if (attempts != 1)
- return;
+ sSlotMachine->machineBias |= sBiasesSpecial[whichBias];
+
+ // ReelTime was not selected; don't add other biases
+ if (whichBias != 1) return;
}
}
- // if it's not a lucky round or you got reel time, roll for the lower lucky flags
- attempts = AttemptsAtLuckyFlags_NotTop3();
- if (attempts != ARRAY_COUNT(sLuckyFlagSettings_NotTop3)) // if you found a lucky number
- sSlotMachine->luckyFlags |= sLuckyFlagSettings_NotTop3[attempts];
+
+ whichBias = TrySelectBias_Regular();
+ if (whichBias != ARRAY_COUNT(sBiasesRegular)) // A bias was selected
+ sSlotMachine->machineBias |= sBiasesRegular[whichBias];
}
}
}
-static void SetLuckySpins(void)
+// Reset `didNotFailBias` to match `machineBias`.
+static void ResetBiasFailure(void)
{
- sSlotMachine->isLuckySpin = FALSE;
- if (sSlotMachine->luckyFlags)
- sSlotMachine->isLuckySpin = TRUE;
+ sSlotMachine->didNotFailBias = FALSE;
+ if (sSlotMachine->machineBias)
+ sSlotMachine->didNotFailBias = TRUE;
}
-static u8 GetBiasTag(u8 luckyFlags)
+// See sBiasSymbols for each bias's corresponding symbol.
+static u8 GetBiasSymbol(u8 machineBias)
{
u8 i;
for (i = 0; i < 8; i++)
{
- if (luckyFlags & 1)
- return sBiasTags[i];
- luckyFlags >>= 1;
+ if (machineBias & 1)
+ return sBiasSymbols[i];
+ machineBias >>= 1;
}
return 0;
}
-// you have way more luck betting 3 coins than anything lower
-static bool8 IsThisRoundLucky(void)
+// Decides whether you will be given the opportunity to draw for a Special bias.
+// Depends on your bet and the machine you're using.
+//
+// The probability of getting to draw a Special is miniscule if you don't bet 3
+// coins: barely 1% even on the luckiest machine.
+//
+// The odds increase to roughly ~5% if you bet 3 coins.
+static bool8 ShouldTrySpecialBias(void)
{
u8 rval = Random();
- if (sLuckyRoundProbabilities[sSlotMachine->machineId][sSlotMachine->bet - 1] > rval)
+ if (sSpecialDrawOdds[sSlotMachine->machineId][sSlotMachine->bet - 1] > rval)
return TRUE;
return FALSE;
}
-static u8 AttemptsAtLuckyFlags_Top3(void)
+// Draws for a Special bias. Note that even when you're given the opportunity to
+// draw a Special bias, you can still miss.
+//
+// On the luckiest machine, there's a 61% chance of drawing no Special bias. On
+// the unluckiest, a 73% chance.
+static u8 TrySelectBias_Special(void)
{
- s16 count;
+ s16 whichBias;
- for (count = 0; count < (int)ARRAY_COUNT(sLuckyFlagSettings_Top3); count++)
+ for (whichBias = 0; whichBias < (int)ARRAY_COUNT(sBiasesSpecial); whichBias++)
{
s16 rval = Random() & 0xff;
- s16 value = sLuckyFlagProbabilities_Top3[count][sSlotMachine->machineId];
+ s16 value = sBiasProbabilities_Special[whichBias][sSlotMachine->machineId];
if (value > rval)
break;
}
- return count;
+ return whichBias;
}
-static u8 AttemptsAtLuckyFlags_NotTop3(void)
+static u8 TrySelectBias_Regular(void)
{
- s16 count;
+ s16 whichBias;
- for (count = 0; count < (int)ARRAY_COUNT(sLuckyFlagSettings_NotTop3); count++)
+ for (whichBias = 0; whichBias < (int)ARRAY_COUNT(sBiasesRegular); whichBias++)
{
- s16 rval = Random() & 0xff; // random byte
- s16 value = sLuckyFlagProbabilities_NotTop3[count][sSlotMachine->machineId];
- // make first attempt easier if it's a lucky game
- if (count == 0 && sSlotMachine->luckyGame == TRUE)
+ s16 rval = Random() & 0xff;
+ s16 value = sBiasProbabilities_Regular[whichBias][sSlotMachine->machineId];
+
+ // Boost odds of BIAS_POWER if it's a lucky game.
+ if (whichBias == 0 && sSlotMachine->luckyGame == TRUE)
{
value += 10;
if (value > 0x100)
value = 0x100;
}
- // make last attempt harder if it's a lucky game
- else if (count == 4 && sSlotMachine->luckyGame == TRUE)
+ // Reduce odds of BIAS_REPLAY if it's a lucky game
+ else if (whichBias == 4 && sSlotMachine->luckyGame == TRUE)
{
value -= 10;
if (value < 0)
@@ -1735,45 +1902,60 @@ static u8 AttemptsAtLuckyFlags_NotTop3(void)
if (value > rval)
break;
}
- return count;
+ return whichBias;
}
-static u8 GetReelTimeProbability(u8 reelTimeDraw)
+// Return the probability of drawing the given number of ReelTime spins.
+//
+// This depends on whether it is a lucky game and the number of Power bolts you
+// have collected.
+static u8 GetReelTimeSpinProbability(u8 spins)
{
if (sSlotMachine->luckyGame == FALSE)
- return sReeltimeProbabilities_UnluckyGame[reelTimeDraw][sSlotMachine->pikaPower];
+ return sReelTimeProbabilities_NormalGame[spins][sSlotMachine->pikaPowerBolts];
else
- return sReelTimeProbabilities_LuckyGame[reelTimeDraw][sSlotMachine->pikaPower];
+ return sReelTimeProbabilities_LuckyGame[spins][sSlotMachine->pikaPowerBolts];
}
-static void GetReeltimeDraw(void)
+// The way this is computed skews the odds much more toward drawing a 0 than
+// intended. It initially checks whether you draw a 0 (using the intended
+// probability). It then tries to draw positive values, but if these draws all
+// miss, you'll still draw a 0.
+//
+// As a result, even when the power gauge is maxed out, you still have a ~30%
+// chance of drawing 0 spins. See sReelTimeProbabilities for more details.
+//
+// Drawing a random number via a cumulative pdf would have prevented this.
+static void GetReelTimeDraw(void)
{
u8 rval;
- s16 reelTimeDraw;
+ s16 spins;
sSlotMachine->reelTimeDraw = 0;
rval = Random();
- if (rval < GetReelTimeProbability(0))
+ if (rval < GetReelTimeSpinProbability(0))
return;
- for (reelTimeDraw = 5; reelTimeDraw > 0; reelTimeDraw--)
+ for (spins = 5; spins > 0; spins--)
{
rval = Random();
- if (rval < GetReelTimeProbability(reelTimeDraw))
+ if (rval < GetReelTimeSpinProbability(spins))
break;
}
- sSlotMachine->reelTimeDraw = reelTimeDraw;
+ sSlotMachine->reelTimeDraw = spins;
}
-static bool8 ShouldReelTimeMachineExplode(u16 i)
+// Returns true if the ReelTime machine should explode. Each time we check,
+// the odds of explosion increase.
+static bool8 ShouldReelTimeMachineExplode(u16 check)
{
u16 rval = Random() & 0xff;
- if (rval < sReelTimeExplodeProbability[i])
+ if (rval < sReelTimeExplodeProbability[check])
return TRUE;
else
return FALSE;
}
-static u16 SlowReelSpeed(void)
+static u16 ReelTimeSpeed(void)
{
u8 i = 0;
u8 rval;
@@ -1786,20 +1968,23 @@ static u16 SlowReelSpeed(void)
i = 2;
else if (sSlotMachine->netCoinLoss >= 150)
i = 1;
+
rval = Random() % 100;
- value = sReelIncrementTable[i][0];
+ value = sReelTimeSpeed_Probabilities[i][0];
if (rval < value)
- return 4;
+ return REEL_HALF_SPEED;
+
rval = Random() % 100;
- value = sReelIncrementTable[i][1] + sReelTimeBonusIncrementTable[sSlotMachine->reelTimeSpinsUsed];
+ value = sReelTimeSpeed_Probabilities[i][1] + sQuarterSpeed_ProbabilityBoost[sSlotMachine->reelTimeSpinsUsed];
if (rval < value)
- return 2;
- return 8;
+ return REEL_QUARTER_SPEED;
+
+ return REEL_NORMAL_SPEED;
}
static void CheckMatch(void)
{
- sSlotMachine->matchedSymbols = 0;
+ sSlotMachine->matches = 0;
CheckMatch_CenterRow();
if (sSlotMachine->bet > 1)
CheckMatch_TopAndBottom();
@@ -1809,140 +1994,146 @@ static void CheckMatch(void)
static void CheckMatch_CenterRow(void)
{
- u8 c1, c2, c3, match;
+ u8 sym1, sym2, sym3, match;
- c1 = GetTagAtRest(LEFT_REEL, 2);
- c2 = GetTagAtRest(MIDDLE_REEL, 2);
- c3 = GetTagAtRest(RIGHT_REEL, 2);
- match = GetMatchFromSymbols(c1, c2, c3);
- if (match != MATCHED_NONE)
+ sym1 = GetSymbolAtRest(LEFT_REEL, 2);
+ sym2 = GetSymbolAtRest(MIDDLE_REEL, 2);
+ sym3 = GetSymbolAtRest(RIGHT_REEL, 2);
+ match = GetMatchFromSymbols(sym1, sym2, sym3);
+ if (match != MATCH_NONE)
{
sSlotMachine->payout += sSlotPayouts[match];
- sSlotMachine->matchedSymbols |= sSlotMatchFlags[match];
+ sSlotMachine->matches |= sSlotMatchFlags[match];
FlashMatchLine(MATCH_MIDDLE_ROW);
}
}
static void CheckMatch_TopAndBottom(void)
{
- u8 c1, c2, c3, match;
+ u8 sym1, sym2, sym3, match;
- c1 = GetTagAtRest(LEFT_REEL, 1);
- c2 = GetTagAtRest(MIDDLE_REEL, 1);
- c3 = GetTagAtRest(RIGHT_REEL, 1);
- match = GetMatchFromSymbols(c1, c2, c3);
- if (match != MATCHED_NONE)
+ sym1 = GetSymbolAtRest(LEFT_REEL, 1);
+ sym2 = GetSymbolAtRest(MIDDLE_REEL, 1);
+ sym3 = GetSymbolAtRest(RIGHT_REEL, 1);
+ match = GetMatchFromSymbols(sym1, sym2, sym3);
+ if (match != MATCH_NONE)
{
- if (match == MATCHED_1CHERRY)
- match = MATCHED_2CHERRY;
+ if (match == MATCH_CHERRY)
+ match = MATCH_TOPBOT_CHERRY;
sSlotMachine->payout += sSlotPayouts[match];
- sSlotMachine->matchedSymbols |= sSlotMatchFlags[match];
+ sSlotMachine->matches |= sSlotMatchFlags[match];
FlashMatchLine(MATCH_TOP_ROW);
}
- c1 = GetTagAtRest(LEFT_REEL, 3);
- c2 = GetTagAtRest(MIDDLE_REEL, 3);
- c3 = GetTagAtRest(RIGHT_REEL, 3);
- match = GetMatchFromSymbols(c1, c2, c3);
- if (match != MATCHED_NONE)
+ sym1 = GetSymbolAtRest(LEFT_REEL, 3);
+ sym2 = GetSymbolAtRest(MIDDLE_REEL, 3);
+ sym3 = GetSymbolAtRest(RIGHT_REEL, 3);
+ match = GetMatchFromSymbols(sym1, sym2, sym3);
+ if (match != MATCH_NONE)
{
- if (match == MATCHED_1CHERRY)
- match = MATCHED_2CHERRY;
+ if (match == MATCH_CHERRY)
+ match = MATCH_TOPBOT_CHERRY;
sSlotMachine->payout += sSlotPayouts[match];
- sSlotMachine->matchedSymbols |= sSlotMatchFlags[match];
+ sSlotMachine->matches |= sSlotMatchFlags[match];
FlashMatchLine(MATCH_BOTTOM_ROW);
}
}
static void CheckMatch_Diagonals(void)
{
- u8 c1, c2, c3, match;
+ u8 sym1, sym2, sym3, match;
- c1 = GetTagAtRest(LEFT_REEL, 1);
- c2 = GetTagAtRest(MIDDLE_REEL, 2);
- c3 = GetTagAtRest(RIGHT_REEL, 3);
- match = GetMatchFromSymbols(c1, c2, c3);
- if (match != MATCHED_NONE)
+ sym1 = GetSymbolAtRest(LEFT_REEL, 1);
+ sym2 = GetSymbolAtRest(MIDDLE_REEL, 2);
+ sym3 = GetSymbolAtRest(RIGHT_REEL, 3);
+ match = GetMatchFromSymbols(sym1, sym2, sym3);
+ if (match != MATCH_NONE)
{
- if (match != MATCHED_1CHERRY)
+ // Don't add payout for cherry, since it's already counted in
+ // CheckMatch_TopAndBottom().
+ if (match != MATCH_CHERRY)
{
sSlotMachine->payout += sSlotPayouts[match];
- sSlotMachine->matchedSymbols |= sSlotMatchFlags[match];
+ sSlotMachine->matches |= sSlotMatchFlags[match];
}
FlashMatchLine(MATCH_NWSE_DIAG);
}
- c1 = GetTagAtRest(LEFT_REEL, 3);
- c2 = GetTagAtRest(MIDDLE_REEL, 2);
- c3 = GetTagAtRest(RIGHT_REEL, 1);
- match = GetMatchFromSymbols(c1, c2, c3);
- if (match != MATCHED_NONE)
+ sym1 = GetSymbolAtRest(LEFT_REEL, 3);
+ sym2 = GetSymbolAtRest(MIDDLE_REEL, 2);
+ sym3 = GetSymbolAtRest(RIGHT_REEL, 1);
+ match = GetMatchFromSymbols(sym1, sym2, sym3);
+ if (match != MATCH_NONE)
{
- if (match != MATCHED_1CHERRY)
+ // Don't add payout for cherry, since it's already counted in
+ // CheckMatch_TopAndBottom().
+ if (match != MATCH_CHERRY)
{
sSlotMachine->payout += sSlotPayouts[match];
- sSlotMachine->matchedSymbols |= sSlotMatchFlags[match];
+ sSlotMachine->matches |= sSlotMatchFlags[match];
}
FlashMatchLine(MATCH_NESW_DIAG);
}
}
-static u8 GetMatchFromSymbols(u8 c1, u8 c2, u8 c3)
+static u8 GetMatchFromSymbols(u8 sym1, u8 sym2, u8 sym3)
{
- if (c1 == c2 && c1 == c3)
- return sSymToMatch[c1];
- if (c1 == GFXTAG_7_RED && c2 == GFXTAG_7_RED && c3 == GFXTAG_7_BLUE)
- return MATCHED_777_MIXED;
- if (c1 == GFXTAG_7_BLUE && c2 == GFXTAG_7_BLUE && c3 == GFXTAG_7_RED)
- return MATCHED_777_MIXED;
- if (c1 == GFXTAG_CHERRY)
- return MATCHED_1CHERRY;
- return MATCHED_NONE;
+ if (sym1 == sym2 && sym1 == sym3)
+ return sSymbolToMatch[sym1];
+ if (sym1 == SYMBOL_7_RED && sym2 == SYMBOL_7_RED && sym3 == SYMBOL_7_BLUE)
+ return MATCH_MIXED_7;
+ if (sym1 == SYMBOL_7_BLUE && sym2 == SYMBOL_7_BLUE && sym3 == SYMBOL_7_RED)
+ return MATCH_MIXED_7;
+ if (sym1 == SYMBOL_CHERRY)
+ return MATCH_CHERRY;
+ return MATCH_NONE;
}
static void AwardPayout(void)
{
- RunAwardPayoutActions(CreateTask(RunAwardPayoutActions, 4));
+ Task_Payout(CreateTask(Task_Payout, 4));
}
-static bool8 IsFinalTask_RunAwardPayoutActions(void)
+static bool8 IsFinalTask_Task_Payout(void)
{
- if (FindTaskIdByFunc(RunAwardPayoutActions) == TAIL_SENTINEL)
+ if (FindTaskIdByFunc(Task_Payout) == TAIL_SENTINEL)
return TRUE;
else
return FALSE;
}
-static void RunAwardPayoutActions(u8 taskId)
+static void Task_Payout(u8 taskId)
{
- while (sAwardPayoutActions[gTasks[taskId].data[0]](&gTasks[taskId]))
+ while (sPayoutTasks[gTasks[taskId].data[0]](&gTasks[taskId]))
;
}
-static bool8 AwardPayoutAction0(struct Task *task)
+#define tState data[0]
+#define tTimer data[1]
+
+static bool8 PayoutTask_Init(struct Task *task)
{
if (IsMatchLineDoneFlashingBeforePayout())
{
- task->data[0]++;
+ task->tState++; // PAYOUT_TASK_GIVE_PAYOUT
if (sSlotMachine->payout == 0)
{
- task->data[0] = 2;
+ task->tState = PAYOUT_TASK_FREE;
return TRUE;
}
}
return FALSE;
}
-// task->data[1]: timer
-static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
+static bool8 PayoutTask_GivePayout(struct Task *task)
{
- if (!task->data[1]--)
+ if (!task->tTimer--)
{
if (IsFanfareTaskInactive())
PlaySE(SE_PIN);
sSlotMachine->payout--;
if (sSlotMachine->coins < MAX_COINS)
sSlotMachine->coins++;
- task->data[1] = 8;
+ task->tTimer = 8;
if (JOY_HELD(A_BUTTON))
- task->data[1] = 4;
+ task->tTimer = 4;
}
if (IsFanfareTaskInactive() && JOY_NEW(START_BUTTON))
{
@@ -1953,19 +2144,22 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task)
sSlotMachine->payout = 0;
}
if (sSlotMachine->payout == 0)
- task->data[0]++;
+ task->tState++; // PAYOUT_TASK_FREE
return FALSE;
}
-static bool8 AwardPayoutAction_FreeTask(struct Task *task)
+static bool8 PayoutTask_Free(struct Task *task)
{
if (TryStopMatchLinesFlashing())
- DestroyTask(FindTaskIdByFunc(RunAwardPayoutActions));
+ DestroyTask(FindTaskIdByFunc(Task_Payout));
return FALSE;
}
-// Get the tag at position `offset` below the top of the reel's tape. Note that
-// if `offset` is negative, it wraps around to the bottom of the tape.
+#undef tState
+#undef tTimer
+
+// Get the symbol at position `offset` below the top of the reel's tape. Note
+// that if `offset` is negative, it wraps around to the bottom of the tape.
// .-----------------.
// | [ ] | [ ] | [ ] | <- offset = 0
// /-----|-----|-----\
@@ -1976,40 +2170,42 @@ static bool8 AwardPayoutAction_FreeTask(struct Task *task)
// | ... | ... | ... |
// | [ ] | [ ] | [ ] | <- offset = 20
// .-----------------.
-static u8 GetTagAtRest(u8 reel, s16 offset)
+static u8 GetSymbolAtRest(u8 reel, s16 offset)
{
s16 pos = (sSlotMachine->reelPositions[reel] + offset) % SYMBOLS_PER_REEL;
if (pos < 0)
pos += SYMBOLS_PER_REEL;
- return sReelSymbolTileTags[reel][pos];
+ return sReelSymbols[reel][pos];
}
-// Calculates GetTagAtRest as if the reel were snapped downwards into place.
-static u8 GetTag(u8 reel, s16 offset)
+// Calculates GetSymbolAtRest as if the reel were snapped downwards into place.
+static u8 GetSymbol(u8 reel, s16 offset)
{
s16 inc = 0;
s16 pixelOffset = sSlotMachine->reelPixelOffsets[reel] % REEL_SYMBOL_HEIGHT;
if (pixelOffset != 0)
inc = -1;
- return GetTagAtRest(reel, offset + inc);
+ return GetSymbolAtRest(reel, offset + inc);
}
-static u8 GetNearbyReelTimeTag(s16 n)
+static u8 GetReelTimeSymbol(s16 offset)
{
- s16 newPosition = (sSlotMachine->reeltimePosition + n) % 6;
+ s16 newPosition = (sSlotMachine->reeltimePosition + offset) % REELTIME_SYMBOLS;
if (newPosition < 0)
- newPosition += 6;
- return sReelTimeTags[newPosition];
+ newPosition += REELTIME_SYMBOLS;
+ return sReelTimeSymbols[newPosition];
}
static void AdvanceSlotReel(u8 reelIndex, s16 value)
{
sSlotMachine->reelPixelOffsets[reelIndex] += value;
- sSlotMachine->reelPixelOffsets[reelIndex] %= 504;
+ sSlotMachine->reelPixelOffsets[reelIndex] %= REEL_HEIGHT;
sSlotMachine->reelPositions[reelIndex] = SYMBOLS_PER_REEL - sSlotMachine->reelPixelOffsets[reelIndex] / REEL_SYMBOL_HEIGHT;
}
-s16 AdvanceSlotReelToNextTag(u8 reelIndex, s16 value)
+// Advances the reel no further than the next symbol. Returns the remaining
+// pixels until the next symbol.
+s16 AdvanceSlotReelToNextSymbol(u8 reelIndex, s16 value)
{
s16 offset = sSlotMachine->reelPixelOffsets[reelIndex] % REEL_SYMBOL_HEIGHT;
if (offset != 0)
@@ -2025,48 +2221,53 @@ s16 AdvanceSlotReelToNextTag(u8 reelIndex, s16 value)
static void AdvanceReeltimeReel(s16 value)
{
sSlotMachine->reeltimePixelOffset += value;
- sSlotMachine->reeltimePixelOffset %= 120;
- sSlotMachine->reeltimePosition = 6 - sSlotMachine->reeltimePixelOffset / 20;
+ sSlotMachine->reeltimePixelOffset %= REELTIME_REEL_HEIGHT;
+ sSlotMachine->reeltimePosition = REELTIME_SYMBOLS - sSlotMachine->reeltimePixelOffset / REELTIME_SYMBOL_HEIGHT;
}
-s16 AdvanceReeltimeReelToNextTag(s16 value)
+// Advances the reel no further than the next symbol. Returns the remaining
+// pixels until the next symbol.
+s16 AdvanceReeltimeReelToNextSymbol(s16 value)
{
- s16 offset = sSlotMachine->reeltimePixelOffset % 20;
+ s16 offset = sSlotMachine->reeltimePixelOffset % REELTIME_SYMBOL_HEIGHT;
if (offset != 0)
{
if (offset < value)
value = offset;
AdvanceReeltimeReel(value);
- offset = sSlotMachine->reeltimePixelOffset % 20;
+ offset = sSlotMachine->reeltimePixelOffset % REELTIME_SYMBOL_HEIGHT;
}
return offset;
}
-#define tState data[0]
-#define tMoving data[14]
-#define tReelId data[15]
+#define tState data[0]
+#define tExtraTurns data[1]
+#define tShockMagnitude data[1]
+#define tTimer data[2]
+#define tMoving data[14]
+#define tReelId data[15]
-static void CreateSlotReelTasks(void)
+static void CreateReelTasks(void)
{
u8 i;
for (i = 0; i < NUM_REELS; i++)
{
- u8 taskId = CreateTask(Task_RunSlotReelActions, 2);
+ u8 taskId = CreateTask(Task_Reel, 2);
gTasks[taskId].tReelId = i;
sSlotMachine->slotReelTasks[i] = taskId;
- Task_RunSlotReelActions(taskId);
+ Task_Reel(taskId);
}
}
static void SpinSlotReel(u8 reelIndex)
{
- gTasks[sSlotMachine->slotReelTasks[reelIndex]].tState = REEL_ACTION_SPIN;
+ gTasks[sSlotMachine->slotReelTasks[reelIndex]].tState = REEL_TASK_SPIN;
gTasks[sSlotMachine->slotReelTasks[reelIndex]].tMoving = TRUE;
}
static void StopSlotReel(u8 reelIndex)
{
- gTasks[sSlotMachine->slotReelTasks[reelIndex]].tState = REEL_ACTION_STOP;
+ gTasks[sSlotMachine->slotReelTasks[reelIndex]].tState = REEL_TASK_DECIDE_STOP;
}
static bool8 IsSlotReelMoving(u8 reelIndex)
@@ -2074,43 +2275,52 @@ static bool8 IsSlotReelMoving(u8 reelIndex)
return gTasks[sSlotMachine->slotReelTasks[reelIndex]].tMoving;
}
-static void Task_RunSlotReelActions(u8 taskId)
+static void Task_Reel(u8 taskId)
{
- while (sSlotReelActions[gTasks[taskId].tState](&gTasks[taskId]))
+ while (sReelTasks[gTasks[taskId].tState](&gTasks[taskId]))
;
}
-// task->data[1] reel turns
-static bool8 SlotReelAction_StayStill(struct Task *task)
+static bool8 ReelTask_StayStill(struct Task *task)
{
return FALSE;
}
-static bool8 SlotReelAction_Spin(struct Task *task)
+static bool8 ReelTask_Spin(struct Task *task)
{
- AdvanceSlotReel(task->tReelId, sSlotMachine->reelIncrement);
+ AdvanceSlotReel(task->tReelId, sSlotMachine->reelSpeed);
return FALSE;
}
-// As in previous generations, the slot machine often doesn't stop exactly when you press stop
-static bool8 SlotReelAction_DecideWhereToStop(struct Task *task)
+// In ReelTime, the reel stops immediately. Otherwise, the game may manipulate
+// the results by stopping after at most 4 extra turns. The exact behavior
+// differs depending on whether the machine has a bias.
+//
+// If the machine has a bias, it will try to match the bias symbol in each reel.
+//
+// Otherwise, if the machine doesn't have a bias or it could not line up the
+// bias symbol in any of the previous reels, it will perform the NoBias stopping
+// routine, which manipulates the outcome so the player loses.
+static bool8 ReelTask_DecideStop(struct Task *task)
{
- task->tState++;
- // initialize data for that reel --> these will be changed if sBiasTags can be lined up
+ task->tState++; // REEL_TASK_STOP_MOVE
sSlotMachine->winnerRows[task->tReelId] = 0;
sSlotMachine->reelExtraTurns[task->tReelId] = 0;
- if (sSlotMachine->reelTimeSpinsLeft == 0 && (sSlotMachine->luckyFlags == 0 || !sSlotMachine->isLuckySpin || !sDecideReelTurns_BiasTag[task->tReelId]()))
+ if (sSlotMachine->reelTimeSpinsLeft == 0)
{
- sSlotMachine->isLuckySpin = FALSE;
- sDecideReelTurns_NoBiasTag[task->tReelId]();
+ if (sSlotMachine->machineBias == 0 || !sSlotMachine->didNotFailBias || !sDecideStop_Bias[task->tReelId]())
+ {
+ sSlotMachine->didNotFailBias = FALSE;
+ sDecideStop_NoBias[task->tReelId]();
+ }
}
- task->data[1] = sSlotMachine->reelExtraTurns[task->tReelId];
+ task->tExtraTurns = sSlotMachine->reelExtraTurns[task->tReelId];
return TRUE;
}
-// go to next tag and then do any additional turns
-static bool8 SlotReelAction_MoveToStop(struct Task *task)
+// Go to the next symbol, then add any extra turns.
+static bool8 ReelTask_MoveToStop(struct Task *task)
{
u16 reelStopShocks[ARRAY_COUNT(sReelStopShocks)];
s16 reelPixelPos;
@@ -2118,112 +2328,147 @@ static bool8 SlotReelAction_MoveToStop(struct Task *task)
memcpy(reelStopShocks, sReelStopShocks, sizeof(sReelStopShocks));
reelPixelPos = sSlotMachine->reelPixelOffsets[task->tReelId] % REEL_SYMBOL_HEIGHT;
if (reelPixelPos != 0)
- reelPixelPos = AdvanceSlotReelToNextTag(task->tReelId, sSlotMachine->reelIncrement);
+ reelPixelPos = AdvanceSlotReelToNextSymbol(task->tReelId, sSlotMachine->reelSpeed);
else if (sSlotMachine->reelExtraTurns[task->tReelId])
{
sSlotMachine->reelExtraTurns[task->tReelId]--;
- AdvanceSlotReel(task->tReelId, sSlotMachine->reelIncrement);
+ AdvanceSlotReel(task->tReelId, sSlotMachine->reelSpeed);
reelPixelPos = sSlotMachine->reelPixelOffsets[task->tReelId] % REEL_SYMBOL_HEIGHT;
}
+
if (reelPixelPos == 0 && sSlotMachine->reelExtraTurns[task->tReelId] == 0)
{
- task->tState++;
- task->data[1] = reelStopShocks[task->data[1]];
- task->data[2] = 0;
+ task->tState++; // REEL_TASK_STOP_SHAKE
+ task->tShockMagnitude = reelStopShocks[task->tExtraTurns];
+ task->tTimer = 0;
}
return FALSE;
}
-// make selected tag oscillate before it becomes still
-static bool8 SlotReelAction_OscillatingStop(struct Task *task)
+// The reel shakes a little at the selected symbol before settling.
+static bool8 ReelTask_ShakingStop(struct Task *task)
{
- sSlotMachine->reelPixelOffsetsWhileStopping[task->tReelId] = task->data[1];
- task->data[1] = -task->data[1];
- task->data[2]++;
- if ((task->data[2] & 0x3) == 0)
- task->data[1] >>= 1;
- if (task->data[1] == 0)
+ sSlotMachine->reelShockOffsets[task->tReelId] = task->tShockMagnitude;
+ task->tShockMagnitude = -task->tShockMagnitude;
+ task->tTimer++;
+ if ((task->tTimer & 0x3) == 0)
+ task->tShockMagnitude >>= 1;
+ if (task->tShockMagnitude == 0)
{
task->tState = 0;
task->tMoving = FALSE;
- sSlotMachine->reelPixelOffsetsWhileStopping[task->tReelId] = 0;
+ sSlotMachine->reelShockOffsets[task->tReelId] = 0;
}
return FALSE;
}
#undef tState
+#undef tExtraTurns
+#undef tShockMagnitude
+#undef tTimer
#undef tMoving
#undef tReelId
-static bool8 DecideReelTurns_BiasTag_Reel1(void)
+// We pass along two symbols to bias toward. If the machine is biased toward
+// 7's, we pass both the 7 symbols. Otherwise, we just pass the bias symbol
+// twice.
+static bool8 DecideStop_Bias_Reel1(void)
{
- u8 tag2 = GetBiasTag(sSlotMachine->luckyFlags);
- u8 tag1 = tag2;
- if (sSlotMachine->luckyFlags & (LUCKY_BIAS_777 | LUCKY_BIAS_MIXED_777))
+ u8 sym2 = GetBiasSymbol(sSlotMachine->machineBias);
+ u8 sym1 = sym2;
+ if (sSlotMachine->machineBias & (BIAS_STRAIGHT_7 | BIAS_MIXED_7))
{
- tag1 = GFXTAG_7_RED;
- tag2 = GFXTAG_7_BLUE;
+ sym1 = SYMBOL_7_RED;
+ sym2 = SYMBOL_7_BLUE;
}
- return sDecideReelTurns_BiasTag_Reel1_Bets[sSlotMachine->bet - 1](tag1, tag2);
+ return sDecideStop_Bias_Reel1_Bets[sSlotMachine->bet - 1](sym1, sym2);
}
-static bool8 AreTagsAtPosition_Reel1(s16 pos, u8 tag1, u8 tag2)
+// The biasSymbol for subsequent reels is determined based on which of the bias
+// symbols can be found in reel 1. This really only matters when the machine is
+// biased toward 7's. It will try to match a 7 of the same color as reel 1.
+static bool8 EitherSymbolAtPos_Reel1(s16 pos, u8 sym1, u8 sym2)
{
- u8 tag = GetTag(LEFT_REEL, pos);
- if (tag == tag1 || tag == tag2)
+ u8 sym = GetSymbol(LEFT_REEL, pos);
+ if (sym == sym1 || sym == sym2)
{
- sSlotMachine->biasTag = tag;
+ sSlotMachine->biasSymbol = sym;
return TRUE;
}
return FALSE;
}
-static bool8 AreCherriesOnScreen_Reel1(s16 offsetFromCenter)
+// Returns true if there are cherries on screen in reel 1 after the given number
+// of turns.
+static bool8 AreCherriesOnScreen_Reel1(s16 turns)
{
- if (GetTag(LEFT_REEL, 1 - offsetFromCenter) == GFXTAG_CHERRY
- || GetTag(LEFT_REEL, 2 - offsetFromCenter) == GFXTAG_CHERRY
- || GetTag(LEFT_REEL, 3 - offsetFromCenter) == GFXTAG_CHERRY)
+ if (GetSymbol(LEFT_REEL, 1 - turns) == SYMBOL_CHERRY
+ || GetSymbol(LEFT_REEL, 2 - turns) == SYMBOL_CHERRY
+ || GetSymbol(LEFT_REEL, 3 - turns) == SYMBOL_CHERRY)
return TRUE;
else
return FALSE;
}
-static bool8 IsBiasTowardsCherryOr7s(void)
+static bool8 BiasedTowardCherryOr7s(void)
{
- if (sSlotMachine->luckyFlags & (LUCKY_BIAS_777 | LUCKY_BIAS_MIXED_777 | LUCKY_BIAS_CHERRY))
+ if (sSlotMachine->machineBias & (BIAS_STRAIGHT_7 | BIAS_MIXED_7 | BIAS_CHERRY))
return TRUE;
else
return FALSE;
}
-static bool8 DecideReelTurns_BiasTag_Reel1_Bet1(u8 tag1, u8 tag2)
+// If a bias symbol appears in the center of reel 1 within the next 4 turns,
+// stop there. That symbol becomes the biasSymbol for the subsequent reels.
+static bool8 DecideStop_Bias_Reel1_Bet1(u8 sym1, u8 sym2)
{
s16 i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- // if a lucky tag appears in the center row within 4 turns
- if (AreTagsAtPosition_Reel1(2 - i, tag1, tag2))
+ if (EitherSymbolAtPos_Reel1(2 - i, sym1, sym2))
{
sSlotMachine->winnerRows[LEFT_REEL] = 2;
- sSlotMachine->reelExtraTurns[0] = i;
+ sSlotMachine->reelExtraTurns[LEFT_REEL] = i;
return TRUE;
}
}
return FALSE;
}
-static bool8 DecideReelTurns_BiasTag_Reel1_Bet2or3(u8 tag1, u8 tag2)
+// There is slightly different behavior depending on the machine's bias.
+//
+// Bias toward cherry or 7s:
+// - Check if a cherry or 7 is currently on screen. If so, stop immediately.
+// - Roll up to 4 extra turns to see if a cherry or 7 enters the screen:
+// - If it enters after 1 turn, stop the reel when it gets the bottom row.
+// - Otherwise, if it enters before the 4th turn, stop the reel when it gets
+// to the middle row.
+// - If it enters on the 4th turn, stop here. It will be in the top row.
+//
+// Other bias:
+// - This is very similar, except the game is checking for the bias symbol
+// rather than cherries / 7s.
+//
+// However, the game adds an additional constraint: it will not stop if there
+// will be any cherries on screen. Presumably, this ensures that you will not
+// get any matches if you fail to line up the bias symbol in the remaining
+// reels.
+//
+// This is programmed in such a way that it excludes more options than
+// necessary. If there are cherries in the two positions below the bias symbol,
+// it will skip over this option, even if those cherries would not have ended
+// up on screen.
+static bool8 DecideStop_Bias_Reel1_Bet2or3(u8 sym1, u8 sym2)
{
s16 i;
- bool8 biased = IsBiasTowardsCherryOr7s();
- // if lucky numbers or no cherries are currently on screen in reel 1...
- if (biased || !AreCherriesOnScreen_Reel1(0))
+ bool8 cherry7Bias = BiasedTowardCherryOr7s();
+ if (cherry7Bias || !AreCherriesOnScreen_Reel1(0))
{
- for (i = 1; i < 4; i++)
+ // Check the current screen
+ for (i = 1; i <= 3; i++)
{
- // if a bias tag is currently on the screen
- if (AreTagsAtPosition_Reel1(i, tag1, tag2))
+ if (EitherSymbolAtPos_Reel1(i, sym1, sym2))
{
sSlotMachine->winnerRows[0] = i;
sSlotMachine->reelExtraTurns[0] = 0;
@@ -2231,30 +2476,27 @@ static bool8 DecideReelTurns_BiasTag_Reel1_Bet2or3(u8 tag1, u8 tag2)
}
}
}
- for (i = 1; i < 5; i++)
+
+ // Check the next 4 turns
+ for (i = 1; i <= MAX_EXTRA_TURNS; i++)
{
- bool8 biasedCopy = biased; // redundant
- // if biased or if in the next 4 turns there is a screen with no cherries...
- if (biasedCopy || !AreCherriesOnScreen_Reel1(i))
+ bool8 cherry7BiasCopy = cherry7Bias; // redundant
+ if (cherry7BiasCopy || !AreCherriesOnScreen_Reel1(i))
{
- //...and if a bias tag is in top row of that screen
- if (AreTagsAtPosition_Reel1(1 - i, tag1, tag2))
+ if (EitherSymbolAtPos_Reel1(1 - i, sym1, sym2))
{
- //...and if it only took 1 turn and the lucky tag could also be the bottom row of a screen with no cherries...
- if (i == 1 && (biasedCopy || !AreCherriesOnScreen_Reel1(3)))
+ if (i == 1 && (cherry7BiasCopy || !AreCherriesOnScreen_Reel1(3)))
{
sSlotMachine->winnerRows[0] = 3;
sSlotMachine->reelExtraTurns[0] = 3;
return TRUE;
}
- //...or if it isn't the last turn and the lucky tag could be in the center row of a screen with no cherries...
- if (i < 4 && (biasedCopy || !AreCherriesOnScreen_Reel1(i + 1)))
+ if (i <= 3 && (cherry7BiasCopy || !AreCherriesOnScreen_Reel1(i + 1)))
{
sSlotMachine->winnerRows[0] = 2;
sSlotMachine->reelExtraTurns[0] = i + 1;
return TRUE;
}
- //...else
sSlotMachine->winnerRows[0] = 1;
sSlotMachine->reelExtraTurns[0] = i;
return TRUE;
@@ -2264,22 +2506,23 @@ static bool8 DecideReelTurns_BiasTag_Reel1_Bet2or3(u8 tag1, u8 tag2)
return FALSE;
}
-static bool8 DecideReelTurns_BiasTag_Reel2(void)
+static bool8 DecideStop_Bias_Reel2(void)
{
- return sDecideReelTurns_BiasTag_Reel2_Bets[sSlotMachine->bet - 1]();
+ return sDecideStop_Bias_Reel2_Bets[sSlotMachine->bet - 1]();
}
-static bool8 DecideReelTurns_BiasTag_Reel2_Bet1or2(void)
+// Turn at most 4 extra turns to try to line up the bias symbol in the same row
+// as reel 1.
+static bool8 DecideStop_Bias_Reel2_Bet1or2(void)
{
s16 i;
- s16 biasTagLocation_Reel1 = sSlotMachine->winnerRows[0];
+ s16 reel1BiasRow = sSlotMachine->winnerRows[0];
- for (i = 0; i < 5; i++)
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- // if biasTag appears in the same row within 4 turns
- if (GetTag(MIDDLE_REEL, biasTagLocation_Reel1 - i) == sSlotMachine->biasTag)
+ if (GetSymbol(MIDDLE_REEL, reel1BiasRow - i) == sSlotMachine->biasSymbol)
{
- sSlotMachine->winnerRows[1] = biasTagLocation_Reel1;
+ sSlotMachine->winnerRows[1] = reel1BiasRow;
sSlotMachine->reelExtraTurns[1] = i;
return TRUE;
}
@@ -2287,19 +2530,55 @@ static bool8 DecideReelTurns_BiasTag_Reel2_Bet1or2(void)
return FALSE;
}
-static bool8 DecideReelTurns_BiasTag_Reel2_Bet3(void)
+// Checks whether it can match the bias symbol diagonally, and sometimes skews
+// toward this type of match rather than a match straight across.
+//
+// The behavior is different depending on where the bias symbol landed in
+// reel 1:
+//
+// Landed in middle row:
+// A diagonal match is impossible. Just try to match the bias symbol in the
+// middle row of reel 2 within 4 turns.
+//
+// Landed in top/bottom row:
+// - If it would take 2 or 3 turns to get the bias symbol into the same row as
+// reel 1, force a diagonal match by stopping it in the middle row instead.
+// - Check if the bias symbol is already in the same row as reel 1, or if it
+// takes 1 or 4 turns to get it there. If so, stop when it reaches that row.
+// - Otherwise, check if the bias symbol is already in the middle row of
+// reel 2. If so, stop here.
+//
+// So in how many more cases would betting 3 coins let you win compared to
+// betting 2?
+// Not many. Most of the time, the game would have matched the symbol in the
+// same row as reel 1 if you had bet 2 coins. Betting 3 effectively adds
+// coverage for only two additional cases:
+// - Bias symbol is in top row of reel 1 and bias symbol is currently in
+// middle row of reel 2.
+// - Bias symbol is in bottom row of reel 1 and bias symbol could get to the
+// middle row of reel 2 in 4 turns.
+//
+// Assuming this is the implementation Game Freak intended, the game effectively
+// turns straight matches into diagonal matches with 2/5 probability.
+// Presumably, this makes the player feel fortunate that they bet 3 coins rather
+// than 2, even though most times the game would have still forced a match with
+// only 2 coins.
+static bool8 DecideStop_Bias_Reel2_Bet3(void)
{
s16 i;
- // if biasTag appears in the same row within 4 turns...
- if (DecideReelTurns_BiasTag_Reel2_Bet1or2())
+ // If you can line up the bias symbol in the same row as reel 1 within 4
+ // turns
+ if (DecideStop_Bias_Reel2_Bet1or2())
{
- //...and if the biasTag is not in middle row of reel 1 and if biasTag appears in middle row of reel 2 in 2 or 3 turns...
+ // If bias symbol is not in the middle row of reel 1 and it takes either
+ // 2 or 3 turns to get it in the same row for reel 2
if (sSlotMachine->winnerRows[0] != 2 && sSlotMachine->reelExtraTurns[1] > 1 && sSlotMachine->reelExtraTurns[1] != 4)
{
- for (i = 0; i < 5; i++)
+ // Try turning this into a diagonal match by lining up the bias
+ // symbol in the middle row of reel 2 within 4 turns.
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- //...and if the bias tag will appear in the middle row within 4 turns
- if (GetTag(MIDDLE_REEL, 2 - i) == sSlotMachine->biasTag)
+ if (GetSymbol(MIDDLE_REEL, 2 - i) == sSlotMachine->biasSymbol)
{
sSlotMachine->winnerRows[1] = 2;
sSlotMachine->reelExtraTurns[1] = i;
@@ -2309,13 +2588,16 @@ static bool8 DecideReelTurns_BiasTag_Reel2_Bet3(void)
}
return TRUE;
}
- // else if the biasTag is not in middle row of reel 1...
+
+ // If you can't line up the bias symbol in the same row in 4 turns, and the
+ // bias symbol is not in the middle row of reel 1
if (sSlotMachine->winnerRows[0] != 2)
{
- for (i = 0; i < 5; i++)
+ // Try to match the bias symbol in middle row of reel 2 within 4 turns.
+ // Adds coverage for the two cases mentioned above.
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- //...and if the biasTag will appear in the center row of reel 2 within 4 turns
- if (GetTag(MIDDLE_REEL, 2 - i) == sSlotMachine->biasTag)
+ if (GetSymbol(MIDDLE_REEL, 2 - i) == sSlotMachine->biasSymbol)
{
sSlotMachine->winnerRows[1] = 2;
sSlotMachine->reelExtraTurns[1] = i;
@@ -2326,31 +2608,34 @@ static bool8 DecideReelTurns_BiasTag_Reel2_Bet3(void)
return FALSE;
}
-static bool8 DecideReelTurns_BiasTag_Reel3(void)
+// If the machine is biased toward mixed 7's, swap the color of the bias symbol
+// from red 7 to blue 7, or vice versa.
+static bool8 DecideStop_Bias_Reel3(void)
{
- u8 biasTag = sSlotMachine->biasTag;
- if (sSlotMachine->luckyFlags & LUCKY_BIAS_MIXED_777)
+ u8 biasSymbol = sSlotMachine->biasSymbol;
+ if (sSlotMachine->machineBias & BIAS_MIXED_7)
{
- biasTag = GFXTAG_7_RED;
- if (sSlotMachine->biasTag == GFXTAG_7_RED)
+ biasSymbol = SYMBOL_7_RED;
+ if (sSlotMachine->biasSymbol == SYMBOL_7_RED)
{
- biasTag = GFXTAG_7_BLUE;
+ biasSymbol = SYMBOL_7_BLUE;
}
}
- return sDecideReelTurns_BiasTag_Reel3_Bets[sSlotMachine->bet - 1](biasTag);
+ return sDecideStop_Bias_Reel3_Bets[sSlotMachine->bet - 1](biasSymbol);
}
-static bool8 DecideReelTurns_BiasTag_Reel3_Bet1or2(u8 biasTag)
+// Turn at most 4 extra turns to try to line up the bias symbol in the same
+// row as reel 2.
+static bool8 DecideStop_Bias_Reel3_Bet1or2(u8 biasSymbol)
{
s16 i;
- s16 biasTagLocation_Reel2 = sSlotMachine->winnerRows[1];
+ s16 reel2BiasRow = sSlotMachine->winnerRows[1];
- for (i = 0; i < 5; i++)
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- // if the biasTag appears in the same row as in reel 2 within 4 turns
- if (GetTag(RIGHT_REEL, biasTagLocation_Reel2 - i) == biasTag)
+ if (GetSymbol(RIGHT_REEL, reel2BiasRow - i) == biasSymbol)
{
- sSlotMachine->winnerRows[2] = biasTagLocation_Reel2;
+ sSlotMachine->winnerRows[2] = reel2BiasRow;
sSlotMachine->reelExtraTurns[2] = i;
return TRUE;
}
@@ -2358,35 +2643,40 @@ static bool8 DecideReelTurns_BiasTag_Reel3_Bet1or2(u8 biasTag)
return FALSE;
}
-static bool8 DecideReelTurns_BiasTag_Reel3_Bet3(u8 biasTag)
+// Try to complete a match in reel 3 by lining up a bias symbol with the bias
+// symbols from the first two reels.
+static bool8 DecideStop_Bias_Reel3_Bet3(u8 biasSymbol)
{
s16 i;
- s16 biasTagFinalPos;
- // if the final position of the biasTag matches in reel 1 and reel 2...
+ s16 biasRow;
+
+ // First two bias symbols in the same row. Try to line up bias symbol in
+ // same the row here too
if (sSlotMachine->winnerRows[0] == sSlotMachine->winnerRows[1])
- //...then try to line it up in reel 3
- return DecideReelTurns_BiasTag_Reel3_Bet1or2(biasTag);
- // else place it in the row opposite reel 1's
+ return DecideStop_Bias_Reel3_Bet1or2(biasSymbol);
+
+ // Otherwise, try to line up the bias symbol diagonally
if (sSlotMachine->winnerRows[0] == 1)
- biasTagFinalPos = 3;
+ biasRow = 3;
else
- biasTagFinalPos = 1;
- for (i = 0; i < 5; i++)
+ biasRow = 1;
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- // if the biasTag lands in that position within 4 turns
- if (GetTag(RIGHT_REEL, biasTagFinalPos - i) == biasTag)
+ if (GetSymbol(RIGHT_REEL, biasRow - i) == biasSymbol)
{
sSlotMachine->reelExtraTurns[2] = i;
- sSlotMachine->winnerRows[2] = biasTagFinalPos;
+ sSlotMachine->winnerRows[2] = biasRow;
return TRUE;
}
}
return FALSE;
}
-// Advance until there are no cherries on screen in reel 1
-
-static void DecideReelTurns_NoBiasTag_Reel1(void)
+// Advance as many turns as needed until there are no cherries on screen in
+// reel 1, as cherries would cause a match.
+//
+// Based on the distribution of reel 1, this will add at most 3 extra turns.
+static void DecideStop_NoBias_Reel1(void)
{
s16 i = 0;
@@ -2395,41 +2685,60 @@ static void DecideReelTurns_NoBiasTag_Reel1(void)
sSlotMachine->reelExtraTurns[0] = i;
}
-static bool8 IsBiasTag777_SwitchColor(u8 *biasTagPtr)
+// If the bias symbol is one of the 7's, switch to the opposite color and return
+// true. Otherwise, return false.
+static bool8 IfSymbol7_SwitchColor(u8 *symbol)
{
- if (*biasTagPtr == GFXTAG_7_RED)
+ if (*symbol == SYMBOL_7_RED)
{
- *biasTagPtr = GFXTAG_7_BLUE;
+ *symbol = SYMBOL_7_BLUE;
return TRUE;
}
- if (*biasTagPtr == GFXTAG_7_BLUE)
+ if (*symbol == SYMBOL_7_BLUE)
{
- *biasTagPtr = GFXTAG_7_RED;
+ *symbol = SYMBOL_7_RED;
return TRUE;
}
return FALSE;
}
-static void DecideReelTurns_NoBiasTag_Reel2(void)
-{
- sDecideReelTurns_NoBiasTag_Reel2_Bets[sSlotMachine->bet - 1]();
-}
-
-// only does stuff if the biasTag is one of the 7's, plus other conditions
-static void DecideReelTurns_NoBiasTag_Reel2_Bet1(void)
-{
- if (sSlotMachine->winnerRows[0] != 0 && sSlotMachine->luckyFlags & LUCKY_BIAS_777)
- {
- u8 biasTag = GetTag(LEFT_REEL, 2 - sSlotMachine->reelExtraTurns[0]);
- //...and if biasTag is one of the 7's...
- if (IsBiasTag777_SwitchColor(&biasTag))
- //...swap color of biasTag...
+// If the machine doesn't have a bias, the reel stops immediately.
+//
+// Otherwise, the machine tries to taunt the player if it is biased toward
+// straight 7's. This would only happen if the player did not stop near the
+// correct-color 7, so the machine couldn't force a match.
+//
+// Instead, the machine now tries to line up the opposite-color 7, which is not
+// a valid match.
+static void DecideStop_NoBias_Reel2(void)
+{
+ sDecideStop_NoBias_Reel2_Bets[sSlotMachine->bet - 1]();
+}
+
+// If the machine has no bias, stop immediately.
+//
+// Otherwise, the machine manipulates the results if all the following
+// conditions are met:
+// If
+// - The machine is biased toward straight 7's
+// - The machine managed to match a 7 in the middle of reel 1
+// - The machine could not line up a 7 of the same color in reel 2
+// Then
+// The machine will try to line up a 7 of the opposite color in reel 2
+static void DecideStop_NoBias_Reel2_Bet1(void)
+{
+ if (sSlotMachine->winnerRows[0] != 0 && sSlotMachine->machineBias & BIAS_STRAIGHT_7)
+ {
+ // Note here and in other NoBias functions, reelExtraTurns is 0 if it
+ // corresponds to a previous reel. That reel has already stopped and any
+ // extra turns were applied.
+ u8 reel1MiddleSym = GetSymbol(LEFT_REEL, 2 - sSlotMachine->reelExtraTurns[0]);
+ if (IfSymbol7_SwitchColor(&reel1MiddleSym))
{
s16 i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- //...and if the biasTag appears within 4 turns
- if (biasTag == GetTag(MIDDLE_REEL, 2 - i))
+ if (reel1MiddleSym == GetSymbol(MIDDLE_REEL, 2 - i))
{
sSlotMachine->winnerRows[1] = 2;
sSlotMachine->reelExtraTurns[1] = i;
@@ -2440,20 +2749,27 @@ static void DecideReelTurns_NoBiasTag_Reel2_Bet1(void)
}
}
-static void DecideReelTurns_NoBiasTag_Reel2_Bet2(void)
+// If the machine has no bias, stop immediately.
+//
+// Otherwise, the machine manipulates the results if all the following
+// conditions are met:
+// If
+// - The machine is biased toward straight 7's
+// - The machine managed to match a 7 anywhere in reel 1
+// - The machine could not line up a 7 of the same color in reel 2
+// Then
+// The machine will try to line up a 7 of the opposite color in reel 2
+static void DecideStop_NoBias_Reel2_Bet2(void)
{
- if (sSlotMachine->winnerRows[0] != 0 && sSlotMachine->luckyFlags & LUCKY_BIAS_777)
+ if (sSlotMachine->winnerRows[0] != 0 && sSlotMachine->machineBias & BIAS_STRAIGHT_7)
{
- u8 biasTag = GetTag(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
- //...and if biasTag is one of the 7's...
- if (IsBiasTag777_SwitchColor(&biasTag))
- //...swap color of biasTag...
+ u8 reel1BiasSym = GetSymbol(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
+ if (IfSymbol7_SwitchColor(&reel1BiasSym))
{
s16 i;
- for (i = 0; i < 5; i++)
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- //...and if the biasTag appears in same row in reel 2 within 4 turns
- if (biasTag == GetTag(MIDDLE_REEL, sSlotMachine->winnerRows[0] - i))
+ if (reel1BiasSym == GetSymbol(MIDDLE_REEL, sSlotMachine->winnerRows[0] - i))
{
sSlotMachine->winnerRows[1] = sSlotMachine->winnerRows[0];
sSlotMachine->reelExtraTurns[1] = i;
@@ -2464,146 +2780,225 @@ static void DecideReelTurns_NoBiasTag_Reel2_Bet2(void)
}
}
-static void DecideReelTurns_NoBiasTag_Reel2_Bet3(void)
+// If the machine has no bias, stop immediately.
+//
+// Otherwise, the machine manipulates the results if all the following
+// conditions are met:
+// If
+// - The machine is biased toward straight 7's
+// - The machine managed to match a 7 anywhere in reel 1
+// - The machine could not line up a 7 of the same color in reel 2
+// Then
+// The machine will try to line up a 7 of the opposite color in reel 2
+//
+// The way it tries to line up an opposite-color 7 differs depending on where
+// the 7 is in reel 1:
+//
+// Middle row:
+// Try to line up an opposite-color 7 in the middle of reel 2 within 4 turns.
+//
+// Top row:
+// - First check for an opposite-color 7 in the top and middle rows of the
+// current screen. If found, stop immediately.
+// - Otherwise, check if an opposite-color 7 will enter the top row within 4
+// turns.
+// - If one enters in 1 or 2 turns, stop the reel when it gets to the middle
+// row.
+// - If one enters in 3 or 4 turns, stop the reel when it gets to the top
+// row.
+//
+// Bottom row:
+// - First check for an opposite-color 7 in the middle and bottom rows of the
+// current screen. If found, stop immediately.
+// - Otherwise, check if an opposite-color 7 will enter the bottom row within 4
+// turns.
+// - If one enters in 1 or 2 turns, stop the reel when it gets to the bottom
+// row.
+// - If one enters in 3 or 4 turns, stop the reel when it gets to the middle
+// row.
+//
+// BUG: This procedure misses an opportunity to line up an opposite-color 7 in
+// one scenario, when:
+// - There is a 7 in the bottom row of reel 1
+// - And, you can get an opposite-color 7 in the middle row of reel 2 in 4
+// turns
+static void DecideStop_NoBias_Reel2_Bet3(void)
{
s16 i;
s16 j;
- // if reel 1 has a biasTag and bit 7 is set in luckyFlags...
- if (sSlotMachine->winnerRows[0] != 0 && sSlotMachine->luckyFlags & LUCKY_BIAS_777)
+ u8 reel1BiasSym;
+
+ if (sSlotMachine->winnerRows[0] != 0 && sSlotMachine->machineBias & BIAS_STRAIGHT_7)
{
- //...and if biasTag appeared in the center row of reel 1
+ // Lined up 7 in middle of reel 1
if (sSlotMachine->winnerRows[0] == 2)
{
- DecideReelTurns_NoBiasTag_Reel2_Bet2();
+ DecideStop_NoBias_Reel2_Bet2();
+ return;
}
- else
+
+ reel1BiasSym = GetSymbol(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
+ if (IfSymbol7_SwitchColor(&reel1BiasSym))
{
- u8 biasTag = GetTag(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
- //...and if biasTag is one of the 7's...
- if (IsBiasTag777_SwitchColor(&biasTag))
- //...swap the color of the 7...
+ // Check current screen to see if there is already an opposite-color
+ // 7 lined up for a match.
+ j = 2;
+ if (sSlotMachine->winnerRows[0] == 3)
+ j = 3;
+ for (i = 0; i < 2; i++, j--)
{
- j = 2;
- if (sSlotMachine->winnerRows[0] == 3)
- j = 3;
- for (i = 0; i < 2; i++, j--)
+ if (reel1BiasSym == GetSymbol(MIDDLE_REEL, j))
{
- if (biasTag == GetTag(MIDDLE_REEL, j))
- {
- sSlotMachine->winnerRows[1] = j;
- sSlotMachine->reelExtraTurns[1] = 0;
- return;
- }
+ sSlotMachine->winnerRows[1] = j;
+ sSlotMachine->reelExtraTurns[1] = 0;
+ return;
}
- for (j = 1; j < 5; j++)
+ }
+
+ // Check if opposite-color 7 will appear in same row as reel 1 in
+ // over the next 4 turns
+ for (j = 1; j <= MAX_EXTRA_TURNS; j++)
+ {
+ if (reel1BiasSym == GetSymbol(MIDDLE_REEL, sSlotMachine->winnerRows[0] - j))
{
- if (biasTag == GetTag(MIDDLE_REEL, sSlotMachine->winnerRows[0] - j))
+ // If 7 appeared in top row of reel 1
+ if (sSlotMachine->winnerRows[0] == 1)
+ {
+ if (j <= 2)
+ {
+ sSlotMachine->winnerRows[1] = 2;
+ sSlotMachine->reelExtraTurns[1] = j + 1;
+ }
+ else
+ {
+ sSlotMachine->winnerRows[1] = 1;
+ sSlotMachine->reelExtraTurns[1] = j;
+ }
+ }
+ // If 7 appeared in bottom row of reel 1
+ else
{
- if (sSlotMachine->winnerRows[0] == 1)
+ if (j <= 2)
{
- if (j < 3)
- {
- sSlotMachine->winnerRows[1] = 2;
- sSlotMachine->reelExtraTurns[1] = j + 1;
- }
- else
- {
- sSlotMachine->winnerRows[1] = 1;
- sSlotMachine->reelExtraTurns[1] = j;
- }
+ sSlotMachine->winnerRows[1] = 3;
+ sSlotMachine->reelExtraTurns[1] = j;
}
else
{
- if (j < 3)
- {
- sSlotMachine->winnerRows[1] = 3;
- sSlotMachine->reelExtraTurns[1] = j;
- }
- else
- {
- sSlotMachine->winnerRows[1] = 2;
- sSlotMachine->reelExtraTurns[1] = j - 1;
- }
+ sSlotMachine->winnerRows[1] = 2;
+ sSlotMachine->reelExtraTurns[1] = j - 1;
}
- return;
}
+ return;
}
}
}
}
}
-static bool8 AreTagsMixed77(u8 tag1, u8 tag2)
+// Returns true if the reel 1 and reel 2 symbols are opposite-color 7's.
+//
+// Note that if true, this does not constitue a MATCH_MIXED_7, as the first two
+// reels are not the same color.
+static bool8 MismatchedSyms_77(u8 sym1, u8 sym2)
{
- if ((tag1 == GFXTAG_7_RED && tag2 == GFXTAG_7_BLUE) || (tag1 == GFXTAG_7_BLUE && tag2 == GFXTAG_7_RED))
+ if ((sym1 == SYMBOL_7_RED && sym2 == SYMBOL_7_BLUE) || (sym1 == SYMBOL_7_BLUE && sym2 == SYMBOL_7_RED))
return TRUE;
else
return FALSE;
}
-static bool8 AreTagsMixed777(u8 tag1, u8 tag2, u8 tag3)
+// Returns true if the reel 1, reel 2 and reel 3 symbolss form a 7 mismatch,
+// i.e. {7R, 7B, 7R} or {7B, 7R, 7B}.
+static bool8 MismatchedSyms_777(u8 sym1, u8 sym2, u8 sym3)
{
- if ((tag1 == GFXTAG_7_RED && tag2 == GFXTAG_7_BLUE && tag3 == GFXTAG_7_RED) ||
- (tag1 == GFXTAG_7_BLUE && tag2 == GFXTAG_7_RED && tag3 == GFXTAG_7_BLUE))
+ if ((sym1 == SYMBOL_7_RED && sym2 == SYMBOL_7_BLUE && sym3 == SYMBOL_7_RED) ||
+ (sym1 == SYMBOL_7_BLUE && sym2 == SYMBOL_7_RED && sym3 == SYMBOL_7_BLUE))
return TRUE;
else
return FALSE;
}
-static bool8 TagsDontMatchOrHaveAny7s(u8 tag1, u8 tag2, u8 tag3)
+// Returns false if either:
+// - The symbols form a match (including MATCH_MIXED_7)
+// - Or, the symbols form a 7 mismatch (i.e., {7R, 7B, 7R} or {7B, 7R, 7B})
+//
+// Note, this does not account for cherry matches.
+static bool8 NeitherMatchNor7Mismatch(u8 sym1, u8 sym2, u8 sym3)
{
- if ((tag1 == GFXTAG_7_RED && tag2 == GFXTAG_7_BLUE && tag3 == GFXTAG_7_RED) ||
- (tag1 == GFXTAG_7_BLUE && tag2 == GFXTAG_7_RED && tag3 == GFXTAG_7_BLUE) ||
- (tag1 == GFXTAG_7_RED && tag2 == GFXTAG_7_RED && tag3 == GFXTAG_7_BLUE) ||
- (tag1 == GFXTAG_7_BLUE && tag2 == GFXTAG_7_BLUE && tag3 == GFXTAG_7_RED) ||
- (tag1 == tag2 && tag1 == tag3))
+ if ((sym1 == SYMBOL_7_RED && sym2 == SYMBOL_7_BLUE && sym3 == SYMBOL_7_RED)
+ || (sym1 == SYMBOL_7_BLUE && sym2 == SYMBOL_7_RED && sym3 == SYMBOL_7_BLUE)
+ || (sym1 == SYMBOL_7_RED && sym2 == SYMBOL_7_RED && sym3 == SYMBOL_7_BLUE)
+ || (sym1 == SYMBOL_7_BLUE && sym2 == SYMBOL_7_BLUE && sym3 == SYMBOL_7_RED)
+ || (sym1 == sym2 && sym1 == sym3))
{
return FALSE;
}
return TRUE;
}
-static void DecideReelTurns_NoBiasTag_Reel3(void)
+// Spin until there's no match, or try to taunt the player with a 7 mismatch if
+// they failed the straight 7 bias.
+static void DecideStop_NoBias_Reel3(void)
{
- sDecideReelTurns_NoBiasTag_Reel3_Bets[sSlotMachine->bet - 1]();
+ sDecideStop_NoBias_Reel3_Bets[sSlotMachine->bet - 1]();
}
-static void DecideReelTurns_NoBiasTag_Reel3_Bet1(void)
+// Spin until there is no match in reel 3. Additionally, if the player failed a
+// straight 7 bias, try to taunt them with a 7 mismatch.
+//
+// The way this plays out depends on the first two matched symbols.
+//
+// If first two symbols are the same:
+// Spin until you get a symbol that won't complete a match.
+//
+// Otherwise, if the first two symbols are opposite-color 7's:
+// - If the machine is biased toward straight 7's, then the player must have
+// failed with this bias. The machine tries to taunt the player by turning
+// up to 4 turns to complete a 7 mismatch (i.e., {7R, 7B, 7R} or
+// {7B, 7R, 7B}).
+// - Otherwise, spin until you get a symbol that won't complete a match.
+static void DecideStop_NoBias_Reel3_Bet1(void)
{
s16 i = 0;
- u8 tag1 = GetTag(LEFT_REEL, 2 - sSlotMachine->reelExtraTurns[0]);
- u8 tag2 = GetTag(MIDDLE_REEL, 2 - sSlotMachine->reelExtraTurns[1]);
- // if tags match in first 2 reels...
- if (tag1 == tag2)
+ u8 sym1 = GetSymbol(LEFT_REEL, 2 - sSlotMachine->reelExtraTurns[0]);
+ u8 sym2 = GetSymbol(MIDDLE_REEL, 2 - sSlotMachine->reelExtraTurns[1]);
+
+ // If first two symbols match, spin until you get a non-matching symbol
+ if (sym1 == sym2)
{
- //...spin until you get non-matching tag
- while (1)
+ while (TRUE)
{
- u8 tag3;
- if (!(tag1 == (tag3 = GetTag(RIGHT_REEL, 2 - i)) || (tag1 == GFXTAG_7_RED && tag3 == GFXTAG_7_BLUE) || (tag1 == GFXTAG_7_BLUE && tag3 == GFXTAG_7_RED)))
+ u8 sym3;
+ if (!((sym1 == (sym3 = GetSymbol(RIGHT_REEL, 2 - i)))
+ || (sym1 == SYMBOL_7_RED && sym3 == SYMBOL_7_BLUE)
+ || (sym1 == SYMBOL_7_BLUE && sym3 == SYMBOL_7_RED)))
break;
i++;
}
}
- else if (AreTagsMixed77(tag1, tag2))
+ // First two symbols are opposite-color 7's
+ else if (MismatchedSyms_77(sym1, sym2))
{
- if (sSlotMachine->luckyFlags & LUCKY_BIAS_777)
+ // If biased toward straight 7's, try to complete the 7 mismatch in 4
+ // turns
+ if (sSlotMachine->machineBias & BIAS_STRAIGHT_7)
{
- //...see if you can match with reel 1 within 4 turns
- for (i = 0; i < 5; i++)
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- if (tag1 == GetTag(RIGHT_REEL, 2 - i))
+ if (sym1 == GetSymbol(RIGHT_REEL, 2 - i))
{
sSlotMachine->reelExtraTurns[2] = i;
return;
}
}
}
- // turn until you aren't matching with reel 1
+
+ // Otherwise, just spin until you get a non-matching symbol
i = 0;
- while (1)
+ while (TRUE)
{
- if (tag1 != GetTag(RIGHT_REEL, 2 - i))
+ if (sym1 != GetSymbol(RIGHT_REEL, 2 - i))
break;
i++;
}
@@ -2611,25 +3006,49 @@ static void DecideReelTurns_NoBiasTag_Reel3_Bet1(void)
sSlotMachine->reelExtraTurns[2] = i;
}
-static void DecideReelTurns_NoBiasTag_Reel3_Bet2(void)
+// Spin until there is no match in reel 3. Additionally, if the player failed a
+// straight 7 bias, try to taunt them with a 7 mismatch.
+//
+// There are up to two stages, depending on the first two matched symbols:
+//
+// 1. [Optional] If first two symbols are opposite-color 7's in the same row and
+// the machine is biased toward straight 7's:
+// Check if a 7 with the same color as reel 1 appears in the same row
+// within 4 turns. If so, initially advance to that position.
+//
+// 2. Check rows. Keep advancing the reel a turn at a time as long as:
+// - There is a match in any row
+// - Or, there is a 7 mismatch in any row and the machine isn't biased
+// toward straight 7's
+//
+// Note, stage 2 is not limited to 4 turns. The reel keeps spinning until you
+// lose.
+static void DecideStop_NoBias_Reel3_Bet2(void)
{
s16 extraTurns = 0;
s16 i;
- u8 tag1;
- u8 tag2;
- u8 tag3;
- if (sSlotMachine->winnerRows[1] != 0 && sSlotMachine->winnerRows[0] == sSlotMachine->winnerRows[1] && sSlotMachine->luckyFlags & LUCKY_BIAS_777)
- {
- tag1 = GetTag(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
- tag2 = GetTag(MIDDLE_REEL, sSlotMachine->winnerRows[1] - sSlotMachine->reelExtraTurns[1]);
- //...and if tags are mixed 7s...
- if (AreTagsMixed77(tag1, tag2))
+ u8 sym1;
+ u8 sym2;
+ u8 sym3;
+
+ // Effectively, if you lined up two 7's in the same row
+ if (sSlotMachine->winnerRows[1] != 0 &&
+ sSlotMachine->winnerRows[0] == sSlotMachine->winnerRows[1] &&
+ sSlotMachine->machineBias & BIAS_STRAIGHT_7)
+ {
+ sym1 = GetSymbol(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
+ sym2 = GetSymbol(MIDDLE_REEL, sSlotMachine->winnerRows[1] - sSlotMachine->reelExtraTurns[1]);
+
+ // If the first two 7's are opposite colors, see if you can line up a 7
+ // mismatch in the same row. If so, advance initially to that position.
+ // More turns may be added further below.
+ if (MismatchedSyms_77(sym1, sym2))
{
- //...try to match with reel 1 within 4 turns
- for (i = 0; i < 5; i++)
+ // Iterate over the next 4 turns
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- tag3 = GetTag(RIGHT_REEL, sSlotMachine->winnerRows[1] - i);
- if (tag1 == tag3)
+ sym3 = GetSymbol(RIGHT_REEL, sSlotMachine->winnerRows[1] - i);
+ if (sym1 == sym3)
{
extraTurns = i;
break;
@@ -2637,53 +3056,100 @@ static void DecideReelTurns_NoBiasTag_Reel3_Bet2(void)
}
}
}
- // GUESS: spin until there's no possible match within 4 turns of you stopping
- while (1)
+
+ while (TRUE)
{
- s16 loopExit;
- for (i = 1, loopExit = 0; i < 4; i++)
+ s16 numMatches;
+ // Iterate over the rows of the screen after `extraTurns` turns
+ for (i = 1, numMatches = 0; i <= 3; i++)
{
- tag1 = GetTag(LEFT_REEL, i - sSlotMachine->reelExtraTurns[0]); // why does this update with i
- tag2 = GetTag(MIDDLE_REEL, i - sSlotMachine->reelExtraTurns[1]);
- tag3 = GetTag(RIGHT_REEL, i - extraTurns);
- // if bit 7 of luckyFlags is unset...
- //...and if all 3 tags match and they're not mixed 7s
- if (!TagsDontMatchOrHaveAny7s(tag1, tag2, tag3) && (!AreTagsMixed777(tag1, tag2, tag3) || !(sSlotMachine->luckyFlags & LUCKY_BIAS_777)))
+ sym1 = GetSymbol(LEFT_REEL, i - sSlotMachine->reelExtraTurns[0]);
+ sym2 = GetSymbol(MIDDLE_REEL, i - sSlotMachine->reelExtraTurns[1]);
+ sym3 = GetSymbol(RIGHT_REEL, i - extraTurns);
+
+ // This boils down to:
+ // If there's a match on screen, keep spinning. Otherwise, if
+ // there's a 7 mismatch on screen, keep spinning if the machine
+ // isn't biased toward straight 7's.
+ if (!NeitherMatchNor7Mismatch(sym1, sym2, sym3) &&
+ !(MismatchedSyms_777(sym1, sym2, sym3) && (sSlotMachine->machineBias & BIAS_STRAIGHT_7)))
{
- loopExit++;
+ numMatches++;
break;
}
}
- if (loopExit == 0)
+
+ // If no matches were found, stop here. Otherwise, add an extra spin and
+ // check again.
+ if (numMatches == 0)
break;
extraTurns++;
}
sSlotMachine->reelExtraTurns[2] = extraTurns;
}
-static void DecideReelTurns_NoBiasTag_Reel3_Bet3(void)
-{
- u8 tag1;
- u8 tag2;
- u8 tag3;
- s16 j;
+// Try to spin until there is no match in reel 3. Additionally, if the player
+// failed a straight 7 bias, try to taunt them with a 7 mismatch.
+//
+// There are up to four stages:
+//
+// 1. Advance the reel as if 2 coins were bet: to mildly oversimplify, spin
+// until there's no matches straight across in any rows.
+//
+// 2. [Optional] If you've lined up two opposite-color 7's diagonally and the
+// machine is biased toward straight 7's:
+// Check if a 7 with the same color as reel 1 appears in the final diagonal
+// position within 4 turns. If so, advance to that position.
+//
+// 3. Check NWSE diagonal. Keep advancing the reel a turn at a time as long as:
+// - There is a match in the diagonal
+// - Or, there is a 7 mismatch in the diagonal and the machine isn't
+// biased toward straight 7's
+//
+// 3. Check NESW diagonal. Keep advancing the reel a turn at a time as long as:
+// - There is a match in the diagonal
+// - Or, there is a 7 mismatch in the diagonal and the machine isn't
+// biased toward straight 7's
+//
+// Note that stages 3 and 4 are not limited to 4 turns.
+//
+// Also, note that it actually is possible to win a match here. After stage 1,
+// the game never again checks whether it will be matching any rows straight
+// across. So any extra turns added in stages 2-4 could result in a match
+// occurring straight across.
+static void DecideStop_NoBias_Reel3_Bet3(void)
+{
+ u8 sym1;
+ u8 sym2;
+ u8 sym3;
+ s16 row;
s16 i;
- DecideReelTurns_NoBiasTag_Reel3_Bet2();
- if (sSlotMachine->winnerRows[1] != 0 && sSlotMachine->winnerRows[0] != sSlotMachine->winnerRows[1] && sSlotMachine->luckyFlags & LUCKY_BIAS_777)
+ // Spin until there's no matches in any row straight across, potentially
+ // skewing toward a 7 mismatch. Consider this the new starting position for
+ // this function.
+ DecideStop_NoBias_Reel3_Bet2();
+
+ // Essentially, if you lined up two 7's diagonally
+ if (sSlotMachine->winnerRows[1] != 0 &&
+ sSlotMachine->winnerRows[0] != sSlotMachine->winnerRows[1] &&
+ sSlotMachine->machineBias & BIAS_STRAIGHT_7)
{
- tag1 = GetTag(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
- tag2 = GetTag(MIDDLE_REEL, sSlotMachine->winnerRows[1] - sSlotMachine->reelExtraTurns[1]);
- //..and if tags are mixed 7s...
- if (AreTagsMixed77(tag1, tag2))
+ sym1 = GetSymbol(LEFT_REEL, sSlotMachine->winnerRows[0] - sSlotMachine->reelExtraTurns[0]);
+ sym2 = GetSymbol(MIDDLE_REEL, sSlotMachine->winnerRows[1] - sSlotMachine->reelExtraTurns[1]);
+
+ // If the first two 7's are opposite colors, try advancing up to 4
+ // additional turns to line up a diagonal 7 mismatch. More turns may be
+ // added further below.
+ if (MismatchedSyms_77(sym1, sym2))
{
- j = 1;
+ row = 1;
if (sSlotMachine->winnerRows[0] == 1)
- j = 3;
- for (i = 0; i < 5; i++)
+ row = 3;
+ for (i = 0; i <= MAX_EXTRA_TURNS; i++)
{
- tag3 = GetTag(RIGHT_REEL, j - (sSlotMachine->reelExtraTurns[2] + i));
- if (tag1 == tag3)
+ sym3 = GetSymbol(RIGHT_REEL, row - (sSlotMachine->reelExtraTurns[2] + i));
+ if (sym1 == sym3)
{
sSlotMachine->reelExtraTurns[2] += i;
break;
@@ -2691,21 +3157,27 @@ static void DecideReelTurns_NoBiasTag_Reel3_Bet3(void)
}
}
}
- while (1)
+
+ while (TRUE)
{
- tag1 = GetTag(LEFT_REEL, 1 - sSlotMachine->reelExtraTurns[0]);
- tag2 = GetTag(MIDDLE_REEL, 2 - sSlotMachine->reelExtraTurns[1]);
- tag3 = GetTag(RIGHT_REEL, 3 - sSlotMachine->reelExtraTurns[2]);
- if (TagsDontMatchOrHaveAny7s(tag1, tag2, tag3) || (AreTagsMixed777(tag1, tag2, tag3) && sSlotMachine->luckyFlags & LUCKY_BIAS_777))
+ // Check NWSE diagonal
+ sym1 = GetSymbol(LEFT_REEL, 1 - sSlotMachine->reelExtraTurns[0]);
+ sym2 = GetSymbol(MIDDLE_REEL, 2 - sSlotMachine->reelExtraTurns[1]);
+ sym3 = GetSymbol(RIGHT_REEL, 3 - sSlotMachine->reelExtraTurns[2]);
+ if (NeitherMatchNor7Mismatch(sym1, sym2, sym3)
+ || (MismatchedSyms_777(sym1, sym2, sym3) && sSlotMachine->machineBias & BIAS_STRAIGHT_7))
break;
sSlotMachine->reelExtraTurns[2]++;
}
- while (1)
+
+ while (TRUE)
{
- tag1 = GetTag(LEFT_REEL, 3 - sSlotMachine->reelExtraTurns[0]);
- tag2 = GetTag(MIDDLE_REEL, 2 - sSlotMachine->reelExtraTurns[1]);
- tag3 = GetTag(RIGHT_REEL, 1 - sSlotMachine->reelExtraTurns[2]);
- if (TagsDontMatchOrHaveAny7s(tag1, tag2, tag3) || (AreTagsMixed777(tag1, tag2, tag3) && sSlotMachine->luckyFlags & LUCKY_BIAS_777))
+ // Check NESW diagonal
+ sym1 = GetSymbol(LEFT_REEL, 3 - sSlotMachine->reelExtraTurns[0]);
+ sym2 = GetSymbol(MIDDLE_REEL, 2 - sSlotMachine->reelExtraTurns[1]);
+ sym3 = GetSymbol(RIGHT_REEL, 1 - sSlotMachine->reelExtraTurns[2]);
+ if (NeitherMatchNor7Mismatch(sym1, sym2, sym3)
+ || (MismatchedSyms_777(sym1, sym2, sym3) && sSlotMachine->machineBias & BIAS_STRAIGHT_7))
break;
sSlotMachine->reelExtraTurns[2]++;
}
@@ -2720,7 +3192,7 @@ static void PressStopReelButton(u8 reelNum)
static void Task_PressStopReelButton(u8 taskId)
{
- sReelStopButtonFuncs[gTasks[taskId].data[0]](&gTasks[taskId], taskId);
+ sReelStopButtonTasks[gTasks[taskId].data[0]](&gTasks[taskId], taskId);
}
static void StopReelButton_Press(struct Task *task, u8 taskId)
@@ -2926,11 +3398,11 @@ static void CreatePikaPowerBoltTask(void)
sSlotMachine->pikaPowerBoltTaskId = CreateTask(Task_CreatePikaPowerBolt, 8);
}
-static void AddPikaPowerBolt(u8 pikaPower)
+static void AddPikaPowerBolt(u8 bolts)
{
struct Task *task = &gTasks[sSlotMachine->pikaPowerBoltTaskId];
ResetPikaPowerBoltTask(task);
- task->tState = 1;
+ task->tState = PIKABOLT_TASK_ADD_BOLT;
task->tNumBolts++;
task->tAnimating = TRUE;
}
@@ -2939,7 +3411,7 @@ static void ResetPikaPowerBolts(void)
{
struct Task *task = &gTasks[sSlotMachine->pikaPowerBoltTaskId];
ResetPikaPowerBoltTask(task);
- task->tState = 3;
+ task->tState = PIKABOLT_TASK_CLEAR_ALL;
task->tAnimating = TRUE;
}
@@ -2950,7 +3422,7 @@ static bool8 IsPikaPowerBoltAnimating(void)
static void Task_CreatePikaPowerBolt(u8 taskId)
{
- sPikaPowerBoltFuncs[gTasks[taskId].tState](&gTasks[taskId]);
+ sPikaPowerBoltTasks[gTasks[taskId].tState](&gTasks[taskId]);
}
static void PikaPowerBolt_Idle(struct Task *task)
@@ -2960,7 +3432,7 @@ static void PikaPowerBolt_Idle(struct Task *task)
static void PikaPowerBolt_AddBolt(struct Task *task)
{
task->tSpriteId = CreatePikaPowerBoltSprite((task->tNumBolts << 3) + 20, 20);
- task->tState++;
+ task->tState++; // PIKABOLT_TASK_WAIT_ANIM
}
// The bolt sprite spins around as it appears
@@ -2979,7 +3451,7 @@ static void PikaPowerBolt_WaitAnim(struct Task *task)
sSelectedPikaPowerTile[r2] = sPikaPowerTileTable[r3][0];
LoadBgTilemap(2, &sSelectedPikaPowerTile[r2], 2, r5 + 0x40);
DestroyPikaPowerBoltSprite(task->tSpriteId);
- task->tState = 0;
+ task->tState = PIKABOLT_TASK_IDLE;
task->tAnimating = 0;
}
}
@@ -3003,7 +3475,7 @@ static void PikaPowerBolt_ClearAll(struct Task *task)
task->tTimer = 0;
if (task->tNumBolts == 0)
{
- task->tState = 0;
+ task->tState = PIKABOLT_TASK_IDLE;
task->tAnimating = 0;
}
}
@@ -3016,17 +3488,17 @@ static void ResetPikaPowerBoltTask(struct Task *task)
task->data[i] = 0;
}
-static void LoadPikaPowerMeter(u8 pikaPower)
+static void LoadPikaPowerMeter(u8 bolts)
{
s16 i;
s16 r3 = 0, r1 = 0;
s16 r4 = 3;
- for (i = 0; i < pikaPower; i++, r4++)
+ for (i = 0; i < bolts; i++, r4++)
{
r3 = 0, r1 = 0;
if (i == 0)
r3 = 1, r1 = 1;
- else if (i == 15) // pikaPower meter is full
+ else if (i == 15) // meter is full
r3 = 2, r1 = 2;
sSelectedPikaPowerTile[r1] = sPikaPowerTileTable[r3][0];
LoadBgTilemap(2, &sSelectedPikaPowerTile[r1], 2, r4 + 0x40);
@@ -3041,7 +3513,7 @@ static void LoadPikaPowerMeter(u8 pikaPower)
sSelectedPikaPowerTile[r1] = sPikaPowerTileTable[r3][1];
LoadBgTilemap(2, &sSelectedPikaPowerTile[r1], 2, r4 + 0x40);
}
- gTasks[sSlotMachine->pikaPowerBoltTaskId].data[1] = pikaPower;
+ gTasks[sSlotMachine->pikaPowerBoltTaskId].data[1] = bolts;
}
#undef tState
@@ -3050,7 +3522,13 @@ static void LoadPikaPowerMeter(u8 pikaPower)
#undef tTimer
#undef tAnimating
-#define tState data[0]
+#define tState data[0]
+#define tReelSpeed data[1]
+#define tTimer3 data[2]
+#define tRtReelSpeed data[4]
+#define tTimer2 data[4]
+#define tTimer1 data[5]
+#define tExplodeChecks data[6]
static void BeginReelTime(void)
{
@@ -3067,10 +3545,7 @@ static bool8 IsReelTimeTaskDone(void)
static void Task_ReelTime(u8 taskId)
{
- // task.data[1] has something to do with the threshold
- // task.data[4] says how many pixels to advance the reel
- // task.data[5] is a timer
- sReelTimeActions[gTasks[taskId].tState](&gTasks[taskId]);
+ sReelTimeTasks[gTasks[taskId].tState](&gTasks[taskId]);
}
static void ReelTime_Init(struct Task *task)
@@ -3078,10 +3553,10 @@ static void ReelTime_Init(struct Task *task)
sSlotMachine->reelTimeSpinsLeft = 0;
sSlotMachine->reeltimePixelOffset = 0;
sSlotMachine->reeltimePosition = 0;
- task->tState++;
+ task->tState++; // RT_TASK_WINDOW_ENTER
task->data[1] = 0;
task->data[2] = 30;
- task->data[4] = 1280; // reel speed
+ task->tRtReelSpeed = 1280;
gSpriteCoordOffsetX = 0;
gSpriteCoordOffsetY = 0;
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
@@ -3092,7 +3567,7 @@ static void ReelTime_Init(struct Task *task)
CreateReelTimeNumberSprites();
CreateReelTimeShadowSprites();
CreateReelTimeNumberGapSprite();
- GetReeltimeDraw();
+ GetReelTimeDraw();
StopMapMusic();
PlayNewMapMusic(MUS_ROULETTE);
}
@@ -3112,18 +3587,18 @@ static void ReelTime_WindowEnter(struct Task *task)
}
if (task->data[1] >= 200)
{
- task->tState++;
+ task->tState++; // RT_TASK_WAIT_START_PIKA
task->data[3] = 0;
}
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
}
static void ReelTime_WaitStartPikachu(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
- if (++task->data[5] >= 60)
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
+ if (++task->tTimer1 >= 60)
{
- task->tState++;
+ task->tState++; // RT_TASK_PIKA_SPEEDUP1
CreateReelTimeBoltSprites();
CreateReelTimePikachuAuraSprites();
}
@@ -3140,29 +3615,29 @@ static void ReelTime_PikachuSpeedUp1(struct Task *task)
memcpy(reelTimeBoltDelays, sReelTimeBoltDelays, sizeof(sReelTimeBoltDelays));
memcpy(pikachuAuraFlashDelays, sPikachuAuraFlashDelays, sizeof(sPikachuAuraFlashDelays));
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
// gradually slow down the reel
- task->data[4] -= 4;
- i = 4 - (task->data[4] >> 8);
+ task->tRtReelSpeed -= 4;
+ i = 4 - (task->tRtReelSpeed >> 8);
SetReelTimeBoltDelay(reelTimeBoltDelays[i]);
SetReelTimePikachuAuraFlashDelay(pikachuAuraFlashDelays[i]);
StartSpriteAnimIfDifferent(&gSprites[sSlotMachine->reelTimePikachuSpriteId], pikachuAnimIds[i]);
- // once speed goes below 256, go to next ReelTimeAction and keep the speed level
- if (task->data[4] <= 0x100)
+ // once speed goes below 256, go to next ReelTime task and keep the speed level
+ if (task->tRtReelSpeed <= 0x100)
{
- task->tState++;
- task->data[4] = 0x100;
- task->data[5] = 0;
+ task->tState++; // RT_TASK_PIKA_SPEEDUP2
+ task->tRtReelSpeed = 0x100;
+ task->tTimer1 = 0;
}
}
static void ReelTime_PikachuSpeedUp2(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
- if (++task->data[5] >= 80)
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
+ if (++task->tTimer1 >= 80)
{
- task->tState++;
- task->data[5] = 0;
+ task->tState++; // RT_TASK_WAIT_REEL
+ task->tTimer1 = 0;
SetReelTimePikachuAuraFlashDelay(2);
StartSpriteAnimIfDifferent(&gSprites[sSlotMachine->reelTimePikachuSpriteId], 3);
}
@@ -3170,83 +3645,94 @@ static void ReelTime_PikachuSpeedUp2(struct Task *task)
static void ReelTime_WaitReel(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
- task->data[4] = (u8)task->data[4] + 0x80;
- if (++task->data[5] >= 80)
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
+ task->tRtReelSpeed = (u8)task->tRtReelSpeed + 0x80;
+ if (++task->tTimer1 >= 80)
{
- task->tState++;
- task->data[5] = 0;
+ task->tState++; // RT_TASK_CHECK_EXPLODE
+ task->tTimer1 = 0;
}
}
+// Check whether the ReelTime machine should explode.
+//
+// The ReelTime machine displays 0 when this task starts. If there is a positive
+// ReelTime draw, the machine keeps spinning until it lands on that number.
+//
+// Otherwise, it checks every 40 frames whether it should explode. If so, it
+// explodes immediately. After 4 checks, the machine won't explode but continues
+// to spin until it lands on 0.
static void ReelTime_CheckExplode(struct Task *task)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
- task->data[4] = (u8)task->data[4] + 0x40;
- if (++task->data[5] >= 40)
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
+ task->tRtReelSpeed = (u8)task->tRtReelSpeed + 0x40;
+ if (++task->tTimer1 >= 40)
{
- task->data[5] = 0;
+ task->tTimer1 = 0;
if (sSlotMachine->reelTimeDraw)
{
- if (sSlotMachine->reelTimeSpinsLeft <= task->data[6])
- task->tState++;
+ if (sSlotMachine->reelTimeSpinsLeft <= task->tExplodeChecks)
+ task->tState++; // RT_TASK_LAND
}
- else if (task->data[6] > 3)
+ else if (task->tExplodeChecks > 3)
{
- task->tState++;
+ task->tState++; // RT_TASK_LAND
}
- else if (ShouldReelTimeMachineExplode(task->data[6]))
+ else if (ShouldReelTimeMachineExplode(task->tExplodeChecks))
{
- task->tState = 14; // ReelTime_ExplodeMachine
+ task->tState = RT_TASK_EXPLODE;
}
- task->data[6]++;
+ task->tExplodeChecks++;
}
}
+// Reel spins until it lands on the selected outcome.
static void ReelTime_LandOnOutcome(struct Task *task)
{
s16 reeltimePixelOffset = sSlotMachine->reeltimePixelOffset % 20;
if (reeltimePixelOffset)
{
- reeltimePixelOffset = AdvanceReeltimeReelToNextTag(task->data[4] >> 8);
- task->data[4] = (u8)task->data[4] + 0x40;
+ reeltimePixelOffset = AdvanceReeltimeReelToNextSymbol(task->tRtReelSpeed >> 8);
+ task->tRtReelSpeed = (u8)task->tRtReelSpeed + 0x40;
}
- else if (GetNearbyReelTimeTag(1) != sSlotMachine->reelTimeDraw)
+ else if (GetReelTimeSymbol(1) != sSlotMachine->reelTimeDraw)
{
- AdvanceReeltimeReel(task->data[4] >> 8);
+ AdvanceReeltimeReel(task->tRtReelSpeed >> 8);
reeltimePixelOffset = sSlotMachine->reeltimePixelOffset % 20;
- task->data[4] = (u8)task->data[4] + 0x40;
+ task->tRtReelSpeed = (u8)task->tRtReelSpeed + 0x40;
}
- if (reeltimePixelOffset == 0 && GetNearbyReelTimeTag(1) == sSlotMachine->reelTimeDraw)
+ if (reeltimePixelOffset == 0 && GetReelTimeSymbol(1) == sSlotMachine->reelTimeDraw)
{
- task->data[4] = 0; // stop moving
- task->tState++;
+ task->tRtReelSpeed = 0; // Also initializes task->tTimer2
+ task->tState++; // RT_TASK_PIKA_REACT
}
}
+// Animate Pikachu reaction. Clear any power bolts the player may have won if
+// they got a positive ReelTime draw.
static void ReelTime_PikachuReact(struct Task *task)
{
- if (++task->data[4] >= 60)
+ if (++task->tTimer2 >= 60)
{
StopMapMusic();
DestroyReelTimeBoltSprites();
DestroyReelTimePikachuAuraSprites();
- task->tState++;
+ task->tState++; // RT_TASK_WAIT_CLEAR_POWER
if(sSlotMachine->reelTimeDraw == 0)
{
- task->data[4] = 0xa0;
+ task->tTimer2 = 0xa0;
StartSpriteAnimIfDifferent(&gSprites[sSlotMachine->reelTimePikachuSpriteId], 5);
PlayFanfare(MUS_TOO_BAD);
}
else
{
- task->data[4] = 0xc0;
+ task->tTimer2 = 0xc0;
StartSpriteAnimIfDifferent(&gSprites[sSlotMachine->reelTimePikachuSpriteId], 4);
gSprites[sSlotMachine->reelTimePikachuSpriteId].animCmdIndex = 0;
- if (sSlotMachine->pikaPower)
+ if (sSlotMachine->pikaPowerBolts)
{
ResetPikaPowerBolts();
- sSlotMachine->pikaPower = 0;
+ sSlotMachine->pikaPowerBolts = 0;
}
PlayFanfare(MUS_SLOTS_WIN);
}
@@ -3255,8 +3741,8 @@ static void ReelTime_PikachuReact(struct Task *task)
static void ReelTime_WaitClearPikaPower(struct Task *task)
{
- if ((task->data[4] == 0 || --task->data[4] == 0) && !IsPikaPowerBoltAnimating())
- task->tState++;
+ if ((task->tTimer2 == 0 || --task->tTimer2 == 0) && !IsPikaPowerBoltAnimating())
+ task->tState++; // RT_TASK_CLOSE_WINDOW_SUCCESS
}
static void ReelTime_CloseWindow(struct Task *task)
@@ -3270,16 +3756,20 @@ static void ReelTime_CloseWindow(struct Task *task)
if (task->data[3] >> 3 <= 25)
ClearReelTimeWindowTilemap(r4);
else
- task->tState++;
+ task->tState++; // RT_TASK_DESTROY_SPRITES
}
+// Destroy sprites and wrap up the ReelTime task.
+//
+// If the player got a positive ReelTime draw, select the speed that the slot
+// reels will initially move at.
static void ReelTime_DestroySprites(struct Task *task)
{
sSlotMachine->reelTimeSpinsUsed = 0;
sSlotMachine->reelTimeSpinsLeft = sSlotMachine->reelTimeDraw;
gSpriteCoordOffsetX = 0;
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
- sSlotMachine->reelIncrement = 8;
+ sSlotMachine->reelSpeed = REEL_NORMAL_SPEED;
DestroyReelTimePikachuSprite();
DestroyReelTimeMachineSprites();
DestroyReelTimeShadowSprites();
@@ -3291,19 +3781,20 @@ static void ReelTime_DestroySprites(struct Task *task)
else
{
CreateDigitalDisplayScene(DIG_DISPLAY_REEL_TIME);
- task->data[1] = SlowReelSpeed();
- task->data[2] = 0;
+ task->tReelSpeed = ReelTimeSpeed();
+ task->tTimer3 = 0;
task->data[3] = 0;
- task->tState++;
+ task->tState++; // RT_TASK_SET_REEL_SPEED
}
}
-static void ReelTime_SetReelIncrement(struct Task *task)
+// Slow the slot reels down until they match the selected speed.
+static void ReelTime_SetReelSpeed(struct Task *task)
{
- if (sSlotMachine->reelIncrement == task->data[1])
- task->tState++;
- else if (sSlotMachine->reelPixelOffsets[0] % REEL_SYMBOL_HEIGHT == 0 && (++task->data[2]& 0x07) == 0)
- sSlotMachine->reelIncrement >>= 1;
+ if (sSlotMachine->reelSpeed == task->tReelSpeed)
+ task->tState++; // RT_TASK_END_SUCCESS
+ else if (sSlotMachine->reelPixelOffsets[0] % REEL_SYMBOL_HEIGHT == 0 && (++task->tTimer3 & 0x07) == 0)
+ sSlotMachine->reelSpeed >>= 1;
}
static void ReelTime_EndSuccess(struct Task *task)
@@ -3320,9 +3811,9 @@ static void ReelTime_ExplodeMachine(struct Task *task)
CreateReelTimeExplosionSprite();
gSprites[sSlotMachine->reelTimeShadowSpriteIds[0]].invisible = TRUE;
StartSpriteAnimIfDifferent(&gSprites[sSlotMachine->reelTimePikachuSpriteId], 5);
- task->tState++;
+ task->tState++; // RT_TASK_WAIT_EXPLODE
task->data[4] = 4;
- task->data[5] = 0;
+ task->tTimer1 = 0;
StopMapMusic();
PlayFanfare(MUS_TOO_BAD);
PlaySE(SE_M_EXPLOSION);
@@ -3332,9 +3823,9 @@ static void ReelTime_WaitExplode(struct Task *task)
{
gSpriteCoordOffsetY = task->data[4];
SetGpuReg(REG_OFFSET_BG1VOFS, task->data[4]);
- if (task->data[5] & 0x01)
+ if (task->tTimer1 & 0x01)
task->data[4] = -task->data[4];
- if ((++task->data[5] & 0x1f) == 0)
+ if ((++task->tTimer1 & 0x1f) == 0)
task->data[4] >>= 1;
if (task->data[4] == 0)
{
@@ -3343,8 +3834,8 @@ static void ReelTime_WaitExplode(struct Task *task)
CreateBrokenReelTimeMachineSprite();
CreateReelTimeSmokeSprite();
gSprites[sSlotMachine->reelTimeShadowSpriteIds[0]].invisible = FALSE;
- task->tState++;
- task->data[5] = 0;
+ task->tState++; // RT_TASK_WAIT_SMOKE
+ task->tTimer1 = 0;
}
}
@@ -3354,7 +3845,7 @@ static void ReelTime_WaitSmoke(struct Task *task)
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
if (IsReelTimeSmokeAnimFinished())
{
- task->tState++;
+ task->tState++; // RT_TASK_CLOSE_WINDOW_FAILURE
DestroyReelTimeSmokeSprite();
}
}
@@ -3392,28 +3883,33 @@ static void ClearReelTimeWindowTilemap(s16 a0)
}
#undef tState
+#undef tReelSpeed
+#undef tRtReelSpeed
+#undef tTimer2
+#undef tTimer1
+#undef tExplodeChecks
#define tState data[0]
// Info Box is the screen shown when Select is pressed
static void OpenInfoBox(u8 digDisplayId)
{
- u8 taskId = CreateTask(RunInfoBoxActions, 1);
+ u8 taskId = CreateTask(Task_InfoBox, 1);
gTasks[taskId].data[1] = digDisplayId;
- RunInfoBoxActions(taskId);
+ Task_InfoBox(taskId);
}
static bool8 IsInfoBoxClosed(void)
{
- if (FindTaskIdByFunc(RunInfoBoxActions) == TASK_NONE)
+ if (FindTaskIdByFunc(Task_InfoBox) == TASK_NONE)
return TRUE;
else
return FALSE;
}
-static void RunInfoBoxActions(u8 taskId)
+static void Task_InfoBox(u8 taskId)
{
- sInfoBoxActions[gTasks[taskId].tState](&gTasks[taskId]);
+ sInfoBoxTasks[gTasks[taskId].tState](&gTasks[taskId]);
}
static void InfoBox_FadeIn(struct Task *task)
@@ -3422,7 +3918,7 @@ static void InfoBox_FadeIn(struct Task *task)
task->tState++;
}
-static void InfoBox_WaitForFade(struct Task *task)
+static void InfoBox_WaitFade(struct Task *task)
{
if (!gPaletteFade.active)
task->tState++;
@@ -3446,7 +3942,7 @@ static void InfoBox_AddText(struct Task *task)
task->tState++;
}
-static void InfoBox_AwaitPlayerInput(struct Task *task)
+static void InfoBox_WaitInput(struct Task *task)
{
if (JOY_NEW(B_BUTTON | SELECT_BUTTON))
{
@@ -3474,14 +3970,14 @@ static void InfoBox_CreateDigitalDisplay(struct Task *task)
static void InfoBox_LoadPikaPowerMeter(struct Task *task)
{
- LoadPikaPowerMeter(sSlotMachine->pikaPower);
+ LoadPikaPowerMeter(sSlotMachine->pikaPowerBolts);
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB(0, 0, 0));
task->tState++;
}
static void InfoBox_FreeTask(struct Task *task)
{
- DestroyTask(FindTaskIdByFunc(RunInfoBoxActions));
+ DestroyTask(FindTaskIdByFunc(Task_InfoBox));
}
#undef tState
@@ -3572,7 +4068,7 @@ static bool8 IsDigitalDisplayAnimFinished(void)
static void Task_DigitalDisplay(u8 taskId)
{
- sDigitalDisplayActions[gTasks[taskId].data[0]](&gTasks[taskId]);
+ sDigitalDisplayTasks[gTasks[taskId].data[0]](&gTasks[taskId]);
}
static void DigitalDisplay_Idle(struct Task *task)
@@ -3601,8 +4097,8 @@ static void SpriteCB_ReelSymbol(struct Sprite *sprite)
{
sprite->data[2] = sSlotMachine->reelPixelOffsets[sprite->data[0]] + sprite->data[1];
sprite->data[2] %= 120;
- sprite->y = sSlotMachine->reelPixelOffsetsWhileStopping[sprite->data[0]] + 28 + sprite->data[2];
- sprite->sheetTileStart = GetSpriteTileStartByTag(GetTagAtRest(sprite->data[0], sprite->data[2] / 24));
+ sprite->y = sSlotMachine->reelShockOffsets[sprite->data[0]] + 28 + sprite->data[2];
+ sprite->sheetTileStart = GetSpriteTileStartByTag(GetSymbolAtRest(sprite->data[0], sprite->data[2] / 24));
SetSpriteSheetFrameTileNum(sprite);
}
@@ -3773,7 +4269,7 @@ static void SpriteCB_ReelTimeNumbers(struct Sprite *sprite)
s16 r0 = (u16)(sSlotMachine->reeltimePixelOffset + sprite->data[7]);
r0 %= 40;
sprite->y = r0 + 59;
- StartSpriteAnimIfDifferent(sprite, GetNearbyReelTimeTag(r0 / 20));
+ StartSpriteAnimIfDifferent(sprite, GetReelTimeSymbol(r0 / 20));
}
static void CreateReelTimeShadowSprites(void)
@@ -4720,90 +5216,92 @@ static void AllocDigitalDisplayGfx(void)
sImageTable_DigitalDisplay_DPad[1].size = 0x180;
}
-static const u8 sReelSymbolTileTags[NUM_REELS][SYMBOLS_PER_REEL] =
+static const u8 sReelSymbols[NUM_REELS][SYMBOLS_PER_REEL] =
{
[LEFT_REEL] = {
- GFXTAG_7_RED,
- GFXTAG_CHERRY,
- GFXTAG_AZURILL,
- GFXTAG_REPLAY,
- GFXTAG_POWER,
- GFXTAG_LOTAD,
- GFXTAG_7_BLUE,
- GFXTAG_LOTAD,
- GFXTAG_CHERRY,
- GFXTAG_POWER,
- GFXTAG_REPLAY,
- GFXTAG_AZURILL,
- GFXTAG_7_RED,
- GFXTAG_POWER,
- GFXTAG_LOTAD,
- GFXTAG_REPLAY,
- GFXTAG_AZURILL,
- GFXTAG_7_BLUE,
- GFXTAG_POWER,
- GFXTAG_LOTAD,
- GFXTAG_REPLAY
+ SYMBOL_7_RED,
+ SYMBOL_CHERRY,
+ SYMBOL_AZURILL,
+ SYMBOL_REPLAY,
+ SYMBOL_POWER,
+ SYMBOL_LOTAD,
+ SYMBOL_7_BLUE,
+ SYMBOL_LOTAD,
+ SYMBOL_CHERRY,
+ SYMBOL_POWER,
+ SYMBOL_REPLAY,
+ SYMBOL_AZURILL,
+ SYMBOL_7_RED,
+ SYMBOL_POWER,
+ SYMBOL_LOTAD,
+ SYMBOL_REPLAY,
+ SYMBOL_AZURILL,
+ SYMBOL_7_BLUE,
+ SYMBOL_POWER,
+ SYMBOL_LOTAD,
+ SYMBOL_REPLAY
},
[MIDDLE_REEL] = {
- GFXTAG_7_RED,
- GFXTAG_CHERRY,
- GFXTAG_REPLAY,
- GFXTAG_LOTAD,
- GFXTAG_AZURILL,
- GFXTAG_CHERRY,
- GFXTAG_REPLAY,
- GFXTAG_POWER,
- GFXTAG_POWER,
- GFXTAG_LOTAD,
- GFXTAG_7_BLUE,
- GFXTAG_LOTAD,
- GFXTAG_REPLAY,
- GFXTAG_CHERRY,
- GFXTAG_AZURILL,
- GFXTAG_LOTAD,
- GFXTAG_REPLAY,
- GFXTAG_CHERRY,
- GFXTAG_LOTAD,
- GFXTAG_REPLAY,
- GFXTAG_CHERRY
+ SYMBOL_7_RED,
+ SYMBOL_CHERRY,
+ SYMBOL_REPLAY,
+ SYMBOL_LOTAD,
+ SYMBOL_AZURILL,
+ SYMBOL_CHERRY,
+ SYMBOL_REPLAY,
+ SYMBOL_POWER,
+ SYMBOL_POWER,
+ SYMBOL_LOTAD,
+ SYMBOL_7_BLUE,
+ SYMBOL_LOTAD,
+ SYMBOL_REPLAY,
+ SYMBOL_CHERRY,
+ SYMBOL_AZURILL,
+ SYMBOL_LOTAD,
+ SYMBOL_REPLAY,
+ SYMBOL_CHERRY,
+ SYMBOL_LOTAD,
+ SYMBOL_REPLAY,
+ SYMBOL_CHERRY
},
[RIGHT_REEL] = {
- GFXTAG_7_RED,
- GFXTAG_POWER,
- GFXTAG_7_BLUE,
- GFXTAG_REPLAY,
- GFXTAG_LOTAD,
- GFXTAG_AZURILL,
- GFXTAG_REPLAY,
- GFXTAG_LOTAD,
- GFXTAG_POWER,
- GFXTAG_AZURILL,
- GFXTAG_REPLAY,
- GFXTAG_LOTAD,
- GFXTAG_AZURILL,
- GFXTAG_POWER,
- GFXTAG_REPLAY,
- GFXTAG_LOTAD,
- GFXTAG_AZURILL,
- GFXTAG_POWER,
- GFXTAG_REPLAY,
- GFXTAG_LOTAD,
- GFXTAG_CHERRY
+ SYMBOL_7_RED,
+ SYMBOL_POWER,
+ SYMBOL_7_BLUE,
+ SYMBOL_REPLAY,
+ SYMBOL_LOTAD,
+ SYMBOL_AZURILL,
+ SYMBOL_REPLAY,
+ SYMBOL_LOTAD,
+ SYMBOL_POWER,
+ SYMBOL_AZURILL,
+ SYMBOL_REPLAY,
+ SYMBOL_LOTAD,
+ SYMBOL_AZURILL,
+ SYMBOL_POWER,
+ SYMBOL_REPLAY,
+ SYMBOL_LOTAD,
+ SYMBOL_AZURILL,
+ SYMBOL_POWER,
+ SYMBOL_REPLAY,
+ SYMBOL_LOTAD,
+ SYMBOL_CHERRY
},
};
-static const u8 sReelTimeTags[] = {
+static const u8 sReelTimeSymbols[] = {
1, 0, 5, 4, 3, 2
};
+// Column 0: Normal game
+// Column 1: Lucky game
static const s16 sInitialReelPositions[NUM_REELS][2] = {
[LEFT_REEL] = {0, 6},
[MIDDLE_REEL] = {0, 10},
[RIGHT_REEL] = {0, 2}
};
-static const u8 sLuckyRoundProbabilities[NUM_SLOT_MACHINE_IDS][MAX_BET] = {
+static const u8 sSpecialDrawOdds[NUM_SLOT_MACHINE_IDS][MAX_BET] = {
[SLOT_MACHINE_UNLUCKIEST] = {1, 1, 12},
[SLOT_MACHINE_UNLUCKIER] = {1, 1, 14},
[SLOT_MACHINE_UNLUCKY] = {2, 2, 14},
@@ -4812,8 +5310,9 @@ static const u8 sLuckyRoundProbabilities[NUM_SLOT_MACHINE_IDS][MAX_BET] = {
[SLOT_MACHINE_LUCKIEST] = {3, 3, 16}
};
-static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS] = {
- { // Probabilities for LUCKY_BIAS_777
+static const u8 sBiasProbabilities_Special[][NUM_SLOT_MACHINE_IDS] = {
+ {
+ // Probabilities for BIAS_STRAIGHT_7
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 30,
@@ -4821,7 +5320,8 @@ static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS] = {
[SLOT_MACHINE_LUCKIER] = 40,
[SLOT_MACHINE_LUCKIEST] = 50
},
- { // Probabilities for LUCKY_BIAS_REELTIME
+ {
+ // Probabilities for BIAS_REELTIME
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 30,
@@ -4829,7 +5329,8 @@ static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS] = {
[SLOT_MACHINE_LUCKIER] = 35,
[SLOT_MACHINE_LUCKIEST] = 35
},
- { // Probabilities for LUCKY_BIAS_MIXED_777
+ {
+ // Probabilities for BIAS_MIXED_7
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 30,
@@ -4839,8 +5340,9 @@ static const u8 sLuckyFlagProbabilities_Top3[][NUM_SLOT_MACHINE_IDS] = {
}
};
-static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
- { // Probabilities for LUCKY_BIAS_POWER
+static const u8 sBiasProbabilities_Regular[][NUM_SLOT_MACHINE_IDS] = {
+ {
+ // Probabilities for BIAS_POWER
[SLOT_MACHINE_UNLUCKIEST] = 20,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 25,
@@ -4848,7 +5350,8 @@ static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
[SLOT_MACHINE_LUCKIER] = 25,
[SLOT_MACHINE_LUCKIEST] = 25
},
- { // Probabilities for LUCKY_BIAS_AZURILL
+ {
+ // Probabilities for BIAS_AZURILL
[SLOT_MACHINE_UNLUCKIEST] = 12,
[SLOT_MACHINE_UNLUCKIER] = 15,
[SLOT_MACHINE_UNLUCKY] = 15,
@@ -4856,7 +5359,8 @@ static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
[SLOT_MACHINE_LUCKIER] = 19,
[SLOT_MACHINE_LUCKIEST] = 22
},
- { // Probabilities for LUCKY_BIAS_LOTAD
+ {
+ // Probabilities for BIAS_LOTAD
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 25,
@@ -4864,7 +5368,8 @@ static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
[SLOT_MACHINE_LUCKIER] = 30,
[SLOT_MACHINE_LUCKIEST] = 40
},
- { // Probabilities for LUCKY_BIAS_CHERRY
+ {
+ // Probabilities for BIAS_CHERRY
[SLOT_MACHINE_UNLUCKIEST] = 25,
[SLOT_MACHINE_UNLUCKIER] = 25,
[SLOT_MACHINE_UNLUCKY] = 20,
@@ -4872,7 +5377,8 @@ static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
[SLOT_MACHINE_LUCKIER] = 15,
[SLOT_MACHINE_LUCKIEST] = 15
},
- { // Probabilities for LUCKY_BIAS_REPLAY
+ {
+ // Probabilities for BIAS_REPLAY
[SLOT_MACHINE_UNLUCKIEST] = 40,
[SLOT_MACHINE_UNLUCKIER] = 40,
[SLOT_MACHINE_UNLUCKY] = 35,
@@ -4882,29 +5388,61 @@ static const u8 sLuckyFlagProbabilities_NotTop3[][NUM_SLOT_MACHINE_IDS] = {
}
};
-static const u8 sReeltimeProbabilities_UnluckyGame[][17] = {
- {243, 243, 243, 80, 80, 80, 80, 40, 40, 40, 40, 40, 40, 5, 5, 5, 5},
- { 5, 5, 5, 150, 150, 150, 150, 130, 130, 130, 130, 130, 130, 100, 100, 100, 5},
- { 4, 4, 4, 20, 20, 20, 20, 80, 80, 80, 80, 80, 80, 100, 100, 100, 40},
- { 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 45, 45, 45, 100},
- { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 5, 100},
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6}
-};
-
+// INTENTION:
+// As you get more Power bolts, the odds of getting higher yields (3+ spins)
+// increases modestly. There's a high chance of getting at least 1 spin, which
+// will clear your Power bolts.
+//
+// NOTE: The way these probabilities are drawn significantly skews the odds
+// toward drawing 0 spins:
+//
+// | Up to N bolts | Prob intended | Prob actual |
+// |---------------|---------------|-------------|
+// | 2 | 94% | 99% |
+// | 6 | 31% | 57% |
+// | 12 | 16% | 44% |
+// | 15 | 2% | 31% |
+// | 16 | 2% | 31% |
+static const u8 sReelTimeProbabilities_NormalGame[][17] = {
+ {243, 243, 243, 80, 80, 80, 80, 40, 40, 40, 40, 40, 40, 5, 5, 5, 5}, // 0 spins
+ { 5, 5, 5, 150, 150, 150, 150, 130, 130, 130, 130, 130, 130, 100, 100, 100, 5}, // 1 spin
+ { 4, 4, 4, 20, 20, 20, 20, 80, 80, 80, 80, 80, 80, 100, 100, 100, 40}, // 2 spins
+ { 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 45, 45, 45, 100}, // 3 spins
+ { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 5, 100}, // 4 spins
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6} // 5 spins
+};
+
+// INTENTION:
+// As you get more Power bolts, the odds of getting higher yields (3+ spins)
+// increases substantially. There is always a high chance of getting no spins,
+// which lets you keep your Power bolts.
+//
+// NOTE: The way these probabilities are drawn significantly skews the odds
+// toward drawing 0 spins:
+//
+// | Up to N bolts | Prob intended | Prob actual |
+// |---------------|---------------|-------------|
+// | 2 | 94% | 99% |
+// | 6 | 78% | 96% |
+// | 12 | 63% | 88% |
+// | 15 | 27% | 58% |
+// | 16 | 2% | 33% |
static const u8 sReelTimeProbabilities_LuckyGame[][17] = {
- { 243, 243, 243, 200, 200, 200, 200, 160, 160, 160, 160, 160, 160, 70, 70, 70, 5},
- { 5, 5, 5, 25, 25, 25, 25, 5, 5, 5, 5, 5, 5, 2, 2, 2, 6},
- { 4, 4, 4, 25, 25, 25, 25, 30, 30, 30, 30, 30, 30, 40, 40, 40, 35},
- { 2, 2, 2, 3, 3, 3, 3, 30, 30, 30, 30, 30, 30, 100, 100, 100, 50},
- { 1, 1, 1, 2, 2, 2, 2, 30, 30, 30, 30, 30, 30, 40, 40, 40, 100},
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 60}
+ { 243, 243, 243, 200, 200, 200, 200, 160, 160, 160, 160, 160, 160, 70, 70, 70, 5}, // 0 spins
+ { 5, 5, 5, 25, 25, 25, 25, 5, 5, 5, 5, 5, 5, 2, 2, 2, 6}, // 1 spin
+ { 4, 4, 4, 25, 25, 25, 25, 30, 30, 30, 30, 30, 30, 40, 40, 40, 35}, // 2 spins
+ { 2, 2, 2, 3, 3, 3, 3, 30, 30, 30, 30, 30, 30, 100, 100, 100, 50}, // 3 spins
+ { 1, 1, 1, 2, 2, 2, 2, 30, 30, 30, 30, 30, 30, 40, 40, 40, 100}, // 4 spins
+ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 60} // 5 spins
};
static const u16 sReelTimeExplodeProbability[] = {
128, 175, 200, 225, 256
};
-static const u16 sReelIncrementTable[][2] = {
+// Column 0: Probability of half-speed
+// Column 1: Base probability of quarter-speed
+static const u16 sReelTimeSpeed_Probabilities[][2] = {
{10, 5},
{10, 10},
{10, 15},
@@ -4912,55 +5450,62 @@ static const u16 sReelIncrementTable[][2] = {
{10, 35}
};
-static const u16 sReelTimeBonusIncrementTable[] = {
+// Boosted odds of quarter speed during ReelTime
+static const u16 sQuarterSpeed_ProbabilityBoost[] = {
0, 5, 10, 15, 20
};
-// tentative name
-static const u8 sBiasTags[] = {
- GFXTAG_REPLAY, GFXTAG_CHERRY, GFXTAG_LOTAD, GFXTAG_AZURILL, GFXTAG_POWER, GFXTAG_7_RED, GFXTAG_7_RED, GFXTAG_7_RED
+static const u8 sBiasSymbols[] = {
+ SYMBOL_REPLAY, // BIAS_REPLAY
+ SYMBOL_CHERRY, // BIAS_CHERRY
+ SYMBOL_LOTAD, // BIAS_LOTAD
+ SYMBOL_AZURILL, // BIAS_AZURILL
+ SYMBOL_POWER, // BIAS_POWER
+ SYMBOL_7_RED, // BIAS_REELTIME
+ SYMBOL_7_RED, // BIAS_MIXED_7
+ SYMBOL_7_RED // BIAS_STRAIGHT_7
};
-static const u16 sLuckyFlagSettings_Top3[] = {
- LUCKY_BIAS_777, LUCKY_BIAS_REELTIME, LUCKY_BIAS_MIXED_777
+static const u16 sBiasesSpecial[] = {
+ BIAS_STRAIGHT_7, BIAS_REELTIME, BIAS_MIXED_7
};
-static const u16 sLuckyFlagSettings_NotTop3[] = {
- LUCKY_BIAS_POWER, LUCKY_BIAS_AZURILL, LUCKY_BIAS_LOTAD, LUCKY_BIAS_CHERRY, LUCKY_BIAS_REPLAY
+static const u16 sBiasesRegular[] = {
+ BIAS_POWER, BIAS_AZURILL, BIAS_LOTAD, BIAS_CHERRY, BIAS_REPLAY
};
-static const u8 sSymToMatch[] = {
- [GFXTAG_7_RED] = MATCHED_777_RED,
- [GFXTAG_7_BLUE] = MATCHED_777_BLUE,
- [GFXTAG_AZURILL] = MATCHED_AZURILL,
- [GFXTAG_LOTAD] = MATCHED_LOTAD,
- [GFXTAG_CHERRY] = MATCHED_1CHERRY,
- [GFXTAG_POWER] = MATCHED_POWER,
- [GFXTAG_REPLAY] = MATCHED_REPLAY
+static const u8 sSymbolToMatch[] = {
+ [SYMBOL_7_RED] = MATCH_RED_7,
+ [SYMBOL_7_BLUE] = MATCH_BLUE_7,
+ [SYMBOL_AZURILL] = MATCH_AZURILL,
+ [SYMBOL_LOTAD] = MATCH_LOTAD,
+ [SYMBOL_CHERRY] = MATCH_CHERRY,
+ [SYMBOL_POWER] = MATCH_POWER,
+ [SYMBOL_REPLAY] = MATCH_REPLAY
};
static const u16 sSlotMatchFlags[] = {
- [MATCHED_1CHERRY] = 1 << MATCHED_1CHERRY,
- [MATCHED_2CHERRY] = 1 << MATCHED_2CHERRY,
- [MATCHED_REPLAY] = 1 << MATCHED_REPLAY,
- [MATCHED_LOTAD] = 1 << MATCHED_LOTAD,
- [MATCHED_AZURILL] = 1 << MATCHED_AZURILL,
- [MATCHED_POWER] = 1 << MATCHED_POWER,
- [MATCHED_777_MIXED] = 1 << MATCHED_777_MIXED,
- [MATCHED_777_RED] = 1 << MATCHED_777_RED,
- [MATCHED_777_BLUE] = 1 << MATCHED_777_BLUE
+ [MATCH_CHERRY] = 1 << MATCH_CHERRY,
+ [MATCH_TOPBOT_CHERRY] = 1 << MATCH_TOPBOT_CHERRY,
+ [MATCH_REPLAY] = 1 << MATCH_REPLAY,
+ [MATCH_LOTAD] = 1 << MATCH_LOTAD,
+ [MATCH_AZURILL] = 1 << MATCH_AZURILL,
+ [MATCH_POWER] = 1 << MATCH_POWER,
+ [MATCH_MIXED_7] = 1 << MATCH_MIXED_7,
+ [MATCH_RED_7] = 1 << MATCH_RED_7,
+ [MATCH_BLUE_7] = 1 << MATCH_BLUE_7
};
static const u16 sSlotPayouts[] = {
- [MATCHED_1CHERRY] = 2,
- [MATCHED_2CHERRY] = 4,
- [MATCHED_REPLAY] = 0,
- [MATCHED_LOTAD] = 6,
- [MATCHED_AZURILL] = 12,
- [MATCHED_POWER] = 3,
- [MATCHED_777_MIXED] = 90,
- [MATCHED_777_RED] = 300,
- [MATCHED_777_BLUE] = 300
+ [MATCH_CHERRY] = 2,
+ [MATCH_TOPBOT_CHERRY] = 4,
+ [MATCH_REPLAY] = 0,
+ [MATCH_LOTAD] = 6,
+ [MATCH_AZURILL] = 12,
+ [MATCH_POWER] = 3,
+ [MATCH_MIXED_7] = 90,
+ [MATCH_RED_7] = 300,
+ [MATCH_BLUE_7] = 300
};
static const s16 sDigitalDisplay_SpriteCoords[][2] = {
@@ -7203,8 +7748,8 @@ static const u8 sMatchLinePalOffsets[NUM_MATCH_LINES] = {
static const u8 sBetToMatchLineIds[MAX_BET][2] =
{
{MATCH_MIDDLE_ROW, MATCH_MIDDLE_ROW}, // Bet 1
- {MATCH_TOP_ROW, MATCH_BOTTOM_ROW}, // Bet 2
- {MATCH_NWSE_DIAG, MATCH_NESW_DIAG}, // Bet 3
+ {MATCH_TOP_ROW, MATCH_BOTTOM_ROW}, // Bet 2
+ {MATCH_NWSE_DIAG, MATCH_NESW_DIAG}, // Bet 3
};
static const u8 sMatchLinesPerBet[MAX_BET] = { 1, 2, 2 };
diff --git a/src/trainer_hill.c b/src/trainer_hill.c
index 8d5be0116..39c6202a0 100644
--- a/src/trainer_hill.c
+++ b/src/trainer_hill.c
@@ -677,9 +677,9 @@ static u16 GetMetatileForFloor(u8 floorId, u32 x, u32 y, u32 stride) // stride i
impassable = (sHillData->floors[floorId].display.collisionData[y] >> (15 - x) & 1);
metatile = sHillData->floors[floorId].display.metatileData[stride * y + x] + NUM_METATILES_IN_PRIMARY;
- elevation = 3 << METATILE_ELEVATION_SHIFT;
+ elevation = 3 << MAPGRID_ELEVATION_SHIFT;
- return ((impassable << METATILE_COLLISION_SHIFT) & METATILE_COLLISION_MASK) | elevation | (metatile & METATILE_ID_MASK);
+ return ((impassable << MAPGRID_COLLISION_SHIFT) & MAPGRID_COLLISION_MASK) | elevation | (metatile & MAPGRID_METATILE_ID_MASK);
}
void GenerateTrainerHillFloorLayout(u16 *mapArg)
diff --git a/src/trainer_see.c b/src/trainer_see.c
index 07021a316..dc6c3b917 100644
--- a/src/trainer_see.c
+++ b/src/trainer_see.c
@@ -367,8 +367,6 @@ static u8 GetTrainerApproachDistanceEast(struct ObjectEvent *trainerObj, s16 ran
return 0;
}
-#define COLLISION_MASK (~1)
-
static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 approachDistance, u8 direction)
{
s16 x, y;
@@ -385,8 +383,9 @@ static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 ap
MoveCoords(direction, &x, &y);
for (i = 0; i < approachDistance - 1; i++, MoveCoords(direction, &x, &y))
{
+ // Check for collisions on approach, ignoring the "out of range" collision for regular movement
collision = GetCollisionFlagsAtCoords(trainerObj, x, y, direction);
- if (collision != 0 && (collision & COLLISION_MASK))
+ if (collision != 0 && (collision & ~(1 << (COLLISION_OUTSIDE_RANGE - 1))))
return 0;
}
diff --git a/src/tv.c b/src/tv.c
index 710b98968..b9d064026 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -852,7 +852,7 @@ void UpdateTVScreensOnMap(int width, int height)
}
}
-static void SetTVMetatilesOnMap(int width, int height, u16 tileId)
+static void SetTVMetatilesOnMap(int width, int height, u16 metatileId)
{
int x;
int y;
@@ -862,7 +862,7 @@ static void SetTVMetatilesOnMap(int width, int height, u16 tileId)
for (x = 0; x < width; x++)
{
if (MapGridGetMetatileBehaviorAt(x, y) == MB_TELEVISION)
- MapGridSetMetatileIdAt(x, y, tileId | METATILE_COLLISION_MASK);
+ MapGridSetMetatileIdAt(x, y, metatileId | MAPGRID_COLLISION_MASK);
}
}
}