Sunday, April 3rd, 2016

Remember the 6502 microprocessor?

It has been a very long time since I talked about one of my side projects, Hacker's Edge. Over the weekend I found sometime to put in some work into it. The ending result is that Hacker's Edge now runs 6502 hosts in-game!

While I'm not 100% complete yet with the integration, both the 6502 assembler and virtual machine are fully functioning within the game world. The end goal is to basically replace all my hardcoded Python routines with pure 6502 machine code, assembled using the in-game assembler. Why you ask? Because, this is a game about hacking, and my goal is to make the simulation as immersive as technically possible. This means that the 6502 virtual machine will take control of the game's mechanics as soon as possible. Here is a basic drill down of how a user log into to the game world will be like:

  1. Player successfully logs in, check to see if host is online.
  2. If host is offline, we initiate an empty memory address space for the VM, we attempt to load in KERNEL.SYS
  3. KERNEL.SYS will be entirely coded in 6502 code, and built specifically for Hacker's Edge.
  4. KERNEL.SYS will be responsible for loading the Shell program, which the player will finally interact with.

There will be extensions to the 6502, not the op-codes or the assembly language. The extensions will all be present as either hardware interrupts(BRK) or through memory mapped I/O channels. Currently the Hacker's Edge TTY device is mapped to a memory address, any data written to this address is send out to the player as ASCII text. Since we are working with a TTY here, and not a framebuffer, there's no memory mapped video or text buffers available. All output to the player is done via a TTY device, AKA a serial link. Input from the player is done in a similar fashion, where keys the player enters are placed into a keyboard buffer, which then the 6502 code can read and parse.

Other memory mapped I/O will include the ability to read from the virtual Hacker's Edge host's block device, and then there will networking I/O, which will allow the 6502 code to communicate with other in-game hosts. With all these devices combined, a complete working virtual operating environment based on real 6502 code can be created in Hacker's Edge!

I originally wrote my own custom assembler and Virtual machine called Simple CPU simulator, which was used on a previous incarnation of Hacker's Edge. However, coding for this would require a bit of a learning curve for anybody, excluding myself... With the 6502, there is a vast amount of online documentation available, and lots of people still alive that know how to use the 6502 assembly language to make programs. The 6502 is also considered one of the easier microprocessors to code assembly on as well, making the overall learning curve for new players low.

Hacker's Edge will hopefully be the epiphany of User-generated content, where players will be completely free to write any 6502 compatible assembly code and easily have a way to display those creations to the world. I know that people could basically just download and run a 6502 assembler and simulator/emulator on their local machine... However, the one big downside is that not many 6502 emulators are connected to a vast virtual Internet full of other 6502 hosts. What players will be-able to do in Hacker's Edge with a 6502 will just not be possible on a stand-alone configuration, and most definitely not as fun and entertaining. Here are some things I anticipate players to do with their virtual 6502 hosts:

  • Compile a custom KERNEL/Operating system
  • Build their own in-game hacking tools, to attack other in-game hosts
  • Create in-game games, which then other players can play
  • Ummm, perhaps create a multi-player game in the game itself... Like a MUD, or BBS doors
  • Emulate real-world TCP protocols in the game with 6502
  • Host in-game BBS systems, which can be used to say hide it from the real world Internet...
  • Develop viruses and worms to infect the virtual 6502 Internet of Things.
  • Attempt to build a Python interpreter in 6502 assembly(Would this even be feasible?) I've see LISP on the original Apple 2, and Python for the Apple 2GS model.

As you could imagine, the possibilities will be endless, as countless programs were made on the VIC-20, Atari 800, Apple ][, Commodore Pet, and the Nintendo Entertainment System. After some research, it seems that the 6502 is still being widely used in embedded projects in it's CMOS form. The 6502 core, once fully integrated in Hacker's Edge should prove to the most unique part of the Hacker's Edge community.

Email address

Comment #1: Posted 5 years, 6 months ago by Nerdbeard

Wow, I'm excited to learn about this. I had (have?) a project to simulate the circa 1985 BBS experience in a browser. I got a barebones version of it up and running (see bitbucket URL above) where I emulated the terminal and an ersatz phone system but I realized that what I really needed to do was emulate the actual computer and modem hardware and provide an accurate emulated telephone network for it to play with, so that users would run actual era-appropriate terminal and BBS software. Which puts me on a very convergent path with what you are doing! Cool stuff.

About Me

My Photo
Names Kevin, hugely into UNIX technologies, not just Linux. I've dabbled with the demons, played with the Sun, and now with the Penguins.

Kevin Veroneau Consulting Services
Do you require the services of a Django contractor? Do you need both a website and hosting services? Perhaps I can help.

This Month

If you like what you read, please consider donating to help with hosting costs, and to fund future books to review.

Python Powered | © 2012-2019 Kevin Veroneau