#7679 - einhaender - Sun Jun 22, 2003 10:11 pm
Hi all,
on pernproject.com I have found a tutorial about zooming/rotating background maps. There they are using this function to archive that:
FIXED zoom = 1<<8;
void RotateBackground(Bg* bg, int angle,int x, int y, fixed zoom)
{
y = (y * zoom)>>8;
x = (x * zoom)>>8;
bg->DX = (bg->x_scroll-y*SIN[angle]-x*COS[angle]);
bg->DY = (bg->y_scroll-y*COS[angle]+x*SIN[angle]);
bg->PA = (COS[angle]*zoom)>>8;
bg->PB = (SIN[angle]*zoom)>>8;
bg->PC = (-SIN[angle]*zoom)>>8;
bg->PD = (COS[angle]*zoom)>>8;
}
followed by updating the appropriate registers.
To calculate PA...PD values however they use a different approach than
the developer manual tells, for example PA (BGxPA) should be
1 / a * COS[0] where a is the magnification along x-axis, why is
theirs different?
I could write my own logic using the math from the manual for
calculating BGxPA ... BGxPD but unfortunately I dont know the
values to put into BG2X_L, BG2X_H and BG2Y_L, BG2Y_H.
Also I wonder, for the effect of zooming a screen-centered element exactly in the middle without going along x or y axis, I would need to modify the rotation center coordinate every time before calling the above function, right? 1 pixel per frame?
And how can I zoom faster or slower? Lots of questions, hope somebody can help me a bit. Thanks
on pernproject.com I have found a tutorial about zooming/rotating background maps. There they are using this function to archive that:
FIXED zoom = 1<<8;
void RotateBackground(Bg* bg, int angle,int x, int y, fixed zoom)
{
y = (y * zoom)>>8;
x = (x * zoom)>>8;
bg->DX = (bg->x_scroll-y*SIN[angle]-x*COS[angle]);
bg->DY = (bg->y_scroll-y*COS[angle]+x*SIN[angle]);
bg->PA = (COS[angle]*zoom)>>8;
bg->PB = (SIN[angle]*zoom)>>8;
bg->PC = (-SIN[angle]*zoom)>>8;
bg->PD = (COS[angle]*zoom)>>8;
}
followed by updating the appropriate registers.
To calculate PA...PD values however they use a different approach than
the developer manual tells, for example PA (BGxPA) should be
1 / a * COS[0] where a is the magnification along x-axis, why is
theirs different?
I could write my own logic using the math from the manual for
calculating BGxPA ... BGxPD but unfortunately I dont know the
values to put into BG2X_L, BG2X_H and BG2Y_L, BG2Y_H.
Also I wonder, for the effect of zooming a screen-centered element exactly in the middle without going along x or y axis, I would need to modify the rotation center coordinate every time before calling the above function, right? 1 pixel per frame?
And how can I zoom faster or slower? Lots of questions, hope somebody can help me a bit. Thanks