Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: I'm building a game for the Nintendo GameBoy (bonsaiden.github.io)
260 points by BonsaiDen on Aug 14, 2014 | hide | past | favorite | 102 comments



> Tuff including all graphics, characters, ideas, sounds and maps are Copyright (c) 2014 Ivo Wetzel. All rights reserved.

(emphasis mine) IANAL, but my understanding is that at least in the US, it is the expression of the idea (the software and code, the graphics, and the other things mentioned on that line) that are subject to copyright, not the idea. See https://en.wikipedia.org/wiki/Idea-expression_divide.


IANAL, and yes, you can not copyright game mechanics or ideas. This is why so many clones of every game exists. Because no one owns the rights to "a tower defense".


IANAL, but The Tetris Company seems to have had legal successes in the area of copyrighting mechanics.


There is only one successful Tetris clone lawsuit.[1] Most Tetris clones are removed just because they are fairly aggressive with their claims (not necessarily because their claims are valid).

The successful suit was due to the playing field having the exact same dimensions as well as very similar visual expressions as regular Tetris outside of the just the game mechanic.

[1] http://www.wired.co.uk/news/archive/2012-06/20/tetris-clone-...


I have moved to the negative zone after trying the B button. :)

http://i.imgur.com/pkZhTCJ.jpg

The screens are positioned correctly next to each other.

----

Are you writing this in assembly?!


Yes, it's all written in z80 assembly, although the GameBoy CPU really uses a mix of i8080 and z80 instructions, the mnemonics are all z80. I've also written my own assembler just recently, to have more control over the output and more easily generate debugging information: https://github.com/BonsaiDen/gbasm


"my own assembler" - now you're just showing off. :)


Nah' I would only be showing off if I were to put it onto a real cartrdige and GameBoy, wouldn't I? ;)

- https://dl.dropboxusercontent.com/u/2332843/tuff.cartridge.j... - https://www.youtube.com/watch?v=yXNEeld8Lq8


If folks want to try it on a real Gameboy without all the wires, the Drag'n'Derp works pretty well. It's a Gameboy cart with a USB port for easy writing: http://derpcart.com/


I was looking at these option initially too, but ended up going for the challenge since, both I read some not-so-good reviews and shipping the thing to germany would probably ended up being at least as expensive as buying the soldering equipment :) Building one of those custom GamePaks takes about ~4 hours once you have all the materials prepared (you really need very, very thin wires!) and putting it together for the first time is one of those finger crossing moments which you'll remember for a really long time :)


I took a cart, removed the game IC, and soldered in a ZIF socket for eproms. And I'm a klutz so it's easy enough.

http://www.devrs.com/gb/files/faq.html


Am I right in thinking that GameBoy carts are now a precious resource? We'll run out one day?


Pretty sure you could make your own with a 3d printer and one of those kitchen PCB-etching setups you see people using. There's no magic in there AFAIK.


The Everdrive GB takes micro SD cards, so it has more space:

http://krikzz.com/index.php?route=product/product&product_id...


It sounds very advanced but an assembler for a rather simple architecture like z80 is much easier to write like most (other) compilers for example.


Used to be a standard 2nd or 3rd year assignment in a comp. sci. curriculum. Not sure if it is anymore.


When I was tinkering with gbdev 15 years ago, we had lcc targetting z80. It seems far less painful to write in C than asm.


C is just an advanced macro-assembler anyway.

Would seem painful enough as soon as speed or size became limited. C then was not as optimized as today. Old games used to be written in assembler, now the eeproms are bigger, the compilers are faster and portable.


Nice! Also nice that these days Assemblers get written in JavaScript. ;)


Well, they used to be written in Basic as well, so given that JavaScript has apparently taken Basic's role....


although the GameBoy CPU really uses a mix of i8080 and z80 instructions, the mnemonics are all z80.

I'd love to hear more about this if anybody knows and feels like telling about it...


It's a Z80-like core with some modifications; not all the Z80 instructions and registers are present and some instructions are completely different. Most instructions are the same as the 8080, but all 3 CPUs are not completely binary-compatible. It's neither truly an 8080 with added instructions, nor a Z80 with omitted ones.

For comparison: http://pastraiser.com/cpu/gameboy/gameboy_opcodes.html http://pastraiser.com/cpu/i8080/i8080_opcodes.html


Holy carp - he is writing it in assembly.

https://github.com/BonsaiDen/Tuff.gb/blob/master/src/core/co...

Nice.


In what language do you imagine GameBoy games were written?



C was a bloated language for targeting the Gameboy[0].

Only slowly after the 32bit became mainstream, did professional game developers started adopting C.

In the 8 and 16 bit days, C (and Pascal dialects) were viewed as C# and Java are nowadays for game development.

[0]Using my 80's developer hat.


Actually a lot of games are written in c# these days since that's what most unity developers use (and the other options are even less "lean").

I'd say c or c++ is only really standard in the AAA world, most casual/mobile/indie devs use higher level languages & engines (c#/unity, haxe, as3/flash, lua/corona, etc.)


I agree, that is why I smile every time I see the discussing of language X being too slow for game development, because of GC, bounds checking or whatever one comes up with.

As I am old enough to have lived through a few programming language generations accused of the same performance issues for game development, C included.


To be fair, currently most of those tools involve low level linking to C code for performance-critical computations, no?


Actually C++, as most studios have moved away from pure C around the PS2 timeframe.

But the reason it is not always performance. Sometimes it is reusing already existing, battlefield tested proven code.

However, I can rephrase your question by replacing C with inline Assembly and we are back to the discussions I was having around 25 years ago.


Werent most Amiga and Atari ST games written in C though?


Surely not.

You need to do a lot of low level programming to target the custom sound and graphics chips those machines had available.

Not to mention that with 512 KB, every byte counted.

I cannot speak much for the Atari ST, as I was on the Amiga side of the bench.

The operating system was originally coded in Assembly and BCPL, with later versions having some C code as well(mostly K&R still).

Assembly and special game programming languages like AMOS, were the main programming languages for game developers on Amiga.

C was just another business programming language like C#, Java, Ruby and many others are today.

Mostly used for standard desktop software, or for doing the UNIX university projects at home.

Young developers take C's ubiquity for granted nowadays, but there was a time, when it was just yet another programming language.


> it was just yet another programming language.

It was considered a high-level programming language.


I have a few 80's books that refer to C as middle-level programming language.

High-level was already reserved for the likes of Lisp and Smalltalk.


That's a "recent" development though :) The original title back in the day were all written in assembly, you really have to squeeze out every single byte and cycle for something like Pokemon or Kirby.


Pokemon is turn based with no AI, why would it need cycles?


Because softwares are not the only one to use cycles.

For example, in the GB, some memory space is only adressable during a few cycles, and so you have to optimize your code when you wish to update the video ram. If you miss the window, too bad.


ASM isn't all that hard, just a little tedious once you understand the CPU architecture a little and the mnemonics. You can think of it like a low-level basic. ;)


Cool, came here to report the exact same bug. Twitching, and doing the down smash eventually caused me to warp through the floor and initiate an endless fall into white nothingness. [Edit] After exploring some more, the extents of completeness are more obvious. I like the design style, and the art is very evocative. In terms of gameplay, there's a lot of blind jumps that basically end in death (spike and lava rooms to lower right). While I like the quick save mechanic with the light pillars, telegraphing those rapidly changing hazards might be less frustrating. Also, is it currently possible to get to the stuff up to the left?


It's probably not possible at this time. The whole map is just a giant demo level which evolved (and still is) along with the gameplay and other features (like spikes and lava).

I've got some rough sketches for the final world as well as the powerup placement, since there are no text boxes in the game, everything will be explained through level design or other hints like enemies or neutral creatures performing certain maneuvers for the player to imitate.


I got there too.


The attention to detail is awesome - I played for a little bit, then started reading, and when I scrolled up the little bunny character was sleeping!


If anyone wants to go back more, AtariAge has good tutorials on 2600 game programming. Nothing like counting clock cycles to make sure the CRT beam is far enough over before changing the background buffer :)

http://atariage.com/2600/programming/


Atari Archives also has quite a good selection of old programming books for the later models.

http://www.atariarchives.org/


Reminds me a lot of Knytt and Knytt Stories created by Nicklas "Nifflas" Nygren [1]

[1] - http://nifflas.ni2.se/


You got me! I enjoyed Knytt so much, and it was the game that first inspired me to make the first version of Tuff way back in 2010 :) https://github.com/BonsaiDen/Tuff/commits/master


Yeah, I wanted to mention that too. The save mechanic is very similar.


So why JavaScript for the assembler? Was it familiarity with the language, did the dynamic nature of the language help out...?


I'm a full stack Web Developer at daytime and I'd argue that I probably do speak JavaScript more fluently than I do English. So for me it really was a no brainer. The custom conversion tools needed for the graphics / map / sounds are also written in JS, so it's a bonus to have good interop with those too.

In addition to that, getting the compiler up to speed (takes < 90ms on my old core i5) was a nice exercise in getting more familiar with v8's performance analysis tools :)


> probably do speak JavaScript more fluently than I do English

Ah, a feeling many of us know too well.


Some options include: He is familiar with it, the Z80 is so simple it doesn't really matter, and someone else already wrote one in JavaScript. Lastly does it matter?


All those are valid, I was just wondering if the dynamic nature of JavaScript, adding properties to objects at will etc. made writing an assembler easier.


Rad. I'm writing a Z80 emulator in Haskell. I'll be sure to test Tuff on it once I'm to the point where graphics are being drawn.


You'll probably need to do a little work to make it work. The Gameboy used a Sharp LR35902, which is kinda 8080-ish and kinda z80-ish and has some of it's own stuff as well.


Yeah, I meant I was writing a Gameboy emulator.


Either way, it's a really cool project! A working processor emulator, even a slow one, kind of makes you realize how deceptively simple lots of old CPUs are.


More like the original CPU/microprocessor. The man behind the Z80 was also the main contributor to Intel's 8080 as well as the 4004, which is arguably the foundation of a general purpose computer (calculator + memory) on an integrated circuit (microprocessor). I wouldn't say so much simple as it is ingenious.


If you like this post you might like the titles in development for the Atari 2600+ https://atariage.com/development_list.html


Very cool. Not sure this was meant to happen, but at one point I did a double jump over a wall and then just started to continuously fall and it never stopped.


It's a 16x16 screen world which wraps around, if you move to the left or right you should eventually land on a non-empty screen. The "world" is anything but finished, to be honest, it's more of a debug / feature test world than anything else at the moment :)

Here's a picture of the whole world for reference: https://dl.dropboxusercontent.com/u/2332843/tuff.map.png


Could you go into a little more detail on how the process is for adding sounds and sprites to the game?

I am very interested in this type of work and have been hacking at trying to build a game for the SNES. All I've been able to do so far is to collect all relevant documentation for developing it: https://github.com/bttf/snes_dev


Sure!

I'll start with the graphics part, since that's the easier part of the two.

Since the original GameBoy has only 4 shades of gray, all "bitmaps" are 2 bits per pixel so you can squeeze a total of 4 pixels into 1 byte, the graphics are converted from PNG files via some JavaScript routines which can be found in the convert.js file in the repository.

The GameBoy uses 8x8 pixel hardware tiles on a scrollable "background" and supports up to 40 sprites which can be either 8x8 or 8x16 pixels in size.

There are 2 tile buffers in VRAM which partly overlap and only the lower one can be used for sprites, which gives you 128, 8x8 tiles for use with sprites and 256 for use with backgrounds.

Sprites can be mirrored, so this somewhat reduces the amount of graphics needed for the player character.

In order to reduce the map data, each room uses 80 16x16 blocks which are served from a meta table in memory, where each index maps to 4 8x8 tile definitions of the block. When drawing the screen the code resolves the individual 8x8 tiles and sets their value into the current VRAM buffer for the screen (there are two, which are swapped, to minimize draw artefacts).

Since the meta table is limited to 256 16x16 blocks too (due to the fact that the map format only uses 1 byte per block tile) there is some additional pre-computation magic going on when creating the map data. Basically, the block tiles are split into 4 x 8 rows, each screen then maps onto 4 of these "rows". By then packing often uses block tiles together, you can have more details for certain rooms since they don't need to use all of the different rows available and can basically swap some of them out.

Also, all graphics and map data are additionally compressed with a custom LT Type compression routing and are decompressed on the fly. Except for player graphics, which are stored into a RAM buffer at start in order to avoid graphic glichtes when switching out the sprite tile reference indexes and the graphics at the same time.

Overall, the timing is really important since you don't have too much time during the VBlank period (yes, it emulates a vblank!)

Now as for the sound, right now I'm really just setting the sound channel register values pretty much "Per hand", meaning, that I pick some decent values (tested in some GBA sound test ROM for gameboy sound channels I found somehwere - yes the GBA still has the original GameBoys 4 channels, since it's backwards compatible).

The sound data is stored in some kind of JSON format for easier editing, all the bit field stuff is than generated at compile time and baked into the ROM.

I've also gotten a prototype of a music engine running (not yet in the repository) where you'd play pre-defined sound "patterns" on virtual channels and "mix" them down. The sound / music stuff really is a whole story of its own, especially since there are nearly no references to find, except for some old, undocumented ASM sources of some Rare Ware GameBoy ports of Banjo / Jet Force Gemini which apparently got uploaded by one of the Sound Engineers at Rare.


Quick question about the music for the game ; I see you have already answered a few questions along those lines.

When the bunny dies , there is a sound for its micro-explosion. I remember "Dangerous Dave" died with the same sound :) Are a lot of these interchangeably used ? Are these just system sounds ? How do these work ?


> On the web GameBoy Online is probably the best of the available JavaScript based emulators out there.

That's true, but I'm really trying to shake it off! And looking for contributors, should you be interested :)

[1] https://github.com/arcanis/virt.js


Wow fantastic. I can't wait to see it complete. Great art style and control feel. Lots of nice subtle details.


Awesome project! So, are there any hard-way books or something, to begin developing for GB platforms? ASM and C have already learned by me, but I'm really frightened about code environment like IDE, testing and run on real hw? Are this question already answered or I'm really can't google?


There are quite a few resources you can find after searching for a bit e.g http://problemkaputt.de/pandocs.htm or http://students.washington.edu/fidelp/galp/megaguides/GameBo... (the latter one being the original manual for licensed developers)



Hey Ivo! Remember you from the Nintendocast days. Great to see you're still doing awesome stuff! Rock on!


The feel of this game reminds me a lot of Montezuma's Revenge, a classic in my book. Very cool, and nicely done!

I really like your project page as well, very concise, extremely informative, and covers exactly the things that someone wanting to make their own would need. Bookmarked!


I would love to write GB/GBC/GBA games using something like Ruby (or JavaScript!). Is this possible? Have any higher-level languages been used to write games for these platforms?


You would have to first port the ruby interpreter to the Zilog Z80 which could be a challenge because it is only an 8bit CPU!

The GBA actually has a 32 bit ARM CPU, although a very slow one (16 Mhz) so perhaps it would be possible to build a very minimal Ruby VM for that. I wonder if it would be possible to optimize by building a JIT compiler and JITing on an emulator before installing on the cartridge?


libruby, if that is the core of the interpreter, weighs 2MB. That's not gonna fly, even with heavy size optimization it would be unbearably slow, even on just a subset.


mruby can be compiled to embedded bytecode in a C file [1]. It might be possible to do something with that on the GBA, but the original GB is out of the question -- even the options for C are limited.

[1]: https://github.com/mruby/mruby


I'd "settle" for GBA ;) GB would be fun because it's so limiting but I am not interested in writing assembly (actually, could be a fun way to learn it...)


You can't :)

The people who might be able to and the people who would want to do so are mutually exclusive groups.


Which part of the process are you interested in- -executing in z80? -using the sounds? -using the graphics? -etc?

if the latter three, why not write in those languages and use an API to interface to the drivers for those peripherals?


Nice. You can find RGBASM at OtakuNoZoku.com and the Gameboy Cribsheet too. Along with a bunch of other tools and code. I can send you complete game source if you want to study it.


i fell below the water and began infinite falling

-----

really cool and impressive that you developed an published a game on such a platform, that's still easily playable via a browser


So did I.


Seriously I am amazed by your project! I wish I had the time to do something like that! Great job and I can't wait to play the final version.



Thanks for the shout-out! :)

You can also grab the RGASM project from the OtakuNoZoku website. I think Carsten (Surfsmurf) may have revived it on his github. I think I also pushed my source trees to github too. There is a GBC emulator that is both a COM component, and works inside of Visual Studio (at least, VS from around year 2000). Bunch of docs too kicking around. I have copies of most of them still.

I wrote programmer docs, assembler (before switching to extending RGBASM), linker, patcher, emulators, games, visual studio plugins, debugger, cartridge downloader, serial port driver, bunch of libraries, etc. Ah... the good old days.


Cool project!

I got stuck really early on, oops: http://i.imgur.com/pqAblgU.png


You can do a wall jump or a double jump, at the moment all powerups are enable from the start since I'm missing out on the animation for collecting them an all other sorts of things. I tend to deviate from the gameplay aspects of programming and spend a lot of time doing optimizations and tooling, just recently I wrote my own assembler to cook the whole thing into the final ROM image https://github.com/BonsaiDen/gbasm


Open up spotify on your mac and start playing a song. Visit http://bonsaiden.github.io/Tuff.gb is the audio from spotify garbled?

I submit this bug: https://code.google.com/p/chromium/issues/detail?id=403907&t...


It's not only Spotify. I've had the same issue with Adium notification sounds while the game was running in Safari on OS X 10.9.

Funny, the sound became all 8-bit like, so it fitted the game quite nicely. :)


It's known issue, I've to the exact same issue here on Linux, seems to be related with their Web Audio implementation.


If you can add anything to the bug listed above that would be super helpful for the chrome team :)


Here on Linux with Pulseaudio, WebAudio mutes other channels. Pretty nice actually.


I had the same problem though I was playing music with Radiant Player. However, I switched my sound output from HDMI (a Vizio TV) to my MBP speakers and it went away.

I'll also submit the above as a comment on the bug report.


Works fine for me.


Thats really cool. Don't you find developing for it frustratingly slow though by today's coding standards?


I really did get stuck.

http://imgur.com/syZX03k


I ended up falling endlessly through a blank void :-\


move left.


Very cool. I hope to have spare time again in my life, at some point!


How does this site manage to lower the volume of iTunes?


Pretty nice, I was even able to go out of bounds :)


Reminds me of A Boy and his Blob. Good work.


Can I play this game in full screen?


The sound I get when I open this page is pretty sharp, noisy and unpleasant. I prefer it when websites have that turned off by default (unless it's obvious that the web-page involves a video that I'm supposed to be watching or something like that).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: