i thought id kick this off by bringing this nintendo ds example across from my old forum bear with me because im going to write a tut that will get anybody going with a ds.
//////////////////////////////////////////////////////////////////////
// two screen demo
// ninos picture viewer
//////////////////////////////////////////////////////////////////////
#include <NDS/NDS.h>
#include <NDS/ARM9/console.h>
#include "milo.h"//256x192 bmp image converted to raw bgr 5:5:5 format
#include "milo1.h"//256x192 bmp image converted to raw bgr 5:5:5 format
u16* front;//
u16* back;
void WaitForVblank();
void draw_bmp(void);
void flip();
void cls();
//THE TWO COMMANDS I MADE BELLOW HELP MENIPULATE BACKGROUNDS THEY ROTATE MOVE AND SCALE
//AND CHOOSE ROTATOIN POINTS ON BACKGROUNDS
//ANOTHER POINT FOR SCALEX AND SCALEY TO WORK THEY HAVE TO BE FIXED POINT FIRST SO
//(1<<8) IS YOUR NORMAL SIZE THEN TO ADJUST THE SIZE YOU DO (1<<8)+-AMOUNT
void rotate_and_scale_main_image(s16 scale_x,s16 scale_y,s16 x_pos,s16 Y_pos,s16 angle,s16 rot_pointx,s16 rot_pointy);
void rotate_and_scale_sub_image(s16 scale_x,s16 scale_y,s16 x_pos,s16 Y_pos,s16 angle,s16 rot_pointx,s16 rot_pointy);
s16 angle;
int main(void)
{
powerON(POWER_ALL);
irqInitHandler(irqDefaultHandler);
irqSet(IRQ_VBLANK, 0);
videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE);
videoSetModeSub(MODE_5_2D | DISPLAY_BG2_ACTIVE);
vramSetBankA(VRAM_A_MAIN_BG_0x6000000);
vramSetBankB(VRAM_B_MAIN_BG_0x6020000);
vramSetBankC(VRAM_C_SUB_BG_0x6200000);
BG2_CR = BG_BMP16_256x256;
SUB_BG2_CR = BG_BMP16_256x256;
front=(u16*)(0x6000000);
back=(u16*)(0x6020000);
while(1)
{
angle += 4;
if(IPC->touchX != 0)
{
lcdSwap();
}
draw_bmp();
flip();
cls();
rotate_and_scale_main_image((1<<8)-30,(1<<8)-30,128,96,angle,128,96);
rotate_and_scale_sub_image((1<<8)-30,(1<<8)-30,128,96,angle,128,96);
WaitForVblank();
}
return 0;
}
void WaitForVblank()
{
while(DISP_Y!=192);
while(DISP_Y==192);
}
void draw_bmp(void)
{
for(int ix = 0; ix < 256*192; ix++)
{
back[ix] = milo[ix] | BIT(15);
BG_GFX_SUB[ix] = milo1[ix] | BIT(15);
}
}
void flip()
{
//flip the main screen
u16* temp;
temp=back;
back=front;
front=temp;
BG2_CR ^= BG_BMP_BASE( 128 / 16 );
}
void cls()
{
for(int ix = 0; ix < 246*192; ix++)
{
back[ix] = 0x0000 | BIT(15);
}
}
void rotate_and_scale_main_image(s16 scale_x , s16 scale_y , s16 x_pos , s16 Y_pos , s16 angle , s16 rot_pointx , s16 rot_pointy)
{
s16 coz=COS[angle & 0x1FF] >> 4;
s16 zin=SIN[angle & 0x1FF] >> 4;
BG2_XDX = ( coz * (scale_x) ) >> 8;
BG2_XDY = (-zin * (scale_x) ) >> 8;
BG2_YDX = ( zin * (scale_y) ) >> 8;
BG2_YDY = ( coz * (scale_y) ) >> 8;
BG2_CX = (x_pos<<8) - rot_pointx * (coz - zin);
BG2_CY = (Y_pos<<8) - rot_pointy * (zin + coz);
}
void rotate_and_scale_sub_image(s16 scale_x , s16 scale_y , s16 x_pos , s16 Y_pos , s16 angle , s16 rot_pointx , s16 rot_pointy)
{
s16 coz=COS[angle & 0x1FF] >> 4;
s16 zin=SIN[angle & 0x1FF] >> 4;
SUB_BG2_XDX = ( coz * (scale_x) ) >> 8;
SUB_BG2_XDY = (-zin * (scale_x) ) >> 8;
SUB_BG2_YDX = ( zin * (scale_y) ) >> 8;
SUB_BG2_YDY = ( coz * (scale_y) ) >> 8;
SUB_BG2_CX = (x_pos<<8) - rot_pointx * (coz - zin);
SUB_BG2_CY = (Y_pos<<8) - rot_pointy * (zin + coz);
}