From ProjectWiki
Jump to: navigation, search

Nyan nyan nyan nyan....


What 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 fairly mature NitroFS Filesystem driver as well as be fun 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.
  • cute appearance.. :P

Heres a youtube vid... sry, my cam is not great u_u;;

Changes for v0.3:

  • added NDS_POWER power management driver. Now closing the lid puts it into sleep mode, yay! :D
  • removed some debug code from thmp3 lib so that startup messages appear properly
  • updated top title screen gfx

Some notes: ø(._. )

  • It would be better and faster to load the animations from one continuous file rather than buncha individual files for each frame as am doing currently. Opening files has considerably more overhead than just reading and rewinding the same file... This could be done relatively simply using 'cat'
  • Had a thought to add 'subtitles' will consider this... nice thought but meh...

Where do i get it?

Here is the .nds, should work on most cards and emulators, enjoy...If you have problems and are using a GBA memory cart, try removing it... (will fix this soon ^^)
nyanroll.nds v0.3 nyanroll source code

Due to demand and because it was April 1st have created a rickroll version too with a few changes, it is found here:

Rickroll variant... >_> <_<

rickroll.nds v0.1
rickroll source code
Rickroll has all features of nyanroll, except:

  • ~30 seconds of video @ 10fps
  • adpcm audio
  • audio sync in vblank interrupt, in this way it most always stays locked and restarts properly even on slow cards (this was solved differently in nyanroll)
  • Rickroll video

Source code requires devkitArm, libnds, and libthds to compile.

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:

if [ -n "$INPREFIX" ]&&[ -n "$OUTPREFIX" ]&&[ -n "$MAX" ]; then
        while [ $COUNTER -lt $MAX ]
            FNAME=`printf "$INPREFIX%d" $COUNTER`
            FNAMEOUT=`printf "$OUTPREFIX%d" $COUNTER`
            echo "Converting $FNAME to $FNAMEOUT"
            $BMP2BIN -d $FNAME.bmp $FNAMEOUT.raw
            let COUNTER=COUNTER+1
        echo "Usage: $0 inprefix outprefix numframes"

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. Could improve the script by utilizing argument variables $1 and $2 so to determine PREFIX and MAX values from the command line such as: ./vidconv.sh nyan 107 [Done 2009.03.3]

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
int vbcnt;
int 	fps;
int	fpscnt;
void vBlankInt(void) {
	if((vbcnt%60)==0) { //vBlabkInt is also used for fps counter
//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
		fpscnt++;  //increment fps counter
		FILE *f=fopen(filename,"rb");
		if(f) {
		} else {
			printf("opening %s failed\n",filename);

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 lib functions. With nyanroll.nds 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 until 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.

A better way to keep the audio in sync, and was used on rickroll.nds, would be to start the audio from the vblank interrupt. This was not done here (yet?) because there is also the unsync'd mp3 playback option which would require creating a global variable to keep track of which mode its in, one of either WAV or mp3 mode. No big deal rly just I dislike globals when possible as a matter of style.

Okais, more on this later...

Personal tools
irssi scripts
eggdrop scripts