gutomaiahttps://gutomaia.net/2017-02-22T23:00:00-03:00Double Dragon2017-02-22T23:00:00-03:002017-02-12T13:54:00-02:00Guto Maiatag:gutomaia.net,2017-02-22:/double_dragon.html<div class="figure align-center">
<img alt="Double Dragon" src="https://gutomaia.net/images/double_dragon.jpg" />
</div>
<p>Not in the mood to code today, so let's play a classic: Double Dragon. It's hard to explain nowadays what a phenomenal game it was back then. So before reviewing the NES version, which I'm going to play, let's first talk about the game’s history.</p>
<p>At the end eighties …</p><div class="figure align-center">
<img alt="Double Dragon" src="https://gutomaia.net/images/double_dragon.jpg" />
</div>
<p>Not in the mood to code today, so let's play a classic: Double Dragon. It's hard to explain nowadays what a phenomenal game it was back then. So before reviewing the NES version, which I'm going to play, let's first talk about the game’s history.</p>
<p>At the end eighties, there was a Double Dragon machine at the center of every arcade. The game was so popular that it opened up the <a class="reference external" href="https://en.wikipedia.org/wiki/Beat_em_up">beat'em up genre</a>. Soon enough, arcades were filled with beloved beat ‘em up games like Golden Axe and Final Fight; and then eventually CAPCOM would lead the genre to whole other level. But even by then, in the mid-nineties, brothers Billy and Jimmy Lee—the stars of Double Dragon—would never lose their spot.</p>
<p>This story was quite simple: a love interest of Billy and Jimmy gets kidnapped by a street gang. Yep, both brothers are interested in the same girl and—spoiler alert—they fight each other for her at the end of the game. Prior the first stage, a small intro shows henchman's punching and taking the girl away, then the garage door open's up and the music and beat begins. Not exactly an original story, but the game made it feel like a great story; at the least, it was a great eighties story. In fact, there was something about the style that always reminded me of another eighties classic: <a class="reference external" href="https://en.wikipedia.org/wiki/Streets_of_Fire">Streets of Fire</a> style. I swear, whenever I played Double Dragon, I always saw Willem Dafoe as the kidnapper; running off with that kidnapped girl over the shoulders.</p>
<p>All in all, the arcade game was a classic. I’ll never forget the hours I spent waiting to play the game; talking with others about how to best control the elbow smash or how to throw an enemy from a bridge without falling too. I remember that once I had to wait a guy cleanup the coin safe, 'cause coins were getting jammed. It was the main subject among gamers and game magazines.</p>
<div class="section" id="the-home-version">
<h2>The HOME version</h2>
<p>Playing Double Dragon, at home, without needing to "insert coin" was amazing. But there were problems too. For me, I used to have the Master System version as a child. But the Master System missed the thrill. The timing of the game was off (especially compared to the NES version) and it also lacked the action sequences (I know it's related to licensing, but I as a gamer, I didn't care).</p>
<p>Nevertheless, it was great. And then it got better: <cite>Double Dragon 2 - The Revenge.’ Even just the cover was amazing. It also seemed to share an element with the movie `Big Trouble in Little China</cite> and, again, <cite>Streets of Fire</cite>. All in all, it was a lot of fun; the graphics were simple and the arm over the body style was remarkable.</p>
<p>Then you stomp on with <cite>Double Dragon 3: The Sacred Stones</cite>. More characters and a new feature: "Once you defeated your bitter enemies join your quest". Meaning, after you beat a boss you can play with him too. And for sure, it was one of the hardest titles on the NES. It was hard as hell! Dammed stones, why so sacred?</p>
<p>I think that the NES version is the definitive console version.</p>
</div>
<div class="section" id="a-king-still-a-king">
<h2>A King still a King</h2>
<p>Meanwhile, Final Fight was dominating the arcades in the early nineties and then the Super Nintendo was announced with it listed as a launch title. At the time I thought, "here comes a new Double Dragon.” Sega's had an upstart advantage, not only <cite>Golden Axe</cite> was Genesis's launch title, but also it comes bundled with Altered Beast. Two beat ‘em up in the launch, Sega was way ahead.</p>
<p>Capcom, had the chance to help even things for Nintendo, but missed badly. Although the game was a almost perfect arcade conversion in terms of graphics, the lack of two player took away the replayability that NES's Double Dragon had. The sixteen bit's beat ‘em up title was took from Nintendo by Sega's <a class="reference external" href="https://en.wikipedia.org/wiki/Streets_of_Rage">Streets of Rage</a> later on. And here we go again, another game with Streets of Fire references. I think I see a pattern.</p>
<p>This year, we have the launch of <cite>Double Dragon 4</cite>. Ok, before we go on. Let's pretend they never release either <cite>Double Dragon Neon</cite> game or the <cite>Double Dragon</cite> movie. It's perfect stated here Streets of Fire is the official Double Dragon movie and Willem Dafoe the leader of the Black Warriors gang.</p>
<p>The new adventure of the Lee brother's took place after the events of the DD3 and their sacred as hell stones, which I would never be able to collect. It has all the main features from his predecessors. The 2-player co-op with friend fighting at the end from the first. The remarkable style with the arms over the body from the second. And, finally, the bad-guys-join-the-party-after-you-beat-them feature.</p>
<p>It took decades for a fourth episode, and all the other beat 'em up greaties never took this step (Golden Axe, Streets of Rage and Final Fight each have only 3 games). Why didn't they? My answer would be, the lack of style, good memories and nostalgia. Because ultimately Double Dragon was the game that created and defines the beat 'em up genre, as well as defines the "2 player" game style of the eighties.</p>
</div>
<div class="section" id="ending-credits-and-bonus-stage">
<h2>Ending credits and bonus stage</h2>
<p>I must share the authoring credits of this post with <a class="reference external" href="http://www.blakejharris.com">Blake J. Harris</a>. He did more than amazing review on the final draft. He reestructed and extracted the whole essence that was there. Blake is the author of the best-selling <a class="reference external" href="https://www.amazon.com.br/Console-Wars-Nintendo-Defined-Generation/dp/0062276700">Console Wars</a> book and made a interview that digs <a class="reference external" href="http://www.slashfilm.com/streets-of-fire-oral-history/">Streets of Fire history</a>. There wouldn't be a better reviewer for this post. Also, he is working on a new book about virtual reality.</p>
</div>
Ghostbusters2017-02-16T22:15:00-02:002017-02-16T22:15:00-02:00Guto Maiatag:gutomaia.net,2017-02-16:/ghostbusters.html<div class="figure align-center">
<img alt="stranger things ghostbusters" src="https://gutomaia.net/images/stranger_things_ghostbusters.jpg" />
</div>
<p>I had my childhood in the eighties, and 'course, I used to wake up on staturday morning to watch ghostbusters. Then, when I though for a continuos integration lamp, I know it should have the "prohibed ghost sign"! In this post, I'm gonna show you, how to use your smartthings …</p><div class="figure align-center">
<img alt="stranger things ghostbusters" src="https://gutomaia.net/images/stranger_things_ghostbusters.jpg" />
</div>
<p>I had my childhood in the eighties, and 'course, I used to wake up on staturday morning to watch ghostbusters. Then, when I though for a continuos integration lamp, I know it should have the "prohibed ghost sign"! In this post, I'm gonna show you, how to use your smartthings hub to notify you when your travis deploy is broken.</p>
<p>Well, it's not hard, in fact, you might get yours working in a couple of minutes. As said, I will need a Smarthing Hub and a Switch. Then you need to follow the steps on <a class="reference external" href="https://github.com/dpjanes/iotdb-smartthings">Iotdb Smartthings</a>.</p>
<p>With that setup, your smarthing thing had a JSON api that you can call on the cloud. All you need is the URL for the device and the access token. (I will post a simple code later)</p>
<p>And finally, add the SMARTTHINGS_URL and SMARTTHINGS_ACCESS_TOKEN vars to your travis settings and the following code .travis file.</p>
<div class="highlight"><pre><span></span>after_failure: >-
curl -X PUT -H "Authorization: Bearer ${SMARTTHINGS_ACCESS_TOKEN}" -H "Content-Type: application/json" -d '{"switch": 1}' ${SMARTTHINGS_URL}
</pre></div>
<div class="figure align-center">
<img alt="Who are you gonna call?" src="https://gutomaia.net/images/ghostbusters_lamp.jpg" />
</div>
<p>Then, when a build got rogue on wedNESday, I got it! I ain't gotta a build falling. Not on my watch!</p>
wedNESday #7 - More than just coding2017-02-15T23:00:00-02:002017-02-18T13:54:00-02:00Guto Maiatag:gutomaia.net,2017-02-15:/wednesday_7.html<div class="figure align-center">
<img alt="more than coding" src="https://gutomaia.net/images/more_than_coding.jpg" />
</div>
<p>One thing that I noticed on opensorce projects, it's more than just coding. Indeed the code itself is the center on wich everything else related to the project gravitates, but there is lot more. Today made some tweaks on my travis continuos integration, and also had a lot of reading …</p><div class="figure align-center">
<img alt="more than coding" src="https://gutomaia.net/images/more_than_coding.jpg" />
</div>
<p>One thing that I noticed on opensorce projects, it's more than just coding. Indeed the code itself is the center on wich everything else related to the project gravitates, but there is lot more. Today made some tweaks on my travis continuos integration, and also had a lot of reading to keep up. I had make some proof of concepts related to plugins, and at the end I thought, wow that was very productive, but... wait... I didn't either write or commit a single line of code in the main project. How that could be productive? Did you ever had the same feeling?</p>
<p>That happens a lot, 'cause you are building the ideia on your head. If you alredy knew, you would be just typing. Programing is much more related to thinking than pressing keys, although hollywood might disagree. In my daily work, my mind must be focused and aimed at the goal. But, in your personal projects, you must have fun along the way, let your mind flow for a while.</p>
<p>In my opinion, opensource projects are marathons, not short runs. So have fun, appreciate the view, get some small detours. Don't rush and lose your breath, just keep going. If you can't enjoy yourself, how contributors will get inpired?</p>
<p>And them, as said, there is much more than code. There must be passion doing this.</p>
<p>Today's post is dedicated to my friend <a class="reference external" href="https://twitter.com/luizf0510">Luiz Fuhrmeister</a> who have passed away yesterday, on February 14.</p>
<div class="section" id="next-wednesday">
<h2>Next wedNESday</h2>
<blockquote>
<ul class="simple">
<li>Have more fun!</li>
</ul>
</blockquote>
</div>
wedNESday #6 - A bigger blender brain2017-02-08T23:00:00-02:002017-02-12T13:54:00-02:00Guto Maiatag:gutomaia.net,2017-02-08:/wednesday_6.html<div class="figure align-center">
<img alt="Blender Brain" src="https://gutomaia.net/images/blender_bigger_brain.jpg" />
<p class="caption">Blender Bigger Brain*</p>
</div>
<p>On last week's post, I had a "to do" list over the comments of the "upcoming improvements". So <a class="reference external" href="https://twitter.com/salexkidd">Toshimitsu Kamei</a> came to the rescue again with the IO expander stuff. He sent some study material and sugests a small proof of concept just by following some internet …</p><div class="figure align-center">
<img alt="Blender Brain" src="https://gutomaia.net/images/blender_bigger_brain.jpg" />
<p class="caption">Blender Bigger Brain*</p>
</div>
<p>On last week's post, I had a "to do" list over the comments of the "upcoming improvements". So <a class="reference external" href="https://twitter.com/salexkidd">Toshimitsu Kamei</a> came to the rescue again with the IO expander stuff. He sent some study material and sugests a small proof of concept just by following some internet tutorials. He sugests the use of a MCP23017 I2C port expander.</p>
<p>Then, let me share the links:</p>
<ul class="simple">
<li><a class="reference external" href="http://www.raspberrypi-spy.co.uk/2013/07/how-to-use-a-mcp23017-i2c-port-expander-with-the-raspberry-pi-part-1/">How To Use A MCP23017 I2C Port Expander With The Raspberry Pi - part 1</a>;</li>
<li><a class="reference external" href="http://www.raspberrypi-spy.co.uk/2013/07/how-to-use-a-mcp23017-i2c-port-expander-with-the-raspberry-pi-part-2/">How To Use A MCP23017 I2C Port Expander With The Raspberry Pi - part 2</a>;</li>
<li><a class="reference external" href="http://www.raspberrypi-spy.co.uk/2013/07/how-to-use-a-mcp23017-i2c-port-expander-with-the-raspberry-pi-part-3/">How To Use A MCP23017 I2C Port Expander With The Raspberry Pi - part 3</a>;</li>
<li><a class="reference external" href="http://hackaday.com/2011/06/07/working-with-i2c-port-expanders/">Working with I2C port expanders</a>;</li>
</ul>
<p>And then, let's start reading and connecting wire jumps over the protoboard. I don't think that I will achieve a major breaktru this week, but I do need to improve my hardware skills.</p>
wedNESday #5 - It's alive!2017-02-01T23:00:00-02:002017-02-04T13:54:00-02:00Guto Maiatag:gutomaia.net,2017-02-01:/wednesday_5.html<div class="figure align-center">
<img alt="it's alive" src="https://gutomaia.net/images/blender_terminal.jpg" />
</div>
<p>First of all, I must thanks <a class="reference external" href="https://twitter.com/salexkidd">Toshimitsu Kamei</a>, without him this post wouln't be possible. Some time ago, he helped me up connecting the RasberryPI's GPIO along with <a class="reference external" href="http://datasheets.chipdb.org/Western%20Design/W65C02S.pdf">W65C02S</a>. It was fun, although I was kind of clumsy in this meantime, and them now I have to reattach everything. So …</p><div class="figure align-center">
<img alt="it's alive" src="https://gutomaia.net/images/blender_terminal.jpg" />
</div>
<p>First of all, I must thanks <a class="reference external" href="https://twitter.com/salexkidd">Toshimitsu Kamei</a>, without him this post wouln't be possible. Some time ago, he helped me up connecting the RasberryPI's GPIO along with <a class="reference external" href="http://datasheets.chipdb.org/Western%20Design/W65C02S.pdf">W65C02S</a>. It was fun, although I was kind of clumsy in this meantime, and them now I have to reattach everything. So, let's do it.</p>
<div class="section" id="the-ingredients">
<h2>The Ingredients</h2>
<ul class="simple">
<li><a class="reference external" href="https://www.amazon.com/gp/product/B01CD5VC92/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01CD5VC92&linkCode=as2&tag=gutomaia-20&linkId=e9dd7c39ce1445557706ad75cbf52728">Raspberry PI's 2 or 3</a></li>
<li>Breadboard</li>
<li>W65C02S</li>
<li><a class="reference external" href="https://www.amazon.com/Honbay-120pcs-Multicolored-Female-Breadboard/dp/B017NEGTXC">Wires</a></li>
<li><a class="reference external" href="https://www.amazon.com/gp/product/B01CNKXM54/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01CNKXM54&linkCode=as2&tag=gutomaia-20&linkId=92cbec6f2c6b0cc63afeaef93116a30b">GPIO Expansion Board</a></li>
</ul>
<p>You must use a Raspberry PI's 2 or above, due to the number of available GPIO ports. Using the GPIO Expansion Board is optional but highly recommended. The types of wiring that you might use depends if you be using or not the GPIO Expansion Board.</p>
</div>
<div class="section" id="wiring-up">
<h2>Wiring Up</h2>
<p>Not really a big deal, however, you need to be carefull and patient. Raspberry PI's GPIO is not so fault tolerant as the Arduino is, any wrong connection on the ground or VCC and you might kill it. About the W65C02S, I'm not so sure, didn't burn any so far.</p>
<div class="figure align-center">
<img alt="breadboard.jpg" src="https://gutomaia.net/images/blender_breadboard.jpg" />
<p class="caption">GPIO's connections</p>
</div>
</div>
<div class="section" id="hello-world">
<h2>Hello World</h2>
<p>Now that we got all connected, let's say hello. The following "Hello World" will read the address bus after the reset. When started, 6502 must read content from address 0xfffa, although, anything from 0xfffa to 0xfffe would be nice.</p>
<div class="highlight"><pre><span></span>GPIO.setmode(GPIO.BCM)
ADDRESS_PINS = [
4, 17, 27, 22, 10, 9, 11, 5, 6, 13, 19, 26, 21, 20, 16, 12
]
RESET_PIN = 8
CLOCK_PIN = 7
def terminate(signum, frame):
GPIO.cleanup()
sys.exit(0)
def setup():
# Address pins
for pin in ADDRESS_PINS:
GPIO.setup(pin, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
# Reset pin
GPIO.setup(RESET_PIN, GPIO.OUT)
# Clock PIN (PHI2)
GPIO.setup(CLOCK_PIN, GPIO.OUT)
# SIGINT
signal.signal(signal.SIGINT, terminate)
def reset():
GPIO.output(RESET_PIN, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(RESET_PIN, GPIO.LOW)
time.sleep(0.1)
GPIO.output(RESET_PIN, GPIO.HIGH)
print("reset complete")
def send_clock():
time.sleep(0.1)
GPIO.output(CLOCK_PIN, GPIO.LOW)
time.sleep(0.1)
GPIO.output(CLOCK_PIN, GPIO.HIGH)
def read_address():
pin_state = ""
for pin in reversed(ADDRESS_PINS):
pin_state += str(GPIO.input(pin))
hex_address = hex(int(pin_state, 2))
return pin_state, hex_address
def read_address2():
pins = [int(GPIO.input(pin) for pin in ADDRESS_PINS)]
state = sum([int(cc) * (2 ** i) for i, cc in enumerate(reversed(pins))])
return state, hex(state)
def main_loop():
while True:
address = read_address()
input = None
input = raw_input('("reset", (n)ext, "(r)ead" [{}]> '.format(address))
if input == "reset":
reset()
elif input == "r":
print("READ!: [{}]".format(read_address()))
else:
print("READ!: [{}]".format(read_address()))
send_clock()
if __name__ == "__main__":
setup()
reset()
try:
main_loop()
except:
terminate()
</pre></div>
<p>Not much to watch right now. You only be able to reset and check that it is reading the expected address. So far, we just acomplished a overside blinking led demo.</p>
</div>
<div class="section" id="upcomming-improvements">
<h2>Upcomming Improvements</h2>
<ul class="simple">
<li>The reset routine is not consistent. Sometime it jumps to 0xfff[a-e], sometime it doesn't.</li>
<li>If you took a closer look on the wiring, you will notice that not all PINs were connected. I know, we are just connecting the address bus. We did not connected the data bus due the lack of available ports. That's why we can only hear from the address bus so far.</li>
<li>We need to use some IO expander for sending data to address bus and data bus, that way will be using less ports on the Raspberry PI.</li>
</ul>
</div>
wedNESday #42017-01-25T23:00:00-02:002017-01-28T17:35:00-02:00Guto Maiatag:gutomaia.net,2017-01-25:/wednesday_4.html<div class="figure align-center">
<img alt="Blender Brain" src="https://gutomaia.net/images/blender_brain.jpg" />
<p class="caption">Blender Brain*</p>
</div>
<div class="section" id="split-and-share">
<h2>Split and Share</h2>
<p>I'm splitting the project wedNESday into a guide project. Unfortunelly, it does not have a catch name yet. The goal of this sidekick project is to serve as a lighthouse for thouse who attempt to create an emulator. It's filled with abstract test case scenarios …</p></div><div class="figure align-center">
<img alt="Blender Brain" src="https://gutomaia.net/images/blender_brain.jpg" />
<p class="caption">Blender Brain*</p>
</div>
<div class="section" id="split-and-share">
<h2>Split and Share</h2>
<p>I'm splitting the project wedNESday into a guide project. Unfortunelly, it does not have a catch name yet. The goal of this sidekick project is to serve as a lighthouse for thouse who attempt to create an emulator. It's filled with abstract test case scenarios. Well, for now the sameone I already have on wedNESday (yep, mostly,just copy and clip).</p>
</div>
<div class="section" id="the-real-deal">
<h2>The Real Deal</h2>
<p>As I had more time, due to a local holiday, I've spent a lot of time with an actual 6502 microprocessor, thanks to <a class="reference external" href="https://twitter.com/salexkidd">Toshimitsu Kamei</a>, who bought that for me sended it to Brazil from Japan. The MPU is a <a class="reference external" href="http://datasheets.chipdb.org/Western%20Design/W65C02S.pdf">W65C02S</a>. I'm using the RaspberryPi's GPIO to interract with it. So far, haven't done much. Still reading the manual and how to actially send and data and memory addresses. Also dealing with pinout flags, to understand when I should read from data and address and when I should write.</p>
<div class="section" id="trivia-fact">
<h3>Trivia fact</h3>
<ul class="simple">
<li>Matt Groening's Futurama showed that Blender uses a 6502 CPU.</li>
</ul>
<div class="figure align-center">
<img alt="Futurama" src="https://gutomaia.net/images/futurama.jpg" />
</div>
</div>
</div>
<div class="section" id="next-wednesday">
<h2>Next wedNESday</h2>
<blockquote>
<ul class="simple">
<li>Don't know yet. I'll certainly have less time available this week. How about some GUI?</li>
</ul>
</blockquote>
</div>
wedNESday #32017-01-18T23:00:00-02:002017-01-21T17:34:00-02:00Guto Maiatag:gutomaia.net,2017-01-18:/wednesday_3.html<div class="section" id="goals-and-detours">
<h2>Goals and Detours</h2>
<p>One of goals this week was to create a fake PPU, so that we can start testing it and playing with it and create a Pull Request in the py65 project with some tests. Although, while writing some tests in order to reach the first goal, I …</p></div><div class="section" id="goals-and-detours">
<h2>Goals and Detours</h2>
<p>One of goals this week was to create a fake PPU, so that we can start testing it and playing with it and create a Pull Request in the py65 project with some tests. Although, while writing some tests in order to reach the first goal, I thought that I could do better.</p>
</div>
<div class="section" id="running-some-asm-snippets">
<h2>Running some ASM snippets</h2>
<p>For the fake PPU, I need some tests that calls it. All the tests that I had so far, dealed only with CPU. Then using <a class="reference external" href="https://github.com/gutomaia/nesasm_py">nesasm_py</a> I've managed to run some ASM code snippets within a test in a very readable way. I took some code snippets, some of them, like
<a class="reference external" href="https://github.com/gutomaia/wedNESday/blob/9d162406bb01144b9339284801f4cd2e5c1ba352/wednesday/tests/nes_snippet_test.py#L104">load palettes</a> uses the PPU. Then the detours started.</p>
<p>Those tests open the possibility to run some book and tutorials codesnippets without much effort. I've started some demos from <a class="reference external" href="http://www.6502.org/tutorials/compare_beyond.html">6502.org's compare beyond</a>, now I'm playing with some codesnippets from the book <a class="reference external" href="https://www.amazon.com/Machine-Language-Beginners-Richard-Mansfield/dp/0942386116">Machine Language for Beginners</a> by Richard Mansfield.</p>
</div>
<div class="section" id="divide-and-conquer">
<h2>Divide and Conquer</h2>
<p>I though, that not only py65 deserve some pull requests, but those demos might be useful for other projects. I'm thinking in creating kind of a 'guide' project/module just filled with tests in the most generic way. If anyone could think of a catch name, please tweet me!</p>
<p>As usual, you can checkout the progress at <a class="reference external" href="https://github.com/gutomaia/wedNESday">wedNESday repository</a>.</p>
</div>
<div class="section" id="next-wednesday">
<h2>Next wedNESday</h2>
<blockquote>
<ul class="simple">
<li>It will be a holiday on São Paulo-Brasil, thefore I might have more time to evolve on the PPU.</li>
<li>Code Snippets from <a class="reference external" href="https://www.amazon.com/Machine-Language-Beginners-Richard-Mansfield/dp/0942386116">Machine Language for Beginners</a>'s book.</li>
<li>Split the tests into a Guide project.</li>
</ul>
</blockquote>
</div>
wedNESday #22017-01-11T23:00:00-02:002017-01-14T17:34:00-02:00Guto Maiatag:gutomaia.net,2017-01-11:/wednesday_2.html<div class="section" id="keep-up">
<h2>Keep up</h2>
<p>I've refactored the tests and extracted to <a class="reference external" href="https://github.com/gutomaia/wedNESday/blob/68e17dff9ec06215c53f05c5069c3c06aadc8816/wednesday/tests/cpu_6502_spec.py">CPU6502Spec</a>, and them start playing with py65. Didn't take long to have most of the test working. Now I have the same test spec running with either ApplyPy or Py65 6502, and that's amazing. Although, let's keep in mind that the …</p></div><div class="section" id="keep-up">
<h2>Keep up</h2>
<p>I've refactored the tests and extracted to <a class="reference external" href="https://github.com/gutomaia/wedNESday/blob/68e17dff9ec06215c53f05c5069c3c06aadc8816/wednesday/tests/cpu_6502_spec.py">CPU6502Spec</a>, and them start playing with py65. Didn't take long to have most of the test working. Now I have the same test spec running with either ApplyPy or Py65 6502, and that's amazing. Although, let's keep in mind that the goal is a Ricoh 2A03 CPU, the NES CPU. And that lead us to deal with interrupts.</p>
</div>
<div class="section" id="irq-and-nmi">
<h2>IRQ and NMI</h2>
<p>IRQ stands for "Interrupt Request" and NMI for "Non-Masked Interrupt". As far as I know, and please someone correct me if I got it wrong. Interrupts are used for event handling. On the NES, you have two CPUs (Main and PPU for graphics) that runs in parallel. There fore, to accurately emulate a NES, we need to deal with several race conditional on the hardware. Or, for start, we can make then serial (<a class="reference external" href="https://wiki.nesdev.com/w/index.php/NMI_thread">NMI Thread</a> on NESDev gives good tips in NMI only), and be able to run Super Mario Bros.</p>
<p>As usual, you can checkout the progress at <a class="reference external" href="https://github.com/gutomaia/wedNESday">wedNESday repository</a>.</p>
</div>
<div class="section" id="next-wednesday">
<h2>Next wedNESday</h2>
<blockquote>
<ul class="simple">
<li>Create a fake PPU and a memory bridge and try to run a simple waitvblank program.</li>
<li>Create a pull request with CPUSpec and send to <a class="reference external" href="https://github.com/mnaberez/py65">py65</a>.</li>
</ul>
</blockquote>
</div>
wedNESday #12017-01-04T23:00:00-02:002017-01-07T23:00:00-02:00Guto Maiatag:gutomaia.net,2017-01-04:/wednesday_1.html<div class="section" id="forewords">
<h2>Forewords</h2>
<p>I've been hacking the NES for quite a long time, and since them, I've always been asked for writing an emulator. Although it was never a priority, everytime a question like that stands, I usually answer: "Why not?".</p>
<p>Let's think over. Why should I, and why you should to …</p></div><div class="section" id="forewords">
<h2>Forewords</h2>
<p>I've been hacking the NES for quite a long time, and since them, I've always been asked for writing an emulator. Although it was never a priority, everytime a question like that stands, I usually answer: "Why not?".</p>
<p>Let's think over. Why should I, and why you should to? There are already several good emulators available, why write another one?</p>
<p>Moreover, googling about the subject "write nes emulator", there are several good stories. I've put the most relevant links at the bottom. I also recomend you to read them.</p>
<p>Therefore. What to tell abount NES emulators that haven't already being told? Well, not saying that I do intend to fishish it, but let's explore more the ideia.</p>
</div>
<div class="section" id="press-start">
<h2>Press Start</h2>
<p>In order to write the emulator, we need to keep up with the overall architecture that was involved. For now, let's focus on the CPU. NES had a Ricoh 2A03 CPU with the same instruaction set of the 6502. Since we are talking about code. Let highlight the code
from Niels Widger's <a class="reference external" href="https://github.com/nwidger/nintengo">Nintengo</a>. It's very polished, and more important, it's filled with tests. So as a experiment, I've rewrote the tests and used on the James Tauber's <a class="reference external" href="https://github.com/jtauber/applepy">ApplePy</a>, most impressive, without mush effort, the test spec payoff, and show how well made ApplePy is.</p>
<p>You can checkout the progress at <a class="reference external" href="https://github.com/gutomaia/wedNESday">wedNESday repository</a>.</p>
</div>
<div class="section" id="next-wednesday">
<h2>Next wedNESday</h2>
<blockquote>
<ul class="simple">
<li>Get a better understand on how IRQ and NMI works</li>
<li>try to do the same with <a class="reference external" href="https://github.com/mnaberez/py65">py65</a>.</li>
</ul>
</blockquote>
</div>
<div class="section" id="references">
<h2>References</h2>
<p><a class="reference external" href="http://nwidger.github.io/blog/post/writing-an-nes-emulator-in-go-part-1/">Writing an NES emulator in Go Part 1</a></p>
<p><a class="reference external" href="http://blog.alexanderdickson.com/javascript-nes-emulator-part-1">Write a NES Emulator with Javascript Part 1</a></p>
<p><a class="reference external" href="http://blog.alexanderdickson.com/javascript-nes-emulator-part-2">Write a NES Emulator with Javascript Part 2</a></p>
<p><a class="reference external" href="https://medium.com/@fogleman/i-made-an-nes-emulator-here-s-what-i-learned-about-the-original-nintendo-2e078c9b28fe#.7535jmlgd">I made an NES emulator Heres what I learned about the original Nintendo</a></p>
</div>
The First Post2016-02-20T19:18:00-02:002016-02-20T22:21:00-02:00Guto Maiatag:gutomaia.net,2016-02-20:/first_post.html<p>This is not my first attempt to write a blog, nevertheless, shall be the last. However, in this brief time lapse before the next attempt I must overcome the mistakes that lead previous blog to fade after the "First Post".</p>
<p>One early mistake is the actual "first post". Usually, in …</p><p>This is not my first attempt to write a blog, nevertheless, shall be the last. However, in this brief time lapse before the next attempt I must overcome the mistakes that lead previous blog to fade after the "First Post".</p>
<p>One early mistake is the actual "first post". Usually, in the content is said what's the blog is about and dictate boundaries for what readers might find. This time, I won't put any restriction. I might write about books that I'm reading, code and hacks and whatever comes in mind.</p>
<p>My second mistake was the platform. Previous blogs were done with wordpress and "Meme", a discontinued Yahoo blog platform. Neither them suited me well. The first is jungle of templates and plugins that don't get along well and the second was discontinued despite being great, what also made me avoid other platforms like tumblr and medium.</p>
<p>Third mistake, was trying to being perfect. That end up with fewer post and lots of unfinished drafts. Most of then were kept as draft due to the fear of critcism.</p>
<p>As a coder, I found markdown generated blogs more suited for daily use. With trivial automated scripts, I can easily update content with a commit, friends could send fix and even submit article with pull requests.</p>