/* the main function */ int main( ) { /* we set the mode to mode 0 with bg0 on */ *display_control = MODE0 | BG0_ENABLE; /* setup the background 0 */ setup_background(); /* set initial scroll to 0 */ int xscroll = 0; int yscroll = 0; /* loop forever */ while (1) { /* scroll with the arrow keys */ if (button_pressed(BUTTON_DOWN)) { yscroll++; } if (button_pressed(BUTTON_UP)) { yscroll--; } if (button_pressed(BUTTON_RIGHT)) { xscroll++; } if (button_pressed(BUTTON_LEFT)) { xscroll--; } /* wait for vblank before scrolling */ wait_vblank(); *bg0_x_scroll = xscroll; *bg0_y_scroll = yscroll; /* delay some */ delay(200); } }
/* wait until start of vertical blank */ wait_sync() { wait_novblank(); wait_vblank(); }