Skip to content

noeamiot/Bad-Apple-on-GRUB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bad Apple !! Played on GRUB

Bad Apple !! But it's on GRUB (2.06 but AFAIK, it should work on older versions). Link to the video

What's GRUB ?

"GNU GRUB (short for GNU GRand Unified Bootloader, commonly referred to as GRUB) is a boot loader package from the GNU Project. GRUB is the reference implementation of the Free Software Foundation's Multiboot Specification, which provides a user the choice to boot one of multiple operating systems installed on a computer or select a specific kernel configuration available on a particular operating system's partitions." Wikipedia

Other useful resources, like documentation, here.

How ?

Every frame of the video Bad Apple !! is saved as a text file in which if the pixel is white, a is written and if it is black, a # is written.

GRUB will simply show the content of each file one by one using the cat command quickly enough to give the illusion of motion. I added the script in a menuentry for clarity.

Can I reproduce it ?

You can, of course ! The framerate will differ but here are the steps to follow :

  • Download video (using youtube-dl for example)
  • Update values and build the getframe.c program
  • Run the getframe program (you can check the result using the display.sh script)
  • Add the grub.cfg content to your grub.cfg and move the frames where GRUB is installed

Why is it challenging ?

The main problem with the scripting language of GRUB is ... the lack of support of arithmetic. So I had to make it possible without additions, which can be useful for doing a loop, for example. The solution I came up with is using variable expansion. We have around 5000 files, all named after their frame number so we will have 4 variables each representing a power of 10. The concatenation of each variable can be used to show a specific frame.

Due to the way I/O work in GRUB, the time to run the script isn't deterministic and the framerate is far from constant.

What did you change for the video ?

First of all, I added the music Bad Apple !! on top of my record as this script does not include sound. I also only showed the frames ending with the numbers 0, 3 and 7 to have a timing similar to the real one (I only had to put the recorded file at 95% to have a result similar to the first video).

We can see errors at the end of the video

Yup, I made the loop to read 6000 files but there are less so GRUB can't find about 500 of them. One could add an if statement to end the script when all the variables are equal to the right values but I'm afraid it would slow down the script (and who cares ?? it's a POC :p).

Can we add sound ?

It is technically possible to add sound between two frames but as each task is done sequentially, one would have to reduce the number of frames to keep a correct framerate as sound in GRUB takes some time. The way of generating the config file would also not be the same, the best answer I can come up with is not using variable expansion and instead programmatically generate a big configuration file with each filename and sound (in the GRUB format).

What other things have you tried ?

GRUB can show image files as a background, so I tried to replace the cat command with backgrounds. Unfortunately due to the way GRUB handles I/O and backgrounds, this just cause the script to freeze a long time and show the last background.

I tried to put every frame in one big text file and have the scroll do the illusion of motion, but it didn't work.

I also tried to increase the speed by using a SSD but the results were even worse.

About

Bad Apple !! But it's on GRUB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published