Programming Pi Games With Bare Metal Assembly

pifoxWhile the most common use for a Raspberry Pi is probably a media center PC or retro game emulator, the Pi was designed as an educational computer meant to be an easy-to-use system in the hands of millions of students. Team 28 at Imperial College London certainly living up to the Raspberry Pi Foundation’s expectations with their bare metal assembly clone of Star Fox, aptly titled PiFox.

This isn’t the first time a college course has taken up the task of developing software for the Pi without an operating system; a few years ago, Cambridge University started that off with a series of bare metal tutorials for the Pi that included drawing graphics on the screen and playing around with USB keyboards. PiFox greatly expands on what those early tutorials could do, reading an NES joystick from the GPIO pins, sound with DMA, and rendering 3D objects.

If you’d like to build PiFox for yourself, or better yet, expand on the existing build, all the code is up on Github. There’s also a Raspberry Pi emulator for Linux, just in case you have an ARM assembly bug you just can’t scratch with a Raspberry Pi.

[Read more...]

The Sega Mega Drive Dev Kit

segaWhile most homebrew video game development has focused on the original NES, Atari consoles, and has produced a few SNES games, there is another console out there that hasn’t seen much love. Sega’s classic console, the Genesis or Mega Drive, depending on where you’re from, was an extremely capable machine with amazing capabilities for its time. [Chris] figured the Mega Drive would make a good target for an all-in-one development kit, and with a lot of work he managed to put one together.

The standard cartridge for the Genesis or Mega Drive is just a simple ROM chip wired directly into the console’s address space. [Chris] took a cheap FPGA and some dual port ram to create a seamless interface between the modern world and the inside of this ancient console, allowing him to load every Mega Drive game off an SD card, as well as use modern tools to modify old games, or even create new ones.

To demonstrate his dev kit, [Chris] took a copy of Sonic 1, and using the debugger and GDB, gave himself infinite lives. It’s a very cool demonstration, searching through all the commands executed by the Megadrive CPU with the standard Linux debugging tools.Going through the trace, [Chris] found the instruction that decremented that value representing Sonics lives, replaced it with NOPs, in effect giving himself infinite lives. This is a lot like how the Game Genie works, only using much, much better tools.

Of course a USB dev kit wouldn’t be much use if it could only modify existing games. The real power of [Chris]‘ work comes from being able to develop your own demos, games, and homebrew apps.

[Chris] needed to write a small homebrew Mega Drive app for the ROM loader portion of his dev kit using SGDK. Disassembling his own code with the dev kit, he was able to take a look at the instructions, and potentially even modify his loader.

It’s a really impressive technical accomplishment, and something that could be a boon to the extremely small homebrew scene for the Mega Drive. All the boards, code, and everything else are available over on [Chris]‘ github, with the entire project written up on Videos below.

[Read more...]

MiniBloq IDE, Graphical Programming For Robots Of All Sizes


The Arduino IDE only brings the ire of actual EEs and People Who Know Better™, but if you’re teaching robotics and programming to kids, you really don’t want something as simple as a text editor with a ‘compile’ button. For that educational feat, a graphical system would be much better suited. [Julián] has been working for months to build such a tool, and now miniBloq, the graphical programming tool for just about every dev board out there, has a new release.

The idea of a graphical programming language for robotics has been done before, most memorably with the Lego Mindstorms programming interface. That was closed source, of course, and only worked with the magical Lego brick that allowed you to attach motors and sensors to a child’s creation. miniBloq takes the same idea and allows the same programming environment to work with dozens of dev boards for robots of every shape and size. Already, the Pi-Bot, SparkFun RedBot, Maple, Multiplo DuinoBot, and anything based on an Arduino Leonardo works with miniBloq, as will any future dev boards that understand C/C++, Python, or JavaScript. It’s not just for powering motors, either: there’s a few Python and OpenCV tutorials that demonstrate how a robot can track a colored object with a camera.

The current version of miniBloq can be downloaded from the gits, with versions available for Windows and *nix. The IDE is written with wxWidgets, so this could also be easily ported to OS X.

Python With Braces


If there’s one thing about Python that’s slightly disconcerting, it’s the complete lack of braces, or as they’re called in American English, suspenders. A feature of every variety of C, Java, PHP, Perl, and a whole bunch of other very powerful languages, braces make things more legible and don’t rely on precise indentation. [Ruby] and [Eran] have come up with a way to use these punctuation marks with Python in a project they call Python with Braces.

As its name implies, Python with Braces doesn’t care about indentation: you’re free to make you code extremely ugly, or write your code properly in K&R style. Each line is terminated in a semicolon, and blocks of code with only one statement don’t require curly braces, just like C and Java.

Right now [Ruby] and [Eran] have a Windows installer with an OS X package on its way. Executing a Python with Braces script only requires executing it with a ‘pythonb’ executable instead of the normal ‘python’ executable.

Using A Computer To Read Braille


[Matthiew] needed to create a system that would allow a computer to read braille. An electromechanical system would be annoying to develop and would require many hardware iterations as the system [Matthew] is developing evolves. Instead, he came up with a much better solution using a webcam and OpenCV that still gets 100% accuracy.

Instead of using a camera to look for raised or lowered pins in this mechanical braille display, [Matthiew] is using OpenCV to detect the shadows. This requires calibrating the camera to the correct angle, or in OpenCV terms, pose.

After looking at the OpenCV tutorials, [Matthiew] found a demo that undistorts an image of a chess board. Using this same technique, he used fiducials from the ARTag project to correctly calibrate an image of his mechanical braille pins.

As for why [Matthiew] went through all the trouble to get a computer to read braille – something that doesn’t make a whole lot of sense if you think about it – he’s building a braille eBook reader, something that just screams awesome mechanical design. We’d be interested in seeing some more info on that project as well.

Manual Bitcoin Transactions


For something that’s used for such banal transactions like buying drugs and sending the Jamaican bobsled team to the Olympics, cryptocurrencies such as Bitcoin are actually very impressive pieces of software. It’s a very ingenious solution to the Two Generals Problem, and the fact it made a few Bitcoin early adopters very, very rich doesn’t hurt either. [Ken Shirriff] decided to take a look at the Bitcoin protocol by creating a Bitcoin address and transferring a small amount of bitcoin to that address, manually. It’s a great look at how the Bitcoin protocol actually works, and how ingenious this protocol actually is.

[Ken]‘s first task was to create a Bitcoin address. This is a 256-bit private key is the basis for the Bitcoin wallet private key (after being encoded as ASCII characters), and as the 512-bit public key (after being sent through an elliptic curve algorithm). The 512-bit public key is then hashed with SHA-256 and RIPEM 160 to generate the 160-bit public key hash and the Bitcoin address.

After creating a bitcoin address and wallet, [Ken] set out on manually creating a transaction. The idea was to buy a few cents (USD) from Coinbase and send them to his manually created address. This involved creating a transaction according to the Bitcoin spec and signing the transaction. Signing each Bitcoin transaction is the key to Bitcoin’s security, and is done with a small bit of code written in the Bitcoin scripting language.

With everything written in Python, [Ken] was ready to send his transaction off into the Bitcoin network. This was done by finding a few peers on the Bitcoin network and sending off a few packets. After a little bit of mining on the network, [Ken]‘s transaction went through, confirmed by a deposit into his Bitcoin wallet.

It’s an awesome writeup and impressive achievement to manually send a few Bitcoins from one wallet to another. More impressively, [Ken] provided some amazing insight into how the Bitcoin protocol works, and how much work went into its creation.

International Obfuscated C Code Contest Winners Posted


The International Obfuscated C Contest – the contest to create the most useful, useless, or unique program in absolutely unreadable C code – has just posted the winners of the 2013 contest.

Of the entries of note, a few really stand out. The pic at the top of this post, for instance, comes courtesy of this submission. It’s an iterative ray tracer stuck inside an infinite loop that, when left running overnight, is able to produce amazing renders.

An IOCCC contest wouldn’t be complete without some ASCII art C code, and this entry fits the bill. It’s a Tetris painting tool that creates images made out of tetronomoes. Each image is built up one line at a time from the bottom up, using Tetris’ lack of physics to create a picture out of un-cleared lines.

One of the most impressive entries for this (last?) year’s contest is a tiny 8086 PC emulator/virtual machine written in only 4043 bytes of code. It’s a fully functional 80s-era PC emulator that can run vintage copies of AutoCAD, Windows, Lotus 1-2-3, and SimCity.

All the submissions are awesome, but like any IOCCC contest, there aren’t actually any winners. Or they’re all winners. The Obfuscated rules aren’t very clear in that regard.