Misc cleanup

This commit is contained in:
GriffinR
2022-01-04 10:09:42 -05:00
parent 84925a892b
commit ce55e58ad8
11 changed files with 95 additions and 109 deletions
+2 -3
View File
@@ -604,9 +604,8 @@
.endm .endm
@ Blocks script execution until the movements being applied to the specified (localId) object finish. @ Blocks script execution until the movements being applied to the specified (localId) object finish.
@ If the specified object is 0, then the command will block script execution until all objects @ If localId is 0, then the id of the last-moved object will be used instead. If the specified object
@ affected by applymovement finish their movements. If the specified object is not currently being @ is not currently being manipulated with applymovement, then this command does nothing.
@ manipulated with applymovement, then this command does nothing.
@ If no map is specified, then the current map is used. @ If no map is specified, then the current map is used.
.macro waitmovement localId:req, map .macro waitmovement localId:req, map
.ifb \map .ifb \map
+6 -6
View File
@@ -80,16 +80,16 @@ gScriptCmdTable::
.4byte ScrCmd_checkdecor @ 0x4d .4byte ScrCmd_checkdecor @ 0x4d
.4byte ScrCmd_checkdecorspace @ 0x4e .4byte ScrCmd_checkdecorspace @ 0x4e
.4byte ScrCmd_applymovement @ 0x4f .4byte ScrCmd_applymovement @ 0x4f
.4byte ScrCmd_applymovement_at @ 0x50 .4byte ScrCmd_applymovementat @ 0x50
.4byte ScrCmd_waitmovement @ 0x51 .4byte ScrCmd_waitmovement @ 0x51
.4byte ScrCmd_waitmovement_at @ 0x52 .4byte ScrCmd_waitmovementat @ 0x52
.4byte ScrCmd_removeobject @ 0x53 .4byte ScrCmd_removeobject @ 0x53
.4byte ScrCmd_removeobject_at @ 0x54 .4byte ScrCmd_removeobjectat @ 0x54
.4byte ScrCmd_addobject @ 0x55 .4byte ScrCmd_addobject @ 0x55
.4byte ScrCmd_addobject_at @ 0x56 .4byte ScrCmd_addobjectat @ 0x56
.4byte ScrCmd_setobjectxy @ 0x57 .4byte ScrCmd_setobjectxy @ 0x57
.4byte ScrCmd_showobject_at @ 0x58 .4byte ScrCmd_showobjectat @ 0x58
.4byte ScrCmd_hideobject_at @ 0x59 .4byte ScrCmd_hideobjectat @ 0x59
.4byte ScrCmd_faceplayer @ 0x5a .4byte ScrCmd_faceplayer @ 0x5a
.4byte ScrCmd_turnobject @ 0x5b .4byte ScrCmd_turnobject @ 0x5b
.4byte ScrCmd_trainerbattle @ 0x5c .4byte ScrCmd_trainerbattle @ 0x5c
+5 -5
View File
@@ -17,11 +17,11 @@ struct BikeHistoryInputInfo
// Player speeds // Player speeds
enum enum
{ {
BIKE_SPEED_STANDING, PLAYER_SPEED_STANDING,
BIKE_SPEED_NORMAL, PLAYER_SPEED_NORMAL,
BIKE_SPEED_FAST, PLAYER_SPEED_FAST,
BIKE_SPEED_FASTER, PLAYER_SPEED_FASTER,
BIKE_SPEED_FASTEST, PLAYER_SPEED_FASTEST,
}; };
// mach bike transitions enum // mach bike transitions enum
+13 -13
View File
@@ -108,7 +108,7 @@ static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) =
}; };
// used with bikeFrameCounter from mach bike // used with bikeFrameCounter from mach bike
static const u16 sMachBikeSpeeds[] = {BIKE_SPEED_NORMAL, BIKE_SPEED_FAST, BIKE_SPEED_FASTEST}; static const u16 sMachBikeSpeeds[] = {PLAYER_SPEED_NORMAL, PLAYER_SPEED_FAST, PLAYER_SPEED_FASTEST};
// this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list. // this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list.
static const u8 sAcroBikeJumpTimerList[] = {4, 0}; static const u8 sAcroBikeJumpTimerList[] = {4, 0};
@@ -147,7 +147,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
if (*dirTraveling == 0) if (*dirTraveling == 0)
{ {
*dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving. *dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving.
if (gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING) if (gPlayerAvatar.bikeSpeed == PLAYER_SPEED_STANDING)
{ {
gPlayerAvatar.runningState = NOT_MOVING; gPlayerAvatar.runningState = NOT_MOVING;
return MACH_TRANS_FACE_DIRECTION; return MACH_TRANS_FACE_DIRECTION;
@@ -159,7 +159,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
// we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check. // we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check.
if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING) if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING)
{ {
if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING) if (gPlayerAvatar.bikeSpeed != PLAYER_SPEED_STANDING)
{ {
*dirTraveling = direction; // implement the new direction *dirTraveling = direction; // implement the new direction
gPlayerAvatar.runningState = MOVING; gPlayerAvatar.runningState = MOVING;
@@ -246,7 +246,7 @@ static void MachBikeTransition_TrySlowDown(u8 direction)
{ {
u8 collision; u8 collision;
if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING) if (gPlayerAvatar.bikeSpeed != PLAYER_SPEED_STANDING)
gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed; gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
collision = GetBikeCollision(direction); collision = GetBikeCollision(direction);
@@ -306,7 +306,7 @@ static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys)
return ACRO_TRANS_FACE_DIRECTION; return ACRO_TRANS_FACE_DIRECTION;
} }
} }
if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING) if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == PLAYER_SPEED_STANDING)
{ {
gPlayerAvatar.bikeSpeed++; gPlayerAvatar.bikeSpeed++;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
@@ -342,7 +342,7 @@ static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys
if (*newDirection == AcroBike_GetJumpDirection()) if (*newDirection == AcroBike_GetJumpDirection())
{ {
Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump. Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump.
gPlayerAvatar.bikeSpeed = BIKE_SPEED_NORMAL; gPlayerAvatar.bikeSpeed = PLAYER_SPEED_NORMAL;
if (*newDirection == GetOppositeDirection(direction)) if (*newDirection == GetOppositeDirection(direction))
{ {
// do a turn jump. // do a turn jump.
@@ -775,7 +775,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u
else else
{ {
Bike_UpdateDirTimerHistory(direction); Bike_UpdateDirTimerHistory(direction);
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; gPlayerAvatar.bikeSpeed = PLAYER_SPEED_STANDING;
} }
direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason. direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason.
@@ -787,7 +787,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u
else else
{ {
Bike_UpdateABStartSelectHistory(direction); Bike_UpdateABStartSelectHistory(direction);
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; gPlayerAvatar.bikeSpeed = PLAYER_SPEED_STANDING;
} }
} }
@@ -994,7 +994,7 @@ void BikeClearState(int newDirHistory, int newAbStartHistory)
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
gPlayerAvatar.newDirBackup = DIR_NONE; gPlayerAvatar.newDirBackup = DIR_NONE;
gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeFrameCounter = 0;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; gPlayerAvatar.bikeSpeed = PLAYER_SPEED_STANDING;
gPlayerAvatar.directionHistory = newDirHistory; gPlayerAvatar.directionHistory = newDirHistory;
gPlayerAvatar.abStartSelectHistory = newAbStartHistory; gPlayerAvatar.abStartSelectHistory = newAbStartHistory;
@@ -1014,7 +1014,7 @@ void Bike_UpdateBikeCounterSpeed(u8 counter)
static void Bike_SetBikeStill(void) static void Bike_SetBikeStill(void)
{ {
gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeFrameCounter = 0;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; gPlayerAvatar.bikeSpeed = PLAYER_SPEED_STANDING;
} }
s16 GetPlayerSpeed(void) s16 GetPlayerSpeed(void)
@@ -1027,11 +1027,11 @@ s16 GetPlayerSpeed(void)
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE)
return machSpeeds[gPlayerAvatar.bikeFrameCounter]; return machSpeeds[gPlayerAvatar.bikeFrameCounter];
else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
return BIKE_SPEED_FASTER; return PLAYER_SPEED_FASTER;
else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH)) else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH))
return BIKE_SPEED_FAST; return PLAYER_SPEED_FAST;
else else
return BIKE_SPEED_NORMAL; return PLAYER_SPEED_NORMAL;
} }
void Bike_HandleBumpySlopeJump(void) void Bike_HandleBumpySlopeJump(void)
+1 -1
View File
@@ -94,7 +94,7 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
if ((tileTransitionState == T_TILE_CENTER && forcedMove == FALSE) || tileTransitionState == T_NOT_MOVING) if ((tileTransitionState == T_TILE_CENTER && forcedMove == FALSE) || tileTransitionState == T_NOT_MOVING)
{ {
if (GetPlayerSpeed() != 4) if (GetPlayerSpeed() != PLAYER_SPEED_FASTEST)
{ {
if (newKeys & START_BUTTON) if (newKeys & START_BUTTON)
input->pressedStartButton = TRUE; input->pressedStartButton = TRUE;
+1 -1
View File
@@ -557,7 +557,7 @@ static bool8 ForcedMovement_MuddySlope(void)
{ {
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
if (playerObjEvent->movementDirection != DIR_NORTH || GetPlayerSpeed() <= 3) if (playerObjEvent->movementDirection != DIR_NORTH || GetPlayerSpeed() < PLAYER_SPEED_FASTEST)
{ {
Bike_UpdateBikeCounterSpeed(0); Bike_UpdateBikeCounterSpeed(0);
playerObjEvent->facingDirectionLocked = TRUE; playerObjEvent->facingDirectionLocked = TRUE;
+1 -1
View File
@@ -820,7 +820,7 @@ static void CrackedFloorPerStepCallback(u8 taskId)
tPrevY = y; tPrevY = y;
if (MetatileBehavior_IsCrackedFloor(behavior)) if (MetatileBehavior_IsCrackedFloor(behavior))
{ {
if (GetPlayerSpeed() != BIKE_SPEED_FASTEST) if (GetPlayerSpeed() != PLAYER_SPEED_FASTEST)
VarSet(VAR_ICE_STEP_COUNT, 0); // this var does double duty VarSet(VAR_ICE_STEP_COUNT, 0); // this var does double duty
if (tFloor1Delay == 0) if (tFloor1Delay == 0)
+20 -17
View File
@@ -1516,28 +1516,26 @@ static void UnhideRegionMapPlayerIcon(void)
} }
} }
#define sY data[0]
#define sX data[1]
#define sVisible data[2]
#define sTimer data[7]
static void SpriteCB_PlayerIconMapZoomed(struct Sprite *sprite) static void SpriteCB_PlayerIconMapZoomed(struct Sprite *sprite)
{ {
sprite->x2 = -2 * gRegionMap->scrollX; sprite->x2 = -2 * gRegionMap->scrollX;
sprite->y2 = -2 * gRegionMap->scrollY; sprite->y2 = -2 * gRegionMap->scrollY;
sprite->data[0] = sprite->y + sprite->y2 + sprite->centerToCornerVecY; sprite->sY = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
sprite->data[1] = sprite->x + sprite->x2 + sprite->centerToCornerVecX; sprite->sX = sprite->x + sprite->x2 + sprite->centerToCornerVecX;
if (sprite->data[0] < -8 || sprite->data[0] > 0xa8 || sprite->data[1] < -8 || sprite->data[1] > 0xf8) if (sprite->sY < -8 || sprite->sY > DISPLAY_HEIGHT + 8 || sprite->sX < -8 || sprite->sX > DISPLAY_WIDTH + 8)
{ sprite->sVisible = FALSE;
sprite->data[2] = FALSE;
}
else else
{ sprite->sVisible = TRUE;
sprite->data[2] = TRUE;
} if (sprite->sVisible == TRUE)
if (sprite->data[2] == TRUE)
{
SpriteCB_PlayerIcon(sprite); SpriteCB_PlayerIcon(sprite);
}
else else
{
sprite->invisible = TRUE; sprite->invisible = TRUE;
}
} }
static void SpriteCB_PlayerIconMapFull(struct Sprite *sprite) static void SpriteCB_PlayerIconMapFull(struct Sprite *sprite)
@@ -1549,9 +1547,9 @@ static void SpriteCB_PlayerIcon(struct Sprite *sprite)
{ {
if (gRegionMap->blinkPlayerIcon) if (gRegionMap->blinkPlayerIcon)
{ {
if (++sprite->data[7] > 16) if (++sprite->sTimer > 16)
{ {
sprite->data[7] = 0; sprite->sTimer = 0;
sprite->invisible = sprite->invisible ? FALSE : TRUE; sprite->invisible = sprite->invisible ? FALSE : TRUE;
} }
} }
@@ -1567,6 +1565,11 @@ void TrySetPlayerIconBlink(void)
gRegionMap->blinkPlayerIcon = TRUE; gRegionMap->blinkPlayerIcon = TRUE;
} }
#undef sY
#undef sX
#undef sVisible
#undef sTimer
u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength) u8 *GetMapName(u8 *dest, u16 regionMapId, u16 padLength)
{ {
u8 *str; u8 *str;
@@ -1709,7 +1712,7 @@ void CB2_OpenFlyMap(void)
gMain.state++; gMain.state++;
break; break;
case 7: case 7:
LoadPalette(sRegionMapFramePal, 0x10, 0x20); LoadPalette(sRegionMapFramePal, 0x10, sizeof(sRegionMapFramePal));
PutWindowTilemap(2); PutWindowTilemap(2);
FillWindowPixelBuffer(2, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized(2, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL); AddTextPrinterParameterized(2, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL);
+4 -8
View File
@@ -684,13 +684,11 @@ static void RotatingGate_LoadPuzzleConfig(void)
{ {
case PUZZLE_FORTREE_CITY_GYM: case PUZZLE_FORTREE_CITY_GYM:
gRotatingGate_PuzzleConfig = sRotatingGate_FortreePuzzleConfig; gRotatingGate_PuzzleConfig = sRotatingGate_FortreePuzzleConfig;
gRotatingGate_PuzzleCount = gRotatingGate_PuzzleCount = ARRAY_COUNT(sRotatingGate_FortreePuzzleConfig);
sizeof(sRotatingGate_FortreePuzzleConfig) / sizeof(struct RotatingGatePuzzle);
break; break;
case PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6: case PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6:
gRotatingGate_PuzzleConfig = sRotatingGate_TrickHousePuzzleConfig; gRotatingGate_PuzzleConfig = sRotatingGate_TrickHousePuzzleConfig;
gRotatingGate_PuzzleCount = gRotatingGate_PuzzleCount = ARRAY_COUNT(sRotatingGate_TrickHousePuzzleConfig);
sizeof(sRotatingGate_TrickHousePuzzleConfig) / sizeof(struct RotatingGatePuzzle);
break; break;
case PUZZLE_NONE: case PUZZLE_NONE:
default: default:
@@ -698,9 +696,7 @@ static void RotatingGate_LoadPuzzleConfig(void)
} }
for (i = 0; i < ROTATING_GATE_PUZZLE_MAX - 1; i++) for (i = 0; i < ROTATING_GATE_PUZZLE_MAX - 1; i++)
{
gRotatingGate_GateSpriteIds[i] = MAX_SPRITES; gRotatingGate_GateSpriteIds[i] = MAX_SPRITES;
}
} }
static void RotatingGate_CreateGatesWithinViewport(s16 deltaX, s16 deltaY) static void RotatingGate_CreateGatesWithinViewport(s16 deltaX, s16 deltaY)
@@ -773,7 +769,7 @@ static void SpriteCallback_RotatingGate(struct Sprite *sprite)
{ {
affineAnimation = orientation + 4; affineAnimation = orientation + 4;
if (GetPlayerSpeed() != 1) if (GetPlayerSpeed() != PLAYER_SPEED_NORMAL)
affineAnimation += 8; affineAnimation += 8;
PlaySE(SE_ROTATING_GATE); PlaySE(SE_ROTATING_GATE);
@@ -783,7 +779,7 @@ static void SpriteCallback_RotatingGate(struct Sprite *sprite)
{ {
affineAnimation = orientation + 8; affineAnimation = orientation + 8;
if (GetPlayerSpeed() != 1) if (GetPlayerSpeed() != PLAYER_SPEED_NORMAL)
affineAnimation += 8; affineAnimation += 8;
PlaySE(SE_ROTATING_GATE); PlaySE(SE_ROTATING_GATE);
+6 -6
View File
@@ -999,7 +999,7 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx)
return FALSE; return FALSE;
} }
bool8 ScrCmd_applymovement_at(struct ScriptContext *ctx) bool8 ScrCmd_applymovementat(struct ScriptContext *ctx)
{ {
u16 localId = VarGet(ScriptReadHalfword(ctx)); u16 localId = VarGet(ScriptReadHalfword(ctx));
const void *movementScript = (const void *)ScriptReadWord(ctx); const void *movementScript = (const void *)ScriptReadWord(ctx);
@@ -1028,7 +1028,7 @@ bool8 ScrCmd_waitmovement(struct ScriptContext *ctx)
return TRUE; return TRUE;
} }
bool8 ScrCmd_waitmovement_at(struct ScriptContext *ctx) bool8 ScrCmd_waitmovementat(struct ScriptContext *ctx)
{ {
u16 localId = VarGet(ScriptReadHalfword(ctx)); u16 localId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup; u8 mapGroup;
@@ -1052,7 +1052,7 @@ bool8 ScrCmd_removeobject(struct ScriptContext *ctx)
return FALSE; return FALSE;
} }
bool8 ScrCmd_removeobject_at(struct ScriptContext *ctx) bool8 ScrCmd_removeobjectat(struct ScriptContext *ctx)
{ {
u16 objectId = VarGet(ScriptReadHalfword(ctx)); u16 objectId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup = ScriptReadByte(ctx); u8 mapGroup = ScriptReadByte(ctx);
@@ -1070,7 +1070,7 @@ bool8 ScrCmd_addobject(struct ScriptContext *ctx)
return FALSE; return FALSE;
} }
bool8 ScrCmd_addobject_at(struct ScriptContext *ctx) bool8 ScrCmd_addobjectat(struct ScriptContext *ctx)
{ {
u16 objectId = VarGet(ScriptReadHalfword(ctx)); u16 objectId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup = ScriptReadByte(ctx); u8 mapGroup = ScriptReadByte(ctx);
@@ -1108,7 +1108,7 @@ bool8 ScrCmd_copyobjectxytoperm(struct ScriptContext *ctx)
return FALSE; return FALSE;
} }
bool8 ScrCmd_showobject_at(struct ScriptContext *ctx) bool8 ScrCmd_showobjectat(struct ScriptContext *ctx)
{ {
u16 localId = VarGet(ScriptReadHalfword(ctx)); u16 localId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup = ScriptReadByte(ctx); u8 mapGroup = ScriptReadByte(ctx);
@@ -1118,7 +1118,7 @@ bool8 ScrCmd_showobject_at(struct ScriptContext *ctx)
return FALSE; return FALSE;
} }
bool8 ScrCmd_hideobject_at(struct ScriptContext *ctx) bool8 ScrCmd_hideobjectat(struct ScriptContext *ctx)
{ {
u16 localId = VarGet(ScriptReadHalfword(ctx)); u16 localId = VarGet(ScriptReadHalfword(ctx));
u8 mapGroup = ScriptReadByte(ctx); u8 mapGroup = ScriptReadByte(ctx);
+36 -48
View File
@@ -41,6 +41,8 @@ static void SpriteCB_HourHand(struct Sprite *sprite);
static void SpriteCB_PMIndicator(struct Sprite *sprite); static void SpriteCB_PMIndicator(struct Sprite *sprite);
static void SpriteCB_AMIndicator(struct Sprite *sprite); static void SpriteCB_AMIndicator(struct Sprite *sprite);
#define sTaskId data[0]
#define tMinuteHandAngle data[0] #define tMinuteHandAngle data[0]
#define tHourHandAngle data[1] #define tHourHandAngle data[1]
#define tHours data[2] #define tHours data[2]
@@ -696,21 +698,21 @@ void CB2_StartWallClock(void)
gTasks[taskId].tHourHandAngle = 300; gTasks[taskId].tHourHandAngle = 300;
spriteId = CreateSprite(&sSpriteTemplate_MinuteHand, 120, 80, 1); spriteId = CreateSprite(&sSpriteTemplate_MinuteHand, 120, 80, 1);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 0; gSprites[spriteId].oam.matrixNum = 0;
spriteId = CreateSprite(&sSpriteTemplate_HourHand, 120, 80, 0); spriteId = CreateSprite(&sSpriteTemplate_HourHand, 120, 80, 0);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 1; gSprites[spriteId].oam.matrixNum = 1;
spriteId = CreateSprite(&sSpriteTemplate_PM, 120, 80, 2); spriteId = CreateSprite(&sSpriteTemplate_PM, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].data[1] = 45; gSprites[spriteId].data[1] = 45;
spriteId = CreateSprite(&sSpriteTemplate_AM, 120, 80, 2); spriteId = CreateSprite(&sSpriteTemplate_AM, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].data[1] = 90; gSprites[spriteId].data[1] = 90;
WallClockInit(); WallClockInit();
@@ -744,21 +746,21 @@ void CB2_ViewWallClock(void)
} }
spriteId = CreateSprite(&sSpriteTemplate_MinuteHand, 120, 80, 1); spriteId = CreateSprite(&sSpriteTemplate_MinuteHand, 120, 80, 1);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 0; gSprites[spriteId].oam.matrixNum = 0;
spriteId = CreateSprite(&sSpriteTemplate_HourHand, 120, 80, 0); spriteId = CreateSprite(&sSpriteTemplate_HourHand, 120, 80, 0);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
gSprites[spriteId].oam.matrixNum = 1; gSprites[spriteId].oam.matrixNum = 1;
spriteId = CreateSprite(&sSpriteTemplate_PM, 120, 80, 2); spriteId = CreateSprite(&sSpriteTemplate_PM, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].data[1] = angle1; gSprites[spriteId].data[1] = angle1;
spriteId = CreateSprite(&sSpriteTemplate_AM, 120, 80, 2); spriteId = CreateSprite(&sSpriteTemplate_AM, 120, 80, 2);
gSprites[spriteId].data[0] = taskId; gSprites[spriteId].sTaskId = taskId;
gSprites[spriteId].data[1] = angle2; gSprites[spriteId].data[1] = angle2;
WallClockInit(); WallClockInit();
@@ -1015,7 +1017,7 @@ static void InitClockWithRtc(u8 taskId)
static void SpriteCB_MinuteHand(struct Sprite *sprite) static void SpriteCB_MinuteHand(struct Sprite *sprite)
{ {
u16 angle = gTasks[sprite->data[0]].tMinuteHandAngle; u16 angle = gTasks[sprite->sTaskId].tMinuteHandAngle;
s16 sin = Sin2(angle) / 16; s16 sin = Sin2(angle) / 16;
s16 cos = Cos2(angle) / 16; s16 cos = Cos2(angle) / 16;
u16 x, y; u16 x, y;
@@ -1035,7 +1037,7 @@ static void SpriteCB_MinuteHand(struct Sprite *sprite)
static void SpriteCB_HourHand(struct Sprite *sprite) static void SpriteCB_HourHand(struct Sprite *sprite)
{ {
u16 angle = gTasks[sprite->data[0]].tHourHandAngle; u16 angle = gTasks[sprite->sTaskId].tHourHandAngle;
s16 sin = Sin2(angle) / 16; s16 sin = Sin2(angle) / 16;
s16 cos = Cos2(angle) / 16; s16 cos = Cos2(angle) / 16;
u16 x, y; u16 x, y;
@@ -1053,58 +1055,44 @@ static void SpriteCB_HourHand(struct Sprite *sprite)
sprite->y2 = y; sprite->y2 = y;
} }
#define sAngle data[1]
static void SpriteCB_PMIndicator(struct Sprite *sprite) static void SpriteCB_PMIndicator(struct Sprite *sprite)
{ {
if (gTasks[sprite->data[0]].tPeriod != PERIOD_AM) if (gTasks[sprite->sTaskId].tPeriod != PERIOD_AM)
{ {
if (sprite->data[1] >= 60 && sprite->data[1] < 90) if (sprite->sAngle >= 60 && sprite->sAngle < 90)
{ sprite->sAngle += 5;
sprite->data[1] += 5; if (sprite->sAngle < 60)
} sprite->sAngle++;
if (sprite->data[1] < 60)
{
sprite->data[1]++;
}
} }
else else
{ {
if (sprite->data[1] >= 46 && sprite->data[1] < 76) if (sprite->sAngle >= 46 && sprite->sAngle < 76)
{ sprite->sAngle -= 5;
sprite->data[1] -= 5; if (sprite->sAngle > 75)
} sprite->sAngle--;
if (sprite->data[1] > 75)
{
sprite->data[1]--;
}
} }
sprite->x2 = Cos2(sprite->data[1]) * 30 / 0x1000; sprite->x2 = Cos2(sprite->sAngle) * 30 / 0x1000;
sprite->y2 = Sin2(sprite->data[1]) * 30 / 0x1000; sprite->y2 = Sin2(sprite->sAngle) * 30 / 0x1000;
} }
static void SpriteCB_AMIndicator(struct Sprite *sprite) static void SpriteCB_AMIndicator(struct Sprite *sprite)
{ {
if (gTasks[sprite->data[0]].tPeriod != PERIOD_AM) if (gTasks[sprite->sTaskId].tPeriod != PERIOD_AM)
{ {
if (sprite->data[1] >= 105 && sprite->data[1] < 135) if (sprite->sAngle >= 105 && sprite->sAngle < 135)
{ sprite->sAngle += 5;
sprite->data[1] += 5; if (sprite->sAngle < 105)
} sprite->sAngle++;
if (sprite->data[1] < 105)
{
sprite->data[1]++;
}
} }
else else
{ {
if (sprite->data[1] >= 91 && sprite->data[1] < 121) if (sprite->sAngle >= 91 && sprite->sAngle < 121)
{ sprite->sAngle -= 5;
sprite->data[1] -= 5; if (sprite->sAngle > 120)
} sprite->sAngle--;
if (sprite->data[1] > 120)
{
sprite->data[1]--;
}
} }
sprite->x2 = Cos2(sprite->data[1]) * 30 / 0x1000; sprite->x2 = Cos2(sprite->sAngle) * 30 / 0x1000;
sprite->y2 = Sin2(sprite->data[1]) * 30 / 0x1000; sprite->y2 = Sin2(sprite->sAngle) * 30 / 0x1000;
} }