示例#1
0
void displaySetup()
{
	DISPLAY_OFF;
	set_bkg_palette( 0, 1, &bgpalette[0] ); 

	/* Initialize the background */
	set_bkg_data(0, 92, data_font);	
	//set_bkg_tiles(1,0, 20, 18, bgmap);
	
	set_sprite_palette(0,2,&spritepalette[0]);
	
	for(j=0;j!=4;j++) {
		cursorBigStartX[j] = SCREEN_XO + SCREEN_PSTARTX + (j * SCREEN_XSPACE) - 1;
		cursorBigStartY[j] = SCREEN_YO + SCREEN_PSTARTY - 8;
		cursorStartX[j] = SCREEN_XO + SCREEN_PSTARTX + (j * SCREEN_XSPACE) - 8;
		cursorStartY[j] = SCREEN_YO + SCREEN_PSTARTY;
		cursorRow[j] = cursorStartY[j];
	}
	
	SPRITES_8x8;
	
	set_sprite_data(SPRITE_ARRT,0x01U, data_barrow);
	set_sprite_data(SPRITE_ARRL,0x01U, data_larrow);
	
	
	set_sprite_tile(SPRITE_ARRT_START, SPRITE_ARRT);
	for(j=0;j!=4;j++) set_sprite_tile(j+SPRITE_ARRL_START, SPRITE_ARRL);
	
	for(j=0;j!=4;j++) set_sprite_prop(j+SPRITE_ARRT_START,1);
	for(j=0;j!=4;j++) set_sprite_prop(j+SPRITE_ARRL_START,1);
	
	DISPLAY_ON;
}
示例#2
0
void setupPointer()
{
   SPRITES_8x8;

   currSelection = MENU_STORYLINE;

   pointerTile = 1; /* the current tile for the pointer */

   set_sprite_palette(0, 1, &pointerPalCGB[0]);

   set_sprite_data(0, 9, pointerTiles);

   set_sprite_tile(0, pointerTile);
   set_sprite_prop(0, pointerTilesCGB[pointerTile]);

   move_sprite(0, pointerX, pointerYPositions[currSelection]);

   SHOW_SPRITES;
}
示例#3
0
int main()
{
	//setup

	//sprite stuff
	set_sprite_palette(0,1,&spritepalette[0]);
	SPRITES_8x8;
	set_sprite_data(MARIO, 4, mario);
	set_sprite_tile(0,0);
	set_sprite_tile(1,1);
	set_sprite_tile(2,2);
	set_sprite_tile(3,3);

/*
	set_sprite_location(0, 0, 20, 0, MARIO, current_map);
	set_camera_location(0, 0, 2, 0);
*/



	//background stuff
	set_bkg_palette(0,1,&backgroundpalette[0]);
	set_bkg_palette(1,1,&backgroundpalette[4]);
	set_bkg_data(0,4,backgroundcharacters);
	VBK_REG=1;
	set_bkg_tiles(0,0,20,24,cgbmap);
	VBK_REG=0;
	set_bkg_tiles(0,0,20,24,bgmap);
	SHOW_BKG;
	enable_interrupts();
	DISPLAY_ON;
	scroll_bkg(0,1);
	
	while(1) {/*
		printf("camera_x: %i\n", camera_x);
		printf("camera_y: %i\n", camera_y);
		printf("spritex: %i\n", spritex);
		printf("spritey: %i\n", spritey);*/

		//read
		input = joypad();



		//eval
		if(input & J_UP) {
			spritey--;
		}
		if(input & J_DOWN) {
			spritey++;  
		}
		if(input & J_LEFT) {
			if(spritex != 0) {
				spritex--;
			}
			camera_x = spritex - 80;
			if(spritex <= 80) {
				camera_x = 0;
			}
			if(spritex >= world_width_px - 80) {
				camera_x = world_width_px - SCREEN_WIDTH;
			}
			scrolled = 0;
		}
		if(input & J_RIGHT) {
			if(spritex != world_width_px - 16) {
				spritex++;
			}
			camera_x = spritex - 80;
			if(spritex <= 80) {
				camera_x = 0;
			}
			if(spritex >= world_width_px - 80) {
				camera_x = world_width_px - SCREEN_WIDTH;
			}
			scrolled = 0;
		}

		//print
		for(y = 0; y <= 18; y++) {
		/*			VBK_REG=1;
		set_bkg_tiles(0,3,20,19,cgbmap);
		VBK_REG=0;
		set_bkg_tiles(0,0,20,19,bgmap);
		*/
			map_row = camera_y/8;
			map_row *= tile_width;
			map_row += (camera_x/8);

			VBK_REG=1;
			set_bkg_tiles(0,y,21,1,&cgbmap[map_row]);
			VBK_REG=0;
			set_bkg_tiles(0,y,21,1,&bgmap[map_row]);
		}

		move_sprite(0,spritex-camera_x+8,spritey-camera_y+16);
		move_sprite(1,spritex-camera_x+16,spritey-camera_y+16);
		move_sprite(2,spritex-camera_x+8,spritey-camera_y+24);
		move_sprite(3,spritex-camera_x+16,spritey-camera_y+24);

		//print
		for(i = 0; i < 4; i++) {
			//slow down animation
			wait_vbl_done();
		}
		SHOW_BKG;
		SHOW_SPRITES;
	}
	return 0;
}