Exemple #1
0
// rulez nyan scene
int main(int argc, char **argv)
{
	bool nyaning = true;

	// self explain
	nyan();
	MP3Player_PlayBuffer(nyannyannyan_mp3, nyannyannyan_mp3_size, NULL);

	VIDEO_SetBlack(FALSE);
	while(nyaning)
	{
		u64 cticks = ticks_to_millisecs(gettime());
		// Loop the sound if ended
		if(!MP3Player_IsPlaying()) MP3Player_PlayBuffer(nyannyannyan_mp3, nyannyannyan_mp3_size, NULL);
		//Check wiimote input
		WPAD_ScanPads();
		u32 pressed = WPAD_ButtonsDown(0);
		if (pressed & WPAD_BUTTON_HOME) nyaning = false;
		// blackscreen until 3,8s like the youtube video (not extreme precison ;))
		if(cticks < startTime+3900) continue;
		// bkg frame counter (tick each 100ms)
		if(cticks > bkgTimeCounter+100)
		{
			bkgTimeCounter = cticks;
			currentBkgStep = (currentBkgStep+1) % BKG_STEP;
		}
		// nyan frame counter (tick each 60ms)
		if(cticks > nyanTimeCounter+60)
		{
			nyanTimeCounter = cticks;
			currentNyanStep = (currentNyanStep+1) % NYAN_STEP;
		}
		// Set the 2d matrix
		guMtxIdentity(GXmodelView2D);
		GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);

		// nyan
		f32 move =  delta % BKG_SIZE;
		f32 x = -move;
		while(x < rmode->fbWidth)
		{
			drawBkgSprite(x, currentBkgStep);
			x += BKG_SIZE;
		}

		// nyan nyan
		drawNyan(-5, 240 - ((NYAN_HEIGHT*8)/2), currentNyanStep);

		// Copy & switch fb
		GX_DrawDone();
		GX_CopyDisp(xfb[wichFb], GX_TRUE);
		VIDEO_SetNextFramebuffer(xfb[wichFb]);
		VIDEO_Flush();
		VIDEO_WaitVSync();
		wichFb ^= 1;
		delta += 8;
	}

	return 0;
}
Exemple #2
0
uint32_t shell(void) {

	uint32_t ch;
	uint8_t buff[4096] = {0}; // buffer to hold input
	uint32_t i; // placeholder in buffer
	uint8_t *print = "print";
	uint8_t *meow = "meow";
	/* Enter our "shell" */

	while (1) {
		i = 0;
		while (1) {
			//get input and echo it to screen
			ch=uart_getc();
			uart_putc(ch);

			//check if return was hit, 
			//if so, terminate string and break out of loop to analyze input
			if (ch == '\r') {
				buff[i] = '\0';
				break;
			}
			//while within the limits of the buffer, keep adding characters
			if (i<4096) {
				buff[i] = ch;
				i++;
			} 
			//if exceeded buffer size, print error and break out of loop
			else {
				printk("chill wif teh input\n");
				break;
			}
		}

		//compare input with list of known commands
		//first check that lengths match
		//then check if content matches
		if (i==5) {
			if(strncmp(print, buff, 5)==0) {
				printk("Hello World\n");
			} else print_err();
		} else if (i == 4) {
			if (strncmp(meow, buff, 4)==0) {
				nyan();
			} else print_err();
		} else print_err();

	}
}
Exemple #3
0
int main() {
	try {
		xp::RexImage nyan("files/nyan.xp");

		/*Flatten all layers into one, respecting transparency.*/
		nyan.flatten();

		/*Flip around the R,G,B values.*/
		/*It is also possible to reference a tile by its index into its layer's tile array.*/
		for (int x = 0; x < nyan.getWidth(); x++) {
			for (int y = 0; y < nyan.getHeight(); y++) {
				xp::RexTile original = *nyan.getTile(0, x, y);
				xp::RexTile modified = original;

				modified.fore_red = original.fore_blue;
				modified.fore_blue = original.fore_green;
				modified.fore_green = original.fore_red;

				nyan.setTile(0, x, y, modified);
			}
		}
		nyan.save("cat.xp");
	}
	catch (xp::Rexception& e) {
		std::cerr << "Exception! " << e.what() << " [" << e.code << "]" << std::endl;
	}

	std::cout << "Successfuly saved, modified, and loaded the file." << std::endl;


	/*The following functions test how long it takes to save and load.*/
#define TESTING_TIME 0
#if TESTING_TIME
	/*These files are 10x10, 20x20, etc.*/
	testTime("files\\10");
	testTime("files\\20");
	testTime("files\\40");
	testTime("files\\80");
	testTime("files\\160");
	testTime("files\\320");
	testTime("files\\640");
	testTime("files\\1280");
	testTime("files\\2500"); //Maximum size REXPaint 1.02 allows
#endif
	return EXIT_SUCCESS;
}
Exemple #4
0
		cat() {std::cout << "cat" << std::endl; nyan();}