Nyanroll

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
(Wut is this?)
(Wut is this?)
Line 3: Line 3:
 
==Wut is this?==
 
==Wut is this?==
 
[[Image:Screenshot-1.png|thumb|Nyanroll :D]]
 
[[Image:Screenshot-1.png|thumb|Nyanroll :D]]
[http://www.youtube.com/watch?v=ss9q2OZRjag Nyanroll], a minor internet meme, similar in concept to the much more popular [http://en.wikipedia.org/wiki/Rickroll rickroll] except much much more cute!! Here it is used to evaluate the bitmap functionality of [[Thbg|background library]] and [[Nitrofs|NitroFS Filesystem driver]] as well as be a fun proof of concept for playing raw video on the DS.
+
[http://www.youtube.com/watch?v=ss9q2OZRjag Nyanroll], a minor internet meme, similar in concept to the much more popular [http://en.wikipedia.org/wiki/Rickroll rickroll] except much much more cute!! Here it is used to evaluate the bitmap functionality of the currently developing [[Thbg|background library]] and [[Nitrofs|NitroFS Filesystem driver]] as well as be a fun proof of concept for playing raw video on the DS. Also been having frustating issues with [[Thds|thds]] so needed a small break. ^^
  
 
Some features include:
 
Some features include:

Revision as of 05:49, 25 March 2009

Nyan nyan nyan nyan....

Contents

Wut is this?

Nyanroll :D

Nyanroll, a minor internet meme, similar in concept to the much more popular rickroll except much much more cute!! Here it is used to evaluate the bitmap functionality of the currently developing background library and NitroFS Filesystem driver as well as be a fun proof of concept for playing raw video on the DS. Also been having frustating issues with thds so needed a small break. ^^

Some features include:

  • Plays up to 15fps uncompressed video and audio from the flash card, embedded within the nitrofs.
  • Alternate plays mp3 remixes of the nyanroll song
  • Zooming, scrolling, rotating, centering are supported.
  • Looks cute.. :P

Some notes: ø(._. )
Had a thought to add 'subtitles' will consider this...

Where do i get it?

There is a small bug in the rotation code actually, think i just figured it out! but about to sleep so will need to wait.

Technical details

The video was converted from .flv (stolen from youtube >_> <_<) into .avi and then VirtualDub was used to resize to 256x192 resolution and output as a sequence as .bmp images which can then be converted using the bmp2raw utility included with devkitARM.

Next I used a shell script based one the one found on Meraman's WAV&BMP player page with a few changes as follows:

#!/bin/bash
BMP2BIN=$DEVKITPRO/devkitARM/bin/bmp2bin
PREFIX="nyan"
MAX=107
 
COUNTER=0
while [ $COUNTER -lt $MAX ]
do
    FNAME=`printf "$PREFIX%d" $COUNTER`
    echo "Converting $FNAME"
    $BMP2BIN -d $FNAME.bmp $FNAME.raw
    let COUNTER=COUNTER+1
done

Mostly wanted to set a path for the bmp2bin (really i should just add it to my search path) and allow for quickly changing the number of frames and filenames.

Used his suggestion and started with 15fps, which plays fine on one of my cards, however an older DS-X-Treme card will do no further than 3 fps. The vblank interrupt is used to count the elapsed frames, 60 per second. (actually its a little off to be compatible with NTSC television standard of 29.97 FPS i suspect.) This 60fps clock is divided by 4 to give 15fps. This clock continues to run regardless if speed of the flash card, that is, it should remain in sync even if the data from flashcard is too slow to keep up. Code explains it best:

#define MAXFRAMES 107 
#define FRAMERATE 15
#define FRAMEDIV (60/FRAMERATE)
int vbcnt;
int 	fps;
int	fpscnt;
 
void vBlankInt(void) {
	vbcnt++;
	if((vbcnt%60)==0) { //vBlabkInt is also used for fps counter
		fps=fpscnt;
		fpscnt=0;
	}
}
 
//Called during each vblank from main program loop...
void updateVid(int frame) {
	char filename[0x100];
	if((frame%FRAMEDIV)==0) { //get us @ 15fps
                //calculate which frame to display
		sprintf(filename,"nitro:/nyan%d.raw",(frame/FRAMEDIV)%MAXFRAMES); 
		fpscnt++;  //increment fps counter
		FILE *f=fopen(filename,"rb");
		if(f) {
			fread((void*)BGBMPRAM(1,2),sizeof(u16),49152,f);
			fclose(f);
		} else {
			printf("opening %s failed\n",filename);
		}
	}
}
 
sprintf(filename,"nitro:/nyan%d.raw",(frame/FRAMEDIV)%MAXFRAMES);

In this way the video should remain in sync. :D The audio is saved as a .wav file and because its short is loaded into ram off the filesystem and played back using the [[Thsound|thSound] lib functions. Here i sorted cheated <_<... The first few milliseconds of the audio loop is silence, so this was used to an advantage... the audio is restarted for the first 4 frames, then allowed to play untill the animation sequence starts again. This was done because on slower cards it may take several frames before returning to the main program loop, and with this scheme it is more likely the audio will be restarted properly at start of each animation loop.

Okais, more on this tomorrow... sleeepz 4 me ^_^///

Personal tools
irssi scripts
eggdrop scripts