mirror of
https://github.com/pret/pmd-red.git
synced 2026-08-27 03:07:22 -05:00
Make pos->pixelPos conversion more readable
This commit is contained in:
@@ -19,6 +19,9 @@ typedef struct PixelPos
|
||||
/* 0x4 */ s32 y;
|
||||
} PixelPos;
|
||||
|
||||
#define X_POS_TO_PIXELPOS(x)((((x) * 24) + 12) << 8)
|
||||
#define Y_POS_TO_PIXELPOS(y)((((y) * 24) + 16) << 8)
|
||||
|
||||
/**
|
||||
* Currently only used in script data, for entities and GroundLink data.
|
||||
* DungeonPos expressed in terms of *graphics* tiles, 8 pixels per unit.
|
||||
|
||||
@@ -58,8 +58,8 @@ s32 sub_80416A4(DungeonPos *pos_1, u32 param_2, bool8 param_3)
|
||||
{
|
||||
PixelPos pos;
|
||||
|
||||
pos.x = pos_1->x * 0x1800 + 0xc00;
|
||||
pos.y = pos_1->y * 0x1800 + 0x1000;
|
||||
pos.x = X_POS_TO_PIXELPOS(pos_1->x);
|
||||
pos.y = Y_POS_TO_PIXELPOS(pos_1->y);
|
||||
return sub_80416E0(&pos, param_2, param_3);
|
||||
}
|
||||
|
||||
|
||||
@@ -892,8 +892,8 @@ bool8 UseAttack(Entity *a0)
|
||||
PixelPos pos;
|
||||
|
||||
monInfo->flags |= 0x2000;
|
||||
pos.x = (monInfo->unk184[0].previousTargetMovePosition2.x * 0x1800) + 0xC00;
|
||||
pos.y = (monInfo->unk184[0].previousTargetMovePosition2.y * 0x1800) + 0x1000;
|
||||
pos.x = X_POS_TO_PIXELPOS(monInfo->unk184[0].previousTargetMovePosition2.x);
|
||||
pos.y = Y_POS_TO_PIXELPOS(monInfo->unk184[0].previousTargetMovePosition2.y);
|
||||
sub_804535C(mon, &pos);
|
||||
sub_806CDFC(mon, 0, monInfo->unk184[0].lastMoveDirection);
|
||||
monInfo->notMoving = 0;
|
||||
@@ -929,8 +929,8 @@ bool8 UseAttack(Entity *a0)
|
||||
else {
|
||||
PixelPos pos;
|
||||
|
||||
pos.x = (monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.x * 0x1800) + 0xC00;
|
||||
pos.y = (monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.y * 0x1800) + 0x1000;
|
||||
pos.x = X_POS_TO_PIXELPOS(monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.x);
|
||||
pos.y = Y_POS_TO_PIXELPOS(monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.y);
|
||||
sub_804535C(mon, &pos);
|
||||
sub_806CDFC(mon, 0, monInfo->unk184[monInfo->notMoving].lastMoveDirection);
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ void sub_807D068(Entity *pokemon, DungeonPos *pos)
|
||||
int incrementX;
|
||||
int incrementY;
|
||||
|
||||
posX = pos->x * 0x1800 + 0xc00;
|
||||
posY = pos->y * 0x1800 + 0x1000;
|
||||
posX = X_POS_TO_PIXELPOS(pos->x);
|
||||
posY = Y_POS_TO_PIXELPOS(pos->y);
|
||||
diff = (pokemon->pixelPos).x - posX;
|
||||
if (diff < 0) {
|
||||
diff = -diff;
|
||||
|
||||
@@ -742,8 +742,8 @@ void sub_807F43C(Entity *target, Entity *attacker)
|
||||
|
||||
newDir = GetDirectionTowardsPosition(&attackerPos, &attacker->pos);
|
||||
|
||||
pixelPosX = (((attackerPos.x * 24) + 12) << 8) + ((gAdjacentTileOffsets[newDir].x << 8) / 3);
|
||||
pixelPosY = (((attackerPos.y * 24) + 16) << 8) + ((gAdjacentTileOffsets[newDir].y << 8) / 3);
|
||||
pixelPosX = X_POS_TO_PIXELPOS(attackerPos.x) + ((gAdjacentTileOffsets[newDir].x << 8) / 3);
|
||||
pixelPosY = Y_POS_TO_PIXELPOS(attackerPos.y) + ((gAdjacentTileOffsets[newDir].y << 8) / 3);
|
||||
|
||||
var_30 = (pixelPosX - attacker->pixelPos.x) / r6;
|
||||
r10 = (pixelPosY - attacker->pixelPos.y) / r6;
|
||||
|
||||
@@ -1270,12 +1270,10 @@ void MoltresScreenFlash1(s32 xArg, s32 yArg)
|
||||
s32 x, y;
|
||||
DungeonPos newPos;
|
||||
|
||||
x = (xArg * 3) << 11;
|
||||
x += 0xC00;
|
||||
x = X_POS_TO_PIXELPOS(xArg);
|
||||
newPos.x = x / 256;
|
||||
|
||||
y = (yArg * 3) << 11;
|
||||
y += 0x1000;
|
||||
y = Y_POS_TO_PIXELPOS(yArg);
|
||||
newPos.y = y / 256;
|
||||
|
||||
sub_8085EC8(370,16,0,&newPos,0);
|
||||
@@ -1287,12 +1285,10 @@ void MoltresScreenFlash2(s32 xArg, s32 yArg)
|
||||
s32 i, x, y;
|
||||
DungeonPos newPos;
|
||||
|
||||
x = (xArg * 3) << 11;
|
||||
x += 0xC00;
|
||||
x = X_POS_TO_PIXELPOS(xArg);
|
||||
newPos.x = x / 256;
|
||||
|
||||
y = (yArg * 3) << 11;
|
||||
y += 0x1000;
|
||||
y = Y_POS_TO_PIXELPOS(yArg);
|
||||
newPos.y = y / 256;
|
||||
|
||||
r6 = sub_8085EC8(370,22,0,&newPos,0);
|
||||
@@ -4102,12 +4098,10 @@ void sub_808BB3C(DungeonPos *pos1)
|
||||
s32 x, y;
|
||||
DungeonPos newPos;
|
||||
|
||||
x = (pos1->x * 3) << 11;
|
||||
x += 0xC00;
|
||||
x = X_POS_TO_PIXELPOS(pos1->x);
|
||||
newPos.x = x / 256;
|
||||
|
||||
y = (pos1->y * 3) << 11;
|
||||
y += 0x1000;
|
||||
y = Y_POS_TO_PIXELPOS(pos1->y);
|
||||
newPos.y = y / 256;
|
||||
|
||||
sub_8085EC8(100,0,0,&newPos,0);
|
||||
|
||||
@@ -2274,17 +2274,11 @@ s32 sub_8056564(Entity *entity, DungeonPos *pos, Move *move, s32 r4)
|
||||
|
||||
if (!gDungeon->unk181e8.blinded && (GetBodySize(entInfo->apparentID) < 4 || r4 != 1)) {
|
||||
s32 unk6 = sub_800ECB8(sub_80412E0(move->id, GetApparentWeather(entity), 1))->unk6;
|
||||
s32 x = (pos->x * 3 << 11);
|
||||
s32 y = (pos->y * 3 << 11);
|
||||
// This is needed for matching purposes.
|
||||
s32 y2;
|
||||
s32 pixelPosX = X_POS_TO_PIXELPOS(pos->x);
|
||||
s32 pixelPosY = Y_POS_TO_PIXELPOS(pos->y);
|
||||
|
||||
x += 0xC00;
|
||||
y += 0x1000;
|
||||
y2 = y;
|
||||
|
||||
unkSp2.x = x / 256;
|
||||
unkSp2.y = y2 / 256;
|
||||
unkSp2.x = pixelPosX / 256;
|
||||
unkSp2.y = pixelPosY / 256;
|
||||
|
||||
if (unk6 != 0) {
|
||||
s32 someRetVal;
|
||||
@@ -2422,8 +2416,8 @@ void sub_80566F8(Entity *attacker, Move *move, s32 a2, bool8 a3, s32 itemId, s32
|
||||
var_68.y += var_48;
|
||||
if (sub_803F428(&var_68) && !gDungeon->unk181e8.blinded) {
|
||||
PixelPos pos32;
|
||||
pos32.x = (var_68Before.x * 0x1800) + 0xC00;
|
||||
pos32.y = (var_68Before.y * 0x1800) + 0x1000;
|
||||
pos32.x = X_POS_TO_PIXELPOS(var_68Before.x);
|
||||
pos32.y = Y_POS_TO_PIXELPOS(var_68Before.y);
|
||||
var_28 = var_30 * (var_4C << 8);
|
||||
var_24 = var_30 * (var_48 << 8);
|
||||
for (j = 0; j < 24 / var_30; j++) {
|
||||
|
||||
@@ -179,14 +179,13 @@ void sub_804522C(void) {
|
||||
|
||||
void sub_804535C(Entity *entity, PixelPos *pos)
|
||||
{
|
||||
|
||||
if (pos != NULL) {
|
||||
(entity->pixelPos).x = pos->x;
|
||||
(entity->pixelPos).y = pos->y;
|
||||
entity->pixelPos.x = pos->x;
|
||||
entity->pixelPos.y = pos->y;
|
||||
}
|
||||
else {
|
||||
(entity->pixelPos).x = (entity->pos).x * 0x1800 + 0xc00;
|
||||
(entity->pixelPos).y = (entity->pos).y * 0x1800 + 0x1000;
|
||||
entity->pixelPos.x = X_POS_TO_PIXELPOS(entity->pos.x);
|
||||
entity->pixelPos.y = Y_POS_TO_PIXELPOS(entity->pos.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ void sub_80857B8(void)
|
||||
void sub_8085860(s32 x, s32 y)
|
||||
{
|
||||
sub_803F4A0(0);
|
||||
sub_803F878(x * 0x1800 + 0xc00, y * 0x1800 + 0x1000);
|
||||
sub_803F878(X_POS_TO_PIXELPOS(x), Y_POS_TO_PIXELPOS(y));
|
||||
}
|
||||
|
||||
void sub_8085890(s32 x, s32 y)
|
||||
|
||||
@@ -2585,8 +2585,6 @@ bool8 SplashMoveAction(Entity * pokemon, Entity * target, Move *move, u32 param_
|
||||
PixelPos pos2;
|
||||
Tile *tile;
|
||||
Entity *entity;
|
||||
s32 temp;
|
||||
s32 temp2;
|
||||
u8 check;
|
||||
|
||||
|
||||
@@ -2610,14 +2608,9 @@ _0805A8C2:
|
||||
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FEBDC);
|
||||
return FALSE;
|
||||
}
|
||||
temp = pos1.x * 0x1800;
|
||||
temp += (0xC00);
|
||||
pos2.x = (temp - target->pixelPos.x) / 0xc;
|
||||
|
||||
temp2 = pos1.y * 0x1800;
|
||||
temp2 += (0x80 << 5);
|
||||
pos2.y = ((temp2 - target->pixelPos.y) / 0xc);
|
||||
|
||||
pos2.x = (X_POS_TO_PIXELPOS(pos1.x) - target->pixelPos.x) / 0xc;
|
||||
pos2.y = (Y_POS_TO_PIXELPOS(pos1.y) - target->pixelPos.y) / 0xc;
|
||||
|
||||
if (((check = sub_803F428(&target->pos), r9 = &target->pos, check)) || (sub_803F428(&pos1))) {
|
||||
for(counter = 0; counter < 0xC; counter++)
|
||||
|
||||
Reference in New Issue
Block a user