Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lode_runner_reveng

Reverse engineering of Lode Runner for the Apple II series.

main.pdf is the literate programming document for this project. This means the explanatory text is interspersed with source code. The source code can be extracted from the document and compiled.

The goal is to provide all the source code and data necessary to reproduce a disk image byte-for-byte identical to the Internet Archive's Lode_Runner_1983_Broderbund_cr_Reset_Vector.do.

The assembly code is assembled using dasm.

This document doesn't explain every last detail. It's assumed that the reader can find enough details on the 6502 processor and the Apple II series of computers to fill in the gaps.

Useful 6502 and Apple II resources:

Compilation

This step should not be necessary, as the release provides the assembly files, the 6502 binary, and the PDF.

This project no longer depends on the (deprecated) noweb tools. Instead it ships a small, self-contained weaver/tangler, weave.py, and a vendored copy of the noweb LaTeX macros, noweb.sty. This approach mirrors the Ali Baba reverse-engineering project.

Prerequisites

  • dasm, the 6502 assembler.
  • A distribution of TeX Live with the booktabs and tikz packages.
  • Python 3.9 or later (standard library only — no third-party packages).

No noweb installation is required, and any current TeX Live works (the bundled noweb.sty replaces the noweb LaTeX package, which recent TeX Live releases no longer provide).

Generating the binary and disk image

$ python build.py            # add --dasm PATH if dasm is not on your PATH

build.py tangles main.nw into assembly (expanding the <<*>> root chunk), reorders the code so that ORG locations are increasing — dasm does not handle code blocks whose origins jump around — assembles main.asm into main.bin, and then reconstructs the original disk image as lode_runner.do. Add --verify to compare main.bin against golden_source.bin and lode_runner.do against the archive.org original (place Lode_Runner_1983_Broderbund_cr_Reset_Vector.do in the project root; it is not committed to the repository).

How the disk image is reconstructed

The approach mirrors the Ali Baba reverse-engineering project: build.py starts from a zero-filled 143,360-byte DOS-ordered (.do) image and fills in each sector from its proper source:

  • The game itself (tracks $12–$1A) is stored on the disk as an ordinary DOS 3.3 binary file — the catalog on track $11 lists it as LODE RUNNER, BSAVEd with address A$800 and length L$8100. build.py lays out the file exactly the way DOS 3.3's BSAVE did: a 4-byte address/length header followed by the load image (memory $3F00–$BFFF, which is main.bin's $0000–$1FFF followed by its $5F00–$BFFF), written across data sectors in DOS's descending-sector allocation order, with the two track/sector list sectors (track $12 sector $F and track $19 sector $4) generated in standard DOS 3.3 format. Even the slack bytes in the file's final sector (stale DOS write-buffer contents on the original disk) are reproduced.
  • Everything else comes from the disk/track_XX.asm data files: the boot loader on tracks 0–2, the 150 levels stored raw on tracks 3–$C (16 levels per track, one level per sector), and the DOS 3.3 catalog on track $11.

The result is byte-for-byte identical to the Internet Archive's Lode_Runner_1983_Broderbund_cr_Reset_Vector.do.

Generating the PDF

$ python weave.py main.nw    # writes main.tex
$ pdflatex main.tex
$ pdflatex main.tex

Yes, you have to run pdflatex twice. The first run generates auxilliary information about indexes that the second run can use to properly cross-reference things. A build starting from scratch (no main.aux) may need a third run before the page cross-references settle; keep running pdflatex until it stops printing "Rerun to get cross-references right".

(python build.py also regenerates main.tex as part of its run, so you only need to run pdflatex afterwards.)

License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

About

Reverse engineering of Lode Runner for the Apple II series

Resources

Stars

95 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages