Creating a program and your own "Diskette"

Topics covering the 6502 emulator in Ranger Citadel: tutorials, specs, source code and share your work!

Moderator: Ranger Team Alpha

Post Reply
User avatar
Posts: 129
Joined: February 23rd, 2012, 9:21 am
Location: Ground Zero - inXile

Creating a program and your own "Diskette"

Post by Joby » September 3rd, 2014, 12:32 pm

If you're well versed on writing assembly programs for the 6502 (be sure to check out this thread on learning about the 6502), now you'll want to get some tools together to actually create your own Diskette binary file to run on the computer in Ranger Citadel. This is by no means the best way to do so... I'm just giving you some easy and free methods to get you going...

1) Write your 6502 assembly program. This is by far the easiest step. Use a text editor. Done! See how easy this is?!

Code: Select all

LDA #$01
STA $0200
LDA #$05
STA $0201
LDA #$08
STA $0202
2) Assemble your program into 6502 opcode. The following is a nice little assembler that allows you to use labels and relative addressing, though a little limited but good to start you off. You can also define the initial address location, which for the Wasteland 2 computer needs to be $7000.

Opcode generated:

Code: Select all

A9 01 8D 00 02 A9 05 8D
01 02 A9 08 8D 02 02
3) Compile the opcode into a binary file. You can do this by simply pasting the opcodes into a hex editor, like HxD, or you can create a script to compile the file for you. I like this second method as I can also add in other bits of data, like resources or secret messages explaining the file is part of an easter egg. ;) Whatever you prefer. Here is a Ruby script that can compile your opcode from the above into the needed binary file:


Code: Select all

opcode = <<EOS
A9 01 8D 00 02 A9 05 8D
01 02 A9 08 8D 02 02

program = opcode.split(/\s/).map!{|code| code.to_i(16) }"./Diskette",'wb'){|fh|
4) Replace the current "Diskette" file with your program. (I'm assuming you've gotten into Ranger Citadel and played the Snake game... the file won't get generated unless you do.)

On Windows, this file is located at C:\Users\(your username)\Documents\My Games\Wasteland2\Drive1

On OSX, this file is a little harder to access as it's in a hidden Library directory under your user folder. Poke around using your command shell to locate and open the folder with the Diskette file.

5) Load up your Wasteland 2 save and use the computer in the museum of Ranger Citadel. If all goes well, you'll see your program run. If not... well... welcome to the world of assembly programming in the 80s! :lol:

Next, to truly create your program you'll need to know how the computer is structured and what memory locations are mapped to what "hardware", soft-switches, etc. Continue on with this thread.
- Joby
inXile's ruthless Leader of Scripters

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest