<?xml version="1.0" encoding="utf-8"?>
<feed
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:at="http://www.sixapart.com/ns/at"
    xmlns:icbm="http://postneo.com/icbm"
    xmlns:rvw="http://purl.org/NET/RVW/0.2/"
    xml:lang="en">
    <title>bricas’ blog</title>
    <link rel="self" type="application/atom+xml" title="bricas’ blog (Atom)" href="http://bricas.vox.com/library/posts/tags/emulation/page/1/atom.xml" />
    <link rel="alternate" type="text/html" title="bricas’ blog" href="http://bricas.vox.com/library/posts/tags/emulation/page/1/"/> 
    <link rel="service.post" type="application/atom+xml" title="bricas’ blog" href="http://www.vox.com/services/atom/svc=post/collection_id=6a00d09e62f541be2b00d4142f23d13c7f" /> 
    <link rel="service.subscribe" type="application/atom+xml" title="bricas’ blog" href="http://bricas.vox.com/library/posts/tags/emulation/atom.xml" />   
    <link rel="last" type="application/atom+xml" title="bricas’ blog" href="http://bricas.vox.com/library/posts/tags/emulation/page/1/atom.xml" />  
    <category term="emulation" scheme="http://bricas.vox.com/tags/emulation/?_c=feed-atom-full" label="emulation" /> 
    <generator uri="http://www.vox.com/">Vox</generator>
    <updated>2007-08-13T15:05:19Z</updated> 
    <author>
        <name>Brian</name>
        <uri>http://bricas.vox.com/?_c=feed-atom-full</uri>
    </author> 
    <id>tag:vox.com,2006:6p00d09e62f541be2b/tags/emulation/</id>  
    
    <entry>
        <title>Games::NES::Emulator 0.03</title>   
        <link rel="alternate" type="text/html" title="Games::NES::Emulator 0.03" href="http://bricas.vox.com/library/post/gamesnesemulator-003.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Games::NES::Emulator 0.03" href="http://bricas.vox.com/library/post/gamesnesemulator-003.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Games::NES::Emulator 0.03" href="http://www.vox.com/atom/svc=post/asset_id=6a00d09e62f541be2b00e3989d48b90001" />          <id>tag:vox.com,2007-08-13:asset-6a00d09e62f541be2b00e3989d48b90001</id>
        <published>2007-08-13T15:05:18Z</published>
        <updated>2007-08-13T15:05:19Z</updated>
    
        <author>
            <name>Brian</name>
            <uri>http://bricas.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://bricas.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>Another week, another <a href="http://search.cpan.org/dist/Games-NES-Emulator-0.03/">release</a>. This time I&#39;ve totally revamped the code for the instructions. It&#39;s been simplified to the point where it actually makes sense at a glance. For example, DEY (decrement the Y register by 1) looked like this:</p><blockquote><p>my $self = shift;<br />my $reg = $self-&gt;registers;</p><p>$reg-&gt;{ y } = ( $reg-&gt;{ y } - 1 ) &amp; 0xff;<br />$reg-&gt;{ status } &amp;= CPU::Emulator::6502::CLEAR_SIGN;<br />$reg-&gt;{ status } &amp;= CPU::Emulator::6502::CLEAR_ZERO;</p><p>$reg-&gt;{ status } |= CPU::Emulator::6502::SET_ZERO if !$reg-&gt;{ y };<br />$reg-&gt;{ status } |= CPU::Emulator::6502::SET_SIGN if $reg-&gt;{ y } &amp; 0x80;</p><p>$reg-&gt;{ pc }++;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br /></p></blockquote><p>There&#39;s a lot of junk in there for setting the N and Z flags and incrementing the program counter. It now looks like this:</p><blockquote><p>my $self = shift;<br />my $reg = $self-&gt;registers;</p><p>$reg-&gt;{ y } = ( $reg-&gt;{ y } - 1 ) &amp; 0xff;<br />$self-&gt;set_nz( $reg-&gt;{ y } );<br /></p></blockquote><p>Much nicer.</p><p>I&#39;ve also eliminated any cycle counter code from the instructions. Rather than adding 2 cycles for each instruction, then adding the remainder in the instruction itself, I&#39;ve simply added the total number of cycles to the metadata for each instruction. The absolute addressing mode for the EOR instruction (exclusive or between the accumulator and memory contents) is setup like so:</p><blockquote><p>0x4D =&gt; {<br />&#160;&#160;&#160; addressing =&gt; &#39;absolute&#39;,<br />&#160;&#160;&#160; cycles =&gt; 4,<br />&#160;&#160;&#160; code =&gt; \&amp;eor,<br />},<br /></p></blockquote><p>I plan to add some unit tests for the addressing modes and instructions for the next release.</p><p>Other than that, I have a TODO to re-work the CPU read() and write() code. It is currently a twisty maze of if {} elsif {} statements due to the fact that NES uses memory-mapped IO, I think this could be better written as a hash table of subs that will delegate to the PPU and APU as needed. Last on that list is the need to remove all of the swapping code in the base mapper. That process can happen many times per frame and will seriously slow down the emulator -- instead I can just use a list of pointers to mimic the swap. That refactoring will probably have to wait until i get some actual PPU functionality written, though.</p>    <p style="clear:both;"> 
    <a href="http://bricas.vox.com/library/post/gamesnesemulator-003.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00d09e62f541be2b00e3989d48b90001?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="perl" scheme="http://bricas.vox.com/tags/perl/" label="perl" /> 
    <category term="emulation" scheme="http://bricas.vox.com/tags/emulation/" label="emulation" /> 
    </entry> 
    
    <entry>
        <title>Games::NES::Emulator 0.02</title>   
        <link rel="alternate" type="text/html" title="Games::NES::Emulator 0.02" href="http://bricas.vox.com/library/post/gamesnesemulator-002.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Games::NES::Emulator 0.02" href="http://bricas.vox.com/library/post/gamesnesemulator-002.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Games::NES::Emulator 0.02" href="http://www.vox.com/atom/svc=post/asset_id=6a00d09e62f541be2b00e3989b50a60005" />          <id>tag:vox.com,2007-08-07:asset-6a00d09e62f541be2b00e3989b50a60005</id>
        <published>2007-08-07T02:16:48Z</published>
        <updated>2007-08-07T17:26:44Z</updated>
    
        <author>
            <name>Brian</name>
            <uri>http://bricas.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://bricas.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>I released a new version of <a href="http://search.cpan.org/dist/Games-NES-Emulator/">Games::NES::Emulator</a>. It still doesn&#39;t work. :) But, I&#39;m getting closer. Ive added a bunch of the 6502 operations. My interpretation of their functionality may be, uh, well, off -- but I&#39;ve added some debugging to see what the state of the emulator is after each instruction.</p><blockquote><pre>.------+------+----+----+----+----------+------.<br />| PC&#160;&#160; | SP&#160;&#160; | A&#160; | X&#160; | Y&#160; | Status&#160;&#160; | OP&#160;&#160; |<br />+------+------+----+----+----+----------+------+<br />| 8000 | ff&#160;&#160; | 0&#160; | 0&#160; | 0&#160; | ..-B.... | 78&#160;&#160; |<br />&#39;------+------+----+----+----+----------+------&#39;<br />.-------. .------+-----------------------------.<br />| Stack | | Addr | Code&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />+-------+ +------+-----------------------------+<br />| 0&#160;&#160;&#160;&#160; | | 8000 | 78&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8001 | d8&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8002 | a9&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8003 | 40&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8004 | 8d&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8005 | 0&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8006 | 20&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8007 | a2&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8008 | ff&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />| 0&#160;&#160;&#160;&#160; | | 8009 | 9a&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |<br />&#39;-------&#39; &#39;------+-----------------------------&#39;</pre><p></p></blockquote><p>Eventually I&#39;ll do some disassembling and fix up the &quot;Code&quot; section to reflect the actual op names and params.<br />  </p>   <p style="clear:both;"> 
    <a href="http://bricas.vox.com/library/post/gamesnesemulator-002.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00d09e62f541be2b00e3989b50a60005?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="perl" scheme="http://bricas.vox.com/tags/perl/" label="perl" /> 
    <category term="emulation" scheme="http://bricas.vox.com/tags/emulation/" label="emulation" /> 
    </entry> 
    
    <entry>
        <title>Games::NES::Emulator</title>   
        <link rel="alternate" type="text/html" title="Games::NES::Emulator" href="http://bricas.vox.com/library/post/gamesnesemulator.html?_c=feed-atom-full" />  
        <link rel="service.post" type="application/atom+xml" title="Games::NES::Emulator" href="http://bricas.vox.com/library/post/gamesnesemulator.html?_c=feed-atom-full#comments" /> 
        <link rel="service.edit" type="application/atom+xml" title="Games::NES::Emulator" href="http://www.vox.com/atom/svc=post/asset_id=6a00d09e62f541be2b00e398992ab40002" />          <id>tag:vox.com,2007-07-31:asset-6a00d09e62f541be2b00e398992ab40002</id>
        <published>2007-07-31T20:03:48Z</published>
        <updated>2007-08-01T12:45:59Z</updated>
    
        <author>
            <name>Brian</name>
            <uri>http://bricas.vox.com/?_c=feed-atom-full</uri>
        </author>
    
        
        <content type="html" xml:base="http://bricas.vox.com/?_c=feed-atom-full">
            <![CDATA[
                <div xmlns="http://www.w3.org/1999/xhtml" xmlns:at="http://www.sixapart.com/ns/at">
        <p>I&#39;ve pushed <a href="http://search.cpan.org/dist/Games-NES-Emulator/">Games::NES::Emulator to CPAN</a>. Like the &quot;WARNING&quot; section says, don&#39;t get overly excited yet, it doesn&#39;t actually do anything -- yet.</p><p>I&#39;ve had a bunch of code going stale on my machine that I&#39;ve been meaning to put out. I hope to put out periodic releases, as I piece things together, gradually forming into a working emulator. I long for the day when the little &quot;nintendo&quot; logo show up on screen due to this module...<br /> </p>   <p style="clear:both;"> 
    <a href="http://bricas.vox.com/library/post/gamesnesemulator.html?_c=feed-atom-full#comments">Read and post comments</a>   |   
    <a href="http://www.vox.com/share/6a00d09e62f541be2b00e398992ab40002?_c=feed-atom-full">Send to a friend</a> 
</p>

                </div>
            ]]>
        </content> 
    <category term="perl" scheme="http://bricas.vox.com/tags/perl/" label="perl" /> 
    <category term="emulation" scheme="http://bricas.vox.com/tags/emulation/" label="emulation" /> 
    </entry> 
</feed>


