<?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>GuShH&#039;s DevBlog &#187; Libraries</title>
	<atom:link href="http://gushh.net/blog/?cat=5&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://gushh.net/blog</link>
	<description>This blog is about software, electronics engineering and game development.</description>
	<lastBuildDate>Tue, 24 Jan 2012 00:31:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PB Parallel Port Library</title>
		<link>http://gushh.net/blog/parallel-port-library/</link>
		<comments>http://gushh.net/blog/parallel-port-library/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 04:17:42 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[LPT]]></category>
		<category><![CDATA[Parallel Port]]></category>
		<category><![CDATA[Paraport]]></category>
		<category><![CDATA[PB Parallel Library]]></category>
		<category><![CDATA[purebasic]]></category>
		<category><![CDATA[Stepper Motor]]></category>
		<category><![CDATA[Unipolar Stepper]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=743</guid>
		<description><![CDATA[What is it: This is a minimalist  library based on the inpout32 DLL Basically I wrapped the original library and added a whole bunch of useful constants to easily access the Control and Status registers while keeping things clean and simple. This library is currently being used on a side project I&#8217;ve been working on with a friend, [...]]]></description>
			<content:encoded><![CDATA[<h2>What is it:</h2>
<p>This is a minimalist  library based on the <a title="http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html" href="http://" target="_blank">inpout32 DLL</a></p>
<p>Basically I wrapped the original library and added a whole bunch of useful constants to easily access the Control and Status registers while keeping things clean and simple.</p>
<p>This library is currently being used on a side project I&#8217;ve been working on with a friend, since he doesn&#8217;t have any μController experience we decided to use LPT for the time being.</p>
<h3></h3>
<h2>The code:</h2>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;">&nbsp;
<span style="color: #ff0000; font-style: italic;">; 	Minimalist Library for Parallel port access based on inpout32.dll </span>
<span style="color: #ff0000; font-style: italic;">;		by Gustavo J. Fiorenza AKA GuShH (info@gushh.net - info@gushh.com.ar)</span>
<span style="color: #ff0000; font-style: italic;">;		Version 1.0 - 11/01/2011</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EnableExplicit</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">; Default LPT Addresses.</span>
#PARALLEL_PORT_LPT1						<span style="color: #000066;">=</span> $3BC
#PARALLEL_PORT_LPT2						<span style="color: #000066;">=</span> $378
#PARALLEL_PORT_LPT3						<span style="color: #000066;">=</span> $278
&nbsp;
<span style="color: #ff0000; font-style: italic;">; Register offsets.</span>
#PARALLEL_PORT_STATUS						<span style="color: #000066;">=</span> $01
#PARALLEL_PORT_CONTROL						<span style="color: #000066;">=</span> $02
&nbsp;
<span style="color: #ff0000; font-style: italic;">; Shared with Data Register.</span>
#PARALLEL_PORT_OFF						<span style="color: #000066;">=</span> $00
#PARALLEL_PORT_BIT0						<span style="color: #000066;">=</span> $01
#PARALLEL_PORT_BIT1						<span style="color: #000066;">=</span> $02
#PARALLEL_PORT_BIT2						<span style="color: #000066;">=</span> $04
#PARALLEL_PORT_BIT3						<span style="color: #000066;">=</span> $08
#PARALLEL_PORT_BIT4						<span style="color: #000066;">=</span> $10
#PARALLEL_PORT_BIT5						<span style="color: #000066;">=</span> $20
#PARALLEL_PORT_BIT6						<span style="color: #000066;">=</span> $40
#PARALLEL_PORT_BIT7						<span style="color: #000066;">=</span> $80
&nbsp;
<span style="color: #000066; font-weight: bold;">XIncludeFile</span> <span style="color: #009900;">&quot;ParallelPort_Constants.pbi&quot;</span> 	<span style="color: #ff0000; font-style: italic;">; All of the helper, non-essential constants are defined here.</span>
&nbsp;
&nbsp;
<span style="color: #000066; font-weight: bold;">Structure</span> PARALLEL_PORT
	Handle.i
	Port.i
	LastData.i
<span style="color: #000066; font-weight: bold;">EndStructure</span>
&nbsp;
&nbsp;
<span style="color: #ff0000; font-style: italic;">;- Instance construction and destruction</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_Create<span style="color: #000066;">&#40;</span> Port.i <span style="color: #000066;">=</span> #PARALLEL_PORT_LPT2 <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">Define</span>.PARALLEL_PORT <span style="color: #000066;">*</span>this <span style="color: #000066;">=</span> <span style="color: #0000ff;">AllocateMemory</span><span style="color: #000066;">&#40;</span> <span style="color: #0000ff;">SizeOf</span><span style="color: #000066;">&#40;</span>PARALLEL_PORT<span style="color: #000066;">&#41;</span> <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Port 	<span style="color: #000066;">=</span> port
		<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Handle 	<span style="color: #000066;">=</span> <span style="color: #0000ff;">OpenLibrary</span><span style="color: #000066;">&#40;</span> #PB_Any, <span style="color: #009900;">&quot;inpout32.dll&quot;</span> <span style="color: #000066;">&#41;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #0000ff;">IsLibrary</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Handle <span style="color: #000066;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066; font-weight: bold;">Else</span>
			<span style="color: #000066; font-weight: bold;">Debug</span> <span style="color: #009900;">&quot;Couldn't load inpout32.dll&quot;</span>
			<span style="color: #0000ff;">FreeMemory</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">*</span>this<span style="color: #000066;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> #Null
		<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_Destroy<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT <span style="color: #000066;">&#41;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
&nbsp;
		<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #0000ff;">IsLibrary</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Handle <span style="color: #000066;">&#41;</span>
			<span style="color: #0000ff;">CloseLibrary</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Handle <span style="color: #000066;">&#41;</span>
		<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
		<span style="color: #0000ff;">FreeMemory</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span>
		<span style="color: #000066;">*</span>this <span style="color: #000066;">=</span> #Null
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this
&nbsp;
	<span style="color: #000066; font-weight: bold;">EndIf</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">;- Communication Functions</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_Out<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT, Bits.w <span style="color: #000066;">=</span> $00 <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>LastData <span style="color: #000066;">=</span> Bits <span style="color: #000066;">&amp;</span> $FF
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #0000ff;">CallFunction</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>handle, <span style="color: #009900;">&quot;Out32&quot;</span>, <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Port, Bits <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_In<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT, Type.i <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #0000ff;">CallFunction</span><span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>handle, <span style="color: #009900;">&quot;Inp32&quot;</span>, <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Port <span style="color: #000066;">+</span> Type <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">;- Getter Functions</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_GetHandle<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Handle
	<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_GetPort<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>Port
	<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_GetLastData<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		<span style="color: #000066; font-weight: bold;">ProcedureReturn</span> <span style="color: #000066;">*</span>this<span style="color: #000066;">\</span>LastData
	<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">;- Helper Functions</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">Procedure</span>.i ParallelPort_Clear<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this.PARALLEL_PORT <span style="color: #000066;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">If</span> <span style="color: #000066;">*</span>this
		ParallelPort_Out<span style="color: #000066;">&#40;</span> <span style="color: #000066;">*</span>this <span style="color: #000066;">&#41;</span> <span style="color: #ff0000; font-style: italic;">; The default data parameter is $00</span>
	<span style="color: #000066; font-weight: bold;">EndIf</span>
<span style="color: #000066; font-weight: bold;">EndProcedure</span></pre></div></div>

<p>And the constants include:</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;">&nbsp;
<span style="color: #ff0000; font-style: italic;">; Read Only Status Register.</span>
#PARALLEL_PORT_STATUS_IRQ		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT2
&nbsp;
#PARALLEL_PORT_STATUS_ERROR		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT3
#PARALLEL_PORT_STATUS_SELECT		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT4
#PARALLEL_PORT_STATUS_PAPEROUT		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT5
#PARALLEL_PORT_STATUS_ACK		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT6
#PARALLEL_PORT_STATUS_BUSY		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT7
&nbsp;
<span style="color: #ff0000; font-style: italic;">; Read / Write Control Register.</span>
#PARALLEL_PORT_CONTROL_STROBE		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT0
#PARALLEL_PORT_CONTROL_LINEFEED		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT1
#PARALLEL_PORT_CONTROL_RESET		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT2 <span style="color: #ff0000; font-style: italic;">; AKA Initialize Printer OR Init.</span>
#PARALLEL_PORT_CONTROL_SELECT		<span style="color: #000066;">=</span> #PARALLEL_PORT_BIT3
&nbsp;
<span style="color: #ff0000; font-style: italic;">; These constants are icluded for completeness. All pin numbers are relative to D-Type 25, Centronics pins are between parentheses.</span>
&nbsp;
#PARALLEL_PORT_D0	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT0			<span style="color: #ff0000; font-style: italic;">; PIN2</span>
#PARALLEL_PORT_D1	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT1			<span style="color: #ff0000; font-style: italic;">; PIN3</span>
#PARALLEL_PORT_D2	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT2			<span style="color: #ff0000; font-style: italic;">; PIN4</span>
#PARALLEL_PORT_D3	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT3			<span style="color: #ff0000; font-style: italic;">; PIN5</span>
#PARALLEL_PORT_D4	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT4			<span style="color: #ff0000; font-style: italic;">; PIN6</span>
#PARALLEL_PORT_D5	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT5			<span style="color: #ff0000; font-style: italic;">; PIN7</span>
#PARALLEL_PORT_D6	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT6			<span style="color: #ff0000; font-style: italic;">; PIN8</span>
#PARALLEL_PORT_D7	<span style="color: #000066;">=</span>	#PARALLEL_PORT_BIT7			<span style="color: #ff0000; font-style: italic;">; PIN9</span>
&nbsp;
#PARALLEL_PORT_C0	<span style="color: #000066;">=</span>	#PARALLEL_PORT_CONTROL_STROBE		<span style="color: #ff0000; font-style: italic;">; PIN 1</span>
#PARALLEL_PORT_C1	<span style="color: #000066;">=</span>	#PARALLEL_PORT_CONTROL_LINEFEED		<span style="color: #ff0000; font-style: italic;">; PIN 14</span>
#PARALLEL_PORT_C2	<span style="color: #000066;">=</span>	#PARALLEL_PORT_CONTROL_RESET		<span style="color: #ff0000; font-style: italic;">; PIN 16	(31)</span>
#PARALLEL_PORT_C3	<span style="color: #000066;">=</span>	#PARALLEL_PORT_CONTROL_SELECT		<span style="color: #ff0000; font-style: italic;">; PIN 17	(36)</span>
&nbsp;
#PARALLEL_PORT_S3	<span style="color: #000066;">=</span>	#PARALLEL_PORT_STATUS_ERROR		<span style="color: #ff0000; font-style: italic;">; PIN 15	(32)</span>
#PARALLEL_PORT_S4	<span style="color: #000066;">=</span>	#PARALLEL_PORT_STATUS_SELECT		<span style="color: #ff0000; font-style: italic;">; PIN 13</span>
#PARALLEL_PORT_S5	<span style="color: #000066;">=</span>	#PARALLEL_PORT_STATUS_PAPEROUT		<span style="color: #ff0000; font-style: italic;">; PIN 12</span>
#PARALLEL_PORT_S6	<span style="color: #000066;">=</span>	#PARALLEL_PORT_STATUS_ACK		<span style="color: #ff0000; font-style: italic;">; PIN 10</span>
#PARALLEL_PORT_S7	<span style="color: #000066;">=</span>	#PARALLEL_PORT_STATUS_BUSY		<span style="color: #ff0000; font-style: italic;">; PIN 11</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">; PINS 18-25 (19-30) Are all tied to GND.</span></pre></div></div>

<h3>The hardware:</h3>
<p>You don&#8217;t need any special hardware other than a Centronics or similar cable and a PC with a Parallel port (I&#8217;m sure some of you keep older PCs around for a good reason!) &#8212; Aside from this if you&#8217;re planning on running the examples you might want to get some LEDs and Switches.</p>
<h3>Something to download:</h3>
<p>The entire sources and support files including the examples can be found <a href='http://gushh.net/blog/wp-content/uploads/2011/01/ParallelPort.zip'>Here</a>. Remember to exit the demo programs with the ESC key so the program gets a chance to reset the output bits.</p>
<h3>Useful companion:</h3>
<p>During development you may want to keep an eye on the status of each pin, however not everyone has a breakout board for this particular interface so you may want to use a software version of this concept instead, one of my favourite ones is <a href="http://neil.fraser.name/software/lpt/" target="_blank">LPT.exe</a> &#8212; It works fairly well and there are several ports to different languages in case you&#8217;re interested in modifying it to suit your own needs.</p>
<h3>Closing up:</h3>
<p>That&#8217;s all for now, hopefully I&#8217;ll be able to finish the project and post some of the code here. Hint: it involves controlling unipolar steppers, computer vision and webcams!</p>
<p>Can you guess what it is?</p>
<p>Cheers.</p>
<g:plusone href='http://gushh.net/blog/parallel-port-library/'></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/parallel-port-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An efficient and simple object factory for PureBasic</title>
		<link>http://gushh.net/blog/object-factory-for-purebasic/</link>
		<comments>http://gushh.net/blog/object-factory-for-purebasic/#comments</comments>
		<pubDate>Sun, 03 May 2009 16:43:05 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[EasyObject]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[GuShH]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[purebasic]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=65</guid>
		<description><![CDATA[Whenever you deal with structures and what have you it&#8217;s obvious that there has to be a better way of doing it. Think about it, you encapsulate your structure-related code in such a way that it becomes clean, nice and tidy &#8212; in other words it makes it easy to understand what it does. However [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Whenever you deal with structures and what have you it&#8217;s obvious that there has to be a better way of doing it. Think about it, you encapsulate your structure-related code in such a way that it becomes clean, nice and tidy &#8212; in other words it makes it easy to understand what it does.</p>
<p>However in essence, you end up writing pretty much the same allocate / deallocate, list, etc. code every time you incorporate a new &#8220;class&#8221; into your project. Why should we?, let&#8217;s avoid it all together and focus our efforts in the task at hand rather than in the mundane stuff.</p>
<p>If you open your eyes you&#8217;ll see that this is an obvious pattern but what isn&#8217;t so obvious is how do you implement a template that deals with it in an efficient and clean way within the current constraints of the language.</p>
<p>Well&#8230; Have no fear, EasyObject is here!<br />
First, <a href="http://gushh.net/dls/easyobject.zip" target="_blank">download it</a>. Secondly, embrace it.</p>
<p>Third, you&#8217;re free to post any comments regarding on how to enhance it if you dear to!.</p>
<p><span id="more-65"></span>Ok, now let&#8217;s describe this thing a little more and leave the marketing speech in the past.</p>
<p>From the &#8220;readme&#8221;:</p>
<blockquote><p>EasyObject is an object factory template for PureBasic. It allows you to register any structure as a &#8220;class&#8221;. With EasyObject you can define constructors and destructors as well as iterators with ease.</p>
<p>The purpose of EasyObject is mainly to encapsulate trivial and redundant code usually regarded to allocation, deallocation and keeping track of the objects. The usage is fairly simple: classes can be registered and unregistered. Once a class has been registered, we can create new objects and delete them at will. If we decide to unregister a class, all of the objects will be freed and their respective destructors will be called.</p></blockquote>
<p>More from where that came from&#8230;</p>
<blockquote><p>Macros in this case are used as an aid to define templates (like you would in C++ for instance). There are certain limitations that forced me to design the template as it is right now but the usage is very simple. We&#8217;re not trying to mimic any language here but rather provide a way of dealing with objects without having to write redundant code all the time. Because overloading doesn&#8217;t exist in PB, the constructor will be called twice (once by the template and once by yourself) if you want to define the members using said ctor, just make certain that any dynamic allocations are performed only once or you&#8217;ll have a nasty memory leak in your hands.</p></blockquote>
<p>It&#8217;s clear that some limitations are present in the template but for most of the tasks this is a great addition to anyone&#8217;s code.</p>
<p>Let me know if you find any bugs!</p>
<p>Cheers,<br />
GuShH</p></div>
<g:plusone href='http://gushh.net/blog/object-factory-for-purebasic/'></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/object-factory-for-purebasic/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Updated the vec3 lib, major overhaul.</title>
		<link>http://gushh.net/blog/updated-the-vec3-lib-major-overhaul/</link>
		<comments>http://gushh.net/blog/updated-the-vec3-lib-major-overhaul/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 10:37:31 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[coordinate]]></category>
		<category><![CDATA[cross product]]></category>
		<category><![CDATA[dot product]]></category>
		<category><![CDATA[endpoint]]></category>
		<category><![CDATA[fmod]]></category>
		<category><![CDATA[isometric]]></category>
		<category><![CDATA[lerp]]></category>
		<category><![CDATA[purebasic]]></category>
		<category><![CDATA[quadratic curve]]></category>
		<category><![CDATA[transformation]]></category>
		<category><![CDATA[vec2]]></category>
		<category><![CDATA[vec3]]></category>
		<category><![CDATA[vector math]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=49</guid>
		<description><![CDATA[The VEC3 lib was updated today, I haven&#8217;t had time to put the newer versions as they were developed so I&#8217;m just uploading the latest version right now. A small change-log can be found at the header of the source. Same link as before: VEC3_MACRO.PBI Or you can download the package: VEC3_MACRO.ZIP New functionality as seen [...]]]></description>
			<content:encoded><![CDATA[<p>The VEC3 lib was updated today, I haven&#8217;t had time to put the newer versions as they were developed so I&#8217;m just uploading the latest version right now. A small change-log can be found at the header of the source.</p>
<p>Same link as before: <a href="http://gushh.net/dev/?file=pb/vec3_macro.pbi" target="_blank">VEC3_MACRO.PBI</a></p>
<p>Or you can download the package: <a href="http://gushh.net/dls/vec3_macro.zip" target="_blank">VEC3_MACRO.ZIP</a></p>
<p><a href="http://gushh.net/dls/vec3_macro.zip"><span id="more-49"></span><br />
</a></p>
<p>New functionality as seen on the change-log:</p>
<blockquote><p>24/01/2009: Added min, max. Fixed Lerp.</p>
<p>18/01/2009: Fixed structure, made FMOD compliant with VEC3_TYPE. Refactored FastSine() and PIWRAP().</p>
<p>12/01/2009: Optimized/Fixed the PIWRAP macro with FMOD. Added resolution switch For the quadratic curve.</p>
<p>11/01/2009: Added wrap, clamp, lerp, string. Fixed some bugs. Refactored the vec3 structure. Added approximation method for sine and cosine functions.</p>
<p>10/01/2009: Library created.</p></blockquote>
<p> </p>
<p>I think I got carried away a little, but it proves to be a useful library for quick prototyping (at least that&#8217;s what I use it for). I&#8217;ll write a few examples with a small drawing framework perhaps by next week if I have time for it. Some of the things that are left to do include angle and coordinate helpers, which also means isometric transformation for 3d points, projections, etc.</p>
<p>As it stands right now, you could prototype almost any type of game/application without having to code most of the trivial stuff (such as, the vector code, provided by the library!).</p>
<p>Cheers.</p>
<g:plusone href='http://gushh.net/blog/updated-the-vec3-lib-major-overhaul/'></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/updated-the-vec3-lib-major-overhaul/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A fast vector library for purebasic.</title>
		<link>http://gushh.net/blog/a-fast-vector-library-for-purebasic/</link>
		<comments>http://gushh.net/blog/a-fast-vector-library-for-purebasic/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 17:03:31 +0000</pubDate>
		<dc:creator>GuShH</dc:creator>
				<category><![CDATA[Libraries]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[PureBasic]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[pb]]></category>
		<category><![CDATA[purebasic]]></category>
		<category><![CDATA[resident]]></category>
		<category><![CDATA[sqrt]]></category>
		<category><![CDATA[sse2]]></category>
		<category><![CDATA[vec2]]></category>
		<category><![CDATA[vec3]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://gushh.net/blog/?p=24</guid>
		<description><![CDATA[I recently required some vector functions to prototype a game idea in PureBasic, however there is no such thing as a built-in vector library and any of the existent community code was buggy to say the least (no offense but it&#8217;s old, ugly code that you&#8217;ll find anywhere else). The reason for this library is [...]]]></description>
			<content:encoded><![CDATA[<p>I recently required some vector functions to prototype a game idea in PureBasic, however there is no such thing as a built-in vector library and any of the existent community code was buggy to say the least (no offense but it&#8217;s old, ugly code that you&#8217;ll find anywhere else).</p>
<p>The reason for this library is quite simple, and so is the library itself. you can either include it or install the resource file and start using it right away. After taking a quick look at the source, you&#8217;ll soon familiarize with it&#8217;s naming convention; there is no need to write any documentation for this type of code, since it&#8217;s basic vector math. However a test source is included for your delight.</p>
<p>You can find the source in here: <a href="http://gushh.net/dev/?file=pb/vec3_macro.pbi" target="_blank">http://gushh.net/dev/?file=pb/vec3_macro.pbi</a><br />
And some ugly test code in here: <a href="http://gushh.net/dev/?file=pb/vec3_macro_test.pb" target="_blank">http://gushh.net/dev/?file=pb/vec3_macro_test.pb</a></p>
<p>Or, you can get &#8220;the whole package&#8221; from here: <a href="http://gushh.net/dls/vec3_macro.zip">http://gushh.net/dls/vec3_macro.zip</a></p>
<p>Using this library is as easy as&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="purebasic" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">Define</span>.VEC3 a, b, c
VEC3_SET<span style="color: #000066;">&#40;</span> a, <span style="color: #CC0000;">0.1</span>, <span style="color: #CC0000;">0.2</span>, <span style="color: #CC0000;">0.3</span> <span style="color: #000066;">&#41;</span>
VEC3_SET<span style="color: #000066;">&#40;</span> b, <span style="color: #CC0000;">0.4</span>, <span style="color: #CC0000;">0.5</span>, <span style="color: #CC0000;">0.6</span> <span style="color: #000066;">&#41;</span>
VEC3_ADD<span style="color: #000066;">&#40;</span> a, b, c <span style="color: #000066;">&#41;</span>
VEC3_DEBUG3<span style="color: #000066;">&#40;</span> a, b, c <span style="color: #000066;">&#41;</span> <span style="color: #ff0000; font-style: italic;">; display the vectors in the debug console.</span></pre></div></div>

<p> <br />
<span id="more-24"></span></p>
<p>I mention &#8220;so-called fast&#8221; because it&#8217;s relatively fast, however not as fast as a pure sse2+ implementation would be &#8211; although we remain &#8220;as fast as we can&#8221; without breaking code readability and maintainability at all. This is also 100% cross-platform and as fast as it gets with the current compiler. &#8220;Macrofobics&#8221; could disagree but it&#8217;s their loss.</p>
<p>Some might argue that using a &#8220;fast sqrt&#8221; would be a good thing, but I disagree. You don&#8217;t really need this at all now a days. Also, any implementation of the fast sqrt in PB would not benefit from much speed increase at all, if any you&#8217;ll ruin code readability over a little bit of speed while giving away precision and portability.</p>
<p>That said, feel free to modify as you see fit &#8211; But please share your findings with the community.</p>
<p>If there is a need for a VEC2 lib, I&#8217;ll gladly release it. Remember, you don&#8217;t need a point library / class at all, a vector library can indeed be used for points and it is recommended; cuts unecesarry redundant code and makes your life easier. Perhaps a purist OOP coder would disagree, but I don&#8217;t care.</p>
<p>Have fun with vectors!</p>
<g:plusone href='http://gushh.net/blog/a-fast-vector-library-for-purebasic/'></g:plusone>]]></content:encoded>
			<wfw:commentRss>http://gushh.net/blog/a-fast-vector-library-for-purebasic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: gushh.net @ 2012-02-09 08:42:20 by W3 Total Cache -->
