void initgraphics(MainStruct* mains)
{
	SetFontTilesIndex(67);
	InitMusicPlayer(patches);

	//Screen info horziontal
	mains->x.SCREENTILE = SCREEN_TILES_H;
	mains->x.TILE = TILE_WIDTH;
	mains->x.MEGATILE = TILE_WIDTH * MEGATILE_WIDTH;
	mains->x.MAP = MAP_MEGA_WIDTH;
	mains->x.MEGA = MEGATILE_WIDTH;

	//Screen info vertical
	mains->y.SCREENTILE = SCREEN_TILES_V;
	mains->y.TILE = TILE_HEIGHT;
	mains->y.MEGATILE = TILE_HEIGHT * MEGATILE_HEIGHT;
	mains->y.MAP = MAP_MEGA_HEIGHT;
	mains->y.MEGA = MEGATILE_HEIGHT;
	
	//Screen position
	mains->x.p = 2;
	mains->y.p = 6;

	screenSections[1].flags = SCT_PRIORITY_SPR;
	screenSections[1].tileTableAdress = tiles;
	screenSections[1].scrollX = screenSections[1].scrollY = 0;

	screenSections[0].flags = SCT_PRIORITY_BG;
	screenSections[0].tileTableAdress = tiles;


	sprites[0].tileIndex=0;
	SetSpritesOptions(SPR_OVERFLOW_ROTATE);
}
Beispiel #2
0
	//Callback invoked by UzeboxCore.Initialize()
	void InitializeVideoMode(){

		//clear sprite-per-line buffer
		for(u16 i=0;i<(SCREEN_TILES_H+2)*TILE_WIDTH;i++){
			scanline_sprite_buf[i]=TRANSLUCENT_COLOR;
		}

		//set default to no flickers
		SetSpritesOptions(0);

		//set defaults for main screen section
		for(u16 i=0;i<SCREEN_SECTIONS_COUNT;i++){
			screenSections[i].scrollX=0;
			screenSections[i].scrollY=0;
		
			if(i==0){
				screenSections[i].height=SCREEN_TILES_V*TILE_HEIGHT;
			}else{
				screenSections[i].height=0;
			}
			screenSections[i].vramBaseAdress=vram;
			screenSections[i].wrapLine=0;
			screenSections[i].flags=SCT_PRIORITY_SPR;
		}

		//sprites flicker rotation
		rotate_spr_no=1;
		
	}
Beispiel #3
0
int main(){	

	unsigned char i,c,x,y,spr;
	
	ClearVram();
		
	//initialize stuff
	InitMusicPlayer(patches);
	SetMasterVolume(0xc0); //crank up the volume a bit since the sample is not too loud

	SetSpritesTileTable(cubes_tileset);
	SetSpritesOptions(SPR_OVERFLOW_CLIP);

	//To allocate/deallocate a player's voice
	//tracks[0].allocated=false;
	//tracks[1].allocated=false;
	//tracks[2].allocated=false;


	//start the beat loop
	TriggerNote(3,1,23,0xff);

	
 	//Define the screen sections. 

	for(i=0;i<9;i++){
		screenSections[i].tileTableAdress=spritedemo_tileset;
	}

	screenSections[0].height=76;	
	screenSections[0].flags=SCT_PRIORITY_SPR;

	screenSections[1].height=2;
	screenSections[1].vramBaseAdress=vram+(32*37);
	screenSections[1].flags=SCT_PRIORITY_BG;

	screenSections[2].height=3;
	screenSections[2].vramBaseAdress=vram+(32*37);
	screenSections[2].flags=SCT_PRIORITY_BG;
	screenSections[2].scrollY=2;

	screenSections[3].height=3;
	screenSections[3].vramBaseAdress=vram+(32*37);
	screenSections[3].flags=SCT_PRIORITY_BG;
	screenSections[3].scrollY=5;

	screenSections[4].height=40;
	screenSections[4].vramBaseAdress=vram+(32*32);
	screenSections[4].flags=SCT_PRIORITY_SPR;

	screenSections[5].height=3;
	screenSections[5].vramBaseAdress=vram+(32*38);
	screenSections[5].flags=SCT_PRIORITY_BG;

	screenSections[6].height=3;
	screenSections[6].vramBaseAdress=vram+(32*38);
	screenSections[6].flags=SCT_PRIORITY_BG;
	screenSections[6].scrollY=3;

	screenSections[7].height=2;
	screenSections[7].vramBaseAdress=vram+(32*38);
	screenSections[7].flags=SCT_PRIORITY_BG;
	screenSections[7].scrollY=6;

	screenSections[8].height=76;
	screenSections[8].flags=SCT_PRIORITY_SPR;
	screenSections[8].scrollY=132;

	Fill(0,37,32,1,1);
	Fill(0,38,32,1,2);


	for(y=0;y<30;y+=4){
		for(x=0;x<30;x+=5){
			DrawMap2(x,y,map_bg);
		}
	}

	DrawMap2(0,32,map_logo);

	for(i=22;i<32;i++){
		DrawMap2(i,32,map_bar);
	}
	
	srand(18);
	c=1;
	spr=1;
	for(i=0;i<7;i++){
		//randomize positions
		cubes[i].x=((unsigned char)(rand() % 110))+2;
		cubes[i].y=((unsigned char)(rand() % 180))+2;

		cubes[i].rotation=((unsigned char)(rand() % 7));

		if((unsigned char)(rand() % 16)<10){
			cubes[i].xdir=1;
		}else{
			cubes[i].xdir=-1;
		}

		if((unsigned char)(rand() % 16)<8){
			cubes[i].ydir=1;
		}else{
			cubes[i].ydir=-1;
		}


	}

	c=0;
	char w1=0,w2=0;
	while(1){

		//syncronize gameplay on vsync (30 hz)	
		WaitVsync(1);

		w2++;
		if(w2==3){
			sx3++;
			if(sx3>X_SCROLL_WRAP) sx3=0;		
			
			screenSections[1].scrollX=sx3;	
			screenSections[7].scrollX=sx3;	
			
			w2=0;
		}

		w1++;
		if(w1==2){
			sx2++;
			if(sx2>=X_SCROLL_WRAP) sx2=0;		
			
			screenSections[2].scrollX=sx2;	
			screenSections[6].scrollX=sx2;	
			
			w1=0;
		}

		sx++;
		if(sx>=X_SCROLL_WRAP) sx=0;

		screenSections[3].scrollX=sx;	
		screenSections[4].scrollX=sx;
		screenSections[5].scrollX=sx;	

		screenSections[0].scrollY++;
		screenSections[8].scrollY++;



		spr=1;
		for(i=0;i<7;i++){
	
			cubes[i].x+=cubes[i].xdir;
			cubes[i].y+=cubes[i].ydir;
			
			if(cubes[i].x>123 && cubes[i].xdir==1){
				cubes[i].xdir=-1;
			}
			if(cubes[i].x<9 && cubes[i].xdir==-1){
				cubes[i].xdir=1;
			}

			cubes[i].y+=cubes[i].ydir;
			if(cubes[i].y>=196 && cubes[i].ydir==1){
				cubes[i].ydir=-1;
			}
			if(cubes[i].y<10 && cubes[i].ydir==-1){
				cubes[i].ydir=1;
			}
		

			if(c==0){
				cubes[i].rotation++;
				if(cubes[i].rotation==14)cubes[i].rotation=0;

				sprites[spr+0].tileIndex=(cubes[i].rotation*2)+1;
				sprites[spr+1].tileIndex=(cubes[i].rotation*2)+1+1;
				sprites[spr+2].tileIndex=(cubes[i].rotation*2)+1+29;
				sprites[spr+3].tileIndex=(cubes[i].rotation*2)+1+30;
			}

			
				sprites[spr+0].x=cubes[i].x;
				sprites[spr+0].y=cubes[i].y;

				sprites[spr+1].x=cubes[i].x+6;
				sprites[spr+1].y=cubes[i].y;

				sprites[spr+2].x=cubes[i].x;
				sprites[spr+2].y=cubes[i].y+8;

				sprites[spr+3].x=cubes[i].x+6;
				sprites[spr+3].y=cubes[i].y+8;
		
			spr+=4;
			c+=128;
		}

		processControls();

		
	
	}
}