BLINKENmini simulator
---------------------

bmsim is a simulator for the people who do not have the BLINKENmini hardware. It uses two fifos to provide an bmdrv-like interface for programs that use bmdrv with read and write operations. Of course, the ioctls of bmdrv can not be simulated. If you do not know what bmdrv or BLINKENmini is take a look at http://blinkenmini.1stein.no-ip.com/.



Compiling
---------

Since you are reding this, you already unpacked the archive into a directory. So you should be able to compile:

  make

This should create a file named bmsim.



Creating the Fifos
------------------

Now you'll have to create the fifos:

  mknod bmsim.out p
  mknod bmsim.in p



Starting the Simulator
----------------------

Let's start the simulator:

  ./bmsim bmsim.out bmsim.in

You should get a screen with an empty area and two (S)NES-style controllers. The empty area is the display where the movies can be displayed. Try this on another console:

  cp my_movie.bmbm bmsim.out

Then you should see the movie play on the simulator.
The characters in the (S)NES-style controllers can be typed in to simulate input. This input can be shown when you type on another console:

  hexdump bmsim.in

As we've seen, the fifos can be used like bmdrv when the simulator is running.



Output Device
-------------

When writing data to bmsim.out, the data is expected to be in the bmbm-format. This format consists of one or more frames directly behind each other. A frame has got the following format:

<frame> = <size-x><size-y><row>...<row><delay> //size-y times row <row>
<row> = <pixel>...<pixel> //size-x times <pixel>
<size-x> = the width of the frame in pixels as unsigned char
<size-y> = the height of the frame in pixels as unsigned char
<pixel> = the greyscale value of that pixel as unsigned char, 0x00 dark, 0xFF full on
<delay> = the time to hold execution after displaying this frame in steps of 5ms as unsigned char

Do not read from bmsim.out.



Input Device
------------

Do not write to bmsim.in.

When reading from bmsim.in and no data is availible the read-function will block if the file is not opned in nonblocking mode. The data read consists of 4-byte blocks, each block corresponds to a key-press or a key-release, but it is not ensured that only complete blocks are read.

<block>=<sync><press><controller><key>
<sync>=0xFF as unsigned char
<press>=0x00 is key was released or 0x01 if key was pressed as unsigned char
<controller>=number of the controller as unsigned char
<key>=number of the key as unsigned char

