More Ramblings from a Los Angeles Programmer

January 25, 2007

Working (sort of) NES Emulator

Filed under: coding, technology — Tags: — Josh DeWald @ 6:46 am

Well, I spent all day hacking on Sunday and managed to get some graphics to display on the NES emulator. As I hoped, I was able to use the same architecture as the C64 Emulator and actually am using the exact same processor implementation. The ADC and SBC instructions have slightly different modifications (the version of the 6502 used in the NES does not make use of the Decimal flag for BCD mode), but that’s *it*.

I had a business trip and hacked on the plane and manged to get Pacman to become playable (but look horrible).
Pacman screenshot
I was having some major palette issues. Using the tried and true bug-fixing technique of…stepping away…I was able to track down why the graphics were totally jacked (had some incorrect handling of the Attribute tables as they relate to the tiles displayed on the screen). So now Pacman looks *almost* correct. At least I thought so until I made the screenshot. There is a lot of work to do to get the sprites to draw correctly. Thankfully the background is at least correct.

My “end goal” is to get it so that my wife can play Super Mario Brothers 3. I’m hoping to implement the mapping for it soon. Currently Super Mario Brothers (1) will play the starting demo (but has all sorts of artifacts on the screen including the fact that I’m not handling transparent pixels).
Super Mario Brothers screenshot 2Super Mario Brothers screenshot

So, as you can tell, a lot of work left… but I’m pleased with it as a proof of concept and a definite work in progress. I’d like to also implement the audio for this one (which can hopefully be reused for the C64).

Update (11/30/2007): Here are screenshots from the more recent version of the emulator (these are actually from April) of which I have released the source

Super Mario Brothers 3 Home ScreenZelda SwordMario 1 Level 2

January 21, 2007

Testing Emulator Architecture

Filed under: coding, technology — Tags: — Josh DeWald @ 3:09 am

Even though my Java-based Commodore 64 emulator isn’t yet complete, I’ve decided to start on an NES emulator. One of my reasons is that I’d like to test out my design for how the emulator is structured to see how reusable the components are. Technically the only shared component is the MOS 6502/6510 that acts as the main processor. In addition to that same physical component, the two will share the way that memory reads and interrupts are handled.

My hope is that coming at the system from a different angle will help me work out kinks in the design in addition to any inaccuracies in the emulation at the low level. Not all of the instructions in my 6502 having correct timing, and I believe that could relate to why some of the games have odd behavior. The actual implementations (aside from the BCD code in the SBC instruction) are all correct and pass the tests in the excellent C64 Emulator Test suite developed by Wolfgang Lorenz as part of his PC64 emulator.

Eventually I would like to be able to “build” virtual machines a property file and some form of IoC (Inversion of Control) with Spring or the likes to wire everything together. As it stands, most components are fairly independent from each other and only know about some interfaces. Without doing any modifications to the core really (only added support for NMI), I’ve already managed to read in an NES ROM and start executing instructions. The graphics aren’t implemented yet, so there it’s not doing anything obvious, but we shall see.

This page also serves as a marker for me to know when I started it and track some progress.

I want to put some thanks right now to all of those out there (much of which can be found through NesDev) who have created excellent documentation.

January 18, 2007

Calculating Quality of American Idol Audition

Filed under: daily life — Josh DeWald @ 5:09 am

Through my minimal watching of American Idol (my wife loves the show), I’ve noticed that, at least in the auditions they choose to show, talent is inversely proportional to self-perception of talent.

T = 1/kS + C

Where:

T = talent
S = Self-perception of talent
k = Constant of proportion
C = Base level of talent (one hopes this exists)

I think that S reveals itself through, and can perhaps be quantified by, the usage of such terms and phrases as “unique”,”different than “everyone else”,”I’ve been told I sound like…” and, with extra weighting, “I know that I’m going to be next American Idol” and “I have a wide vocal range.”

Writing this reminded me of an article I read a while back about the fact that incompetent people tend to believe they are experts. I believe that this is actual the original article.

January 11, 2007

Book Meme

Filed under: Uncategorized — Josh DeWald @ 4:13 am

Found here:

bronzechef.com » Blog Archive » Book Meme

The instructions were: Bold the ones you’ve read, strike-out the ones you hated, italicize those you started but never finished and put an asterisk beside the ones you loved.
1. The Lord of the Rings, J.R.R. Tolkien
2. The Foundation Trilogy, Isaac Asimov *
3. Dune, Frank Herbert *
4. Stranger in a Strange Land, Robert A. Heinlein *
5. A Wizard of Earthsea, Ursula K. Le Guin
6. Neuromancer, William Gibson
7. Childhood’s End, Arthur C. Clarke *
8. Do Androids Dream of Electric Sheep?, Philip K. Dick
9. The Mists of Avalon, Marion Zimmer Bradley
10. Fahrenheit 451, Ray Bradbury
11. The Book of the New Sun, Gene Wolfe
12. A Canticle for Leibowitz, Walter M. Miller, Jr.
13. The Caves of Steel, Isaac Asimov
14. Children of the Atom, Wilmar Shiras
15. Cities in Flight, James Blish
16. The Colour of Magic, Terry Pratchett
17. Dangerous Visions, edited by Harlan Ellison
18. Deathbird Stories, Harlan Ellison
19. The Demolished Man, Alfred Bester
20. Dhalgren, Samuel R. Delany
21. Dragonflight, Anne McCaffrey
22. Ender’s Game, Orson Scott Card *
23. The First Chronicles of Thomas Covenant the Unbeliever, Stephen R. Donaldson
24. The Forever War, Joe Haldeman
25. Gateway, Frederik Pohl
26. Harry Potter and the Philosopher’s Stone, J.K. Rowling
27. The Hitchhiker’s Guide to the Galaxy, Douglas Adams *
28. I Am Legend, Richard Matheson
29. Interview with the Vampire, Anne Rice
30. The Left Hand of Darkness, Ursula K. Le Guin
31. Little, Big, John Crowley
32. Lord of Light, Roger Zelazny
33. The Man in the High Castle, Philip K. Dick
34. Mission of Gravity, Hal Clement
35. More Than Human, Theodore Sturgeon
36. The Rediscovery of Man, Cordwainer Smith
37. On the Beach, Nevil Shute
38. Rendezvous with Rama, Arthur C. Clarke *
39. Ringworld, Larry Niven *
40. Rogue Moon, Algis Budrys
41. The Silmarillion, J.R.R. Tolkien
42. Slaughterhouse-5, Kurt Vonnegut
43. Snow Crash, Neal Stephenson
44. Stand on Zanzibar, John Brunner
45. The Stars My Destination, Alfred Bester
46. Starship Troopers, Robert A. Heinlein
47. Stormbringer, Michael Moorcock
48. The Sword of Shannara, Terry Brooks
49. Timescape, Gregory Benford
50. To Your Scattered Bodies Go, Philip Jose Farmer

Looks like I’ve got some books to read…

January 4, 2007

Researchers use brain scans on shoppers | Science Blog

Filed under: Uncategorized — Josh DeWald @ 5:33 pm

Researchers use brain scans on shoppers | Science Blog
The results of this paper support an alternative perspective that views consumers as trading off the immediate pleasure of making a purchase against an immediate pain: the pain of forking out the money for the item.

All I gotta say is: Ain’t that the truth!

January 2, 2007

Start of a new year

Filed under: daily life — Josh DeWald @ 2:33 am

For the past couple of years, the New Year has only meant that I reset my counter for my reading goal of 52 books in a year. The first year, I managed 54 in the end. This year I was able to get 48. If I pretend that my goal was 4 books a month, then I met the goal! Score one for revisionism. I actually think I will make that my revised goal for this year. On top of it I would like to write at least one short story a month.

I haven’t really tried writing but I have been wanting to for a long time and the best way to write is to write. My own maintenance of this blog will hopefully not be the best indicator at my ability to maintain steady prose. I don’t actually have any ideas yet, so it should be…entertaining.

I have a feeling that I’ll quickly want to change my reading habits to be 2 a month. However, depending on where I live when I move to England for my job, I could have a 45 minute train ride (similar to my hour to hour and half bus ride here in LA) to work and back to get my reading (and writing) done.

I’ve also been working recently on my Commodore 64 Emulator . I’ve made some strides in the graphics handling. There are some weird glitches in playing the games which I think might be related to the not-quite-accurate-but-not-horrible-either timing of the instruction emulation. So I need to revisit that and hopefully that will iron out some of the weirdness. It has come a long way since I got ’10 PRINT “HELLO WORLD”‘ to work.

Create a free website or blog at WordPress.com.