The firmware to display the graphical effects is completely written in C. It has to do two things: display the swirling textures and overlay all the particles over it.

Getting the image data for the swirling textures proved somewhat more difficult than I thought. I expected them to be among the other material textures inside a big png-file inside the Minecraft main .jar-file, but they were nowhere to be found. Only after decompiling the code with the excellent Minecraft Coder Pack, I found out that the textures are re-calculated every time you start Minecraft, using some nifty floating point algorithm.

Recreating this code in C was fairly easy. Letting the STM32 do all these calculations on-the-fly wouldn't be feasible, though, so I decided to let my PC do the calculations and just spit out 32 16x16 images of the swirl animation. These could then be linked into the STM32s code and end up in it's flash memory. I also was curious what exactly I was looking at: the 16x16 pixels making up the texture don't give away more than that it is some kind of swirl. Now I had the code I could also render it in a larger image size so I could take a look at that magnificent swirl in all it's glory:

...Hokay, that's one texture that's best kept at 16x16 pixels.

The other graphic elements are the particles. They were a bit easier to get: there's a file, aptly named 'particles.png', containing the 8 default particles. To emulate the 3d-effect, I'd need to scale it. Because I had enough flash memory left, I decided to write a small php-script that precalculates the 8 particles scaled to a few sizes, so the STM32 doesn't need to be bothered by the cpu-intensive task of doing the scaling itself.

With everything precalculated, it was time to move on to the STM32s code. I've written it in C and compiled it with gcc using libopenstm32 to do some of the initialisation of the STM32. All these tools and libs can be obtained by running the summon-arm-toolchain script, by the way.

The STM32 code itself isn't that difficult. Basically, it initializes it's own peripherials and the the LCD, and then proceeds to calculate and send the imagery, one line at a time, to the LCD. Every frame, the particles' position and size is adjusted to make it look like the particles are flying into the portal, and that's about it.

« Prev 3 Next »

© 2006-2016 Sprite_tm - Contact