Skip to content
| Marketplace
Sign in
Visual Studio Code>Education>BitMagic X16 DocumentationNew to Visual Studio Code? Get it now.
BitMagic X16 Documentation

BitMagic X16 Documentation

Yazwh0

|
1 install
| (0) | Free
The Commander X16 Programmer's Reference Guide inside VS Code: read it, search it, and look up KERNAL routines, BASIC keywords, VERA registers and 65C02 instructions from the editor.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

BitMagic X16 Documentation

The Commander X16 Programmer's Reference Guide inside VS Code. Read it in an editor tab, search it, and look up KERNAL routines, BASIC keywords, VERA registers, math library routines, memory addresses and 65C02 instructions straight from your code.

It works on its own, and the other BitMagic extensions use it for their hovers when it's installed.

The reader, showing the VERA registers

Reading

Click the BitMagic X16 butterfly in the activity bar. Its X16 Reference view has the contents: every chapter, with its sections. Click one to open it in the reader.

The reader shows one chapter at a time, in your theme's colours:

  • Back and forward (also Alt+Left and Alt+Right, or the mouse's side buttons), and links between chapters stay in the tab.
  • Chapter list to jump to any chapter, and Previous / Next at the bottom of each page.
  • Outline of the page down the side, following where you are. Hide it with the Outline button.
  • Search box (Ctrl+K or /) and Find in page (Ctrl+F).
  • It reopens where you left it when VS Code restarts.

Searching and looking things up

  • X16 Reference: Search the X16 Reference searches as you type. It looks for names (CHROUT, ADDRx_L, POKE), addresses ($FFD2, 0x9F20) and words (sprite attributes). Reference entries come first, then the pages.
  • Look Up in the X16 Reference (Ctrl+F1, or the editor's context menu) looks up the word under the cursor, or the selection, and opens it beside your code. It understands the forms code uses: VERA_ADDR0_L, VERA_DATA0, .CHROUT, $9F20, CHR$, PRINT#. If there's no exact match you get the search instead.
  • In Copilot Chat and agent mode, #x16docs (the x16docs_search tool) answers from the reference.

Where the docs come from

The X16 docs don't have a licence that lets this extension ship a copy, so it downloads them from X16Community/x16-docs on GitHub the first time they're needed (about 5 MB), into VS Code's storage for the extension. After that they work offline. Every page says which version it's from and links to it.

By default you get master, the newest docs, kept up to date as x16-docs changes. Choose a release instead if you're working to a particular ROM.

Setting
bitMagicX16Documentation.version Master (the default): the newest docs, which may describe ROM changes that aren't released yet. Latest release: the newest release, which matches the newest ROM. A particular release: the one in bitMagicX16Documentation.versionTag. Choose the X16 Reference Version lists the releases and sets these for you.
bitMagicX16Documentation.versionTag The release for A particular release, eg r48.
bitMagicX16Documentation.checkForUpdates Check for new commits on master (or a new release, for Latest release) at most once a day and download them. On by default.
bitMagicX16Documentation.localPath Read the docs from a folder instead, eg your own clone of x16-docs.
bitMagicX16Documentation.languages More languages that get Look Up on the context menu (eg c, ca65). Empty by default: the BitMagic extensions add their own languages.

Check for an Updated X16 Reference downloads the newest straight away. The X16 Reference output channel logs what was loaded and any problems.

For extension authors

The API

Other extensions can use the reference if it's installed, and carry on without it if it isn't. There's no need to depend on this extension.

const ext = vscode.extensions.getExtension<X16DocumentationApi>("yazwh0.bitmagic-x16documentation");
const docs = ext ? await ext.activate() : undefined;

const [entry] = await docs?.lookup({ name: "CHROUT", kind: "kernal" }) ?? [];
if (entry) {
    const md = new vscode.MarkdownString(docs!.hoverMarkdown(entry));
    md.isTrusted = { enabledCommands: ["x16docs.show"] }; // for its "Open in the X16 Reference" link
    return new vscode.Hover(md);
}

The API never downloads the docs by itself: until the user has opened the reference once, lookup and the rest return nothing (ready() says whether there are docs). That keeps a hover from starting a download.

The types, to copy into your extension:

type EntryKind = "kernal" | "math" | "basic" | "vera" | "io" | "memory" | "opcode" | "other";

interface DocTarget { book: string; chapter: string; anchor?: string }

interface DocEntry {
    kind: EntryKind;
    name: string;                  // as the docs write it: CHROUT's entry is BSOUT, with CHROUT an alias
    aliases?: string[];
    address?: number;
    addressEnd?: number;           // for a range
    summary: string;
    signature?: string;            // a call signature, BASIC format, or an instruction's addressing modes
    details?: [string, string][];  // Inputs, Affects, Origin, Type, When, Bits and so on
    target: DocTarget;
}

type ShowTarget = DocTarget | { name: string; kind?: EntryKind | EntryKind[] } | { address: number } | { query: string };

interface X16DocumentationApi {
    readonly version: 1;
    readonly onDidChange: vscode.Event<void>;
    ready(download?: boolean): Promise<boolean>;
    lookup(query: { name?: string; address?: number; kind?: EntryKind | EntryKind[] }): Promise<DocEntry[]>;
    addressName(address: number): Promise<DocEntry | undefined>;
    search(text: string, limit?: number): Promise<{ title: string; detail: string; description?: string; target: DocTarget; entry?: DocEntry }[]>;
    hoverMarkdown(entry: DocEntry, options?: { brief?: boolean }): string;
    showLink(target: ShowTarget): string;
    show(target: ShowTarget, options?: { preserveFocus?: boolean; beside?: boolean }): Promise<boolean>;
    // from 0.1.3: check it's there before calling it
    registerLookupProvider?(languageId: string,
        provider: (document: vscode.TextDocument, position: vscode.Position) => ShowTarget | undefined | Thenable<ShowTarget | undefined>): vscode.Disposable;
}

Pass kind to lookup when you know what the word is (a BASIC keyword, a jsr target, a register), so a label called LOAD doesn't turn up the BASIC command. addressName gives the best name for an address: the routine or register there, or the smallest memory range holding it.

Telling Look Up what's under the cursor

Look Up (Ctrl+F1) guesses the word from the text. Your extension knows your language better, so it can say what's there instead:

docs.registerLookupProvider?.("x16basic", (document, position) => {
    const keyword = keywordAt(document, position);           // your own parsing
    return keyword ? { name: keyword, kind: "basic" } : undefined;
});

Return any ShowTarget; { address } suits names that don't match the docs, like Prog8's cx16.VERA_ADDR_L. Return undefined where there's nothing, and the usual guess is used. Dispose of what it returns to take the provider away. It arrived in 0.1.3, so the ?. keeps you working with older versions.

Commands

Without the API, the x16docs.show command opens the reader. It takes one of the ShowTarget forms, eg { "name": "CHROUT" }, { "address": 65490 } or { "query": "sprites" }, so it works in a command: link too (showLink makes one). If this extension isn't installed, the command doesn't exist and executeCommand rejects.

Adding views to the BitMagic X16 button

The activity bar button is a view container, bitmagicX16, shared by the BitMagic X16 extensions rather than owned by this one. Each extension with views declares the container itself, with the same title and icon, and puts its views in it:

"contributes": {
    "viewsContainers": {
        "activitybar": [{ "id": "bitmagicX16", "title": "BitMagic X16", "icon": "media/icon.svg" }]
    },
    "views": {
        "bitmagicX16": [{ "id": "myext.things", "name": "Things" }]
    }
}

VS Code registers a container once and reuses it when another extension declares the same id, so with any of these extensions installed the button is there, and with several they share it. None of them has to depend on another.

Whichever extension loads first supplies the title and icon, so keep them identical: the title BitMagic X16, and a copy of this extension's media/icon.svg.

Look Up on the context menu for your language

To have Look Up in the X16 Reference on the editor's context menu in your language, declare its id in your package.json:

"contributes": {
    "bitMagicX16Documentation.languages": ["prog8"]
}

It's read from the package.json, so neither extension needs to be activated for it, and it does nothing if this extension isn't installed. Users can add other languages with the bitMagicX16Documentation.languages setting.

Adding your own docs

An extension can add a doc set of its own: its pages join the contents, the reader and the search. Declare it in your package.json:

"contributes": {
    "bitMagicX16Documentation.docs": [
        { "path": "docs/library", "title": "Prog8 Library", "entries": "docs/library/entries.json" }
    ]
}
  • path: a folder of Markdown files (subfolders too). index.md or README.md, or the file named by index, is the first page, and the order it links to the others is the order of the chapters.
  • title: the book's name in the contents.
  • entries (optional): a JSON array of reference entries for lookup and search: { "name", "kind", "aliases", "address", "summary", "signature", "file", "anchor" }, where file is the Markdown file it's in (relative to path) and anchor the heading's GitHub-style anchor. address can be a number or a string like "$FFD2".

Building

npm install
npm run compile      # type checks, compiles the tests, bundles dist/extension.js
npm test             # unit tests; the ones on the real docs need a clone in upstream-x16-docs (or X16DOCS)
npm run itest        # integration tests in VS Code (CODE_EXE to use an installed one); downloads the docs
npx @vscode/vsce package

For the docs tests: git clone https://github.com/X16Community/x16-docs upstream-x16-docs.

Licence

This extension is GPL-3.0-or-later. The Commander X16 Programmer's Reference Guide belongs to its authors, the X16 community; the extension downloads it from their repository and doesn't include it.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft