#22058 - Mr. GBA - Sat Jun 12, 2004 6:08 pm
Hi,
I'm trying mode 7 using MODE2 with BG 3, ROTBG_SIZE_256x256 & BG_COLOR_256.
I think I have the correct code placed in the HBLANK interrupt, but I'm not getting the right result. The following code is from the HBLANK interrupt.
/* do something */
int center_y; //these are the points around which the the screen rotates
int center_x;
int tempS = SIN[angle];//some temps to hold the sine cos values so we eliminate all those table acceses
int tempC = COS[angle];//actualy only need to do this once per frame so we could store then in a global
//and calc durring the vblank if we wanted
int zoom;
zoom = (height*div[REG_VCOUNT])>>16; //div is fixed 16.16 height is fixed 24.8 so I end up with 8.24..
//so I shift away 16 bits to give me a zoom that is fixed 24.8
//you may notice that I still have some distortion at the bottom of the screen
//this can probably be fixed by keeping some of the presision in the
//value and shifting later
center_y = (180 * zoom)>>2; //set for the center of the screen in the x direction and slightlu
center_x = (120 * zoom)>>2; //bellow the screen for the Y (about were the observer would be standing)
REG_BG3X = (((ScaleX)-center_y*tempS-center_x*tempC))>>14; //x and y are the background scroll factors
REG_BG3Y = (((ScaleY)-center_y*tempC+center_x*tempS))>>14;
REG_BG3PA = (tempC*zoom)>>16; //cos&sin are LUTs that are .8 fixed numbers
REG_BG3PB = (tempS*zoom)>>16; //zoom is also fixed
REG_BG3PC = (-tempS*zoom)>>16;
REG_BG3PD = (tempC*zoom)>>16;
The angle variable is incremented and decremented in the keypad functions.
I would be much obliged if someone could help me figure out how to get mode seven working.
Thanks.
_________________
my dev/business site:
http://codebytesdev.afraid.org
I'm trying mode 7 using MODE2 with BG 3, ROTBG_SIZE_256x256 & BG_COLOR_256.
I think I have the correct code placed in the HBLANK interrupt, but I'm not getting the right result. The following code is from the HBLANK interrupt.
/* do something */
int center_y; //these are the points around which the the screen rotates
int center_x;
int tempS = SIN[angle];//some temps to hold the sine cos values so we eliminate all those table acceses
int tempC = COS[angle];//actualy only need to do this once per frame so we could store then in a global
//and calc durring the vblank if we wanted
int zoom;
zoom = (height*div[REG_VCOUNT])>>16; //div is fixed 16.16 height is fixed 24.8 so I end up with 8.24..
//so I shift away 16 bits to give me a zoom that is fixed 24.8
//you may notice that I still have some distortion at the bottom of the screen
//this can probably be fixed by keeping some of the presision in the
//value and shifting later
center_y = (180 * zoom)>>2; //set for the center of the screen in the x direction and slightlu
center_x = (120 * zoom)>>2; //bellow the screen for the Y (about were the observer would be standing)
REG_BG3X = (((ScaleX)-center_y*tempS-center_x*tempC))>>14; //x and y are the background scroll factors
REG_BG3Y = (((ScaleY)-center_y*tempC+center_x*tempS))>>14;
REG_BG3PA = (tempC*zoom)>>16; //cos&sin are LUTs that are .8 fixed numbers
REG_BG3PB = (tempS*zoom)>>16; //zoom is also fixed
REG_BG3PC = (-tempS*zoom)>>16;
REG_BG3PD = (tempC*zoom)>>16;
The angle variable is incremented and decremented in the keypad functions.
I would be much obliged if someone could help me figure out how to get mode seven working.
Thanks.
_________________
my dev/business site:
http://codebytesdev.afraid.org