Пример #1
0
/* Main function */
void main(void)
{
	/* Initialize pseudo "random" number generator */
  	printf("\nWelcome to DruggoGB...\n");
  	waitpad(J_A);
  	waitpadup();
  	puts("...");
  	waitpad(J_A);
  	waitpadup();
  	/* Seed with the DIV register. Gameboy PSRNG has extremely low entropy */
  	seed |= (UWORD)DIV_REG << 8;
  	/* Call initrand passing the div register as the seed */
  	initrand(seed);
  	/* Start the game */
  	startGame();
}
Пример #2
0
void main() {
	int i, j;
	for (i = 0; i < WIDTH*HEIGHT; ++i){
		printf("%c", i);
		waitpad(J_UP);
		waitpadup();
	}
}
Пример #3
0
/*--------------------------------------------------------*/
void RANSUU_INIT() //乱数の初期化 このやり方はSDKのexampleフォルダの中にあります
{
	waitpad(J_A);
	seed.b.l = DIV_REG;
	waitpadup();
	seed.b.h = DIV_REG;

	initarand(seed.w);   // 乱数の初期化

}
void main(){
	int xpos = 8 + GRAPHICS_WIDTH / 2;
	int ypos = 16 + GRAPHICS_HEIGHT / 2;
	int count = 0;
	int joy, i;
	set_sprite_data(0, 1, crosshair_tiledata);
	set_sprite_data(1, 6, explode_tiledata);
	SWITCH_ROM_MBC1(3);
	set_bkg_data(0, 179, title_tiledata);
	set_bkg_tiles(0, 0, 20, 18, title_tilemap);
	SHOW_BKG;
	DISPLAY_ON;
	waitpad(J_START);
	DISPLAY_OFF;
	SWITCH_ROM_MBC1(2);
	set_bkg_data(0, 182, earth_tiledata);
	set_bkg_tiles(0, 0, 20, 18, earth_tilemap);
	set_sprite_tile(0,0);
	move_sprite(0, xpos, ypos);
	SHOW_SPRITES;
	DISPLAY_ON;
	waitpadup();
	while (1){
		wait_vbl_done();
		joy = joypad();
		if (joy & J_UP && ypos > 14)
			--ypos;
		if (joy & J_DOWN && ypos < GRAPHICS_HEIGHT + 13)
			++ypos;
		if (joy & J_LEFT && xpos > 8)
			--xpos;
		if (joy & J_RIGHT && xpos < GRAPHICS_WIDTH + 8)
			++xpos;
		if (joy & J_A || joy & J_B){
			++count;
			move_sprite(count, xpos - 2, ypos - 2);
			for (i = 1; i != 7; ++i){
				set_sprite_tile(count, i);
				wait_vbl_done();
				wait_vbl_done();
			}
			set_sprite_tile(count, 4);
			set_sprite_prop(count, 1 << 4);
			if (count == 39){
				delay(500);
				end();
			}
		}		
		move_sprite(0, xpos, ypos);
	}
}
Пример #5
0
/**
 * Draws the title screen
 * and halts until START is pushed.
 */
void showTitle() {
	UWORD seed;

	// Load titlescreen and seed RNG
	DISPLAY_OFF;
	LCDC_REG = B8(01000001);
	set_bkg_data(0, title_dataLen, title_data);
	set_bkg_tiles(0, 0, 20, 18, title_tiles);
	DISPLAY_ON;

	waitpad(J_START);
	seed = DIV_REG;

	waitpadup();
	seed |= (UWORD)DIV_REG << 8;
	initarand(seed);
}
Пример #6
0
void recordSounds()
{
   int joy;

	DISPLAY_OFF;
	HIDE_BKG;

  /*************************************************************************/
  /* the following set of routines loads the palettes into the display.    */
  /* each palette is send (one by one) by using the command:               */
  /*   set_bkg_palette( palette-no, first color in palette, Palette-data ) */
  /*************************************************************************/

  set_bkg_palette( 7, 1, &recordPalCGB[28] );
  set_bkg_palette( 6, 1, &recordPalCGB[24] );
  set_bkg_palette( 5, 1, &recordPalCGB[20] );
  set_bkg_palette( 4, 1, &recordPalCGB[16] );
  set_bkg_palette( 3, 1, &recordPalCGB[12] );
  set_bkg_palette( 2, 1, &recordPalCGB[8] );
  set_bkg_palette( 1, 1, &recordPalCGB[4] );
  set_bkg_palette( 0, 1, &recordPalCGB[0] );


  /*************************************************************************/
  /* Next, the tile-data is send to the display;
  /*************************************************************************/

  set_bkg_data( 0, 235, recordTiles );

  /*************************************************************************/
  /* Now it's time to send the map-data to the display. Again, in two      */
  /* steps, as the tiles and attributes reside in different banks.         */
  /* The data is send to the display by using the command:                 */
  /*   set_bkg_tiles( Left, Top, Width, Height, Map-data )                 */
  /*************************************************************************/

  VBK_REG = 1;
  set_bkg_tiles(0,0,recordMapWidth,recordMapHeight,recordPal);

  VBK_REG = 0;
  set_bkg_tiles(0,0,recordMapWidth,recordMapHeight,recordMap);



  /*************************************************************************/
  /* the remaining code init the Gameboy and makes it wait untill you turn */
  /* it off..                                                              */
  /*************************************************************************/

  SHOW_BKG;
  DISPLAY_ON;

   do
   {
   	joy = joypad();
   } while (!joy);
	waitpadup();

  	HIDE_BKG;

   return;
}