void vblfunc(void);
void hblfunc(void);
u16 scrollx = 0; // used to update BG scroll when using pad
u16 scrolly = 0; // same
u8 sinus_offset=0; // for next use
u8 sinus_count=0;
ISR saved_isr;
const s8 g_SinTab1[128*4]=
{ 2 , 3 , 5 , 6 , 8 , 9 , 11 , 12 ,
14 , 15 , 16 , 18 , 19 , 20 , 21 , 23 ,
24 , 25 , 26 , 27 , 27 , 28 , 29 , 30 ,
30 , 31 , 31 , 31 , 32 , 32 , 32 , 32 ,
32 , 32 , 32 , 31 , 31 , 31 , 30 , 30 ,
29 , 28 , 27 , 27 , 26 , 25 , 24 , 23 ,
21 , 20 , 19 , 18 , 16 , 15 , 14 , 12 ,
11 , 9 , 8 , 6 , 5 , 3 , 2 , 0 ,
-2 ,-3 ,-5 ,-6 ,-8 ,-9 ,-11 ,-12 ,
-14 ,-15 ,-16 ,-18 ,-19 ,-20 ,-21 ,-23 ,
-24 ,-25 ,-26 ,-27 ,-27 ,-28 ,-29 ,-30 ,
-30 ,-31 ,-31 ,-31 ,-32 ,-32 ,-32 ,-32 ,
-32 ,-32 ,-32 ,-31 ,-31 ,-31 ,-30 ,-30 ,
-29 ,-28 ,-27 ,-27 ,-26 ,-25 ,-24 ,-23 ,
-21 ,-20 ,-19 ,-18 ,-16 ,-15 ,-14 ,-12 ,
-11 ,-9 ,-8 ,-6 ,-5 ,-3 ,-2 , 0,
2 , 3 , 5 , 6 , 8 , 9 , 11 , 12 ,
14 , 15 , 16 , 18 , 19 , 20 , 21 , 23 ,
24 , 25 , 26 , 27 , 27 , 28 , 29 , 30 ,
30 , 31 , 31 , 31 , 32 , 32 , 32 , 32 ,
32 , 32 , 32 , 31 , 31 , 31 , 30 , 30 ,
29 , 28 , 27 , 27 , 26 , 25 , 24 , 23 ,
21 , 20 , 19 , 18 , 16 , 15 , 14 , 12 ,
11 , 9 , 8 , 6 , 5 , 3 , 2 , 0 ,
-2 ,-3 ,-5 ,-6 ,-8 ,-9 ,-11 ,-12 ,
-14 ,-15 ,-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,
29 , 28 , 27 , 27 , 26 , 25 , 24 , 23 ,
21 , 20 , 19 , 18 , 16 , 15 , 14 , 12 ,
11 , 9 , 8 , 6 , 5 , 3 , 2 , 0 ,
-2 ,-3 ,-5 ,-6 ,-8 ,-9 ,-11 ,-12 ,
-14 ,-15 ,-16 ,-18 ,-19 ,-20 ,-21 ,-23 ,
-24 ,-25 ,-26 ,-27 ,-27 ,-28 ,-29 ,-30 ,
-30 ,-31 ,-31 ,-31 ,-32 ,-32 ,-32 ,-32 ,
-32 ,-32 ,-32 ,-31 ,-31 ,-31 ,-30 ,-30 ,
-29 ,-28 ,-27 ,-27 ,-26 ,-25 ,-24 ,-23 ,
-21 ,-20 ,-19 ,-18 ,-16 ,-15 ,-14 ,-12 ,
-11 ,-9 ,-8 ,-6 ,-5 ,-3 ,-2 , 0 };
void AgbMain(void)
{
/* Init interuption handler */
INTENABLE = 0;
saved_isr = GET_MASTER_ISR();
SET_MASTER_ISR(isr);
LCDSTAT |= LCDSTAT_VBLINT;
INTMASK |= INT_VBLANK;
LCDSTAT |= LCDSTAT_HBLINT;
INTMASK |= INT_HBLANK;
INTENABLE = 1;
...
while(1)
{
// in the main loop, scrollx and scrolly are updated when pad is pressed
// not relative to the wave effect
}
}
void hblfunc(void)
{
// I tested Y wave effect, it was really fun to see ! ^^
// I commented these lines
// sinus_offset is not used for the moment, always 0
BGSCROLL[1].x = scrollx+(g_SinTab1[LCD_Y+sinus_count+(sinus_offset)]);
//BGSCROLL[1].y = scrolly+(g_SinTab1[LCD_Y+sinus_count+(sinus_offset)]);
BGSCROLL[2].x = scrollx+(g_SinTab1[LCD_Y+sinus_count+(sinus_offset)]);
//BGSCROLL[2].y = scrolly+(g_SinTab1[LCD_Y+sinus_count+(sinus_offset)]);
}
void vblfunc(void)
{
sinus_count++;
// not relative to the wave effect
// it's just for scrolling BG with pad
BGSCROLL[1].x = scrollx;
BGSCROLL[1].y = scrolly;
BGSCROLL[2].x = scrollx;
BGSCROLL[2].y = scrolly;
}
|