Archive

Archive for the ‘code’ Category

8-bit Assembler Artwork

November 16th, 2008 Brad No comments

I happened upon this project called dismap last week that generated fantastic artwork from 8-bit game carts.  The person behind the project, Ben Fry, disassembled the roms using a tool called NESrev, and then formatted the 6502 assembler instructions into readable columns.  To touch up the visuals, he then drew lines between all of the jmp source and destinations.  He also lead a companion project called Mario Soup, featuring tiles ripped from Super Mario Bros., and another project called distellamap, which featured assembly code from Atari 2600 games.  Prints are available for both dismap, and distellamap.

Categories: Art, code Tags:

Silence on the Wire

July 16th, 2008 Brad No comments

Sorry, I haven’t updated in ages. Prepare yourself for some rambling. I switched to Night Shift, then back to Day Shift. Went on a couple road trips, read a book or two, etc. Anyway, I’ve been porting Mode8 to SDL. It was sad when I decided to do so, as I had to throw away the coolest, and most time consuming classes. But actually the switch improved the over all structure. I’ve also been watching a lot of races over at the Velodrome. Good stuff. The Tour de France is currently in the Pyrenees’s; Team Columbia has been doing well. I wish both them and Garmin-Chipotle the best. Also, the teams that composed the ProTour decided not to renew their licenses, effectively ending, well, the ProTour.  FF4ds comes out next week, and it looks fantastic. DQ4ds comes out in two months and looks even better. This years E3 was utterly pathetic; the only decent news to emerge was about Mirrors Edge, and the FFXIII port to the Xbox 360.

Categories: Books, Cycling, Site, blife, code Tags:

blife2 on the wii

May 26th, 2008 Brad 1 comment

I was up until 3:30am last night working on this. :=)

blife2 on the wii

Categories: blife, code Tags:

blogging

May 19th, 2008 Brad No comments

You might remember blife.  It was an implementation of Conway’s Game of Life in C, and used OpenGL to render the state of the colony.  It worked in Windows, Linux, and everything else.

I threw it away.

I’ve been working on a nice and clean generic cellular automata application.  I’ve been programming in C++, and using SDL to render output.  The kicker is this, though–the ruleset isn’t going to be hardcoded.  The idea here is to abstract away the rules, so that it can be used to simulate anything.  I’m working on a LISP interpreter that will run the rulesets.

What are the advantages of this approach?  In the original blife, you were bound to Game of Life, and only Game of Life.  By virtue of implementing the GoL as a standard, you were also stuck with its default rules. Neither of these assumptions will be present in this new application.  You’ll be able to modify life to your hearts content.  And who says you have to run Life; run Wolframs ‘Rule 30′ instead.  Or use it as a tsst bed for any ideas you have kicking around in your head.

I forgot to mention, SDL wont be the only output option available.  NULL, Text, and PNG output will be available out of the box.

Categories: blife, code Tags:

The Codebook

March 13th, 2008 Brad 1 comment

I’ve been keeping a journal that I call “The Codebook” for the past four of five years. When people see it for the first time, they usually ask me something like: “So.. are you with the NSA then..?”, and I although cliche, reply with something like: “I can neither confirm nor deny my involvement with the NSA”. Anyway, The Codebook is a notebook that I write down all of my programming ideas, work through technical problems, and keep track of what I’m working on.

The content of The Codebook is intractable. It ranges from C++-pseudo code, and algorithm analysis, to mocked up maps that I plotted out when I did that Legend of Zelda clone I wrote back in college. It’s also organized very poorly. Anybody who looked at it would probably think it’s gibberish Computer Science, or some kind of nerd stream of consciousness piece. For instance, I just found an outline of what my plans for JuiceMUD were, right next to a rather large listing of UNIX programs, and then on the next page there’s some mysterious binary work surrounded by blank paper.

This all leads me to a question: how do you keep your technical thoughts organized?

Codebook Cover Codebook Example Codebook Map

Categories: Computing, code Tags:

Compiling libpng in Visual Studio .NET {2005}

March 1st, 2008 Brad No comments

There is very spotty documentation on how to use libpng under Windows. I did find one site that talks about the subject, so you might want to refer to it as well.

1. Libpng Setup:

First, you’ll need to download the latest version of libpng and zlib. Extract them someplace (I placed them within my projects root, in a directory called ‘deps’). The pre-canned Visual Studio settings that come with libpng look for ‘zlib’ rather than ‘zlib-x.y.z’, so rename the directories so that they lack the version numbers.

2. Compiling libpng and zlib

Next go into <projectname>\deps\libpng\projects\visualc71 and open libpng.sln. Go to Build and run ‘Clean Solution’. Now you have a choice, you can either compile libpng as a dynamically loaded library, or a binary blob to statically link into your executable. You can compile either one as a debug or release build. Just make sure that whichever way you compile libpng (debug/release), is the same as what you compile your project. So choose an option, and go to Build -> Build Solution. This will compile both libpng and zlib.

3. Project Setup

Now you’ll need to set your project up to include the libpng and zlib files. Open your Visual Studio project, and go to Project -> <projectname> Properties. Expand Configuration Properties, and then expand C/C++. The top field on the right will read “Additional Include Directories”. Click it and add “C:\<projectname>\deps\zlib;C:\<projectname>\deps\libpng”.

Now close the C/C++ tree and expand the Linker tree, which is directly below it. Roughly 3/4 of the way down is a field called “Additional Library Directories”. Click it and add

“C:\<projectname>\deps\libpng\projects\visualc71\<projecttype>\ZLib;
C:\AnimTester\deps\libpng\projects\visualc71\<projecttype>”.

In my case, I compiled as Win32_LIB_Debug (Statically Linked, Debug Symbols included), so that’s what I set <projecttypeyoucompiledas> to.

Next open the Input node that is in the Linker tree. Under “Additional Dependancies” add libpngd.lib zlibd.lib if you chose to statically link, or libpng13d.lib zlib1d.lib if you compiled it as a dll. If you did compile as a dll, you will then need to copy the dll’s that were generated to the same directory as your executable, or to a directory loaded in PATH.

Now you can implement PNG reading or writing into your project.

4. Troubleshooting

Q: I get a ton of linking errors!
A: Visual Studio cannot find the lib files. Double check that they are compiled (libpng{..}.lib, zlib{…}.lib), that your projects Library dependancies includes the directories that they are in, and that the lib files are included in the Additional Dependancies field.

Q: Visual Studio spits out errors about undeclared identifiers!
A: Make sure you have #include <png.h> in your source. Also make sure that png.h’s path is included under Additional Included Directories in your projects settings.

Categories: Computing, Projects, code Tags:

My History of Programming

December 19th, 2007 Brad 3 comments

This essay is a somewhat brief history of my programming experiences. It is by no means all encompassing, but I’ve tried to hit all of the big moments in my programming career (my favorite classes and so forth).

Although I had experimented with QBasic a little bit as a lad, it wasn’t until High School when I got my TI-85 graphing calculator that I really started to program. The TI-85 was a wonderful device that allowed users to program in a BASIC right on the calculator using the keypad. The primitives and control structures were all listed in horizontal menus, and you’d select which one you wanted using the menu buttons as the top of the keypad.

I didn’t have a manual on BASIC, so I fooled around with each keyword until I understood what it did. The first program I managed to write was a simple Fahrenheit to Celsius converter. The program prompted the user for a number, which would then be run through the function c = (f - 32) * 5/9. I followed that up by giving the program modes so I could also convert from Celsius to Fahrenheit. After that I programmed miscellaneous math programs for the classes I was taking at that time, most of which were for trigonometry so that I could verify my answers.

Sometime around the summer of 1999, I purchased one of those “Learn in 30 days” books on Visual C++. It was so awful that I stopped using it after Day 2. I made an assumption that C++ was universally awful, and I stopped going down that road altogether. So I gave up on C++ and kept doing little things on my 85 for the rest of High School.

I enrolled in a University in 2001 and wasn’t certain what I wanted to do with my life, so I signed up for two General Education classes and the introductory Computer Science course since it sounded like fun. The course (cs110) was taught in Java by Prof. G. Object Oriented programming pretty much blew my mind–everything was so abstracted and elegant. The next course (cs111) was an extension of 110, further exploring abstraction and data-hiding. The only project I recall from either class was a movie rental program that allowed users to register products (DVD’s and VHS tapes), and check them out to customers. To augment 111, I put together a little command line battle simulator that allowed the user to equip items (which never changed), and battle a single monster to the death. It was kind of like those old text games such as Adventure, or Zork–except without features.

After cs111 there was a jump in difficulty, as I took a course on Data Structures from Prof. A. It wasn’t so much that the ideas were tough, it was that his style (at least at that point) was to throw the class into the deep end of the pool, with three large assignments of which he provided a specification that we had to program. The lectures were rarely on the same topic as the assignments, forcing us to come into our own by researching and developing our own solutions (meanwhile studying the lectures for the tests). At the time the experience freaked me out, but now I’d consider it one of the most helpful exercises I had during college.

The next interesting course I took was on assembly language, which I must confess, is probably my favorite language. Everything is broken down into logical little pieces and you’re able to see why, and how every single little thing in your program is working.

The quarter after I took the course on assembly, I didn’t feel like I had built any large programs, and that I wasn’t really doing anything interesting, so I started programming a Multi-User Dungeon (MUD) in Java. I used it as an opportunity to teach myself 1) Network programming and 2) Multithreading. This project, which I called Vagabond, progressed pretty far. I got it to the point where there was a map that players could walk around on using simple keywords such as north, south, east, and west. Players could load, and save data. They could also interact with other people that were logged in. I even programmed my own text formatting library that used a subset of HTML to specify where on the screen text should be placed, and what color it ought to be. This enabled me to spruce up text such as “A <bold><green>Green Dragon</green></bold> draws near!”. Players could also use the color tags. Here’s a screenshot:
vagabond mud screenshot

It was about this time that I started teaching myself C. I was getting antsy to ditch Java (which all the courses up until this point other than the assembly course were taught in). Specifically I wanted to be able to interface with all the great C api’s that are out there. So I went to the university library and checked out their copy of K&R C. I had that book checked out for six months straight before I could afford to purchase my own (speaking of which I ought to donate a copy to the library..). My first C program was a little utility to convert number bases. I started out by having the user input a number in decimal, and it would simply print out the binary representation. Frankly it was easy, but most of the exercise ws to teach myself pointers (and the requisit arithmatic), and pass by reference. I also started to dabble in TeX, the great typesetting markup language since I wanted to print my sourcecode out and have it look nice.

Coincidentally, after that the CS courses finally started using C and C++ as their main languages.

The only two other classes worth mentioning were the Parallel Processing class I took, which used MPI as its API, and Computer Graphics which used OpenGL. Parallel Processing was one of the funnest and neatest classes I took. We had to take specifications and transform them into parallelized C programs. We then had to test them on networks with variable amounts of nodes. There’s something alluring about having to stay in a lab until it closes to rig up a supercomputer.

Computer Graphics was also great, there were only five people total in that class, so there was this weird, fantastic, signal to noise ratio with the professor. My term project for that class was a Legend of Zelda clone. The class didn’t even cover raster graphics (bitmaps/pictures), just vector graphics (mathematically derived), so I had to research and design pretty much the whole thing myself. I wrote it from the ground up, incorporting BMP’s, and used a certain gaudy pink color to mark areas I wanted to be transparent by upscaling to the RGBA colorspace (So if R=255,G=0,B=255, then when I convert it to RGBA, I sample it as R=255,G=0,B=255,A=0 for complete transparency (a=255 for anything else)). I got carried away with the clone and added audio support for background music, and a bump sound when Link would collide with an obstacle.
cs440 zelda

At that I graduated with my Computer Science degree, and since then I’ve led and trained a bunch of testers (albeit not programmed) a video game for Microsoft Game Studios, and learned Common Lisp. I’ve also been slowly rewriting the Legend of Zelda clone using a much cleaner approach, and I’ve been working on an open source version of Conway’s Game of Life called blife. blife is almost finished, and the newer Zelda clone is working, but I haven’t released anything yet.

Categories: code Tags:

Programming Font

May 1st, 2006 Brad 1 comment

I’ve been flipping between two fonts (Courier New and Monaco) for about six months now. Monaco looks good, but there’s always been something about it that annoys me (aspect ratio, maybe). Courier New is fine, but I guess I would prefer something a bit smoother. So, I started looking at ‘programming fonts’ again, finding a lot of same sets as before (profont, proggy, crisp) and a couple new ones (Dina, Coding Font Tobi 1, Pixel Carnage). Dina is based on proggy and incorporates elements from some of these other fonts. So long story short, it’s become my default font. You can find these fonts on Google, or click the download link for Dina.

Dina

Download Dina

X11 Installation:

  1. Download the PCF files that bpcw001 compiled from here.
  2. Extract them to a directory that X11 and fontconfig see (e.g. /usr/share/fonts/dina)
  3. Run mkfontdir on that directory.
  4. Run xset fp rehash and fc-cache -f
Categories: Computing, code Tags: