LED Pac-man in Assembly

As part of training for new employees at BNG, we planned, soldered, and programmed (in assembly) games on a practice circuit boards with Renesas 16-bit H8/300H Tiny Series processors (specifically the H8/3687). 

Here's a video of what I made:

 

As you can see, it's a Pac-man themed dot-eating game.  I implemented 3 modes:

  • The first mode is an attract mode, like you'd see in arcades (when nobody's playing the game, it plays itself).  The dots slowly enter Pac-man's mouth and he eats them and gets larger and it flashes when he's at maximum size.  Also the digital display (the green number 8 LED) spins around in a circle.
  • The second mode is a timing game, where you have to push the green button when the dot is in Pac-man's mouth.  He eats it and grows larger.
  • The third mode is a button sequence game in which you just push the buttons in the correct order to feed pack man. (When we were soldering on the components, there was a lot of colored switches, so I put as many on as I could, and I had to think of something to use them for so they didn't go to waste.)

In addition to being able to change modes with the black button, the brown button changes difficulty, which is actually adjusting the speed of the timer that controls everything.

Here's a picture of the circuit diagram as planned in advance, though it is a little different than how it turned out in the end:

Circuit Diagram!The code was written entirely in assembly, which was a new challenge for me.  Compared to writing in C++, it felt like everything took years to do.  But it does make you realize how every line of code you write in C++ is really comprised of a multitude of these moves between registers and RAM (not to mention chip cache) and how all this complex logic breaks simplifies down into branch-if-zero's and other simple math equations. One thing I didn't have time to do was to understand argument passing in functions.  It looked complex and I had a lot to implement, so I just copied and pasted a few functions rather than mess with trying to use a feature I don't fully understand on a platform with no debugging to help me understand what I'm doing wrong.  But it would have been nice to learn if I had the time.

The (amateurishly written) source is available for download here, and is also after the break, with some unfortunately pink syntax highlighting.

Game Engine Project (It Begins!)

See that? That's ¥156,789 down the drain.

I mean, that's my new computer and my new desk! (Also, if you look closely, you can see my space-saving strategy: my futon bed rolled out beneath the desk. I now sleep under my desk every night.)

Why did I spend ~$1,900? Because I'm crazy.  Because I have a plan!

I want to start writing my own game engine. I've recently been reading Jason Gregory's Game Engine Architecture book, and it made me want to have the experience of writing all these systems myself.

While it may take a few years, I'm going to start doing just that, in my spare time.  I wanted to write for code to run on a game console, but the closest thing I have is this iPad, so I bought a new mac computer. (My previous one is about 5 years old, the first Intel mac.) I also spent $100 on an iOS developer license, so now we're up over $2,000.

If you want to follow along with my progress, bookmark this link. I'll try to post on here somewhat frequently about how the project is going, but it will be slow, especially while I'm still taking masters classes part time in Japanese, and working full time.  But maybe in summer the pace will pick up a bit.

Quick update

I'm lazy and haven't updated in a while, but things have changed quite a bit so I wanted to at least mention them.  First, since I'm not writing a lot on the blog itself, I decided to at least present the stuff I am writing on this site.  So if you would kindly look to the right column, where I've now included a twooter feed (Twatter? Something like that.) I write crap and post links to pictures, and you read it.  Below that I've embedded my news stories that I like. These sections should be updated with more frequency than the blog, so please enjoy them!

And oh yeah, the internship at Bandai Namco Games ended, all the interns that applied (including myself) got full time job offers, and I'm living in Yokohama and working in Tokyo full time now, and it's awesome, my friends here are awesome, blahdy blah blah.  You know, minor details. 

Later I will update the resume, LinkedIn, Facebook... oh god nevermind, there's too much to update,  I quit.

Here's some pictures of my new apartment before I put anything in it:

Empty New Yokohama Apt

And here's a picture of where I work now, taken back in the summer:

Games

Oh boy, another week is gone, this internship is going by too quickly!  Halfway done now.  Things continue to be more productive at work, I feel like I'm contributing something now as opposed to being the newbie that is slowing everyone else down while they have to explain everything to him.  Communication is slowly improving.  There are a few people at work I can converse with decently now.  There's some people I have a really hard time with because of either their voice/manner of speaking or or the grammar they use, or both.  Oh well I'll figure it out.  I'd like to write more about the internship work, but I don't want to cross any confidentiality boundaries.

On Friday, I got kind of soaked going home from work because I still have not bought an umbrella.  We wanted to go out, but since it was kind of nasty out, we stayed in and watched this Gambling Apocalypse Kaiji movie, based on this manga/anime series of the same name.  I don't think me and Yan understood much, but Karen had read the manga or watched the anime before, so she explained it all to us.  It was pretty interesting.  Basically this guy has some debt to a yakuza like organization, and he has to gamble his way out of it, or spend his life as an indentured servant.  The way the main actor played the role was kind of annoying though, he just basically cried and complained the whole time.

Saturday night we were invited to our work friend Ogura's house again for dinner and drinks, but this time we planned ahead and paid for him.  We played the same drinking game we played last friday, and it was just as loud as before, but at least it wasn't in the hotel.

Sunday I had plans to meet my coworker Daigo from VV, who's working in Tokyo at Square Enix now.

Game Center

It was a Namco arcade I guess, so we played some Tekken, we all lost badly to Daigo.  Maybe he's related to this Daigo.

Then I went home and played a ton of Final Fantasy 13.  Man this game won't end.  I hope I can finish it soon, I really need to start playing something else!

Odaiba

Today the interns and some coworkers took a trip to Odaiba, an artificial island that is part of Tokyo.

It is the home of Fuji Television:

Odaiba Photos

We ate in this fancy shopping mall, had some pretty delicious chinese food:

After that we headed for this museum, but we ran into this big cosplay gathering before we got there.  Apparently you were supposed to pay to take pictures, but nobody stopped us:

At the museum, they had an Asimo robot, it was pretty cool, a little creepy how human-like it is:

After that, we played some pool and had okonomiyaki, and it was awesome.  Of course our senpais paid for more than their share of everything, because they are too nice.  

The rest of this week has been going pretty smoothly... I was pretty exhausted the beginning of the week, from not sleeping much on Saturday, and from staying up on Tuesday to watch the Japan world cup game, which they lost in penalty kicks, unfortunately.

On Friday, we went with the same people went to Odaiba with for Thai food, and then some of us also went out to do Karaoke, but everywhere was full since it was Friday night.  So we went to an izakaya instead.  After that we partied in my room for a few hours, playing some drinking games.  We were so loud, I'm wondering how long it's going to be before they kick us out of this hotel.

Maybe we'll find out next week. But hopefully not.

Back in Japan

So I wasn't sure I'd ever get another chance to live in Japan, but here I am.

For those of you that are out of the loop, I recently accepted a summer internship for programming at Namco Bandai Games in Tokyo. I couldn't pass up the chance to get more Japanese practice and see what living in Tokyo, the most populous metropolis in the world, is like.

I got into Narita on Friday, and took a train down to Tokyo to check into my hotel in Shinagawa:

It's a pretty nice hotel, we're pretty spoiled I think, it's only 10 min from work too.  I met Ed from HR and another one of the interns, Karen, who already had moved in.

On Saturday, I got on the train and ended up in Asakusa:

Asakusa

Then the Japan World Cup game versus the Netherlands was that night, so I asked the front desk to find me a sports bar.  It was pretty packed, which was awesome, but Japan didn't score a goal unfortunately (though they won their next match in a big upset.

Sunday we went to Ginza and saw some weird stuff.

The streets were closed off and they put tables out for people to sit at.  This on had a litter of kittens and the mother.  I don't know why.

These people like to rock out.

Monday we started work.  The first day was mostly orientation and meeting people.  The second day they threw the interns a welcome party, and it was awesome.  Then afterward there was an after party at a local restaurant.  The lead programmer of Tekken 1, 2, 3, Tag and 4 treated us, he's awesome.

Work has been kind of tough, communication is really difficult.  I'm so bad at speaking and even worse at listening.  I really hope I can start learning faster in the next few weeks.

Friday, my team took me out for another welcome party, and it was pretty awesome too.  They are pretty interesting people, I like them a lot.  Saturday we went to Harajuku to see crazy people dance or dress up or something, but I guess we missed it.  It was still pretty packed:

Then I went to Akihabara to buy cables to hook up my ps3.  The hotel was only supposed to have crappy TVs, but they upgraded all the rooms to HDTVs on Monday for some reason.  I couldn't get Wii cables because apparently they are different for Japanese Wii's.

That night the interns and 3 of our American friends went out to Shibuya, drank at a couple all you can drink places, then I went with some of them to go to this place Club Atom.  I really never dance, but they were all going so I went, the place was packed on all 3 floors so no one could tell that my squirming in the crowd was any worse than anyone else's fortunately.  It was pretty fun, we stayed their until 3am, but it was after the last train, so we had to wait until 5AM to take the first one in the morning.

Sunday my friend from KIT Masa came, and we went to the Edo-Tokyo museum.  It was pretty neat, the special exhibit was insects though, it was for kids.  After that we went together with the other interns to a coworker Ogura's place, and he treated us to an awesome dinner, even Masa who he didn't know at all.

That's all for week 1, hopefully I can find the time to write again next week.