<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dave&#039;s blog of art and programming &#187; howto</title>
	<atom:link href="http://www.pawfal.org/dave/blog/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pawfal.org/dave/blog</link>
	<description>missing acceptable use policy</description>
	<lastBuildDate>Wed, 08 Feb 2012 12:11:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Betablocker DS code patterns (part 1)</title>
		<link>http://www.pawfal.org/dave/blog/2012/01/betablocker-ds-code-patterns-1/</link>
		<comments>http://www.pawfal.org/dave/blog/2012/01/betablocker-ds-code-patterns-1/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 17:05:36 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[livecoding]]></category>
		<category><![CDATA[visual programming]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=2485</guid>
		<description><![CDATA[Some useful Betablocker DS code patterns as used in common live coding situations.
Firstly, when carrying out a sound check before a live performance it's important to keep some kinds of sound engineers happy generating as many different sounds as you can so they can fiddle around with stuff - of course remember to turn everything [...]]]></description>
			<content:encoded><![CDATA[<p>Some useful <a href="http://www.pawfal.org/dave/index.cgi?Projects/BetablockerDS">Betablocker DS</a> code patterns as used in common live coding situations.</p>
<p>Firstly, when carrying out a sound check before a live performance it's important to keep some kinds of sound engineers happy generating as many different sounds as you can so they can fiddle around with stuff - of course remember to turn everything up to 8 when asked to make the loudest sound you can in order to leave some overhead to blow the PA.</p>
<p>This is a betablocker program which will play all the sounds in a sound bank at all frequencies. Add more concurrent threads to make it more interesting. Values interpreted as pointers are visualised as arrows:</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2012/01/bbds-sndchk1.png"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2012/01/bbds-sndchk1.png" alt="" title="bbds-sndchk" width="300" height="92" class="alignnone size-full wp-image-2489" /></a><br />
(the instruction set description can be <a href="http://www.pawfal.org/dave/images/bbds-page2.png">found here</a>)</p>
<p>In betablocker the beat is always locked to the instruction cycle rate, so fast changing sounds are a matter of optimisation. One of the most common ways around this (and a good way to start things off in a gig) is to use one fast loop program for playing sounds while another slower program modifies the first by overwriting bits of it. </p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2012/01/bbds-xorrave.png"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2012/01/bbds-xorrave.png" alt="" title="bbds-xorrave" width="350" height="157" class="alignnone size-full wp-image-2492" /></a></p>
<p>More to follow in this series. See also <a href="http://www.pawfal.org/dave/blog/2011/10/evolving-musical-bytecode-3/">evolved betablocker genetic programs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2012/01/betablocker-ds-code-patterns-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run your own Germination X server</title>
		<link>http://www.pawfal.org/dave/blog/2011/11/run-your-own-germination-x-server/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/11/run-your-own-germination-x-server/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 13:14:21 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[clojure]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lirec]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=2389</guid>
		<description><![CDATA[We are in the process of moving the Germination X game to a new server, which gives me the chance to properly document the steps required to set it up - this is based on a clean Debian Squeeze 6.0.1 box on Linode.
Step 1: Get the source and Clojure installed
sudo apt-get install subversion
svn co http://svn.lirec.eu/scenarios/GerminationX/
wget [...]]]></description>
			<content:encoded><![CDATA[<p>We are in the process of moving the Germination X game to a new server, which gives me the chance to properly document the steps required to set it up - this is based on a clean Debian Squeeze 6.0.1 box on <a href="http://www.linode.com/">Linode</a>.</p>
<p><b>Step 1: Get the source and Clojure installed</b></p>
<p>sudo apt-get install subversion<br />
svn co http://svn.lirec.eu/scenarios/GerminationX/<br />
wget https://raw.github.com/technomancy/leiningen/stable/bin/lein<br />
cp lein /usr/bin; sudo chmod +x /usr/bin/lein<br />
sudo apt-get install default-jdk<br />
cd GerminationX/oak<br />
lein deps <i>(automatically installs all the clojure dependancies)</i><br />
cp fatjars/* lib/ <i>(installs the FAtiMA precompiled jars)</i></p>
<p><b>Step 2: Install mongodb</b> (used to store the game world)</p>
<p>sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10<br />
add: "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" to /etc/apt/sources.list<br />
sudo apt-get update<br />
sudo apt-get install mongodb-10gen</p>
<p>Once the server is running, you can browse the database (players and tiles containing plants) using the "mongo" console, the database is called "oak".</p>
<p><b>Step 3: Start the server</b></p>
<p>Configure core.clj to build a new world (see comments in source) and test by running as normal user (WARNING: this is not secure!!! - only for testing!!!)</p>
<p>./run.sh</p>
<p>This will start the game server printing output to stderr/stdout, and after a while the three plant spirit FAtiMA processes. Wait a moment then check port 8001 - the game should be running. Once checked, comment out world building in core.clj and kill the 4 java processes.</p>
<p><b>Step 4: Locking down the game server</b></p>
<p>For reasons of security the game server should be run as a user with very restricted permissions - this means if someone finds a way to run commands via the process in some way, they wouldn't be able to do much to the server except access some game data. The standard user for this is called "www-data".</p>
<p>sudo chown www-data:www-data public<br />
sudo chown www-data:www-data public/log.txt<br />
sudo ./server.sh start<br />
Check port 8001</p>
<p>Check the server is running with "sudo ./server.sh status" or stop it with "sudo ./server.sh stop". This code was based on a similar script for <a href="http://naked-on-pluto.net">Naked on Pluto</a>, thanks to <a href="http://0xa.kuri.mu/">Aymeric</a>! The game logs it's stdout/stderr output in /var/log/oak-server-8001.log while some in-game logging currently goes to public/log.txt (so it can be visible from a browser).</p>
<p>We are also running the game via apache using a reverse proxy, (again based on the setup used for NoP) this gives us an added layer of protection/load management etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/11/run-your-own-germination-x-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Isometric engineering</title>
		<link>http://www.pawfal.org/dave/blog/2011/09/isometric-engineering/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/09/isometric-engineering/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 15:22:27 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[groworld]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lirec]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=2231</guid>
		<description><![CDATA[The first report from south western Sweden where I am on unofficial residency/hacking retreat in the environs of the Tjärnö Marine Research Laboratory. 
This is a great place for my main task, to focus on Germination X, and I'm starting with new isometric ground tiles. I'm aiming for the feeling of roots and interconnectedness with [...]]]></description>
			<content:encoded><![CDATA[<p>The first report from south western Sweden where I am on unofficial residency/hacking retreat in the environs of the Tjärnö Marine Research Laboratory. </p>
<p>This is a great place for my main task, to focus on Germination X, and I'm starting with new isometric ground tiles. I'm aiming for the feeling of roots and interconnectedness with just a whiff of geological process.</p>
<p>Germination X is about thinking by sketching, and this started with a couple of rough drawings playing with different pathways across squares. If the connection points are kept consistent they fit together to build cubes, and automatically, the cubes joined together too.</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso1.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso1-300x182.jpg" alt="" title="iso1" width="300" height="182" class="alignnone size-medium wp-image-2232" /></a> <a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso2.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso2-300x273.jpg" alt="" title="iso2" width="300" height="273" class="alignnone size-medium wp-image-2233" /></a></p>
<p>I also thought that varying the widths of the paths would be more interesting, and built a kind of template from the master Germination X cube.</p>
<p>If I kept to these guidelines the plan should work - but I wasn't sure how it the end effect would actually look. Using the template (visible underneath the paper, still in analogue mode) I drew five different variations of these pathway cubes.</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso3.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso3-300x287.jpg" alt="" title="iso3" width="300" height="287" class="alignnone size-medium wp-image-2234" /></a> <a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso4.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/09/iso4-300x243.jpg" alt="" title="iso4" width="300" height="243" class="alignnone size-medium wp-image-2235" /></a></p>
<p>After a bit of fixing and colouring in the gimp, this is an example chunk of world rendered in the Germination X 2D engine. Although the lining up is still not perfect, I like the roughness. Any combination of cubes will fit, you can swap any one for any other without breaking the pattern. The only tricky bit is that the random number generator is seeded from the position of the cubes, so the same pattern is generated consistently for any part of the world without having to store anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/09/isometric-engineering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS2 homebrew #5</title>
		<link>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-5/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-5/#comments</comments>
		<pubDate>Wed, 11 May 2011 06:53:23 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[accidental art]]></category>
		<category><![CDATA[fluxus hacking]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1974</guid>
		<description><![CDATA[Getting stuff to work on PS2 wasn't quite as easy as I probably made it sound in the last homebrew post. The problem with loading code from usb stick is that there is no way to debug anything, no remote debugging, no stdout - not even any way to render text unless you write your [...]]]></description>
			<content:encoded><![CDATA[<p>Getting stuff to work on PS2 wasn't quite as easy as I probably made it sound in the last homebrew post. The problem with loading code from usb stick is that there is no way to debug anything, no remote debugging, no stdout - not even any way to render text unless you write your own program to do that.</p>
<p>The trick is to use the fact that we are rendering a CRT TV signal and that you can control what gets rendered in the overscan area (think 8bit loading screens). There is a register which directly sets the background colour of the scanline - this macro is all you need:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#004a43; '>#</span><span style='color:#004a43; '>define</span><span style='color:#004a43; '> gs_p_bgcolor        0x120000e0    </span><span style='color:#696969; '>// Set CRTC background color</span>

<span style='color:#004a43; '>#</span><span style='color:#004a43; '>define</span><span style='color:#004a43; '> GS_SET_BGCOLOR</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>r</span><span style='color:#808030; '>,</span><span style='color:#004a43; '>g</span><span style='color:#808030; '>,</span><span style='color:#004a43; '>b</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> \</span>
<span style='color:#004a43; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#808030; '>*</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>volatile unsigned long </span><span style='color:#808030; '>*</span><span style='color:#808030; '>)</span><span style='color:#004a43; '>gs_p_bgcolor </span><span style='color:#808030; '>=</span><span style='color:#004a43; '>    \</span>
<span style='color:#004a43; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>unsigned long</span><span style='color:#808030; '>)</span><span style='color:#808030; '>(</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>r</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> </span><span style='color:#808030; '>&amp;</span><span style='color:#004a43; '> 0x000000FF</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> </span><span style='color:#808030; '>&lt;</span><span style='color:#808030; '>&lt;</span><span style='color:#004a43; '>  0 </span><span style='color:#808030; '>|</span><span style='color:#004a43; '> \</span>
<span style='color:#004a43; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>unsigned long</span><span style='color:#808030; '>)</span><span style='color:#808030; '>(</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>g</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> </span><span style='color:#808030; '>&amp;</span><span style='color:#004a43; '> 0x000000FF</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> </span><span style='color:#808030; '>&lt;</span><span style='color:#808030; '>&lt;</span><span style='color:#004a43; '>  8 </span><span style='color:#808030; '>|</span><span style='color:#004a43; '> \</span>
<span style='color:#004a43; '>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>unsigned long</span><span style='color:#808030; '>)</span><span style='color:#808030; '>(</span><span style='color:#808030; '>(</span><span style='color:#004a43; '>b</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> </span><span style='color:#808030; '>&amp;</span><span style='color:#004a43; '> 0x000000FF</span><span style='color:#808030; '>)</span><span style='color:#004a43; '> </span><span style='color:#808030; '>&lt;</span><span style='color:#808030; '>&lt;</span><span style='color:#004a43; '> 16</span>
</pre>
<p>Which you can use to set the background to green for example:</p>
<pre style='color:#000000;background:#ffffff;'>GS_SET_BGCOLOR<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>0,255,0</span><span style='color:#808030; '>)</span><span style='color:#696969; '>;</span>
</pre>
<p>Its a good idea to change this at different points in your program. When you get a crash the border colour it's frozen with will tell you what area it was last in, allowing you to track down errors. </p>
<p>There is also a nice side effect that this provides a visual profile of your code at the same time. Rendering is synced to the vertical blank - when the CRT laser shoots back to the top of the screen a new frame is started and you have a 50th of a second (PAL) to get everything done. In the screenshot below you can see how the frame time breaks down rendering 9 animated primitives - and why it might be a good idea to use some of these other processors:</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/debug.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/debug-1024x768.jpg" alt="" title="debug" width="1024" height="768" class="alignnone size-large wp-image-1975" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS2 homebrew #4</title>
		<link>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-4/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-4/#comments</comments>
		<pubDate>Tue, 10 May 2011 07:58:29 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[fluxus hacking]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1959</guid>
		<description><![CDATA[
Getting things to render on the PS2 is a little more complicated than using OpenGL and it's also a very different system to a PC. On the right you can see a block diagram of the Emotion Engine - it consists of the EE core, the CPU on the left and the GS - Graphics [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/ps2_block_diagram.gif"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/ps2_block_diagram.gif" alt="" title="ps2_block_diagram" width="437" height="334" class="alignright size-full wp-image-1961" /></a></p>
<p>Getting things to render on the PS2 is a little more complicated than using OpenGL and it's also a very different system to a PC. On the right you can see a block diagram of the Emotion Engine - it consists of the EE core, the CPU on the left and the GS - Graphics Synthesiser, on the right. In between are 2 other processors called Vector Units - very fast processors designed to do things to vectors - points, colours etc.</p>
<p>All the Graphics Synthesiser can do is rasterise 2D shapes with points given in screen space and do your texturing & gouraud shading for you. It can draw points, lines, triangles or quads in various configurations (similar to OpenGL). However all the 3D transformations and lighting calculations have to happen elsewhere - in one, or both of the Vector Units or the CPU.</p>
<p>So how do we get the GS to render something? Well you send it chunks of data, called GS Packets, that look a little like this:</p>
<p>GIF Tag 1<br />
Primitive data<br />
GIF Tag 2<br />
Primitive data<br />
...</p>
<p>The GIF Tags contain information on what sort of primitive it should draw and how the primitive data is laid out. The primitive data is the same as the primitive data in fluxus - vertex positions, colours, texture coordinates, texture data etc.</p>
<p>Once I had tinyscheme and the basic scenegraph working that the minimal fluxus build uses, I wrote a <a href="https://gitorious.org/flotsam/flotsam/blobs/master/android/fluxus/jni/engine/ps2-renderer.h">very simple renderer</a> running on the EE core to apply the transformation matrices to the primitives (with similar push and pop to OpenGL). It doesn't calculate lighting at the moment, so it's just setting the vertex colours to the normal's values for debugging. This is a literal photographic screen shot of my PS2 running exactly the same <a href="http://www.pawfal.org/dave/blog/2011/04/more-android-tinkering/">test fluxus script as the android was running</a>:</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/DSC00759.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/DSC00759-1024x768.jpg" alt="" title="DSC00759" width="1024" height="768" class="alignnone size-large wp-image-1960" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS2 homebrew #3</title>
		<link>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-3/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-3/#comments</comments>
		<pubDate>Mon, 09 May 2011 08:23:47 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[fluxus hacking]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1954</guid>
		<description><![CDATA[The next thing I wanted to do was see if I could compile the minimal android version of fluxus for the PS2. All the PS2SDK examples are written in C, and when I tried the C++ compiler at link time I got a bunch of these odd errors:
ps2-main.cpp: undefined reference to `__gxx_personality_v0'
It turns out the [...]]]></description>
			<content:encoded><![CDATA[<p>The next thing I wanted to do was see if I could compile the minimal android version of fluxus for the PS2. All the PS2SDK examples are written in C, and when I tried the C++ compiler at link time I got a bunch of these odd errors:</p>
<p>ps2-main.cpp: undefined reference to `__gxx_personality_v0'</p>
<p>It turns out the C++ compiler does not support exceptions so you need to add this line to the makefile: </p>
<p>EE_CXXFLAGS += -fno-exceptions</p>
<p>The other thing to get used to is one of the side effects of a machine with so many processors is that you need send lots of data around between them using DMA transfer, or direct memory access. DMA works on chunks of memory at a time, so your data needs to be aligned on particular byte boundaries. This sounds a lot more complicated than it is in practice (although it does lead to really obscure bugs if you get it wrong).</p>
<p>For instance, when making arrays on the heap you can do this:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#800000; font-weight:bold; '>struct</span> my_struct
<span style='color:#800080; '>{</span>
    <span style='color:#800000; font-weight:bold; '>int</span> an_int<span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>float</span> my_array<span style='color:#808030; '>[</span><span style='color:#008c00; '>8</span><span style='color:#808030; '>]</span> __attribute__<span style='color:#808030; '>(</span><span style='color:#808030; '>(</span>__aligned__<span style='color:#808030; '>(</span><span style='color:#008c00; '>16</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>float</span> a_float<span style='color:#800080; '>;</span>
<span style='color:#800080; '>}</span><span style='color:#800080; '>;</span>
</pre>
<p>Which tells gcc to sort it out for you by forcing the pointer to my_array to fall on a 16 byte boundary.</p>
<p>When allocating from the heap the EE kernel provides you with a memalign version of malloc:</p>
<pre style='color:#000000;background:#ffffff;'><span style='color:#800000; font-weight:bold; '>float</span> <span style='color:#808030; '>*</span>some_floats<span style='color:#808030; '>=</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>float</span><span style='color:#808030; '>*</span><span style='color:#808030; '>)</span>memalign<span style='color:#808030; '>(</span><span style='color:#008c00; '>128</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>float</span><span style='color:#808030; '>)</span> <span style='color:#808030; '>*</span> <span style='color:#008c00; '>100</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
</pre>
<p>The pointer some_floats will be aligned to a 128 byte boundary. This works as normal with free().</p>
<p>At this point, other than a few changes to tinyscheme for string functions that don't exist on the PS2 libraries, most of the fluxus code was building. The only problem was the OpenGL ES code, as although the PS2 has some attempts at libraries that work a bit like OpenGL, the real point of playing with this machine is to write your own realtime renderer. a bit more on that next...</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS2 homebrew #2</title>
		<link>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-2/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-2/#comments</comments>
		<pubDate>Sun, 08 May 2011 09:13:42 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[homebrew]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1943</guid>
		<description><![CDATA[Once you have a system for running unauthorised code, you can test it with some well used homebrew - I used uLaunchElf for this purpose. Using swapmagic you need to put the executable on your usb stick called SWAPMAGIC/SWAPMAGIC.ELF and it should boot automatically. Not all usb sticks work, I had to try a few [...]]]></description>
			<content:encoded><![CDATA[<p>Once you have a system for running unauthorised code, you can test it with some well used homebrew - I used <a href="http://ps2ulaunchelf.pbworks.com/w/page/19520134/FrontPage">uLaunchElf</a> for this purpose. Using swapmagic you need to put the executable on your usb stick called SWAPMAGIC/SWAPMAGIC.ELF and it should boot automatically. Not all usb sticks work, I had to try a few before I found a suitable one.</p>
<p>The next task is installing the toolchain of compilers and related utilities for making your own executables. At this point I found that the <a href="http://ps2dev.org/">ps2dev</a> site was offline along with it's svn repo, but I managed to find a backup <a href="http://bucket.jim.sh/ps2dev-svn/">here</a>, which I am now mirroring <a href="http://www.pawfal.org/dave/files/psx/">here</a>. When you have the svn repo recreated, follow the instructions in ps2dev/trunk/ps2toolchain/readme.txt to build and install, you just need to set up some paths to tell it where to install (I use ~/opt) and run a script. The script tries to update from the unresponsive official svn, so I also had to change ps2toolchain/scripts/005-ps2sdk.sh to get it to complete.</p>
<p>You get a load of sample code in ps2dev/ps2sdk/samples, all you need to do is run make to build them. Just as with the Nintendo DS and Android devices, the compiler is gcc - or rather "ee-gcc". "ee" stands for the Emotion Engine, Sony's name for the main MIPS processor.</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/ps2dev.png"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/ps2dev-300x169.png" alt="" title="ps2dev" width="300" height="169" class="alignnone size-medium wp-image-1945" /></a></p>
<p>The result of the make command in the exciting screenshot above is a file called "cube.elf". ELF stands for Executable and Linkable Format, a unix standard (debugging variants used to be called DWARFs "Debugging With Attributed Record Formats", I make no comment).</p>
<p>Copy this to your USB stick and you should see something like this:</p>
<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/DSC00777.jpg"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/DSC00777-300x225.jpg" alt="" title="DSC00777" width="300" height="225" class="alignnone size-medium wp-image-1948" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PS2 homebrew #1</title>
		<link>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-1/</link>
		<comments>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-1/#comments</comments>
		<pubDate>Sat, 07 May 2011 20:49:09 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[homebrew]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1918</guid>
		<description><![CDATA[Reuse is the better form of recycling, and the machines that we all increasingly use are fabulous concoctions of various plastics, metals and ceramic compounds. It's simply shortsighted to treat them as throwaway items. With this in mind, and lacking a computer I can use at gigs with a GPU for a while now, I [...]]]></description>
			<content:encoded><![CDATA[<p>Reuse is the better form of recycling, and the machines that we all increasingly use are fabulous concoctions of various plastics, metals and ceramic compounds. It's simply shortsighted to treat them as throwaway items. With this in mind, and lacking a computer I can use at gigs with a GPU for a while now, I thought I'd postpone the inevitable cost by doing a little obsolete tech archeology. </p>
<p>I think homebrew and it's associated arts - as a creative subversion (rather than a route to piracy) is increasingly relevant, so I'm going to try and log my notes here. The information out there can be a bit challenging to understand, but I'd also like to show that it's not that much of a dark art (compared to official development of, for example android which I've been <a href="http://www.pawfal.org/dave/blog/2011/04/more-android-tinkering/">exploring lately</a>). I must admit an advantage with PS2, as some time ago I was doing this "the proper way" for things <a href="http://en.wikipedia.org/wiki/The_Thing_%28video_game%29">like this</a>, so perhaps some useful information can leak out of long dead <a href="http://en.wikipedia.org/wiki/Non-disclosure_agreement">NDA's</a> too.</p>
<p><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2011/05/DSC00769-300x225.jpg" alt="" title="DSC00769" width="300" height="225" class="alignnone size-medium wp-image-1919" /></p>
<p>The first problem to overcome with homebrew is how to get the machine to run code it's not supposed to run. You need special hardware to burn PS2 bootable disks, and the hardcore approach to getting around that is known as the <a href="http://bootleg.sksapps.com/tutorials/fmcb/swap.php">swap trick</a>. You block the various sensors that detect if a disk is present, make a copy of a game on a CDR, replacing the code with your own. Boot using the original, then find a place in the game where the software isn't paying attention and carefully switch it with the CDR. Once you can run "unofficial code", you can make use of one of the various discovered exploits to (for example) make a <a href="http://freemcboot.psx-scene.com/">bootable memory card</a> to launch your own software from then on. A simpler approach is to give your memory card to someone who has already done this and get them to do it for you.</p>
<p>I didn't know anyone who had done this, and I am also not that hardcore, so I spent a little bit of cash on a bootable <a href="http://www.swapmagic3.com/">CD designed for this purpose</a> (which is legal to produce, because of homebrew). Along with the CD you get a variety of small shaped pieces of plastic for circumventing the drive opening detectors. These are only really needed for piracy though AFAICT, as you can boot into homebrew on a normal USB stick, so I haven't needed to bother with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2011/05/ps2-homebrew-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About @NopCleanerBot</title>
		<link>http://www.pawfal.org/dave/blog/2010/12/about-nopcleanerbot/</link>
		<comments>http://www.pawfal.org/dave/blog/2010/12/about-nopcleanerbot/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 07:27:01 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[naked on pluto]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1599</guid>
		<description><![CDATA[
In our continuing efforts to embrace all "social media", one of the bots in Naked on Pluto has started a twitter account. Could this be the first character in a FaceBook game to tweet? 
The tweeting bot's actions cause it to wander the world and sporadically report on it's progress, who is in the same [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pawfal.org/dave/blog/wp-content/uploads/2010/12/nopcleanerbot.png"><img src="http://www.pawfal.org/dave/blog/wp-content/uploads/2010/12/nopcleanerbot.png" alt="" title="nopcleanerbot" width="533" height="395" class="alignright size-full wp-image-1600" /></a><br />
In our continuing efforts to embrace all "social media", one of the bots in Naked on Pluto has started a twitter account. Could this be the first character in a FaceBook game to tweet? </p>
<p>The tweeting bot's actions cause it to wander the world and sporadically report on it's progress, who is in the same location (bots, players or objects) and snippets of conversations it hears, from players or bots talking to each other. I'm using <a href="https://github.com/joshthecoder/tweepy">tweepy</a>, a python twitter library, so I had to do a bit of a cheap hack for the racket->python process communication using the filesystem. The python daemon simply waits for a file to be created by the main bot AI thread and sends the contents of it to the twitter stream. In order to do the authentication with <a href="http://oauth.net/">OAuth</a> I needed to set up a Twitter application to get a pair of keys to sign the single user the app will have.</p>
<p>Here is the code for the tweepy daemon:</p>
<pre lang=”python” lineno="1">
#!/usr/bin/env python
import tweepy
import os.path
import time

auth = tweepy.OAuthHandler("your consumer key", "your consumer secret")
print(auth.get_authorization_url()) # you need to visit this site, logged in as the twitter user
verifier = raw_input('Verifier:') # then input the verifier code here before continuing
auth.get_access_token(verifier)
api = tweepy.API(auth) # this api allows us to read or write from the user's account

while True:
    if os.path.isfile("msg"): # look for a file called "msg"
        f = open("msg", "r")
        api.update_status(f.read()) # dump the contents into the twitter stream
        f.close()
        os.remove("msg")
    time.sleep(10)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2010/12/about-nopcleanerbot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Jackd, performances and harddisks</title>
		<link>http://www.pawfal.org/dave/blog/2010/11/jackd-performances-and-harddisks/</link>
		<comments>http://www.pawfal.org/dave/blog/2010/11/jackd-performances-and-harddisks/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 09:48:51 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[slub]]></category>

		<guid isPermaLink="false">http://www.pawfal.org/dave/blog/?p=1595</guid>
		<description><![CDATA[So you have your sample loading working in a separate thread to your realtime audio code and the interface i/o communication is also tucked away in it's own thread. You have a lock free mechanism for communicating between all threads and still, sometimes - when loading data from disk jackd chucks your program off for [...]]]></description>
			<content:encoded><![CDATA[<p>So you have your sample loading working in a separate thread to your realtime audio code and the interface i/o communication is also tucked away in it's own thread. You have a lock free mechanism for communicating between all threads and still, sometimes - when loading data from disk jackd chucks your program off for blocking - usually during a live performance, and you have to fumble around restarting the audio server. What's going on?</p>
<p>Well, it turns out that when your hard drive goes to sleep, the spin up resulting from a disk access request (such as mid-performance sample loading) can cause the kernel to block, which causes jackd to panic and either stop entirely or detach your client. This is even with jackd running with the --nozombies switch, so it must be the watchdog thread at work.</p>
<p>The solution is simply to prevent your drive spinning down when you are performing, by adding "hdparm -S 0 /dev/yourharddisk" to your live audio startup script. Thanks to <a href="http://claudiusmaximus.goto10.org/cm/">ClaudiusMaximus</a> for helping me fix this at <a href="http://www.piksel.no">Piksel</a> - it's been bothering me for ages.
<ol>
]]></content:encoded>
			<wfw:commentRss>http://www.pawfal.org/dave/blog/2010/11/jackd-performances-and-harddisks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

