NES ASM Tips – Box Collision

One of the most important parts in any game, code wise, is to have some form of collision detection between sprites. This is Assembly Code snippet ( using NESASM3) should help you out when it comes to box to box collision and uses little space, so should be quite fast. We’re only using the A register AND 9 bits of RAM for simplicity.

Here we go, first with the variables being declared in Zero Page:

Next Up, The Function Itself, with an explanation of what we’re doing:

So, to use this effectively, simply set your sprite bits up appropriately, then Jump to the function (well, subroutine) by calling:

If there is a collision between the two points, spriteCollision Result should contain a value of 1, otherwise it’s just a 0

Hopefully, this has helped someone out there get past one of the stumbling blocks with NES ASM development.

Happy coding everyone!

Why code NES games in ASM in 2018?

So, there’s a few reasons as to why I’ve chosen this for 2018:

The Challenge
There’s something about learning a new language, one that’s so different from anything I’ve learnt before, delving deep into the NES registers seems like a fun thing to try out also.

It’s The First “True” Console I owned
Yeah, like most kids I wanted a NES for bloody ages before I could place my tiny mitts on a controller, heck , I even remember the guy at the store attempting to sell me a megadrive instead back in the day, but my love for Megaman 2 from play sessions at my cousins house meant that simply wasn’t an option for 8 year old Ryan.

Even then, I wanted to make games for the console and would happily spend hours drawing out sprites on graph paper, even cutting out and drawing up fake cartridge boxes for games that I wanted to make happen. A racing game in the style of F1 race for the gameboy ( Turbo Racing on the NES was a regular favourite also back then ) and a platformer involving some fairly Mario-inspired little characters.

Yeah! There’s a big chunk of nostalgia going on here, childhood hopes and dreams which never really left me. This year is certainly the year to accomplish them.

Now If you’ll excuse me, it’s back to the code for me 🙂

Wish me luck!

2018 is here and so is the year of NES Development in Assembly!

So, happy new year, I haven’t updated the blog in ages, my bad. A few things have happened since the last post. Christmas, Halloween and my beginnings of learning NES Development and the lowest level of language I’ll ever attempt to learn, ASSEMBLY (ASM)!

I attempted some ASM on the Atari 2600 a year ago to little success but decided, after a chat to the guys at Mega Cat Studios, to give it the college try.

The first 2 projects started and finished without really finishing, but that’s to be expected really, it’s a new language to me and I’m still learning a lot about it. Needless to say, it’s a lot more involved than C, as you’re dealing with the raw bytes and nothing else, which feels stark compared to anything else but I’m ableto understand a lot more of it now and feel that game #3, a port of the amazing Flapadiddle by Jayenkai, will be a worthy first completed game.

The first 2 games, taught me a lot about ASM and gave me some guidance as to how to organise my code as well as how backgrounds and palettes work. So, I put together the beginnings of a port of Invasion VS from my days of OUYA coding which got a fair way, then btibitjam came around so I decided to take what I’d learnt and put it into a gamejam.

invasion vs - nes eidtion - homebrew attempt #1super floofy sheepie - homebrew test #2 To be blunt, it didn’t work out, I ran out of time and spent most of August feeling pretty downbeat over everything, eventually picking myself up again mid October to retry again, but with the task of creating a procedurally generated game.

This meant creating a seeded linear randomiser in asm, that produces reasonably random, set values. After a while of researching I came across a simple one for 8-bit values which simply multiplied by 13 and added 1.

After protottypinmg some levels in PHP and GDLib I felt ready to tackle this in ASM and so far we have the following.

It’s actually playing pretty well and works in both emulator and on my PAL NES, there’s lots of features I want to add to this game and so far, it only has 5kb of game code out of an available 32kb, so ,there’s lots of scope available.

Each level is procedurally generated with a seed based on the internal framecounter and, whilst the platform placement still leaves much to be desired (and coded in properly) It feels like the game I’ve loved playing for a lot of last year.

You should check it out by the way, it’s both FREE and awesome [Download Flapadiddle]

More updates on the way.