6502 ASM

So the current stuff I’ve been working on in graduate school has come to a stand still, mostly because I’m waiting for a bit of code which the post doc in our group is writing. I should be using this as an opportunity to become better acquainted with the theoretical side of the stuff I’m involved with… but instead I’m writing this post on a 6502 asm emulator I’ve been playing around with. It’s frustrating that I didn’t put time in where I know it suppose to be but I’ve been feeling quite burnt out over the past week and I feel like this is a good avenue for some lighthearted learning.

 

I’ve been playing around with the idea of combining my love the low-level programming with my love for game development. More specifically, I want to make a game in which it is possible to program little bots in 6502 assembly.

How? well, good question. I recently found this C-library, (referred to as lib6502) by Ian Piumarta, which is able to emulate the 6502 microprocessor. So this allows me to run assembly instructions as they would be run on the 6502 microprocessor. Next, by compiling my C-code I will be able to execute the code and display the results in a web browser using PHP’s exec() function. And… that’s all I’ve got so far. Interesting idea but I’m not sure how much work it will be to code or how fun it will be to play.

 

One big question still is what will the game play be like? OK, so you are able to emulate the 6502 and open a dialogue between that emulator and a website. Still, by requiring PHP, a server side tech, that means that a POST require much be sent every time the 6502 emulator is asked to run code, no? And any sort of AJAX type approach is quite outdated at this point.

 

OK, so is it possible to setup a NodeJS server to execute the 6502 code and instead open dialogue with the browser through websockets? This seems possible and is probably a better way to go.

 

So, the user sends ASM instructions to a NodeJS server which in turn executes and instructions in a 6502 emulator and sends back a memory map that will be used to tell the bots what to do? Well, the problem now is that the bots need to know the memory mapping after each ASM instruction so that they can set and change state. Sending this type of data back and forth over a websocket doesn’t seem like a good idea.

 

Alright, are there any 6502 emulators written in Javascript? A Javascript 6502 emulator would allow for fast instruction execution while allowing the bots to check flags and memory locations. The only slight problem being that if the game is multiplayer the player might be able to modify the memory layout for the bots and essentially hack. So some sort of server side validation is required here.

 

There is a Javascript 6502 emulator available. Perhaps I can try and modify this for my needs. The first step will be to make an attempt at getting it functional on my site and then establish some sort of NodeJS connectivity.

 

More on this hopefully soon!

Leave a Reply

Your email address will not be published.