Exemple #1
0
void initVideo(void)
{
	/* We need access to DS hardware */
	FeOS_DirectMode();
	vramSetPrimaryBanks (VRAM_A_LCD, VRAM_B_LCD, VRAM_C_SUB_BG_0x06200000, VRAM_D_LCD);
	/* Init video engine for the SUB_SCREEN */
	videoSetModeSub(MODE_5_2D);
	vramSetBankI(VRAM_I_SUB_SPRITE);
	oamEnable(states(SUB_SCREEN));
	oamInit(states(SUB_SCREEN), SpriteMapping_1D_128, false);
	/* Init video engine for the MAIN_SCREEN */
	init3D();
}
void Statue::init()
{
	init_timer(1, 30);
	counter = 0;

	oamClear(&oamMain, 0, 0);
	oamEnable(&oamMain);
	oamInit(&oamMain, SpriteMapping_1D_32, false);

	dmaCopy(statuePal, SPRITE_PALETTE, sizeof(statuePal));
	
	oamSet(	&oamMain, STATUE_SPRITE, 50, 50, /*priority*/1, /*palette*/0,
		SpriteSize_32x64, SpriteColorFormat_16Color, oamGetGfxPtr(&oamMain, STATUE_TILE),
		-1, false, false, false, false, false);

	Game::init();

	writeTimed("\x1b[10;10HDetruis!", 1000);
}
void Aim::init()
{
	init_timer(3, 0);
	counter = 0;

	oamClear(&oamMain, 0, 0);
	oamEnable(&oamMain);
	oamInit(&oamMain, SpriteMapping_1D_32, false);

	dmaCopy(capitalistTiles, oamGetGfxPtr(&oamMain, CAPITALIST_TILE), sizeof(capitalistTiles));
	dmaCopy(capitalistPal, SPRITE_PALETTE, sizeof(capitalistPal));
	dmaCopy(sovietTiles, oamGetGfxPtr(&oamMain, SOVIET_TILE), sizeof(sovietTiles));
	dmaCopy(sovietPal, SPRITE_PALETTE + 16, sizeof(sovietPal));

	for (int i = 0; i <= NUM_SOVIET; ++i)
	{
		frame[i] = rand() % 8;
		anim[i] = rand() % 2;

		oamSet(	&oamMain, SOVIET_SPRITE + i, (rand() % 128) + 32, (rand() % 64) + 32, /*priority*/1, /*palette*/1,
			SpriteSize_64x64, SpriteColorFormat_16Color, NULL,
			-1, false, false, false, false, false);
	}

	for (int i = 0; i < NUM_SOVIET; ++i)
	{
		SpriteEntry* ii = oamMain.oamMemory + SOVIET_SPRITE + i;

		for (int j = i + 1; j <= NUM_SOVIET; ++j)
		{
			SpriteEntry* jj = oamMain.oamMemory + SOVIET_SPRITE + j;
			
			if (ii->y < jj->y)
			{
				int tmp = jj->y;
				jj->y = ii->y;
				ii->y = tmp;
			} 
		}
	}

	capitalist_sprite = rand() % NUM_SOVIET;
	(oamMain.oamMemory + SOVIET_SPRITE + capitalist_sprite)->palette = 0;

	for (int i = 0; i <= NUM_SOVIET; ++i)
	{
		if (i == capitalist_sprite)
		{
			(oamMain.oamMemory + SOVIET_SPRITE + i)->gfxIndex = CAPITALIST_TILE + anim[i]*CAPITALIST_TILE_COUNT;
		}
		else
		{
			(oamMain.oamMemory + SOVIET_SPRITE + i)->gfxIndex = SOVIET_TILE + anim[i]*SOVIET_TILE_COUNT;
		}
	}

	Game::init();

	writeTimed("\x1b[5;15HCamoufle le capitaliste!", 1000);

	bgHide(1);
}