9 ms·
Show HN: I'm building a game for the Nintendo GameBoy
- Gracana 12y agoCool project! I got stuck really early on, oops: http://i.imgur.com/pqAblgU.png http://i.imgur.com/pqAblgU.png
- BonsaiDen 12y agoYou 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 https://github.com/BonsaiDen/gbasm
- deleted 12y ago[deleted]
- Sealy 12y agoThats really cool. Don't you find developing for it frustratingly slow though by today's coding standards?
- prezjordan 12y agoI 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?
- jiggy2011 12y agoYou 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?
- vegedor 12y agolibruby, 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.
- Sir_Cmpwn 12y agoYou can't :) The people who might be able to and the people who would want to do so are mutually exclusive groups.
- chillingeffect 12y agoWhich 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?
- djur 12y agomruby 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 https://github.com/mruby/mruby
- prezjordan 12y agoI'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...)
- pavel_lishin 12y agoThe 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!
- tvirelli 12y agoVery 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.
- BonsaiDen 12y agoIt'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 https://dl.dropboxusercontent.com/u/2332843/tuff.map.png
- readerrrr 12y agoI have moved to the negative zone after trying the B button. :) http://i.imgur.com/pkZhTCJ.jpg http://i.imgur.com/pkZhTCJ.jpg The screens are positioned correctly next to each other. ---- Are you writing this in assembly?!
- BonsaiDen 12y agoYes, 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 https://github.com/BonsaiDen/gbasm
- glhaynes 12y agoalthough 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...
- userbinator 12y agoIt'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/gameboy/gameboy_opcodes.html http://pastraiser.com/cpu/i8080/i8080_opcodes.html http://pastraiser.com/cpu/i8080/i8080_opcodes.html
- harwoodr 12y ago"my own assembler" - now you're just showing off. :)
- BonsaiDen 12y agoNah' 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.jpg https://dl.dropboxusercontent.com/u/2332843/tuff.cartridge.j... - https://www.youtube.com/watch?v=yXNEeld8Lq8 https://www.youtube.com/watch?v=yXNEeld8Lq8
- bttf 12y agoCould 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 https://github.com/bttf/snes_dev
- BonsaiDen 12y agoSure! 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.
- ralphc 12y agoSo why JavaScript for the assembler? Was it familiarity with the language, did the dynamic nature of the language help out...?
- icefox 12y agoSome 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?
- ralphc 12y agoAll 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.
- BonsaiDen 12y agoI'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 :)
- grrowl 12y ago> probably do speak JavaScript more fluently than I do English Ah, a feeling many of us know too well.
- wslh 12y agoIf you like this post you might like the titles in development for the Atari 2600+ https://atariage.com/development_list.html https://atariage.com/development_list.html
- hayksaakian 12y agoi 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
- belzebub 12y agoSo did I.
- jastanton 12y agoOpen up spotify on your mac and start playing a song. Visit http://bonsaiden.github.io/Tuff.gb 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&thanks=403907&ts=1408045980 https://code.google.com/p/chromium/issues/detail?id=403907&t...
- avree 12y agoWorks fine for me.
- BonsaiDen 12y agoIt's known issue, I've to the exact same issue here on Linux, seems to be related with their Web Audio implementation.
- scrollaway 12y agoHere on Linux with Pulseaudio, WebAudio mutes other channels. Pretty nice actually.
- jastanton 12y agoIf you can add anything to the bug listed above that would be super helpful for the chrome team :)
- andrewjkerr 12y agoI 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.
- HDevo 12y agoIt'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. :)
- matthewwiese 12y agoReminds me a lot of Knytt and Knytt Stories created by Nicklas "Nifflas" Nygren [1] [1] - http://nifflas.ni2.se/ http://nifflas.ni2.se/
- readerrrr 12y agoYeah, I wanted to mention that too. The save mechanic is very similar.
- BonsaiDen 12y agoYou 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 https://github.com/BonsaiDen/Tuff/commits/master
- 0xA115A 12y agoAwesome 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?
- DanBC 12y agohttp://devrs.com/gb/ http://devrs.com/gb/
- BonsaiDen 12y agoThere are quite a few resources you can find after searching for a bit e.g http://problemkaputt.de/pandocs.htm http://problemkaputt.de/pandocs.htm or http://students.washington.edu/fidelp/galp/megaguides/GameBoyProgrammingManual.pdf http://students.washington.edu/fidelp/galp/megaguides/GameBo... (the latter one being the original manual for licensed developers)
- Globz 12y agoSeriously 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.
- BonsaiDen 12y agoIt's a bit hard to find, but it's all there :) - http://gameboy.mongenel.com/dmg/gbspec.txt http://gameboy.mongenel.com/dmg/gbspec.txt (html version http://problemkaputt.de/pandocs.htm#soundcontroller http://problemkaputt.de/pandocs.htm#soundcontroller ) - http://www.otakunozoku.com/nintendo-gameboy-cribsheet/ http://www.otakunozoku.com/nintendo-gameboy-cribsheet/ - http://realboyemulator.files.wordpress.com/2013/01/gbcpuman.pdf http://realboyemulator.files.wordpress.com/2013/01/gbcpuman.... - http://students.washington.edu/fidelp/galp/megaguides/GameBoyProgrammingManual.pdf http://students.washington.edu/fidelp/galp/megaguides/GameBo... (The original Manual) There are more, but I can't seem to find the links right now :O
- justinlloyd 12y agoThanks 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.
- VikingCoder 12y agoVery cool. I hope to have spare time again in my life, at some point!
- thisjepisje 12y agoHow does this site manage to lower the volume of iTunes?
- cadr 12y agoIf 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/ http://atariage.com/2600/programming/
- pjmlp 12y agoAtari Archives also has quite a good selection of old programming books for the later models. http://www.atariarchives.org/ http://www.atariarchives.org/
- Lambdanaut 12y agoRad. 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.
- bane 12y agoYou'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.
- Lambdanaut 12y agoYeah, I meant I was writing a Gameboy emulator.
- bane 12y agoEither 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.
- boyaka 12y agoMore 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.
- bane 12y agoWow fantastic. I can't wait to see it complete. Great art style and control feel. Lots of nice subtle details.
- dahart 12y agoThe 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!
- c0deporn 12y agoReminds me of A Boy and his Blob. Good work.
- graup 12y agoHey Ivo! Remember you from the Nintendocast days. Great to see you're still doing awesome stuff! Rock on!
- deathanatos 12y ago> 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 https://en.wikipedia.org/wiki/Idea-expression_divide.
- Mandelbug 12y agoIANAL, 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".
- zorked 12y agoIANAL, but The Tetris Company seems to have had legal successes in the area of copyrighting mechanics.
- yincrash 12y agoThere 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-ruling http://www.wired.co.uk/news/archive/2012-06/20/tetris-clone-...
- thanesh 12y agoCan I play this game in full screen?
- arcatek 12y ago> 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 https://github.com/arcanis/virt.js
- tutts 12y agoI really did get stuck. http://imgur.com/syZX03k http://imgur.com/syZX03k
- albinoloverats 12y agoI ended up falling endlessly through a blank void :-\
- sherjilozair 12y agomove left.
- justinlloyd 12y agoNice. 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.
- gnuvince 12y agoPretty nice, I was even able to go out of bounds :)
- Dewie 12y agoThe 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).
- mind_heist 12y agoQuick 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 ?