Sunday 14 August 2011

Hanger 18

Back to early 90's - XCOM aka UFO returns (via an open-source remake). Happily, nearly trivial to build on OSX.


Grab the source. Github has a nice OSX client, and the webpages have a wee button to spawn the OSX client and make the git clone process painless.


Get a packaging system for install Unix packages on OSX - the new hotness is Homebrew, in addition to fink or macports. Homebrew has the relevant dependencies, so it works (tm).


brew install yaml-cpp
brew install sdl
brew install sdl_gfx
brew install sdl_mixer


set the pkgconfig tools environment variable to find the installed stuff.


export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig


In the src directory of OpenXcom


make


And tis done. Copy the games data files to the relevant location, and all is well.

Tuesday 9 August 2011

Terminal Illusions

Flocking makes for a nice screen-saver - see here for a nice JS demo, and this pseudocode for a nice, dirt simple explanation. Managing so many objects interacting in space, even 2D, calls for some spatial data structures. The approach of buckets in 1D, and sorting + binary searching in the other dimension seems to work well for my flocking screen saver. 64 bit in Lion (hmm. and Snow Leopard?) break 32 bit screen saver modules (bah!) and also Saver Lab. Can capture screenshots with another OSX command line tool, screencapture.


Simple Flocking ScreenSaver
GDB in Visual Studio - they are working on an Android NDK version,
which could be a great improvement on current tools, if it worked.


The C++ language has plenty of odd corners; but so do the standard libraries, and the cross platform variations. The std::string class can surprise on some platforms with its Copy On Write semantics and the sharing of underlying memory buffers.

Every new version of Windows breeds a new bit of software to handle disk images, see WinCDEmu for Windows 7.


Getting a visa to travel to the states can be done online. The EU should reciprocate with US visitors until this nonsense gets stopped. 


Consider Lockharts lament; replace "maths" with "programming", and ponder on education now. And recall how maths was taught, too. Ick.


The HunSpell spell checker has many dictionaries. The executable can be controlled via pipes from Java. There is a Swedish dictionary from "The Big Swedish Wordlist".


Tuesday 28 June 2011

Not Ready Yet

ConstCPP - C++ with optional mutable state aka const by default.

This blog posting ui is nearly unusable on iPhone - been a while since I found a site with this sort of issue.

Thursday 17 February 2011

Sleepless Nights

To quote a colleague
I want gdb to die in a fire. If thats possible.
A sentiment I can only agree with, to be honest. However, it remains in its spread of variably buggy obsolete forms embedded within the development tool chains of too much of the world to avoid. Some notes on living in the land of the clone of the Unix tools from the 1980s. A link to a GDB reference card. Programmable systems (debuggers like GDB, editors like emacs, typesetting systems like LaTeX) have been universally dire in user experience, in _my_ experience. The intended bonus of programmability becomes a curse of necessity; the burden is placed on the user to make the tool usable in the first place. In essence, I want to write programs to solve _my_ problems; not to solve problems in the tools I use; and _not_ to write programs in the debugger while debugging the interesting program or to debug program errors in a document processor.

A set of optparse documentation for common tasks since, as it notes,
we start new project so seldom, it is difficult to remember all those recipes that we come up with, every time we add a new command line option. This article is an attempt to bring together such recipes.

Python can query its environment for the functions in the current module (which is done slightly differently than for _other_ modules). This is useful for auto-testing, saving the need to write out a function list explicitly. Can embed these gist things into a blog post, too.



After the GDB rant, I confess I don't program gdb much and have not (yet) needed a .gdbinit file to customise GDB in a semi-permanent manner. However, I have some user defined commands to not forget in case I need to stay in GDB a little longer...



JGrowl implements growl style notifications in a web page. Cool, if not immediately useful. Also, drop shadows via CSS.

Can fork multiple threads (well, processes) in bash and then join (wait) for the completion of them. Good for parallelism of shell script controlled processes.


cmd_A &
cmd_B &
wait

Monday 31 January 2011

Left Unfinished


Can build a simple and useful unit test system in python exploiting first class functions, dynamic checks on the names of functions, and a naming convention.


See codepad.org for coloured src and a sample run, or github for a "gist" with highlighted source.

### Begin unit test code


def test_function1():
    # Do some test code
    # return True on Pass, False on Fail


def test_function2_EXPECTED_FAIL():
    # Do some test (more) code
    # return True on Pass, False on Fail


def test_functionN():
    # Do some test (more) code
    # return True on Pass, False on Fail


# Build a list of test functions to run
# as test cases
tests = [ test_function1
        , test_function2_EXPECTED_FAIL
        # as many as you like...
        , test_functionN
        ]


def main():
    failed  = []
    # Invoke each test case in turn
    for t in tests:
        if not t():
            # Can check names of test functions 
            # to detect expected fails
            if t.__name__.endswith("_EXPECTED_FAIL"):
                continue
            # Record fails for later report
            failed.append(t.__name__)
            # Can stop on 1st fail if desired
            # return 1
    # Print the list of tests that failed, if any
    for f in failed:
        print "FAIL:",f
        
# Invoke the test runner
if __name__ == "__main__":
    main()


### End unit test code


Tile based game development tutorial.

A series of blog articles on Maze generation algorithms.

A C pre processor (cpp) in python. A programmers text editor Kod for OSX based on the google chrome tab UI.

Tuesday 25 January 2011

Lore of the Arcane

Compilation of Offload C++ code for the Cell BE processor and the Linux OS entirely within a Linux environment is complicated by the fact that the Offload C++ compiler ("offloadcpp") is a Windows executable. This compiler compiles programs to run on the Cell processor by first compiling Offload C++ code into Cell specific C code; the C is then compiled for the Cell processor using a Cell BE GCC tool chain (GCC and associated utilities) on Windows, via Cygwin. The result is that, on Windows, the compiler can generate a Cell Linux executable with embedded SPU sub-programs automatically.
The below process (described by Paul Keir, thanks!) outlines how the Offload C++ compiler can be used to compile for the Cell from within Linux using Wine. The first stage is to compile the Offload C++ code (your original program) into C code targeting the Cell. The second stage is to compile that generated C code on the Cell using the Cell SDK on the PS3 running Linux.
Note that depending on how your Linux PS3 is setup, it is possible to create a script (e.g. via scp and ssh) to push the generated code onto the PS3, and to subsequently invoke the PS3 compilation process on the PS3 automatically.                                 
                                             
--------------  Stage 1: Linux/Windows ------------

1.  Install Wine on your Linux system.

2.  Copy the Codeplay Offload C++ installation directory from Windows to somewhere convenient on your Linux system.
   
3.  On Linux, set the SIEVESDK environment variable to the offload-cell-linux-sdk directory contained within the installation directory.

4.  Offload may install a Cygwin-compatible Cell Toolchain. By default it will be installed in C:\cygwin\opt\cell .
Place the entire cell directory tree within the /opt/ directory of your Linux system. The Cygwin-compatible PS3 toolchain is also available here: http://sourceforge.net/projects/cellwindowssdk/
The toolchain.7z file there also contains the /opt/cell/... directory tree.

5.  The Offload compiler is now ready to run, though only with the -nomake switch. If you have placed the Offload installation directory at $HOME/apps/codeplay, offloadcpp may be used to compile hello.cpp using the following command:

$ wine $HOME/apps/codeplay/offloadcpp.exe -I$SIEVESDK/include -I/opt/cell/toolchain/include/c++/4.1.1 -I/opt/cell/sysroot/usr/include -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include/c++/powerpc-linux -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include -nomake hello.cpp

An alias may be useful, say "oll":

$ alias oll='wine $HOME/apps/codeplay/offloadcpp.exe -I$SIEVESDK/include -I/opt/cell/toolchain/include/c++/4.1.1 -I/opt/cell/sysroot/usr/include -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include/c++/powerpc-linux -I/opt/cell/toolchain/lib/gcc/powerpc-linux/4.1.1/include'

$ oll -nomake hello.cpp

6.  The result will be a directory called "outputc". This directory must now be transferred to the PS3, before issuing the make command, as described in Step 3. below.

--------------  Stage 2: PlayStation 3 ------------

1.  Copy the offload-cell-linux-sdk directory to the PS3, and set the SIEVESDK environment variable to that location.

2.  Mars should already be installed (mars-1.1.4-1.ppc.rpm), but the development libraries are now also needed, so:

$ wget ftp://ftp.infradead.org/pub/Sony-PS3/mars/1.1.4/mars-devel-1.1.4-1.ppc.rpm
$ rpm -ivh mars-devel-1.1.4-1.ppc.rpm

3.  An "outputc" directory, obtained as in step 5. above, contains a makefile. To complete the compilation of hello.cpp:
    
$ cd outputc
$ make
$ cd ..
$ ./hello