Nyanroll

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
m (Protected "Nyanroll": fuck you spammers srsly...wtf [edit=autoconfirmed:move=autoconfirmed] (expires 07:49, 1 September 2010 (UTC)))
Line 1: Line 1:
<big>Nyan nyan nyan nyan....</big>
+
=[http://ucozisit.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
 +
&lt;big&gt;Nyan nyan nyan nyan....&lt;/big&gt;
 
__TOC__
 
__TOC__
 
==What is this?==
 
==What is this?==
Line 18: Line 19:
 
* updated top title screen gfx
 
* updated top title screen gfx
  
Some notes: ø(._. )<br>
+
Some notes: ø(._. )&lt;br&gt;
 
* 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'
 
* 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'
* <s>Had a thought to add 'subtitles' will consider this...</s> nice thought but meh...
+
* &lt;s&gt;Had a thought to add 'subtitles' will consider this...&lt;/s&gt; nice thought but meh...
  
 
==Where do i get it?==
 
==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 ^^)'''<br>
+
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 ^^)'''&lt;br&gt;
 
[http://blea.ch/~eris/litter/nyanroll.nds nyanroll.nds v0.3]
 
[http://blea.ch/~eris/litter/nyanroll.nds nyanroll.nds v0.3]
 
[http://blea.ch/~eris/litter/nyanroll.tar.bz2 nyanroll source code]
 
[http://blea.ch/~eris/litter/nyanroll.tar.bz2 nyanroll source code]
  
Due to demand and because it was [http://en.wikipedia.org/wiki/April_fools April 1st] have created a rickroll version too with a few changes, it is found here:<br>
+
Due to demand and because it was [http://en.wikipedia.org/wiki/April_fools April 1st] have created a rickroll version too with a few changes, it is found here:&lt;br&gt;
[[Image:Screenshot.png|thumb|left|Rickroll variant... >_> <_<]]
+
[[Image:Screenshot.png|thumb|left|Rickroll variant... &gt;_&gt; &lt;_&lt;]]
[http://blea.ch/~eris/litter/rickroll.nds rickroll.nds v0.1]  <br>
+
[http://blea.ch/~eris/litter/rickroll.nds rickroll.nds v0.1]  &lt;br&gt;
[http://blea.ch/~eris/litter/rickroll.tar.bz2 rickroll source code]<br>
+
[http://blea.ch/~eris/litter/rickroll.tar.bz2 rickroll source code]&lt;br&gt;
 
Rickroll has all features of nyanroll, except:
 
Rickroll has all features of nyanroll, except:
 
* ~30 seconds of video @ 10fps
 
* ~30 seconds of video @ 10fps
Line 42: Line 43:
  
 
==Technical details==
 
==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.
+
The video was converted from .flv (stolen from youtube &gt;_&gt;) 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 [http://meraman.dip.jp/index.php?NDS_Chap13 WAV&BMP player] page with a few changes as follows:
+
Next I used a shell script based one the one found on Meraman's [http://meraman.dip.jp/index.php?NDS_Chap13 WAV&amp;BMP player] page with a few changes as follows:
<source lang="bash">
+
&lt;source lang=&quot;bash&quot;&gt;
 
#!/bin/bash
 
#!/bin/bash
 
BMP2BIN=$DEVKITPRO/devkitARM/bin/bmp2bin
 
BMP2BIN=$DEVKITPRO/devkitARM/bin/bmp2bin
Line 52: Line 53:
 
MAX=$3
 
MAX=$3
  
if [ -n "$INPREFIX" ]&&[ -n "$OUTPREFIX" ]&&[ -n "$MAX" ]; then
+
if [ -n &quot;$INPREFIX&quot; ]&amp;&amp;[ -n &quot;$OUTPREFIX&quot; ]&amp;&amp;[ -n &quot;$MAX&quot; ]; then
 
         COUNTER=0
 
         COUNTER=0
 
         while [ $COUNTER -lt $MAX ]
 
         while [ $COUNTER -lt $MAX ]
 
         do
 
         do
             FNAME=`printf "$INPREFIX%d" $COUNTER`
+
             FNAME=`printf &quot;$INPREFIX%d&quot; $COUNTER`
             FNAMEOUT=`printf "$OUTPREFIX%d" $COUNTER`
+
             FNAMEOUT=`printf &quot;$OUTPREFIX%d&quot; $COUNTER`
             echo "Converting $FNAME to $FNAMEOUT"
+
             echo &quot;Converting $FNAME to $FNAMEOUT&quot;
 
             $BMP2BIN -d $FNAME.bmp $FNAMEOUT.raw
 
             $BMP2BIN -d $FNAME.bmp $FNAMEOUT.raw
 
             let COUNTER=COUNTER+1
 
             let COUNTER=COUNTER+1
 
         done
 
         done
 
else
 
else
         echo "Usage: $0 inprefix outprefix numframes"
+
         echo &quot;Usage: $0 inprefix outprefix numframes&quot;
 
fi
 
fi
  
</source>
+
&lt;/source&gt;
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.<s> 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</s> [Done 2009.03.3]
+
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.&lt;s&gt; 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&lt;/s&gt; [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:
 
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:
<source lang="c">
+
&lt;source lang=&quot;c&quot;&gt;
 
#define MAXFRAMES 107  
 
#define MAXFRAMES 107  
 
#define FRAMERATE 15
 
#define FRAMERATE 15
Line 91: Line 92:
 
if((frame%FRAMEDIV)==0) { //get us @ 15fps
 
if((frame%FRAMEDIV)==0) { //get us @ 15fps
 
                 //calculate which frame to display
 
                 //calculate which frame to display
sprintf(filename,"nitro:/nyan%d.raw",(frame/FRAMEDIV)%MAXFRAMES);  
+
sprintf(filename,&quot;nitro:/nyan%d.raw&quot;,(frame/FRAMEDIV)%MAXFRAMES);  
 
fpscnt++;  //increment fps counter
 
fpscnt++;  //increment fps counter
FILE *f=fopen(filename,"rb");
+
FILE *f=fopen(filename,&quot;rb&quot;);
 
if(f) {
 
if(f) {
 
fread((void*)BGBMPRAM(1,2),sizeof(u16),49152,f);
 
fread((void*)BGBMPRAM(1,2),sizeof(u16),49152,f);
 
fclose(f);
 
fclose(f);
 
} else {
 
} else {
printf("opening %s failed\n",filename);
+
printf(&quot;opening %s failed\n&quot;,filename);
 
}
 
}
 
}
 
}
 
}
 
}
  
</source>
+
&lt;/source&gt;
  
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. 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.
+
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. With nyanroll.nds i sorted cheated &lt;_&lt;... 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.  
 
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.  

Revision as of 00:25, 24 November 2010

This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page

<big>Nyan nyan nyan nyan....</big>

Contents

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: ø(._. )<br>

  • 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'
  • <s>Had a thought to add 'subtitles' will consider this...</s> 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 ^^)<br> 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:<br>

Rickroll variant... >_> <_<

rickroll.nds v0.1 <br> rickroll source code<br> 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: <source lang="bash">

  1. !/bin/bash

BMP2BIN=$DEVKITPRO/devkitARM/bin/bmp2bin INPREFIX=$1 OUTPREFIX=$2 MAX=$3

if [ -n "$INPREFIX" ]&&[ -n "$OUTPREFIX" ]&&[ -n "$MAX" ]; then

       COUNTER=0
       while [ $COUNTER -lt $MAX ]
       do
           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
       done

else

       echo "Usage: $0 inprefix outprefix numframes"

fi

</source> 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.<s> 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</s> [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: <source lang="c">

  1. define MAXFRAMES 107
  2. define FRAMERATE 15
  3. 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); } } }

</source>

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