예제 #1
0
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);
}
예제 #2
0
파일: Atomix.c 프로젝트: Aliandrana/uzebox
/**
 * Main code
 */
int main() {
	SetTileTable(tiles);
	SetSpritesTileTable(tiles);
	SetFontTilesIndex(TILE_FIRST_FONT);
	InitMusicPlayer(patches);
	TriggerNote(3,SOUND_INTRO_MUSIC,20,0xff);
	SetUserPostVsyncCallback(vsync_callback);

	// read custom configuration from eeprom
	EepromReadBlock(129, &eeprom_data);
	eeprom_data.id = 129;

	game();
}
예제 #3
0
파일: gghost.c 프로젝트: kivan117/gghost
/**
 * \brief Performs some basic initialization functions.
 *
 * Sets up our graphics, initializes a few variables for convenience, loads saved scores and gets the music going.
 */
static void initialSetup()
{
	SetSpritesTileTable(ghost_sprites); //sets the tiles to be used for our various sprites
	SetFontTilesIndex(TITLE_TILES_SIZE); //tiles for the font were included immediately after the include for background tiles
	                               //therefore this says how many tiles in memory to move forward from the first one
	                               //in order to find the beginning of the font tiles
	SetTileTable(title_tiles); //sets the tiles to be used for the normal background tiles in the game
	                     //fonts use this and the index above to set font tiles
	InitMusicPlayer(patches); //initialize the sound engine
	SetMasterVolume(0xff); //set volume to max
	StartSong(midisong); //start playing the main theme
	ClearVram(); //fill entire screen with first tile in the tileset (blank the screen)

	//set up some convenience variables for changing player image and drawing the score
	player_sprites[0]=ghost0;
	player_sprites[1]=ghost1;
	player_sprites[2]=ghost2;
	player_sprites[3]=ghost3;
	player_sprites[4]=ghost4;
	player_sprites[5]=ghost5;
	player_sprites[6]=ghost6;
	player_sprites[7]=ghost7;
	player_sprites[8]=ghost8;
	numbers[0]=num0;
	numbers[1]=num1;
	numbers[2]=num2;
	numbers[3]=num3;
	numbers[4]=num4;
	numbers[5]=num5;
	numbers[6]=num6;
	numbers[7]=num7;
	numbers[8]=num8;
	numbers[9]=num9;

	//checks if our desired eeprom block is setup correctly,
	//if not, it wipes it so we don't have to deal with garbage data in the high score list
	if(checkEeprom()==1)
	{
		wipeEeprom();
	}
	//load our top 10 saved scores from eeprom
	LoadScore(0, 9);
}
예제 #4
0
void DisplayHowToPlay(){
	SetTileTable(tiles);
	SetFontTilesIndex(TILES_SIZE);

	ClearTextVram();
	DrawMap2(4,1,map_title2);

	Print(1,5,PSTR("The Game of Life is a cellular        "));
	Print(1,6,PSTR("automaton devised by the mathematician"));
	Print(1,7,PSTR("John Conway in 1970. One interacts    "));
	Print(1,8,PSTR("with the game by creating an initial  "));
	Print(1,9,PSTR("configuration and observing how it    "));
	Print(1,10,PSTR("evolves."));

	Print(1,12,PSTR("The game is made of a grid of cells  "));
	Print(1,13,PSTR("each of which has two possible states"));
	Print(1,14,PSTR("alive or dead. Each turn, cells"));
	Print(1,15,PSTR("evolves according to four rules:"));

	Print(1,17,PSTR("1.Any live cell with fewer than two "));
	Print(1,18,PSTR("  live neighbours dies"));

	Print(1,19,PSTR("2.Any live cell with two or three live"));
	Print(1,20,PSTR("  neighbours lives on to the next turn"));

	Print(1,21,PSTR("3.Any live cell with more than three"));
	Print(1,22,PSTR("  live neighbours dies"));

	Print(1,23,PSTR("4.Any dead cell with exactly three"));
	Print(1,24,PSTR("  live neighbours becomes a live cell"));

	Print(15,26,PSTR("PRESS START"));

	while(1){
		if(ReadJoypad(0)==BTN_START){
			while(ReadJoypad(0)!=0);
			return;
		}
	}
}
예제 #5
0
char introscreen(GameStruct* game)
{
	unsigned char counter;
	unsigned int joypad;

	ClearVram();
	memset(sprites, 0, sizeof(struct SpriteStruct)*32);

	SetFontTilesIndex(49);
	screenSections[1].flags = SCT_PRIORITY_BG;
	screenSections[0].tileTableAdress = zombienator_title;
	screenSections[1].scrollX = screenSections[1].scrollY = 0;
	setoverlay(0);

	game->menupos = counter = 0;

	DrawMap2(0,6, title_map);
	for(int i = 0; i < 22; i++)
		SetTile(i, 10, 27 + i);

	for(;;)
	{
		WaitVsync(1);
		Fill(0,13, SCREEN_TILES_H, SCREEN_TILES_V - 13, 0);

		Print(5, 14, singlestr);
		Print(5, 15, multistr);
		Print(5, 16, highstr);
		Print(3, 14 + game->menupos, selectstr);
		joypad = 0;
		counter++;
		game->frames++;
		
		if(counter >= 15)
		{
			counter = 0;
			while(!(joypad&(BTN_START|BTN_SELECT|BTN_UP|BTN_DOWN)))
			{
				joypad = ReadJoypad(0);
				switch(joypad&(BTN_START|BTN_SELECT|BTN_UP|BTN_DOWN))
				{
					case BTN_START:
					case BTN_SELECT:
						if(game->menupos == 0)
							return 1;
						else if(game->menupos == 1)
							return 2;
						break;
					case BTN_UP:
						if(game->menupos > 0 )
							game->menupos--;
						else
							game->menupos = 2;
						break;
					case BTN_DOWN:
						if(game->menupos < 2)
							game->menupos++;
						else
							game->menupos = 0;
						break;
				}
			}
		}
	}


	return 0;
}
예제 #6
0
u8 Title(){
	ClearTextVram();

	SetTileTable(tiles);
	SetFontTilesIndex(TILES_SIZE);
	DrawMap2(8,3,map_title1);
	DrawMap2(4,6,map_title2);
	DrawMap2(24,13,map_title3);

	Print(8,15,PSTR("PLAY"));
	Print(8,16,PSTR("HOW TO PLAY"));
//	Print(8,17,PSTR("OPTIONS"));

	Print(13,26,PSTR("V1.1 \\ 2013 Uze"));

	u8 option=0;
	u8 animFrame=0,animDelay=0;
	u8 x=6,y=15;
	u16 joy,prevJoy=0;
	while(1){
		WaitVsync(1);
		joy=ReadJoypad(0);
		AnimateCursor(x,y+option);
		/*
		if(animDelay==15){
			//clear othercursor  location
			SetTile(x,y+(option^1),0);
			SetTile(x+1,y+(option^1),0);

			animDelay=0;
			animFrame++;
			if(animFrame==4)animFrame=0;
			switch(animFrame){
				case 0:
					SetTile(x,y+option,1);
					SetTile(x+1,y+option,2);
					break;
				case 1:
					SetTile(x,y+option,3);
					SetTile(x+1,y+option,4);
					break;
				case 2:
					SetTile(x,y+option,5);
					SetTile(x+1,y+option,6);
					break;
				default:
					SetTile(x,y+option,7);
					SetTile(x+1,y+option,8);
					break;
			}
		}
		animDelay++;
		*/

		if(prevJoy==0){
			if (joy==BTN_SELECT || joy==BTN_UP || joy==BTN_DOWN){
				option^=1;
				animDelay=15;
			}else if(joy==BTN_START){
				while(ReadJoypad(0)!=0);
				return option;
			}
		}
		prevJoy=joy;
	}

}
예제 #7
0
int main(){


	SetUserPostVsyncCallback(&VsyncCallBack);



	while(1){
		vmode=0;
		vmode_text_lines=SCREEN_TILES_V;
		paused=true;
		u8 option=0;


		do{
			option=Title();
			if(option==1){
				DisplayHowToPlay();
			}
		}while(option!=0);

		ClearVram();

		SetTileTable(font);
		SetFontTilesIndex(0);
		CreateStatusBar();


		//SetTile(0,0,91);
		//SetTile(1,0,92);
		//Print(1,0,PSTR("Started  Generation:       SELECT=Menu"));


		vmode_text_lines=1;
		//vmode=1;
		vmode_grid_col=9;//82;
		vmode_page=0;

		cursor_x=44;
		cursor_y=25;

		//R-pentamino
		//PutPixel(40,30,1,0);
		//PutPixel(41,30,1,0);
		//PutPixel(39,31,1,0);
		//PutPixel(40,31,1,0);
		//PutPixel(40,32,1,0);



		//u16 joy;

		inMainLoop=true;
		bool gameEnd=false;
		while(1){

			WaitVsync(1);

			if(!paused){
				ComputeNextStep();
				vmode_page^=1;
				gen++;

			}
		
			if(keyAction!=ACTION_NONE){
				switch(keyAction){
					case ACTION_STARTSTOP:
						paused=!paused;
						keyAction=ACTION_NONE;
						break;
					case ACTION_OPENMENU:
						if(OpenMenu()==1){
							gameEnd=true;
							inMainLoop=false;
						}
						keyAction=ACTION_NONE;
						break;
				}

			}

			UpdateStatusBar();
			if(gameEnd)break;
		}
	}

} 
예제 #8
0
u8 OpenMenu(){

	ClearTextVram();
	
	SetTileTable(tiles);
	SetFontTilesIndex(TILES_SIZE);

	//Show object types
	Print(6,2,PSTR("Select life object to insert"));
	Print(5,3,PSTR("at the current cursor position"));

	Print(7,7,PSTR("Glider"));
	Print(7,8,PSTR("Lightweight spaceship (LWSS)"))	;
	Print(7,9,PSTR("R-Pentamino"));
	Print(7,10,PSTR("Gosper glider gun"));

	Print(7,11,PSTR("Clear field"));
	Print(7,12,PSTR("Exit game"));


	//slide in menu
	WaitVsync(1);
	Fill(0,0,40,1,0);
	for(u8 i=1;i<29;i++){
		WaitVsync(1);
		vmode_text_lines=i;
	}


	s8 option=0,x=5,y=7;
	u16 joy,prevJoy=0;
	while(1){
		WaitVsync(1);
		joy=ReadJoypad(0);
		if(prevJoy==0){
			if (joy==BTN_UP){
				if(option>0) option--;

			}else if (joy==BTN_DOWN){
				if(option<5)option++;

			}else if(joy==BTN_SELECT){
				break;
			}else if(joy==BTN_START){
				switch(option){
					case 0:
						glider(cursor_x,cursor_y);
						break;

					case 1:
						lwss(cursor_x,cursor_y);
						break;
	
					case 2:
						rPentamino(cursor_x,cursor_y);
						break;					

					case 3:
						gliderGun(cursor_x,cursor_y);
						break;	

					case 4:
						ClearVram();
						break;

					default:						
						while(ReadJoypad(0)!=0);
						return 1;  //signal game end, back to main menu
				}
	
				break;
			}
		}
		prevJoy=joy;
		AnimateCursor(x,y+option);
	}

	while(ReadJoypad(0)!=0);

	//close menu
	for(u8 i=29;i>0;i--){
		WaitVsync(1);
		vmode_text_lines=i;
	}
	ClearTextVram();
	SetTileTable(font);
	SetFontTilesIndex(0);
	CreateStatusBar();
	
	return 0;
}
예제 #9
0
int main(){	
	TriggerFx(0,0,0);


	ClearVram();
	InitMusicPlayer(patches);
	SetMasterVolume(0x40);
	StartSong(midisong);

	SetSpritesTileTable(mario_sprites_tileset);
	SetFontTilesIndex(SMB_TILESET_SIZE);
	SetTileTable(smb_tileset);

    Screen.scrollHeight = 23;
	

    Screen.overlayHeight=4;
    Screen.overlayTileTable=smb_tileset;
	DrawMap2(0,Screen.scrollHeight,map_hud);
	
	unsigned char c;
	for(int y=0;y<22;y++){
		for(int x=0;x<30;x++){
			c=pgm_read_byte(&(map_main[(y*MAP_MAIN_WIDTH)+x+2]));
			SetTile(x,y+1,c);
		}	
	}


	dx=0;
	sx=50;
	sy=169-32+8;
	sprDir=1;

	goombaX[0]=17; //159;
	goombaDir[0]=-1;
	goombaAnim[0]=0;
	goombaSpr[0]=0;
	goombaSprIndex[0]=6;

	goombaX[1]=65 ;//201;
	goombaDir[1]=1;
	goombaAnim[1]=0;
	goombaSpr[1]=0;
	goombaSprIndex[1]=10;


	MapSprite2(0,map_rwalk1,0);
	MapSprite2(6,map_rgoomba1,SPRITE_FLIP_X);
	MapSprite2(10,map_rgoomba2,0);



	g=0;
	MoveSprite(0,sx,sy,2,3);
	Scroll(0,-1);

	MoveSprite(goombaSprIndex[0],goombaX[0],176,2,2);
	MoveSprite(goombaSprIndex[1],goombaX[1],176,2,2);

	Screen.scrollY=0;
	Screen.overlayHeight=4;//OVERLAY_LINES;

	
	while(1){
		WaitVsync(1);
	

		processControls();

		if((active&1)!=0){
			PerformActions();
			MoveSprite(0,sx,sy+dy,2,3);
		}else{
			MoveSprite(0,sx,230,2,3);
		}



		//animate goombas
		for(g=0;g<2;g++){
		

				if(goombaX[g]<=0 && goombaDir[g]==-1){
					goombaDir[g]=1;
				}
		
				if(goombaX[g] >= (215+15) && goombaDir[g]==1){
					goombaDir[g]=-1;
			
				}
		
				goombaX[g]+=goombaDir[g];
				goombaAnim[g]++;

				if(goombaAnim[g]==8){
					goombaSpr[g]^=1;
					goombaAnim[g]=0;
				}

				if(goombaSpr[g]==0){
					MapSprite2(goombaSprIndex[g],map_rgoomba1,goombaDir[g]!=1?SPRITE_FLIP_X:0);
				}else{
					MapSprite2(goombaSprIndex[g],map_rgoomba2,goombaDir[g]!=1?SPRITE_FLIP_X:0);
				}

				MoveSprite(goombaSprIndex[g],goombaX[g],176-32+8,2,2);
			

		}
	

	}		
	
}
예제 #10
0
파일: gghost.c 프로젝트: kivan117/gghost
/**
 * \brief The main game loop. This just cycles endlessly, it uses the game's 'state' to determine which screen to show and what to do.
 */
int main(){
	//looping back and forth forever (cards against humanity reference)
	while(1)
	{
		//some basic prep work performed once before our custom intro
		if(game_state == INTRO)
		{
			initialSetup();
			initIntro();
		}
		//perform custom intro
		while(game_state == INTRO)
		{
			//wait until the next frame
			WaitVsync(1);
			drawIntro();
			processIntro();
		}
		//prep the main menu
		if(game_state == MAIN_MENU)
		{
			FadeOut(0,true);
			ClearVram();
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawMainMenu();
			FadeIn(0,false);
		}
		//draw menu and handle input
		while(game_state == MAIN_MENU)
		{
			WaitVsync(1);
			drawMenuCursor();
			processMainMenu();
		}
		if(game_state== GAME)
		{
			//run our setup for the main game
			ClearVram();
			FadeOut(0,true);
			gameSetup();
			FadeIn(0,false);
		}
		//when we're in the gameplay portion, draw and accept input for the game
		while(game_state == GAME)
		{
			WaitVsync(1);
			processScrollSpeed(); //scrolls screen as appropriate
			updateCity(); //offsets city for parallax
			processControls(); //accepts and processes controller input
			processPlayerMotion(); //update player position
			processSprites(); //updates and moves player image to player position
		}
		if(game_state == HIGH_SCORES)
		{
			FadeOut(0,true);
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawLocalHighScoreMenu(); //draw up the high score screen
			FadeIn(0,false);
			deathclock=120; //reset death timer to 2 seconds
			if(score > topscores[9])
			{
			    LoadScore(0, 9); //load top 10 saved high scores
			    SaveScore(score); //save our current score if it's high enough
			    drawLocalHighScoreMenu(); //draw up the high score screen
			}
		}
		//draw and accepts input for the local high score screen
		while(game_state == HIGH_SCORES)
		{
			WaitVsync(1);
			processHighScoreMenu();
		}
    }
}
예제 #11
0
파일: SDTest.c 프로젝트: Aliandrana/uzebox
int main(){


SetTileTable(tiles);			//Set the tileset to use (set this first)
SetFontTilesIndex(TILES_SIZE);	//Set the tile number in the tilset that contains the first font
ClearVram();					//Clear the screen (fills the vram with tile zero)

long sectorStart;

sdCardInitNoBuffer();

sectorStart = sdCardFindFileFirstSectorFlash(fileName);

if(sectorStart == 0){
	Print(0,0,PSTR("FILE HELLWRLD.TXT NOT FOUND ON SD CARD"));
} else {

    sdCardCueSectorAddress(sectorStart);


    /*

    HELLO WORLD FROM THE SD CARD
    VERTICAL TEXT
    DOUBLE SPACES
    DOUBLE LINE SPACING DOUBLE LINE SPACING  DOUBLE LINE SPACING DOUBLE LINE SPACING
    RUN2SPANXFOR16BITINDEX

	*/

    // sdCardDirectReadSimple(uint8_t *dest, uint16_t count);
    // sdDirectRead(uint8_t *dest, uint16_t count, uint8_t span, uint8_t run);
    //
    //
    // HELLO WORLD FROM THE SD CARD
    // Read 28 bytes of test straight to VRAM
    // sdCardDirectReadSimple(address, length) == sdDriectReadSimple(address, length, 0, 0)
    // That is SPAN = 0 RUN = 0

    sdCardDirectReadSimple(&vram[COORD(0,0)], 28);    // HELLO WORLD
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // VERTICAL TEXT
    // SPAN = 39
    // RUN = 1
    //
    // Every 1 (RUN) byte skip 39 (SPAN) bytes
    //
    // Screen width = 40 so 39 is screen width - 1

    sdCardDirectRead(&vram[COORD(0,2)], 13, 39, 1);   // VERTICAL TEXT
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // DOUBLE SPACES
    // SPAN = 1
    // RUN = 1
    //
    // Every 1 (RUN) byte skip 1 (SPAN) bytes

    sdCardDirectRead(&vram[COORD(3,2)], 13, 1, 1);    // DOUBLE SPACES
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // DOUBLE SPACES
    // SPAN = 39
    // RUN = 80
    //
    // Every 40 (RUN) bytes skip 39 (SPAN) bytes
    // 40 is one whole line of text
    // 39 is (40-1)

    sdCardDirectRead(&vram[COORD(0,17)], 80, 39, 40); // DOUBLE LINE SPACING
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // 16 bit modes
    // SPAN = 38
    // RUN = 2
    //
    // Every 2 (RUN) bytes skip 38 (SPAN) bytes
    // 2 bytes = 16 bits.  So modes with a 16 bit tile index could use this to fill in a column
    // 38 is (40-2)

    sdCardDirectRead(&vram[COORD(20,4)], 22, 38, 2);  // 16 BIT MODES
}

while(1);

}